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
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
|
<?php include('_init.php');
//var_dump($_SESSION["category_page"]);
if (isset($_GET["reset"]) && (int)$_GET["reset"] == 1) { unset($_SESSION["category_page"]); }
if (isset($_GET["id"])){ $category_id = (int)$_GET["id"]; // = mas_instrument id $_SESSION["category_page"]["category_id"] = $category_id; $path = 'category.php'; @header("Location: {$path}"); echo "<script language='JavaScript'>window.location='{$path}'</script>"; exit(); }else{ $category_id = 0; }
if (isset($_GET["search"]) && !empty($_GET["search"])) { $sql = "select * from master_type_code where typeid = ? and (name_en LIKE ? or name_cn LIKE ?)"; $parameters = array("INSTRUMENT", "%" . _h($_GET["search"]) . "%", "%" . _h($_GET["search"]) . "%"); $result = bind_pdo($sql, $parameters, "selectone");
if (!empty($result)) { $category_id = $result["id"]; $_SESSION["category_page"]["category_id"] = $result["id"]; }
}
$where_clause = ""; $parameters = array(0, 4, 0, 1);
if (!empty($_GET["recommend"]) && (int)$_GET["recommend"] == 1) { $where_clause = " and tutor_main.recommend = ?"; $parameters[] = 1; }
$sql = "select * from tutor_main INNER JOIN tutor_charge ON tutor_main.id = tutor_charge.tutormain_id INNER JOIN tutor_expectcharge ON tutor_charge.id = tutor_expectcharge.charge_id where tutor_charge.deleted = ? and tutor_main.status = ? and tutor_main.deleted = ? and tutor_main.approved = ? {$where_clause} group by tutor_main.id";
$all_tutors = bind_pdo($sql, $parameters, "selectall");
$level_of_grades = get_master_type_code("LEVEL_OF_GRADE"); $locations = get_master_type_code("TEACH_POSITIONCODE"); $instrument_categories = get_master_type_code("INSTRUMENT_TYPE"); //$all_instruments = get_master_type_code("INSTRUMENT"); $instrument = get_master_type_code_by_id($category_id);
$teach_venues = get_master_type_code("TEACH_VENUS"); $last_login_date_range = get_master_type_code("LAST_LOGIN_DATE_RANGE");
/*if (isset($_SESSION["category_page"]["min_hourly_rate"]) && isset($_SESSION["category_page"]["max_hourly_rate"])) { $min_fee = $_SESSION["category_page"]["min_hourly_rate"]; $max_fee = $_SESSION["category_page"]["max_hourly_rate"]; } else {*/ $min_fee = 9999999; $max_fee = 0; foreach ($all_tutors as $tutor) { $tutor_expectcharge = get_tutor_expectcharge($tutor["tutormain_id"], $category_id, "fee"); if ($tutor_expectcharge[0]["min_fee"] < $min_fee && $tutor_expectcharge[0]["min_fee"] > 0) { $min_fee = $tutor_expectcharge[0]["min_fee"]; }
if ($tutor_expectcharge[0]["min_fee"] > $max_fee && $tutor_expectcharge[0]["min_fee"] > 0) { $max_fee = $tutor_expectcharge[0]["min_fee"]; } }
if ($min_fee == 9999999) { $min_fee = 0; }
$min_fee = 0; //} ?>
<!DOCTYPE html> <html lang="en"> <head> <?php include('_head.php'); ?> <link href="css/style_k.css" type="text/css" rel="stylesheet"> </head>
<body> <?php include('_header.php') ?>
<?php include('_dialog.php') ?>
<div class="Categoryheader"> <div class="container"> <!--<div class="intro-text"> <p class="BannerBigFont"><? /*= $instrument["name_en"] */ ?> Tutors in Hong Kong</p>
<p class="weFound">The best place to find your perfect tutor</p> </div>--> </div> </div>
<div class="GreyBackground"> <div class="container"> <div class="row"> <div class="col-sm-3" id="Sorting"> <div class="QuickSearch"> <h12><?= _lang("Quick Search") ?></h12> <br>
<div class="input-group"> <input type="text" class="form-control" placeholder="導師名稱、導師編號" name="quick_search" id="quick_search" value="<?= $_SESSION["category_page"]["quick_search"] ?>"> <span class="input-group-addon pointer" id="quick_search_submit"> <span class="glyphicon glyphicon-search" aria-hidden="true"> </span> </span> </div>
<hr> </div>
<div class="SortInstrument"> <h12><?= _lang("Musical Instrument") ?></h12> <br> <select class="SelectBox" name="category_id" id="category_id"> <option value="ANY"><?= _lang("Any") ?></option> <?php foreach ($instrument_categories as $row) { echo '<optgroup label="' . $row["name_" . $langcode] . '">';
$sql = "select * from master_type_code where typeid = ? and extra1 = ? and deleted = ? order by sort asc"; $parameters = array('INSTRUMENT', $row['code'], 0); $rows_instrument = bind_pdo($sql, $parameters, "selectall");
foreach ($rows_instrument as $row2) { echo '<option value="' . $row2["id"] . '" ' . ($_SESSION["category_page"]["category_id"] == $row2["id"] ? "selected" : "") . '>' . $row2["name_" . $langcode] . '</option>'; } echo '</optgroup>'; } ?> </select> <hr> </div>
<div class="SortLevel"> <h12><?= _lang("Musical Instrument Level") ?></h12> <br> <select class="SelectBox" name="level_of_grade" id="level_of_grade"> <option value="ANY"><?= _lang("Any") ?></option> <?php foreach ($level_of_grades as $row) { echo '<option value="' . $row["code"] . '" ' . ($_SESSION["category_page"]["level_of_grade"] == $row["code"] ? "selected" : "") . '>' . $row["name_" . $langcode] . '</option>'; } ?> </select> <hr> </div>
<div class="SortLocation"> <h12><?= _lang("Teaching District") ?></h12> <br> <select class="SelectBox" name="location[]" id="location" multiple> <option value="ANY"><?= _lang("Any") ?></option> <?php foreach ($locations as $row) { $selected = ""; foreach ($_SESSION["category_page"]["location"] as $location_id) { if ($location_id == $row["id"]) { $selected = "selected"; break; } } echo '<option value="' . $row["id"] . '" ' . $selected . '>' . $row["name_" . $langcode] . '</option>'; } ?> </select> <hr> </div>
<div class="SortTeachVenue"> <h12><?= _lang("Teaching Venue") ?></h12> <br> <select class="SelectBox" name="teach_venue[]" id="teach_venue" multiple> <option value="ANY"><?= _lang("Any") ?></option> <?php foreach ($teach_venues as $row) { $selected = ""; foreach ($_SESSION["category_page"]["teach_venue"] as $teach_venue_id) { if ($teach_venue_id == $row["id"]) { $selected = "selected"; break; } } echo '<option value="' . $row["id"] . '" ' . $selected . '>' . $row["name_" . $langcode] . '</option>'; } ?> </select> <hr> </div>
<div class="SortRate"> <h12><?= _lang("Tutorial Fee") ?><br> <? $max_fee = 1000; //edit benny 2016-09-02?> <div class="rangeBar"> <strong>$<?= (float)$min_fee ?></strong> <input id="ex2" type="text" class="span2" value="" data-slider-min="<?= (float)$min_fee ?>" data-slider-max="<?= (float)$max_fee ?>" data-slider-step="5" data-slider-value="[<?= $_SESSION["category_page"]["min_hourly_rate"]?$_SESSION["category_page"]["min_hourly_rate"]:(float)$min_fee ?>,<?= $_SESSION["category_page"]["max_hourly_rate"]?$_SESSION["category_page"]["max_hourly_rate"]:(float)$max_fee ?>]"/> <b>$<?= (float)$max_fee ?></b> </div> <hr> </div>
<div class="SortGender"> <h12><?= _lang("Tutor Gender") ?></h12> <br>
<div class="searchable-container"> <?php $checked = ""; $active = ""; foreach ($_SESSION["category_page"]["gender"] as $gender) { if ($gender == "m") { $checked = "checked"; $active = "active"; } } ?>
<div data-toggle="buttons" class="btn-group bizmoduleselect gender gender_m"> <label class="btn btn-default <?= $active ?>">
<input type="checkbox" name="gender[]" autocomplete="off" value="m" <?= $checked ?> style="float:left;"> <span class="glyphicon glyphicon-ok glyphicon-lg" id="TickIcon"></span> <h5><?= _lang("Male") ?></h5> </label> </div>
<?php $checked = ""; $active = ""; foreach ($_SESSION["category_page"]["gender"] as $gender) { if ($gender == "f") { $checked = "checked"; $active = "active"; } } ?> <div data-toggle="buttons" class="btn-group bizmoduleselect gender gender_f"> <label class="btn btn-default <?= $active ?>"> <input type="checkbox" name="gender[]" autocomplete="off" value="f" <?= $checked ?> style="float:left;"> <span class="glyphicon glyphicon-ok glyphicon-lg" id="TickIcon"></span> <h5><?= _lang("Female") ?></h5> </label> </div> </div> <hr> </div>
<!--<div class="SortAccumulateTutorialHours"> <h12><? /*= _lang("Accumulate Tutorial Hours") . " (" . _lang("hours") . ")" */ ?></h12> <br> <input type="text" name="accumulate_tutorial_hours" id="accumulate_tutorial_hours" value="<? /*= $_SESSION["category_page"]["accumulate_tutorial_hours"] */ ?>" style="width: 100%;"/>
<hr> </div>-->
<div class="SortLocation"> <h12><?= _lang("Last Login") ?></h12> <br> <select class="SelectBox" name="last_login" id="last_login"> <option value="ANY"><?= _lang("Any") ?></option> <?php foreach ($last_login_date_range as $row) {
echo '<option value="' . $row["extra1"] . '" ' . ($_SESSION["category_page"]["last_login"] == $row["extra1"] ? "selected" : "") . '>' . $row["name_" . $langcode] . '</option>'; } ?> </select> <hr> </div>
<div class="SortScore"> <h12><?= _lang("Score") ?></h12> <br> <select class="SelectBox" name="score" id="score"> <option value="ANY"><?= _lang("Any") ?></option> <?php /*foreach ($last_login_date_range as $row) { echo '<option value="' . $row["id"] . '">' . $row["name_" . $langcode] . '</option>'; }*/ ?> </select> <hr> </div>
<div class="SortBy"> <h12><?= _lang("Sort By") ?></h12> <br>
<div class="searchable-container"> <?php $sort_by_array = array("MOST_POPULAR" => _lang("Most Popular"), "LOW_HIGH" => _lang("Fee (low to high)"), "HIGH_LOW" => _lang("Fee (high to low)"), "ACCUMULATE_HOUR_LOW_HIGH" => _lang("Accumulate Tutorial Hours <br>(low to high)"), "ACCUMULATE_HOUR_HIGH_LOW" => _lang("Accumulate Tutorial Hours <br>(high to low)"));
foreach ($sort_by_array as $key => $sort) { $checked = ""; $active = ""; if ($_SESSION["category_page"]["sort_by"] == $key || (!isset($_SESSION["category_page"]["sort_by"]) && $key == "MOST_POPULAR")) { $checked = "checked"; $active = "active"; } ?> <div data-toggle="buttons" class="btn-group bizmoduleselect sort_by <?= $key ?>"> <label class="btn btn-default <?= $active ?>"> <input type="checkbox" name="sort_by" autocomplete="off" value="<?= $key ?>" style="float:left;" <?= $checked ?>> <span class="glyphicon glyphicon-ok glyphicon-lg" id="TickIcon"></span> <h5><?= htmlspecialchars_decode($sort) ?></h5> </label> </div> <?php } ?> </div> <hr> </div>
<div class="ResetFilter"> <button type="button" onclick="location.href='category.php?id=<?= $category_id ?>&reset=1<?= (!empty($_GET["recommend"]) && (int)$_GET["recommend"] == 1 ? "&recommend=1" : "") ?>';"><?= _lang("Reset Filter") ?></button> </div> </div>
<div class="col-sm-9"> <div class="row" id="tutor_list">
</div> </div> </div> </div> </div>
<div id="loading"><img src="img/loading_icon.gif" style="width: 100px;"></div>
<? include('_footer.php') ?> <link href="css/agency.css" rel="stylesheet"> <link href="css/bootstrap-slider.css" rel="stylesheet"> <script src="js/bootstrap-slider.js"></script> <script src="js/jquery.dotdotdot.min.js"></script> <script src="js/chosen_v1.6.2/chosen.jquery.min.js"></script> <link href="js/chosen_v1.6.2/chosen.min.css" rel="stylesheet"> <script>
function resizeImage() { console.log($(window).width()); if ($(window).width() <= 974) { $(".tutor_img").hide(); $(".tutor_img2").show(); } else { $(".tutor_img").show(); $(".tutor_img2").hide(); }
//$(".tutor_img2").show(); }
function filter_tutor(start) { $('#loading').slideDown(100); console.log("filter tutor");
var quick_search = $("#quick_search").val(); var category_id = $("#category_id").val(); //instrument var level_of_grade = $("#level_of_grade").val(); var location = JSON.stringify($("#location").val()); var teach_venue = JSON.stringify($("#teach_venue").val()); var min_hourly_rate = $(".min-slider-handle").attr("aria-valuenow"); var max_hourly_rate = $(".max-slider-handle").attr("aria-valuenow");
var gender_m; var gender_f; $('input[name="gender[]"]:checked').each(function () { if ($(this).val() == 'm') { gender_m = $(this).val(); }else if($(this).val() == 'f'){ gender_f = $(this).val(); } }); var accumulate_tutorial_hours = $("#accumulate_tutorial_hours").val(); var last_login = $("#last_login").val(); var score = $("#score").val();
//var gender = $("input[name='gender[]']:checked").val(); var sort_by = $("input[name='sort_by']:checked").val();
jQuery.ajax({ url: '_ajax.php', type: 'POST', data: { ajax: "filter_tutor", quick_search: quick_search, category_id: category_id, level_of_grade: level_of_grade, location: location, teach_venue: teach_venue, min_hourly_rate: min_hourly_rate, max_hourly_rate: max_hourly_rate, gender_m: gender_m, gender_f: gender_f, accumulate_tutorial_hours: accumulate_tutorial_hours, last_login: last_login, score: score, sort_by: sort_by, recommend: <?=(int)$_GET["recommend"]?>, start: start }, dataType: 'html', //dataType (default: Intelligent Guess (xml, json, script, or html)) timeout: 10000, error: function (result) { //alert('Error Occur. Please try again.'); //console.log(result.responseText);
$("html, body").animate({ scrollTop: 0 }, "slow"); }, success: function (result) { $("html, body").animate({ scrollTop: 0 }, "slow"); $('#loading').slideUp(100); //console.log(result); $("#tutor_list").empty().html(result);
$(".start").on("click", function () { var start = $(this).attr("data-value"); filter_tutor(start); });
$(".self_describemyself").dotdotdot();
resizeImage(); } });
}
$(function () { $("#ex2").slider({});
//set category id <?php if (!empty($_GET["id"]) && (int)$_GET["id"] > 0) { echo '$("#category_id ").val(' . (int)$_GET["id"] . ');'; } ?>
//filter quick search $("#quick_search_submit").on("click", function () { filter_tutor();
});
$("#category_id, #level_of_grade, #location, #teach_venue, #last_login").on("change", function () { filter_tutor(); });
//filter fee $("#ex2").slider().on("slideStop", function (slide) { filter_tutor(); });
//filter gender $(".gender").on("click", function () { if ($(this).find("input:checkbox").prop("checked")) { $(this).find("input:checkbox").prop("checked", false); } else { $(this).find("input:checkbox").prop("checked", true); }
filter_tutor(); });
<?php /*$checked = ""; foreach($_SESSION["category_page"]["gender"] as $gender){ if($gender == "m"){ echo '$(".gender_m").trigger("click");'; }else if($gender == "f"){ echo '$(".gender_f").trigger("click");'; } }*/ ?>
//filter sort by $(".sort_by").on("click", function () { $(".sort_by").each(function () { $(this).find("input:checkbox").prop("checked", false); });
if ($(this).find("input:checkbox").prop("checked")) { $(this).find("input:checkbox").prop("checked", false); } else { $(this).find("input:checkbox").prop("checked", true); }
$(".sort_by label").removeClass("active"); filter_tutor(); });
<?php if (isset($_SESSION["category_page"]["sort_by"])) { //echo '$(".'.$_SESSION["category_page"]["sort_by"].'").trigger("click");'; }?> //filter page //$(".start").on("click", function () { $(".start").on("click", function () { var start = $(this).attr("data-value"); filter_tutor(start); });
//center image resizeImage();
$(window).resize(function () { resizeImage(); });
//text overflow $(".self_describemyself").dotdotdot();
//change select $("#category_id").chosen({ width: "100%", search_contains: true, no_results_text: "<?=_lang("No results match")?>" });
$("#level_of_grade").chosen({ disable_search: true, width: "100%" });
$("#location").chosen({ width: "100%", search_contains: true, disable_search: false, placeholder_text_multiple: "<?=_lang("Select Some Options")?>" });
$("#teach_venue").chosen({ width: "100%", search_contains: true, placeholder_text_multiple: "<?=_lang("Select Some Options")?>" });
$("#last_login").chosen({ disable_search: true, width: "100%" });
$("#score").chosen({ disable_search: true, width: "100%" });
filter_tutor(); //auto run the first time filter tutor });
</script>
</body> </html>
|