From 8b28b48ff90e6638ab06cc865616fcee45fc1882 Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 23 Jan 2018 18:49:09 +0100 Subject: [PATCH] - Merged controller system/infocenter/InfoCenter.php into system/infocenter/InfocenterDetails.php - Removed controller application/controllers/system/infocenter/InfocenterDetails.php - Removed method _getFilterList from controller system/infocenter/InfoCenter.php - Added method _setNavigationMenuArray to controller system/infocenter/InfoCenter.php to generate the array for the left menu - Added public method getFilterList to model Filters_model - Removed view application/views/widgets/navigation.php - Removed widget application/widgets/navigation.php - Widget application/widgets/FHC_navigation.php now is usable to print any menu from an array --- .../system/infocenter/InfoCenter.php | 609 ++++++++++++++++-- .../system/infocenter/InfocenterDetails.php | 419 ------------ application/models/system/Filters_model.php | 20 + .../views/system/infocenter/infocenter.php | 91 +-- .../system/infocenter/infocenterData.php | 12 +- .../system/infocenter/infocenterDetails.php | 3 +- .../system/infocenter/infocenterFilters.php | 30 - application/views/widgets/fhcnavigation.php | 39 +- application/views/widgets/navigation.php | 12 - application/widgets/FHC_navigation.php | 101 ++- application/widgets/navigation.php | 17 - 11 files changed, 688 insertions(+), 665 deletions(-) delete mode 100644 application/controllers/system/infocenter/InfocenterDetails.php delete mode 100644 application/views/system/infocenter/infocenterFilters.php delete mode 100644 application/views/widgets/navigation.php delete mode 100644 application/widgets/navigation.php diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index ac6cd2aa7..ae1cc0e95 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -2,71 +2,600 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); +/** + * Also shows aufnahme-related data for a person and its prestudents, enables document and zgv checks, + * displays and saves Notizen for a person, logs aufnahme-related actions for a person + */ class InfoCenter extends VileSci_Controller { + // App and Verarbeitungstaetigkeit name for logging + const APP = 'aufnahme'; + const TAETIGKEIT = 'bewerbung'; + + // URL prefix for this controller + const URL_PREFIX = '/system/infocenter/InfoCenter/'; + + // Used to log with PersonLogLib + private $logparams = array( + 'saveformalgep' => array( + 'logtype' => 'Action', + 'name' => 'document formally checked', + 'message' => 'document %s formally checked, set to %s' + ), + 'savezgv' => array( + 'logtype' => 'Action', + 'name' => 'ZGV saved', + 'message' => 'ZGV saved for degree program %s, prestudentid %s' + ), + 'abgewiesen' => array( + 'logtype' => 'Processstate', + 'name' => 'Interessent rejected', + 'message' => 'Interessent with prestudentid %s was rejected for degree program %s, reason: %s' + ), + 'freigegeben' => array( + 'logtype' => 'Processstate', + 'name' => 'Interessent confirmed', + 'message' => 'status Interessent for prestudentid %s was confirmed for degree program %s' + ), + 'savenotiz' => array( + 'logtype' => 'Action', + 'name' => 'note added', + 'message' => 'note with title %s was added' + ) + ); + private $uid; // contains the UID of the logged user + private $navigationMenuArray; // contains all the voices for the navigation menu + + /** + * Constructor + */ public function __construct() { parent::__construct(); - // + // Loads models + $this->load->model('crm/akte_model', 'AkteModel'); + $this->load->model('crm/prestudent_model', 'PrestudentModel'); + $this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel'); + $this->load->model('crm/statusgrund_model', 'StatusgrundModel'); + $this->load->model('person/notiz_model', 'NotizModel'); + $this->load->model('person/person_model', 'PersonModel'); $this->load->model('system/Filters_model', 'FiltersModel'); - // - $this->load->library('WidgetLib'); + // Loads libraries + $this->load->library('DmsLib'); + $this->load->library('PersonLogLib'); + $this->load->library('WidgetLib'); + + $this->_setAuthUID(); // sets property uid + + $this->_setNavigationMenuArray(); // sets property navigationMenuArray } + // ----------------------------------------------------------------------------------------------------------------- + // Public methods + + /** + * Default + */ + public function index() + { + $this->load->view('system/infocenter/infocenter.php', array('navigationMenuArray' => $this->navigationMenuArray)); + } + + /** + * Initialization function, gets person and prestudent data and loads the view with the data + * @param $person_id + */ + public function showDetails($person_id) + { + if (!is_numeric($person_id)) + show_error('person id is not numeric!'); + + $persondata = $this->_loadPersonData($person_id); + if (!isset($persondata)) + show_error('person does not exist!'); + + $prestudentdata = $this->_loadPrestudentData($person_id); + + $this->load->view('system/infocenter/infocenterDetails.php', array_merge($persondata, $prestudentdata, array('navigationMenuArray' => $this->navigationMenuArray))); + } + + /** + * Saves if a document has been formal geprueft. saves current timestamp if checked as geprueft, or null if not. + */ + public function saveFormalGeprueft() + { + $akte_id = $this->input->get('akte_id'); + $formalgeprueft = $this->input->get('formal_geprueft'); + $person_id = $this->input->get('person_id'); + + if (!isset($akte_id) || !isset($formalgeprueft) || !isset($person_id)) + show_error('Parameters not set!'); + + $akte = $this->AkteModel->load($akte_id); + + if (isError($akte)) + { + show_error($akte->retval); + } + + $timestamp = ($formalgeprueft === 'true') ? date('Y-m-d H:i:s') : null; + $result = $this->AkteModel->update($akte_id, array('formal_geprueft_amum' => $timestamp)); + + if (isError($result)) + { + show_error($result->retval); + } + + //write person log + $this->_log( + $person_id, + 'saveformalgep', + array( + empty($akte->retval[0]->titel) ? $akte->retval[0]->bezeichnung : $akte->retval[0]->titel, + is_null($timestamp) ? 'NULL' : $timestamp + ) + ); + + redirect(self::URL_PREFIX.'showDetails/'.$person_id.'#DokPruef'); + } + + /** + * Saves a zgv for a prestudent. includes Ort, Datum, Nation for bachelor and master. + * @param $prestudent_id + */ + public function saveZgvPruefung($prestudent_id) + { + // zgvdata + // Check for string null, in case dropdown changed to default value + $zgv_code = $this->input->post('zgv') === 'null' ? null : $this->input->post('zgv'); + $zgvort = $this->input->post('zgvort'); + $zgvdatum = $this->input->post('zgvdatum'); + $zgvdatum = empty($zgvdatum) ? null : date_format(date_create($zgvdatum), 'Y-m-d'); + $zgvnation_code = $this->input->post('zgvnation') === 'null' ? null : $this->input->post('zgvnation'); + + //zgvmasterdata + $zgvmas_code = $this->input->post('zgvmas') === 'null' ? null : $this->input->post('zgvmas'); + $zgvmaort = $this->input->post('zgvmaort'); + $zgvmadatum = $this->input->post('zgvmadatum'); + $zgvmadatum = empty($zgvmadatum) ? null : date_format(date_create($zgvmadatum), 'Y-m-d'); + $zgvmanation_code = $this->input->post('zgvmanation') === 'null' ? null : $this->input->post('zgvmanation'); + + $result = $this->PrestudentModel->update( + $prestudent_id, + array( + 'zgv_code' => $zgv_code, + 'zgvort' => $zgvort, + 'zgvdatum' => $zgvdatum, + 'zgvnation' => $zgvnation_code, + 'zgvmas_code' => $zgvmas_code, + 'zgvmaort' => $zgvmaort, + 'zgvmadatum' => $zgvmadatum, + 'zgvmanation' => $zgvmanation_code + ) + ); + + if (isError($result)) + { + show_error($result->retval); + } + + //get extended Prestudent data for logging + $logdata = $this->_getPersonAndStudiengangFromPrestudent($prestudent_id); + + $this->_log($logdata['person_id'], 'savezgv', array($logdata['studiengang_kurzbz'], $prestudent_id)); + + $this->_redirectToStart($prestudent_id, 'ZgvPruef'); + } + + /** + * Saves Absage for Prestudent including the reason for the Absage (statusgrund). + * inserts Studiensemester and Ausbildungssemester for the new Absage of (chronologically) last status. + * @param $prestudent_id + */ + public function saveAbsage($prestudent_id) + { + //TODO email messaging + $statusgrund = $this->input->post('statusgrund'); + + $lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent_id); + + if (isError($lastStatus)) + { + show_error($lastStatus->retval); + } + + $result = $this->PrestudentstatusModel->insert( + array( + 'prestudent_id' => $prestudent_id, + 'studiensemester_kurzbz' => $lastStatus->retval[0]->studiensemester_kurzbz, + 'ausbildungssemester' => $lastStatus->retval[0]->ausbildungssemester, + 'datum' => date('Y-m-d'), + 'orgform_kurzbz' => $lastStatus->retval[0]->orgform_kurzbz, + 'studienplan_id' => $lastStatus->retval[0]->studienplan_id, + 'status_kurzbz' => 'Abgewiesener', + 'statusgrund_id' => $statusgrund, + 'insertvon' => $this->uid, + 'insertamum' => date('Y-m-d H:i:s') + ) + ); + + if (isError($result)) + { + show_error($result->retval); + } + + $logdata = $this->_getPersonAndStudiengangFromPrestudent($prestudent_id); + + //statusgrund bezeichnung for logging + $this->StatusgrundModel->addSelect('bezeichnung_mehrsprachig'); + $result = $this->StatusgrundModel->load($statusgrund); + if (isError($result)) + { + show_error($result->retval); + } + + $statusgrund_bez = $result->retval[0]->bezeichnung_mehrsprachig[1]; + + $this->_log($logdata['person_id'], 'abgewiesen', array($prestudent_id, $logdata['studiengang_kurzbz'], $statusgrund_bez)); + + $this->_redirectToStart($prestudent_id, 'ZgvPruef'); + } + + /** + * Saves Freigabe of a Prestudent to the Studiengang. + * updates bestaetigtam and bestaetigtvon fields of the last status + * @param $prestudent_id + */ + public function saveFreigabe($prestudent_id) + { + $lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent_id); + + if (count($lastStatus->retval) > 0) + { + $lastStatus = $lastStatus->retval[0]; + + $result = $this->PrestudentstatusModel->update( + array( + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => $lastStatus->status_kurzbz, + 'studiensemester_kurzbz' => $lastStatus->studiensemester_kurzbz, + 'ausbildungssemester' => $lastStatus->ausbildungssemester + ), + array( + 'bestaetigtvon' => $this->uid, + 'bestaetigtam' => date('Y-m-d'), + 'updatevon' => $this->uid, + 'updateamum' => date('Y-m-d H:i:s') + ) + ); + + if (isError($result)) + { + show_error($result->retval); + } + } + + $logdata = $this->_getPersonAndStudiengangFromPrestudent($prestudent_id); + + $this->_log($logdata['person_id'], 'freigegeben', array($prestudent_id, $logdata['studiengang_kurzbz'])); + + $this->_redirectToStart($prestudent_id, 'ZgvPruef'); + } + + /** + * Saves a new Notiz for a person + * @param $person_id + */ + public function saveNotiz($person_id) + { + $titel = $this->input->post('notiztitel'); + $text = $this->input->post('notiz'); + $erledigt = false; + + $result = $this->NotizModel->addNotizForPerson($person_id, $titel, $text, $erledigt, $this->uid); + + if (isError($result)) + { + show_error($result->retval); + } + + $this->_log($person_id, 'savenotiz', array($titel)); + + redirect(self::URL_PREFIX.'showDetails/'.$person_id.'#NotizAkt'); + } + + /** + * Outputs content of an Akte, sends appropriate headers (so the document can be downloaded) + * @param $akte_id + */ + public function outputAkteContent($akte_id) + { + $akte = $this->AkteModel->load($akte_id); + + if (isError($akte)) + { + show_error($akte->retval); + } + + $aktecontent = $this->dmslib->getAkteContent($akte_id); + + if (isError($aktecontent)) + { + show_error($aktecontent->retval); + } + + $this->output + ->set_status_header(200) + ->set_content_type($akte->retval[0]->mimetype, 'utf-8') + ->set_header('Content-Disposition: attachment; filename="'.$akte->retval[0]->titel.'"') + ->set_output($aktecontent->retval) + ->_display(); + } + + // ----------------------------------------------------------------------------------------------------------------- + // Private methods + + /** + * Retrive the UID of the logged user and checks if it is valid + */ + private function _setAuthUID() + { + $this->uid = getAuthUID(); + + if (!$this->uid) show_error('User authentification failed'); + } + /** * */ - public function index() + private function _setNavigationMenuArray() { - $listFiltersSent = array(); - $listFiltersNotSent = array(); + $filtersSent = $this->FiltersModel->getFilterList('aufnahme', 'PersonActions', '%InfoCenterSentApplication%'); + if (hasData($filtersSent)) + { + for ($filtersCounter = 0; $filtersCounter < count($filtersSent->retval); $filtersCounter++) + { + $filter = $filtersSent->retval[$filtersCounter]; - $listFiltersSent = $this->_getFilterList('%InfoCenterSentApplication%'); + $listFiltersSent[$filter->filter_id] = $filter->description[0]; + } + } - $listFiltersNotSent = $this->_getFilterList('%InfoCenterNotSentApplication%'); + $filtersNotSent = $this->FiltersModel->getFilterList('aufnahme', 'PersonActions', '%InfoCenterNotSentApplication%'); + if (hasData($filtersNotSent)) + { + for ($filtersCounter = 0; $filtersCounter < count($filtersNotSent->retval); $filtersCounter++) + { + $filter = $filtersNotSent->retval[$filtersCounter]; - $this->load->view( - 'system/infocenter/infocenter.php', - array( - 'listFiltersSent' => $listFiltersSent, - 'listFiltersNotSent' => $listFiltersNotSent + $listFiltersNotSent[$filter->filter_id] = $filter->description[0]; + } + } + + $filtersarray = array( + 'abgeschickt' => array( + 'link' => '#', + 'description' => 'Abgeschickt', + 'expand' => true, + 'children' => array() + ), + 'nichtabgeschickt' => array( + 'link' => '#', + 'description' => 'Nicht abgeschickt', + 'expand' => true, + 'children' => array() + ) + ); + + $this->_fillFilters($listFiltersSent, $filtersarray['abgeschickt']); + $this->_fillFilters($listFiltersNotSent, $filtersarray['nichtabgeschickt']); + + $this->navigationMenuArray = array( + 'dashboard' => array( + 'link' => '#', + 'description' => 'Dashboard', + 'icon' => 'dashboard' + ), + 'filters' => array( + 'link' => '#', + 'description' => 'Filter', + 'icon' => 'filter', + 'expand' => true, + 'children' => $filtersarray ) ); } - /** - * - */ - private function _getFilterList($filter_kurzbz) + private function _fillFilters($filters, &$tofill) { - $listFilters = array(); - - $personActionsArray = array( - 'app' => 'aufnahme', - 'dataset_name' => 'PersonActions', - 'person_id' => null, - 'default_filter' => false, - 'array_length(description, 1) >' => 0 - ); - - $this->FiltersModel->resetQuery(); - $this->FiltersModel->addSelect('filter_id, description'); - $this->FiltersModel->addOrder('sort', 'ASC'); - - $personActionsArray['filter_kurzbz ILIKE'] = $filter_kurzbz; - $filters = $this->FiltersModel->loadWhere($personActionsArray); - if (hasData($filters)) + foreach ($filters as $filterId => $description) { - for ($filtersCounter = 0; $filtersCounter < count($filters->retval); $filtersCounter++) - { - $filter = $filters->retval[$filtersCounter]; + $toPrint = "%s=%s"; + $tofill['children'][] = array( + 'link' => sprintf($toPrint, base_url('index.ci.php/system/infocenter/InfoCenter?filterId'), $filterId), + 'description' => $description + ); + } + } - $listFilters[$filter->filter_id] = $filter->description[0]; - } + /** + * Loads all necessary Person data: Stammdaten (name, svnr, contact, ...), Dokumente, Logs and Notizen + * @param $person_id + * @return array + */ + private function _loadPersonData($person_id) + { + $stammdaten = $this->PersonModel->getPersonStammdaten($person_id); + + if (isError($stammdaten)) + { + show_error($stammdaten->retval); } - return $listFilters; + if (!isset($stammdaten->retval)) + return null; + + $dokumente = $this->AkteModel->getAktenWithDokInfo($person_id, null, false); + + if (isError($dokumente)) + { + show_error($dokumente->retval); + } + + $dokumente_nachgereicht = $this->AkteModel->getAktenWithDokInfo($person_id, null, true); + + if (isError($dokumente_nachgereicht)) + { + show_error($dokumente->retval); + } + + $logs = $this->personloglib->getLogs($person_id); + + $notizen = $this->NotizModel->getNotiz($person_id); + + if (isError($notizen)) + { + show_error($notizen->retval); + } + + $data = array ( + 'stammdaten' => $stammdaten->retval, + 'dokumente' => $dokumente->retval, + 'dokumente_nachgereicht' => $dokumente_nachgereicht->retval, + 'logs' => $logs, + 'notizen' => $notizen->retval + ); + + return $data; + } + + /** + * Loads all necessary Prestudent data: Zgv data, Statusgruende + * @param $person_id + * @return array + */ + private function _loadPrestudentData($person_id) + { + $zgvpruefungen = array(); + + $prestudenten = $this->PrestudentModel->loadWhere(array('person_id' => $person_id)); + + if (isError($prestudenten)) + { + show_error($prestudenten->retval); + } + + foreach ($prestudenten->retval as $prestudent) + { + $prestudent = $this->PrestudentModel->getPrestudentWithZgv($prestudent->prestudent_id); + + if (isError($prestudent)) + { + show_error($prestudent->retval); + } + + $zgvpruefung = $prestudent->retval[0]; + + $position = strpos($zgvpruefung->prestudentstatus->anmerkung, 'Alt:'); + + //parse Anmerkung for Alternative (Prio is given in orgform and sprache anyway) + $zgvpruefung->prestudentstatus->alternative = is_numeric($position) ? substr($zgvpruefung->prestudentstatus->anmerkung, $position) : null; + + //if prestudent is not interessent or is already bestaetigt, then show only as information, non-editable + $zgvpruefung->infoonly = !isset($zgvpruefung->prestudentstatus) || isset($zgvpruefung->prestudentstatus->bestaetigtam) || $zgvpruefung->prestudentstatus->status_kurzbz != 'Interessent'; + + $zgvpruefungen[] = $zgvpruefung; + } + + // Interessenten come first + usort($zgvpruefungen, function ($a, $b) + { + if (!isset($a->prestudentstatus->status_kurzbz) || !isset($b->prestudentstatus->status_kurzbz)) + return 0; + elseif ($a->prestudentstatus->status_kurzbz === 'Interessent' && $b->prestudentstatus->status_kurzbz === 'Interessent') + { + //infoonly Interessenten come after new Interessenten + if ($a->infoonly) + return 1; + elseif ($b->infoonly) + return -1; + } + elseif ($a->prestudentstatus->status_kurzbz === 'Interessent') + return -1; + elseif ($b->prestudentstatus->status_kurzbz === 'Interessent') + return 1; + else + return 0; + }); + + $statusgruende = $this->StatusgrundModel->loadWhere(array('status_kurzbz' => 'Abgewiesener'))->retval; + + $data = array ( + 'zgvpruefungen' => $zgvpruefungen, + 'statusgruende' => $statusgruende + ); + + return $data; + } + + /** + * Helper function for redirecting to initial page for person from a prestudent-specific page + * @param $prestudent_id + * @param $section optional section of the page to go to + */ + private function _redirectToStart($prestudent_id, $section = '') + { + $this->PrestudentModel->addSelect('person_id'); + $person_id = $this->PrestudentModel->load($prestudent_id)->retval[0]->person_id; + + redirect(self::URL_PREFIX.'showDetails/'.$person_id.'#'.$section); + } + + /** + * Helper function retrieves personid and studiengang kurzbz from a prestudent id + * @param $prestudent_id + * @return array + */ + private function _getPersonAndStudiengangFromPrestudent($prestudent_id) + { + $prestudent = $this->PrestudentModel->getPrestudentWithZgv($prestudent_id); + + if (isError($prestudent)) + { + show_error($prestudent->retval); + } + + $person_id = $prestudent->retval[0]->person_id; + $studiengang_kurzbz = $prestudent->retval[0]->studiengang; + + return array('person_id' => $person_id, 'studiengang_kurzbz' => $studiengang_kurzbz); + } + + /** + * Helper function for logging + * @param $person_id + * @param $logname + * @param $messageparams + */ + private function _log($person_id, $logname, $messageparams) + { + $logdata = $this->logparams[$logname]; + + $this->personloglib->log( + $person_id, + $logdata['logtype'], + array( + 'name' => $logdata['name'], + 'message' => vsprintf($logdata['message'], + $messageparams), + 'success' => 'true' + ), + self::TAETIGKEIT, + self::APP, + null, + $this->uid + ); } } diff --git a/application/controllers/system/infocenter/InfocenterDetails.php b/application/controllers/system/infocenter/InfocenterDetails.php deleted file mode 100644 index 329facd4d..000000000 --- a/application/controllers/system/infocenter/InfocenterDetails.php +++ /dev/null @@ -1,419 +0,0 @@ - array('logtype' => 'Action', 'name' => 'document formally checked', 'message' => 'document %s formally checked, set to %s'), - 'savezgv' => array('logtype' => 'Action', 'name' => 'ZGV saved', 'message' => 'ZGV saved for degree program %s, prestudentid %s'), - 'abgewiesen' => array('logtype' => 'Processstate', 'name' => 'Interessent rejected', 'message' => 'Interessent with prestudentid %s was rejected for degree program %s, reason: %s'), - 'freigegeben' => array('logtype' => 'Processstate', 'name' => 'Interessent confirmed', 'message' => 'status Interessent for prestudentid %s was confirmed for degree program %s'), - 'savenotiz' => array('logtype' => 'Action', 'name' => 'note added', 'message' => 'note with title %s was added') - ); - - /** - * constructor - */ - public function __construct() - { - parent::__construct(); - - $this->load->model('person/person_model', 'PersonModel'); - $this->load->model('person/notiz_model', 'NotizModel'); - $this->load->model('crm/prestudent_model', 'PrestudentModel'); - $this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel'); - $this->load->model('crm/statusgrund_model', 'StatusgrundModel'); - $this->load->model('crm/akte_model', 'AkteModel'); - - $this->load->library('DmsLib'); - $this->load->library('WidgetLib'); - $this->load->library('PersonLogLib'); - - $this->load->helper('fhcauth'); - $this->load->helper('url'); - - $this->uid = getAuthUID(); - if(!$this->uid) - show_error('user authentification failed'); - } - - /** - * loads all necessary Person data: Stammdaten (name, svnr, contact, ...), Dokumente, Logs and Notizen - * @param $person_id - * @return array - */ - private function __loadPersonData($person_id) - { - $stammdaten = $this->PersonModel->getPersonStammdaten($person_id); - - if ($stammdaten->error) - { - show_error($stammdaten->retval); - } - - if(!isset($stammdaten->retval)) - return null; - - $dokumente = $this->AkteModel->getAktenWithDokInfo($person_id, null, false); - - if ($dokumente->error) - { - show_error($dokumente->retval); - } - - $dokumente_nachgereicht = $this->AkteModel->getAktenWithDokInfo($person_id, null, true); - - if ($dokumente_nachgereicht->error) - { - show_error($dokumente->retval); - } - - $logs = $this->personloglib->getLogs($person_id); - - $notizen = $this->NotizModel->getNotiz($person_id); - - if ($notizen->error) - { - show_error($notizen->retval); - } - - $data = array ( - 'stammdaten' => $stammdaten->retval, - 'dokumente' => $dokumente->retval, - 'dokumente_nachgereicht' => $dokumente_nachgereicht->retval, - 'logs' => $logs, - 'notizen' => $notizen->retval - ); - - return $data; - } - - /** - * loads all necessary Prestudent data: Zgv data, Statusgruende - * @param $person_id - * @return array - */ - private function __loadPrestudentData($person_id) - { - $zgvpruefungen = array(); - - $prestudenten = $this->PrestudentModel->loadWhere(array('person_id' => $person_id)); - - if ($prestudenten->error) - { - show_error($prestudenten->retval); - } - - foreach ($prestudenten->retval as $prestudent) - { - $prestudent = $this->PrestudentModel->getPrestudentWithZgv($prestudent->prestudent_id); - - if ($prestudent->error) - { - show_error($prestudent->retval); - } - - $zgvpruefung = $prestudent->retval[0]; - - $position = strpos($zgvpruefung->prestudentstatus->anmerkung, 'Alt:'); - - //parse Anmerkung for Alternative (Prio is given in orgform and sprache anyway) - $zgvpruefung->prestudentstatus->alternative = is_numeric($position) ? substr($zgvpruefung->prestudentstatus->anmerkung, $position) : null; - - //if prestudent is not interessent or is already bestaetigt, then show only as information, non-editable - $zgvpruefung->infoonly = !isset($zgvpruefung->prestudentstatus) || isset($zgvpruefung->prestudentstatus->bestaetigtam) || $zgvpruefung->prestudentstatus->status_kurzbz != 'Interessent'; - - $zgvpruefungen[] = $zgvpruefung; - } - - //Interessenten come first - usort($zgvpruefungen, function ($a, $b) - { - if(!isset($a->prestudentstatus->status_kurzbz) || !isset($b->prestudentstatus->status_kurzbz)) - return 0; - elseif($a->prestudentstatus->status_kurzbz === 'Interessent' && $b->prestudentstatus->status_kurzbz === 'Interessent') - { - //infoonly Interessenten come after new Interessenten - if($a->infoonly) - return 1; - elseif($b->infoonly) - return -1; - } - elseif($a->prestudentstatus->status_kurzbz === 'Interessent') - return -1; - elseif($b->prestudentstatus->status_kurzbz === 'Interessent') - return 1; - else - return 0; - }); - - $statusgruende = $this->StatusgrundModel->loadWhere(array('status_kurzbz' => 'Abgewiesener'))->retval; - - $data = array ( - 'zgvpruefungen' => $zgvpruefungen, - 'statusgruende' => $statusgruende - ); - - return $data; - } - - /** - * initialization function, gets person and prestudent data and loads the view with the data - * @param $person_id - */ - public function showDetails($person_id) - { - if(!is_numeric($person_id)) - show_error('person id is not numeric!'); - $persondata = $this->__loadPersonData($person_id); - if(!isset($persondata)) - show_error('person does not exist!'); - $prestudentdata = $this->__loadPrestudentData($person_id); - $this->load->view('system/infocenter/infocenterDetails.php', array_merge($persondata, $prestudentdata)); - } - - /** - * saves if a document has been formal geprueft. saves current timestamp if checked as geprueft, or null if not. - */ - public function saveFormalGeprueft() - { - $akte_id = $this->input->get('akte_id'); - $formalgeprueft = $this->input->get('formal_geprueft'); - $person_id = $this->input->get('person_id'); - - if(!isset($akte_id) || !isset($formalgeprueft) || !isset($person_id)) - show_error('Parameters not set!'); - - $akte = $this->AkteModel->load($akte_id); - - if ($akte->error) - { - show_error($akte->retval); - } - - $timestamp = ($formalgeprueft === 'true') ? date('Y-m-d H:i:s') : null; - $result = $this->AkteModel->update($akte_id, array('formal_geprueft_amum' => $timestamp)); - - if ($result->error) - { - show_error($result->retval); - } - - //write person log - $this->__log($person_id, 'saveformalgep', array(empty($akte->retval[0]->titel) ? $akte->retval[0]->bezeichnung : $akte->retval[0]->titel, is_null($timestamp) ? 'NULL' : $timestamp)); - - redirect('/system/infocenter/InfocenterDetails/showDetails/'.$person_id.'#DokPruef'); - } - - /** - * saves a zgv for a prestudent. includes Ort, Datum, Nation for bachelor and master. - * @param $prestudent_id - */ - public function saveZgvPruefung($prestudent_id) - { - // zgvdata - $zgv_code = $this->input->post('zgv') === 'null' ? null : $this->input->post('zgv');//check for string null, in case dropdown changed to default value - $zgvort = $this->input->post('zgvort'); - $zgvdatum = $this->input->post('zgvdatum'); - $zgvdatum = empty($zgvdatum) ? null : date_format(date_create($zgvdatum), 'Y-m-d'); - $zgvnation_code = $this->input->post('zgvnation') === 'null' ? null : $this->input->post('zgvnation'); - - //zgvmasterdata - $zgvmas_code = $this->input->post('zgvmas') === 'null' ? null : $this->input->post('zgvmas'); - $zgvmaort = $this->input->post('zgvmaort'); - $zgvmadatum = $this->input->post('zgvmadatum'); - $zgvmadatum = empty($zgvmadatum) ? null : date_format(date_create($zgvmadatum), 'Y-m-d'); - $zgvmanation_code = $this->input->post('zgvmanation') === 'null' ? null : $this->input->post('zgvmanation'); - - $result = $this->PrestudentModel->update($prestudent_id, array('zgv_code' => $zgv_code, 'zgvort' => $zgvort, 'zgvdatum' => $zgvdatum, 'zgvnation' => $zgvnation_code, - 'zgvmas_code' => $zgvmas_code, 'zgvmaort' => $zgvmaort, 'zgvmadatum' => $zgvmadatum, 'zgvmanation' => $zgvmanation_code)); - - if ($result->error) - { - show_error($result->retval); - } - - //get extended Prestudent data for logging - $logdata = $this->__getPersonAndStudiengangFromPrestudent($prestudent_id); - - $this->__log($logdata['person_id'], 'savezgv', array($logdata['studiengang_kurzbz'], $prestudent_id)); - - $this->__redirectToStart($prestudent_id, 'ZgvPruef'); - } - - /** - * saves Absage for Prestudent including the reason for the Absage (statusgrund). - * inserts Studiensemester and Ausbildungssemester for the new Absage of (chronologically) last status. - * @param $prestudent_id - */ - public function saveAbsage($prestudent_id) - { - //TODO email messaging - $statusgrund = $this->input->post('statusgrund'); - - $lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent_id); - - if ($lastStatus->error) - { - show_error($lastStatus->retval); - } - - $result = $this->PrestudentstatusModel->insert(array('prestudent_id' => $prestudent_id, 'studiensemester_kurzbz' => $lastStatus->retval[0]->studiensemester_kurzbz, 'ausbildungssemester' => $lastStatus->retval[0]->ausbildungssemester, 'datum' => date('Y-m-d'), 'orgform_kurzbz' => $lastStatus->retval[0]->orgform_kurzbz, 'studienplan_id' => $lastStatus->retval[0]->studienplan_id, 'status_kurzbz' => 'Abgewiesener', 'statusgrund_id' => $statusgrund, 'insertvon' => $this->uid, 'insertamum' => date('Y-m-d H:i:s'))); - - if ($result->error) - { - show_error($result->retval); - } - - $logdata = $this->__getPersonAndStudiengangFromPrestudent($prestudent_id); - - //statusgrund bezeichnung for logging - $this->StatusgrundModel->addSelect('bezeichnung_mehrsprachig'); - $result = $this->StatusgrundModel->load($statusgrund); - if ($result->error) - { - show_error($result->retval); - } - - $statusgrund_bez = $result->retval[0]->bezeichnung_mehrsprachig[1]; - - $this->__log($logdata['person_id'], 'abgewiesen', array($prestudent_id, $logdata['studiengang_kurzbz'], $statusgrund_bez)); - - $this->__redirectToStart($prestudent_id, 'ZgvPruef'); - } - - /** - * saves Freigabe of a Prestudent to the Studiengang. - * updates bestaetigtam and bestaetigtvon fields of the last status - * @param $prestudent_id - */ - public function saveFreigabe($prestudent_id) - { - $lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent_id); - - if (count($lastStatus->retval) > 0) - { - $lastStatus = $lastStatus->retval[0]; - - $result = $this->PrestudentstatusModel->update(array('prestudent_id' => $prestudent_id, 'status_kurzbz' => $lastStatus->status_kurzbz, 'studiensemester_kurzbz' => $lastStatus->studiensemester_kurzbz, 'ausbildungssemester' => $lastStatus->ausbildungssemester), - array('bestaetigtvon' => $this->uid, 'bestaetigtam' => date('Y-m-d'), 'updatevon' => $this->uid, 'updateamum' => date('Y-m-d H:i:s'))); - - if ($result->error) - { - show_error($result->retval); - } - } - - $logdata = $this->__getPersonAndStudiengangFromPrestudent($prestudent_id); - - $this->__log($logdata['person_id'], 'freigegeben', array($prestudent_id, $logdata['studiengang_kurzbz'])); - - $this->__redirectToStart($prestudent_id, 'ZgvPruef'); - } - - /** - * saves a new Notiz for a person - * @param $person_id - */ - public function saveNotiz($person_id) - { - $titel = $this->input->post('notiztitel'); - $text = $this->input->post('notiz'); - $erledigt = false; - - $result = $this->NotizModel->addNotizForPerson($person_id, $titel, $text, $erledigt, $this->uid); - - if ($result->error) - { - show_error($result->retval); - } - - $this->__log($person_id, 'savenotiz', array($titel)); - - redirect('/system/infocenter/InfocenterDetails/showDetails/'.$person_id.'#NotizAkt'); - } - - /** - * Outputs content of an Akte, sends appropriate headers (so the document can be downloaded) - * @param $akte_id - */ - public function outputAkteContent($akte_id) - { - $akte = $this->AkteModel->load($akte_id); - - if ($akte->error) - { - show_error($akte->retval); - } - - $aktecontent = $this->dmslib->getAkteContent($akte_id); - - if($aktecontent->error) - { - show_error($aktecontent->retval); - } - - $this->output - ->set_status_header(200) - ->set_content_type($akte->retval[0]->mimetype, 'utf-8') - ->set_header('Content-Disposition: attachment; filename="'.$akte->retval[0]->titel.'"') - ->set_output($aktecontent->retval) - ->_display(); - } - - /** - * helper function for redirecting to initial page for person from a prestudent-specific page - * @param $prestudent_id - * @param $section optional section of the page to go to - */ - private function __redirectToStart($prestudent_id, $section = '') - { - $this->PrestudentModel->addSelect('person_id'); - $person_id = $this->PrestudentModel->load($prestudent_id)->retval[0]->person_id; - redirect('/system/infocenter/InfocenterDetails/showDetails/'.$person_id.'#'.$section); - } - - /** - * helper function retrieves personid and studiengang kurzbz from a prestudent id - * @param $prestudent_id - * @return array - */ - private function __getPersonAndStudiengangFromPrestudent($prestudent_id) - { - $prestudent = $this->PrestudentModel->getPrestudentWithZgv($prestudent_id); - - if ($prestudent->error) - { - show_error($prestudent->retval); - } - - $person_id = $prestudent->retval[0]->person_id; - $studiengang_kurzbz = $prestudent->retval[0]->studiengang; - - return array('person_id' => $person_id, 'studiengang_kurzbz' => $studiengang_kurzbz); - } - - /** - * helper function for logging - * @param $person_id - * @param $logname - * @param $messageparams - */ - private function __log($person_id, $logname, $messageparams) - { - $logdata = $this->logparams[$logname]; - $this->personloglib->log($person_id, $logdata['logtype'], - array('name' => $logdata['name'], 'message' => vsprintf($logdata['message'], $messageparams), 'success' => 'true'), - $this::TAETIGKEIT, $this::APP, null, $this->uid); - } - -} \ No newline at end of file diff --git a/application/models/system/Filters_model.php b/application/models/system/Filters_model.php index 546e2a5fd..1395a7a40 100644 --- a/application/models/system/Filters_model.php +++ b/application/models/system/Filters_model.php @@ -11,4 +11,24 @@ class Filters_model extends DB_Model $this->dbTable = 'system.tbl_filters'; $this->pk = 'filter_id'; } + + /** + * + */ + public function getFilterList($app, $dataset_name, $filter_kurzbz) + { + $this->addSelect('filter_id, description'); + $this->addOrder('sort', 'ASC'); + + $filterParametersArray = array( + 'app' => $app, + 'dataset_name' => $dataset_name, + 'person_id' => null, + 'default_filter' => false, + 'array_length(description, 1) >' => 0, + 'filter_kurzbz ILIKE' => $filter_kurzbz + ); + + return $this->FiltersModel->loadWhere($filterParametersArray); + } } diff --git a/application/views/system/infocenter/infocenter.php b/application/views/system/infocenter/infocenter.php index 8007d0cd1..b57fe1c0c 100644 --- a/application/views/system/infocenter/infocenter.php +++ b/application/views/system/infocenter/infocenter.php @@ -1,56 +1,59 @@ load->view('templates/FHC-Header', array('title' => 'Info Center', 'jquery3' => true, 'bootstrap' => true, 'fontawesome' => true, 'sbadmintemplate' => true, 'tablesorter' => false, 'customCSSs' => 'vendor/FHC-vendor/jquery-tableso -rter/css/theme.default.css', 'customJSs' => array('vendor/FHC-vendor/jquery-tablesorter/js/jquery.tablesorter.js', 'vendor/FHC-vendor/jquery-tablesorter/js/jquery.tablesorter.widgets.js'))); + $this->load->view( + 'templates/FHC-Header', + array( + 'title' => 'Info Center', + 'jquery3' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'tablesorter' => false, + 'customCSSs' => 'vendor/FHC-vendor/jquery-tablesorter/css/theme.default.css', + 'customJSs' => array( + 'vendor/FHC-vendor/jquery-tablesorter/js/jquery.tablesorter.js', + 'vendor/FHC-vendor/jquery-tablesorter/js/jquery.tablesorter.widgets.js' + ) + ) + ); ?> - -
- +
+
+
+
+ +
+
+
+ load->view('system/infocenter/infocenterData.php'); + ?>
- - - - load->view('system/infocenter/infocenterData.php'); - ?> -
- - + + load->view('templates/FHC-Footer'); ?> diff --git a/application/views/system/infocenter/infocenterData.php b/application/views/system/infocenter/infocenterData.php index b3ae4f362..d307529ea 100644 --- a/application/views/system/infocenter/infocenterData.php +++ b/application/views/system/infocenter/infocenterData.php @@ -33,7 +33,7 @@ AND pss.bestaetigtam IS NULL AND pss.bestaetigtvon IS NULL AND ps.person_id = p.person_id - AND tbl_studiengang.typ in(\'b\',\'m\') + AND tbl_studiengang.typ in(\'b\', \'m\') ORDER BY pss.datum DESC, pss.insertamum DESC, pss.ext_id DESC LIMIT 1 ) AS "Studiensemester", @@ -47,7 +47,7 @@ AND pss.bestaetigtam IS NULL AND pss.bestaetigtvon IS NULL AND ps.person_id = p.person_id - AND tbl_studiengang.typ in(\'b\',\'m\') + AND tbl_studiengang.typ in(\'b\', \'m\') ORDER BY pss.datum DESC, pss.insertamum DESC, pss.ext_id DESC LIMIT 1 ) AS "SendDate" @@ -60,7 +60,7 @@ JOIN public.tbl_studiengang USING(studiengang_kz) WHERE person_id=p.person_id - AND tbl_studiengang.typ in(\'b\',\'m\') + AND tbl_studiengang.typ in(\'b\', \'m\') AND \'Interessent\' = (SELECT status_kurzbz FROM public.tbl_prestudentstatus WHERE prestudent_id=tbl_prestudent.prestudent_id ORDER BY datum DESC, insertamum DESC, ext_id DESC @@ -72,8 +72,8 @@ FROM public.tbl_prestudentstatus WHERE - prestudent_id=tbl_prestudent.prestudent_id - AND status_kurzbz=\'Interessent\' + prestudent_id = tbl_prestudent.prestudent_id + AND status_kurzbz = \'Interessent\' AND bestaetigtam IS NULL AND bestaetigtvon IS NULL AND studiensemester_kurzbz IN ( @@ -96,7 +96,7 @@ $datasetRaw->{$fieldName} = sprintf( $link, - base_url('index.ci.php/system/infocenter/infocenterDetails/showDetails/'), + base_url('index.ci.php/system/infocenter/InfoCenter/showDetails/'), $datasetRaw->PersonId ); } diff --git a/application/views/system/infocenter/infocenterDetails.php b/application/views/system/infocenter/infocenterDetails.php index 6d503b7fc..9f6f4a03e 100644 --- a/application/views/system/infocenter/infocenterDetails.php +++ b/application/views/system/infocenter/infocenterDetails.php @@ -11,7 +11,8 @@ $this->load->view('templates/FHC-Header', array('title' => 'InfocenterDetails', ); echo $this->widgetlib->widget( - 'FHC_navigation' + 'FHC_navigation', + $navigationMenuArray ); ?> diff --git a/application/views/system/infocenter/infocenterFilters.php b/application/views/system/infocenter/infocenterFilters.php deleted file mode 100644 index 9780be77f..000000000 --- a/application/views/system/infocenter/infocenterFilters.php +++ /dev/null @@ -1,30 +0,0 @@ - $description) - { - $toPrint = '
%s
'; - - echo sprintf($toPrint, base_url('index.ci.php/system/infocenter/InfoCenter?filterId'), $filterId, $description).PHP_EOL; - } - } - -// HTML - // body - // span -?> -
- -
- Abgeschickt: -
- - - -
- Nicht abgeschickt: -
- - - -
diff --git a/application/views/widgets/fhcnavigation.php b/application/views/widgets/fhcnavigation.php index cc1f00673..9b72afeb1 100644 --- a/application/views/widgets/fhcnavigation.php +++ b/application/views/widgets/fhcnavigation.php @@ -1,44 +1,9 @@ - - - '.(isset($item['icon']) ? ' ' : '').$item['description'].(!empty($item['children']) ? '':'').''; - if (!empty($item['children'])) - { - $level = ''; - if ($depth === 1) - $level = 'second'; - elseif ($depth > 1) - $level = 'third'; - - echo ''; - } - echo ''; -} -?> \ No newline at end of file diff --git a/application/views/widgets/navigation.php b/application/views/widgets/navigation.php deleted file mode 100644 index 6baca95f5..000000000 --- a/application/views/widgets/navigation.php +++ /dev/null @@ -1,12 +0,0 @@ - \ No newline at end of file diff --git a/application/widgets/FHC_navigation.php b/application/widgets/FHC_navigation.php index c22a0930c..bc6465208 100644 --- a/application/widgets/FHC_navigation.php +++ b/application/widgets/FHC_navigation.php @@ -1,75 +1,58 @@ navigationMenu = $widgetData; - $listFiltersSent = $this->_getFilterList('%InfoCenterSentApplication%'); + self::$FHC_navigationInstance = $this; - $listFiltersNotSent = $this->_getFilterList('%InfoCenterNotSentApplication%'); - - $filtersarray = array('abgeschickt' => array('link' => '#', 'description' => 'Abgeschickt', 'expand' => true, 'children' => array()), - 'nichtabgeschickt' => array('link' => '#', 'description' => 'Nicht abgeschickt','expand' => true,'children' => array())); - - $this->_fillFilters($listFiltersSent, $filtersarray['abgeschickt']); - $this->_fillFilters($listFiltersNotSent, $filtersarray['nichtabgeschickt']); - - $data = array(); - $data['items'] = array('dashboard' => array('link' => '#', 'description' => 'Dashboard', 'icon' => 'dashboard'), - 'filters' => array('link' => '#', 'description' => 'Filter', 'icon' => 'filter','expand' => true, 'children' => - $filtersarray - )); - } - - $this->view('widgets/fhcnavigation', $data); + $this->view('widgets/fhcnavigation'); } - private function _getFilterList($filter_kurzbz) + /** + * + */ + public static function printNavigationMenu() { - $this->load->model('system/Filters_model', 'FiltersModel'); - - $listFilters = array(); - - $personActionsArray = array( - 'app' => 'aufnahme', - 'dataset_name' => 'PersonActions', - 'person_id' => null, - 'default_filter' => false, - 'array_length(description, 1) >' => 0 - ); - - $this->FiltersModel->resetQuery(); - $this->FiltersModel->addSelect('filter_id, description'); - $this->FiltersModel->addOrder('sort', 'ASC'); - - $personActionsArray['filter_kurzbz ILIKE'] = $filter_kurzbz; - $filters = $this->FiltersModel->loadWhere($personActionsArray); - if (hasData($filters)) - { - for ($filtersCounter = 0; $filtersCounter < count($filters->retval); $filtersCounter++) - { - $filter = $filters->retval[$filtersCounter]; - - $listFilters[$filter->filter_id] = $filter->description[0]; - } - } - - return $listFilters; + foreach (self::$FHC_navigationInstance->navigationMenu as $item) + self::printNavItem($item); } - private function _fillFilters($filters, &$tofill) + /** + * + */ + public static function printNavItem($item, $depth = 1) { - foreach ($filters as $filterId => $description) + $expanded = isset($item['expand']) && $item['expand'] === true ? ' active' : ''; + echo '
  • + '.(isset($item['icon']) ? ' ' : '').$item['description'].(!empty($item['children']) ? '':'').''; + if (!empty($item['children'])) { - $toPrint = "%s=%s"; - $tofill['children'][] = array('link' => sprintf($toPrint, base_url('index.ci.php/system/infocenter/InfoCenter?filterId'), $filterId), 'description' => $description); + $level = ''; + if ($depth === 1) + $level = 'second'; + elseif ($depth > 1) + $level = 'third'; + + echo ''; } + echo '
  • '; } -} \ No newline at end of file +} diff --git a/application/widgets/navigation.php b/application/widgets/navigation.php deleted file mode 100644 index 67e1af8b2..000000000 --- a/application/widgets/navigation.php +++ /dev/null @@ -1,17 +0,0 @@ -view('widgets/navigation', $data); - } - -} \ No newline at end of file