summaryrefslogtreecommitdiff
path: root/Views/Includes/incl_form_admin.php
blob: 6176bc4be11cc659f046d5b695f25d422113cbbd (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
<?php
// ****************************************************************************
// Description: Récupération de tous les utilisateurs 
//              pour choix d'une suppression par son ID de table.
// ****************************************************************************
// Import du texte 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_dbadmin.php");
require_once(dirname( __FILE__ )."/../../Database/meth_dbsearch.php");

// Instanciation de la bdd avec les méthodes de recherche.
$dbadmin = new DbAdmin;
$dbsearch = new DbSearch;
// Form pour ajout d'une catégorie d'emploi
echo('        <!-- Separateur -->
        <div class="separator"></div>
        <!-- Form pour ajout d une catégorie d emploi -->
        <div id="admin">
            <h2>'.$text[basename(__FILE__, ".php")]["h2Job"].'</h2>
            <form class="flex-center" action="../../Wrapper/wrapper.php" method="post">
                <label class="width-auto">
                    <i class="fas fa-briefcase"></i>
                    <input type="text" name="addCategoryNameEn" maxlength="128" placeholder="'.$text[basename(__FILE__, ".php")]["formJobAddEn"].'" required>
                    <i class="fas fa-briefcase" style="margin-left: 5%;"></i>
                    <input type="text" name="addCategoryNameFr" maxlength="128" placeholder="'.$text[basename(__FILE__, ".php")]["formJobAddFr"].'" required>
                </label>
                <input type="submit" value="'.$text[basename(__FILE__, ".php")]["submitJobAdd"].'">
            </form>
            <!-- Form pour suppression d une catégorie d emploi -->
            <form class="flex-center" action="/../Wrapper/wrapper.php" method="post">
                <label>
                    <select name="delCategoryId" required>
                        <option value="" selected>'.$text[basename(__FILE__, ".php")]["selJobDel"].'</option>'.PHP_EOL);

$result = $dbsearch->get_job_category_all();
for ($i = 0; $i < count($result); $i++){
    echo('                        <option value="'.$result[$i]["jobCategoryId"].'">'.$result[$i]["jobCategoryName".ucwords($_SESSION["lang"])].'</option>'.PHP_EOL);
}

echo('                    </select>
                </label>
                <input type="submit" value="'.$text[basename(__FILE__, ".php")]["submitJobDel"].'">
            </form>'.PHP_EOL);

// Form pour la suppression et envoie au wrappeur.
echo('          <!-- Form pour choix de la suppression -->
            <h2>'.$text[basename(__FILE__, ".php")]["h2Del"].'</h2>
            <form class="flex-center" action="../../Wrapper/wrapper.php" method="post">
                <label class="width-auto">
                    <i class="fas fa-trash-alt"></i>
                    <input type="text" name="userId" maxlength="10" placeholder="'.$text[basename(__FILE__, ".php")]["formDel"].'" required>
                </label>
                <input type="submit" value="'.$text[basename(__FILE__, ".php")]["submitDel"].'">
            </form>'.PHP_EOL);

// Récupération de tous les utilisateurs.
$result = $dbadmin->get_all_users_account();
// Affichage de la table.
echo("        <!-- Tableau des utilisateurs-->
        <table>
            <!-- En-tête -->
            <tr>".PHP_EOL);
// Affichage des en-tête de colonne.
foreach($header["adminDel"] as $header) {
    echo("                <th>".$header."</th>".PHP_EOL);
}
echo("            </tr>".PHP_EOL);
// Affichage du résultat de la recherche.
foreach ($result as $rows) {
    echo("            <!-- Utilisateurs -->
            <tr>".PHP_EOL);
    foreach ($rows as $key => $value) {
        switch ($key) {
            case "userStatus":
                switch ($value) {
                    case 0:
                        echo("                <td><pre>Admin<pre></td>".PHP_EOL);
                        break;
                    case 1:
                        echo("                <td><pre>Pro<pre></td>".PHP_EOL);
                        break;
                    case 2:
                        echo("                <td><pre>Client<pre></td>".PHP_EOL);
                        break;
                }
                break;
            default:
                echo("                <td><pre>".$value."</pre></td>".PHP_EOL);
                break;
        }
    }
    echo("            </tr>".PHP_EOL);
}
echo('        </table>
        <!-- Espace vide si le tableau est petit -->
        <div class="spacer"></div>
        </div>'.PHP_EOL);

?>