/var/www/hkosl.com/imusiccircle/webadmin/course_search_index_20161220.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
542
543
<?php
    $page_settings 
= array(
        
'formid'     => 'Tutor_search'// for permission
        
'section'    => 'Master'// parent/page title
        
'subsection' => 'Course Search'// page title
        
'domain'     => 'tutor_search'// table/model name
        
'access'     => 'GNr'// for permission
    
);

    require_once 
"check_login.php";

    if (isset(
$_GET["reset"]) && $_GET["reset"] == || !empty($_GET["student_postjob_id"])) {
        unset(
$_SESSION["tutor_search"]);
    }

    if (
$_SESSION["is_student"] != && $_SESSION["cmsrole"] == "user") {
        
//add alert message
        
header("Location: index.php");
    } else {
        
//get this student info
        
$sql        "select * from student_main where cmsloginid = ?";
        
$parameters = array($_SESSION["cmsloginid"]);
        
$student    bind_pdo($sql$parameters"selectone");

        
//get post list
        
$sql        "select * from student_postjob where studentmain_id = ? and status =? and deleted = ?";
        
$parameters = array($student["id"], 10);
        
$posts      bind_pdo($sql$parameters"selectall");
    }

    if (
$_SESSION["cmsrole"] == "super_admin" || $_SESSION["cmsrole"] == "admin") {
        
//get student list
        
$sql        "select * from student_main where status = ? and deleted = ?";
        
$parameters = array(40);
        
$students   bind_pdo($sql$parameters"selectall");

        
//get post list
        
$sql        "select * from student_postjob where status =? and deleted = ?";
        
$parameters = array(10);
        
$posts      bind_pdo($sql$parameters"selectall");
    }
    
$level_of_grades     get_master_type_code("LEVEL_OF_GRADE");
    
$music_theory_grades get_master_type_code("MUSTHEORY_GRADE");
    
$locations           get_master_type_code("TEACH_POSITIONCODE");
    
$all_instruments     get_master_type_code("INSTRUMENT");
    
$teach_venues        get_master_type_code("TEACH_VENUS");
    
$teach_modes         get_master_type_code("TEACH_MODE");
    
$instrument_categories get_master_type_code("INSTRUMENT_TYPE");

    
$_30min_fee       0;
    
$_30max_fee       9999;
    
$_45min_fee       0;
    
$_45max_fee       9999;
    
$_60min_fee       0;
    
$_60max_fee       9999;
    
$tutorreq_age_min 0;
    
$tutorreq_age_max 100;

    
//get post request
    
if (!empty($_GET["studentmain_id"]) && !empty($_GET["student_postjob_id"])) {
        
//set value in filter form
        
$studentmain_id     = (int)$_GET["studentmain_id"];
        
$student_postjob_id = (int)$_GET["student_postjob_id"];

        
$sql        "select * from student_postjob where student_postjob.studentmain_id = ? and student_postjob.id = ? and student_postjob.deleted = ?";
        
$parameters = array($studentmain_id$student_postjob_id0);
        
$postjob    bind_pdo($sql$parameters"selectone");

        
$category_id                                  $postjob["mas_instrument"];
        
$_SESSION["tutor_search"]["category_id"]      = $postjob["mas_instrument"];
        
$require_tutor_gender                         $postjob["tutorreq_gender"];
        
$_SESSION["tutor_search"]["tutorreq_gender"]  = $postjob["tutorreq_gender"];
        
$require_tutor_instrument_level               $postjob["level"]; //LEVEL OF GRADE
        
$_SESSION["tutor_search"]["level"]            = $postjob["level"];
        
/*$require_tutor_theory_level                   = $postjob["tutorreq_level"]; //theory grade
        $_SESSION["tutor_search"]["tutorreq_level"]   = $postjob["tutorreq_level"];*/
        
$require_tutor_age_min                        $postjob["tutorreq_age_min"];
        
$_SESSION["tutor_search"]["tutorreq_age_min"] = $postjob["tutorreq_age_min"];
        
$require_tutor_age_max                        $postjob["tutorreq_age_max"];
        
$_SESSION["tutor_search"]["tutorreq_age_max"] = $postjob["tutorreq_age_max"];

        
$sql                             "select mas_teachareacode from student_postjoblearndistrict where studentpostjob_id = ? and deleted = ?";
        
$parameters                      = array($student_postjob_id0);
        
$require_tutor_mas_teachareacode bind_pdo($sql$parameters"selectall");
        foreach (
$require_tutor_mas_teachareacode as $row) {
            
$_SESSION["tutor_search"]["tutor_mas_teachareacode"][] = $row["mas_teachareacode"];
        }

        
$sql                         "select mas_teachmode from student_postjoblearnmode where studentpostjob_id = ? and deleted = ?";
        
$parameters                  = array($student_postjob_id0);
        
$require_tutor_mas_teachmode bind_pdo($sql$parameters"selectall");
        foreach (
$require_tutor_mas_teachmode as $row) {
            
$_SESSION["tutor_search"]["tutor_mas_teachmode"][] = $row["mas_teachmode"];
        }

        
$sql                          "select mas_teachvenus from student_postjoblearnvenus where studentpostjob_id = ? and deleted = ?";
        
$parameters                   = array($student_postjob_id0);
        
$require_tutor_mas_teachvenus bind_pdo($sql$parameters"selectall");
        foreach (
$require_tutor_mas_teachvenus as $row) {
            
$_SESSION["tutor_search"]["tutor_mas_teachvenus"][] = $row["mas_teachvenus"];
        }
    }

    if (isset(
$_SESSION["tutor_search"]["30mins_min_budget"]) && isset($_SESSION["tutor_search"]["30mins_max_budget"])) {
        
$_30min_fee $_SESSION["tutor_search"]["30mins_min_budget"];
        
$_30max_fee $_SESSION["tutor_search"]["30mins_max_budget"];
    }

    if (isset(
$_SESSION["tutor_search"]["45mins_min_budget"]) && isset($_SESSION["tutor_search"]["45mins_max_budget"])) {
        
$_45min_fee $_SESSION["tutor_search"]["45mins_min_budget"];
        
$_45max_fee $_SESSION["tutor_search"]["45mins_max_budget"];
    }

    if (isset(
$_SESSION["tutor_search"]["60mins_min_budget"]) && isset($_SESSION["tutor_search"]["60mins_max_budget"])) {
        
$_60min_fee $_SESSION["tutor_search"]["60mins_min_budget"];
        
$_60max_fee $_SESSION["tutor_search"]["60mins_max_budget"];
    }

    if (isset(
$_SESSION["tutor_search"]["tutorreq_age_min"]) && isset($_SESSION["tutor_search"]["tutorreq_age_max"])) {
        
$tutorreq_age_min $_SESSION["tutor_search"]["tutorreq_age_min"];
        
$tutorreq_age_max $_SESSION["tutor_search"]["tutorreq_age_max"];
    }
?>
<!DOCTYPE html>
<html>
<head>
    <?php require_once "_html_head.php"?>
    <link rel="stylesheet" href="css/tutor_student_search.css">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <?php require_once "_header.php"?>
    <?php require_once "_menu.php"?>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                <?= _lang($page_settings['subsection']) ?>
                <small>
                    <?= _lang("Index"?>
                </small> </h1>
            <ol class="breadcrumb">
                <li>
                    <?= _lang("Home"?>
                </li>
                <li class="active"> <a href="<?= $page_settings['domain'?>_index.php"><i class="fa"></i>
                        <?= _lang($page_settings['subsection']) ?>
                    </a></li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">

            <!-- Your Page Content Here -->

            <!-- main table -->
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-body">
                            <?php if ($_SESSION["cmsrole"] == "super_admin" || $_SESSION["cmsrole"] == "admin") { ?>
                                <div class="row">
                                    <div class="col-md-1">
                                        <?=_lang("Student")?>
                                        : </div>
                                    <div class="col-md-6">
                                        <select name="studentmain_id" id="studentmain_id" class="form-control input-sm">
                                            <option value="">---
                                                <?=_lang("Please Select")?>
                                                ---</option>
                                            <?php foreach ($students as $row) {
                                                echo 
'<option value="' $row["id"] . '" '.(isset($_GET["studentmain_id"]) && $row["id"] == $_GET["studentmain_id"]?"selected":"").'>' $row["contactname"] . '</option>';
                                            } 
?>
                                        </select>
                                    </div>
                                </div>
                                <br>
                            <?php } else { ?>
                                <input type="hidden" name="studentmain_id" id="studentmain_id" value="<?= $student["id"?>"/>
                            <?php ?>
                            <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["tutor_search"]["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_" $_SESSION["wlangcode"]] . '">';

                                                
$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["tutor_search"]["category_id"] == $row2["id"] ? "selected" "") . '>' $row2["name_" $_SESSION["wlangcode"]] . '</option>';
                                                }
                                                echo 
'</optgroup>';
                                            }
                                        
?>
                                    </select>
                                    <hr>
                                </div>
                                <div class="SortLevel">
                                    <h12>
                                        <?= _lang("Musical Instrument Level"?>
                                    </h12>
                                    <br>
                                    <select class="SelectBox" name="level" id="level">
                                        <option value="ANY">
                                            <?= _lang("Any"?>
                                        </option>
                                        <?php
                                            
foreach ($level_of_grades as $row) {
                                                echo 
'<option value="' $row["code"] . '" ' . ($_SESSION["tutor_search"]["level"] == $row["code"] ? "selected" "") . '>' $row["name_" $_SESSION["wlangcode"]] . '</option>';
                                            }
                                        
?>
                                    </select>
                                    <hr>
                                </div>
                                <!--
                <div class="SortLocation">
                  <h12>
                    <?= _lang("Teaching District"?>
                  </h12>
                  <br>
                  <select class="SelectBox" name="tutor_mas_teachareacode[]" id="tutor_mas_teachareacode" multiple>
                    <option value="ANY">
                    <?= _lang("Any"?>
                    </option>
                    <?php
                                    
foreach ($locations as $row) {
                                        
$selected "";
                                        foreach (
$_SESSION["tutor_search"]["tutor_mas_teachareacode"] as $location_id) {
                                            if (
$location_id == $row["id"]) {
                                                
$selected "selected";
                                                break;
                                            }
                                        }
                                        echo 
'<option value="' $row["id"] . '" ' $selected '>' $row["name_" $_SESSION["wlangcode"]] . '</option>';
                                    }
                                
?>
                  </select>
                  <hr>
                </div>
                <!--
                <div class="SortRate">
                  <h12>
                    <?= _lang("Fee"?>
                  </h12>
                  <br>
                  <div class="rangeBar">
                    <div id="30mins_charge_container"> <b>$0</b>&nbsp;&nbsp;
                      <input id="30mins_charge" type="text" class="span2" value="" data-slider-min="0" data-slider-max="1000" data-slider-step="10" data-slider-value="[<?= (float)$_30min_fee ?>,<?= (float)$_30max_fee ?>]"/>
                      &nbsp;<b>$1000</b> </div>
                  </div>
                  <br>
                  <hr>
                </div>
                <div class="SortAge">
                  <h12>
                    <?= _lang("Tutor Age"?>
                  </h12>
                  <br>
                  <div class="rangeBar">
                    <div id="tutor_age_container"> <b>0</b>
                      <input id="tutor_age" type="text" class="span2" value="" data-slider-min="0" data-slider-max="100" data-slider-step="5" data-slider-value="[<?= (float)$tutorreq_age_min ?>,<?= (float)$tutorreq_age_max ?>]"/>
                      &nbsp;<b>100</b> </div>
                  </div>
                  <hr>
                </div>
                -->
                                <div class="ResetFilter">
                                    <button type="button" onclick="location.href='course_search_index.php?reset=1';">
                                        <?= _lang("Reset Filter"?>
                                    </button>
                                </div>
                            </div>
                            <div class="col-sm-9">
                                <div class="row" id="tutor_list"> </div>
                            </div>
                        </div>
                    </div>
                    <!-- /.box-body -->
                </div>
                <!-- /.box -->
            </div>
            <!-- /.col -->
        </section>
    </div>
    <!-- /.row -->

    <!-- End of Your Page Content Here -->

    <!-- /.content -->
</div>
<!-- /.content-wrapper -->

<?php require_once "_footer.php"?>
<?php 
require_once "_aside.php"?>
</div>
<!-- ./wrapper -->

<div id="accumulate_tutorial_hours" style="display:none;">
    <h4><b>累積上課時數</b></h4>
    <p> 導師跟學生於iMusicCircle進行配對後,會開始學習階段。當中每次透過iMusicCircle 付款的時數,都會記錄於iMusicCircle的系統內,導師累積時數愈多,導師排名愈高。 </p>
    <h4><b>累積時數的星級分配</b></h4>
    <p> iMusicCircle會每天總結導師的累積時數,並按比例地分配各導師所得的星級,比例如下: </p>
    <table id="accumulate_tutorial_hours_table">
        <tr>
            <th>星級</th>
            <th class="nowrap">導師比例</th>
            <th>例子(以100位導師計算)</th>
        </tr>
        <tr>
            <td><span class="stars">5</span></td>
            <td>20% (最高)</td>
            <td>累積時數排名第1-20位</td>
        </tr>
        <tr>
            <td><span class="stars">4</span></td>
            <td>30%</td>
            <td>累積時數排名第21-50位</td>
        </tr>
        <tr>
            <td><span class="stars">3</span></td>
            <td>30%</td>
            <td>累積時數排名第51-80位</td>
        </tr>
        <tr>
            <td><span class="stars">2</span></td>
            <td>10%</td>
            <td>累積時數排名第81-90位</td>
        </tr>
        <tr>
            <td><span class="stars">1</span></td>
            <td>10%</td>
            <td>累積時數排名第91-100位</td>
        </tr>
    </table>
</div>
<div id="loading"><img src="../img/loading_icon.gif" style="width: 100px;"></div>

<!-- REQUIRED JS SCRIPTS -->
<?php require_once "_html_script.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/select2/select2.min.js"></script>
<link href="../js/select2/select2.min.css" rel="stylesheet">
<script src="js/jquery.chained.min.js"></script>
<link rel="stylesheet" href="../js/fancybox/jquery.fancybox.css?v=2.1.5" type="text/css" media="screen"/>
<script type="text/javascript" src="../js/fancybox/jquery.fancybox.pack.js?v=2.1.5"></script>
<script type="text/javascript">
    function resizeImage() {
        if ($(window).width() <= 768) {
            $(".tutor_img").hide();
            $(".tutor_img2").show();
        } else {
            $(".tutor_img").show();
            $(".tutor_img2").hide();
        }
    }

    function tutor_search(start) {
        $('#loading').slideDown(100);

        if (!start)
            start = 0;
        //$('#loading').slideDown(100);
        //console.log("filter tutor");
        var quick_search = $("#quick_search").val();
        var category_id = $("#category_id").val(); //instrument
        var level = $("#level").val();

        console.log(level);

        //tutorreq_gender = JSON.stringify(tutorreq_gender);

        var sort_by = $("input[name='sort_by']:checked").val();

        jQuery.ajax({
            url: '_ajax.php',
            type: 'POST',
            data: {
                ajax: "course_search",
                quick_search: quick_search,
                category_id: category_id,
                level: level,
                sort_by: sort_by,
                start: start
            },
            dataType: 'html', //dataType (default: Intelligent Guess (xml, json, script, or html))
            timeout: 10000,
            error: function (result) {
                //console.log(result);
                console.log(result.responseText);
                //alert('Error Occur. Please try again.');
                //location.href="tutor_search_index.php?reset=1";
            },
            success: function (result) {
                $('#loading').slideUp(100);
                //console.log(result);
                if (result == "FAIL") {
                    alert("Access Denied!");
                } else {
                    $("#tutor_list").empty().html(result);

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

                    resizeImage();

                    //text overflow
                    $(".self_describemyself").dotdotdot();

                    $.fn.stars = function() {
                        return $(this).each(function() {
                            $(this).html($('<span />').width(Math.max(0, (Math.min(5, parseFloat($(this).html())))) * 16));
                        });
                    };

                    $('span.stars').stars();
                }

                $(".fancybox1").fancybox({
                    maxWidth    : 800,
                    maxHeight    : 290,
                    fitToView    : false,
                    width        : '100%',
                    height        : '100%',
                    autoSize    : false,
                    closeClick    : false,
                    openEffect    : 'none',
                    closeEffect    : 'none'
                });
            }
        });

    }

    $(function () {
        <?php if ($_SESSION["cmsrole"] == "super_admin" || $_SESSION["cmsrole"] == "admin") {
        echo 
'$("#student_postjob_id").chained("#studentmain_id");';
    } 
?>

        $("#30mins_charge, #45mins_charge, #60mins_charge, #tutor_age").slider({});

        $("#studentmain_id, #student_postjob_id").on("change", function () {
            //reload page
            var studentmain_id = $("#studentmain_id").val();
            var student_postjob_id = $("#student_postjob_id").val(); //instrument
            location.href = 'tutor_search_index.php?studentmain_id=' + studentmain_id + '&student_postjob_id=' + student_postjob_id;
            //tutor_search();
        });

        //filter quick search
        $("#quick_search_submit").on("click", function () {
            tutor_search();
        });

        /*$("#category_id, #level, #tutorreq_level, #tutor_mas_teachareacode, #tutor_mas_teachvenus, #tutor_mas_teachmode").on("change", function () {
         tutor_search();
         });*/

        $("#category_id, #level, #tutor_mas_teachareacode, #tutor_mas_teachvenus, #tutor_mas_teachmode").on("change", function () {
            tutor_search();
        });


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

        //center image
        resizeImage();

        $(window).resize(function () {
            resizeImage();
        });

        //text overflow
        $(".self_describemyself").dotdotdot();

        //change select
        $("#category_id").select2({
            width: "100%"
        });

        $("#level").select2({
            width: "100%"
        });

        /*$("#tutorreq_level").select2({
         disable_search: true,
         width: "100%"
         });*/

        $("#tutor_mas_teachareacode").select2({
            width: "100%",
            placeholder: "<?=_lang("Select Some Options")?>"
        });

        $("#tutor_mas_teachvenus").select2({
            width: "100%",
            placeholder: "<?=_lang("Select Some Options")?>"
        });

        $("#tutor_mas_teachmode").select2({
            width: "100%",
            placeholder: "<?=_lang("Select Some Options")?>"
        });

        tutor_search(); //auto run the first time filter tutor

    });

</script>
</body>
</html>