From 82d6d693a914ad4fee8d02635dd746f6135fa082 Mon Sep 17 00:00:00 2001
From: nicrausaz <n.crausaz99@gmail.com>
Date: Wed, 28 Nov 2018 15:10:13 +0100
Subject: [PATCH] config file improove

---
 canapEPFL/README.md                           |  1 +
 canapEPFL/cible.php                           |  9 +++--
 canapEPFL/configs/config.php                  |  9 +++--
 canapEPFL/configs/db.template.php             |  1 +
 canapEPFL/models/PersonnalData.php            |  5 ++-
 .../viewPostulationTables/filesTables.php     | 37 ++++++++-----------
 6 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/canapEPFL/README.md b/canapEPFL/README.md
index 6294c94..960ac04 100644
--- a/canapEPFL/README.md
+++ b/canapEPFL/README.md
@@ -1,6 +1,7 @@
 # Améliorations en cours
 - [x] Utiliser la nouvelle charte 2018
 - [ ] Adapter pour ajouter les postulations dans une DB
+- [x] Ajouter une page pour voir / supprimer sa / ses postulation(s)
 - [ ] Commentaires et section du code
 
 # Améliorations possibles du formulaire canap.epfl.ch
diff --git a/canapEPFL/cible.php b/canapEPFL/cible.php
index 34a2064..bd487fc 100644
--- a/canapEPFL/cible.php
+++ b/canapEPFL/cible.php
@@ -13,7 +13,7 @@
     <?php
       include('templates/header.php');
       // Init personnalData with postedData
-      $candidateData = new PersonnalData($_POST, $_FILES);
+      $candidateData = new PersonnalData($_POST, $_FILES, $FILESERVERPATH);
       // Init dataValidator
       $validator = new PersonnalDataValidator($candidateData);
 
@@ -25,9 +25,10 @@
         $candidateData = uploadAllFiles($filesPath, $candidateData->fichiers, $candidateData);
         insertFiles($pdo, $candidateData->fichiers, $candidateId, $candidateData->rootpath);
 
-        // mailToResp($candidateData->prenomApprenti, $candidateData->nomApprenti, $candidateData->formation);
-        // mailToApprenti($candidateData->mailApprenti, $candidateData->formation);
-
+        if ($SENDEMAILS) {
+          mailToResp($candidateData->prenomApprenti, $candidateData->nomApprenti, $candidateData->formation);
+          mailToApprenti($candidateData->mailApprenti, $candidateData->formation);
+        }
         // kill session
         $_SESSION['formError'] = false;
         // unset($_SESSION);
diff --git a/canapEPFL/configs/config.php b/canapEPFL/configs/config.php
index 6b37398..12c81bf 100644
--- a/canapEPFL/configs/config.php
+++ b/canapEPFL/configs/config.php
@@ -1,8 +1,6 @@
 <?php
     if(count(get_included_files()) == 1) exit("Direct access not permitted.");
 
-    // by default, labo can't apply by this formular, in case, add some of these these values in the array:
-
     /*
     -- DO NOT DELETE --
 
@@ -45,8 +43,11 @@
         "neSaisPas" => "Pas de filière préférée"
     ];
 
-    // ajouter le chemin des fichiers
-    // ajouter envois de mail actif / inactif
+    // default: \\\\scxdata\\apprentis$\\candidatures\\
+    $FILESERVERPATH = 'D:/formdata/';
+
+    // Mettre a false pour pas spammer pendant le dev
+    $SENDEMAILS = false;
 
     $POSTULATION_OPEN = true; // close/open postulation
 
diff --git a/canapEPFL/configs/db.template.php b/canapEPFL/configs/db.template.php
index 710498f..f5a297d 100644
--- a/canapEPFL/configs/db.template.php
+++ b/canapEPFL/configs/db.template.php
@@ -1,4 +1,5 @@
 <?php
+  /* template pour la connection DB, renommer en db.php */
   $db_user = '';
   $db_pass = '';
   $pdo = new PDO('mysql:host=localhost;dbname=canap_dev', $db_user, $db_pass);
diff --git a/canapEPFL/models/PersonnalData.php b/canapEPFL/models/PersonnalData.php
index 7e34660..f9cec7b 100644
--- a/canapEPFL/models/PersonnalData.php
+++ b/canapEPFL/models/PersonnalData.php
@@ -17,7 +17,7 @@ class PersonnalData {
     "interactiveMediaDesigner" => "InteractiveMediaDesigners"
     );
     private $dateNow;
-    public $rootpath = 'D:/formdata/'; // \\\\scxdata\\apprentis$\\candidatures\\nouvelles\\
+    public $rootpath = '';
     public $guest_sciper = "";
     public $formation = "";
     public $lieu = "";
@@ -48,7 +48,8 @@ class PersonnalData {
     public $datePostulation = "";
     public $fichiers = [];
 
-    public function __construct($postedData, $postedFiles) {
+    public function __construct($postedData, $postedFiles, $FILESERVERPATH) {
+        $this->rootpath = $FILESERVERPATH;
         $this->dateNow = date('Y-m-d_H-i-s');
         // Rempli les infos
         $this->postedData = $postedData;
diff --git a/canapEPFL/templates/viewPostulationTables/filesTables.php b/canapEPFL/templates/viewPostulationTables/filesTables.php
index 2ac8510..28db54c 100644
--- a/canapEPFL/templates/viewPostulationTables/filesTables.php
+++ b/canapEPFL/templates/viewPostulationTables/filesTables.php
@@ -1,29 +1,24 @@
 <?php
   $files = getFilesById($pdo, $postulation['applicant_id']);
 ?>
-
 <button class="collapse-title collapse-title-desktop collapsed" type="button" data-toggle="collapse" data-target="#collapse-files" aria-expanded="true" aria-controls="collapse-files">
   Annexes
 </button>
 <div class="collapse collapse-item collapse-item-desktop" id="collapse-files">
-  <?php foreach ($files as $file) { ?>
-    <table class="table table-boxed mb-5">
-      <thead>
-        <tr>
-          <th>Fichier</th>
-          <th>Données</th>
-        </tr>
-      </thead>
-      <tbody>
-        <tr>
-          <td>Nom</td>
-          <td>Nom</td>
-        </tr>
-        <tr>
-          <td>Entreprise</td>
-          <td><a href="/getFile?id=<?= $file['file_id']?>"><?= $file['file_name'] ?></a></td>
-        </tr>
-      </tbody>
-    </table>
-  <?php } ?>
+  <table class="table table-boxed mb-5">
+    <thead>
+      <tr>
+        <th>Fichier</th>
+        <th>Données</th>
+      </tr>
+    </thead>
+    <tbody>
+      <?php foreach ($files as $file) { ?>
+      <tr>
+      <td>Nom</td>
+        <td><a href="/getFile?id=<?= $file['file_id']?>"><?= $file['file_name'] ?></a></td>
+      </tr>
+      <?php } ?>
+    </tbody>
+  </table>
 </div>
-- 
GitLab