summaryrefslogtreecommitdiff
path: root/Template/Include/incl_table_myMission.php
diff options
context:
space:
mode:
Diffstat (limited to 'Template/Include/incl_table_myMission.php')
-rw-r--r--Template/Include/incl_table_myMission.php202
1 files changed, 202 insertions, 0 deletions
diff --git a/Template/Include/incl_table_myMission.php b/Template/Include/incl_table_myMission.php
new file mode 100644
index 0000000..504abac
--- /dev/null
+++ b/Template/Include/incl_table_myMission.php
@@ -0,0 +1,202 @@
+<?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]);
+ }
+}
+
+// ****************************************************************************
+// DIV PRINCIPALE
+// ****************************************************************************
+echo('<!-- Mes missions -->
+<main id="mainMyMission">');
+
+// ****************************************************************************
+// BOUTTONS DE NAVIGATION
+// ****************************************************************************
+echo('<div id="myMissionButtons">
+ <button onclick="show(\'mainMyMission\', \'section\', \'secPending\', \'show_block\')">'.$text[basename(__FILE__, ".php")]["pendingMission"].'</button>
+ <button onclick="show(\'mainMyMission\', \'section\', \'secOngoing\', \'show_block\')">'.$text[basename(__FILE__, ".php")]["ongoingMission"].'</button>
+ <button onclick="show(\'mainMyMission\', \'section\', \'secCompleted\',\'show_block\')">'.$text[basename(__FILE__, ".php")]["completedMission"].'</button>
+</div>'.PHP_EOL);
+
+// ****************************************************************************
+// TABLEAU DES MISSIONS EN ATTENTE
+// ****************************************************************************
+if ($missionStatus["pending"]) {
+ echo('<section id="secPending">
+ <table>
+ <!-- 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="/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>
+ </section>');
+} else {
+ echo('<section id="secPending">
+ <p>'.$text[basename(__FILE__, ".php")]["noPending"].'</p>
+ </section>');
+}
+
+// ****************************************************************************
+// TABLEAU DES MISSIONS EN COURS
+// ****************************************************************************
+if ($missionStatus["ongoing"]) {
+ echo('<section id="secOngoing">
+ <table>
+ <!-- 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="/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>
+ </section>');
+} else {
+ echo('<section id="secOngoing">
+ <p>'.$text[basename(__FILE__, ".php")]["noOngoing"].'</p>
+ </section>');
+}
+
+// ****************************************************************************
+// TABLEAU DES MISSIONS TERMINEES
+// ****************************************************************************
+if ($missionStatus["completed"]) {
+ echo('<section id="secCompleted">
+ <table>
+ <!-- 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>
+ </section>');
+} else {
+ echo('<section id="secCompleted">
+ <p>'.$text[basename(__FILE__, ".php")]["noCompleted"].'</p>
+ </section>');
+}
+
+echo('<!-- Espace vide si le tableau est petit -->
+<div class="spacer"></div>');
+
+// ****************************************************************************
+// FIN DIV PRINCIPALE
+// ****************************************************************************
+echo('</main>'.PHP_EOL);
+
+?> \ No newline at end of file