From 2c6d8937f64eb322af4feaac831412b7f7f398d8 Mon Sep 17 00:00:00 2001 From: ma0048 Date: Wed, 12 May 2021 12:48:29 +0200 Subject: [PATCH 01/16] funktion hinzugefuegt um mehrere bewerber abzuweisen und status wird nur angezeigt wenn aktiv --- .../system/infocenter/InfoCenter.php | 56 ++++++++- application/models/crm/Prestudent_model.php | 13 +++ application/models/crm/Statusgrund_model.php | 13 +++ .../models/organisation/Studiengang_model.php | 13 +++ .../views/system/infocenter/infocenter.php | 1 + .../js/infocenter/infocenterPersonDataset.js | 107 ++++++++++++++++++ 6 files changed, 197 insertions(+), 6 deletions(-) diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index 43de8bb60..fd3f98320 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -108,7 +108,9 @@ class InfoCenter extends Auth_Controller 'setOnHold' => 'infocenter:rw', 'removeOnHold' => 'infocenter:rw', 'getStudienjahrEnd' => 'infocenter:r', - 'setNavigationMenuArrayJson' => 'infocenter:r' + 'setNavigationMenuArrayJson' => 'infocenter:r', + 'getAbsageData' => 'infocenter:r', + 'saveAbsageForAll' => 'infocenter:rw' ) ); @@ -433,11 +435,14 @@ class InfoCenter extends Auth_Controller * Saves Absage for Prestudent including the reason for the Absage (statusgrund). * inserts Studiensemester and Ausbildungssemester for the new Absage of (chronologically) last status. */ - public function saveAbsage() + public function saveAbsage($prestudent_id = null, $statusgrund = null) { $json = null; - $prestudent_id = $this->input->post('prestudent_id'); - $statusgrund = $this->input->post('statusgrund'); + if (is_null($prestudent_id)) + $prestudent_id = $this->input->post('prestudent_id'); + + if (is_null($statusgrund)) + $statusgrund = $this->input->post('statusgrund'); $lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent_id); @@ -1427,8 +1432,8 @@ class InfoCenter extends Auth_Controller $this->_sortPrestudents($zgvpruefungen); - $abwstatusgruende = $this->StatusgrundModel->loadWhere(array('status_kurzbz' => self::ABGEWIESENERSTATUS))->retval; - $intstatusgruende = $this->StatusgrundModel->loadWhere(array('status_kurzbz' => self::INTERESSENTSTATUS))->retval; + $abwstatusgruende = $this->StatusgrundModel->getStatus(self::ABGEWIESENERSTATUS, true)->retval; + $intstatusgruende = $this->StatusgrundModel->getStatus(self::INTERESSENTSTATUS)->retval; $data = array ( 'zgvpruefungen' => $zgvpruefungen, @@ -1687,4 +1692,43 @@ class InfoCenter extends Auth_Controller $this->loglib->logError('Studiengang has no mail for sending Freigabe mail'); } } + + public function getAbsageData() + { + $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + + $statusgruende = $this->StatusgrundModel->getStatus(self::ABGEWIESENERSTATUS, true)->retval; + $studiengaenge = $this->StudiengangModel->getStudiengaengeWithOrgForm(['b', 'm']); + + $data = array ( + 'statusgruende' => $statusgruende, + 'studiengaenge' => $studiengaenge->retval + ); + + $this->outputJsonSuccess($data); + } + + public function saveAbsageForAll() + { + $statusgrund = $this->input->post('statusgrund'); + $studiengang = $this->input->post('studiengang'); + $personen = $this->input->post('personen'); + + if ($statusgrund === 'null' || $studiengang === 'null' || empty($personen)) + $this->terminateWithJsonError("Bitte Statusgrund, Studiengang und Personen auswählen."); + + foreach($personen as $person) + { + $prestudent = $this->PrestudentModel->getPrestudentByStudiengangAndPerson($studiengang, $person); + + if(!hasData($prestudent)) + continue; + + $prestudentData = getData($prestudent); + + $this->saveAbsage($prestudentData[0]->prestudent_id, $statusgrund); + } + + $this->outputJsonSuccess("Success"); + } } diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index 2e014800c..41639d0ac 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -581,4 +581,17 @@ class Prestudent_model extends DB_Model return $this->execQuery($query, array($person_id)); } + + public function getPrestudentByStudiengangAndPerson($studiengang, $person) + { + $query = "SELECT ps.prestudent_id + FROM public.tbl_prestudentstatus pss + JOIN public.tbl_prestudent ps USING(prestudent_id) + JOIN public.tbl_studiengang sg USING(studiengang_kz) + JOIN lehre.tbl_studienplan sp USING(studienplan_id) + WHERE ps.person_id = ? + AND UPPER((sg.typ || sg.kurzbz) || ':' || sp.orgform_kurzbz) = ?"; + + return $this->execQuery($query, array($person, $studiengang)); + } } diff --git a/application/models/crm/Statusgrund_model.php b/application/models/crm/Statusgrund_model.php index 4717a7571..f9b156b76 100644 --- a/application/models/crm/Statusgrund_model.php +++ b/application/models/crm/Statusgrund_model.php @@ -11,4 +11,17 @@ class Statusgrund_model extends DB_Model $this->dbTable = "public.tbl_status_grund"; $this->pk = "statusgrund_id"; } + + public function getStatus($status_kurzbz = null, $aktiv = null) + { + $where = array(); + if (!is_null($status_kurzbz)) + $where['status_kurzbz'] = $status_kurzbz; + if (!is_null($aktiv)) + $where['aktiv'] = $aktiv; + + $status = $this->loadWhere($where); + + return success($status->retval); + } } diff --git a/application/models/organisation/Studiengang_model.php b/application/models/organisation/Studiengang_model.php index 8b8be0366..999fcbbd0 100644 --- a/application/models/organisation/Studiengang_model.php +++ b/application/models/organisation/Studiengang_model.php @@ -481,4 +481,17 @@ class Studiengang_model extends DB_Model return $this->loadWhere($condition); } + + public function getStudiengaengeWithOrgForm($typ) + { + $query = "SELECT DISTINCT (UPPER(sg.typ || sg.kurzbz || ':' || sp.orgform_kurzbz)) AS Studiengang + FROM public.tbl_prestudentstatus pss + JOIN public.tbl_prestudent ps USING(prestudent_id) + JOIN public.tbl_studiengang sg USING(studiengang_kz) + JOIN lehre.tbl_studienplan sp USING(studienplan_id) + WHERE sg.typ IN ? + ORDER BY Studiengang;"; + + return $this->execQuery($query, array($typ)); + } } diff --git a/application/views/system/infocenter/infocenter.php b/application/views/system/infocenter/infocenter.php index 4005518a1..43e326bb5 100644 --- a/application/views/system/infocenter/infocenter.php +++ b/application/views/system/infocenter/infocenter.php @@ -13,6 +13,7 @@ 'ajaxlib' => true, 'filterwidget' => true, 'navigationwidget' => true, + 'dialoglib' => true, 'phrases' => array( 'person' => array('vorname', 'nachname'), 'global' => array('mailAnXversandt'), diff --git a/public/js/infocenter/infocenterPersonDataset.js b/public/js/infocenter/infocenterPersonDataset.js index 87a40c0f1..7ea048b71 100644 --- a/public/js/infocenter/infocenterPersonDataset.js +++ b/public/js/infocenter/infocenterPersonDataset.js @@ -31,6 +31,20 @@ var InfocenterPersonDataset = { var formHtml = '
'; $("#datasetActionsTop").before(formHtml); + var auswahlAbsageToggle = + 'Erweiterte Einstellungen'; + + var auswahlAbsage = + '' + + '' + + ''; + + InfocenterPersonDataset.getAbsageData(); + var studienSemesterHtml = ' ' + @@ -60,6 +74,14 @@ var InfocenterPersonDataset = { "
"+studienSemesterHtml+"
"+ "

"); + $("#datasetActionsBottom").append( + "
"+ + "
"+auswahlAbsageToggle+"
"+ + ""+ + "
" + + "
" + + "
" + ) $("button.incStudiensemester").click(function() { InfocenterPersonDataset.changeStudiensemesterUservar(1); }); @@ -68,6 +90,16 @@ var InfocenterPersonDataset = { InfocenterPersonDataset.changeStudiensemesterUservar(-1); }); + $('button.auswahlAbsageBtn').click(function() + { + InfocenterPersonDataset.saveAbsageForAll(); + }); + + $('a.absageToggle').click(function() + { + $('#absagePunkte').toggle(); + }) + var personcount = 0; FHC_AjaxClient.ajaxCallGet( @@ -203,6 +235,81 @@ var InfocenterPersonDataset = { ); }, + saveAbsageForAll: function() + { + var idsel = $("#filterTableDataset input:checked[name=PersonId\\[\\]]"); + + if(idsel.length <= 0) + return FHC_DialogLib.alertInfo("Bitte wählen Sie die Personen aus."); + + var statusgrund = $('.absgstatusgrund').val(); + var studiengang = $('.auswahlAbsageStg').val(); + + if(statusgrund === 'null' || studiengang === 'null') + return FHC_DialogLib.alertInfo("Bitte den Absagegrund und Studiengang auswählen."); + + var personen = []; + + for (var i = 0; i < idsel.length; i++) + { + personen.push($(idsel[i]).val()); + } + + FHC_AjaxClient.ajaxCallPost( + 'system/infocenter/InfoCenter/saveAbsageForAll', + { + 'statusgrund': statusgrund, + 'studiengang': studiengang, + 'personen' : personen + }, + { + successCallback: function(data, textStatus, jqXHR) { + if (FHC_AjaxClient.isError(data)) + FHC_DialogLib.alertError(FHC_AjaxClient.getError(data)); + + if (FHC_AjaxClient.hasData(data)) + FHC_FilterWidget.reloadDataset(); + + }, + errorCallback: function(jqXHR, textStatus, errorThrown) { + FHC_DialogLib.alertError(textStatus); + } + } + ); + }, + + getAbsageData: function() + { + FHC_AjaxClient.ajaxCallGet( + 'system/infocenter/InfoCenter/getAbsageData', + {}, + { + successCallback: function(data, textStatus, jqXHR) { + if (FHC_AjaxClient.hasData(data)) + { + data = FHC_AjaxClient.getData(data); + $.each(data.statusgruende, function(key, value){ + $('.absgstatusgrund').append($("