diff options
Diffstat (limited to 'Templates/Includes/incl_table_myMission.php')
| -rw-r--r-- | Templates/Includes/incl_table_myMission.php | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/Templates/Includes/incl_table_myMission.php b/Templates/Includes/incl_table_myMission.php new file mode 100644 index 0000000..5e0a7a8 --- /dev/null +++ b/Templates/Includes/incl_table_myMission.php @@ -0,0 +1,183 @@ +<?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; +$missionStatus = [ + "pending" => [], + "ongoing" => [], + "completed" => [] +]; + +// Recherches des missions avec l'id de l'utilisateur actuellement connecté. +switch ($_SESSION["userStatus"]) { + case 1: + $result = $dbmission->get_mission_by_proid($_SESSION["userId"]); + for ($i = 0; $i < count($result); $i++) { + $result[$i]["jobCategoryId"] = $dbsearch->get_job_by_jobid($result[$i]["jobCategoryId"]); + } + break; + case 2: + $result = $dbmission->get_mission_by_clientid($_SESSION["userId"]); + for ($i = 0; $i < count($result); $i++) { + $result[$i]["jobCategoryId"] = $dbsearch->get_job_by_jobid($result[$i]["jobCategoryId"]); + } + break; + default: + break; +} + +// Puis on dispatch les missions dans leur categorie +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]); + } +} + +// **************************************************************************** +// SEPARATEUR +// **************************************************************************** +echo('<!-- Separateur --> +<div class="separator"></div>'); + +// **************************************************************************** +// DIV PRINCIPALE +// **************************************************************************** +echo('<!-- Mes missions --> +<main id="mainMyMission">'); + +// **************************************************************************** +// BOUTTONS DE NAVIGATION +// **************************************************************************** +echo(' <div id="missionButtons"> + <button onclick="show(\'mainMyMission\', \'table\', \'pendingTable\', \'show_table\')"><h2>'.$text[basename(__FILE__, ".php")]["pendingMission"].'</h2></button> + <button onclick="show(\'mainMyMission\', \'table\', \'ongoingTable\', \'show_table\')"><h2>'.$text[basename(__FILE__, ".php")]["ongoingMission"].'</h2></button> + <button onclick="show(\'mainMyMission\', \'table\', \'completedTable\', \'show_table\')"><h2>'.$text[basename(__FILE__, ".php")]["completedMission"].'</h2></button> + </div>'.PHP_EOL); + +// **************************************************************************** +// TABLEAU DES MISSIONS EN ATTENTE +// **************************************************************************** +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> + <form action="/Core/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 DES MISSIONS EN COURS +// **************************************************************************** +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> + <form action="/Core/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 DES MISSIONS TERMINEES +// **************************************************************************** +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 DIV PRINCIPALE +// **************************************************************************** +echo('</main>'.PHP_EOL); + +?>
\ No newline at end of file |
