From 2ef386c34e7cd1352f7cb2df211e438bcc627b40 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 12 Jun 2019 17:27:35 +0200 Subject: [PATCH 001/138] - Changed system/dbupdate_3.3.php to add oe_kurzbz to table public.tbl_msg_recipient and foreign key fk_tbl_msg_recipient_oe_kurzbz - Removed not used constants for messaging from config/constants.php - Renamed config entry assistent_function to ou_receivers and converted from string to array - Moved controllers/MailJob.php to controllers/jobs/MailJob.php - Controller MailJob now extends CLI_Controller - Added new function parseText to helpers/hlp_common_helper.php - Improved code function generateToken in helpers/hlp_common_helper.php - helpers/hlp_sancho_helper.php now uses parseText function from hlp_common_helper - Removed method parseVorlagetext from PhrasesLib.php - PhrasesLib.php now uses parseText function from hlp_common_helper - Removed method parseVorlagetext from VorlageLib - Improved code of controller controllers/system/Messages.php (uses parseText too) - Controller controllers/system/Vorlage.php now uses parseText --- application/config/constants.php | 37 +++--- application/config/message.php | 2 +- .../controllers/{ => jobs}/MailJob.php | 11 +- application/controllers/system/Messages.php | 121 +++++++++--------- application/controllers/system/Vorlage.php | 2 +- application/helpers/hlp_common_helper.php | 73 +++++++---- application/helpers/hlp_sancho_helper.php | 4 +- application/libraries/PhrasesLib.php | 12 +- application/libraries/VorlageLib.php | 14 -- system/dbupdate_3.3.php | 27 +++- 10 files changed, 161 insertions(+), 142 deletions(-) rename application/controllers/{ => jobs}/MailJob.php (68%) diff --git a/application/config/constants.php b/application/config/constants.php index ac2ecc649..e1c5906c3 100644 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -136,26 +136,19 @@ define('MSG_STATUS_READ', 1); define('MSG_STATUS_ARCHIVED', 2); define('MSG_STATUS_DELETED', 3); -// Priority -define('PRIORITY_LOW', 1); -define('PRIORITY_NORMAL', 2); -define('PRIORITY_HIGH', 3); -define('PRIORITY_URGENT', 4); +// Message priorities +define('MSG_PRIORITY_LOW', 1); +define('MSG_PRIORITY_NORMAL', 2); +define('MSG_PRIORITY_HIGH', 3); +define('MSG_PRIORITY_URGENT', 4); -define('MSG_ERR_SUBJECT_EMPTY', 40); -define('MSG_ERR_BODY_EMPTY', 41); -define('MSG_ERR_TEMPLATE_NOT_FOUND', 42); -define('MSG_ERR_DELIVERY_MESSAGE', 43); -define('MSG_ERR_CONTACT_NOT_FOUND', 44); -define('MSG_ERR_OU_CONTACTS_NOT_FOUND', 45); - -define('MSG_ERR_INVALID_USER_ID', 100); -define('MSG_ERR_INVALID_MSG_ID', 101); -define('MSG_ERR_INVALID_THREAD_ID', 102); -define('MSG_ERR_INVALID_STATUS_ID', 103); -define('MSG_ERR_INVALID_SENDER_ID', 104); -define('MSG_ERR_INVALID_RECIPIENTS', 105); -define('MSG_ERR_INVALID_RECEIVER_ID', 106); -define('MSG_ERR_INVALID_OU', 107); -define('MSG_ERR_INVALID_TEMPLATE', 108); -define('MSG_ERR_INVALID_TOKEN', 109); +// Message error status +define('MSG_ERR_INVALID_SUBJECT', 40); +define('MSG_ERR_INVALID_BODY', 41); +define('MSG_ERR_INVALID_TEMPLATE', 42); +define('MSG_ERR_INVALID_MSG_ID', 43); +define('MSG_ERR_INVALID_STATUS_ID', 44); +define('MSG_ERR_INVALID_SENDER', 45); +define('MSG_ERR_INVALID_RECIPIENTS', 46); +define('MSG_ERR_INVALID_OU', 47); +define('MSG_ERR_INVALID_TOKEN', 48); diff --git a/application/config/message.php b/application/config/message.php index 40d15a07e..30444b0ef 100644 --- a/application/config/message.php +++ b/application/config/message.php @@ -12,7 +12,7 @@ $config['message_html_view_url'] = '/ViewMessage/toHTML/'; // Change this to CIS Server (https://cis.example.com/index.ci.php) if you are sending Messages from Vilesci $config['message_server'] = site_url(); -$config['assistent_function'] = 'ass'; +$config['ou_receivers'] = array('ass'); $config['message_redirect_url'] = array(); $config['message_redirect_url']['fallback'] = site_url('ViewMessage/writeReply'); diff --git a/application/controllers/MailJob.php b/application/controllers/jobs/MailJob.php similarity index 68% rename from application/controllers/MailJob.php rename to application/controllers/jobs/MailJob.php index 2f8b5b92d..cb5ffc032 100644 --- a/application/controllers/MailJob.php +++ b/application/controllers/jobs/MailJob.php @@ -14,22 +14,25 @@ if (!defined("BASEPATH")) exit("No direct script access allowed"); -class MailJob extends Auth_Controller +class MailJob extends CLI_Controller { /** * API constructor */ public function __construct() { - // An empty array as parameter will ensure that this controller is ONLY callable from command line - parent::__construct(array()); + parent::__construct(); // Loads MessageLib $this->load->library('MessageLib'); } + /** + * Send all not sent messages + * Parameters are used to overrride messages and mail configuration + */ public function sendMessages($numberToSent = null, $numberPerTimeRange = null, $email_time_range = null, $email_from_system = null) { - $this->messagelib->sendAll($numberToSent, $numberPerTimeRange, $email_time_range, $email_from_system); + $this->messagelib->sendAllNotices($numberToSent, $numberPerTimeRange, $email_time_range, $email_from_system); } } diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index ec630da1e..744eb880e 100644 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -5,7 +5,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class Messages extends Auth_Controller { /** - * + * MessageLib is loaded by CLMessagesModel */ public function __construct() { @@ -20,9 +20,6 @@ class Messages extends Auth_Controller ) ); - // Loads the message library - $this->load->library('MessageLib'); - // Loads the widget library $this->load->library('WidgetLib'); @@ -38,30 +35,26 @@ class Messages extends Auth_Controller } // ----------------------------------------------------------------------------------------------------------------- - // Public methods + // Public methods - HTML output /** - * Write a new message + * Initialize all the parameters used by view system/messages/messageWrite + * to build a GUI used to write a messate to user/s */ public function write() { - $person_id = $this->input->post('person_id'); - $sender_id = null; + $persons = $this->input->post('person_id'); $authUser = $this->CLMessagesModel->getAuthUser(); - if (isError($authUser)) - { - show_error(getData($authUser)); - } - else - { - $sender_id = getData($authUser)[0]->person_id; - } + if (isError($authUser)) show_error(getData($authUser)); - $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($person_id); + $sender_id = getData($authUser)[0]->person_id; + + // Retrieves person information + $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($persons); if (isError($msgVarsData)) show_error(getData($msgVarsData)); - // Retrieves message vars for a person from view view vw_msg_vars_person + // Retrieves message vars from view vw_msg_vars_person $variables = $this->messagelib->getMessageVarsPerson(); if (isError($variables)) show_error(getData($variables)); @@ -73,33 +66,43 @@ class Messages extends Auth_Controller $isAdmin = $this->messagelib->getIsAdmin($sender_id); if (isError($isAdmin)) show_error(getData($isAdmin)); - $data = array ( - 'recipients' => getData($msgVarsData), - 'variables' => getData($variables), - 'oe_kurzbz' => getData($oe_kurzbz), // used to get the templates - 'isAdmin' => getData($isAdmin) + $this->load->view( + 'system/messages/messageWrite', + array ( + 'recipients' => getData($msgVarsData), // recipients data + 'variables' => getData($variables), // message vars + 'oe_kurzbz' => getData($oe_kurzbz), // used to get the templates + 'isAdmin' => getData($isAdmin) // is admin? + ) ); - - $this->load->view('system/messages/messageWrite', $data); } /** - * Send message + * Send a new message or reply to user/s + * If a relationmessage_id this message is a reply to another one */ public function send() { $persons = $this->input->post('persons'); $relationmessage_id = $this->input->post('relationmessage_id'); + // Retrieves message vars data for the fiven user/s $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($persons); + // Send the message $send = $this->CLMessagesModel->send($msgVarsData, $relationmessage_id); $this->load->view('system/messages/messageSent', array('success' => isSuccess($send))); } + // ----------------------------------------------------------------------------------------------------------------- + // Public methods - JSON output + /** - * Send message, response is in JSON format + * Send a new message + * - The recipients are prestudents + * - An email template with message var may be provided + * - A global organisation unit may be provided, otherwise is used the prestudent one */ public function sendJson() { @@ -120,23 +123,19 @@ class Messages extends Auth_Controller } $send = $this->CLMessagesModel->send($msgVarsData, null, $oe_kurzbz, $vorlage_kurzbz, $msgVars); - if (isError($send)) - { - $this->outputJsonError(getData($send)); - } - else - { - $this->outputJsonSuccess(getData($send)); - } + + $this->outputJson(getData($send)); } /** - * getVorlage + * Returns an object that represent a template store in database + * If no templates are found with the given parameter or the given parameter is an empty string, + * then an error is returned */ public function getVorlage() { $vorlage_kurzbz = $this->input->get('vorlage_kurzbz'); - $result = null; + $result = error('The given vorlage_kurzbz is not valid'); if (!isEmptyString($vorlage_kurzbz)) { @@ -145,10 +144,6 @@ class Messages extends Auth_Controller $result = $this->VorlagestudiengangModel->loadWhere(array('vorlage_kurzbz' => $vorlage_kurzbz)); } - else - { - $result = error('The given vorlage_kurzbz is not valid'); - } if (isError($result) || !hasData($result)) { @@ -161,40 +156,37 @@ class Messages extends Auth_Controller } /** - * parseMessageText + * Parse the given given text using data from the given user + * Use the CI parser which performs simple text substitution for pseudo-variable */ public function parseMessageText() { $person_id = $this->input->get('person_id'); $text = $this->input->get('text'); - $parsedText = ''; - $data = null; + $msgVarsData = error('The given person_id is not a valid number'); if (is_numeric($person_id)) { - $data = $this->MessageModel->getMsgVarsDataByPersonId($person_id); + $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($person_id); + } + + if (isError($msgVarsData) || !hasData($msgVarsData)) + { + $this->outputJsonError(getData($msgVarsData)); } else { - $data = error('The given person_id is not a valid number'); - } - - if (isError($data) || !hasData($data)) - { - $this->outputJsonError(getData($data)); - } - else - { - $parsedText = $this->messagelib->parseMessageText($text, $this->CLMessagesModel->replaceKeys((array)getData($data)[0])); - - $this->outputJsonSuccess($parsedText); + $this->outputJsonSuccess( + parseText( + $text, + $this->CLMessagesModel->replaceKeys((array)getData($msgVarsData)[0]) + ) + ); } } /** * 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() { @@ -203,8 +195,13 @@ class Messages extends Auth_Controller $msg = $this->messagelib->getMessage($msg_id, $receiver_id); - $this->output - ->set_content_type('application/json') - ->set_output(json_encode(array(getData($msg)[0]))); + if (isError($msg) || !hasData($msg)) + { + $this->outputJson(array()); + } + else + { + $this->outputJson(array(getData($msg)[0])); + } } } diff --git a/application/controllers/system/Vorlage.php b/application/controllers/system/Vorlage.php index 4712d0e68..22513970e 100644 --- a/application/controllers/system/Vorlage.php +++ b/application/controllers/system/Vorlage.php @@ -269,7 +269,7 @@ class Vorlage extends Auth_Controller show_error($vorlagetext->retval); $data = array( - 'text' => $this->vorlagelib->parseVorlagetext($vorlagetext->retval[0]->text, $jsonDecodedForm) + 'text' => parseText($vorlagetext->retval[0]->text, $jsonDecodedForm) ); $this->load->view('system/vorlage/templatetextPreview', $data); diff --git a/application/helpers/hlp_common_helper.php b/application/helpers/hlp_common_helper.php index bc09cd32c..45a36914c 100644 --- a/application/helpers/hlp_common_helper.php +++ b/application/helpers/hlp_common_helper.php @@ -24,39 +24,54 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); // ------------------------------------------------------------------------ /** - * generateToken() - generates a new token for diffent use - * - reading Messages from external - * - forgotten Password - * - * @return string + * Generates a new token for diffent use cases. Default token length is 64 + * - Reading messages + * - Forgotten password + * - etc + * Returns null on failure */ function generateToken($length = 64) { + $token = null; + $firstGeneratedToken = null; + // For PHP 7 you can use 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 - return strtr(substr($token, 0, $length), '+/=', '-_,'); + try + { + $firstGeneratedToken = random_bytes($length); // try to generates cryptographically secure pseudo-random bytes... + } + catch (Exception $e) { $firstGeneratedToken = null; } // if fails $firstGeneratedToken is set to null } - - // for PHP >=5.3 and <7 - if (function_exists('openssl_random_pseudo_bytes')) + // For PHP >= 5.3 and < 7 and openssl is available + elseif (function_exists('openssl_random_pseudo_bytes')) { - $token = base64_encode(openssl_random_pseudo_bytes($length, $strong)); - // is the token strong enough? - if($strong == true) - return strtr(substr($token, 0, $length), '+/=', '-_,'); + $firstGeneratedToken = openssl_random_pseudo_bytes($length, $strong); + // If the token generation ended with errors OR the generated token is NOT strong enough + if ($firstGeneratedToken == false || $strong == false) $firstGeneratedToken = null; // $firstGeneratedToken is set to null } - //fallback to mt_rand if php < 5.3 or no openssl available - $characters = '0123456789'; - $characters .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/+'; - $charactersLength = strlen($characters)-1; - $token = ''; - //select some random characters - for ($i = 0; $i < $length; $i++) - $token .= $characters[mt_rand(0, $charactersLength)]; + if ($firstGeneratedToken != null) // If everything was fine + { + // base64 is about 33% longer, so we need to truncate the result + $token = strtr(substr(base64_encode($firstGeneratedToken), 0, $length), '+/=', '-_,'); + } + + // Fallback to mt_rand if: + // php < 5.3 + // OR no openssl is available + // OR openssl_random_pseudo_bytes used an algorithm that is cryptographically NOT strong + // OR one of the previous methods failed + if ($token == null) + { + $token = ''; // set $token as an empty string + $characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/+'; + $charactersLength = strlen($characters) - 1; + + // Select some random characters + for ($i = 0; $i < $length; $i++) $token .= $characters[mt_rand(0, $charactersLength)]; + } return $token; } @@ -224,3 +239,15 @@ function isDateWorkingDay($date, $days = null) return true; } } + +/** + * Parse the given given text using the given data parameter + * Use the CI parser which performs simple text substitution for pseudo-variable + */ +function parseText($text, $data) +{ + $ci =& get_instance(); // get CI instance + $ci->load->library('parser'); // Loads CI parser library + + return $ci->parser->parse_string($text, $data, true); +} diff --git a/application/helpers/hlp_sancho_helper.php b/application/helpers/hlp_sancho_helper.php index 6f5ef8c24..5d2d9f1f1 100644 --- a/application/helpers/hlp_sancho_helper.php +++ b/application/helpers/hlp_sancho_helper.php @@ -98,9 +98,7 @@ function _parseMailContent($vorlage_kurzbz, $vorlage_data) !isEmptyString($result->retval[0]->text)) { // Parses template text - $parsedText = $ci->vorlagelib->parseVorlagetext($result->retval[0]->text, $vorlage_data); - - return $parsedText; + return parseText($result->retval[0]->text, $vorlage_data); } } } diff --git a/application/libraries/PhrasesLib.php b/application/libraries/PhrasesLib.php index af642fe9e..7d0d6859f 100644 --- a/application/libraries/PhrasesLib.php +++ b/application/libraries/PhrasesLib.php @@ -165,16 +165,6 @@ class PhrasesLib } /** - * parseVorlagetext() - will parse a Vorlagetext. - */ - public function parseVorlagetext($text, $data = array()) - { - if (isEmptyString($text)) return error('Not a valid text'); - - return $this->_ci->parser->parse_string($text, $data, true); - } - - /** * Retrieves a phrases from the the property _phrases with the given parameters * It also replace parameters inside the phrase if they are provided * @param string $category Category name which is used to categorize the phrase. @@ -201,7 +191,7 @@ class PhrasesLib { if (!is_array($parameters)) $parameters = array(); // if params is not an array - return $this->_ci->parser->parse_string($_phrase->text, $parameters, true); // parsing + return parseText($_phrase->text, $parameters); // parsing } } } diff --git a/application/libraries/VorlageLib.php b/application/libraries/VorlageLib.php index d6c9d6a98..9679dff1c 100644 --- a/application/libraries/VorlageLib.php +++ b/application/libraries/VorlageLib.php @@ -188,18 +188,4 @@ class VorlageLib $vorlagetext = $this->ci->VorlageStudiengangModel->update($vorlagestudiengang_id, $data); return $vorlagetext; } - - /** - * parseVorlagetext() - will parse a Vorlagetext. - * - * @param string $text REQUIRED - * @param array $data REQUIRED - * @return string - */ - public function parseVorlagetext($text, $data = array()) - { - if (isEmptyString($text)) return error('Not a valid text'); - - return $this->ci->parser->parse_string($text, $data, true); - } } diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index ac5f5fdba..b76d994ee 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -2938,6 +2938,31 @@ if(!$result = @$db->db_query("SELECT bezeichnung_mehrsprachig FROM bis.tbl_orgfo } } +// Add column oe_kurzbz to public.tbl_msg_recipient +if(!$result = @$db->db_query("SELECT oe_kurzbz FROM public.tbl_msg_recipient LIMIT 1")) +{ + $qry = 'ALTER TABLE public.tbl_msg_recipient ADD COLUMN oe_kurzbz character varying(32);'; + if(!$db->db_query($qry)) + echo 'public.tbl_msg_recipient: '.$db->db_last_error().'
'; + else + echo '
Added column oe_kurzbz to table public.tbl_msg_recipient'; + + // FOREIGN KEY fk_tbl_msg_recipient_oe_kurzbz: public.tbl_msg_recipient.oe_kurzbz references public.tbl_organisationseinheit.oe_kurzbz + if ($result = @$db->db_query("SELECT conname FROM pg_constraint WHERE conname = 'fk_tbl_msg_recipient_oe_kurzbz'")) + { + if ($db->db_num_rows($result) == 0) + { + $qry = "ALTER TABLE public.tbl_msg_recipient ADD CONSTRAINT fk_tbl_msg_recipient_oe_kurzbz FOREIGN KEY (oe_kurzbz) + REFERENCES public.tbl_organisationseinheit(oe_kurzbz) ON UPDATE CASCADE ON DELETE RESTRICT;"; + + if (!$db->db_query($qry)) + echo 'public.tbl_msg_recipient: '.$db->db_last_error().'
'; + else + echo '
public.tbl_msg_recipient: added foreign key on column oe_kurzbz referenced to public.tbl_organisationseinheit(oe_kurzbz)'; + } + } +} + // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen echo '

Pruefe Tabellen und Attribute!

'; @@ -3121,7 +3146,7 @@ $tabellen=array( "public.tbl_mitarbeiter" => array("mitarbeiter_uid","personalnummer","telefonklappe","kurzbz","lektor","fixangestellt","bismelden","stundensatz","ausbildungcode","ort_kurzbz","standort_id","anmerkung","insertamum","insertvon","updateamum","updatevon","ext_id","kleriker"), "public.tbl_msg_attachment" => array("attachment_id","message_id","name","filename"), "public.tbl_msg_message" => array("message_id","person_id","subject","body","priority","relationmessage_id","oe_kurzbz","insertamum","insertvon"), - "public.tbl_msg_recipient" => array("message_id","person_id","token","sent","sentinfo","insertamum","insertvon"), + "public.tbl_msg_recipient" => array("message_id","person_id","token","sent","sentinfo","insertamum","insertvon","oe_kurzbz"), "public.tbl_msg_status" => array("message_id","person_id","status","statusinfo","insertamum","insertvon","updateamum","updatevon"), "public.tbl_notiz" => array("notiz_id","titel","text","verfasser_uid","bearbeiter_uid","start","ende","erledigt","insertamum","insertvon","updateamum","updatevon","ext_id"), "public.tbl_notizzuordnung" => array("notizzuordnung_id","notiz_id","projekt_kurzbz","projektphase_id","projekttask_id","uid","person_id","prestudent_id","bestellung_id","lehreinheit_id","ext_id","anrechnung_id"), From a5b3f0ed88219ea817c8aa496ac334384a810bc9 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 13 Jun 2019 14:09:56 +0200 Subject: [PATCH 002/138] - Moved constants EMAIL_KONTAKT_TYPE and SENT_INFO_NEWLINE from config/constants.php to MessageLib - Added function parseTemplate to helper helpers/hlp_common_helper.php - Changed method getMessages of model models/system/Recipient_model.php - Changed views/templates/mailHTML.php and views/templates/mailTXT.php --- application/config/constants.php | 5 ----- application/helpers/hlp_common_helper.php | 14 +++++++++++++- application/models/system/Recipient_model.php | 16 +++------------- application/views/templates/mailHTML.php | 6 +++--- application/views/templates/mailTXT.php | 8 ++++++-- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/application/config/constants.php b/application/config/constants.php index e1c5906c3..ce917b5a3 100644 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -125,11 +125,6 @@ define('EMAIL_CONFIG_INDEX', 'mail'); | Messaging system constants |-------------------------------------------------------------------------- */ -// Email kontakt type -define('EMAIL_KONTAKT_TYPE', 'email'); -// tbl_msg_recipient->sentInfo separator -define('SENT_INFO_NEWLINE', '\n'); - // Message statuses define('MSG_STATUS_UNREAD', 0); define('MSG_STATUS_READ', 1); diff --git a/application/helpers/hlp_common_helper.php b/application/helpers/hlp_common_helper.php index 45a36914c..025834ed2 100644 --- a/application/helpers/hlp_common_helper.php +++ b/application/helpers/hlp_common_helper.php @@ -241,7 +241,7 @@ function isDateWorkingDay($date, $days = null) } /** - * Parse the given given text using the given data parameter + * Parse the given text using the given data parameter * Use the CI parser which performs simple text substitution for pseudo-variable */ function parseText($text, $data) @@ -251,3 +251,15 @@ function parseText($text, $data) return $ci->parser->parse_string($text, $data, true); } + +/** + * Parse the given template using the given data parameter + * Use the CI parser which performs simple text substitution for pseudo-variable + */ +function parseTemplate($template, $data) +{ + $ci =& get_instance(); // get CI instance + $ci->load->library('parser'); // Loads CI parser library + + return $ci->parser->parse($template, $data, true); +} diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 654a9a883..74a1c3256 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -205,7 +205,7 @@ class Recipient_model extends DB_Model * @param limit specifies the number of messages to get * @param message_id specifies a single message */ - public function getMessages($kontaktType, $sent, $limit = null, $message_id = null) + public function getMessages($kontaktType, $limit = 1, $message_id = null) { $query = 'SELECT mm.message_id, ks.kontakt as sender, @@ -239,17 +239,7 @@ class Recipient_model extends DB_Model $parametersArray = array($kontaktType, $kontaktType); - if (is_null($sent) || $sent == '') - { - $query .= ' WHERE mr.sent IS NULL'; - } - else - { - array_push($parametersArray, $sent); - $query .= ' WHERE mr.sent = ?'; - } - - if (!is_null($message_id)) + if (is_numeric($message_id)) { array_push($parametersArray, $message_id); $query .= ' AND mm.message_id = ?'; @@ -257,7 +247,7 @@ class Recipient_model extends DB_Model $query .= ' ORDER BY mr.insertamum ASC'; - if (!is_null($limit)) + if (is_numeric($limit)) { $query .= ' LIMIT ?'; array_push($parametersArray, $limit); diff --git a/application/views/templates/mailHTML.php b/application/views/templates/mailHTML.php index c2e072f68..32d544c5a 100644 --- a/application/views/templates/mailHTML.php +++ b/application/views/templates/mailHTML.php @@ -1,12 +1,12 @@ - This is not the email template, this is a tribute + Notification of personal message reception
-

Neue Nachricht vorhanden

+

A new message is available

diff --git a/application/views/templates/mailTXT.php b/application/views/templates/mailTXT.php index cd55aeb06..09634e6ae 100644 --- a/application/views/templates/mailTXT.php +++ b/application/views/templates/mailTXT.php @@ -1,3 +1,7 @@ -Follow the following link to read the message. +Notification of personal message reception -{href} \ No newline at end of file +A new message is available + +Click here to view the message + +{href} From 8135c6275e991b34b8cc98a41c355ef600a8affc Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 13 Jun 2019 15:57:45 +0200 Subject: [PATCH 003/138] - Fixed query building in method getMessages of model models/system/Recipient_model.php - Better code in controller api/v1/system/Message.php - Adapted controller api/v1/system/Message.php to use sendMessageUser and sendMessageUserTemplate methods from MessageLib - Adapted model models/CL/Messages_model.php to use sendMessageUser and sendMessageUserTemplate methods from MessageLib - Adapted model models/CL/Messages_model.php to use function parseText - Removed constant MSG_INDX_PREFIX from MessageLib - Added constants to MessageLib: CFG_SYSTEM_PERSON_ID, CFG_SEND_IMMEDIATELY, CFG_MESSAGE_SERVER, CFG_MESSAGE_HTML_VIEW_URL, CFG_OU_RECEIVERS, NOTICE_TEMPLATE_HTML, NOTICE_TEMPLATE_TXT, NOTICE_TEMPLATE_FALLBACK_HTML, NOTICE_TEMPLATE_FALLBACK_TXT, EMAIL_KONTAKT_TYPE and SENT_INFO_NEWLINE - MessageLib does not load anymore library parser - Improved MessageLib code - Added private methodis _sendMessage, _getSender, _getNoticeBody, _getNoticeHTMLBody, _getNoticeTXTBody and _ouExists to MessageLib - Added public methods sendMessageUser, sendMessageUserTemplate and sendMessageOU to MessageLib - Renamed method sendAll to sendAllNotices in MessageLib - Renamed method sendOne to _sendNotice and changed it from public to private - Renamed method _checkReceiverId to _getReceiversByPersonId --- .../controllers/api/v1/system/Message.php | 63 +- application/libraries/MessageLib.php | 1145 ++++++++--------- application/models/CL/Messages_model.php | 39 +- application/models/system/Recipient_model.php | 2 +- 4 files changed, 574 insertions(+), 675 deletions(-) diff --git a/application/controllers/api/v1/system/Message.php b/application/controllers/api/v1/system/Message.php index be87526ed..5c663e832 100644 --- a/application/controllers/api/v1/system/Message.php +++ b/application/controllers/api/v1/system/Message.php @@ -144,26 +144,26 @@ class Message extends APIv1_Controller */ public function postMessage() { - $validation = $this->_validatePostMessage($this->post()); + $postMessage = $this->_validatePostMessage($this->post()); - if (isSuccess($validation)) + if (isSuccess($postMessage)) { - $result = $this->messagelib->sendMessage( - isset($this->post()['person_id']) ? $this->post()['person_id'] : null, - isset($this->post()['receiver_id']) ? $this->post()['receiver_id'] : null, - $this->post()['subject'], - $this->post()['body'], - PRIORITY_NORMAL, - isset($this->post()['relationmessage_id']) ? $this->post()['relationmessage_id'] : null, - isset($this->post()['oe_kurzbz']) ? $this->post()['oe_kurzbz'] : null, // Sender organisation unit - isset($this->post()['multiPartMime']) ? $this->post()['multiPartMime'] : true + $result = $this->messagelib->sendMessageUser( + $this->post()['receiver_id']), // receiverPersonId + $this->post()['subject'], // subject + $this->post()['body'], // body + $this->post()['person_id']) ? $this->post()['person_id'] : null, // sender_id + isset($this->post()['oe_kurzbz']) ? $this->post()['oe_kurzbz'] : null, // senderOU + isset($this->post()['relationmessage_id']) ? $this->post()['relationmessage_id'] : null, // relationmessage_id + MSG_PRIORITY_NORMAL, // priority + isset($this->post()['multiPartMime']) ? $this->post()['multiPartMime'] : true // multiPartMime ); $this->response($result, REST_Controller::HTTP_OK); } else { - $this->response($validation, REST_Controller::HTTP_OK); + $this->response($postMessage, REST_Controller::HTTP_OK); } } @@ -172,26 +172,27 @@ class Message extends APIv1_Controller */ public function postMessageVorlage() { - $validation = $this->_validatePostMessageVorlage($this->post()); + $postMessage = $this->_validatePostMessageVorlage($this->post()); - if (isSuccess($validation)) + if (isSuccess($postMessage)) { - $result = $this->messagelib->sendMessageVorlage( - isset($this->post()['sender_id']) ? $this->post()['sender_id'] : null, - isset($this->post()['receiver_id']) ? $this->post()['receiver_id'] : null, - $this->post()['vorlage_kurzbz'], - isset($this->post()['oe_kurzbz']) ? $this->post()['oe_kurzbz'] : null, // Sender organisation unit - $this->post()['data'], - isset($this->post()['relationmessage_id']) ? $this->post()['relationmessage_id'] : null, - isset($this->post()['orgform_kurzbz']) ? $this->post()['orgform_kurzbz'] : null, - isset($this->post()['multiPartMime']) ? $this->post()['multiPartMime'] : true + $result = $this->messagelib->sendMessageUserTemplate( + isset($this->post()['receiver_id']) ? $this->post()['receiver_id'] : null, // receiversPersonId + $this->post()['vorlage_kurzbz'], // vorlage + $this->post()['data'], // parseData + isset($this->post()['orgform_kurzbz']) ? $this->post()['orgform_kurzbz'] : null, // orgform + isset($this->post()['sender_id']) ? $this->post()['sender_id'] : null, // sender_id + isset($this->post()['oe_kurzbz']) ? $this->post()['oe_kurzbz'] : null, // senderOU + isset($this->post()['relationmessage_id']) ? $this->post()['relationmessage_id'] : null, // relationmessage_id + MSG_PRIORITY_NORMAL, // priority + isset($this->post()['multiPartMime']) ? $this->post()['multiPartMime'] : true // multiPartMime ); $this->response($result, REST_Controller::HTTP_OK); } else { - $this->response($validation, REST_Controller::HTTP_OK); + $this->response($postMessage, REST_Controller::HTTP_OK); } } @@ -220,26 +221,26 @@ class Message extends APIv1_Controller /** * _validatePostMessage */ - private function _validatePostMessage($message = null) + private function _validatePostMessage($post = null) { - if (!isset($message)) + if (!isset($post)) { return error('Parameter is null'); } - if (!isset($message['subject'])) + if (!isset($post['subject'])) { return error('subject is not set'); } - if( !isset($message['body'])) + if (!isset($post['body'])) { return error('body is not set'); } - if (!isset($message['receiver_id']) && !isset($message['oe_kurzbz'])) + if (!isset($post['receiver_id'])) { - return error('If a receiver_id is not given a oe_kurzbz must be specified'); + return error('receiver_id is not set'); } - return success('Input data are valid'); + return success(); } /** diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index feba96473..7911d4b2d 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -7,7 +7,21 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); */ class MessageLib { - const MSG_INDX_PREFIX = 'message_'; + // Config entries + const CFG_SYSTEM_PERSON_ID = 'system_person_id'; + const CFG_SEND_IMMEDIATELY = 'send_immediately'; + const CFG_MESSAGE_SERVER = 'message_server'; + const CFG_MESSAGE_HTML_VIEW_URL = 'message_html_view_url'; + const CFG_OU_RECEIVERS = 'ou_receivers'; + + // Templates names + const NOTICE_TEMPLATE_HTML = 'MessageMailHTML'; + const NOTICE_TEMPLATE_TXT = 'MessageMailTXT'; + const NOTICE_TEMPLATE_FALLBACK_HTML = 'templates/mailHTML'; + const NOTICE_TEMPLATE_FALLBACK_TXT = 'templates/mailTXT'; + + const EMAIL_KONTAKT_TYPE = 'email'; // Email kontakt type + const SENT_INFO_NEWLINE = '\n'; // tbl_msg_recipient->sentInfo separator private $_ci; @@ -22,8 +36,6 @@ class MessageLib // Loads message configuration $this->_ci->config->load('message'); - // CI Parser library - $this->_ci->load->library('parser'); // Loads LogLib $this->_ci->load->library('LogLib'); // Loads VorlageLib @@ -31,352 +43,106 @@ class MessageLib // Loads Mail library $this->_ci->load->library('MailLib'); - // Loading models + // Loads message models $this->_ci->load->model('system/Message_model', 'MessageModel'); $this->_ci->load->model('system/MsgStatus_model', 'MsgStatusModel'); $this->_ci->load->model('system/Recipient_model', 'RecipientModel'); $this->_ci->load->model('system/Attachment_model', 'AttachmentModel'); + + // Loads extra models + $this->_ci->load->model('person/Person_model', 'PersonModel'); + $this->_ci->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); + $this->_ci->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); + $this->_ci->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); } //------------------------------------------------------------------------------------------------------------------ // Public methods /** - * getMessage() - returns the specified received message for a specified person + * Returns the specified message for a specified person */ public function getMessage($msg_id, $person_id) { - if (!is_numeric($msg_id)) - return $this->_error('', MSG_ERR_INVALID_MSG_ID); - if (!is_numeric($person_id)) - return $this->_error('', MSG_ERR_INVALID_RECIPIENTS); + if (!is_numeric($msg_id)) return error('The given message id is not valid', MSG_ERR_INVALID_MSG_ID); + if (!is_numeric($person_id)) return error('The given person id is not valid', MSG_ERR_INVALID_RECIPIENTS); return $this->_ci->RecipientModel->getMessage($msg_id, $person_id); } /** - * getMessagesByUID() - will return all messages, including the latest status for specified user. It don´t returns Attachments. + * Sends a message to persons ($receiversPersonId) */ - public function getMessagesByUID($uid, $oe_kurzbz = null, $all = false) + public function sendMessageUser( + $receiversPersonId, $subject, $body, // Required parameters + $sender_id = null, $senderOU = null, $relationmessage_id = null, $priority = MSG_PRIORITY_NORMAL, $multiPartMime = true + ) { - if (isEmptyString($uid)) - return $this->_error('', MSG_ERR_INVALID_MSG_ID); + // Retrieves receiver id and checks that is valid + $receivers = $this->_getReceiversByPersonId($receiversPersonId); + if (isError($receivers)) return $receivers; - return $this->_ci->RecipientModel->getMessagesByUID($uid, $oe_kurzbz, $all); + // Send the message and return the result + return $this->_sendMessage($receivers, null, $subject, $body, $sender_id, $senderOU, $relationmessage_id, $priority, $multiPartMime); } /** - * getMessagesByPerson() - will return all messages, including the latest status for specified user. It don´t returns Attachments. + * Sends a message to persons ($receiversPersonId) */ - public function getMessagesByPerson($person_id, $oe_kurzbz = null, $all = false) + public function sendMessageUserTemplate( + $receiversPersonId, $vorlage, $parseData, // Required parameters + $orgform = null, $sender_id = null, $senderOU = null, $relationmessage_id = null, $priority = MSG_PRIORITY_NORMAL, $multiPartMime = true + ) { - if (!is_numeric($person_id)) - return $this->_error('', MSG_ERR_INVALID_MSG_ID); - - return $this->_ci->RecipientModel->getMessagesByPerson($person_id, $oe_kurzbz, $all); - } - - /** - * getSentMessagesByPerson() - Get all sent messages from a person identified by person_id - */ - public function getSentMessagesByPerson($person_id, $oe_kurzbz = null, $all = false) - { - if (!is_numeric($person_id)) - return $this->_error('', MSG_ERR_INVALID_MSG_ID); - - return $this->_ci->MessageModel->getMessagesByPerson($person_id, $oe_kurzbz, $all); - } - - /** - * getMessageByToken - */ - public function getMessageByToken($token) - { - if (isEmptyString($token)) - return $this->_error('', MSG_ERR_INVALID_TOKEN); - - $result = $this->_ci->RecipientModel->getMessageByToken($token); - if (hasData($result)) + // Loads template data + $templateResult = $this->_ci->vorlagelib->loadVorlagetext($vorlage, $senderOU, $orgform, getUserLanguage()); + if (hasData($templateResult)) // if a template is found { - // Searches for a status that is different from unread - $found = -1; - for ($i = 0; $i < count($result->retval); $i++) - { - if ($result->retval[$i]->status > MSG_STATUS_UNREAD) - { - $found = $i; - break; - } - } + $template = getData($templateResult)[0]; // template object - // If not found then insert the read status - if ($found == -1) - { - $statusKey = array( - 'message_id' => $result->retval[0]->message_id, - 'person_id' => $result->retval[0]->receiver_id, - 'status' => MSG_STATUS_READ - ); + // Parses template subject + $subject = parseText($template->subject, $parseData); + // Parses template text + $body = parseText($template->text, $parseData); - $resultIns = $this->_ci->MsgStatusModel->insert($statusKey); - // If an error occured while writing on data base, then return it - if (isError($resultIns)) - { - $result = $resultIns; - } - } - } - - return $result; - } - - /** - * getCountUnreadMessages - */ - public function getCountUnreadMessages($person_id, $oe_kurzbz = null) - { - if (!is_numeric($person_id)) - return $this->_error('', MSG_ERR_INVALID_RECIPIENTS); - - return $this->_ci->RecipientModel->getCountUnreadMessages($person_id, $oe_kurzbz); - } - - /** - * 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 (!is_numeric($message_id)) - { - return $this->_error('', MSG_ERR_INVALID_MSG_ID); - } - - if (!is_numeric($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); - } - - // Searches if the status is already present - $result = $this->_ci->MsgStatusModel->load(array($message_id, $person_id, $status)); - if (hasData($result)) - { - // status already present - } - else - { - // Insert the new status - $statusKey = array( - 'message_id' => $message_id, - 'person_id' => $person_id, - 'status' => $status + return $this->sendMessageUser( + $receiversPersonId, $subject, $body, $sender_id, $senderOU, $relationmessage_id, $priority, $multiPartMime ); - - $result = $this->_ci->MsgStatusModel->insert($statusKey); } - - return $result; + elseif (isError($templateResult)) // if an error occured + { + return $templateResult; // return it + } + else // if a template was not found + { + return error('Template was not found', MSG_ERR_INVALID_TEMPLATE); + } } /** - * sendMessage() - sends new internal message. This function will create a new thread + * Sends a message to all the persons that are enabled to read messages for the given organisation unit ($receiversOU) */ - public function sendMessage($sender_id, $receiver_id, $subject, $body, $priority = PRIORITY_NORMAL, $relationmessage_id = null, $oe_kurzbz = null, $multiPartMime = true) + public function sendMessageOU( + $receiversOU, $subject, $body, // Required parameters + $sender_id = null, $senderOU = null, $relationmessage_id = null, $priority = MSG_PRIORITY_NORMAL, $multiPartMime = true + ) { - if (!is_numeric($sender_id)) - { - $sender_id = $this->_ci->config->item('system_person_id'); - } + // If the recipient is an organisation unit that would be possible to send the same message (same message id) + // to the entire organisation unit (one to many functionality) + // In this case the receiver id is a the one present in message configuration + $receivers = success(array($this->_ci->config->item(self::CFG_SYSTEM_PERSON_ID))); - $receivers = $this->_getReceivers($receiver_id, $oe_kurzbz); - - // If everything went ok - if (isSuccess($receivers) && is_array($receivers->retval)) - { - // If no receivers were found for this organization unit - if (count($receivers->retval) == 0) - { - $result = $this->_error($receivers->retval, MSG_ERR_OU_CONTACTS_NOT_FOUND); - } - - // Looping on receivers - for ($i = 0; $i < count($receivers->retval); $i++) - { - $receiver_id = $receivers->retval[$i]->person_id; - - // Checks if the receiver exists - if ($this->_checkReceiverId($receiver_id)) - { - // If the text and the subject of the template are not empty - if (!isEmptyString($subject) && !isEmptyString($body)) - { - $result = $this->_saveMessage($sender_id, $receiver_id, $subject, $body, $relationmessage_id, $oe_kurzbz); - // If no errors were occurred - // Leave the code commented - if (isSuccess($result)) - { - // If the system is configured to send messages immediately - if ($this->_ci->config->item('send_immediately') === true) - { - // Send message by email! - $resultSendEmail = $this->sendOne($result->retval, $subject, $body, $multiPartMime); - } - } - } - else - { - if (isEmptyString($subject)) - { - $result = $this->_error('', MSG_ERR_SUBJECT_EMPTY); - break; - } - elseif (isEmptyString($body)) - { - $result = $this->_error('', MSG_ERR_BODY_EMPTY); - break; - } - } - } - else - { - $result = $this->_error('', MSG_ERR_INVALID_RECEIVER_ID); - break; - } - } - } - // If there was some errors then copy them into the returning variable - else - { - $result = $receivers; - } - - return $result; + // Send the message and return the result + return $this->_sendMessage($receivers, $receiversOU, $subject, $body, $sender_id, $senderOU, $relationmessage_id, $priority, $multiPartMime); } - /** - * 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); - - // If everything went ok - if (isSuccess($receivers) && is_array($receivers->retval)) - { - // If no receivers were found for this organization unit - if (count($receivers->retval) == 0) - { - $result = $this->_error($receivers->retval, MSG_ERR_OU_CONTACTS_NOT_FOUND); - } - else - { - // Load reveiver data to get its relative language - $this->_ci->load->model('person/Person_model', 'PersonModel'); - } - - // Looping on receivers - for ($i = 0; $i < count($receivers->retval); $i++) - { - $receiver_id = $receivers->retval[$i]->person_id; - - // Checks if the receiver exists - $result = $this->_ci->PersonModel->load($receiver_id); - if (hasData($result)) - { - // Retrieves the language of the logged user - $sprache = getUserLanguage(); - - // Loads template data - $result = $this->_ci->vorlagelib->loadVorlagetext($vorlage_kurzbz, $oe_kurzbz, $orgform_kurzbz, $sprache); - if (isSuccess($result)) - { - // If the text and the subject of the template are not empty - if (is_array($result->retval) && count($result->retval) > 0 && - !isEmptyString($result->retval[0]->text) && !isEmptyString($result->retval[0]->subject)) - { - // Parses template text - $parsedText = $this->_ci->vorlagelib->parseVorlagetext($result->retval[0]->text, $data); - // Parses subject - $subject = $this->_ci->vorlagelib->parseVorlagetext($result->retval[0]->subject, $data); - - // Save message - $result = $this->_saveMessage($sender_id, $receiver_id, $subject, $parsedText, $relationmessage_id, $oe_kurzbz); - // If no errors were occurred - if (isSuccess($result)) - { - // If the system is configured to send messages immediately - if ($this->_ci->config->item('send_immediately') === true) - { - // Send message by email! - $resultSendEmail = $this->sendOne($result->retval, $subject, $parsedText, $multiPartMime); - } - } - } - else - { - // Better message error - if (!is_array($result->retval) || (is_array($result->retval) && count($result->retval) == 0)) - { - $result = $this->_error('', MSG_ERR_TEMPLATE_NOT_FOUND); - break; - } - elseif (is_array($result->retval) && count($result->retval) > 0) - { - if (is_null($result->retval[0]->oe_kurzbz)) - { - $result = $this->_error('', MSG_ERR_TEMPLATE_NOT_FOUND); - break; - } - elseif (isEmptyString($result->retval[0]->text)) - { - $result = $this->_error('', MSG_ERR_INVALID_TEMPLATE); - break; - } - elseif (isEmptyString($result->retval[0]->subject)) - { - $result = $this->_error('', MSG_ERR_INVALID_TEMPLATE); - break; - } - } - } - } - else - { - $result = $this->_error($result->retval, EXIT_ERROR); - break; - } - } - else - { - $result = $this->_error('', MSG_ERR_INVALID_RECEIVER_ID); - break; - } - } - } - // If there was some errors then copy them into the returning variable - else - { - $result = $receivers; - } - - return $result; - } + //------------------------------------------------------------------------------------------------------------------ + // Public methods called by a job /** * Gets all the messages from DB and sends them via email */ - public function sendAll($numberToSent = null, $numberPerTimeRange = null, $email_time_range = null, $email_from_system = null) + public function sendAllNotices($numberToSent = null, $numberPerTimeRange = null, $email_time_range = null, $email_from_system = null) { $sent = true; // optimistic expectation @@ -393,8 +159,7 @@ class MessageLib // Gets a number ($this->_ci->maillib->getMaxEmailToSent()) of unsent messages from DB // having EMAIL_KONTAKT_TYPE as relative contact type $result = $this->_ci->RecipientModel->getMessages( - EMAIL_KONTAKT_TYPE, - null, + self::EMAIL_KONTAKT_TYPE, $this->_ci->maillib->getConfigs()->email_number_to_sent ); // Checks if errors were occurred @@ -410,21 +175,20 @@ class MessageLib if ((!is_null($result->retval[$i]->receiver) && $result->retval[$i]->receiver != '') || (!is_null($result->retval[$i]->employeecontact) && $result->retval[$i]->employeecontact != '')) { - $href = $this->_ci->config->item('message_server').$this->_ci->config->item('message_html_view_url').$result->retval[$i]->token; + $href = $this->_ci->config->item(self::CFG_MESSAGE_SERVER).$this->_ci->config->item(self::CFG_MESSAGE_HTML_VIEW_URL).$result->retval[$i]->token; - $vorlage = $this->_ci->vorlagelib->loadVorlagetext('MessageMailHTML'); + $vorlage = $this->_ci->vorlagelib->loadVorlagetext(self::NOTICE_TEMPLATE_HTML); if(hasData($vorlage)) { // Using a template for the html email body - $body = $this->_ci->parser->parse_string( + $body = parseText( $vorlage->retval[0]->text, array( 'href' => $href, 'subject' => $result->retval[$i]->subject, 'body' => $result->retval[$i]->body - ), - true + ) ); } else @@ -445,18 +209,17 @@ class MessageLib $this->_ci->loglib->logError('Error while parsing the mail template'); } - $vorlage = $this->_ci->vorlagelib->loadVorlagetext('MessageMailTXT'); + $vorlage = $this->_ci->vorlagelib->loadVorlagetext(self::NOTICE_TEMPLATE_TXT); if(hasData($vorlage)) { // Using a template for the plain text email body - $altBody = $this->_ci->parser->parse_string( + $altBody = parseText( $vorlage->retval[0]->text, array( 'href' => $href, 'subject' => $result->retval[$i]->subject, 'body' => $result->retval[$i]->body - ), - true + ) ); } else @@ -506,7 +269,7 @@ class MessageLib { $this->_ci->loglib->logError('Error while sending an email'); // Writing errors in tbl_msg_recipient - $sme = $this->setMessageError( + $sme = $this->_setSentError( $result->retval[$i]->message_id, $result->retval[$i]->receiver_id, 'Error while sending an email', @@ -520,7 +283,7 @@ class MessageLib else { // Setting the message as sent in DB - $sent = $this->setMessageSent($result->retval[$i]->message_id, $result->retval[$i]->receiver_id); + $sent = $this->_setSentSuccess($result->retval[$i]->message_id, $result->retval[$i]->receiver_id); // If some errors occurred if (!$sent) { @@ -532,7 +295,7 @@ class MessageLib { $this->_ci->loglib->logError('This person does not have an email account'); // Writing errors in tbl_msg_recipient - $sme = $this->setMessageError( + $sme = $this->_setSentError( $result->retval[$i]->message_id, $result->retval[$i]->receiver_id, 'This person does not have an email account', @@ -561,244 +324,51 @@ class MessageLib return $sent; } - /** - * Gets one message from DB and sends it via email - */ - public function sendOne($message_id, $subject = null, $body = null, $multiPartMime = true) - { - $sent = true; // optimistic expectation - - // Get a specific message from DB having EMAIL_KONTAKT_TYPE as relative contact type - $result = $this->_ci->RecipientModel->getMessages( - EMAIL_KONTAKT_TYPE, - null, - null, - $message_id - ); - - // Checks if errors were occurred - if (isSuccess($result)) - { - // If data are present - if (is_array($result->retval) && count($result->retval) > 0) - { - // If the person has an email account - if ((!is_null($result->retval[0]->receiver) && $result->retval[0]->receiver != '') - || (!is_null($result->retval[0]->employeecontact) && $result->retval[0]->employeecontact != '')) - { - // If it is required use a multi-part message in MIME format - if ($multiPartMime === true) - { - // Using a template for the html email body - $href = $this->_ci->config->item('message_server').$this->_ci->config->item('message_html_view_url').$result->retval[0]->token; - - $vorlage = $this->_ci->vorlagelib->loadVorlagetext('MessageMailHTML'); - if(hasData($vorlage)) - { - $bodyMsg = $this->_ci->parser->parse_string( - $vorlage->retval[0]->text, - array( - 'href' => $href, - 'subject' => $result->retval[0]->subject, - 'body' => $result->retval[0]->body - ), - true - ); - } - else - { - $bodyMsg = $this->_ci->parser->parse( - 'templates/mailHTML', - array( - 'href' => $href, - 'subject' => $result->retval[0]->subject, - 'body' => $result->retval[0]->body - ), - true - ); - } - if (is_null($bodyMsg) || $bodyMsg == '') - { - // $body = $result->retval[0]->body; - $this->_ci->loglib->logError('Error while parsing the html mail template'); - } - - // Using a template for the plain text email body - $vorlage = $this->_ci->vorlagelib->loadVorlagetext('MessageMailTXT'); - if(hasData($vorlage)) - { - $altBody = $this->_ci->parser->parse_string( - $vorlage->retval[0]->text, - array( - 'href' => $href, - 'subject' => $result->retval[0]->subject, - 'body' => $result->retval[0]->body - ), - true - ); - } - else - { - $altBody = $this->_ci->parser->parse( - 'templates/mailTXT', - array( - 'href' => $href, - 'subject' => $result->retval[0]->subject, - 'body' => $result->retval[0]->body - ), - true - ); - } - if (is_null($altBody) || $altBody == '') - { - $this->_ci->loglib->logError('Error while parsing the plain text mail template'); - } - } - else - { - $bodyMsg = $altBody = $body; - } - - // If the sender is not an employee, then system-sender is used if empty - $sender = ''; - if (!is_null($result->retval[0]->senderemployeecontact) && $result->retval[0]->senderemployeecontact != '') - { - $sender = $result->retval[0]->senderemployeecontact.'@'.DOMAIN; - } - - $receiverContact = $result->retval[0]->receiver; - if (!is_null($result->retval[0]->employeecontact) && $result->retval[0]->employeecontact != '') - { - $receiverContact = $result->retval[0]->employeecontact.'@'.DOMAIN; - } - - // Sending email - $sent = $this->_ci->maillib->send( - null, - $receiverContact, - is_null($subject) ? $result->retval[0]->subject : $subject, // if parameter subject is not null, use it! - $bodyMsg, - null, - null, - null, - $altBody - ); - // If errors were occurred while sending the email - if (!$sent) - { - $this->_ci->loglib->logError('Error while sending an email'); - // Writing errors in tbl_msg_recipient - $sme = $this->setMessageError( - $result->retval[0]->message_id, - $result->retval[0]->receiver_id, - 'Error while sending an email', - $result->retval[0]->sentinfo - ); - if (!$sme) - { - $this->_ci->loglib->logError('Error while updating DB'); - } - } - else - { - // Setting the message as sent in DB - $sent = $this->setMessageSent($result->retval[0]->message_id, $result->retval[0]->receiver_id); - // If the email has been sent and the DB updated - if (!$sent) - { - $this->_ci->loglib->logError('Error while updating DB'); - } - } - } - else - { - $this->_ci->loglib->logError('This person does not have an email account'); - // Writing errors in tbl_msg_recipient - $sme = $this->setMessageError( - $result->retval[0]->message_id, - $result->retval[0]->receiver_id, - 'This person does not have an email account', - $result->retval[0]->sentinfo - ); - if (!$sme) - { - $this->_ci->loglib->logError('Error while updating DB'); - } - $sent = true; // Non blocking error - } - } - else - { - $this->_ci->loglib->logInfo('There are no email to be sent'); - $sent = false; - } - } - else - { - $this->_ci->loglib->logError('Something went wrong while getting data from DB'); - $sent = false; - } - - return $sent; - } + //------------------------------------------------------------------------------------------------------------------ + // Public methods used by to build the GUI to write messages to user/s /** - * parseMessageText - */ - public function parseMessageText($text, $data = array()) - { - return $this->_ci->parser->parse_string($text, $data, true); - } - - /** - * Gets data for Person from view vw_msg_vars_person - * @param $person_id + * Retrieves message vars from view vw_msg_vars_person */ public function getMessageVarsPerson() { - $variablesArray = array(); + // Retrieves message vars from view vw_msg_vars_person + $messageVarsPerson = $this->_ci->MessageModel->getMessageVarsPerson(); + if (isSuccess($messageVarsPerson)) // if everything is ok + { + $variablesArray = array(); + $tmpVariablesArray = getData($messageVarsPerson); - $variables = $this->_ci->MessageModel->getMessageVarsPerson(); - if (isError($variables)) - { - return $variables; - } - elseif (hasData($variables)) - { - $tmpVariablesArray = getData($variables); - // Skip person_id + // Starts from 1 to skip the first element which is person_id for ($i = 1; $i < count($tmpVariablesArray); $i++) { $variablesArray['{'.str_replace(' ', '_', strtolower($tmpVariablesArray[$i])).'}'] = $tmpVariablesArray[$i]; } + + return success($variablesArray); } - return success($variablesArray); + return $messageVarsPerson; // otherwise returns the error } /** - * A person may belongs to more organisation units + * Retrieves organisation units for each role that a user plays inside that organisation unit */ public function getOeKurzbz($sender_id) { - $oe_kurzbz = array(); - - $this->_ci->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); - + // Retrieves organisation units for a user from database $benutzer = $this->_ci->BenutzerfunktionModel->getByPersonId($sender_id); - if (isError($benutzer)) - { - return $benutzer; - } - elseif (hasData($benutzer)) + if (isSuccess($benutzer)) // if everything is ok { - foreach (getData($benutzer) as $val) - { - $oe_kurzbz[] = $val->oe_kurzbz; - } + $ouArray = array(); + + // Copies organisation units in $ouArray array + foreach (getData($benutzer) as $val) $ouArray[] = $val->oe_kurzbz; + + return success($ouArray); } - return success($oe_kurzbz); + return $benutzer; // otherwise returns the error } /** @@ -806,55 +376,172 @@ class MessageLib */ public function getIsAdmin($sender_id) { - $this->_ci->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); - return $this->_ci->BenutzerrolleModel->isAdminByPersonId($sender_id); } + //------------------------------------------------------------------------------------------------------------------ + // Public methods used by REST API + + /** + * Return all messages, including the latest status for specified user. It don´t returns Attachments. + * The sender organisation unit may be specified to filter messages + */ + public function getMessagesByUID($uid, $senderOU = null, $all = false) + { + if (isEmptyString($uid)) return error('The given message id is not valid', MSG_ERR_INVALID_MSG_ID); + + return $this->_ci->RecipientModel->getMessagesByUID($uid, $senderOU, $all); + } + + /** + * Return all messages, including the latest status for specified user. It does not return attachments + * The sender organisation unit may be specified to filter messages + */ + public function getMessagesByPerson($person_id, $senderOU = null, $all = false) + { + if (!is_numeric($person_id)) return error('The given message id is not valid', MSG_ERR_INVALID_MSG_ID); + + return $this->_ci->RecipientModel->getMessagesByPerson($person_id, $senderOU, $all); + } + + /** + * Get all sent messages from a person identified by person_id + * The sender organisation unit may be specified to filter messages + */ + public function getSentMessagesByPerson($person_id, $senderOU = null, $all = false) + { + if (!is_numeric($person_id)) return error('The given message id is not valid', MSG_ERR_INVALID_MSG_ID); + + return $this->_ci->MessageModel->getMessagesByPerson($person_id, $senderOU, $all); + } + + /** + * Retrieves a message by its token + * If a message is found with the given token then this message is set as read + */ + public function getMessageByToken($token) + { + if (isEmptyString($token)) return error('The given token is not valid', MSG_ERR_INVALID_TOKEN); + + $result = $this->_ci->RecipientModel->getMessageByToken($token); + if (hasData($result)) + { + // Searches for a status that is NOT unread + $found = false; + + foreach (getData($result) as $message) + { + if ($message->status > MSG_STATUS_UNREAD) + { + $found = true; + break; + } + } + + // If NOT found then insert the read status + if (!$found) + { + $statusData = array( + 'message_id' => getData($result)[0]->message_id, + 'person_id' => getData($result)[0]->receiver_id, + 'status' => MSG_STATUS_READ + ); + + $resultIns = $this->_ci->MsgStatusModel->insert($statusData); + // If an error occured while writing on data base, then return it + if (isError($resultIns)) $result = $resultIns; + } + } + + return $result; + } + + /** + * Counts the unread messages for the given user + * The sender organisation unit may be specified to filter messages + */ + public function getCountUnreadMessages($person_id, $senderOU = null) + { + if (!is_numeric($person_id)) return error('The given person id is not valid', MSG_ERR_INVALID_RECIPIENTS); + + return $this->_ci->RecipientModel->getCountUnreadMessages($person_id, $senderOU); + } + + /** + * Change the message status of the given message specified by message_id and person_id, using the given status + * NOTE: it performs an insert NOT an update + */ + public function updateMessageStatus($message_id, $person_id, $status) + { + if (!is_numeric($message_id)) return error('The given message id is not valid', MSG_ERR_INVALID_MSG_ID); + if (!is_numeric($person_id)) return error('The given person id is not valid', MSG_ERR_INVALID_RECIPIENTS); + if (!is_numeric($status)) return error('The given status is not valid', MSG_ERR_INVALID_STATUS_ID); + + $this->_ci->MsgStatusModel->resetQuery(); // Reset an eventually already buit query + + // Searches if the status is already present + $result = $this->_ci->MsgStatusModel->load(array($message_id, $person_id, $status)); + if (!hasData($result)) // if not found + { + // Insert the new status + $statusKey = array( + 'message_id' => $message_id, + 'person_id' => $person_id, + 'status' => $status + ); + $result = $this->_ci->MsgStatusModel->insert($statusKey); + } + + return $result; + } + //------------------------------------------------------------------------------------------------------------------ // Private methods /** - * Update the table tbl_msg_recipient + * */ - private function _updateMessageRecipient($message_id, $receiver_id, $parameters) + private function _getSender($sender_id) { - $updated = false; - - // Updates table tbl_msg_recipient - $resultUpdate = $this->_ci->RecipientModel->update(array($receiver_id, $message_id), $parameters); - // Checks if errors were occurred - if (isSuccess($resultUpdate) && is_array($resultUpdate->retval)) + // By default the sender is defined in message configuration + $sender = success($this->_ci->config->item(self::CFG_SYSTEM_PERSON_ID)); + if ($sender_id != null) // if it was given as parameter { - $updated = true; + if (is_numeric($sender_id)) // if it valid -> it is a number + { + $sender = success($sender_id); // return it as a success object + } + else + { + // Otherwise returns an error + $sender = error('The given sender is not valid', MSG_ERR_INVALID_SENDER); + } } - return $updated; + return $sender; } /** - * Changes the status of the message from unsent to sent + * Checks if the given receiver ids belong to persons in database */ - private function setMessageSent($message_id, $receiver_id) + private function _getReceiversByPersonId($receiver_id) { - $parameters = array('sent' => 'NOW()', 'sentinfo' => null); + // Reset an eventually already buit query + $this->_ci->PersonModel->resetQuery(); - return $this->_updateMessageRecipient($message_id, $receiver_id, $parameters); - } + // Get only this columns + $this->_ci->PersonModel->addSelect('person_id'); - /** - * Sets the sentInfo with the error - */ - private function setMessageError($message_id, $receiver_id, $sentInfo, $prevSentInfo = null) - { - if (!is_null($prevSentInfo) && $prevSentInfo != '') + // Loads from database the person by its person_id + $personResult = $this->_ci->PersonModel->load($receiver_id); + if (hasData($personResult)) // if data are retrieved { - $sentInfo = $prevSentInfo.SENT_INFO_NEWLINE.$sentInfo; + return $personResult; // return them + } + else // otherwise an error occurred (blocking error or data not found) + { + return error('The given person id is not valid', MSG_ERR_INVALID_RECIPIENTS); } - - $parameters = array('sent' => null, 'sentinfo' => $sentInfo); - - return $this->_updateMessageRecipient($message_id, $receiver_id, $parameters); } /** @@ -869,92 +556,49 @@ class MessageLib // Get all the valid receivers id using the oe_kurzbz $receivers = $this->_ci->BenutzerfunktionModel->loadWhere( 'oe_kurzbz = '.$this->_ci->db->escape($oe_kurzbz). - ' AND funktion_kurzbz = '.$this->_ci->db->escape($this->_ci->config->item('assistent_function')). + ' AND funktion_kurzbz = '.$this->_ci->db->escape($this->_ci->config->item(self::CFG_OU_RECEIVERS)). ' AND (NOW() BETWEEN COALESCE(datum_von, NOW()) AND COALESCE(datum_bis, NOW()))' ); - return $receivers; } /** - * Gets the receivers id + * Save a new message in DB */ - private function _getReceivers($receiver_id, $oe_kurzbz = null) + private function _saveMessage($sender_id, $senderOU, $receiver_id, $receiverOU, $subject, $body, $priority, $relationmessage_id) { - $receivers = null; - - // If no receiver_id is given... - if (is_null($receiver_id)) - { - // ...a oe_kurzbz must be specified - if (is_null($oe_kurzbz)) - { - $receivers = $this->_error('', MSG_ERR_INVALID_OU); - } - else - { - $receivers = $this->_getReceiversByOekurzbz($oe_kurzbz); - } - } - // Else if the receiver id is given - else - { - $receivers = $this->_success(array(new stdClass())); - $receivers->retval[0]->person_id = $receiver_id; - } - - return $receivers; - } - - /** - * 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); - if (hasData($result)) - { - return true; - } - - return false; - } - - /** - * Save a message in DB - **/ - private function _saveMessage($sender_id, $receiver_id, $subject, $body, $relationmessage_id, $oe_kurzbz) - { - // Starts db transaction + // Starts database transaction $this->_ci->db->trans_start(false); - // Save Message - $msgData = array( + // Store message information in tbl_msg_message + $messageData = array( 'person_id' => $sender_id, 'subject' => $subject, 'body' => $body, - 'priority' => PRIORITY_NORMAL, + 'priority' => $priority, 'relationmessage_id' => $relationmessage_id, - 'oe_kurzbz' => $oe_kurzbz + 'oe_kurzbz' => $senderOU ); - $result = $this->_ci->MessageModel->insert($msgData); + + $result = $this->_ci->MessageModel->insert($messageData); if (isSuccess($result)) { - // Link the message with the receiver - $msg_id = $result->retval; + $messageId = getData($result); // Gets the message id generated by database + + // Store message information in tbl_msg_recipient $recipientData = array( 'person_id' => $receiver_id, - 'message_id' => $msg_id, - 'token' => generateToken() + 'message_id' => $messageId, + 'token' => generateToken(), + 'oe_kurzbz' => $receiverOU ); + $result = $this->_ci->RecipientModel->insert($recipientData); if (isSuccess($result)) { - // Save message status + // Store message information in tbl_msg_status $statusData = array( - 'message_id' => $msg_id, + 'message_id' => $messageId, 'person_id' => $receiver_id, 'status' => MSG_STATUS_UNREAD ); @@ -962,35 +606,262 @@ class MessageLib } } - $this->_ci->db->trans_complete(); + $this->_ci->db->trans_complete(); // Ends database transaction + // If the transaction failed... if ($this->_ci->db->trans_status() === false || isError($result)) { - $this->_ci->db->trans_rollback(); - $result = $this->_error('An error occurred while saving a message', EXIT_ERROR); + $this->_ci->db->trans_rollback(); // ...then rollback } - else + else // otherwise commit... { $this->_ci->db->trans_commit(); - $result = $this->_success($msg_id); + $result = success($messageId); // ...and returns the message id } return $result; } /** - * Wrapper for function error + * Set the message as sent successfully by setting columns 'sent' and 'sentinfo' of table tbl_msg_recipient + * sent column is set with date of delivery + * sentinfo is set to null */ - private function _error($retval, $code) + private function _setSentSuccess($message_id, $receiver_id) { - return error($retval, $code); + return $this->_ci->RecipientModel->update(array($receiver_id, $message_id), array('sent' => 'NOW()', 'sentinfo' => null)); } /** - * Wrapper for function success + * Set the message as sent with error by setting columns 'sent' and 'sentinfo' of table tbl_msg_recipient + * Stores the type of error in 'sentinfo' column keeping en eventual previous error + * sent column is set to null */ - private function _success($retval, $code = null) + private function _setSentError($message_id, $receiver_id, $sentInfo, $prevSentInfo) { - return success($retval, $code); + if (!isEmptyString($prevSentInfo)) + { + $sentInfo .= self::SENT_INFO_NEWLINE.$prevSentInfo; + } + + return $this->_ci->RecipientModel->update(array($receiver_id, $message_id), array('sent' => null, 'sentinfo' => $sentInfo)); + } + + /** + * Returns the notice body. Tries to use the template present in database and then falling back + * on the one present in filesystem. If both fail then an error is returned + */ + private function _getNoticeBody($viewMessageLink, $subject, $body, $dbTemplateName, $fsTemplateName) + { + $noticeBody = null; + + $vorlageResult = $this->_ci->vorlagelib->loadVorlagetext($dbTemplateName); + + if (isError($vorlageResult)) return $vorlageResult; + + if (hasData($vorlageResult)) + { + $vorlage = getData($vorlageResult)[0]; + + $noticeBody = parseText( + $vorlage->text, + array( + 'href' => $viewMessageLink, + 'subject' => $subject, + 'body' => $body + ) + ); + } + else + { + $noticeBody = parseTemplate( + $fsTemplateName, + array( + 'href' => $viewMessageLink, + 'subject' => $subject, + 'body' => $body + ) + ); + } + + if (isEmptyString($noticeBody)) return error('An error occurred while generating the notice body'); + + return success($noticeBody); + } + + /** + * Returns the notice HTML body try to using the template present in database and then falling back + * on the one present in filesystem. If both fail then an error is returned + */ + private function _getNoticeHTMLBody($viewMessageLink, $subject, $body) + { + return $this->_getNoticeBody($viewMessageLink, $subject, $body, self::NOTICE_TEMPLATE_HTML, self::NOTICE_TEMPLATE_FALLBACK_HTML); + } + + /** + * Returns the notice TXT body try to using the template present in database and then falling back + * on the one present in filesystem. If both fail then an error is returned + */ + private function _getNoticeTXTBody($viewMessageLink, $subject, $body) + { + return $this->_getNoticeBody($viewMessageLink, $subject, $body, self::NOTICE_TEMPLATE_TXT, self::NOTICE_TEMPLATE_FALLBACK_TXT); + } + + /** + * Sends a notice email that notices to a user about a new received message + */ + private function _sendNotice($message_id) + { + // Get the message and related data (sender, recipient, etc...) + $messageResult = $this->_ci->RecipientModel->getMessages( + self::EMAIL_KONTAKT_TYPE, + 1, + $message_id + ); + + if (isError($messageResult)) return $messageResult; // if an error occured then return it + if (!hasData($messageResult)) return error('No data found with the given message id'); // if no data found then return an error + + $messageData = getData($messageResult)[0]; // Message data from database + + // Checks if this person has a valid email address where to send the notice email + if (isEmptyString($messageData->receiver) && isEmptyString($messageData->employeecontact)) + { + // Set in database why this email is NOT going to be send + $sse = $this->_setSentError( + $message_id, + $messageData->receiver_id, + 'This person does not have an email account', + $messageData->sentinfo + ); + + // If database error occurred then return it, otherwise return a logic error + return isError($sse) ? $sse : error('This person does not have an email account'); + } + + // Create a link to the controller to view the message using a token + $viewMessageLink = $this->_ci->config->item(self::CFG_MESSAGE_SERVER). + $this->_ci->config->item(self::CFG_MESSAGE_HTML_VIEW_URL). + $messageData->token; + + // Generates notice email body in HTML and plain text version. + // If an error occured during the generation then the error itself is returned + $noticeHTMLBody = $this->_getNoticeHTMLBody($viewMessageLink, $messageData->subject, $messageData->body); + if (isError($noticeHTMLBody)) return $noticeHTMLBody; + $noticeTXTBody = $this->_getNoticeTXTBody($viewMessageLink, $messageData->subject, $messageData->body); + if (isError($noticeTXTBody)) return $noticeTXTBody; + + // If an employeecontact contact is present then use it, otherwise use the personal contacts + $receiverContact = $messageData->receiver; + if (!isEmptyString($messageData->employeecontact)) $receiverContact = $messageData->employeecontact.'@'.DOMAIN; + + // Sending email + $sent = $this->_ci->maillib->send( + null, + $receiverContact, + $messageData->subject, + getData($noticeHTMLBody), + null, + null, + null, + getData($noticeTXTBody) + ); + + // If errors occurred while sending the email + if (!$sent) + { + // Set in database why this email is NOT going to be send + $sse = $this->_setSentError( + $message_id, + $messageData->receiver_id, + 'An error occurred while sending the email', + $messageData->sentinfo + ); + + // If database error occurred then return it, otherwise return a logic error + return isError($sse) ? $sse : error('An error occurred while sending the email'); + } + else // success! + { + // Set in database that the notice email was succesfully sent + $sss = $this->_setSentSuccess($message_id, $messageData->receiver_id); + if (isError($sss)) return $sss; // If database error occurred then return it + } + + return success('Notice email sent successfully'); + } + + /** + * Sends new message core method, may be wrapped by other methods. + */ + private function _sendMessage( + $receivers, $receiversOU, $subject, $body, $sender_id, $senderOU, $relationmessage_id, $priority, $multiPartMime + ) + { + // Checks if sender is fine + $sender = $this->_getSender($sender_id); + if (!hasData($sender)) return $sender; + // Checks if the sender and receiver organisation unit are valid + if (($receiversOU != null && !$this->_ouExists($receiversOU)) || ($senderOU != null && !$this->_ouExists($senderOU))) + { + return error('The given organisation unit is not valid', MSG_ERR_INVALID_OU); + } + // Checks subjects + if (isEmptyString($subject)) return error('The given subject is an empty string', MSG_ERR_INVALID_SUBJECT); + // Checks body + if (isEmptyString($body)) return error('The given body is an empty string', MSG_ERR_INVALID_BODY); + + $savedMessages = array(); // This array contains all the message ids of the saved messages + + // Looping on receivers + foreach (getData($receivers) as $receiver) + { + // Save message in database + $saveMessageResult = $this->_saveMessage( + getData($sender), $senderOU, $receiver->person_id, $receiversOU, $subject, $body, $priority, $relationmessage_id + ); + if (isSuccess($saveMessageResult)) // If successfully saved + { + // If the system is configured to send messages immediately + if ($this->_ci->config->item(self::CFG_SEND_IMMEDIATELY) === true) + { + $savedMessages[] = getData($saveMessageResult); // store the message id of the saved message + } + } + else + { + return $saveMessageResult; // If an error occured while saving + } + } + + // If the system is configured to send messages immediately + if ($this->_ci->config->item(self::CFG_SEND_IMMEDIATELY) === true) + { + // Looping through saved messages ids + foreach ($savedMessages as $message_id) + { + // Send message notice via email! + $sendNotice = $this->_sendNotice($message_id); + // If an error occurred then return it + if (isError($sendNotice)) return $sendNotice; + } + } + + return success('Message sent successfully'); + } + + /** + * Checks if the given organisation unit exists in database + */ + private function _ouExists($ou) + { + // Reset an eventually already buit query + $this->_ci->OrganisationseinheitModel->resetQuery(); + // Get only this columns + $this->_ci->OrganisationseinheitModel->addSelect('oe_kurzbz'); + // Retrieves the given organisation unit from database + $ouResults = $this->_ci->OrganisationseinheitModel->loadWhere(array('oe_kurzbz' => $ou)); + + return hasData($ouResults); } } diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 5f3f40e6d..c17d608c7 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -38,19 +38,29 @@ class Messages_model extends CI_Model $sender_id = getData($authUser)[0]->person_id; + // Send message(s) if (hasData($msgVarsData)) { for ($i = 0; $i < count(getData($msgVarsData)); $i++) { - $parsedText = ""; + $parsedText = ''; $msgVarsDataArray = $this->replaceKeys((array)getData($msgVarsData)[$i]); // replaces array keys // Send without vorlage if (isEmptyString($vorlage_kurzbz)) { - $parsedText = $this->messagelib->parseMessageText($body, $msgVarsDataArray); - $msg = $this->messagelib->sendMessage($sender_id, $msgVarsDataArray['person_id'], $subject, $parsedText, PRIORITY_NORMAL, $relationmessage_id, $oe_kurzbz); + $parsedText = parseText($body, $msgVarsDataArray); + + $msg = $this->messagelib->sendMessageUser( + $msgVarsDataArray['person_id'], // receiverPersonId + $subject, // subject + $parsedText, // body + $sender_id, // sender_id + $oe_kurzbz, // senderOU + $relationmessage_id, // relationmessage_id + MSG_PRIORITY_NORMAL // priority + ); } // Send with vorlage else @@ -63,7 +73,15 @@ class Messages_model extends CI_Model $msgVarsDataArray[$key] = $msgvar; } } - $msg = $this->messagelib->sendMessageVorlage($sender_id, $msgVarsDataArray['person_id'], $vorlage_kurzbz, $oe_kurzbz, $msgVarsDataArray); + + $msg = $this->messagelib->sendMessageUserTemplate( + $msgVarsDataArray['person_id'], // receiversPersonId + $vorlage_kurzbz, // vorlage + $msgVarsDataArray, // parseData + null, // orgform + $sender_id, // sender_id + $oe_kurzbz // senderOU + ); } if (isError($msg)) return $msg; @@ -95,7 +113,7 @@ class Messages_model extends CI_Model } /** - * Send a reply + * Send a reply to a message accessed using a token */ public function sendReply($subject, $body, $persons, $relationmessage_id, $token) { @@ -116,7 +134,16 @@ class Messages_model extends CI_Model { $dataArray = (array)getData($data)[$i]; - $msg = $this->messagelib->sendMessage($sender_id, $dataArray['person_id'], $subject, $body, PRIORITY_NORMAL, $relationmessage_id, null); + $msg = $this->messagelib->sendMessageUser( + $dataArray['person_id'], // receiverPersonId + $subject, // subject + $body, // body + $sender_id, // sender_id + null, // senderOU + $relationmessage_id, // relationmessage_id + MSG_PRIORITY_NORMAL // priority + ); + if (isError($msg)) return $msg; // Logs person data diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 74a1c3256..49fc21fc4 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -242,7 +242,7 @@ class Recipient_model extends DB_Model if (is_numeric($message_id)) { array_push($parametersArray, $message_id); - $query .= ' AND mm.message_id = ?'; + $query .= ' WHERE mm.message_id = ?'; } $query .= ' ORDER BY mr.insertamum ASC'; From 0ef94aacdad9545edc20a160d36d70753e8852f4 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 13 Jun 2019 18:23:24 +0200 Subject: [PATCH 004/138] - Fixed query method getMessages in model models/system/Recipient_model.php - Changed interface method sendMessages of job jobs/MailJob.php - Added function terminateWithError to helper helpers/hlp_common_helper.php - Changed method overrideConfigs of library MailLib - Removed method getConfigs from library MailLib - Added public method getEmailNumberToSent to library MailLib - Changed method sendAllNotices of library MessageLib - Renamed private method _sendNotice to _sendOneNotice in library MessageLib - Added new private methods _loadDbNoticeEmailTemplate, _loadFsNoticeEmailTemplate and _sendNotice to library MessageLib - Changed method _getNoticeBody in library MessageLib - Removed methods _getNoticeHTMLBody and _getNoticeTXTBody from in library MessageLib --- application/controllers/jobs/MailJob.php | 4 +- application/helpers/hlp_common_helper.php | 22 + application/libraries/MailLib.php | 47 +- application/libraries/MessageLib.php | 444 ++++++------------ application/models/system/Recipient_model.php | 11 +- 5 files changed, 202 insertions(+), 326 deletions(-) diff --git a/application/controllers/jobs/MailJob.php b/application/controllers/jobs/MailJob.php index cb5ffc032..721db0068 100644 --- a/application/controllers/jobs/MailJob.php +++ b/application/controllers/jobs/MailJob.php @@ -31,8 +31,8 @@ class MailJob extends CLI_Controller * Send all not sent messages * Parameters are used to overrride messages and mail configuration */ - public function sendMessages($numberToSent = null, $numberPerTimeRange = null, $email_time_range = null, $email_from_system = null) + public function sendMessages($numberToSent = null, $numberPerTimeRange = null, $emailTimeRange = null, $emailFromSystem = null) { - $this->messagelib->sendAllNotices($numberToSent, $numberPerTimeRange, $email_time_range, $email_from_system); + $this->messagelib->sendAllNotices($numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem); } } diff --git a/application/helpers/hlp_common_helper.php b/application/helpers/hlp_common_helper.php index 025834ed2..dbd8eb905 100644 --- a/application/helpers/hlp_common_helper.php +++ b/application/helpers/hlp_common_helper.php @@ -263,3 +263,25 @@ function parseTemplate($template, $data) return $ci->parser->parse($template, $data, true); } + +/** + * Terminate immediately the execution of the current script. + * If message parameter is given then: + * - logs the given message in CI logs + * - prints the given message to standard output + * Otherwise terminate with the generic error + */ +function terminateWithError($message = null) +{ + if (!isEmptyString($message)) + { + $ci =& get_instance(); // get CI instance + $ci->load->library('LogLib'); // Loads LogLib + + $ci->loglib->logError($message); + + exit($message); + } + + exit(EXIT_ERROR); +} diff --git a/application/libraries/MailLib.php b/application/libraries/MailLib.php index 6d0a48f73..e9e571f6c 100644 --- a/application/libraries/MailLib.php +++ b/application/libraries/MailLib.php @@ -110,43 +110,34 @@ class MailLib } /** - * To ovveride the configurations + * Overrides configuration parameters + * If the given parameters are not null or empty strings then they are used to override + * the following properties of this object: + * - email_number_to_sent + * - email_number_per_time_range + * - email_time_range + * - email_from_system */ - public function overrideConfigs($cfg) + public function overrideConfigs($numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem) { - if (!is_null($cfg)) + if (is_numeric($numberToSent)) $this->email_number_to_sent = $numberToSent; + + if (is_numeric($numberPerTimeRange)) $this->email_number_per_time_range = $numberPerTimeRange; + + if (is_numeric($emailTimeRange)) $this->email_time_range = $emailTimeRange; + + if (!isEmptyString($emailFromSystem) && filter_var($emailFromSystem, FILTER_VALIDATE_EMAIL)) { - if (isset($cfg->email_number_to_sent) && is_numeric($cfg->email_number_to_sent)) - { - $this->email_number_to_sent = $cfg->email_number_to_sent; - } - if (isset($cfg->email_number_per_time_range) && is_numeric($cfg->email_number_per_time_range)) - { - $this->email_number_per_time_range = $cfg->email_number_per_time_range; - } - if (isset($cfg->email_time_range) && is_numeric($cfg->email_time_range)) - { - $this->email_time_range = $cfg->email_time_range; - } - if (isset($cfg->email_from_system) && filter_var($cfg->email_from_system, FILTER_VALIDATE_EMAIL)) - { - $this->email_from_system = $cfg->email_from_system; - } + $this->email_from_system = $emailFromSystem; } } /** - * Returns the current configuration + * Returns value of property email_number_to_sent */ - public function getConfigs() + public function getEmailNumberToSent() { - $cfg = new stdClass(); - $cfg->email_number_to_sent = $this->email_number_to_sent; - $cfg->email_number_per_time_range = $this->email_number_per_time_range; - $cfg->email_time_range = $this->email_time_range; - $cfg->email_from_system = $this->email_from_system; - - return $cfg; + return $this->email_number_to_sent; } /** diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 7911d4b2d..c3c1169d4 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -36,8 +36,6 @@ class MessageLib // Loads message configuration $this->_ci->config->load('message'); - // Loads LogLib - $this->_ci->load->library('LogLib'); // Loads VorlageLib $this->_ci->load->library('VorlageLib'); // Loads Mail library @@ -140,188 +138,27 @@ class MessageLib // Public methods called by a job /** - * Gets all the messages from DB and sends them via email + * Gets all NOT sent messages from DB and sends for each of them the notice email + * Does not return anything, it logs info and errors on CI logs and in tbl_msg_recipient table + * Wrapper for _sendNotice. */ - public function sendAllNotices($numberToSent = null, $numberPerTimeRange = null, $email_time_range = null, $email_from_system = null) + public function sendAllNotices($numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem) { - $sent = true; // optimistic expectation + // Overrides MailLib configs with the given parameters + $this->_ci->maillib->overrideConfigs($numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem); - // Gets standard configs - $cfg = $this->_ci->maillib->getConfigs(); - $cfg->email_number_to_sent = $numberToSent; - $cfg->email_number_per_time_range = $numberPerTimeRange; - $cfg->email_time_range = $email_time_range; - $cfg->email_from_system = $email_from_system; - - // Overrides configs with the parameters - $this->_ci->maillib->overrideConfigs($cfg); - - // Gets a number ($this->_ci->maillib->getMaxEmailToSent()) of unsent messages from DB - // having EMAIL_KONTAKT_TYPE as relative contact type - $result = $this->_ci->RecipientModel->getMessages( + // Retrieves a certain amount of NOT sent messages, the amount is given by maillib->email_number_to_sent + $messagesResult = $this->_ci->RecipientModel->getMessages( self::EMAIL_KONTAKT_TYPE, - $this->_ci->maillib->getConfigs()->email_number_to_sent + null, + $this->_ci->maillib->getEmailNumberToSent() ); - // Checks if errors were occurred - if (isSuccess($result)) - { - // If data are present - if (is_array($result->retval) && count($result->retval) > 0) - { - // Iterating through the result set, if no errors occurred in the previous iteration - for ($i = 0; $i < count($result->retval) && $sent; $i++) - { - // If the person has an email account - if ((!is_null($result->retval[$i]->receiver) && $result->retval[$i]->receiver != '') - || (!is_null($result->retval[$i]->employeecontact) && $result->retval[$i]->employeecontact != '')) - { - $href = $this->_ci->config->item(self::CFG_MESSAGE_SERVER).$this->_ci->config->item(self::CFG_MESSAGE_HTML_VIEW_URL).$result->retval[$i]->token; - $vorlage = $this->_ci->vorlagelib->loadVorlagetext(self::NOTICE_TEMPLATE_HTML); + if (isError($messagesResult)) terminateWithError(getData($messagesResult)); // If an error occurred then log it and terminate - if(hasData($vorlage)) - { - // Using a template for the html email body - $body = parseText( - $vorlage->retval[0]->text, - array( - 'href' => $href, - 'subject' => $result->retval[$i]->subject, - 'body' => $result->retval[$i]->body - ) - ); - } - else - { - // Using a template for the html email body - $body = $this->_ci->parser->parse( - 'templates/mailHTML', - array( - 'href' => $href, - 'subject' => $result->retval[$i]->subject, - 'body' => $result->retval[$i]->body - ), - true - ); - } - if (is_null($body) || $body == '') - { - $this->_ci->loglib->logError('Error while parsing the mail template'); - } + $sendNotice = $this->_sendNotice(getData($messagesResult)); - $vorlage = $this->_ci->vorlagelib->loadVorlagetext(self::NOTICE_TEMPLATE_TXT); - if(hasData($vorlage)) - { - // Using a template for the plain text email body - $altBody = parseText( - $vorlage->retval[0]->text, - array( - 'href' => $href, - 'subject' => $result->retval[$i]->subject, - 'body' => $result->retval[$i]->body - ) - ); - } - else - { - // Using a template for the plain text email body - $altBody = $this->_ci->parser->parse( - 'templates/mailTXT', - array( - 'href' => $href, - 'subject' => $result->retval[$i]->subject, - 'body' => $result->retval[$i]->body - ), - true - ); - } - if (is_null($altBody) || $altBody == '') - { - $this->_ci->loglib->logError('Error while parsing the mail template'); - } - - // If the sender is not an employee, then system-sender is used if empty - $sender = ''; - if (!is_null($result->retval[0]->senderemployeecontact) && $result->retval[0]->senderemployeecontact != '') - { - $sender = $result->retval[0]->senderemployeecontact.'@'.DOMAIN; - } - - $receiverContact = $result->retval[$i]->receiver; - if (!is_null($result->retval[$i]->employeecontact) && $result->retval[$i]->employeecontact != '') - { - $receiverContact = $result->retval[$i]->employeecontact.'@'.DOMAIN; - } - - // Sending email - $sent = $this->_ci->maillib->send( - $sender, - $receiverContact, - $result->retval[$i]->subject, - $body, - null, - null, - null, - $altBody - ); - // If errors were occurred while sending the email - if (!$sent) - { - $this->_ci->loglib->logError('Error while sending an email'); - // Writing errors in tbl_msg_recipient - $sme = $this->_setSentError( - $result->retval[$i]->message_id, - $result->retval[$i]->receiver_id, - 'Error while sending an email', - $result->retval[$i]->sentinfo - ); - if (!$sme) - { - $this->_ci->loglib->logError('Error while updating DB'); - } - } - else - { - // Setting the message as sent in DB - $sent = $this->_setSentSuccess($result->retval[$i]->message_id, $result->retval[$i]->receiver_id); - // If some errors occurred - if (!$sent) - { - $this->_ci->loglib->logError('Error while updating DB'); - } - } - } - else - { - $this->_ci->loglib->logError('This person does not have an email account'); - // Writing errors in tbl_msg_recipient - $sme = $this->_setSentError( - $result->retval[$i]->message_id, - $result->retval[$i]->receiver_id, - 'This person does not have an email account', - $result->retval[$i]->sentinfo - ); - if (!$sme) - { - $this->_ci->loglib->logError('Error while updating DB'); - } - $sent = true; // Non blocking error - } - } - } - else - { - $this->_ci->loglib->logInfo('There are no email to be sent'); - $sent = false; - } - } - else - { - $this->_ci->loglib->logError('Something went wrong while getting data from DB'); - $sent = false; - } - - return $sent; + if (isError($sendNotice)) terminateWithError(getData($sendNotice)); // If an error occurred then log it and terminate } //------------------------------------------------------------------------------------------------------------------ @@ -423,13 +260,13 @@ class MessageLib { if (isEmptyString($token)) return error('The given token is not valid', MSG_ERR_INVALID_TOKEN); - $result = $this->_ci->RecipientModel->getMessageByToken($token); - if (hasData($result)) + $messageTokenResult = $this->_ci->RecipientModel->getMessageByToken($token); + if (hasData($messageTokenResult)) { // Searches for a status that is NOT unread $found = false; - foreach (getData($result) as $message) + foreach (getData($messageTokenResult) as $message) { if ($message->status > MSG_STATUS_UNREAD) { @@ -442,18 +279,18 @@ class MessageLib if (!$found) { $statusData = array( - 'message_id' => getData($result)[0]->message_id, - 'person_id' => getData($result)[0]->receiver_id, + 'message_id' => getData($messageTokenResult)[0]->message_id, + 'person_id' => getData($messageTokenResult)[0]->receiver_id, 'status' => MSG_STATUS_READ ); - $resultIns = $this->_ci->MsgStatusModel->insert($statusData); + $messageTokenResultIns = $this->_ci->MsgStatusModel->insert($statusData); // If an error occured while writing on data base, then return it - if (isError($resultIns)) $result = $resultIns; + if (isError($messageTokenResultIns)) $messageTokenResult = $messageTokenResultIns; } } - return $result; + return $messageTokenResult; } /** @@ -480,8 +317,8 @@ class MessageLib $this->_ci->MsgStatusModel->resetQuery(); // Reset an eventually already buit query // Searches if the status is already present - $result = $this->_ci->MsgStatusModel->load(array($message_id, $person_id, $status)); - if (!hasData($result)) // if not found + $updMessageStatusResult = $this->_ci->MsgStatusModel->load(array($message_id, $person_id, $status)); + if (!hasData($updMessageStatusResult)) // if not found { // Insert the new status $statusKey = array( @@ -489,10 +326,10 @@ class MessageLib 'person_id' => $person_id, 'status' => $status ); - $result = $this->_ci->MsgStatusModel->insert($statusKey); + $updMessageStatusResult = $this->_ci->MsgStatusModel->insert($statusKey); } - return $result; + return $updMessageStatusResult; } //------------------------------------------------------------------------------------------------------------------ @@ -580,10 +417,10 @@ class MessageLib 'oe_kurzbz' => $senderOU ); - $result = $this->_ci->MessageModel->insert($messageData); - if (isSuccess($result)) + $saveMessageResult = $this->_ci->MessageModel->insert($messageData); + if (isSuccess($saveMessageResult)) { - $messageId = getData($result); // Gets the message id generated by database + $messageId = getData($saveMessageResult); // Gets the message id generated by database // Store message information in tbl_msg_recipient $recipientData = array( @@ -593,8 +430,8 @@ class MessageLib 'oe_kurzbz' => $receiverOU ); - $result = $this->_ci->RecipientModel->insert($recipientData); - if (isSuccess($result)) + $saveMessageResult = $this->_ci->RecipientModel->insert($recipientData); + if (isSuccess($saveMessageResult)) { // Store message information in tbl_msg_status $statusData = array( @@ -602,24 +439,24 @@ class MessageLib 'person_id' => $receiver_id, 'status' => MSG_STATUS_UNREAD ); - $result = $this->_ci->MsgStatusModel->insert($statusData); + $saveMessageResult = $this->_ci->MsgStatusModel->insert($statusData); } } $this->_ci->db->trans_complete(); // Ends database transaction // If the transaction failed... - if ($this->_ci->db->trans_status() === false || isError($result)) + if ($this->_ci->db->trans_status() === false || isError($saveMessageResult)) { $this->_ci->db->trans_rollback(); // ...then rollback } else // otherwise commit... { $this->_ci->db->trans_commit(); - $result = success($messageId); // ...and returns the message id + $saveMessageResult = success($messageId); // ...and returns the message id } - return $result; + return $saveMessageResult; } /** @@ -651,20 +488,14 @@ class MessageLib * Returns the notice body. Tries to use the template present in database and then falling back * on the one present in filesystem. If both fail then an error is returned */ - private function _getNoticeBody($viewMessageLink, $subject, $body, $dbTemplateName, $fsTemplateName) + private function _getNoticeBody($dbEmailNoticeTemplate, $fsEmailNoticeTemplate, $viewMessageLink, $subject, $body) { - $noticeBody = null; + $noticeBody = null; // pessimistic expectation - $vorlageResult = $this->_ci->vorlagelib->loadVorlagetext($dbTemplateName); - - if (isError($vorlageResult)) return $vorlageResult; - - if (hasData($vorlageResult)) + if (!isEmptyString($dbEmailNoticeTemplate)) { - $vorlage = getData($vorlageResult)[0]; - $noticeBody = parseText( - $vorlage->text, + $dbEmailNoticeTemplate, array( 'href' => $viewMessageLink, 'subject' => $subject, @@ -674,8 +505,8 @@ class MessageLib } else { - $noticeBody = parseTemplate( - $fsTemplateName, + $noticeBody = parseText( + $fsEmailNoticeTemplate, array( 'href' => $viewMessageLink, 'subject' => $subject, @@ -689,106 +520,111 @@ class MessageLib return success($noticeBody); } - /** - * Returns the notice HTML body try to using the template present in database and then falling back - * on the one present in filesystem. If both fail then an error is returned - */ - private function _getNoticeHTMLBody($viewMessageLink, $subject, $body) - { - return $this->_getNoticeBody($viewMessageLink, $subject, $body, self::NOTICE_TEMPLATE_HTML, self::NOTICE_TEMPLATE_FALLBACK_HTML); - } - - /** - * Returns the notice TXT body try to using the template present in database and then falling back - * on the one present in filesystem. If both fail then an error is returned - */ - private function _getNoticeTXTBody($viewMessageLink, $subject, $body) - { - return $this->_getNoticeBody($viewMessageLink, $subject, $body, self::NOTICE_TEMPLATE_TXT, self::NOTICE_TEMPLATE_FALLBACK_TXT); - } - /** * Sends a notice email that notices to a user about a new received message + * It gets just one message. Wrapper for _sendNotice. */ - private function _sendNotice($message_id) + private function _sendOneNotice($message_id) { // Get the message and related data (sender, recipient, etc...) $messageResult = $this->_ci->RecipientModel->getMessages( self::EMAIL_KONTAKT_TYPE, - 1, $message_id ); if (isError($messageResult)) return $messageResult; // if an error occured then return it if (!hasData($messageResult)) return error('No data found with the given message id'); // if no data found then return an error - $messageData = getData($messageResult)[0]; // Message data from database + return $this->_sendNotice(getData($messageResult)); + } - // Checks if this person has a valid email address where to send the notice email - if (isEmptyString($messageData->receiver) && isEmptyString($messageData->employeecontact)) + /** + * Core method to send one or more email notices for one or more messages + */ + private function _sendNotice($messagesResult) + { + // Prefix for all links that will be subsequently generated + $prefixLink = $this->_ci->config->item(self::CFG_MESSAGE_SERVER).$this->_ci->config->item(self::CFG_MESSAGE_HTML_VIEW_URL); + + // Loads all the needed templates for HTML and plain text. Main templates from database, fallback templates from file system + $dbEmailNoticeTemplateHTML = $this->_loadDbNoticeEmailTemplate(self::NOTICE_TEMPLATE_HTML); + $dbEmailNoticeTemplateTXT = $this->_loadDbNoticeEmailTemplate(self::NOTICE_TEMPLATE_TXT); + $fsEmailNoticeTemplateHTML = $this->_loadFsNoticeEmailTemplate(self::NOTICE_TEMPLATE_FALLBACK_HTML); + $fsEmailNoticeTemplateTXT = $this->_loadFsNoticeEmailTemplate(self::NOTICE_TEMPLATE_FALLBACK_TXT); + + // Loops through all the messages to be sent + foreach ($messagesResult as $messageData) { - // Set in database why this email is NOT going to be send - $sse = $this->_setSentError( - $message_id, - $messageData->receiver_id, - 'This person does not have an email account', - $messageData->sentinfo + // Checks if this person has a valid email address where to send the notice email + if (isEmptyString($messageData->receiver) && isEmptyString($messageData->employeecontact)) + { + // Set in database why this email is NOT going to be send + $sse = $this->_setSentError( + $messageData->message_id, + $messageData->receiver_id, + 'This person does not have an email account', + $messageData->sentinfo + ); + + // If database error occurred then return it + if (isError($sse)) return $sse; + + continue; // Skip the rest, continue with the next one + } + + // Create a link to the controller to view the message using a token + $viewMessageLink = $prefixLink.$messageData->token; + + // Generates notice email body in HTML and plain text version. + // If an error occured during the generation then the error itself is returned + $noticeHTMLBody = $this->_getNoticeBody( + $dbEmailNoticeTemplateHTML, $fsEmailNoticeTemplateHTML, $viewMessageLink, $messageData->subject, $messageData->body + ); + if (isError($noticeHTMLBody)) return $noticeHTMLBody; + $noticeTXTBody = $this->_getNoticeBody( + $dbEmailNoticeTemplateTXT, $fsEmailNoticeTemplateTXT, $viewMessageLink, $messageData->subject, $messageData->body + ); + if (isError($noticeTXTBody)) return $noticeTXTBody; + + // If an employeecontact contact is present then use it, otherwise use the personal contacts + $receiverContact = $messageData->receiver; + if (!isEmptyString($messageData->employeecontact)) $receiverContact = $messageData->employeecontact.'@'.DOMAIN; + + // Sending email + $sent = $this->_ci->maillib->send( + null, + $receiverContact, + $messageData->subject, + getData($noticeHTMLBody), + null, + null, + null, + getData($noticeTXTBody) ); - // If database error occurred then return it, otherwise return a logic error - return isError($sse) ? $sse : error('This person does not have an email account'); + // If errors occurred while sending the email + if (!$sent) + { + // Set in database why this email is NOT going to be send + $sse = $this->_setSentError( + $messageData->message_id, + $messageData->receiver_id, + 'An error occurred while sending the email', + $messageData->sentinfo + ); + + // If database error occurred then return it, otherwise return a logic error + return isError($sse) ? $sse : error('An error occurred while sending the email'); + } + else // success! + { + // Set in database that the notice email was succesfully sent + $sss = $this->_setSentSuccess($messageData->message_id, $messageData->receiver_id); + if (isError($sss)) return $sss; // If database error occurred then return it + } } - // Create a link to the controller to view the message using a token - $viewMessageLink = $this->_ci->config->item(self::CFG_MESSAGE_SERVER). - $this->_ci->config->item(self::CFG_MESSAGE_HTML_VIEW_URL). - $messageData->token; - - // Generates notice email body in HTML and plain text version. - // If an error occured during the generation then the error itself is returned - $noticeHTMLBody = $this->_getNoticeHTMLBody($viewMessageLink, $messageData->subject, $messageData->body); - if (isError($noticeHTMLBody)) return $noticeHTMLBody; - $noticeTXTBody = $this->_getNoticeTXTBody($viewMessageLink, $messageData->subject, $messageData->body); - if (isError($noticeTXTBody)) return $noticeTXTBody; - - // If an employeecontact contact is present then use it, otherwise use the personal contacts - $receiverContact = $messageData->receiver; - if (!isEmptyString($messageData->employeecontact)) $receiverContact = $messageData->employeecontact.'@'.DOMAIN; - - // Sending email - $sent = $this->_ci->maillib->send( - null, - $receiverContact, - $messageData->subject, - getData($noticeHTMLBody), - null, - null, - null, - getData($noticeTXTBody) - ); - - // If errors occurred while sending the email - if (!$sent) - { - // Set in database why this email is NOT going to be send - $sse = $this->_setSentError( - $message_id, - $messageData->receiver_id, - 'An error occurred while sending the email', - $messageData->sentinfo - ); - - // If database error occurred then return it, otherwise return a logic error - return isError($sse) ? $sse : error('An error occurred while sending the email'); - } - else // success! - { - // Set in database that the notice email was succesfully sent - $sss = $this->_setSentSuccess($message_id, $messageData->receiver_id); - if (isError($sss)) return $sss; // If database error occurred then return it - } - - return success('Notice email sent successfully'); + return success('Notice emails sent successfully'); } /** @@ -841,7 +677,7 @@ class MessageLib foreach ($savedMessages as $message_id) { // Send message notice via email! - $sendNotice = $this->_sendNotice($message_id); + $sendNotice = $this->_sendOneNotice($message_id); // If an error occurred then return it if (isError($sendNotice)) return $sendNotice; } @@ -864,4 +700,30 @@ class MessageLib return hasData($ouResults); } + + /** + * Loads a the specified template from database + * Returns null if not found or on failure + */ + private function _loadDbNoticeEmailTemplate($dbTemplateName) + { + $emailNoticeTemplate = null; + + $vorlageResult = $this->_ci->vorlagelib->loadVorlagetext($dbTemplateName); + + if (hasData($vorlageResult)) + { + $emailNoticeTemplate = getData($vorlageResult)[0]->text; + } + + return $emailNoticeTemplate; + } + + /** + * Loads a the specified template from database + */ + private function _loadFsNoticeEmailTemplate($fsTemplateName) + { + return $this->_ci->load->view($fsTemplateName, null, true); + } } diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 49fc21fc4..3a30bba1f 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -205,7 +205,7 @@ class Recipient_model extends DB_Model * @param limit specifies the number of messages to get * @param message_id specifies a single message */ - public function getMessages($kontaktType, $limit = 1, $message_id = null) + public function getMessages($kontaktType, $message_id = null, $limit = 1) { $query = 'SELECT mm.message_id, ks.kontakt as sender, @@ -219,10 +219,10 @@ class Recipient_model extends DB_Model mr.sentinfo FROM public.tbl_msg_recipient mr INNER JOIN public.tbl_msg_message mm USING (message_id) LEFT JOIN ( - SELECT person_id, kontakt FROM public.tbl_kontakt WHERE kontakttyp = ? + SELECT person_id, kontakt FROM public.tbl_kontakt WHERE zustellung = true AND kontakttyp = ? ) ks ON (ks.person_id = mm.person_id) LEFT JOIN ( - SELECT person_id, kontakt FROM public.tbl_kontakt WHERE kontakttyp = ? + SELECT person_id, kontakt FROM public.tbl_kontakt WHERE zustellung = true AND kontakttyp = ? ) kr ON (kr.person_id = mr.person_id) LEFT JOIN ( SELECT b.person_id, @@ -235,14 +235,15 @@ class Recipient_model extends DB_Model m.mitarbeiter_uid FROM public.tbl_benutzer b INNER JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) WHERE b.aktiv = TRUE - ) ms ON (ms.person_id = mm.person_id)'; + ) ms ON (ms.person_id = mm.person_id) + WHERE mr.sent IS NULL'; $parametersArray = array($kontaktType, $kontaktType); if (is_numeric($message_id)) { array_push($parametersArray, $message_id); - $query .= ' WHERE mm.message_id = ?'; + $query .= ' AND mm.message_id = ?'; } $query .= ' ORDER BY mr.insertamum ASC'; From 5bda5eb966a21ac612e9b6716c297bde5532d629 Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 14 Jun 2019 15:40:15 +0200 Subject: [PATCH 005/138] - Moved view system/messages/messageList.php -> system/infocenter/messageList.php - Moved js public/js/messaging/messageList.js -> public/js/infocenter/messageList.js - Updated includes in controller system/infocenter/InfoCenter.php and view system/infocenter/infocenterDetails.php --- application/controllers/system/Messages.php | 63 ++++++++++--------- .../system/infocenter/InfoCenter.php | 2 +- .../system/infocenter/infocenterDetails.php | 4 +- .../{messages => infocenter}/messageList.php | 0 .../{messaging => infocenter}/messageList.js | 0 5 files changed, 36 insertions(+), 33 deletions(-) rename application/views/system/{messages => infocenter}/messageList.php (100%) rename public/js/{messaging => infocenter}/messageList.js (100%) diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index 744eb880e..a7709a702 100644 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -96,36 +96,7 @@ class Messages extends Auth_Controller } // ----------------------------------------------------------------------------------------------------------------- - // Public methods - JSON output - - /** - * Send a new message - * - The recipients are prestudents - * - An email template with message var may be provided - * - A global organisation unit may be provided, otherwise is used the prestudent one - */ - public function sendJson() - { - $prestudents = $this->input->post('prestudents'); - $vorlage_kurzbz = $this->input->post('vorlage_kurzbz'); - $oe_kurzbz = $this->input->post('oe_kurzbz'); - $msgVars = $this->input->post('msgvars'); - - $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents); - - $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - $prestudentsData = $this->PrestudentModel->getOrganisationunits($prestudents); - - // Adds the organisation unit to each prestudent - if (isEmptyString($oe_kurzbz) && hasData($msgVarsData) && hasData($prestudentsData)) - { - $this->CLMessagesModel->addOeToPrestudents($msgVarsData, $prestudentsData); - } - - $send = $this->CLMessagesModel->send($msgVarsData, null, $oe_kurzbz, $vorlage_kurzbz, $msgVars); - - $this->outputJson(getData($send)); - } + // Public methods - JSON output - called by this controller and FASMessages (view system/messages/messageWrite) /** * Returns an object that represent a template store in database @@ -185,6 +156,9 @@ class Messages extends Auth_Controller } } + // ----------------------------------------------------------------------------------------------------------------- + // Public methods - JSON output - called by infocenter + /** * Outputs message data for a message (identified my msg id and receiver id) in JSON format */ @@ -204,4 +178,33 @@ class Messages extends Auth_Controller $this->outputJson(array(getData($msg)[0])); } } + + /** + * Send a new message + * - The recipients are prestudents + * - An email template with message var may be provided + * - A global organisation unit may be provided, otherwise is used the prestudent one + */ + public function sendJson() + { + $prestudents = $this->input->post('prestudents'); + $vorlage_kurzbz = $this->input->post('vorlage_kurzbz'); + $oe_kurzbz = $this->input->post('oe_kurzbz'); + $msgVars = $this->input->post('msgvars'); + + $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents); + + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $prestudentsData = $this->PrestudentModel->getOrganisationunits($prestudents); + + // Adds the organisation unit to each prestudent + if (isEmptyString($oe_kurzbz) && hasData($msgVarsData) && hasData($prestudentsData)) + { + $this->CLMessagesModel->addOeToPrestudents($msgVarsData, $prestudentsData); + } + + $send = $this->CLMessagesModel->send($msgVarsData, null, $oe_kurzbz, $vorlage_kurzbz, $msgVars); + + $this->outputJson(getData($send)); + } } diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index d59c058cf..b83d6e48b 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -646,7 +646,7 @@ class InfoCenter extends Auth_Controller public function reloadMessages($person_id) { $messages = $this->MessageModel->getMessagesOfPerson($person_id, 1); - $this->load->view('system/messages/messageList.php', array('messages' => $messages->retval)); + $this->load->view('system/infocenter/messageList.php', array('messages' => $messages->retval)); } /** diff --git a/application/views/system/infocenter/infocenterDetails.php b/application/views/system/infocenter/infocenterDetails.php index 9e708d076..86493134c 100644 --- a/application/views/system/infocenter/infocenterDetails.php +++ b/application/views/system/infocenter/infocenterDetails.php @@ -22,7 +22,7 @@ 'customJSs' => array( 'public/js/bootstrapper.js', 'public/js/tablesort/tablesort.js', - 'public/js/messaging/messageList.js', + 'public/js/infocenter/messageList.js', 'public/js/infocenter/infocenterDetails.js' ), 'phrases' => array( @@ -147,7 +147,7 @@
load->view('system/messages/messageList.php', $messages); + $this->load->view('system/infocenter/messageList.php', $messages); ?>
diff --git a/application/views/system/messages/messageList.php b/application/views/system/infocenter/messageList.php similarity index 100% rename from application/views/system/messages/messageList.php rename to application/views/system/infocenter/messageList.php diff --git a/public/js/messaging/messageList.js b/public/js/infocenter/messageList.js similarity index 100% rename from public/js/messaging/messageList.js rename to public/js/infocenter/messageList.js From f6e0f58b3dbe9031d2520fbb1c350c1ff7bf0be3 Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 18 Jun 2019 18:25:26 +0200 Subject: [PATCH 006/138] - Renamed view system/messages/messageSent.php to system/messages/htmlSuccess.php - Added new view system/messages/htmlError.php - Renamed view system/messages/messageWrite.php to system/messages/htmlWriteTemplate.php - Added new widget views: widgets/Dropdown_widget.php and widgets/MultipleDropdown_widget.php - Added new CSS public/css/Widgets.css - Controller system/FASMessages: - Renamed method write to writeTemplate and method writeReply to writeReplyTemplate - Removed all the private methods and moved all the logic to model CL/Messages_model - Methods writeTemplate and writeReplyTemplate do not need anymore the sender id as parameter - Controller system/Messages: - Renamed method write to writeTemplate - Renamed method send to sendImplicitTemplate - Renamed method sendJson to sendExplicitTemplateJson - Moved all the logic to model CL/Messages_model - Adapted php and JS code to use these new methods names and interfaces - Removed public method getIsAdmin from MessageLib - Method _sendMessage of MessageLib now returns the saved message ids - Added new package olifolkerd/tabulator to composer - Added new parameter widgets to view templates/FHC-Header.php - Added new HTML widget widgets/Dropdown_widget and widgets/MultipleDropdown_widget - Added constants REPLY_SUBJECT_PREFIX and REPLY_BODY_PREFIX to model CL/Messages_model - Added new public methods prepareHtmlWriteTemplatePersons, prepareHtmlWriteTemplatePrestudents, sendImplicitTemplate, sendExplicitTemplate, getVorlage, parseMessageText and getMessageFromIds to model CL/Messages_model - Added new private methods _getAuthUser, _lowerReplaceSpaceArrayKeys, _addOeToPrestudents, _personLog and _prepareHtmlWriteTemplate to model CL/Messages_model --- .../controllers/system/FASMessages.php | 177 +------- application/controllers/system/Messages.php | 147 ++----- application/libraries/MessageLib.php | 18 +- application/models/CL/Messages_model.php | 409 ++++++++++++++---- .../views/system/infocenter/stammdaten.php | 2 +- .../views/system/messages/htmlError.php | 82 ++++ .../{messageSent.php => htmlSuccess.php} | 12 +- .../system/messages/htmlWriteTemplate.php | 167 +++++++ .../views/system/messages/messageWrite.php | 183 -------- application/views/templates/FHC-Header.php | 4 + application/views/widgets/dropdown.php | 6 +- application/widgets/Dropdown_widget.php | 19 + .../widgets/MultipleDropdown_widget.php | 20 + application/widgets/html/DropdownWidget.php | 42 +- composer.json | 13 + composer.lock | 49 ++- content/fasoverlay.js.php | 2 +- content/messages.js.php | 4 +- public/css/Widgets.css | 46 ++ public/css/messaging/messageWrite.css | 7 +- public/js/infocenter/infocenterDetails.js | 2 +- .../js/infocenter/infocenterPersonDataset.js | 2 +- public/js/messaging/messageWrite.js | 2 +- 23 files changed, 802 insertions(+), 613 deletions(-) create mode 100644 application/views/system/messages/htmlError.php rename application/views/system/messages/{messageSent.php => htmlSuccess.php} (95%) create mode 100644 application/views/system/messages/htmlWriteTemplate.php delete mode 100644 application/views/system/messages/messageWrite.php create mode 100644 application/widgets/Dropdown_widget.php create mode 100644 application/widgets/MultipleDropdown_widget.php create mode 100644 public/css/Widgets.css diff --git a/application/controllers/system/FASMessages.php b/application/controllers/system/FASMessages.php index 6928a919d..55d1da25f 100644 --- a/application/controllers/system/FASMessages.php +++ b/application/controllers/system/FASMessages.php @@ -11,17 +11,15 @@ class FASMessages extends Auth_Controller { parent::__construct( array( - 'write' => 'basis/message:rw', - 'writeReply' => 'basis/message:rw' + 'writeTemplate' => 'basis/message:rw', + 'writeReplyTemplate' => 'basis/message:rw' ) ); - // Loads the message library - $this->load->library('MessageLib'); - - // Loads the widget library - $this->load->library('WidgetLib'); + // Loads model CLMessagesModel which contains the GUI logic + $this->load->model('CL/Messages_model', 'CLMessagesModel'); + // Phrases used in loaded views $this->loadPhrases( array( 'global', @@ -30,162 +28,33 @@ class FASMessages extends Auth_Controller ); } - // ----------------------------------------------------------------------------------------------------------------- - // Public methods - /** - * Write a new message + * Writes a new message to a prestudent using templates */ - public function write($sender_id) + public function writeTemplate() { - $prestudent_id = $this->input->post('prestudent_id'); // recipients prestudend_id(s) + $prestudents = $this->input->post('prestudent_id'); // recipients prestudend_id(s) - if (!is_numeric($sender_id)) - { - show_error('The current logged user person_id is not defined'); - } - - $msgVarsData = $this->_getMsgVarsData($prestudent_id); - - // Retrieves message vars for a person from view view vw_msg_vars_person - $variablesArray = $this->_getMessageVarsPerson(); - - // Organisation units used to get the templates - $oe_kurzbz = $this->_getOeKurzbz($sender_id); - - // Admin or commoner? - $isAdmin = $this->_getIsAdmin($sender_id); - - $data = array( - 'recipients' => getData($msgVarsData), - 'variables' => $variablesArray, - 'oe_kurzbz' => $oe_kurzbz, // used to get the templates - 'isAdmin' => $isAdmin - ); - - $this->load->view('system/messages/messageWrite', $data); + // Loads the view to write a new message with a template + $this->load->view( + 'system/messages/htmlWriteTemplate', + $this->CLMessagesModel->prepareHtmlWriteTemplatePrestudents($prestudents) + ); } /** - * Write a reply + * Writes a reply to a message identified by parameters $message_id and $recipient_id + * The recipient is a prestudent + * Uses templates */ - public function writeReply($sender_id, $msg_id, $receiver_id) + public function writeReplyTemplate($message_id, $recipient_id) { - $prestudent_id = $this->input->post('prestudent_id'); // recipients prestudend_id(s) + $prestudents = $this->input->post('prestudent_id'); // recipients prestudend_id(s) - if (!is_numeric($sender_id)) - { - show_error('The current logged user person_id is not defined'); - } - - if (!is_numeric($msg_id)) - { - show_error('The msg_id must be a number'); - } - - if (!is_numeric($receiver_id)) - { - show_error('The receiver_id must be a number'); - } - - $msg = $this->_getMessage($msg_id, $receiver_id); - - $msgVarsData = $this->_getMsgVarsData($prestudent_id); - - // Retrieves message vars for a person from view view vw_msg_vars_person - $variablesArray = $this->_getMessageVarsPerson(); - - // Organisation units used to get the templates - $oe_kurzbz = $this->_getOeKurzbz($sender_id); - - // Admin or commoner? - $isAdmin = $this->_getIsAdmin($sender_id); - - $data = array( - 'recipients' => getData($msgVarsData), - 'message' => $msg, - 'variables' => $variablesArray, - 'oe_kurzbz' => $oe_kurzbz, // used to get the templates - 'isAdmin' => $isAdmin - ); - - $this->load->view('system/messages/messageWrite', $data); + // Loads the view to write a new message with a template + $this->load->view( + 'system/messages/htmlWriteTemplate', + $this->CLMessagesModel->prepareHtmlWriteTemplatePrestudents($prestudents, $message_id, $recipient_id) + ); } - - // ----------------------------------------------------------------------------------------------------------------- - // Private methods - - /** - * - */ - private function _getMessage($msg_id, $receiver_id) - { - $msg = $this->messagelib->getMessage($msg_id, $receiver_id); - if (isError($msg)) - { - show_error(getData($msg)); - } - elseif (!hasData($msg)) - { - show_error('The selected message does not exist'); - } - else - { - $msg = getData($msg)[0]; - } - - return $msg; - } - - /** - * Retrieves message vars from view vw_msg_vars - */ - private function _getMsgVarsData($prestudent_id) - { - $this->load->model('system/Message_model', 'MessageModel'); - $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); - - if (isError($msgVarsData)) - { - show_error(getData($msgVarsData)); - } - - return $msgVarsData; - } - - /** - * Wrapper method to call messagelib->getMessageVarsPerson - */ - private function _getMessageVarsPerson() - { - $variables = $this->messagelib->getMessageVarsPerson(); - - if (isError($variables)) show_error(getData($variables)); - - return getData($variables); - } - - /** - * Wrapper method to call messagelib->getOeKurzbz - */ - private function _getOeKurzbz($sender_id) - { - $oe_kurzbz = $this->messagelib->getOeKurzbz($sender_id); - - if (isError($oe_kurzbz)) show_error(getData($oe_kurzbz)); - - return getData($oe_kurzbz); - } - - /** - * Wrapper method to call messagelib->getIsAdmin - */ - private function _getIsAdmin($sender_id) - { - $isAdmin = $this->messagelib->getIsAdmin($sender_id); - - if (isError($isAdmin)) show_error(getData($isAdmin)); - - return getData($isAdmin); - } } diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index a7709a702..20fed38ad 100644 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -4,28 +4,23 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class Messages extends Auth_Controller { - /** - * MessageLib is loaded by CLMessagesModel - */ public function __construct() { parent::__construct( array( - 'write' => array('basis/message:rw', 'infocenter:rw'), - 'send' => array('basis/message:rw', 'infocenter:rw'), - 'sendJson' => array('basis/message:rw', 'infocenter:rw'), + 'writeTemplate' => array('basis/message:rw', 'infocenter:rw'), + 'sendImplicitTemplate' => array('basis/message:rw', 'infocenter:rw'), + 'sendExplicitTemplateJson' => array('basis/message:rw', 'infocenter:rw'), 'getVorlage' => array('basis/message:r', 'infocenter:r'), 'parseMessageText' => array('basis/message:r', 'infocenter:r'), 'getMessageFromIds' => array('basis/message:r', 'infocenter:r') ) ); - // Loads the widget library - $this->load->library('WidgetLib'); - - $this->load->model('system/Message_model', 'MessageModel'); + // Loads model CLMessagesModel which contains the GUI logic $this->load->model('CL/Messages_model', 'CLMessagesModel'); + // Phrases used in loaded views $this->loadPhrases( array( 'global', @@ -38,65 +33,45 @@ class Messages extends Auth_Controller // Public methods - HTML output /** - * Initialize all the parameters used by view system/messages/messageWrite - * to build a GUI used to write a messate to user/s + * Initialize all the parameters used by view system/messages/htmlWriteTemplate + * to build a GUI used to write a messate to user/s using a template */ - public function write() + public function writeTemplate() { $persons = $this->input->post('person_id'); - $authUser = $this->CLMessagesModel->getAuthUser(); - if (isError($authUser)) show_error(getData($authUser)); - - $sender_id = getData($authUser)[0]->person_id; - - // Retrieves person information - $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($persons); - if (isError($msgVarsData)) show_error(getData($msgVarsData)); - - // Retrieves message vars from view vw_msg_vars_person - $variables = $this->messagelib->getMessageVarsPerson(); - if (isError($variables)) show_error(getData($variables)); - - // Organisation units used to get the templates - $oe_kurzbz = $this->messagelib->getOeKurzbz($sender_id); - if (isError($oe_kurzbz)) show_error(getData($oe_kurzbz)); - - // Admin or commoner? - $isAdmin = $this->messagelib->getIsAdmin($sender_id); - if (isError($isAdmin)) show_error(getData($isAdmin)); - + // Loads the view to write a new message with a template $this->load->view( - 'system/messages/messageWrite', - array ( - 'recipients' => getData($msgVarsData), // recipients data - 'variables' => getData($variables), // message vars - 'oe_kurzbz' => getData($oe_kurzbz), // used to get the templates - 'isAdmin' => getData($isAdmin) // is admin? - ) + 'system/messages/htmlWriteTemplate', + $this->CLMessagesModel->prepareHtmlWriteTemplatePersons($persons) ); } /** * Send a new message or reply to user/s * If a relationmessage_id this message is a reply to another one + * Body is a template and will be parsed using information present in persons parameter */ - public function send() + public function sendImplicitTemplate() { + $subject = $this->input->post('subject'); + $body = $this->input->post('body'); $persons = $this->input->post('persons'); $relationmessage_id = $this->input->post('relationmessage_id'); - // Retrieves message vars data for the fiven user/s - $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($persons); - - // Send the message - $send = $this->CLMessagesModel->send($msgVarsData, $relationmessage_id); - - $this->load->view('system/messages/messageSent', array('success' => isSuccess($send))); + $sendImplicitTemplate = $this->CLMessagesModel->sendImplicitTemplate($persons, $subject, $body, $relationmessage_id); + if (isSuccess($sendImplicitTemplate)) + { + $this->load->view('system/messages/htmlSuccess'); + } + else + { + $this->load->view('system/messages/htmlError'); + } } // ----------------------------------------------------------------------------------------------------------------- - // Public methods - JSON output - called by this controller and FASMessages (view system/messages/messageWrite) + // Public methods - JSON output - called by this controller and FASMessages (view system/messages/htmlWriteTemplate) /** * Returns an object that represent a template store in database @@ -106,24 +81,8 @@ class Messages extends Auth_Controller public function getVorlage() { $vorlage_kurzbz = $this->input->get('vorlage_kurzbz'); - $result = error('The given vorlage_kurzbz is not valid'); - if (!isEmptyString($vorlage_kurzbz)) - { - $this->load->model('system/Vorlagestudiengang_model', 'VorlagestudiengangModel'); - $this->VorlagestudiengangModel->addOrder('version','DESC'); - - $result = $this->VorlagestudiengangModel->loadWhere(array('vorlage_kurzbz' => $vorlage_kurzbz)); - } - - if (isError($result) || !hasData($result)) - { - $this->outputJsonError(getData($result)); - } - else - { - $this->outputJsonSuccess(getData($result)); - } + $this->outputJson($this->CLMessagesModel->getVorlage($vorlage_kurzbz)); } /** @@ -134,26 +93,8 @@ class Messages extends Auth_Controller { $person_id = $this->input->get('person_id'); $text = $this->input->get('text'); - $msgVarsData = error('The given person_id is not a valid number'); - if (is_numeric($person_id)) - { - $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($person_id); - } - - if (isError($msgVarsData) || !hasData($msgVarsData)) - { - $this->outputJsonError(getData($msgVarsData)); - } - else - { - $this->outputJsonSuccess( - parseText( - $text, - $this->CLMessagesModel->replaceKeys((array)getData($msgVarsData)[0]) - ) - ); - } + $this->outputJson($this->CLMessagesModel->parseMessageText($person_id, $text)); } // ----------------------------------------------------------------------------------------------------------------- @@ -164,19 +105,10 @@ class Messages extends Auth_Controller */ public function getMessageFromIds() { - $msg_id = $this->input->get('msg_id'); + $message_id = $this->input->get('msg_id'); $receiver_id = $this->input->get('receiver_id'); - $msg = $this->messagelib->getMessage($msg_id, $receiver_id); - - if (isError($msg) || !hasData($msg)) - { - $this->outputJson(array()); - } - else - { - $this->outputJson(array(getData($msg)[0])); - } + $this->outputJson($this->CLMessagesModel->getMessageFromIds($message_id, $receiver_id)); } /** @@ -184,27 +116,16 @@ class Messages extends Auth_Controller * - The recipients are prestudents * - An email template with message var may be provided * - A global organisation unit may be provided, otherwise is used the prestudent one + * - A template is explicitly specified */ - public function sendJson() + public function sendExplicitTemplateJson() { $prestudents = $this->input->post('prestudents'); - $vorlage_kurzbz = $this->input->post('vorlage_kurzbz'); $oe_kurzbz = $this->input->post('oe_kurzbz'); + $vorlage_kurzbz = $this->input->post('vorlage_kurzbz'); $msgVars = $this->input->post('msgvars'); - $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents); - - $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - $prestudentsData = $this->PrestudentModel->getOrganisationunits($prestudents); - - // Adds the organisation unit to each prestudent - if (isEmptyString($oe_kurzbz) && hasData($msgVarsData) && hasData($prestudentsData)) - { - $this->CLMessagesModel->addOeToPrestudents($msgVarsData, $prestudentsData); - } - - $send = $this->CLMessagesModel->send($msgVarsData, null, $oe_kurzbz, $vorlage_kurzbz, $msgVars); - - $this->outputJson(getData($send)); + $sendExplicitTemplate = $this->CLMessagesModel->sendExplicitTemplate($prestudents, $oe_kurzbz, $vorlage_kurzbz, $msgVars); + $this->outputJson(getData($sendExplicitTemplate)); } } diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index c3c1169d4..7bf6b7518 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -49,7 +49,6 @@ class MessageLib // Loads extra models $this->_ci->load->model('person/Person_model', 'PersonModel'); - $this->_ci->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); $this->_ci->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); $this->_ci->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); } @@ -208,14 +207,6 @@ class MessageLib return $benutzer; // otherwise returns the error } - /** - * Admin or commoner? - */ - public function getIsAdmin($sender_id) - { - return $this->_ci->BenutzerrolleModel->isAdminByPersonId($sender_id); - } - //------------------------------------------------------------------------------------------------------------------ // Public methods used by REST API @@ -629,6 +620,7 @@ class MessageLib /** * Sends new message core method, may be wrapped by other methods. + * If success then returns an array of successfully saved message ids */ private function _sendMessage( $receivers, $receiversOU, $subject, $body, $sender_id, $senderOU, $relationmessage_id, $priority, $multiPartMime @@ -658,11 +650,7 @@ class MessageLib ); if (isSuccess($saveMessageResult)) // If successfully saved { - // If the system is configured to send messages immediately - if ($this->_ci->config->item(self::CFG_SEND_IMMEDIATELY) === true) - { - $savedMessages[] = getData($saveMessageResult); // store the message id of the saved message - } + $savedMessages[] = getData($saveMessageResult); // store the message id of the saved message } else { @@ -683,7 +671,7 @@ class MessageLib } } - return success('Message sent successfully'); + return success($savedMessages); } /** diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index c17d608c7..05eaa8b16 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -1,11 +1,15 @@
-------------------------------------------------------------------------------'; + /** * Constructor */ @@ -14,102 +18,143 @@ class Messages_model extends CI_Model parent::__construct(); // Loads the message library - $this->load->library('MessageLib'); - + $this->load->library('MessageLib'); // MessageModel loaded here! // Loads the person log library $this->load->library('PersonLogLib'); + // Loads the widget library + $this->load->library('WidgetLib'); + // Loads model MessageToken_model $this->load->model('system/MessageToken_model', 'MessageTokenModel'); + + // Loads model Benutzerrolle_model + $this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Prepares data for the view system/messages/htmlWriteTemplate using person ids as main parameter + * Wrap method to _prepareHtmlWriteTemplate + */ + public function prepareHtmlWriteTemplatePersons($persons, $message_id = null, $recipient_id = null) + { + // Retrieves persons information + $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($persons); + + return $this->_prepareHtmlWriteTemplate($msgVarsData, $message_id, $recipient_id); } /** - * Executes message sending - * @param $sender_id - * @return array wether execution was successfull - error or success + * Prepares data for the view system/messages/htmlWriteTemplate using prestudent ids as main parameter + * Wrap method to _prepareHtmlWriteTemplate */ - public function send($msgVarsData, $relationmessage_id = null, $oe_kurzbz = null, $vorlage_kurzbz = null, $msgVars = null) + public function prepareHtmlWriteTemplatePrestudents($prestudents, $message_id = null, $recipient_id = null) { - $subject = $this->input->post('subject'); - $body = $this->input->post('body'); + // Retrieves prestudents information + $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents); - $authUser = $this->getAuthUser(); + return $this->_prepareHtmlWriteTemplate($msgVarsData, $message_id, $recipient_id); + } - if (isError($authUser)) return $authUser; + /** + * Sends a new message or a reply to a message (if $relationmessage_id is given) + * using the template stored in the subject and body + */ + public function sendImplicitTemplate($persons, $subject, $body, $relationmessage_id = null) + { + // Retrieves the sender id + $authUser = $this->_getAuthUser(); + if (isError($authUser)) show_error(getData($authUser)); + if (!hasData($authUser)) show_error('The current logged user person_id is not defined'); $sender_id = getData($authUser)[0]->person_id; + // Retrieves message vars data for the given user/s + $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($persons); + if (isError($msgVarsData)) show_error(getData($msgVarsData)); + if (!hasData($msgVarsData)) show_error('No recipients were given'); - // Send message(s) - if (hasData($msgVarsData)) + foreach (getData($msgVarsData) as $receiver) { - for ($i = 0; $i < count(getData($msgVarsData)); $i++) - { - $parsedText = ''; - $msgVarsDataArray = $this->replaceKeys((array)getData($msgVarsData)[$i]); // replaces array keys + $msgVarsDataArray = $this->_lowerReplaceSpaceArrayKeys((array)$receiver); // replaces array keys - // Send without vorlage - if (isEmptyString($vorlage_kurzbz)) - { - $parsedText = parseText($body, $msgVarsDataArray); + $parsedSubject = parseText($subject, $msgVarsDataArray); + $parsedBody = parseText($body, $msgVarsDataArray); - $msg = $this->messagelib->sendMessageUser( - $msgVarsDataArray['person_id'], // receiverPersonId - $subject, // subject - $parsedText, // body - $sender_id, // sender_id - $oe_kurzbz, // senderOU - $relationmessage_id, // relationmessage_id - MSG_PRIORITY_NORMAL // priority - ); - } - // Send with vorlage - else - { - if (is_array($msgVars)) - { - // Additional message variables - foreach ($msgVars as $key => $msgvar) - { - $msgVarsDataArray[$key] = $msgvar; - } - } + $message = $this->messagelib->sendMessageUser( + $msgVarsDataArray['person_id'], // receiverPersonId + $parsedSubject, // subject + $parsedBody, // body + $sender_id, // sender_id + null, // senderOU + $relationmessage_id, // relationmessage_id + MSG_PRIORITY_NORMAL // priority + ); - $msg = $this->messagelib->sendMessageUserTemplate( - $msgVarsDataArray['person_id'], // receiversPersonId - $vorlage_kurzbz, // vorlage - $msgVarsDataArray, // parseData - null, // orgform - $sender_id, // sender_id - $oe_kurzbz // senderOU - ); - } + if (isError($message)) return $message; + if (!hasData($message)) return error('No messages were saved in database'); - if (isError($msg)) return $msg; - - // Write log entry - $personLog = $this->personloglib->log( - $msgVarsDataArray['person_id'], - 'Action', - array( - 'name' => 'Message sent', - 'message' => 'Message sent from person '.$sender_id.' to '.$msgVarsDataArray['person_id'].', messageid '.getData($msg), - 'success' => 'true' - ), - 'kommunikation', - 'core', - null, - getAuthUID() - ); - - if (isError($personLog)) return $personLog; - } - - return success('Messages sent successfully'); + // Write log entry + $personLog = $this->_personLog($sender_id, $msgVarsDataArray['person_id'], getData($message)[0]); + if (isError($personLog)) return $personLog; } - else + + return success('Messages sent successfully'); + } + + /** + * Sends a new message using the given template and information present in parameter prestudents + * Extra variables can be added using parameter $msgVars + */ + public function sendExplicitTemplate($prestudents, $oe_kurzbz, $vorlage_kurzbz, $msgVars) + { + // Retrieves the sender id + $authUser = $this->_getAuthUser(); + if (isError($authUser)) show_error(getData($authUser)); + if (!hasData($authUser)) show_error('The current logged user person_id is not defined'); + + $sender_id = getData($authUser)[0]->person_id; + + // Retrieves message vars data for the given user/s + $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents); + if (isError($msgVarsData)) show_error(getData($msgVarsData)); + if (!hasData($msgVarsData)) show_error('No recipients were given'); + + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $prestudentsData = $this->PrestudentModel->getOrganisationunits($prestudents); + + // Adds the organisation unit to each prestudent + if (isEmptyString($oe_kurzbz) && hasData($msgVarsData) && hasData($prestudentsData)) { - return $msgVarsData; + $this->CLMessagesModel->_addOeToPrestudents($msgVarsData, $prestudentsData); } + + foreach (getData($msgVarsData) as $receiver) + { + $msgVarsDataArray = $this->_lowerReplaceSpaceArrayKeys((array)$receiver); // replaces array keys + + // Additional message variables + if (is_array($msgVars)) $msgVarsDataArray = array_merge($msgVarsDataArray, $msgVars); + + $message = $this->messagelib->sendMessageUserTemplate( + $msgVarsDataArray['person_id'], // receiversPersonId + $vorlage_kurzbz, // vorlage + $msgVarsDataArray, // parseData + null, // orgform + $sender_id, // sender_id + $oe_kurzbz // senderOU + ); + + if (isError($message)) return $message; + + // Write log entry + $personLog = $this->_personLog($sender_id, $msgVarsDataArray['person_id'], getData($message)[0]); + if (isError($personLog)) return $personLog; + } + + return success('Messages sent successfully'); } /** @@ -171,29 +216,98 @@ class Messages_model extends CI_Model return success('Reply sent'); } - /** - * - */ - public function getAuthUser() - { - $sender_id = null; + //------------------------------------------------------------------------------------------------------------------ + // Public methods called by controller system/Messages + /** + * Returns an object that represent a template store in database + * If no templates are found with the given parameter or the given parameter is an empty string, + * then an error is returned + */ + public function getVorlage($vorlage_kurzbz) + { + $getVorlage = error('The given vorlage_kurzbz is not valid'); + + if (!isEmptyString($vorlage_kurzbz)) + { + $this->load->model('system/Vorlagestudiengang_model', 'VorlagestudiengangModel'); + $this->VorlagestudiengangModel->addOrder('version','DESC'); + + $getVorlage = $this->VorlagestudiengangModel->loadWhere(array('vorlage_kurzbz' => $vorlage_kurzbz)); + } + + return $getVorlage; + } + + /** + * Parse the given given text using data from the given user + * Use the CI parser which performs simple text substitution for pseudo-variable + */ + public function parseMessageText($person_id, $text) + { + $parseMessageText = error('The given person_id is not a valid number'); + + if (is_numeric($person_id)) + { + $parseMessageText = $this->MessageModel->getMsgVarsDataByPersonId($person_id); + } + + if (hasData($parseMessageText)) + { + $parseMessageText = success( + parseText( + $text, + $this->_lowerReplaceSpaceArrayKeys((array)getData($parseMessageText)[0]) + ) + ); + } + + return $parseMessageText; + } + + /** + * Outputs message data for a message (identified my msg id and receiver id) in JSON format + */ + public function getMessageFromIds($message_id, $receiver_id) + { + $getMessageFromIds = error('The given message id or receiver id are not valid'); + + if (is_numeric($message_id) && is_numeric($receiver_id)) + { + $getMessageFromIds = $this->messagelib->getMessage($message_id, $receiver_id); + } + + if (isError($getMessageFromIds) || !hasData($getMessageFromIds)) + { + return array(); + } + else + { + return array(getData($getMessageFromIds)[0]); + } + } + + //------------------------------------------------------------------------------------------------------------------ + // Private methods + + /** + * Returns the current authenticated person object + */ + private function _getAuthUser() + { $this->load->model('person/Person_model', 'PersonModel'); $authUser = $this->PersonModel->getByUid(getAuthUID()); - if (!hasData($authUser)) $authUser = error('The current logged user person_id is not defined'); - return $authUser; } /** - * + * Replaces data array keys to a lowercase string with underscores instead of spaces */ - public function replaceKeys($data) + private function _lowerReplaceSpaceArrayKeys($data) { $tmpData = array(); - // Replaces data array keys to a lowercase without spaces string foreach ($data as $key => $val) { $tmpData[str_replace(' ', '_', strtolower($key))] = $val; @@ -203,9 +317,9 @@ class Messages_model extends CI_Model } /** - * + * Add organisation unit to an array of prestudents (objects) */ - public function addOeToPrestudents(&$msgVarsData, $prestudentsData) + private function _addOeToPrestudents(&$msgVarsData, $prestudentsData) { for ($i = 0; $i < count(getData($msgVarsData)); $i++) { @@ -219,4 +333,127 @@ class Messages_model extends CI_Model } } } + + /** + * Perform a person log after a message is sent + */ + private function _personLog($sender_id, $receiver_id, $message_id) + { + $_personLog = $this->personloglib->log( + $receiver_id, + 'Action', + array( + 'name' => 'Message sent', + 'message' => 'Message sent from person '.$sender_id.' to '.$receiver_id.', message id: '.$message_id, + 'success' => 'true' + ), + 'kommunikation', + 'core', + null, + getAuthUID() + ); + + return $_personLog; + } + + /** + * Prepares data for the view system/messages/htmlWriteTemplate using the given parameters + */ + private function _prepareHtmlWriteTemplate($info, $message_id, $recipient_id) + { + // Checks that info parameter is valid + if (isError($info)) show_error(getData($info)); + if (!hasData($info)) show_error('No recipients were given'); + + // If the message id and recipient id are given, then both they must be valid numbers + if ((is_numeric($message_id) && !is_numeric($recipient_id)) + || (!is_numeric($message_id) && is_numeric($recipient_id))) + { + show_error('If given, message id and recipient id both must be valid numbers'); + } + + // --------------------------------------------------------------------------------------- + // Retrieves the recipients information and builds: + // - recipientsArray: an array that contains objects with id (person_id) and description (Vorname + Nachname) of recipient + // - recipientsList: a string that contains all the recipients descriptions (Vorname + Nachname) separated by ; + // - persons: a string that contains HTML input hidden with alla the receivers id (person_id) + $recipientsArray = array(); + $recipientsList = ''; + $persons = ''; + foreach (getData($info) as $receiver) + { + $recipient = new stdClass(); + $recipient->id = $receiver->person_id; + $recipient->description = $receiver->Vorname.' '.$receiver->Nachname; + + $recipientsArray[] = $recipient; + $recipientsList .= $receiver->Vorname.' '.$receiver->Nachname.'; '; + $persons .= ''."\n"; + } + + // --------------------------------------------------------------------------------------- + // Retrieves the message to reply to, if it is specified by parameters $message_id and $recipient_id + $replySubject = ''; // message reply subject + $replyBody = ''; // message reply body + $relationmessage = ''; // input hidden that contains the message id to be replied to + // If both are given and they are valid + if (is_numeric($message_id) && is_numeric($recipient_id)) + { + // Retrieves a received message from tbl_msg_recipient + $messageResult = $this->messagelib->getMessage($message_id, $recipient_id); + if (isError($messageResult)) show_error(getData($messageResult)); + if (!hasData($messageResult)) show_error('The selected message does not exist'); + + $message = getData($messageResult)[0]; + + $replySubject = self::REPLY_SUBJECT_PREFIX.$message->subject; + $replyBody = self::REPLY_BODY_PREFIX.$message->body; + $relationmessage = ''; + } + + // --------------------------------------------------------------------------------------- + // Retrieves message vars from database view vw_msg_vars_person + $variablesResult = $this->messagelib->getMessageVarsPerson(); + if (isError($variablesResult)) show_error(getData($variablesResult)); + + // Then builds an array that contains objects with id (person_id) and description (Vorname + Nachname) of recipient + $variables = array(); + foreach (getData($variablesResult) as $id => $description) + { + $tmpVar = new stdClass(); + $tmpVar->id = $id; + $tmpVar->description = $description; + + $variables[] = $tmpVar; + } + + // --------------------------------------------------------------------------------------- + // Retrieves the sender id + $authUser = $this->_getAuthUser(); + if (isError($authUser)) show_error(getData($authUser)); + if (!hasData($authUser)) show_error('The current logged user person_id is not defined'); + + $sender_id = getData($authUser)[0]->person_id; + + // --------------------------------------------------------------------------------------- + // Organisation units and a boolean (true if the sender is administrator) are used to get the templates + $organisationUnits = $this->messagelib->getOeKurzbz($sender_id); + if (isError($organisationUnits)) show_error(getData($organisationUnits)); + $senderIsAdmin = $this->BenutzerrolleModel->isAdminByPersonId($sender_id); + if (isError($senderIsAdmin)) show_error(getData($senderIsAdmin)); + + // --------------------------------------------------------------------------------------- + // Returns data as an array + return array ( + 'recipientsList' => $recipientsList, + 'subject' => $replySubject, + 'body' => $replyBody, + 'variables' => $variables, + 'organisationUnits' => getData($organisationUnits), + 'senderIsAdmin' => getData($senderIsAdmin), + 'recipientsArray' => $recipientsArray, + 'persons' => $persons, + 'relationmessage_id' => $relationmessage + ); + } } diff --git a/application/views/system/infocenter/stammdaten.php b/application/views/system/infocenter/stammdaten.php index 2b481692e..ebd812c6a 100644 --- a/application/views/system/infocenter/stammdaten.php +++ b/application/views/system/infocenter/stammdaten.php @@ -113,7 +113,7 @@
-
+  p->t('ui','nachrichtSenden'); ?> diff --git a/application/views/system/messages/htmlError.php b/application/views/system/messages/htmlError.php new file mode 100644 index 000000000..7e029b50c --- /dev/null +++ b/application/views/system/messages/htmlError.php @@ -0,0 +1,82 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Message sent failure', + 'jquery' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageSent.css') + ) + ); +?> + + + + + +load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/messageSent.php b/application/views/system/messages/htmlSuccess.php similarity index 95% rename from application/views/system/messages/messageSent.php rename to application/views/system/messages/htmlSuccess.php index 674ccd5a0..0260c9d16 100644 --- a/application/views/system/messages/messageSent.php +++ b/application/views/system/messages/htmlSuccess.php @@ -2,7 +2,7 @@ $this->load->view( 'templates/FHC-Header', array( - 'title' => 'MessageSent', + 'title' => 'Message sent successfully', 'jquery' => true, 'bootstrap' => true, 'fontawesome' => true, @@ -17,11 +17,6 @@
- -
@@ -79,11 +74,6 @@
- - -
diff --git a/application/views/system/messages/htmlWriteTemplate.php b/application/views/system/messages/htmlWriteTemplate.php new file mode 100644 index 000000000..8ce4d670a --- /dev/null +++ b/application/views/system/messages/htmlWriteTemplate.php @@ -0,0 +1,167 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Write a message', + 'jquery' => true, + 'jqueryui' => true, + 'bootstrap' => true, + 'ajaxlib' => true, + 'fontawesome' => true, + 'tinymce' => true, + 'sbadmintemplate' => true, + 'widgets' => true, + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'), + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/messageWrite.js') + ) + ); +?> + + + + +load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/messageWrite.php b/application/views/system/messages/messageWrite.php deleted file mode 100644 index 93caaf861..000000000 --- a/application/views/system/messages/messageWrite.php +++ /dev/null @@ -1,183 +0,0 @@ -load->view( - 'templates/FHC-Header', - array( - 'title' => 'Write a message', - 'jquery' => true, - 'jqueryui' => true, - 'bootstrap' => true, - 'ajaxlib' => true, - 'fontawesome' => true, - 'tinymce' => true, - 'sbadmintemplate' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'), - 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/messageWrite.js') - ) -); -?> - -
-
-
-
-
- -
-
-
-
-
-
- -
-
- 1 && $i % 10 == 0) - { - echo '
'; - } - echo $receiver->Vorname." ".$receiver->Nachname."; "; - } - ?> -
-
-
-
-
-
- -
  - subject; - } - ?> -
- -
-
-
-
-
-
- - body; - } - ?> - -
- -
-
- - -
-
- -
-
-
-
- widgetlib->widget( - 'Vorlage_widget', - array('oe_kurzbz' => $oe_kurzbz, 'isAdmin' => $isAdmin), - array('name' => 'vorlage', 'id' => 'vorlageDnD') - ); - ?> -
-
- -
-
- 0) - { - ?> -
-
-
- -
-
-
-
-
-
- - -   - Refresh -
-
-
- -
-
-
- -
- - - person_id.'">'."\n"; - } - ?> - - - - - -
-
-
-
- - -load->view("templates/FHC-Footer"); ?> diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index 43112dd7b..6b9afd6b9 100644 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -30,6 +30,7 @@ $sbadmintemplate = isset($sbadmintemplate) ? $sbadmintemplate : false; $tablesorter = isset($tablesorter) ? $tablesorter : false; $tinymce = isset($tinymce) ? $tinymce : false; + $widgets = isset($widgets) ? $widgets : false; ?> @@ -94,6 +95,9 @@ // NavigationWidget CSS if ($navigationwidget === true) generateCSSsInclude('public/css/NavigationWidget.css'); + // HTML Widget CSS + if ($widgets === true) generateCSSsInclude('public/css/Widgets.css'); + // Eventually required CSS generateCSSsInclude($customCSSs); // Eventually required CSS diff --git a/application/views/widgets/dropdown.php b/application/views/widgets/dropdown.php index c1bdbf5c8..3db602755 100644 --- a/application/views/widgets/dropdown.php +++ b/application/views/widgets/dropdown.php @@ -37,11 +37,11 @@
- \ No newline at end of file + diff --git a/application/widgets/Dropdown_widget.php b/application/widgets/Dropdown_widget.php new file mode 100644 index 000000000..91e41e3ad --- /dev/null +++ b/application/widgets/Dropdown_widget.php @@ -0,0 +1,19 @@ +setElementsArray( + $elements, + true, + $emptyElement, + 'No data present' + ); + + $this->loadDropDownView($widgetData); + } +} diff --git a/application/widgets/MultipleDropdown_widget.php b/application/widgets/MultipleDropdown_widget.php new file mode 100644 index 000000000..a13f62492 --- /dev/null +++ b/application/widgets/MultipleDropdown_widget.php @@ -0,0 +1,20 @@ +setElementsArray( + $elements, + false, + '', + 'No data present' + ); + + $this->setMultiple(); + + $this->loadDropDownView($widgetData); + } +} diff --git a/application/widgets/html/DropdownWidget.php b/application/widgets/html/DropdownWidget.php index ca3e30163..5c28e5a9f 100644 --- a/application/widgets/html/DropdownWidget.php +++ b/application/widgets/html/DropdownWidget.php @@ -17,32 +17,32 @@ class DropdownWidget extends HTMLWidget const SELECTED_ELEMENT = 'selectedElement'; // Default HTML value const HTML_DEFAULT_VALUE = 'null'; - + const SIZE = 'size'; // size of the dropdown const MULTIPLE = 'multiple'; // multiple attribute - + // Alias of $this->_args[HTMLWidget::HTML_ARG_NAME] for a better code readability protected $htmlParameters; - + /** - * + * */ public function __construct($name, $args = array(), $htmlArgs = array()) { parent::__construct($name, $args, $htmlArgs); - + // If the selectd element is not set then set it to HTML_DEFAULT_VALUE if (!isset($this->_args[DropdownWidget::SELECTED_ELEMENT])) { $this->_args[DropdownWidget::SELECTED_ELEMENT] = DropdownWidget::HTML_DEFAULT_VALUE; } - + $this->htmlParameters =& $this->_args[HTMLWidget::HTML_ARG_NAME]; // Reference for a better code readability - + // By default is not a multiple dropdown unset($this->htmlParameters[DropdownWidget::MULTIPLE]); } - + /** * Set this dropdown as multiple: * - Setting the multiple attribute @@ -53,23 +53,23 @@ class DropdownWidget extends HTMLWidget $this->htmlParameters[DropdownWidget::MULTIPLE] = DropdownWidget::MULTIPLE; $this->htmlParameters[HTMLWidget::HTML_NAME] .= '[]'; } - + /** * Checks if this object is a multiple dropdown */ public function isMultipleDropdown() { $isMultipleDropdown = false; - + if (isset($this->htmlParameters[DropdownWidget::MULTIPLE]) && $this->htmlParameters[DropdownWidget::MULTIPLE] == DropdownWidget::MULTIPLE) { $isMultipleDropdown = true; } - + return $isMultipleDropdown; } - + /** * Add the correct select to the model used to load a list of elemets for this dropdown * @param model $model the model used to load elements @@ -88,7 +88,7 @@ class DropdownWidget extends HTMLWidget ) ); } - + /** * Set the array used to populate the dropdown * @param array $elements list used to populate this dropdown @@ -102,7 +102,7 @@ class DropdownWidget extends HTMLWidget ) { $tmpElements = array(); - + if (isError($elements)) { if (is_object($elements) && isset($elements->retval)) @@ -133,11 +133,11 @@ class DropdownWidget extends HTMLWidget { $tmpElements = $elements->retval; } - + $this->_args[DropdownWidget::WIDGET_DATA_ELEMENTS_ARRAY_NAME] = $tmpElements; } } - + /** * Adds an element to the beginning of the array */ @@ -146,17 +146,17 @@ class DropdownWidget extends HTMLWidget $element = new stdClass(); $element->{DropdownWidget::ID_FIELD} = $id; $element->{DropdownWidget::DESCRIPTION_FIELD} = $stdDescription; - + if (!hasData($elements)) { $element->{DropdownWidget::DESCRIPTION_FIELD} = $noDataDescription; } - + array_unshift($elements->retval, $element); - + return $elements->retval; } - + /** * Loads the dropdown view with all the elements to be displayed */ @@ -164,4 +164,4 @@ class DropdownWidget extends HTMLWidget { $this->view('widgets/dropdown', $this->_args); } -} \ No newline at end of file +} diff --git a/composer.json b/composer.json index d763dc5ad..c6816e075 100644 --- a/composer.json +++ b/composer.json @@ -173,6 +173,17 @@ } } }, + { + "type": "package", + "package": { + "name": "olifolkerd/tabulator", + "version": "4.2.7", + "dist": { + "url": "https://github.com/olifolkerd/tabulator/archive/4.2.7.zip", + "type": "zip" + } + } + }, { "type": "package", "package": { @@ -260,6 +271,8 @@ "netcarver/textile": "^3.5", "nicolaskruchten/pivottable": "^2.15.0", + "olifolkerd/tabulator": "4.2.7", + "phpseclib/phpseclib": "^2.0", "rmariuzzo/jquery-checkboxes": "1.0.7", diff --git a/composer.lock b/composer.lock index 8fc88ce07..f328832e6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "ddbbad487c655512e6983408339cb85f", - "content-hash": "b5902c71fe21cd14397101dba5a3080c", + "hash": "df6059a4bee974ecf5447aad8a8b1e15", + "content-hash": "2111c73853dbc47938c3f31dbc349883", "packages": [ { "name": "BlackrockDigital/startbootstrap-sb-admin-2", @@ -1198,16 +1198,16 @@ }, { "name": "netcarver/textile", - "version": "v3.7.1", + "version": "v3.7.2", "source": { "type": "git", "url": "https://github.com/textile/php-textile.git", - "reference": "377933125dd30d708804c545bf33da87a3c1b0f4" + "reference": "c24d68d9f4d099f9c2434e71024f2a6140dc1594" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/textile/php-textile/zipball/377933125dd30d708804c545bf33da87a3c1b0f4", - "reference": "377933125dd30d708804c545bf33da87a3c1b0f4", + "url": "https://api.github.com/repos/textile/php-textile/zipball/c24d68d9f4d099f9c2434e71024f2a6140dc1594", + "reference": "c24d68d9f4d099f9c2434e71024f2a6140dc1594", "shasum": "" }, "require": { @@ -1247,7 +1247,7 @@ "plaintext", "textile" ], - "time": "2019-01-26 17:03:58" + "time": "2019-06-08 17:57:17" }, { "name": "nicolaskruchten/pivottable", @@ -1260,18 +1260,29 @@ }, "type": "library" }, + { + "name": "olifolkerd/tabulator", + "version": "4.2.7", + "dist": { + "type": "zip", + "url": "https://github.com/olifolkerd/tabulator/archive/4.2.7.zip", + "reference": null, + "shasum": null + }, + "type": "library" + }, { "name": "phpseclib/phpseclib", - "version": "2.0.15", + "version": "2.0.18", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "11cf67cf78dc4acb18dc9149a57be4aee5036ce0" + "reference": "60519001db8d791215a822efd366d24cafee9e63" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/11cf67cf78dc4acb18dc9149a57be4aee5036ce0", - "reference": "11cf67cf78dc4acb18dc9149a57be4aee5036ce0", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/60519001db8d791215a822efd366d24cafee9e63", + "reference": "60519001db8d791215a822efd366d24cafee9e63", "shasum": "" }, "require": { @@ -1350,7 +1361,7 @@ "x.509", "x509" ], - "time": "2019-03-10 16:53:45" + "time": "2019-06-13 06:15:54" }, { "name": "psr/log", @@ -2180,16 +2191,16 @@ }, { "name": "twig/twig", - "version": "v1.41.0", + "version": "v1.42.1", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "575cd5028362da591facde1ef5d7b94553c375c9" + "reference": "671347603760a88b1e7288aaa9378f33687d7edf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/575cd5028362da591facde1ef5d7b94553c375c9", - "reference": "575cd5028362da591facde1ef5d7b94553c375c9", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/671347603760a88b1e7288aaa9378f33687d7edf", + "reference": "671347603760a88b1e7288aaa9378f33687d7edf", "shasum": "" }, "require": { @@ -2199,12 +2210,12 @@ "require-dev": { "psr/container": "^1.0", "symfony/debug": "^2.7", - "symfony/phpunit-bridge": "^3.4.19|^4.1.8" + "symfony/phpunit-bridge": "^3.4.19|^4.1.8|^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.41-dev" + "dev-master": "1.42-dev" } }, "autoload": { @@ -2242,7 +2253,7 @@ "keywords": [ "templating" ], - "time": "2019-05-14 11:59:08" + "time": "2019-06-04 11:31:08" }, { "name": "zetacomponents/base", diff --git a/content/fasoverlay.js.php b/content/fasoverlay.js.php index 0c80221e9..3089b6032 100644 --- a/content/fasoverlay.js.php +++ b/content/fasoverlay.js.php @@ -1250,7 +1250,7 @@ function MessageNew() { var prestudentIdArray = getMultipleTreeCellText(tree, 'student-treecol-prestudent_id'); - var action = 'index.ci.php/system/FASMessages/write/' + person_id; ?>; + var action = 'index.ci.php/system/FASMessages/writeTemplate/' + person_id; ?>; openWindowPostArray(action, 'prestudent_id', prestudentIdArray); } diff --git a/content/messages.js.php b/content/messages.js.php index fae1db4ba..4094cddb8 100644 --- a/content/messages.js.php +++ b/content/messages.js.php @@ -104,7 +104,7 @@ function MessagesNewMessage() { var prestudentIdArray = getMultipleTreeCellText(tree, 'student-treecol-prestudent_id'); - var action = 'index.ci.php/system/FASMessages/write/' + MessageSenderPersonID; + var action = 'index.ci.php/system/FASMessages/writeTemplate'; openWindowPostArray(action, 'prestudent_id', prestudentIdArray); } @@ -128,7 +128,7 @@ function MessagesSendAnswer() var RecipientID = getTreeCellText(messagesTree, 'messages-tree-recipient_id', messagesTree.currentIndex); var prestudentIdArray = new Array(getTreeCellText(studentsTree, 'student-treecol-prestudent_id', studentsTree.currentIndex)); - var action = 'index.ci.php/system/FASMessages/writeReply/' + MessageSenderPersonID + '/' + MessageId + '/' + RecipientID; + var action = 'index.ci.php/system/FASMessages/writeReplyTemplate/' + MessageId + '/' + RecipientID; openWindowPostArray(action, 'prestudent_id', prestudentIdArray); } diff --git a/public/css/Widgets.css b/public/css/Widgets.css new file mode 100644 index 000000000..ef98856ea --- /dev/null +++ b/public/css/Widgets.css @@ -0,0 +1,46 @@ +.div-table { + display: table; +} + +.div-row { + display: table-row; +} + +.div-cell { + display: table-cell; +} + +.div-cell-label { + display: table-cell; +} + +label[required-field=true]::after { + content: "*"; +} + +.div-cell-data { + display: table-cell; +} + +.halign-right { + text-align: right; + margin-left: auto; + margin-right: 0; +} + +.valign-middle { + vertical-align: middle; +} + +.valign-top { + vertical-align: top; + padding-top: 1px; +} + +.width-150px { + width: 150px; +} + +.width-30px { + width: 30px; +} diff --git a/public/css/messaging/messageWrite.css b/public/css/messaging/messageWrite.css index 91b20729f..3b5e1fd0e 100644 --- a/public/css/messaging/messageWrite.css +++ b/public/css/messaging/messageWrite.css @@ -21,4 +21,9 @@ input[type=text] { #sendButton { width: 120px; -} \ No newline at end of file +} + +/* Overwrites the Widget.css class */ +div .width-150px { + width: 200px; +} diff --git a/public/js/infocenter/infocenterDetails.js b/public/js/infocenter/infocenterDetails.js index a43b36df8..3edb9d42d 100644 --- a/public/js/infocenter/infocenterDetails.js +++ b/public/js/infocenter/infocenterDetails.js @@ -629,7 +629,7 @@ var InfocenterDetails = { sendFreigabeMessage: function(prestudentid, vorlage_kurzbz, msgvars) { FHC_AjaxClient.ajaxCallPost( - 'system/Messages/sendJson', + 'system/Messages/sendExplicitTemplateJson', { "prestudents": prestudentid, "vorlage_kurzbz": vorlage_kurzbz, diff --git a/public/js/infocenter/infocenterPersonDataset.js b/public/js/infocenter/infocenterPersonDataset.js index dc6af2284..c5ea99dfc 100644 --- a/public/js/infocenter/infocenterPersonDataset.js +++ b/public/js/infocenter/infocenterPersonDataset.js @@ -26,7 +26,7 @@ var InfocenterPersonDataset = { appendTableActionsHtml: function() { var currurl = window.location.href; - var url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/system/Messages/write"; + var url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/system/Messages/writeTemplate"; var formHtml = '
'; $("#datasetActionsTop").before(formHtml); diff --git a/public/js/messaging/messageWrite.js b/public/js/messaging/messageWrite.js index 9894573ee..c496b269d 100644 --- a/public/js/messaging/messageWrite.js +++ b/public/js/messaging/messageWrite.js @@ -1,5 +1,5 @@ /** - * JS used by view system/messages/messageWrite + * JS used by view system/messages/htmlWriteTemplate */ function tinymcePreviewSetContent() From 99570978c3676346d42b6becc7a87396a9bd86b6 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 19 Jun 2019 14:51:54 +0200 Subject: [PATCH 007/138] - Renamed view system/messages/messageHTML to system/messages/htmlRead - Renamed view system/messages/messageWriteReply to system/messages/htmlWriteReply - Removed views system/messages/messageReplySent and system/messages/messageForm - Moved logic from controller ViewMessage to model CL/Messages_model - Added new constants CFG_REDIRECT_VIEW_MESSAGE_URL to MessageLib - Removed public method getPersonData from model system/MessageToken_model - Changed query in method system/Recipient_model->getMessage to include column tbl_msg_recipient.sent - Added new public method prepareHtmlRead to model CL/Messages_model - Changed constant REPLY_BODY_FORMAT of model CL/Messages_model - Added new constant NO_AUTH_UID to model CL/Messages_model - Added new public method prepareHtmlWriteReply to model CL/Messages_model - Changed public method sendReply of model CL/Messages_model - Added new private method _getReplyBody to model CL/Messages_model - Changed method _personLog of model CL/Messages_model to manage not authenticated users --- application/controllers/ViewMessage.php | 107 ++-------- application/libraries/MessageLib.php | 1 + application/models/CL/Messages_model.php | 183 +++++++++++++----- .../models/system/MessageToken_model.php | 65 +------ application/models/system/Recipient_model.php | 3 +- .../{messageHTML.php => htmlRead.php} | 23 ++- .../views/system/messages/htmlWriteReply.php | 73 +++++++ .../views/system/messages/messageForm.php | 81 -------- .../system/messages/messageReplySent.php | 103 ---------- .../system/messages/messageWriteReply.php | 63 ------ 10 files changed, 242 insertions(+), 460 deletions(-) rename application/views/system/messages/{messageHTML.php => htmlRead.php} (87%) create mode 100644 application/views/system/messages/htmlWriteReply.php delete mode 100644 application/views/system/messages/messageForm.php delete mode 100644 application/views/system/messages/messageReplySent.php delete mode 100644 application/views/system/messages/messageWriteReply.php diff --git a/application/controllers/ViewMessage.php b/application/controllers/ViewMessage.php index 3c22c8977..9c6fc4c4e 100644 --- a/application/controllers/ViewMessage.php +++ b/application/controllers/ViewMessage.php @@ -16,14 +16,10 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); /** * Handles sending messages with token - * NOTE: in this controller is not possible to include/call everything - * that automatically call the authentication system, like the most of models or libraries + * NOTE: it extends FHC_Controller instead of Auth_Controller because authentication is not needed */ class ViewMessage extends FHC_Controller { - /** - * API constructor - */ public function __construct() { parent::__construct(); @@ -32,121 +28,48 @@ class ViewMessage extends FHC_Controller $this->config->load('message'); // Load model MessageToken_model, not calling the authentication system - $this->load->model('system/MessageToken_model', 'MessageTokenModel'); $this->load->model('CL/Messages_model', 'CLMessagesModel'); } /** - * Using the MessageTokenModel instead of MessageLib to allow - * viewing the message without prompting the login + * Display a message in read mode only using the specified token */ public function toHTML($token) { - $msg = $this->MessageTokenModel->getMessageByToken($token); - - if ($msg->error) - { - show_error(getData($msg)); - } - - if (is_array(getData($msg)) && count(getData($msg)) > 0) - { - $setReadMessageStatusByToken = $this->MessageTokenModel->setReadMessageStatusByToken($token); - - if (isError($setReadMessageStatusByToken)) - { - show_error($msg->$setReadMessageStatusByToken); - } - - $sender_id = getData($msg)[0]->sender_id; - $receiver_id = getData($msg)[0]->receiver_id; - $sender = $this->MessageTokenModel->getSenderData($sender_id); - - // To decide how to change the redirection - $isEmployee = $this->MessageTokenModel->isEmployee($receiver_id); - if (!is_bool($isEmployee) && isError($isEmployee)) - { - show_error($isEmployee); - } - - if($this->config->item('redirect_view_message_url') != '') - $href = $this->config->item('message_server').$this->config->item('redirect_view_message_url').$token; - else - $href = ''; - - $data = array ( - 'sender_id' => $sender_id, - 'sender' => getData($sender)[0], - 'message' => getData($msg)[0], - 'isEmployee' => $isEmployee, - 'href' => $href - ); - - $this->load->view('system/messages/messageHTML.php', $data); - } + // Loads the view to read a received message using its token as identifier + $this->load->view('system/messages/htmlRead', $this->CLMessagesModel->prepareHtmlRead($token)); } /** - * write the reply + * Write a reply message to a received one using its token as identifier */ public function writeReply() { - $token = $this->input->get('token'); + $token = $this->input->get('token'); // gets received message token - if (isEmptyString($token)) - { - show_error('No token supplied'); - } - - $msg = null; - - // Get message data if possible - $msg = $this->MessageTokenModel->getMessageByToken($token); - if (!hasData($msg)) - { - show_error('No message found'); - } - - $msg = getData($msg)[0]; - - // Get variables - $receiverData = $this->MessageTokenModel->getPersonData($msg->sender_id); - if (!hasData($receiverData)) - { - show_error('No sender found'); - } - - $data = array ( - 'receivers' => getData($receiverData), - 'message' => $msg, - 'token' => $token - ); - - $this->load->view('system/messages/messageWriteReply', $data); + // Loads the view to write a reply message + $this->load->view('system/messages/htmlWriteReply', $this->CLMessagesModel->prepareHtmlWriteReply($token)); } /** - * Send a reply + * Send a reply message (no templates are used) */ public function sendReply() { $subject = $this->input->post('subject'); $body = $this->input->post('body'); - $persons = $this->input->post('persons'); + $receiver_id = $this->input->post('receiver_id'); $relationmessage_id = $this->input->post('relationmessage_id'); $token = $this->input->post('token'); - if (!isset($relationmessage_id) || $relationmessage_id == '' || !isset($token) || $token == '') + $sendReply = $this->CLMessagesModel->sendReply($receiver_id, $subject, $body, $relationmessage_id, $token); + if (isSuccess($sendReply)) { - show_error('Error while sending reply'); + $this->load->view('system/messages/htmlSuccess'); } - - $sendReply = $this->CLMessagesModel->sendReply($subject, $body, $persons, $relationmessage_id, $token); - if (isError($sendReply)) + else { - show_error(getData($sendReply)); + $this->load->view('system/messages/htmlError'); } - - $this->load->view('system/messages/messageReplySent'); } } diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 7bf6b7518..206aeed87 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -13,6 +13,7 @@ class MessageLib const CFG_MESSAGE_SERVER = 'message_server'; const CFG_MESSAGE_HTML_VIEW_URL = 'message_html_view_url'; const CFG_OU_RECEIVERS = 'ou_receivers'; + const CFG_REDIRECT_VIEW_MESSAGE_URL = 'redirect_view_message_url'; // Templates names const NOTICE_TEMPLATE_HTML = 'MessageMailHTML'; diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 05eaa8b16..33bc90e80 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -8,7 +8,9 @@ class Messages_model extends CI_Model { const REPLY_SUBJECT_PREFIX = 'Re: '; - const REPLY_BODY_PREFIX = '

-------------------------------------------------------------------------------'; + const REPLY_BODY_FORMAT = '

On %s %s %s wrote:
%s
'; + + const NO_AUTH_UID = 'online'; // hard coded uid if no authentication is performed /** * Constructor @@ -34,6 +36,87 @@ class Messages_model extends CI_Model //------------------------------------------------------------------------------------------------------------------ // Public methods + /** + * Prepares data for the view system/messages/htmlRead using a token that identifies a single message + */ + public function prepareHtmlRead($token) + { + if (isEmptyString($token)) show_error('The given token is not valid'); + + // Retrieves message using the given token + $messageResult = $this->MessageTokenModel->getMessageByToken($token); + if (isError($messageResult)) show_error(getData($messageResult)); + if (!hasData($messageResult)) show_error('No message found with the given token'); + + $message = getData($messageResult)[0]; // Found message data + + // Set message as read + $srmsbtResult = $this->MessageTokenModel->setReadMessageStatusByToken($token); + if (isError($srmsbtResult)) show_error(getData($srmsbtResult)); + + // Retrieves message sender information + $senderResult = $this->MessageTokenModel->getSenderData($message->sender_id); + if (isError($senderResult)) show_error(getData($senderResult)); + if (!hasData($senderResult)) show_error('No sender information found'); + + $sender = getData($senderResult)[0]; // Found sender data + + // Check if the receiver is an employee + $isEmployee = false; // not by default + $isEmployeeResult = $this->MessageTokenModel->isEmployee($message->receiver_id); + if (isError($isEmployeeResult)) show_error(getData($isEmployeeResult)); + if (hasData($isEmployeeResult)) $isEmployee = true; + + // If the sender is an employee and are present configurations to reply + $hrefReply = ''; + if ($isEmployee && !isEmptyString($this->config->item(MessageLib::CFG_REDIRECT_VIEW_MESSAGE_URL))) + { + $hrefReply = $this->config->item(MessageLib::CFG_MESSAGE_SERVER). + $this->config->item(MessageLib::CFG_REDIRECT_VIEW_MESSAGE_URL). + $token; + } + + return array ( + 'sender' => $sender, + 'message' => $message, + 'hrefReply' => $hrefReply + ); + } + + /** + * Prepares data for the view system/messages/htmlWriteReply using a token that identifies a single message + */ + public function prepareHtmlWriteReply($token) + { + if (isEmptyString($token)) show_error('The given token is not valid'); + + // Retrieves message using the given token + $messageResult = $this->MessageTokenModel->getMessageByToken($token); + if (isError($messageResult)) show_error(getData($messageResult)); + if (!hasData($messageResult)) show_error('No message found with the given token'); + + $message = getData($messageResult)[0]; // Found message data + + // Retrieves message sender information + $senderResult = $this->MessageTokenModel->getSenderData($message->sender_id); + if (isError($senderResult)) show_error(getData($senderResult)); + if (!hasData($senderResult)) show_error('No sender information found'); + + $sender = getData($senderResult)[0]; // Found sender data + + $replySubject = self::REPLY_SUBJECT_PREFIX.$message->subject; + $replyBody = $this->_getReplyBody($message->body, $sender->vorname, $sender->nachname, $message->sent); + + return array ( + 'receiver' => $sender->vorname.' '.$sender->nachname, // yep! the sender of the sent message is the receiver of the reply message + 'subject' => $replySubject, + 'body' => $replyBody, + 'receiver_id' => $message->sender_id, + 'relationmessage_id' => $message->message_id, + 'token' => $token + ); + } + /** * Prepares data for the view system/messages/htmlWriteTemplate using person ids as main parameter * Wrap method to _prepareHtmlWriteTemplate @@ -158,62 +241,45 @@ class Messages_model extends CI_Model } /** - * Send a reply to a message accessed using a token + * Send a reply to a single recipient for a message identified by a token (no templates are used) */ - public function sendReply($subject, $body, $persons, $relationmessage_id, $token) + public function sendReply($receiver_id, $subject, $body, $relationmessage_id, $token) { - $relationmsg = $this->MessageTokenModel->getMessageByToken($token); - if (!hasData($relationmsg) || $relationmessage_id !== getData($relationmsg)[0]->message_id) + // Retrieves message sender information + $senderResult = $this->MessageTokenModel->getSenderData($receiver_id); + if (isError($senderResult)) show_error(getData($senderResult)); + if (!hasData($senderResult)) show_error('No sender information found'); + + $sender = getData($senderResult)[0]; // Found sender data + + $messageResult = $this->MessageTokenModel->getMessageByToken($token); + if (isError($messageResult)) show_error(getData($messageResult)); + // Security check! It is possible to reply only to a received message!! + if (!hasData($messageResult) || $relationmessage_id != getData($messageResult)[0]->message_id) { - show_error('Error while sending reply'); + show_error('An error occurred while sending your message, please contact the site administrator'); } - // Get sender (receiver of previous msg) - $sender_id = getData($relationmsg)[0]->receiver_id; + $sender_id = getData($messageResult)[0]->receiver_id; - // Get message data of persons - $data = $this->MessageTokenModel->getPersonData($persons); - if (hasData($data)) - { - for ($i = 0; $i < count(getData($data)); $i++) - { - $dataArray = (array)getData($data)[$i]; + $message = $this->messagelib->sendMessageUser( + $receiver_id, // receiverPersonId + $subject, // subject + $body, // body + $sender_id, // sender_id, the receiver of the previous message is the sender of the current one + null, // senderOU + $relationmessage_id, // relationmessage_id + MSG_PRIORITY_NORMAL // priority + ); - $msg = $this->messagelib->sendMessageUser( - $dataArray['person_id'], // receiverPersonId - $subject, // subject - $body, // body - $sender_id, // sender_id - null, // senderOU - $relationmessage_id, // relationmessage_id - MSG_PRIORITY_NORMAL // priority - ); + if (isError($message)) return $message; + if (!hasData($message)) return error('No messages were saved in database'); - if (isError($msg)) return $msg; + // Write log entry + $personLog = $this->_personLog($sender_id, $receiver_id, getData($message)[0]); + if (isError($personLog)) return $personLog; - // Logs person data - $personLog = $this->personloglib->log( - $sender_id, - 'Action', - array( - 'name' => 'Message sent', - 'message' => 'Message sent from person '.$sender_id.' to '.$dataArray['person_id'].', messageid '.getData($msg), - 'success' => 'true' - ), - 'kommunikation', - 'core', - null, - 'online' - ); - - // Unpark bewerber after he sends message - $personLog = $this->personloglib->unPark($sender_id); - - if (isError($personLog)) return $personLog; - } - } - - return success('Reply sent'); + return success('Messages sent successfully'); } //------------------------------------------------------------------------------------------------------------------ @@ -339,7 +405,11 @@ class Messages_model extends CI_Model */ private function _personLog($sender_id, $receiver_id, $message_id) { - $_personLog = $this->personloglib->log( + // In case the message is accessed via ViewMessage controller -> no authentication + // If no authentication is performed then use a hard coded uid + $loggedUserUID = function_exists('getAuthUID') ? getAuthUID() : self::NO_AUTH_UID; + + return $this->personloglib->log( $receiver_id, 'Action', array( @@ -350,10 +420,19 @@ class Messages_model extends CI_Model 'kommunikation', 'core', null, - getAuthUID() + $loggedUserUID ); + } - return $_personLog; + /** + * + */ + private function _getReplyBody($body, $receiverName, $receiverSurname, $sentDate) + { + return sprintf( + self::REPLY_BODY_FORMAT, + date_format(date_create($sentDate), 'd.m.Y H:i'), $receiverName, $receiverSurname, $body + ); } /** @@ -407,7 +486,7 @@ class Messages_model extends CI_Model $message = getData($messageResult)[0]; $replySubject = self::REPLY_SUBJECT_PREFIX.$message->subject; - $replyBody = self::REPLY_BODY_PREFIX.$message->body; + $replyBody = $this->_getReplyBody($message->body, $receiver->Vorname, $receiver->Nachname, $message->sent); $relationmessage = ''; } diff --git a/application/models/system/MessageToken_model.php b/application/models/system/MessageToken_model.php index 2398bf57a..bdb6136ac 100644 --- a/application/models/system/MessageToken_model.php +++ b/application/models/system/MessageToken_model.php @@ -152,45 +152,7 @@ class MessageToken_model extends DB_Model LEFT JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) WHERE p.person_id = ?'; - $result = $this->db->query($sql, array($person_id)); - - // If no errors occurred - if ($result) - { - return success($result->result()); - } - else - { - return error($this->db->error()); - } - } - - /** - * Get data of a person - */ - public function getPersonData($person_id) - { - $sql = 'SELECT person_id, - vorname as "Vorname", - nachname as "Nachname", - anrede as "Anrede", - titelpost as "TitelPost", - titelpre as "TitelPre", - vornamen as "Vornamen" - FROM public.tbl_person - WHERE person_id %s ?'; - - $result = $this->db->query(sprintf($sql, is_array($person_id) ? 'IN' : '='), array($person_id)); - - // If no errors occurred - if ($result) - { - return success($result->result()); - } - else - { - return error($this->db->error()); - } + return $this->execQuery($sql, array($person_id)); } /** @@ -205,30 +167,7 @@ class MessageToken_model extends DB_Model WHERE p.person_id = ? AND b.aktiv = TRUE'; - $result = $this->db->query($sql, array($person_id)); - - // If no errors occurred - if ($result) - { - // If data are present - if (is_array($result->result()) && count($result->result()) > 0) - { - $personresults = $result->result(); - $person = $personresults[0]; - - // If it is an employee - if ($person->mitarbeiter_uid != null) - { - return true; - } - } - - return false; - } - else - { - return error($this->db->error()); - } + return $this->execQuery($sql, array($person_id)); } /** diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 3a30bba1f..65812580e 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -25,7 +25,8 @@ class Recipient_model extends DB_Model ks.kontakt, p.nachname, p.vorname, - b.uid + b.uid, + mr.sent FROM public.tbl_msg_recipient mr INNER JOIN public.tbl_msg_message mm USING (message_id) INNER JOIN public.tbl_person p ON (mm.person_id = p.person_id) LEFT JOIN public.tbl_benutzer b ON (mr.person_id = b.person_id) diff --git a/application/views/system/messages/messageHTML.php b/application/views/system/messages/htmlRead.php similarity index 87% rename from application/views/system/messages/messageHTML.php rename to application/views/system/messages/htmlRead.php index 0ae6c3866..97751f96f 100644 --- a/application/views/system/messages/messageHTML.php +++ b/application/views/system/messages/htmlRead.php @@ -1,4 +1,4 @@ - load->view( 'templates/FHC-Header', array( @@ -10,7 +10,7 @@ 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageReply.css') ) ); - ?> +?>
@@ -24,7 +24,9 @@
+ subject; ?> +
@@ -33,7 +35,9 @@ From: @@ -41,7 +45,9 @@ Subject: @@ -49,7 +55,9 @@ Message:
+ vorname.' '.$sender->nachname; ?> +
+ subject; ?> +
+ body; ?> +
@@ -57,11 +65,15 @@ @@ -72,4 +84,5 @@
- load->view("templates/FHC-Footer"); ?> \ No newline at end of file + +load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/htmlWriteReply.php b/application/views/system/messages/htmlWriteReply.php new file mode 100644 index 000000000..fe8145613 --- /dev/null +++ b/application/views/system/messages/htmlWriteReply.php @@ -0,0 +1,73 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'MessageReply', + 'jquery' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'tinymce' => true, + 'sbadmintemplate' => true, + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'), + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/messageWriteReply.js') + ) + ); +?> + +
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+ + + +
+
+
+
+
+
+ +
+   +
+ +
+
+
+
+
+
+ + +
+
+
+
+
+ +
+
+ + + + + +
+
+
+
+ + +load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/messageForm.php b/application/views/system/messages/messageForm.php deleted file mode 100644 index d1436a492..000000000 --- a/application/views/system/messages/messageForm.php +++ /dev/null @@ -1,81 +0,0 @@ -
-
-
- -
-
- 1 && $i % 10 == 0) - { - echo '
'; - } - echo $receiver->Vorname." ".$receiver->Nachname."; "; - } - ?> -
-
-
-
-
-
- -
  - subject; - } - ?> -
- -
-
-
-
-
-
- -

On '.date_format(date_create($message->sent), 'd.m.Y H:i').' '.$receivers[0]->Vorname.' '.$receivers[0]->Nachname.' wrote:'.'
'; - $body .= '
'; - $body .= $message->body.'
'; - } - ?> - -
- -
-
- - -
-
- -
-
-
-
- -
-
\ No newline at end of file diff --git a/application/views/system/messages/messageReplySent.php b/application/views/system/messages/messageReplySent.php deleted file mode 100644 index 88fc945b0..000000000 --- a/application/views/system/messages/messageReplySent.php +++ /dev/null @@ -1,103 +0,0 @@ -load->view( - 'templates/FHC-Header', - array( - 'title' => 'MessageSent', - 'jquery' => true, - 'bootstrap' => true, - 'fontawesome' => true, - 'sbadmintemplate' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageSent.css') - ) - ); -?> - - -
-
-
- -
- -
- -
- -
- -
- -
- -
-
-
-
-
-
- Message sent successfully! -
-
- Nachricht erfolgreich versandt! -
-
-
-
-
-
- - Thank you for your message. - - - We will get back to you shortly. - -
-
- - Herzlichen Dank für Ihre Nachricht. - - - Wir werden uns schnellstmöglich um Ihr Anliegen kümmern. - -
-
- -
- -
-
- You can safely close this window. -
-
- Sie können dieses Fenster schließen. -
-
-
-
-
- Your InfoCenter@FHTW Team -
-
- Ihr InfoCenter@FHTW Team -
-
-
-
-
-
-
-

- Fachhochschule Technikum Wien | University of Applied Sciences Technikum Wien -
Hoechstaedtplatz 6, 1200 Wien, AUSTRIA -
www.technikum-wien.at -

-
-
-
-
-
-
-
- - -load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/messageWriteReply.php b/application/views/system/messages/messageWriteReply.php deleted file mode 100644 index 344871b2d..000000000 --- a/application/views/system/messages/messageWriteReply.php +++ /dev/null @@ -1,63 +0,0 @@ -load->view( - 'templates/FHC-Header', - array( - 'title' => 'MessageReply', - 'jquery' => true, - 'bootstrap' => true, - 'fontawesome' => true, - 'tinymce' => true, - 'sbadmintemplate' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'), - 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/messageWriteReply.js') - ) -); -?> - - -
-
-
-
-
- -
-
-
- load->view('system/messages/messageForm.php'); - - for ($i = 0; $i < count($receivers); $i++) - { - $receiver = $receivers[$i]; - $receiverid = $receiver->person_id; - $fieldname = 'persons[]'; - - echo ''."\n"; - } - ?> - - - - - - - -
-
-
-
- - -load->view("templates/FHC-Footer"); ?> From b364cfae06348790fec1e7b84fd3ba8917e0b65a Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 19 Jun 2019 15:29:17 +0200 Subject: [PATCH 008/138] - Moved controllers FASMessages and Messages to system/messages/ - Adapted code to use the new path --- application/controllers/system/{ => messages}/FASMessages.php | 0 application/controllers/system/{ => messages}/Messages.php | 0 application/models/CL/Messages_model.php | 2 +- application/views/system/infocenter/stammdaten.php | 2 +- application/views/system/messages/htmlWriteTemplate.php | 2 +- content/fasoverlay.js.php | 2 +- content/messages.js.php | 4 ++-- public/js/infocenter/infocenterDetails.js | 2 +- public/js/infocenter/infocenterPersonDataset.js | 2 +- public/js/infocenter/messageList.js | 2 +- public/js/messaging/messageWrite.js | 4 ++-- 11 files changed, 11 insertions(+), 11 deletions(-) rename application/controllers/system/{ => messages}/FASMessages.php (100%) rename application/controllers/system/{ => messages}/Messages.php (100%) diff --git a/application/controllers/system/FASMessages.php b/application/controllers/system/messages/FASMessages.php similarity index 100% rename from application/controllers/system/FASMessages.php rename to application/controllers/system/messages/FASMessages.php diff --git a/application/controllers/system/Messages.php b/application/controllers/system/messages/Messages.php similarity index 100% rename from application/controllers/system/Messages.php rename to application/controllers/system/messages/Messages.php diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 33bc90e80..302e51340 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -283,7 +283,7 @@ class Messages_model extends CI_Model } //------------------------------------------------------------------------------------------------------------------ - // Public methods called by controller system/Messages + // Public methods called by controller system/messages/Messages /** * Returns an object that represent a template store in database diff --git a/application/views/system/infocenter/stammdaten.php b/application/views/system/infocenter/stammdaten.php index ebd812c6a..a80439bfe 100644 --- a/application/views/system/infocenter/stammdaten.php +++ b/application/views/system/infocenter/stammdaten.php @@ -113,7 +113,7 @@ - +
diff --git a/content/fasoverlay.js.php b/content/fasoverlay.js.php index 3089b6032..2fafb5ea8 100644 --- a/content/fasoverlay.js.php +++ b/content/fasoverlay.js.php @@ -1250,7 +1250,7 @@ function MessageNew() { var prestudentIdArray = getMultipleTreeCellText(tree, 'student-treecol-prestudent_id'); - var action = 'index.ci.php/system/FASMessages/writeTemplate/' + person_id; ?>; + var action = 'index.ci.php/system/messages/FASMessages/writeTemplate/' + person_id; ?>; openWindowPostArray(action, 'prestudent_id', prestudentIdArray); } diff --git a/content/messages.js.php b/content/messages.js.php index 4094cddb8..3e72748ec 100644 --- a/content/messages.js.php +++ b/content/messages.js.php @@ -104,7 +104,7 @@ function MessagesNewMessage() { var prestudentIdArray = getMultipleTreeCellText(tree, 'student-treecol-prestudent_id'); - var action = 'index.ci.php/system/FASMessages/writeTemplate'; + var action = 'index.ci.php/system/messages/FASMessages/writeTemplate'; openWindowPostArray(action, 'prestudent_id', prestudentIdArray); } @@ -128,7 +128,7 @@ function MessagesSendAnswer() var RecipientID = getTreeCellText(messagesTree, 'messages-tree-recipient_id', messagesTree.currentIndex); var prestudentIdArray = new Array(getTreeCellText(studentsTree, 'student-treecol-prestudent_id', studentsTree.currentIndex)); - var action = 'index.ci.php/system/FASMessages/writeReplyTemplate/' + MessageId + '/' + RecipientID; + var action = 'index.ci.php/system/messages/FASMessages/writeReplyTemplate/' + MessageId + '/' + RecipientID; openWindowPostArray(action, 'prestudent_id', prestudentIdArray); } diff --git a/public/js/infocenter/infocenterDetails.js b/public/js/infocenter/infocenterDetails.js index 3edb9d42d..60da695d2 100644 --- a/public/js/infocenter/infocenterDetails.js +++ b/public/js/infocenter/infocenterDetails.js @@ -629,7 +629,7 @@ var InfocenterDetails = { sendFreigabeMessage: function(prestudentid, vorlage_kurzbz, msgvars) { FHC_AjaxClient.ajaxCallPost( - 'system/Messages/sendExplicitTemplateJson', + 'system/messages/Messages/sendExplicitTemplateJson', { "prestudents": prestudentid, "vorlage_kurzbz": vorlage_kurzbz, diff --git a/public/js/infocenter/infocenterPersonDataset.js b/public/js/infocenter/infocenterPersonDataset.js index c5ea99dfc..07163ccee 100644 --- a/public/js/infocenter/infocenterPersonDataset.js +++ b/public/js/infocenter/infocenterPersonDataset.js @@ -26,7 +26,7 @@ var InfocenterPersonDataset = { appendTableActionsHtml: function() { var currurl = window.location.href; - var url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/system/Messages/writeTemplate"; + var url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/system/messages/Messages/writeTemplate"; var formHtml = ''; $("#datasetActionsTop").before(formHtml); diff --git a/public/js/infocenter/messageList.js b/public/js/infocenter/messageList.js index 85d5ad603..6146c7639 100644 --- a/public/js/infocenter/messageList.js +++ b/public/js/infocenter/messageList.js @@ -54,7 +54,7 @@ var MessageList = { var recid = id.substr(id.indexOf('_') + 1); FHC_AjaxClient.ajaxCallGet( - 'system/Messages/getMessageFromIds', + 'system/messages/Messages/getMessageFromIds', { "msg_id": msgid, "receiver_id": recid diff --git a/public/js/messaging/messageWrite.js b/public/js/messaging/messageWrite.js index c496b269d..4146b7008 100644 --- a/public/js/messaging/messageWrite.js +++ b/public/js/messaging/messageWrite.js @@ -20,7 +20,7 @@ function tinymcePreviewSetContent() function parseMessageText(receiver_id, text) { FHC_AjaxClient.ajaxCallGet( - "system/Messages/parseMessageText", + "system/messages/Messages/parseMessageText", { person_id: receiver_id, text: text @@ -111,7 +111,7 @@ $(document).ready(function () if (vorlage_kurzbz != '') { FHC_AjaxClient.ajaxCallGet( - "system/Messages/getVorlage", + "system/messages/Messages/getVorlage", { vorlage_kurzbz: vorlage_kurzbz }, From 1cb9c28f7dfecb35559635188372df7234824879 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 19 Jun 2019 17:53:51 +0200 Subject: [PATCH 009/138] - Added new controller system/messages/MessageClient used to read and write messages using a new GUI based on ajax and tabulator - system/messages/MessageClient currently has only two methods: read and listMessages - Added new view system/messages/ajaxRead.php used for the GUI to read messages - Added new parameters to templates/FHC-Header: tabulator and momentjs - Added new packages to composer: tabulator and momentjs --- .../system/messages/MessageClient.php | 39 +++++++++++++++++++ .../controllers/system/messages/Messages.php | 6 +-- .../views/system/messages/ajaxRead.php | 20 ++++++++++ .../views/system/messages/htmlRead.php | 2 +- .../views/system/messages/htmlWriteReply.php | 2 +- .../system/messages/htmlWriteTemplate.php | 2 +- application/views/templates/FHC-Header.php | 30 ++++++++------ composer.json | 12 ++++++ composer.lock | 25 ++++++++---- 9 files changed, 114 insertions(+), 24 deletions(-) create mode 100644 application/controllers/system/messages/MessageClient.php create mode 100644 application/views/system/messages/ajaxRead.php diff --git a/application/controllers/system/messages/MessageClient.php b/application/controllers/system/messages/MessageClient.php new file mode 100644 index 000000000..3000e6b91 --- /dev/null +++ b/application/controllers/system/messages/MessageClient.php @@ -0,0 +1,39 @@ + array('basis/message:r'), + 'listMessages' => array('basis/message:r') + ) + ); + + // Loads model CLMessagesModel which contains the GUI logic + $this->load->model('CL/Messages_model', 'CLMessagesModel'); + } + + /** + * Starts the GUI used to read all the personal messages + */ + public function read() + { + // Loads the view to read messages + $this->load->view('system/messages/ajaxRead'); + } + + /** + * Returns JSON that that contains all the received messages by the currently logged user + * This JSON structure is nested data used by tabulator + */ + public function listMessages() + { + $jsonNestedData = $this->CLMessagesModel->prepareAjaxRead(); + + $this->outputJson($jsonNestedData); + } +} diff --git a/application/controllers/system/messages/Messages.php b/application/controllers/system/messages/Messages.php index 20fed38ad..869caec39 100644 --- a/application/controllers/system/messages/Messages.php +++ b/application/controllers/system/messages/Messages.php @@ -30,7 +30,7 @@ class Messages extends Auth_Controller } // ----------------------------------------------------------------------------------------------------------------- - // Public methods - HTML output + // Methods with HTML output /** * Initialize all the parameters used by view system/messages/htmlWriteTemplate @@ -71,7 +71,7 @@ class Messages extends Auth_Controller } // ----------------------------------------------------------------------------------------------------------------- - // Public methods - JSON output - called by this controller and FASMessages (view system/messages/htmlWriteTemplate) + // Methods with JSON output called by this controller and FASMessages (view system/messages/htmlWriteTemplate) /** * Returns an object that represent a template store in database @@ -98,7 +98,7 @@ class Messages extends Auth_Controller } // ----------------------------------------------------------------------------------------------------------------- - // Public methods - JSON output - called by infocenter + // Methods with JSON output called by infocenter /** * Outputs message data for a message (identified my msg id and receiver id) in JSON format diff --git a/application/views/system/messages/ajaxRead.php b/application/views/system/messages/ajaxRead.php new file mode 100644 index 000000000..97f16ce3b --- /dev/null +++ b/application/views/system/messages/ajaxRead.php @@ -0,0 +1,20 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Read personal messages', + 'jquery' => true, + 'bootstrap' => true, + 'momentjs' => true, + 'tabulator' => true, + 'ajaxlib' => true, + 'customJSs' => array('public/js/messaging/messageClient.js') + ) + ); +?> + +
+
+ + +load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/htmlRead.php b/application/views/system/messages/htmlRead.php index 97751f96f..01a5421ac 100644 --- a/application/views/system/messages/htmlRead.php +++ b/application/views/system/messages/htmlRead.php @@ -2,7 +2,7 @@ $this->load->view( 'templates/FHC-Header', array( - 'title' => 'MessageSent', + 'title' => 'Read a message', 'jquery' => true, 'bootstrap' => true, 'fontawesome' => true, diff --git a/application/views/system/messages/htmlWriteReply.php b/application/views/system/messages/htmlWriteReply.php index fe8145613..b9932148b 100644 --- a/application/views/system/messages/htmlWriteReply.php +++ b/application/views/system/messages/htmlWriteReply.php @@ -2,7 +2,7 @@ $this->load->view( 'templates/FHC-Header', array( - 'title' => 'MessageReply', + 'title' => 'Reply to a message', 'jquery' => true, 'bootstrap' => true, 'fontawesome' => true, diff --git a/application/views/system/messages/htmlWriteTemplate.php b/application/views/system/messages/htmlWriteTemplate.php index f46138e28..7132cfb36 100644 --- a/application/views/system/messages/htmlWriteTemplate.php +++ b/application/views/system/messages/htmlWriteTemplate.php @@ -2,7 +2,7 @@ $this->load->view( 'templates/FHC-Header', array( - 'title' => 'Write a message', + 'title' => 'Write a new message or reply using templates', 'jquery' => true, 'jqueryui' => true, 'bootstrap' => true, diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index 6b9afd6b9..7b75e2ad7 100644 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -25,10 +25,12 @@ $jqueryui = isset($jqueryui) ? $jqueryui : false; $jquerycheckboxes = isset($jquerycheckboxes) ? $jquerycheckboxes : false; $jquerytreetable = isset($jquerytreetable) ? $jquerytreetable : false; + $momentjs = isset($momentjs) ? $momentjs : false; $navigationwidget = isset($navigationwidget) ? $navigationwidget : false; $pivotui = isset($pivotui) ? $pivotui : false; $sbadmintemplate = isset($sbadmintemplate) ? $sbadmintemplate : false; $tablesorter = isset($tablesorter) ? $tablesorter : false; + $tabulator = isset($tabulator) ? $tabulator : false; $tinymce = isset($tinymce) ? $tinymce : false; $widgets = isset($widgets) ? $widgets : false; ?> @@ -61,10 +63,7 @@ if ($fontawesome === true) generateCSSsInclude('vendor/components/font-awesome/css/font-awesome.min.css'); // PivotUI CSS - if ($pivotui === true) - { - generateCSSsInclude('vendor/nicolaskruchten/pivottable/dist/pivot.min.css'); - } + if ($pivotui === true) generateCSSsInclude('vendor/nicolaskruchten/pivottable/dist/pivot.min.css'); // SB Admin 2 template CSS if ($sbadmintemplate === true) @@ -80,6 +79,9 @@ generateCSSsInclude('vendor/mottie/tablesorter/dist/css/jquery.tablesorter.pager.min.css'); } + // Tabulator CSS + if ($tabulator === true) generateCSSsInclude('vendor/olifolkerd/tabulator/dist/css/bootstrap/tabulator_bootstrap.min.css'); + // -------------------------------------------------------------------------------------------------------- // From public folder @@ -101,6 +103,7 @@ // Eventually required CSS generateCSSsInclude($customCSSs); // Eventually required CSS + // -------------------------------------------------------------------------------------------------------- // Javascripts @@ -126,10 +129,7 @@ } // jQuery checkboxes - if ($jquerycheckboxes === true) - { - generateJSsInclude('vendor/rmariuzzo/jquery-checkboxes/dist/jquery.checkboxes-1.0.7.min.js'); - } + if ($jquerycheckboxes === true) generateJSsInclude('vendor/rmariuzzo/jquery-checkboxes/dist/jquery.checkboxes-1.0.7.min.js'); // Bootstrap JS if ($bootstrap === true) generateJSsInclude('vendor/twbs/bootstrap/dist/js/bootstrap.min.js'); @@ -138,12 +138,17 @@ // NOTE: keep it after jQuery includes if ($jquerytreetable === true) generateJSsInclude('vendor/ludo/jquery-treetable/jquery.treetable.js'); - // PivotUI CSS - if ($pivotui === true) + // MomentJS + if ($momentjs === true) { - generateJSsInclude('vendor/nicolaskruchten/pivottable/dist/pivot.min.js'); + generateJSsInclude('vendor/moment/momentjs/min/moment.min.js'); + generateJSsInclude('vendor/moment/momentjs/locale/de-at.js'); + generateJSsInclude('vendor/moment/momentjs/locale/en-ie.js'); } + // PivotUI JS + if ($pivotui === true) generateJSsInclude('vendor/nicolaskruchten/pivottable/dist/pivot.min.js'); + // Table sorter JS if ($tablesorter === true) { @@ -152,6 +157,9 @@ generateJSsInclude('vendor/mottie/tablesorter/dist/js/extras/jquery.tablesorter.pager.min.js'); } + // Tabulator JS + if ($tabulator === true) generateJSsInclude('vendor/olifolkerd/tabulator/dist/js/tabulator.min.js'); + // Tinymce JS if ($tinymce === true) generateJSsInclude('vendor/tinymce/tinymce/tinymce.min.js'); diff --git a/composer.json b/composer.json index c6816e075..5003468c2 100644 --- a/composer.json +++ b/composer.json @@ -162,6 +162,17 @@ } } }, + { + "type": "package", + "package": { + "name": "moment/momentjs", + "version": "2.24.0", + "dist": { + "url": "https://github.com/moment/moment/archive/2.24.0.zip", + "type": "zip" + } + } + }, { "type": "package", "package": { @@ -263,6 +274,7 @@ "ludo/jquery-treetable": "^3.2", + "moment/momentjs": "2.24.0", "michelf/php-markdown": "1.5.0", "ml/json-ld": "1.*", "mottie/tablesorter": "^2.29", diff --git a/composer.lock b/composer.lock index f328832e6..85e506cc4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "df6059a4bee974ecf5447aad8a8b1e15", - "content-hash": "2111c73853dbc47938c3f31dbc349883", + "hash": "e3de1eee238160400fb63f68735b4144", + "content-hash": "5b71e8a3c356d52e43d788eb6f018151", "packages": [ { "name": "BlackrockDigital/startbootstrap-sb-admin-2", @@ -1095,6 +1095,17 @@ ], "time": "2018-11-18 20:26:18" }, + { + "name": "moment/momentjs", + "version": "2.24.0", + "dist": { + "type": "zip", + "url": "https://github.com/moment/moment/archive/2.24.0.zip", + "reference": null, + "shasum": null + }, + "type": "library" + }, { "name": "mottie/tablesorter", "version": "v2.31.1", @@ -2191,16 +2202,16 @@ }, { "name": "twig/twig", - "version": "v1.42.1", + "version": "v1.42.2", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "671347603760a88b1e7288aaa9378f33687d7edf" + "reference": "21707d6ebd05476854805e4f91b836531941bcd4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/671347603760a88b1e7288aaa9378f33687d7edf", - "reference": "671347603760a88b1e7288aaa9378f33687d7edf", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/21707d6ebd05476854805e4f91b836531941bcd4", + "reference": "21707d6ebd05476854805e4f91b836531941bcd4", "shasum": "" }, "require": { @@ -2253,7 +2264,7 @@ "keywords": [ "templating" ], - "time": "2019-06-04 11:31:08" + "time": "2019-06-18 15:35:16" }, { "name": "zetacomponents/base", From 27ccd086ac18e59513dd91cd713a56203d3ffd5d Mon Sep 17 00:00:00 2001 From: Paolo Date: Mon, 24 Jun 2019 17:32:31 +0200 Subject: [PATCH 010/138] - Added new functions getAuthFirstname and getAuthSurname to helper hlp_authentication_helper - Added methods getReceivedMessages and getSentMessages to model system/Recipient_model.php - Added jqueryui and dialoglib to view system/messages/ajaxRead - Added method prepareAjaxRead to model CL/Messages_model - Removed private method _getAuthUser from model CL/Messages_model - Adapted code in model CL/Messages_model to use functions isLogged and getAuthPersonId --- .../helpers/hlp_authentication_helper.php | 29 +++++- application/models/CL/Messages_model.php | 95 +++++++++++++------ application/models/system/Recipient_model.php | 59 ++++++++++++ .../views/system/messages/ajaxRead.php | 2 + public/js/messaging/messageClient.js | 53 +++++++++++ 5 files changed, 210 insertions(+), 28 deletions(-) create mode 100644 public/js/messaging/messageClient.js diff --git a/application/helpers/hlp_authentication_helper.php b/application/helpers/hlp_authentication_helper.php index 740823ff9..459c7fb80 100644 --- a/application/helpers/hlp_authentication_helper.php +++ b/application/helpers/hlp_authentication_helper.php @@ -20,7 +20,6 @@ function getAuthPersonId() return isLogged() ? ($ci->authlib->getAuthObj())->{AuthLib::AO_PERSON_ID} : null; } - /** * If the user is NOT logged then a null value is returned. * If the user is alredy logged, then it is possible to access to the authentication object @@ -34,3 +33,31 @@ function getAuthUID() return isLogged() ? ($ci->authlib->getAuthObj())->{AuthLib::AO_USERNAME} : null; } + +/** + * If the user is NOT logged then a null value is returned. + * If the user is alredy logged, then it is possible to access to the authentication object + * that contains the firstname of the logged user + * NOTE: if the user is logged with a "foreign" method (ex. Bewerbungstool), + * then it is possible that the firstname is null! + */ +function getAuthFirstname() +{ + $ci =& get_instance(); // get CI instance + + return isLogged() ? ($ci->authlib->getAuthObj())->{AuthLib::AO_NAME} : null; +} + +/** + * If the user is NOT logged then a null value is returned. + * If the user is alredy logged, then it is possible to access to the authentication object + * that contains the surname of the logged user + * NOTE: if the user is logged with a "foreign" method (ex. Bewerbungstool), + * then it is possible that the surname is null! + */ +function getAuthSurname() +{ + $ci =& get_instance(); // get CI instance + + return isLogged() ? ($ci->authlib->getAuthObj())->{AuthLib::AO_SURNAME} : null; +} diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 302e51340..21cba1d68 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -36,6 +36,67 @@ class Messages_model extends CI_Model //------------------------------------------------------------------------------------------------------------------ // Public methods + /** + * + */ + public function prepareAjaxRead() + { + $jsonNestedData = error('Something did not go as it should'); + + $loggedUserName = getAuthFirstname().' '.getAuthSurname(); + + if (isEmptyString($loggedUserName)) $loggedUserName = 'Me'; + + $receivedMessagesResult = $this->RecipientModel->getReceivedMessages(getAuthPersonId()); + if (isError($receivedMessagesResult)) return $receivedMessagesResult; + + $sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId()); + if (isError($sentMessagesResult)) return $sentMessagesResult; + + if (hasData($receivedMessagesResult)) + { + $jsonArray = array(); + + foreach (getData($receivedMessagesResult) as $receivedMessage) + { + $jsonRecord = new stdClass(); + $jsonRecord->subject = $receivedMessage->subject; + $jsonRecord->from = $receivedMessage->vorname.' '.$receivedMessage->nachname; + $sentDate = new DateTime($receivedMessage->sent); + $jsonRecord->sent = $sentDate->format('d/m/Y H:i:s'); + $jsonRecord->status = $receivedMessage->status; + + if (hasData($sentMessagesResult)) + { + $jsonChildrenArray = array(); + + foreach (getData($sentMessagesResult) as $sentMessage) + { + if ($receivedMessage->relationmessage_id == $sentMessage->message_id) + { + $jsonChildrenRecord = new stdClass(); + $jsonChildrenRecord->subject = $sentMessage->subject; + $jsonChildrenRecord->from = $loggedUserName; + $sentDate = new DateTime($sentMessage->sent); + $jsonChildrenRecord->sent = $sentDate->format('d/m/Y H:i:s'); + $jsonChildrenRecord->status = $sentMessage->status; + + $jsonChildrenArray[] = $jsonChildrenRecord; + } + } + + if (!isEmptyArray($jsonChildrenArray)) $jsonRecord->_children = $jsonChildrenArray; + } + + $jsonArray[] = $jsonRecord; + } + + $jsonNestedData = success(json_encode($jsonArray)); + } + + return $jsonNestedData; + } + /** * Prepares data for the view system/messages/htmlRead using a token that identifies a single message */ @@ -148,11 +209,8 @@ class Messages_model extends CI_Model public function sendImplicitTemplate($persons, $subject, $body, $relationmessage_id = null) { // Retrieves the sender id - $authUser = $this->_getAuthUser(); - if (isError($authUser)) show_error(getData($authUser)); - if (!hasData($authUser)) show_error('The current logged user person_id is not defined'); - - $sender_id = getData($authUser)[0]->person_id; + $sender_id = getAuthPersonId(); + if (!is_numeric($sender_id)) show_error('The current logged user person_id is not defined'); // Retrieves message vars data for the given user/s $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($persons); @@ -194,11 +252,8 @@ class Messages_model extends CI_Model public function sendExplicitTemplate($prestudents, $oe_kurzbz, $vorlage_kurzbz, $msgVars) { // Retrieves the sender id - $authUser = $this->_getAuthUser(); - if (isError($authUser)) show_error(getData($authUser)); - if (!hasData($authUser)) show_error('The current logged user person_id is not defined'); - - $sender_id = getData($authUser)[0]->person_id; + $sender_id = getAuthPersonId(); + if (!is_numeric($sender_id)) show_error('The current logged user person_id is not defined'); // Retrieves message vars data for the given user/s $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents); @@ -356,17 +411,6 @@ class Messages_model extends CI_Model //------------------------------------------------------------------------------------------------------------------ // Private methods - /** - * Returns the current authenticated person object - */ - private function _getAuthUser() - { - $this->load->model('person/Person_model', 'PersonModel'); - $authUser = $this->PersonModel->getByUid(getAuthUID()); - - return $authUser; - } - /** * Replaces data array keys to a lowercase string with underscores instead of spaces */ @@ -407,7 +451,7 @@ class Messages_model extends CI_Model { // In case the message is accessed via ViewMessage controller -> no authentication // If no authentication is performed then use a hard coded uid - $loggedUserUID = function_exists('getAuthUID') ? getAuthUID() : self::NO_AUTH_UID; + $loggedUserUID = isLogged() ? getAuthUID() : self::NO_AUTH_UID; return $this->personloglib->log( $receiver_id, @@ -508,11 +552,8 @@ class Messages_model extends CI_Model // --------------------------------------------------------------------------------------- // Retrieves the sender id - $authUser = $this->_getAuthUser(); - if (isError($authUser)) show_error(getData($authUser)); - if (!hasData($authUser)) show_error('The current logged user person_id is not defined'); - - $sender_id = getData($authUser)[0]->person_id; + $sender_id = getAuthPersonId(); + if (!is_numeric($sender_id)) show_error('The current logged user person_id is not defined'); // --------------------------------------------------------------------------------------- // Organisation units and a boolean (true if the sender is administrator) are used to get the templates diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 65812580e..8d1162de5 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -299,4 +299,63 @@ class Recipient_model extends DB_Model return $this->execQuery($sql, $parametersArray); } + + /** + * + */ + public function getReceivedMessages($person_id) + { + $sql = 'SELECT mr.message_id, + mm.relationmessage_id, + mm.subject, + mm.body, + mr.sent, + p.vorname, + p.nachname, + MAX(ms.status) AS status + FROM public.tbl_msg_recipient mr + JOIN public.tbl_msg_message mm ON (mm.message_id = mr.message_id) + JOIN public.tbl_msg_status ms ON (ms.message_id = mr.message_id AND ms.person_id = mr.person_id) + JOIN public.tbl_person p ON (p.person_id = mm.person_id) + WHERE mr.person_id = ? + AND mr.sent IS NOT NULL + AND mr.sentinfo IS NULL + GROUP BY mr.message_id, + mm.relationmessage_id, + mm.subject, + mm.body, + mr.sent, + p.vorname, + p.nachname + ORDER BY mr.sent DESC'; + + return $this->execQuery($sql, array($person_id)); + } + + /** + * + */ + public function getSentMessages($person_id) + { + $sql = 'SELECT mm.message_id, + mm.relationmessage_id, + mm.subject, + mm.body, + mr.sent, + MAX(ms.status) AS status + FROM public.tbl_msg_message mm + JOIN public.tbl_msg_recipient mr ON (mr.message_id = mm.message_id) + JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND mr.person_id = mr.person_id) + WHERE mm.person_id = ? + AND mr.sent IS NOT NULL + AND mr.sentinfo IS NULL + GROUP BY mm.message_id, + mm.relationmessage_id, + mm.subject, + mm.body, + mr.sent + ORDER BY mr.sent DESC'; + + return $this->execQuery($sql, array($person_id)); + } } diff --git a/application/views/system/messages/ajaxRead.php b/application/views/system/messages/ajaxRead.php index 97f16ce3b..e3ff133f0 100644 --- a/application/views/system/messages/ajaxRead.php +++ b/application/views/system/messages/ajaxRead.php @@ -4,10 +4,12 @@ array( 'title' => 'Read personal messages', 'jquery' => true, + 'jqueryui' => true, 'bootstrap' => true, 'momentjs' => true, 'tabulator' => true, 'ajaxlib' => true, + 'dialoglib' => true, 'customJSs' => array('public/js/messaging/messageClient.js') ) ); diff --git a/public/js/messaging/messageClient.js b/public/js/messaging/messageClient.js new file mode 100644 index 000000000..850777ea9 --- /dev/null +++ b/public/js/messaging/messageClient.js @@ -0,0 +1,53 @@ +/** + * + */ +$(document).ready(function () { + + FHC_AjaxClient.ajaxCallGet( + FHC_JS_DATA_STORAGE_OBJECT.called_path + '/listMessages', + null, + { + successCallback: function(data, textStatus, jqXHR) { + + if (FHC_AjaxClient.hasData(data)) + { + try + { + var jsonMessageLst = JSON.parse(FHC_AjaxClient.getData(data)); + + console.log(jsonMessageLst); + + var tableMessageLst = new Tabulator("#lstMessagesPanel", { + height: "400px", + data: jsonMessageLst, + dataTree: true, + dataTreeStartExpanded: true, + dataTreeElementColumn: "subject", + columns: [ + {title: "Subject", field: "subject", width: 700, responsive: 0}, + {title: "From", field: "from", width: 400}, + {title: "Date", field: "sent", sorter: "datetime", width: 150} + ], + rowClick: function(e, row) { + // TODO + } + }); + } + catch (syntaxError) + { + FHC_DialogLib.alertError("An error occurred while retrieving message, contact the website administrator"); + } + } + else + { + FHC_DialogLib.alertWarning("No message currently available"); + } + }, + errorCallback: function() { + + }, + veilTimeout: 300 + } + ); + +}); From 34dc82766acd3f28fb0e5cd77f6e5c306d7889cf Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 28 Jun 2019 19:01:25 +0200 Subject: [PATCH 011/138] - Renamed public/js/messaging/messageClient.js to public/js/messaging/read.js - Added new JS public/js/messaging/write.js used in view application/views/system/messages/ajaxWrite.php - Added new public method write, listReceivedMessages, listSentMessages and sendMessageToOU to controller system/messages/MessageClient.php - Removed private method _getReceiversByOekurzbz from MessageLib - Fixed method sendMessageOU of MessageLib - Added new public method prepareAjaxWrite to model CL/Messages_model - Fixed method prepareAjaxReadReceived of model CL/Messages_model - Added new public method prepareAjaxReadSent to model CL/Messages_model - Changed method CL/Messages_model->_personLog interface - Added new public method getOrganisationunitsByPersonId to crm/Prestudent_model - Added new public method getReceivedMessages to model system/Recipient_model - Changed getReceivedMessages method of model system/Recipient_model - Changed view system/messages/ajaxRead.php - Added new view system/messages/ajaxWrite.php --- .../system/messages/MessageClient.php | 43 +++++- application/libraries/MessageLib.php | 22 +-- application/models/CL/Messages_model.php | 131 ++++++++++++++---- application/models/crm/Prestudent_model.php | 16 +++ application/models/system/Recipient_model.php | 40 +++++- .../views/system/messages/ajaxRead.php | 15 +- .../views/system/messages/ajaxWrite.php | 71 ++++++++++ public/js/messaging/messageClient.js | 53 ------- public/js/messaging/messageWrite.js | 10 +- public/js/messaging/read.js | 116 ++++++++++++++++ public/js/messaging/write.js | 52 +++++++ 11 files changed, 449 insertions(+), 120 deletions(-) create mode 100644 application/views/system/messages/ajaxWrite.php delete mode 100644 public/js/messaging/messageClient.js create mode 100644 public/js/messaging/read.js create mode 100644 public/js/messaging/write.js diff --git a/application/controllers/system/messages/MessageClient.php b/application/controllers/system/messages/MessageClient.php index 3000e6b91..1062202c1 100644 --- a/application/controllers/system/messages/MessageClient.php +++ b/application/controllers/system/messages/MessageClient.php @@ -8,8 +8,11 @@ class MessageClient extends Auth_Controller { parent::__construct( array( - 'read' => array('basis/message:r'), - 'listMessages' => array('basis/message:r') + 'read' => array('basis/person:r'), + 'write' => array('basis/person:r'), + 'listReceivedMessages' => array('basis/person:r'), + 'listSentMessages' => array('basis/person:r'), + 'sendMessageToOU' => array('basis/person:r') ) ); @@ -27,13 +30,39 @@ class MessageClient extends Auth_Controller } /** - * Returns JSON that that contains all the received messages by the currently logged user - * This JSON structure is nested data used by tabulator + * Starts the GUI used to write a personal message to an organisation unit */ - public function listMessages() + public function write() { - $jsonNestedData = $this->CLMessagesModel->prepareAjaxRead(); + // Loads the view to write a message + $this->load->view('system/messages/ajaxWrite', $this->CLMessagesModel->prepareAjaxWrite()); + } - $this->outputJson($jsonNestedData); + /** + * Returns JSON that that contains all the received messages by the currently logged user + */ + public function listReceivedMessages() + { + $this->outputJson($this->CLMessagesModel->prepareAjaxReadReceived()); + } + + /** + * Returns JSON that that contains all the sent messages by the currently logged user + */ + public function listSentMessages() + { + $this->outputJson($this->CLMessagesModel->prepareAjaxReadSent()); + } + + /** + * + */ + public function sendMessageToOU() + { + $receiverOU = $this->input->post('receiverOU'); + $subject = $this->input->post('subject'); + $body = $this->input->post('body'); + + $this->outputJson($this->CLMessagesModel->sendToOrganisationUnit($receiverOU, $subject, $body)); } } diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 206aeed87..18b958e14 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -128,7 +128,9 @@ class MessageLib // If the recipient is an organisation unit that would be possible to send the same message (same message id) // to the entire organisation unit (one to many functionality) // In this case the receiver id is a the one present in message configuration - $receivers = success(array($this->_ci->config->item(self::CFG_SYSTEM_PERSON_ID))); + $receiver = new stdClass(); + $receiver->person_id = $this->_ci->config->item(self::CFG_SYSTEM_PERSON_ID); + $receivers = success(array($receiver)); // Send the message and return the result return $this->_sendMessage($receivers, $receiversOU, $subject, $body, $sender_id, $senderOU, $relationmessage_id, $priority, $multiPartMime); @@ -373,24 +375,6 @@ class MessageLib } } - /** - * 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 - $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 = '.$this->_ci->db->escape($oe_kurzbz). - ' AND funktion_kurzbz = '.$this->_ci->db->escape($this->_ci->config->item(self::CFG_OU_RECEIVERS)). - ' AND (NOW() BETWEEN COALESCE(datum_von, NOW()) AND COALESCE(datum_bis, NOW()))' - ); - return $receivers; - } - /** * Save a new message in DB */ diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 21cba1d68..5810487a9 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -28,9 +28,10 @@ class Messages_model extends CI_Model // Loads model MessageToken_model $this->load->model('system/MessageToken_model', 'MessageTokenModel'); - // Loads model Benutzerrolle_model $this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); + // Loads model Prestudent_model + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); } //------------------------------------------------------------------------------------------------------------------ @@ -39,20 +40,42 @@ class Messages_model extends CI_Model /** * */ - public function prepareAjaxRead() + public function prepareAjaxWrite() { - $jsonNestedData = error('Something did not go as it should'); + $ouResult = $this->PrestudentModel->getOrganisationunitsByPersonId(getAuthPersonId()); + + if (isError($ouResult)) show_error('An error occurred while loading this page, please contact the site administrator'); + + $ouOptions = ''; + + if (hasData($ouResult)) + { + foreach (getData($ouResult) as $ou) + { + $ouOptions .= sprintf("\n".'', $ou->oe_kurzbz, $ou->bezeichnung); + } + } + + return array('organisationUnitOptions' => $ouOptions); + } + + /** + * + */ + public function prepareAjaxReadReceived() + { + $jsonResult = error('Something did not go as it should'); $loggedUserName = getAuthFirstname().' '.getAuthSurname(); if (isEmptyString($loggedUserName)) $loggedUserName = 'Me'; - $receivedMessagesResult = $this->RecipientModel->getReceivedMessages(getAuthPersonId()); + $receivedMessagesResult = $this->RecipientModel->getReceivedMessages( + getAuthPersonId(), + $this->config->item(MessageLib::CFG_OU_RECEIVERS) + ); if (isError($receivedMessagesResult)) return $receivedMessagesResult; - $sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId()); - if (isError($sentMessagesResult)) return $sentMessagesResult; - if (hasData($receivedMessagesResult)) { $jsonArray = array(); @@ -60,41 +83,59 @@ class Messages_model extends CI_Model foreach (getData($receivedMessagesResult) as $receivedMessage) { $jsonRecord = new stdClass(); + $jsonRecord->message_id = $receivedMessage->message_id; $jsonRecord->subject = $receivedMessage->subject; + $jsonRecord->body = $receivedMessage->body; $jsonRecord->from = $receivedMessage->vorname.' '.$receivedMessage->nachname; $sentDate = new DateTime($receivedMessage->sent); $jsonRecord->sent = $sentDate->format('d/m/Y H:i:s'); $jsonRecord->status = $receivedMessage->status; - if (hasData($sentMessagesResult)) - { - $jsonChildrenArray = array(); + $jsonArray[] = $jsonRecord; + } - foreach (getData($sentMessagesResult) as $sentMessage) - { - if ($receivedMessage->relationmessage_id == $sentMessage->message_id) - { - $jsonChildrenRecord = new stdClass(); - $jsonChildrenRecord->subject = $sentMessage->subject; - $jsonChildrenRecord->from = $loggedUserName; - $sentDate = new DateTime($sentMessage->sent); - $jsonChildrenRecord->sent = $sentDate->format('d/m/Y H:i:s'); - $jsonChildrenRecord->status = $sentMessage->status; + $jsonResult = success(json_encode($jsonArray)); + } - $jsonChildrenArray[] = $jsonChildrenRecord; - } - } + return $jsonResult; + } - if (!isEmptyArray($jsonChildrenArray)) $jsonRecord->_children = $jsonChildrenArray; - } + /** + * + */ + public function prepareAjaxReadSent() + { + $jsonResult = error('Something did not go as it should'); + + $loggedUserName = getAuthFirstname().' '.getAuthSurname(); + + if (isEmptyString($loggedUserName)) $loggedUserName = 'Me'; + + $sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId()); + if (isError($sentMessagesResult)) return $sentMessagesResult; + + if (hasData($sentMessagesResult)) + { + $jsonArray = array(); + + foreach (getData($sentMessagesResult) as $sentMessage) + { + $jsonRecord = new stdClass(); + $jsonRecord->message_id = $sentMessage->message_id; + $jsonRecord->subject = $sentMessage->subject; + $jsonRecord->body = $sentMessage->body; + $jsonRecord->from = $sentMessage->vorname.' '.$sentMessage->nachname; + $sentDate = new DateTime($sentMessage->sent); + $jsonRecord->sent = $sentDate->format('d/m/Y H:i:s'); + $jsonRecord->status = $sentMessage->status; $jsonArray[] = $jsonRecord; } - $jsonNestedData = success(json_encode($jsonArray)); + $jsonResult = success(json_encode($jsonArray)); } - return $jsonNestedData; + return $jsonResult; } /** @@ -260,7 +301,6 @@ class Messages_model extends CI_Model if (isError($msgVarsData)) show_error(getData($msgVarsData)); if (!hasData($msgVarsData)) show_error('No recipients were given'); - $this->load->model('crm/Prestudent_model', 'PrestudentModel'); $prestudentsData = $this->PrestudentModel->getOrganisationunits($prestudents); // Adds the organisation unit to each prestudent @@ -337,6 +377,34 @@ class Messages_model extends CI_Model return success('Messages sent successfully'); } + /** + * Send a message to an organisation unit + */ + public function sendToOrganisationUnit($receiverOU, $subject, $body) + { + if (isEmptyString($receiverOU)) return error('Not a valid organisation unit'); + if (isEmptyString($subject)) return error('Subject is an empty string'); + if (isEmptyString($body)) return error('Body is an empty string'); + + $sender_id = getAuthPersonId(); + + $message = $this->messagelib->sendMessageOU( + $receiverOU, // receiverPersonId + $subject, // subject + $body, // body + $sender_id // sender_id + ); + + if (isError($message)) return $message; + if (!hasData($message)) return error('No messages were saved in database'); + + // Write log entry + $personLog = $this->_personLog($sender_id, $this->config->item(MessageLib::CFG_SYSTEM_PERSON_ID), getData($message)[0], $receiverOU); + if (isError($personLog)) return $personLog; + + return success('Messages sent successfully'); + } + //------------------------------------------------------------------------------------------------------------------ // Public methods called by controller system/messages/Messages @@ -447,18 +515,21 @@ class Messages_model extends CI_Model /** * Perform a person log after a message is sent */ - private function _personLog($sender_id, $receiver_id, $message_id) + private function _personLog($sender_id, $receiver_id, $message_id, $receiverOU = null) { // In case the message is accessed via ViewMessage controller -> no authentication // If no authentication is performed then use a hard coded uid $loggedUserUID = isLogged() ? getAuthUID() : self::NO_AUTH_UID; + $message = 'Message sent from person '.$sender_id.' to '.$receiver_id.', message id: '.$message_id; + if (!isEmptyString($receiverOU)) $message .= ', receiverOU: '.$receiverOU; + return $this->personloglib->log( $receiver_id, 'Action', array( 'name' => 'Message sent', - 'message' => 'Message sent from person '.$sender_id.' to '.$receiver_id.', message id: '.$message_id, + 'message' => $message, 'success' => 'true' ), 'kommunikation', diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index ffc6afb0e..b4c756e52 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -523,4 +523,20 @@ class Prestudent_model extends DB_Model } } } + + /** + * Get organisation units for all the prestudents of a person + */ + public function getOrganisationunitsByPersonId($person_id) + { + $query = 'SELECT o.oe_kurzbz, o.bezeichnung + FROM public.tbl_prestudent p + JOIN public.tbl_studiengang s USING(studiengang_kz) + JOIN public.tbl_organisationseinheit o USING(oe_kurzbz) + WHERE p.person_id = ? + GROUP BY o.oe_kurzbz, o.bezeichnung + ORDER BY o.bezeichnung'; + + return $this->execQuery($query, array($person_id)); + } } diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 8d1162de5..39961cdbf 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -303,13 +303,13 @@ class Recipient_model extends DB_Model /** * */ - public function getReceivedMessages($person_id) + public function getReceivedMessages($person_id, $functions) { $sql = 'SELECT mr.message_id, mm.relationmessage_id, mm.subject, mm.body, - mr.sent, + mr.sent AS sent, p.vorname, p.nachname, MAX(ms.status) AS status @@ -327,9 +327,34 @@ class Recipient_model extends DB_Model mr.sent, p.vorname, p.nachname - ORDER BY mr.sent DESC'; + UNION + SELECT mrou.message_id, + mm.relationmessage_id, + mm.subject, + mm.body, + mrou.sent AS sent, + p.vorname, + p.nachname, + MAX(ms.status) AS status + FROM public.tbl_person p + JOIN public.tbl_benutzer b ON (b.person_id = p.person_id) + JOIN (SELECT uid, oe_kurzbz FROM public.tbl_benutzerfunktion WHERE funktion_kurzbz IN ?) bf ON (bf.uid = b.uid) + JOIN public.tbl_msg_recipient mrou ON (mrou.oe_kurzbz = bf.oe_kurzbz) + JOIN public.tbl_msg_message mm ON (mm.message_id = mrou.message_id) + JOIN public.tbl_msg_status ms ON (ms.message_id = mrou.message_id AND ms.person_id = mrou.person_id) + WHERE p.person_id = ? + AND mrou.sent IS NOT NULL + AND mrou.sentinfo IS NULL + GROUP BY mrou.message_id, + mm.relationmessage_id, + mm.subject, + mm.body, + mrou.sent, + p.vorname, + p.nachname + ORDER BY sent DESC'; - return $this->execQuery($sql, array($person_id)); + return $this->execQuery($sql, array($person_id, $functions, $person_id)); } /** @@ -342,10 +367,13 @@ class Recipient_model extends DB_Model mm.subject, mm.body, mr.sent, + p.vorname, + p.nachname, MAX(ms.status) AS status FROM public.tbl_msg_message mm JOIN public.tbl_msg_recipient mr ON (mr.message_id = mm.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND mr.person_id = mr.person_id) + JOIN public.tbl_person p ON (p.person_id = mr.person_id) WHERE mm.person_id = ? AND mr.sent IS NOT NULL AND mr.sentinfo IS NULL @@ -353,7 +381,9 @@ class Recipient_model extends DB_Model mm.relationmessage_id, mm.subject, mm.body, - mr.sent + mr.sent, + p.vorname, + p.nachname ORDER BY mr.sent DESC'; return $this->execQuery($sql, array($person_id)); diff --git a/application/views/system/messages/ajaxRead.php b/application/views/system/messages/ajaxRead.php index e3ff133f0..b8d2ea4a6 100644 --- a/application/views/system/messages/ajaxRead.php +++ b/application/views/system/messages/ajaxRead.php @@ -6,15 +6,28 @@ 'jquery' => true, 'jqueryui' => true, 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, 'momentjs' => true, 'tabulator' => true, 'ajaxlib' => true, 'dialoglib' => true, - 'customJSs' => array('public/js/messaging/messageClient.js') + 'tinymce' => true, + 'customJSs' => array('public/js/messaging/read.js') ) ); ?> +
+
+ + +
+
diff --git a/application/views/system/messages/ajaxWrite.php b/application/views/system/messages/ajaxWrite.php new file mode 100644 index 000000000..a21a724b2 --- /dev/null +++ b/application/views/system/messages/ajaxWrite.php @@ -0,0 +1,71 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Write a new message', + 'jquery' => true, + 'jqueryui' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'tinymce' => true, + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'), + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/write.js') + ) + ); +?> + +
+
+
+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+   +
+ +
+
+
+
+
+
+ + +
+
+
+
+
+ +
+
+
+
+
+ + +load->view("templates/FHC-Footer"); ?> diff --git a/public/js/messaging/messageClient.js b/public/js/messaging/messageClient.js deleted file mode 100644 index 850777ea9..000000000 --- a/public/js/messaging/messageClient.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * - */ -$(document).ready(function () { - - FHC_AjaxClient.ajaxCallGet( - FHC_JS_DATA_STORAGE_OBJECT.called_path + '/listMessages', - null, - { - successCallback: function(data, textStatus, jqXHR) { - - if (FHC_AjaxClient.hasData(data)) - { - try - { - var jsonMessageLst = JSON.parse(FHC_AjaxClient.getData(data)); - - console.log(jsonMessageLst); - - var tableMessageLst = new Tabulator("#lstMessagesPanel", { - height: "400px", - data: jsonMessageLst, - dataTree: true, - dataTreeStartExpanded: true, - dataTreeElementColumn: "subject", - columns: [ - {title: "Subject", field: "subject", width: 700, responsive: 0}, - {title: "From", field: "from", width: 400}, - {title: "Date", field: "sent", sorter: "datetime", width: 150} - ], - rowClick: function(e, row) { - // TODO - } - }); - } - catch (syntaxError) - { - FHC_DialogLib.alertError("An error occurred while retrieving message, contact the website administrator"); - } - } - else - { - FHC_DialogLib.alertWarning("No message currently available"); - } - }, - errorCallback: function() { - - }, - veilTimeout: 300 - } - ); - -}); diff --git a/public/js/messaging/messageWrite.js b/public/js/messaging/messageWrite.js index 4146b7008..08a3b46a0 100644 --- a/public/js/messaging/messageWrite.js +++ b/public/js/messaging/messageWrite.js @@ -1,6 +1,6 @@ -/** - * JS used by view system/messages/htmlWriteTemplate - */ +// ******************************************************** +// JS used by view system/messages/htmlWriteTemplate +// ******************************************************** function tinymcePreviewSetContent() { @@ -52,12 +52,12 @@ $(document).ready(function () }); tinymce.init({ + selector: "#tinymcePreview", + plugins: "autoresize", menubar: false, toolbar: false, statusbar: false, readonly: 1, - selector: "#tinymcePreview", - plugins: "autoresize", autoresize_min_height: 150, autoresize_bottom_margin: 10 }); diff --git a/public/js/messaging/read.js b/public/js/messaging/read.js new file mode 100644 index 000000000..c4a27edc6 --- /dev/null +++ b/public/js/messaging/read.js @@ -0,0 +1,116 @@ +// *********************************************************************** +// List all personal messages, used by view system/messages/ajaxRead +// *********************************************************************** + +// +var tableMessageLst; + +/** + * + */ +function genericError() +{ + FHC_DialogLib.alertError("An error occurred while retrieving message, contact the website administrator"); +} + +/** + * + */ +function getReceivedMessages() +{ + _getMessages(FHC_JS_DATA_STORAGE_OBJECT.called_path + '/listReceivedMessages'); +} + +/** + * + */ +function getSentMessages() +{ + _getMessages(FHC_JS_DATA_STORAGE_OBJECT.called_path + '/listSentMessages'); +} + +/** + * + */ +function _getMessages(getMessagesURL) +{ + FHC_AjaxClient.ajaxCallGet( + getMessagesURL, + null, + { + successCallback: function(data, textStatus, jqXHR) { + + if (FHC_AjaxClient.hasData(data)) + { + try + { + tableMessageLst.replaceData(JSON.parse(FHC_AjaxClient.getData(data))); + } + catch (syntaxError) + { + genericError(); + } + } + }, + errorCallback: genericError, + veilTimeout: 300 + } + ); +} + +/** + * + */ +function changeTinyMCE(e, row) +{ + tinyMCE.get("readMessagePanel").setContent(row._row.data.body); +} + +/** + * + */ +function toggleMessages() +{ + // + if ($(this)[0].className.search('active') == -1) + { + $(this)[0].id == 'r' ? getReceivedMessages() : getSentMessages(); + } +} + +/** + * + */ +$(document).ready(function () { + + // + tinymce.init({ + selector: "#readMessagePanel", + plugins: "autoresize", + menubar: false, + toolbar: false, + statusbar: false, + readonly: 1, + autoresize_min_height: 200, + autoresize_bottom_margin: 0 + }); + + // + tableMessageLst = new Tabulator("#lstMessagesPanel", { + height: "400px", + pagination: "local", + columns: [ + {title: "Subject", field: "subject", width: 700, responsive: 0}, + {title: "From", field: "from", width: 400}, + {title: "Date", field: "sent", sorter: "datetime", width: 150} + ], + rowClick: changeTinyMCE + }); + + // + $('.toggleMessages .btn').click(toggleMessages); + + // + getReceivedMessages(); + +}); diff --git a/public/js/messaging/write.js b/public/js/messaging/write.js new file mode 100644 index 000000000..180a47c36 --- /dev/null +++ b/public/js/messaging/write.js @@ -0,0 +1,52 @@ +// **************************************************************************************** +// Write a message to an organisation unit, used by view system/messages/ajaxWrite +// **************************************************************************************** + +/** + * + */ +function sendMessageToOU() +{ + if ($('#organisationUnit').val() == 0) + { + FHC_DialogLib.alertWarning("Not valid organisation unit"); + } + else + { + FHC_AjaxClient.ajaxCallPost( + FHC_JS_DATA_STORAGE_OBJECT.called_path + '/sendMessageToOU', + { + receiverOU: $('#organisationUnit').val(), + subject: $('#subject').val(), + body: tinyMCE.get("body").getContent() + }, + { + successCallback: function(data, textStatus, jqXHR) { + FHC_DialogLib.alertSuccess("Message sent succesfully"); + }, + errorCallback: function() { + FHC_DialogLib.alertError("Error"); + }, + veilTimeout: 300 + } + ); + } +} + +/** + * + */ +$(document).ready(function () { + + // + tinymce.init({ + selector: "#body", + plugins: "autoresize", + autoresize_min_height: 150, + autoresize_max_height: 600, + autoresize_bottom_margin: 10 + }); + + $('#sendButton').click(sendMessageToOU); + +}); From 99e541d5065fd3623fe5cc4261e827f1725b2d69 Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 28 Jun 2019 19:18:18 +0200 Subject: [PATCH 012/138] Fixed receiver/sender retrieved from database --- application/models/CL/Messages_model.php | 2 +- application/models/system/Recipient_model.php | 11 ++++++----- public/js/messaging/read.js | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 5810487a9..37b244038 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -124,7 +124,7 @@ class Messages_model extends CI_Model $jsonRecord->message_id = $sentMessage->message_id; $jsonRecord->subject = $sentMessage->subject; $jsonRecord->body = $sentMessage->body; - $jsonRecord->from = $sentMessage->vorname.' '.$sentMessage->nachname; + $jsonRecord->to = $sentMessage->vorname.' '.$sentMessage->nachname; $sentDate = new DateTime($sentMessage->sent); $jsonRecord->sent = $sentDate->format('d/m/Y H:i:s'); $jsonRecord->status = $sentMessage->status; diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 39961cdbf..8a3ee1aa6 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -316,7 +316,7 @@ class Recipient_model extends DB_Model FROM public.tbl_msg_recipient mr JOIN public.tbl_msg_message mm ON (mm.message_id = mr.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mr.message_id AND ms.person_id = mr.person_id) - JOIN public.tbl_person p ON (p.person_id = mm.person_id) + JOIN public.tbl_person p ON (p.person_id = mr.person_id) WHERE mr.person_id = ? AND mr.sent IS NOT NULL AND mr.sentinfo IS NULL @@ -333,8 +333,8 @@ class Recipient_model extends DB_Model mm.subject, mm.body, mrou.sent AS sent, - p.vorname, - p.nachname, + pr.vorname, + pr.nachname, MAX(ms.status) AS status FROM public.tbl_person p JOIN public.tbl_benutzer b ON (b.person_id = p.person_id) @@ -342,6 +342,7 @@ class Recipient_model extends DB_Model JOIN public.tbl_msg_recipient mrou ON (mrou.oe_kurzbz = bf.oe_kurzbz) JOIN public.tbl_msg_message mm ON (mm.message_id = mrou.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mrou.message_id AND ms.person_id = mrou.person_id) + JOIN public.tbl_person pr ON (pr.person_id = mrou.person_id) WHERE p.person_id = ? AND mrou.sent IS NOT NULL AND mrou.sentinfo IS NULL @@ -350,8 +351,8 @@ class Recipient_model extends DB_Model mm.subject, mm.body, mrou.sent, - p.vorname, - p.nachname + pr.vorname, + pr.nachname ORDER BY sent DESC'; return $this->execQuery($sql, array($person_id, $functions, $person_id)); diff --git a/public/js/messaging/read.js b/public/js/messaging/read.js index c4a27edc6..348e6b3ed 100644 --- a/public/js/messaging/read.js +++ b/public/js/messaging/read.js @@ -102,6 +102,7 @@ $(document).ready(function () { columns: [ {title: "Subject", field: "subject", width: 700, responsive: 0}, {title: "From", field: "from", width: 400}, + {title: "To", field: "to", width: 400}, {title: "Date", field: "sent", sorter: "datetime", width: 150} ], rowClick: changeTinyMCE From c62b4dc018fb62ced6370187d7d7ce28eae71ceb Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 4 Jul 2019 11:15:07 +0200 Subject: [PATCH 013/138] - Added new public method setMessageRead to system/messages/MessageClient - system/Recipient_model methods getReceivedMessages and getSentMessages now retrieve person_id from tbl_msg_status - Added new public method setMessageRead to CL/Messages_model - Improved code in public/js/messaging/read.js --- .../system/messages/MessageClient.php | 16 ++- application/models/CL/Messages_model.php | 79 ++++++++--- application/models/system/Recipient_model.php | 27 ++-- public/js/messaging/read.js | 128 +++++++++++++----- 4 files changed, 183 insertions(+), 67 deletions(-) diff --git a/application/controllers/system/messages/MessageClient.php b/application/controllers/system/messages/MessageClient.php index 1062202c1..4cc4c9f2a 100644 --- a/application/controllers/system/messages/MessageClient.php +++ b/application/controllers/system/messages/MessageClient.php @@ -12,7 +12,8 @@ class MessageClient extends Auth_Controller 'write' => array('basis/person:r'), 'listReceivedMessages' => array('basis/person:r'), 'listSentMessages' => array('basis/person:r'), - 'sendMessageToOU' => array('basis/person:r') + 'sendMessageToOU' => array('basis/person:r'), + 'setMessageRead' => array('basis/person:r') ) ); @@ -55,7 +56,7 @@ class MessageClient extends Auth_Controller } /** - * + * Sends a message to an organisation unit */ public function sendMessageToOU() { @@ -65,4 +66,15 @@ class MessageClient extends Auth_Controller $this->outputJson($this->CLMessagesModel->sendToOrganisationUnit($receiverOU, $subject, $body)); } + + /** + * Set a message as read + */ + public function setMessageRead() + { + $message_id = $this->input->post('message_id'); + $statusPersonId = $this->input->post('statusPersonId'); + + $this->outputJson($this->CLMessagesModel->setMessageRead($message_id, $statusPersonId)); + } } diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 37b244038..e907022aa 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -2,13 +2,23 @@ /** * Messages GUI logic - * This model extends CI_Model because here is just implemented logic - * It does not represent a resource (ex. like models that extend DB_Model) + * - This model extends CI_Model because here is just implemented logic + * - It does not represent a resource (ex. like models that extend DB_Model) */ class Messages_model extends CI_Model { - const REPLY_SUBJECT_PREFIX = 'Re: '; - const REPLY_BODY_FORMAT = '

On %s %s %s wrote:
%s
'; + const REPLY_SUBJECT_PREFIX = 'Re: '; // reply subject prefix + // To quote a reply body message + const REPLY_BODY_FORMAT = '
+
+
+ + On %s %s %s wrote: + +
+
+ %s +
'; const NO_AUTH_UID = 'online'; // hard coded uid if no authentication is performed @@ -38,7 +48,28 @@ class Messages_model extends CI_Model // Public methods /** - * + * Set a message as read by its id ($message_id + $person_id) + */ + public function setMessageRead($message_id, $person_id) + { + // Checks parameters + if (!is_numeric($message_id) || !is_numeric($person_id)) return error('Invalid setMessageRead parameters'); + + // Loads needed models + $this->load->model('system/MsgStatus_model', 'MsgStatusModel'); + + // Set date used to insert + $statusData = array( + 'message_id' => $message_id, + 'person_id' => $person_id, + 'status' => MSG_STATUS_READ + ); + + return $this->MsgStatusModel->insert($statusData); // insert and return result + } + + /** + * Prepares data for the view system/messages/ajaxWrite */ public function prepareAjaxWrite() { @@ -60,26 +91,31 @@ class Messages_model extends CI_Model } /** - * + * Prepares data for the view system/messages/ajaxRead + * If everything is fine returns a list of received messages (objects) */ public function prepareAjaxReadReceived() { - $jsonResult = error('Something did not go as it should'); - + // Name and surname of the logged user $loggedUserName = getAuthFirstname().' '.getAuthSurname(); + // If empty then use a hard coded one if (isEmptyString($loggedUserName)) $loggedUserName = 'Me'; + // Retrieves received messages for the logged user and its organisation units $receivedMessagesResult = $this->RecipientModel->getReceivedMessages( getAuthPersonId(), $this->config->item(MessageLib::CFG_OU_RECEIVERS) ); + // If an error occurred return it if (isError($receivedMessagesResult)) return $receivedMessagesResult; + // If data were found if (hasData($receivedMessagesResult)) { - $jsonArray = array(); + $jsonArray = array(); // array that contains all the received messages + // Collect'em all in the array $jsonArray foreach (getData($receivedMessagesResult) as $receivedMessage) { $jsonRecord = new stdClass(); @@ -90,34 +126,38 @@ class Messages_model extends CI_Model $sentDate = new DateTime($receivedMessage->sent); $jsonRecord->sent = $sentDate->format('d/m/Y H:i:s'); $jsonRecord->status = $receivedMessage->status; + $jsonRecord->statusPersonId = $receivedMessage->statuspersonid; $jsonArray[] = $jsonRecord; } - $jsonResult = success(json_encode($jsonArray)); + return success(json_encode($jsonArray)); // return as an json encoded string } - return $jsonResult; + return success('No messages were found'); // NOT a blocking error } /** - * + * Prepares data for the view system/messages/ajaxRead + * If everything is fine returns a list of sent messages (objects) */ public function prepareAjaxReadSent() { - $jsonResult = error('Something did not go as it should'); - + // Name and surname of the logged user $loggedUserName = getAuthFirstname().' '.getAuthSurname(); + // If empty then use a hard coded one if (isEmptyString($loggedUserName)) $loggedUserName = 'Me'; + // Retrieves sent messages from the logged user $sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId()); - if (isError($sentMessagesResult)) return $sentMessagesResult; + if (isError($sentMessagesResult)) return $sentMessagesResult; // If an error occurred return it if (hasData($sentMessagesResult)) { - $jsonArray = array(); + $jsonArray = array();// array that contains all the sent messages + // Collect'em all in the array $jsonArray foreach (getData($sentMessagesResult) as $sentMessage) { $jsonRecord = new stdClass(); @@ -128,14 +168,15 @@ class Messages_model extends CI_Model $sentDate = new DateTime($sentMessage->sent); $jsonRecord->sent = $sentDate->format('d/m/Y H:i:s'); $jsonRecord->status = $sentMessage->status; + $jsonRecord->statusPersonId = $sentMessage->statuspersonid; $jsonArray[] = $jsonRecord; } - $jsonResult = success(json_encode($jsonArray)); + return success(json_encode($jsonArray)); // return as an json encoded string } - return $jsonResult; + return success('No messages were found'); // NOT a blocking error } /** @@ -540,7 +581,7 @@ class Messages_model extends CI_Model } /** - * + * Quotes the previous message body */ private function _getReplyBody($body, $receiverName, $receiverSurname, $sentDate) { diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 8a3ee1aa6..46cf0e36f 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -301,18 +301,21 @@ class Recipient_model extends DB_Model } /** - * + * - Gets the directly recieved messages using the given person id + * - Gets the recieved messages from an organisation unit where this person plays a role given by the parameter functions */ public function getReceivedMessages($person_id, $functions) { - $sql = 'SELECT mr.message_id, + $sql = '-- Messages sent directly to the person + SELECT mr.message_id, mm.relationmessage_id, mm.subject, mm.body, mr.sent AS sent, p.vorname, p.nachname, - MAX(ms.status) AS status + MAX(ms.status) AS status, + ms.person_id AS statusPersonId FROM public.tbl_msg_recipient mr JOIN public.tbl_msg_message mm ON (mm.message_id = mr.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mr.message_id AND ms.person_id = mr.person_id) @@ -326,8 +329,10 @@ class Recipient_model extends DB_Model mm.body, mr.sent, p.vorname, - p.nachname + p.nachname, + ms.person_id UNION + -- Messages sent to a person that belongs to the recipient organisation unit SELECT mrou.message_id, mm.relationmessage_id, mm.subject, @@ -335,7 +340,8 @@ class Recipient_model extends DB_Model mrou.sent AS sent, pr.vorname, pr.nachname, - MAX(ms.status) AS status + MAX(ms.status) AS status, + ms.person_id AS statusPersonId FROM public.tbl_person p JOIN public.tbl_benutzer b ON (b.person_id = p.person_id) JOIN (SELECT uid, oe_kurzbz FROM public.tbl_benutzerfunktion WHERE funktion_kurzbz IN ?) bf ON (bf.uid = b.uid) @@ -352,14 +358,15 @@ class Recipient_model extends DB_Model mm.body, mrou.sent, pr.vorname, - pr.nachname + pr.nachname, + ms.person_id ORDER BY sent DESC'; return $this->execQuery($sql, array($person_id, $functions, $person_id)); } /** - * + * Gets all the sent message by the given person */ public function getSentMessages($person_id) { @@ -370,7 +377,8 @@ class Recipient_model extends DB_Model mr.sent, p.vorname, p.nachname, - MAX(ms.status) AS status + MAX(ms.status) AS status, + ms.person_id AS statusPersonId FROM public.tbl_msg_message mm JOIN public.tbl_msg_recipient mr ON (mr.message_id = mm.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND mr.person_id = mr.person_id) @@ -384,7 +392,8 @@ class Recipient_model extends DB_Model mm.body, mr.sent, p.vorname, - p.nachname + p.nachname, + ms.person_id ORDER BY mr.sent DESC'; return $this->execQuery($sql, array($person_id)); diff --git a/public/js/messaging/read.js b/public/js/messaging/read.js index 348e6b3ed..99426bffa 100644 --- a/public/js/messaging/read.js +++ b/public/js/messaging/read.js @@ -2,35 +2,108 @@ // List all personal messages, used by view system/messages/ajaxRead // *********************************************************************** -// +// Global variable that contains tha tabulator instance var tableMessageLst; /** - * + * Use DialogLib to display a Generic error */ -function genericError() +function readMessagesGenericError() { FHC_DialogLib.alertError("An error occurred while retrieving message, contact the website administrator"); } /** - * + * Gets all the received messages */ function getReceivedMessages() { - _getMessages(FHC_JS_DATA_STORAGE_OBJECT.called_path + '/listReceivedMessages'); + _getMessages(FHC_JS_DATA_STORAGE_OBJECT.called_path + "/listReceivedMessages"); } /** - * + * Gets all the sent messages */ function getSentMessages() { - _getMessages(FHC_JS_DATA_STORAGE_OBJECT.called_path + '/listSentMessages'); + _getMessages(FHC_JS_DATA_STORAGE_OBJECT.called_path + "/listSentMessages"); } /** - * + * Change the TinyMCE content + */ +function changeTinyMCE(row) +{ + tinyMCE.get("readMessagePanel").setContent(row.getData().body); +} + +/** + * Called on Tabulator row click event + * - If a clicked message is unread thes is set as read + * - Change the TinyMCE content with the clicked message body + */ +function rowClick(e, row) +{ + // If the message is unread + if (row.getData().status == "0") + { + FHC_AjaxClient.ajaxCallPost( + FHC_JS_DATA_STORAGE_OBJECT.called_path + "/setMessageRead", + { + message_id: row.getData().message_id, + statusPersonId: row.getData().statusPersonId + }, + { + successCallback: function(data, textStatus, jqXHR) { + + if (FHC_AjaxClient.isSuccess(data)) + { + rowFormatter(row, "normal"); + } + else + { + readMessagesGenericError(); + } + }, + errorCallback: readMessagesGenericError, + veilTimeout: 300 + } + ); + } + + changeTinyMCE(row); // Change TinyMCE content +} + +/** + * Radio button click event to switch between received and sent messages + */ +function toggleMessages() +{ + // + if ($(this)[0].className.search("active") == -1) + { + $(this)[0].id == "r" ? getReceivedMessages() : getSentMessages(); + } +} + +/** + * Formats tabulator rows + */ +function rowFormatter(row, fontWeight = 700) +{ + if (row.getData().status == "0") + { + var cells = row.getElement().childNodes; + + for (var i = 0; i < cells.length; i++) + { + cells[i].style.fontWeight = fontWeight; + } + } +} + +/** + * Get received/sent messages and change tabulator content */ function _getMessages(getMessagesURL) { @@ -48,42 +121,22 @@ function _getMessages(getMessagesURL) } catch (syntaxError) { - genericError(); + readMessagesGenericError(); } } }, - errorCallback: genericError, + errorCallback: readMessagesGenericError, veilTimeout: 300 } ); } /** - * - */ -function changeTinyMCE(e, row) -{ - tinyMCE.get("readMessagePanel").setContent(row._row.data.body); -} - -/** - * - */ -function toggleMessages() -{ - // - if ($(this)[0].className.search('active') == -1) - { - $(this)[0].id == 'r' ? getReceivedMessages() : getSentMessages(); - } -} - -/** - * + * Start! */ $(document).ready(function () { - // + // TinyMCE initialization tinymce.init({ selector: "#readMessagePanel", plugins: "autoresize", @@ -95,7 +148,7 @@ $(document).ready(function () { autoresize_bottom_margin: 0 }); - // + // Tabulator initialization tableMessageLst = new Tabulator("#lstMessagesPanel", { height: "400px", pagination: "local", @@ -105,13 +158,14 @@ $(document).ready(function () { {title: "To", field: "to", width: 400}, {title: "Date", field: "sent", sorter: "datetime", width: 150} ], - rowClick: changeTinyMCE + rowClick: rowClick, + rowFormatter: rowFormatter }); - // - $('.toggleMessages .btn').click(toggleMessages); + // Bind radio buttons click event with toggleMessages function + $(".toggleMessages .btn").click(toggleMessages); - // + // First retrieve the received message and populate the tabulator getReceivedMessages(); }); From 18ea98416f683e5291e10bd50d95a458aae8e083 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 4 Jul 2019 15:11:58 +0200 Subject: [PATCH 014/138] From/To toggle tabulator columns --- public/js/messaging/read.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/public/js/messaging/read.js b/public/js/messaging/read.js index 99426bffa..e1fe784d0 100644 --- a/public/js/messaging/read.js +++ b/public/js/messaging/read.js @@ -18,6 +18,9 @@ function readMessagesGenericError() */ function getReceivedMessages() { + tableMessageLst.hideColumn("to"); + tableMessageLst.showColumn("from"); + _getMessages(FHC_JS_DATA_STORAGE_OBJECT.called_path + "/listReceivedMessages"); } @@ -26,6 +29,9 @@ function getReceivedMessages() */ function getSentMessages() { + tableMessageLst.hideColumn("from"); + tableMessageLst.showColumn("to"); + _getMessages(FHC_JS_DATA_STORAGE_OBJECT.called_path + "/listSentMessages"); } @@ -154,8 +160,8 @@ $(document).ready(function () { pagination: "local", columns: [ {title: "Subject", field: "subject", width: 700, responsive: 0}, - {title: "From", field: "from", width: 400}, - {title: "To", field: "to", width: 400}, + {title: "From", field: "from", width: 400, visible: false}, + {title: "To", field: "to", width: 400, visible: false}, {title: "Date", field: "sent", sorter: "datetime", width: 150} ], rowClick: rowClick, From 48bcc77c975ec19ddc7c0ca8bfe4f6fa4b886735 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 4 Jul 2019 17:18:01 +0200 Subject: [PATCH 015/138] - Added CSS public/css/Tabulator.css and public/css/TinyMCE.css - Added these new CSS to views/templates/FHC-Header.php - Unified messages CSS in public/css/messaging/message.css - Messages Inbox/Outbox GUI beautified --- .../views/system/messages/ajaxRead.php | 19 +- .../views/system/messages/ajaxWrite.php | 2 +- .../views/system/messages/htmlError.php | 2 +- .../views/system/messages/htmlRead.php | 2 +- .../views/system/messages/htmlSuccess.php | 2 +- .../views/system/messages/htmlWriteReply.php | 2 +- .../system/messages/htmlWriteTemplate.php | 2 +- application/views/templates/FHC-Header.php | 9 +- public/css/Tabulator.css | 14 ++ public/css/TinyMCE.css | 7 + public/css/messaging/message.css | 191 ++++++++++++++++++ public/css/messaging/messageReply.css | 17 -- public/css/messaging/messageSent.css | 25 --- public/css/messaging/messageWrite.css | 29 --- public/js/messaging/read.js | 20 +- 15 files changed, 245 insertions(+), 98 deletions(-) create mode 100644 public/css/Tabulator.css create mode 100644 public/css/TinyMCE.css create mode 100644 public/css/messaging/message.css delete mode 100644 public/css/messaging/messageReply.css delete mode 100644 public/css/messaging/messageSent.css delete mode 100644 public/css/messaging/messageWrite.css diff --git a/application/views/system/messages/ajaxRead.php b/application/views/system/messages/ajaxRead.php index b8d2ea4a6..f5a733c74 100644 --- a/application/views/system/messages/ajaxRead.php +++ b/application/views/system/messages/ajaxRead.php @@ -13,21 +13,20 @@ 'ajaxlib' => true, 'dialoglib' => true, 'tinymce' => true, - 'customJSs' => array('public/js/messaging/read.js') + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/read.js') ) ); ?> -
-
- - +
+
+ + + +
-
+
diff --git a/application/views/system/messages/ajaxWrite.php b/application/views/system/messages/ajaxWrite.php index a21a724b2..88767628c 100644 --- a/application/views/system/messages/ajaxWrite.php +++ b/application/views/system/messages/ajaxWrite.php @@ -11,7 +11,7 @@ 'ajaxlib' => true, 'dialoglib' => true, 'tinymce' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'), + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/write.js') ) ); diff --git a/application/views/system/messages/htmlError.php b/application/views/system/messages/htmlError.php index 7e029b50c..78ffc7164 100644 --- a/application/views/system/messages/htmlError.php +++ b/application/views/system/messages/htmlError.php @@ -7,7 +7,7 @@ 'bootstrap' => true, 'fontawesome' => true, 'sbadmintemplate' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageSent.css') + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css') ) ); ?> diff --git a/application/views/system/messages/htmlRead.php b/application/views/system/messages/htmlRead.php index 01a5421ac..390e84ccc 100644 --- a/application/views/system/messages/htmlRead.php +++ b/application/views/system/messages/htmlRead.php @@ -7,7 +7,7 @@ 'bootstrap' => true, 'fontawesome' => true, 'sbadmintemplate' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageReply.css') + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css') ) ); ?> diff --git a/application/views/system/messages/htmlSuccess.php b/application/views/system/messages/htmlSuccess.php index 0260c9d16..e421a77e0 100644 --- a/application/views/system/messages/htmlSuccess.php +++ b/application/views/system/messages/htmlSuccess.php @@ -7,7 +7,7 @@ 'bootstrap' => true, 'fontawesome' => true, 'sbadmintemplate' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageSent.css') + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css') ) ); ?> diff --git a/application/views/system/messages/htmlWriteReply.php b/application/views/system/messages/htmlWriteReply.php index b9932148b..dde6cf17a 100644 --- a/application/views/system/messages/htmlWriteReply.php +++ b/application/views/system/messages/htmlWriteReply.php @@ -8,7 +8,7 @@ 'fontawesome' => true, 'tinymce' => true, 'sbadmintemplate' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'), + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/messageWriteReply.js') ) ); diff --git a/application/views/system/messages/htmlWriteTemplate.php b/application/views/system/messages/htmlWriteTemplate.php index 7132cfb36..9d087f2ca 100644 --- a/application/views/system/messages/htmlWriteTemplate.php +++ b/application/views/system/messages/htmlWriteTemplate.php @@ -11,7 +11,7 @@ 'tinymce' => true, 'sbadmintemplate' => true, 'widgets' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'), + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/messageWrite.js') ) ); diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index 7b75e2ad7..2d6a92ace 100644 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -80,7 +80,14 @@ } // Tabulator CSS - if ($tabulator === true) generateCSSsInclude('vendor/olifolkerd/tabulator/dist/css/bootstrap/tabulator_bootstrap.min.css'); + if ($tabulator === true) + { + generateCSSsInclude('vendor/olifolkerd/tabulator/dist/css/bootstrap/tabulator_bootstrap.min.css'); + generateCSSsInclude('public/css/Tabulator.css'); + } + + // Tinymce CSS + if ($tinymce === true) generateCSSsInclude('public/css/TinyMCE.css'); // -------------------------------------------------------------------------------------------------------- // From public folder diff --git a/public/css/Tabulator.css b/public/css/Tabulator.css new file mode 100644 index 000000000..359f29e72 --- /dev/null +++ b/public/css/Tabulator.css @@ -0,0 +1,14 @@ +.tabulator-col { + font-size: 14px; +} + +.tabulator-page { + color: black; + opacity: 1 !important; + padding: 2px 7px !important; + border: 0px !important; +} + +.tabulator-page.active { + color: #337ab7 !important; +} diff --git a/public/css/TinyMCE.css b/public/css/TinyMCE.css new file mode 100644 index 000000000..a6d956b48 --- /dev/null +++ b/public/css/TinyMCE.css @@ -0,0 +1,7 @@ +.mce-tinymce .mce-container .mce-panel { + border-width: 0px; +} + +.mce-panel { + border-width: 0px !important; +} diff --git a/public/css/messaging/message.css b/public/css/messaging/message.css new file mode 100644 index 000000000..5d62a5e6a --- /dev/null +++ b/public/css/messaging/message.css @@ -0,0 +1,191 @@ +/* Smaller subject field */ +input[type=text] { + height: 28px; + padding: 0; +} + +.msgfield label { + margin-bottom: 0 !important; + margin-top: 3px; +} + +@media screen and (min-width: 1200px) { + .col-lg-1.msgfieldcol-left { + width: 13%; + } + + .col-lg-11.msgfieldcol-right { + width: 87%; + } +} + +#sendButton { + width: 120px; +} + +/* Overwrites the Widget.css class */ +div .width-150px { + width: 200px; +} + +.panel-heading { + font-size: 16px; +} + +.signatureblock { + color: grey; +} + +.signatureblocklink { + color: grey; +} + +.signatureblocklink:hover { + color: #337ab7; +} + +.rwd-line { + display: block; +} + +@media screen and (min-width: 1831px) { + .rwd-line { + display: inline; + } +} + +.panel-heading { + font-size: 16px; +} + +@media screen and (min-width: 1500px) { + #msgtable { + width: 70%; + } +} + +#msgtable td { + border: none !important; +} + +#replybutton { + width: 120px; +} + +/* STYLE THE HTML ELEMENTS (INCLUDES RESETS FOR THE DEFAULT FIELDSET AND LEGEND STYLES) */ +fieldset { + margin: 0; + padding: 2rem; + box-sizing: border-box; + display: block; + border: none; + border: solid 1px #CCC; + min-width: 0; + background-color: #FFF; +} +fieldset legend { + margin: 0 0 1.5rem; + padding: 0; + width: 100%; + float: left; + display: table; + font-size: 1.5rem; + line-height: 140%; + font-weight: 600; + color: #333; +} +fieldset legend + * { + clear: both; +} +body:not(:-moz-handler-blocked) fieldset { + display: table-cell; +} + +/* TOGGLE STYLING */ +.toggle { + margin: 0 0 1.5rem; + box-sizing: border-box; + font-size: 0; + display: flex; + flex-flow: row nowrap; + justify-content: flex-start; + align-items: stretch; +} +.toggle input { + width: 0; + height: 0; + position: absolute; + left: -9999px; +} +.toggle input + label { + margin: 0; + padding: .75rem 2rem; + box-sizing: border-box; + position: relative; + display: inline-block; + border: solid 1px #DDD; + background-color: #FFF; + font-size: 14px; + line-height: 140%; + font-weight: 600; + text-align: center; + box-shadow: 0 0 0 rgba(255, 255, 255, 0); + transition: border-color .15s ease-out, color .25s ease-out, background-color .15s ease-out, box-shadow .15s ease-out; + cursor: pointer; +} +.toggle input + label:first-of-type { + border-radius: 6px 0 0 6px; + border-right: none; +} +.toggle input + label:last-of-type { + border-radius: 0 6px 6px 0; + border-left: none; +} +.toggle input:hover + label { + border-color: #213140; +} +.toggle input:checked + label { + background-color: #337ab7; + color: #FFF; + box-shadow: 0 0 10px rgba(102, 179, 251, 0.5); + border-color: #337ab7; + z-index: 1; +} +.toggle input:focus + label { + outline: dotted 1px #CCC; + outline-offset: .45rem; +} +@media (max-width: 800px) { + .toggle input + label { + padding: .75rem .25rem; + flex: 0 0 50%; + display: flex; + justify-content: center; + align-items: center; + } +} + +/* STYLING FOR THE STATUS HELPER TEXT FOR THE DEMO */ +.status { + margin: 0; + font-size: 1rem; + font-weight: 400; +} +.status span { + font-weight: 600; + color: #B6985A; +} +.status span:first-of-type { + display: inline; +} +.status span:last-of-type { + display: none; +} +@media (max-width: 800px) { + .status span:first-of-type { + display: none; + } + .status span:last-of-type { + display: inline; + } +} diff --git a/public/css/messaging/messageReply.css b/public/css/messaging/messageReply.css deleted file mode 100644 index 17f978ecc..000000000 --- a/public/css/messaging/messageReply.css +++ /dev/null @@ -1,17 +0,0 @@ -.panel-heading { - font-size: 16px; -} - -@media screen and (min-width: 1500px) { - #msgtable { - width: 70%; - } -} - -#msgtable td { - border: none !important; -} - -#replybutton { - width: 120px; -} diff --git a/public/css/messaging/messageSent.css b/public/css/messaging/messageSent.css deleted file mode 100644 index 96403d797..000000000 --- a/public/css/messaging/messageSent.css +++ /dev/null @@ -1,25 +0,0 @@ -.panel-heading { - font-size: 16px; -} - -.signatureblock { - color: grey; -} - -.signatureblocklink { - color: grey; -} - -.signatureblocklink:hover { - color: #337ab7; -} - -.rwd-line { - display: block; -} - -@media screen and (min-width: 1831px) { - .rwd-line { - display: inline; - } -} diff --git a/public/css/messaging/messageWrite.css b/public/css/messaging/messageWrite.css deleted file mode 100644 index 3b5e1fd0e..000000000 --- a/public/css/messaging/messageWrite.css +++ /dev/null @@ -1,29 +0,0 @@ -/*smaller subject field*/ -input[type=text] { - height: 28px; - padding: 0; -} - -.msgfield label { - margin-bottom: 0 !important; - margin-top: 3px; -} - -@media screen and (min-width: 1200px) { - .col-lg-1.msgfieldcol-left { - width: 13%; - } - - .col-lg-11.msgfieldcol-right { - width: 87%; - } -} - -#sendButton { - width: 120px; -} - -/* Overwrites the Widget.css class */ -div .width-150px { - width: 200px; -} diff --git a/public/js/messaging/read.js b/public/js/messaging/read.js index e1fe784d0..edafe7483 100644 --- a/public/js/messaging/read.js +++ b/public/js/messaging/read.js @@ -85,11 +85,9 @@ function rowClick(e, row) */ function toggleMessages() { - // - if ($(this)[0].className.search("active") == -1) - { - $(this)[0].id == "r" ? getReceivedMessages() : getSentMessages(); - } + $(this)[0].id == "received" ? getReceivedMessages() : getSentMessages(); + + tableMessageLst.redraw(); // redraw table after its content is changed } /** @@ -158,18 +156,20 @@ $(document).ready(function () { tableMessageLst = new Tabulator("#lstMessagesPanel", { height: "400px", pagination: "local", + layout: "fitColumns", + layoutColumnsOnNewData: true, columns: [ - {title: "Subject", field: "subject", width: 700, responsive: 0}, - {title: "From", field: "from", width: 400, visible: false}, - {title: "To", field: "to", width: 400, visible: false}, - {title: "Date", field: "sent", sorter: "datetime", width: 150} + {title: "Subject", field: "subject", responsive: 0}, + {title: "From", field: "from", visible: false}, + {title: "To", field: "to", visible: false}, + {title: "Date", field: "sent", sorter: "datetime"} ], rowClick: rowClick, rowFormatter: rowFormatter }); // Bind radio buttons click event with toggleMessages function - $(".toggleMessages .btn").click(toggleMessages); + $("#toggleMessages input").click(toggleMessages); // First retrieve the received message and populate the tabulator getReceivedMessages(); From c30135f197c2bc3363d8ecbf6c3c48a27ca0eafe Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 17 Sep 2019 10:38:25 +0200 Subject: [PATCH 016/138] Now MessageClient extends FHC_Controller and then starts the authentication --- .../system/messages/MessageClient.php | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/application/controllers/system/messages/MessageClient.php b/application/controllers/system/messages/MessageClient.php index 4cc4c9f2a..f7bc760ad 100644 --- a/application/controllers/system/messages/MessageClient.php +++ b/application/controllers/system/messages/MessageClient.php @@ -2,20 +2,19 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); -class MessageClient extends Auth_Controller +/** + * NOTE: MessageClient extends FHC_Controller and NOT Auth_Controller to be able to use + * the authentication system without the need to load the permissions system + */ +class MessageClient extends FHC_Controller { public function __construct() { - parent::__construct( - array( - 'read' => array('basis/person:r'), - 'write' => array('basis/person:r'), - 'listReceivedMessages' => array('basis/person:r'), - 'listSentMessages' => array('basis/person:r'), - 'sendMessageToOU' => array('basis/person:r'), - 'setMessageRead' => array('basis/person:r') - ) - ); + parent::__construct(); + + // Loads authentication library and starts authentication + // NOTE: it is loaded here because the controller extends FHC_Controller and NOT Auth_Controller + $this->load->library('AuthLib'); // Loads model CLMessagesModel which contains the GUI logic $this->load->model('CL/Messages_model', 'CLMessagesModel'); From 509fdef03b565bcb3ed744b10276743cd85d2be8 Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 15 Oct 2019 11:54:01 +0200 Subject: [PATCH 017/138] - Removed tabulator local pagination for messages list - Removed error messages when the messages list is empty --- public/js/messaging/read.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/public/js/messaging/read.js b/public/js/messaging/read.js index edafe7483..c3b117636 100644 --- a/public/js/messaging/read.js +++ b/public/js/messaging/read.js @@ -119,13 +119,18 @@ function _getMessages(getMessagesURL) if (FHC_AjaxClient.hasData(data)) { - try + var messages = FHC_AjaxClient.getData(data); + + if ($.isArray(messages)) { - tableMessageLst.replaceData(JSON.parse(FHC_AjaxClient.getData(data))); - } - catch (syntaxError) - { - readMessagesGenericError(); + try + { + tableMessageLst.replaceData(JSON.parse()); + } + catch (syntaxError) + { + readMessagesGenericError(); + } } } }, @@ -155,7 +160,6 @@ $(document).ready(function () { // Tabulator initialization tableMessageLst = new Tabulator("#lstMessagesPanel", { height: "400px", - pagination: "local", layout: "fitColumns", layoutColumnsOnNewData: true, columns: [ From d40fd6391a1c876bca5cfbaee42be569587b9816 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 30 Oct 2019 18:30:16 +0100 Subject: [PATCH 018/138] Added some phrases for the messaging system, english only --- system/phrasesupdate.php | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 4f5145034..a2ff737c2 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -3450,6 +3450,66 @@ $phrases = array( 'insertvon' => 'system' ) ) + ), + array( + 'app' => 'core', + 'category' => 'global', + 'phrase' => 'write', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => '', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Write', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'global', + 'phrase' => 'received', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => '', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Received', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'global', + 'phrase' => 'reply', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => '', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Reply', + 'description' => '', + 'insertvon' => 'system' + ) + ) ) ); From 6594a5288bfb38bfff2ca7a089b490b71ef03327 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 30 Oct 2019 18:30:50 +0100 Subject: [PATCH 019/138] Better CSS for messaging system pages --- public/css/messaging/message.css | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/public/css/messaging/message.css b/public/css/messaging/message.css index 5d62a5e6a..f5440b892 100644 --- a/public/css/messaging/message.css +++ b/public/css/messaging/message.css @@ -83,6 +83,7 @@ fieldset { min-width: 0; background-color: #FFF; } + fieldset legend { margin: 0 0 1.5rem; padding: 0; @@ -94,9 +95,11 @@ fieldset legend { font-weight: 600; color: #333; } + fieldset legend + * { clear: both; } + body:not(:-moz-handler-blocked) fieldset { display: table-cell; } @@ -106,17 +109,18 @@ body:not(:-moz-handler-blocked) fieldset { margin: 0 0 1.5rem; box-sizing: border-box; font-size: 0; - display: flex; flex-flow: row nowrap; justify-content: flex-start; align-items: stretch; } + .toggle input { width: 0; height: 0; position: absolute; left: -9999px; } + .toggle input + label { margin: 0; padding: .75rem 2rem; @@ -133,17 +137,21 @@ body:not(:-moz-handler-blocked) fieldset { transition: border-color .15s ease-out, color .25s ease-out, background-color .15s ease-out, box-shadow .15s ease-out; cursor: pointer; } + .toggle input + label:first-of-type { border-radius: 6px 0 0 6px; border-right: none; } + .toggle input + label:last-of-type { border-radius: 0 6px 6px 0; border-left: none; } + .toggle input:hover + label { border-color: #213140; } + .toggle input:checked + label { background-color: #337ab7; color: #FFF; @@ -151,15 +159,16 @@ body:not(:-moz-handler-blocked) fieldset { border-color: #337ab7; z-index: 1; } + .toggle input:focus + label { outline: dotted 1px #CCC; outline-offset: .45rem; } + @media (max-width: 800px) { .toggle input + label { padding: .75rem .25rem; flex: 0 0 50%; - display: flex; justify-content: center; align-items: center; } @@ -171,16 +180,20 @@ body:not(:-moz-handler-blocked) fieldset { font-size: 1rem; font-weight: 400; } + .status span { font-weight: 600; color: #B6985A; } + .status span:first-of-type { display: inline; } + .status span:last-of-type { display: none; } + @media (max-width: 800px) { .status span:first-of-type { display: none; @@ -189,3 +202,9 @@ body:not(:-moz-handler-blocked) fieldset { display: inline; } } + + +.buttonsSpacer { + display: inline-block; + width: 30px; +} From 36e5009d68b0731a7d35e5e260b55e055f997287 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 30 Oct 2019 18:31:21 +0100 Subject: [PATCH 020/138] Fixed problems with DialogLib --- public/js/DialogLib.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/DialogLib.js b/public/js/DialogLib.js index 05558844a..3b472cd6a 100644 --- a/public/js/DialogLib.js +++ b/public/js/DialogLib.js @@ -74,7 +74,7 @@ var FHC_DialogLib = { buttons: [{ text: "Ok", click: function() { - $(this).dialog("close"); + $("#fhc-dialoglib-dialog").remove(); } }] }); From 2a4360862af77f03d59069f9041001184971fa5e Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 30 Oct 2019 18:35:46 +0100 Subject: [PATCH 021/138] =?UTF-8?q?-=20Reply=20Button=20in=20Inbox/outbox?= =?UTF-8?q?=20Page=20-=20Write=20new=20message=20Button=20with=20Layer/Pop?= =?UTF-8?q?up=20-=20Degree=20Programs=20drop=20down=20displays=20longer=20?= =?UTF-8?q?name=20(if=20prestudent=20best=C3=A4tigt=20(alias=20interessent?= =?UTF-8?q?=20with=20bestaetigtam=20!=3D=20null=20)=20receiver->=20dp,=20o?= =?UTF-8?q?therwise=20->=20infocenter)=20-=20SQL=20to=20get=20OU=20recipie?= =?UTF-8?q?nt=20doesn't=20use=20beginn=20/=20End=20of=20function=20-=20Alw?= =?UTF-8?q?ays=20set=20insertvon=20in=20tbl=5Fmsg=5Fstatus=20-=20Add=20Mul?= =?UTF-8?q?tilanguage=20Support=20for=20Message=20Page=20(not=20completed?= =?UTF-8?q?=20yet)=20-=20If=20in=20sent=20mode=20do=20not=20set=20messages?= =?UTF-8?q?=20as=20read=20-=20Error=20message=20when=20there=20are=20no=20?= =?UTF-8?q?Messages=20available=20shouldnt=20be=20displayed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/messages/MessageClient.php | 33 ++++++ application/libraries/MessageLib.php | 35 +++++- application/models/CL/Messages_model.php | 71 +++++++++--- application/models/crm/Prestudent_model.php | 18 ++- application/models/system/Recipient_model.php | 109 ++++++++++++++++-- .../views/system/messages/ajaxRead.php | 90 +++++++++------ .../views/system/messages/ajaxWriteReply.php | 80 +++++++++++++ public/js/messaging/read.js | 88 ++++++++++++-- public/js/messaging/writeReply.js | 48 ++++++++ 9 files changed, 494 insertions(+), 78 deletions(-) create mode 100644 application/views/system/messages/ajaxWriteReply.php create mode 100644 public/js/messaging/writeReply.js diff --git a/application/controllers/system/messages/MessageClient.php b/application/controllers/system/messages/MessageClient.php index f7bc760ad..a0cc5c518 100644 --- a/application/controllers/system/messages/MessageClient.php +++ b/application/controllers/system/messages/MessageClient.php @@ -18,6 +18,14 @@ class MessageClient extends FHC_Controller // Loads model CLMessagesModel which contains the GUI logic $this->load->model('CL/Messages_model', 'CLMessagesModel'); + + // Phrases used in loaded views + $this->loadPhrases( + array( + 'global', + 'ui' + ) + ); } /** @@ -38,6 +46,17 @@ class MessageClient extends FHC_Controller $this->load->view('system/messages/ajaxWrite', $this->CLMessagesModel->prepareAjaxWrite()); } + /** + * Starts the GUI used to reply to a received personal message + */ + public function writeReply() + { + $token = $this->input->get('token'); + + // Loads the view to reply to a message + $this->load->view('system/messages/ajaxWriteReply', $this->CLMessagesModel->prepareAjaxWriteReply($token)); + } + /** * Returns JSON that that contains all the received messages by the currently logged user */ @@ -66,6 +85,20 @@ class MessageClient extends FHC_Controller $this->outputJson($this->CLMessagesModel->sendToOrganisationUnit($receiverOU, $subject, $body)); } + /** + * Sends a message to an organisation unit + */ + public function sendMessageReply() + { + $receiver_id = $this->input->post('receiver_id'); + $relationmessage_id = $this->input->post('relationmessage_id'); + $token = $this->input->post('token'); + $subject = $this->input->post('subject'); + $body = $this->input->post('body'); + + $this->outputJson($this->CLMessagesModel->sendReply($receiver_id, $subject, $body, $relationmessage_id, $token)); + } + /** * Set a message as read */ diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 18b958e14..9224996c8 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -272,10 +272,17 @@ class MessageLib // If NOT found then insert the read status if (!$found) { + $uid = null; + if (!isEmptyString($messageTokenResult[0]->uid)) + { + $uid = $messageTokenResult[0]->uid; + } + $statusData = array( 'message_id' => getData($messageTokenResult)[0]->message_id, 'person_id' => getData($messageTokenResult)[0]->receiver_id, - 'status' => MSG_STATUS_READ + 'status' => MSG_STATUS_READ, + 'insertvon' => $uid ); $messageTokenResultIns = $this->_ci->MsgStatusModel->insert($statusData); @@ -383,6 +390,15 @@ class MessageLib // Starts database transaction $this->_ci->db->trans_start(false); + $this->_ci->load->model('person/Benutzer_model', 'BenutzerModel'); + + $uid = null; + $benutzerDB = $this->_ci->BenutzerModel->loadWhere(array('person_id' => $sender_id)); + if (hasData($benutzerDB)) + { + $uid = getData($benutzerDB)[0]->uid; + } + // Store message information in tbl_msg_message $messageData = array( 'person_id' => $sender_id, @@ -413,7 +429,8 @@ class MessageLib $statusData = array( 'message_id' => $messageId, 'person_id' => $receiver_id, - 'status' => MSG_STATUS_UNREAD + 'status' => MSG_STATUS_UNREAD, + 'insertvon' => $uid ); $saveMessageResult = $this->_ci->MsgStatusModel->insert($statusData); } @@ -511,7 +528,17 @@ class MessageLib if (isError($messageResult)) return $messageResult; // if an error occured then return it if (!hasData($messageResult)) return error('No data found with the given message id'); // if no data found then return an error - return $this->_sendNotice(getData($messageResult)); + $messages = getData($messageResult); + if (count($messages) == 1 && $messages[0]->receiver_id == $this->_ci->config->item(self::CFG_SYSTEM_PERSON_ID)) + { + $messages = $this->_ci->RecipientModel->getReceivedMessagesByOE( + $messages[0]->oe_kurzbz, + $this->_ci->config->item(MessageLib::CFG_OU_RECEIVERS), + self::EMAIL_KONTAKT_TYPE + ); + } + + return $this->_sendNotice($messages); } /** @@ -614,11 +641,13 @@ class MessageLib // Checks if sender is fine $sender = $this->_getSender($sender_id); if (!hasData($sender)) return $sender; + // Checks if the sender and receiver organisation unit are valid if (($receiversOU != null && !$this->_ouExists($receiversOU)) || ($senderOU != null && !$this->_ouExists($senderOU))) { return error('The given organisation unit is not valid', MSG_ERR_INVALID_OU); } + // Checks subjects if (isEmptyString($subject)) return error('The given subject is an empty string', MSG_ERR_INVALID_SUBJECT); // Checks body diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index e907022aa..7673a6d71 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -62,7 +62,8 @@ class Messages_model extends CI_Model $statusData = array( 'message_id' => $message_id, 'person_id' => $person_id, - 'status' => MSG_STATUS_READ + 'status' => MSG_STATUS_READ, + 'insertvon' => getAuthUID() ); return $this->MsgStatusModel->insert($statusData); // insert and return result @@ -83,25 +84,61 @@ class Messages_model extends CI_Model { foreach (getData($ouResult) as $ou) { - $ouOptions .= sprintf("\n".'', $ou->oe_kurzbz, $ou->bezeichnung); + $ouOptions .= sprintf( + "\n".'', + is_numeric($ou->prestudent_id) ? $ou->oe_kurzbz : 'infocenter', + $ou->bezeichnung + ); } } return array('organisationUnitOptions' => $ouOptions); } + /** + * Prepares data for the view system/messages/ajaxWriteReply + */ + public function prepareAjaxWriteReply($token) + { + if (isEmptyString($token)) show_error('The given token is not valid'); + + // Retrieves message using the given token + $messageResult = $this->MessageTokenModel->getMessageByToken($token); + if (isError($messageResult)) show_error('An error occurred while loading this page, please contact the site administrator'); + + if (hasData($messageResult)) + { + $message = getData($messageResult)[0]; // Found message data + + // Retrieves message sender information + $senderResult = $this->MessageTokenModel->getSenderData($message->sender_id); + if (isError($senderResult)) show_error('An error occurred while loading this page, please contact the site administrator'); + + if (hasData($senderResult)) + { + $sender = getData($senderResult)[0]; // Found sender data + + $replySubject = self::REPLY_SUBJECT_PREFIX.$message->subject; + $replyBody = $this->_getReplyBody($message->body, $sender->vorname, $sender->nachname, $message->sent); + + return array ( + 'receiver' => $sender->vorname.' '.$sender->nachname, // yep! the sender of the sent message is the receiver of the reply message + 'subject' => $replySubject, + 'body' => $replyBody, + 'receiver_id' => $message->sender_id, + 'relationmessage_id' => $message->message_id, + 'token' => $token + ); + } + } + } + /** * Prepares data for the view system/messages/ajaxRead * If everything is fine returns a list of received messages (objects) */ public function prepareAjaxReadReceived() { - // Name and surname of the logged user - $loggedUserName = getAuthFirstname().' '.getAuthSurname(); - - // If empty then use a hard coded one - if (isEmptyString($loggedUserName)) $loggedUserName = 'Me'; - // Retrieves received messages for the logged user and its organisation units $receivedMessagesResult = $this->RecipientModel->getReceivedMessages( getAuthPersonId(), @@ -127,6 +164,7 @@ class Messages_model extends CI_Model $jsonRecord->sent = $sentDate->format('d/m/Y H:i:s'); $jsonRecord->status = $receivedMessage->status; $jsonRecord->statusPersonId = $receivedMessage->statuspersonid; + $jsonRecord->token = $receivedMessage->token; $jsonArray[] = $jsonRecord; } @@ -143,12 +181,6 @@ class Messages_model extends CI_Model */ public function prepareAjaxReadSent() { - // Name and surname of the logged user - $loggedUserName = getAuthFirstname().' '.getAuthSurname(); - - // If empty then use a hard coded one - if (isEmptyString($loggedUserName)) $loggedUserName = 'Me'; - // Retrieves sent messages from the logged user $sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId()); if (isError($sentMessagesResult)) return $sentMessagesResult; // If an error occurred return it @@ -164,11 +196,20 @@ class Messages_model extends CI_Model $jsonRecord->message_id = $sentMessage->message_id; $jsonRecord->subject = $sentMessage->subject; $jsonRecord->body = $sentMessage->body; - $jsonRecord->to = $sentMessage->vorname.' '.$sentMessage->nachname; $sentDate = new DateTime($sentMessage->sent); $jsonRecord->sent = $sentDate->format('d/m/Y H:i:s'); $jsonRecord->status = $sentMessage->status; $jsonRecord->statusPersonId = $sentMessage->statuspersonid; + $jsonRecord->token = $sentMessage->token; + + if ($sentMessage->person_id == $this->config->item(MessageLib::CFG_SYSTEM_PERSON_ID)) + { + $jsonRecord->to = $sentMessage->sg; + } + else + { + $jsonRecord->to = $sentMessage->vorname.' '.$sentMessage->nachname; + } $jsonArray[] = $jsonRecord; } diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index b4c756e52..b1ae9b8e9 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -529,13 +529,23 @@ class Prestudent_model extends DB_Model */ public function getOrganisationunitsByPersonId($person_id) { - $query = 'SELECT o.oe_kurzbz, o.bezeichnung + $query = 'SELECT o.oe_kurzbz, + sg.bezeichnung, + ps.prestudent_id FROM public.tbl_prestudent p - JOIN public.tbl_studiengang s USING(studiengang_kz) + JOIN public.tbl_studiengang sg USING(studiengang_kz) JOIN public.tbl_organisationseinheit o USING(oe_kurzbz) + LEFT JOIN ( + SELECT prestudent_id + FROM public.tbl_prestudentstatus + WHERE bestaetigtam IS NOT NULL + AND status_kurzbz = \'Interessent\' + ) ps USING(prestudent_id) WHERE p.person_id = ? - GROUP BY o.oe_kurzbz, o.bezeichnung - ORDER BY o.bezeichnung'; + GROUP BY o.oe_kurzbz, + sg.bezeichnung, + ps.prestudent_id + ORDER BY sg.bezeichnung'; return $this->execQuery($query, array($person_id)); } diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 46cf0e36f..76a0bf435 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -57,11 +57,13 @@ class Recipient_model extends DB_Model m.oe_kurzbz, s.status, s.statusinfo, - s.insertamum as statusamum + s.insertamum as statusamum, + b.uid FROM public.tbl_msg_recipient r JOIN public.tbl_msg_message m USING (message_id) JOIN ( SELECT * FROM public.tbl_msg_status WHERE status < ? ORDER BY insertamum DESC, status DESC - ) s ON (r.message_id = s.message_id AND r.person_id = s.person_id) + ) s ON (r.message_id = s.message_id AND r.person_id = s.person_id), + LEFT JOIN public.tbl_benutzer b USING(person_id) WHERE r.token = ? LIMIT 1'; @@ -217,7 +219,8 @@ class Recipient_model extends DB_Model mr.token, mm.subject, mm.body, - mr.sentinfo + mr.sentinfo, + mr.oe_kurzbz FROM public.tbl_msg_recipient mr INNER JOIN public.tbl_msg_message mm USING (message_id) LEFT JOIN ( SELECT person_id, kontakt FROM public.tbl_kontakt WHERE zustellung = true AND kontakttyp = ? @@ -315,11 +318,12 @@ class Recipient_model extends DB_Model p.vorname, p.nachname, MAX(ms.status) AS status, - ms.person_id AS statusPersonId + ms.person_id AS statusPersonId, + mr.token FROM public.tbl_msg_recipient mr JOIN public.tbl_msg_message mm ON (mm.message_id = mr.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mr.message_id AND ms.person_id = mr.person_id) - JOIN public.tbl_person p ON (p.person_id = mr.person_id) + JOIN public.tbl_person p ON (p.person_id = mm.person_id) WHERE mr.person_id = ? AND mr.sent IS NOT NULL AND mr.sentinfo IS NULL @@ -330,7 +334,8 @@ class Recipient_model extends DB_Model mr.sent, p.vorname, p.nachname, - ms.person_id + ms.person_id, + mr.token UNION -- Messages sent to a person that belongs to the recipient organisation unit SELECT mrou.message_id, @@ -341,14 +346,21 @@ class Recipient_model extends DB_Model pr.vorname, pr.nachname, MAX(ms.status) AS status, - ms.person_id AS statusPersonId + ms.person_id AS statusPersonId, + mrou.token FROM public.tbl_person p JOIN public.tbl_benutzer b ON (b.person_id = p.person_id) - JOIN (SELECT uid, oe_kurzbz FROM public.tbl_benutzerfunktion WHERE funktion_kurzbz IN ?) bf ON (bf.uid = b.uid) + JOIN ( + SELECT uid, oe_kurzbz + FROM public.tbl_benutzerfunktion + WHERE (datum_von IS NULL OR datum_von <= NOW()) + AND (datum_bis IS NULL OR datum_bis >= NOW()) + AND funktion_kurzbz IN ? + ) bf ON (bf.uid = b.uid) JOIN public.tbl_msg_recipient mrou ON (mrou.oe_kurzbz = bf.oe_kurzbz) JOIN public.tbl_msg_message mm ON (mm.message_id = mrou.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mrou.message_id AND ms.person_id = mrou.person_id) - JOIN public.tbl_person pr ON (pr.person_id = mrou.person_id) + JOIN public.tbl_person pr ON (pr.person_id = mm.person_id) WHERE p.person_id = ? AND mrou.sent IS NOT NULL AND mrou.sentinfo IS NULL @@ -359,12 +371,78 @@ class Recipient_model extends DB_Model mrou.sent, pr.vorname, pr.nachname, - ms.person_id + ms.person_id, + mrou.token ORDER BY sent DESC'; return $this->execQuery($sql, array($person_id, $functions, $person_id)); } + /** + * Gets only the recieved messages from an organisation unit where this person plays a role given by the parameter functions + */ + public function getReceivedMessagesByOE($oe_kurzbz, $functions, $kontaktType) + { + // Messages sent to a person that belongs to the recipient organisation unit + $sql = 'SELECT mm.message_id, + mm.subject, + mm.body, + mrou.person_id as receiver_id, + mrou.sentinfo, + mrou.token, + mrou.oe_kurzbz, + ks.kontakt as sender, + kr.kontakt as receiver, + mu.mitarbeiter_uid as employeeContact, + mb.mitarbeiter_uid as senderemployeeContact + FROM public.tbl_benutzer b + JOIN ( + SELECT uid, oe_kurzbz + FROM public.tbl_benutzerfunktion + WHERE (datum_von IS NULL OR datum_von <= NOW()) + AND (datum_bis IS NULL OR datum_bis >= NOW()) + AND funktion_kurzbz IN ? + ) bf ON (bf.uid = b.uid) + JOIN public.tbl_msg_recipient mrou ON (mrou.oe_kurzbz = bf.oe_kurzbz) + JOIN public.tbl_msg_message mm ON (mm.message_id = mrou.message_id) + JOIN public.tbl_msg_status ms ON (ms.message_id = mrou.message_id AND ms.person_id = mrou.person_id) + JOIN public.tbl_person pr ON (pr.person_id = mm.person_id) + LEFT JOIN ( + SELECT person_id, kontakt FROM public.tbl_kontakt WHERE zustellung = true AND kontakttyp = ? + ) ks ON (ks.person_id = mm.person_id) + LEFT JOIN ( + SELECT person_id, kontakt FROM public.tbl_kontakt WHERE zustellung = true AND kontakttyp = ? + ) kr ON (kr.person_id = mrou.person_id) + LEFT JOIN ( + SELECT b.person_id, + m.mitarbeiter_uid + FROM public.tbl_benutzer b INNER JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) + WHERE b.aktiv = TRUE + ) mu ON (mu.person_id = mrou.person_id) + LEFT JOIN ( + SELECT b.person_id, + m.mitarbeiter_uid + FROM public.tbl_benutzer b INNER JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) + WHERE b.aktiv = TRUE + ) mb ON (mb.person_id = mm.person_id) + WHERE bf.oe_kurzbz = ? + AND mrou.sent IS NULL + AND mrou.sentinfo IS NOT NULL + GROUP BY mm.message_id, + mm.subject, + mm.body, + mrou.person_id, + mrou.sentinfo, + mrou.token, + mrou.oe_kurzbz, + ks.kontakt, + kr.kontakt, + mu.mitarbeiter_uid, + mb.mitarbeiter_uid'; + + return $this->execQuery($sql, array($functions, $kontaktType, $kontaktType, $oe_kurzbz)); + } + /** * Gets all the sent message by the given person */ @@ -375,14 +453,18 @@ class Recipient_model extends DB_Model mm.subject, mm.body, mr.sent, + p.person_id, p.vorname, p.nachname, MAX(ms.status) AS status, - ms.person_id AS statusPersonId + ms.person_id AS statusPersonId, + sg.bezeichnung AS sg, + mr.token FROM public.tbl_msg_message mm JOIN public.tbl_msg_recipient mr ON (mr.message_id = mm.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND mr.person_id = mr.person_id) JOIN public.tbl_person p ON (p.person_id = mr.person_id) + LEFT JOIN public.tbl_studiengang sg ON (sg.oe_kurzbz = mr.oe_kurzbz) WHERE mm.person_id = ? AND mr.sent IS NOT NULL AND mr.sentinfo IS NULL @@ -391,9 +473,12 @@ class Recipient_model extends DB_Model mm.subject, mm.body, mr.sent, + p.person_id, p.vorname, p.nachname, - ms.person_id + ms.person_id, + sg.bezeichnung, + mr.token ORDER BY mr.sent DESC'; return $this->execQuery($sql, array($person_id)); diff --git a/application/views/system/messages/ajaxRead.php b/application/views/system/messages/ajaxRead.php index f5a733c74..1e4dbd187 100644 --- a/application/views/system/messages/ajaxRead.php +++ b/application/views/system/messages/ajaxRead.php @@ -1,34 +1,56 @@ -load->view( - 'templates/FHC-Header', - array( - 'title' => 'Read personal messages', - 'jquery' => true, - 'jqueryui' => true, - 'bootstrap' => true, - 'fontawesome' => true, - 'sbadmintemplate' => true, - 'momentjs' => true, - 'tabulator' => true, - 'ajaxlib' => true, - 'dialoglib' => true, - 'tinymce' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), - 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/read.js') - ) - ); -?> - -
-
- - - - -
-
-
-
- - -load->view("templates/FHC-Footer"); ?> +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Read personal messages', + 'jquery' => true, + 'jqueryui' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'momentjs' => true, + 'tabulator' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'tinymce' => true, + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/read.js') + ) + ); +?> + + +
+ + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+ + + +load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/ajaxWriteReply.php b/application/views/system/messages/ajaxWriteReply.php new file mode 100644 index 000000000..25602271c --- /dev/null +++ b/application/views/system/messages/ajaxWriteReply.php @@ -0,0 +1,80 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Reply to a message', + 'jquery' => true, + 'jqueryui' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'tinymce' => true, + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/writeReply.js') + ) + ); +?> + +
+
+
+
+
+ +
+
+
+
+
+ +
+
+ + + +
+
+
+
+
+
+ +
+   +
+ + + +
+
+
+
+
+
+ + +
+
+
+
+
+ + + + + + +
+
+
+
+
+ + +load->view("templates/FHC-Footer"); ?> diff --git a/public/js/messaging/read.js b/public/js/messaging/read.js index c3b117636..cc463b3f7 100644 --- a/public/js/messaging/read.js +++ b/public/js/messaging/read.js @@ -4,6 +4,7 @@ // Global variable that contains tha tabulator instance var tableMessageLst; +var selectedToggleMessage = "received"; /** * Use DialogLib to display a Generic error @@ -40,7 +41,14 @@ function getSentMessages() */ function changeTinyMCE(row) { - tinyMCE.get("readMessagePanel").setContent(row.getData().body); + if (row == null) + { + tinyMCE.get("readMessagePanel").setContent(''); + } + else + { + tinyMCE.get("readMessagePanel").setContent(row.getData().body); + } } /** @@ -50,8 +58,8 @@ function changeTinyMCE(row) */ function rowClick(e, row) { - // If the message is unread - if (row.getData().status == "0") + // If in received mode and the message is not unread + if (selectedToggleMessage == "received" && row.getData().status == "0") { FHC_AjaxClient.ajaxCallPost( FHC_JS_DATA_STORAGE_OBJECT.called_path + "/setMessageRead", @@ -64,7 +72,8 @@ function rowClick(e, row) if (FHC_AjaxClient.isSuccess(data)) { - rowFormatter(row, "normal"); + rowFormatter(row, "normal"); // format row + row.getData().status = "1"; // update status to read } else { @@ -77,6 +86,12 @@ function rowClick(e, row) ); } + // If NOT in send mode + if (selectedToggleMessage == "received") + { + $("#replyMessage").show(); + } + changeTinyMCE(row); // Change TinyMCE content } @@ -85,8 +100,19 @@ function rowClick(e, row) */ function toggleMessages() { - $(this)[0].id == "received" ? getReceivedMessages() : getSentMessages(); + if ($(this)[0].id == "received") + { + selectedToggleMessage = "received"; + getReceivedMessages(); + } + else + { + selectedToggleMessage = "send"; + $("#replyMessage").hide(); + getSentMessages(); + } + changeTinyMCE(null); // clean tinymce tableMessageLst.redraw(); // redraw table after its content is changed } @@ -119,13 +145,19 @@ function _getMessages(getMessagesURL) if (FHC_AjaxClient.hasData(data)) { - var messages = FHC_AjaxClient.getData(data); + var messages = null; + + try + { + messages = JSON.parse(FHC_AjaxClient.getData(data)); + } + catch (syntaxError) {} if ($.isArray(messages)) { try { - tableMessageLst.replaceData(JSON.parse()); + tableMessageLst.replaceData(messages); } catch (syntaxError) { @@ -141,10 +173,39 @@ function _getMessages(getMessagesURL) } /** - * Start! + * Open new tab/window to write a new message + */ +function writeNewMessage() +{ + window.open("write", "_blank"); +} + +/** + * Open new tab/window to reply to a received message + */ +function replyMessage() +{ + var selectedMessages = tableMessageLst.getSelectedData(); + + if ($.isArray(selectedMessages)) + { + var selectedMessage = selectedMessages[0]; + + window.open("writeReply?token=" + selectedMessage.token, "_blank"); + } + else // + { + FHC_DialogLib.alertInfo("Please select a message"); + } +} + +/** + * Start me up! */ $(document).ready(function () { + $("#replyMessage").hide(); + // TinyMCE initialization tinymce.init({ selector: "#readMessagePanel", @@ -153,14 +214,15 @@ $(document).ready(function () { toolbar: false, statusbar: false, readonly: 1, - autoresize_min_height: 200, + autoresize_min_height: 300, autoresize_bottom_margin: 0 }); // Tabulator initialization tableMessageLst = new Tabulator("#lstMessagesPanel", { - height: "400px", + height: "270px", layout: "fitColumns", + selectable: 1, layoutColumnsOnNewData: true, columns: [ {title: "Subject", field: "subject", responsive: 0}, @@ -175,6 +237,12 @@ $(document).ready(function () { // Bind radio buttons click event with toggleMessages function $("#toggleMessages input").click(toggleMessages); + // Bind write a new message button + $("#writeMessage").click(writeNewMessage); + + // Bind reply to a message button + $("#replyMessage").click(replyMessage); + // First retrieve the received message and populate the tabulator getReceivedMessages(); diff --git a/public/js/messaging/writeReply.js b/public/js/messaging/writeReply.js new file mode 100644 index 000000000..aeb13dc2c --- /dev/null +++ b/public/js/messaging/writeReply.js @@ -0,0 +1,48 @@ +// **************************************************************************************** +// Write a reply to a received message, used by view system/messages/ajaxWriteReply +// **************************************************************************************** + +/** + * + */ +function sendReply() +{ + FHC_AjaxClient.ajaxCallPost( + FHC_JS_DATA_STORAGE_OBJECT.called_path + '/sendMessageReply', + { + receiver_id: $('#receiver_id').val(), + relationmessage_id: $('#relationmessage_id').val(), + token: $('#token').val(), + subject: $('#subject').html(), + body: tinyMCE.get("body").getContent() + }, + { + successCallback: function(data, textStatus, jqXHR) { + + FHC_DialogLib.alertSuccess("Message sent succesfully"); + }, + errorCallback: function() { + FHC_DialogLib.alertError("Error"); + }, + veilTimeout: 300 + } + ); +} + +/** + * + */ +$(document).ready(function () { + + // + tinymce.init({ + selector: "#body", + plugins: "autoresize", + autoresize_min_height: 150, + autoresize_max_height: 600, + autoresize_bottom_margin: 10 + }); + + $('#sendButton').click(sendReply); + +}); From ece06bc462971022917b2b81fbfc5ad7fc622281 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 6 Nov 2019 16:34:20 +0100 Subject: [PATCH 022/138] Notice email for all people allowed to receive messages for an organisation unit --- application/libraries/MessageLib.php | 12 +++++++++--- application/models/system/Recipient_model.php | 6 +++--- public/js/messaging/write.js | 10 +++++++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 9224996c8..cff457a77 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -528,17 +528,23 @@ class MessageLib if (isError($messageResult)) return $messageResult; // if an error occured then return it if (!hasData($messageResult)) return error('No data found with the given message id'); // if no data found then return an error + // If the message was sent to an organisation unit, then retrives the allowed people to receive the notice email for that organisation unit $messages = getData($messageResult); - if (count($messages) == 1 && $messages[0]->receiver_id == $this->_ci->config->item(self::CFG_SYSTEM_PERSON_ID)) + if (count($messages) == 1 + && $messages[0]->receiver_id == $this->_ci->config->item(self::CFG_SYSTEM_PERSON_ID) + && !isEmptyString($messages[0]->oe_kurzbz)) { - $messages = $this->_ci->RecipientModel->getReceivedMessagesByOE( + $messageResult = $this->_ci->RecipientModel->getMessagesToSentToOE( $messages[0]->oe_kurzbz, $this->_ci->config->item(MessageLib::CFG_OU_RECEIVERS), self::EMAIL_KONTAKT_TYPE ); } - return $this->_sendNotice($messages); + if (isError($messageResult)) return $messageResult; + if (!hasData($messageResult)) return error('It is not possible to retrieve the recipient for this message: '.$message_id); + + return $this->_sendNotice(getData($messageResult)); } /** diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 76a0bf435..4d5e4b986 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -379,9 +379,9 @@ class Recipient_model extends DB_Model } /** - * Gets only the recieved messages from an organisation unit where this person plays a role given by the parameter functions + * Get all the messages to sent to an organisation unit */ - public function getReceivedMessagesByOE($oe_kurzbz, $functions, $kontaktType) + public function getMessagesToSentToOE($oe_kurzbz, $functions, $kontaktType) { // Messages sent to a person that belongs to the recipient organisation unit $sql = 'SELECT mm.message_id, @@ -427,7 +427,7 @@ class Recipient_model extends DB_Model ) mb ON (mb.person_id = mm.person_id) WHERE bf.oe_kurzbz = ? AND mrou.sent IS NULL - AND mrou.sentinfo IS NOT NULL + AND mrou.sentinfo IS NULL GROUP BY mm.message_id, mm.subject, mm.body, diff --git a/public/js/messaging/write.js b/public/js/messaging/write.js index 180a47c36..7be07f28a 100644 --- a/public/js/messaging/write.js +++ b/public/js/messaging/write.js @@ -22,7 +22,15 @@ function sendMessageToOU() }, { successCallback: function(data, textStatus, jqXHR) { - FHC_DialogLib.alertSuccess("Message sent succesfully"); + + if (FHC_AjaxClient.isSuccess(data)) + { + FHC_DialogLib.alertSuccess("Message sent succesfully"); + } + else + { + FHC_DialogLib.alertError("Error"); + } }, errorCallback: function() { FHC_DialogLib.alertError("Error"); From 565cf93f5d1f8177245cd8078c7c7be25cb30ec3 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 14 Nov 2019 13:49:31 +0100 Subject: [PATCH 023/138] - Messages GUI multilingual - Tabulator refresh fixed --- application/views/system/messages/ajaxRead.php | 1 + application/views/system/messages/ajaxWrite.php | 13 ++++++++----- .../views/system/messages/ajaxWriteReply.php | 11 ++++++----- .../views/system/messages/htmlWriteTemplate.php | 1 + public/js/messaging/messageWrite.js | 4 ++-- public/js/messaging/messageWriteReply.js | 2 +- public/js/messaging/read.js | 6 ++++-- public/js/messaging/write.js | 8 ++++---- 8 files changed, 27 insertions(+), 19 deletions(-) diff --git a/application/views/system/messages/ajaxRead.php b/application/views/system/messages/ajaxRead.php index 1e4dbd187..2ff1f6cbb 100644 --- a/application/views/system/messages/ajaxRead.php +++ b/application/views/system/messages/ajaxRead.php @@ -13,6 +13,7 @@ 'ajaxlib' => true, 'dialoglib' => true, 'tinymce' => true, + 'phrases' => array('global', 'ui'), 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/read.js') ) diff --git a/application/views/system/messages/ajaxWrite.php b/application/views/system/messages/ajaxWrite.php index 88767628c..6080f3eef 100644 --- a/application/views/system/messages/ajaxWrite.php +++ b/application/views/system/messages/ajaxWrite.php @@ -11,6 +11,7 @@ 'ajaxlib' => true, 'dialoglib' => true, 'tinymce' => true, + 'phrases' => array('global', 'ui'), 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/write.js') ) @@ -22,13 +23,13 @@
- +
- +

- +
diff --git a/application/views/system/messages/ajaxWriteReply.php b/application/views/system/messages/ajaxWriteReply.php index 25602271c..36d999fc0 100644 --- a/application/views/system/messages/ajaxWriteReply.php +++ b/application/views/system/messages/ajaxWriteReply.php @@ -11,6 +11,7 @@ 'ajaxlib' => true, 'dialoglib' => true, 'tinymce' => true, + 'phrases' => array('global', 'ui'), 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/writeReply.js') ) @@ -22,13 +23,13 @@
- +
- +
@@ -40,7 +41,7 @@
- +
 
@@ -53,7 +54,7 @@
- + + +
+ +
+ p->t('ui', 'altRecipientNote'); ?> +

diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index f0c66b758..e4ea4aacb 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -4174,6 +4174,26 @@ When on hold, the date is only a reminder.', 'insertvon' => 'system' ) ) + ), + array( + 'app' => 'core', + 'category' => 'ui', + 'phrase' => 'altRecipientNote', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => '* This is a notice to notice you that you have been noticed DE', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => '* This is a notice to notice you that you have been noticed', + 'description' => '', + 'insertvon' => 'system' + ) + ) ) ); From 53ac4d11ba33eb31c5350d3b50a545cce15eebe6 Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 4 Feb 2020 14:42:53 +0100 Subject: [PATCH 040/138] Do not retrieve the degree program name from studiengang table but directly from the organization unit table in student sent messages page and student write to organisation unit page --- application/models/CL/Messages_model.php | 4 ++-- application/models/crm/Prestudent_model.php | 7 ++++--- application/models/system/Recipient_model.php | 15 +++++---------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 84f4e59aa..87eff0f99 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -183,7 +183,7 @@ class Messages_model extends CI_Model public function prepareAjaxReadSent() { // Retrieves sent messages from the logged user - $sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId(), self::ALT_OE); + $sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId()); if (isError($sentMessagesResult)) return $sentMessagesResult; // If an error occurred return it if (hasData($sentMessagesResult)) @@ -205,7 +205,7 @@ class Messages_model extends CI_Model if ($sentMessage->person_id == $this->config->item(MessageLib::CFG_SYSTEM_PERSON_ID)) { - $jsonRecord->to = $sentMessage->sg; + $jsonRecord->to = $sentMessage->oe; } else { diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index 5b74ed5e4..94d77f8d3 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -524,11 +524,12 @@ class Prestudent_model extends DB_Model /** * Get organisation units for all the prestudents of a person + * TODO */ public function getOrganisationunitsByPersonId($person_id) { $query = 'SELECT o.oe_kurzbz, - sg.bezeichnung, + o.bezeichnung, ps.prestudent_id FROM public.tbl_prestudent p JOIN public.tbl_studiengang sg USING(studiengang_kz) @@ -541,9 +542,9 @@ class Prestudent_model extends DB_Model ) ps USING(prestudent_id) WHERE p.person_id = ? GROUP BY o.oe_kurzbz, - sg.bezeichnung, + o.bezeichnung, ps.prestudent_id - ORDER BY sg.bezeichnung'; + ORDER BY o.bezeichnung'; return $this->execQuery($query, array($person_id)); } diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 8f5dfa397..c2acd2d56 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -446,7 +446,7 @@ class Recipient_model extends DB_Model /** * Gets all the sent message by the given person */ - public function getSentMessages($person_id, $altOe = '') + public function getSentMessages($person_id) { $sql = 'SELECT mm.message_id, mm.relationmessage_id, @@ -458,18 +458,13 @@ class Recipient_model extends DB_Model p.nachname, MAX(ms.status) AS status, ms.person_id AS statusPersonId, - sg.bezeichnung AS sg, + oe.bezeichnung AS oe, mr.token FROM public.tbl_msg_message mm JOIN public.tbl_msg_recipient mr ON (mr.message_id = mm.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND mr.person_id = mr.person_id) JOIN public.tbl_person p ON (p.person_id = mr.person_id) - LEFT JOIN ( - SELECT oe_kurzbz, bezeichnung - FROM public.tbl_studiengang - UNION - SELECT ?, ? - ) sg ON (sg.oe_kurzbz = mr.oe_kurzbz) + JOIN public.tbl_organisationseinheit oe ON (oe.oe_kurzbz = mr.oe_kurzbz) WHERE mm.person_id = ? AND mr.sent IS NOT NULL AND mr.sentinfo IS NULL @@ -482,10 +477,10 @@ class Recipient_model extends DB_Model p.vorname, p.nachname, ms.person_id, - sg.bezeichnung, + oe.bezeichnung, mr.token ORDER BY mr.sent DESC'; - return $this->execQuery($sql, array($altOe, ucfirst($altOe), $person_id)); + return $this->execQuery($sql, array($person_id)); } } From 749e9be64d0d996642c6e8fce6756ed412f247c5 Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 4 Feb 2020 17:02:25 +0100 Subject: [PATCH 041/138] Messaging system: student writes new message: separate logic for master and bachelor --- application/models/crm/Prestudent_model.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index 94d77f8d3..b40897d82 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -524,26 +524,30 @@ class Prestudent_model extends DB_Model /** * Get organisation units for all the prestudents of a person - * TODO */ public function getOrganisationunitsByPersonId($person_id) { $query = 'SELECT o.oe_kurzbz, o.bezeichnung, - ps.prestudent_id + (CASE + WHEN sg.typ = \'b\' THEN ps.prestudent_id + WHEN sg.typ = \'m\' THEN p.prestudent_id + ELSE NULL + END) AS prestudent_id FROM public.tbl_prestudent p JOIN public.tbl_studiengang sg USING(studiengang_kz) JOIN public.tbl_organisationseinheit o USING(oe_kurzbz) LEFT JOIN ( SELECT prestudent_id FROM public.tbl_prestudentstatus - WHERE bestaetigtam IS NOT NULL - AND status_kurzbz = \'Interessent\' + WHERE status_kurzbz = \'Bewerber\' ) ps USING(prestudent_id) WHERE p.person_id = ? GROUP BY o.oe_kurzbz, o.bezeichnung, - ps.prestudent_id + sg.typ, + ps.prestudent_id, + p.prestudent_id ORDER BY o.bezeichnung'; return $this->execQuery($query, array($person_id)); From a5ad57ceeefa9b5825646848783229643d3ca400 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 4 Feb 2020 17:53:32 +0100 Subject: [PATCH 042/138] =?UTF-8?q?testtool/admin/edit=5Fgebiet.php:=20Off?= =?UTF-8?q?setpunkte=20k=C3=B6nnen=20nun=20=C3=BCber=20admin=20GUI=20einge?= =?UTF-8?q?tragen=20werden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cis/testtool/admin/edit_gebiet.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cis/testtool/admin/edit_gebiet.php b/cis/testtool/admin/edit_gebiet.php index afe81dae7..474546d4a 100644 --- a/cis/testtool/admin/edit_gebiet.php +++ b/cis/testtool/admin/edit_gebiet.php @@ -186,6 +186,7 @@ if (isset($_POST['speichern'])) $gebiet->zufallvorschlag = isset($_POST['zufallvorschlag']); $gebiet->levelgleichverteilung = isset($_POST['levelgleichverteilung']); $gebiet->maxpunkte = $_POST['maxpunkte']; + $gebiet->offsetpunkte = $_POST['offsetpunkte']; $gebiet->maxfragen = $_POST['maxfragen']; $gebiet->level_start = $_POST['level_start']; $gebiet->level_sprung_auf = $_POST['level_sprung_auf']; @@ -257,6 +258,8 @@ if ($gebiet_id != '') $hinweis = ''; echo 'Maximale Punkteanzahl'.$hinweis.''; echo ''; + echo 'Offsetpunkte (minimale Punkteanzahl)'; + echo ''; echo 'Maximale Fragenanzahl'; echo ''; echo 'Antworten pro Zeile'; From e724f7159fe4f2a017ea7fd0c8b8af66ec9de297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Fri, 7 Feb 2020 11:31:08 +0100 Subject: [PATCH 043/138] Datentyp der Offsetpunkte auf Numeric korrigiert --- system/dbupdate_3.3.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index af529bab4..703e40857 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -3452,7 +3452,7 @@ if(!$result = @$db->db_query("SELECT 1 FROM fue.tbl_projekttyp LIMIT 1")) // Add column offset to testtool.tbl_gebiet if(!$result = @$db->db_query("SELECT offsetpunkte FROM testtool.tbl_gebiet LIMIT 1")) { - $qry = "ALTER TABLE testtool.tbl_gebiet ADD COLUMN offsetpunkte smallint"; + $qry = "ALTER TABLE testtool.tbl_gebiet ADD COLUMN offsetpunkte numeric(8,4)"; if(!$db->db_query($qry)) echo 'testtool.tbl_gebiet: '.$db->db_last_error().'
'; From 7fdaaace50f6bc74554f3bb004f948eccb15c217 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 7 Feb 2020 17:46:29 +0100 Subject: [PATCH 044/138] If Prestudent is freigegeben for RT and has already a Bewerber with reihungstestangetreten = true, a new Bewerber for the prestudent is created, reihungstestangetreten and teilgenommen are set to true --- .../system/infocenter/InfoCenter.php | 67 ++++++++++++++++++- application/models/person/Person_model.php | 19 ++++++ 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index d085e7db0..e4d2c4e21 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -69,6 +69,7 @@ class InfoCenter extends Auth_Controller // Name of Interessentenstatus const INTERESSENTSTATUS = 'Interessent'; const ABGEWIESENERSTATUS = 'Abgewiesener'; + const BEWERBERSTATUS = 'Bewerber'; // Statusgruende for which no Studiengangsfreigabemessage should be sent private $_statusgruendeNoStgFreigabeMessage = array('FIT Programm', 'FIT program', 'FIT programme'); @@ -493,7 +494,9 @@ class InfoCenter extends Auth_Controller $logdata = $this->_getPersonAndStudiengangFromPrestudent($prestudent_id); - $akteresult = $this->AkteModel->loadWhere(array('person_id' => $logdata['person_id'], 'formal_geprueft_amum !=' => NULL)); + $person_id = $logdata['person_id']; + + $akteresult = $this->AkteModel->loadWhere(array('person_id' => $person_id, 'formal_geprueft_amum !=' => NULL)); if (hasData($lastStatus) && isSuccess($akteresult)) { @@ -554,8 +557,68 @@ class InfoCenter extends Auth_Controller if (hasData($statusgrund_kurzbz)) $logparams[2] = ', confirmation type '.$statusgrund_kurzbz->retval[0]->bezeichnung_mehrsprachig[0]; } + else + { + // check if there is already a Bewerberstatus and Reihungsverfahren already absolviert + $bewerber = $this->PersonModel->hasBewerber($person_id, $lastStatus->studiensemester_kurzbz); - $this->_log($logdata['person_id'], 'freigegeben', $logparams); + if (hasData($bewerber)) + { + $bewerbercnt = getData($bewerber); + + if (is_numeric($bewerbercnt[0]->anzahl_bewerber) && $bewerbercnt[0]->anzahl_bewerber > 0) + { + // then insert Bewerberstatus and rt absolviert, teilgenommen for prestudent + $bewerberresult = $this->PrestudentstatusModel->insert( + array( + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => self::BEWERBERSTATUS, + 'studiensemester_kurzbz' => $lastStatus->studiensemester_kurzbz, + 'ausbildungssemester' => $lastStatus->ausbildungssemester, + 'datum' => date('Y-m-d'), + 'orgform_kurzbz' => $lastStatus->orgform_kurzbz, + 'studienplan_id' => $lastStatus->studienplan_id, + 'insertvon' => $this->_uid, + 'insertamum' => date('Y-m-d H:i:s') + ) + ); + + if (isError($bewerberresult)) + $json->retval['nonCriticalErrors'] = 'error when inserting Bewerberstatus'; + + $rtangetretenres = $this->PrestudentModel->update( + $prestudent_id, + array( + 'reihungstestangetreten' => true + ) + ); + + if (isError($rtangetretenres)) + { + $json->retval['nonCriticalErrors'] = 'error when setting reihungstestangetreten'; + } + else + { + $this->load->model('crm/RtPerson_model', 'RtPersonModel'); + + $rtteilgenommenres = $this->RtPersonModel->update( + array( + 'person_id' => $person_id, + 'studienplan_id' => $lastStatus->studienplan_id + ), + array( + 'teilgenommen' => true + ) + ); + + if (isError($rtteilgenommenres)) + $json->retval['nonCriticalErrors'] = 'error when setting reihungstest teilgenommen'; + } + } + } + } + + $this->_log($person_id, 'freigegeben', $logparams); $this->_sendFreigabeMail($prestudent_id); } diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index 388f77b0a..4f826dac1 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -213,4 +213,23 @@ class Person_model extends DB_Model return $this->loadWhere(array('uid' => $uid, 'content' => true)); } + + /** + * Checks if a person has a Bewerberstatus and reihungstestangetreten = true + * @param $person_id + * @param $studiensemester_kurzbz + * @return array + */ + public function hasBewerber($person_id, $studiensemester_kurzbz) + { + $qry = "SELECT count(*) AS anzahl_bewerber FROM public.tbl_person + JOIN public.tbl_prestudent USING (person_id) + JOIN public.tbl_prestudentstatus ON tbl_prestudentstatus.prestudent_id = tbl_prestudent.prestudent_id + WHERE person_id = ? + AND studiensemester_kurzbz = ? + AND status_kurzbz = 'Bewerber' + AND reihungstestangetreten"; + + return $this->execQuery($qry, array($person_id, $studiensemester_kurzbz)); + } } From 5953b6932f45c67d6d596ec0617c36929947fe14 Mon Sep 17 00:00:00 2001 From: Cris Date: Mon, 10 Feb 2020 15:42:34 +0100 Subject: [PATCH 045/138] Bufixed Chromes autofilling username in random input field If no username input field is required, Chorme is autofilling a random inputfield with username. This is a Chrome bug. Workaround by adding a hidden username field. Also setting autocomplete= new-password should help stopping random autofill in some browsers. --- .../views/lehre/lehrauftrag/acceptLehrauftrag.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/application/views/lehre/lehrauftrag/acceptLehrauftrag.php b/application/views/lehre/lehrauftrag/acceptLehrauftrag.php index 14ebacecb..3f2575ec1 100644 --- a/application/views/lehre/lehrauftrag/acceptLehrauftrag.php +++ b/application/views/lehre/lehrauftrag/acceptLehrauftrag.php @@ -166,12 +166,13 @@ $this->load->view(
-
- - - - -
+
+ + + + + +

From d5e8d33adcc3b0447cd65f90a819cfdd84a62e1d Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 11 Feb 2020 10:28:43 +0100 Subject: [PATCH 046/138] public.vw_msg_vars: added orgform_kurzbz for tbl_bankverbindung --- system/dbupdate_3.3.php | 107 +++++++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 44 deletions(-) diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index 7721fefa4..a7d4011cc 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -3449,6 +3449,18 @@ if(!$result = @$db->db_query("SELECT 1 FROM fue.tbl_projekttyp LIMIT 1")) echo '
fue.tbl_projekttyp hinzugefuegt.'; } +// Add column orgform_kurzbz to tbl_bankverbindung +if(!$result = @$db->db_query("SELECT orgform_kurzbz FROM public.tbl_bankverbindung LIMIT 1")) +{ + $qry = "ALTER TABLE public.tbl_bankverbindung ADD COLUMN orgform_kurzbz varchar(3); + ALTER TABLE public.tbl_bankverbindung ADD CONSTRAINT fk_bankverbindung_orgform FOREIGN KEY (orgform_kurzbz) REFERENCES bis.tbl_orgform (orgform_kurzbz) ON DELETE RESTRICT ON UPDATE CASCADE;"; + + if(!$db->db_query($qry)) + echo 'public.tbl_bankverbindung: '.$db->db_last_error().'
'; + else + echo '
public.tbl_bankverbindung: Spalte orgform_kurzbz hinzugefuegt'; +} + // iban und bic zu vw_msg_vars hinzufügen if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang" FROM public.vw_msg_vars LIMIT 1')) { @@ -3469,53 +3481,60 @@ if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang" FROM s.bezeichnung AS "Studiengang DE", s.english AS "Studiengang EN", st.bezeichnung AS "Typ", - orgform_kurzbz AS "Orgform", + last_prestudent_status.orgform_kurzbz AS "Orgform", p.zugangscode AS "Zugangscode", bk.iban AS "IBAN Studiengang", bk.bic AS "BIC Studiengang" FROM public.tbl_person p - LEFT JOIN ( - SELECT person_id, - kontakt - FROM public.tbl_kontakt - WHERE zustellung = TRUE - AND kontakttyp = \'email\' - ORDER BY kontakt_id DESC - ) ke USING(person_id) - LEFT JOIN ( - SELECT person_id, - kontakt - FROM public.tbl_kontakt - WHERE zustellung = TRUE - AND kontakttyp IN (\'telefon\', \'mobil\') - ORDER BY kontakt_id DESC - ) kt USING(person_id) - LEFT JOIN ( - SELECT person_id, - strasse, - ort, - plz, - gemeinde, - langtext - FROM public.tbl_adresse - LEFT JOIN bis.tbl_nation ON(bis.tbl_nation.nation_code = public.tbl_adresse.nation) - WHERE public.tbl_adresse.heimatadresse = TRUE - ORDER BY adresse_id DESC - ) a USING(person_id) - LEFT JOIN public.tbl_prestudent pr USING(person_id) - INNER JOIN public.tbl_studiengang s USING(studiengang_kz) - INNER JOIN public.tbl_studiengangstyp st USING(typ) - LEFT JOIN ( SELECT DISTINCT ON (prestudent_id) - tbl_prestudent.prestudent_id, - tbl_bankverbindung.iban, - tbl_bankverbindung.bic, - tbl_studiengang.oe_kurzbz - FROM public.tbl_bankverbindung - JOIN public.tbl_studiengang USING(oe_kurzbz) - JOIN public.tbl_prestudent USING (studiengang_kz) - ORDER BY prestudent_id, tbl_bankverbindung.insertamum DESC, iban) bk USING (prestudent_id) - WHERE p.aktiv = TRUE - ORDER BY p.person_id ASC, pr.prestudent_id ASC + LEFT JOIN ( + SELECT person_id, + kontakt + FROM public.tbl_kontakt + WHERE zustellung = TRUE + AND kontakttyp = \'email\' + ORDER BY kontakt_id DESC + ) ke USING(person_id) + LEFT JOIN ( + SELECT person_id, + kontakt + FROM public.tbl_kontakt + WHERE zustellung = TRUE + AND kontakttyp IN (\'telefon\', \'mobil\') + ORDER BY kontakt_id DESC + ) kt USING(person_id) + LEFT JOIN ( + SELECT person_id, + strasse, + ort, + plz, + gemeinde, + langtext + FROM public.tbl_adresse + LEFT JOIN bis.tbl_nation ON(bis.tbl_nation.nation_code = public.tbl_adresse.nation) + WHERE public.tbl_adresse.heimatadresse = TRUE + ORDER BY adresse_id DESC + ) a USING(person_id) + LEFT JOIN public.tbl_prestudent pr USING(person_id) + INNER JOIN public.tbl_studiengang s USING(studiengang_kz) + INNER JOIN public.tbl_studiengangstyp st USING(typ) + LEFT JOIN ( + SELECT DISTINCT ON (ps.prestudent_id) tbl_studienplan.orgform_kurzbz, ps.prestudent_id + FROM public.tbl_prestudent ps + JOIN public.tbl_prestudentstatus ON ps.prestudent_id = tbl_prestudentstatus.prestudent_id + JOIN lehre.tbl_studienplan USING(studienplan_id) + ORDER BY ps.prestudent_id DESC, + tbl_prestudentstatus.datum DESC, + tbl_prestudentstatus.insertamum DESC, + tbl_prestudentstatus.ext_id DESC + ) last_prestudent_status ON pr.prestudent_id = last_prestudent_status.prestudent_id + LEFT JOIN ( + SELECT DISTINCT ON (oe_kurzbz, orgform_kurzbz) oe_kurzbz, orgform_kurzbz, iban, bic + FROM tbl_bankverbindung + WHERE oe_kurzbz IS NOT NULL + ORDER BY oe_kurzbz, orgform_kurzbz, tbl_bankverbindung.insertamum DESC,tbl_bankverbindung.iban + )bk ON s.oe_kurzbz = bk.oe_kurzbz AND (last_prestudent_status.orgform_kurzbz = bk.orgform_kurzbz OR bk.orgform_kurzbz IS NULL) + WHERE p.aktiv = TRUE + ORDER BY p.person_id ASC, pr.prestudent_id ASC );'; if(!$db->db_query($qry)) @@ -3682,7 +3701,7 @@ $tabellen=array( "public.tbl_aufnahmeschluessel" => array("aufnahmeschluessel"), "public.tbl_aufnahmetermin" => array("aufnahmetermin_id","aufnahmetermintyp_kurzbz","prestudent_id","termin","teilgenommen","bewertung","protokoll","insertamum","insertvon","updateamum","updatevon","ext_id"), "public.tbl_aufnahmetermintyp" => array("aufnahmetermintyp_kurzbz","bezeichnung"), - "public.tbl_bankverbindung" => array("bankverbindung_id","person_id","name","anschrift","bic","blz","iban","kontonr","typ","verrechnung","updateamum","updatevon","insertamum","insertvon","ext_id","oe_kurzbz"), + "public.tbl_bankverbindung" => array("bankverbindung_id","person_id","name","anschrift","bic","blz","iban","kontonr","typ","verrechnung","updateamum","updatevon","insertamum","insertvon","ext_id","oe_kurzbz", "orgform_kurzbz"), "public.tbl_benutzer" => array("uid","person_id","aktiv","alias","insertamum","insertvon","updateamum","updatevon","ext_id","updateaktivvon","updateaktivam","aktivierungscode"), "public.tbl_benutzerfunktion" => array("benutzerfunktion_id","fachbereich_kurzbz","uid","oe_kurzbz","funktion_kurzbz","semester", "datum_von","datum_bis", "updateamum","updatevon","insertamum","insertvon","ext_id","bezeichnung","wochenstunden"), "public.tbl_benutzergruppe" => array("uid","gruppe_kurzbz","studiensemester_kurzbz","updateamum","updatevon","insertamum","insertvon","ext_id"), From ba7b4cf3ade316824d9004b0b2cab0887a4820bc Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Tue, 11 Feb 2020 14:41:21 +0100 Subject: [PATCH 047/138] New Unique Index unq_idx_ablauf_gebiet_studiengang_semester MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UNIQUE INDEX unq_idx_ablauf_gebiet_studiengang_semester in testtool.tbl_ablauf löschen und durch neuen INDEX ersetzen, der auch den Studienplan einschließt --- system/dbupdate_3.3.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index f100f2115..09d5e000a 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -3525,6 +3525,20 @@ if($result = $db->db_query("SELECT * FROM pg_proc WHERE proname = 'transform_ges echo '
Function transform_geschlecht hinzugefügt.'; } } +// UNIQUE INDEX unq_idx_ablauf_gebiet_studiengang_semester in testtool.tbl_ablauf löschen und durch neuen INDEX ersetzen, der auch den Studienplan einschließt +if ($result = $db->db_query("SELECT 1 FROM pg_class WHERE relname = 'unq_idx_ablauf_gebiet_studiengang_semester'")) +{ + if ($db->db_num_rows($result) == 1) + { + $qry = 'DROP INDEX testtool.unq_idx_ablauf_gebiet_studiengang_semester;'; + $qry .= 'CREATE UNIQUE INDEX unq_idx_ablauf_gebiet_studiengang_semester_studienplan ON testtool.tbl_ablauf USING btree (gebiet_id, studiengang_kz, semester, studienplan_id);'; + if (!$db->db_query($qry)) + echo 'unq_idx_ablauf_gebiet_studiengang_semester_studienplan '.$db->db_last_error().'
'; + else + echo '
Dropped index "unq_idx_ablauf_gebiet_studiengang_semester" and created unique index "unq_idx_ablauf_gebiet_studiengang_semester_studienplan"'; + } +} + // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen echo '

Pruefe Tabellen und Attribute!

'; From 11231b99c2d9a97ebb3885c5dfb0e6bdfa20157e Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Tue, 11 Feb 2020 14:41:59 +0100 Subject: [PATCH 048/138] Fallback Sprache --- cis/testtool/frage.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cis/testtool/frage.php b/cis/testtool/frage.php index f15c2c2d2..a760d00aa 100644 --- a/cis/testtool/frage.php +++ b/cis/testtool/frage.php @@ -460,6 +460,12 @@ if($frage->frage_id!='') $frage_id = $frage->frage_id; $frage->getFrageSprache($frage_id, $_SESSION['sprache_user']); + // Fallback auf DEFAULT_LANGUAGE wenn keine Frage in der $_SESSION['sprache_user'] vorhanden ist + if ($frage->text == '' && $frage->bild == '' && $frage->audio == '') + { + $frage->getFrageSprache($frage_id, DEFAULT_LANGUAGE); + } + if(!$demo) { //Nachschauen ob diese Frage bereits angesehen wurde From 58a67ead5d0420beda1ad78326ba244be203c5a2 Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Tue, 11 Feb 2020 14:42:45 +0100 Subject: [PATCH 049/138] =?UTF-8?q?Ber=C3=BCcksichtigung=20von=20Studienpl?= =?UTF-8?q?an=20bei=20Ablauf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit + Kleine GUI-Anpassungen --- cis/testtool/index.html | 2 +- cis/testtool/login.php | 14 +- cis/testtool/menu.php | 305 ++++++++++++++++++++++------------------ 3 files changed, 174 insertions(+), 147 deletions(-) diff --git a/cis/testtool/index.html b/cis/testtool/index.html index ac39c5deb..02044a4bc 100644 --- a/cis/testtool/index.html +++ b/cis/testtool/index.html @@ -10,7 +10,7 @@ - + <body> diff --git a/cis/testtool/login.php b/cis/testtool/login.php index 477901803..a1bb7b517 100644 --- a/cis/testtool/login.php +++ b/cis/testtool/login.php @@ -66,6 +66,7 @@ $gebdatum=''; $date = new datum(); $reload_menu=false; +$alertmsg = ''; $sg_var = new studiengang(); @@ -189,7 +190,7 @@ if (isset($_POST['prestudent']) && isset($gebdatum)) // * 1. Sprache über Ablauf Vorgaben ermitteln $ablauf = new Ablauf(); - $ablauf->getAblaufVorgabeStudiengang($firstPrio_studiengang_kz); + $ablauf->getAblaufGebiete($firstPrio_studiengang_kz, $firstPrio_studienplan_id); $rt_sprache = ''; if(!empty($ablauf->result[0])) @@ -224,17 +225,17 @@ if (isset($_POST['prestudent']) && isset($gebdatum)) } else { - echo '<span class="error">'.$p->t('testtool/reihungstestNichtFreigeschalten').'</span>'; + $alertmsg .= '<div class="alert alert-danger">'.$p->t('testtool/reihungstestNichtFreigeschalten').'</div>'; } } else { - echo '<span class="error">'.$p->t('testtool/reihungstestKannNichtGeladenWerden').'</span>'; + $alertmsg .= '<div class="alert alert-danger">'.$p->t('testtool/reihungstestKannNichtGeladenWerden').'</div>'; } } else { - echo '<span class="error">'.$p->t('testtool/geburtsdatumStimmtNichtUeberein').'</span>'; + $alertmsg .= '<div class="alert alert-danger">'.$p->t('testtool/geburtsdatumStimmtNichtUeberein').'</div>'; } } @@ -499,7 +500,7 @@ if (isset($prestudent_id)) } elseif($ps_obj->ausbildungssemester == '3') { - echo '<td>'. $p->t('testtool/quereinstieg'). ' (3.Semester)</td>'; + echo '<td>'. $p->t('testtool/quereinstieg'). ' (3. Semester)</td>'; } } // wenn letzter Status \'Abgewiesener\' ist, dann als solchen kennzeichnen @@ -564,7 +565,8 @@ else // LOGIN Site (vor Login) echo '<div class="col-xs-11">'; // Welcome text - echo ' + echo $alertmsg; + echo ' <div class="row" style="margin-bottom: 10%; margin-top: 3%;"> <div class="col-xs-6 text-center" style="border-right: 1px solid lightgrey;"> <h1 style="white-space: normal">Herzlich Willkommen zum Reihungstest</h1><br><br> diff --git a/cis/testtool/menu.php b/cis/testtool/menu.php index 4d075ee9a..8a8c245de 100644 --- a/cis/testtool/menu.php +++ b/cis/testtool/menu.php @@ -69,7 +69,7 @@ if (isset($_SESSION['pruefling_id'])) $result = $db->db_query($qry); echo '<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-right-width:1px;border-right-color:#BCBCBC; border-collapse: separate; - border-spacing: 0 3px;">'; + border-spacing: 0 3px;">'; // Link zur Startseite echo '<tr><td class="ItemTesttool" style="margin-left: 20px;" nowrap> @@ -78,16 +78,16 @@ if (isset($_SESSION['pruefling_id'])) // Link zur Einleitung if ($content_id = $db->db_fetch_object($result)) - { + { if($content_id->content_id!='') - { + { echo ' - <tr id="tr-einleitung"><td class="ItemTesttool" style="margin-left: 20px;" nowrap> - <a class="ItemTesttool navButton" href="../../cms/content.php?content_id='.$content_id->content_id.'&sprache='.$sprache_user.'" target="content">'.$p->t('testtool/einleitung').'</a> - </td></tr> - '; - } - } + <tr id="tr-einleitung"><td class="ItemTesttool" style="margin-left: 20px;" nowrap> + <a class="ItemTesttool navButton" href="../../cms/content.php?content_id='.$content_id->content_id.'&sprache='.$sprache_user.'" target="content">'.$p->t('testtool/einleitung').'</a> + </td></tr> + '; + } + } echo '<tr><td style="padding-left: 20px;" nowrap>'; $studiengang_kz = (isset($_SESSION['studiengang_kz'])) ? $_SESSION['studiengang_kz'] : ''; @@ -98,78 +98,78 @@ if (isset($_SESSION['pruefling_id'])) /** * Spaltennamen-Aliase extrahieren um sie im Outer-Select verwenden zu können - * $bezeichnung_mehrsprachig liefert: bezeichnung_mehrsprachig[1] as bezeichnung_mehrsprachig_1,... - * $bezeichnung_mehrsprachig_sel liefert: bezeichnung_mehrsprachig_1, bezeichnung_mehrsprachig_2,... + * $bezeichnung_mehrsprachig liefert: bezeichnung_mehrsprachig[1] as bezeichnung_mehrsprachig_1,... + * $bezeichnung_mehrsprachig_sel liefert: bezeichnung_mehrsprachig_1, bezeichnung_mehrsprachig_2,... */ $bezeichnung_mehrsprachig_sel = explode(",", $bezeichnung_mehrsprachig); foreach ($bezeichnung_mehrsprachig_sel as &$bm) - { - $bm = strrchr($bm, ' as '); - } + { + $bm = strrchr($bm, ' as '); + } $bezeichnung_mehrsprachig_sel = implode(', ', $bezeichnung_mehrsprachig_sel); /** * Reihungstestgebiete der Person ermitteln; Zusammenfassen, falls RT für mehrere Studien - * 1. Aktuelle Prestudenten zur Person über den Prüfling ermitteln, - * 2. Einstiegssemester (Erstsemester/Quereinsteiger) und Studienplan pro Prestudent ermitteln, - * 3. RT-Gebiete falls vorhanden über Studienplan, sonst über STG ermitteln - * 4. Für Quereinsteiger zusätzlich auch Erstsemestrigen-Gebiete + * 1. Aktuelle Prestudenten zur Person über den Prüfling ermitteln, + * 2. Einstiegssemester (Erstsemester/Quereinsteiger) und Studienplan pro Prestudent ermitteln, + * 3. RT-Gebiete falls vorhanden über Studienplan, sonst über STG ermitteln + * 4. Für Quereinsteiger zusätzlich auch Erstsemestrigen-Gebiete */ $qry = " - WITH prestudent_data AS - ( - SELECT DISTINCT ON (prestudent_id) - prestudent_id, - studienplan_id, - studiengang_kz, - typ, + WITH prestudent_data AS + ( + SELECT DISTINCT ON (prestudent_id) + prestudent_id, + studienplan_id, + studiengang_kz, + typ, tbl_studiengangstyp.bezeichnung AS typ_bz, - ausbildungssemester AS semester - FROM - public.tbl_prestudentstatus AS ps_status - JOIN - public.tbl_prestudent USING (prestudent_id) - JOIN - public.tbl_studiengang USING (studiengang_kz) - JOIN - public.tbl_studiengangstyp USING (typ) - WHERE - tbl_prestudent.person_id = ( - SELECT - person_id - FROM - public.tbl_prestudent - WHERE - prestudent_id = ".$db->db_add_param($_SESSION['prestudent_id'])." - ) + ausbildungssemester AS semester + FROM + public.tbl_prestudentstatus AS ps_status + JOIN + public.tbl_prestudent USING (prestudent_id) + JOIN + public.tbl_studiengang USING (studiengang_kz) + JOIN + public.tbl_studiengangstyp USING (typ) + WHERE + tbl_prestudent.person_id = ( + SELECT + person_id + FROM + public.tbl_prestudent + WHERE + prestudent_id = ".$db->db_add_param($_SESSION['prestudent_id'])." + ) - /* Filter only future studiensemester (incl. actual one) */ - AND - studiensemester_kurzbz IN ( - SELECT - studiensemester_kurzbz - FROM - public.tbl_studiensemester - WHERE - ende > now() - ) + /* Filter only future studiensemester (incl. actual one) */ + AND + studiensemester_kurzbz IN ( + SELECT + studiensemester_kurzbz + FROM + public.tbl_studiensemester + WHERE + ende > now() + ) - /* Filter out all Abgewiesene */ - AND NOT EXISTS ( - SELECT - 1 - FROM - tbl_prestudentstatus - WHERE - status_kurzbz = 'Abgewiesener' - AND - prestudent_id = ps_status.prestudent_id - ) + /* Filter out all Abgewiesene */ + AND NOT EXISTS ( + SELECT + 1 + FROM + tbl_prestudentstatus + WHERE + status_kurzbz = 'Abgewiesener' + AND + prestudent_id = ps_status.prestudent_id + ) - AND - status_kurzbz = 'Interessent'"; + AND + status_kurzbz = 'Interessent'"; - /* If the logged-in prestudents study is a Bachelor-study, filter only Bachelor-studies */ + /* If the logged-in prestudents study is a Bachelor-study, filter only Bachelor-studies */ if ($stg->typ == 'b') { $qry .= " @@ -184,86 +184,95 @@ if (isset($_SESSION['pruefling_id'])) $qry .= " - /* Order to get last semester when using distinct on */ - ORDER BY - prestudent_id, - datum DESC, - ps_status.insertamum DESC, - ps_status.ext_id DESC - ) + /* Order to get last semester when using distinct on */ + ORDER BY + prestudent_id, + datum DESC, + ps_status.insertamum DESC, + ps_status.ext_id DESC + ) - SELECT DISTINCT ON - (gebiet_id, semester) - semester, - gebiet_id, - STRING_AGG(studiengang_kz::TEXT, ', ' ORDER BY studiengang_kz) AS studiengang_kz_list, - bezeichnung, - MIN(reihung) AS reihung, - ". $bezeichnung_mehrsprachig_sel. " - FROM ( - SELECT - * - FROM ( - (SELECT - prestudent_data.semester AS ps_sem, - gebiet_id, - bezeichnung, - tbl_ablauf.studienplan_id, - tbl_ablauf.studiengang_kz, - tbl_ablauf.semester, - tbl_ablauf.reihung, - ".$bezeichnung_mehrsprachig. " - FROM - prestudent_data - JOIN - testtool.tbl_ablauf USING (studiengang_kz) - JOIN - testtool.tbl_gebiet USING (gebiet_id) - WHERE - (prestudent_data.semester= 1 AND tbl_ablauf.semester = 1) - OR - (prestudent_data.semester= 3 AND tbl_ablauf.semester IN (1,3)) - ) + SELECT DISTINCT ON + (gebiet_id, semester, reihung) + semester, + gebiet_id, + STRING_AGG(studiengang_kz::TEXT, ', ' ORDER BY studiengang_kz) AS studiengang_kz_list, + bezeichnung, + MIN(reihung) AS reihung, + ". $bezeichnung_mehrsprachig_sel. " + FROM ( + SELECT + * + FROM ( + (SELECT + prestudent_data.semester AS ps_sem, + gebiet_id, + bezeichnung, + tbl_ablauf.studienplan_id, + tbl_ablauf.studiengang_kz, + tbl_ablauf.semester, + tbl_ablauf.reihung, + ".$bezeichnung_mehrsprachig. " + FROM + prestudent_data + JOIN + testtool.tbl_ablauf USING (studiengang_kz) + JOIN + testtool.tbl_gebiet USING (gebiet_id) + WHERE + ( + (prestudent_data.semester= 1 AND tbl_ablauf.semester = 1) + OR + (prestudent_data.semester= 3 AND tbl_ablauf.semester IN (1,3)) + ) + AND ( + prestudent_data.studienplan_id = tbl_ablauf.studienplan_id + OR + tbl_ablauf.studienplan_id IS NULL + ) + ) - UNION + UNION - ( - SELECT - prestudent_data.semester AS ps_sem, - gebiet_id, - bezeichnung, - tbl_ablauf.studienplan_id, - tbl_ablauf.studiengang_kz, - tbl_ablauf.semester, - tbl_ablauf.reihung, - ". $bezeichnung_mehrsprachig. " - FROM - prestudent_data - JOIN - testtool.tbl_ablauf USING (studienplan_id) - JOIN - testtool.tbl_gebiet USING (gebiet_id) - WHERE - (prestudent_data.semester= 1 AND tbl_ablauf.semester = 1) - OR - (prestudent_data.semester= 3 AND tbl_ablauf.semester IN (1,3)) - ) - ) temp - ) temp2 + ( + SELECT + prestudent_data.semester AS ps_sem, + gebiet_id, + bezeichnung, + tbl_ablauf.studienplan_id, + tbl_ablauf.studiengang_kz, + tbl_ablauf.semester, + tbl_ablauf.reihung, + ". $bezeichnung_mehrsprachig. " + FROM + prestudent_data + JOIN + testtool.tbl_ablauf USING (studienplan_id) + JOIN + testtool.tbl_gebiet USING (gebiet_id) + WHERE + (prestudent_data.semester= 1 AND tbl_ablauf.semester = 1) + OR + (prestudent_data.semester= 3 AND tbl_ablauf.semester IN (1,3)) + ) + ) temp + ) temp2 - GROUP BY - semester, - gebiet_id, - bezeichnung, + GROUP BY + semester, + gebiet_id, + bezeichnung, ". $bezeichnung_mehrsprachig_sel ." - ORDER BY - semester, - gebiet_id - "; + ORDER BY + semester, + reihung, + gebiet_id + "; $result = $db->db_query($qry); + $anzahlGebiete = $db->db_num_rows($result); $lastsemester = ''; $quereinsteiger_stg = ''; while($row = $db->db_fetch_object($result)) @@ -355,10 +364,22 @@ if (isset($_SESSION['pruefling_id'])) $class='ItemTesttool'; } + // Fallback für Gebietbezeichnung, falls nicht in gewählter Sprache vorhanden + $gebietbezeichnung = $sprache_mehrsprachig->parseSprachResult("bezeichnung_mehrsprachig", $row)[$sprache_user]; + if ($gebietbezeichnung == '') + { + $gebietbezeichnung = $sprache_mehrsprachig->parseSprachResult("bezeichnung_mehrsprachig", $row)[DEFAULT_LANGUAGE]; + + if ($gebietbezeichnung == '') + { + $gebietbezeichnung = $row->bezeichnung; + } + } + echo '<tr> <!--<td width="10" class="ItemTesttoolLeft" nowrap>&nbsp;</td>--> <td class="'.$class.'"> - <a class="'.$class.'" href="frage.php?gebiet_id='.$row->gebiet_id.'" onclick="document.location.reload()" target="content" style="'.$style.'">'.$sprache_mehrsprachig->parseSprachResult("bezeichnung_mehrsprachig", $row)[$sprache_user].'</a> + <a class="'.$class.'" href="frage.php?gebiet_id='.$row->gebiet_id.'" onclick="document.location.reload()" target="content" style="'.$style.'">'.$gebietbezeichnung.'</a> </td> <!--<td width="10" class="ItemTesttoolRight" nowrap>&nbsp;</td>--> </tr>'; @@ -368,9 +389,13 @@ if (isset($_SESSION['pruefling_id'])) $invalid_gebiete = true; } } - echo '</table>'; + if ($anzahlGebiete > 0) + { + echo '</table>'; + } // Link zum Logout + echo '<tr><td class="ItemTesttool" style="margin-left: 20px;" nowrap> <a class="ItemTesttool navButton" href="login.php?logout=true" target="content">Logout</a> </td></tr>'; From 8f915d3c3945dfdee9f9018c613daea2f8393c2b Mon Sep 17 00:00:00 2001 From: Manfred Kindl <kindlm@technikum-wien.at> Date: Tue, 11 Feb 2020 14:44:23 +0100 Subject: [PATCH 050/138] Initial File --- application/controllers/jobs/Priorisation.php | 787 ++++++++++++++++++ 1 file changed, 787 insertions(+) create mode 100644 application/controllers/jobs/Priorisation.php diff --git a/application/controllers/jobs/Priorisation.php b/application/controllers/jobs/Priorisation.php new file mode 100644 index 000000000..7e63eb9b1 --- /dev/null +++ b/application/controllers/jobs/Priorisation.php @@ -0,0 +1,787 @@ +<?php +if (!defined('BASEPATH')) exit('No direct script access allowed'); + +class Priorisation extends CLI_Controller +{ + /** + * Constructor + */ + public function __construct() + { + parent::__construct(); + + // Load models + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + //$this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + //$this->load->model('organisation/Studienplan_model', 'StudienplanModel'); + + // Load helpers + //$this->load->helper('hlp_sancho_helper'); + } + + /** + * runReihungstestJob + */ + public function runReihungstestJob() + { + // Get study plans that have no assigned placement tests yet + $result = $this->ReihungstestModel->checkMissingReihungstest(); + + $missing_rt_arr = array(); + if (hasData($result)) + { + $missing_rt_arr = $result->retval; + } + elseif (isError($result)) + { + show_error(getError($result)); + } + + // Get free places + $result = $this->ReihungstestModel->getFreePlaces(); + + $free_places_arr = array(); + if (hasData($result)) + { + $free_places_arr = $result->retval; + } + elseif (isError($result)) + { + show_error(getError($result)); + } + + // Prepare data for mail template 'ReihungstestJob' + $content_data_arr = $this->_getContentData($missing_rt_arr, $free_places_arr); + + // Send email in Sancho design + if (!empty($missing_rt_arr) || !empty($free_places_arr)) + { + sendSanchoMail( + 'ReihungstestJob', + $content_data_arr, + MAIL_INFOCENTER, + 'Support für die Reihungstest-Verwaltung'); + } + } + + /* + * Sends an email to all assistants of a placement test when an anmeldeschluss has been reached + * + * @param integer $degreeProgram. Kennzahl of Degree Program to check + * @param string $bcc. Optional. BCC-Mailadress to send the Mails to + * @param string $from. Optional. Sender-Mailadress shown to recipient + */ + public function runZentraleReihungstestAnmeldefristAssistenzJob($degreeProgram, $bcc = null, $from = null) + { + // Encode Params + if ($bcc != '') + { + // $bcc can be given as null-string, so check that too + if ($bcc == 'null') + { + $bcc = ''; + } + else + { + $bcc = urldecode($bcc); + } + } + if ($from != '') + { + $from = urldecode($from); + } + + // Get placement tests where registration date was yesterday + $result = $this->ReihungstestModel->checkReachedRegistrationDate($degreeProgram); + + $reachedRegistration_rt_arr = array(); + + if (hasData($result)) + { + $reachedRegistration_rt_arr = $result->retval; + } + elseif (isError($result)) + { + show_error(getError($result)); + } + + $applicants_arr = array(); + + foreach ($reachedRegistration_rt_arr as $reihungstest) + { + $applicants = $this->ReihungstestModel->getApplicantsOfPlacementTestForCronjob($reihungstest->reihungstest_id); + + if (hasData($applicants)) + { + $applicants_arr = $applicants->retval; + } + elseif (isError($applicants)) + { + show_error(getError($applicants)); + } + + // Get all Bachelor-Degree-Programs with Mailadress + $bachelorStudiengeange = $this->StudiengangModel->loadStudiengaengeFromTyp('b'); + $bachelorStudiengeange_arr = array(); + + if (hasData($bachelorStudiengeange)) + { + $bachelorStudiengeange_arr = $bachelorStudiengeange->retval; + } + elseif (isError($bachelorStudiengeange)) + { + show_error(getError($bachelorStudiengeange)); + } + + // If a person ist an applicant of this degree-program send mail with application data + // Otherwise inform assistant, that no applicant is registered in this test + foreach ($bachelorStudiengeange_arr as $bachelorStudiengang) + { + $studiengang_kuerzel = strtoupper($bachelorStudiengang->typ.$bachelorStudiengang->kurzbz); + $applicantCounter = 0; + $mailcontent_data_arr = array(); + foreach ($applicants_arr as $applicant) + { + if ($bachelorStudiengang->studiengang_kz == $applicant->studiengang_kz) + { + $applicantCounter ++; + } + } + if ($applicantCounter == 0) + { + $mailcontent = '<p style="font-family: verdana, sans-serif;">Der Anmeldeschluss für den zentralen Reihungstest am ' . date_format(date_create($reihungstest->datum), 'd.m.Y') . ' um ' . $reihungstest->uhrzeit . ' Uhr wurde gestern erreicht.</p>'; + $mailcontent .= '<p style="font-family: verdana, sans-serif;"><b>Für den Studiengang '.$studiengang_kuerzel.' nehmen keine InteressentInnen an diesem Reihungstest teil</b></p>'; + } + else + { + $mailcontent = '<p style="font-family: verdana, sans-serif;">Der Anmeldeschluss für den zentralen Reihungstest am ' . date_format(date_create($reihungstest->datum), 'd.m.Y') . ' um ' . $reihungstest->uhrzeit . ' Uhr wurde gestern erreicht.</p>'; + $mailcontent .= ' + <p style="font-family: verdana, sans-serif;"><b>' . $applicantCounter . '</b> InteressentIn(nen) des Studiengangs ' . $studiengang_kuerzel . ' nehmen daran teil:</p> + <p style="font-family: verdana, sans-serif;"> + <a href="'.APP_ROOT.'vilesci/stammdaten/auswertung_fhtw.php?reihungstest='.$reihungstest->reihungstest_id.'&studiengang='.$bachelorStudiengang->studiengang_kz.'" target="_blank"> + Liste der Anmeldungen + </a> + </p>'; + } + $mailcontent_data_arr['table'] = $mailcontent; + + // Send email in Sancho design + if (!isEmptyString($mailcontent)) + { + sendSanchoMail( + 'Sancho_ReihungstestteilnehmerJob', + $mailcontent_data_arr, + $bachelorStudiengang->email, + 'Anmeldeschluss Reihungstest ' . date_format(date_create($reihungstest->datum), 'd.m.Y') . ' ' . $reihungstest->uhrzeit . ' Uhr', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg', + $from, + '', + $bcc); + } + } + } + } + + /* + * Checks, if an applicant was assigned to a test after Anmeldefrist and sends an email to all responsible assistants + * + * @param integer $degreeProgram. Kennzahl of Degree Program to check + * @param string $bcc. Optional. BCC-Mailadress to send the Mails to + * @param string $from. Optional. Sender-Mailadress shown to recipient + */ + public function runZentraleReihungstestNachtraeglichHinzugefuegtJob($degreeProgram, $bcc = null, $from = null) + { + // Encode Params + if ($bcc != '') + { + // $bcc can be given as null-string, so check that too + if ($bcc == 'null') + { + $bcc = ''; + } + else + { + $bcc = urldecode($bcc); + } + } + if ($from != '') + { + $from = urldecode($from); + } + + // Get applicants that have been added to a test after Anmeldefrist + $result = $this->ReihungstestModel->getApplicantAssignedAfterDate($degreeProgram); + + $applicants_after_anmeldefrist_arr = array(); + + if (hasData($result)) + { + $applicants_after_anmeldefrist_arr = $result->retval; + } + elseif (isError($result)) + { + show_error(getError($result)); + } + + $studiengang = ''; + $mailReceipients = ''; // String with all mailadresses + $mailcontent_data_arr = array(); + $headerstyle = 'style="background: #DCE4EF; border: 1px solid #FFF; padding: 4px; text-align: left;"'; + $rowstyle = 'style="background-color: #EEEEEE; padding: 4px;"'; + $mailcontent = ''; + $applicants_list = ''; + + if (count($applicants_after_anmeldefrist_arr) > 0) + { + foreach ($applicants_after_anmeldefrist_arr as $applicant) + { + if ($studiengang != $applicant->studiengang_kz) + { + if ($studiengang != '' && $studiengang != $applicant->studiengang_kz) + { + $bachelorStudiengang = $this->StudiengangModel->load($studiengang); + $mailcontent .= $applicants_list; + $mailcontent .= '</tbody></table>'; + $mailcontent .= '<p style="font-family: verdana, sans-serif;"> + <a href="'.APP_ROOT.'vilesci/stammdaten/auswertung_fhtw.php?reihungstest='.$applicant->reihungstest_id.'&studiengang='.$studiengang.'" target="_blank"> + Liste der Anmeldungen + </a> + </p>'; + $mailcontent_data_arr['table'] = $mailcontent; + sendSanchoMail( + 'Sancho_ReihungstestteilnehmerJob', + $mailcontent_data_arr, + $bachelorStudiengang->retval[0]->email, + 'InteressentIn nach Reihungstest-Anmeldeschluss hinzugefügt', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg', + $from, + '', + $bcc); + $applicants_list = ''; + $mailcontent_data_arr = array(); + } + + $mailcontent = '<p style="font-family: verdana, sans-serif;">Folgende InteressentInnen wurden <b>nach</b> der Anmeldefrist zu einem Reihungstest hinzugefügt.<br>Details siehe Link</p>'; + $mailcontent .= ' + <table width="100%" style="cellpadding: 3px; font-family: verdana, sans-serif; border: 1px solid #000000;"> + <thead> + <th ' . $headerstyle . '>Datum des Tests</th> + <th ' . $headerstyle . '>Uhrzeit des Tests</th> + <th ' . $headerstyle . '>OrgForm</th> + <th ' . $headerstyle . '>Semester</th> + <th ' . $headerstyle . '>Nachname</th> + <th ' . $headerstyle . '>Vorname</th> + </thead> + <tbody> + '; + } + + $studiengang = $applicant->studiengang_kz; + $mailReceipients .= $applicant->email . ';'; + $applicants_list .= ' + <tr ' . $rowstyle . '> + <td>' . date_format(date_create($applicant->datum), 'd.m.Y') . '</td> + <td>' . $applicant->uhrzeit . '</td> + <td>' . $applicant->orgform_kurzbz . '</td> + <td>' . $applicant->ausbildungssemester . '</td> + <td>' . $applicant->nachname . '</td> + <td>' . $applicant->vorname . '</td> + </tr> + '; + }; + $bachelorStudiengang = $this->StudiengangModel->load($studiengang); + $mailcontent .= $applicants_list; + $mailcontent .= '</tbody></table>'; + $mailcontent .= '<p style="font-family: verdana, sans-serif;"> + <a href="'.APP_ROOT.'vilesci/stammdaten/auswertung_fhtw.php?reihungstest='.$applicant->reihungstest_id.'&studiengang='.$studiengang.'" target="_blank"> + Liste der Anmeldungen + </a> + </p>'; + $mailcontent_data_arr['table'] = $mailcontent; + sendSanchoMail( + 'Sancho_ReihungstestteilnehmerJob', + $mailcontent_data_arr, + $bachelorStudiengang->retval[0]->email, + 'InteressentIn nach Reihungstest-Anmeldeschluss hinzugefügt', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg', + $from, + '', + $bcc); + } + } + + /* + * Sends an email to all applicants of a placement test to remind them 3 working days before + * + * @param integer $degreeProgram. Kennzahl of Degree Program to check + * @param string $bcc. Optional. BCC-Mailadress to send the Mails to + * @param string $from. Optional. Sender-Mailadress shown to recipient + */ + public function remindApplicantsOfPlacementTest($degreeProgram, $bcc = null, $from = null) + { + // Encode Params + if ($bcc != '') + { + // $bcc can be given as null-string, so check that too + if ($bcc == 'null') + { + $bcc = ''; + } + else + { + $bcc = urldecode($bcc); + } + } + if ($from != '') + { + $from = urldecode($from); + } + + // Get placement tests with testdate within the next 2 weeks + $resultNextTestDates = $this->ReihungstestModel->getNextPlacementtests($degreeProgram, 14); + if (hasData($resultNextTestDates)) + { + $nextTestDates = $resultNextTestDates->retval; + $enddate = ''; + // Loop through the dates + foreach ($nextTestDates as $testDates) + { + $workingdays = 0; + $testsOndate = array(); + + // Deduct days till 3 working days are reached + for ($i = 1; ; $i++) + { + if (isDateWorkingDay($testDates->datum, $i) === true) + { + $workingdays++; + } + if ($workingdays == 3) + { + $enddate = date("Y-m-d", strtotime("$testDates->datum -" . $i . " days")); + break; + } + else + { + continue; + } + } + + // If $enddate is today -> load all tests of $testDates->datum + if (date("Y-m-d", strtotime($enddate)) == date('Y-m-d')) + { + $resultTestsOnDate = $this->ReihungstestModel->getTestsOnDate($testDates->datum, $degreeProgram); + + if (hasData($resultTestsOnDate)) + { + $testsOndate = $resultTestsOnDate->retval; + } + elseif (isError($resultTestsOnDate)) + { + show_error(getError($resultTestsOnDate)); + } + } + + if (!isEmptyArray($testsOndate)) + { + foreach ($testsOndate as $reihungstest) + { + // Loads applicants of a test + $applicants = $this->ReihungstestModel->getApplicantsOfPlacementTest($reihungstest->reihungstest_id); + + if (hasData($applicants)) + { + $applicants_arr = $applicants->retval; + } + elseif (isError($applicants)) + { + show_error(getError($applicants)); + } + + foreach ($applicants_arr as $applicant) + { + $mailcontent_data_arr = array(); + $mailcontent_data_arr['anrede'] = $applicant->anrede; + $mailcontent_data_arr['nachname'] = $applicant->nachname; + $mailcontent_data_arr['vorname'] = $applicant->vorname; + $mailcontent_data_arr['rt_datum'] = date_format(date_create($reihungstest->datum), 'd.m.Y'); + $mailcontent_data_arr['rt_uhrzeit'] = date_format(date_create($reihungstest->uhrzeit), 'H:i'); + $mailcontent_data_arr['rt_raum'] = $applicant->planbezeichnung; + if ($applicant->lageplan == '') + { + $mailcontent_data_arr['wegbeschreibung'] = 'Für diesen Raum liegt noch keine Wegbeschreibung vor.<br><br>No directions were found for this room'; + } + else + { + $mailcontent_data_arr['wegbeschreibung'] = $applicant->lageplan; + } + + sendSanchoMail( + 'Sancho_RemindApplicantsOfTest', + $mailcontent_data_arr, + $applicant->email, + 'Ihre Anmeldung zum Reihungstest - Reminder / Your registration for the placement test - Reminder', + DEFAULT_SANCHO_HEADER_IMG, + DEFAULT_SANCHO_FOOTER_IMG, + $from, + '', + $bcc); + } + } + } + } + } + } + + /** + * This job sends eMail(s) to the relevant stg assistance(s) informing about: + * All applicants, who have sent new applications AFTER they had absolved a + * placement test in the actual studiensemester + * AND who have been confirmed yesterday. + */ + public function mailNewApplicants() + { + // Get yesterdays confirmed applicants for Bachelor-studies + $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); + $this->PrestudentstatusModel->addSelect(' + tbl_person.person_id, + tbl_prestudentstatus.prestudent_id, + tbl_prestudent.studiengang_kz, + tbl_prestudentstatus.studiensemester_kurzbz, + tbl_prestudentstatus.bestaetigtam, + tbl_prestudentstatus.bewerbung_abgeschicktamum + '); + $this->PrestudentstatusModel->addJoin('public.tbl_prestudent', 'prestudent_id'); + $this->PrestudentstatusModel->addJoin('public.tbl_studiengang', 'studiengang_kz'); + $this->PrestudentstatusModel->addJoin('public.tbl_studiengangstyp', 'typ'); + $this->PrestudentstatusModel->addJoin('public.tbl_person', 'person_id'); + + $yesterdays_applicants_arr = $this->PrestudentstatusModel->loadWhere(' + status_kurzbz = \'Interessent\' AND + typ = \'b\' AND + bestaetigtam = current_date - 1 + '); + + // Retrieve the person_ids of yesterdays confirmed applicants + $person_id_arr = array(); + if (hasData($yesterdays_applicants_arr)) + { + foreach ($yesterdays_applicants_arr->retval as $yesterdays_applicant) + { + if (isset($yesterdays_applicant->person_id)) { + $person_id_arr[] = $yesterdays_applicant->person_id; + } + } + } + elseif (isError($yesterdays_applicants_arr)) + { + show_error(getError($yesterdays_applicants_arr)); + } + + // Get all other prestudenten of the given persons. + if (!isEmptyArray($person_id_arr)) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $this->PrestudentModel->addDistinct(); + $this->PrestudentModel->addSelect(' + person_id, + tbl_reihungstest.studiensemester_kurzbz, + tbl_reihungstest.reihungstest_id, + (SELECT(tbl_reihungstest.datum::text || \' \' || tbl_reihungstest.uhrzeit::text)::timestamp) AS reihungstest_timestamp + '); + $this->PrestudentModel->addJoin('public.tbl_studiengang', 'studiengang_kz'); + $this->PrestudentModel->addJoin('public.tbl_studiengangstyp', 'typ'); + $this->PrestudentModel->addJoin('public.tbl_prestudentstatus', 'prestudent_id'); + $this->PrestudentModel->addJoin('public.tbl_person', 'person_id'); + $this->PrestudentModel->addJoin('public.tbl_rt_person', 'person_id'); + $this->PrestudentModel->addJoin('public.tbl_reihungstest', 'tbl_reihungstest.reihungstest_id = tbl_rt_person.rt_id'); + + // Store them, if they have already absolved a placement test in the same study term they have applied for. + $placement_absolvents_arr = $this->PrestudentModel->loadWhere(' + person_id IN (' . implode(', ', $person_id_arr) . ') AND + typ = \'b\' AND + teilgenommen = \'t\' AND + tbl_reihungstest.studiensemester_kurzbz IN ( + SELECT + studiensemester_kurzbz + FROM + public.tbl_studiensemester + WHERE + ende >= now() + ) + '); + } + + // Store data to be send in the email-link + $result_arr = array(); + foreach($yesterdays_applicants_arr->retval as $yesterdays_applicant) + { + foreach ($placement_absolvents_arr->retval as $placement_absolvent) + { + if ($yesterdays_applicant->person_id == $placement_absolvent->person_id && + $yesterdays_applicant->studiensemester_kurzbz == $placement_absolvent->studiensemester_kurzbz && + $yesterdays_applicant->bewerbung_abgeschicktamum >= $placement_absolvent->reihungstest_timestamp) + { + $obj = new stdClass(); + $obj->prestudent_id = $yesterdays_applicant->prestudent_id; // prestudent_id of the yesterdays applicant + $obj->studiengang_kz = $yesterdays_applicant->studiengang_kz; // study program of interest of the yesterdays applicant + $obj->reihungstest_id = $placement_absolvent->reihungstest_id; // reihungstest_id of absolved reihungstest of that person + + $result_arr[]= $obj; + } + } + } + + // Sort by STG. This is important to send the mails clustered by STG to the different STG assistances. + usort($result_arr, function ($a, $b) + { + if ($a->studiengang_kz == $b->studiengang_kz) { + return 0; + } + return ($a->studiengang_kz < $b->studiengang_kz) ? -1 : 1; + }); + + $to = ''; // mail recipient (stg assistance) + $content_arr = array(); // url paths to the new applicants + $base_link = base_url('vilesci/stammdaten/auswertung_fhtw.php'); + + $i = 0; // loop counter + $len = count($result_arr); + + // Loop trough list of new applicants + foreach($result_arr as $result) + { + $studiengang = $this->StudiengangModel->load($result->studiengang_kz); + $mail_stg_assistance = $studiengang->retval[0]->email; + + // If first loop + if ($i == 0) + { + $to = $mail_stg_assistance; // set recipient initially + } + + // If new study is encountered but is not the first loop + if ($to != $mail_stg_assistance && $i != 0) + { + // Prepare content for mail template + $content_data_arr = $this->_getContentDataNewApplicant($content_arr); + + // Send mail + sendSanchoMail( + 'BewerberNachReihungstest', + $content_data_arr, + $to, + 'Neue Bewerbungen nach absolviertem Reihungstest', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg' + ); + + // Reset content for new study applicants & reset recipient (new stg assistance) + $content_arr = array($base_link. '?reihungstest='. $result->reihungstest_id. '&prestudent_id='. $result->prestudent_id); + $to = $mail_stg_assistance; + } + // If same study + else + { + // just add content + $content_arr[]= $base_link. '?reihungstest='. $result->reihungstest_id. '&prestudent_id='. $result->prestudent_id; // add to content + } + + // If last loop + if (($i == $len - 1)) + { + // Prepare content for mail template + $content_data_arr = $this->_getContentDataNewApplicant($content_arr); + + // Send mail + sendSanchoMail( + 'BewerberNachReihungstest', + $content_data_arr, + $to, + 'Neue Bewerbungen nach absolviertem Reihungstest', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg' + ); + } + $i++; // iterate counter + } + } + + // ------------------------------------------------------------------------ + // Private methods + /** + * Returns associative array with data as needed in the reihungstest job template. + * @param array $missing_rt_arr Array with studienpläne, which have no assigned placement tests. + * @param array $free_places_arr Array with info and amount of free placement test places. + * @return array + */ + private function _getContentData($missing_rt_arr, $free_places_arr) + { + $style_tbl1 = ' cellpadding="0" cellspacing="10" width="100%" style="font-family: courier, verdana, sans-serif; font-size: 0.95em; border: 1px solid #000000;" '; + $style_tbl2 = ' cellpadding="0" cellspacing="20" width="100%" style="font-family: courier, verdana, sans-serif; font-size: 0.95em; border: 1px solid #000000;" '; + + // Prepare HTML table with study plans that have no placement tests yet + if (!empty($missing_rt_arr)) { + $studienplan_list + = ' + <table' . $style_tbl2 . '> + '; + + foreach ($missing_rt_arr as $rt) { + $studienplan_list .= ' + <tr><td>' . $rt->bezeichnung . '</td></tr> + '; + } + + $studienplan_list .= ' + </table> + '; + } else { + $studienplan_list = ' + <table' . $style_tbl1 . '> + <tr><td>Alles okay! Alle Studienpläne haben zumindest einen Reihungstest.</td></tr> + </table> + '; + } + + // Prepare HTML table with information and amount of free places + if (!empty($free_places_arr)) { + $freie_plaetze_list = ' + <table' . $style_tbl2 . '> + <tr> + <th>Fakultät</th> + <th>Reihungstesttermine</th> + <th>Freie Plätze</th> + </tr> + '; + + foreach ($free_places_arr as $free_place) { + $datum = new DateTime($free_place->datum); + $style_alarm = ($free_place->freie_plaetze <= 5) ? ' style=" color: red; font-weight: bold" ' : ''; // mark if <=5 free places + + $freie_plaetze_list .= ' + <tr> + <td width="350">' . $free_place->fakultaet . '</td> + <td align="center">' . $datum->format('d.m.Y') . '</td> + <td align="center"' . $style_alarm . '>' . $free_place->freie_plaetze . '</td> + </tr> + '; + } + + $freie_plaetze_list .= ' + </table> + '; + } else { + $freie_plaetze_list = ' + <table' . $style_tbl1 . '> + <tr><td>Es gibt heute keine Ergebnisse zu freien Reihungstestplätze.</td></tr> + </table> + '; + } + + // Set associative array with the prepared HTML tables and URL be used by the template's variables + $content_data_arr['studienplan_list'] = $studienplan_list; + $content_data_arr['freie_plaetze_list'] = $freie_plaetze_list; + $content_data_arr['link'] = site_url('/organisation/Reihungstest'); + + return $content_data_arr; + } + + /** + * Returns associative array with data as needed in the BewerberNachReihungstest-template. + * @param array $content_arr Array with links to the testtool evaluation page of the new applicants. + * @return array + */ + private function _getContentDataNewApplicant($content_arr) + { + $content = ''; + $counter = 1; + foreach ($content_arr as $row) + { + $content .= '<br>Link zu: <a href="'. $row. '">Bewerber '. $counter. '</a>'; + $counter++; + } + + $content_data_arr['link'] = $content; + return $content_data_arr; + } + + + /** + * Checks the upcoming placement tests if there are correct studyplans assigned + * If there are invalid studyplans assigned (outdated because there exists a new version), + * it tries to find a better one and assigns it additionaly + */ + public function correctStudienplan() + { + // get all placement tests with incorrect studyplan + $qry = " + SELECT + tbl_reihungstest.reihungstest_id, + tbl_studienplan.studienplan_id, + tbl_reihungstest.studiensemester_kurzbz, + tbl_studienordnung.studiengang_kz + FROM + public.tbl_reihungstest + JOIN public.tbl_rt_studienplan ON(tbl_rt_studienplan.reihungstest_id=tbl_reihungstest.reihungstest_id) + JOIN lehre.tbl_studienplan USING(studienplan_id) + JOIN lehre.tbl_studienordnung USING(studienordnung_id) + WHERE + NOT EXISTS( + SELECT 1 FROM lehre.tbl_studienplan_semester + WHERE studienplan_id=tbl_rt_studienplan.studienplan_id + AND tbl_studienplan_semester.studiensemester_kurzbz=tbl_reihungstest.studiensemester_kurzbz + ) + AND tbl_reihungstest.datum >= now() + AND NOT EXISTS( + SELECT + 1 + FROM + public.tbl_rt_studienplan rtstp + JOIN lehre.tbl_studienplan stp USING(studienplan_id) + JOIN lehre.tbl_studienordnung sto USING(studienordnung_id) + JOIN lehre.tbl_studienplan_semester stpsem USING(studienplan_id) + WHERE + sto.studiengang_kz=tbl_studienordnung.studiengang_kz + AND rtstp.reihungstest_id=tbl_reihungstest.reihungstest_id + AND stpsem.studiensemester_kurzbz=tbl_reihungstest.studiensemester_kurzbz + ) + "; + + $db = new DB_Model(); + $result_rt = $db->execReadOnlyQuery($qry); + + if (hasdata($result_rt)) { + foreach ($result_rt->retval as $row_rt) { + // find an active studyplan for the same degree program with is valid in this semester + $result_stpl = $this->StudienplanModel->getStudienplaeneBySemester( + $row_rt->studiengang_kz, + $row_rt->studiensemester_kurzbz + ); + + if (hasData($result_stpl)) { + foreach ($result_stpl->retval as $row_stpl) { + // Add new Studyplan to RtStudienplan if missing + $rt_studienplan = $this->RtStudienplanModel->loadWhere(array( + "reihungstest_id" => $row_rt->reihungstest_id, + "studienplan_id" => $row_stpl->studienplan_id + )); + + if (!hasData($rt_studienplan)) { + echo "\nAdding StudienplanId: $row_stpl->studienplan_id"; + echo " to ReihungstestId: $row_rt->reihungstest_id"; + + $this->RtStudienplanModel->insert(array( + "reihungstest_id" => $row_rt->reihungstest_id, + "studienplan_id" => $row_stpl->studienplan_id + )); + } + } + } + } + } + } +} From c7b33fe160b67202d359f1b400238da918c8c291 Mon Sep 17 00:00:00 2001 From: Paolo <bison@technikum-wien.at> Date: Tue, 11 Feb 2020 16:04:08 +0100 Subject: [PATCH 051/138] Bugfix: FAS write page person id and prestudent id are swapped --- application/models/CL/Messages_model.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 87eff0f99..3c8217e73 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -687,9 +687,18 @@ class Messages_model extends CI_Model foreach (getData($info) as $receiver) { $recipient = new stdClass(); - $recipient->id = $receiver->person_id; $recipient->description = $receiver->Vorname.' '.$receiver->Nachname; + // If it is a prestudent then + if (isset($receiver->prestudent_id) && is_numeric($receiver->prestudent_id)) + { + $recipient->id = $receiver->prestudent_id; + } + else // otherwise it is a person + { + $recipient->id = $receiver->person_id; + } + $recipientsArray[] = $recipient; $recipientsList .= $receiver->Vorname.' '.$receiver->Nachname.'; '; $persons .= '<input type="hidden" name="persons[]" value="'.$receiver->person_id.'">'."\n"; @@ -723,7 +732,7 @@ class Messages_model extends CI_Model // If data contains a prestudent id // NOTE: // - info is checked at the beginning of this method so it is safe to use getData($info)[0] - // - the provided data inside info are all persons or prestudents, so it is safe to check only the first one + // - the provided data inside info are all persons or all prestudents, so it is safe to check only the first one if (isset(getData($info)[0]->prestudent_id) && is_numeric(getData($info)[0]->prestudent_id)) { $variablesResult = $this->messagelib->getMessageVarsPrestudent(); From 1b9693e316656d06a3a6032fedcfd8768dca646d Mon Sep 17 00:00:00 2001 From: Paolo <bison@technikum-wien.at> Date: Tue, 11 Feb 2020 16:10:39 +0100 Subject: [PATCH 052/138] Bugfix: Infocenter write page person id and prestudent id are swapped --- public/js/messaging/messageWrite.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/public/js/messaging/messageWrite.js b/public/js/messaging/messageWrite.js index 04a262cbc..cc9d40730 100644 --- a/public/js/messaging/messageWrite.js +++ b/public/js/messaging/messageWrite.js @@ -21,14 +21,18 @@ function parseMessageText(receiver_id, text) { var data = {text: text}; - if ($("#type").val() == 'person_id') + if ($("#type").val() == 'persons') { data.person_id = receiver_id; } - else + else if ($("#type").val() == 'prestudents') { data.prestudent_id = receiver_id; } + else + { + return; + } FHC_AjaxClient.ajaxCallGet( "system/messages/Messages/parseMessageText", From b41ef00b3d395e66505dfcae6cbb6ebd5e26fb88 Mon Sep 17 00:00:00 2001 From: alex <karpen_ko@hotmail.com> Date: Tue, 11 Feb 2020 16:42:04 +0100 Subject: [PATCH 053/138] crm/Prestudent_model: hasBewerber can optionally check bewerber only for a Studiengangtyp. In InfoCenter, only Bachelors are checked after Freigabe (for setting Bewerber and Reihungstestbooleans) --- .../system/infocenter/InfoCenter.php | 4 +-- application/models/person/Person_model.php | 26 +++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index e4d2c4e21..d5a751b05 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -560,7 +560,7 @@ class InfoCenter extends Auth_Controller else { // check if there is already a Bewerberstatus and Reihungsverfahren already absolviert - $bewerber = $this->PersonModel->hasBewerber($person_id, $lastStatus->studiensemester_kurzbz); + $bewerber = $this->PersonModel->hasBewerber($person_id, $lastStatus->studiensemester_kurzbz, 'b'); if (hasData($bewerber)) { @@ -1559,7 +1559,7 @@ class InfoCenter extends Auth_Controller } /** - * Sends infomail with prestudent and person data when Prestudent is freigegeben + * Sends infomail to Studiengang with prestudent and person data when Prestudent is freigegeben * @param $prestudent_id */ private function _sendFreigabeMail($prestudent_id) diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index 4f826dac1..d8ddb381c 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -220,16 +220,32 @@ class Person_model extends DB_Model * @param $studiensemester_kurzbz * @return array */ - public function hasBewerber($person_id, $studiensemester_kurzbz) + public function hasBewerber($person_id, $studiensemester_kurzbz, $studiengangtyp = null) { + $parametersArray = array($person_id, $studiensemester_kurzbz); + $qry = "SELECT count(*) AS anzahl_bewerber FROM public.tbl_person JOIN public.tbl_prestudent USING (person_id) - JOIN public.tbl_prestudentstatus ON tbl_prestudentstatus.prestudent_id = tbl_prestudent.prestudent_id - WHERE person_id = ? + JOIN public.tbl_prestudentstatus ON tbl_prestudentstatus.prestudent_id = tbl_prestudent.prestudent_id"; + + if (isset($studiengangtyp)) + { + $qry .= " JOIN lehre.tbl_studienplan USING(studienplan_id) + JOIN lehre.tbl_studienordnung USING(studienordnung_id) + JOIN public.tbl_studiengang ON tbl_studienordnung.studiengang_kz = tbl_studiengang.studiengang_kz"; + } + + $qry .= " WHERE person_id = ? AND studiensemester_kurzbz = ? - AND status_kurzbz = 'Bewerber' + AND tbl_prestudentstatus.status_kurzbz = 'Bewerber' AND reihungstestangetreten"; - return $this->execQuery($qry, array($person_id, $studiensemester_kurzbz)); + if (isset($studiengangtyp)) + { + $parametersArray[] = $studiengangtyp; + $qry .= " AND tbl_studiengang.typ = ?"; + } + + return $this->execQuery($qry, $parametersArray); } } From 16cb4a0d4ca4175b7d80a8011f706a78fa9f59b6 Mon Sep 17 00:00:00 2001 From: Paolo <bison@technikum-wien.at> Date: Tue, 11 Feb 2020 16:49:25 +0100 Subject: [PATCH 054/138] - Replace "This is a notice to notice you that you have been noticed..." with: EN: "This message will be delivered to the Infocenter of UAS Technikum Wien" DE: "Diese Nachricht wird an das Infocenter der FHTW zugestellt " - Bugfix: fixed phrases in system/messages/MessageClient/write --- application/views/system/messages/ajaxWrite.php | 10 +++++----- system/phrasesupdate.php | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/application/views/system/messages/ajaxWrite.php b/application/views/system/messages/ajaxWrite.php index df6c1bfcb..5a0a3f7b9 100644 --- a/application/views/system/messages/ajaxWrite.php +++ b/application/views/system/messages/ajaxWrite.php @@ -23,13 +23,13 @@ <div class="container-fluid"> <div class="row"> <div class="col-lg-12"> - <h3 class="page-header"><?php echo $this->p->t('ui', 'sendMessage'); ?></h3> + <h3 class="page-header"><?php echo $this->p->t('ui', 'nachrichtSenden'); ?></h3> </div> </div> <div class="row"> <div class="form-group"> <div class="col-lg-1 msgfieldcol-left"> - <label><?php echo $this->p->t('ui', 'receiver'); ?>:</label> + <label><?php echo $this->p->t('global', 'empfaenger'); ?>:</label> </div> <div class="col-lg-11 msgfieldcol-right"> <select id="organisationUnit"> @@ -43,7 +43,7 @@ <div class="row"> <div class="form-group"> <div class="col-lg-1 msgfield msgfieldcol-left"> - <label><?php echo $this->p->t('ui', 'subject'); ?>:</label> + <label><?php echo $this->p->t('global', 'betreff'); ?>:</label> </div> &nbsp; <div class="col-lg-7"> @@ -54,7 +54,7 @@ <br> <div class="row"> <div class="col-lg-12"> - <label><?php echo $this->p->t('ui', 'message'); ?>:</label> + <label><?php echo $this->p->t('global', 'nachricht'); ?>:</label> <textarea id="body"></textarea> <br> @@ -68,7 +68,7 @@ <div class="row"> <div class="col-lg-12 text-right"> <button id="sendButton" class="btn btn-default" type="button"> - <?php echo $this->p->t('ui', 'send'); ?> + <?php echo $this->p->t('ui', 'senden'); ?> </button> </div> </div> diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index d53d87dbb..3766f976d 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -4383,13 +4383,13 @@ When on hold, the date is only a reminder.', 'phrases' => array( array( 'sprache' => 'German', - 'text' => '* This is a notice to notice you that you have been noticed DE', + 'text' => '* Diese Nachricht wird an das Infocenter der FHTW zugestellt', 'description' => '', 'insertvon' => 'system' ), array( 'sprache' => 'English', - 'text' => '* This is a notice to notice you that you have been noticed', + 'text' => '* This message will be delivered to the Infocenter of UAS Technikum Wien', 'description' => '', 'insertvon' => 'system' ) From 98918bc3362c269a596bfaa8e20577370f523628 Mon Sep 17 00:00:00 2001 From: Paolo <bison@technikum-wien.at> Date: Tue, 11 Feb 2020 18:05:26 +0100 Subject: [PATCH 055/138] - Bugfix: fixed phrases in views/system/messages/* - Added new phrases where missing or hard coded - Fixed windowz new lines in /application/* --- .../controllers/api/v1/person/Person.php | 534 +++++++++--------- application/views/crm/statusEdit.php | 178 +++--- application/views/crm/statusgrund.php | 64 +-- application/views/crm/statusgrundEdit.php | 214 +++---- application/views/crm/statusgrundNew.php | 132 ++--- application/views/system/fas_udf.php | 300 +++++----- application/views/system/infocenter/logs.php | 36 +- .../views/system/infocenter/messageList.php | 74 +-- .../views/system/infocenter/notizen.php | 38 +- .../views/system/messages/ajaxRead.php | 6 +- .../views/system/messages/ajaxWrite.php | 180 +++--- .../views/system/messages/ajaxWriteReply.php | 182 +++--- .../views/system/messages/htmlRead.php | 192 ++++--- .../views/system/messages/htmlWriteReply.php | 30 +- .../system/messages/htmlWriteTemplate.php | 20 +- application/views/system/phrases/phrases.php | 40 +- .../views/system/phrases/phrasesEdit.php | 34 +- .../system/phrases/phrasesinhaltList.php | 108 ++-- .../views/system/vorlage/templates.php | 40 +- .../system/vorlage/templatetextPreview.php | 4 +- application/views/templates/vilesci.php | 82 +-- application/widgets/Dropdown_widget.php | 38 +- .../widgets/MultipleDropdown_widget.php | 40 +- application/widgets/Nation_widget.php | 42 +- application/widgets/Zgv_widget.php | 42 +- 25 files changed, 1368 insertions(+), 1282 deletions(-) diff --git a/application/controllers/api/v1/person/Person.php b/application/controllers/api/v1/person/Person.php index c8c95ae06..ca8a66bea 100644 --- a/application/controllers/api/v1/person/Person.php +++ b/application/controllers/api/v1/person/Person.php @@ -1,267 +1,267 @@ -<?php -/** - * FH-Complete - * - * @package FHC-API - * @author FHC-Team - * @copyright Copyright (c) 2016, fhcomplete.org - * @license GPLv3 - * @link http://fhcomplete.org - * @since Version 1.0 - * @filesource - */ -// ------------------------------------------------------------------------ - -if (!defined('BASEPATH')) exit('No direct script access allowed'); - -class Person extends APIv1_Controller -{ - /** - * Person API constructor. - */ - public function __construct() - { - parent::__construct(array('Person' => 'basis/person:rw', 'CheckBewerbung' => 'basis/person:r')); - // Load model PersonModel - $this->load->model('person/person_model', 'PersonModel'); - } - - /** - * @return void - */ - public function getPerson() - { - $person_id = $this->get('person_id'); - $code = $this->get('code'); - $email = $this->get('email'); - - if (isset($code) || isset($email) || isset($person_id)) - { - if (isset($code) && isset($email)) - { - $result = $this->PersonModel->getPersonKontaktByZugangscode($code, $email); - } - else - { - $parametersArray = array(); - - if (isset($code)) - { - $parametersArray['zugangscode'] = $code; - } - else - { - $parametersArray['person_id'] = $person_id; - } - - $result = $this->PersonModel->loadWhere($parametersArray); - } - - $this->response($result, REST_Controller::HTTP_OK); - } - else - { - $this->response(); - } - } - - /** - * @return void - */ - public function getCheckBewerbung() - { - $email = $this->get('email'); - $studiensemester_kurzbz = $this->get('studiensemester_kurzbz'); - - if (isset($email)) - { - $result = $this->PersonModel->checkBewerbung($email, $studiensemester_kurzbz); - - $this->response($result, REST_Controller::HTTP_OK); - } - else - { - $this->response(); - } - } - - /** - * @return void - */ - public function postPerson() - { - $person = $this->post(); - $validation = $this->_validate($person); - - if (isSuccess($validation)) - { - if(isset($person['person_id']) && !(is_null($person['person_id'])) && ($person['person_id'] != '')) - { - $result = $this->PersonModel->updatePerson($person); - } - else - { - $result = $this->PersonModel->insert($person); - } - - $this->response($result, REST_Controller::HTTP_OK); - } - else - { - $this->response($validation, REST_Controller::HTTP_OK); - } - } - - private function _validate($person) - { - // If $person is consistent - if (!isset($person) || (isset($person) && !is_array($person))) - { - return error('Any parameters posted'); - } - - // Trim all the values - foreach($person as $key => $value) - { - if (gettype($value) == 'string') - { - $person[$key] = trim($value); - } - } - - if (isset($person['sprache']) && mb_strlen($person['sprache']) > 16) - { - return error('Sprache darf nicht laenger als 16 Zeichen sein'); - } - if (isset($person['anrede']) && mb_strlen($person['anrede']) > 16) - { - return error('Anrede darf nicht laenger als 16 Zeichen sein'); - } - if (isset($person['titelpost']) && mb_strlen($person['titelpost']) > 32) - { - return error('Titelpost darf nicht laenger als 32 Zeichen sein'); - } - if (isset($person['titelpre']) && mb_strlen($person['titelpre']) > 64) - { - return error('Titelpre darf nicht laenger als 64 Zeichen sein'); - } - if (isset($person['nachname']) && mb_strlen($person['nachname']) > 64) - { - return error('Nachname darf nicht laenger als 64 Zeichen sein'); - } - if (isset($person['nachname']) && ($person['nachname'] == '' || is_null($person['nachname']))) - { - return error('Nachname muss eingegeben werden'); - } - if (isset($person['vorname']) && mb_strlen($person['vorname']) > 32) - { - return error('Vorname darf nicht laenger als 32 Zeichen sein'); - } - if (isset($person['vornamen']) && mb_strlen($person['vornamen']) > 128) - { - return error('Vornamen darf nicht laenger als 128 Zeichen sein'); - } - if (isset($person['gebort']) && mb_strlen($person['gebort']) > 128) - { - return error('Geburtsort darf nicht laenger als 128 Zeichen sein'); - } - if (isset($person['homepage']) && mb_strlen($person['homepage']) > 256) - { - return error('Homepage darf nicht laenger als 256 Zeichen sein'); - } - if (isset($person['matr_nr']) && mb_strlen($person['matr_nr']) > 32) - { - return error('Matrikelnummer darf nicht laenger als 32 Zeichen sein'); - } - if (isset($person['ersatzkennzeichen']) && mb_strlen($person['ersatzkennzeichen']) > 10) - { - return error('Ersatzkennzeichen darf nicht laenger als 10 Zeichen sein'); - } - if (isset($person['familienstand']) && mb_strlen($person['familienstand']) > 1) - { - return error('Familienstand ist ungueltig'); - } - if (isset($person['anzahlkinder']) && $person['anzahlkinder'] != '' && !is_numeric($person['anzahlkinder'])) - { - return error('Anzahl der Kinder ist ungueltig'); - } - if (!isset($person['aktiv']) || (isset($person['aktiv']) && $person['aktiv'] !== true && $person['aktiv'] !== false)) - { - return error('Aktiv ist ungueltig'); - } - if (!isset($person['person_id']) && isset($person['insertvon']) && mb_strlen($person['insertvon']) > 32) - { - return error('Insertvon darf nicht laenger als 32 Zeichen sein'); - } - if (isset($person['updatevon']) && mb_strlen($person['updatevon']) > 32) - { - return error('Updatevon darf nicht laenger als 32 Zeichen sein'); - } - if (isset($person['geburtsnation']) && mb_strlen($person['geburtsnation']) > 3) - { - return error('Geburtsnation darf nicht laenger als 3 Zeichen sein'); - } - if (isset($person['staatsbuergerschaft']) && mb_strlen($person['staatsbuergerschaft']) > 3) - { - return error('Staatsbuergerschaft darf nicht laenger als 3 Zeichen sein'); - } - if (!isset($person['geschlecht']) || (isset($person['geschlecht']) && mb_strlen($person['geschlecht']) > 1)) - { - return error('Geschlecht darf nicht laenger als 1 Zeichen sein'); - } - if (isset($person['geschlecht']) && $person['geschlecht'] != 'm' && $person['geschlecht'] != 'w' && $person['geschlecht'] != 'u') - { - return error('Geschlecht muss w, m oder u sein!'); - } - - if (isset($person['svnr'])) - { - if ($person['svnr'] != '' && mb_strlen($person['svnr']) != 16 - && mb_strlen($person['svnr']) != 12 && mb_strlen($person['svnr']) != 10) - { - return error('SVNR muss 10, 12 oder 16 Zeichen lang sein'); - } - if (mb_strlen($person['svnr']) == 10 || mb_strlen($person['svnr']) == 12) - { - //SVNR mit Pruefziffer pruefen - //Die 4. Stelle in der SVNR ist die Pruefziffer - //(Summe von (gewichtung[i]*svnr[i])) modulo 11 ergibt diese Pruefziffer - //Falls nicht, ist die SVNR ungueltig - $gewichtung = array(3, 7, 9, 0, 5, 8, 4, 2, 1, 6); - $erg = 0; - $tmpSvnr = substr($person['svnr'], 0, 10); - //Quersumme bilden - for ($i = 0; $i < 10; $i++) - { - $erg += $gewichtung[$i] * $tmpSvnr{$i}; - } - - if ($tmpSvnr{3} != ($erg % 11)) //Vergleichen der Pruefziffer mit Quersumme Modulo 11 - { - return error('SVNR ist ungueltig'); - } - - if (mb_strlen($person['svnr']) == 12) - { - $last = substr($person['svnr'], 10, 12); - if ($last{0} != 'v' || !is_numeric($last{1})) - { - return error('SVNR ist ungueltig'); - } - } - } - - //Pruefen ob das Geburtsdatum mit der SVNR uebereinstimmt. - if (isset($person['gebdatum']) && $person['svnr'] != '' && $person['gebdatum'] != '') - { - if (!mb_ereg('([0-9]{1,2}).([0-9]{1,2}).([0-9]{4})', $person['gebdatum']) - && !mb_ereg('([0-9]{4})-([0-9]{2})-([0-9]{2})', $person['gebdatum'])) - { - return error('Format des Geburtsdatums ist ungueltig'); - } - } - } - - return success('Input data are valid'); - } -} +<?php +/** + * FH-Complete + * + * @package FHC-API + * @author FHC-Team + * @copyright Copyright (c) 2016, fhcomplete.org + * @license GPLv3 + * @link http://fhcomplete.org + * @since Version 1.0 + * @filesource + */ +// ------------------------------------------------------------------------ + +if (!defined('BASEPATH')) exit('No direct script access allowed'); + +class Person extends APIv1_Controller +{ + /** + * Person API constructor. + */ + public function __construct() + { + parent::__construct(array('Person' => 'basis/person:rw', 'CheckBewerbung' => 'basis/person:r')); + // Load model PersonModel + $this->load->model('person/person_model', 'PersonModel'); + } + + /** + * @return void + */ + public function getPerson() + { + $person_id = $this->get('person_id'); + $code = $this->get('code'); + $email = $this->get('email'); + + if (isset($code) || isset($email) || isset($person_id)) + { + if (isset($code) && isset($email)) + { + $result = $this->PersonModel->getPersonKontaktByZugangscode($code, $email); + } + else + { + $parametersArray = array(); + + if (isset($code)) + { + $parametersArray['zugangscode'] = $code; + } + else + { + $parametersArray['person_id'] = $person_id; + } + + $result = $this->PersonModel->loadWhere($parametersArray); + } + + $this->response($result, REST_Controller::HTTP_OK); + } + else + { + $this->response(); + } + } + + /** + * @return void + */ + public function getCheckBewerbung() + { + $email = $this->get('email'); + $studiensemester_kurzbz = $this->get('studiensemester_kurzbz'); + + if (isset($email)) + { + $result = $this->PersonModel->checkBewerbung($email, $studiensemester_kurzbz); + + $this->response($result, REST_Controller::HTTP_OK); + } + else + { + $this->response(); + } + } + + /** + * @return void + */ + public function postPerson() + { + $person = $this->post(); + $validation = $this->_validate($person); + + if (isSuccess($validation)) + { + if(isset($person['person_id']) && !(is_null($person['person_id'])) && ($person['person_id'] != '')) + { + $result = $this->PersonModel->updatePerson($person); + } + else + { + $result = $this->PersonModel->insert($person); + } + + $this->response($result, REST_Controller::HTTP_OK); + } + else + { + $this->response($validation, REST_Controller::HTTP_OK); + } + } + + private function _validate($person) + { + // If $person is consistent + if (!isset($person) || (isset($person) && !is_array($person))) + { + return error('Any parameters posted'); + } + + // Trim all the values + foreach($person as $key => $value) + { + if (gettype($value) == 'string') + { + $person[$key] = trim($value); + } + } + + if (isset($person['sprache']) && mb_strlen($person['sprache']) > 16) + { + return error('Sprache darf nicht laenger als 16 Zeichen sein'); + } + if (isset($person['anrede']) && mb_strlen($person['anrede']) > 16) + { + return error('Anrede darf nicht laenger als 16 Zeichen sein'); + } + if (isset($person['titelpost']) && mb_strlen($person['titelpost']) > 32) + { + return error('Titelpost darf nicht laenger als 32 Zeichen sein'); + } + if (isset($person['titelpre']) && mb_strlen($person['titelpre']) > 64) + { + return error('Titelpre darf nicht laenger als 64 Zeichen sein'); + } + if (isset($person['nachname']) && mb_strlen($person['nachname']) > 64) + { + return error('Nachname darf nicht laenger als 64 Zeichen sein'); + } + if (isset($person['nachname']) && ($person['nachname'] == '' || is_null($person['nachname']))) + { + return error('Nachname muss eingegeben werden'); + } + if (isset($person['vorname']) && mb_strlen($person['vorname']) > 32) + { + return error('Vorname darf nicht laenger als 32 Zeichen sein'); + } + if (isset($person['vornamen']) && mb_strlen($person['vornamen']) > 128) + { + return error('Vornamen darf nicht laenger als 128 Zeichen sein'); + } + if (isset($person['gebort']) && mb_strlen($person['gebort']) > 128) + { + return error('Geburtsort darf nicht laenger als 128 Zeichen sein'); + } + if (isset($person['homepage']) && mb_strlen($person['homepage']) > 256) + { + return error('Homepage darf nicht laenger als 256 Zeichen sein'); + } + if (isset($person['matr_nr']) && mb_strlen($person['matr_nr']) > 32) + { + return error('Matrikelnummer darf nicht laenger als 32 Zeichen sein'); + } + if (isset($person['ersatzkennzeichen']) && mb_strlen($person['ersatzkennzeichen']) > 10) + { + return error('Ersatzkennzeichen darf nicht laenger als 10 Zeichen sein'); + } + if (isset($person['familienstand']) && mb_strlen($person['familienstand']) > 1) + { + return error('Familienstand ist ungueltig'); + } + if (isset($person['anzahlkinder']) && $person['anzahlkinder'] != '' && !is_numeric($person['anzahlkinder'])) + { + return error('Anzahl der Kinder ist ungueltig'); + } + if (!isset($person['aktiv']) || (isset($person['aktiv']) && $person['aktiv'] !== true && $person['aktiv'] !== false)) + { + return error('Aktiv ist ungueltig'); + } + if (!isset($person['person_id']) && isset($person['insertvon']) && mb_strlen($person['insertvon']) > 32) + { + return error('Insertvon darf nicht laenger als 32 Zeichen sein'); + } + if (isset($person['updatevon']) && mb_strlen($person['updatevon']) > 32) + { + return error('Updatevon darf nicht laenger als 32 Zeichen sein'); + } + if (isset($person['geburtsnation']) && mb_strlen($person['geburtsnation']) > 3) + { + return error('Geburtsnation darf nicht laenger als 3 Zeichen sein'); + } + if (isset($person['staatsbuergerschaft']) && mb_strlen($person['staatsbuergerschaft']) > 3) + { + return error('Staatsbuergerschaft darf nicht laenger als 3 Zeichen sein'); + } + if (!isset($person['geschlecht']) || (isset($person['geschlecht']) && mb_strlen($person['geschlecht']) > 1)) + { + return error('Geschlecht darf nicht laenger als 1 Zeichen sein'); + } + if (isset($person['geschlecht']) && $person['geschlecht'] != 'm' && $person['geschlecht'] != 'w' && $person['geschlecht'] != 'u') + { + return error('Geschlecht muss w, m oder u sein!'); + } + + if (isset($person['svnr'])) + { + if ($person['svnr'] != '' && mb_strlen($person['svnr']) != 16 + && mb_strlen($person['svnr']) != 12 && mb_strlen($person['svnr']) != 10) + { + return error('SVNR muss 10, 12 oder 16 Zeichen lang sein'); + } + if (mb_strlen($person['svnr']) == 10 || mb_strlen($person['svnr']) == 12) + { + //SVNR mit Pruefziffer pruefen + //Die 4. Stelle in der SVNR ist die Pruefziffer + //(Summe von (gewichtung[i]*svnr[i])) modulo 11 ergibt diese Pruefziffer + //Falls nicht, ist die SVNR ungueltig + $gewichtung = array(3, 7, 9, 0, 5, 8, 4, 2, 1, 6); + $erg = 0; + $tmpSvnr = substr($person['svnr'], 0, 10); + //Quersumme bilden + for ($i = 0; $i < 10; $i++) + { + $erg += $gewichtung[$i] * $tmpSvnr{$i}; + } + + if ($tmpSvnr{3} != ($erg % 11)) //Vergleichen der Pruefziffer mit Quersumme Modulo 11 + { + return error('SVNR ist ungueltig'); + } + + if (mb_strlen($person['svnr']) == 12) + { + $last = substr($person['svnr'], 10, 12); + if ($last{0} != 'v' || !is_numeric($last{1})) + { + return error('SVNR ist ungueltig'); + } + } + } + + //Pruefen ob das Geburtsdatum mit der SVNR uebereinstimmt. + if (isset($person['gebdatum']) && $person['svnr'] != '' && $person['gebdatum'] != '') + { + if (!mb_ereg('([0-9]{1,2}).([0-9]{1,2}).([0-9]{4})', $person['gebdatum']) + && !mb_ereg('([0-9]{4})-([0-9]{2})-([0-9]{2})', $person['gebdatum'])) + { + return error('Format des Geburtsdatums ist ungueltig'); + } + } + } + + return success('Input data are valid'); + } +} diff --git a/application/views/crm/statusEdit.php b/application/views/crm/statusEdit.php index 5fee3ee92..5f0353acf 100644 --- a/application/views/crm/statusEdit.php +++ b/application/views/crm/statusEdit.php @@ -1,89 +1,89 @@ -<?php - $this->load->view('templates/header', array('title' => 'StatusEdit')); - - $s = $status; -?> - - <div class="row"> - <div class="span4"> - <h2>Status: <?php echo $s->status_kurzbz; ?></h2> - <form method="post" action="../saveStatus"> - <table> - <tr> - <td colspan="2"> - beschreibung:<br/><br/> - <input type="text" name="beschreibung" value="<?php echo $s->beschreibung; ?>" /><br/> - </td> - </tr> - <tr> - <td colspan="2"> - &nbsp; - </td> - </tr> - <tr> - <td colspan="2"> - Anmerkung:<br/><br/> - <textarea name="anmerkung"><?php echo $s->anmerkung; ?></textarea><br/> - </td> - </tr> - <tr> - <td colspan="2"> - &nbsp; - </td> - </tr> - <tr> - <td colspan="2"> - Bezeichnung mehrsprachig:<br/><br/> - - <?php - $val = ''; - $i = 0; - ?> - - <?php foreach ($sprache as $sp): ?> - <?php echo $sp->sprache; ?>:<br/> - <?php - if (!isset($s->bezeichnung_mehrsprachig[$i])) - { - $val = ''; - } - else - { - $val = $s->bezeichnung_mehrsprachig[$i]; - } - $i++; - ?> - <input type="text" name="bezeichnung_mehrsprachig[]" value="<?php echo $val; ?>" /><br/> - <?php endforeach ?> - - </td> - </tr> - <tr> - <td colspan="2"> - &nbsp; - </td> - </tr> - <tr> - <td colspan="2" align="center"> - <button type="submit">Save</button> - </td> - </tr> - </table> - <input type="hidden" name="status_kurzbz" value="<?php echo $s->status_kurzbz; ?>" /> - </form> - </div> - </div> - </body> - - <?php - if (!is_null($update)) - { - ?> - <script> - parent.document.getElementById("StatusgrundLeft").contentWindow.location.reload(true); - </script> - <?php - } - ?> - -</html> +<?php + $this->load->view('templates/header', array('title' => 'StatusEdit')); + + $s = $status; +?> + + <div class="row"> + <div class="span4"> + <h2>Status: <?php echo $s->status_kurzbz; ?></h2> + <form method="post" action="../saveStatus"> + <table> + <tr> + <td colspan="2"> + beschreibung:<br/><br/> + <input type="text" name="beschreibung" value="<?php echo $s->beschreibung; ?>" /><br/> + </td> + </tr> + <tr> + <td colspan="2"> + &nbsp; + </td> + </tr> + <tr> + <td colspan="2"> + Anmerkung:<br/><br/> + <textarea name="anmerkung"><?php echo $s->anmerkung; ?></textarea><br/> + </td> + </tr> + <tr> + <td colspan="2"> + &nbsp; + </td> + </tr> + <tr> + <td colspan="2"> + Bezeichnung mehrsprachig:<br/><br/> + + <?php + $val = ''; + $i = 0; + ?> + + <?php foreach ($sprache as $sp): ?> + <?php echo $sp->sprache; ?>:<br/> + <?php + if (!isset($s->bezeichnung_mehrsprachig[$i])) + { + $val = ''; + } + else + { + $val = $s->bezeichnung_mehrsprachig[$i]; + } + $i++; + ?> + <input type="text" name="bezeichnung_mehrsprachig[]" value="<?php echo $val; ?>" /><br/> + <?php endforeach ?> + + </td> + </tr> + <tr> + <td colspan="2"> + &nbsp; + </td> + </tr> + <tr> + <td colspan="2" align="center"> + <button type="submit">Save</button> + </td> + </tr> + </table> + <input type="hidden" name="status_kurzbz" value="<?php echo $s->status_kurzbz; ?>" /> + </form> + </div> + </div> + </body> + + <?php + if (!is_null($update)) + { + ?> + <script> + parent.document.getElementById("StatusgrundLeft").contentWindow.location.reload(true); + </script> + <?php + } + ?> + +</html> diff --git a/application/views/crm/statusgrund.php b/application/views/crm/statusgrund.php index e79fa5d05..d4a31aa53 100644 --- a/application/views/crm/statusgrund.php +++ b/application/views/crm/statusgrund.php @@ -1,32 +1,32 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN"> -<html lang="de_AT"> - - <head> - <title>VileSci - Statusgrund</title> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> - </head> - - <frameset cols="30%, *"> - <frame src="Statusgrund/listStatus" id="StatusgrundLeft" name="StatusgrundLeft" frameborder="1" /> - <noframes> - <body bgcolor="#FFFFFF"> - This application works only with a frames-enabled browser.<br /> - </body> - - - - - <body bgcolor="#FFFFFF"> - This application works only with a frames-enabled browser.<br /> - </body> - - - - <body bgcolor="#FFFFFF"> - This application works only with a frames-enabled browser.<br /> - </body> - - - - - + + + + + VileSci - Statusgrund + + + + + + + <body bgcolor="#FFFFFF"> + This application works only with a frames-enabled browser.<br /> + </body> + + + + + <body bgcolor="#FFFFFF"> + This application works only with a frames-enabled browser.<br /> + </body> + + + + <body bgcolor="#FFFFFF"> + This application works only with a frames-enabled browser.<br /> + </body> + + + + + diff --git a/application/views/crm/statusgrundEdit.php b/application/views/crm/statusgrundEdit.php index ddbd1ff0a..9fa91b6d5 100644 --- a/application/views/crm/statusgrundEdit.php +++ b/application/views/crm/statusgrundEdit.php @@ -1,107 +1,107 @@ -load->view('templates/header', array('title' => 'StatusgrundEdit')); - - $sg = $statusgrund; -?> - -
-
-

Statusgrund: status_kurzbz; ?>

-
"> - - - - - - - - - - - - - - - - - - - - - - - -
- Bezeichnung mehrsprachig:

- - - sprache; ?>:
- bezeichnung_mehrsprachig[$i])) - { - $val = ""; - } - else - { - $val = $sg->bezeichnung_mehrsprachig[$i]; - } - $i++; - ?> -
- - -
-   -
- Beschreibung:

- - - sprache; ?>:
- beschreibung[$i])) - { - $val = ""; - } - else - { - $val = $sg->beschreibung[$i]; - } - $i++; - ?> -
- -
-   -
- Aktiv: - - aktiv) && $sg->aktiv === true ? "checked" : ""; ?> /> -
-   -
- -
- " /> -
-
-
- - - - - - - +load->view('templates/header', array('title' => 'StatusgrundEdit')); + + $sg = $statusgrund; +?> + +
+
+

Statusgrund: status_kurzbz; ?>

+
"> + + + + + + + + + + + + + + + + + + + + + + + +
+ Bezeichnung mehrsprachig:

+ + + sprache; ?>:
+ bezeichnung_mehrsprachig[$i])) + { + $val = ""; + } + else + { + $val = $sg->bezeichnung_mehrsprachig[$i]; + } + $i++; + ?> +
+ + +
+   +
+ Beschreibung:

+ + + sprache; ?>:
+ beschreibung[$i])) + { + $val = ""; + } + else + { + $val = $sg->beschreibung[$i]; + } + $i++; + ?> +
+ +
+   +
+ Aktiv: + + aktiv) && $sg->aktiv === true ? "checked" : ""; ?> /> +
+   +
+ +
+ " /> +
+
+
+ + + + + + + diff --git a/application/views/crm/statusgrundNew.php b/application/views/crm/statusgrundNew.php index bd2ebe7d7..ffcd18429 100644 --- a/application/views/crm/statusgrundNew.php +++ b/application/views/crm/statusgrundNew.php @@ -1,66 +1,66 @@ -load->view('templates/header', array('title' => 'StatusgrundNew')); -?> - -
-
-

Neuer Statusgrund

-
"> - - - - - - - - - - - - - - - - - - - - - - - -
- Bezeichnung mehrsprachig:

- - - sprache; ?>:
-
- - -
-   -
- Beschreibung:

- - - sprache; ?>:
-
- -
-   -
- Aktiv: - - -
-   -
- -
- -
-
-
- - - +load->view('templates/header', array('title' => 'StatusgrundNew')); +?> + +
+
+

Neuer Statusgrund

+
"> + + + + + + + + + + + + + + + + + + + + + + + +
+ Bezeichnung mehrsprachig:

+ + + sprache; ?>:
+
+ + +
+   +
+ Beschreibung:

+ + + sprache; ?>:
+
+ +
+   +
+ Aktiv: + + +
+   +
+ +
+ +
+
+
+ + + diff --git a/application/views/system/fas_udf.php b/application/views/system/fas_udf.php index d4a01b9e9..3efc61abc 100644 --- a/application/views/system/fas_udf.php +++ b/application/views/system/fas_udf.php @@ -1,150 +1,150 @@ -load->view("templates/header", array("title" => "UDF", "widgetsCSS" => true)); ?> - - - - -
- Saved! -
- -
- -
- Error while saving! -
-
-
-retval; - if(is_array($errors)) - { - foreach ($errors as $error) - { - foreach ($error as $fieldError) - { - echo $fieldError->code . ': ' . $fieldError->retval . '
'; - } - } - } - else - echo $result->retval; -?> -
- -
-
-
- -
- -
-
-
- Zusatzfelder -
-
-
-
-   -
-
-
- -
- udflib->UDFWidget( - array( - UDFLib::SCHEMA_ARG_NAME => 'public', - UDFLib::TABLE_ARG_NAME => 'tbl_person', - UDFLib::UDFS_ARG_NAME => $personUdfs - ) - ); - ?> -
-
-   -
- - -
- udflib->UDFWidget( - array( - UDFLib::SCHEMA_ARG_NAME => 'public', - UDFLib::TABLE_ARG_NAME => 'tbl_prestudent', - UDFLib::UDFS_ARG_NAME => $prestudentUdfs - ) - ); - ?> -
- -
-
-
-   -
-
-
- -
-   -
-
-   -
- -
- -
-
-
- - - - - - - - -
- - - -load->view("templates/footer"); ?> +load->view("templates/header", array("title" => "UDF", "widgetsCSS" => true)); ?> + + + + +
+ Saved! +
+ +
+ +
+ Error while saving! +
+
+
+retval; + if(is_array($errors)) + { + foreach ($errors as $error) + { + foreach ($error as $fieldError) + { + echo $fieldError->code . ': ' . $fieldError->retval . '
'; + } + } + } + else + echo $result->retval; +?> +
+ +
+
+
+ +
+ +
+
+
+ Zusatzfelder +
+
+
+
+   +
+
+
+ +
+ udflib->UDFWidget( + array( + UDFLib::SCHEMA_ARG_NAME => 'public', + UDFLib::TABLE_ARG_NAME => 'tbl_person', + UDFLib::UDFS_ARG_NAME => $personUdfs + ) + ); + ?> +
+
+   +
+ + +
+ udflib->UDFWidget( + array( + UDFLib::SCHEMA_ARG_NAME => 'public', + UDFLib::TABLE_ARG_NAME => 'tbl_prestudent', + UDFLib::UDFS_ARG_NAME => $prestudentUdfs + ) + ); + ?> +
+ +
+
+
+   +
+
+
+ +
+   +
+
+   +
+ +
+ +
+
+
+ + + + + + + + +
+ + + +load->view("templates/footer"); ?> diff --git a/application/views/system/infocenter/logs.php b/application/views/system/infocenter/logs.php index de97d5055..8005bf4f7 100644 --- a/application/views/system/infocenter/logs.php +++ b/application/views/system/infocenter/logs.php @@ -1,19 +1,19 @@ - - - - - - - - - - - - - - - - - +
p->t('global', 'datum')) ?>p->t('global', 'aktivitaet')) ?>User
zeitpunkt), 'd.m.Y H:i:s') ?>logdata->name) ? $log->logdata->name : '' ?>insertvon ?>
+ + + + + + + + + + + + + + + +
p->t('global', 'datum')) ?>p->t('global', 'aktivitaet')) ?>User
zeitpunkt), 'd.m.Y H:i:s') ?>logdata->name) ? $log->logdata->name : '' ?>insertvon ?>
\ No newline at end of file diff --git a/application/views/system/infocenter/messageList.php b/application/views/system/infocenter/messageList.php index d666e32fe..18b859314 100644 --- a/application/views/system/infocenter/messageList.php +++ b/application/views/system/infocenter/messageList.php @@ -1,37 +1,37 @@ - 0; -$widthColumn = $msgExists === true ? 8 : 12; -?> -
- - - - - - - - - - - - - - - - - - - - - -
p->t('global','gesendetAm')) ?>p->t('global','sender')) ?>p->t('global','empfaenger')) ?>p->t('global','betreff')) ?>p->t('global','gelesenAm')) ?>
insertamum) ? date_format(date_create($message->insertamum), 'd.m.Y H:i:s') : '' ?>sevorname.' '.$message->senachname ?>revorname.' '.$message->renachname ?>subject ?>statusamum) ? date_format(date_create($message->statusamum), 'd.m.Y H:i:s') : '' ?>
-
- -
-
-
-
- -
-
- + 0; +$widthColumn = $msgExists === true ? 8 : 12; +?> +
+ + + + + + + + + + + + + + + + + + + + + +
p->t('global','gesendetAm')) ?>p->t('global','sender')) ?>p->t('global','empfaenger')) ?>p->t('global','betreff')) ?>p->t('global','gelesenAm')) ?>
insertamum) ? date_format(date_create($message->insertamum), 'd.m.Y H:i:s') : '' ?>sevorname.' '.$message->senachname ?>revorname.' '.$message->renachname ?>subject ?>statusamum) ? date_format(date_create($message->statusamum), 'd.m.Y H:i:s') : '' ?>
+
+ +
+
+
+
+ +
+
+ diff --git a/application/views/system/infocenter/notizen.php b/application/views/system/infocenter/notizen.php index 13f7bb6e1..b28f7939a 100644 --- a/application/views/system/infocenter/notizen.php +++ b/application/views/system/infocenter/notizen.php @@ -1,20 +1,20 @@ - - - - - - - - - - - - - - - - - - +
p->t('global', 'datum')) ?>p->t('global', 'notiz')) ?>User
insertamum), 'd.m.Y H:i:s') ?>titel) ?>verfasser_uid ?>
+ + + + + + + + + + + + + + + + +
p->t('global', 'datum')) ?>p->t('global', 'notiz')) ?>User
insertamum), 'd.m.Y H:i:s') ?>titel) ?>verfasser_uid ?>
\ No newline at end of file diff --git a/application/views/system/messages/ajaxRead.php b/application/views/system/messages/ajaxRead.php index 2ff1f6cbb..1ed1b7f40 100644 --- a/application/views/system/messages/ajaxRead.php +++ b/application/views/system/messages/ajaxRead.php @@ -27,12 +27,16 @@ @@ -40,7 +44,7 @@ - + diff --git a/application/views/system/messages/ajaxWrite.php b/application/views/system/messages/ajaxWrite.php index 5a0a3f7b9..fe9b9e897 100644 --- a/application/views/system/messages/ajaxWrite.php +++ b/application/views/system/messages/ajaxWrite.php @@ -1,80 +1,100 @@ -load->view( - 'templates/FHC-Header', - array( - 'title' => 'Write a new message', - 'jquery' => true, - 'jqueryui' => true, - 'bootstrap' => true, - 'fontawesome' => true, - 'sbadmintemplate' => true, - 'ajaxlib' => true, - 'dialoglib' => true, - 'tinymce' => true, - 'phrases' => array('global', 'ui'), - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), - 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/write.js') - ) - ); -?> - -
-
-
-
-
- -
-
-
-
-
- -
-
- -
-
-
-
-
-
- -
-   -
- -
-
-
-
-
-
- - - -
- -
- p->t('ui', 'altRecipientNote'); ?> -
-
-
-
-
-
- -
-
-
-
-
- - -load->view("templates/FHC-Footer"); ?> +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Write a new message', + 'jquery' => true, + 'jqueryui' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'tinymce' => true, + 'phrases' => array('global', 'ui'), + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/write.js') + ) + ); +?> + +
+
+
+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+   +
+ +
+
+
+
+
+
+ + + +
+ +
+ + p->t('ui', 'altRecipientNote'); ?> + +
+
+
+
+
+
+ +
+
+
+
+
+ + +load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/ajaxWriteReply.php b/application/views/system/messages/ajaxWriteReply.php index 36d999fc0..2fdaea907 100644 --- a/application/views/system/messages/ajaxWriteReply.php +++ b/application/views/system/messages/ajaxWriteReply.php @@ -1,81 +1,101 @@ -load->view( - 'templates/FHC-Header', - array( - 'title' => 'Reply to a message', - 'jquery' => true, - 'jqueryui' => true, - 'bootstrap' => true, - 'fontawesome' => true, - 'sbadmintemplate' => true, - 'ajaxlib' => true, - 'dialoglib' => true, - 'tinymce' => true, - 'phrases' => array('global', 'ui'), - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), - 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/writeReply.js') - ) - ); -?> - -
-
-
-
-
- -
-
-
-
-
- -
-
- - - -
-
-
-
-
-
- -
-   -
- - - -
-
-
-
-
-
- - -
-
-
-
-
- - - - - - -
-
-
-
-
- - -load->view("templates/FHC-Footer"); ?> +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Reply to a message', + 'jquery' => true, + 'jqueryui' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'tinymce' => true, + 'phrases' => array('global', 'ui'), + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/writeReply.js') + ) + ); +?> + +
+
+
+
+
+ +
+
+
+
+
+ +
+
+ + + +
+
+
+
+
+
+ +
+   +
+ + + +
+
+
+
+
+
+ + +
+
+
+
+
+ + + + + + +
+
+
+
+
+ + +load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/htmlRead.php b/application/views/system/messages/htmlRead.php index 390e84ccc..ed184f7c5 100644 --- a/application/views/system/messages/htmlRead.php +++ b/application/views/system/messages/htmlRead.php @@ -1,88 +1,104 @@ -load->view( - 'templates/FHC-Header', - array( - 'title' => 'Read a message', - 'jquery' => true, - 'bootstrap' => true, - 'fontawesome' => true, - 'sbadmintemplate' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css') - ) - ); -?> - -
-
-
-
-
- -
-
-
-
-
-
- - subject; ?> - -
-
- - - - - - - - - - - - - -
- From: - - - vorname.' '.$sender->nachname; ?> - -
- Subject: - - - subject; ?> - -
- Message: - - - body; ?> - -
-
- -
-
-
-
-
-
- - -load->view("templates/FHC-Footer"); ?> +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Read a message', + 'jquery' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css') + ) + ); +?> + +
+
+
+
+
+ +
+
+
+
+
+
+ + subject; ?> + +
+
+ + + + + + + + + + + + + +
+ + + p->t('ui', 'from')); ?>: + + + + + vorname.' '.$sender->nachname; ?> + +
+ + + p->t('global', 'betreff')); ?>: + + + + + subject; ?> + +
+ + + p->t('global', 'nachricht')); ?>: + + + + + body; ?> + +
+
+ +
+
+
+
+
+
+ + +load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/htmlWriteReply.php b/application/views/system/messages/htmlWriteReply.php index 8e1ef7d7f..fa3390bfa 100644 --- a/application/views/system/messages/htmlWriteReply.php +++ b/application/views/system/messages/htmlWriteReply.php @@ -19,14 +19,22 @@
- +
- +
@@ -38,7 +46,11 @@
- +
 
@@ -49,14 +61,22 @@
- +

- +
diff --git a/application/views/system/messages/htmlWriteTemplate.php b/application/views/system/messages/htmlWriteTemplate.php index 5309e0cb5..d26ec534c 100644 --- a/application/views/system/messages/htmlWriteTemplate.php +++ b/application/views/system/messages/htmlWriteTemplate.php @@ -36,7 +36,7 @@
@@ -50,7 +50,7 @@
@@ -65,7 +65,7 @@
+<<<<<<< Updated upstream +======= + +>>>>>>> Stashed changes diff --git a/public/js/messaging/messageWrite.js b/public/js/messaging/messageWrite.js index cc9d40730..0676329de 100644 --- a/public/js/messaging/messageWrite.js +++ b/public/js/messaging/messageWrite.js @@ -19,24 +19,13 @@ function tinymcePreviewSetContent() function parseMessageText(receiver_id, text) { - var data = {text: text}; - - if ($("#type").val() == 'persons') - { - data.person_id = receiver_id; - } - else if ($("#type").val() == 'prestudents') - { - data.prestudent_id = receiver_id; - } - else - { - return; - } - FHC_AjaxClient.ajaxCallGet( "system/messages/Messages/parseMessageText", - data, + { + receiver_id: receiver_id, + text: text, + type: $("#type").val() + }, { successCallback: function(data, textStatus, jqXHR) { From 937db42e1187ca1e91e0d5c4999e4d3f6a4a7ff4 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 12 Feb 2020 16:14:50 +0100 Subject: [PATCH 060/138] - Allow to change the subject in all reply pages - Remove tabs and/or blanks from subject when replying --- application/views/system/messages/ajaxWriteReply.php | 4 ++-- application/views/system/messages/htmlRead.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/application/views/system/messages/ajaxWriteReply.php b/application/views/system/messages/ajaxWriteReply.php index 2fdaea907..a43131d1d 100644 --- a/application/views/system/messages/ajaxWriteReply.php +++ b/application/views/system/messages/ajaxWriteReply.php @@ -56,9 +56,9 @@
  -
+
- +
diff --git a/application/views/system/messages/htmlRead.php b/application/views/system/messages/htmlRead.php index 985eee326..5413af9f4 100644 --- a/application/views/system/messages/htmlRead.php +++ b/application/views/system/messages/htmlRead.php @@ -85,7 +85,7 @@ From c54579ef7de80e0ab64a5ce78f474b36567ef582 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 12 Feb 2020 16:39:00 +0100 Subject: [PATCH 061/138] /system/messages/MessageClient/read sent messages: read them all --- application/models/system/Recipient_model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index c2acd2d56..8e2e46513 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -464,7 +464,7 @@ class Recipient_model extends DB_Model JOIN public.tbl_msg_recipient mr ON (mr.message_id = mm.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND mr.person_id = mr.person_id) JOIN public.tbl_person p ON (p.person_id = mr.person_id) - JOIN public.tbl_organisationseinheit oe ON (oe.oe_kurzbz = mr.oe_kurzbz) + LEFT JOIN public.tbl_organisationseinheit oe ON (oe.oe_kurzbz = mr.oe_kurzbz) WHERE mm.person_id = ? AND mr.sent IS NOT NULL AND mr.sentinfo IS NULL From a4bfdfb4a0e590ffdbb9c48b3acc5b26245984b0 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 13 Feb 2020 12:49:57 +0100 Subject: [PATCH 062/138] Fixed merge with stashed files in system/messages/htmlWriteTemplate.php --- application/views/system/messages/htmlWriteTemplate.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/application/views/system/messages/htmlWriteTemplate.php b/application/views/system/messages/htmlWriteTemplate.php index 77bc168a7..64a8c8236 100644 --- a/application/views/system/messages/htmlWriteTemplate.php +++ b/application/views/system/messages/htmlWriteTemplate.php @@ -162,12 +162,7 @@
-<<<<<<< Updated upstream - - -======= ->>>>>>> Stashed changes From 21da8dfb51e94004dbecc04153658c3b1efd06aa Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 13 Feb 2020 18:49:01 +0100 Subject: [PATCH 063/138] - Added offsetpunkte Berechnung for Suggestions on admin/edit_gebiet page - offsetpunkte are validated before saving --- cis/testtool/admin/edit_gebiet.php | 8 +- include/gebiet.class.php | 135 ++++++++++++++++++++++++++++- 2 files changed, 141 insertions(+), 2 deletions(-) diff --git a/cis/testtool/admin/edit_gebiet.php b/cis/testtool/admin/edit_gebiet.php index 474546d4a..80a205574 100644 --- a/cis/testtool/admin/edit_gebiet.php +++ b/cis/testtool/admin/edit_gebiet.php @@ -258,7 +258,13 @@ if ($gebiet_id != '') $hinweis = ''; echo 'Maximale Punkteanzahl'.$hinweis.''; echo ''; - echo 'Offsetpunkte (minimale Punkteanzahl)'; + // empfohlene offsetpunkte berechnen und anzeigen + $offsetpunkte = $gebiet->berechneOffsetpunkte($gebiet_id); + if ($gebiet->offsetpunkte != $offsetpunkte) + $hinweis = ' empfohlene Offsetpunkteanzahl: '.round($offsetpunkte).(round($offsetpunkte) != $offsetpunkte?' ('.$offsetpunkte.' gerundet)':'').''; + else + $hinweis = ''; + echo 'Offsetpunkte (minimale Punkteanzahl)'.$hinweis.''; echo ''; echo 'Maximale Fragenanzahl'; echo ''; diff --git a/include/gebiet.class.php b/include/gebiet.class.php index a83c3319c..0268944cc 100644 --- a/include/gebiet.class.php +++ b/include/gebiet.class.php @@ -171,6 +171,11 @@ class gebiet extends basis_db $this->errormsg = 'Maxpunkte muss eine gueltige Zahl sein'; return false; } + if(!is_numeric($this->offsetpunkte) && $this->offsetpunkte!='') + { + $this->errormsg = 'Offsetpunkte muss eine gueltige Zahl sein'; + return false; + } if(!is_numeric($this->antwortenprozeile) || $this->antwortenprozeile<=0) { $this->errormsg = 'AntortenProZeile muss eine gueltige Zahl und groesser als 0 sein'; @@ -571,7 +576,8 @@ class gebiet extends basis_db ( SELECT level, frage_id, sum(punkte) as punkte FROM testtool.tbl_frage JOIN testtool.tbl_vorschlag USING(frage_id) - WHERE gebiet_id=".$this->db_add_param($gebiet_id, FHC_INTEGER)." AND punkte>0 AND level>=".$this->db_add_param($this->level_start)." AND NOT demo + WHERE gebiet_id=".$this->db_add_param($gebiet_id, FHC_INTEGER)." AND punkte>0 + AND level>=".$this->db_add_param($this->level_start)." AND NOT demo GROUP BY level, frage_id ) as a GROUP by level, punkte ORDER BY level"; @@ -616,6 +622,133 @@ class gebiet extends basis_db } } + /** + * Berechnet die offsetpunkte fuer das Gebiet + * + * @param $gebiet_id + */ + public function berechneOffsetpunkte($gebiet_id) + { + if(!$this->load($gebiet_id)) + return false; + + $qry = " + WITH fragen AS ( + SELECT tbl_frage.frage_id, tbl_frage.gebiet_id, tbl_frage.level, punkte + FROM testtool.tbl_frage + JOIN testtool.tbl_vorschlag USING (frage_id) + WHERE tbl_vorschlag.aktiv + AND tbl_vorschlag.punkte < 0 + AND tbl_frage.demo = false + AND tbl_frage.aktiv + ), + fragenanzahl AS ( + SELECT gebiet_id, level, levelgleichverteilung, + CASE WHEN levelgleichverteilung + THEN + ROUND(COALESCE(maxfragen + * ((SELECT count(*) FROM testtool.tbl_frage f WHERE f.level = tbl_frage.level AND f.gebiet_id = tbl_frage.gebiet_id)::decimal) + / (SELECT count(*) FROM testtool.tbl_frage f WHERE f.gebiet_id = tbl_frage.gebiet_id)::decimal + , (SELECT count(*) FROM testtool.tbl_frage f WHERE f.level = tbl_frage.level AND f.gebiet_id = tbl_frage.gebiet_id) + )) + ELSE + COALESCE(maxfragen, count(*)) + END + AS anzahl + FROM testtool.tbl_frage + JOIN testtool.tbl_gebiet USING (gebiet_id) + WHERE tbl_frage.aktiv + AND tbl_frage.demo = false + GROUP BY gebiet_id, level, levelgleichverteilung, maxfragen + ) + SELECT + tbl_gebiet.gebiet_id, tbl_gebiet.bezeichnung, + tbl_gebiet.multipleresponse, + tbl_gebiet.maxpunkte, tbl_gebiet.maxfragen, + tbl_gebiet.levelgleichverteilung, + tbl_gebiet.level_start, + ( + CASE WHEN tbl_gebiet.levelgleichverteilung THEN + (CASE WHEN tbl_gebiet.multipleresponse=false THEN + (SELECT sum(frprolevel) FROM + ( + SELECT fragen.level, (min(punkte) + * (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = fragen.gebiet_id and fragenanzahl.level = fragen.level LIMIT 1)) AS frprolevel + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + GROUP BY fragen.gebiet_id, level + ) pkteprolevel) + ELSE + (SELECT sum(frprolevel) FROM + ( + SELECT fragen.level, (sum(punkte) + * (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = fragen.gebiet_id and fragenanzahl.level = fragen.level LIMIT 1)) AS frprolevel + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + AND frage_id = (SELECT min(frage_id) FROM fragen fr WHERE fr.gebiet_id = fragen.gebiet_id AND fr.level = fragen.level) + GROUP BY fragen.gebiet_id, level + ) pkteprolevel) + END) *(-1) + WHEN tbl_gebiet.level_start IS NOT NULL THEN + (CASE WHEN tbl_gebiet.multipleresponse=false THEN + ( + SELECT min(punkte) + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + AND fragen.level = tbl_gebiet.level_start + ) * (SELECT fragenanzahl.anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) + ELSE + (SELECT sum(punkte) + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + AND frage_id = (SELECT min(frage_id) FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id) + AND fragen.level = tbl_gebiet.level_start + )* (SELECT fragenanzahl.anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) + END) *(-1) + ELSE + (CASE WHEN tbl_gebiet.multipleresponse=false THEN + ( + SELECT min(punkte) + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + ) * (SELECT fragenanzahl.anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) + ELSE + (SELECT sum(punkte) + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + AND frage_id = (SELECT min(frage_id) FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id) + )* (SELECT fragenanzahl.anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) + END) *(-1) + + END) AS offsetpunkte + FROM + testtool.tbl_gebiet + WHERE + EXISTS( + SELECT 1 FROM fragen WHERE fragen.gebiet_id=tbl_gebiet.gebiet_id + ) + AND gebiet_id = ".$this->db_add_param($gebiet_id, FHC_INTEGER)." + "; + + if($this->db_query($qry)) + { + if($row = $this->db_fetch_object()) + { + return $row->offsetpunkte; + } + else + { + $this->errormsg = 'Fehler beim Ermitteln der Offsetpunkte'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Ermitteln der Offsetpunkte'; + return false; + } + } + /** * Prueft ob das Gebiet bereits gestartet wurde. Wahlweise pruefling_id oder prestudent_id * From b60e7ed43927332c4cf307696691a452a1c291e0 Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Thu, 13 Feb 2020 19:08:37 +0100 Subject: [PATCH 064/138] =?UTF-8?q?Option=20zur=20Ausgabe=20der=20Fragen?= =?UTF-8?q?=20ohne=20L=C3=B6sungen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cis/testtool/admin/uebersichtFragen.php | 35 +++++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/cis/testtool/admin/uebersichtFragen.php b/cis/testtool/admin/uebersichtFragen.php index 71d154a1b..50963a337 100644 --- a/cis/testtool/admin/uebersichtFragen.php +++ b/cis/testtool/admin/uebersichtFragen.php @@ -35,7 +35,7 @@ if (!$db = new basis_db()) Testool Fragen Übersicht - + isBerechtigt('basis/testtool', null, 's')) $gebiet = new gebiet(); $gebiet->getAll(); $sprache = (isset($_REQUEST['Sprache'])?$_REQUEST['Sprache']:'German'); -$Auswahlgebiet = (isset($_REQUEST['AuswahlGebiet'])?$_REQUEST['AuswahlGebiet']:''); +$Auswahlgebiet = (isset($_REQUEST['AuswahlGebiet'])?$_REQUEST['AuswahlGebiet']:''); +$loesungen = (isset($_REQUEST['loesungen']) && $_REQUEST['loesungen'] != '' ? true:false); echo ' @@ -76,6 +77,13 @@ else echo' + + + + +
+Mit Lösungen +

'; @@ -208,8 +216,17 @@ if(isset($_REQUEST['AuswahlGebiet'])) $vorschlag = new vorschlag(); $vorschlag->loadVorschlagSprache($vor->vorschlag_id, $sprache); - if($vorschlag->bild =='') - echo ''.$vor->punkte.' '.$vorschlag->text.''; + if($vorschlag->bild == '') + { + if ($loesungen) + { + echo ''.$vor->nummer.''.$vor->punkte.' '.$vorschlag->text.''; + } + else + { + echo ''.$vor->nummer.' '.$vorschlag->text.''; + } + } if($vorschlag->bild!='') { // zeilenumbruch nach 4 bilder @@ -217,7 +234,15 @@ if(isset($_REQUEST['AuswahlGebiet'])) echo ""; echo ""; echo "
"; - echo "
".$vor->punkte.""; + if ($loesungen) + { + echo "
".$vor->punkte.""; + } + else + { + echo ""; + } + $anzahlBild++; } if($vorschlag->audio!='') From 1ac14fca24de1a9c55aec14c3d586e41d02a3d51 Mon Sep 17 00:00:00 2001 From: Nikolaus Krondraf Date: Fri, 14 Feb 2020 07:33:28 +0100 Subject: [PATCH 065/138] =?UTF-8?q?Pr=C3=BCfungstermine=20werden=20nicht?= =?UTF-8?q?=20mehr=20doppelt=20angezeigt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cis/private/lehre/pruefung/pruefung.js.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cis/private/lehre/pruefung/pruefung.js.php b/cis/private/lehre/pruefung/pruefung.js.php index b207c94e5..aafcf9710 100644 --- a/cis/private/lehre/pruefung/pruefung.js.php +++ b/cis/private/lehre/pruefung/pruefung.js.php @@ -337,10 +337,10 @@ function writePruefungsTable(e, data, anmeldung) { var row = ""; var teilnehmer = ""; - var button = ""; row += ""+e.organisationseinheit+""+e.lehrveranstaltung[0].bezeichnung+"
("+e.lehrveranstaltung[0].lehrform_kurzbz+", "+e.lehrveranstaltung[0].ects+" ECTS, "+e.pruefung.mitarbeiter_uid+")"; e.pruefung.termine.forEach(function(d){ - var storno = false; + var button = ""; + var storno = false; var anmeldung_id = null; data.result.anmeldungen.forEach(function(anmeldung){ if((anmeldung.pruefungstermin_id === d.pruefungstermin_id) && (anmeldung.lehrveranstaltung_id === e.lehrveranstaltung[0].lehrveranstaltung_id)) From c81a25988e30affe25bb3950b716a030a1c97a15 Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Fri, 14 Feb 2020 15:31:20 +0100 Subject: [PATCH 066/138] Historie-Feld nebeneinander --- content/student/studentdetailoverlay.xul.php | 326 ++++++++++--------- 1 file changed, 164 insertions(+), 162 deletions(-) diff --git a/content/student/studentdetailoverlay.xul.php b/content/student/studentdetailoverlay.xul.php index aabe442d4..0a014b20a 100644 --- a/content/student/studentdetailoverlay.xul.php +++ b/content/student/studentdetailoverlay.xul.php @@ -504,170 +504,172 @@ echo '';
diff --git a/public/js/messaging/writeReply.js b/public/js/messaging/writeReply.js index aeb13dc2c..c78748889 100644 --- a/public/js/messaging/writeReply.js +++ b/public/js/messaging/writeReply.js @@ -13,7 +13,7 @@ function sendReply() receiver_id: $('#receiver_id').val(), relationmessage_id: $('#relationmessage_id').val(), token: $('#token').val(), - subject: $('#subject').html(), + subject: $('#subject').val(), body: tinyMCE.get("body").getContent() }, { From a063a73c412f234d8f265e7015440770cceb745d Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 17 Feb 2020 19:26:55 +0100 Subject: [PATCH 071/138] reihungst admin edit_gebiet.php: checking that there are same negativpoints for one gebiet and one level before showing offsetpunkte suggestion for RT gebiete --- cis/testtool/admin/edit_gebiet.php | 14 ++++--- include/gebiet.class.php | 59 ++++++++++++++++++++++++++---- 2 files changed, 60 insertions(+), 13 deletions(-) diff --git a/cis/testtool/admin/edit_gebiet.php b/cis/testtool/admin/edit_gebiet.php index 80a205574..5610679b4 100644 --- a/cis/testtool/admin/edit_gebiet.php +++ b/cis/testtool/admin/edit_gebiet.php @@ -259,12 +259,16 @@ if ($gebiet_id != '') echo 'Maximale Punkteanzahl'.$hinweis.''; echo ''; // empfohlene offsetpunkte berechnen und anzeigen + $offsethinweis = ''; $offsetpunkte = $gebiet->berechneOffsetpunkte($gebiet_id); - if ($gebiet->offsetpunkte != $offsetpunkte) - $hinweis = ' empfohlene Offsetpunkteanzahl: '.round($offsetpunkte).(round($offsetpunkte) != $offsetpunkte?' ('.$offsetpunkte.' gerundet)':'').''; - else - $hinweis = ''; - echo 'Offsetpunkte (minimale Punkteanzahl)'.$hinweis.''; + if ($offsetpunkte) + { + $offsetwarnung = strlen($gebiet->errormsg) > 0 ? ' (HINWEIS: '.$gebiet->errormsg.')' : ''; + + if ($gebiet->offsetpunkte != $offsetpunkte) + $offsethinweis = ' empfohlene Offsetpunkteanzahl: '.round($offsetpunkte).(round($offsetpunkte) != $offsetpunkte ? ' ('.$offsetpunkte.' gerundet)' : '').$offsetwarnung.''; + } + echo 'Offsetpunkte (minimale Punkteanzahl)'.$offsethinweis.''; echo ''; echo 'Maximale Fragenanzahl'; echo ''; diff --git a/include/gebiet.class.php b/include/gebiet.class.php index 0268944cc..dbdd50b3d 100644 --- a/include/gebiet.class.php +++ b/include/gebiet.class.php @@ -632,6 +632,49 @@ class gebiet extends basis_db if(!$this->load($gebiet_id)) return false; + $checkqry = "SELECT COUNT (uniquepoints) AS count_uniquepoints + FROM ( + SELECT gebiet_id, + level, + count(DISTINCT punkte), + CASE WHEN count(DISTINCT punkte) > 1 THEN FALSE ELSE TRUE END AS uniquepoints + FROM ( + SELECT tbl_frage.gebiet_id, + tbl_frage.level, + CASE WHEN multipleresponse THEN sum(punkte) ELSE min(punkte) END AS punkte + FROM testtool.tbl_frage + JOIN testtool.tbl_vorschlag USING (frage_id) + JOIN testtool.tbl_gebiet USING (gebiet_id) + WHERE tbl_vorschlag.aktiv + AND tbl_vorschlag.punkte < 0 + AND tbl_frage.demo = false + AND tbl_frage.aktiv + AND gebiet_id = ".$this->db_add_param($gebiet_id, FHC_INTEGER)." + GROUP BY tbl_frage.gebiet_id, multipleresponse, tbl_frage.level, tbl_frage.frage_id + ) p + GROUP BY gebiet_id, level + ) pu + WHERE uniquepoints = FALSE"; + + if($this->db_query($checkqry)) + { + if($row = $this->db_fetch_object()) + { + if (!is_numeric($row->count_uniquepoints) || $row->count_uniquepoints > 0) + $this->errormsg = 'Negativpunkte sind nicht für alle Fragen gleich hoch!'; + } + else + { + $this->errormsg = 'Fehler beim Prüfen der Offsetpunkte'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Prüfen der Offsetpunkte'; + return false; + } + $qry = " WITH fragen AS ( SELECT tbl_frage.frage_id, tbl_frage.gebiet_id, tbl_frage.level, punkte @@ -688,7 +731,7 @@ class gebiet extends basis_db AND frage_id = (SELECT min(frage_id) FROM fragen fr WHERE fr.gebiet_id = fragen.gebiet_id AND fr.level = fragen.level) GROUP BY fragen.gebiet_id, level ) pkteprolevel) - END) *(-1) + END) WHEN tbl_gebiet.level_start IS NOT NULL THEN (CASE WHEN tbl_gebiet.multipleresponse=false THEN ( @@ -696,31 +739,31 @@ class gebiet extends basis_db FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id AND fragen.level = tbl_gebiet.level_start - ) * (SELECT fragenanzahl.anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) + ) * (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) ELSE (SELECT sum(punkte) FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id AND frage_id = (SELECT min(frage_id) FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id) AND fragen.level = tbl_gebiet.level_start - )* (SELECT fragenanzahl.anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) - END) *(-1) + )* (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) + END) ELSE (CASE WHEN tbl_gebiet.multipleresponse=false THEN ( SELECT min(punkte) FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id - ) * (SELECT fragenanzahl.anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) + ) * (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) ELSE (SELECT sum(punkte) FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id AND frage_id = (SELECT min(frage_id) FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id) - )* (SELECT fragenanzahl.anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) - END) *(-1) + )* (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) + END) - END) AS offsetpunkte + END) * (-1) AS offsetpunkte FROM testtool.tbl_gebiet WHERE From 0db611ed270d2128cc80b37f0707a8cdf8dc2dd5 Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 18 Feb 2020 15:19:58 +0100 Subject: [PATCH 072/138] - Added new config entry in mail config file called enable_debug - If enable_debug is true then info about the mail are logged into the CI error logs - Fixed queries to get sent and received messages with Recipient_model, now messages for which a notice email was not sent are retrieved and messages are sorted by insertamum - CL/Messages_model: - Before setting a message as read check if a record is already present - If the recipient is a prestudent then in table tbl_msg_message oe_kurzbz is set with the ou of the prestudent - The sender id (person_id) now is get from the currently logged user also when replying - MessageLib->_sendNoticeEmails checks that the message was sent only from FAS (NOT from infocenter) --- application/config/mail.php | 3 + application/libraries/MailLib.php | 50 ++++++++++----- application/libraries/MessageLib.php | 7 ++- application/models/CL/Messages_model.php | 61 +++++++++++++++---- application/models/system/Recipient_model.php | 22 +++---- 5 files changed, 100 insertions(+), 43 deletions(-) diff --git a/application/config/mail.php b/application/config/mail.php index 2163bc122..9d577720d 100644 --- a/application/config/mail.php +++ b/application/config/mail.php @@ -29,3 +29,6 @@ $config['wrapchars'] = 76; // Character count to wrap at. $config['mailtype'] = 'html'; // html or text $config['priority'] = 3; // Email Priority. 1 = highest. 5 = lowest. 3 = normal $config['validate'] = false; // If true then the email address will be validated + +// If enabled will be logged info about emails in Codeigniter error logs +$config['enable_debug'] = false; diff --git a/application/libraries/MailLib.php b/application/libraries/MailLib.php index e9e571f6c..dbbc22f08 100644 --- a/application/libraries/MailLib.php +++ b/application/libraries/MailLib.php @@ -7,6 +7,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); */ class MailLib { + const ENABLE_DEBUG = 'enable_debug'; + private $sended; // Sended email counter // Properties for storing the configuration @@ -15,6 +17,8 @@ class MailLib private $email_time_range; private $email_from_system; + private $_ci; // Codeigniter instance + /** * Class constructor */ @@ -24,16 +28,16 @@ class MailLib $this->sended = 0; // Get CI instance - $this->ci =& get_instance(); + $this->_ci =& get_instance(); // The second parameter is used to avoiding name collisions in the config array - $this->ci->config->load('mail', true); + $this->_ci->config->load('mail', true); // CI Email library - $this->ci->load->library('email'); + $this->_ci->load->library('email'); // Initializing email library with the loaded configurations - $this->ci->email->initialize($this->ci->config->config['mail']); + $this->_ci->email->initialize($this->_ci->config->config['mail']); // Set the configuration properties with the standard configuration values $this->email_number_to_sent = $this->getEmailCfgItem('email_number_to_sent'); @@ -48,6 +52,22 @@ class MailLib */ public function send($from, $to, $subject, $message, $alias = '', $cc = null, $bcc = null, $altMessage = '', $bulk = false, $autogenerated = false) { + // If it is configured then log mail info into the CI error logs + if ($this->getEmailCfgItem(self::ENABLE_DEBUG) === true) + { + $this->_ci->load->library('LogLib'); // Loads logging library + + // Log them all! + $this->_ci->loglib->logError('From: '.$from); + $this->_ci->loglib->logError('To: '.$to); + $this->_ci->loglib->logError('Subject: '.$subject); + $this->_ci->loglib->logError('Message: '.$message); + $this->_ci->loglib->logError('Alias: '.$alias); + $this->_ci->loglib->logError('CC: '.$cc); + $this->_ci->loglib->logError('BCC: '.$bcc); + $this->_ci->loglib->logError('Alternative message: '.$altMessage); + } + // If from is not specified then use the standard one if (is_null($from) || $from == '') { @@ -67,7 +87,7 @@ class MailLib } } - $this->ci->email->from($from, $alias); + $this->_ci->email->from($from, $alias); // Check if the email address of the debug recipient is a valid one $recipient = $to; @@ -83,20 +103,20 @@ class MailLib $recipientBCC = MAIL_DEBUG; } - $this->ci->email->to($recipient); - if (!is_null($recipientCC)) $this->ci->email->cc($recipientCC); - if (!is_null($recipientBCC)) $this->ci->email->bcc($recipientBCC); - $this->ci->email->subject($subject); - $this->ci->email->message($message); - if (!isEmptyString($altMessage)) $this->ci->email->set_alt_message($altMessage); + $this->_ci->email->to($recipient); + if (!is_null($recipientCC)) $this->_ci->email->cc($recipientCC); + if (!is_null($recipientBCC)) $this->_ci->email->bcc($recipientBCC); + $this->_ci->email->subject($subject); + $this->_ci->email->message($message); + if (!isEmptyString($altMessage)) $this->_ci->email->set_alt_message($altMessage); if($bulk) - $this->ci->email->set_header('Precedence', 'bulk'); + $this->_ci->email->set_header('Precedence', 'bulk'); if($autogenerated) - $this->ci->email->set_header('Auto-Submitted', 'auto-generated'); + $this->_ci->email->set_header('Auto-Submitted', 'auto-generated'); // Avoid printing on standard output ugly error messages - $result = @$this->ci->email->send(); + $result = @$this->_ci->email->send(); // If the email was succesfully sended then increment the counter // and checks if it has to wait until the sending of the next @@ -171,6 +191,6 @@ class MailLib */ private function getEmailCfgItem($itemName) { - return $this->ci->config->item($itemName, EMAIL_CONFIG_INDEX); + return $this->_ci->config->item($itemName, EMAIL_CONFIG_INDEX); } } diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 240055978..3a8f133cf 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -575,8 +575,9 @@ class MessageLib // Use the degree program email if (hasData($studiengangResult)) $message->receiverContact = getData($studiengangResult)[0]->email; } - // If message was sent from FAS - elseif (!isEmptyString($message->sender_ou)) + // If message was sent from FAS and NOT from infocenter + elseif (!isEmptyString($message->sender_ou) + && !array_search($message->sender_ou, $this->_ci->config->item(self::CFG_OU_RECEIVERS_NO_NOTICE))) { // If the recipient organisation unit is NOT in the list of organisation units that sent only to private emails if (array_search($message->receiver_ou, $this->_ci->config->item(self::CFG_OU_RECEIVERS_PRIVATE)) === false) @@ -592,7 +593,7 @@ class MessageLib } // Otherwise try with the private email - if ($message->receiverContact == null) + if (isEmptyString($message->receiverContact)) { $privateEmailResult = $this->_getPrivateEmail($message->receiver_id); if (isError($privateEmailResult)) return $privateEmailResult; // if an error occured then return it diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index e2c5c34c2..a841e266a 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -62,15 +62,31 @@ class Messages_model extends CI_Model // Loads needed models $this->load->model('system/MsgStatus_model', 'MsgStatusModel'); - // Set date used to insert - $statusData = array( - 'message_id' => $message_id, - 'person_id' => $person_id, - 'status' => MSG_STATUS_READ, - 'insertvon' => getAuthUID() + $statuResult = $this->MsgStatusModel->loadWhere( + array( + 'message_id' => $message_id, + 'person_id' => $person_id, + 'status' => MSG_STATUS_READ + ) ); - return $this->MsgStatusModel->insert($statusData); // insert and return result + if (isError($statuResult)) return $statuResult; + if (!hasData($statuResult)) + { + // Set date used to insert + return $this->MsgStatusModel->insert( + array( + 'message_id' => $message_id, + 'person_id' => $person_id, + 'status' => MSG_STATUS_READ, + 'insertvon' => getAuthUID() + ) + ); // insert and return result + } + else + { + return success('Already set as read'); + } } /** @@ -348,23 +364,43 @@ class Messages_model extends CI_Model elseif ($type == self::TYPE_PRESTUDENTS) // otherwise prestudents were given { $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($recipients_ids); + + // Retrieve organisation unit for the recipients + $organisationUnitsResult = $this->PrestudentModel->getOrganisationunits($recipients_ids); + if (isError($organisationUnitsResult)) return $organisationUnitsResult; + if (hasData($organisationUnitsResult)) $senderOUArray = getData($organisationUnitsResult); } if (isError($msgVarsData)) show_error(getError($msgVarsData)); if (!hasData($msgVarsData)) show_error('No recipients were given'); + $senderOU = null; // sender organisation unit only for presetudents + $receiversCounter = 0; // a counter + + // Looping on receivers data foreach (getData($msgVarsData) as $receiver) { $msgVarsDataArray = $this->_lowerReplaceSpaceArrayKeys((array)$receiver); // replaces array keys - $parsedSubject = parseText($subject, $msgVarsDataArray); $parsedBody = parseText($body, $msgVarsDataArray); + // If exist an organisation unit for this prestudent and it is valid + if (isset($senderOUArray[$receiversCounter]) + && isset($senderOUArray[$receiversCounter]->oe_kurzbz) + && !isEmptyString($senderOUArray[$receiversCounter]->oe_kurzbz)) + { + $senderOU = $senderOUArray[$receiversCounter]->oe_kurzbz; + } + else + { + $senderOU = null; + } + $message = $this->messagelib->sendMessageUser( $msgVarsDataArray['person_id'], // receiverPersonId $parsedSubject, // subject $parsedBody, // body $sender_id, // sender_id - null, // senderOU + $senderOU, // senderOU $relationmessage_id, // relationmessage_id MSG_PRIORITY_NORMAL // priority ); @@ -378,6 +414,8 @@ class Messages_model extends CI_Model $personLog = $this->_personLog($sender_id, $msgVarsDataArray['person_id'], getData($message)[0]); if (isError($personLog)) return $personLog; } + + $receiversCounter++; // increment the counter } return success('Messages sent successfully'); @@ -452,7 +490,8 @@ class Messages_model extends CI_Model show_error('An error occurred while sending your message, please contact the site administrator'); } - $sender_id = getData($messageResult)[0]->receiver_id; + $sender_id = getAuthPersonId(); + if (!is_numeric($sender_id)) return error('The current logged user person_id is not defined'); $message = $this->messagelib->sendMessageUser( $receiver_id, // receiverPersonId @@ -484,6 +523,7 @@ class Messages_model extends CI_Model if (isEmptyString($body)) return error('Body is an empty string'); $sender_id = getAuthPersonId(); + if (!is_numeric($sender_id)) return error('The current logged user person_id is not defined'); $message = $this->messagelib->sendMessageOU( $receiverOU, // receiverPersonId @@ -672,7 +712,6 @@ class Messages_model extends CI_Model */ private function _prepareHtmlWriteTemplate($info, $message_id, $recipient_id) { - // Checks that info parameter is valid if (isError($info)) show_error(getError($info)); if (!hasData($info)) show_error('No recipients were given'); diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index bc7ab246f..cea11a7a7 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -314,7 +314,7 @@ class Recipient_model extends DB_Model mm.relationmessage_id, mm.subject, mm.body, - mr.sent AS sent, + mm.insertamum AS sent, p.vorname, p.nachname, MAX(ms.status) AS status, @@ -325,13 +325,11 @@ class Recipient_model extends DB_Model JOIN public.tbl_msg_status ms ON (ms.message_id = mr.message_id AND ms.person_id = mr.person_id) JOIN public.tbl_person p ON (p.person_id = mm.person_id) WHERE mr.person_id = ? - AND mr.sent IS NOT NULL - AND mr.sentinfo IS NULL GROUP BY mr.message_id, mm.relationmessage_id, mm.subject, mm.body, - mr.sent, + mm.insertamum, p.vorname, p.nachname, ms.person_id, @@ -342,7 +340,7 @@ class Recipient_model extends DB_Model mm.relationmessage_id, mm.subject, mm.body, - mrou.sent AS sent, + mm.insertamum AS sent, pr.vorname, pr.nachname, MAX(ms.status) AS status, @@ -362,13 +360,11 @@ class Recipient_model extends DB_Model JOIN public.tbl_msg_status ms ON (ms.message_id = mrou.message_id AND ms.person_id = mrou.person_id) JOIN public.tbl_person pr ON (pr.person_id = mm.person_id) WHERE p.person_id = ? - AND mrou.sent IS NOT NULL - AND mrou.sentinfo IS NULL GROUP BY mrou.message_id, mm.relationmessage_id, mm.subject, mm.body, - mrou.sent, + mm.insertamum, pr.vorname, pr.nachname, ms.person_id, @@ -387,7 +383,7 @@ class Recipient_model extends DB_Model mm.relationmessage_id, mm.subject, mm.body, - mr.sent, + mm.insertamum AS sent, p.person_id, p.vorname, p.nachname, @@ -397,24 +393,22 @@ class Recipient_model extends DB_Model mr.token FROM public.tbl_msg_message mm JOIN public.tbl_msg_recipient mr ON (mr.message_id = mm.message_id) - JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND mr.person_id = mr.person_id) + JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND ms.person_id = mr.person_id) JOIN public.tbl_person p ON (p.person_id = mr.person_id) LEFT JOIN public.tbl_organisationseinheit oe ON (oe.oe_kurzbz = mr.oe_kurzbz) WHERE mm.person_id = ? - AND mr.sent IS NOT NULL - AND mr.sentinfo IS NULL GROUP BY mm.message_id, mm.relationmessage_id, mm.subject, mm.body, - mr.sent, + mm.insertamum, p.person_id, p.vorname, p.nachname, ms.person_id, oe.bezeichnung, mr.token - ORDER BY mr.sent DESC'; + ORDER BY sent DESC'; return $this->execQuery($sql, array($person_id)); } From d74a516202a776cbc0752810f6ca54dd835ec1e6 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 18 Feb 2020 17:33:44 +0100 Subject: [PATCH 073/138] - testtool edit_gebiet.php: hinweis for suggestion offsetpunkteanzahl is always shown --- cis/testtool/admin/edit_gebiet.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cis/testtool/admin/edit_gebiet.php b/cis/testtool/admin/edit_gebiet.php index 5610679b4..68c502577 100644 --- a/cis/testtool/admin/edit_gebiet.php +++ b/cis/testtool/admin/edit_gebiet.php @@ -265,8 +265,8 @@ if ($gebiet_id != '') { $offsetwarnung = strlen($gebiet->errormsg) > 0 ? ' (HINWEIS: '.$gebiet->errormsg.')' : ''; - if ($gebiet->offsetpunkte != $offsetpunkte) - $offsethinweis = ' empfohlene Offsetpunkteanzahl: '.round($offsetpunkte).(round($offsetpunkte) != $offsetpunkte ? ' ('.$offsetpunkte.' gerundet)' : '').$offsetwarnung.''; + $offsethinweis = ' empfohlene Offsetpunkteanzahl: '.round($offsetpunkte).(round($offsetpunkte) != $offsetpunkte ? ' ('.$offsetpunkte.' gerundet)' : '').''; + $offsethinweis .= ''.$offsetwarnung.''; } echo 'Offsetpunkte (minimale Punkteanzahl)'.$offsethinweis.''; echo ''; From 0b3d5e19a37fcde97901874a7d3436648c993f72 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 20 Feb 2020 14:39:37 +0100 Subject: [PATCH 074/138] CL/Messages_model->sendReply now uses as sender id the logged user person id or the previous message recipient id --- application/models/CL/Messages_model.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index a841e266a..dd9655131 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -472,6 +472,7 @@ class Messages_model extends CI_Model /** * Send a reply to a single recipient for a message identified by a token (no templates are used) + * NOTE: this method could be also called from not authenticated controllers */ public function sendReply($receiver_id, $subject, $body, $relationmessage_id, $token) { @@ -490,8 +491,9 @@ class Messages_model extends CI_Model show_error('An error occurred while sending your message, please contact the site administrator'); } - $sender_id = getAuthPersonId(); - if (!is_numeric($sender_id)) return error('The current logged user person_id is not defined'); + // If the user is logged then use its person id as sender id, otherwise get the receiver id of the previous message + $sender_id = isLogged() ? getAuthPersonId() : getData($messageResult)[0]->receiver_id; + if (!is_numeric($sender_id)) return error('The sender id is not valid'); $message = $this->messagelib->sendMessageUser( $receiver_id, // receiverPersonId From 1ac1c118d530efb7e28729297a31aa2f154b6c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Thu, 20 Feb 2020 15:53:43 +0100 Subject: [PATCH 075/138] Fixed Message Reply --- application/models/CL/Messages_model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index dd9655131..de6ec5a10 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -271,9 +271,9 @@ class Messages_model extends CI_Model if (isError($isEmployeeResult)) show_error(getError($isEmployeeResult)); if (hasData($isEmployeeResult)) $isEmployee = true; - // If the sender is an employee and are present configurations to reply + // If the sender is not an employee and are present configurations to reply $hrefReply = ''; - if ($isEmployee && !isEmptyString($this->config->item(MessageLib::CFG_REDIRECT_VIEW_MESSAGE_URL))) + if (!$isEmployee && !isEmptyString($this->config->item(MessageLib::CFG_REDIRECT_VIEW_MESSAGE_URL))) { $hrefReply = $this->config->item(MessageLib::CFG_MESSAGE_SERVER). $this->config->item(MessageLib::CFG_REDIRECT_VIEW_MESSAGE_URL). From 9a9b847138ba5c32842ae43b4775adc731c41775 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 20 Feb 2020 16:21:31 +0100 Subject: [PATCH 076/138] Fixed Tabulator include in FHC-Header --- application/views/templates/FHC-Header.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index c569d2389..5eec10f43 100644 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -182,7 +182,11 @@ } // Tabulator JS - if ($tabulator === true) generateJSsInclude('vendor/olifolkerd/tabulator/dist/js/tabulator.min.js'); + if ($tabulator === true) + { + generateJSsInclude('vendor/olifolkerd/tabulator/dist/js/tabulator.min.js'); + generateJSsInclude('vendor/olifolkerd/tabulator/dist/js/jquery_wrapper.min.js'); + } // Tinymce JS if ($tinymce === true) generateJSsInclude('vendor/tinymce/tinymce/tinymce.min.js'); From fc9ae760b5a7849c2287d2678eca3140cd2ca209 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 20 Feb 2020 17:07:57 +0100 Subject: [PATCH 077/138] public.vw_msg_vars: added variables semester, Studiengangsassistenz, relative Prio --- system/dbupdate_3.3.php | 174 ++++++++++++++++++++++++++-------------- 1 file changed, 116 insertions(+), 58 deletions(-) diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index a7d4011cc..de3df43c0 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -3462,77 +3462,135 @@ if(!$result = @$db->db_query("SELECT orgform_kurzbz FROM public.tbl_bankverbindu } // iban und bic zu vw_msg_vars hinzufügen -if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang" FROM public.vw_msg_vars LIMIT 1')) +if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang", "Studiengangskennzahl", "Einstiegssemester", "Einstiegsstudiensemester", "Vorname Studiengangsassistenz", "Nachname Studiengangsassistenz", "Durchwahl Studiengangsassistenz", "Relative Priorität" FROM public.vw_msg_vars LIMIT 1')) { $qry = ' CREATE OR REPLACE VIEW public.vw_msg_vars AS ( SELECT DISTINCT ON(p.person_id, pr.prestudent_id) p.person_id, - pr.prestudent_id AS prestudent_id, - p.nachname AS "Nachname", - p.vorname AS "Vorname", - p.anrede AS "Anrede", - a.strasse AS "Strasse", - a.ort AS "Ort", - a.plz AS "PLZ", - a.gemeinde AS "Gemeinde", - a.langtext AS "Nation", - ke.kontakt AS "Email", - kt.kontakt AS "Telefon", - s.bezeichnung AS "Studiengang DE", - s.english AS "Studiengang EN", - st.bezeichnung AS "Typ", - last_prestudent_status.orgform_kurzbz AS "Orgform", - p.zugangscode AS "Zugangscode", - bk.iban AS "IBAN Studiengang", - bk.bic AS "BIC Studiengang" - FROM public.tbl_person p - LEFT JOIN ( - SELECT person_id, - kontakt - FROM public.tbl_kontakt - WHERE zustellung = TRUE - AND kontakttyp = \'email\' - ORDER BY kontakt_id DESC - ) ke USING(person_id) - LEFT JOIN ( - SELECT person_id, - kontakt - FROM public.tbl_kontakt - WHERE zustellung = TRUE - AND kontakttyp IN (\'telefon\', \'mobil\') - ORDER BY kontakt_id DESC - ) kt USING(person_id) - LEFT JOIN ( - SELECT person_id, - strasse, - ort, - plz, - gemeinde, - langtext - FROM public.tbl_adresse + pr.prestudent_id AS prestudent_id, + p.nachname AS "Nachname", + p.vorname AS "Vorname", + p.anrede AS "Anrede", + a.strasse AS "Strasse", + a.ort AS "Ort", + a.plz AS "PLZ", + a.gemeinde AS "Gemeinde", + a.langtext AS "Nation", + ke.kontakt AS "Email", + kt.kontakt AS "Telefon", + s.bezeichnung AS "Studiengang DE", + s.english AS "Studiengang EN", + st.bezeichnung AS "Typ", + last_prestudent_status.orgform_kurzbz AS "Orgform", + p.zugangscode AS "Zugangscode", + bk.iban AS "IBAN Studiengang", + bk.bic AS "BIC Studiengang", + s.studiengang_kz AS "Studiengangskennzahl", + first_prestudent_status.ausbildungssemester AS "Einstiegssemester", + first_prestudent_status.studiensemester AS "Einstiegsstudiensemester", + ass.vorname AS "Vorname Studiengangsassistenz", + ass.nachname AS "Nachname Studiengangsassistenz", + ass.telefonklappe AS "Durchwahl Studiengangsassistenz", + (SELECT count(*) + FROM ( + SELECT pss.prestudent_id, pss.person_id, priorisierung, + ( + SELECT status_kurzbz + FROM public.tbl_prestudentstatus + WHERE prestudent_id = pss.prestudent_id + ORDER BY datum DESC, + tbl_prestudentstatus.insertamum DESC LIMIT 1 + ) AS laststatus + FROM public.tbl_prestudent pss + JOIN public.tbl_prestudentstatus USING (prestudent_id) + WHERE person_id = ( + SELECT person_id + FROM public.tbl_prestudent + WHERE prestudent_id = pr.prestudent_id + ) + AND studiensemester_kurzbz = ( + SELECT studiensemester_kurzbz + FROM public.tbl_prestudentstatus + WHERE prestudent_id = pr.prestudent_id + AND status_kurzbz = \'Interessent\' LIMIT 1 + ) + AND status_kurzbz = \'Interessent\' + ) prest + WHERE laststatus NOT IN (\'Abbrecher\', \'Abgewiesener\', \'Absolvent\') + AND priorisierung <= pr.priorisierung) AS "Relative Priorität" + FROM public.tbl_person p + LEFT JOIN ( + SELECT person_id, + kontakt + FROM public.tbl_kontakt + WHERE zustellung = TRUE + AND kontakttyp = \'email\' + ORDER BY kontakt_id DESC + ) ke USING(person_id) + LEFT JOIN ( + SELECT person_id, + kontakt + FROM public.tbl_kontakt + WHERE zustellung = TRUE + AND kontakttyp IN (\'telefon\', \'mobil\') + ORDER BY kontakt_id DESC + ) kt USING(person_id) + LEFT JOIN ( + SELECT person_id, + strasse, + ort, + plz, + gemeinde, + langtext + FROM public.tbl_adresse LEFT JOIN bis.tbl_nation ON(bis.tbl_nation.nation_code = public.tbl_adresse.nation) - WHERE public.tbl_adresse.heimatadresse = TRUE - ORDER BY adresse_id DESC - ) a USING(person_id) + WHERE public.tbl_adresse.heimatadresse = TRUE + ORDER BY adresse_id DESC + ) a USING(person_id) LEFT JOIN public.tbl_prestudent pr USING(person_id) INNER JOIN public.tbl_studiengang s USING(studiengang_kz) INNER JOIN public.tbl_studiengangstyp st USING(typ) LEFT JOIN ( - SELECT DISTINCT ON (ps.prestudent_id) tbl_studienplan.orgform_kurzbz, ps.prestudent_id - FROM public.tbl_prestudent ps - JOIN public.tbl_prestudentstatus ON ps.prestudent_id = tbl_prestudentstatus.prestudent_id - JOIN lehre.tbl_studienplan USING(studienplan_id) - ORDER BY ps.prestudent_id DESC, - tbl_prestudentstatus.datum DESC, - tbl_prestudentstatus.insertamum DESC, - tbl_prestudentstatus.ext_id DESC - ) last_prestudent_status ON pr.prestudent_id = last_prestudent_status.prestudent_id + SELECT DISTINCT ON (ps.prestudent_id) ps.prestudent_id, tbl_studienplan.orgform_kurzbz + FROM public.tbl_prestudent ps + JOIN public.tbl_prestudentstatus ON ps.prestudent_id = tbl_prestudentstatus.prestudent_id + JOIN lehre.tbl_studienplan USING(studienplan_id) + ORDER BY ps.prestudent_id DESC, + tbl_prestudentstatus.datum DESC, + tbl_prestudentstatus.insertamum DESC, + tbl_prestudentstatus.ext_id DESC + ) last_prestudent_status ON pr.prestudent_id = last_prestudent_status.prestudent_id LEFT JOIN ( + SELECT DISTINCT ON (ps.prestudent_id) ps.prestudent_id, tbl_prestudentstatus.ausbildungssemester, + studiensemester_kurzbz, tbl_studiensemester.bezeichnung AS studiensemester, + tbl_studienordnung.studiengang_kz + FROM public.tbl_prestudent ps + JOIN public.tbl_prestudentstatus ON ps.prestudent_id = tbl_prestudentstatus.prestudent_id + JOIN public.tbl_studiensemester USING (studiensemester_kurzbz) + JOIN lehre.tbl_studienplan USING(studienplan_id) + JOIN lehre.tbl_studienordnung USING (studienordnung_id) + WHERE tbl_prestudentstatus.status_kurzbz = \'Interessent\' + ORDER BY ps.prestudent_id ASC, + tbl_prestudentstatus.datum ASC, + tbl_prestudentstatus.insertamum ASC, + tbl_prestudentstatus.ext_id ASC + ) first_prestudent_status ON pr.prestudent_id = first_prestudent_status.prestudent_id + LEFT JOIN ( + SELECT DISTINCT ON (tbl_benutzerfunktion.oe_kurzbz) vorname, nachname, oe_kurzbz, telefonklappe + FROM public.tbl_benutzerfunktion + JOIN public.tbl_benutzer USING (uid) + JOIN public.tbl_person USING (person_id) + JOIN public.tbl_mitarbeiter on tbl_benutzer.uid = tbl_mitarbeiter.mitarbeiter_uid + WHERE tbl_benutzerfunktion.funktion_kurzbz = \'ass\' + AND NOW() BETWEEN COALESCE(datum_von, NOW()) AND COALESCE(datum_bis, NOW()) + ORDER BY tbl_benutzerfunktion.oe_kurzbz, tbl_benutzerfunktion.insertamum DESC NULLS LAST, datum_von DESC NULLS LAST + ) ass ON s.oe_kurzbz = ass.oe_kurzbz + LEFT JOIN ( SELECT DISTINCT ON (oe_kurzbz, orgform_kurzbz) oe_kurzbz, orgform_kurzbz, iban, bic FROM tbl_bankverbindung WHERE oe_kurzbz IS NOT NULL ORDER BY oe_kurzbz, orgform_kurzbz, tbl_bankverbindung.insertamum DESC,tbl_bankverbindung.iban - )bk ON s.oe_kurzbz = bk.oe_kurzbz AND (last_prestudent_status.orgform_kurzbz = bk.orgform_kurzbz OR bk.orgform_kurzbz IS NULL) + )bk ON s.oe_kurzbz = bk.oe_kurzbz AND (last_prestudent_status.orgform_kurzbz = bk.orgform_kurzbz OR bk.orgform_kurzbz IS NULL) WHERE p.aktiv = TRUE ORDER BY p.person_id ASC, pr.prestudent_id ASC );'; @@ -3540,7 +3598,7 @@ if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang" FROM if(!$db->db_query($qry)) echo 'public.vw_msg_vars: '.$db->db_last_error().'
'; else - echo '
public.vw_msg_vars iban und bic added'; + echo '
public.vw_msg_vars IBAN Studiengang, BIC Studiengang, Studiengangskennzahl, Einstiegssemester, Einstiegsstudiensemester, Vorname Studiengangsassistenz, Nachname Studiengangsassistenz, Durchwahl Studiengangsassistenz, Relative Priorität added'; } // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen From 7043422fe9c96d7a443bb4bb75dd4eac6ef86d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Thu, 20 Feb 2020 18:11:37 +0100 Subject: [PATCH 078/138] Zahlenformat bei Lehrauftragsexport korrigiert --- content/statistik/lehrauftragsliste_mail.xls.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/statistik/lehrauftragsliste_mail.xls.php b/content/statistik/lehrauftragsliste_mail.xls.php index 6c701c4f5..853be72fe 100644 --- a/content/statistik/lehrauftragsliste_mail.xls.php +++ b/content/statistik/lehrauftragsliste_mail.xls.php @@ -125,15 +125,15 @@ $format_colored =& $workbook->addFormat(); $format_colored->setFgColor(10); $format_number_colored =& $workbook->addFormat(); -$format_number_colored->setNumFormat('0, 0.00'); +$format_number_colored->setNumFormat('0,0.00'); //$format_number_colored->setNumFormat('0.00'); $format_number_colored->setFgColor(10); $format_number =& $workbook->addFormat(); -$format_number->setNumFormat('0, 0.00'); +$format_number->setNumFormat('0,0.00'); $format_number_bold =& $workbook->addFormat(); -$format_number_bold->setNumFormat('0, 0.00'); +$format_number_bold->setNumFormat('0,0.00'); //$format_number_bold->setNumFormat('0.00'); $format_number_bold->setBold(); From f1cf82c107267f606e61599dac64cd28a9a30211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Thu, 20 Feb 2020 18:48:15 +0100 Subject: [PATCH 079/138] =?UTF-8?q?Spalte=20Alias=20hinzugef=C3=BCgt,=20Sp?= =?UTF-8?q?alte=20Prio=20umbenannt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- system/dbupdate_3.3.php | 107 ++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index de3df43c0..a3965780a 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -3462,62 +3462,63 @@ if(!$result = @$db->db_query("SELECT orgform_kurzbz FROM public.tbl_bankverbindu } // iban und bic zu vw_msg_vars hinzufügen -if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang", "Studiengangskennzahl", "Einstiegssemester", "Einstiegsstudiensemester", "Vorname Studiengangsassistenz", "Nachname Studiengangsassistenz", "Durchwahl Studiengangsassistenz", "Relative Priorität" FROM public.vw_msg_vars LIMIT 1')) +if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang", "Studiengangskennzahl", "Einstiegssemester", "Einstiegsstudiensemester", "Vorname Studiengangsassistenz", "Nachname Studiengangsassistenz", "Durchwahl Studiengangsassistenz", "Relative Prio" FROM public.vw_msg_vars LIMIT 1')) { $qry = ' CREATE OR REPLACE VIEW public.vw_msg_vars AS ( SELECT DISTINCT ON(p.person_id, pr.prestudent_id) p.person_id, - pr.prestudent_id AS prestudent_id, - p.nachname AS "Nachname", - p.vorname AS "Vorname", - p.anrede AS "Anrede", - a.strasse AS "Strasse", - a.ort AS "Ort", - a.plz AS "PLZ", - a.gemeinde AS "Gemeinde", - a.langtext AS "Nation", - ke.kontakt AS "Email", - kt.kontakt AS "Telefon", - s.bezeichnung AS "Studiengang DE", - s.english AS "Studiengang EN", - st.bezeichnung AS "Typ", - last_prestudent_status.orgform_kurzbz AS "Orgform", - p.zugangscode AS "Zugangscode", - bk.iban AS "IBAN Studiengang", - bk.bic AS "BIC Studiengang", - s.studiengang_kz AS "Studiengangskennzahl", - first_prestudent_status.ausbildungssemester AS "Einstiegssemester", - first_prestudent_status.studiensemester AS "Einstiegsstudiensemester", - ass.vorname AS "Vorname Studiengangsassistenz", - ass.nachname AS "Nachname Studiengangsassistenz", - ass.telefonklappe AS "Durchwahl Studiengangsassistenz", - (SELECT count(*) - FROM ( - SELECT pss.prestudent_id, pss.person_id, priorisierung, - ( - SELECT status_kurzbz - FROM public.tbl_prestudentstatus - WHERE prestudent_id = pss.prestudent_id - ORDER BY datum DESC, - tbl_prestudentstatus.insertamum DESC LIMIT 1 - ) AS laststatus - FROM public.tbl_prestudent pss - JOIN public.tbl_prestudentstatus USING (prestudent_id) - WHERE person_id = ( - SELECT person_id - FROM public.tbl_prestudent - WHERE prestudent_id = pr.prestudent_id - ) - AND studiensemester_kurzbz = ( - SELECT studiensemester_kurzbz - FROM public.tbl_prestudentstatus - WHERE prestudent_id = pr.prestudent_id - AND status_kurzbz = \'Interessent\' LIMIT 1 - ) - AND status_kurzbz = \'Interessent\' - ) prest - WHERE laststatus NOT IN (\'Abbrecher\', \'Abgewiesener\', \'Absolvent\') - AND priorisierung <= pr.priorisierung) AS "Relative Priorität" + pr.prestudent_id AS prestudent_id, + p.nachname AS "Nachname", + p.vorname AS "Vorname", + p.anrede AS "Anrede", + a.strasse AS "Strasse", + a.ort AS "Ort", + a.plz AS "PLZ", + a.gemeinde AS "Gemeinde", + a.langtext AS "Nation", + ke.kontakt AS "Email", + kt.kontakt AS "Telefon", + s.bezeichnung AS "Studiengang DE", + s.english AS "Studiengang EN", + st.bezeichnung AS "Typ", + last_prestudent_status.orgform_kurzbz AS "Orgform", + p.zugangscode AS "Zugangscode", + bk.iban AS "IBAN Studiengang", + bk.bic AS "BIC Studiengang", + s.studiengang_kz AS "Studiengangskennzahl", + first_prestudent_status.ausbildungssemester AS "Einstiegssemester", + first_prestudent_status.studiensemester AS "Einstiegsstudiensemester", + ass.vorname AS "Vorname Studiengangsassistenz", + ass.nachname AS "Nachname Studiengangsassistenz", + ass.telefonklappe AS "Durchwahl Studiengangsassistenz", + ass.alias AS "Alias Studiengangsassistenz", + (SELECT count(*) + FROM ( + SELECT pss.prestudent_id, pss.person_id, priorisierung, + ( + SELECT status_kurzbz + FROM public.tbl_prestudentstatus + WHERE prestudent_id = pss.prestudent_id + ORDER BY datum DESC, + tbl_prestudentstatus.insertamum DESC LIMIT 1 + ) AS laststatus + FROM public.tbl_prestudent pss + JOIN public.tbl_prestudentstatus USING (prestudent_id) + WHERE person_id = ( + SELECT person_id + FROM public.tbl_prestudent + WHERE prestudent_id = pr.prestudent_id + ) + AND studiensemester_kurzbz = ( + SELECT studiensemester_kurzbz + FROM public.tbl_prestudentstatus + WHERE prestudent_id = pr.prestudent_id + AND status_kurzbz = \'Interessent\' LIMIT 1 + ) + AND status_kurzbz = \'Interessent\' + ) prest + WHERE laststatus NOT IN (\'Abbrecher\', \'Abgewiesener\', \'Absolvent\') + AND priorisierung <= pr.priorisierung) AS "Relative Prio" FROM public.tbl_person p LEFT JOIN ( SELECT person_id, @@ -3576,7 +3577,7 @@ if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang", "Stu tbl_prestudentstatus.ext_id ASC ) first_prestudent_status ON pr.prestudent_id = first_prestudent_status.prestudent_id LEFT JOIN ( - SELECT DISTINCT ON (tbl_benutzerfunktion.oe_kurzbz) vorname, nachname, oe_kurzbz, telefonklappe + SELECT DISTINCT ON (tbl_benutzerfunktion.oe_kurzbz) vorname, nachname, oe_kurzbz, telefonklappe, alias FROM public.tbl_benutzerfunktion JOIN public.tbl_benutzer USING (uid) JOIN public.tbl_person USING (person_id) From ff7f150cb63612e1ecd14f3b8cee7429ac54d424 Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Thu, 20 Feb 2020 20:42:37 +0100 Subject: [PATCH 080/138] prioritizationJob created --- .../controllers/jobs/ReihungstestJob.php | 994 +++++++++++------- 1 file changed, 619 insertions(+), 375 deletions(-) diff --git a/application/controllers/jobs/ReihungstestJob.php b/application/controllers/jobs/ReihungstestJob.php index 84a5fe614..948eeb0b8 100644 --- a/application/controllers/jobs/ReihungstestJob.php +++ b/application/controllers/jobs/ReihungstestJob.php @@ -3,30 +3,32 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); class ReihungstestJob extends CLI_Controller { - /** - * Constructor - */ - public function __construct() - { - parent::__construct(); + /** + * Constructor + */ + public function __construct() + { + parent::__construct(); - // Load models - $this->load->model('crm/Reihungstest_model', 'ReihungstestModel'); - $this->load->model('crm/RtStudienplan_model', 'RtStudienplanModel'); - $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); - $this->load->model('organisation/Studienplan_model', 'StudienplanModel'); + // Load models + $this->load->model('crm/Reihungstest_model', 'ReihungstestModel'); + $this->load->model('crm/RtStudienplan_model', 'RtStudienplanModel'); + $this->load->model('crm/Konto_model', 'KontoModel'); + $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); + $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + $this->load->model('organisation/Studienplan_model', 'StudienplanModel'); - // Load helpers - $this->load->helper('hlp_sancho_helper'); - } + // Load helpers + $this->load->helper('hlp_sancho_helper'); + } - /** - * runReihungstestJob - */ - public function runReihungstestJob() - { - // Get study plans that have no assigned placement tests yet - $result = $this->ReihungstestModel->checkMissingReihungstest(); + /** + * runReihungstestJob + */ + public function runReihungstestJob() + { + // Get study plans that have no assigned placement tests yet + $result = $this->ReihungstestModel->checkMissingReihungstest(); $missing_rt_arr = array(); if (hasData($result)) @@ -38,8 +40,8 @@ class ReihungstestJob extends CLI_Controller show_error(getError($result)); } - // Get free places - $result = $this->ReihungstestModel->getFreePlaces(); + // Get free places + $result = $this->ReihungstestModel->getFreePlaces(); $free_places_arr = array(); if (hasData($result)) @@ -51,8 +53,8 @@ class ReihungstestJob extends CLI_Controller show_error(getError($result)); } - // Prepare data for mail template 'ReihungstestJob' - $content_data_arr = $this->_getContentData($missing_rt_arr, $free_places_arr); + // Prepare data for mail template 'ReihungstestJob' + $content_data_arr = $this->_getContentData($missing_rt_arr, $free_places_arr); // Send email in Sancho design if (!empty($missing_rt_arr) || !empty($free_places_arr)) @@ -95,7 +97,7 @@ class ReihungstestJob extends CLI_Controller // Get placement tests where registration date was yesterday $result = $this->ReihungstestModel->checkReachedRegistrationDate($degreeProgram); - $reachedRegistration_rt_arr = array(); + $reachedRegistration_rt_arr = array(); if (hasData($result)) { @@ -106,11 +108,11 @@ class ReihungstestJob extends CLI_Controller show_error(getError($result)); } - $applicants_arr = array(); + $applicants_arr = array(); - foreach ($reachedRegistration_rt_arr as $reihungstest) - { - $applicants = $this->ReihungstestModel->getApplicantsOfPlacementTestForCronjob($reihungstest->reihungstest_id); + foreach ($reachedRegistration_rt_arr as $reihungstest) + { + $applicants = $this->ReihungstestModel->getApplicantsOfPlacementTestForCronjob($reihungstest->reihungstest_id); if (hasData($applicants)) { @@ -214,24 +216,24 @@ class ReihungstestJob extends CLI_Controller // Get applicants that have been added to a test after Anmeldefrist $result = $this->ReihungstestModel->getApplicantAssignedAfterDate($degreeProgram); - $applicants_after_anmeldefrist_arr = array(); + $applicants_after_anmeldefrist_arr = array(); - if (hasData($result)) - { - $applicants_after_anmeldefrist_arr = $result->retval; - } - elseif (isError($result)) - { - show_error(getError($result)); - } + if (hasData($result)) + { + $applicants_after_anmeldefrist_arr = $result->retval; + } + elseif (isError($result)) + { + show_error(getError($result)); + } - $studiengang = ''; - $mailReceipients = ''; // String with all mailadresses - $mailcontent_data_arr = array(); - $headerstyle = 'style="background: #DCE4EF; border: 1px solid #FFF; padding: 4px; text-align: left;"'; - $rowstyle = 'style="background-color: #EEEEEE; padding: 4px;"'; - $mailcontent = ''; - $applicants_list = ''; + $studiengang = ''; + $mailReceipients = ''; // String with all mailadresses + $mailcontent_data_arr = array(); + $headerstyle = 'style="background: #DCE4EF; border: 1px solid #FFF; padding: 4px; text-align: left;"'; + $rowstyle = 'style="background-color: #EEEEEE; padding: 4px;"'; + $mailcontent = ''; + $applicants_list = ''; if (count($applicants_after_anmeldefrist_arr) > 0) { @@ -277,11 +279,11 @@ class ReihungstestJob extends CLI_Controller '; - } + } - $studiengang = $applicant->studiengang_kz; - $mailReceipients .= $applicant->email . ';'; - $applicants_list .= ' + $studiengang = $applicant->studiengang_kz; + $mailReceipients .= $applicant->email . ';'; + $applicants_list .= ' ' . date_format(date_create($applicant->datum), 'd.m.Y') . ' ' . $applicant->uhrzeit . ' @@ -315,7 +317,7 @@ class ReihungstestJob extends CLI_Controller } /* - * Sends an email to all applicants of a placement test to remind them 3 working days before + * Sends an email to all applicants of a placement test to remind them 2 working days before * * @param integer $degreeProgram. Kennzahl of Degree Program to check * @param string $bcc. Optional. BCC-Mailadress to send the Mails to @@ -341,66 +343,66 @@ class ReihungstestJob extends CLI_Controller $from = urldecode($from); } - // Get placement tests with testdate within the next 2 weeks - $resultNextTestDates = $this->ReihungstestModel->getNextPlacementtests($degreeProgram, 14); - if (hasData($resultNextTestDates)) - { - $nextTestDates = $resultNextTestDates->retval; - $enddate = ''; - // Loop through the dates - foreach ($nextTestDates as $testDates) - { - $workingdays = 0; - $testsOndate = array(); + // Get placement tests with testdate within the next 2 weeks + $resultNextTestDates = $this->ReihungstestModel->getNextPlacementtests($degreeProgram, 14); + if (hasData($resultNextTestDates)) + { + $nextTestDates = $resultNextTestDates->retval; + $enddate = ''; + // Loop through the dates + foreach ($nextTestDates as $testDates) + { + $workingdays = 0; + $testsOndate = array(); - // Deduct days till 3 working days are reached - for ($i = 1; ; $i++) - { - if (isDateWorkingDay($testDates->datum, $i) === true) - { - $workingdays++; - } - if ($workingdays == 3) - { - $enddate = date("Y-m-d", strtotime("$testDates->datum -" . $i . " days")); - break; - } - else - { - continue; - } - } + // Deduct days till 2 working days are reached + for ($i = 1; ; $i++) + { + if (isDateWorkingDay($testDates->datum, $i) === true) + { + $workingdays++; + } + if ($workingdays == 2) + { + $enddate = date("Y-m-d", strtotime("$testDates->datum -" . $i . " days")); + break; + } + else + { + continue; + } + } - // If $enddate is today -> load all tests of $testDates->datum - if (date("Y-m-d", strtotime($enddate)) == date('Y-m-d')) - { - $resultTestsOnDate = $this->ReihungstestModel->getTestsOnDate($testDates->datum, $degreeProgram); + // If $enddate is today -> load all tests of $testDates->datum + if (date("Y-m-d", strtotime($enddate)) == date('Y-m-d')) + { + $resultTestsOnDate = $this->ReihungstestModel->getTestsOnDate($testDates->datum, $degreeProgram); - if (hasData($resultTestsOnDate)) - { - $testsOndate = $resultTestsOnDate->retval; - } - elseif (isError($resultTestsOnDate)) - { - show_error(getError($resultTestsOnDate)); - } - } + if (hasData($resultTestsOnDate)) + { + $testsOndate = $resultTestsOnDate->retval; + } + elseif (isError($resultTestsOnDate)) + { + show_error(getError($resultTestsOnDate)); + } + } - if (!isEmptyArray($testsOndate)) - { - foreach ($testsOndate as $reihungstest) - { - // Loads applicants of a test - $applicants = $this->ReihungstestModel->getApplicantsOfPlacementTest($reihungstest->reihungstest_id); + if (!isEmptyArray($testsOndate)) + { + foreach ($testsOndate as $reihungstest) + { + // Loads applicants of a test + $applicants = $this->ReihungstestModel->getApplicantsOfPlacementTest($reihungstest->reihungstest_id); - if (hasData($applicants)) - { - $applicants_arr = $applicants->retval; - } - elseif (isError($applicants)) - { - show_error(getError($applicants)); - } + if (hasData($applicants)) + { + $applicants_arr = $applicants->retval; + } + elseif (isError($applicants)) + { + show_error(getError($applicants)); + } foreach ($applicants_arr as $applicant) { @@ -420,237 +422,237 @@ class ReihungstestJob extends CLI_Controller $mailcontent_data_arr['wegbeschreibung'] = $applicant->lageplan; } - sendSanchoMail( - 'Sancho_RemindApplicantsOfTest', - $mailcontent_data_arr, - $applicant->email, - 'Ihre Anmeldung zum Reihungstest - Reminder / Your registration for the placement test - Reminder', - DEFAULT_SANCHO_HEADER_IMG, - DEFAULT_SANCHO_FOOTER_IMG, - $from, - '', - $bcc); - } - } - } - } - } - } + sendSanchoMail( + 'Sancho_RemindApplicantsOfTest', + $mailcontent_data_arr, + $applicant->email, + 'Ihre Anmeldung zum Reihungstest - Reminder / Your registration for the placement test - Reminder', + DEFAULT_SANCHO_HEADER_IMG, + DEFAULT_SANCHO_FOOTER_IMG, + $from, + '', + $bcc); + } + } + } + } + } + } - /** - * This job sends eMail(s) to the relevant stg assistance(s) informing about: - * All applicants, who have sent new applications AFTER they had absolved a - * placement test in the actual studiensemester - * AND who have been confirmed yesterday. - */ - public function mailNewApplicants() - { - // Get yesterdays confirmed applicants for Bachelor-studies - $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); - $this->PrestudentstatusModel->addSelect(' - tbl_person.person_id, - tbl_prestudentstatus.prestudent_id, - tbl_prestudent.studiengang_kz, - tbl_prestudentstatus.studiensemester_kurzbz, - tbl_prestudentstatus.bestaetigtam, - tbl_prestudentstatus.bewerbung_abgeschicktamum - '); - $this->PrestudentstatusModel->addJoin('public.tbl_prestudent', 'prestudent_id'); - $this->PrestudentstatusModel->addJoin('public.tbl_studiengang', 'studiengang_kz'); - $this->PrestudentstatusModel->addJoin('public.tbl_studiengangstyp', 'typ'); - $this->PrestudentstatusModel->addJoin('public.tbl_person', 'person_id'); + /** + * This job sends eMail(s) to the relevant stg assistance(s) informing about: + * All applicants, who have sent new applications AFTER they had absolved a + * placement test in the actual studiensemester + * AND who have been confirmed yesterday. + */ + public function mailNewApplicants() + { + // Get yesterdays confirmed applicants for Bachelor-studies + $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); + $this->PrestudentstatusModel->addSelect(' + tbl_person.person_id, + tbl_prestudentstatus.prestudent_id, + tbl_prestudent.studiengang_kz, + tbl_prestudentstatus.studiensemester_kurzbz, + tbl_prestudentstatus.bestaetigtam, + tbl_prestudentstatus.bewerbung_abgeschicktamum + '); + $this->PrestudentstatusModel->addJoin('public.tbl_prestudent', 'prestudent_id'); + $this->PrestudentstatusModel->addJoin('public.tbl_studiengang', 'studiengang_kz'); + $this->PrestudentstatusModel->addJoin('public.tbl_studiengangstyp', 'typ'); + $this->PrestudentstatusModel->addJoin('public.tbl_person', 'person_id'); - $yesterdays_applicants_arr = $this->PrestudentstatusModel->loadWhere(' - status_kurzbz = \'Interessent\' AND - typ = \'b\' AND - bestaetigtam = current_date - 1 - '); + $yesterdays_applicants_arr = $this->PrestudentstatusModel->loadWhere(' + status_kurzbz = \'Interessent\' AND + typ = \'b\' AND + bestaetigtam = current_date - 1 + '); - // Retrieve the person_ids of yesterdays confirmed applicants - $person_id_arr = array(); - if (hasData($yesterdays_applicants_arr)) - { - foreach ($yesterdays_applicants_arr->retval as $yesterdays_applicant) - { - if (isset($yesterdays_applicant->person_id)) { - $person_id_arr[] = $yesterdays_applicant->person_id; - } - } - } - elseif (isError($yesterdays_applicants_arr)) - { - show_error(getError($yesterdays_applicants_arr)); - } + // Retrieve the person_ids of yesterdays confirmed applicants + $person_id_arr = array(); + if (hasData($yesterdays_applicants_arr)) + { + foreach ($yesterdays_applicants_arr->retval as $yesterdays_applicant) + { + if (isset($yesterdays_applicant->person_id)) { + $person_id_arr[] = $yesterdays_applicant->person_id; + } + } + } + elseif (isError($yesterdays_applicants_arr)) + { + show_error(getError($yesterdays_applicants_arr)); + } - // Get all other prestudenten of the given persons. - if (!isEmptyArray($person_id_arr)) - { - $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - $this->PrestudentModel->addDistinct(); - $this->PrestudentModel->addSelect(' - person_id, - tbl_reihungstest.studiensemester_kurzbz, - tbl_reihungstest.reihungstest_id, - (SELECT(tbl_reihungstest.datum::text || \' \' || tbl_reihungstest.uhrzeit::text)::timestamp) AS reihungstest_timestamp - '); - $this->PrestudentModel->addJoin('public.tbl_studiengang', 'studiengang_kz'); - $this->PrestudentModel->addJoin('public.tbl_studiengangstyp', 'typ'); - $this->PrestudentModel->addJoin('public.tbl_prestudentstatus', 'prestudent_id'); - $this->PrestudentModel->addJoin('public.tbl_person', 'person_id'); - $this->PrestudentModel->addJoin('public.tbl_rt_person', 'person_id'); - $this->PrestudentModel->addJoin('public.tbl_reihungstest', 'tbl_reihungstest.reihungstest_id = tbl_rt_person.rt_id'); + // Get all other prestudenten of the given persons. + if (!isEmptyArray($person_id_arr)) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $this->PrestudentModel->addDistinct(); + $this->PrestudentModel->addSelect(' + person_id, + tbl_reihungstest.studiensemester_kurzbz, + tbl_reihungstest.reihungstest_id, + (SELECT(tbl_reihungstest.datum::text || \' \' || tbl_reihungstest.uhrzeit::text)::timestamp) AS reihungstest_timestamp + '); + $this->PrestudentModel->addJoin('public.tbl_studiengang', 'studiengang_kz'); + $this->PrestudentModel->addJoin('public.tbl_studiengangstyp', 'typ'); + $this->PrestudentModel->addJoin('public.tbl_prestudentstatus', 'prestudent_id'); + $this->PrestudentModel->addJoin('public.tbl_person', 'person_id'); + $this->PrestudentModel->addJoin('public.tbl_rt_person', 'person_id'); + $this->PrestudentModel->addJoin('public.tbl_reihungstest', 'tbl_reihungstest.reihungstest_id = tbl_rt_person.rt_id'); - // Store them, if they have already absolved a placement test in the same study term they have applied for. - $placement_absolvents_arr = $this->PrestudentModel->loadWhere(' - person_id IN (' . implode(', ', $person_id_arr) . ') AND - typ = \'b\' AND - teilgenommen = \'t\' AND - tbl_reihungstest.studiensemester_kurzbz IN ( - SELECT - studiensemester_kurzbz - FROM - public.tbl_studiensemester - WHERE - ende >= now() - ) - '); - } + // Store them, if they have already absolved a placement test in the same study term they have applied for. + $placement_absolvents_arr = $this->PrestudentModel->loadWhere(' + person_id IN (' . implode(', ', $person_id_arr) . ') AND + typ = \'b\' AND + teilgenommen = \'t\' AND + tbl_reihungstest.studiensemester_kurzbz IN ( + SELECT + studiensemester_kurzbz + FROM + public.tbl_studiensemester + WHERE + ende >= now() + ) + '); + } - // Store data to be send in the email-link - $result_arr = array(); - foreach($yesterdays_applicants_arr->retval as $yesterdays_applicant) - { - foreach ($placement_absolvents_arr->retval as $placement_absolvent) - { - if ($yesterdays_applicant->person_id == $placement_absolvent->person_id && - $yesterdays_applicant->studiensemester_kurzbz == $placement_absolvent->studiensemester_kurzbz && - $yesterdays_applicant->bewerbung_abgeschicktamum >= $placement_absolvent->reihungstest_timestamp) - { - $obj = new stdClass(); - $obj->prestudent_id = $yesterdays_applicant->prestudent_id; // prestudent_id of the yesterdays applicant - $obj->studiengang_kz = $yesterdays_applicant->studiengang_kz; // study program of interest of the yesterdays applicant - $obj->reihungstest_id = $placement_absolvent->reihungstest_id; // reihungstest_id of absolved reihungstest of that person + // Store data to be send in the email-link + $result_arr = array(); + foreach($yesterdays_applicants_arr->retval as $yesterdays_applicant) + { + foreach ($placement_absolvents_arr->retval as $placement_absolvent) + { + if ($yesterdays_applicant->person_id == $placement_absolvent->person_id && + $yesterdays_applicant->studiensemester_kurzbz == $placement_absolvent->studiensemester_kurzbz && + $yesterdays_applicant->bewerbung_abgeschicktamum >= $placement_absolvent->reihungstest_timestamp) + { + $obj = new stdClass(); + $obj->prestudent_id = $yesterdays_applicant->prestudent_id; // prestudent_id of the yesterdays applicant + $obj->studiengang_kz = $yesterdays_applicant->studiengang_kz; // study program of interest of the yesterdays applicant + $obj->reihungstest_id = $placement_absolvent->reihungstest_id; // reihungstest_id of absolved reihungstest of that person - $result_arr[]= $obj; - } - } - } + $result_arr[]= $obj; + } + } + } - // Sort by STG. This is important to send the mails clustered by STG to the different STG assistances. - usort($result_arr, function ($a, $b) - { - if ($a->studiengang_kz == $b->studiengang_kz) { - return 0; - } - return ($a->studiengang_kz < $b->studiengang_kz) ? -1 : 1; - }); + // Sort by STG. This is important to send the mails clustered by STG to the different STG assistances. + usort($result_arr, function ($a, $b) + { + if ($a->studiengang_kz == $b->studiengang_kz) { + return 0; + } + return ($a->studiengang_kz < $b->studiengang_kz) ? -1 : 1; + }); - $to = ''; // mail recipient (stg assistance) - $content_arr = array(); // url paths to the new applicants - $base_link = base_url('vilesci/stammdaten/auswertung_fhtw.php'); + $to = ''; // mail recipient (stg assistance) + $content_arr = array(); // url paths to the new applicants + $base_link = base_url('vilesci/stammdaten/auswertung_fhtw.php'); - $i = 0; // loop counter - $len = count($result_arr); + $i = 0; // loop counter + $len = count($result_arr); - // Loop trough list of new applicants - foreach($result_arr as $result) - { - $studiengang = $this->StudiengangModel->load($result->studiengang_kz); - $mail_stg_assistance = $studiengang->retval[0]->email; + // Loop trough list of new applicants + foreach($result_arr as $result) + { + $studiengang = $this->StudiengangModel->load($result->studiengang_kz); + $mail_stg_assistance = $studiengang->retval[0]->email; - // If first loop - if ($i == 0) - { - $to = $mail_stg_assistance; // set recipient initially - } + // If first loop + if ($i == 0) + { + $to = $mail_stg_assistance; // set recipient initially + } - // If new study is encountered but is not the first loop - if ($to != $mail_stg_assistance && $i != 0) - { - // Prepare content for mail template - $content_data_arr = $this->_getContentDataNewApplicant($content_arr); + // If new study is encountered but is not the first loop + if ($to != $mail_stg_assistance && $i != 0) + { + // Prepare content for mail template + $content_data_arr = $this->_getContentDataNewApplicant($content_arr); - // Send mail - sendSanchoMail( - 'BewerberNachReihungstest', - $content_data_arr, - $to, - 'Neue Bewerbungen nach absolviertem Reihungstest', - 'sancho_header_min_bw.jpg', - 'sancho_footer_min_bw.jpg' - ); + // Send mail + sendSanchoMail( + 'BewerberNachReihungstest', + $content_data_arr, + $to, + 'Neue Bewerbungen nach absolviertem Reihungstest', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg' + ); - // Reset content for new study applicants & reset recipient (new stg assistance) - $content_arr = array($base_link. '?reihungstest='. $result->reihungstest_id. '&prestudent_id='. $result->prestudent_id); - $to = $mail_stg_assistance; - } - // If same study - else - { - // just add content - $content_arr[]= $base_link. '?reihungstest='. $result->reihungstest_id. '&prestudent_id='. $result->prestudent_id; // add to content - } + // Reset content for new study applicants & reset recipient (new stg assistance) + $content_arr = array($base_link. '?reihungstest='. $result->reihungstest_id. '&prestudent_id='. $result->prestudent_id); + $to = $mail_stg_assistance; + } + // If same study + else + { + // just add content + $content_arr[]= $base_link. '?reihungstest='. $result->reihungstest_id. '&prestudent_id='. $result->prestudent_id; // add to content + } - // If last loop - if (($i == $len - 1)) - { - // Prepare content for mail template - $content_data_arr = $this->_getContentDataNewApplicant($content_arr); + // If last loop + if (($i == $len - 1)) + { + // Prepare content for mail template + $content_data_arr = $this->_getContentDataNewApplicant($content_arr); - // Send mail - sendSanchoMail( - 'BewerberNachReihungstest', - $content_data_arr, - $to, - 'Neue Bewerbungen nach absolviertem Reihungstest', - 'sancho_header_min_bw.jpg', - 'sancho_footer_min_bw.jpg' - ); - } - $i++; // iterate counter - } - } + // Send mail + sendSanchoMail( + 'BewerberNachReihungstest', + $content_data_arr, + $to, + 'Neue Bewerbungen nach absolviertem Reihungstest', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg' + ); + } + $i++; // iterate counter + } + } - // ------------------------------------------------------------------------ - // Private methods - /** - * Returns associative array with data as needed in the reihungstest job template. - * @param array $missing_rt_arr Array with studienpläne, which have no assigned placement tests. - * @param array $free_places_arr Array with info and amount of free placement test places. - * @return array - */ - private function _getContentData($missing_rt_arr, $free_places_arr) - { - $style_tbl1 = ' cellpadding="0" cellspacing="10" width="100%" style="font-family: courier, verdana, sans-serif; font-size: 0.95em; border: 1px solid #000000;" '; - $style_tbl2 = ' cellpadding="0" cellspacing="20" width="100%" style="font-family: courier, verdana, sans-serif; font-size: 0.95em; border: 1px solid #000000;" '; + // ------------------------------------------------------------------------ + // Private methods + /** + * Returns associative array with data as needed in the reihungstest job template. + * @param array $missing_rt_arr Array with studienpläne, which have no assigned placement tests. + * @param array $free_places_arr Array with info and amount of free placement test places. + * @return array + */ + private function _getContentData($missing_rt_arr, $free_places_arr) + { + $style_tbl1 = ' cellpadding="0" cellspacing="10" width="100%" style="font-family: courier, verdana, sans-serif; font-size: 0.95em; border: 1px solid #000000;" '; + $style_tbl2 = ' cellpadding="0" cellspacing="20" width="100%" style="font-family: courier, verdana, sans-serif; font-size: 0.95em; border: 1px solid #000000;" '; - // Prepare HTML table with study plans that have no placement tests yet - if (!empty($missing_rt_arr)) { - $studienplan_list - = ' + // Prepare HTML table with study plans that have no placement tests yet + if (!empty($missing_rt_arr)) { + $studienplan_list + = ' '; - foreach ($missing_rt_arr as $rt) { - $studienplan_list .= ' + foreach ($missing_rt_arr as $rt) { + $studienplan_list .= ' ' . $rt->bezeichnung . ' '; - } + } - $studienplan_list .= ' + $studienplan_list .= ' '; - } else { - $studienplan_list = ' + } else { + $studienplan_list = ' Alles okay! Alle Studienpläne haben zumindest einen Reihungstest. '; - } + } - // Prepare HTML table with information and amount of free places - if (!empty($free_places_arr)) { - $freie_plaetze_list = ' + // Prepare HTML table with information and amount of free places + if (!empty($free_places_arr)) { + $freie_plaetze_list = ' Fakultät @@ -659,67 +661,67 @@ class ReihungstestJob extends CLI_Controller '; - foreach ($free_places_arr as $free_place) { - $datum = new DateTime($free_place->datum); - $style_alarm = ($free_place->freie_plaetze <= 5) ? ' style=" color: red; font-weight: bold" ' : ''; // mark if <=5 free places + foreach ($free_places_arr as $free_place) { + $datum = new DateTime($free_place->datum); + $style_alarm = ($free_place->freie_plaetze <= 5) ? ' style=" color: red; font-weight: bold" ' : ''; // mark if <=5 free places - $freie_plaetze_list .= ' + $freie_plaetze_list .= ' ' . $free_place->fakultaet . ' ' . $datum->format('d.m.Y') . ' ' . $free_place->freie_plaetze . ' '; - } + } - $freie_plaetze_list .= ' + $freie_plaetze_list .= ' '; - } else { - $freie_plaetze_list = ' + } else { + $freie_plaetze_list = ' Es gibt heute keine Ergebnisse zu freien Reihungstestplätze. '; - } + } - // Set associative array with the prepared HTML tables and URL be used by the template's variables - $content_data_arr['studienplan_list'] = $studienplan_list; - $content_data_arr['freie_plaetze_list'] = $freie_plaetze_list; - $content_data_arr['link'] = site_url('/organisation/Reihungstest'); + // Set associative array with the prepared HTML tables and URL be used by the template's variables + $content_data_arr['studienplan_list'] = $studienplan_list; + $content_data_arr['freie_plaetze_list'] = $freie_plaetze_list; + $content_data_arr['link'] = site_url('/organisation/Reihungstest'); - return $content_data_arr; - } + return $content_data_arr; + } - /** - * Returns associative array with data as needed in the BewerberNachReihungstest-template. - * @param array $content_arr Array with links to the testtool evaluation page of the new applicants. - * @return array - */ - private function _getContentDataNewApplicant($content_arr) - { - $content = ''; - $counter = 1; - foreach ($content_arr as $row) - { - $content .= '
Link zu: Bewerber '. $counter. ''; - $counter++; - } + /** + * Returns associative array with data as needed in the BewerberNachReihungstest-template. + * @param array $content_arr Array with links to the testtool evaluation page of the new applicants. + * @return array + */ + private function _getContentDataNewApplicant($content_arr) + { + $content = ''; + $counter = 1; + foreach ($content_arr as $row) + { + $content .= '
Link zu:
Bewerber '. $counter. ''; + $counter++; + } - $content_data_arr['link'] = $content; - return $content_data_arr; - } + $content_data_arr['link'] = $content; + return $content_data_arr; + } - /** - * Checks the upcoming placement tests if there are correct studyplans assigned - * If there are invalid studyplans assigned (outdated because there exists a new version), - * it tries to find a better one and assigns it additionaly - */ - public function correctStudienplan() - { - // get all placement tests with incorrect studyplan - $qry = " + /** + * Checks the upcoming placement tests if there are correct studyplans assigned + * If there are invalid studyplans assigned (outdated because there exists a new version), + * it tries to find a better one and assigns it additionaly + */ + public function correctStudienplan() + { + // get all placement tests with incorrect studyplan + $qry = " SELECT tbl_reihungstest.reihungstest_id, tbl_studienplan.studienplan_id, @@ -752,37 +754,279 @@ class ReihungstestJob extends CLI_Controller ) "; - $db = new DB_Model(); - $result_rt = $db->execReadOnlyQuery($qry); + $db = new DB_Model(); + $result_rt = $db->execReadOnlyQuery($qry); - if (hasdata($result_rt)) { - foreach ($result_rt->retval as $row_rt) { - // find an active studyplan for the same degree program with is valid in this semester - $result_stpl = $this->StudienplanModel->getStudienplaeneBySemester( - $row_rt->studiengang_kz, - $row_rt->studiensemester_kurzbz - ); + if (hasdata($result_rt)) { + foreach ($result_rt->retval as $row_rt) { + // find an active studyplan for the same degree program with is valid in this semester + $result_stpl = $this->StudienplanModel->getStudienplaeneBySemester( + $row_rt->studiengang_kz, + $row_rt->studiensemester_kurzbz + ); - if (hasData($result_stpl)) { - foreach ($result_stpl->retval as $row_stpl) { - // Add new Studyplan to RtStudienplan if missing - $rt_studienplan = $this->RtStudienplanModel->loadWhere(array( - "reihungstest_id" => $row_rt->reihungstest_id, - "studienplan_id" => $row_stpl->studienplan_id - )); + if (hasData($result_stpl)) { + foreach ($result_stpl->retval as $row_stpl) { + // Add new Studyplan to RtStudienplan if missing + $rt_studienplan = $this->RtStudienplanModel->loadWhere(array( + "reihungstest_id" => $row_rt->reihungstest_id, + "studienplan_id" => $row_stpl->studienplan_id + )); - if (!hasData($rt_studienplan)) { - echo "\nAdding StudienplanId: $row_stpl->studienplan_id"; - echo " to ReihungstestId: $row_rt->reihungstest_id"; + if (!hasData($rt_studienplan)) { + echo "\nAdding StudienplanId: $row_stpl->studienplan_id"; + echo " to ReihungstestId: $row_rt->reihungstest_id"; - $this->RtStudienplanModel->insert(array( - "reihungstest_id" => $row_rt->reihungstest_id, - "studienplan_id" => $row_stpl->studienplan_id - )); - } - } - } - } - } - } + $this->RtStudienplanModel->insert(array( + "reihungstest_id" => $row_rt->reihungstest_id, + "studienplan_id" => $row_stpl->studienplan_id + )); + } + } + } + } + } + } + + /* + * Cronjob for priorisation process of FHTW + * + * Wenn ein Student in einer höheren Prio aufgenommen wird, werden die anderen Bewerbungen auf "Abgewiesen" gesetzt, + * solang diese noch im Status "Bewerber" sind. + * Andernfalls wird eine Mail an die niedrigeren Prios verschickt, dass eine höhere Prio aufgenommen hat + * Die Kaution wird automatisch gebucht + * + * @param string $bcc. Optional. BCC-Mailadress to send the Mails to + * @param string $from. Optional. Sender-Mailadress shown to recipient + */ + public function prioritizationJob($bcc = null, $from = null) + { + $qry = " + SELECT DISTINCT + get_rolle_prestudent (tbl_prestudent.prestudent_id, 'WS2020') AS laststatus, /* Studiensemester dynamisch ermitteln oder als Parameter */ + tbl_prestudentstatus.studiensemester_kurzbz, + tbl_prestudent.* + FROM PUBLIC.tbl_person + JOIN PUBLIC.tbl_prestudent USING (person_id) + JOIN PUBLIC.tbl_prestudentstatus USING (prestudent_id) + JOIN lehre.tbl_studienplan USING (studienplan_id) + JOIN lehre.tbl_studienordnung USING (studienordnung_id) + JOIN PUBLIC.tbl_studiengang ON (tbl_studienordnung.studiengang_kz = tbl_studiengang.studiengang_kz) + WHERE tbl_prestudentstatus.datum >= (SELECT CURRENT_DATE -1) + AND get_rolle_prestudent (tbl_prestudent.prestudent_id, 'WS2020') IN ('Aufgenommener','Bewerber','Wartender') + AND studiensemester_kurzbz = 'WS2020' /* Studiensemester dynamisch ermitteln oder als Parameter */ + AND tbl_studiengang.typ = 'b' + ORDER BY studiengang_kz, laststatus + "; + + // Encode Params + if ($bcc != '') + { + // $bcc can be given as null-string, so check that too + if ($bcc == 'null') + { + $bcc = ''; + } + else + { + $bcc = urldecode($bcc); + } + } + if ($from != '') + { + $from = urldecode($from); + } + + $db = new DB_Model(); + $result_prestudents = $db->execReadOnlyQuery($qry); + $mailArray = array(); + + if (hasdata($result_prestudents)) + { + foreach ($result_prestudents->retval as $row_ps) + { + // Wenn der letzte Status "Aufgenommener" ist, alle niedrigeren Prios auf "Abgewiesen" setzen + // falls diese Bewerber oder Warteliste sind + // Danach Kaution einbuchen + if ($row_ps->laststatus == 'Aufgenommener') + { + // Alle niedrigeren Prios laden + $qryNiedrPrios = " + SELECT DISTINCT + get_rolle_prestudent (tbl_prestudent.prestudent_id, '".$row_ps->studiensemester_kurzbz."') AS laststatus, + tbl_studienplan.orgform_kurzbz, + tbl_person.nachname, + tbl_person.vorname, + tbl_prestudent.* + FROM PUBLIC.tbl_person + JOIN PUBLIC.tbl_prestudent USING (person_id) + JOIN PUBLIC.tbl_prestudentstatus USING (prestudent_id) + JOIN lehre.tbl_studienplan USING (studienplan_id) + JOIN PUBLIC.tbl_studiengang ON (tbl_prestudent.studiengang_kz = tbl_studiengang.studiengang_kz) + WHERE tbl_prestudent.person_id = ".$row_ps->person_id." + AND tbl_prestudent.prestudent_id != ".$row_ps->prestudent_id." + AND get_rolle_prestudent (tbl_prestudent.prestudent_id, '".$row_ps->studiensemester_kurzbz."') IN ('Aufgenommener','Bewerber','Wartender') + AND studiensemester_kurzbz = '".$row_ps->studiensemester_kurzbz."' + AND tbl_studiengang.typ = 'b' + AND priorisierung > ".$row_ps->priorisierung." + ORDER BY studiengang_kz, laststatus + "; + + $resultNiedrPrios = $db->execReadOnlyQuery($qryNiedrPrios); + + if (hasdata($resultNiedrPrios)) + { + foreach ($resultNiedrPrios->retval as $rowNiedrPrios) + { + if ($rowNiedrPrios->laststatus == 'Bewerber') + { + // Abgewiesenen-Status mit Statusgrund "Aufnahme anderer Studiengang" (ID 5) setzen + $lastStatus = $this->PrestudentstatusModel->getLastStatus($rowNiedrPrios->prestudent_id); + + $result = $this->PrestudentstatusModel->insert( + array( + 'prestudent_id' => $rowNiedrPrios->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' => 5, + 'insertvon' => 'prioritizationJob', + 'insertamum' => date('Y-m-d H:i:s') + ) + ); + if (isSuccess($result)) + { + $mailArray[$rowNiedrPrios->studiengang_kz][$rowNiedrPrios->orgform_kurzbz]['AbgewiesenGesetzt'][] + = $rowNiedrPrios->nachname.' '.$rowNiedrPrios->vorname.' ('.$rowNiedrPrios->prestudent_id.')'; + } + } + elseif ($rowNiedrPrios->laststatus == 'Wartender') + { + // Abgewiesenen-Status mit Statusgrund "Aufnahme anderer Studiengang" (ID 5) setzen + // Mail zur Info an Assistenz schicken + $lastStatus = $this->PrestudentstatusModel->getLastStatus($rowNiedrPrios->prestudent_id); + + $result = $this->PrestudentstatusModel->insert( + array( + 'prestudent_id' => $rowNiedrPrios->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' => 5, + 'insertvon' => 'prioritizationJob', + 'insertamum' => date('Y-m-d H:i:s') + ) + ); + if (isSuccess($result)) + { + $mailArray[$rowNiedrPrios->studiengang_kz][$rowNiedrPrios->orgform_kurzbz]['AbgewiesenGesetzt'][] + = $rowNiedrPrios->nachname.' '.$rowNiedrPrios->vorname.' ('.$rowNiedrPrios->prestudent_id.')'; + } + } + elseif ($rowNiedrPrios->laststatus == 'Aufgenommener') + { + // Mail zur Info an Assistenz schicken, dass in höherer Prio aufgenommen wurde + $mailArray[$rowNiedrPrios->studiengang_kz][$rowNiedrPrios->orgform_kurzbz]['AufnahmeHoeherePrio'][] + = $rowNiedrPrios->nachname.' '.$rowNiedrPrios->vorname.' ('.$rowNiedrPrios->prestudent_id.')'; + } + } + } + echo '
', var_dump($mailArray), '
'; + // Kaution einbuchen für $row_ps->prestudent_id + // Vorher prüfen, ob schon eine Kaution gebucht ist + // Todo: Betrag automatisch aus tbl_buchungstyp laden + + $qryKautionExists = " + SELECT count(*) as anzahl + FROM public.tbl_konto + WHERE person_id = ".$row_ps->person_id." + AND studiensemester_kurzbz = '".$row_ps->studiensemester_kurzbz."' + AND buchungstyp_kurzbz = 'Kaution'"; + + $resultKautionExists = $db->execReadOnlyQuery($qryKautionExists); + if (hasdata($resultKautionExists)) + { + if ($resultKautionExists->retval[0]->anzahl == '0') + { + // Todo: Zahlungsreferenz generieren (StudiengangsOE+Buchungsnummer) + $this->KontoModel->insert(array( + "person_id" => $row_ps->person_id, + "studiengang_kz" => $row_ps->studiengang_kz, + "studiensemester_kurzbz" => $row_ps->studiensemester_kurzbz, + "betrag" => -150, + "buchungsdatum" => date('Y-m-d'), + "buchungstext" => 'Kaution', + "buchungstyp_kurzbz" => 'Kaution', + "insertvon" => 'prioritizationJob', + "insertamum" => date('Y-m-d H:i:s') + )); + } + } + } + } + } + // Mails senden + if (!isEmptyArray($mailArray)) + { + foreach ($mailArray AS $stg=>$orgform) + { + $studiengang = $this->StudiengangModel->load($stg); + + $mailcontent = '

+ Folgende BewerberInnen wurden in einem höher priorisierten Studiengang aufgenommen und haben deshalb einen Status "Abgewiesen" erhalten:

'; + + foreach ($orgform AS $art=>$value) + { + $mailcontent .= '

Orgform '.$art.'

'; + if (isset($value['AbgewiesenGesetzt']) && !isEmptyArray($value['AbgewiesenGesetzt'])) + { + $mailcontent .= ' + + '; + sort($value['AbgewiesenGesetzt']); + foreach ($value['AbgewiesenGesetzt'] AS $key=>$bewerber) + { + $mailcontent .= ''; + } + $mailcontent .= '
Zuvor Warteliste
'.$bewerber.'


'; + } + if (isset($value['AufnahmeHoeherePrio']) && !isEmptyArray($value['AufnahmeHoeherePrio'])) + { + $mailcontent .= ' + + '; + sort($value['AufnahmeHoeherePrio']); + foreach ($value['AufnahmeHoeherePrio'] AS $key=>$bewerber) + { + $mailcontent .= ''; + } + $mailcontent .= '
Zuvor BewerberIn
'.$bewerber.'
'; + } + } + + $mailcontent_data_arr['table'] = $mailcontent; + + // Send email in Sancho design + if (!isEmptyString($mailcontent)) + { + sendSanchoMail( + 'Sancho_ReihungstestteilnehmerJob', + $mailcontent_data_arr, + $studiengang->retval[0]->email, + 'Status Abgewiesen gesetzt', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg', + $from, + '', + $bcc); + } + } + } + } } From 304d7727f000fc30a051b4d4235f21df7764e6d0 Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 21 Feb 2020 16:59:25 +0100 Subject: [PATCH 081/138] - CL/Messages_model-> sendReply applied workaround for Infocenter - MailJob now extends JOB_Controller and writes logs in DB - MailJob->sendMessages renamed to sendAllMessageEmailNotices - sendAllMessageEmailNotices now accept new parameter since to restrict number of messages - MessageLib->sendAllEmailNotices now accept new parameter since and adapted to use new MessageLib->_sendNoticeEmails - Recipient_model->getMessages renamed to getNotSentMessages - Now accepts only limit and since as parameters - Changed query to retrieve only message ids --- application/controllers/jobs/MailJob.php | 42 ++++++----- application/libraries/MessageLib.php | 26 ++++--- application/models/CL/Messages_model.php | 3 +- application/models/system/Recipient_model.php | 69 ++++--------------- 4 files changed, 55 insertions(+), 85 deletions(-) diff --git a/application/controllers/jobs/MailJob.php b/application/controllers/jobs/MailJob.php index 721db0068..b4b772f78 100644 --- a/application/controllers/jobs/MailJob.php +++ b/application/controllers/jobs/MailJob.php @@ -1,20 +1,8 @@ messagelib->sendAllNotices($numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem); + $this->logInfo('Send all message email notices started'); + + // Send them all! + $sendAllEmailNotices = $this->messagelib->sendAllEmailNotices($since, $numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem); + if (isError($sendAllEmailNotices)) + { + $optionalParameters = new stdClass(); + $optionalParameters->$since = $since; + $optionalParameters->$numberToSent = $numberToSent; + $optionalParameters->$numberPerTimeRange = $numberPerTimeRange; + $optionalParameters->$emailTimeRange = $emailTimeRange; + $optionalParameters->$emailFromSystem = $emailFromSystem; + + $this->logError($sendAllEmailNotices->retval, $optionalParameters); + } + elseif (!hasData($sendAllEmailNotices)) + { + $this->logInfo('There were no unsent messages'); + } + + $this->logInfo('Send all message email notices ended'); } } diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 3a8f133cf..cfd450f98 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -139,27 +139,31 @@ class MessageLib // Public methods called by a job /** - * Gets all NOT sent messages from DB and sends for each of them the notice email - * Does not return anything, it logs info and errors on CI logs and in tbl_msg_recipient table + * Gets all messages for which notice emails are still not sent from DB and sends for each of them the notice email * Wrapper for _sendNoticeEmail. */ - public function sendAllEmailNotices($numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem) + public function sendAllEmailNotices($since, $numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem) { // Overrides MailLib configs with the given parameters $this->_ci->maillib->overrideConfigs($numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem); - // Retrieves a certain amount of NOT sent messages, the amount is given by maillib->email_number_to_sent - $messagesResult = $this->_ci->RecipientModel->getMessages( - self::EMAIL_KONTAKT_TYPE, - null, - $this->_ci->maillib->getEmailNumberToSent() + // Retrieves a certain amount of NOT sent messages + $messagesResult = $this->_ci->RecipientModel->getNotSentMessages( + $this->_ci->maillib->getEmailNumberToSent(), + $since ); - if (isError($messagesResult)) terminateWithError(getData($messagesResult)); // If an error occurred then log it and terminate + if (isError($messagesResult) || !hasData($messagesResult)) return $messagesResult; - $sendNotice = $this->_sendNoticeEmails(getData($messagesResult)); + // Collects all the message ids in an array + $messageIds = array(); + foreach (getData($messagesResult) as $message) + { + $messageIds[] = $message->message_id; + } - if (isError($sendNotice)) terminateWithError(getData($sendNotice)); // If an error occurred then log it and terminate + // Send'em all + return $this->_sendNoticeEmails($messageIds); } //------------------------------------------------------------------------------------------------------------------ diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index de6ec5a10..9cc4a76da 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -509,7 +509,8 @@ class Messages_model extends CI_Model if (!hasData($message)) return error('No messages were saved in database'); // Write log entry - $personLog = $this->_personLog($sender_id, $receiver_id, getData($message)[0]); + // NOTE: $receiver_id and $sender_id are switched!!! Currently this is a workaround + $personLog = $this->_personLog($receiver_id, $sender_id, getData($message)[0]); if (isError($personLog)) return $personLog; return success('Messages sent successfully'); diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index cea11a7a7..ad1c1e850 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -199,66 +199,23 @@ class Recipient_model extends DB_Model } /** - * getMessages + * Gets all messages for which notice emails are still not sent * - * Gets all the messages to be sent - * - * @param kontaktType specifies the type of the kontakt to get - * @param sent specifies the status of the messages to get (NULL never sent, otherwise the shipping date) - * @param limit specifies the number of messages to get - * @param message_id specifies a single message + * @param kontaktType specifies the type of the kontakt to get (email,...) + * @param limit specifies the max number of messages to get + * @param since specifies from which date messages have to be retrieved */ - public function getMessages($kontaktType, $message_id = null, $limit = 1) + public function getNotSentMessages($limit, $since = '1970-01-01') { - $query = 'SELECT mm.message_id, - ks.kontakt as sender, - kr.kontakt as receiver, - mu.mitarbeiter_uid as employeeContact, - ms.mitarbeiter_uid as senderemployeeContact, - mr.person_id as receiver_id, - mr.token, - mm.subject, - mm.body, - mr.sentinfo, - mr.oe_kurzbz - FROM public.tbl_msg_recipient mr INNER JOIN public.tbl_msg_message mm USING (message_id) - LEFT JOIN ( - SELECT person_id, kontakt FROM public.tbl_kontakt WHERE zustellung = true AND kontakttyp = ? - ) ks ON (ks.person_id = mm.person_id) - LEFT JOIN ( - SELECT person_id, kontakt FROM public.tbl_kontakt WHERE zustellung = true AND kontakttyp = ? - ) kr ON (kr.person_id = mr.person_id) - LEFT JOIN ( - SELECT b.person_id, - m.mitarbeiter_uid - FROM public.tbl_benutzer b INNER JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) - WHERE b.aktiv = TRUE - ) mu ON (mu.person_id = mr.person_id) - LEFT JOIN ( - SELECT b.person_id, - m.mitarbeiter_uid - FROM public.tbl_benutzer b INNER JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) - WHERE b.aktiv = TRUE - ) ms ON (ms.person_id = mm.person_id) - WHERE mr.sent IS NULL'; + $query = 'SELECT mm.message_id + FROM public.tbl_msg_recipient mr + JOIN public.tbl_msg_message mm USING (message_id) + WHERE mr.sent IS NULL + AND mm.insertamum > ? + ORDER BY mr.insertamum ASC + LIMIT ?'; - $parametersArray = array($kontaktType, $kontaktType); - - if (is_numeric($message_id)) - { - array_push($parametersArray, $message_id); - $query .= ' AND mm.message_id = ?'; - } - - $query .= ' ORDER BY mr.insertamum ASC'; - - if (is_numeric($limit)) - { - $query .= ' LIMIT ?'; - array_push($parametersArray, $limit); - } - - return $this->execQuery($query, $parametersArray); + return $this->execQuery($query, array($since, $limit)); } /** From 0addc4ffb59108aa384e4791c19d1e668c67721f Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 21 Feb 2020 17:22:50 +0100 Subject: [PATCH 082/138] gebiet.class.php: improved offset calculation, LIMIT maxfragen instead multiplication --- include/gebiet.class.php | 138 +++++++++++++++++++++++---------------- 1 file changed, 82 insertions(+), 56 deletions(-) diff --git a/include/gebiet.class.php b/include/gebiet.class.php index 7f622c299..a4df72338 100644 --- a/include/gebiet.class.php +++ b/include/gebiet.class.php @@ -677,13 +677,13 @@ class gebiet extends basis_db $qry = " WITH fragen AS ( - SELECT tbl_frage.frage_id, tbl_frage.gebiet_id, tbl_frage.level, punkte - FROM testtool.tbl_frage - JOIN testtool.tbl_vorschlag USING (frage_id) - WHERE tbl_vorschlag.aktiv - AND tbl_vorschlag.punkte < 0 - AND tbl_frage.demo = false - AND tbl_frage.aktiv + SELECT tbl_frage.frage_id, tbl_frage.gebiet_id, tbl_frage.level, tbl_frage.nummer, punkte + FROM testtool.tbl_frage + JOIN testtool.tbl_vorschlag USING (frage_id) + WHERE tbl_vorschlag.aktiv + AND tbl_vorschlag.punkte < 0 + AND tbl_frage.demo = false + AND tbl_frage.aktiv ), fragenanzahl AS ( SELECT gebiet_id, level, levelgleichverteilung, @@ -712,57 +712,83 @@ class gebiet extends basis_db tbl_gebiet.level_start, ( CASE WHEN tbl_gebiet.levelgleichverteilung THEN - (CASE WHEN tbl_gebiet.multipleresponse=false THEN - (SELECT sum(frprolevel) FROM - ( - SELECT fragen.level, (min(punkte) - * (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = fragen.gebiet_id and fragenanzahl.level = fragen.level LIMIT 1)) AS frprolevel - FROM fragen - WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id - GROUP BY fragen.gebiet_id, level - ) pkteprolevel) - ELSE - (SELECT sum(frprolevel) FROM - ( - SELECT fragen.level, (sum(punkte) - * (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = fragen.gebiet_id and fragenanzahl.level = fragen.level LIMIT 1)) AS frprolevel - FROM fragen - WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id - AND frage_id = (SELECT min(frage_id) FROM fragen fr WHERE fr.gebiet_id = fragen.gebiet_id AND fr.level = fragen.level) - GROUP BY fragen.gebiet_id, level - ) pkteprolevel) - END) + (CASE WHEN tbl_gebiet.multipleresponse=false THEN + (SELECT sum(frprolevel) FROM + ( + SELECT fragen.level, (SELECT sum(punkte) FROM (SELECT min(punkte) AS punkte FROM fragen lvlfr WHERE lvlfr.gebiet_id = fragen.gebiet_id and lvlfr.level = fragen.level + GROUP BY lvlfr.frage_id, lvlfr.nummer + ORDER BY lvlfr.nummer + LIMIT (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = fragen.gebiet_id and fragenanzahl.level = fragen.level LIMIT 1)) fr) + AS frprolevel + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + GROUP BY fragen.gebiet_id, level + ) pkteprolevel) + ELSE + (SELECT sum(frprolevel) FROM + ( + SELECT fragen.level, + (SELECT sum(punkte) FROM (SELECT sum(punkte) AS punkte FROM fragen lvlfr WHERE lvlfr.gebiet_id = fragen.gebiet_id and lvlfr.level = fragen.level + GROUP by lvlfr.frage_id, lvlfr.nummer + ORDER BY lvlfr.nummer + LIMIT (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = fragen.gebiet_id and fragenanzahl.level = fragen.level LIMIT 1)) fr) + AS frprolevel + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + GROUP BY fragen.gebiet_id, level + ) pkteprolevel) + END) WHEN tbl_gebiet.level_start IS NOT NULL THEN - (CASE WHEN tbl_gebiet.multipleresponse=false THEN - ( - SELECT min(punkte) - FROM fragen - WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + (CASE WHEN tbl_gebiet.multipleresponse=false THEN + (SELECT sum(pkte) + FROM ( + SELECT min(punkte) AS pkte + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id AND fragen.level = tbl_gebiet.level_start - ) * (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) - ELSE - (SELECT sum(punkte) - FROM fragen - WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id - AND frage_id = (SELECT min(frage_id) FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id) - AND fragen.level = tbl_gebiet.level_start - )* (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) - END) + GROUP BY frage_id, nummer + ORDER BY nummer + LIMIT (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) + ) minpkte + ) + ELSE + ( + SELECT sum(pkte) + FROM (SELECT sum(punkte) AS pkte + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + AND fragen.level = tbl_gebiet.level_start + GROUP BY frage_id, nummer + ORDER BY nummer + LIMIT (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) + ) sumpkte + ) + END) ELSE - (CASE WHEN tbl_gebiet.multipleresponse=false THEN - ( - SELECT min(punkte) - FROM fragen - WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id - ) * (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) - ELSE - (SELECT sum(punkte) - FROM fragen - WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id - AND frage_id = (SELECT min(frage_id) FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id) - )* (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) - END) - + (CASE WHEN tbl_gebiet.multipleresponse=false THEN + ( + SELECT sum(pkte) + FROM (SELECT min(punkte) AS pkte + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + GROUP BY frage_id, nummer + ORDER BY nummer + LIMIT (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) + ) minpkte + ) + ELSE + ( + SELECT sum(pkte) + FROM (SELECT sum(punkte) AS pkte + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + GROUP BY frage_id, nummer + ORDER BY nummer + LIMIT (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) + ) sumpkte + ) + END) + END) * (-1) AS offsetpunkte FROM testtool.tbl_gebiet @@ -770,7 +796,7 @@ class gebiet extends basis_db EXISTS( SELECT 1 FROM fragen WHERE fragen.gebiet_id=tbl_gebiet.gebiet_id ) - AND gebiet_id = ".$this->db_add_param($gebiet_id, FHC_INTEGER)." + AND gebiet_id = ".$this->db_add_param($gebiet_id, FHC_INTEGER)." "; if($this->db_query($qry)) From b8b36e975e8baa57b4362faab684217fd3646bbf Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Sun, 23 Feb 2020 18:18:14 +0100 Subject: [PATCH 083/138] Orgform_kurzbz in bankverbindung.class und zahlungen_details.php --- cis/private/profile/zahlungen_details.php | 93 ++++++++++++++--------- include/bankverbindung.class.php | 49 +++++++----- 2 files changed, 88 insertions(+), 54 deletions(-) diff --git a/cis/private/profile/zahlungen_details.php b/cis/private/profile/zahlungen_details.php index a6d35cc72..650ee81c0 100644 --- a/cis/private/profile/zahlungen_details.php +++ b/cis/private/profile/zahlungen_details.php @@ -26,6 +26,8 @@ require_once('../../../include/organisationseinheit.class.php'); require_once('../../../include/addon.class.php'); require_once('../../../include/benutzer.class.php'); require_once('../../../include/benutzerberechtigung.class.php'); +require_once('../../../include/student.class.php'); +require_once('../../../include/prestudent.class.php'); $uid = get_uid(); @@ -66,7 +68,19 @@ $studiengang=new studiengang(); $studiengang->load($konto->studiengang_kz); $bankverbindung=new bankverbindung(); -$kontodaten = getBankverbindung($studiengang->oe_kurzbz); +// Wenn Person StudentIn ist, auch die OrgForm laden um die richtige Kontonummer anzeigen zu können +$student = new student(); +$orgform = ''; +if ($student->load($uid)) +{ + $laststatus = new prestudent(); + if ($laststatus->getLastStatus($student->prestudent_id)) + { + $orgform = $laststatus->orgform_kurzbz; + } +} + +$kontodaten = getBankverbindung($studiengang->oe_kurzbz, $orgform); $iban=$kontodaten["iban"]; $bic=$kontodaten["bic"]; @@ -156,56 +170,63 @@ $addon = new addon(); $addon->loadAddons(); foreach($addon->result as $a) { - if($a->kurzbz === "eps") - { + if($a->kurzbz === "eps") + { echo ' - + - - + + - - + + - - + + - +
Zahlung anweisenZahlung anweisen
EPS - EPS Überweisung - EPS + EPS Überweisung +
'; - } - + } + } echo ''; -function getBankverbindung($oe_kurzbz) +function getBankverbindung($oe_kurzbz, $orgform_kurzbz = null) { - $iban = ""; - $bic = ""; - $result = array(); - $bankverbindung=new bankverbindung(); - if($bankverbindung->load_oe($oe_kurzbz) && count($bankverbindung->result)>0) - { - $result["iban"]=$bankverbindung->result[0]->iban; - $result["bic"]=$bankverbindung->result[0]->bic; - return $result; - } - else - { - $organisationseinheit = new organisationseinheit(); - $organisationseinheit->load($oe_kurzbz); - if($organisationseinheit->oe_parent_kurzbz !== NULL) + $iban = ""; + $bic = ""; + $result = array(); + $bankverbindung=new bankverbindung(); + if($bankverbindung->load_oe($oe_kurzbz, $orgform_kurzbz) && count($bankverbindung->result) > 0) { - $result = getBankverbindung($organisationseinheit->oe_parent_kurzbz); - return $result; + $result["iban"] = $bankverbindung->result[0]->iban; + $result["bic"] = $bankverbindung->result[0]->bic; + return $result; + } + // Nochmal ohne $orgform_kurzbz versuchen + elseif($bankverbindung->load_oe($oe_kurzbz) && count($bankverbindung->result) > 0) + { + $result["iban"] = $bankverbindung->result[0]->iban; + $result["bic"] = $bankverbindung->result[0]->bic; + return $result; } else { - $result["iban"]=""; - $result["bic"]=""; + $organisationseinheit = new organisationseinheit(); + $organisationseinheit->load($oe_kurzbz); + if($organisationseinheit->oe_parent_kurzbz !== NULL) + { + $result = getBankverbindung($organisationseinheit->oe_parent_kurzbz, $orgform_kurzbz); + return $result; + } + else + { + $result["iban"] = ""; + $result["bic"] = ""; + } } - } } ?> diff --git a/include/bankverbindung.class.php b/include/bankverbindung.class.php index b9056f3b8..44139375e 100644 --- a/include/bankverbindung.class.php +++ b/include/bankverbindung.class.php @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * Authors: Christian Paminger , - * Andreas Oesterreicher and - * Rudolf Hangl . + * Andreas Oesterreicher and + * Rudolf Hangl . */ /** * Klasse bankverbindung @@ -47,6 +47,7 @@ class bankverbindung extends basis_db public $updateamum; // timestamp public $updatevon; // bigint public $oe_kurzbz; // string + public $orgform_kurzbz; // string /** * Konstruktor @@ -95,6 +96,7 @@ class bankverbindung extends basis_db $this->insertvon = $row->insertvon; $this->ext_id = $row->ext_id; $this->oe_kurzbz = $row->oe_kurzbz; + $this->orgform_kurzbz = $row->orgform_kurzbz; return true; } else @@ -176,19 +178,20 @@ class bankverbindung extends basis_db //Neuen Datensatz einfuegen $qry = 'BEGIN;INSERT INTO public.tbl_bankverbindung (person_id, name, anschrift, blz, bic, - kontonr, iban, typ, oe_kurzbz, verrechnung, insertamum, insertvon, updateamum, updatevon) VALUES('. - $this->db_add_param($this->person_id, FHC_INTEGER).', '. - $this->db_add_param($this->name).', '. - $this->db_add_param($this->anschrift).', '. - $this->db_add_param($this->blz).', '. - $this->db_add_param($this->bic).', '. - $this->db_add_param($this->kontonr).', '. - $this->db_add_param($this->iban).', '. - $this->db_add_param($this->typ).', '. - $this->db_add_param($this->oe_kurzbz).', '. - $this->db_add_param($this->verrechnung, FHC_BOOLEAN).', now(), '. - $this->db_add_param($this->insertvon).', now(), '. - $this->db_add_param($this->updatevon).');'; + kontonr, iban, typ, oe_kurzbz, orgform_kurzbz, verrechnung, insertamum, insertvon, updateamum, updatevon) VALUES('. + $this->db_add_param($this->person_id, FHC_INTEGER).', '. + $this->db_add_param($this->name).', '. + $this->db_add_param($this->anschrift).', '. + $this->db_add_param($this->blz).', '. + $this->db_add_param($this->bic).', '. + $this->db_add_param($this->kontonr).', '. + $this->db_add_param($this->iban).', '. + $this->db_add_param($this->typ).', '. + $this->db_add_param($this->oe_kurzbz).', '. + $this->db_add_param($this->orgform_kurzbz).', '. + $this->db_add_param($this->verrechnung, FHC_BOOLEAN).', now(), '. + $this->db_add_param($this->insertvon).', now(), '. + $this->db_add_param($this->updatevon).');'; } else { @@ -212,6 +215,7 @@ class bankverbindung extends basis_db 'typ='.$this->db_add_param($this->typ).', '. 'verrechnung='.$this->db_add_param($this->verrechnung,FHC_BOOLEAN).', '. 'oe_kurzbz='.$this->db_add_param($this->oe_kurzbz).', '. + 'orgform_kurzbz='.$this->db_add_param($this->orgform_kurzbz).', '. 'updateamum='.$this->db_add_param($this->updateamum).','. 'updatevon='.$this->db_add_param($this->updatevon).' '. 'WHERE bankverbindung_id='.$this->db_add_param($this->bankverbindung_id).';'; @@ -315,6 +319,7 @@ class bankverbindung extends basis_db $obj->insertvon = $row->insertvon; $obj->ext_id = $row->ext_id; $obj->oe_kurzbz = $row->oe_kurzbz; + $obj->orgform_kurzbz = $row->orgform_kurzbz; $this->result[] = $obj; } @@ -328,11 +333,12 @@ class bankverbindung extends basis_db } /** - * Laedt die Bankverbindung einer Organisationseinheit - * @param $person_id + * Laedt die Bankverbindung einer Organisationseinheit und optional einer OrgForm + * @param string $oe_kurzbz + * @param string $orgform_kurzbz * @return true wenn ok, false im Fehlerfall */ - public function load_oe($oe_kurzbz) + public function load_oe($oe_kurzbz, $orgform_kurzbz = null) { if($oe_kurzbz==null || $oe_kurzbz=='') { @@ -342,6 +348,11 @@ class bankverbindung extends basis_db $qry = "SELECT * FROM public.tbl_bankverbindung WHERE oe_kurzbz=".$this->db_add_param($oe_kurzbz); + if($orgform_kurzbz != '') + { + $qry .= " AND orgform_kurzbz=".$this->db_add_param($orgform_kurzbz); + } + if($this->db_query($qry)) { while($row = $this->db_fetch_object()) @@ -364,6 +375,7 @@ class bankverbindung extends basis_db $obj->insertvon = $row->insertvon; $obj->ext_id = $row->ext_id; $obj->oe_kurzbz = $row->oe_kurzbz; + $obj->orgform_kurzbz = $row->orgform_kurzbz; $this->result[] = $obj; } @@ -412,6 +424,7 @@ class bankverbindung extends basis_db $this->insertvon = $row->insertvon; $this->ext_id = $row->ext_id; $this->oe_kurzbz = $row->oe_kurzbz; + $this->orgform_kurzbz = $row->orgform_kurzbz; return true; } From d07b0684c3fc005c2060a4412d19aedbb28de0d5 Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Sun, 23 Feb 2020 20:47:54 +0100 Subject: [PATCH 084/138] Orgform nur dazu schreiben, wenn es mehr als Eine gibt --- application/controllers/jobs/ReihungstestJob.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/application/controllers/jobs/ReihungstestJob.php b/application/controllers/jobs/ReihungstestJob.php index 948eeb0b8..c548d2495 100644 --- a/application/controllers/jobs/ReihungstestJob.php +++ b/application/controllers/jobs/ReihungstestJob.php @@ -899,8 +899,8 @@ class ReihungstestJob extends CLI_Controller ); if (isSuccess($result)) { - $mailArray[$rowNiedrPrios->studiengang_kz][$rowNiedrPrios->orgform_kurzbz]['AbgewiesenGesetzt'][] - = $rowNiedrPrios->nachname.' '.$rowNiedrPrios->vorname.' ('.$rowNiedrPrios->prestudent_id.')'; + /*$mailArray[$rowNiedrPrios->studiengang_kz][$rowNiedrPrios->orgform_kurzbz]['AbgewiesenGesetzt'][] + = $rowNiedrPrios->nachname.' '.$rowNiedrPrios->vorname.' ('.$rowNiedrPrios->prestudent_id.')';*/ } } elseif ($rowNiedrPrios->laststatus == 'Wartender') @@ -937,7 +937,8 @@ class ReihungstestJob extends CLI_Controller } } } - echo '
', var_dump($mailArray), '
'; + + // Kaution einbuchen für $row_ps->prestudent_id // Vorher prüfen, ob schon eine Kaution gebucht ist // Todo: Betrag automatisch aus tbl_buchungstyp laden @@ -971,6 +972,7 @@ class ReihungstestJob extends CLI_Controller } } } + echo '
', var_dump($mailArray), '
'; // Mails senden if (!isEmptyArray($mailArray)) { @@ -983,7 +985,11 @@ class ReihungstestJob extends CLI_Controller foreach ($orgform AS $art=>$value) { - $mailcontent .= '

Orgform '.$art.'

'; + // Orgform nur dazu schreiben, wenn es mehr als Eine gibt + if (count($orgform) > 1) + { + $mailcontent .= '

Orgform '.$art.'

'; + } if (isset($value['AbgewiesenGesetzt']) && !isEmptyArray($value['AbgewiesenGesetzt'])) { $mailcontent .= ' From 8507f639366fd74deb574b8e11a5bbafa414948b Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Sun, 23 Feb 2020 20:51:16 +0100 Subject: [PATCH 085/138] GUI-changes in writeTemplate - Show only "bezeichnung" of template in select for regular users - New styled "Preview"-Button. - Click on "Preview" automatically scrolls to Preview-Div --- .../system/messages/htmlWriteTemplate.php | 28 ++++++++----------- application/widgets/Vorlage_widget.php | 3 +- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/application/views/system/messages/htmlWriteTemplate.php b/application/views/system/messages/htmlWriteTemplate.php index 64a8c8236..bb031a370 100644 --- a/application/views/system/messages/htmlWriteTemplate.php +++ b/application/views/system/messages/htmlWriteTemplate.php @@ -129,34 +129,30 @@ -
+
-
-
- +
+
+
widgetlib->widget( 'Dropdown_widget', - array('elements' => success($recipientsArray), 'emptyElement' => 'Select...'), + array('elements' => success($recipientsArray), 'emptyElement' => ucfirst($this->p->t('global', 'empfaenger')).'...'), array( - 'title' => ucfirst($this->p->t('global', 'empfaenger')).': ', + /*'title' => ucfirst($this->p->t('global', 'empfaenger')).': ',*/ 'name' => 'recipients[]', 'id' => 'recipients' ) ); ?> - + + + p->t('ui', 'refresh')); ?> + + +
-

diff --git a/application/widgets/Vorlage_widget.php b/application/widgets/Vorlage_widget.php index 9c9abe430..1c05db9e3 100644 --- a/application/widgets/Vorlage_widget.php +++ b/application/widgets/Vorlage_widget.php @@ -63,7 +63,8 @@ class Vorlage_widget extends DropdownWidget FROM tbl_vorlagestudiengang vs INNER JOIN tbl_vorlage v USING(vorlage_kurzbz) ) templates'; $alias = 'templates'; - $fields = array("templates.vorlage_kurzbz AS id", "UPPER(templates.oe_kurzbz) || ' - ' || templates.bezeichnung || ' - V' || templates.version AS description"); + //$fields = array("templates.vorlage_kurzbz AS id", "UPPER(templates.oe_kurzbz) || ' - ' || templates.bezeichnung || ' - V' || templates.version AS description"); + $fields = array("templates.vorlage_kurzbz AS id", "templates.bezeichnung AS description"); $where = 'templates.aktiv = TRUE AND templates.subject IS NOT NULL AND templates.text IS NOT NULL From 166a4a76e84ba5c65b6364fa236e4ed61a7a6d8d Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 24 Feb 2020 16:44:57 +0100 Subject: [PATCH 086/138] stammdaten/auswertung_fhtw.php: - added column "Punkte mit offset" - removed commented code concerning RT-punkte without Physik --- vilesci/stammdaten/auswertung_fhtw.php | 83 +++++++++++--------------- 1 file changed, 36 insertions(+), 47 deletions(-) diff --git a/vilesci/stammdaten/auswertung_fhtw.php b/vilesci/stammdaten/auswertung_fhtw.php index a47230087..18b783e8e 100644 --- a/vilesci/stammdaten/auswertung_fhtw.php +++ b/vilesci/stammdaten/auswertung_fhtw.php @@ -1211,7 +1211,11 @@ if (isset($_REQUEST['reihungstest'])) } $gebiet[$row->gebiet_id]->name = $row->gebiet; $gebiet[$row->gebiet_id]->gebiet_id = $row->gebiet_id; - $gebiet[$row->gebiet_id]->gewicht = $row->gewicht; + //gewicht ist meist für alle Studiengänge gleich (Bachelor, Master und Distance haben jeweilsandere Gebiete) + if (!isset($gebiet[$row->gebiet_id]->gewicht)) + { + $gebiet[$row->gebiet_id]->gewicht = $row->gewicht; + } } // Alle Ergebnisse laden @@ -1476,18 +1480,22 @@ if (isset($_REQUEST['reihungstest'])) $ergebnis[$row->prestudent_id]->gebiet[$row->gebiet_id]->prozent = null; $ergebnis[$row->prestudent_id]->gebiet[$row->gebiet_id]->punkte = $punkte; + $ergebnis[$row->prestudent_id]->gebiet[$row->gebiet_id]->punktemitoffset = null; // Punkte berechnen if (isset($punkte)) { + //offset zur Vermeidung negativer Prozentzahlen + $punkte_positiv = $punkte + $row->offsetpunkte; + $maxpunkte_positiv = $row->maxpunkte + $row->offsetpunkte; + $ergebnis[$row->prestudent_id]->gebiet[$row->gebiet_id]->punktemitoffset = $punkte_positiv; + if ($row->punkte >= $row->maxpunkte) + { $ergebnis[$row->prestudent_id]->gebiet[$row->gebiet_id]->prozent = 100; + } else { - //offset zur Vermeidung negativer Prozentzahlen - $punkte_positiv = $punkte + $row->offsetpunkte; - $maxpunkte_positiv = $row->maxpunkte + $row->offsetpunkte; - //Formel: Summe(Punkte/Maxpunkte * Gewicht) $ergebnis[$row->prestudent_id]->gebiet[$row->gebiet_id]->prozent = $maxpunkte_positiv > 0 ? $punkte_positiv / $maxpunkte_positiv * /*$row->gewicht **/ 100 : null; } } @@ -1518,6 +1526,15 @@ if (isset($_REQUEST['reihungstest'])) $ergebnis[$row->prestudent_id]->gesamtpunkte = $punkte; } + if (isset($ergebnis[$row->prestudent_id]->gesamtoffsetpunkte)) + { + $ergebnis[$row->prestudent_id]->gesamtoffsetpunkte += $ergebnis[$row->prestudent_id]->gebiet[$row->gebiet_id]->punktemitoffset; + } + else + { + $ergebnis[$row->prestudent_id]->gesamtoffsetpunkte = $ergebnis[$row->prestudent_id]->gebiet[$row->gebiet_id]->punktemitoffset; + } + if (isset($row->punkte)) { if (isset($ergebnis[$row->prestudent_id]->gesamtgewicht)) @@ -1529,28 +1546,6 @@ if (isset($_REQUEST['reihungstest'])) $ergebnis[$row->prestudent_id]->gesamtgewicht = $row->gewicht; } } - - // Gesamtpunkte ohne Physik -/* if ($row->gebiet_id != 10) - { - if (isset($ergebnis[$row->prestudent_id]->gesamt_ohne_physik)) - { - $ergebnis[$row->prestudent_id]->gesamt_ohne_physik += $prozent * $row->gewicht; - } - else - { - $ergebnis[$row->prestudent_id]->gesamt_ohne_physik = $prozent * $row->gewicht; - } - - if (isset($ergebnis[$row->prestudent_id]->gesamtpunkte_ohne_physik)) - { - $ergebnis[$row->prestudent_id]->gesamtpunkte_ohne_physik += $punkte; - } - else - { - $ergebnis[$row->prestudent_id]->gesamtpunkte_ohne_physik = $punkte; - } - }*/ } } @@ -1703,7 +1698,7 @@ if (isset($_REQUEST['format']) && $_REQUEST['format'] == 'xls') foreach ($gebiet AS $gbt) { ++$spalte; - $worksheet->write($zeile, ++$spalte, strip_tags($gbt->name) . (isset($gbt->gewicht) ? " (Gew: $gbt->gewicht)" : ""), $format_bold_border); + $worksheet->write($zeile, ++$spalte, strip_tags($gbt->name) . ( isset($gbt->gewicht) ? " (Gew: $gbt->gewicht)" : ""), $format_bold_border); $worksheet->mergeCells($zeile, $spalte, 0, $spalte + 1); $maxlength[$spalte] = 10; } @@ -2142,7 +2137,7 @@ else $("#auswertung_table").tablesorter( { widgets: ["zebra", "filter", "columnSelector"], - sortList: [[15,1],[17,1],[3,0],[4,0]],//16th fake hidden column for correct sort with colspan + sortList: [[15,1],[18,1],[3,0],[4,0]],//16th (index 15) fake hidden column for correct sort with colspan headers: {0: { sorter: false, filter: false}, 2: { sorter: false, filter: false}, 4: { dateFormat: "ddmmyyyy" }, 15: { sorter: false, filter: false}} /*widgetOptions : { columnSelector_container : $("#columnSelector"), @@ -2940,22 +2935,24 @@ else
- '; + '; foreach ($gebiet AS $gbt) { - echo ''; + echo ''; } echo ' + '; foreach ($gebiet AS $gbt) { echo ""; + echo ""; echo ""; } @@ -3010,25 +3007,16 @@ else echo ' ' . ($erg->gesamtpunkte != '' ? number_format($erg->gesamtpunkte, 2, ',', ' ') : '') . ''; } echo ' '; -/* if (!isset($erg->gesamtpunkte_ohne_physik)) - { - $erg->gesamtpunkte_ohne_physik = ''; - }*/ -/* if (!isset($erg->gesamt_ohne_physik)) - { - $erg->gesamt_ohne_physik = ''; - }*/ + + echo ' '; + echo ' '; -/* echo ' ';*/ -/* echo ' ';*/ + foreach ($gebiet AS $gbt) { if (isset($erg->gebiet[$gbt->gebiet_id])) @@ -3060,11 +3048,12 @@ else echo ' ' . ($erg->gebiet[$gbt->gebiet_id]->punkte != '' ? number_format($erg->gebiet[$gbt->gebiet_id]->punkte, 2, ',', ' ') : '') . ''; } echo ''; + echo ''; echo ''; } else { - echo ''; + echo ''; } } From 8c3066604360b09def5969a69528142f03c5f4b0 Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Mon, 24 Feb 2020 18:43:38 +0100 Subject: [PATCH 087/138] =?UTF-8?q?Testtool=20Login=20shows=20applicants?= =?UTF-8?q?=20only=20once=20(Only=20application=20of=20first=20priority)?= =?UTF-8?q?=20->=20Only=20for=20FHTW!=20New=20function=20getFirstPrioPrest?= =?UTF-8?q?udentRT=20in=20prestudent.class.php=20Link=20to=20pivot-table?= =?UTF-8?q?=20in=20mail=20to=20assistants=20auswertung=5Ffhtw=20ber=C3=BCc?= =?UTF-8?q?ksichtigt=20nun=20orgformen=20(studienpl=C3=A4ne)=20aus=20tbl?= =?UTF-8?q?=5Fablauf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cis/testtool/login.php | 15 ++++++- include/prestudent.class.php | 56 ++++++++++++++++++++++++++ vilesci/stammdaten/auswertung_fhtw.php | 27 ++++++++++--- 3 files changed, 91 insertions(+), 7 deletions(-) diff --git a/cis/testtool/login.php b/cis/testtool/login.php index fac890bc8..f69065aa0 100644 --- a/cis/testtool/login.php +++ b/cis/testtool/login.php @@ -276,7 +276,15 @@ else //$prestudent_id=null; $ps=new prestudent(); $datum=date('Y-m-d'); - $ps->getPrestudentRT($datum); + // An der FHTW wird ein Bewerber nur einmal ausgegeben (1. Prio) falls es mehrere Bewerbungen gibt + if (CAMPUS_NAME == 'FH Technikum Wien') + { + $ps->getFirstPrioPrestudentRT($datum); + } + else + { + $ps->getPrestudentRT($datum); + } } @@ -491,7 +499,10 @@ if (isset($prestudent_id)) echo ''; $stg = new Studiengang($ps_obj->studiengang_kz); - if($ps_obj->lastStatus == "Interessent") + if($ps_obj->lastStatus == "Interessent" + || $ps_obj->lastStatus == "Bewerber" + || $ps_obj->lastStatus == "Wartender" + || $ps_obj->lastStatus == "Aufgenommener") { echo ''; if($ps_obj->ausbildungssemester == '1') diff --git a/include/prestudent.class.php b/include/prestudent.class.php index 4304e5341..923ca81be 100644 --- a/include/prestudent.class.php +++ b/include/prestudent.class.php @@ -420,6 +420,62 @@ class prestudent extends person return true; } + /** + * Laden aller Prestudenten, die an $datum zum Reihungstest geladen sind. + * Wenn es mehrere Bewerbungen für ein Person gibt, wird nur die höchste Prestudent_id zurückgeliefert + * @param string $datum Datum in der Form YYYY-MM-DD an dem der Reihungstest stattfindet + * @return true wenn erfolgreich, false im Fehlerfall + */ + public function getFirstPrioPrestudentRT($datum) + { + $sql_query='SELECT DISTINCT + ps.prestudent_id, + pers.vorname, pers.nachname, pers.person_id, pers.titelpre, + pers.titelpost, pers.gebdatum, + tbl_reihungstest.*, + ps.studiengang_kz as studiengang_kz + FROM + public.tbl_prestudent ps + JOIN public.tbl_person pers USING(person_id) + JOIN public.tbl_rt_person USING(person_id) + JOIN public.tbl_reihungstest ON(tbl_reihungstest.reihungstest_id=tbl_rt_person.rt_id) + WHERE + tbl_reihungstest.datum='.$this->db_add_param($datum).' + AND tbl_rt_person.studienplan_id IN (SELECT studienplan_id FROM public.tbl_prestudentstatus WHERE prestudent_id=ps.prestudent_id) + AND EXISTS(SELECT * FROM public.tbl_prestudentstatus JOIN public.tbl_studiensemester USING(studiensemester_kurzbz) + WHERE prestudent_id=ps.prestudent_id AND tbl_studiensemester.ende>'.$this->db_add_param($datum).') + AND priorisierung = (SELECT priorisierung FROM public.tbl_prestudent + WHERE person_id = pers.person_id + AND get_rolle_prestudent (ps.prestudent_id,NULL) IN (\'Interessent\',\'Bewerber\',\'Wartender\',\'Aufgenommener\') + ORDER BY priorisierung ASC LIMIT 1) + ORDER BY nachname,vorname'; + + if(!$this->db_query($sql_query)) + { + $this->errormsg = 'Fehler beim Laden der Daten'; + return false; + } + + $this->num_rows=0; + + while($row = $this->db_fetch_object()) + { + $ps=new prestudent(); + $ps->prestudent_id = $row->prestudent_id; + $ps->person_id = $row->person_id; + $ps->reihungstest_id = $row->reihungstest_id; + $ps->titelpost = $row->titelpost; + $ps->titelpre = $row->titelpre; + $ps->nachname = $row->nachname; + $ps->vorname = $row->vorname; + $ps->gebdatum = $row->gebdatum; + $ps->studiengang_kz = $row->studiengang_kz; + $this->result[]=$ps; + $this->num_rows++; + } + return true; + } + /** * Laedt über einen Prestudenten alle anderen Prestudenten einer Person, die aktuell an STG interessiert sind. * @integer $prestudent_id Prestudent ID, über die alle weiteren Prestudenten ermittelt werden sollen. diff --git a/vilesci/stammdaten/auswertung_fhtw.php b/vilesci/stammdaten/auswertung_fhtw.php index a47230087..e38be43bf 100644 --- a/vilesci/stammdaten/auswertung_fhtw.php +++ b/vilesci/stammdaten/auswertung_fhtw.php @@ -562,10 +562,9 @@ if ($testende) @@ -643,7 +642,7 @@ if (isset($_POST['method']) && $_POST['method'] == 'addPerson') if ($row->bewerbung_abgeschicktamum != '' && $row->bestaetigtam != '' && $row->studienplan_id != '') { $studienplan = $row->studienplan_id; - $break; + break; } } @@ -1154,7 +1153,7 @@ if (isset($_REQUEST['reihungstest'])) JOIN PUBLIC.tbl_person ON (tbl_rt_person.person_id = tbl_person.person_id) JOIN PUBLIC.tbl_prestudent ps ON (ps.person_id = tbl_rt_person.person_id) JOIN PUBLIC.tbl_reihungstest rt ON (tbl_rt_person.rt_id = rt.reihungstest_id) - JOIN PUBLIC.tbl_prestudentstatus USING (prestudent_id) + JOIN PUBLIC.tbl_prestudentstatus pss USING (prestudent_id) JOIN public.tbl_studiengang ON (ps.studiengang_kz = tbl_studiengang.studiengang_kz) LEFT JOIN bis.tbl_zgv ON (ps.zgv_code = tbl_zgv.zgv_code) LEFT JOIN PUBLIC.tbl_ort ON (tbl_rt_person.ort_kurzbz = tbl_ort.ort_kurzbz) @@ -1196,6 +1195,20 @@ if (isset($_REQUEST['reihungstest'])) { $query .= " AND ps.prestudent_id=" . $db->db_add_param($prestudent_id, FHC_INTEGER); } + if ($orgform_kurzbz != '' && $studiengang != '') + { + $query .= " AND tbl_ablauf.studienplan_id=( + SELECT studienplan_id FROM lehre.tbl_studienplan + JOIN lehre.tbl_studienordnung USING (studienordnung_id) + WHERE studiengang_kz=".$db->db_add_param($studiengang, FHC_INTEGER)." + AND tbl_studienplan.orgform_kurzbz = ".$db->db_add_param($orgform_kurzbz)." + AND tbl_studienplan.aktiv + AND tbl_studienordnung.status_kurzbz='approved' + AND ((SELECT start FROM public.tbl_studiensemester WHERE studiensemester_kurzbz=tbl_studienordnung.gueltigvon) <= now() + OR tbl_studienordnung.gueltigvon IS NULL) + AND ((SELECT ende FROM public.tbl_studiensemester WHERE studiensemester_kurzbz=tbl_studienordnung.gueltigbis) >= now() OR tbl_studienordnung.gueltigbis IS NULL) + ORDER BY studienplan_id DESC LIMIT 1)"; + } //$query .= " AND nachname='Al-Mafrachi'"; $query .= " ORDER BY tbl_ablauf.studiengang_kz, tbl_ablauf.semester, reihung"; @@ -1403,6 +1416,9 @@ if (isset($_REQUEST['reihungstest'])) } if ($orgform_kurzbz != '') { + //$query .= " AND tbl_prestudentstatus.orgform_kurzbz=" . $db->db_add_param($orgform_kurzbz); + //$query .= " AND tbl_ablauf.studienplan_id = tbl_prestudentstatus.studienplan_id"; + //$query .= " AND tbl_ablauf.studienplan_id = 5"; $query .= " AND tbl_studienplan.orgform_kurzbz=" . $db->db_add_param($orgform_kurzbz); } //$query .= " AND nachname='Al-Mafrachi'"; @@ -1410,6 +1426,7 @@ if (isset($_REQUEST['reihungstest'])) vorname, person_id ";/*print_r($query);*/ + //echo '
', var_dump($query), '
'; if (!($result = $db->db_query($query))) { die($db->db_last_error()); From 9586a3e55121d274ea537d9f5231af6ef32031ab Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Mon, 24 Feb 2020 21:01:41 +0100 Subject: [PATCH 088/138] Updated function getFirstPrioPrestudentRT --- include/prestudent.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/prestudent.class.php b/include/prestudent.class.php index 923ca81be..16ed8857d 100644 --- a/include/prestudent.class.php +++ b/include/prestudent.class.php @@ -441,7 +441,7 @@ class prestudent extends person JOIN public.tbl_reihungstest ON(tbl_reihungstest.reihungstest_id=tbl_rt_person.rt_id) WHERE tbl_reihungstest.datum='.$this->db_add_param($datum).' - AND tbl_rt_person.studienplan_id IN (SELECT studienplan_id FROM public.tbl_prestudentstatus WHERE prestudent_id=ps.prestudent_id) + /*AND tbl_rt_person.studienplan_id IN (SELECT studienplan_id FROM public.tbl_prestudentstatus WHERE prestudent_id=ps.prestudent_id)*/ AND EXISTS(SELECT * FROM public.tbl_prestudentstatus JOIN public.tbl_studiensemester USING(studiensemester_kurzbz) WHERE prestudent_id=ps.prestudent_id AND tbl_studiensemester.ende>'.$this->db_add_param($datum).') AND priorisierung = (SELECT priorisierung FROM public.tbl_prestudent From ed78f7c7af46287f6d28a5d0177a527c856bddb1 Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Mon, 24 Feb 2020 22:03:06 +0100 Subject: [PATCH 089/138] frage.php: Fallback auf DEFAULT_LANGUAGE wenn kein Vorschlag in der Sessionsprache vorhanden ist --- cis/testtool/frage.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cis/testtool/frage.php b/cis/testtool/frage.php index a760d00aa..86ed76252 100644 --- a/cis/testtool/frage.php +++ b/cis/testtool/frage.php @@ -581,6 +581,14 @@ if($frage->frage_id!='') //Vorschlaege laden $vs = new vorschlag(); $vs->getVorschlag($frage->frage_id, $_SESSION['sprache_user'], $gebiet->zufallvorschlag); + + // Fallback auf DEFAULT_LANGUAGE wenn kein Vorschlag in der $_SESSION['sprache_user'] vorhanden ist + if (isset($vs->result[0]) && $vs->result[0]->text == '' && $vs->result[0]->bild == '' && $vs->result[0]->audio == '') + { + $vs = new vorschlag(); + $vs->getVorschlag($frage->frage_id, DEFAULT_LANGUAGE, $gebiet->zufallvorschlag); + } + $letzte = $frage->getNextFrage($gebiet_id, $_SESSION['pruefling_id'], $frage_id, $demo); echo "frage_id\" method=\"POST\" ".(!$letzte && !$levelgebiet?"onsubmit=\"letzteFrage()\"":"").">"; echo ' From a50cc6cba87c1ff25abc1d84032437e4248c1ef6 Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 25 Feb 2020 16:41:27 +0100 Subject: [PATCH 090/138] - jobs/MailJob->sendAllMessageEmailNotices changed since parameter default value - Moved ALT_OE from MessageLib to CL/Messages_model - MessageLib->_setSentError renamed to _updatedRecipientNoticeEmailInfo - MessageLib->_sendNoticeEmail changed to have more information about a not sent notice email - Recipient_model->getNotSentMessages now does not retrieve messages with notice email send failure --- application/controllers/jobs/MailJob.php | 3 +- application/libraries/MessageLib.php | 33 +++++++++++++++---- application/models/CL/Messages_model.php | 4 ++- application/models/system/Recipient_model.php | 3 +- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/application/controllers/jobs/MailJob.php b/application/controllers/jobs/MailJob.php index b4b772f78..f459d4d3e 100644 --- a/application/controllers/jobs/MailJob.php +++ b/application/controllers/jobs/MailJob.php @@ -19,12 +19,13 @@ class MailJob extends JOB_Controller * Send all the NOT sent notice emails for messaging system * The parameters are all not mandatory, they could be used to overrides the configs for testing, debug or one shot purposes */ - public function sendAllMessageEmailNotices($since = null, $numberToSent = null, $numberPerTimeRange = null, $emailTimeRange = null, $emailFromSystem = null) + public function sendAllMessageEmailNotices($since = '1970-01-01', $numberToSent = null, $numberPerTimeRange = null, $emailTimeRange = null, $emailFromSystem = null) { $this->logInfo('Send all message email notices started'); // Send them all! $sendAllEmailNotices = $this->messagelib->sendAllEmailNotices($since, $numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem); + if (isError($sendAllEmailNotices)) { $optionalParameters = new stdClass(); diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index cfd450f98..f2ede9cef 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -26,8 +26,6 @@ class MessageLib const EMAIL_KONTAKT_TYPE = 'email'; // Email kontakt type const SENT_INFO_NEWLINE = '\n'; // tbl_msg_recipient->sentInfo separator - const ALT_OE = 'infocenter'; // alternative organisation unit when no one is found for a presetudent - private $_ci; /** @@ -498,7 +496,7 @@ class MessageLib * Stores the type of error in 'sentinfo' column keeping en eventual previous error * sent column is set to null */ - private function _setSentError($message_id, $receiver_id, $sentInfo, $prevSentInfo) + private function _updatedRecipientNoticeEmailInfo($message_id, $receiver_id, $sentInfo, $prevSentInfo) { if (!isEmptyString($prevSentInfo)) { @@ -763,15 +761,15 @@ class MessageLib if (!$sent) { // Set in database why this email is NOT going to be send - $sse = $this->_setSentError( + $sse = $this->_updatedRecipientNoticeEmailInfo( $messageData->message_id, $messageData->receiver_id, - 'An error occurred while sending the notice email', - $messageData->sentinfo + 'An error occurred while sending the notice email', // current info + $messageData->sentinfo // previous info ); // If database error occurred then return it, otherwise return a logic error - return isError($sse) ? $sse : error('An error occurred while sending the notice email'); + return isError($sse) ? $sse : error('An error occurred while updating the recipient notice email info'); } else // success! { @@ -780,6 +778,27 @@ class MessageLib if (isError($sss)) return $sss; // If database error occurred then return it } } + else // Because was not possible to find a valid contact + { + $reason = 'Was not possible to find a valid contact for this user'; // default reason + + // In case that the organisation unit does not receive any email notices + if (!isEmptyString($messageData->receiver_ou)) $reason = 'This organization unit does not receive email notices'; + + // In case that a degree program sent a message to a user without a valid contact or UID + if (!isEmptyString($messageData->sender_ou)) $reason = 'Sent from a degree program to a user that does not have a valid UID or a valid contact'; + + // Set in database why this email is NOT going to be send + $sse = $this->_updatedRecipientNoticeEmailInfo( + $messageData->message_id, + $messageData->receiver_id, + $reason, // current info + $messageData->sentinfo // previous info + ); + + // If database error occurred then return it + if (isError($sse)) return $sse; + } } return success('Notice emails sent successfully'); diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 9cc4a76da..cbb42543f 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -26,6 +26,8 @@ class Messages_model extends CI_Model const TYPE_PERSONS = 'persons'; const TYPE_PRESTUDENTS = 'prestudents'; + const ALT_OE = 'infocenter'; // alternative organisation unit when no one is found for a presetudent + /** * Constructor */ @@ -106,7 +108,7 @@ class Messages_model extends CI_Model { $ouOptions .= sprintf( "\n".'', - is_numeric($ou->prestudent_id) ? $ou->oe_kurzbz : MessageLib::ALT_OE, + is_numeric($ou->prestudent_id) ? $ou->oe_kurzbz : self::ALT_OE, $ou->bezeichnung . (is_numeric($ou->prestudent_id) ? '' : ' *') ); } diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index ad1c1e850..d74d03243 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -205,12 +205,13 @@ class Recipient_model extends DB_Model * @param limit specifies the max number of messages to get * @param since specifies from which date messages have to be retrieved */ - public function getNotSentMessages($limit, $since = '1970-01-01') + public function getNotSentMessages($limit, $since) { $query = 'SELECT mm.message_id FROM public.tbl_msg_recipient mr JOIN public.tbl_msg_message mm USING (message_id) WHERE mr.sent IS NULL + AND mr.sentinfo IS NULL AND mm.insertamum > ? ORDER BY mr.insertamum ASC LIMIT ?'; From 34afbe9f63ce69c18b2eb0f2cdcd18512b45e9ec Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 26 Feb 2020 13:53:05 +0100 Subject: [PATCH 091/138] system/dbupdate_3.3: added "Alias Studienassistenz" to check for creation of vs_msg_vars in dbupdate --- system/dbupdate_3.3.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index 43be48715..623ea7ac7 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -3687,8 +3687,8 @@ if(!$result = @$db->db_query("SELECT orgform_kurzbz FROM public.tbl_bankverbindu echo '
public.tbl_bankverbindung: Spalte orgform_kurzbz hinzugefuegt'; } -// iban und bic zu vw_msg_vars hinzufügen -if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang", "Studiengangskennzahl", "Einstiegssemester", "Einstiegsstudiensemester", "Vorname Studiengangsassistenz", "Nachname Studiengangsassistenz", "Durchwahl Studiengangsassistenz", "Relative Prio" FROM public.vw_msg_vars LIMIT 1')) +// iban, bic und weitere Variablen zu vw_msg_vars hinzufügen +if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang", "Studiengangskennzahl", "Einstiegssemester", "Einstiegsstudiensemester", "Vorname Studiengangsassistenz", "Nachname Studiengangsassistenz", "Durchwahl Studiengangsassistenz", "Alias Studiengangsassistenz", "Relative Prio" FROM public.vw_msg_vars LIMIT 1')) { $qry = ' CREATE OR REPLACE VIEW public.vw_msg_vars AS ( From 6509d74f4b4f5c47a3780c8fe006486808d061ba Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Wed, 26 Feb 2020 15:20:08 +0100 Subject: [PATCH 092/138] Fix height of Prestudent-Statuslist on smaller Screens --- content/student/studentdetailoverlay.xul.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/student/studentdetailoverlay.xul.php b/content/student/studentdetailoverlay.xul.php index 0a014b20a..7f45342dc 100644 --- a/content/student/studentdetailoverlay.xul.php +++ b/content/student/studentdetailoverlay.xul.php @@ -509,7 +509,7 @@ echo '';
Raum TG GesamtGesamt' . $gbt->name . '' . $gbt->name . '
PunktePunkte mit Offset ProzentPunktePunkte mit OffsetProzent + ' . ($erg->gesamtoffsetpunkte != '' ? number_format($erg->gesamtoffsetpunkte, 2, ',', ' ') : '') . ' + ' . $gesamtprozent . ' - ' . ($erg->gesamtpunkte_ohne_physik != '' ? number_format($erg->gesamtpunkte_ohne_physik, 2, ',', ' ') : '') . ' - - ' . ($erg->gesamt_ohne_physik != '' ? number_format($erg->gesamt_ohne_physik, 2, ',', ' ') : '') . ' - - ' . ($erg->gebiet[$gbt->gebiet_id]->punktemitoffset != '' ? number_format($erg->gebiet[$gbt->gebiet_id]->punktemitoffset, 2, ',', ' ') : '') . '' . ($erg->gebiet[$gbt->gebiet_id]->prozent != '' ? number_format($erg->gebiet[$gbt->gebiet_id]->prozent, 2, ',', ' ') . ' %' : '') . '
'. $ps_obj->typ_bz .' '. ($sprache_user == 'English' ? $stg->english : $stg->bezeichnung). '
'; $mailtext .= 'Der Reihungstest vom ' . $datum_obj->convertISODate($reihungstest->datum) . ' um ' . $datum_obj->formatDatum($reihungstest->uhrzeit, 'H:i') . ' Uhr ist beendet.'; - $mailtext .= '
Es haben '.$anzahl.' Person(en) aus dem Studiengang '.$stg->kuerzel.'-'.$orgForm.' teilgenommen'; - $mailtext .= '
Sie finden die Auswertung unter dem folgendem Link:'; + $mailtext .= '
Es haben '.$anzahl.' Person(en) aus dem Studiengang '.$stg->kuerzel.'-'.$orgForm.' teilgenommen.'; $mailtext .= '

Link zur Auswertung'; - + $mailtext .= '

Link zur Pivot-Tabelle für die Priorisierung'; $mailtext .= '
Date: Wed, 26 Feb 2020 17:11:00 +0100 Subject: [PATCH 093/138] Added function getLehreinheiten_SWS_BISMeldung This function retrieves semesterwochenstunden of a given studiensemester for all employees who should be BIS reported. --- include/lehreinheitmitarbeiter.class.php | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/include/lehreinheitmitarbeiter.class.php b/include/lehreinheitmitarbeiter.class.php index 48d0de485..d7d469c2f 100644 --- a/include/lehreinheitmitarbeiter.class.php +++ b/include/lehreinheitmitarbeiter.class.php @@ -495,6 +495,41 @@ class lehreinheitmitarbeiter extends basis_db return $ret; } + public function getLehreinheiten_SWS_BISMeldung($uid, $studiensemester) + { + $qry = ' + SELECT + round(sum(semesterstunden) / 15) AS sws + FROM ( + SELECT DISTINCT lehreinheit_id, studiensemester_kurzbz, mitarbeiter_uid, semesterstunden + FROM lehre.tbl_lehreinheitmitarbeiter + JOIN public.tbl_mitarbeiter ma USING (mitarbeiter_uid) + JOIN public.tbl_benutzer ON (mitarbeiter_uid = uid) + JOIN public.tbl_person USING (person_id) + JOIN bis.tbl_bisverwendung USING (mitarbeiter_uid) + JOIN lehre.tbl_lehreinheit USING (lehreinheit_id) + JOIN public.tbl_studiensemester ss USING (studiensemester_kurzbz) + WHERE mitarbeiter_uid = '. $this->db_add_param($uid).' + AND ma.bismelden + AND studiensemester_kurzbz = '. $this->db_add_param($studiensemester).' + ) tbl_semesterstunden + '; + + if($this->db_query($qry)) + { + while($row = $this->db_fetch_object()) + { + $this->result[] = $row->sws; + } + return true; + } + else + { + $this->errormsg = 'Fehler bei der Datenbankabfrage'; + return false; + } + } + /** * Laedt die Lektoren einer Lehrveranstaltung in einem Studiensemester * @param lehrveranstaltung_id From 6874408200d5172ff2939482dd42fe35a3013c46 Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Wed, 26 Feb 2020 17:11:11 +0100 Subject: [PATCH 094/138] Bugfix Fallback Bild Bugfix Loginliste --- cis/testtool/frage.php | 157 ++++++++++++++++++----------------- cis/testtool/login.php | 6 +- include/prestudent.class.php | 27 ++++-- 3 files changed, 104 insertions(+), 86 deletions(-) diff --git a/cis/testtool/frage.php b/cis/testtool/frage.php index 86ed76252..e2c87ed67 100644 --- a/cis/testtool/frage.php +++ b/cis/testtool/frage.php @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * Authors: Christian Paminger , - * Andreas Oesterreicher , - * Rudolf Hangl , + * Andreas Oesterreicher , + * Rudolf Hangl , * Gerald Simane-Sequens , * Manfred Kindl */ @@ -48,8 +48,8 @@ session_start(); // If language is changed by language select menu, reset language variables if (isset($_GET['sprache_user']) && !empty($_GET['sprache_user'])) { - $_SESSION['sprache_user'] = $_GET['sprache_user']; - $sprache_user = $_GET['sprache_user']; + $_SESSION['sprache_user'] = $_GET['sprache_user']; + $sprache_user = $_GET['sprache_user']; } // Set language variable, which impacts the question language @@ -78,10 +78,10 @@ echo ' - + - - + + - - - - - - - - - - - - - - - - -'; - -foreach($mitarbeiter_gesamt as $row) +// --------------------------------------------------------------------------------------------------------------------- +// Private Functions +// --------------------------------------------------------------------------------------------------------------------- +/** + * Funktion ermittelt fuer jede BIS-Verwendung die Dauer (in Tagen) und Gewichtung (Dauer / Tage im Jahr) + * @param array $bisverwendung_arr Array mit BIS-Verwendungsobjekten + * @return array + */ +function _addDauerGewichtung_imBISMeldungsjahr($bisverwendung_arr) { - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - foreach($row['verwendung'] as $row_verwendung) + global $tage_imJahr; + + foreach ($bisverwendung_arr as &$bisverwendung) { - // Ba1Code - if(isset($ba1_arr[$row_verwendung['ba1code']])) - echo ''; - else - echo ''; + $bisverwendung_beginn_imBISMeldungsJahr = new DateTime($bisverwendung->beginn_imBISMeldungsJahr); + $bisverwendung_ende_imBISMeldungsJahr = new DateTime($bisverwendung->ende_imBISMeldungsJahr); - // Ba2Code - if(isset($ba2_arr[$row_verwendung['ba2code']])) - echo ''; - else - echo ''; - - // Ausmass - if(isset($ausmass_arr[$row_verwendung['beschausmasscode']])) - echo ''; - else - echo ''; - - // Verwendung - if(isset($verwendung_arr[$row_verwendung['verwendung_code']])) - echo ''; - else - echo ''; - - echo ''; + $bisverwendung->dauer_imBISMeldungsJahr = $bisverwendung_ende_imBISMeldungsJahr->diff($bisverwendung_beginn_imBISMeldungsJahr)->days + 1; + $bisverwendung->gewichtung = round($bisverwendung->dauer_imBISMeldungsJahr / $tage_imJahr, 2); } - echo ''; + + return $bisverwendung_arr; } -echo '
UIDVornameNachnamePersonalnummerFixangestelltLektorBeschaeftigungsArt1BeschaeftigungsArt2AusmassVerwendungDetails (Funktion/Lehre)
'.$row['uid'].''.$row['vorname'].''.$row['nachname'].''.$row['personalnummer'].''.($row['fixangestellt']?'Ja':'Nein').''.($row['lektor']?'Ja':'Nein').''.$ba1_arr[$row_verwendung['ba1code']].''.$row_verwendung['ba1code'].''.$ba2_arr[$row_verwendung['ba2code']].''.$row_verwendung['ba2code'].''.$ausmass_arr[$row_verwendung['beschausmasscode']].''.$row_verwendung['beschausmasscode'].''.$verwendung_arr[$row_verwendung['verwendung_code']].''.$row_verwendung['verwendung_code'].''; - // Details - if(isset($row_verwendung['stgltg'])) - { - - foreach($row_verwendung['stgltg'] as $row_stgl) - { - echo 'Leitung:'.$stg_obj->kuerzel_arr[$row_stgl]; - echo '
'; - } - } - - if(isset($row_verwendung['fkt'])) - { - foreach($row_verwendung['fkt'] as $row_fkt) - { - echo $stg_obj->kuerzel_arr[$row_fkt['stgkz']].': '.$row_fkt['sws'].' SWS'; - echo '
'; - } - } - - echo '

'; -echo 'Mitarbeiter-BIS-Meldung archivieren
'; -echo "XML-Datei für Mitarbeiter-BIS-Meldung

"; -?> + +/** + * Funktion ermittelt, ob Person im BIS Meldungsjahr vorwiegend haupt- oder nebenberuflich taetig war. + * @param $bisverwendung_arr Array mit BIS-Verwendungsobjekten + * @return boolean True wenn vorwiegend hauptberuflich + */ +function _getUeberwiegendeTaetigkeit_HauptNebenberuf($bisverwendung_arr) +{ + // Zeiten vergleichen + $sum_dauer_hauptberuflich = 0; + $sum_dauer_nebenberuflich = 0; + + foreach ($bisverwendung_arr as $bisverwendung) + { + if ($bisverwendung->hauptberuflich == true) + { + $sum_dauer_hauptberuflich += $bisverwendung->dauer_imBISMeldungsJahr; + } + else + { + $sum_dauer_nebenberuflich += $bisverwendung->dauer_imBISMeldungsJahr; + } + } + + // Laengere Dauer bestimmt Haupt- oder Nebenberuf + $is_hauptberuflich = $sum_dauer_hauptberuflich > $sum_dauer_nebenberuflich; + + return array($is_hauptberuflich); +} + +/** + * Funktion erstellt Verwendung fuer Lehrtaetigkeiten fuer Personen mit echtem Dienstvertrag. + * (zB STG Leiter mit Lehrtaetigkeit) + * @param object $studiensemester Sommer- / Winterstudiensemester + * @param object $bisverwendung + * @return array + */ +function _addVerwendung_fuerLehre_inkludiert($studiensemester, $bisverwendung) +{ + $verwendung_lehre_obj = new StdClass(); + + $verwendung_lehre_obj->ba1code = $bisverwendung->ba1code; + $verwendung_lehre_obj->ba2code = $bisverwendung->ba2code; + $verwendung_lehre_obj->beschausmasscode = $bisverwendung->beschausmasscode; + $verwendung_lehre_obj->verwendung_code = 1; + $verwendung_lehre_obj->beginn_imBISMeldungsJahr = $bisverwendung->beginn_imBISMeldungsJahr; + $verwendung_lehre_obj->ende_imBISMeldungsJahr = $bisverwendung->ende_imBISMeldungsJahr; + + /** + * Anteilige Lehrtage im Studiensemester ermitteln + * NOTE: Da die gesamte Lehrtaetigkeit fuer SS und WS im BIS Meldungsjahr gemeldet wird, muss die WS Lehrtaetigkeit + * jahresuebergreifend erfasst werden. Daher Datumsvergleiche mit dem tatsaechlichen BIS-Verwendungsende. + * */ + $tage_lehre_imSemester = 182; // default Tage im Halbjahr entsprechend der default Gewichtung von 0.5 + $studsem_start = new DateTime($studiensemester->start); + $studsem_ende = new DateTime($studiensemester->ende); + $bisverwendung_beginn_BIS = new DateTime($bisverwendung->beginn_imBISMeldungsJahr); + $bisverwendung_ende = new DateTime($bisverwendung->ende); + + $beginn_im_semester = ($bisverwendung_beginn_BIS < $studsem_start) ? $studsem_start : $bisverwendung_beginn_BIS; + $ende_im_semester = (!is_null($bisverwendung_ende) && $bisverwendung_ende > $studsem_ende) ? $studsem_ende : $bisverwendung_ende; + $tage_lehre_imSemester = $beginn_im_semester->diff($ende_im_semester)->days + 1; + + return array($tage_lehre_imSemester, $verwendung_lehre_obj); +} + +/** + * Funktion erstellt Verwendung fuer Lehrtaetigkeiten fuer freie Lektoren. + * @param object $bisverwendung + * @return object Verwendung fuer Lehrtaetigkeit + */ +function _addVerwendung_fuerLehre_Stundenbasis($bisverwendung) +{ + $verwendung_lehre_obj = new StdClass(); + + $verwendung_lehre_obj->ba1code = $bisverwendung->ba1code; + $verwendung_lehre_obj->ba2code = $bisverwendung->ba2code; + $verwendung_lehre_obj->beschausmasscode = $bisverwendung->beschausmasscode; + $verwendung_lehre_obj->verwendung_code = 1; + $verwendung_lehre_obj->beginn_imBISMeldungsJahr =$bisverwendung->beginn_imBISMeldungsJahr; + $verwendung_lehre_obj->ende_imBISMeldungsJahr = $bisverwendung->ende_imBISMeldungsJahr; + + return $verwendung_lehre_obj; +} + + From 3d663cdbd715534210d6775a822cc32f6a4e2c14 Mon Sep 17 00:00:00 2001 From: Cris Date: Thu, 5 Mar 2020 14:29:56 +0100 Subject: [PATCH 110/138] Added getVerwendungenBISMeldung() + isHabilitiert() . getVerwendungenBISMeldung: Holt alle Verwendungen eines Mitarbeiters innerhalb des BIS Meldungszeitraums . isHabilitiert: Prueft, ob Mitarbeiter habilitiert ist --- include/bisverwendung.class.php | 91 +++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/include/bisverwendung.class.php b/include/bisverwendung.class.php index 0e4e4fc06..ab8b5a4e4 100644 --- a/include/bisverwendung.class.php +++ b/include/bisverwendung.class.php @@ -587,5 +587,96 @@ class bisverwendung extends basis_db return false; } } + + /** + * Prueft, ob Mitarbeiter habilitiert ist + * @param $uid UID des Mitarbeiters + * @return bool + */ + public function isHabilitiert($uid) + { + $qry = ' + SELECT + * + FROM + bis.tbl_bisverwendung + WHERE + mitarbeiter_uid = '. $this->db_add_param($uid). ' + AND + habilitation = true; + '; + + if ($this->db_query($qry)) + { + return $this->db_num_rows() > 0; + } + } + + /** + * Holt alle Verwendungen eines Mitarbeiters innerhalb des BIS Meldungszeitraums + * @param $uid UID des Mitarbeiters + * @param $stichtag + * @return bool + */ + public function getVerwendungenBISMeldung($uid, $stichtag) + { + $datetime = new DateTime($stichtag); + $stichtag = $datetime->format('Y-m-d'); + $bismeldung_jahr = $datetime->format('Y'); + + $qry = ' + SELECT + *, + CASE + WHEN (beginn is null OR beginn < make_date('. $this->db_add_param($bismeldung_jahr). '::INTEGER, 1, 1)) + THEN make_date('. $this->db_add_param($bismeldung_jahr). '::INTEGER, 1, 1) + ELSE beginn + END as beginn_imBISMeldungsJahr, + CASE + WHEN (ende is null OR ende > make_date('. $this->db_add_param($bismeldung_jahr). '::INTEGER, 12, 31)) + THEN make_date('. $this->db_add_param($bismeldung_jahr). '::INTEGER, 12, 31) + ELSE ende + END as ende_imBISMeldungsJahr + FROM + bis.tbl_bisverwendung + WHERE + mitarbeiter_uid = '. $this->db_add_param($uid).' + AND (beginn <= '. $this->db_add_param($stichtag).' OR beginn is null) + AND (ende >= make_date('. $this->db_add_param($bismeldung_jahr). '::INTEGER, 1, 1) OR ende is null) + ORDER BY ende + '; + + if($this->db_query($qry)) + { + while($row = $this->db_fetch_object()) + { + $obj = new StdClass(); + + $obj->bisverwendung_id = $row->bisverwendung_id; + $obj->mitarbeiter_uid = $row->mitarbeiter_uid; + $obj->vertragsstunden = $row->vertragsstunden; + $obj->ba1code = $row->ba1code; + $obj->ba2code = $row->ba2code; + $obj->verwendung_code = $row->verwendung_code; + $obj->beschausmasscode = $row->beschausmasscode; + $obj->hauptberufcode = $row->hauptberufcode; + $obj->hauptberuflich = $this->db_parse_bool($row->hauptberuflich); + $obj->beginn = $row->beginn; + $obj->ende = $row->ende; + $obj->beginn_imBISMeldungsJahr = $row->beginn_imbismeldungsjahr; + $obj->ende_imBISMeldungsJahr = $row->ende_imbismeldungsjahr; + + + + $this->result[] = $obj; + } + return true; + } + else + { + $this->errormsg = 'Fehler bei der Datenbankabfrage'; + return false; + } + } } ?> From afb5cc3205c56f6684e59cb8925b07ccdc9b1091 Mon Sep 17 00:00:00 2001 From: Cris Date: Thu, 5 Mar 2020 14:31:20 +0100 Subject: [PATCH 111/138] Added getMitarbeiterBISMeldung() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit getMitarbeiterBISMeldung: Gibt alle Mitarbeiter zurück, die im BIS Meldungszeitraum bisgemeldet sind --- include/mitarbeiter.class.php | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/include/mitarbeiter.class.php b/include/mitarbeiter.class.php index 467bff8f8..78bc1a439 100644 --- a/include/mitarbeiter.class.php +++ b/include/mitarbeiter.class.php @@ -1539,5 +1539,56 @@ class mitarbeiter extends benutzer } } + /** + * Gibt alle Mitarbeiter zurück, die im BIS Meldungszeitraum bisgemeldet sind + * @param String $stichtag BIS Meldung Stichtag + * @return boolean + */ + public function getMitarbeiterBISMeldung($stichtag) + { + $datetime = new DateTime($stichtag); + $bismeldung_jahr = $datetime->format('Y'); + + $qry = ' + SELECT DISTINCT ON (UID) *, + transform_geschlecht(tbl_person.geschlecht, tbl_person.gebdatum) as geschlecht_imputiert + FROM + public.tbl_mitarbeiter + JOIN public.tbl_benutzer ON(mitarbeiter_uid=uid) + JOIN public.tbl_person USING(person_id) + JOIN bis.tbl_bisverwendung USING(mitarbeiter_uid) + JOIN bis.tbl_beschaeftigungsausmass USING(beschausmasscode) + WHERE + bismelden + AND personalnummer > 0 + AND (beginn <= make_date('. $this->db_add_param($bismeldung_jahr). '::INTEGER, 12, 31) OR beginn is null) + AND (tbl_bisverwendung.ende is NULL OR tbl_bisverwendung.ende >= make_date('. $this->db_add_param($bismeldung_jahr). '::INTEGER, 1, 1)) + ORDER BY uid, nachname, vorname + '; + + if($result = $this->db_query($qry)) + { + while($row = $this->db_fetch_object($result)) + { + $obj = new StdClass(); + + $obj->uid = $row->uid; + $obj->vorname = $row->vorname; + $obj->vornamen = $row->vornamen; + $obj->nachname = $row->nachname; + $obj->gebdatum = $row->gebdatum; + $obj->geschlecht = $row->geschlecht; + $obj->geschlechtX = $row->geschlecht_imputiert; + $obj->staatsbuergerschaft = $row->staatsbuergerschaft; + $obj->personalnummer = $row->personalnummer; + $obj->ausbildungcode = $row->ausbildungcode; + + $this->result []= $obj; + } + return true; + } + return false; + } + } ?> From da201df53430b1250f3461c75400297fe45ed5c3 Mon Sep 17 00:00:00 2001 From: Cris Date: Mon, 9 Mar 2020 12:23:47 +0100 Subject: [PATCH 112/138] Added Berechnung fuer Studentische Hilfskraefte Die Jahres-/Vollzeitaequivalenz fuer Studentische Hilfskraefte werden ueber eine kalkulatorische Stundenpauschale berechnet. --- vilesci/bis/personalmeldung.php | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/vilesci/bis/personalmeldung.php b/vilesci/bis/personalmeldung.php index 2f5745dd7..c41c3fdd8 100644 --- a/vilesci/bis/personalmeldung.php +++ b/vilesci/bis/personalmeldung.php @@ -9,6 +9,7 @@ require_once('../../include/bisverwendung.class.php'); require_once('../../include/mitarbeiter.class.php'); require_once('../../include/studiengang.class.php'); require_once('../../include/lehreinheitmitarbeiter.class.php'); +require_once('../../include/benutzerfunktion.class.php'); $uid = get_uid(); @@ -46,6 +47,11 @@ if (!defined('BIS_HALBJAHRES_GEWICHTUNG_SWS') || empty('BIS_HALBJAHRES_GEWICHTUN die('config var BIS_HALBJAHRES_GEWICHTUNG_SWS fehlt'); } +if (!defined('BIS_PAUSCHALE_STUDENTISCHE_HILFSKRAFT') || empty('BIS_PAUSCHALE_STUDENTISCHE_HILFSKRAFT')) +{ + die('config var BIS_PAUSCHALE_STUDENTISCHE_HILFSKRAFT fehlt'); +} + // Prüfe Zeitraum zur Erstellung einer BIS-Meldung $studiensemester = new studiensemester(); @@ -68,6 +74,7 @@ $beginn_imJahr = new DateTime(($jahr - 1). '-01-01'); $ende_imJahr = new DateTime(($jahr - 1). '-12-31'); $tage_imJahr = $ende_imJahr->diff($beginn_imJahr)->days + 1; +$wochen_imJahr = $tage_imJahr / 7; // Sommer- und Wintersemester im BIS Meldungsjahr $ss_kurzbz = $studiensemester->getBeforePrevious(); @@ -252,6 +259,36 @@ foreach ($mitarbeiter_arr as $mitarbeiter) } } } + else + { + // Studentische Hilfskraft + // --------------------------------------------------------------------------------------------------------- + $benutzerfunktion = new Benutzerfunktion(); + $is_studentische_hilfskraft = $benutzerfunktion->getBenutzerFunktionByUid( + $person_obj->uid, + 'hilfskraft', + $beginn_imJahr->format('Y-m-d'), + $ende_imJahr->format('Y-m-d') + ); + + if ($is_studentische_hilfskraft) + { + // Kalkulatorische Umrechnung der Jahrespauschale + $pauschale_hilfskraft_inStunden = BIS_PAUSCHALE_STUDENTISCHE_HILFSKRAFT; // Pauschale pro Jahr und Person (in Stunden) + $pauschale_hilfskraft_relativImJahr = $pauschale_hilfskraft_inStunden / 1; // Stundenpauschale in Verhaeltnis zu 1 Jahr + $vollzeit_arbeitsstunden_imJahr = BIS_VOLLZEIT_ARBEITSSTUNDEN * $wochen_imJahr; + + // Relatives Beschaeftigungsausmass / Anteilige JVZAE ermitteln + $bisverwendung->beschaeftigungsausmass_relativ = round($pauschale_hilfskraft_relativImJahr / $vollzeit_arbeitsstunden_imJahr, 4); + $bisverwendung->jvzae_anteilig =round($pauschale_hilfskraft_relativImJahr / $vollzeit_arbeitsstunden_imJahr, 4); + } + // Mitarbeiter ohne Vertragsstunden und keine SWS + // --------------------------------------------------------------------------------------------------------- + else + { + // TODO: Plausicheck + } + } } // ***************************************************************************************************************** From 40915ba3e160c3c6cdd31fb1442a64e2fa912bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Tue, 10 Mar 2020 16:36:21 +0100 Subject: [PATCH 113/138] =?UTF-8?q?Neue=20Funktionen=20f=C3=BCr=20BIS-Meld?= =?UTF-8?q?ung=20erg=C3=A4nzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- system/dbupdate_3.3.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index 2700bf43d..00d075dfd 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -3616,6 +3616,12 @@ if (!$result = @$db->db_query("SELECT ba1code_bis FROM bis.tbl_beschaeftigungsar DELETE FROM bis.tbl_verwendung WHERE verwendung_code=9; "; + $qry.=" + INSERT INTO public.tbl_funktion(funktion_kurzbz, beschreibung, aktiv, fachbereich, semester) VALUES('vertrBefugter','Vertretungsbefugte/r des Erhalters',true,false,false); + INSERT INTO public.tbl_funktion(funktion_kurzbz, beschreibung, aktiv, fachbereich, semester) VALUES('kollegium_Ltg','Leiter/in des Kollegiums',true,false,false); + INSERT INTO public.tbl_funktion(funktion_kurzbz, beschreibung, aktiv, fachbereich, semester) VALUES('kollegium_stvLtg','Stellv. Leiter/in des Kollegiums',true,false,false); + "; + if(!$db->db_query($qry)) echo 'bis.tbl_verwendung und bis.tbl_beschaeftigungsart: '.$db->db_last_error().'
'; else From 2df57dd019f8bb925e6aacf967cc6b4ff6438295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Tue, 10 Mar 2020 16:41:01 +0100 Subject: [PATCH 114/138] Fixed Syntax Error in Message API --- application/controllers/api/v1/system/Message.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/controllers/api/v1/system/Message.php b/application/controllers/api/v1/system/Message.php index 5c663e832..1825b7db9 100644 --- a/application/controllers/api/v1/system/Message.php +++ b/application/controllers/api/v1/system/Message.php @@ -149,10 +149,10 @@ class Message extends APIv1_Controller if (isSuccess($postMessage)) { $result = $this->messagelib->sendMessageUser( - $this->post()['receiver_id']), // receiverPersonId + $this->post()['receiver_id'], // receiverPersonId $this->post()['subject'], // subject $this->post()['body'], // body - $this->post()['person_id']) ? $this->post()['person_id'] : null, // sender_id + $this->post()['person_id'] ? $this->post()['person_id'] : null, // sender_id isset($this->post()['oe_kurzbz']) ? $this->post()['oe_kurzbz'] : null, // senderOU isset($this->post()['relationmessage_id']) ? $this->post()['relationmessage_id'] : null, // relationmessage_id MSG_PRIORITY_NORMAL, // priority From 505dba7f4c2bffea392d918d7c31d533d7451dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Tue, 10 Mar 2020 16:42:22 +0100 Subject: [PATCH 115/138] Added Inbox/Outbox Link to CI Page --- application/config/navigation.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/application/config/navigation.php b/application/config/navigation.php index 9253c87a1..a89c259ee 100644 --- a/application/config/navigation.php +++ b/application/config/navigation.php @@ -72,11 +72,18 @@ $config['navigation_header'] = array( 'sort' => 40, 'requiredPermissions' => 'basis/vilesci:r', 'children'=> array( + 'messages' => array( + 'link' => site_url('system/messages/MessageClient/read'), + 'icon' => '', + 'target' => '_blank', + 'description' => 'Messages', + 'sort' => 10, + ), 'bpk' => array( 'link' => site_url('person/BPKWartung'), 'icon' => '', 'description' => 'BPK Wartung', - 'sort' => 10, + 'sort' => 20, 'requiredPermissions' => 'admin:r' ) ) From e8460f03c19b6ccc2a44ecfde346a25e8c708302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Tue, 10 Mar 2020 16:56:00 +0100 Subject: [PATCH 116/138] Fixed Syntax Error in Phrases Page --- application/controllers/system/Phrases.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/system/Phrases.php b/application/controllers/system/Phrases.php index f589eaeb2..2bb003567 100644 --- a/application/controllers/system/Phrases.php +++ b/application/controllers/system/Phrases.php @@ -161,7 +161,7 @@ class Phrases extends Auth_Controller $phrase_inhalt = $this->phraseslib->insertPhraseinhalt($data); if ($phrase_inhalt->error) - show_error(getError($phrase_inhalt); + show_error(getError($phrase_inhalt)); $phrase_inhalt_id = $phrase_inhalt->retval; From 72c2ce6410a1e0ed43154a6cdb7587f43229359f Mon Sep 17 00:00:00 2001 From: Cris Date: Wed, 11 Mar 2020 14:42:07 +0100 Subject: [PATCH 117/138] Added Container Funktion . FunktionsCode . BesondereQualifikationsCode . Studiengang - StgKz --- vilesci/bis/personalmeldung.php | 191 ++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) diff --git a/vilesci/bis/personalmeldung.php b/vilesci/bis/personalmeldung.php index c41c3fdd8..5bd0a0e89 100644 --- a/vilesci/bis/personalmeldung.php +++ b/vilesci/bis/personalmeldung.php @@ -10,6 +10,8 @@ require_once('../../include/mitarbeiter.class.php'); require_once('../../include/studiengang.class.php'); require_once('../../include/lehreinheitmitarbeiter.class.php'); require_once('../../include/benutzerfunktion.class.php'); +require_once('../../include/organisationseinheit.class.php'); +require_once('../../include/entwicklungsteam.class.php'); $uid = get_uid(); @@ -52,6 +54,21 @@ if (!defined('BIS_PAUSCHALE_STUDENTISCHE_HILFSKRAFT') || empty('BIS_PAUSCHALE_ST die('config var BIS_PAUSCHALE_STUDENTISCHE_HILFSKRAFT fehlt'); } +if (!defined('BIS_FUNKTIONSCODE_1234_ARR') || empty('BIS_FUNKTIONSCODE_1234_ARR')) +{ + die('config var BIS_FUNKTIONSCODE_1234_ARR fehlt'); +} + +if (!defined('BIS_FUNKTIONSCODE_5_ARR') || empty('BIS_FUNKTIONSCODE_5_ARR')) +{ + die('config var BIS_FUNKTIONSCODE_5_ARR fehlt'); +} + +if (!defined('BIS_FUNKTIONSCODE_6_ARR') || empty('BIS_FUNKTIONSCODE_6_ARR')) +{ + die('config var BIS_FUNKTIONSCODE_6_ARR fehlt'); +} + // Prüfe Zeitraum zur Erstellung einer BIS-Meldung $studiensemester = new studiensemester(); @@ -366,6 +383,43 @@ foreach ($mitarbeiter_arr as $mitarbeiter) // Container Verwendung dem Container Person anhaengen // ----------------------------------------------------------------------------------------------------------------- $person_obj->verwendung_arr = $verwendung_arr; + + + // ********************************************************************************************************************* + // Container Funktion und Lehre werden nur für STG generiert (nicht für Lehrgaenge) + // ********************************************************************************************************************* + // ----------------------------------------------------------------------------------------------------------------- + // Container Funktion generieren + // ----------------------------------------------------------------------------------------------------------------- + $funktion_arr = array(); + + // Alle Benutzerfunktionen im BIS Meldungsjahr holen + $benutzerfunktion = new Benutzerfunktion(); + $benutzerfunktion->getBenutzerFunktionByUid( + $person_obj->uid, null, + $beginn_imJahr->format('Y-m-d'), + $ende_imJahr->format('Y-m-d') + ); + $bisfunktion_arr = $benutzerfunktion->result; + + /** + * Funktionscode 1 - 6 anhand Benutzerfunktionen ermitteln + * Exkludiert Funktionen, die einem Lehrgang bzw. STG, die nicht BIS-gemeldet werden, zugeordnet sind. + */ + // ------------------------------------------------------------------------------------------------------------- + $funktion_arr = _getFunktionscontainer_Funktionscode123456($bisfunktion_arr); + + /** + * Funktionscode 7 aus Entwicklungsteam-Tabelle ermitteln + * Exkludiert Funktionen, die einem Lehrgang bzw. STG, die nicht BIS-gemeldet werden, zugeordnet sind. + */ + // ------------------------------------------------------------------------------------------------------------- + $funktion_arr = _addFunktionscontainer_Funktionscode7($person_obj->uid, $funktion_arr); + + // Container Funktion dem Container Person anhaengen + // ----------------------------------------------------------------------------------------------------------------- + $person_obj->funktion_arr = $funktion_arr; + $person_arr []= $person_obj; } @@ -477,4 +531,141 @@ function _addVerwendung_fuerLehre_Stundenbasis($bisverwendung) return $verwendung_lehre_obj; } +/** + * Funktionscode 1 - 6 anhand Benutzerfunktionen ermitteln + * @param array $bisfunktion_arr + * @return array + */ +function _getFunktionscontainer_Funktionscode123456($bisfunktion_arr) +{ + $funktion_arr = array(); + + foreach ($bisfunktion_arr as $bisfunktion) + { + $funktion_code = NULL; + $has_oe_lehrgang = false; // default + + $studiengang = new Studiengang(); + $studiengang->getStudiengangFromOe($bisfunktion->oe_kurzbz); + + // Wenn OE der Funktion eine STG-Kennzahl ist + if (!is_null($studiengang->studiengang_kz)) + { + // Pruefen ob STG-Kennzahl STG oder Lehrgang + $has_oe_lehrgang = !($studiengang->studiengang_kz > 0 && $studiengang->studiengang_kz < 10000); + + // STG, die nicht BIS-bemeldet werden, ueberspringen + if (in_array($studiengang->studiengang_kz, BIS_EXCLUDE_STG)) + { + continue; + } + } + + // Funktionscode 1 - 6 anhand Benutzerfunktionen ermitteln + // ------------------------------------------------------------------------------------------------------------- + // Wenn OE der Funktion nicht einem Lehrgang zugeordnet ist + if (!$has_oe_lehrgang) + { + // FunktionsCode 1-4 + if (array_key_exists($bisfunktion->funktion_kurzbz, BIS_FUNKTIONSCODE_1234_ARR)) + { + $funktion_code = BIS_FUNKTIONSCODE_1234_ARR[$bisfunktion->funktion_kurzbz]; + } + + if (in_array($bisfunktion->funktion_kurzbz, BIS_FUNKTIONSCODE_5_ARR)) // Leitung + { + // FunktionsCode 5 : STG-Leitung + if (!is_null($studiengang->studiengang_kz)) + { + $funktion_code = 5; + } + + // FunktionsCode 6 : Leitung Organisationseinheit der postsekundaeren Bildungseinrichtung + $organisationseinheit = new Organisationseinheit($bisfunktion->oe_kurzbz); + if (is_null($studiengang->studiengang_kz) && + !in_array($organisationseinheit->oetyp_bezeichnung, BIS_FUNKTIONSCODE_6_ARR)) // nicht Teamleitung + { + $funktion_code = 6; + } + } + } + + // Funktionsobjekt generieren + if (!is_null($funktion_code) && // Funktionscode vorhanden UND + (empty($funktion_arr) || // (Erster Durchlauf ODER + !in_array($funktion_code, array_column($funktion_arr, 'funktionscode')))) // Funktionsobjekt mit diesem Funktionscode nicht vorhanden) + { + $funktion_obj = new StdClass(); + $funktion_obj->funktionscode = $funktion_code; + $funktion_obj->besondereQualifikationCode = NULL; + $funktion_obj->studiengang = ($funktion_code == 5) + ? array(setLeadingZero(intval($studiengang->studiengang_kz), 4)) // STG bei Funktionscode 5 melden + : NULL; + + // Funktionsobjekt dem Funktionscontainer anhaengen + $funktion_arr []= $funktion_obj; + } + else if ($funktion_code == 5) // Funktionscontainer vorhanden und Funktionscode 5 + { + $funktion_obj_arr = array_filter($funktion_arr, function (&$obj) { + return $obj->funktionscode == 5; + }); + + $funktion_obj_arr[0]->studiengang[]= setLeadingZero(intval($studiengang->studiengang_kz), 4); // STG ergaenzen + } + } + + return $funktion_arr; +} + +/** + * Funktionscode 7 aus Entwicklungsteam-Tabelle ermitteln + * @param String $uid + * @param array $funktion_arr Object-Array + * @return array + * + */ +function _addFunktionscontainer_Funktionscode7($uid, $funktion_arr) +{ + $entwicklungsteam = new Entwicklungsteam(); + $entwicklungsteam->getEntwicklungsteam($uid); + $entwicklungsteam_arr = $entwicklungsteam->result; + + if (!empty($entwicklungsteam_arr)) + { + // Lehrgaenge und STG, die nicht BIS gemeldet werden, extrahieren + $entwicklungsteam_arr = array_filter($entwicklungsteam_arr, function ($obj) + { + return + !in_array($obj->studiengang_kz, BIS_EXCLUDE_STG) && + $obj->studiengang_kz > 0 && + $obj->studiengang_kz < 10000; + }); + } + + if (!empty($entwicklungsteam_arr)) + { + // Hoechste besondere Qualifikation + $besondere_qualifikation_code_arr = array_values(array_column($entwicklungsteam_arr, 'besqualcode')); + $besondere_qualifikation_code = max($besondere_qualifikation_code_arr); + + // Studiengaenge, wo Person Teil des Entwicklungsteams gewesen ist + $studiengang_kz_arr = array_values(array_column($entwicklungsteam_arr, 'studiengang_kz')); + sort($studiengang_kz_arr); // sortieren + foreach($studiengang_kz_arr as &$studiengang_kz) // fuehrende Nullen fuer STG + { + $studiengang_kz = setLeadingZero(intval($studiengang_kz), 4); + } + + // Funktionsobjekt generieren und dem Funktionscontainer anhaengen + $funktion_obj = new StdClass(); + $funktion_obj->funktionscode = 7; + $funktion_obj->besondereQualifikationCode = $besondere_qualifikation_code; + $funktion_obj->studiengang = $studiengang_kz_arr; + $funktion_arr []= $funktion_obj; + } + + return $funktion_arr; +} + From a5884127f7f933ccf01efa782db463c897137c86 Mon Sep 17 00:00:00 2001 From: Cris Date: Wed, 11 Mar 2020 14:54:09 +0100 Subject: [PATCH 118/138] Corrected Realtives Beschaeftigungsausmass Fuer Verwendungen von angestellten Personen in der Admin/Verwaltung, jedoch mit Lehrtaetigkeit, werden fuer die Lehre eigene Verwendungen mit Verwendungscode 1 erstellt. Das relative Beschaeftigungsausmass muss dann entsprechend angepasst werden. Zuvor wurden dem rel BA der Hauptverwendung die rel BA von Sommer- und Wintersemester abgezogen. Fuer die richtige Berechnung der VZAE darf jedoch nur das rel BA Wintersemester abgezogen werden. (Faellt in den Stichtag 31.12) --- vilesci/bis/personalmeldung.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vilesci/bis/personalmeldung.php b/vilesci/bis/personalmeldung.php index 5bd0a0e89..a6fde06ea 100644 --- a/vilesci/bis/personalmeldung.php +++ b/vilesci/bis/personalmeldung.php @@ -241,8 +241,13 @@ foreach ($mitarbeiter_arr as $mitarbeiter) /** * Relativen Beschaeftigungsausmass der BIS-Verwendung berichtigen * (durch Abzug des eben erstellten relativen Beschaeftigungsausmass fuer Lehrtaetigkeiten) + * NOTE: Abzug nur fuer Lehrtaetigkeiten im WS, da nur diese das Beschaeftigungsausmass der + * BIS-Verwendung (und in Folge die VZAE ) zum Stichtag 31.12. bestimmen. * */ - $bisverwendung->beschaeftigungsausmass_relativ -= $verwendung_lehre_obj->beschaeftigungsausmass_relativ; + if(substr($studsem_kurzbz, 0, 2) == 'WS') + { + $bisverwendung->beschaeftigungsausmass_relativ -= $verwendung_lehre_obj->beschaeftigungsausmass_relativ; + } /** * Anteilige JVZAE der BIS-Verwendung berichtigen From 9c8312f880b978c84f7cfc9256dd899a5c590370 Mon Sep 17 00:00:00 2001 From: Cris Date: Thu, 12 Mar 2020 13:20:30 +0100 Subject: [PATCH 119/138] Added Lehre-Container Lehrecontainer mit . StgKz . SommersemesterSWS . WintersemesterSWS Lehrtaetigkeit an Lehrgaengen bzw. Lehrtaetigkeit an STG, die nicht BIS-gemeldet werden, werden exkludiert. --- vilesci/bis/personalmeldung.php | 92 +++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/vilesci/bis/personalmeldung.php b/vilesci/bis/personalmeldung.php index a6fde06ea..6437f24a5 100644 --- a/vilesci/bis/personalmeldung.php +++ b/vilesci/bis/personalmeldung.php @@ -425,6 +425,34 @@ foreach ($mitarbeiter_arr as $mitarbeiter) // ----------------------------------------------------------------------------------------------------------------- $person_obj->funktion_arr = $funktion_arr; + + // ----------------------------------------------------------------------------------------------------------------- + // Container Lehre generieren + // ----------------------------------------------------------------------------------------------------------------- + $lehre_arr = array(); + + // Alle Semesterwochenstunden, summiert nach STG und Studiensemester + $lehreinheitmitarbeiter = new Lehreinheitmitarbeiter(); + $lehreinheitmitarbeiter->get_SWS_groupByStg( + $person_obj->uid, + $beginn_imJahr->format('Y-m-d'), + $ende_imJahr->format('Y-m-d') + ); + $sws_proStg_arr = $lehreinheitmitarbeiter->result; + + /** + * Lehrtaetigkeit (Semesterwochenstunden) pro STG ermitteln. + * Exkludiert Lehrtaetigkeit an Lehrgaengen bzw. Lehrtaetigkeit an STG, die nicht BIS-gemeldet werden. + */ + $lehre_arr = _getLehrecontainer($sws_proStg_arr); + + // Container Lehre dem Container Person anhaengen + // ----------------------------------------------------------------------------------------------------------------- + $person_obj->lehre_arr = $lehre_arr; + + + // Container Person dem Gesamt-Container anhaengen + // ----------------------------------------------------------------------------------------------------------------- $person_arr []= $person_obj; } @@ -673,4 +701,68 @@ function _addFunktionscontainer_Funktionscode7($uid, $funktion_arr) return $funktion_arr; } +/** + * Lehrecontainer fuer Lehrtaetigkeit (Semesterwochenstunden) pro STG erstellen. + * @param array $sws_proStg_arr Object-Array + * @return array + */ +function _getLehrecontainer($sws_proStg_arr) +{ + $lehre_arr = array(); + + if (!empty($sws_proStg_arr)) + { + // Lehrgaenge und STG, die nicht BIS gemeldet werden, extrahieren + $sws_proStg_arr = array_filter($sws_proStg_arr, function ($obj) + { + return + !in_array($obj->studiengang_kz, BIS_EXCLUDE_STG) && + $obj->studiengang_kz > 0 && + $obj->studiengang_kz < 10000; + }); + } + + if (!empty($sws_proStg_arr)) + { + foreach ($sws_proStg_arr as $sws_proStg) + { + $is_sommersemester = substr($sws_proStg->studiensemester_kurzbz, 0, 2) == 'SS'; + $is_wintersemester = substr($sws_proStg->studiensemester_kurzbz, 0, 2) == 'WS'; + + // Lehreobjekt generieren + if (empty($lehre_arr) || // Erster Durchlauf ODER + !in_array($sws_proStg->studiengang_kz, array_column($lehre_arr, 'StgKz'))) // Neu + { + $lehre_obj = new StdClass(); + + $lehre_obj->StgKz = $sws_proStg->studiengang_kz; + $lehre_obj->SommersemesterSWS = $is_sommersemester ? $sws_proStg->sws : NULL; + $lehre_obj->WintersemesterSWS = $is_wintersemester ? $sws_proStg->sws : NULL; + + // Lehreobjekt dem Lehrecontainer anhaengen + $lehre_arr []= $lehre_obj; + } + else // Lehrecontainer mit STG schon vorhanden + { + $lehre_obj_arr = array_filter($lehre_arr, function (&$obj) use ($sws_proStg) { + return $obj->StgKz == $sws_proStg->studiengang_kz; + }); + + // SWS ergaenzen + if ($is_sommersemester) + { + current($lehre_obj_arr)->SommersemesterSWS = $sws_proStg->sws; + } + else if ($is_wintersemester) + { + current($lehre_obj_arr)->WintersemesterSWS = $sws_proStg->sws; + } + } + } + } + + + return $lehre_arr; +} + From 588f2996b3f71207f1bbe42d1cce137448654592 Mon Sep 17 00:00:00 2001 From: Cris Date: Thu, 12 Mar 2020 13:22:57 +0100 Subject: [PATCH 120/138] Added get_SWS_groupByStg() Ladet Semesterwochenstunden-Summe gruppiert nach Studiengang und Studiensemester. Es werden die Studiensemester herangezogen, die im Zeitraum zwischen beginn und ende beginnen. --- include/lehreinheitmitarbeiter.class.php | 68 ++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/include/lehreinheitmitarbeiter.class.php b/include/lehreinheitmitarbeiter.class.php index d7d469c2f..64140a174 100644 --- a/include/lehreinheitmitarbeiter.class.php +++ b/include/lehreinheitmitarbeiter.class.php @@ -530,6 +530,74 @@ class lehreinheitmitarbeiter extends basis_db } } + /** + * Ladet Semesterwochenstunden-Summe gruppiert nach Studiengang und Studiensemester. + * Es werden die Studiensemester herangezogen, die im Zeitraum zwischen beginn und ende beginnen. + * @param String $uid + * @param String $beginn + * @param String $ende + * @return bool + */ + public function get_SWS_groupByStg($uid, $beginn, $ende) + { + $beginn = new DateTime($beginn); + $ende = new DateTime($ende); + + $qry = ' + WITH semester_sws_tbl AS ( + SELECT DISTINCT lehreinheit_id, studiensemester_kurzbz, lema.semesterstunden, stg.studiengang_kz + FROM lehre.tbl_lehreinheitmitarbeiter lema + JOIN lehre.tbl_lehreinheit USING (lehreinheit_id) + JOIN lehre.tbl_lehrveranstaltung lv USING (lehrveranstaltung_id) + JOIN lehre.tbl_studienplan_lehrveranstaltung USING (lehrveranstaltung_id) + JOIN lehre.tbl_studienplan USING (studienplan_id) + JOIN lehre.tbl_studienordnung sto USING (studienordnung_id) + JOIN public.tbl_studiengang stg ON stg.studiengang_kz = sto.studiengang_kz + JOIN public.tbl_studiensemester ss USING (studiensemester_kurzbz) + WHERE mitarbeiter_uid = '. $this->db_add_param($uid). ' + AND ( + ss.start BETWEEN + '. $this->db_add_param($beginn->format('Y-m-d')). ' AND + '. $this->db_add_param($ende->format('Y-m-d')). ') + -- nur lehre, die bisgemeldet wird + AND lema.bismelden + -- keine lehreinheiten ohne semesterstunden + AND lema.semesterstunden != 0 + ) + + SELECT + studiengang_kz, + studiensemester_kurzbz, + sum(semesterstunden) AS summe, + round(sum(semesterstunden) / 15, 2) AS sws + FROM + semester_sws_tbl + GROUP BY + studiengang_kz, + studiensemester_kurzbz + ORDER BY + studiengang_kz; + '; + + if ($this->db_query($qry)) + { + while($row = $this->db_fetch_object()) + { + $obj = new StdClass(); + $obj->studiengang_kz = $row->studiengang_kz; + $obj->studiensemester_kurzbz = $row->studiensemester_kurzbz; + $obj->sws = $row->sws; + $this->result []= $obj; + } + return true; + } + else + { + $this->errormsg = 'Fehler bei der Datenbankabfrage'; + return false; + } + } + /** * Laedt die Lektoren einer Lehrveranstaltung in einem Studiensemester * @param lehrveranstaltung_id From a03e3f3355793ca1e4095ad3bb8cd41f4686adc2 Mon Sep 17 00:00:00 2001 From: Cris Date: Thu, 12 Mar 2020 13:24:17 +0100 Subject: [PATCH 121/138] Added result array to properties of Lehreinheitmitarbeiter class --- include/lehreinheitmitarbeiter.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/lehreinheitmitarbeiter.class.php b/include/lehreinheitmitarbeiter.class.php index 64140a174..9941a7e12 100644 --- a/include/lehreinheitmitarbeiter.class.php +++ b/include/lehreinheitmitarbeiter.class.php @@ -44,6 +44,8 @@ class lehreinheitmitarbeiter extends basis_db public $ext_id; // bigint public $vertrag_id; + public $result = array(); + /** * Konstruktor - Laedt optional einee LEMitarbeiterzuordnung * @param $lehreinheit_id From 67a100ea50d2a9e1854d83df1e22d3f3abd2ad86 Mon Sep 17 00:00:00 2001 From: Cris Date: Thu, 12 Mar 2020 13:29:48 +0100 Subject: [PATCH 122/138] Corrected BIS-meldungsrelevante SWS in getLehreinheiten_SWS_BISMeldung Zuvor wurde boolean bismelden der Mitarbeiter-Tabelle geprueft. Nun wird der korrekte boolean bismelden der Lehreinheitmitarbeiter-Tabelle geprueft, da nur die bisrelevanten Lehreinheiten herangezogen werden sollen. --- include/lehreinheitmitarbeiter.class.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/lehreinheitmitarbeiter.class.php b/include/lehreinheitmitarbeiter.class.php index 9941a7e12..6be66bb77 100644 --- a/include/lehreinheitmitarbeiter.class.php +++ b/include/lehreinheitmitarbeiter.class.php @@ -497,6 +497,13 @@ class lehreinheitmitarbeiter extends basis_db return $ret; } + /** + * Ladet Semesterwochenstunden-Summe eines Mitarbeiters eines Semesters. + * Nur bisrelevante SWS. + * @param String $uid + * @param String $studiensemester + * @return bool + */ public function getLehreinheiten_SWS_BISMeldung($uid, $studiensemester) { $qry = ' @@ -504,7 +511,7 @@ class lehreinheitmitarbeiter extends basis_db round(sum(semesterstunden) / 15) AS sws FROM ( SELECT DISTINCT lehreinheit_id, studiensemester_kurzbz, mitarbeiter_uid, semesterstunden - FROM lehre.tbl_lehreinheitmitarbeiter + FROM lehre.tbl_lehreinheitmitarbeiter lema JOIN public.tbl_mitarbeiter ma USING (mitarbeiter_uid) JOIN public.tbl_benutzer ON (mitarbeiter_uid = uid) JOIN public.tbl_person USING (person_id) @@ -512,7 +519,7 @@ class lehreinheitmitarbeiter extends basis_db JOIN lehre.tbl_lehreinheit USING (lehreinheit_id) JOIN public.tbl_studiensemester ss USING (studiensemester_kurzbz) WHERE mitarbeiter_uid = '. $this->db_add_param($uid).' - AND ma.bismelden + AND lema.bismelden AND studiensemester_kurzbz = '. $this->db_add_param($studiensemester).' ) tbl_semesterstunden '; From a65c5076be7243761844f994df2a4829ee5374f4 Mon Sep 17 00:00:00 2001 From: Cris Date: Thu, 12 Mar 2020 15:45:07 +0100 Subject: [PATCH 123/138] Started XML generieren - NOT COMPLETED - --- vilesci/bis/personalmeldung.php | 80 +++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/vilesci/bis/personalmeldung.php b/vilesci/bis/personalmeldung.php index 6437f24a5..324a181e8 100644 --- a/vilesci/bis/personalmeldung.php +++ b/vilesci/bis/personalmeldung.php @@ -456,6 +456,16 @@ foreach ($mitarbeiter_arr as $mitarbeiter) $person_arr []= $person_obj; } +// ********************************************************************************************************************* +// XML generieren +// ********************************************************************************************************************* +$xml = ''; +$xml = _generateXML($person_arr); + +echo '
', print_r($xml, 1), '
'; + + + // --------------------------------------------------------------------------------------------------------------------- // Private Functions // --------------------------------------------------------------------------------------------------------------------- @@ -765,4 +775,74 @@ function _getLehrecontainer($sws_proStg_arr) return $lehre_arr; } +function _generateXML($person_arr) +{ + $xml = ''; + $xml .= ''; + + $xml .= ''; + + foreach ($person_arr as $person) + { + $xml .= ''; + + $xml .= 'personalnummer. ']]>'; + $xml .= 'geschlecht. ']]>'; + $xml .= 'geschlechtX. ']]>'; + $xml .= 'geburtsjahr. ']]>'; + $xml .= 'staatsangehoerigkeit. ']]>'; + $xml .= 'hoechste_abgeschlossene_ausbildung. ']]>'; + $xml .= 'habilitation. ']]>'; + $xml .= 'hauptberufcode. ']]>'; + + foreach ($person->verwendung_arr as $verwendung) + { + $xml .= ''; + $xml .= 'verwendung_code. ']]>'; + $xml .= 'ba1code. ']]>'; + $xml .= 'ba2code. ']]>'; + $xml .= 'vzae. ']]>'; + $xml .= 'jvzae. ']]>'; + $xml .= ''; + } + + foreach ($person->funktion_arr as $funktion) + { + $xml .= ''; + $xml .= 'funktionscode. ']]>'; + $xml .= 'besondereQualifikationCode. ']]>'; + $xml .= ''; + if (is_array($funktion->studiengang)) + { + foreach ($funktion->studiengang as $studiengang) + { + $xml .= ''; + } + } + else if (!is_null($funktion->studiengang)) + { + $xml .= 'studiengang. ']]>'; + + } + $xml .= ''; + $xml .= ''; + } + + foreach ($person->lehre_arr as $lehre) + { + $xml .= ''; + $xml .= 'StgKz. ']]>'; + $xml .= 'SommersemesterSWS. ']]>'; + $xml .= 'WintersemesterSWS. ']]>'; + $xml .= ''; + } + + $xml .= ''; + } + + $xml .= ''; + + return $xml; +} + From 2767dcde9fc688fd1a26dc5490301d662c1937ca Mon Sep 17 00:00:00 2001 From: Cris Date: Thu, 12 Mar 2020 15:48:41 +0100 Subject: [PATCH 124/138] Added BIS configs --- config/vilesci.config-default.inc.php | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/config/vilesci.config-default.inc.php b/config/vilesci.config-default.inc.php index 1d68cfdb3..e737fc58a 100644 --- a/config/vilesci.config-default.inc.php +++ b/config/vilesci.config-default.inc.php @@ -208,4 +208,43 @@ define('DVB_PASSWORD','passwort'); define('CI_ENVIRONMENT', 'development'); // Code igniter environment variable +// BIS Personalmeldung + +// Studiengaenge, die nicht gemeldet werden +define('BIS_EXCLUDE_STG', array()); + +// Basis Vollzeit Arbeitsstunden für Berechnung von Jahresvollzeitaequivalenz JVZAE (echte Dienstverträge) +define('BIS_VOLLZEIT_ARBEITSSTUNDEN', '0'); + +// Basis Vollzeit Semesterwochenstunden für Berechnung von Jahresvollzeitaequivalenz JVZAE auf Stundenbasis (freie Dienstverträge) +define('BIS_VOLLZEIT_SWS_EINZELSTUNDENBASIS', '0'); + +// Basis Vollzeit Semesterwochenstunden für Berechnung von Jahresvollzeitaequivalenz JVZAE für inkludierte Lehre bei echten Dienstverträgen +define('BIS_VOLLZEIT_SWS_INKLUDIERTE_LEHRE', '0'); + +// Semester Gewichtung für Berechnung von Jahresvollzeitaequivalenz JVZAE +define('BIS_HALBJAHRES_GEWICHTUNG_SWS', 0.5); + +// Jahrespauschale fuer studentische Hilfskraefte (in Stunden) +define('BIS_PAUSCHALE_STUDENTISCHE_HILFSKRAFT', 0); + +// Jahrespauschale fuer sonstige Dienstverhaeltnisse, zb Werkvertrag (in Stunden) +define('BIS_PAUSCHALE_SONSTIGES_DIENSTVERHAELTNIS', 0); + +define('BIS_FUNKTIONSCODE_1234_ARR', array( + 'vertrBefugter' => 1, // Vertretungsbefugte/r des Erhalters (GF, Prokura) + 'kollegium_Ltg' => 2, // Leiter/in des Kollegiums + 'kollegium_Ltg' => 2, // Leiter/in des Kollegiums + 'kollegium_stvLtg' => 3, // stellv. Leiter/In des Kollegiums + 'kollegium' => 4 // Mitglied des Kollegiums +)); + +define('BIS_FUNKTIONSCODE_5_ARR', array( + 'Leitung' +)); + +define('BIS_FUNKTIONSCODE_6_ARR', array( + 'Team' +)); + ?> From c171ba3de67c340853e76068ba46e93ba5c4faa1 Mon Sep 17 00:00:00 2001 From: Cris Date: Thu, 12 Mar 2020 15:59:09 +0100 Subject: [PATCH 125/138] Added Berechnung Sonstiges Dienstverhaeltnis (zB. Werkvertraege) --- vilesci/bis/personalmeldung.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/vilesci/bis/personalmeldung.php b/vilesci/bis/personalmeldung.php index 324a181e8..06e7fcd52 100644 --- a/vilesci/bis/personalmeldung.php +++ b/vilesci/bis/personalmeldung.php @@ -54,6 +54,11 @@ if (!defined('BIS_PAUSCHALE_STUDENTISCHE_HILFSKRAFT') || empty('BIS_PAUSCHALE_ST die('config var BIS_PAUSCHALE_STUDENTISCHE_HILFSKRAFT fehlt'); } +if (!defined('BIS_PAUSCHALE_SONSTIGES_DIENSTVERHAELTNIS') || empty('BIS_PAUSCHALE_SONSTIGES_DIENSTVERHAELTNIS')) +{ + die('config var BIS_PAUSCHALE_SONSTIGES_DIENSTVERHAELTNIS fehlt'); +} + if (!defined('BIS_FUNKTIONSCODE_1234_ARR') || empty('BIS_FUNKTIONSCODE_1234_ARR')) { die('config var BIS_FUNKTIONSCODE_1234_ARR fehlt'); @@ -258,7 +263,6 @@ foreach ($mitarbeiter_arr as $mitarbeiter) } } } - // TODO: Interner Check: if ($bisverwendung->jvzae_anteilig < 0) -> Anteil für 'Nicht-Lehre'-Teil muss gegeben sein. } // Sonstige Beschaeftigungsverhaeltnisse ohne Vertragsstunden @@ -304,11 +308,17 @@ foreach ($mitarbeiter_arr as $mitarbeiter) $bisverwendung->beschaeftigungsausmass_relativ = round($pauschale_hilfskraft_relativImJahr / $vollzeit_arbeitsstunden_imJahr, 4); $bisverwendung->jvzae_anteilig =round($pauschale_hilfskraft_relativImJahr / $vollzeit_arbeitsstunden_imJahr, 4); } - // Mitarbeiter ohne Vertragsstunden und keine SWS + // Mitarbeiter mit sonstigem Dienstverhaeltnis (zB. Werkvertrag) // --------------------------------------------------------------------------------------------------------- else { - // TODO: Plausicheck + $pauschale_sonstigeDV_inStunden = BIS_PAUSCHALE_SONSTIGES_DIENSTVERHAELTNIS; // Pauschale pro Jahr und Person (in Stunden) + $pauschale_sonstigeDV_relativImJahr = $pauschale_sonstigeDV_inStunden / 1; // Stundenpauschale in Verhaeltnis zu 1 Jahr + $vollzeit_arbeitsstunden_imJahr = BIS_VOLLZEIT_ARBEITSSTUNDEN * $wochen_imJahr; + + // Relatives Beschaeftigungsausmass / Anteilige JVZAE ermitteln + $bisverwendung->beschaeftigungsausmass_relativ = round($pauschale_sonstigeDV_relativImJahr / $vollzeit_arbeitsstunden_imJahr, 4); + $bisverwendung->jvzae_anteilig =round($pauschale_sonstigeDV_relativImJahr / $vollzeit_arbeitsstunden_imJahr, 4); } } } From e99112dc64b54dc9025658f555b7d7981bb0e09f Mon Sep 17 00:00:00 2001 From: Cris Date: Thu, 12 Mar 2020 16:35:24 +0100 Subject: [PATCH 126/138] Enhanced code readability (structure) --- vilesci/bis/personalmeldung.php | 388 +++++++++++++++++--------------- 1 file changed, 205 insertions(+), 183 deletions(-) diff --git a/vilesci/bis/personalmeldung.php b/vilesci/bis/personalmeldung.php index 06e7fcd52..5c214e730 100644 --- a/vilesci/bis/personalmeldung.php +++ b/vilesci/bis/personalmeldung.php @@ -138,11 +138,11 @@ foreach ($mitarbeiter_arr as $mitarbeiter) // BIS Verwendungsdauer und -gewichtung ergaenzen $bisverwendung_arr = _addDauerGewichtung_imBISMeldungsjahr($bisverwendung_arr); - // Hauptberufcode: wenn Hauptberuf / Nebenberuf im gleichen Jahr - laengere Dauer entscheidet + // Hauptberufcode // ----------------------------------------------------------------------------------------------------------------- - $is_hauptberuflich = $bisverwendung_arr[count($bisverwendung_arr) - 1]->hauptberuflich; // default: hauptberuflich der letzten BIS-Verwendung + $is_hauptberuflich = $bisverwendung_arr[count($bisverwendung_arr) - 1]->hauptberuflich; - // Wenn im selben Jahr hauptberuflich UND nebenberuflich -> laengere Dauer wird gemeldet (Ueberwiegenheitprinzip) + // wenn Hauptberuf / Nebenberuf im gleichen Jahr - laengere Dauer melden (Ueberwiegenheitprinzip) if (in_array(true, array_column($bisverwendung_arr, 'hauptberuflich')) && // hauptberuflich UND in_array(false, array_column($bisverwendung_arr, 'hauptberuflich'))) // nebenberuflich { @@ -154,181 +154,22 @@ foreach ($mitarbeiter_arr as $mitarbeiter) * - hauptberuflich Lehrender: NULL, * - nebenberuflich Lehrender: Hauptberufscode der letzten BIS-Verwendung */ - $person_obj->hauptberufcode = ($is_hauptberuflich == true) ? NULL : $bisverwendung_arr[count($bisverwendung_arr) - 1]->hauptberufcode; + $person_obj->hauptberufcode = ($is_hauptberuflich == true) + ? NULL + : $bisverwendung_arr[count($bisverwendung_arr) - 1]->hauptberufcode; + + + // ***************************************************************************************************************** + // Container Verwendung generieren (mit JVZAE und VZAE) + // ***************************************************************************************************************** + $verwendung_arr = array(); - // ----------------------------------------------------------------------------------------------------------------- // Relatives Beschaeftigungsausmass / Anteilige JVZAE ermitteln // ----------------------------------------------------------------------------------------------------------------- + $bisverwendung_arr = _add_relativesBA_und_anteiligeJVZAE($person_obj->uid, $bisverwendung_arr); - // Lehrtaetigkeit ermitteln - $lema = new lehreinheitmitarbeiter(); - $lema->getLehreinheiten_SWS_BISMeldung($person_obj->uid, $ss_kurzbz); - $lehre_ss_sws = $lema->result[0]; // Anzahl SS - Semesterwochenstunden - - $lema = new lehreinheitmitarbeiter(); - $lema->getLehreinheiten_SWS_BISMeldung($person_obj->uid, $ws_kurzbz); - $lehre_ws_sws = $lema->result[0]; // Anzahl WS - Semesterwochenstunden - - $has_lehrtaetigkeit = !is_null($lehre_ss_sws) || !is_null($lehre_ws_sws); - - foreach ($bisverwendung_arr as $index => $bisverwendung) - { - $has_vertragsstunden = !is_null($bisverwendung->vertragsstunden) && !empty($bisverwendung->vertragsstunden); - $is_lektor = $bisverwendung->verwendung_code == 1 || $bisverwendung->verwendung_code == 2; - - /** - * NOTE: is_karenziert ist ein boolean fuer Vollzeit-Karenz, nicht fuer Teilzeit-(Bildungs-)Karenz! - * Die Unterscheidung ist wichtig fuer die weitere Ermittlung der JVZAE. - * Vollzeitkarenz: Anteiliger Beschaeftigungsausmass und JVZAE wird auf 0 gesetzt. - * Bildungs-Teilzeitkarenz: entspricht im System - */ - $is_karenziert_VZ = $bisverwendung->beschausmasscode == 5 && !$has_vertragsstunden; // VZ-Kinder- und Bildungskarenz - $is_karenziert_TZ = $bisverwendung->beschausmasscode == 5 && $has_vertragsstunden; // TZ-Bildungskarenz - - // Karenzzeit - // ------------------------------------------------------------------------------------------------------------- - if ($is_karenziert_VZ) - { - // Relatives Beschaeftigungsausmass / Anteilige JVZAE ermitteln - $bisverwendung->beschaeftigungsausmass_relativ = number_format(0.00, 2); - $bisverwendung->jvzae_anteilig = 0; - continue; - } - - // Echter Dienstvertrag - d.h. Vertragsstunden sind vorhanden - // Bsp. angestellte Lektoren, angestellte MA in Verwaltung/Management/Wartung - // ------------------------------------------------------------------------------------------------------------- - else if ($has_vertragsstunden) - { - // Vertragsstunden koennen max. VZ Aequivalenz-Basiswert haben - if ($bisverwendung->vertragsstunden > BIS_VOLLZEIT_ARBEITSSTUNDEN) - { - $bisverwendung->vertragsstunden = BIS_VOLLZEIT_ARBEITSSTUNDEN; - } - - // Relatives Beschaeftigungsausmass / Anteilige JVZAE ermitteln - $bisverwendung->beschaeftigungsausmass_relativ = round($bisverwendung->vertragsstunden / BIS_VOLLZEIT_ARBEITSSTUNDEN, 2); - $bisverwendung->jvzae_anteilig = round($bisverwendung->beschaeftigungsausmass_relativ * $bisverwendung->gewichtung, 2); - - // Echter Dienstvertrag - mit Lehrtaetigkeit, jedoch kein Lektor. - // Bsp. STG-Leiter mit Lehrtaetigkeit - // --------------------------------------------------------------------------------------------------------- - if (!$is_lektor && $has_lehrtaetigkeit) - { - /** - * Verwendungen ergänzen, wenn Mitarbeiter in Verwaltung/Managment/Wartung (jedenfalls nicht in Lehre) - * zugeteilt ist und dennoch lehrt. - * Die SWS werden sowohl fuer Sommer- als auch Wintersemster ermittelt und jeweils in einer eigenen - * Verwendung mit dem Verwendungscode 1 ergaenzt. - */ - $bisverwendung_beginn_BIS = new DateTime($bisverwendung->beginn_imBISMeldungsJahr); - $bisverwendung_ende_BIS = new DateTime($bisverwendung->ende_imBISMeldungsJahr); - - foreach (array($ss_kurzbz => $lehre_ss_sws, $ws_kurzbz => $lehre_ws_sws) as $studsem_kurzbz => $lehre_sws) - { - $studsem = new studiensemester($studsem_kurzbz); - $studsem_start = new DateTime($studsem->start); - $studsem_ende = new DateTime($studsem->ende); - - // Wenn Lehrzeit in die BIS Verwendungszeit hineinfaellt, Verwendung erstellen - if (!is_null($lehre_sws) && - (!($studsem_start > $bisverwendung_ende_BIS) && - !($studsem_ende < $bisverwendung_beginn_BIS))) - { - // Verwendung erstellen - list($tage_lehre_imSemester, $verwendung_lehre_obj) = _addVerwendung_fuerLehre_inkludiert($studsem, $bisverwendung); - - // Relatives Beschaeftigungsausmass / Anteilige JVZAE ermitteln - $verwendung_lehre_obj->beschaeftigungsausmass_relativ = round($lehre_sws / BIS_VOLLZEIT_SWS_INKLUDIERTE_LEHRE, 2); // VZ-Basis fuer inkludierte Lehre - $verwendung_lehre_obj->gewichtung = ($tage_lehre_imSemester == 182) ? BIS_HALBJAHRES_GEWICHTUNG_SWS : round(BIS_HALBJAHRES_GEWICHTUNG_SWS / ($tage_imJahr / 2) * $tage_lehre_imSemester, 2); - $verwendung_lehre_obj->jvzae_anteilig = round($verwendung_lehre_obj->beschaeftigungsausmass_relativ * $verwendung_lehre_obj->gewichtung, 3); - - /** - * Relativen Beschaeftigungsausmass der BIS-Verwendung berichtigen - * (durch Abzug des eben erstellten relativen Beschaeftigungsausmass fuer Lehrtaetigkeiten) - * NOTE: Abzug nur fuer Lehrtaetigkeiten im WS, da nur diese das Beschaeftigungsausmass der - * BIS-Verwendung (und in Folge die VZAE ) zum Stichtag 31.12. bestimmen. - * */ - if(substr($studsem_kurzbz, 0, 2) == 'WS') - { - $bisverwendung->beschaeftigungsausmass_relativ -= $verwendung_lehre_obj->beschaeftigungsausmass_relativ; - } - - /** - * Anteilige JVZAE der BIS-Verwendung berichtigen - * (durch Abzug der eben erstellten anteiligen JVZAE fuer Lehrtaetigkeiten) - */ - $bisverwendung->jvzae_anteilig -= $verwendung_lehre_obj->jvzae_anteilig; - $bisverwendung_arr [] = $verwendung_lehre_obj; - } - } - } - } - - // Sonstige Beschaeftigungsverhaeltnisse ohne Vertragsstunden - // Freie Dienstvertraege auf Stundenbasis - // ------------------------------------------------------------------------------------------------------------- - else if (!$has_vertragsstunden && $has_lehrtaetigkeit) - { - foreach (array($ss_kurzbz => $lehre_ss_sws, $ws_kurzbz => $lehre_ws_sws) as $studsem => $lehre_sws) - { - if (!is_null($lehre_sws)) - { - // Verwendungen erstellen - $verwendung_lehre_obj = _addVerwendung_fuerLehre_Stundenbasis($bisverwendung); - - // Relatives Beschaeftigungsausmass / Anteilige JVZAE ermitteln - $verwendung_lehre_obj->beschaeftigungsausmass_relativ = round($lehre_sws / BIS_VOLLZEIT_SWS_EINZELSTUNDENBASIS, 2); // VZ-Basis nach BIS-Vorgabe fuer Stundenbasis - $verwendung_lehre_obj->gewichtung = BIS_HALBJAHRES_GEWICHTUNG_SWS; - $verwendung_lehre_obj->jvzae_anteilig = round($verwendung_lehre_obj->beschaeftigungsausmass_relativ * $verwendung_lehre_obj->gewichtung, 2); - $bisverwendung_arr []= $verwendung_lehre_obj; - } - } - } - else - { - // Studentische Hilfskraft - // --------------------------------------------------------------------------------------------------------- - $benutzerfunktion = new Benutzerfunktion(); - $is_studentische_hilfskraft = $benutzerfunktion->getBenutzerFunktionByUid( - $person_obj->uid, - 'hilfskraft', - $beginn_imJahr->format('Y-m-d'), - $ende_imJahr->format('Y-m-d') - ); - - if ($is_studentische_hilfskraft) - { - // Kalkulatorische Umrechnung der Jahrespauschale - $pauschale_hilfskraft_inStunden = BIS_PAUSCHALE_STUDENTISCHE_HILFSKRAFT; // Pauschale pro Jahr und Person (in Stunden) - $pauschale_hilfskraft_relativImJahr = $pauschale_hilfskraft_inStunden / 1; // Stundenpauschale in Verhaeltnis zu 1 Jahr - $vollzeit_arbeitsstunden_imJahr = BIS_VOLLZEIT_ARBEITSSTUNDEN * $wochen_imJahr; - - // Relatives Beschaeftigungsausmass / Anteilige JVZAE ermitteln - $bisverwendung->beschaeftigungsausmass_relativ = round($pauschale_hilfskraft_relativImJahr / $vollzeit_arbeitsstunden_imJahr, 4); - $bisverwendung->jvzae_anteilig =round($pauschale_hilfskraft_relativImJahr / $vollzeit_arbeitsstunden_imJahr, 4); - } - // Mitarbeiter mit sonstigem Dienstverhaeltnis (zB. Werkvertrag) - // --------------------------------------------------------------------------------------------------------- - else - { - $pauschale_sonstigeDV_inStunden = BIS_PAUSCHALE_SONSTIGES_DIENSTVERHAELTNIS; // Pauschale pro Jahr und Person (in Stunden) - $pauschale_sonstigeDV_relativImJahr = $pauschale_sonstigeDV_inStunden / 1; // Stundenpauschale in Verhaeltnis zu 1 Jahr - $vollzeit_arbeitsstunden_imJahr = BIS_VOLLZEIT_ARBEITSSTUNDEN * $wochen_imJahr; - - // Relatives Beschaeftigungsausmass / Anteilige JVZAE ermitteln - $bisverwendung->beschaeftigungsausmass_relativ = round($pauschale_sonstigeDV_relativImJahr / $vollzeit_arbeitsstunden_imJahr, 4); - $bisverwendung->jvzae_anteilig =round($pauschale_sonstigeDV_relativImJahr / $vollzeit_arbeitsstunden_imJahr, 4); - } - } - } - - // ***************************************************************************************************************** - // JVZAE und VZAE ermitteln (Jahresvollzeitaequivalenz, Vollzeitaequivalenz) - // ***************************************************************************************************************** - - // Container Verwendung aus dem bisverwendung_arr generieren, formatieren und dem Container Person anhängen - $verwendung_arr = array(); + // JVZAE und VZAE ermitteln und Container Verwendung generieren + // ----------------------------------------------------------------------------------------------------------------- foreach ($bisverwendung_arr as $bisverwendung) { if (empty($verwendung_arr) || // wenn erster Durchlauf ODER @@ -400,12 +241,9 @@ foreach ($mitarbeiter_arr as $mitarbeiter) $person_obj->verwendung_arr = $verwendung_arr; - // ********************************************************************************************************************* - // Container Funktion und Lehre werden nur für STG generiert (nicht für Lehrgaenge) - // ********************************************************************************************************************* - // ----------------------------------------------------------------------------------------------------------------- - // Container Funktion generieren - // ----------------------------------------------------------------------------------------------------------------- + // ***************************************************************************************************************** + // Container Funktion generieren (nicht für Lehrgaenge) + // ***************************************************************************************************************** $funktion_arr = array(); // Alle Benutzerfunktionen im BIS Meldungsjahr holen @@ -436,9 +274,9 @@ foreach ($mitarbeiter_arr as $mitarbeiter) $person_obj->funktion_arr = $funktion_arr; - // ----------------------------------------------------------------------------------------------------------------- - // Container Lehre generieren - // ----------------------------------------------------------------------------------------------------------------- + // ***************************************************************************************************************** + // Container Lehre generieren (nicht für Lehrgaenge) + // ***************************************************************************************************************** $lehre_arr = array(); // Alle Semesterwochenstunden, summiert nach STG und Studiensemester @@ -479,6 +317,190 @@ echo '
', print_r($xml, 1), '
'; // --------------------------------------------------------------------------------------------------------------------- // Private Functions // --------------------------------------------------------------------------------------------------------------------- + +/** + * Funktion ermittelt relatives Beschaeftigungsausmass und anteilige Jahresvollzeitaequivalenz + * @param String $uid + * @param array $bisverwendung_arr Object-Array + * @return array + */ +function _add_relativesBA_und_anteiligeJVZAE($uid, $bisverwendung_arr) +{ + global $beginn_imJahr; + global $ende_imJahr; + global $wochen_imJahr; + global $tage_imJahr; + global $ss_kurzbz; + global $ws_kurzbz; + + // Lehrtaetigkeit ermitteln + $lema = new lehreinheitmitarbeiter(); + $lema->getLehreinheiten_SWS_BISMeldung($uid, $ss_kurzbz); + $lehre_ss_sws = $lema->result[0]; // Anzahl SS - Semesterwochenstunden + + $lema = new lehreinheitmitarbeiter(); + $lema->getLehreinheiten_SWS_BISMeldung($uid, $ws_kurzbz); + $lehre_ws_sws = $lema->result[0]; // Anzahl WS - Semesterwochenstunden + + $has_lehrtaetigkeit = !is_null($lehre_ss_sws) || !is_null($lehre_ws_sws); + + foreach ($bisverwendung_arr as $index => $bisverwendung) + { + $has_vertragsstunden = !is_null($bisverwendung->vertragsstunden) && !empty($bisverwendung->vertragsstunden); + $is_lektor = $bisverwendung->verwendung_code == 1 || $bisverwendung->verwendung_code == 2; + + /** + * NOTE: is_karenziert ist ein boolean fuer Vollzeit-Karenz, nicht fuer Teilzeit-(Bildungs-)Karenz! + * Die Unterscheidung ist wichtig fuer die weitere Ermittlung der JVZAE. + * Vollzeitkarenz: Anteiliger Beschaeftigungsausmass und JVZAE wird auf 0 gesetzt. + * Bildungs-Teilzeitkarenz: entspricht im System + */ + $is_karenziert_VZ = $bisverwendung->beschausmasscode == 5 && !$has_vertragsstunden; // VZ-Kinder- und Bildungskarenz + $is_karenziert_TZ = $bisverwendung->beschausmasscode == 5 && $has_vertragsstunden; // TZ-Bildungskarenz + + // Karenzzeit + // ------------------------------------------------------------------------------------------------------------- + if ($is_karenziert_VZ) + { + // Relatives Beschaeftigungsausmass / Anteilige JVZAE ermitteln + $bisverwendung->beschaeftigungsausmass_relativ = number_format(0.00, 2); + $bisverwendung->jvzae_anteilig = 0; + continue; + } + + // Echter Dienstvertrag - d.h. Vertragsstunden sind vorhanden + // Bsp. angestellte Lektoren, angestellte MA in Verwaltung/Management/Wartung + // ------------------------------------------------------------------------------------------------------------- + else if ($has_vertragsstunden) + { + // Vertragsstunden koennen max. VZ Aequivalenz-Basiswert haben + if ($bisverwendung->vertragsstunden > BIS_VOLLZEIT_ARBEITSSTUNDEN) + { + $bisverwendung->vertragsstunden = BIS_VOLLZEIT_ARBEITSSTUNDEN; + } + + // Relatives Beschaeftigungsausmass / Anteilige JVZAE ermitteln + $bisverwendung->beschaeftigungsausmass_relativ = round($bisverwendung->vertragsstunden / BIS_VOLLZEIT_ARBEITSSTUNDEN, 2); + $bisverwendung->jvzae_anteilig = round($bisverwendung->beschaeftigungsausmass_relativ * $bisverwendung->gewichtung, 2); + + // Echter Dienstvertrag - mit Lehrtaetigkeit, jedoch kein Lektor. + // Bsp. STG-Leiter mit Lehrtaetigkeit + // --------------------------------------------------------------------------------------------------------- + if (!$is_lektor && $has_lehrtaetigkeit) + { + /** + * Verwendungen ergänzen, wenn Mitarbeiter in Verwaltung/Managment/Wartung (jedenfalls nicht in Lehre) + * zugeteilt ist und dennoch lehrt. + * Die SWS werden sowohl fuer Sommer- als auch Wintersemster ermittelt und jeweils in einer eigenen + * Verwendung mit dem Verwendungscode 1 ergaenzt. + */ + $bisverwendung_beginn_BIS = new DateTime($bisverwendung->beginn_imBISMeldungsJahr); + $bisverwendung_ende_BIS = new DateTime($bisverwendung->ende_imBISMeldungsJahr); + + foreach (array($ss_kurzbz => $lehre_ss_sws, $ws_kurzbz => $lehre_ws_sws) as $studsem_kurzbz => $lehre_sws) + { + $studsem = new studiensemester($studsem_kurzbz); + $studsem_start = new DateTime($studsem->start); + $studsem_ende = new DateTime($studsem->ende); + + // Wenn Lehrzeit in die BIS Verwendungszeit hineinfaellt, Verwendung erstellen + if (!is_null($lehre_sws) && + (!($studsem_start > $bisverwendung_ende_BIS) && + !($studsem_ende < $bisverwendung_beginn_BIS))) + { + // Verwendung erstellen + list($tage_lehre_imSemester, $verwendung_lehre_obj) = _addVerwendung_fuerLehre_inkludiert($studsem, $bisverwendung); + + // Relatives Beschaeftigungsausmass / Anteilige JVZAE ermitteln + $verwendung_lehre_obj->beschaeftigungsausmass_relativ = round($lehre_sws / BIS_VOLLZEIT_SWS_INKLUDIERTE_LEHRE, 2); // VZ-Basis fuer inkludierte Lehre + $verwendung_lehre_obj->gewichtung = ($tage_lehre_imSemester == 182) + ? BIS_HALBJAHRES_GEWICHTUNG_SWS + : round(BIS_HALBJAHRES_GEWICHTUNG_SWS / ($tage_imJahr / 2) * $tage_lehre_imSemester, 2); + $verwendung_lehre_obj->jvzae_anteilig = round($verwendung_lehre_obj->beschaeftigungsausmass_relativ * $verwendung_lehre_obj->gewichtung, 3); + + /** + * Relativen Beschaeftigungsausmass der BIS-Verwendung berichtigen + * (durch Abzug des eben erstellten relativen Beschaeftigungsausmass fuer Lehrtaetigkeiten) + * NOTE: Abzug nur fuer Lehrtaetigkeiten im WS, da nur diese das Beschaeftigungsausmass der + * BIS-Verwendung (und in Folge die VZAE ) zum Stichtag 31.12. bestimmen. + * */ + if(substr($studsem_kurzbz, 0, 2) == 'WS') + { + $bisverwendung->beschaeftigungsausmass_relativ -= $verwendung_lehre_obj->beschaeftigungsausmass_relativ; + } + + /** + * Anteilige JVZAE der BIS-Verwendung berichtigen + * (durch Abzug der eben erstellten anteiligen JVZAE fuer Lehrtaetigkeiten) + */ + $bisverwendung->jvzae_anteilig -= $verwendung_lehre_obj->jvzae_anteilig; + $bisverwendung_arr [] = $verwendung_lehre_obj; + } + } + } + } + + // Sonstige Beschaeftigungsverhaeltnisse ohne Vertragsstunden + // Freie Dienstvertraege auf Stundenbasis + // ------------------------------------------------------------------------------------------------------------- + else if (!$has_vertragsstunden && $has_lehrtaetigkeit) + { + foreach (array($ss_kurzbz => $lehre_ss_sws, $ws_kurzbz => $lehre_ws_sws) as $studsem => $lehre_sws) + { + if (!is_null($lehre_sws)) + { + // Verwendungen erstellen + $verwendung_lehre_obj = _addVerwendung_fuerLehre_Stundenbasis($bisverwendung); + + // Relatives Beschaeftigungsausmass / Anteilige JVZAE ermitteln + $verwendung_lehre_obj->beschaeftigungsausmass_relativ = round($lehre_sws / BIS_VOLLZEIT_SWS_EINZELSTUNDENBASIS, 2); // VZ-Basis nach BIS-Vorgabe fuer Stundenbasis + $verwendung_lehre_obj->gewichtung = BIS_HALBJAHRES_GEWICHTUNG_SWS; + $verwendung_lehre_obj->jvzae_anteilig = round($verwendung_lehre_obj->beschaeftigungsausmass_relativ * $verwendung_lehre_obj->gewichtung, 2); + $bisverwendung_arr []= $verwendung_lehre_obj; + } + } + } + else + { + // Studentische Hilfskraft + // --------------------------------------------------------------------------------------------------------- + $benutzerfunktion = new Benutzerfunktion(); + $is_studentische_hilfskraft = $benutzerfunktion->getBenutzerFunktionByUid( + $uid, + 'hilfskraft', + $beginn_imJahr->format('Y-m-d'), + $ende_imJahr->format('Y-m-d') + ); + + if ($is_studentische_hilfskraft) + { + // Kalkulatorische Umrechnung der Jahrespauschale + $pauschale_hilfskraft_inStunden = BIS_PAUSCHALE_STUDENTISCHE_HILFSKRAFT; // Pauschale pro Jahr und Person (in Stunden) + $pauschale_hilfskraft_relativImJahr = $pauschale_hilfskraft_inStunden / 1; // Stundenpauschale in Verhaeltnis zu 1 Jahr + $vollzeit_arbeitsstunden_imJahr = BIS_VOLLZEIT_ARBEITSSTUNDEN * $wochen_imJahr; + + // Relatives Beschaeftigungsausmass / Anteilige JVZAE ermitteln + $bisverwendung->beschaeftigungsausmass_relativ = round($pauschale_hilfskraft_relativImJahr / $vollzeit_arbeitsstunden_imJahr, 4); + $bisverwendung->jvzae_anteilig =round($pauschale_hilfskraft_relativImJahr / $vollzeit_arbeitsstunden_imJahr, 4); + } + // Mitarbeiter mit sonstigem Dienstverhaeltnis (zB. Werkvertrag) + // --------------------------------------------------------------------------------------------------------- + else + { + $pauschale_sonstigeDV_inStunden = BIS_PAUSCHALE_SONSTIGES_DIENSTVERHAELTNIS; // Pauschale pro Jahr und Person (in Stunden) + $pauschale_sonstigeDV_relativImJahr = $pauschale_sonstigeDV_inStunden / 1; // Stundenpauschale in Verhaeltnis zu 1 Jahr + $vollzeit_arbeitsstunden_imJahr = BIS_VOLLZEIT_ARBEITSSTUNDEN * $wochen_imJahr; + + // Relatives Beschaeftigungsausmass / Anteilige JVZAE ermitteln + $bisverwendung->beschaeftigungsausmass_relativ = round($pauschale_sonstigeDV_relativImJahr / $vollzeit_arbeitsstunden_imJahr, 4); + $bisverwendung->jvzae_anteilig =round($pauschale_sonstigeDV_relativImJahr / $vollzeit_arbeitsstunden_imJahr, 4); + } + } + } + + return $bisverwendung_arr; +} + /** * Funktion ermittelt fuer jede BIS-Verwendung die Dauer (in Tagen) und Gewichtung (Dauer / Tage im Jahr) * @param array $bisverwendung_arr Array mit BIS-Verwendungsobjekten From a25851613b3cd1881a41599a2ea04a195fdf026f Mon Sep 17 00:00:00 2001 From: Cris Date: Thu, 12 Mar 2020 18:50:03 +0100 Subject: [PATCH 127/138] Changed ba1code to ba1code_bis in getVerwendungenBISMeldung() --- include/bisverwendung.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/bisverwendung.class.php b/include/bisverwendung.class.php index ab8b5a4e4..44c70eb21 100644 --- a/include/bisverwendung.class.php +++ b/include/bisverwendung.class.php @@ -639,6 +639,7 @@ class bisverwendung extends basis_db END as ende_imBISMeldungsJahr FROM bis.tbl_bisverwendung + JOIN bis.tbl_beschaeftigungsart1 USING (ba1code) WHERE mitarbeiter_uid = '. $this->db_add_param($uid).' AND (beginn <= '. $this->db_add_param($stichtag).' OR beginn is null) @@ -655,7 +656,7 @@ class bisverwendung extends basis_db $obj->bisverwendung_id = $row->bisverwendung_id; $obj->mitarbeiter_uid = $row->mitarbeiter_uid; $obj->vertragsstunden = $row->vertragsstunden; - $obj->ba1code = $row->ba1code; + $obj->ba1code = $row->ba1code_bis; $obj->ba2code = $row->ba2code; $obj->verwendung_code = $row->verwendung_code; $obj->beschausmasscode = $row->beschausmasscode; From 54dd6734ba365b5d3b7ed13de40b664810e32d4c Mon Sep 17 00:00:00 2001 From: Cris Date: Thu, 12 Mar 2020 18:53:21 +0100 Subject: [PATCH 128/138] Added XML Output --- vilesci/bis/personalmeldung.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vilesci/bis/personalmeldung.php b/vilesci/bis/personalmeldung.php index 5c214e730..61f59b603 100644 --- a/vilesci/bis/personalmeldung.php +++ b/vilesci/bis/personalmeldung.php @@ -310,7 +310,15 @@ foreach ($mitarbeiter_arr as $mitarbeiter) $xml = ''; $xml = _generateXML($person_arr); -echo '
', print_r($xml, 1), '
'; +$xml_datei = 'bisdaten/bismeldung_mitarbeiter.xml'; +$dateiausgabe = fopen($xml_datei,'w'); +fwrite($dateiausgabe, $xml); +fclose($dateiausgabe); + +echo 'Herunterladen'; + +//header("Content-Type: text/xml"); +//echo $xml; From d1e47ad73e4e5a52183f1a246316cea0982b67cf Mon Sep 17 00:00:00 2001 From: Cris Date: Thu, 12 Mar 2020 18:55:28 +0100 Subject: [PATCH 129/138] Corrected: erste Korrekturen nach BIS Uplaod und Validierung, -- ACHTUNG: TODO ! - . kleine Korrekturen (Typen-, Semantikecheck) . TODO!!!: Meldedatum und ErhKz ersetzen! --- vilesci/bis/personalmeldung.php | 62 +++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/vilesci/bis/personalmeldung.php b/vilesci/bis/personalmeldung.php index 61f59b603..9d0f92894 100644 --- a/vilesci/bis/personalmeldung.php +++ b/vilesci/bis/personalmeldung.php @@ -12,6 +12,7 @@ require_once('../../include/lehreinheitmitarbeiter.class.php'); require_once('../../include/benutzerfunktion.class.php'); require_once('../../include/organisationseinheit.class.php'); require_once('../../include/entwicklungsteam.class.php'); +require_once('../../include/erhalter.class.php'); $uid = get_uid(); @@ -118,7 +119,7 @@ foreach ($mitarbeiter_arr as $mitarbeiter) { $person_obj = new StdClass(); - $person_obj->personalnummer = $mitarbeiter->personalnummer; + $person_obj->personalnummer = setLeadingZero(intval($mitarbeiter->personalnummer), 15); $person_obj->uid = $mitarbeiter->uid; $person_obj->geschlecht = $mitarbeiter->geschlecht; $person_obj->geschlechtX = $mitarbeiter->geschlechtX; @@ -191,7 +192,7 @@ foreach ($mitarbeiter_arr as $mitarbeiter) $verwendung_obj->ba1code = $bisverwendung->ba1code; $verwendung_obj->ba2code = $bisverwendung->ba2code; $verwendung_obj->verwendung_code = $bisverwendung->verwendung_code; - $verwendung_obj->jvzae = 0; + $verwendung_obj->jvzae = 0.00; $verwendung_obj->vzae = -1; // default // Loop innerhalb Verwendungen mit selben Beschaeftigungsverhaeltnissen und Verwendung_codes @@ -204,7 +205,9 @@ foreach ($mitarbeiter_arr as $mitarbeiter) * Berechnung: * JVZAE wird aus der Summe aller anteiligen JVZE gebildet. */ - $verwendung_obj->jvzae += (isset($verwendung_tmp->jvzae_anteilig)) ? $verwendung_tmp->jvzae_anteilig * 100 : NULL; // TODO: not null... + $verwendung_obj->jvzae += (isset($verwendung_tmp->jvzae_anteilig)) + ? number_format($verwendung_tmp->jvzae_anteilig * 100, 2) + : NULL; // TODO: not null... // Vollzeitaequivalenz VZAE ermitteln (Beschaeftigungsausmass zum Stichtag 31.12) @@ -785,9 +788,9 @@ function _getLehrecontainer($sws_proStg_arr) { $lehre_obj = new StdClass(); - $lehre_obj->StgKz = $sws_proStg->studiengang_kz; - $lehre_obj->SommersemesterSWS = $is_sommersemester ? $sws_proStg->sws : NULL; - $lehre_obj->WintersemesterSWS = $is_wintersemester ? $sws_proStg->sws : NULL; + $lehre_obj->StgKz = setLeadingZero(intval($sws_proStg->studiengang_kz), 4); + $lehre_obj->SommersemesterSWS = $is_sommersemester ? $sws_proStg->sws : 0.00; + $lehre_obj->WintersemesterSWS = $is_wintersemester ? $sws_proStg->sws : 0.00; // Lehreobjekt dem Lehrecontainer anhaengen $lehre_arr []= $lehre_obj; @@ -820,6 +823,10 @@ function _generateXML($person_arr) $xml = ''; $xml .= ''; +// TODO: ErhKz und Meldedatum aendern + $xml .= ''; + $xml .= '005'; + $xml .= '15042020'; $xml .= ''; foreach ($person_arr as $person) @@ -830,15 +837,17 @@ function _generateXML($person_arr) $xml .= 'geschlecht. ']]>'; $xml .= 'geschlechtX. ']]>'; $xml .= 'geburtsjahr. ']]>'; - $xml .= 'staatsangehoerigkeit. ']]>'; + $xml .= 'staatsangehoerigkeit. ']]>'; $xml .= 'hoechste_abgeschlossene_ausbildung. ']]>'; $xml .= 'habilitation. ']]>'; - $xml .= 'hauptberufcode. ']]>'; + $xml .= (!is_null($person->hauptberufcode)) + ? 'hauptberufcode. ']]>' + : ''; foreach ($person->verwendung_arr as $verwendung) { $xml .= ''; - $xml .= 'verwendung_code. ']]>'; + $xml .= 'verwendung_code. ']]>'; $xml .= 'ba1code. ']]>'; $xml .= 'ba2code. ']]>'; $xml .= 'vzae. ']]>'; @@ -850,21 +859,29 @@ function _generateXML($person_arr) { $xml .= ''; $xml .= 'funktionscode. ']]>'; - $xml .= 'besondereQualifikationCode. ']]>'; - $xml .= ''; - if (is_array($funktion->studiengang)) - { - foreach ($funktion->studiengang as $studiengang) - { - $xml .= ''; - } - } - else if (!is_null($funktion->studiengang)) - { - $xml .= 'studiengang. ']]>'; + $xml .= (!is_null($funktion->besondereQualifikationCode)) + ? 'besondereQualifikationCode. ']]>' + : ''; + if ($funktion->funktionscode == 5 || $funktion->funktionscode == 7) + { + $xml .= ''; + + if (is_array($funktion->studiengang)) + { + foreach ($funktion->studiengang as $studiengang) + { + $xml .= ''; + } + } + else if (!is_null($funktion->studiengang)) + { + $xml .= 'studiengang. ']]>'; + + } + $xml .= ''; } - $xml .= ''; + $xml .= ''; } @@ -881,6 +898,7 @@ function _generateXML($person_arr) } $xml .= ''; + $xml .= ''; return $xml; } From 1f4722b7a0b30227b1ae4a3a0476d543f5bd5bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Thu, 12 Mar 2020 19:24:47 +0100 Subject: [PATCH 130/138] =?UTF-8?q?-=20Config=20hinzugef=C3=BCgt=20um=20Le?= =?UTF-8?q?ktorenzuordnungen=20im=20CIS=20nur=20anzuzeigen=20wenn=20der=20?= =?UTF-8?q?Vertrag=20erteilt=20wurde=20-=20Vertr=C3=A4ge=20werden=20erst?= =?UTF-8?q?=20ab=20Status=20erteilt=20f=C3=BCr=20Lektoren=20angezeigt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lehre/lehrauftrag/acceptLehrauftrag.php | 7 +- .../lehrauftrag/acceptLehrauftragData.php | 10 +-- cis/private/lehre/anwesenheitsliste.php | 13 +++- cis/private/lehre/lesson.php | 18 ++++- cis/private/profile/lva_liste.php | 13 ++++ cms/menu/menu_addon_meinelv.inc.php | 13 ++++ config/global.config-default.inc.php | 4 + include/vertrag.class.php | 77 +++++++++++++++++++ .../js/lehre/lehrauftrag/acceptLehrauftrag.js | 20 ++++- 9 files changed, 157 insertions(+), 18 deletions(-) diff --git a/application/views/lehre/lehrauftrag/acceptLehrauftrag.php b/application/views/lehre/lehrauftrag/acceptLehrauftrag.php index 3f2575ec1..a4116e8d0 100644 --- a/application/views/lehre/lehrauftrag/acceptLehrauftrag.php +++ b/application/views/lehre/lehrauftrag/acceptLehrauftrag.php @@ -69,13 +69,11 @@ $this->load->view( - - @@ -148,9 +146,6 @@ $this->load->view( - @@ -196,7 +191,7 @@ $this->load->view(
- +
diff --git a/application/views/lehre/lehrauftrag/acceptLehrauftragData.php b/application/views/lehre/lehrauftrag/acceptLehrauftragData.php index 2a9cc4245..6ac3abbdc 100644 --- a/application/views/lehre/lehrauftrag/acceptLehrauftragData.php +++ b/application/views/lehre/lehrauftrag/acceptLehrauftragData.php @@ -170,7 +170,7 @@ FROM /* filter active organisationseinheiten */ AND oe.aktiv = TRUE /* filter vertragsstatus to avoid showing before status is bestellt */ - AND vvs.vertragsstatus_kurzbz IN (\'bestellt\', \'erteilt\', \'akzeptiert\') + AND vvs.vertragsstatus_kurzbz IN (\'erteilt\', \'akzeptiert\') ) tmp_lehrauftraege UNION @@ -182,8 +182,8 @@ FROM (SELECT uid FROM - public.tbl_benutzer JOIN public.tbl_mitarbeiter ma - ON tbl_benutzer.uid = ma.mitarbeiter_uid + public.tbl_benutzer JOIN public.tbl_mitarbeiter ma + ON tbl_benutzer.uid = ma.mitarbeiter_uid WHERE person_id = tmp_projektbetreuung.person_id ORDER BY aktiv DESC, updateaktivam DESC -- accept inactive as some person_ids have no active, but order them last @@ -285,8 +285,8 @@ FROM AND lv.aktiv = TRUE /* filter active organisationseinheiten */ AND oe.aktiv = TRUE - /* filter vertragsstatus to avoid showing before status is bestellt */ - AND vvs.vertragsstatus_kurzbz IN (\'bestellt\', \'erteilt\', \'akzeptiert\') + /* filter vertragsstatus to avoid showing before status is erteilt */ + AND vvs.vertragsstatus_kurzbz IN (\'erteilt\', \'akzeptiert\') ) tmp_projektbetreuung ) auftraege ORDER BY "akzeptiert" NULLS FIRST, "erteilt" NULLS LAST, "bestellt" diff --git a/cis/private/lehre/anwesenheitsliste.php b/cis/private/lehre/anwesenheitsliste.php index 4e328f5f2..bc7d96083 100644 --- a/cis/private/lehre/anwesenheitsliste.php +++ b/cis/private/lehre/anwesenheitsliste.php @@ -33,7 +33,7 @@ require_once('../../../include/studiengang.class.php'); require_once('../../../include/lehrveranstaltung.class.php'); require_once('../../../include/phrasen.class.php'); - + require_once('../../../include/vertrag.class.php'); $sprache = getSprache(); $p=new phrasen($sprache); @@ -134,6 +134,17 @@ { while($row_lkt = $db->db_fetch_object($result_lkt)) { + // Lektor wird erst angezeigt wenn der Auftrag erteilt wurde + if (defined('CIS_LV_LEKTORINNENZUTEILUNG_VERTRAGSPRUEFUNG_VON') + && CIS_LV_LEKTORINNENZUTEILUNG_VERTRAGSPRUEFUNG_VON != '') + { + $vertrag = new vertrag(); + if (!$vertrag->isVertragErteiltLV($lvid, $stsem, $row_lkt->mitarbeiter_uid)) + { + continue; + } + } + if($lektoren!='') $lektoren.=', '; $lektoren .= $row_lkt->kurzbz; diff --git a/cis/private/lehre/lesson.php b/cis/private/lehre/lesson.php index 6d35e46c7..4d8c872a1 100644 --- a/cis/private/lehre/lesson.php +++ b/cis/private/lehre/lesson.php @@ -33,6 +33,7 @@ require_once('../../../include/lvangebot.class.php'); require_once('../../../include/benutzergruppe.class.php'); require_once('../../../include/lehreinheit.class.php'); require_once('../../../include/variable.class.php'); +require_once('../../../include/vertrag.class.php'); $sprache = getSprache(); $p = new phrasen($sprache); @@ -316,6 +317,17 @@ $( document ).ready(function() $i=0; while($row_lector = $db->db_fetch_object($result)) { + // Lektor wird erst angezeigt wenn der Auftrag erteilt wurde + if (defined('CIS_LV_LEKTORINNENZUTEILUNG_VERTRAGSPRUEFUNG_VON') + && CIS_LV_LEKTORINNENZUTEILUNG_VERTRAGSPRUEFUNG_VON != '') + { + $vertrag = new vertrag(); + if (!$vertrag->isVertragErteiltLV($lvid, $angezeigtes_stsem, $row_lector->uid)) + { + continue; + } + } + $i++; if($user==$row_lector->uid) { @@ -327,9 +339,11 @@ $( document ).ready(function() $style='style="font-weight: bold"'; else $style=''; - echo ''.$row_lector->vorname.' '.$row_lector->nachname.''; - if($i!=$num_rows_result) + + if ($i != 1) echo ', '; + echo ''.$row_lector->vorname.' '.$row_lector->nachname.''; + } } } diff --git a/cis/private/profile/lva_liste.php b/cis/private/profile/lva_liste.php index c4f54ce94..8b8829099 100644 --- a/cis/private/profile/lva_liste.php +++ b/cis/private/profile/lva_liste.php @@ -37,6 +37,7 @@ require_once('../../../include/datum.class.php'); require_once('../../../include/lvangebot.class.php'); require_once('../../../include/addon.class.php'); require_once('../../../include/benutzerberechtigung.class.php'); +require_once('../../../include/vertrag.class.php'); if (!$db = new basis_db()) die('Fehler beim Oeffnen der Datenbankverbindung'); @@ -211,6 +212,18 @@ require_once('../../../include/benutzerberechtigung.class.php'); for ($i=0; $i<$num_rows; $i++) { $row=$db->db_fetch_object($result); + + // Nur erteilte Vertraege anzeigen wenn dies im Config hinterlegt ist. + if (defined('CIS_LV_LEKTORINNENZUTEILUNG_VERTRAGSPRUEFUNG_VON') + && CIS_LV_LEKTORINNENZUTEILUNG_VERTRAGSPRUEFUNG_VON != '') + { + $vertrag = new vertrag(); + if (!$vertrag->isVertragErteiltLV($row->lehrveranstaltung_id, $stdsem, $user)) + { + continue; + } + } + $lvangebot = new lvangebot(); echo ''; if(!defined('CIS_LVALISTE_NOTENEINGABE_ANZEIGEN') || CIS_LVALISTE_NOTENEINGABE_ANZEIGEN) diff --git a/cms/menu/menu_addon_meinelv.inc.php b/cms/menu/menu_addon_meinelv.inc.php index 89eecf088..b27029586 100644 --- a/cms/menu/menu_addon_meinelv.inc.php +++ b/cms/menu/menu_addon_meinelv.inc.php @@ -24,11 +24,13 @@ */ require_once(dirname(__FILE__).'/menu_addon.class.php'); require_once(dirname(__FILE__).'/../../config/cis.config.inc.php'); +require_once(dirname(__FILE__).'/../../config/global.config.inc.php'); require_once(dirname(__FILE__).'/../../include/functions.inc.php'); require_once(dirname(__FILE__).'/../../include/phrasen.class.php'); require_once(dirname(__FILE__).'/../../include/studiensemester.class.php'); require_once(dirname(__FILE__).'/../../include/studiengang.class.php'); require_once(dirname(__FILE__).'/../../include/lehrveranstaltung.class.php'); +require_once(dirname(__FILE__).'/../../include/vertrag.class.php'); class menu_addon_meinelv extends menu_addon { @@ -187,6 +189,17 @@ class menu_addon_meinelv extends menu_addon $lv_obj = new lehrveranstaltung(); $lv_obj->load($row->lehrveranstaltung_id); + // Nur erteilte Vertraege anzeigen wenn dies im Config hinterlegt ist. + if (defined('CIS_LV_LEKTORINNENZUTEILUNG_VERTRAGSPRUEFUNG_VON') + && CIS_LV_LEKTORINNENZUTEILUNG_VERTRAGSPRUEFUNG_VON != '') + { + $vertrag = new vertrag(); + if (!$vertrag->isVertragErteiltLV($lv_obj->lehrveranstaltung_id, $stsem, $user)) + { + continue; + } + } + if($row->studiengang_kz==0 AND $row->semester==0) { $this->items[] = array('title'=>$lv_obj->bezeichnung_arr[$sprache], diff --git a/config/global.config-default.inc.php b/config/global.config-default.inc.php index 05da2cb94..a888ee57e 100644 --- a/config/global.config-default.inc.php +++ b/config/global.config-default.inc.php @@ -132,6 +132,10 @@ define('FAS_REIHUNGSTEST_AUFNAHMEGRUPPEN',false); // Legt fest, ob Vertragsdetails zum Lehrauftrag im Reiter LektorInnenzuteilung angezeigt werden define('FAS_LV_LEKTORINNENZUTEILUNG_VERTRAGSDETAILS_ANZEIGEN', false); +// Gibt an, ob/ab welchen Studiensemester eine zusätzliche Vertragspruefung der Lektoren erfolgt. +// Ab diesem Semester wird die Lektorenzuordnung nur angezeigt wenn ein erteilter Vertrag vorhanden ist +define('CIS_LV_LEKTORINNENZUTEILUNG_VERTRAGSPRUEFUNG_VON', ''); + // Legt fest, ob Vertragsdetails zum Projektauftrag im Reiter Projektarbeit angezeigt werden define('FAS_STUDIERENDE_PROJEKTARBEIT_VERTRAGSDETAILS_ANZEIGEN', false); diff --git a/include/vertrag.class.php b/include/vertrag.class.php index 01b10c2b0..37c2fc9e2 100644 --- a/include/vertrag.class.php +++ b/include/vertrag.class.php @@ -1168,5 +1168,82 @@ class vertrag extends basis_db return false; } } + + /** + * Prueft ob ein Mitarbeiter einen erteilten Vertrag zu einer Lehrveranstaltung besitzt. + * @param $lehrveranstaltung_id ID der Lehrveranstaltung + * @param $studiensemester_kurzbz Studiensemester das geprueft wird + * @param $mitarbeiter_uid UID des Mitarbeiters + */ + public function isVertragErteiltLV($lehrveranstaltung_id, $studiensemester_kurzbz, $mitarbeiter_uid) + { + if (defined('CIS_LV_LEKTORINNENZUTEILUNG_VERTRAGSPRUEFUNG_VON') + && CIS_LV_LEKTORINNENZUTEILUNG_VERTRAGSPRUEFUNG_VON != '') + { + // Liegt das Studiensemester vor dem Pruefdatum, wird die LV immer als Erteilt angezeigt + $qry = " + SELECT + tbl_studiensemester.start + FROM + public.tbl_studiensemester + WHERE + studiensemester_kurzbz=".$this->db_add_param($studiensemester_kurzbz)." + AND tbl_studiensemester.start < (SELECT start + FROM public.tbl_studiensemester stsem WHERE + stsem.studiensemester_kurzbz=".$this->db_add_param(CIS_LV_LEKTORINNENZUTEILUNG_VERTRAGSPRUEFUNG_VON)." + )"; + + if ($result = $this->db_query($qry)) + { + if ($this->db_num_rows($result)>0) + { + // Wenn das Studiensemester vor dem Pruefdatum liegt, gilt der Vertrag immer als erteilt. + return true; + } + } + else + { + $this->errormsg = 'Fehler beim Laden des Studiensemesters'; + return false; + } + } + + $qry = " + SELECT + 1 + FROM + lehre.tbl_lehreinheitmitarbeiter + JOIN lehre.tbl_lehreinheit USING(lehreinheit_id) + JOIN lehre.tbl_vertrag USING(vertrag_id) + JOIN lehre.tbl_vertrag_vertragsstatus USING(vertrag_id) + WHERE + tbl_lehreinheitmitarbeiter.mitarbeiter_uid=".$this->db_add_param($mitarbeiter_uid)." + AND tbl_lehreinheit.studiensemester_kurzbz=".$this->db_add_param($studiensemester_kurzbz)." + AND tbl_lehreinheit.lehrveranstaltung_id=".$this->db_add_param($lehrveranstaltung_id)." + AND tbl_vertrag_vertragsstatus.vertragsstatus_kurzbz='erteilt' + AND NOT EXISTS( + SELECT 1 FROM lehre.tbl_vertrag_vertragsstatus vstatus + WHERE vstatus.vertrag_id = tbl_vertrag.vertrag_id + AND vstatus.vertragsstatus_kurzbz='storno' + ) + "; + + if ($result = $this->db_query($qry)) + { + if ($this->db_num_rows($result) > 0) + { + return true; + } + else + { + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Laden der Daten'; + return false; + } + } } ?> diff --git a/public/js/lehre/lehrauftrag/acceptLehrauftrag.js b/public/js/lehre/lehrauftrag/acceptLehrauftrag.js index fffed4f87..da041c232 100644 --- a/public/js/lehre/lehrauftrag/acceptLehrauftrag.js +++ b/public/js/lehre/lehrauftrag/acceptLehrauftrag.js @@ -294,11 +294,12 @@ function footer_downloadCSV(){ */ function footer_selectAll(){ $('#tableWidgetTabulator').tabulator('getRows', true) - .filter(row => row.getData().bestellt != null && // bestellt + .filter(function(row){ return row.getData().bestellt != null && // bestellt row.getData().erteilt != null && // AND erteilt row.getData().akzeptiert == null && // AND NOT akzeptiert - row.getData().status != 'Geändert') // AND NOT geändert - .forEach((row => row.select())); + row.getData().status != 'Geändert' + ;}) // AND NOT geändert + .forEach((function(row){ return row.select();})); } /* @@ -464,6 +465,17 @@ storniert_tooltip = function(cell){ } $(function() { + + // Pruefen ob Promise unterstuetzt wird + // Tabulator funktioniert nicht mit IE + var canPromise = !! window.Promise; + if(!canPromise) + { + alert("Diese Seite kann mit ihrem Browser nicht angezeigt werden. Bitte verwenden Sie Firefox, Chrome oder Edge um die Seite anzuzeigen"); + window.location.href='about:blank'; + return; + } + // Show all rows $("#show-all").click(function(){ $('#tableWidgetTabulator').tabulator('clearFilter'); @@ -582,7 +594,7 @@ $(function() { // Print error message FHC_DialogLib.alertWarning(data.retval); } - + if (!data.error && data.retval != null) { // Update status 'Erteilt' From dd2c384de04dc089c1d5fc0ae8d9fc14b826cfc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Mon, 16 Mar 2020 11:04:40 +0100 Subject: [PATCH 131/138] =?UTF-8?q?Personalmeldung=20angepasst:=20=20=20?= =?UTF-8?q?=20=C3=9Cbersichtstabelle=20hinzugef=C3=BCgt=20=20=20=20Erhalte?= =?UTF-8?q?rkennzahl=20und=20Meldedatum=20wird=20dynamisch=20ermittelt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vilesci/bis/personalmeldung.php | 233 ++++++++++++++++++++++++++++++-- 1 file changed, 221 insertions(+), 12 deletions(-) diff --git a/vilesci/bis/personalmeldung.php b/vilesci/bis/personalmeldung.php index 9d0f92894..2e2910247 100644 --- a/vilesci/bis/personalmeldung.php +++ b/vilesci/bis/personalmeldung.php @@ -1,5 +1,22 @@ + */ require_once('../../config/vilesci.config.inc.php'); require_once('../../include/studiensemester.class.php'); require_once('../../include/datum.class.php'); @@ -78,7 +95,7 @@ if (!defined('BIS_FUNKTIONSCODE_6_ARR') || empty('BIS_FUNKTIONSCODE_6_ARR')) // Prüfe Zeitraum zur Erstellung einer BIS-Meldung $studiensemester = new studiensemester(); -$stsem = (isset($_GET['stsem'])) ? $_GET['stsem'] : $studiensemester->getaktorNext(1); // aktuelles Studiensemester +$stsem = (isset($_GET['stsem'])) ? $_GET['stsem'] : $studiensemester->getaktorNext(); // aktuelles Studiensemester $datum_obj = new datum(); if(mb_strstr($stsem,'SS')) @@ -121,6 +138,8 @@ foreach ($mitarbeiter_arr as $mitarbeiter) $person_obj->personalnummer = setLeadingZero(intval($mitarbeiter->personalnummer), 15); $person_obj->uid = $mitarbeiter->uid; + $person_obj->vorname = $mitarbeiter->vorname; + $person_obj->nachname = $mitarbeiter->nachname; $person_obj->geschlecht = $mitarbeiter->geschlecht; $person_obj->geschlechtX = $mitarbeiter->geschlechtX; $person_obj->geburtsjahr = $datum_obj->formatDatum($mitarbeiter->gebdatum, 'Y'); @@ -311,6 +330,8 @@ foreach ($mitarbeiter_arr as $mitarbeiter) // XML generieren // ********************************************************************************************************************* $xml = ''; + +_outputHTML($person_arr); $xml = _generateXML($person_arr); $xml_datei = 'bisdaten/bismeldung_mitarbeiter.xml'; @@ -318,12 +339,7 @@ $dateiausgabe = fopen($xml_datei,'w'); fwrite($dateiausgabe, $xml); fclose($dateiausgabe); -echo 'Herunterladen'; - -//header("Content-Type: text/xml"); -//echo $xml; - - +echo 'XML Herunterladen'; // --------------------------------------------------------------------------------------------------------------------- // Private Functions @@ -823,10 +839,19 @@ function _generateXML($person_arr) $xml = ''; $xml .= ''; -// TODO: ErhKz und Meldedatum aendern + $erhalter = new erhalter(); + $erhalter->getAll(); + + if(isset($erhalter->result[0])) + { + $erhalter = sprintf("%03s",trim($erhalter->result[0]->erhalter_kz)); + } + else + $erhalter = ''; + $xml .= ''; - $xml .= '005'; - $xml .= '15042020'; + $xml .= ''.$erhalter.''; + $xml .= '1504'.date('Y').''; $xml .= ''; foreach ($person_arr as $person) @@ -835,7 +860,8 @@ function _generateXML($person_arr) $xml .= 'personalnummer. ']]>'; $xml .= 'geschlecht. ']]>'; - $xml .= 'geschlechtX. ']]>'; + if ($person->geschlecht == 'x') + $xml .= 'geschlechtX. ']]>'; $xml .= 'geburtsjahr. ']]>'; $xml .= 'staatsangehoerigkeit. ']]>'; $xml .= 'hoechste_abgeschlossene_ausbildung. ']]>'; @@ -903,4 +929,187 @@ function _generateXML($person_arr) return $xml; } +/** + * Prints the HTML Table with all Persons + * @param $person_arr Array of PersonData + */ +function _outputHTML($person_arr) +{ + echo ' + + BIS - Meldung Personal + + '; + include('../../include/meta/jquery.php'); + include('../../include/meta/jquery-tablesorter.php'); + echo ' + + +

Personalmeldung

'; + echo ' + + '; + + echo "Anzahl der gemeldeten Personen: ".count($person_arr); + + echo ' +
Alle
Alle Lehraufträge mit jedem Status
Bestellt
Nur bestellte UND bestellte Lehraufträge, die in Bearbeitung sind
Erteilt
Nur erteilte UND geänderte Lehraufträge, die in Bearbeitung sind
Angenommen
Nur von Ihnen angenommene Lehraufträge
+ + + + + + + + + + + + + + + + + + '; + + + foreach ($person_arr as $person) + { + echo ' + + + + + + + + + + + '; + + echo ''; + + echo ''; + + echo ' + '; + } + + echo ' +
PersNrVornameNachnameUIDGeschlecht (X)Geb.JahrStaatHöchste Ausb.Habil.HautpberufcodeVerwendungFunktionLehre
'.$person->personalnummer.''.$person->vorname.''.$person->nachname.''.$person->uid.''.$person->geschlecht.($person->geschlecht=='x'?'('.$person->geschlechtX.')':'').''.$person->geburtsjahr.''.$person->staatsangehoerigkeit.''.$person->hoechste_abgeschlossene_ausbildung.''.$person->habilitation.''.$person->hauptberufcode.''; + + if (count($person->verwendung_arr) > 0) + { + echo ' + + + + + + + + + + + + '; + + foreach ($person->verwendung_arr as $verwendung) + { + echo ' + + + + + + + '; + } + echo ' +
VerwendungBa1CodeBa2CodeVZÄJVZÄ
'.$verwendung->verwendung_code.''.$verwendung->ba1code.''.$verwendung->ba2code.''.$verwendung->vzae.''.$verwendung->jvzae.'
'; + } + echo '
'; + + if (count($person->funktion_arr) > 0) + { + echo ' + + + + + + + + + + '; + + foreach ($person->funktion_arr as $funktion) + { + echo ' + + + + + '; + } + echo ' +
FunktionBes.QualStgKZ
'. $funktion->funktionscode. ''. $funktion->besondereQualifikationCode. ''; + + if ($funktion->funktionscode == 5 || $funktion->funktionscode == 7) + { + if (is_array($funktion->studiengang)) + { + foreach ($funktion->studiengang as $studiengang) + { + echo $studiengang.' '; + } + } + else if (!is_null($funktion->studiengang)) + { + echo $funktion->studiengang.' '; + } + } + echo '
'; + } + echo '
'; + if ($person->lehre_arr > 0) + { + echo ' + + + + + + + + + '; + + foreach ($person->lehre_arr as $lehre) + { + echo ' + + + + + '; + } + + echo ' +
StgKZSommerSWSWinterSWS
'. $lehre->StgKz. ''. $lehre->SommersemesterSWS. ''. $lehre->WintersemesterSWS. '
'; + } + echo '
'; +} From fd95f0f67c28df15daa62adf0692b9cf51866bd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Mon, 16 Mar 2020 13:11:16 +0100 Subject: [PATCH 132/138] Firmenhandys werden immer angezeigt auch wenn eine normale Klappe vorhanden ist --- cis/private/profile/index.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cis/private/profile/index.php b/cis/private/profile/index.php index dbef13bfd..17593ec15 100644 --- a/cis/private/profile/index.php +++ b/cis/private/profile/index.php @@ -341,16 +341,16 @@ if ($type == 'mitarbeiter') echo $p->t('profil/telefonTw').": $vorwahl - $user->telefonklappe
"; //echo $p->t('profil/faxTw').": $vorwahl - 99 $user->telefonklappe
"; } - else { - $kontakt = new kontakt(); - $kontakt->load_pers($user->person_id); - foreach($kontakt->result as $k) - { - if ($k->kontakttyp == 'firmenhandy') - echo $p->t('profil/telefonTw').': '.$k->kontakt.'
'; - } + $kontakt = new kontakt(); + $kontakt->load_pers($user->person_id); + foreach($kontakt->result as $k) + { + if ($k->kontakttyp == 'firmenhandy') + echo 'Firmenhandy: '.$k->kontakt.'
'; } + + if ($user->ort_kurzbz != '') echo $p->t('profil/buero').': '.$user->ort_kurzbz.'
'; } From 7b9b5e0dd59e957a64985bbdd39dd013c0534cab Mon Sep 17 00:00:00 2001 From: Nikolaus Krondraf Date: Mon, 16 Mar 2020 13:36:52 +0100 Subject: [PATCH 133/138] ohne Angabe des Studiensemesters werden nun alle LVs exportiert --- include/lehreinheit.class.php | 54 +++++++++++++++++++++++++++++++++++ rdf/lehreinheit.rdf.php | 6 +++- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/include/lehreinheit.class.php b/include/lehreinheit.class.php index 3d754d7ec..23677a6e3 100644 --- a/include/lehreinheit.class.php +++ b/include/lehreinheit.class.php @@ -257,6 +257,60 @@ class lehreinheit extends basis_db } } + /** + * Laedt alle vorhandenen Lehreinheiten zu einer Lehrveranstaltung + * + * @param $lehrveranstaltung_id + * @return bool + */ + public function load_all_lehreinheiten($lehrveranstaltung_id) + { + $this->lehreinheiten = array(); + $this->errormsg =''; + + $qry = "SELECT * FROM lehre.tbl_lehreinheit WHERE + lehrveranstaltung_id=".$this->db_add_param($lehrveranstaltung_id, FHC_INTEGER)." + ORDER BY lehreinheit_id;"; + + if($this->db_query($qry)) + { + while($row = $this->db_fetch_object()) + { + $le_obj = new lehreinheit(); + + $le_obj->lehreinheit_id = $row->lehreinheit_id; + $le_obj->lehrveranstaltung_id = $row->lehrveranstaltung_id; + $le_obj->studiensemester_kurzbz = $row->studiensemester_kurzbz; + $le_obj->lehrfach_id = $row->lehrfach_id; + $le_obj->lehrform_kurzbz = $row->lehrform_kurzbz; + $le_obj->stundenblockung = $row->stundenblockung; + $le_obj->wochenrythmus = $row->wochenrythmus; + $le_obj->start_kw = $row->start_kw; + $le_obj->raumtyp = $row->raumtyp; + $le_obj->raumtypalternativ = $row->raumtypalternativ; + $le_obj->lehre = $this->db_parse_bool($row->lehre); + $le_obj->anmerkung = $row->anmerkung; + $le_obj->unr = $row->unr; + $le_obj->lvnr = $row->lvnr; + $le_obj->sprache = $row->sprache; + $le_obj->insertamum = $row->insertamum; + $le_obj->insertvon = $row->insertvon; + $le_obj->updateamum = $row->updateamum; + $le_obj->updatevon = $row->updatevon; + $le_obj->ext_id = $row->ext_id; + $le_obj->gewicht = $row->gewicht; + + $this->lehreinheiten[] = $le_obj; + } + return true; + } + else + { + $this->errormsg = 'Fehler beim Laden der Lehreinheiten'; + return false; + } + } + /** * Prueft die Variablen vor dem Speichern * auf Gueltigkeit. diff --git a/rdf/lehreinheit.rdf.php b/rdf/lehreinheit.rdf.php index e010768d5..b0e668290 100644 --- a/rdf/lehreinheit.rdf.php +++ b/rdf/lehreinheit.rdf.php @@ -86,7 +86,11 @@ else { if($lehrveranstaltung_id!='') { - $lehreinheit->load_lehreinheiten($lehrveranstaltung_id, $studiensemester_kurzbz); + if($studiensemester_kurzbz=!'') + $lehreinheit->load_lehreinheiten($lehrveranstaltung_id, $studiensemester_kurzbz); + else + $lehreinheit->load_all_lehreinheiten($lehrveranstaltung_id); + foreach ($lehreinheit->lehreinheiten as $row) draw_row($row); } From 8c76f38b4d29b956ef7cfa36b3c3fb0c79caf8a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Mon, 16 Mar 2020 13:52:29 +0100 Subject: [PATCH 134/138] =?UTF-8?q?Plausibilit=C3=A4tspr=C3=BCfungen=20f?= =?UTF-8?q?=C3=BCr=20Personalmeldung=20erg=C3=A4nzt.=20Anpassungen=20f?= =?UTF-8?q?=C3=BCr=20Studiengang-Container?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vilesci/bis/personalmeldung.php | 105 ++++++++++++++++++++++++++++++-- 1 file changed, 101 insertions(+), 4 deletions(-) diff --git a/vilesci/bis/personalmeldung.php b/vilesci/bis/personalmeldung.php index 2e2910247..3b2a43411 100644 --- a/vilesci/bis/personalmeldung.php +++ b/vilesci/bis/personalmeldung.php @@ -891,21 +891,21 @@ function _generateXML($person_arr) if ($funktion->funktionscode == 5 || $funktion->funktionscode == 7) { - $xml .= ''; - if (is_array($funktion->studiengang)) { foreach ($funktion->studiengang as $studiengang) { + $xml .= ''; $xml .= ''; + $xml .= ''; } } else if (!is_null($funktion->studiengang)) { + $xml .= ''; $xml .= 'studiengang. ']]>'; - + $xml .= ''; } - $xml .= ''; } $xml .= ''; @@ -947,6 +947,7 @@ function _outputHTML($person_arr)

Personalmeldung

'; + outputPlausibilitaetschecks($person_arr); echo ' '; + echo "

Meldedaten

"; echo "Anzahl der gemeldeten Personen: ".count($person_arr); echo ' @@ -1113,3 +1115,98 @@ function _outputHTML($person_arr) echo '
'; } + +function outputPlausibilitaetschecks($person_arr) +{ + echo "

Plausibilitätsprüfung

"; + + foreach ($person_arr as $row) + { + $msg = array(); + if ($row->personalnummer == '') + { + $msg[] = 'Personalnummer fehlt '; + } + if ($row->geschlecht == '') + { + $msg[] = 'Geschlecht fehlt '; + } + if ($row->geburtsjahr == '') + { + $msg[] = 'Geburtsjahr fehlt '; + } + if (date('Y') - $row->geburtsjahr >= 100) + { + $msg[] = 'Person darf nicht älter als 100 sein '; + } + if (date('Y') - $row->geburtsjahr <= 10) + { + $msg[] = 'Person darf nicht jünger als 10 sein '; + } + if ($row->staatsangehoerigkeit == '') + { + $msg[] = 'Staatsangehoerigkeit fehlt '; + } + if ($row->hoechste_abgeschlossene_ausbildung == '') + { + $msg[] = 'Höchste Abgeschlossene Ausbildung fehlt '; + } + if ($row->habilitation == '') + { + $msg[] = 'Habilitation fehlt '; + } + + if (isset($row->verwendung_arr) && is_array($row->verwendung_arr) && count($row->verwendung_arr) > 0) + { + foreach ($row->verwendung_arr as $verwendung) + { + if($verwendung->vzae < -1) + { + $msg[] = 'VZAE ist zu klein -> Vertragsstunden prüfen'; + } + if($verwendung->vzae > 100) + { + $msg[] = 'VZAE ist zu gross -> Vertragsstunden prüfen'; + } + + if($verwendung->jvzae < -1) + { + $msg[] = 'JVZAE ist zu klein -> Vertragsstunden prüfen'; + } + if($verwendung->jvzae > 100) + { + $msg[] = 'JVZAE ist zu gross -> Vertragsstunden prüfen'; + } + } + } + + if (isset($row->lehre_arr) && is_array($row->lehre_arr) && count($row->lehre_arr) > 0) + { + foreach ($row->lehre_arr as $lehre) + { + if ($lehre->SommersemesterSWS > 40) + { + $msg[] = 'Sommersemester SWS zu groß '.$lehre->SommersemesterSWS; + } + if ($lehre->WintersemesterSWS < 0) + { + $msg[] = 'Wintersemester SWS zu groß '.$lehre->WintersemesterSWS; + } + if ($lehre->SommersemesterSWS < 0) + { + $msg[] = 'Sommersemester SWS zu klein '.$lehre->SommersemesterSWS; + } + if ($lehre->WintersemesterSWS < 0) + { + $msg[] = 'Wintersemester SWS zu klein '.$lehre->WintersemesterSWS; + } + } + } + + if (count($msg) > 0) + { + echo "Fehler bei ".$row->vorname.' '.$row->nachname.' : '.implode($msg,', '); + echo "\n
"; + } + } +} From 77e2db5a7c7844fba4f5004d09dab9723f394ff7 Mon Sep 17 00:00:00 2001 From: Nikolaus Krondraf Date: Mon, 16 Mar 2020 15:24:48 +0100 Subject: [PATCH 135/138] Bugfix --- rdf/lehreinheit.rdf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdf/lehreinheit.rdf.php b/rdf/lehreinheit.rdf.php index b0e668290..d6bd47411 100644 --- a/rdf/lehreinheit.rdf.php +++ b/rdf/lehreinheit.rdf.php @@ -86,7 +86,7 @@ else { if($lehrveranstaltung_id!='') { - if($studiensemester_kurzbz=!'') + if($studiensemester_kurzbz!='') $lehreinheit->load_lehreinheiten($lehrveranstaltung_id, $studiensemester_kurzbz); else $lehreinheit->load_all_lehreinheiten($lehrveranstaltung_id); From 91ab79d6ebe35c6a960d12b5ad8e6ffae1c8fa37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Tue, 17 Mar 2020 12:09:36 +0100 Subject: [PATCH 136/138] =?UTF-8?q?Config=20Eintr=C3=A4ge=20f=C3=BCr=20BIS?= =?UTF-8?q?=20Meldung=20aktualisiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/vilesci.config-default.inc.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/config/vilesci.config-default.inc.php b/config/vilesci.config-default.inc.php index e737fc58a..1647cb59a 100644 --- a/config/vilesci.config-default.inc.php +++ b/config/vilesci.config-default.inc.php @@ -214,13 +214,13 @@ define('CI_ENVIRONMENT', 'development'); // Code igniter environment variable define('BIS_EXCLUDE_STG', array()); // Basis Vollzeit Arbeitsstunden für Berechnung von Jahresvollzeitaequivalenz JVZAE (echte Dienstverträge) -define('BIS_VOLLZEIT_ARBEITSSTUNDEN', '0'); +define('BIS_VOLLZEIT_ARBEITSSTUNDEN', '40'); // Basis Vollzeit Semesterwochenstunden für Berechnung von Jahresvollzeitaequivalenz JVZAE auf Stundenbasis (freie Dienstverträge) -define('BIS_VOLLZEIT_SWS_EINZELSTUNDENBASIS', '0'); +define('BIS_VOLLZEIT_SWS_EINZELSTUNDENBASIS', '15'); // Basis Vollzeit Semesterwochenstunden für Berechnung von Jahresvollzeitaequivalenz JVZAE für inkludierte Lehre bei echten Dienstverträgen -define('BIS_VOLLZEIT_SWS_INKLUDIERTE_LEHRE', '0'); +define('BIS_VOLLZEIT_SWS_INKLUDIERTE_LEHRE', '25'); // Semester Gewichtung für Berechnung von Jahresvollzeitaequivalenz JVZAE define('BIS_HALBJAHRES_GEWICHTUNG_SWS', 0.5); @@ -239,10 +239,12 @@ define('BIS_FUNKTIONSCODE_1234_ARR', array( 'kollegium' => 4 // Mitglied des Kollegiums )); +// Liste der Leitungsfunktionen define('BIS_FUNKTIONSCODE_5_ARR', array( 'Leitung' )); +// Organisationseinheitstypen bei denen KEINE Leiter gemeldet werden define('BIS_FUNKTIONSCODE_6_ARR', array( 'Team' )); From 44fc614f67f047760522d42c2e2ebbc2657d7ab1 Mon Sep 17 00:00:00 2001 From: Nikolaus Krondraf Date: Tue, 17 Mar 2020 14:19:22 +0100 Subject: [PATCH 137/138] =?UTF-8?q?Durchschnitt=20und=20gewichteter=20Durc?= =?UTF-8?q?hschnitt=20k=C3=B6nnen=20per=20config=20in=20Notenliste=20ausge?= =?UTF-8?q?blendet=20werden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cis/private/lehre/notenliste.php | 11 ++++++++--- config/global.config-default.inc.php | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cis/private/lehre/notenliste.php b/cis/private/lehre/notenliste.php index 56fd4a36d..e7e7ae90f 100644 --- a/cis/private/lehre/notenliste.php +++ b/cis/private/lehre/notenliste.php @@ -417,10 +417,15 @@ else $tblFoot .= ""; - $tbl .= $tblHead.$tblFoot.$tblBody; + if (!defined('CIS_NOTENLISTE_DURCHSCHNITT_ANZEIGEN') || (defined('CIS_NOTENLISTE_DURCHSCHNITT_ANZEIGEN') && CIS_NOTENLISTE_DURCHSCHNITT_ANZEIGEN)) + { + $tbl .= $tblHead.$tblFoot.$tblBody; + $tbl .= ""; + $tbl .= ""; + } + else + $tbl .= $tblHead.$tblBody; - $tbl .= "
*" . $p->t('tools/legendeNotendurchschnitt') . "
**" . $p->t('tools/legendeGewichteterNotendurchschnitt') . "
"; - $tbl .= ""; if ($legende) { $tbl .= ""; diff --git a/config/global.config-default.inc.php b/config/global.config-default.inc.php index 05da2cb94..dff96bc38 100644 --- a/config/global.config-default.inc.php +++ b/config/global.config-default.inc.php @@ -101,6 +101,9 @@ define('CIS_GESAMTNOTE_FREIGABEMAIL_NOTE', false); // Gibt an ob in der Notenliste der Studierenden nur offizielle Noten oder alle angezeigt werden define('CIS_NOTENLISTE_OFFIZIELL_ANZEIGEN', false); +// Gibt an ob in der Notenliste der Durchschnitt und der gewichtete Durchschnitt angezeigt werden +define('CIS_NOTENLISTE_DURCHSCHNITT_ANZEIGEN', true); + // Grenzwerte für Anwesenheit define('FAS_ANWESENHEIT_ROT', 70); define('FAS_ANWESENHEIT_GELB', 90); From 1a9ac9e1fa8d33ffca73d6da8e5a44cbf2de141a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Wed, 18 Mar 2020 13:44:36 +0100 Subject: [PATCH 138/138] =?UTF-8?q?LVA=20Liste=20anzeige=20der=20Anzahl=20?= =?UTF-8?q?der=20Lehrauftr=C3=A4ge=20korrigiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cis/private/profile/lva_liste.php | 827 +++++++++++++++--------------- 1 file changed, 422 insertions(+), 405 deletions(-) diff --git a/cis/private/profile/lva_liste.php b/cis/private/profile/lva_liste.php index 8b8829099..f2d175dbf 100644 --- a/cis/private/profile/lva_liste.php +++ b/cis/private/profile/lva_liste.php @@ -39,45 +39,49 @@ require_once('../../../include/addon.class.php'); require_once('../../../include/benutzerberechtigung.class.php'); require_once('../../../include/vertrag.class.php'); - if (!$db = new basis_db()) - die('Fehler beim Oeffnen der Datenbankverbindung'); +if (!$db = new basis_db()) + die('Fehler beim Oeffnen der Datenbankverbindung'); - $adress=MAIL_ADMIN; +$adress = MAIL_ADMIN; - $user=get_uid(); - $studiensemester = new studiensemester(); +$user=get_uid(); +$studiensemester = new studiensemester(); - if (isset($_GET['uid'])) - $uid=$_GET['uid']; - else - $uid = $user; +if (isset($_GET['uid'])) + $uid = $_GET['uid']; +else + $uid = $user; - if (isset($_GET['stdsem'])) - $stdsem=$_GET['stdsem']; - else - $stdsem=$studiensemester->getaktorNext(); +if (isset($_GET['stdsem'])) + $stdsem = $_GET['stdsem']; +else + $stdsem = $studiensemester->getaktorNext(); - $rechte = new benutzerberechtigung(); - $rechte->getBerechtigungen($user); - if(!$rechte->isBerechtigt('admin') && $uid!=$user) - die('Sie haben keine Berechtigung für diesen Vorgang'); +$rechte = new benutzerberechtigung(); +$rechte->getBerechtigungen($user); +if (!$rechte->isBerechtigt('admin') && $uid != $user) + die('Sie haben keine Berechtigung für diesen Vorgang'); - $datum = new datum(); +$datum = new datum(); - $addon = new addon(); - if(in_array('lvinfo',$addon->aktive_addons)) - $lvinfo=true; - else - $lvinfo=false; +$addon = new addon(); +if (in_array('lvinfo',$addon->aktive_addons)) + $lvinfo=true; +else + $lvinfo=false; - //Studiensemester abfragen. Letzten 5, aktuelles und naechstes. - $sql_query='SELECT * FROM public.tbl_studiensemester WHERE (start<=(now()::date+240) AND ende>=(now()::date-900)) ORDER BY start'; - $result_stdsem=$db->db_query($sql_query); - $num_rows_stdsem=$db->db_num_rows($result_stdsem); - //if (!isset($stdsem)) - //$stdsem=$db->db_result($result_stdsem,0,"studiensemester_kurzbz"); +//Studiensemester abfragen. Letzten 5, aktuelles und naechstes. +$sql_query = ' + SELECT + * + FROM + public.tbl_studiensemester + WHERE (start<=(now()::date+240) AND ende>=(now()::date-900)) + ORDER BY start'; +$result_stdsem = $db->db_query($sql_query); +$num_rows_stdsem = $db->db_num_rows($result_stdsem); - $p = new phrasen(getSprache()); +$p = new phrasen(getSprache()); /* 0000453: Sortierung von LVs - Meine LV 1. Bachelor @@ -90,413 +94,426 @@ require_once('../../../include/vertrag.class.php'); 8. Name der LV */ - //Lehrveranstaltungen abfragen. - $sql_query=" - SELECT - *, UPPER(tbl_studiengang.typ::varchar(1) || tbl_studiengang.kurzbz) as stg_kurzbz, - tbl_lehrveranstaltung.semester as lv_semester, - lehrfach.kurzbz as lehrfach, - lehrfach.bezeichnung as lehrfach_bez, - tbl_lehreinheitmitarbeiter.semesterstunden as semesterstunden, - tbl_lehrveranstaltung.bezeichnung as lv_bezeichnung, - tbl_lehreinheit.anmerkung as le_anmerkung, - tbl_lehreinheit.lehrform_kurzbz as le_lehrform_kurzbz, - (SELECT kurzbz FROM public.tbl_mitarbeiter WHERE mitarbeiter_uid=tbl_lehreinheitmitarbeiter.mitarbeiter_uid) as lektor, - tbl_lehrveranstaltung.lehrveranstaltung_id - FROM +//Lehrveranstaltungen abfragen. +$sql_query = " + SELECT + *, UPPER(tbl_studiengang.typ::varchar(1) || tbl_studiengang.kurzbz) as stg_kurzbz, + tbl_lehrveranstaltung.semester as lv_semester, + lehrfach.kurzbz as lehrfach, + lehrfach.bezeichnung as lehrfach_bez, + tbl_lehreinheitmitarbeiter.semesterstunden as semesterstunden, + tbl_lehrveranstaltung.bezeichnung as lv_bezeichnung, + tbl_lehreinheit.anmerkung as le_anmerkung, + tbl_lehreinheit.lehrform_kurzbz as le_lehrform_kurzbz, + (SELECT kurzbz FROM public.tbl_mitarbeiter + WHERE mitarbeiter_uid=tbl_lehreinheitmitarbeiter.mitarbeiter_uid) as lektor, + tbl_lehrveranstaltung.lehrveranstaltung_id + FROM lehre.tbl_lehreinheit JOIN lehre.tbl_lehreinheitmitarbeiter USING(lehreinheit_id) JOIN lehre.tbl_lehrveranstaltung USING(lehrveranstaltung_id) JOIN public.tbl_studiengang USING(studiengang_kz) JOIN lehre.tbl_lehrveranstaltung as lehrfach ON(tbl_lehreinheit.lehrfach_id=lehrfach.lehrveranstaltung_id) - WHERE tbl_lehreinheit.studiensemester_kurzbz=".$db->db_add_param($stdsem)." AND mitarbeiter_uid=".$db->db_add_param($uid); - $sql_query.=" ORDER BY stg_kurzbz,lv_semester,lv_bezeichnung"; - $result=$db->db_query($sql_query); - $num_rows=$db->db_num_rows($result); + WHERE + tbl_lehreinheit.studiensemester_kurzbz = ".$db->db_add_param($stdsem)." + AND mitarbeiter_uid = ".$db->db_add_param($uid)." + ORDER BY stg_kurzbz,lv_semester,lv_bezeichnung"; - echo ' - - - - '.$p->t('lvaliste/titel').' - - - - - - - - - - - - -

'.$p->t('lvaliste/titel').' ( '.$stdsem.' )

'; - echo '
*" . $p->t('tools/legendeNotendurchschnitt') . "
**" . $p->t('tools/legendeGewichteterNotendurchschnitt') . "
" . $p->t('tools/hinweistextMarkierung') . "
'; - for ($i=0;$i<$num_rows_stdsem;$i++) - { - $row=$db->db_fetch_object($result_stdsem); - if ($stdsem==$row->studiensemester_kurzbz) - echo ''.$row->studiensemester_kurzbz.' - '; - else - echo ''.$row->studiensemester_kurzbz.' - '; - } - echo ''; - echo ''.$p->t('lvaliste/hilfeAnzeigen').''; - echo '

'; - if ($num_rows>0) - { - - echo '

'.$p->t('lvaliste/lehrveranstaltungen').'

'; - echo $p->t('lvaliste/anzahl').': '.$num_rows; - echo ' - - - '; - if(!defined('CIS_LVALISTE_NOTENEINGABE_ANZEIGEN') || CIS_LVALISTE_NOTENEINGABE_ANZEIGEN) - echo ''; - - - if($lvinfo) - echo ''; - - echo ' - - - - - - - - - - - - - - - - '; - // Lektoren sollen die Anmerkung dzt. nicht sehen, da nur für intern gedacht - - echo ' - '; - $stg_obj = new studiengang(); - $stg_obj->getAll(null,null); - $summe_std=0; - - for ($i=0; $i<$num_rows; $i++) + $("#t2").tablesorter( { - $row=$db->db_fetch_object($result); - - // Nur erteilte Vertraege anzeigen wenn dies im Config hinterlegt ist. - if (defined('CIS_LV_LEKTORINNENZUTEILUNG_VERTRAGSPRUEFUNG_VON') - && CIS_LV_LEKTORINNENZUTEILUNG_VERTRAGSPRUEFUNG_VON != '') - { - $vertrag = new vertrag(); - if (!$vertrag->isVertragErteiltLV($row->lehrveranstaltung_id, $stdsem, $user)) - { - continue; - } - } - - $lvangebot = new lvangebot(); - echo ''; - if(!defined('CIS_LVALISTE_NOTENEINGABE_ANZEIGEN') || CIS_LVALISTE_NOTENEINGABE_ANZEIGEN) - echo ''; - - if($lvinfo) - echo ''; - - echo ''; - echo ''; - echo ''; - if ($row->lehrfach_bez!=$row->lv_bezeichnung) - echo ''; - else - echo ''; - echo ''; - echo ''; - echo ''; - - $qry ="SELECT * FROM lehre.tbl_lehreinheitgruppe WHERE lehreinheit_id=".$db->db_add_param($row->lehreinheit_id); - $gruppe=''; - if($result_grp = $db->db_query($qry)) - { - while($row_grp = $db->db_fetch_object($result_grp)) - { - if($row_grp->gruppe_kurzbz!='') - $gruppe.= $row_grp->gruppe_kurzbz.'
'; - else - $gruppe.= $stg_obj->kuerzel_arr[$row->studiengang_kz].'-'.$row_grp->semester.$row_grp->verband.$row_grp->gruppe.'
'; - } - } - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - if(getSprache()=='German') - { - echo ''; - } - else - { - echo ''; - } - echo ''; - - $lvangebot->getAllFromLvId($row->lehrveranstaltung_id, $row->studiensemester_kurzbz); - if(!empty($lvangebot->result)) - { - echo ''; - echo ''; - } - else - { - echo ' - '; - } - //echo ''; Lektoren sollen die Anmerkung dzt. nicht sehen, da nur für intern gedacht - - echo ''; - $summe_std+=$row->semesterstunden; - } - echo ''; - echo ''; - echo ''; - if(!defined('CIS_LVALISTE_NOTENEINGABE_ANZEIGEN') || CIS_LVALISTE_NOTENEINGABE_ANZEIGEN) - echo ''; - if($lvinfo) - echo ''; - - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - if(getSprache()=='German') + sortList: [[0,0],[1,0],[3,0]], + widgets: ["zebra"] + }); + $("#t3").tablesorter( { - echo ''; - } - else - { - echo ''; - } - echo ''; - echo ''; - echo ''; - echo '
'.$p->t('lvaliste/gesamtnote').''.$p->t('lvaliste/lvinfo').''.$p->t('lvaliste/id').''.$p->t('lvaliste/lehrfach').''.$p->t('lvaliste/lehrform').''.$p->t('lvaliste/lvBezeichnung').''.$p->t('lvaliste/lektor').''.$p->t('lvaliste/studiengang').''.$p->t('lvaliste/semester').''.$p->t('lvaliste/gruppen').''.$p->t('lvaliste/raumtyp').''.$p->t('lvaliste/raumtypalternativ').''.$p->t('lvaliste/blockung').''.$p->t('lvaliste/wochenrythmus').''.$p->t('lvaliste/stunden').''.$p->t('lvaliste/kalenderwoche').'Anm. vonAnm. bis'.$p->t('lvaliste/anmerkung').'
'.$p->t('lvaliste/gesamtnote').''.$p->t('lvaliste/lvinfo').''.$row->lehreinheit_id.''.$row->lehrfach.''.$row->le_lehrform_kurzbz.''.$row->lv_bezeichnung.' ('.$p->t('lvaliste/lehrfach').': '.$row->lehrfach_bez.')'.$row->lv_bezeichnung.''.$row->lektor.''.$row->stg_kurzbz.''.$row->semester.''.$gruppe.''.$row->raumtyp.''.$row->raumtypalternativ.''.$row->stundenblockung.''.$row->wochenrythmus.''.number_format($row->semesterstunden,2,$dec_point=",",$thousands_sep=".").''.number_format($row->semesterstunden,2,$dec_point=".",$thousands_sep=",").''.$row->start_kw.''.$datum->formatDatum($lvangebot->result[0]->anmeldefenster_start, "d.m.Y").''.$datum->formatDatum($lvangebot->result[0]->anmeldefenster_ende, "d.m.Y").'  '.$row->le_anmerkung.'
             '.$p->t('lvaliste/summe').''.number_format($summe_std,2,$dec_point=",",$thousands_sep=".").''.number_format($summe_std,2,$dec_point=".",$thousands_sep=",").' 
'; - } + sortList: [[0,0],[1,0],[3,0]], + widgets: ["zebra"] + }); + }); + --> + + + +

'.$p->t('lvaliste/titel').' ( '.$stdsem.' )

'; +echo '
'; +for ($i = 0;$i < $num_rows_stdsem;$i++) +{ + $row = $db->db_fetch_object($result_stdsem); + if ($stdsem == $row->studiensemester_kurzbz) + echo ''.$row->studiensemester_kurzbz.' - '; else - echo $p->t('lvaliste/keineDatensaetze').'
'; + echo ''.$row->studiensemester_kurzbz.' - '; +} +echo '
'; +echo ''.$p->t('lvaliste/hilfeAnzeigen').''; +echo '

'; +if ($num_rows > 0) +{ + $anzahl_lvs = 0; + $lvtable = ' + + + '; + if (!defined('CIS_LVALISTE_NOTENEINGABE_ANZEIGEN') || CIS_LVALISTE_NOTENEINGABE_ANZEIGEN) + $lvtable .= ''; - //Betreuungen - - $mitarbeiter = new benutzer(); - $mitarbeiter->load($uid); - - $qry = "SELECT - tbl_lehrveranstaltung.bezeichnung, tbl_projektarbeit.titel, - (SELECT nachname || ' ' || vorname FROM public.tbl_benutzer JOIN public.tbl_person USING(person_id) - WHERE uid=student_uid) as student, tbl_lehrveranstaltung.studiengang_kz, tbl_lehrveranstaltung.semester, - tbl_studiengang.email, tbl_betreuerart.beschreibung AS beutreuerart_beschreibung, tbl_projektbetreuer.stunden - FROM - lehre.tbl_lehreinheit, lehre.tbl_lehrveranstaltung, lehre.tbl_projektarbeit, lehre.tbl_projektbetreuer, public.tbl_studiengang, lehre.tbl_betreuerart - WHERE - tbl_lehreinheit.lehreinheit_id=tbl_projektarbeit.lehreinheit_id AND - tbl_lehreinheit.lehrveranstaltung_id=tbl_lehrveranstaltung.lehrveranstaltung_id AND - tbl_lehreinheit.studiensemester_kurzbz=".$db->db_add_param($stdsem)." AND - tbl_projektarbeit.projektarbeit_id=tbl_projektbetreuer.projektarbeit_id AND - tbl_lehrveranstaltung.studiengang_kz=tbl_studiengang.studiengang_kz AND - tbl_projektbetreuer.betreuerart_kurzbz=tbl_betreuerart.betreuerart_kurzbz AND - tbl_projektbetreuer.person_id=".$db->db_add_param($mitarbeiter->person_id, FHC_INTEGER); + if ($lvinfo) + $lvtable .= ''; + $lvtable .= ' + + + + + + + + + + + + + + + + + + '; $stg_obj = new studiengang(); $stg_obj->getAll(null,null); $summe_std = 0; - if($result = $db->db_query($qry)) + for ($i = 0; $i < $num_rows; $i++) { - if($db->db_num_rows($result)>0) + $row = $db->db_fetch_object($result); + + // Nur erteilte Vertraege anzeigen wenn dies im Config hinterlegt ist. + if (defined('CIS_LV_LEKTORINNENZUTEILUNG_VERTRAGSPRUEFUNG_VON') + && CIS_LV_LEKTORINNENZUTEILUNG_VERTRAGSPRUEFUNG_VON != '') { - echo '

'.$p->t('lvaliste/betreuungen').'

'; - echo $p->t('lvaliste/anzahl').': '.$db->db_num_rows($result); - echo '
'.$p->t('lvaliste/gesamtnote').''.$p->t('lvaliste/lvinfo').''.$p->t('lvaliste/id').''.$p->t('lvaliste/lehrfach').''.$p->t('lvaliste/lehrform').''.$p->t('lvaliste/lvBezeichnung').''.$p->t('lvaliste/lektor').''.$p->t('lvaliste/studiengang').''.$p->t('lvaliste/semester').''.$p->t('lvaliste/gruppen').''.$p->t('lvaliste/raumtyp').''.$p->t('lvaliste/raumtypalternativ').''.$p->t('lvaliste/blockung').''.$p->t('lvaliste/wochenrythmus').''.$p->t('lvaliste/stunden').''.$p->t('lvaliste/kalenderwoche').'Anm. vonAnm. bis
'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - while($row = $db->db_fetch_object($result)) + $vertrag = new vertrag(); + if (!$vertrag->isVertragErteiltLV($row->lehrveranstaltung_id, $stdsem, $user)) { - echo ''; - echo ''; - echo ''; - if(getSprache()=='German') - { - echo ''; - } + continue; + } + } + $anzahl_lvs++; + + $lvangebot = new lvangebot(); + $lvtable .= ''; + if (!defined('CIS_LVALISTE_NOTENEINGABE_ANZEIGEN') || CIS_LVALISTE_NOTENEINGABE_ANZEIGEN) + $lvtable .= ''; + + if ($lvinfo) + $lvtable .= ''; + + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= ''; + if ($row->lehrfach_bez != $row->lv_bezeichnung) + $lvtable .= ''; + else + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= ''; + + $qry = " + SELECT * FROM lehre.tbl_lehreinheitgruppe + WHERE lehreinheit_id=".$db->db_add_param($row->lehreinheit_id); + + $gruppe = ''; + if ($result_grp = $db->db_query($qry)) + { + while ($row_grp = $db->db_fetch_object($result_grp)) + { + if ($row_grp->gruppe_kurzbz != '') + $gruppe .= $row_grp->gruppe_kurzbz.'
'; else - { - echo ''; - } - echo ''; - echo ''; - echo ''; - echo ''; - - $summe_std+=$row->stunden; + $gruppe .= $stg_obj->kuerzel_arr[$row->studiengang_kz].'-'.$row_grp->semester.$row_grp->verband.$row_grp->gruppe.'
'; } - echo ''; - echo ''; + } + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= ''; + if (getSprache() == 'German') + { + $lvtable .= ''; + } + else + { + $lvtable .= ''; + } + $lvtable .= ''; + + $lvangebot->getAllFromLvId($row->lehrveranstaltung_id, $row->studiensemester_kurzbz); + if (!empty($lvangebot->result)) + { + $lvtable .= ''; + $lvtable .= ''; + } + else + { + $lvtable .= ' + '; + } + + $lvtable .= ''; + $summe_std += $row->semesterstunden; + } + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= ''; + if (!defined('CIS_LVALISTE_NOTENEINGABE_ANZEIGEN') || CIS_LVALISTE_NOTENEINGABE_ANZEIGEN) + $lvtable .= ''; + if ($lvinfo) + $lvtable .= ''; + + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= ''; + if (getSprache() == 'German') + { + $lvtable .= ''; + } + else + { + $lvtable .= ''; + } + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= ''; + $lvtable .= '
'.$p->t('lvaliste/studiengang').''.$p->t('lvaliste/semester').''.$p->t('lvaliste/stunden').''.$p->t('lvaliste/lvBezeichnung').''.$p->t('lvaliste/student').''.$p->t('lvaliste/betreuungsart').''.$p->t('lvaliste/titelProjektarbeit').'
'.$stg_obj->kuerzel_arr[$row->studiengang_kz].''.$row->semester.''.number_format($row->stunden,2,$dec_point =",", $thousands_sep ="."). '
'.$p->t('lvaliste/gesamtnote').''.$p->t('lvaliste/lvinfo').''.$row->lehreinheit_id.''.$row->lehrfach.''.$row->le_lehrform_kurzbz.''.$row->lv_bezeichnung.' ('.$p->t('lvaliste/lehrfach').': '.$row->lehrfach_bez.')'.$row->lv_bezeichnung.''.$row->lektor.''.$row->stg_kurzbz.''.$row->semester.''.number_format($row->stunden,2,$dec_point =".", $thousands_sep =","). ''.$row->bezeichnung.''.$row->student.''.$row->beutreuerart_beschreibung.''.$row->titel.'
'.$gruppe.''.$row->raumtyp.''.$row->raumtypalternativ.''.$row->stundenblockung.''.$row->wochenrythmus.''.number_format($row->semesterstunden,2,$dec_point=",",$thousands_sep=".").''.number_format($row->semesterstunden,2,$dec_point=".",$thousands_sep=",").''.$row->start_kw.''.$datum->formatDatum($lvangebot->result[0]->anmeldefenster_start, "d.m.Y").''.$datum->formatDatum($lvangebot->result[0]->anmeldefenster_ende, "d.m.Y").'  
             '.$p->t('lvaliste/summe').''.number_format($summe_std, 2, $dec_point = ",", $thousands_sep = ".").''.number_format($summe_std, 2, $dec_point = ".", $thousands_sep = ",").' 
'; + + if($anzahl_lvs > 0) + { + echo '

'.$p->t('lvaliste/lehrveranstaltungen').'

'; + echo $p->t('lvaliste/anzahl').': '.$anzahl_lvs; + echo $lvtable; + } + else + { + echo $p->t('lvaliste/keineDatensaetze').'
'; + } +} +else + echo $p->t('lvaliste/keineDatensaetze').'
'; + +//Betreuungen +$mitarbeiter = new benutzer(); +$mitarbeiter->load($uid); + +$qry = "SELECT + tbl_lehrveranstaltung.bezeichnung, tbl_projektarbeit.titel, + (SELECT nachname || ' ' || vorname FROM public.tbl_benutzer JOIN public.tbl_person USING(person_id) + WHERE uid=student_uid) as student, tbl_lehrveranstaltung.studiengang_kz, tbl_lehrveranstaltung.semester, + tbl_studiengang.email, tbl_betreuerart.beschreibung AS beutreuerart_beschreibung, tbl_projektbetreuer.stunden + FROM + lehre.tbl_lehreinheit, lehre.tbl_lehrveranstaltung, lehre.tbl_projektarbeit, lehre.tbl_projektbetreuer, public.tbl_studiengang, lehre.tbl_betreuerart + WHERE + tbl_lehreinheit.lehreinheit_id=tbl_projektarbeit.lehreinheit_id AND + tbl_lehreinheit.lehrveranstaltung_id=tbl_lehrveranstaltung.lehrveranstaltung_id AND + tbl_lehreinheit.studiensemester_kurzbz=".$db->db_add_param($stdsem)." AND + tbl_projektarbeit.projektarbeit_id=tbl_projektbetreuer.projektarbeit_id AND + tbl_lehrveranstaltung.studiengang_kz=tbl_studiengang.studiengang_kz AND + tbl_projektbetreuer.betreuerart_kurzbz=tbl_betreuerart.betreuerart_kurzbz AND + tbl_projektbetreuer.person_id=".$db->db_add_param($mitarbeiter->person_id, FHC_INTEGER); + +$stg_obj = new studiengang(); +$stg_obj->getAll(null,null); +$summe_std = 0; + +if ($result = $db->db_query($qry)) +{ + if ($db->db_num_rows($result) > 0) + { + echo '
'; + echo '

'.$p->t('lvaliste/betreuungen').'

'; + echo $p->t('lvaliste/anzahl').': '.$db->db_num_rows($result); + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + while ($row = $db->db_fetch_object($result)) + { echo ''; - if(!defined('CIS_LVALISTE_NOTENEINGABE_ANZEIGEN') || CIS_LVALISTE_NOTENEINGABE_ANZEIGEN) + echo ''; + echo ''; + if (getSprache() == 'German') { - echo ''; - } - if($lvinfo) - - echo ''; - - if(getSprache()=='German') - { - echo ''; + echo ''; } else { - echo ''; + echo ''; } + echo ''; + echo ''; + echo ''; + echo ''; - - echo ''; - - echo ''; - - echo '
'.$p->t('lvaliste/studiengang').''.$p->t('lvaliste/semester').''.$p->t('lvaliste/stunden').''.$p->t('lvaliste/lvBezeichnung').''.$p->t('lvaliste/student').''.$p->t('lvaliste/betreuungsart').''.$p->t('lvaliste/titelProjektarbeit').'
'.$stg_obj->kuerzel_arr[$row->studiengang_kz].''.$row->semester.' '.$p->t('lvaliste/summe').''.number_format($summe_std,2,$dec_point=",",$thousands_sep=".").''.number_format($row->stunden,2,$dec_point =",", $thousands_sep ="."). ''.number_format($summe_std,2,$dec_point=".",$thousands_sep=",").''.number_format($row->stunden,2,$dec_point =".", $thousands_sep =","). ''.$row->bezeichnung.''.$row->student.''.$row->beutreuerart_beschreibung.''.$row->titel.' 
'; + $summe_std += $row->stunden; } - } - - - //Koordination - - $qry = "SELECT - distinct - tbl_lehrveranstaltung.studiengang_kz, tbl_fachbereich.fachbereich_kurzbz, tbl_lehrveranstaltung.bezeichnung, - tbl_lehrveranstaltung.lehrveranstaltung_id, tbl_lehrveranstaltung.semester,tbl_lehrveranstaltung.koordinator, - tbl_studiengang.email - FROM - lehre.tbl_lehrveranstaltung, - lehre.tbl_lehreinheit, - lehre.tbl_lehrveranstaltung as lehrfach, - public.tbl_studiengang, - public.tbl_fachbereich - WHERE - tbl_lehrveranstaltung.lehrveranstaltung_id=tbl_lehreinheit.lehrveranstaltung_id AND - tbl_lehreinheit.lehrfach_id = lehrfach.lehrveranstaltung_id AND - tbl_fachbereich.oe_kurzbz=lehrfach.oe_kurzbz AND - tbl_lehreinheit.studiensemester_kurzbz=".$db->db_add_param($stdsem)." AND - (tbl_lehrveranstaltung.koordinator=".$db->db_add_param($uid)." - OR - ( tbl_lehrveranstaltung.koordinator is null and (tbl_lehrveranstaltung.studiengang_kz, fachbereich_kurzbz) IN (SELECT studiengang_kz, fachbereich_kurzbz - FROM public.tbl_benutzerfunktion JOIN public.tbl_studiengang USING(oe_kurzbz) - WHERE funktion_kurzbz='fbk' AND uid=".$db->db_add_param($uid)." - and ( tbl_benutzerfunktion.datum_bis is null or now() between tbl_benutzerfunktion.datum_von and tbl_benutzerfunktion.datum_bis ) - )) - ) AND - tbl_lehrveranstaltung.studiengang_kz=tbl_studiengang.studiengang_kz - order by tbl_lehrveranstaltung.studiengang_kz,tbl_lehrveranstaltung.semester ,tbl_lehrveranstaltung.bezeichnung - "; - - - if($result = $db->db_query($qry)) - { - if($db->db_num_rows($result)>0) + echo ''; + echo ''; + echo ''; + if (!defined('CIS_LVALISTE_NOTENEINGABE_ANZEIGEN') || CIS_LVALISTE_NOTENEINGABE_ANZEIGEN) { - echo '

'.$p->t('lvaliste/koordination').'

'; - echo $p->t('lvaliste/anzahl').': '.$db->db_num_rows($result); - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - while($row = $db->db_fetch_object($result)) - { - //Fachbereichskoordinatoren holen - $qry = "SELECT distinct - uid,titelpre, titelpost, vorname, nachname - FROM - lehre.tbl_lehreinheitmitarbeiter, - public.tbl_benutzer, - public.tbl_person, - lehre.tbl_lehreinheit - WHERE - tbl_lehreinheitmitarbeiter.lehreinheit_id=tbl_lehreinheit.lehreinheit_id AND - tbl_lehreinheit.lehrveranstaltung_id=".$db->db_add_param($row->lehrveranstaltung_id, FHC_INTEGER)." AND - tbl_lehreinheitmitarbeiter.mitarbeiter_uid=tbl_benutzer.uid AND - tbl_benutzer.person_id=tbl_person.person_id AND - tbl_lehreinheit.studiensemester_kurzbz=".$db->db_add_param($stdsem); - $lektoren=''; - if($result_lkt = $db->db_query($qry)) - { - while($row_lkt = $db->db_fetch_object($result_lkt)) - { - if($lektoren!='') - $lektoren.=','; - $lektoren.=trim($row_lkt->titelpre.' '.$row_lkt->vorname.' '.$row_lkt->nachname.' '.$row_lkt->titelpost); - } - } - - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - } - echo '
'.$p->t('lvaliste/studiengang').''.$p->t('lvaliste/semester').''.$p->t('lvaliste/institut').''.$p->t('lvaliste/lvBezeichnung').''.$p->t('lvaliste/lektor').'
'.$stg_obj->kuerzel_arr[$row->studiengang_kz].''.$row->semester.''.$row->stunden.''.$row->fachbereich_kurzbz.''.$row->bezeichnung.''.$lektoren.'
'; + echo ' '; } + if ($lvinfo) + + echo ''.$p->t('lvaliste/summe').''; + + if (getSprache() == 'German') + { + echo ''.number_format($summe_std, 2, $dec_point = ",", $thousands_sep = ".").''; + } + else + { + echo ''.number_format($summe_std, 2, $dec_point = ".", $thousands_sep = ",").''; + } + + echo ' '; + echo ''; + echo ''; } +} + +//Koordination +$qry = "SELECT + distinct + tbl_lehrveranstaltung.studiengang_kz, tbl_fachbereich.fachbereich_kurzbz, tbl_lehrveranstaltung.bezeichnung, + tbl_lehrveranstaltung.lehrveranstaltung_id, tbl_lehrveranstaltung.semester,tbl_lehrveranstaltung.koordinator, + tbl_studiengang.email + FROM + lehre.tbl_lehrveranstaltung, + lehre.tbl_lehreinheit, + lehre.tbl_lehrveranstaltung as lehrfach, + public.tbl_studiengang, + public.tbl_fachbereich + WHERE + tbl_lehrveranstaltung.lehrveranstaltung_id=tbl_lehreinheit.lehrveranstaltung_id AND + tbl_lehreinheit.lehrfach_id = lehrfach.lehrveranstaltung_id AND + tbl_fachbereich.oe_kurzbz=lehrfach.oe_kurzbz AND + tbl_lehreinheit.studiensemester_kurzbz=".$db->db_add_param($stdsem)." AND + ( + tbl_lehrveranstaltung.koordinator=".$db->db_add_param($uid)." + OR + ( tbl_lehrveranstaltung.koordinator is null + AND (tbl_lehrveranstaltung.studiengang_kz, fachbereich_kurzbz) IN ( + SELECT studiengang_kz, fachbereich_kurzbz + FROM public.tbl_benutzerfunktion JOIN public.tbl_studiengang USING(oe_kurzbz) + WHERE funktion_kurzbz='fbk' AND uid=".$db->db_add_param($uid)." + AND ( + tbl_benutzerfunktion.datum_bis is null + OR now() between tbl_benutzerfunktion.datum_von and tbl_benutzerfunktion.datum_bis ) + ) + ) + ) + AND tbl_lehrveranstaltung.studiengang_kz=tbl_studiengang.studiengang_kz + ORDER BY + tbl_lehrveranstaltung.studiengang_kz, + tbl_lehrveranstaltung.semester, + tbl_lehrveranstaltung.bezeichnung + "; + + +if ($result = $db->db_query($qry)) +{ + if ($db->db_num_rows($result) > 0) + { + echo '

'.$p->t('lvaliste/koordination').'

'; + echo $p->t('lvaliste/anzahl').': '.$db->db_num_rows($result); + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + while ($row = $db->db_fetch_object($result)) + { + //Fachbereichskoordinatoren holen + $qry = "SELECT distinct + uid,titelpre, titelpost, vorname, nachname + FROM + lehre.tbl_lehreinheitmitarbeiter, + public.tbl_benutzer, + public.tbl_person, + lehre.tbl_lehreinheit + WHERE + tbl_lehreinheitmitarbeiter.lehreinheit_id=tbl_lehreinheit.lehreinheit_id AND + tbl_lehreinheit.lehrveranstaltung_id=".$db->db_add_param($row->lehrveranstaltung_id, FHC_INTEGER)." AND + tbl_lehreinheitmitarbeiter.mitarbeiter_uid=tbl_benutzer.uid AND + tbl_benutzer.person_id=tbl_person.person_id AND + tbl_lehreinheit.studiensemester_kurzbz=".$db->db_add_param($stdsem); + $lektoren=''; + if($result_lkt = $db->db_query($qry)) + { + while($row_lkt = $db->db_fetch_object($result_lkt)) + { + if($lektoren!='') + $lektoren.=','; + $lektoren.=trim($row_lkt->titelpre.' '.$row_lkt->vorname.' '.$row_lkt->nachname.' '.$row_lkt->titelpost); + } + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo '
'.$p->t('lvaliste/studiengang').''.$p->t('lvaliste/semester').''.$p->t('lvaliste/institut').''.$p->t('lvaliste/lvBezeichnung').''.$p->t('lvaliste/lektor').'
'.$stg_obj->kuerzel_arr[$row->studiengang_kz].''.$row->semester.''.$row->stunden.''.$row->fachbereich_kurzbz.''.$row->bezeichnung.''.$lektoren.'
'; + } +} echo '
'.$p->t('lvaliste/fehlerAnStudiengang').'


'; ?>