-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmarket.php
More file actions
359 lines (338 loc) · 12 KB
/
Copy pathmarket.php
File metadata and controls
359 lines (338 loc) · 12 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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
<?
if (!isset($_SESSION)) {
session_start();
}
include 'FoodFunction.php';
$editable=false;
if ( ( isset($_SESSION['UIDS']) && isset($_SESSION['USERNAME']) )
&& authenIdUser() ) {
$editable = true;
}
?>
<!DOCTYPE html>
<!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!-->
<html lang="en">
<!--<![endif]-->
<head>
<!-- Basic Page Needs -->
<meta charset="utf-8">
<title>Market</title>
<meta name="description" content>
<meta name="author" content>
<!-- CSS Style -->
<link rel="stylesheet" href="css/style.css" type="text/css" media="all">
<!-- Short Codes Style -->
<link rel="stylesheet" href="css/shortcode.css" type="text/css" media="all">
<!-- Start Java CSS -->
<link rel="stylesheet" href="css/javascri.css" type="text/css" media="all">
<!-- Color Schemes CSS -->
<link rel="stylesheet" href="css/colors-scheme.css" type="text/css" media="all">
<!--[if lt IE 9]>
<script src="js/html5.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="core/css/mystyle.css">
<link rel="stylesheet" href="core/css/box.css" type="text/css" media="all">
<script src="http://maps.google.com/maps/api/js?sensor=false"
type="text/javascript"></script>
<script src="core/js/jquery-1.9.1.js"></script>
<script src="core/js/jquery-2.0.0.min.js"></script>
<? if ($editable) { ?>
<script type="text/javascript">
function editMarket(sid) {
$.fancybox.open({
href : 'admin/shop/edit.php?confirm=1&ids='+sid,
type : 'iframe',
width : 550,
height : 600,
fitToView : false,
autoSize : true,
padding: 5,
openEffect : 'elastic',
openSpeed : 150,
closeEffect : 'elastic',
closeSpeed : 150,
afterClose : function() {
window.location.reload();
}
});
}
function delMarket(sid) {
if (confirm('Do you want to delete <?=$rowShop['SHOPNAME']; ?> ? ')){
$.fancybox.open({
href : 'admin/shop/delete.php?confirm=1&ids='+sid,
type : 'iframe',
width : 550,
height : 600,
fitToView : false,
autoSize : true,
padding: 5,
openEffect : 'elastic',
openSpeed : 150,
closeEffect : 'elastic',
closeSpeed : 150,
afterClose : function() {
window.location="market.php";
// window.location.reload();
}
});
}
}
</script>
<? }?>
</head>
<body id="def">
<div class="wrapper">
<!-- header -->
<header id="header">
<div class="main-holder">
<h1 id="logo"><a href="index.php"></a></h1>
<nav class="nav">
<? include('_navbar.php'); ?>
</nav>
</div>
</header>
<div class="sloganwrapper">
<div class="main-holder ">
<ul class="breadcrumb">
<li><a href="index.php">HOME</a></li>
<li>MARKET</li>
</ul>
</div>
</div>
<!-- Content -->
<section class="main-content"> <span class="top-bg"></span>
<div class="holder-container">
<section class="grid-holder">
<section class="grid w-padd">
<figure class="column forth-col">
<? include('_side.php'); ?>
</figure>
<figure class="column c-one-half">
<h2>Market</h2><br>
<table width="674" border="0" id="addIngre">
<tr>
<td> </td>
<td align="right"> Search By Ingrdient </td>
<td width="200"><select class="labelF combobox" id="iid" name="ingredient[]">
<option value=""></option>
<?=optionIngredient("");?>
</select>
<input name="inname" type="hidden" id="inname"></td>
<td width="100" ><a class="button_sub" href="javascript:searchIngre()">SEARCH</a>
</td>
</tr>
</table><br>
<article class="staff-list">
<div id="map" style="width: 669px; height: 400px;"></div>
<?
include 'connectDB.php';
$strSQL = "SELECT * FROM ISHOP order by sid";
//echo $strSQL;
$objParse = oci_parse($objConnect, $strSQL);
$objExecute = oci_execute($objParse, OCI_DEFAULT);
$rows = array();
$tmp = array();
$shop=array();
$shopDic=array();
$j=1;
while ($row = oci_fetch_array($objParse, OCI_BOTH)) {
$tmp = array();
$tmp2 = array();
$dis="";
if (is_numeric($_SESSION['lat']) && is_numeric($_SESSION['lng'])){
$dis = distance($_SESSION['lat'], $_SESSION['lng'],(double)$row['LATITUDE'],(double)$row['LONGITUDE'], "K")." km.";
}
$tmp2['SHOPNAME']=$row['SHOPNAME'];
$tmp2['LATITUDE']=(double)$row['LATITUDE'];
$tmp2['ORDER']=$j;
$tmp2['LONGITUDE']=(double)$row['LONGITUDE'];
$tmp2['DIS']=$dis;
$tmp2['SID']=$row['SID'];
array_push($shopDic,$tmp2);
array_push($tmp,$row['SHOPNAME'],(double)$row['LATITUDE'],(double)$row['LONGITUDE'],$j,$row['LATITUDE'],$dis,$row['SID']);
array_push($shop,$tmp);
$j++;
}
function cmp($a, $b) {
if ($a['DIS'] == $b['DIS']) {
return 0;
}
return (floatval($a['DIS']) < floatval($b['DIS'])) ? -1 : 1;
}
uasort($shopDic, 'cmp');
//print_r($shopDic);
//echo json_encode($shop);
?>
<script type="text/javascript">
var i;
var shop=<?php echo json_encode($shop); ?>;
//alert();
/* var locations = [
["Bondi Beach", -33.890542, 151.274856, 1],
["Coogee Beach", -33.923036, 151.259052, 2],
["Cronulla Beach", -34.028249, 151.157507, 3],
["Manly Beach", -33.80010128657071, 151.28747820854187, 4],
["Maroubra Beach", -33.950198, 151.259302, 5]
];*/
getLocation();
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 14,
center: new google.maps.LatLng(18.795633199999997,98.9529055),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker;
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
alert("Geolocation is not supported by this browser.");
}
}
function showPosition(position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
map.setCenter(new google.maps.LatLng(lat, lng));
var marker = new google.maps.Marker({
position: new google.maps.LatLng(lat,lng),
map: map,
icon: 'core/images/blue-dot.png',
title: 'Hello World!'
});
$.get( "module/setLoc.php?lat="+lat+"&lng="+lng, function( data ) {
/*$( ".result" ).html( data );
alert( "Load was performed." );*/
});
//locations[1000] = ["Your Location", lat, lng, 1000];
}
for (i = 0; i < shop.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(shop[i][1], shop[i][2]),
map: map
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
var text = '<a href="market_detail.php?sid='+shop[i][6]+'">'+shop[i][0]+'</a> '+shop[i][5];
infowindow.setContent(text);
infowindow.open(map, marker);
}
})(marker, i));
}
</script>
</article>
<div id="sort">
<?
foreach ($shopDic as $row){
/* $strSQL = "SELECT * FROM ISHOP order by SHOPNAME";
$objParse = oci_parse($objConnect, $strSQL);
$objExecute = oci_execute($objParse, OCI_DEFAULT);
while ($row = oci_fetch_array($objParse, OCI_BOTH)) {
//array_push($tmp,$row['SHOPNAME'],(double)$row['LATITUDE'],(double)$row['LONGITUDE'],$j);
//array_push($shop,$tmp);*/
?>
<article class="box14 boxB" style="display:none;">
<h3><a href="market_detail.php?sid=<? echo $row['SID'] ?>"><? echo $row['SHOPNAME']." " ?></a><span style="font-size:14px" id="theDistance"><script src="core/js/calcDistance.js"></script>
<script type="text/javascript">
var distance = distanceFrom({
// NYC
'lat1': <?=$_SESSION['lat']?>,
'lng1': <?=$_SESSION['lng']?>,
// Philly
'lat2': <?=(double)$row['LATITUDE']?>,
'lng2': <?=(double)$row['LONGITUDE']?>
});
document.write(""+distance+" kilometers");
</script><?=$rowShop['SHOPNAME']?>
<? if ($editable) { ?>
<a href="javascript:editMarket(<? echo $row['SID'] ?>);"><img src="core/images/_myedit.png" alt="Edit" name="im_edit" width="26" height="26" id="im_edit">edit</a>
<a href="javascript:delMarket(<? echo $row['SID'] ?>);"><img src="core/images/_mydelete.png" alt="Delete" name="im_del" width="26" height="26" id="im_del">delete</a>
<? } ?></span></h3>
<ul >
<?
$strSQL2 = "SELECT * FROM IHAVE NATURAL JOIN IINGREDIENT WHERE SID = ".$row['SID']."AND rownum <= 5";
$objParse2 = oci_parse($objConnect, $strSQL2);
$objExecute2 = oci_execute($objParse2, OCI_DEFAULT);
while ($rowHave = oci_fetch_array($objParse2, OCI_BOTH)) {
//array_push($tmp,$row['SHOPNAME'],(double)$row['LATITUDE'],(double)$row['LONGITUDE'],$j);
//array_push($shop,$tmp);
?>
<li>
<?=$rowHave['INNAME']?>
</li>
<? } ?>
</ul>
<?
$total = numberOfHave($row['SID']);
if ($total > 5){
echo '<a href="market_detail.php?sid='.$row['SID'].'">and '.($total-5).' more</a>';
}
?>
</article>
<? } ?>
<div id="load" class="button_addmore my_loadmore">Load More</div>
</div>
</figure>
</section>
</section>
</div>
<? include '_footer.php' ?>
</div>
<!-- Start JavaScript -->
<script src="core/js/jquery-1.9.1.js"></script>
<script src="core/js/jquery-2.0.0.min.js"></script>
<script type="text/javascript" src="js/jquery-u.js"></script><!-- jQuery Ui -->
<script type="text/javascript" src="js/ddsmooth.js"></script><!-- Nav Menu ddsmoothmenu -->
<script type="text/javascript" src="js/jquery03.js"></script><!-- Sliding Text and Icon Menu Style -->
<script type="text/javascript" src="js/jquery04.js"></script><!-- jQuery Prettyphoto -->
<script type="text/javascript" src="js/jquery06.js"></script><!-- UItoTop plugin -->
<script type="text/javascript" src="js/focus.js"></script><!-- text field clear & celander Seting-->
<script type="text/javascript" src="core/js/jquery-1.6.4.min.js"></script>
<link rel="stylesheet" type="text/css" href="core/css/jquery-ui.css">
<link href="core/css/mystyle.css" rel="stylesheet" type="text/css">
<script src="core/js/jquery-ui-1.10.3.js"></script>
<script type="text/javascript" src="core/js/jquery.numeric.js"></script>
<script src="core/js/combobox.js"></script>
<script type="text/javascript" src="core/fancyapps/lib/jquery.mousewheel-3.0.6.pack.js"></script>
<script type="text/javascript" src="core/fancyapps/source/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$( "#iid" ).combobox();
$("article.boxB").slice(0, 10).show(); // select the first ten
$("#load").click(function(e){ // click event for load more
e.preventDefault();
$("article.boxB:hidden").slice(0, 10).show('slow'); // select next 10 hidden divs and show them
if($("article.boxB:hidden").length == 0){ // check if any hidden divs still exist
$('#load').hide('slow');
//alert("No more divs"); // alert if there are none left
}
});
})
function searchIngre() {
var iid=$('#iid').val();
var iname=$('#inname').val();
if (iid==""){
iid=-1;
}
$.fancybox.open({
href : 'module/market_by_ingre.php?iid='+iid+'&iname='+iname,
type : 'iframe',
width : 550,
height : 600,
fitToView : false,
autoSize : true,
padding: 5,
openEffect : 'elastic',
openSpeed : 150,
closeEffect : 'elastic',
closeSpeed : 150,
afterClose : function() {
window.location.reload();
}
});
}
</script>
</body>
</html>