-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplaysales.php
More file actions
256 lines (236 loc) · 7.14 KB
/
Copy pathdisplaysales.php
File metadata and controls
256 lines (236 loc) · 7.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<?php
include("header.php");
?>
<main id="main">
<!-- ======= Cta Section ======= -->
<section id="cta" class="cta">
<div class="container">
<div class="text-center" data-aos="zoom-in">
<br>
<br>
<br>
<h3>Farmer's Market</h3>
</div>
</div>
</section><!-- End Cta Section -->
<!-- ======= Portfolio Section ======= -->
<section id="portfolio" class="portfolio">
<div class="container">
<div class="row" data-aos="fade-up" data-aos-delay="100">
<div class="col-lg-12 d-flex justify-content-center">
<ul id="portfolio-flters">
<?php
if(isset($_GET['category_id']))
{
?>
<li data-filter="*" class="filter-active"><?php echo $_GET['category']; ?></li>
<?php
}
else
{
?>
<li data-filter="*" class="filter-active">All items</li>
<?php
}
?>
</ul>
</div>
</div>
<!-- ======= Contact Section ======= -->
<section id="contact" class="contact" style="padding: 1px 0;">
<div class="container">
<div class="row">
<div class="col-lg-12" data-aos="fade-up" data-aos-delay="100">
<form method="get" action="" name="frmsalessearch" onSubmit="return validatesalessearch()">
<?php
if(isset($_GET['category_id']))
{
?>
<input type="hidden" name="category_id" id="category_id" value="<?php echo $_GET['category_id']; ?>" >
<input type="hidden" name="category" id="category" value="<?php echo $_GET['category']; ?>" >
<?php
}
?>
<div class="row">
<div class="col-lg-5">
<div class="info w-100">
<h6>Select state:</h6>
<span id='loadstate'><select name="state" autofocus class="search_categories form-control" onChange="loadcity(this.value)" ><option value="">Select State</option>
<?php
$sql2 = "SELECT * FROM state where status='Active' ";
$qsql2 =mysqli_query($con,$sql2);
while($rssql2 = mysqli_fetch_array($qsql2))
{
if($_GET['state'] == $rssql2['state_id'])
{
echo "<option value='" . $rssql2['state_id'] . "' selected>" . $rssql2['state'] ."</option>";
}
else
{
echo "<option value='" . $rssql2['state_id'] . "' >" . $rssql2['state'] ."</option>";
}
}
?>
</select></span>
</div>
</div>
<div class="col-lg-4">
<div class="info w-100">
<h6>Select city:</h6>
<span id='loadcity'><select name="city" autofocus class="search_categories form-control"><option value="">Select City</option><?php
$sql3 = "SELECT * FROM city where status='Active' AND state_id='$_GET[state]'";
$qsql3 =mysqli_query($con,$sql3);
while($rssql3 = mysqli_fetch_array($qsql3))
{
if($rssql3['city_id'] == $_GET['city'] )
{
echo "<option value='$rssql3[city_id]' selected>$rssql3[city]</option>";
}
else
{
echo "<option value='$rssql3[city_id]'>$rssql3[city]</option>";
}
}
?></select></span>
</div>
</div>
<div class="col-lg-3">
<div class="info w-100">
<input type="submit" name="submit" id="submit" value="Search" class="btn btn-info">
<a href="displaysales.php">Clear Search</a>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</section><!-- End Contact Section -->
<hr>
<div class="row portfolio-container" data-aos="fade-up" data-aos-delay="200">
<?php
if(isset($_GET['submit']))
{
$sql = "SELECT * FROM product INNER JOIN seller ON product.seller_id = seller.seller_id WHERE product.status='Active' and product.quantity>1 AND seller.state_id='$_GET[state]' and seller.city_id='" . $_GET['city'] . "'";
if(isset($_GET['category_id']))
{
$sql = $sql . " AND product.category_id='$_GET[category_id]'";
}
$qsql = mysqli_query($con,$sql);
if(mysqli_num_rows($qsql) == 0)
{
echo " <div class='col-lg-12 col-md-12 portfolio-item filter-app'><br><center><h2>No Items to display based on location given...</h2></center></br></div>";
}
}
else
{
$sql = "SELECT * FROM product WHERE status='Active' ";
if(isset($_GET['category_id']))
{
$sql = $sql . " AND product.category_id='" . $_GET['category_id'] ."'";
}
$sql = $sql . " and quantity>1";
$qsql = mysqli_query($con,$sql);
}
while($rs = mysqli_fetch_array($qsql))
{
?>
<div class="col-lg-4 col-md-6 portfolio-item filter-app">
<div class="portfolio-wrap">
<img src="imgproduct/<?php echo $rs['img_1']; ?>" class="img-fluid" alt="" style="width: 100%;height: 300px;">
<div class="portfolio-info">
<h4><?php echo $rs['title']; ?></h4>
<p><strong>Quantity :</strong> <?php echo $rs['quantity']; ?> <?php echo $rs['quantity_type']; ?></p>
<div class="portfolio-links">
<a href="displaysalesdetailed.php?productid=<?php echo $rs[0]; ?>" title="More Details" class="btn btn-info"><i class="bx bx-link"></i> View More</a>
</div>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
</section><!-- End Portfolio Section -->
</main><!-- End #main -->
<?php
include("footer.php");
?>
<script type="application/javascript">
function loadstate(id) {
if (id == "") {
document.getElementById("loadstate").innerHTML = "<select name='state'><option value=''>Select</option></select>";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("loadstate").innerHTML = xmlhttp.responseText;
}
};
xmlhttp.open("GET","ajaxstate.php?id="+id,true);
xmlhttp.send();
}
}
function loadcity(id)
{
if (id == "")
{
document.getElementById("loadcity").innerHTML = "";
return;
} else
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else
{
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.getElementById("loadcity").innerHTML = xmlhttp.responseText;
}
};
xmlhttp.open("GET","ajaxcity.php?id="+id,true);
xmlhttp.send();
}
}
function validatesalessearch()
{
if(document.frmsalessearch.country.value == "")
{
alert("Kindly select the country to search..");
document.frmsalessearch.country.focus();
return false;
}
else if(document.frmsalessearch.state.value == "")
{
alert("Kindly select the state to search..");
document.frmsalessearch.state.focus();
return false;
}
else if(document.frmsalessearch.city.value == "")
{
alert("Kindly select the city to search..");
document.frmsalessearch.city.focus();
return false;
}
else
{
return true;
}
}
</script>