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
|
<?php include('_init.php');
//unset($_SESSION["popup"]);
if ($_GET["reset"] && $_GET["reset"] == 1) { unset($_GET); }
$where_clause = ""; $parameters = array(1, 0, 1, 4, 0, 1);
if (!empty($_GET)) { if (!empty($_GET["category_id"]) && $_GET["category_id"] != "ANY") { $where_clause .= " and student_postjob.mas_instrument = ?"; $parameters[] = $_GET["category_id"]; }
if (!empty($_GET["location"]) && $_GET["location"] != "ANY") { $where_clause .= " and student_postjoblearndistrict.mas_teachareacode = ?"; $parameters[] = $_GET["location"]; }
if (!empty($_GET["level_of_grade"]) && $_GET["level_of_grade"] != "ANY") { $where_clause .= " and student_postjob.level = ?"; $parameters[] = $_GET["level_of_grade"]; } }
//update completed flag $sql2 = "select * from `order` where deleted = ? and status = ? and (order_type = ? or order_type = ?)"; $parameters2 = array(0, "paid", "try", "formal"); $orders = bind_pdo($sql2, $parameters2, "selectall"); if (!empty($orders)) { foreach ($orders as $row) { $sql3 = "update student_postjob set completed_flag = ? where completed_flag = ? and id = ?"; $parameters3 = array(1, 0, $row["job_id"]); bind_pdo($sql3, $parameters3); } }
$sql = "select *,student_postjob.id as student_postjob_id, master_type_code.name_" . $langcode . " as instrument_name 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 where student_postjob.status = ? and student_postjob.deleted = ? and student_postjob.approved = ? and student_main.status = ? and student_main.deleted = ? and student_main.approved = ? {$where_clause} group by student_postjob.id order by student_postjob.completed_flag ASC, student_postjob.createdate DESC "; $jobs = bind_pdo($sql, $parameters, "selectall");
//find min fee of job $budget_array = array("30mins_min_budget", "30mins_max_budget", "45mins_min_budget", "45mins_max_budget", "60mins_min_budget", "60mins_max_budget",); foreach ($jobs as $key => $row) { $min_fee = 99999;
foreach ($budget_array as $budget) { if (!empty($row[$budget]) && $row[$budget] < $min_fee) { $min_fee = $row["$budget"]; } } $jobs[$key]["min_fee"] = $min_fee; }
$instrument_categories = get_master_type_code("INSTRUMENT_TYPE"); $locations = get_master_type_code("TEACH_POSITIONCODE"); $level_of_grades = get_master_type_code("LEVEL_OF_GRADE");
//update tutor job app_notification to read $sql = "update app_notification_user set read_date = ? where app_notification_user.cmsloginid = ? and app_notification_user.success = ? and app_notification_user.read_date is null"; $parameters = array(date("Y-m-d H:i:s"), $_SESSION["cmsloginid"], 1); bind_pdo($sql, $parameters); ?> <!DOCTYPE html> <html lang="en"> <head> <?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') ?>
<div class="container" style="margin-top: 50px; margin-bottom: 50px;">
<div class="row"> <div class="col-md-12">
<form action="job.php" method="post" id="job_filter_form" style="margin-bottom: 10px;"> <div class="row" style="background-color: #fff;"> <div class="col-xs-4" style=""> <select class="SelectBox" name="category_id" id="category_id" > <option value=""><?= _lang("Musical Instrument") ?></option> <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"] . '" ' . ($_GET["category_id"] == $row2["id"] ? "selected" : "") . '>' . $row2["name_" . $langcode] . '</option>'; } echo '</optgroup>'; } ?> </select> </div>
<div class="col-xs-4" style=""> <select class="SelectBox" name="level_of_grade" id="level_of_grade"> <option value="ANY"> <?= _lang("Level") ?> </option> <?php foreach ($level_of_grades as $row) { echo '<option value="' . $row["code"] . '" ' . ($_GET["level_of_grade"] == $row["code"] ? "selected" : "") . '>' . $row["name_" . $langcode] . '</option>'; } ?> </select> </div>
<div class="col-xs-4" style=""> <select class="SelectBox" name="location[]" id="location"> <option value="ANY" <?= empty($_GET["location"]) || $_GET["location"][0] == "ANY" ? "selected" : "" ?>><?= _lang("District") ?></option> <?php foreach ($locations as $row) { $selected = ""; foreach ($_GET["location"] as $location_id) { if ($location_id == $row["id"]) { $selected = "selected"; break; } } echo '<option value="' . $row["id"] . '" ' . $selected . '>' . $row["name_" . $langcode] . '</option>'; } ?> </select> </div>
</div>
</form>
<?php if (!empty($jobs)){ foreach ($jobs as $row) {
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 * 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_master = array(); $student_postjoblearndistrict_master_text = "";
if (!empty($result)) { foreach ($result as $row2) { $teachareacode = get_master_type_code("TEACH_AREACODE", $row2["extra1"]); $teachareacode = $teachareacode["name_" . $langcode];
if (!in_array($teachareacode, $student_postjoblearndistrict_master)) { $student_postjoblearndistrict_master[] = $teachareacode; } } }
if (!empty($student_postjoblearndistrict_master)) { foreach ($student_postjoblearndistrict_master as $key3 => $row3) { $student_postjoblearndistrict_master_text .= $row3;
if (($key3 + 1) != count($student_postjoblearndistrict_master)) { $student_postjoblearndistrict_master_text .= " / "; } } } else { $student_postjoblearndistrict_master_text = _lang("N/A"); }
?> <div class="JobSection row" style="padding-bottom: 0; width: auto; min-width: 100%;" id="job_<?= $row["student_postjob_id"] ?>"> <!--<div class="ProfileSectionTitle"></div>--> <?php echo "<div class='col-xs-4' style='padding: 0; margin-bottom: 15px;'><a href='job_detail.php?id=" . $row["student_postjob_id"] . "'><img src='" . $site_info["url"] . "img/instrument/" . $row["extra3"] . "' style='width: 100%;'></a> </div>";
echo "<div class='col-xs-8 short_info' style='margin-bottom: 15px;'>"; echo "<span style='color: #c11c2c'>"._lang("Musical Instrument") . ": " . $row["instrument_name"] . "</span><br>"; echo _lang("Learning Level") . ": " . $row["level"] . "<br>"; echo _lang("Tutorial Budget") . ": " . $_30mins . $_45mins . $_60mins . "<br>"; echo _lang("Expected Tutorial District") . ": " . $student_postjoblearndistrict_master_text;
echo "<div class='row' style='margin-top: 10px;'>"; echo '<div class="col-xs-6 tl nowrap "><a href="job_detail.php?id=' . $row["student_postjob_id"] . '"><button class="ContactTutorBTN" type="button" style="cursor: default; background-color: #fff; color: #000; border: 1px solid #000; padding: 9px 16px;">' . _lang("Detail") . '</button></a></div>';
if ($has_order === true || $row["completed_flag"] == 1) { echo '<div class="col-xs-6 tr nowrap padding0"><button class="ContactTutorBTN" type="button" style="cursor: default; background-color: #575656;">' . _lang("Matched") . '</button></div>'; } else { echo '<div class="col-xs-6 tr nowrap padding0"><button class="ContactTutorBTN" type="button" onclick="contact_student(' . $row["student_postjob_id"] . ', ' . (int)$_SESSION["member_login"] . ');" style="">' . _lang("Contact Student") . '</button></div>'; } echo '</div>';
echo '<div style="clear:both"></div>'; ?>
</div> </div>
<?php } } else { echo _lang("No Job."); } ?>
</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 b) Lesson time c) Music background d) Learning objective 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) 教學地點 b) 上課時間 c) 履歷及背景 d) 學習目的 e) 教材及樂器安排 </p> <?php }*/ ?> </div> </div> </div> <?php } ?>
<?php if ($_SESSION["is_tutor"] == 1 && empty($_SESSION["popup"])) { $tutor = get_tutor($_SESSION["member_login"]);
echo '<div id="popup" style="display: none; text-align: center; color: #00ADEF; font-weight: bold;padding-top: 30px;"><div id="popup_content" style="cursor: pointer;">';
if ($tutor["status"] < 4) { echo '請快快入去「我的履歷」完成導師註冊程序,<br> 你就可以在「學生配對」中直接跟同學對話。'; }
if ($tutor["status"] == 4 && $tutor["approved"] != 1) { echo '管理員正在審查你「我的履歷」中, 完成審查後你的檔案就可以在「導師搜尋」 出現。'; }
echo '</div></div>'; } ?>
<? 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 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 () { $("#popup_content").on("click", function () { window.location.href='tutor_profile.php'; });
//filter onchange $("select").on("change", function () { console.log(1); var category_id = $("#category_id").val(); var level_of_grade = $("#level_of_grade").val(); var location = $("#location").val();
window.location.href='job.php?category_id='+category_id+'&level_of_grade='+level_of_grade+'&location='+location; });
<?php if($_SESSION["is_tutor"] == 1 && empty($_SESSION["popup"]) && ($tutor["status"] < 4 || ($tutor["status"] == 4 && $tutor["approved"] != 1) )){ ?> $.fancybox({ //settings 'type': 'inline', 'fitToView': false, 'maxWidth': 800, 'maxHeight': 80, 'width': '90%', 'height': '80%', 'autoSize': false, 'closeClick': false, 'openEffect': 'none', 'closeEffect': 'none', 'href': '#popup', }); <?php $_SESSION["popup"] = 1; } ?>
$(".full_info").hide(); $(".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 type="text/javascript" src="js/jquery.sticky.js"></script> <script src="js/select2/select2.min.js"></script> <link href="js/select2/select2.min.css" rel="stylesheet"> <script type="text/javascript"> $(function () {
$("#job_filter_form").sticky({topSpacing: 45});
//change select /*$("#category_id").select2({ width: "100%" });
$("#location").select2({ width: "100%", });
$("#level_of_grade").select2({ width: "100%" });*/
/*$("#sort_by").select2({ width: "100%" });*/ }); </script> </body> </html>
|