summaryrefslogtreecommitdiff
path: root/Template/Include/incl_index_search.php
blob: f285c2e2a24bd17c7668c47642bd1d461ba9c69c (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
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
<?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");
require_once(dirname( __FILE__ )."./../../Database/meth_dbsearch.php");

$dbsearch = new DbSearch;

// ****************************************************************************
// SEPARATEUR
// ****************************************************************************
echo('<!-- Separateur -->
<div id="separator2" class="separator"></div>'.PHP_EOL);

// ****************************************************************************
// DIV PRINCIPALE
// ****************************************************************************
echo('<!-- Division principale -->
<main id="mainSearch">'.PHP_EOL);

// Form pour la recherche par nom ou type d'emploi et envoi au wrappeur.
echo('<!-- Form de recherche -->
<h2>'.$text[basename(__FILE__, ".php")]["h2"].'</h2>
<div id="divSearch">
    <div class="spacer"></div>
    <form action="/Core/wrapper.php" method="post">
        <label>
            <i class="fas fa-search"></i>
            <input type="text" name="searchByName" id="searchBar"placeholder="'.$text[basename(__FILE__, ".php")]["searchBarName"].'" required>
        </label>
        <input type="submit" value="'.$text[basename(__FILE__, ".php")]["submit"].'">
    </form>
    <p>'.$text[basename(__FILE__, ".php")]["or"].'</p>
    <form action="/Core/wrapper.php" method="post">
        <label>
            <i class="fas fa-search"></i>
            <select name="searchByJob" required>
                <option value="" selected>'.$text[basename(__FILE__, ".php")]["searchBarJob"].'</option>'.PHP_EOL);
$allJobs = $dbsearch->get_job_all();
for ($i = 0; $i < count($allJobs); $i++){
    echo('                <option value="'.$allJobs[$i]["jobCategoryId"].'">'.$allJobs[$i]["jobCategoryName".ucwords($_SESSION["lang"])].'</option>'.PHP_EOL);
}
echo('            </select>
        </label>
        <input type="submit" value="'.$text[basename(__FILE__, ".php")]["submit"].'">
    </form>
    <div class="spacer"></div>
</div>'.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"])) {
    // Si la variable isResearch est vrai, c'est une rechreche.
    if ($_SESSION["search"]["isResearch"]) {
        if ($_SESSION["search"]["result"]) {
            echo('<table>');
            echo('<thead>');
            echo('<tr>');
            for ($i = 0; $i < count($header["search"]); $i++) {
                switch ($i) {
                    case 1:
                    case 3:
                    case 4:
                    case 5:
                        echo('<th class="extend"><pre>'.$header["search"][$i].'</pre></th>');
                        break;
                    default:
                        echo('<th><pre>'.$header["search"][$i].'</pre></th>');
                        break;
                }
            }
            echo('</tr>');
            echo('</thead>');
            foreach ($_SESSION["search"]["result"] as $result) {
                echo('<tbody>');
                echo('<tr>');
                echo('<td><pre>'.$result["lastname"].'</pre></td>');
                echo('<td class="extend"><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 class="extend"><pre>'.$result["capability"].'</pre></td>');
                echo('<td class="extend"><pre>'.$result["numberOfMissions"].'</pre></td>');
                echo('<td class="extend"><pre>'.$result["note"].'</pre></td>');
                // I'm a star !!
                if ($result["star"]) {
                    echo('<td><pre>');
                    $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('</pre></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="/Core/wrapper.php" method="post">
                            <input type="hidden" name="moreInfoProId" value="'.$result["userId"].'">
                            <input type="submit" value="'.$text[basename(__FILE__, ".php")]["moreInfo"].'">
                        </form>
                    </td>
                </tr>');
            }
            echo('</tbody>
                </table>');
        } else {
            echo('<p>'.$text[basename(__FILE__, ".php")]["noResult"].'</p>');
        }

    // Sinon c'est un "Plus d'info".
    } else {
        echo('<table>
              <tbody>
                  <tr>
                      <th><pre>'.$header["moreInfos"][0].'</pre></th>
                      <td><pre>'.$_SESSION["search"]["result"][0]["lastname"].'</pre></td>
                  </tr>
                  <tr>
                      <th><pre>'.$header["moreInfos"][1].'</pre></th>
                      <td><pre>'.$_SESSION["search"]["result"][0]["firstname"].'</pre></td>
                  </tr>');
        // 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('<tr>
                    <th><pre>'.$header["moreInfos"][2].'</pre></th>
                    <td><pre>'.join(", ", $jobsName).'</pre></td>
                </tr>');
        } else {
            echo('<tr>
                    <th><pre>'.$header["moreInfos"][2].'</pre></th>
                    <td>N/A</td>
                </tr>');
        }
        echo('<tr>
                  <th><pre>'.$header["moreInfos"][3].'</pre></th>
                  <td><pre>'.$_SESSION["search"]["result"][0]["degree"].'</pre></td>
              </tr>
              <tr>
                  <th><pre>'.$header["moreInfos"][4].'</pre></th>
                  <td><pre>'.$_SESSION["search"]["result"][0]["capability"].'</pre></td>
              </tr>
              <tr>
                  <th><pre>'.$header["moreInfos"][5].'</pre></th>
                  <td><pre>'.$_SESSION["search"]["result"][0]["description"].'</pre></td>
              </tr>
              <tr>
                  <th><pre>'.$header["moreInfos"][6].'</pre></th>
                  <td><pre>'.$_SESSION["search"]["result"][0]["phoneNumber"].'</pre></td>
              </tr>
              <tr>
                  <th><pre>'.$header["moreInfos"][7].'</pre></th>
                  <td><pre>'.$_SESSION["search"]["result"][0]["adress"].'</pre></td>
              </tr>
              <tr>
                  <th><pre>'.$header["moreInfos"][8].'</pre></th>
                  <td><pre>'.$_SESSION["search"]["result"][0]["zipCode"].'</pre></td>
              </tr>
              <tr>
                  <th><pre>'.$header["moreInfos"][9].'</pre></th>
                  <td><pre>'.$_SESSION["search"]["result"][0]["city"].'</pre></td>
              </tr>
              </tr>
           </tbody>
        </table>
        <form id="formMandate" action="/Core/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>');

// ****************************************************************************
// FIN DIV PRINCIPALE
// ****************************************************************************
echo('</main>');

// On supprime la variable de recherche si elle existe.
unset($_SESSION["search"]);

?>