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 = { "