summaryrefslogtreecommitdiff
path: root/Views/Includes/incl_index_search.php
blob: ac107b7c83357a8c6a3427710e2e77f089675a8d (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
<?php
// ****************************************************************************
// Description: Partie recherche de l'index.
// ****************************************************************************
// 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êtes des tables.
require_once(dirname( __FILE__ )."/".$_SESSION["lang"]."/table.php");
// Separateur.
echo('        <!-- Separateur -->
        <div id="separator2" class="separator"></div>
        <div id="search">'.PHP_EOL);
// Form pour la recherche par nom et envoi au wrappeur.
echo('            <!-- Form de recherche -->
            <h2>'.$text[basename(__FILE__, ".php")]["h2"].'</h2>
            <form action="/Wrapper/wrapper.php" method="post">
                <label>
                    <i class="fas fa-search"></i>
                    <input type="search" name="search" id="searchBar"placeholder="'.$text[basename(__FILE__, ".php")]["searchBar"].'" required>
                </label>
                <input type="submit" value="'.$text[basename(__FILE__, ".php")]["submit"].'">
            </form>'.PHP_EOL);
// Si l'index est chargé avec des données dans la variable "search" de la session,
// c'est qu'une recherche à été effectuée, on affiche alors le contenu de cette recherche en tableau.
if (isset($_SESSION["search"])) {
    echo("<table>");
    // Si la variable isResearch est vrai, c'est une rechreche.
    if ($_SESSION["search"]["isResearch"]) {
        echo("<tr>");
        for ($i = 0; $i < count($header["search"]); $i++) {
            echo("<th><pre>".$header["search"][$i]."</pre></th>");
        }
        echo("</tr>");
        foreach ($_SESSION["search"]["result"] as $result) {
            echo("<tr>");
            echo("<td><pre>".$result["lastname"]."</pre></td>");
            echo("<td><pre>".$result["firstname"]."</pre></td>");
            // jobs
            if (count($result["jobs"]) > 0) {
                $jobsName = array();
                for ($i = 0; $i < count($result["jobs"]); $i++) {
                    array_push($jobsName, $result["jobs"][$i]["jobCategoryName".ucwords($_SESSION["lang"])]);
                }
                echo("<td><pre>".join(", ", $jobsName)."</pre></td>");
            } else {
                echo('<td>N/A</td>');
            }
            echo("<td><pre>".$result["capability"]."</pre></td>");
            echo("<td><pre>".$result["numberOfMissions"]."</pre></td>");
            echo("<td><pre>".$result["note"]."</pre></td>");
            // I'm a star !!
            if ($result["star"]) {
                echo('<td>');
                $missingStar = 5 - $result["star"];
                for ($i = 0; $i < $result["star"]; $i++) {
                    echo('<i class="fa fa-star star checked"></i>');
                }
                if ($missingStar) {
                    for ($i = 0; $i < $missingStar; $i++) {
                        echo('<i class="fa fa-star star unchecked"></i>');
                    }
                }
                echo("</td>");
            } else {
                echo('<td>N/A</td>');
            }
            // Si c'est une recherche on ajoute le bouton plus d'info,
            // pour plus d'info avec une recherche par Id.
            echo('<td class="noBorder" >
                <form action="/Wrapper/wrapper.php" method="post">
                <input type="hidden" name="moreInfoProId" value="'.$result["userId"].'">
                <input type="submit" value="'.$text[basename(__FILE__, ".php")]["moreInfo"].'">
                </form>
            </td>');
            echo("</tr>");
        }
        echo("</table>");
    // Sinon c'est un "Plus d'info".
    } else {
        echo("<tr>");
        for ($i = 0; $i < count($header["moreInfos"]); $i++) {
            echo("<th><pre>".$header["moreInfos"][$i]."</pre></th>");
        }
        echo('</tr>
            <tr>
            <td><pre>'.$_SESSION["search"]["result"][0]["lastname"].'</pre></td>
            <td><pre>'.$_SESSION["search"]["result"][0]["firstname"].'</pre></td>');
        // jobs
        if (count($_SESSION["search"]["result"][0]["jobs"]) > 0) {
            $jobsName = array();
            for ($i = 0; $i < count($_SESSION["search"]["result"][0]["jobs"]); $i++) {
                array_push($jobsName, $_SESSION["search"]["result"][0]["jobs"][$i]["jobCategoryName".ucwords($_SESSION["lang"])]);
            }
            echo("<td><pre>".join(", ", $jobsName)."</pre></td>");
        } else {
            echo('<td>N/A</td>');
        }
        echo('  <td><pre>'.$_SESSION["search"]["result"][0]["degree"].'</pre></td>
                <td><pre>'.$_SESSION["search"]["result"][0]["capability"].'</pre></td>
                <td><pre>'.$_SESSION["search"]["result"][0]["description"].'</pre></td>
                <td><pre>'.$_SESSION["search"]["result"][0]["phoneNumber"].'</pre></td>
                <td><pre>'.$_SESSION["search"]["result"][0]["adress"].'</pre></td>
                <td><pre>'.$_SESSION["search"]["result"][0]["zipCode"].'</pre></td>
                <td><pre>'.$_SESSION["search"]["result"][0]["city"].'</pre></td>
            </tr>
        </table>
        <form action="/Wrapper/wrapper.php" method="post">
            <input type="hidden" name="mandateProId" value="'.$_SESSION["search"]["result"][0]["userId"].'">
            <input type="submit" value="'.$text[basename(__FILE__, ".php")]["mandate"].'">
        </form>');
    }
}
echo('            <!-- Espace vide si le tableau est petit -->
            <div class="spacer"></div>
        </div>');
// On supprime la variable de recherche si elle existe.
unset($_SESSION["search"]);
?>