/var/www/hkosl.com/m.musiccircle/job_detail.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
544
545
546
547
548
549
550
551
<?php
    
include('_init.php');

    if (empty(
$_GET["id"])) {
        
header("Location: job.php");
    } else {
        
$id = (int)$_GET["id"];
    }

    
/*if(empty($_SESSION["app_device_id"])){
        header("Location: ".$site_info["url"]."job.php?id=".$id);
        exit;
    }*/

    //mas_yearrange move to student post job
    
$student_postjob get_studentpostjob2($idnull0);
    if(!empty(
$student_postjob['student_mas_yearrange'])){
        
$mas_yearrange_sql "student_postjob.student_mas_yearrange";
    }else{
        
$mas_yearrange_sql "student_main.mas_yearrange";
    }

    
$where_clause " and student_postjob.id = ?";
    
$parameters   = array(10140$id);

    
$sql "select student_main.*,student_postjob.*,student_postjob.id as student_postjob_id, master_type_code.name_" $langcode " as instrument_name, master_type_code.extra3 as extra3 , mtc2.name_" $langcode " as level_name , mtc3.name_" $langcode " as student_age_range, mtc4.name_" $langcode " as tutor_instrument_level, mtc5.name_" $langcode " as tutor_age, student_postjob.createdate as post_date 
            from student_postjob 
            INNER JOIN student_main ON student_main.id = student_postjob.studentmain_id
            INNER JOIN student_postjoblearndistrict ON student_postjoblearndistrict.studentpostjob_id = student_postjob.id
            INNER JOIN master_type_code ON master_type_code.id = student_postjob.mas_instrument
            INNER JOIN master_type_code mtc2 ON mtc2.code = student_postjob.level and mtc2.typeid = 'LEVEL_OF_GRADE'
            INNER JOIN master_type_code mtc3 ON mtc3.id = 
$mas_yearrange_sql
            INNER JOIN master_type_code mtc4 ON mtc4.id = student_postjob.tutorreq_level
            INNER JOIN master_type_code mtc5 ON mtc5.id = student_postjob.tutorreq_age
            where student_postjob.status = ? and student_postjob.deleted = ? and student_main.approved = ? and student_main.status = ? and student_main.deleted = ? 
{$where_clause}
            group by student_postjob.id
            order by student_postjob.createdate DESC"
;

    
//echo dump_sql($sql, $parameters);
    //exit;
    
$jobs bind_pdo($sql$parameters"selectall");

    
$instrument_categories get_master_type_code("INSTRUMENT_TYPE");
    
$locations             get_master_type_code("TEACH_POSITIONCODE");

    
$url        $site_info["url"];
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <?php
        
echo $meta '
    <meta property="fb:app_id" content="1136003943104680"/>
    <meta property="og:title" content="' 
_lang("Pairing Number") . ": " "J".str_pad($jobs[0]["student_postjob_id"], 5"0"STR_PAD_LEFT) . '"/>
    <meta property="og:type" content="website"/>
    <meta property="og:url" content="http://' 
$_SERVER["HTTP_HOST"] . '/job_detail.php?id=' $jobs[0]["student_postjob_id"] . '&v=1"/>
    <meta property="og:image" content="'
.$site_info["url"] . "img/instrument/" $jobs[0]["extra3"].'"/>
    <link rel="image_src" type="image/jpeg" href="'
.$site_info["url"] . "img/instrument/" $jobs[0]["extra3"].'"/>
    <meta name="description" content="有一個\''
.$jobs[0]["instrument_name"].'\'學習個案你可能會有興趣" />
    <meta property="og:description" content="有一個\''
.$jobs[0]["instrument_name"].'\'學習個案你可能會有興趣" />
    <meta name="keywords" content="">
    <meta property="og:updated_time" content="' 
time() . '" />';
    
?>

    <?php include('_head.php'); ?>
    <link href="css/style_k.css?v=<?= time(); ?>" type="text/css" rel="stylesheet">
</head>

<body>
<?php include('_header.php'?>

<?php include('_dialog.php'?>

<?php if(!empty($_SESSION["cmsloginid"])){ $my_wish check_my_wish("job"$id); if($my_wish){ $color "color: #CC1342;";}else{ $color "";} ?>

    <div id="my_wish" style="<?=$color?>" onclick="my_wish('job', '<?=$id?>');"><span class="glyphicon glyphicon-heart" aria-hidden="true"></span></div>

<?php ?>

<div class="container" style="margin-top: 50px;">

    <div class="row">
        <div class="col-md-12">
            <p style="margin-top: 5px; width: 90%;">
                <?= "* " _lang("Desired learning time is divided into morning, afternoon and evening hours as follows") . ":" ?>
                <br>
                <?= _lang("Morning") . ": 09:00 - 13:00 " _lang("Afternoon") . ": 14:00 - 18:00 " _lang("Night") . ": 18:00 - 22:00 " ?>
            </p>
            <?php foreach ($jobs as $row) {

                
$row["postjob_no"] = "J".str_pad($row["student_postjob_id"], 5"0"STR_PAD_LEFT);

                if (!empty(
$row["student_post_gender"])) {
                    
$row["gender"] = $row["student_post_gender"];
                }

                
//check if student has paid trial fee
                
$has_order  false;
                
$sql        "select * from `order` where job_id = ? and deleted = ? and status = ?";
                
$parameters = array($row["student_postjob_id"], 0"paid");
                
$order      bind_pdo($sql$parameters"selectone");
                if (!empty(
$order)) {
                    
$has_order true;
                }

                
//budget
                
$_30mins "";
                
$_45mins "";
                
$_60mins "";

                if (!empty(
$row["30mins_min_budget"]) && !empty($row["30mins_max_budget"])) {
                    
$_30mins "30" _lang("mins") . ": $" $row["30mins_min_budget"] . ' - ' $row["30mins_max_budget"] . ', ';
                } else {
                    if (!empty(
$row["30mins_min_budget"]) && empty($row["30mins_max_budget"])) {
                        
$_30mins "30" _lang("mins") . ": " _lang("Above") . " $" $row["30mins_min_budget"] . ', ';
                    }

                    if (empty(
$row["30mins_min_budget"]) && !empty($row["30mins_max_budget"])) {
                        
$_30mins "30" _lang("mins") . ": " _lang("Below") . " $" $row["30mins_max_budget"] . ', ';
                    }
                }

                if (!empty(
$row["45mins_min_budget"]) && !empty($row["45mins_max_budget"])) {
                    
$_45mins "45" _lang("mins") . ": $" $row["45mins_min_budget"] . ' - ' $row["45mins_max_budget"] . ', ';
                } else {
                    if (!empty(
$row["45mins_min_budget"]) && empty($row["45mins_max_budget"])) {
                        
$_45mins "45" _lang("mins") . ": " _lang("Above") . " $" $row["45mins_min_budget"] . ', ';
                    }

                    if (empty(
$row["45mins_min_budget"]) && !empty($row["45mins_max_budget"])) {
                        
$_45mins "45" _lang("mins") . ": " _lang("Below") . " $" $row["45mins_max_budget"] . ', ';
                    }
                }

                if (!empty(
$row["60mins_min_budget"]) && !empty($row["60mins_max_budget"])) {
                    
$_60mins "60" _lang("mins") . ": $" $row["60mins_min_budget"] . ' - ' $row["60mins_max_budget"] . ', ';
                } else {
                    if (!empty(
$row["60mins_min_budget"]) && empty($row["60mins_max_budget"])) {
                        
$_60mins "60" _lang("mins") . ": " _lang("Above") . " $" $row["60mins_min_budget"] . ', ';
                    }

                    if (empty(
$row["60mins_min_budget"]) && !empty($row["60mins_max_budget"])) {
                        
$_60mins "60" _lang("mins") . ": " _lang("Below") . " $" $row["60mins_max_budget"] . ', ';
                    }
                }

                
//district
                
$sql                          "select *, master_type_code.name_" $langcode " as district_name from student_postjoblearndistrict 
                        INNER JOIN master_type_code ON master_type_code.id = student_postjoblearndistrict.mas_teachareacode
            
                        where student_postjoblearndistrict.deleted = ? and student_postjoblearndistrict.studentpostjob_id = ?"
;
                
$parameters                   = array(0$row["student_postjob_id"]);
                
$result                       bind_pdo($sql$parameters"selectall");
                
$student_postjoblearndistrict "";

                if (!empty(
$result)) {
                    foreach (
$result as $key2 => $row2) {
                        
$student_postjoblearndistrict .= $row2["district_name"] . ", ";
                    }

                    if (!empty(
$student_postjoblearndistrict)) {
                        
$student_postjoblearndistrict substr_replace($student_postjoblearndistrict"", -2);
                    }
                } else {
                    
$student_postjoblearndistrict _lang("N/A");
                }

                
//lesson time
                
$sql                      "select * from student_postjoblearntime where studentpostjob_id = ? and deleted = ?";
                
$parameters               = array($row["student_postjob_id"], 0);
                
$student_postjoblearntime bind_pdo($sql$parameters"selectall");

                
//$order_by_week = array();
                
$all_learntime "";
                foreach (
$student_postjoblearntime as $row2) {
                    
$all_learntime .= $row2["learntime"];
                    
//$token                      = explode("_", $row2["learntime"]);
                    //$order_by_week[$token[1]][] = $token[0];
                
}

                
$week_list = array("en" => array("Mon""Tue""Wed""Thu""Fri""Sat""Sun"), "cn" => array("一""二""三""四""五""六""日"));

                
$student_postjoblearntime_text '<br>
                <table id="expected_learning_time_table" style="">
                    <tr>
                        <td>' 
_lang("Date") . '</td>
                        <td>' 
$week_list[$langcode][0] . '</td>
                        <td>' 
$week_list[$langcode][1] . '</td>
                        <td>' 
$week_list[$langcode][2] . '</td>
                        <td>' 
$week_list[$langcode][3] . '</td>
                        <td>' 
$week_list[$langcode][4] . '</td>
                        <td>' 
$week_list[$langcode][5] . '</td>
                        <td>' 
$week_list[$langcode][6] . '</td>
                    </tr>
                    
                    <tr>
                        <td>' 
_lang("Morning") . '</td>';

                for (
$i 1$i <= 7$i++) {
                    
$student_postjoblearntime_text .= '<td>' . (strpos($all_learntime"am_" $i) !== false '<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>' '') . '</td>';
                }

                
$student_postjoblearntime_text .= '</tr>
                    
                    <tr>
                        <td>' 
_lang("Afternoon") . '</td>';
                for (
$i 1$i <= 7$i++) {
                    
$student_postjoblearntime_text .= '<td>' . (strpos($all_learntime"pm_" $i) !== false '<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>' '') . '</td>';
                }
                
$student_postjoblearntime_text .= '</tr>
                    
                    <tr>
                        <td>' 
_lang("Night") . '</td>';
                for (
$i 1$i <= 7$i++) {
                    
$student_postjoblearntime_text .= '<td>' . (strpos($all_learntime"ni_" $i) !== false '<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>' '') . '</td>';
                }
                
$student_postjoblearntime_text .= '</tr>
                </table>'
;

                
$weekmap = array(=> "Mon"=> "Tue"=> "Wed"=> "Thu"=> "Fri"=> "Sat"=> "Sun");

                
//foreach ($order_by_week as $key3 => $row3) {
                /*for ($i = 1; $i <= 7; $i++) {
                    if (!empty($order_by_week[$i])) {
                        $student_postjoblearntime_text .= _lang($weekmap[$i]) . " ";
                        foreach ($order_by_week[$i] as $item3) {
                            $student_postjoblearntime_text .= "[" . ($item3 == "am" ? _lang("Morning") : ($item3 == "pm" ? _lang("Afternoon") : _lang("Night"))) . "] ";
                        }
                        $student_postjoblearntime_text .= ",<br>";
                    }
                }

                if (!empty($student_postjoblearntime_text)) {
                    $student_postjoblearntime_text = substr_replace($student_postjoblearntime_text, "", -5);
                }*/

                //teaching mode
                
$teaching_mode "";
                
$sql           "select * from student_postjoblearnmode 
                        INNER JOIN master_type_code ON master_type_code.id = student_postjoblearnmode.mas_teachmode
            
                        where student_postjoblearnmode.deleted = ? and student_postjoblearnmode.studentpostjob_id = ?"
;
                
$parameters    = array(0$row["student_postjob_id"]);
                
$result        bind_pdo($sql$parameters"selectall");

                foreach (
$result as $row3) {
                    
$teaching_mode .= $row3["name_" $langcode] . ", ";
                }

                if (!empty(
$teaching_mode)) {
                    
$teaching_mode substr_replace($teaching_mode"", -2);
                }

                
//teaching venus
                
$teaching_venus "";
                
$sql            "select * from student_postjoblearnvenus 
                        INNER JOIN master_type_code ON master_type_code.id = student_postjoblearnvenus.mas_teachvenus
            
                        where student_postjoblearnvenus.deleted = ? and student_postjoblearnvenus.studentpostjob_id = ?"
;
                
$parameters     = array(0$row["student_postjob_id"]);
                
$result         bind_pdo($sql$parameters"selectall");

                foreach (
$result as $row3) {
                    
$teaching_venus .= $row3["name_" $langcode] . ", ";
                }

                if (!empty(
$teaching_venus)) {
                    
$teaching_venus substr_replace($teaching_venus"", -2);
                }
                
?>
                <div class="JobSection row" style="padding-bottom: 0; width: 100%; margin: 0 auto;margin-bottom: 100px;" id="job_<?= $row["student_postjob_id"?>">
                    <!--<div class="ProfileSectionTitle"></div>-->
                    <?php
                        
//full info
                        
echo "<div class='col-sm-10 full_info' style='margin-bottom: 15px; padding: 0;'><div class='bold'>" _lang("Pairing Number") . ": " short_code($row["postjob_no"], 1, -5) . "<br>" _lang("Post Date") . ": " date("Y-m-d"strtotime($row["post_date"])) . "</div><br><table style='width: 100%;'><tr><td><p><span class='job_title_text'>" _lang("Student Info.") . "</span></td></tr><tr><td>" _lang("Age") . ": " $row["student_age_range"] . "<span class='job_field_space'></span>" _lang("Gender") . ": " . ($row["gender"] == "m" _lang("Male") : ($row["gender"] == "f" _lang("Female") : _lang("Male / Female"))) . "<br>" _lang("Expected Tutorial District") . ": " $student_postjoblearndistrict "<br>" _lang("Expected Tutorial Venue") . ": " $teaching_venus "</p></td></tr>";

                        echo 
"<tr><td><p><span class='job_title_text'>" _lang("Learning Requirement") . "</span></td></tr><tr><td>" _lang("Musical Instrument") . ": " $row["instrument_name"] . "<span class='job_field_space'></span>" _lang("Level") . ": " $row["level_name"] . "<span class='job_field_space'></span>
                        " 
_lang("Teaching Mode") . ": " $teaching_mode "<br>
                        " 
_lang("Lessons in a month") . ": " $row["explessonpermonth"] . "
                        <br>" 
_lang("Tutorial Budget") . ": " $_30mins $_45mins $_60mins "<br><br><div style='text-align: center;'><span class='glyphicon glyphicon-time' aria-hidden='true'></span> " _lang("Expected Tutorial Time") . "" $student_postjoblearntime_text "</div><br>" "</p>
                        </td></tr>"
;

                        echo 
"<tr><td><p><span class='job_title_text'>" _lang("Tutor Requirement Expectation") . "</span></td></tr><tr><td>" _lang("Gender") . ": " . ($row["tutorreq_gender"] == "m" _lang("Male") : ($row["tutorreq_gender"] == "f" _lang("Female") : _lang("Male / Female"))) . "<span class='job_field_space'></span>" _lang("Musical Instrument Level") . ": " $row["tutor_instrument_level"] . "<span class='job_field_space'></span>" _lang("Age") . ": " $row["tutor_age"] . "<span class='job_field_space'></span>";

                        if (
$row['approved'] == && $row["tutorreq_others"]) {
                            echo 
'<br>' _lang("Special Request") . ": " . (!empty($row["tutorreq_others"]) ? $row["tutorreq_others"] : "");
                        }

                        echo 
'</p></td></tr>';

                        echo 
"<tr><td colspan='2'>" _lang("Link") . ": <a href='http://www.imusiccircle.com/job.php?id=" $row["student_postjob_id"] . "'>" $site_info["url"] . "job.php?id=" $row["student_postjob_id"] . "</td></tr>";

                        echo 
'</table></div>';

                    
?>

                    <div class="tc" style="margin-bottom: 10px;">
                        <div id="fb-root" style="display: inline-block;"></div>
                        <script>(function (d, s, id) {
                                var js, fjs = d.getElementsByTagName(s)[0];
                                if (d.getElementById(id)) return;
                                js = d.createElement(s);
                                js.id = id;
                                js.src = "//connect.facebook.net/zh_HK/sdk.js#xfbml=1&version=v2.7";
                                fjs.parentNode.insertBefore(js, fjs);
                            }(document, 'script', 'facebook-jssdk'));</script>
                        <div class="fb-share-button" data-href="<?= "http://".$_SERVER["HTTP_HOST"] . '/job_detail.php?id=' $id.'&_redirect=1'?>" data-layout="button_count" data-size="large" data-mobile-iframe="true">
                            <a class="fb-xfbml-parse-ignore" href="https://www.facebook.com/sharer/sharer.php?u=<?= "http://".$_SERVER["HTTP_HOST"] . '/job_detail.php?id=' $id.'&_redirect=1' ?>&src=sdkpreparse">分享</a>
                        </div>

                    </div>

                    <?php
                        
if ($has_order === true || $row["completed_flag"] == 1) {
                            echo 
'<div class="col-sm-2 tr nowrap padding0" style="margin-bottom: 10px;"><button class="ContactTutorBTN" type="button" style="cursor: default; background-color: #575656;">' _lang("Matched") . '</button></div>';
                        } else {
                            echo 
'<div class="col-sm-2 tr nowrap padding0 " style="margin-bottom: 10px;"><button class="ContactTutorBTN" type="button" onclick="contact_student(' $row["student_postjob_id"] . ', ' . (int)$_SESSION["member_login"] . ');">' _lang("Contact Student") . '</button></div>';
                        }

                        echo 
'<div style="clear:both"></div>';
                    
?>

                </div>

            <?php ?>

        </div>
    </div>
</div>

<?php if (isset($_SESSION["cmsloginid"]) && isset($_SESSION["is_tutor"]) && $_SESSION["is_tutor"] == 1) { ?>
    <div id="contact_student_chat_box" style="display: none; overflow-x: hidden;">
        <div class="row">
            <div class="col-md-12">
                <h3 class="tc"><?= _lang("Leave Message for Student"?></h3>

                <textarea style="width:100%;" rows="5" name="content" id="content" placeholder="<?= _lang("Please note the tips below."?>"></textarea>

                <div class="tl">
                    <div style="font-size: 12px; color: red;"><?= _lang("Mobile no, email address and any contact is not allowed during the conversation."?></div>

                    <button class="ContactTutorBTN" type="button" id="contact_student_submit" onclick="contact_student_submit();" style="margin-top: 10px;"><?= _lang("Submit"?></button>

                </div>

                <?php /*if ($_SESSION["wlangcode"] == "en") { ?>
                    <p style="color: #0012ff;font-size:12px; font-weight:100;">*Tips:<br> 1) Before confirmation and
                        payment for trial lesson, the tutor and student will only have 5 conversation chances <br> 2) We
                        suggest both parties to chat based on the following topics: <br>
                        <span style="padding-left: 20px;"></span>a) Learning location &nbsp;&nbsp;&nbsp;b) Lesson time
                        &nbsp;&nbsp;&nbsp;c) Music background &nbsp;&nbsp;&nbsp;d) Learning objective &nbsp;&nbsp;&nbsp;e)
                        e) Arrangement of instrument and teaching material
                    </p>
                <?php } else { ?>
                    <p style="color: #0012ff;font-size:12px; font-weight:100;">*提示:<br> 1)於付款確定試堂前,導師與學生有5次來回對話機會 <br>
                        2)我們建議雙方於對話中就以下內容進行商討: <br> <span style="padding-left: 20px;"></span>a) 教學地點 &nbsp;&nbsp;&nbsp;b)
                        上課時間 &nbsp;&nbsp;&nbsp;c) 履歷及背景 &nbsp;&nbsp;&nbsp;d) 學習目的 &nbsp;&nbsp;&nbsp;e) 教材及樂器安排
                    </p>
                <?php } */
?>
            </div>
        </div>
    </div>
<?php ?>
<? 
include('_footer.php'?>
<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 my_wish(type, id) {
        jQuery.ajax({
            url: '_ajax.php',
            type: 'POST',
            data: {
                ajax: "my_wish",
                type: type,
                id: id,
            },
            dataType: 'html', //dataType (default: Intelligent Guess (xml, json, script, or html))
            timeout: 1000,
            error: function (result) {
                //alert('Error Occur. Please try again.');
                //console.log(result.responseText);
            },
            success: function (result) {
                console.log(result);
                if(result == "1"){
                    //change heart color
                    $("#my_wish").css("color", "#CC1342");
                }else{
                    $("#my_wish").css("color", "#ccc");
                }
            }
        });
    }

    function contact_student(job_id, tutor_id) {
        //check if user login
        <?php
        
if(!isset($_SESSION["cmsloginid"])){
        echo 
"alert('" _lang("Please login first. If you have any problem, you can call 9446 0817 with Whatsapp to contact us.") . "'); return;";
    }else if(!isset(
$_SESSION["is_tutor"]) || $_SESSION["is_tutor"] == 0){
        echo 
"alert('" _lang("You are not a tutor. You cannot contact student.") . "'); return;";
    }else {

        
?>

        jQuery.ajax({
            url: '_ajax.php',
            type: 'POST',
            data: {
                ajax: "check_contact",
                job_id: job_id,
                tutor_id: tutor_id,
            },
            dataType: 'html', //dataType (default: Intelligent Guess (xml, json, script, or html))
            timeout: 1000,
            error: function (result) {
                //alert('Error Occur. Please refresh and try again.');
                console.log(result.responseText);
            },
            success: function (result) {
                //$('#loading').slideUp(100);
                //console.log(result);
                var json = result,
                    obj = JSON.parse(json);

                if (obj.error == 1) {
                    alert("Missing job id or tutor id.");
                } else {
                    if (obj.matched_musical_instrument) {
                        if (parseInt(obj.count_chat) > 0) {
                            location.href = "webadmin/chat_index.php?type=1&first_chat_id=" + obj.first_chat_id;
                        } else {
                            //popup box
                            $.fancybox({
                                //settings
                                'type': 'inline',
                                'maxWidth': 800,
                                'fitToView': false,
                                'width': '90%',
                                'height': '45%',
                                'autoSize': false,
                                'closeClick': false,
                                'openEffect': 'none',
                                'closeEffect': 'none',
                                'href': '#contact_student_chat_box'
                            });

                            $("#contact_student_submit").attr("onclick", 'contact_student_submit(' + job_id + ')');
                        }
                    } else {
                        alert("<?=_lang("The musical instrument you are teaching do not match job requirement of student. You do not allow to chat with student.")?>");
                    }
                }
                //alert(result);
            }
        });
        <?php ?>
    }

    function contact_student_submit(job_id) {

        var content = $("#content").val();

        if (!content) {
            alert("<?=_lang("Please enter message.");?>");
            return;
        }

        if (!job_id) {
            alert("<?=_lang("Please select job.");?>");
            return;
        }

        jQuery.ajax({
            url: '_ajax.php',
            type: 'POST',
            data: {
                ajax: "contact_student_submit",
                job_id: job_id,
                content: content,
            },
            dataType: 'html', //dataType (default: Intelligent Guess (xml, json, script, or html))
            timeout: 1000,
            error: function (result) {
                alert('Error Occur. Please try again.');
                //console.log(result.responseText);
            },
            success: function (result) {
                //$('#loading').slideUp(100);
                //console.log(result);
                alert(result);

                $.fancybox.close();
            }
        });

    }

    $(function () {
        $(".full_info").show();
        $(".close_expand").hide();

        $(".expand").on("click", function () {
            $(this).hide();
            $(this).closest(".JobSection").find(".close_expand").show();
            $(this).closest(".JobSection").find(".short_info").hide();
            $(this).closest(".JobSection").find(".full_info").show();
        });

        $(".close_expand").on("click", function () {
            $(this).hide();
            $(this).closest(".JobSection").find(".expand").show();
            $(this).closest(".JobSection").find(".short_info").show();
            $(this).closest(".JobSection").find(".full_info").hide();
        });

        <?php if(!empty($_GET["id"])) { ?>
        $("#job_<?=(int)$_GET["id"]?>").find(".short_info").hide();
        $("#job_<?=(int)$_GET["id"]?>").find(".full_info").show();
        $("#job_<?=(int)$_GET["id"]?>").find(".expand").hide();
        $("#job_<?=(int)$_GET["id"]?>").find(".close_expand").show();
        $("#job_<?=(int)$_GET["id"]?>").css("border", "1px solid #CC1342");


        /*$('html, body').animate({
         //scrollTop: $(window.location.hash).offset().top - 105
         scrollTop: $("#job_<=(int)$_GET["id"]?>").offset().top - 180
         });*/
        <?php ?>
    })
</script>

<script src="js/select2/select2.min.js"></script>
<link href="js/select2/select2.min.css" rel="stylesheet">
<script type="text/javascript">
    $(function () {
        //change select
        $("#category_id").select2({
            width: "100%"
        });

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

    });
</script>
</body>
</html>