diff --git a/application/config/fhcomplete.php b/application/config/fhcomplete.php index 29c93e2e4..3b24595a7 100644 --- a/application/config/fhcomplete.php +++ b/application/config/fhcomplete.php @@ -116,7 +116,6 @@ $config['fhc_acl'] = array 'lehre.tbl_vertrag' => 'basis/vertrag', 'lehre.tbl_vertragsstatus' => 'basis/vertragsstatus', 'lehre.tbl_vertragstyp' => 'basis/vertragstyp', - 'lehre.tbl_zeitfenster' => 'basis/zeitfenster', 'lehre.tbl_zeugnis' => 'basis/zeugnis', 'lehre.tbl_zeugnisnote' => 'basis/zeugnisnote', 'lehre.vw_studienplan' => 'lehre/studienplan', @@ -125,8 +124,6 @@ $config['fhc_acl'] = array 'public.tbl_ampel' => 'basis/ampel', 'public.tbl_aufmerksamdurch' => 'basis/aufmerksamdurch', 'public.tbl_aufnahmeschluessel' => 'basis/aufnahmeschluessel', - 'public.tbl_aufnahmetermin' => 'basis/aufnahmetermin', - 'public.tbl_aufnahmetermintyp' => 'basis/aufnahmetermintyp', 'public.tbl_bankverbindung' => 'basis/bankverbindung', 'public.tbl_benutzer' => 'basis/benutzer', 'public.tbl_benutzerfunktion' => 'basis/benutzerfunktion', @@ -240,8 +237,6 @@ $config['fhc_acl'] = array DMS_PATH => 'fs/dms', - 'public.tbl_sprache' => 'admin', - 'PhrasesLib.getPhrase' => 'system/PhrasesLib' ); diff --git a/application/config/roles.php b/application/config/roles.php index 6c2d0614b..227321f32 100644 --- a/application/config/roles.php +++ b/application/config/roles.php @@ -55,7 +55,7 @@ $config['roles'] = array ( 'basis/adresse','basis/akte','basis/kontakt','basis/log','basis/nation','basis/notiz','basis/notizzuordnung', 'basis/person','basis/prestudent','basis/prestudentstatus','basis/status','basis/zgv','basis/zgvmaster', - 'lehre/studienplan','system/filters','fs/dms' + 'lehre/studienplan','system/filters','fs/dms','basis/message','basis/benutzerrolle', 'basis/sprache' ) ) ); diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index 73d405dcc..2c2474a1e 100644 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -4,6 +4,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class Messages extends VileSci_Controller { + private $uid; // contains the UID of the logged user + /** * */ @@ -18,14 +20,33 @@ class Messages extends VileSci_Controller $this->load->library('WidgetLib'); $this->load->model('person/Person_model', 'PersonModel'); + + $this->_setAuthUID(); // sets property uid } /** * write */ - public function write($sender_id, $msg_id = null, $receiver_id = null) + public function write($sender_id = null, $msg_id = null, $receiver_id = null) { + if ($sender_id === null) + { + $user_person = $this->PersonModel->getByUid($this->uid); + + if (isError($user_person)) + { + show_error($user_person->retval); + } + $sender_id = $user_person->retval[0]->person_id; + } + $prestudent_id = $this->input->post('prestudent_id'); + $person_id = $this->input->post('person_id'); + $personOnly = false; + + if (isset($person_id) && !isset($prestudent_id)) + $personOnly = true; + $msg = null; // Get message data if possible @@ -42,30 +63,15 @@ class Messages extends VileSci_Controller } } + $variablesArray = array(); + $msgVarsData = array(); + // Get variables $this->load->model('system/Message_model', 'MessageModel'); - $msgVarsDataByPrestudentId = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); - if ($msgVarsDataByPrestudentId->error) - { - show_error($msgVarsDataByPrestudentId->retval); - } - - if (!hasData($variables = $this->MessageModel->getMessageVars())) - { - unset($variables); - } + if ($personOnly === true) + $this->getPersonMsgData($person_id, $variablesArray, $msgVarsData); else - { - $variablesArray = array(); - // Skip person_id and prestudent_id - for($i = 2; $i < count($variables->retval); $i++) - { - $variablesArray['{'.str_replace(" ", "_", strtolower($variables->retval[$i])).'}'] = $variables->retval[$i]; - } - } - - array_shift($variables->retval); // Remove person_id - array_shift($variables->retval); // Remove prestudent_id + $this->getPrestudentMsgData($prestudent_id, $variablesArray, $msgVarsData); // Organisation units used to get the templates $oe_kurzbz = array(); // A person can have more organisation units @@ -73,7 +79,7 @@ class Messages extends VileSci_Controller $benutzerResult = $this->BenutzerfunktionModel->getByPersonId($sender_id); if (hasData($benutzerResult)) { - foreach($benutzerResult->retval as $val) + foreach ($benutzerResult->retval as $val) { $oe_kurzbz[] = $val->oe_kurzbz; } @@ -89,26 +95,101 @@ class Messages extends VileSci_Controller $data = array ( 'sender_id' => $sender_id, - 'receivers' => $msgVarsDataByPrestudentId->retval, + 'receivers' => isset($msgVarsData->retval) ? $msgVarsData->retval : $msgVarsData, 'message' => $msg, 'variables' => $variablesArray, 'oe_kurzbz' => $oe_kurzbz, // used to get the templates - 'isAdmin' => $isAdmin->retval + 'isAdmin' => $isAdmin->retval, + 'personOnly' => $personOnly//indicates if sent only to persons ); $v = $this->load->view('system/messageWrite', $data); } + /** + * gets Message Variables and their data for Prestudent + * @param $prestudent_id + * @param $variablesArray to be filled with variable names + * @param $msgVarsData to be filled with variable data + */ + private function getPrestudentMsgData($prestudent_id, &$variablesArray, &$msgVarsData) + { + $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); + if ($msgVarsData->error) + { + show_error($msgVarsData->retval); + } + + if (!hasData($variables = $this->MessageModel->getMessageVars())) + { + unset($variables); + } + else + { + $variablesArray = array(); + // Skip person_id and prestudent_id + for ($i = 2; $i < count($variables->retval); $i++) + { + $variablesArray['{'.str_replace(" ", "_", strtolower($variables->retval[$i])).'}'] = $variables->retval[$i]; + } + } + + array_shift($variables->retval); // Remove person_id + array_shift($variables->retval); // Remove prestudent_id + } + + /** + * gets Message Variables and their data for Person + * @param $person_id + * @param $variablesArray to be filled with variable names + * @param $msgVarsData to be filled with variable data + */ + private function getPersonMsgData($person_id, &$variablesArray, &$msgVarsData) + { + $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($person_id); + if ($msgVarsData->error) + { + show_error($msgVarsData->retval); + } + + if (!hasData($variables = $this->MessageModel->getMessageVarsPerson())) + { + unset($variables); + } + else + { + $variablesArray = array(); + // Skip person_id + for ($i = 1; $i < count($variables->retval); $i++) + { + $variablesArray['{'.str_replace(" ", "_", strtolower($variables->retval[$i])).'}'] = $variables->retval[$i]; + } + array_shift($variables->retval); // Remove person_id + } + } + /** * send */ - public function send($sender_id) + public function send($sender_id = null) { + if ($sender_id === null) + { + $user_person = $this->PersonModel->getByUid($this->uid); + + if (isError($user_person)) + { + show_error($user_person->retval); + } + $sender_id = $user_person->retval[0]->person_id; + } + $error = false; $subject = $this->input->post('subject'); $body = $this->input->post('body'); $prestudents = $this->input->post('prestudents'); + $persons = $this->input->post('persons'); $relationmessage_id = $this->input->post('relationmessage_id'); if (!isset($relationmessage_id) || $relationmessage_id == '') @@ -116,21 +197,26 @@ class Messages extends VileSci_Controller $relationmessage_id = null; } - // - $data = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents); + // get message data of prestudents or persons + $prestudentsData = array(); + if ($prestudents !== null) + { + $data = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents); + // + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $prestudentsData = $this->PrestudentModel->getOrganisationunits($prestudents); + } + else + $data = $this->MessageModel->getMsgVarsDataByPersonId($persons); - // - $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - $prestudentsData = $this->PrestudentModel->getOrganisationunits($prestudents); - - // - if (hasData($data) && hasData($prestudentsData)) + // send message(s) + if (hasData($data)) { for ($i = 0; $i < count($data->retval); $i++) { $parsedText = ""; $dataArray = (array)$data->retval[$i]; - foreach($dataArray as $key => $val) + foreach ($dataArray as $key => $val) { $newKey = str_replace(" ", "_", strtolower($key)); $dataArray[$newKey] = $dataArray[$key]; @@ -138,12 +224,15 @@ class Messages extends VileSci_Controller $parsedText = $this->messagelib->parseMessageText($body, $dataArray); - $oe_kurzbz = ''; - for ($p = 0; $p < count($prestudentsData->retval); $p++) + $oe_kurzbz = null; + if (hasData($prestudentsData)) { - if ($prestudentsData->retval[$p]->prestudent_id == $data->retval[$i]->prestudent_id) + for ($p = 0; $p < count($prestudentsData->retval); $p++) { - $oe_kurzbz = $prestudentsData->retval[$p]->oe_kurzbz; + if ($prestudentsData->retval[$p]->prestudent_id == $data->retval[$i]->prestudent_id) + { + $oe_kurzbz = $prestudentsData->retval[$p]->oe_kurzbz; + } } } @@ -154,6 +243,24 @@ class Messages extends VileSci_Controller $error = true; break; } + + // Loads the person log library + $this->load->library('PersonLogLib'); + + //write log entry + $this->personloglib->log( + $dataArray['person_id'], + 'Action', + array( + 'name' => 'Message sent', + 'message' => 'Message sent from person '.$sender_id.' to '.$dataArray['person_id'].', messageid '.$msg->retval, + 'success' => 'true' + ), + 'kommunikation', + 'core', + null, + $this->uid + ); } } @@ -174,7 +281,7 @@ class Messages extends VileSci_Controller { $person_id = $this->input->get('person_id'); } - else if ($this->input->post('person_id') !== null) + elseif ($this->input->post('person_id') !== null) { $person_id = $this->input->get('person_id'); } @@ -187,6 +294,16 @@ class Messages extends VileSci_Controller return $person_id; } + /** + * Retrieve 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'); + } + /** * getVorlage */ @@ -211,17 +328,23 @@ class Messages extends VileSci_Controller public function parseMessageText() { $prestudent_id = $this->input->get('prestudent_id'); + $person_id = $this->input->get('person_id'); $text = $this->input->get('text'); - if (isset($prestudent_id)) - { + $data = null; + + if (isset($person_id) && !isset($prestudent_id)) + $data = $this->MessageModel->getMsgVarsDataByPersonId($person_id); + elseif (isset($prestudent_id)) $data = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); + if (isset($data)) + { $parsedText = ""; if (hasData($data)) { $dataArray = (array)$data->retval[0]; - foreach($dataArray as $key => $val) + foreach ($dataArray as $key => $val) { $newKey = str_replace(" ", "_", strtolower($key)); $dataArray[$newKey] = $dataArray[$key]; @@ -235,4 +358,19 @@ class Messages extends VileSci_Controller ->set_output(json_encode($parsedText)); } } + + /** + * Outputs message data for a message (identified my msg id and receiver id) in JSON format + * @param $msg_id + * @param $receiver_id + */ + public function getMessageFromIds($msg_id, $receiver_id) + { + $msg = $this->messagelib->getMessage($msg_id, $receiver_id); + + $this->output + ->set_content_type('application/json') + ->set_output(json_encode(array($msg->retval[0]))); + } + } diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index 4f4cefd79..f1cd674b7 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -11,16 +11,17 @@ class InfoCenter extends VileSci_Controller // App and Verarbeitungstaetigkeit name for logging const APP = 'infocenter'; const TAETIGKEIT = 'bewerbung'; + const FILTER_ID = 'filter_id'; // URL prefix for this controller - const URL_PREFIX = '/system/infocenter/InfoCenter/'; + 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' + 'name' => 'Document formally checked', + 'message' => 'Document %s formally checked, set to %s' ), 'savezgv' => array( 'logtype' => 'Action', @@ -35,12 +36,12 @@ class InfoCenter extends VileSci_Controller 'freigegeben' => array( 'logtype' => 'Processstate', 'name' => 'Interessent confirmed', - 'message' => 'status Interessent for prestudentid %s was confirmed for degree program %s' + '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' + 'name' => 'Note added', + 'message' => 'Note with title %s was added' ) ); private $uid; // contains the UID of the logged user @@ -61,7 +62,8 @@ class InfoCenter extends VileSci_Controller $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->model('system/message_model', 'MessageModel'); + $this->load->model('system/filters_model', 'FiltersModel'); // Loads libraries $this->load->library('DmsLib'); @@ -164,7 +166,7 @@ class InfoCenter extends VileSci_Controller ) ); - redirect(self::URL_PREFIX.'showDetails/'.$person_id.'#DokPruef'); + redirect(self::URL_PREFIX.'/showDetails/'.$person_id.'#DokPruef'); } /** @@ -232,40 +234,43 @@ class InfoCenter extends VileSci_Controller 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)) + //check if still Interessent and not freigegeben yet + if($lastStatus->retval[0]->status_kurzbz === 'Interessent' && !isset($lastStatus->retval[0]->bestaetigtam)) { - show_error($result->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)); } - - $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'); } @@ -282,31 +287,35 @@ class InfoCenter extends VileSci_Controller { $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)) + //check if still Interessent and not freigegeben yet + if($lastStatus->status_kurzbz === 'Interessent' && !isset($lastStatus->bestaetigtam)) { - show_error($result->retval); + $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'])); } } - $logdata = $this->_getPersonAndStudiengangFromPrestudent($prestudent_id); - - $this->_log($logdata['person_id'], 'freigegeben', array($prestudent_id, $logdata['studiengang_kurzbz'])); - $this->_redirectToStart($prestudent_id, 'ZgvPruef'); } @@ -329,7 +338,7 @@ class InfoCenter extends VileSci_Controller $this->_log($person_id, 'savenotiz', array($titel)); - redirect(self::URL_PREFIX.'showDetails/'.$person_id.'#NotizAkt'); + redirect(self::URL_PREFIX.'/showDetails/'.$person_id.'#NotizAkt'); } /** @@ -360,6 +369,21 @@ class InfoCenter extends VileSci_Controller ->_display(); } + /** + * + */ + public function deleteCustomFilter() + { + $filter_id = $this->input->get('filter_id'); + + if (is_numeric($filter_id)) + { + $this->FiltersModel->deleteCustomFilter($filter_id); + + redirect(self::URL_PREFIX); + } + } + // ----------------------------------------------------------------------------------------------------------------- // Private methods @@ -378,6 +402,9 @@ class InfoCenter extends VileSci_Controller */ private function _setNavigationMenuArray() { + $listFiltersSent = array(); + $listFiltersNotSent = array(); + $filtersSent = $this->FiltersModel->getFilterList('infocenter', 'PersonActions', '%InfoCenterSentApplication%'); if (hasData($filtersSent)) { @@ -400,6 +427,17 @@ class InfoCenter extends VileSci_Controller } } + $customFilters = $this->FiltersModel->getCustomFiltersList('infocenter', 'PersonActions', $this->uid); + if (hasData($customFilters)) + { + for ($filtersCounter = 0; $filtersCounter < count($customFilters->retval); $filtersCounter++) + { + $filter = $customFilters->retval[$filtersCounter]; + + $listCustomFilters[$filter->filter_id] = $filter->description[0]; + } + } + $filtersarray = array( 'abgeschickt' => array( 'link' => '#', @@ -418,6 +456,18 @@ class InfoCenter extends VileSci_Controller $this->_fillFilters($listFiltersSent, $filtersarray['abgeschickt']); $this->_fillFilters($listFiltersNotSent, $filtersarray['nichtabgeschickt']); + if (isset($listCustomFilters) && is_array($listCustomFilters) && count($listCustomFilters) > 0) + { + $filtersarray['personal'] = array( + 'link' => '#', + 'description' => 'Personal filters', + 'expand' => true, + 'children' => array() + ); + + $this->_fillCustomFilters($listCustomFilters, $filtersarray['personal']); + } + $this->navigationMenuArray = array( 'dashboard' => array( 'link' => '#', @@ -440,12 +490,26 @@ class InfoCenter extends VileSci_Controller { $toPrint = "%s=%s"; $tofill['children'][] = array( - 'link' => sprintf($toPrint, base_url('index.ci.php/system/infocenter/InfoCenter?filterId'), $filterId), + 'link' => sprintf($toPrint, base_url('index.ci.php/system/infocenter/InfoCenter?filter_id'), $filterId), 'description' => $description ); } } + private function _fillCustomFilters($filters, &$tofill) + { + foreach ($filters as $filterId => $description) + { + $toPrint = "%s=%s"; + $tofill['children'][] = array( + 'link' => sprintf($toPrint, base_url('index.ci.php/system/infocenter/InfoCenter?filter_id'), $filterId), + 'description' => $description, + 'subscriptLink' => sprintf($toPrint, base_url('index.ci.php/system/infocenter/InfoCenter/deleteCustomFilter?filter_id'), $filterId), + 'subscriptDescription' => 'Remove' + ); + } + } + /** * Loads all necessary Person data: Stammdaten (name, svnr, contact, ...), Dokumente, Logs and Notizen * @param $person_id @@ -453,7 +517,7 @@ class InfoCenter extends VileSci_Controller */ private function _loadPersonData($person_id) { - $stammdaten = $this->PersonModel->getPersonStammdaten($person_id); + $stammdaten = $this->PersonModel->getPersonStammdaten($person_id, true); if (isError($stammdaten)) { @@ -474,7 +538,14 @@ class InfoCenter extends VileSci_Controller if (isError($dokumente_nachgereicht)) { - show_error($dokumente->retval); + show_error($dokumente_nachgereicht->retval); + } + + $messages = $this->MessageModel->getMessagesOfPerson($person_id, 1); + + if (isError($messages)) + { + show_error($messages->retval); } $logs = $this->personloglib->getLogs($person_id); @@ -486,12 +557,23 @@ class InfoCenter extends VileSci_Controller show_error($notizen->retval); } + $user_person = $this->PersonModel->getByUid($this->uid); + + if (isError($user_person)) + { + show_error($user_person->retval); + } + + $messagelink = base_url('/index.ci.php/system/Messages/write/'.$user_person->retval[0]->person_id); + $data = array ( 'stammdaten' => $stammdaten->retval, 'dokumente' => $dokumente->retval, 'dokumente_nachgereicht' => $dokumente_nachgereicht->retval, + 'messages' => $messages->retval, 'logs' => $logs, - 'notizen' => $notizen->retval + 'notizen' => $notizen->retval, + 'messagelink' => $messagelink ); return $data; @@ -578,7 +660,7 @@ class InfoCenter extends VileSci_Controller $this->PrestudentModel->addSelect('person_id'); $person_id = $this->PrestudentModel->load($prestudent_id)->retval[0]->person_id; - redirect(self::URL_PREFIX.'showDetails/'.$person_id.'#'.$section); + redirect(self::URL_PREFIX.'/showDetails/'.$person_id.'#'.$section); } /** diff --git a/application/helpers/fhc_helper.php b/application/helpers/fhc_helper.php index a7b5b2a29..549247754 100644 --- a/application/helpers/fhc_helper.php +++ b/application/helpers/fhc_helper.php @@ -9,7 +9,7 @@ * @license GPLv3 * @since Version 1.0.0 */ - + /** * FHC Helper * @@ -33,7 +33,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); function generateToken($length = 64) { // For PHP 7 you can use random_bytes() - if(function_exists('random_bytes')) + if (function_exists('random_bytes')) { $token = base64_encode(random_bytes($length)); //base64 is about 33% longer, so we need to truncate the result @@ -41,7 +41,7 @@ function generateToken($length = 64) } // for PHP >=5.3 and <7 - if(function_exists('openssl_random_pseudo_bytes')) + if (function_exists('openssl_random_pseudo_bytes')) { $token = base64_encode(openssl_random_pseudo_bytes($length, $strong)); // is the token strong enough? @@ -51,12 +51,13 @@ function generateToken($length = 64) //fallback to mt_rand if php < 5.3 or no openssl available $characters = '0123456789'; - $characters .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/+'; + $characters .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/+'; $charactersLength = strlen($characters)-1; $token = ''; //select some random characters for ($i = 0; $i < $length; $i++) $token .= $characters[mt_rand(0, $charactersLength)]; + return $token; } @@ -96,18 +97,18 @@ function loadResource($path, $resources = null, $subdir = false) { $path .= '/'; } - + // Loads in $tmpResources all the given resources $tmpResources = $resources; if ($resources == null) { $tmpResources = array(); } - else if (!is_array($resources)) + elseif (!is_array($resources)) { $tmpResources = array($resources); } - + // Loads in $tmpPaths path and eventually the subdirectories $tmpPaths = array($path); // NOTE: Used @ to prevent ugly error messages @@ -133,12 +134,12 @@ function loadResource($path, $resources = null, $subdir = false) } closedir($dirHandler); } - + // Loops through the resources - foreach($tmpResources as $tmpResource) + foreach ($tmpResources as $tmpResource) { // Loops through the paths - foreach($tmpPaths as $tmpPath) + foreach ($tmpPaths as $tmpPath) { $fileName = $tmpPath.$tmpResource.'.php'; // Php extension if (file_exists($fileName)) @@ -147,4 +148,4 @@ function loadResource($path, $resources = null, $subdir = false) } } } -} \ No newline at end of file +} diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index eea05cef6..ee5f77230 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -45,7 +45,7 @@ class MessageLib } /** - * getMessage() - returns the spicified received message for a specified person + * getMessage() - returns the specified received message for a specified person */ public function getMessage($msg_id, $person_id) { diff --git a/application/models/crm/Aufnahmetermin_model.php b/application/models/crm/Aufnahmetermin_model.php deleted file mode 100644 index c023f6403..000000000 --- a/application/models/crm/Aufnahmetermin_model.php +++ /dev/null @@ -1,14 +0,0 @@ -dbTable = 'public.tbl_aufnahmetermin'; - $this->pk = 'aufnahmetermin_id'; - } -} diff --git a/application/models/crm/Aufnahmetermintyp_model.php b/application/models/crm/Aufnahmetermintyp_model.php deleted file mode 100644 index e75db011c..000000000 --- a/application/models/crm/Aufnahmetermintyp_model.php +++ /dev/null @@ -1,14 +0,0 @@ -dbTable = 'public.tbl_aufnahmetermintyp'; - $this->pk = 'aufnahmetermintyp_kurzbz'; - } -} diff --git a/application/models/person/Benutzer_model.php b/application/models/person/Benutzer_model.php index 339c7ea11..221688c21 100644 --- a/application/models/person/Benutzer_model.php +++ b/application/models/person/Benutzer_model.php @@ -11,4 +11,11 @@ class Benutzer_model extends DB_Model $this->dbTable = 'public.tbl_benutzer'; $this->pk = 'uid'; } + + public function getFromPersonId($person_id) + { + /*$this->addSelect('uid, aktiv, alias');*/ + $this->loadWhere(array('person_id' => $person_id)); + } + } diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index caf746b94..9c6f14f89 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -157,13 +157,14 @@ class Person_model extends DB_Model * gets Stammdaten for a person, including contactdata in textform from other tables * nation, kontakt, adresse * @param $person_id - * @return array + * @param bool $zustellung_only, when true, retrieve only Zustellkontakte + * @return array, null when no person found */ - public function getPersonStammdaten($person_id) + public function getPersonStammdaten($person_id, $zustellung_only = false) { - $this->addSelect('tbl_person.*, s.kurztext as staatsbuergerschaft, g.kurztext as geburtsnation'); - $this->addJoin('bis.tbl_nation s', 'tbl_person.staatsbuergerschaft = s.nation_code', 'LEFT'); - $this->addJoin('bis.tbl_nation g', 'tbl_person.geburtsnation = g.nation_code', 'LEFT'); + $this->addSelect('public.tbl_person.*, s.kurztext as staatsbuergerschaft, g.kurztext as geburtsnation'); + $this->addJoin('bis.tbl_nation s', 'public.tbl_person.staatsbuergerschaft = s.nation_code', 'LEFT'); + $this->addJoin('bis.tbl_nation g', 'public.tbl_person.geburtsnation = g.nation_code', 'LEFT'); $person = $this->load($person_id); @@ -180,11 +181,12 @@ class Person_model extends DB_Model $this->KontaktModel->addDistinct(); $this->KontaktModel->addSelect('kontakttyp, anmerkung, kontakt, zustellung'); $this->KontaktModel->addOrder('kontakttyp'); - $kontakte = $this->KontaktModel->loadWhere(array('person_id' => $person_id)); + $where = $zustellung_only === true ? array('person_id' => $person_id, 'zustellung' => true) : array('person_id' => $person_id); + $kontakte = $this->KontaktModel->loadWhere($where); if($kontakte->error) return error($kontakte->retval); - - $adressen = $this->AdresseModel->loadWhere(array('person_id' => $person_id)); + $where = $zustellung_only === true ? array('person_id' => $person_id, 'zustelladresse' => true) : array('person_id' => $person_id); + $adressen = $this->AdresseModel->loadWhere($where); if($adressen->error) return error($adressen->retval); @@ -194,4 +196,18 @@ class Person_model extends DB_Model return success($stammdaten); } + + /** + * gets person data from uid + * @param $uid + * @return array + */ + public function getByUid($uid) + { + $this->addSelect('vorname, nachname, gebdatum, person_id'); + $this->addJoin('tbl_benutzer', 'person_id'); + + return $this->loadWhere(array('uid' => $uid)); + } + } diff --git a/application/models/ressource/Zeitfenster_model.php b/application/models/ressource/Zeitfenster_model.php deleted file mode 100644 index e9ef6709c..000000000 --- a/application/models/ressource/Zeitfenster_model.php +++ /dev/null @@ -1,14 +0,0 @@ -dbTable = 'lehre.tbl_zeitfenster'; - $this->pk = array('wochentag', 'studiengang_kz', 'ort_kurzbz', 'stunde'); - } -} diff --git a/application/models/system/Filters_model.php b/application/models/system/Filters_model.php index 1395a7a40..d84cddf80 100644 --- a/application/models/system/Filters_model.php +++ b/application/models/system/Filters_model.php @@ -29,6 +29,34 @@ class Filters_model extends DB_Model 'filter_kurzbz ILIKE' => $filter_kurzbz ); - return $this->FiltersModel->loadWhere($filterParametersArray); + return $this->loadWhere($filterParametersArray); + } + + /** + * + */ + public function getCustomFiltersList($app, $dataset_name, $uid) + { + $this->addSelect('filter_id, description'); + $this->addJoin('public.tbl_benutzer', 'person_id'); + $this->addOrder('sort', 'ASC'); + + $filterParametersArray = array( + 'app' => $app, + 'dataset_name' => $dataset_name, + 'default_filter' => false, + 'array_length(description, 1) >' => 0, + 'uid' => $uid + ); + + return $this->loadWhere($filterParametersArray); + } + + /** + * + */ + public function deleteCustomFilter($filter_id) + { + return $this->delete($filter_id); } } diff --git a/application/models/system/Message_model.php b/application/models/system/Message_model.php index a99716022..80a2b35ad 100644 --- a/application/models/system/Message_model.php +++ b/application/models/system/Message_model.php @@ -85,6 +85,77 @@ class Message_model extends DB_Model return $this->execQuery($sql, $parametersArray); } + /** + * Gets massages with a person being sender OR receiver. + * @param $person_id + * @param null $status message status. by default, latest status is returned + * @return array|null + */ + public function getMessagesOfPerson($person_id, $status = null) + { + // Checks if the operation is permitted by the API caller + if (isError($ent = $this->isEntitled('public.tbl_person', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR))) + return $ent; + if (isError($ent = $this->isEntitled('public.tbl_msg_status', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR))) + return $ent; + if (isError($ent = $this->isEntitled('public.tbl_msg_message', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR))) + return $ent; + if (isError($ent = $this->isEntitled('public.tbl_msg_recipient', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR))) + return $ent; + + $sql = 'SELECT m.message_id, + m.person_id, + m.subject, + m.body, + m.priority, + m.insertamum, + m.relationmessage_id, + m.oe_kurzbz, + se.person_id AS sepersonid, + se.anrede AS seanrede, + se.titelpost AS setitelpost, + se.titelpre AS setitelpre, + se.nachname AS senachname, + se.vorname AS sevorname, + se.vornamen AS sevornamen, + re.person_id AS repersonid, + re.anrede AS reanrede, + re.titelpost AS retitelpost, + re.titelpre AS retitelpre, + re.nachname AS renachname, + re.vorname AS revorname, + re.vornamen AS revornamen, + s.status, + s.statusinfo, + s.insertamum AS statusamum + FROM public.tbl_msg_message m + JOIN public.tbl_msg_recipient r ON m.message_id = r.message_id + JOIN public.tbl_person se ON (m.person_id = se.person_id) + JOIN public.tbl_person re ON (r.person_id = re.person_id) + LEFT JOIN ( + SELECT message_id, person_id, status, statusinfo, insertamum + FROM public.tbl_msg_status + %s + ORDER BY insertamum DESC + ) s ON (m.message_id = s.message_id AND re.person_id = s.person_id) + WHERE se.person_id = ? + OR re.person_id = ? + '; + + if (is_numeric($status)) + { + $sql = sprintf($sql, 'WHERE status = '.$status); + } + else + { + $sql = sprintf($sql, ''); + } + + $parametersArray = array($person_id, $person_id); + + return $this->execQuery($sql, $parametersArray); + } + /** * getMessageVars */ @@ -102,6 +173,23 @@ class Message_model extends DB_Model } } + /** + * getMessageVars for person + */ + public function getMessageVarsPerson() + { + $result = $this->db->query('SELECT * FROM public.vw_msg_vars_person WHERE 0 = 1'); + + if ($result) + { + return success($result->list_fields()); + } + else + { + return error($this->db->error(), FHC_DB_ERROR); + } + } + /** * getMsgVarsDataByPrestudentId */ @@ -111,4 +199,14 @@ class Message_model extends DB_Model return $this->execQuery(sprintf($query, is_array($prestudent_id) ? 'IN' : '='), array($prestudent_id)); } + + /** + * getMsgVarsDataByPersonId + */ + public function getMsgVarsDataByPersonId($person_id) + { + $query = 'SELECT * FROM public.vw_msg_vars_person WHERE person_id %s ?'; + + return $this->execQuery(sprintf($query, is_array($person_id) ? 'IN' : '='), array($person_id)); + } } diff --git a/application/views/system/infocenter/addNotiz.php b/application/views/system/infocenter/addNotiz.php new file mode 100644 index 000000000..25af11897 --- /dev/null +++ b/application/views/system/infocenter/addNotiz.php @@ -0,0 +1,19 @@ +
\ No newline at end of file diff --git a/application/views/system/infocenter/dokpruefung.php b/application/views/system/infocenter/dokpruefung.php new file mode 100644 index 000000000..1c303e3c2 --- /dev/null +++ b/application/views/system/infocenter/dokpruefung.php @@ -0,0 +1,65 @@ +| Name | +Typ | +Uploaddatum | +Ausstellungsnation | +Formal geprüft | +
|---|---|---|---|---|
| + titel) ? $dokument->bezeichnung : $dokument->titel ?> + | +dokument_bezeichnung ?> | +erstelltam), 'd.m.Y') ?> | +langtext ?> | ++ /> + formal_geprueft_amum) ? date_format(date_create($dokument->formal_geprueft_amum), 'd.m.Y') : ''; ?> + | +
Nachzureichende Dokumente:
+| Typ | +Nachzureichen am | +Ausstellungsnation | +Anmerkung | +
|---|---|---|---|
| dokument_bezeichnung ?> | ++ nachgereicht_am) ? date_format(date_create($dokument->nachgereicht_am), 'd.m.Y') : ''; ?> + | ++ langtext ?> + | ++ anmerkung; ?> + | +