From e25902faca378a529103a72170fc32f93d2f1bfe Mon Sep 17 00:00:00 2001 From: Evellyn Jade <97754536+evellynreis@users.noreply.github.com> Date: Tue, 20 Feb 2024 11:50:41 -0300 Subject: [PATCH 01/19] feat/implementing form --- app/controllers/AdminController.php | 15 +++++- js/admin/grades-structure.js | 22 +++++++++ .../default/views/admin/gradesStructure.php | 48 +++++++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php index 374bd4a6e..f918d21ec 100644 --- a/app/controllers/AdminController.php +++ b/app/controllers/AdminController.php @@ -129,7 +129,7 @@ public function actionCreateUser() if ($model->validate()) { $passwordHasher = new PasswordHasher; $password = $passwordHasher->bcriptHash($_POST['Users']['password']); - + $model->password = $password; // form inputs are valid, do something here if ($model->save()) { @@ -193,6 +193,18 @@ public function actionGetUnities() { $stage = Yii::app()->request->getPost("stage"); + $modality = Yii::app()->db->createCommand(" + select + distinct gu.name, + gu.id, + gu.edcenso_stage_vs_modality_fk + from grade_unity gu + join curricular_matrix cm on cm.stage_fk = gu.edcenso_stage_vs_modality_fk + where cm.school_year = :year and gu.edcenso_stage_vs_modality_fk = :stage_modality") + ->bindParam(":year", Yii::app()->user->year) + ->bindParam(":stage_modality", $stage) + ->queryAll(); + $result = []; $result["unities"] = []; @@ -241,6 +253,7 @@ public function actionGetUnities() $result["mediaCalculation"] = $gradeRules->grade_calculation_fk; $result["ruleType"] = $gradeRules->rule_type; $result["hasFinalRecovery"] = (bool) $gradeRules->has_final_recovery; + $result["modality"] = $modality; echo CJSON::encode($result); } diff --git a/js/admin/grades-structure.js b/js/admin/grades-structure.js index 077f5830d..a20eff85b 100644 --- a/js/admin/grades-structure.js +++ b/js/admin/grades-structure.js @@ -270,6 +270,24 @@ $(document).on("change", ".js-has-final-recovery", function (event) { } }); +$(document).on("change", ".js-has-semianual-unity", function (event) { + const isChecked = $(this).is(":checked"); + const isNew = $(".semianual-unity-id").val() === ""; + if (isChecked) { + $(".js-recovery-semianual-form").show(); + if (isNew) { + $(".semianual-unity-operation").val("create"); + } else { + $(".semianual-unity-operation").val("update"); + } + } else { + $(".js-recovery-semianual-form").hide(); + if (!isNew) { + $(".semianual-unity-operation").val("delete"); + } + } +}); + function initRuleType(ruleType) { if (ruleType === "C") { $(".numeric-fields").hide(); @@ -566,6 +584,10 @@ function loadStructure() { "val", data.final_recovery.grade_calculation_fk ); + $(".semianual-modality").select2( + "val", + data.final_recovery.name + ); $(".final-recover-media").val(data.finalRecoverMedia); if (data.hasFinalRecovery) { diff --git a/themes/default/views/admin/gradesStructure.php b/themes/default/views/admin/gradesStructure.php index 3dae3c27a..7dcd0d58e 100644 --- a/themes/default/views/admin/gradesStructure.php +++ b/themes/default/views/admin/gradesStructure.php @@ -92,6 +92,16 @@ +
+ 't-field-checkbox__input js-has-semianual-unity' + ) + ) ?> + 't-field-checkbox__label', 'id' => 'active-label')); ?> +
+
't-field-checkbox__input js-has-semianual-unity' From 71cdc502ae91bed0e3aac1c13004244281493119 Mon Sep 17 00:00:00 2001 From: Evellyn Jade <97754536+evellynreis@users.noreply.github.com> Date: Wed, 21 Feb 2024 12:29:23 -0300 Subject: [PATCH 03/19] feat/update options unities select --- js/admin/grades-structure.js | 17 +++++++++++++---- themes/default/views/admin/gradesStructure.php | 5 ----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/js/admin/grades-structure.js b/js/admin/grades-structure.js index b76a64bd3..0e3be2abb 100644 --- a/js/admin/grades-structure.js +++ b/js/admin/grades-structure.js @@ -586,10 +586,19 @@ function loadStructure() { "val", data.final_recovery.grade_calculation_fk ); - $(".semianual-modality").select2( - "val", - data.final_recovery.name - ); + + const dataUnities = data.unities.map(unity => [unity.id, unity.name]); + const selectUnities = $('.semianual-modality'); + + console.log(dataUnities); + + dataUnities.forEach(function([id, name]) { + selectUnities.append($('
From e3b42428796376d44dd04d6c9e04331153b059d1 Mon Sep 17 00:00:00 2001 From: Evellyn Jade <97754536+evellynreis@users.noreply.github.com> Date: Thu, 22 Feb 2024 11:56:55 -0300 Subject: [PATCH 04/19] feat/ add multiselect --- js/admin/grades-structure.js | 15 +++++++++++---- themes/default/views/admin/gradesStructure.php | 10 +++++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/js/admin/grades-structure.js b/js/admin/grades-structure.js index 0e3be2abb..1b5cbef3c 100644 --- a/js/admin/grades-structure.js +++ b/js/admin/grades-structure.js @@ -586,17 +586,24 @@ function loadStructure() { "val", data.final_recovery.grade_calculation_fk ); - + const dataUnities = data.unities.map(unity => [unity.id, unity.name]); - const selectUnities = $('.semianual-modality'); + const selectUnitiesFirst = $('#semianual-modality-first'); + const selectUnitiesSecond = $('#semianual-modality-second'); console.log(dataUnities); dataUnities.forEach(function([id, name]) { - selectUnities.append($('