/var/www/hkosl.com/m.musiccircle/my_wish.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
<?php
    
include('_init.php');

    if (empty(
$_SESSION['member_login']) && empty($_SESSION['student_login'])) {
        
header("Location: index.php");
        exit;
    }

    
$sql        "select * from wish_list where cmsloginid = ? and status = ? order by createdate DESC";
    
$parameters = array($_SESSION["cmsloginid"], 1);
    
$result     bind_pdo($sql$parameters"selectall");
?>
<!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="ProfileContent">
    <div class="Profilecontainer">
        <div class="row">
            <div class="col-md-12">
                <?php foreach ($result as $row) {
                    if (!empty(
$_SESSION["member_login"])) { //list my wish job
                        //get job info
                        
$where_clause " and student_postjob.id = ?";
                        
$parameters   = array(101401$row["ref_id"]);
                        
$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}";
                        
$job          bind_pdo($sql$parameters"selectone");

                        if (!empty(
$job)) {
                            
//budget
                            
$_30mins "";
                            
$_45mins "";
                            
$_60mins "";

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

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

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

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

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

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

                        
//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$job["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="row" style="border-bottom: 1px solid #ccc;margin-bottom: 15px;">
                            <div class="col-xs-3" style="padding: 0;">
                                <?php
                                    
echo "<a href='job_detail.php?id=" $job["student_postjob_id"] . "' style='color: inherit;'><img src='" $site_info["url"] . "img/instrument/" $job["extra3"] . "' style='width: 100%;'></a>";
                                
?>
                            </div>
                            <div class="col-xs-7">
                                <?php
                                    
echo "<a href='job_detail.php?id=" $job["student_postjob_id"] . "' style='color: inherit;'>";
                                    echo 
_lang("Musical Instrument") . ": " $job["instrument_name"] . "<br>";
                                    echo 
_lang("Learning Level") . ": " $job["level"] . "<br>";
                                    echo 
_lang("Tutorial Budget") . ": " $_30mins $_45mins $_60mins "<br>";
                                    echo 
_lang("Expected Tutorial District") . ": " $student_postjoblearndistrict_master_text;
                                    echo 
"</a>";
                                
?>
                            </div>
                            <div class="col-xs-2">
                                <?php if (!empty($_SESSION["cmsloginid"])) {
                                    
$my_wish check_my_wish($row["type"], $row["ref_id"]);
                                    if (
$my_wish) {
                                        
$color "color: #CC1342;";
                                    } else {
                                        
$color "";
                                    }
                                } 
?>

                                <div id="my_wish" style="<?= $color ?> position: relative; top: 0; right: 0; " onclick="my_wish('<?= $row["type"?>', '<?= $row["ref_id"?>', this);">
                                    <span class="glyphicon glyphicon-heart" aria-hidden="true"></span></div>
                            </div>
                        </div>
                        <?php
                    
}
                else
                    if (!empty(
$_SESSION["student_login"])) { //list my wish tutor

                        
$sql        "select *,tutor_main.id as id2, mtcode1.name_en as residence_en, mtcode1.name_cn as residence_cn, mtcode1.extra1 as residence_master from tutor_main
                    INNER JOIN master_type_code mtcode1 ON mtcode1.id = tutor_main.mas_residencecode
                    where tutor_main.id = ? and tutor_main.status = ? and tutor_main.deleted = ? and tutor_main.approved = ?"
;
                        
$parameters = array($row["ref_id"], 401);
                        
$tutor      bind_pdo($sql$parameters"selectone");

                        
$tutor_year_range_info get_tutor_year_range($tutor["dob_year"], $tutor["dob_mon"]);
                        
$tutor_year_range      $tutor_year_range_info["tutor_year_range"];

                        
$teaching_area_master = array();
                        
$teaching_area        get_teaching_area($row["ref_id"]);
                        foreach (
$teaching_area as $row2) {
                            
$teachareacode get_master_type_code("TEACH_AREACODE"$row2["extra1"]);
                            
$teachareacode $teachareacode["name_" $langcode];

                            if (!
in_array($teachareacode$teaching_area_master)) {
                                
$teaching_area_master[] = $teachareacode;
                            }
                        }
                        
$teaching_instrument get_teaching_instrument($row["ref_id"]);
                        
?>

                        <div class="row" style="border-bottom: 1px solid #ccc;margin-bottom: 15px;">
                            <div class="col-xs-3" style="padding: 0;">
                                <?php
                                    
if (!empty($tutor["profilephoto_path"])) {
                                        echo 
'<a href="profile.php?id=' $row["ref_id"] . '" style="color: inherit;"><img class="tutor_img2" style="width: 100%;" src="' $site_info["url"] . 'file/teacher/' $tutor["profilephoto_path"] . '"></a>';
                                    }
                                
?>
                            </div>

                            <div class="col-xs-7">
                                <?php
                                    
echo '<a href="profile.php?id=' $row["ref_id"] . '" style="color: inherit;">';
                                    echo 
$tutor["nickname"] . "<br>";
                                    echo 
_lang("Tutor Code") . ": " $tutor["tutor_no"] . "<br>";
                                    echo 
_lang("Gender") . ": " . ($tutor["gender"] == "m" _lang("Male") : _lang("Female")) . " &nbsp;&nbsp;" _lang("Age") . ": " $tutor_year_range "<br>";
                                    echo 
strtolower(_lang("WHERE I TEACH")) . ": ";
                                    foreach (
$teaching_area_master as $key => $row2) {
                                        echo 
$row2;
                                        if ((
$key 1) != count($teaching_area_master)) {
                                            echo 
" / ";
                                        }
                                    }
                                    echo 
"<br>";
                                    echo 
strtolower(_lang("TEACHING MUSICAL INSTRUMENTS")).": ";
                                    if (!empty(
$teaching_instrument)) {
                                        foreach (
$teaching_instrument as $key => $row2) {
                                            echo 
$row2["name_" $langcode];
                                            if ((
$key 1) != count($teaching_instrument)) {
                                                echo 
", ";
                                            }
                                        }
                                    }
                                    echo 
"</a>";

                                
?>
                            </div>
                            <div class="col-xs-2">
                                <?php if (!empty($_SESSION["cmsloginid"])) {
                                    
$my_wish check_my_wish($row["type"], $row["ref_id"]);
                                    if (
$my_wish) {
                                        
$color "color: #CC1342;";
                                    } else {
                                        
$color "";
                                    }
                                } 
?>

                                <div id="my_wish" style="<?= $color ?> position: relative; top: 0; right: 0; " onclick="my_wish('<?= $row["type"?>', '<?= $row["ref_id"?>', this);">
                                    <span class="glyphicon glyphicon-heart" aria-hidden="true"></span></div>
                            </div>
                        </div>
                    <?php }
                } 
?>
                <br><br><br>
            </div>
        </div>
    </div>
</div>
<? include('_footer.php'?>
<script>
    function my_wish(type, id, _this) {
        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
                    $(_this).css("color", "#CC1342");
                } else {
                    $(_this).css("color", "#ccc");
                }
            }
        });
    }
</script>
</body>
</html>