blob: de071b1a2aaf5c46d9509fffda7f00614a6c8d21 (
plain)
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
|
<?php
// ****************************************************************************
// Description: Tableau correspondant aux missions effectuées par l'utilisateur.
// ****************************************************************************
// Import des textes en fonction de la langue définie dans la variable "lang" de la session.
require_once(dirname(__FILE__)."/".$_SESSION["lang"]."/text.php");
// Import des en-tête des tables.
require_once(dirname(__FILE__)."/".$_SESSION["lang"]."/table.php");
// Import des metodes de la base de donnée pour les recherches.
require_once(dirname(__FILE__)."/../../Database/meth_dbsearch.php");
require_once(dirname(__FILE__)."/../../Database/meth_dbmission.php");
// Instanciation de la bdd avec les méthodes de recherche.
$dbsearch = new DbSearch;
$dbmission = new DbMission;
// TODO: commenter
// Recherches des missions avec l'id de l'utilisateur actuellement connecté.
switch ($_SESSION["userStatus"]) {
case 1:
$result = $dbmission->get_mission_by_pro_id($_SESSION["userId"]);
for ($i = 0; $i < count($result); $i++) {
$result[$i]["jobCategoryId"] = $dbsearch->get_job_category_by_id($result[$i]["jobCategoryId"]);
}
break;
case 2:
$result = $dbmission->get_mission_by_client_id($_SESSION["userId"]);
for ($i = 0; $i < count($result); $i++) {
$result[$i]["jobCategoryId"] = $dbsearch->get_job_category_by_id($result[$i]["jobCategoryId"]);
}
break;
default:
break;
}
$missionStatus = [
"pending" => [],
"ongoing" => [],
"completed" => []
];
for ($i = 0; $i < count($result); $i++) {
if (!$result[$i]["acceptedByPro"]
) {
array_push($missionStatus["pending"], $result[$i]);
} elseif (!$result[$i]["validatedByPro"]
|| !$result[$i]["validatedByClient"]
) {
array_push($missionStatus["ongoing"], $result[$i]);
} else {
array_push($missionStatus["completed"], $result[$i]);
}
}
echo(' <!-- Separateur -->
<div class="separator"></div>
<!-- Mes missions -->
<div id="myMission">
<div id="missionButtons">
<button onclick="show(\'pendingTable\')"><h2>'.$text[basename(__FILE__, ".php")]["pendingMission"].'</h2></button>
<button onclick="show(\'ongoingTable\')"><h2>'.$text[basename(__FILE__, ".php")]["ongoingMission"].'</h2></button>
<button onclick="show(\'completedTable\')"><h2>'.$text[basename(__FILE__, ".php")]["completedMission"].'</h2></button>
</div>'.PHP_EOL);
// tableau 3 pending
echo(' <table id="pendingTable">
<!-- En-tête -->
<tr>'.PHP_EOL);
foreach($header["pendingMissions"] as $columnHeader) {
echo(" <th>".$columnHeader."</th>".PHP_EOL);
}
echo(" </tr>".PHP_EOL);
foreach ($missionStatus["pending"] as $rows) {
echo(' <!-- Missions -->
<tr>
<td><pre>'.$rows["date"].'</pre></td>
<td><pre>'.$rows["lastname"].'</pre></td>
<td><pre>'.$rows["jobCategoryId"][0]["jobCategoryName".ucwords($_SESSION["lang"])].'</pre></td>
<td><pre>'.$rows["subject"].'</pre></td>');
if ($_SESSION["userId"] == $rows["proId"]) {
echo(' <td class="noBorder" >
<form action="/Wrapper/wrapper.php" method="post">
<input type="hidden" name="acceptedMissionId" value="'.$rows["missionId"].'">
<input type="submit" value="'.$text[basename(__FILE__, ".php")]["accept"].'">
</form>
</td>');
}
echo(' </tr>'.PHP_EOL);
}
echo(' </table>');
// tableau 4 ongoing
echo(' <table id="ongoingTable">
<!-- En-tête -->
<tr>'.PHP_EOL);
foreach($header["ongoingMissions"] as $columnHeader) {
echo(" <th>".$columnHeader."</th>".PHP_EOL);
}
echo(" </tr>".PHP_EOL);
foreach ($missionStatus["ongoing"] as $rows) {
echo(' <!-- Missions -->
<tr>
<td><pre>'.$rows["acceptedByPro"].'</pre></td>
<td><pre>'.$rows["lastname"].'</pre></td>
<td><pre>'.$rows["jobCategoryId"][0]["jobCategoryName".ucwords($_SESSION["lang"])].'</pre></td>
<td><pre>'.$rows["subject"].'</pre></td>
<td><pre>'.$rows["validatedByClient"].'</pre></td>
<td><pre>'.$rows["validatedByPro"].'</pre></td>');
if (!$rows["validatedByClient"] && $_SESSION["userStatus"] == 2
|| (!$rows["validatedByPro"] && $_SESSION["userStatus"] == 1)
) {
echo(' <td class="noBorder" >
<form action="/Wrapper/wrapper.php" method="post">
<input type="hidden" name="validatedMissionId" value="'.$rows["missionId"].'">
<input type="submit" value="'.$text[basename(__FILE__, ".php")]["validate"].'">
</form>
</td>');
}
echo(' </tr>'.PHP_EOL);
}
echo(' </table>');
// tableau 5 completed
echo(' <table id="completedTable">
<!-- En-tête -->
<tr>'.PHP_EOL);
foreach($header["completedMissions"] as $columnHeader) {
echo(" <th>".$columnHeader."</th>".PHP_EOL);
}
echo(" </tr>".PHP_EOL);
foreach ($missionStatus["completed"] as $rows) {
echo(' <!-- Missions -->
<tr>
<td><pre>'.$rows["date"].'</pre></td>
<td><pre>'.$rows["acceptedByPro"].'</pre></td>
<td><pre>'.$rows["validatedByClient"].'</pre></td>
<td><pre>'.$rows["validatedByPro"].'</pre></td>
<td><pre>'.$rows["lastname"].'</pre></td>
<td><pre>'.$rows["jobCategoryId"][0]["jobCategoryName".ucwords($_SESSION["lang"])].'</pre></td>
<td><pre>'.$rows["subject"].'</pre></td>');
if ($rows["review"]) {
echo('<td><pre>'.$rows["review"].'</pre></td>');
} else {
echo('<td><pre>N/A</pre></td>');
}
if ($rows["note"]) {
echo('<td><pre>'.$rows["note"].'</pre></td>');
} else {
echo('<td><pre>N/A</pre></td>');
}
echo('</tr>'.PHP_EOL);
}
echo(' </table>
<!-- Espace vide si le tableau est petit -->
<div class="spacer"></div>');
// fin
echo(' </div>'.PHP_EOL);
?>
|