diff --git a/canapEPFL/helpers.php b/canapEPFL/helpers.php index 33d5dc5959a7fffa134543fe8617b35dafb5468b..730d6249b8e425ba23d63e6f1848e7c9c7808bb9 100644 --- a/canapEPFL/helpers.php +++ b/canapEPFL/helpers.php @@ -424,7 +424,28 @@ function updatePostulation ($pdo, $posted_data) { $query->bindParam(':responsible_phone', $sec_rep['telephone'], PDO::PARAM_STR); $query->execute(); } - // TODO: si nouveau, insert + + // Si majeur, delete les valeurs + // if ($posted_data->majeur == 1) { + // echo $main_rep['id']; + // if ($main_rep['id'] != '') { + // $sqlreq = "DELETE FROM responsible WHERE responsible_id=:id"; + // $query = $pdo->prepare($sqlreq); + // $query->bindParam(':id1', $main_rep['id'], PDO::PARAM_STR); + // $query->execute(); + // } + // if ($sec_rep['id'] != '') { + // $sqlreq = "DELETE FROM responsible WHERE responsible_id=:id"; + // $query = $pdo->prepare($sqlreq); + // $query->bindParam(':id', $sec_rep['id'], PDO::PARAM_STR); + // $query->execute(); + // } + // } + + // Si nouveau, insert + if ($main_rep['id'] == '' || $sec_rep['id'] == '') { + insertResponsibles($pdo, [$main_rep, $sec_rep], $posted_data->id); + } // update scolarities $to_add = []; diff --git a/canapEPFL/script.js b/canapEPFL/script.js index a32f45d63dc9b5a06544ec3b66421dbd6f3abda6..e187c37ebc20672efb04bb84c3deb58001e398c9 100644 --- a/canapEPFL/script.js +++ b/canapEPFL/script.js @@ -8,6 +8,7 @@ $(document).ready(function () { initDateChecker(); initDatepicker(); checkRequired(); + toggleTableHeaders(); } else if (location.pathname.split("/").slice(-1)[0] == "form.php") { initJobChange(); @@ -61,6 +62,9 @@ function addChildren(parentId, maxItems, childTemplate, addButtonId) { $(addButtonId).hide(); } } + if (location.search == "?edit") { + toggleTableHeaders(); + } } function changeTitleFile(objFile) { @@ -166,6 +170,19 @@ function initAddChildButtons() { }); } +function toggleTableHeaders() { + if ($('#activites')[0].rows.length == 1) { + $($('#activites')[0].rows[0]).hide(); + } else { + $($('#activites')[0].rows[0]).show(); + } + if ($('#stages')[0].rows.length == 1) { + $($('#stages')[0].rows[0]).hide(); + } else { + $($('#stages')[0].rows[0]).show(); + } +} + function setMajState() { $('#maj1')[0].checked ? $("#representants").show() : $("#representants").hide(); } diff --git a/canapEPFL/templates/head.php b/canapEPFL/templates/head.php index 1169763e9f74a6e079bc1f4715b99e895e93022a..1639fee1e890710af5bd45e719291deb740c5fa5 100644 --- a/canapEPFL/templates/head.php +++ b/canapEPFL/templates/head.php @@ -23,8 +23,8 @@ <?php ini_set("display_errors", 0); error_reporting(0); - ini_set("display_errors", 1); - error_reporting(E_ALL); + // ini_set("display_errors", 1); + // error_reporting(E_ALL); require_once('configs/config.php'); require('configs/db.php'); if (!isset($_SESSION)) { session_start(); }