From bd2318bd381c15ef393357df8eaa960b9cc02695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Tue, 20 Feb 2018 17:17:56 +0100 Subject: [PATCH 01/35] MailDebug now also "works" with invalid Mail Fixed Typo and Intendation --- application/libraries/LogLib.php | 2 +- application/libraries/MailLib.php | 8 +- application/libraries/MessageLib.php | 270 +++++++++++++-------------- 3 files changed, 141 insertions(+), 139 deletions(-) diff --git a/application/libraries/LogLib.php b/application/libraries/LogLib.php index 222ed7cc7..a42132644 100644 --- a/application/libraries/LogLib.php +++ b/application/libraries/LogLib.php @@ -55,7 +55,7 @@ class LogLib $function = $backtrace_arr[$functionIndex]['function']; } - if (isset($backtrace_arr[$lineIndex]['line']) && $backgrace_arr[$lineIndex]['line'] != '') + if (isset($backtrace_arr[$lineIndex]['line']) && $backtrace_arr[$lineIndex]['line'] != '') { $line = $backtrace_arr[$lineIndex]['line']; } diff --git a/application/libraries/MailLib.php b/application/libraries/MailLib.php index 5c7093461..8e21815f0 100644 --- a/application/libraries/MailLib.php +++ b/application/libraries/MailLib.php @@ -65,12 +65,14 @@ class MailLib $recipient = $to; $recipientCC = $cc; $recipientBCC = $bcc; - if ($this->validateEmailAddress(MAIL_DEBUG)) + if (defined('MAIL_DEBUG') && MAIL_DEBUG != '') { // if is it valid use it!!! $recipient = MAIL_DEBUG; - $recipientCC = MAIL_DEBUG; - $recipientBCC = MAIL_DEBUG; + if ($recipientCC != '') + $recipientCC = MAIL_DEBUG; + if ($recipientBCC != '') + $recipientBCC = MAIL_DEBUG; } $this->ci->email->to($recipient); diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index ee5f77230..02ba1e65e 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -15,7 +15,7 @@ class MessageLib public function __construct() { // Get code igniter instance - $this->ci =& get_instance(); + $this->ci =& get_instance(); // Loads message configuration $this->ci->config->load('message'); @@ -41,70 +41,70 @@ class MessageLib $this->ci->load->helper('message'); // Loads phrases - $this->ci->lang->load('message'); - } + $this->ci->lang->load('message'); + } - /** - * getMessage() - returns the specified received message for a specified person - */ - public function getMessage($msg_id, $person_id) - { - if (empty($msg_id)) - return $this->_error('', MSG_ERR_INVALID_MSG_ID); + /** + * getMessage() - returns the specified received message for a specified person + */ + public function getMessage($msg_id, $person_id) + { + if (empty($msg_id)) + return $this->_error('', MSG_ERR_INVALID_MSG_ID); if (empty($person_id)) - return $this->_error('', MSG_ERR_INVALID_RECIPIENTS); + return $this->_error('', MSG_ERR_INVALID_RECIPIENTS); $msg = $this->ci->RecipientModel->getMessage($msg_id, $person_id); - return $msg; - } + return $msg; + } /** - * getMessagesByUID() - will return all messages, including the latest status for specified user. It don´t returns Attachments. - */ - public function getMessagesByUID($uid, $oe_kurzbz = null, $all = false) - { - if (empty($uid)) - return $this->_error('', MSG_ERR_INVALID_MSG_ID); + * getMessagesByUID() - will return all messages, including the latest status for specified user. It don´t returns Attachments. + */ + public function getMessagesByUID($uid, $oe_kurzbz = null, $all = false) + { + if (empty($uid)) + return $this->_error('', MSG_ERR_INVALID_MSG_ID); $msg = $this->ci->RecipientModel->getMessagesByUID($uid, $oe_kurzbz, $all); - return $msg; - } + return $msg; + } /** - * getMessagesByPerson() - will return all messages, including the latest status for specified user. It don´t returns Attachments. - */ - public function getMessagesByPerson($person_id, $oe_kurzbz = null, $all = false) - { - if (empty($person_id)) - return $this->_error('', MSG_ERR_INVALID_MSG_ID); + * getMessagesByPerson() - will return all messages, including the latest status for specified user. It don´t returns Attachments. + */ + public function getMessagesByPerson($person_id, $oe_kurzbz = null, $all = false) + { + if (empty($person_id)) + return $this->_error('', MSG_ERR_INVALID_MSG_ID); $msg = $this->ci->RecipientModel->getMessagesByPerson($person_id, $oe_kurzbz, $all); - return $msg; - } + return $msg; + } /** - * getSentMessagesByPerson() - Get all sent messages from a person identified by person_id - */ - public function getSentMessagesByPerson($person_id, $oe_kurzbz = null, $all = false) - { - if (empty($person_id)) - return $this->_error('', MSG_ERR_INVALID_MSG_ID); + * getSentMessagesByPerson() - Get all sent messages from a person identified by person_id + */ + public function getSentMessagesByPerson($person_id, $oe_kurzbz = null, $all = false) + { + if (empty($person_id)) + return $this->_error('', MSG_ERR_INVALID_MSG_ID); $msg = $this->ci->MessageModel->getMessagesByPerson($person_id, $oe_kurzbz, $all); - return $msg; - } + return $msg; + } /** - * getMessageByToken - */ - public function getMessageByToken($token) - { - if (empty($token)) - return $this->_error('', MSG_ERR_INVALID_TOKEN); + * getMessageByToken + */ + public function getMessageByToken($token) + { + if (empty($token)) + return $this->_error('', MSG_ERR_INVALID_TOKEN); $result = $this->ci->RecipientModel->getMessageByToken($token); if (hasData($result)) @@ -138,43 +138,43 @@ class MessageLib } } - return $result; - } + return $result; + } - /** - * getCountUnreadMessages - */ - public function getCountUnreadMessages($person_id, $oe_kurzbz = null) - { - if (!is_numeric($person_id)) - return $this->_error('', MSG_ERR_INVALID_RECIPIENTS); + /** + * getCountUnreadMessages + */ + public function getCountUnreadMessages($person_id, $oe_kurzbz = null) + { + if (!is_numeric($person_id)) + return $this->_error('', MSG_ERR_INVALID_RECIPIENTS); $msg = $this->ci->RecipientModel->getCountUnreadMessages($person_id, $oe_kurzbz); - return $msg; - } + return $msg; + } - /** - * updateMessageStatus() - will change status on message for particular user + /** + * updateMessageStatus() - will change status on message for particular user * NOTE: it performs an insert, NOT an update - */ - public function updateMessageStatus($message_id, $person_id, $status) - { - if (empty($message_id)) - { - return $this->_error('', MSG_ERR_INVALID_MSG_ID); - } + */ + public function updateMessageStatus($message_id, $person_id, $status) + { + if (empty($message_id)) + { + return $this->_error('', MSG_ERR_INVALID_MSG_ID); + } - if (empty($person_id)) - { - return $this->_error('', MSG_ERR_INVALID_USER_ID); - } + if (empty($person_id)) + { + return $this->_error('', MSG_ERR_INVALID_USER_ID); + } // NOTE: Not use empty otherwise if status is 0 it returns an error - if (!isset($status)) - { - return $this->_error('', MSG_ERR_INVALID_STATUS_ID); - } + if (!isset($status)) + { + return $this->_error('', MSG_ERR_INVALID_STATUS_ID); + } // Searches if the status is already present $result = $this->ci->MsgStatusModel->load(array($message_id, $person_id, $status)); @@ -195,17 +195,17 @@ class MessageLib } return $result; - } + } - /** - * sendMessage() - sends new internal message. This function will create a new thread - */ - public function sendMessage($sender_id, $receiver_id, $subject, $body, $priority = PRIORITY_NORMAL, $relationmessage_id = null, $oe_kurzbz = null, $multiPartMime = true) - { - if (!is_numeric($sender_id)) - { + /** + * sendMessage() - sends new internal message. This function will create a new thread + */ + public function sendMessage($sender_id, $receiver_id, $subject, $body, $priority = PRIORITY_NORMAL, $relationmessage_id = null, $oe_kurzbz = null, $multiPartMime = true) + { + if (!is_numeric($sender_id)) + { $sender_id = $this->ci->config->item('system_person_id'); - } + } $receivers = $this->_getReceivers($receiver_id, $oe_kurzbz); @@ -270,17 +270,17 @@ class MessageLib } return $result; - } + } /** - * sendMessageVorlage() - sends new internal message using a template - */ - public function sendMessageVorlage($sender_id, $receiver_id, $vorlage_kurzbz, $oe_kurzbz, $data, $relationmessage_id = null, $orgform_kurzbz = null, $multiPartMime = true) - { - if (!is_numeric($sender_id)) - { + * sendMessageVorlage() - sends new internal message using a template + */ + public function sendMessageVorlage($sender_id, $receiver_id, $vorlage_kurzbz, $oe_kurzbz, $data, $relationmessage_id = null, $orgform_kurzbz = null, $multiPartMime = true) + { + if (!is_numeric($sender_id)) + { $sender_id = $this->ci->config->item('system_person_id'); - } + } $receivers = $this->_getReceivers($receiver_id, $oe_kurzbz); @@ -387,7 +387,7 @@ class MessageLib } return $result; - } + } /** * Gets all the messages from DB and sends them via email @@ -464,16 +464,16 @@ class MessageLib $sender = $result->retval[0]->sender; } - $receiverContanct = $result->retval[$i]->receiver; + $receiverContact = $result->retval[$i]->receiver; if (!is_null($result->retval[$i]->employeecontact) && $result->retval[$i]->employeecontact != '') { - $receiverContanct = $result->retval[$i]->employeecontact.'@'.DOMAIN; + $receiverContact = $result->retval[$i]->employeecontact.'@'.DOMAIN; } // Sending email $sent = $this->ci->maillib->send( $sender, - $receiverContanct, + $receiverContact, $result->retval[$i]->subject, $body, null, @@ -613,16 +613,16 @@ class MessageLib $sender = $result->retval[0]->sender; } - $receiverContanct = $result->retval[0]->receiver; + $receiverContact = $result->retval[0]->receiver; if (!is_null($result->retval[0]->employeecontact) && $result->retval[0]->employeecontact != '') { - $receiverContanct = $result->retval[0]->employeecontact.'@'.DOMAIN; + $receiverContact = $result->retval[0]->employeecontact.'@'.DOMAIN; } // Sending email $sent = $this->ci->maillib->send( $sender, - $receiverContanct, + $receiverContact, is_null($subject) ? $result->retval[0]->subject : $subject, // if parameter subject is not null, use it! $bodyMsg, null, @@ -689,8 +689,8 @@ class MessageLib return $sent; } - // ------------------------------------------------------------------------ - // Private methods + // ------------------------------------------------------------------------ + // Private methods /** * Update the table tbl_msg_recipient @@ -736,10 +736,10 @@ class MessageLib } /** - * Gets the receivers id that are enabled to read messages for that oe_kurzbz - */ - private function _getReceiversByOekurzbz($oe_kurzbz) - { + * Gets the receivers id that are enabled to read messages for that oe_kurzbz + */ + private function _getReceiversByOekurzbz($oe_kurzbz) + { // Load Benutzerfunktion_model $this->ci->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); // Join with table public.tbl_benutzer on field uid @@ -752,13 +752,13 @@ class MessageLib ); return $receivers; - } + } - /** - * Gets the receivers id - */ - private function _getReceivers($receiver_id, $oe_kurzbz = null) - { + /** + * Gets the receivers id + */ + private function _getReceivers($receiver_id, $oe_kurzbz = null) + { $receivers = null; // If no receiver_id is given... @@ -782,13 +782,13 @@ class MessageLib } return $receivers; - } + } - /** - * Checks if the given receiver id is a valid person - */ - private function _checkReceiverId($receiver_id) - { + /** + * Checks if the given receiver id is a valid person + */ + private function _checkReceiverId($receiver_id) + { // Load Person_model $this->ci->load->model('person/Person_model', 'PersonModel'); $result = $this->ci->PersonModel->load($receiver_id); @@ -798,13 +798,13 @@ class MessageLib } return false; - } + } - /** - * Save a message in DB - **/ - private function _saveMessage($sender_id, $receiver_id, $subject, $body, $relationmessage_id, $oe_kurzbz) - { + /** + * Save a message in DB + **/ + private function _saveMessage($sender_id, $receiver_id, $subject, $body, $relationmessage_id, $oe_kurzbz) + { // Starts db transaction $this->ci->db->trans_start(false); @@ -854,27 +854,27 @@ class MessageLib } return $result; - } + } - /** - * Wrapper for function error - */ - private function _error($retval = '', $code = null) - { + /** + * Wrapper for function error + */ + private function _error($retval = '', $code = null) + { return error($retval, $code, MessageLib::MSG_INDX_PREFIX); - } + } - /** - * Wrapper for function success - */ - private function _success($retval = '', $code = null) - { + /** + * Wrapper for function success + */ + private function _success($retval = '', $code = null) + { return success($retval, $code, MessageLib::MSG_INDX_PREFIX); - } + } - /** - * - */ + /** + * + */ public function parseMessageText($text, $data = array()) { return $this->ci->parser->parse_string($text, $data, true); From 4b4dcfff596f822363d8ea747bf878be3bd5b61c Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 20 Feb 2018 17:39:00 +0100 Subject: [PATCH 02/35] added lock tbl.person_lock for locking person --- application/config/fhcomplete.php | 1 + system/dbupdate_3.3.php | 36 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/application/config/fhcomplete.php b/application/config/fhcomplete.php index 3b24595a7..b680d6f5d 100644 --- a/application/config/fhcomplete.php +++ b/application/config/fhcomplete.php @@ -207,6 +207,7 @@ $config['fhc_acl'] = array 'system.tbl_udf' => 'system/udf', 'system.tbl_extensions' => 'system/extensions', 'system.tbl_log' => 'basis/log', + 'system.tbl_person_lock' => 'system/personlock', 'testtool.tbl_ablauf' => 'basis/ablauf', 'testtool.tbl_antwort' => 'basis/antwort', 'testtool.tbl_frage' => 'basis/frage', diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index 96c65c276..0b03c8bcb 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -1265,6 +1265,41 @@ if($result = $db->db_query("SELECT 1 FROM system.tbl_app WHERE app='bewerbung'") } } +// Tabelle person_lock hinzufügen +if (!$result = @$db->db_query("SELECT 1 FROM system.tbl_person_lock LIMIT 1")) +{ + $qry = "CREATE TABLE system.tbl_person_lock + ( + lock_id bigint NOT NULL, + person_id integer NOT NULL, + uid varchar(32) NOT NULL, + zeitpunkt timestamp NOT NULL DEFAULT now(), + app varchar(32) + ); + + ALTER TABLE system.tbl_person_lock ADD CONSTRAINT pk_lock PRIMARY KEY (lock_id); + + CREATE SEQUENCE system.tbl_person_lock_lock_id_seq + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; + ALTER TABLE system.tbl_person_lock ALTER COLUMN lock_id SET DEFAULT nextval('system.tbl_person_lock_lock_id_seq'); + + GRANT SELECT, INSERT, DELETE ON system.tbl_person_lock TO vilesci; + GRANT SELECT, INSERT, DELETE ON system.tbl_person_lock TO web; + GRANT SELECT, UPDATE ON system.tbl_person_lock_lock_id_seq TO vilesci; + GRANT SELECT, UPDATE ON system.tbl_person_lock_lock_id_seq TO web; + + ALTER TABLE system.tbl_person_lock ADD CONSTRAINT fk_lock_person_id FOREIGN KEY (person_id) REFERENCES public.tbl_person(person_id) ON UPDATE CASCADE ON DELETE RESTRICT; + ALTER TABLE system.tbl_person_lock ADD CONSTRAINT fk_lock_uid FOREIGN KEY (uid) REFERENCES public.tbl_benutzer(uid) ON UPDATE CASCADE ON DELETE RESTRICT; + ALTER TABLE system.tbl_person_lock ADD CONSTRAINT fk_lock_app FOREIGN KEY (app) REFERENCES system.tbl_app(app) ON UPDATE CASCADE ON DELETE RESTRICT;"; + if (!$db->db_query($qry)) + echo 'system.tbl_person_lock '.$db->db_last_error().'
'; + else + echo ' system.tbl_person_lock hinzugefügt
'; +} + // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen echo '

Pruefe Tabellen und Attribute!

'; @@ -1527,6 +1562,7 @@ $tabellen=array( "system.tbl_webservicetyp" => array("webservicetyp_kurzbz","beschreibung"), "system.tbl_server" => array("server_kurzbz","beschreibung"), "system.tbl_udf" => array("schema", "table", "jsons"), + "system.tbl_person_lock" => array("lock_id", "person_id", "uid", "zeitpunkt", "app"), "wawi.tbl_betriebsmittelperson" => array("betriebsmittelperson_id","betriebsmittel_id","person_id", "anmerkung", "kaution", "ausgegebenam", "retouram","insertamum", "insertvon","updateamum", "updatevon","ext_id","uid"), "wawi.tbl_betriebsmittel" => array("betriebsmittel_id","betriebsmitteltyp","oe_kurzbz", "ort_kurzbz", "beschreibung", "nummer", "hersteller","seriennummer", "bestellung_id","bestelldetail_id", "afa","verwendung","anmerkung","reservieren","updateamum","updatevon","insertamum","insertvon","ext_id","inventarnummer","leasing_bis","inventuramum","inventurvon","anschaffungsdatum","anschaffungswert","hoehe","breite","tiefe","nummer2","verplanen"), "wawi.tbl_betriebsmittel_betriebsmittelstatus" => array("betriebsmittelbetriebsmittelstatus_id","betriebsmittel_id","betriebsmittelstatus_kurzbz", "datum", "updateamum", "updatevon", "insertamum", "insertvon","anmerkung"), From c987773f8f94979b1a80fd084463601490ef7d4c Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 20 Feb 2018 17:58:03 +0100 Subject: [PATCH 03/35] removed line --- application/models/person/Person_model.php | 1 - 1 file changed, 1 deletion(-) diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index 9c6f14f89..0c7c169bb 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -209,5 +209,4 @@ class Person_model extends DB_Model return $this->loadWhere(array('uid' => $uid)); } - } From d9f6bfb76bd0c6e92bf1835ef0fdac004ddcc3de Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 20 Feb 2018 18:00:37 +0100 Subject: [PATCH 04/35] statusgrund is shown for every status not only for abgewiesener --- .../views/system/infocenter/zgvpruefungen.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/application/views/system/infocenter/zgvpruefungen.php b/application/views/system/infocenter/zgvpruefungen.php index 59935dd1d..cf2bf12b8 100644 --- a/application/views/system/infocenter/zgvpruefungen.php +++ b/application/views/system/infocenter/zgvpruefungen.php @@ -35,7 +35,7 @@ prestudentstatus->status_kurzbz)) { - echo $zgvpruefung->prestudentstatus->status_kurzbz.(isset($zgvpruefung->prestudentstatus->bezeichnung_statusgrund[0]) && $zgvpruefung->prestudentstatus->status_kurzbz === 'Abgewiesener' ? ' ('.$zgvpruefung->prestudentstatus->bezeichnung_statusgrund[0].')' : ''); + echo $zgvpruefung->prestudentstatus->status_kurzbz.(isset($zgvpruefung->prestudentstatus->bezeichnung_statusgrund[0]) ? ' ('.$zgvpruefung->prestudentstatus->bezeichnung_statusgrund[0].')' : ''); } ?> @@ -57,12 +57,12 @@
- prestudentstatus->orgform)) ? ', ' : ''; - echo (isset($zgvpruefung->prestudentstatus->orgform) ? $zgvpruefung->prestudentstatus->orgform : '') - .(isset($zgvpruefung->prestudentstatus->sprachedetails->bezeichnung) ? $separator.$zgvpruefung->prestudentstatus->sprachedetails->bezeichnung[0] : '') - .(isset($zgvpruefung->prestudentstatus->alternative) ? ' ('.$zgvpruefung->prestudentstatus->alternative.')' : '') ?> - + prestudentstatus->orgform)) ? ', ' : ''; + echo (isset($zgvpruefung->prestudentstatus->orgform) ? $zgvpruefung->prestudentstatus->orgform : '') + .(isset($zgvpruefung->prestudentstatus->sprachedetails->bezeichnung) ? $separator.$zgvpruefung->prestudentstatus->sprachedetails->bezeichnung[0] : '') + .(isset($zgvpruefung->prestudentstatus->alternative) ? ' ('.$zgvpruefung->prestudentstatus->alternative.')' : '') ?> +
From 695e7f60afd16857c90695ef97dd45a6854c3b08 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 20 Feb 2018 18:05:36 +0100 Subject: [PATCH 05/35] added lock mechanism for persons, outsourced infocenter code to javascript --- .../system/infocenter/InfoCenter.php | 41 ++++- .../models/system/PersonLock_model.php | 90 +++++++++++ .../views/system/infocenter/infocenter.php | 5 +- .../system/infocenter/infocenterDetails.php | 144 +++++------------- .../views/system/infocenter/stammdaten.php | 15 +- include/js/infocenter/infocenterDetails.js | 74 +++++++++ .../infocenterPersonDataset.js | 27 +++- include/js/tablesort/tablesort.js | 86 +++++++++++ skin/admintemplate.css | 12 +- skin/admintemplate_contentonly.css | 3 + 10 files changed, 371 insertions(+), 126 deletions(-) create mode 100644 application/models/system/PersonLock_model.php create mode 100644 include/js/infocenter/infocenterDetails.js rename include/js/{ => infocenter}/infocenterPersonDataset.js (70%) create mode 100644 include/js/tablesort/tablesort.js diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index f1cd674b7..92932b8ea 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -64,6 +64,7 @@ class InfoCenter extends VileSci_Controller $this->load->model('person/person_model', 'PersonModel'); $this->load->model('system/message_model', 'MessageModel'); $this->load->model('system/filters_model', 'FiltersModel'); + $this->load->model('system/personLock_model', 'PersonLockModel'); // Loads libraries $this->load->library('DmsLib'); @@ -110,10 +111,20 @@ class InfoCenter extends VileSci_Controller if (!is_numeric($person_id)) show_error('person id is not numeric!'); - $persondata = $this->_loadPersonData($person_id); - if (!isset($persondata)) + $personexists = $this->PersonModel->load($person_id); + if(isError($personexists)) + show_error($personexists->retval); + + if (empty($personexists->retval[0])) show_error('person does not exist!'); + //mark person as locked for editing + $result = $this->PersonLockModel->lockPerson($person_id, $this->uid, self::APP); + + if(isError($result)) + show_error($result->retval); + + $persondata = $this->_loadPersonData($person_id); $prestudentdata = $this->_loadPrestudentData($person_id); $this->load->view( @@ -129,6 +140,20 @@ class InfoCenter extends VileSci_Controller ); } + /** + * unlocks page from edit by a person, redirects to overview filter page + * @param $person_id + */ + public function unlockPerson($person_id) + { + $result = $this->PersonLockModel->unlockPerson($person_id, self::APP); + + if(isError($result)) + show_error($result->retval); + + redirect(self::URL_PREFIX); + } + /** * Saves if a document has been formal geprueft. saves current timestamp if checked as geprueft, or null if not. */ @@ -235,7 +260,7 @@ class InfoCenter extends VileSci_Controller } //check if still Interessent and not freigegeben yet - if($lastStatus->retval[0]->status_kurzbz === 'Interessent' && !isset($lastStatus->retval[0]->bestaetigtam)) + if ($lastStatus->retval[0]->status_kurzbz === 'Interessent' && !isset($lastStatus->retval[0]->bestaetigtam)) { $result = $this->PrestudentstatusModel->insert( array( @@ -517,6 +542,13 @@ class InfoCenter extends VileSci_Controller */ private function _loadPersonData($person_id) { + $lockedby = $this->PersonLockModel->checkIfLocked($person_id); + + if (isError($lockedby)) + { + show_error($lockedby->retval); + } + $stammdaten = $this->PersonModel->getPersonStammdaten($person_id, true); if (isError($stammdaten)) @@ -567,6 +599,7 @@ class InfoCenter extends VileSci_Controller $messagelink = base_url('/index.ci.php/system/Messages/write/'.$user_person->retval[0]->person_id); $data = array ( + 'lockedby' => isset($lockedby->retval[0]->uid) ? $lockedby->retval[0]->uid : null, 'stammdaten' => $stammdaten->retval, 'dokumente' => $dokumente->retval, 'dokumente_nachgereicht' => $dokumente_nachgereicht->retval, @@ -606,7 +639,7 @@ class InfoCenter extends VileSci_Controller $zgvpruefung = $prestudent->retval[0]; - if(isset($zgvpruefung->prestudentstatus)) + if (isset($zgvpruefung->prestudentstatus)) { $position = strpos($zgvpruefung->prestudentstatus->anmerkung, 'Alt:'); diff --git a/application/models/system/PersonLock_model.php b/application/models/system/PersonLock_model.php new file mode 100644 index 000000000..1a3edd917 --- /dev/null +++ b/application/models/system/PersonLock_model.php @@ -0,0 +1,90 @@ +dbTable = 'system.tbl_person_lock'; + $this->pk = 'lock_id'; + } + + /** + * checks if a specific person is locked. By default, looks for any entries in locktable for the person. + * Alternatively, looks only for locks in a certain app + * @param $person_id + * @param null $app + * @return array all locks for a person if locked, null otherwise + */ + public function checkIfLocked($person_id, $app = null) + { + $lockdata = $app === null ? array('person_id' => $person_id) : array('person_id' => $person_id, 'app' => $app); + + $result = $this->loadWhere($lockdata); + + if($result->error) + return error($result->retval); + else + { + if(count($result->retval) > 0) + return success($result->retval); + else + return success(null); + } + } + + /** + * locks a person. returns null if person was not locked (e.g. when already locked) + * @param $person_id + * @param $uid user who locks the person + * @param $app optional, application in which person is locked + * @return array inserted lock id if person was locked, null otherwise + */ + public function lockPerson($person_id, $uid, $app = null) + { + $locked = $this->checkIfLocked($person_id, $app); + + if($locked->error) + return error($locked->retval); + + //insert only if not already locked + if($locked->retval === null) + return $this->insert(array('person_id' => $person_id, 'uid' => $uid, 'app' => $app)); + else + return success(null); + } + + /** + * remove a lock for a person. By default, removes any entries in locktable for the person + * Alternatively, removes only locks in a certain app + * @param $person_id + * @param null $app + * @return array deleted lock ids if person was locked, null otherwise + */ + public function unlockPerson($person_id, $app = null) + { + $deleted = array(); + $locks = $this->checkIfLocked($person_id, $app); + + if ($locks->retval === null) + return success(null); + + foreach ($locks->retval as $lock) + { + $result = $this->delete($lock->lock_id); + if($result->error) + return error($result->retval); + + $deleted[] = $lock; + } + + return success($deleted); + } +} diff --git a/application/views/system/infocenter/infocenter.php b/application/views/system/infocenter/infocenter.php index 8244e8c67..a61e8b392 100644 --- a/application/views/system/infocenter/infocenter.php +++ b/application/views/system/infocenter/infocenter.php @@ -9,7 +9,7 @@ 'sbadmintemplate' => true, 'tablesorter' => true, 'customCSSs' => 'skin/tablesort_bootstrap.css', - 'customJSs' => array('include/js/infocenterPersonDataset.js', 'include/js/bootstrapper.js') + 'customJSs' => array('include/js/bootstrapper.js', 'include/js/infocenter/infocenterPersonDataset.js') ) ); ?> @@ -40,9 +40,6 @@ - load->view('templates/FHC-Footer'); ?> diff --git a/application/views/system/infocenter/infocenterDetails.php b/application/views/system/infocenter/infocenterDetails.php index 16effcfdd..0db3a7cdb 100644 --- a/application/views/system/infocenter/infocenterDetails.php +++ b/application/views/system/infocenter/infocenterDetails.php @@ -1,19 +1,27 @@ load->view( - 'templates/FHC-Header', - array( - 'title' => 'InfocenterDetails', - 'jquery' => true, - 'bootstrap' => true, - 'fontawesome' => true, - 'jqueryui' => true, - 'tablesorter' => true, - 'tinymce' => true, - 'sbadmintemplate' => true, - 'customCSSs' => array('skin/admintemplate.css', 'skin/tablesort_bootstrap.css'), - 'customJSs' => 'include/js/bootstrapper.js' - ) -); + $this->load->view( + 'templates/FHC-Header', + array( + 'title' => 'InfocenterDetails', + 'jquery' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'jqueryui' => true, + 'tablesorter' => true, + 'tinymce' => true, + 'sbadmintemplate' => true, + 'customCSSs' => + array( + 'skin/admintemplate.css', + 'skin/tablesort_bootstrap.css' + ), + 'customJSs' => + array( + 'include/js/bootstrapper.js', + 'include/js/tablesort/tablesort.js', + 'include/js/infocenter/infocenterDetails.js') + ) + ); ?>
@@ -29,12 +37,25 @@ $this->load->view(
-
- +
+ +
+
+
+ wird bearbeitet von: + +    +  Freigeben + +
+
@@ -124,27 +145,9 @@ $this->load->view(
diff --git a/application/views/system/infocenter/stammdaten.php b/application/views/system/infocenter/stammdaten.php index 3e2ec1fb7..6aae1c9f6 100644 --- a/application/views/system/infocenter/stammdaten.php +++ b/application/views/system/infocenter/stammdaten.php @@ -80,7 +80,9 @@ strasse.', '.$adresse->plz.' '.$adresse->ort : '' ?> - heimatadresse === true ? 'Heimatadresse' : '').($adresse->heimatadresse === true && $adresse->rechnungsadresse === true ? ', ' : '').($adresse->rechnungsadresse === true ? 'Rechnungsadresse' : ''); ?> + heimatadresse === true ? 'Heimatadresse' : ''). + ($adresse->heimatadresse === true && $adresse->rechnungsadresse === true ? ', ' : ''). + ($adresse->rechnungsadresse === true ? 'Rechnungsadresse' : ''); ?> @@ -103,13 +105,4 @@
-
- \ No newline at end of file +
\ No newline at end of file diff --git a/include/js/infocenter/infocenterDetails.js b/include/js/infocenter/infocenterDetails.js new file mode 100644 index 000000000..a03a5320e --- /dev/null +++ b/include/js/infocenter/infocenterDetails.js @@ -0,0 +1,74 @@ +/* + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ +/** + * javascript file for infocenterDetails page + */ + +$(document).ready( + function () + { + //initialise table sorter + addTablesorter("doctable", [[2, 1], [1, 0]], ["zebra"]); + addTablesorter("nachgdoctable", [[2, 0], [1, 1]], ["zebra"]); + addTablesorter("msgtable", [[0, 1], [2, 0]], ["zebra", "filter"], 2); + addTablesorter("logtable", [[0, 1]], ["filter"], 2); + addTablesorter("notiztable", [[0, 1]], ["filter"], 2); + + //add pager + tablesortAddPager("logtable", "logpager", 23); + tablesortAddPager("notiztable", "notizpager", 10); + + //initialise datepicker + $.datepicker.setDefaults($.datepicker.regional['de']); + $(".dateinput").datepicker({ + "dateFormat": "dd.mm.yy" + }); + + //add click events to "formal geprüft" checkboxes +/* $(".prchbox input[type=checkbox]").click( + function() + { + var akteid = this.; + var personid = ; + window.location = "../saveFormalGeprueft?akte_id="+akteid+"&formal_geprueft=" + this.checked + "&person_id="+personid; + } + );*/ + + //add submit event to message send link + $("#sendmsglink").click( + function () + { + $("#sendmsgform").submit(); + } + ); + + //prevent opening modal when Statusgrund not chosen + $("#absageModal").on('show.bs.modal', function (e) + { + if ($("[name=statusgrund]").val() === "null") + { + $("#statusgrselect").addClass("has-error"); + return e.preventDefault(); + } + } + ); + + $("[name=statusgrund]").change(function () + { + $("#statusgrselect").removeClass("has-error"); + } + ); + } +); diff --git a/include/js/infocenterPersonDataset.js b/include/js/infocenter/infocenterPersonDataset.js similarity index 70% rename from include/js/infocenterPersonDataset.js rename to include/js/infocenter/infocenterPersonDataset.js index 90957e03a..f4d80a370 100644 --- a/include/js/infocenterPersonDataset.js +++ b/include/js/infocenter/infocenterPersonDataset.js @@ -1,8 +1,26 @@ +/* + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ /** + * javascript file for infocenter overview page */ $(document).ready( function() { + //bootstrap table + $("#tableDataset").addClass('table table-bordered table-responsive'); + // Checks if the table contains data (rows) if ($('#tableDataset').find('tbody:empty').length == 0 && $('#tableDataset').find('tr:empty').length == 0) @@ -17,6 +35,9 @@ $(document).ready( } ); +/** + * adds person table additional actions html (above and beneath it) + */ function appendTableActionsHtml() { var currurl = window.location.href; @@ -47,7 +68,9 @@ function appendTableActionsHtml() $("#datasetActionsBottom").append("

"); } - +/** + * sets functionality for the actions above and beneath the person table + */ function setTableActions() { $(".sendMsgsLink").click(function() { @@ -67,7 +90,7 @@ function setTableActions() $(".selectAll").click(function() { - //trs only if not filtered by tablesorter + //select only trs if not filtered by tablesorter var trs = $("#tableDataset tbody tr").not(".filtered"); trs.find("input[name=PersonId\\[\\]]").prop("checked", true); } diff --git a/include/js/tablesort/tablesort.js b/include/js/tablesort/tablesort.js new file mode 100644 index 000000000..c1c171959 --- /dev/null +++ b/include/js/tablesort/tablesort.js @@ -0,0 +1,86 @@ +/* + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ +/** + * provides helper functions for adding mottie tablesorter + * enables easier configuration of the tablesorter by providing a common default configuration + */ + +/** + * adds tablesorter to specified tableid, german date format, default theme + * @param tableid + * @param sortList columns to sort by, as array of arrays (each array contains column number and 1/0 for asc/desc order) + * @param widgets optional widgets like zebra or filter + * @param minrows optional minimal amount of rows for filter row to be shown (only relevant for filter widget) + */ +function addTablesorter(tableid, sortList, widgets, minrows) +{ + $("#" + tableid).tablesorter( + { + theme: "default", + dateFormat: "ddmmyyyy", + sortList: sortList, + widgets: widgets + } + ); + + if($("#" + tableid + " tr.tablesorter-filter-row").length) + { + //hide filters if less than n datarows (+ 2 for headings and filter row itself), default 0 + var minrows = minrows || 0; + if ($("#" + tableid + " tr").length < minrows + 2) + { + $("#" + tableid + " tr.tablesorter-filter-row").hide(); + } + } +} + +/** + * adds pager for specified tableid. Assumes bootstap icons are available! + * @param tableid + * @param pagerid + * @param size number of rows for each page + */ +function tablesortAddPager(tableid, pagerid, size) +{ + var html = + '
' + + '
' + + ' ' + + '' + + '' + + ' ' + + '' + + '
' + + '
'; + + var rowcount = $("#" + tableid + " tr").length; + + //not show pager if only one table page + if (rowcount > size) + { + var table = $("#" + tableid); + table.after(html); + + table.tablesorterPager( + { + container: $("#" + pagerid), + size: size, + cssDisabled: 'disabled', + savePages: false, + output: '{startRow} – {endRow} / {totalRows} Zeilen' + } + ); + } +} \ No newline at end of file diff --git a/skin/admintemplate.css b/skin/admintemplate.css index 5df078833..88fcff3b3 100644 --- a/skin/admintemplate.css +++ b/skin/admintemplate.css @@ -1,3 +1,13 @@ +/*custom styles for sb admin 2 template: https://startbootstrap.com/template-overviews/sb-admin-2/*/ + +/*optional header at right side of the main header*/ +.headerright{ + margin: 40px 0 20px -30px; + padding: 6.4px 0 9px; + border-bottom: 1px solid #eee; +} + +/*change of panel colors (grey) */ .panel-primary > .panel-heading{ color: black; background-color: #dfdfdf; @@ -6,4 +16,4 @@ .panel-primary{ border-color: #dfdfdf; -} +} \ No newline at end of file diff --git a/skin/admintemplate_contentonly.css b/skin/admintemplate_contentonly.css index a8e76cc08..d5a69d07d 100644 --- a/skin/admintemplate_contentonly.css +++ b/skin/admintemplate_contentonly.css @@ -1,3 +1,6 @@ +/*stylesheet for sb admin 2 pages that do not have menu and toolbar*/ +@import "admintemplate.css"; + @media (min-width:768px) { #page-wrapper { margin-right: 250px; From 7c2445dc89602b8b9ef179dfdf3aa8862ce5a1ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Tue, 20 Feb 2018 18:42:23 +0100 Subject: [PATCH 06/35] Messages im FAS werden nach Datum sortiert anstatt nach Betreff --- application/controllers/system/Messages.php | 12 ++++++------ application/libraries/MessageLib.php | 4 ++-- content/messages.xul.php | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index 2c2474a1e..36db0238d 100644 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -10,19 +10,19 @@ class Messages extends VileSci_Controller * */ public function __construct() - { - parent::__construct(); + { + parent::__construct(); - // Loads the message library - $this->load->library('MessageLib'); + // Loads the message library + $this->load->library('MessageLib'); - // Loads the widget library + // Loads the widget library $this->load->library('WidgetLib'); $this->load->model('person/Person_model', 'PersonModel'); $this->_setAuthUID(); // sets property uid - } + } /** * write diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 02ba1e65e..3b5f8093b 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -746,8 +746,8 @@ class MessageLib $this->ci->BenutzerfunktionModel->addJoin('public.tbl_benutzer', 'uid'); // Get all the valid receivers id using the oe_kurzbz $receivers = $this->ci->BenutzerfunktionModel->loadWhere( - 'oe_kurzbz = \''.$oe_kurzbz.'\''. - ' AND funktion_kurzbz = \''.$this->ci->config->item('assistent_function').'\''. + 'oe_kurzbz = '.$this->ci->db->escape($oe_kurzbz). + ' AND funktion_kurzbz = '.$this->ci->db->escape($this->ci->config->item('assistent_function')). ' AND (NOW() BETWEEN COALESCE(datum_von, NOW()) AND COALESCE(datum_bis, NOW()))' ); diff --git a/content/messages.xul.php b/content/messages.xul.php index 35e279c1d..bdd936d93 100644 --- a/content/messages.xul.php +++ b/content/messages.xul.php @@ -86,8 +86,6 @@ echo ']>