/var/www/hkosl.com/imusiccircle/category_20160815.php


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
<?php
    
include('_init.php');

    
$limit 10;

    if (isset(
$_GET["id"]))
        
$category_id = (int)$_GET["id"]; // = mas_instrument id
    
else
        
$category_id 0;

    if (!empty(
$_GET['start'])) {
        
$start = (int)$_GET['start'];
    } else {
        
$start 0;
    }

    
$page         basename($_SERVER['SCRIPT_FILENAME']);
    
$where_clause "";

    
//defaul sort by most popular


    
$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 = ? 
{$where_clause}                       group by tutor_main.id";
    
$parameters = array(040);
    
$all_tutors bind_pdo($sql$parameters"selectall");

    if (!empty(
$category_id)) {
        
$where_clause .= " and tutor_charge.mas_instrument = ?";
        
$parameters[] = $category_id;
    }

    
$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 = ? 
{$where_clause}                       group by tutor_main.id
                    limit " 
$start ", " $limit;

    
$tutors bind_pdo($sql$parameters"selectall");

    
//var_dump($tutors);

    
$count count($all_tutors);
    
//demo
    //$count = 100;
    
$numpage $count $limit;

    if (
$count && !empty($_GET['start'])) {
        
$start $_GET['start'];
    } else {
        
$start 0;
    }

    
$level_of_grades get_master_type_code("LEVEL_OF_GRADE");
    
$locations       get_master_type_code("TEACH_POSITIONCODE");

    
$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;
    }

    
$instrument get_master_type_code_by_id($category_id);

    
$all_instruments       get_master_type_code("INSTRUMENT");
    
$teach_venues          get_master_type_code("TEACH_VENUS");
    
$last_login_date_range get_master_type_code("LAST_LOGIN_DATE_RANGE");
?>

<!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">
                        <span class="input-group-addon pointer" id="quick_search_submit">
                            <span class="glyphicon glyphicon-search" aria-hidden="true"> </span>
                    </div

                    <hr>
                </div>

                <div class="SortInstrument">
                    <h12><?= _lang("Instrument"?></h12>
                    <br> <select class="SelectBox" name="category_id" id="category_id">
                        <option value="ANY"><?= _lang("Any"?></option>
                        <?php
                            
foreach ($all_instruments as $row) {
                                echo 
'<option value="' $row["id"] . '">' $row["name_" $langcode] . '</option>';
                            }
                        
?>
                    </select>
                    <hr>
                </div>

                <div class="SortLevel">
                    <h12><?= _lang("Student 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"] . '">' $row["name_" $langcode] . '</option>';
                            }
                        
?>
                    </select>
                    <hr>
                </div>

                <div class="SortLocation">
                    <h12><?= _lang("Location"?></h12>
                    <br> <select class="SelectBox" name="location[]" id="location" multiple>
                        <option value="ANY"><?= _lang("Any"?></option>
                        <?php
                            
foreach ($locations as $row) {
                                echo 
'<option value="' $row["id"] . '">' $row["name_" $langcode] . '</option>';
                            }
                        
?>
                    </select>
                    <hr>
                </div>

                <div class="SortTeachVenue">
                    <h12><?= _lang("Teach 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) {
                                echo 
'<option value="' $row["id"] . '">' $row["name_" $langcode] . '</option>';
                            }
                        
?>
                    </select>
                    <hr>
                </div>

                <div class="SortRate">
                    <h12><?= _lang("Fee"?><br>

                        <div class="rangeBar">
                            <strong>$<?= (float)$min_fee ?></strong>&nbsp;&nbsp;
                            <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="[<?= (float)$min_fee ?>,<?= (float)$max_fee ?>]"/>
                            &nbsp;<b>$<?= (float)$max_fee ?></b>
                        </div>
                        <hr>
                </div>

                <div class="SortGender">
                    <h12><?= _lang("Gender"?></h12>
                    <br>

                    <div class="searchable-container">
                        <div data-toggle="buttons" class="btn-group bizmoduleselect gender">
                            <label class="btn btn-default">
                                <input type="checkbox" name="gender[]" autocomplete="off" value="m" style="float:left;">
                                <span class="glyphicon glyphicon-ok glyphicon-lg" id="TickIcon"></span>
                                <h5><?= _lang("Male"?></h5>
                            </label>
                        </div>

                        <div data-toggle="buttons" class="btn-group bizmoduleselect gender">
                            <label class="btn btn-default">
                                <input type="checkbox" name="gender[]" autocomplete="off" value="f" 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" 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"] . '">' $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">
                        <div data-toggle="buttons" class="btn-group bizmoduleselect sort_by">
                            <label class="btn btn-default active">
                                <input type="checkbox" name="sort_by" autocomplete="off" value="MOST_POPULAR" style="float:left;" checked>
                                <span class="glyphicon glyphicon-ok glyphicon-lg" id="TickIcon"></span>
                                <h5><?= _lang("Most Popular"?></h5>
                            </label>
                        </div>

                        <div data-toggle="buttons" class="btn-group bizmoduleselect sort_by">
                            <label class="btn btn-default">
                                <input type="checkbox" name="sort_by" autocomplete="off" value="LOW_HIGH" style="float:left;">
                                <span class="glyphicon glyphicon-ok glyphicon-lg" id="TickIcon"></span>
                                <h5><?= _lang("Fee (low to high)"?></h5>
                            </label>
                        </div>

                        <div data-toggle="buttons" class="btn-group bizmoduleselect sort_by">
                            <label class="btn btn-default">
                                <input type="checkbox" name="sort_by" autocomplete="off" value="HIGH_LOW" style="float:left;">
                                <span class="glyphicon glyphicon-ok glyphicon-lg" id="TickIcon"></span>
                                <h5><?= _lang("Fee (high to low)"?></h5>
                            </label>
                        </div>
                    </div>
                    <hr>
                </div>

                <div class="ResetFilter">
                    <button type="button" onclick="location.href='category.php?id=<?= $category_id ?>';"><?= _lang("Reset Filter"?></button>
                </div>
            </div>

            <div class="col-sm-9">
                <div class="row" id="tutor_list">
                    <?php
                        
if (empty($tutors)) {
                            echo 
"&nbsp;&nbsp;&nbsp;" _lang("No tutors.");
                        } else {
                            foreach (
$tutors as $tutor) {
                                if (empty(
$tutor["tutormain_id"]))
                                    continue;

                                
$teaching_experience get_master_type_code_by_id($tutor["mas_teachexp"]);
                                
$tutor_expectcharge  get_tutor_expectcharge($tutor["tutormain_id"], $category_id"fee");

                                
?>
                                <div class="col-lg-4 col-md-6">
                                    <div class="Tutor">
                                        <?php if (!empty($tutor["profilephoto_path"])) { ?>
                                            <a href="profile.php?id=<?= $tutor["tutormain_id"?>">
                                                <div class="tutor_img_container">
                                                    <div class="tutor_img" style="background: url(file/teacher/<?= $tutor["profilephoto_path"?>) center center no-repeat; background-size: contain; width: inherit; height: inherit"></div>
                                                    <img class="tutor_img2" src="file/teacher/<?= $tutor["profilephoto_path"?>">
                                                </div>
                                            </a>
                                        <?php ?>

                                        <div class="CategoryTutorName"><?= $tutor["nickname"?></div>
                                        <div class="TutorInfo">
                                            <font size="4">HK$<?= (float)$tutor_expectcharge[0]["min_fee"?> <?= _lang("per " $tutor_expectcharge[0]["min_minutes"] . " mins"?>
                                                &nbsp;&nbsp;&nbsp;<?= _lang("Level") . ": " $tutor_expectcharge[0]["min_grade"?></font><br>

                                            <div class="TutorDescription">
                                                <?php
                                                    
echo "<p class='self_describemyself' style='height: 33px;'>" nl2br($tutor["self_describemyself"]) . "</p>";

                                                    echo 
"<p>" _lang("Accumulate Tutorial Hours") . ": 10 " _lang("hours") . "</p>";
                                                    echo 
"<p>" _lang("LAST LOGIN") . ": " get_last_login_date($tutor["cmsloginid"]) . "</p>";
                                                
?>

                                            </div>
                                            <hr>

                                            <div class="experience">
                                                <span class="glyphicon glyphicon-paperclip"></span><font color="#ff0000"> <?= $teaching_experience["name_" $langcode?><?= _lang("years experience"?></font>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                            <?php }
                        } 
?>

                    <div class="col-lg-12">
                        <?php
                            
if ($numpage 1) {
                                
pagenav();
                            }
                        
?>
                    </div>

                </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() {
        if ($(window).width() <= 768) {
            $(".tutor_img").hide();
            $(".tutor_img2").show();
        } else {
            $(".tutor_img").show();
            $(".tutor_img2").hide();
        }
    }

    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 = $("#location").val();
        var teach_venue = $("#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 = [];
        $('input:checkbox[name="gender[]"]').each(function () {
            if (this.checked) {
                gender.push(this.value);
            }
        });

        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: gender,
                accumulate_tutorial_hours: accumulate_tutorial_hours,
                last_login: last_login,
                score: score,
                sort_by: sort_by,
                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);
            },
            success: function (result) {
                //$('#loading').slideUp(100);
                //console.log(result);
                $("#tutor_list").empty().html(result);

                $(".start").on("click", function () {
                    var start = $(this).attr("data-value");
                    filter_tutor(start);
                });

                resizeImage();
            }
        });

    }

    $(function () {
        $("#ex2").slider({});

        //filter quick search
        $("#quick_search_submit").on("click", function () {
            var quick_search = $("#quick_search").val();
            if (!quick_search) {
                alert("<?=_lang("Please enter searching words.")?>")
            } else {
                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();
        });

        //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();
        });

        //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%"
        });
    });

</script>

</body>
</html>