From e7a8123d7dece82e214db8b300f7de9e8d4e9230 Mon Sep 17 00:00:00 2001
From: nicrausaz <n.crausaz99@gmail.com>
Date: Thu, 28 Feb 2019 14:22:25 +0100
Subject: [PATCH] update school & pro

---
 canapEPFL/form.php                            |  3 --
 canapEPFL/script.js                           |  3 ++
 .../formParts/edit/proactivities.php          | 28 +++++++++++++++
 .../templates/formParts/edit/scolarity.php    | 35 +++++++++++++++++++
 4 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/canapEPFL/form.php b/canapEPFL/form.php
index f4ca3f1..04e05ef 100644
--- a/canapEPFL/form.php
+++ b/canapEPFL/form.php
@@ -27,9 +27,6 @@
         echo "editing applicant" . $_SESSION['current_post']['applicant_id'];
         $current_post = $_SESSION['current_post'];
         echo $current_post['applicant_guest_sciper'];
-        echo "<pre>";
-        print_r($current_post);
-        echo "</pre>";
       }
     ?>
     <main id="main" role="main" class="content container-grid">
diff --git a/canapEPFL/script.js b/canapEPFL/script.js
index 3cf0c94..598ffaa 100644
--- a/canapEPFL/script.js
+++ b/canapEPFL/script.js
@@ -3,6 +3,9 @@ $(document).ready(function () {
     if (location.search == "?edit") {
         // showPolyAndInfoDivs();
         $("#all").show();
+        initButtonsAction();
+        initAddChildButtons();
+        checkRequired();
     }
     else if (location.pathname.split("/").slice(-1)[0] == "form.php") {
         initJobChange();
diff --git a/canapEPFL/templates/formParts/edit/proactivities.php b/canapEPFL/templates/formParts/edit/proactivities.php
index e69de29..5d22c4b 100644
--- a/canapEPFL/templates/formParts/edit/proactivities.php
+++ b/canapEPFL/templates/formParts/edit/proactivities.php
@@ -0,0 +1,28 @@
+<?php
+  $proactivities = getProActivitiesById($pdo, $current_post['applicant_id']);
+?>
+<table id="activites">
+  <tr>
+    <th>Employeur</th>
+    <th>Lieu</th>
+    <th>Activité</th>
+    <th>Années</th>
+  </tr>
+  <?php foreach ($proactivities as $key => $activity) { $i = $key + 1; ?>
+  <tr>
+    <td>
+      <input type="text" name="employeurPro<?= $i ?>" placeholder="Employeur" class="form-control" value="<?php echo $activity['professional_activity_company'] != '' ? $activity['professional_activity_company'] : ''; ?>" data-required/>
+    </td>
+    <td>
+      <input type="text" name="lieuPro<?= $i ?>" placeholder="Lieu" class="form-control" value="<?php echo $activity['professional_activity_location'] != '' ? $activity['professional_activity_location'] : ''; ?>" data-required/>
+    </td>
+    <td>
+      <input type="text" name="activitePro<?= $i ?>" placeholder="Activité" class="form-control" value="<?php echo $activity['professional_activity_activity'] != '' ? $activity['professional_activity_activity'] : ''; ?>" data-required/>
+    </td>
+    <td>
+      <input type="text" name="anneesPro<?= $i ?>" placeholder="de-à (années)" class="form-control" value="<?php echo $activity['professional_activity_years'] != '' ? $activity['professional_activity_years'] : ''; ?>" data-required/>
+    </td>
+  </tr>
+  <?php } ?>
+</table>
+<button type="button" class="btn btn-primary btn-sm mt-3 mb-2" id="addPro">Ajouter une ligne</button>
\ No newline at end of file
diff --git a/canapEPFL/templates/formParts/edit/scolarity.php b/canapEPFL/templates/formParts/edit/scolarity.php
index e69de29..0f26afc 100644
--- a/canapEPFL/templates/formParts/edit/scolarity.php
+++ b/canapEPFL/templates/formParts/edit/scolarity.php
@@ -0,0 +1,35 @@
+<?php
+  $scolarites = getScolaritiesById($pdo, $current_post['applicant_id']);
+?>
+<table id="scolaire">
+  <tr>
+    <th>Ecole</th>
+    <th>Lieu</th>
+    <th>Niveau</th>
+    <th>Années</th>
+  </tr>
+<?php foreach ($scolarites as $key => $scolarity) { $i = $key + 1; ?>
+  <tr>
+    <td>
+      <input type="text" name="ecole<?= $i ?>" placeholder="Ecole *" class="form-control" value="<?php echo $scolarity['scolarity_school'] != '' ? $scolarity['scolarity_school'] : ''; ?>" data-required/>
+    </td>
+    <td>
+      <input type="text" name="lieuEcole<?= $i ?>" placeholder="Lieu *" class="form-control" value="<?php echo $scolarity['scolarity_location'] != '' ? $scolarity['scolarity_location'] : ''; ?>" data-required/>
+    </td>
+    <td>
+      <input type="text" name="niveauEcole<?= $i ?>" placeholder="Niveau *" class="form-control" value="<?php echo $scolarity['scolarity_level'] != '' ? $scolarity['scolarity_level'] : ''; ?>" data-required/>
+    </td>
+    <td>
+      <input type="text" name="anneesEcole<?= $i ?>" placeholder="de-à (années) *" class="form-control" value="<?php echo $scolarity['scolarity_years'] != '' ? $scolarity['scolarity_years'] : ''; ?>" data-required/>
+    </td>
+  </tr>
+  <?php } ?>
+</table>
+<!-- TODO: check ça passe de 3 a 5 -->
+<button type="button" class="btn btn-primary btn-sm mt-3 mb-2" id="addSch">Ajouter une ligne</button>
+
+<div class="form-group mt-3">
+  <label for="anneeFin">Année de fin de scolarité*</label>
+  <input type="text" name="anneeFin" id="anneeFin" class="form-control" placeholder="Année de fin de scolarité" value="<?php echo $current_post['applicant_scolarity_end'] != '' ? $current_post['applicant_scolarity_end'] : ''; ?>" maxlength="4" data-required/>
+  <small id="anneeFinError" class="error form-text text-muted"></small>
+</div>
\ No newline at end of file
-- 
GitLab