diff --git a/application/config/navigation.php b/application/config/navigation.php index 1d8efb4c5..9253c87a1 100644 --- a/application/config/navigation.php +++ b/application/config/navigation.php @@ -14,6 +14,7 @@ $config['navigation_header'] = array( 'icon' => 'sitemap', 'description' => 'Organisation', 'sort' => 20, + 'requiredPermissions' => 'basis/vilesci:r', 'children'=> array( 'vilesci' => array( 'link' => base_url('vilesci'), @@ -30,6 +31,7 @@ $config['navigation_header'] = array( 'icon' => 'graduation-cap', 'description' => 'Lehre', 'sort' => 30, + 'requiredPermissions' => 'basis/vilesci:r', 'children'=> array( 'cis' => array( 'link' => CIS_ROOT, @@ -51,6 +53,16 @@ $config['navigation_header'] = array( 'sort' => 30, 'requiredPermissions' => 'infocenter:r' ), + 'lehrauftrag' => array( + 'link' => site_url('lehre/lehrauftrag/Lehrauftrag/Dashboard'), + 'description' => 'Lehrauftrag', + 'expand' => true, + 'sort' => 40, + 'requiredPermissions' => array( + 'lehre/lehrauftrag_bestellen:r', + 'lehre/lehrauftrag_erteilen:r' + ) + ) ) ), 'Personen' => array( @@ -58,6 +70,7 @@ $config['navigation_header'] = array( 'icon' => 'user', 'description' => 'Personen', 'sort' => 40, + 'requiredPermissions' => 'basis/vilesci:r', 'children'=> array( 'bpk' => array( 'link' => site_url('person/BPKWartung'), @@ -125,3 +138,62 @@ $config['navigation_menu']['organisation/Reihungstest/index'] = array( 'target' => '_blank' ) ); + +$config['navigation_menu']['lehre/lehrauftrag/Lehrauftrag/*'] = array( + 'lehrauftragDashboard' => array( + 'link' => site_url('lehre/lehrauftrag/Lehrauftrag/Dashboard'), + 'description' => 'Dashboard', + 'icon' => 'dashboard', + 'sort' => 1, + 'requiredPermissions' => array('lehre/lehrauftrag_bestellen:r','lehre/lehrauftrag_erteilen:r') + ),'lehrauftragBestellen' => array( + 'link' => site_url('lehre/lehrauftrag/Lehrauftrag'), + 'description' => 'Lehrauftrag bestellen', + 'icon' => '', + 'sort' => 1, + 'requiredPermissions' => 'lehre/lehrauftrag_bestellen:r' + ), + 'lehrauftragErteilen' => array( + 'link' => site_url('lehre/lehrauftrag/LehrauftragErteilen'), + 'description' => 'Lehrauftrag erteilen', + 'icon' => '', + 'sort' => 1, + 'requiredPermissions' => 'lehre/lehrauftrag_erteilen:r' + ), + 'lehrauftragLehrendeÜbersicht' => array( + 'link' => site_url('lehre/lehrauftrag/Lehrauftrag/LehrendeUebersicht'), + 'description' => 'Lehrendenübersicht', + 'icon' => '', + 'sort' => 1, + 'requiredPermissions' => array('lehre/lehrauftrag_erteilen:r') + ) +); +$config['navigation_menu']['lehre/lehrauftrag/LehrauftragErteilen/*'] = array( + 'lehrauftragDashboard' => array( + 'link' => site_url('lehre/lehrauftrag/Lehrauftrag/Dashboard'), + 'description' => 'Dashboard', + 'icon' => 'dashboard', + 'sort' => 1, + 'requiredPermissions' => array('lehre/lehrauftrag_bestellen:r','lehre/lehrauftrag_erteilen:r') + ),'lehrauftragBestellen' => array( + 'link' => site_url('lehre/lehrauftrag/Lehrauftrag'), + 'description' => 'Lehrauftrag bestellen', + 'icon' => '', + 'sort' => 1, + 'requiredPermissions' => 'lehre/lehrauftrag_bestellen:r' + ), + 'lehrauftragErteilen' => array( + 'link' => site_url('lehre/lehrauftrag/LehrauftragErteilen'), + 'description' => 'Lehrauftrag erteilen', + 'icon' => '', + 'sort' => 1, + 'requiredPermissions' => 'lehre/lehrauftrag_erteilen:r' + ), + 'lehrauftragLehrendeÜbersicht' => array( + 'link' => site_url('lehre/lehrauftrag/Lehrauftrag/LehrendeUebersicht'), + 'description' => 'Lehrendenübersicht', + 'icon' => '', + 'sort' => 1, + 'requiredPermissions' => array('lehre/lehrauftrag_erteilen:r') + ) +); diff --git a/application/controllers/Redirect.php b/application/controllers/Redirect.php index 8a24c590d..8a107b4b3 100644 --- a/application/controllers/Redirect.php +++ b/application/controllers/Redirect.php @@ -37,12 +37,13 @@ class Redirect extends FHC_Controller public function redirectByToken($token) { $msg = $this->MessageTokenModel->getMessageByToken($token); - if ($msg->error) + if (isError($msg)) { - show_error($msg->retval); + show_error(getError($msg)); } - $oe_kurzbz = $msg->retval[0]->oe_kurzbz; + $oe_kurzbz = null; + if (hasData($msg)) $oe_kurzbz = getData($msg)[0]->oe_kurzbz; if ($oe_kurzbz != null && $oe_kurzbz != '') { @@ -51,7 +52,7 @@ class Redirect extends FHC_Controller $getOERoot = $this->MessageTokenModel->getOERoot($oe_kurzbz); if (isSuccess($getOERoot)) // If no errors occurred { - $organisationRoot = $getOERoot->retval; + $organisationRoot = getData($getOERoot); } else { diff --git a/application/controllers/ViewMessage.php b/application/controllers/ViewMessage.php index 3c22c8977..4e076e99d 100644 --- a/application/controllers/ViewMessage.php +++ b/application/controllers/ViewMessage.php @@ -43,19 +43,17 @@ class ViewMessage extends FHC_Controller public function toHTML($token) { $msg = $this->MessageTokenModel->getMessageByToken($token); - - if ($msg->error) + if (isError($msg)) { - show_error(getData($msg)); + show_error(getError($msg)); } if (is_array(getData($msg)) && count(getData($msg)) > 0) { $setReadMessageStatusByToken = $this->MessageTokenModel->setReadMessageStatusByToken($token); - if (isError($setReadMessageStatusByToken)) { - show_error($msg->$setReadMessageStatusByToken); + show_error(getError($setReadMessageStatusByToken)); } $sender_id = getData($msg)[0]->sender_id; @@ -64,9 +62,9 @@ class ViewMessage extends FHC_Controller // To decide how to change the redirection $isEmployee = $this->MessageTokenModel->isEmployee($receiver_id); - if (!is_bool($isEmployee) && isError($isEmployee)) + if (isError($isEmployee)) { - show_error($isEmployee); + show_error(getError($isEmployee)); } if($this->config->item('redirect_view_message_url') != '') @@ -78,7 +76,7 @@ class ViewMessage extends FHC_Controller 'sender_id' => $sender_id, 'sender' => getData($sender)[0], 'message' => getData($msg)[0], - 'isEmployee' => $isEmployee, + 'isEmployee' => hasData($isEmployee), 'href' => $href ); @@ -144,7 +142,7 @@ class ViewMessage extends FHC_Controller $sendReply = $this->CLMessagesModel->sendReply($subject, $body, $persons, $relationmessage_id, $token); if (isError($sendReply)) { - show_error(getData($sendReply)); + show_error(getError($sendReply)); } $this->load->view('system/messages/messageReplySent'); diff --git a/application/controllers/crm/Statusgrund.php b/application/controllers/crm/Statusgrund.php index 472270ef3..344ac06dc 100644 --- a/application/controllers/crm/Statusgrund.php +++ b/application/controllers/crm/Statusgrund.php @@ -35,7 +35,7 @@ class Statusgrund extends Auth_Controller $status = $this->StatusModel->load(); if ($status->error) { - show_error($status->retval); + show_error(getError($status)); } $data = array ( @@ -50,7 +50,7 @@ class Statusgrund extends Auth_Controller $statusGrund = $this->StatusgrundModel->loadWhere(array("status_kurzbz" => $status_kurzbz)); if ($statusGrund->error) { - show_error($statusGrund->retval); + show_error(getError($statusGrund)); } $data = array ( @@ -66,13 +66,13 @@ class Statusgrund extends Auth_Controller $statusGrund = $this->StatusgrundModel->load($statusgrund_id); if ($statusGrund->error) { - show_error($statusGrund->retval); + show_error(getError($statusGrund)); } $sprache = $this->SpracheModel->loadWhere(array('content' => true)); if ($sprache->error) { - show_error($sprache->retval); + show_error(getError($sprache)); } $data = array ( @@ -89,13 +89,13 @@ class Statusgrund extends Auth_Controller $status = $this->StatusModel->load($status_id); if ($status->error) { - show_error($status->retval); + show_error(getError($status)); } $sprache = $this->SpracheModel->loadWhere(array('content' => true)); if ($sprache->error) { - show_error($sprache->retval); + show_error(getError($sprache)); } $data = array ( @@ -112,7 +112,7 @@ class Statusgrund extends Auth_Controller $sprache = $this->SpracheModel->loadWhere(array('content' => true)); if ($sprache->error) { - show_error($sprache->retval); + show_error(getError($sprache)); } $data = array ( @@ -184,7 +184,7 @@ class Statusgrund extends Auth_Controller if ($statusgrund->error) { - show_error($statusgrund->retval); + show_error(getError($statusgrund)); } redirect("/crm/Statusgrund/editGrund/" . $statusgrund_id . "/" . true); @@ -252,7 +252,7 @@ class Statusgrund extends Auth_Controller if ($statusgrund->error) { - show_error($statusgrund->retval); + show_error(getError($statusgrund)); } redirect("/crm/Statusgrund/editGrund/" . $statusgrund->retval . "/" . true); @@ -297,7 +297,7 @@ class Statusgrund extends Auth_Controller if ($status->error) { - show_error($status->retval); + show_error(getError($status)); } redirect("/crm/Statusgrund/editStatus/" . $status_kurzbz . "/" . true); diff --git a/application/controllers/jobs/AmpelMail.php b/application/controllers/jobs/AmpelMail.php index e29cac8fd..67acd76d0 100644 --- a/application/controllers/jobs/AmpelMail.php +++ b/application/controllers/jobs/AmpelMail.php @@ -121,13 +121,13 @@ class AmpelMail extends CLI_Controller } elseif (isError($result_ampel_user)) { - show_error($result_ampel_user->error); + show_error(getError($result_ampel_user)); } } } elseif (isError($result_active_ampeln)) { - show_error($result_active_ampeln->error); + show_error(getError($result_active_ampeln)); } // Send mails for new ampeln merged by user diff --git a/application/controllers/jobs/LehrauftragJob.php b/application/controllers/jobs/LehrauftragJob.php new file mode 100644 index 000000000..2f6b928c7 --- /dev/null +++ b/application/controllers/jobs/LehrauftragJob.php @@ -0,0 +1,536 @@ +load->model('accounting/Vertrag_model', 'VertragModel'); + $this->load->model('accounting/Vertragvertragsstatus_model', 'VertragvertragsstatusModel'); + $this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel'); + $this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); + $this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); + + // Load libraries + $this->load->library('PermissionLib'); + + // Load helpers + $this->load->helper('hlp_sancho_helper'); + } + + /** + * This daily job sends information about all lehr-/projektauftraege ordered (and not approved) the day bofore. + * Receivers: Department-/Kompetenzfeldleiter + **/ + public function mailLehrauftraegeToApprove() + { + // Get vertrag_ids of lehrauftraege that had been ordered and had NOT been approved or cancelled YESTERDAY + $this->VertragvertragsstatusModel->addSelect('vertrag_id'); + $result = $this->VertragvertragsstatusModel->getOrdered_fromDate('YESTERDAY'); + + // Get lehrveranstaltung_ids and studiensemester of the lehr-/or projektauftrag contracts + $lehreinheit_data_arr = array(); + if ($vertrag_arr = getData($result)) + { + foreach ($vertrag_arr as $vertrag) + { + $result = $this->VertragModel->getLehreinheitData($vertrag->vertrag_id, 'lehrveranstaltung_id, studiensemester_kurzbz'); + + if (hasData($result)) + { + $obj = new StdClass(); + $obj->lehrveranstaltung_id = $result->retval[0]->lehrveranstaltung_id; + $obj->studiensemester_kurzbz = $result->retval[0]->studiensemester_kurzbz; + $lehreinheit_data_arr []= $obj; + } + } + } + + /** + * Build the data array to be used in the email. Data array is clustered as follows: + * Array + * [studiensemester_kurzbz] // studiensemester of lehreinheit + * Array + * [oe_kurzbz] // oe of lehreinheits lehrveranstaltung + * [oe_bezeichnung] + * Array + * [stg_kz] // stg of lehreinheits lehrveranstaltung + * [stg_kurzbz] + * [stg_bezeichnung] + * [amount] // amount of new ordered lehrauftraege of that stg + */ + $data_arr = array(); + foreach ($lehreinheit_data_arr as $lehreinheit_data) + { + $result = $this->_getLVData($lehreinheit_data->lehrveranstaltung_id); + + if (hasData($result)) + { + // Search if studiensemester exists in data_arr + $ss_index = array_search($lehreinheit_data->studiensemester_kurzbz, array_column($data_arr, 'studiensemester_kurzbz')); + + // If studiensemester is new, add studienesemester, oe and stg + if ($ss_index === false) + { + $data = array( + 'studiensemester_kurzbz' => $lehreinheit_data->studiensemester_kurzbz + ); + + $data []= array( + 'oe_kurzbz' => $result->retval[0]->oe_kurzbz, + 'oe_bezeichnung' => $result->retval[0]->lv_oe_bezeichnung + ); + + // Add stg data to oe, start amount with 1 + $data[0][] = array( + 'stg_kz' => $result->retval[0]->studiengang_kz, + 'stg_kurzbz' => strtoupper($result->retval[0]->stg_typ. $result->retval[0]->stg_kurzbz), + 'stg_bezeichnung' => $result->retval[0]->lv_stg_bezeichnung, + 'amount' => 1 + ); + + // Push to final data_arr + $data_arr []= $data; + } + // Else if studiensemester exists + else + { + // Search if oe exists inside existing studiensemester of data_arr + $oe_index = array_search($result->retval[0]->oe_kurzbz, array_column($data_arr[$ss_index], 'oe_kurzbz')); + + // If oe is new, add oe and stg to studiensemester + if ($oe_index === false) + { + // Add oe data + $data_arr[$ss_index][] = array( + 'oe_kurzbz' => $result->retval[0]->oe_kurzbz, + 'oe_bezeichnung' => $result->retval[0]->lv_oe_bezeichnung, + + // Add stg data to oe, start amount with 1 + array( + 'stg_kz' => $result->retval[0]->studiengang_kz, + 'stg_kurzbz' => strtoupper($result->retval[0]->stg_typ. $result->retval[0]->stg_kurzbz), + 'stg_bezeichnung' => $result->retval[0]->lv_stg_bezeichnung, + 'amount' => 1 + ) + ); + } + // Else if oe exists + else + { + // Search if stg exists inside existing oe of data_arr + $stg_index = array_search($result->retval[0]->studiengang_kz, array_column($data_arr[$ss_index][$oe_index], 'stg_kz')); + + // If stg is new, add stg to oe, start amount with 1 + if ($stg_index === false) + { + $data_arr[$ss_index][$oe_index][] = array( + 'stg_kz' => $result->retval[0]->studiengang_kz, + 'stg_kurzbz' => strtoupper($result->retval[0]->stg_typ. $result->retval[0]->stg_kurzbz), + 'stg_bezeichnung' => $result->retval[0]->lv_stg_bezeichnung, + 'amount' => 1 + ); + } + // Else if stg exists + else + { + // Increase amount +1 + $data_arr[$ss_index][$oe_index][$stg_index]['amount']++; + } + } + } + } + } + + /** + * Cluster data by uid of entitled mail receivers. + * Returning array is clustered as follows: + * Array + * [uid] + * Array + * [studiensemester_kurzbz] // studiensemester of lehreinheit + * Array + * [oe_kurzbz] // oe of lehreinheits lehrveranstaltung + * [oe_bezeichnung] + * Array + * [stg_kz] // stg of lehreinheits lehrveranstaltung + * [stg_kurzbz] + * [stg_bezeichnung] + * [amount] // amount of new ordered lehrauftraege of that stg + */ + $data_arr = $this->_clusterData_byReceiver($data_arr); + + // Send email + if(!$this->_sendMail_toApprove($data_arr)) + { + $this->logInfo('SUCCEDED: Sending emails about yesterdays ordered lehrauftraege succeded.'); + } + else + { + $this->logError('Error when sending emails in job MailLehrauftragToApprove'); + } + } + + /** + * This daily job sends information about all lehr-/projektauftraege approved the day bofore. + * Receivers: lectors + **/ + public function mailLehrauftraegeToAccept() + { + // Get vertrag_id and uid of lehrauftraege that had been approved and had NOT been accepted or cancelled YESTERDAY + $this->VertragvertragsstatusModel->addSelect('vertrag_id, uid'); + $this->VertragvertragsstatusModel->addOrder('uid'); + $result = $this->VertragvertragsstatusModel->getApproved_fromDate('YESTERDAY'); + + /** + * Build the data array to be used in the email. Data array is clustered as follows: + * Array + * [uid] // lectors uid (mail receiver) + * [studiensemester] // studiensemester of the lehrauftraege (can be more, e.g. 'WS2019 and SS2020') + * [amount] // amount of new approved lehrauftraege + **/ + $data_arr = array(); + if ($vertrag_arr = getData($result)) + { + foreach ($vertrag_arr as $vertrag) + { + // Get studiensemester of the lehrauftrag + $this->VertragModel->addSelect('vertragsstunden_studiensemester_kurzbz'); + $result = $this->VertragModel->load($vertrag->vertrag_id); + if ($studiensemester = getData($result)) + { + $studiensemester = $studiensemester[0]->vertragsstunden_studiensemester_kurzbz; + } + + // Search if uid exists in data_arr + $uid_index = array_search($vertrag->uid, array_column($data_arr, 'uid')); + + // If uid is new, add uid, studiensemester and start amount with 1 + if ($uid_index === false) + { + $data = array(); + $data['uid'] = $vertrag->uid; + $data['studiensemester'] = $studiensemester; + $data['amount']= 1; + $data_arr []= $data; + } + // Else if uid exists + else + { + // If studiensemester is new, add to studiensemester-string + if (strpos($data_arr[$uid_index]['studiensemester'], $studiensemester) === false) + { + $data_arr[$uid_index]['studiensemester'] .= ' und '. $studiensemester; + } + + // Increase amount +1 + $data_arr[$uid_index]['amount']++; + } + } + } + + // Send email + if ($this->_sendMail_toAccept($data_arr)) + { + $this->logInfo('SUCCEDED: Sending emails about yesterdays approved lehrauftraege succeded.'); + } + else + { + $this->logError('Error when sending emails in job MailLehrauftragToAccept'); + } + } + + //****************************************************************************************************************** + // PRIVATE FUNCTIONS + //****************************************************************************************************************** + + /** + * Get data of given lehrveranstaltung. + * @param $lehrveranstaltung_id + * @return mixed + */ + private function _getLVData($lehrveranstaltung_id) + { + $this->LehrveranstaltungModel->addSelect(' + tbl_lehrveranstaltung.oe_kurzbz, + oe.bezeichnung AS "lv_oe_bezeichnung", + tbl_lehrveranstaltung.studiengang_kz, + stg.bezeichnung AS "lv_stg_bezeichnung", + stg.typ AS "stg_typ", + stg.kurzbz AS "stg_kurzbz" + '); + + $this->LehrveranstaltungModel->addJoin('lehre.tbl_studienplan_lehrveranstaltung stpllv', 'lehrveranstaltung_id'); + $this->LehrveranstaltungModel->addJoin('lehre.tbl_studienplan stpl', 'studienplan_id'); + $this->LehrveranstaltungModel->addJoin('lehre.tbl_studienordnung sto', 'studienordnung_id'); + $this->LehrveranstaltungModel->addJoin('public.tbl_studiengang stg', 'ON stg.studiengang_kz = tbl_lehrveranstaltung.studiengang_kz'); + $this->LehrveranstaltungModel->addJoin('public.tbl_organisationseinheit oe', 'ON oe.oe_kurzbz = tbl_lehrveranstaltung.oe_kurzbz'); + $this->LehrveranstaltungModel->addOrder('stpllv.insertamum', 'DESC'); + $this->LehrveranstaltungModel->addLimit(1); + + return $this->LehrveranstaltungModel->load($lehrveranstaltung_id); + } + + /** + * Send Sancho eMail about ordered Lehrauftraege. + * @param $data_arr + */ + private function _sendMail_toApprove($data_arr) + { + // Loop through 'container' of mail recipients + foreach($data_arr as $data) + { + // Set mail recipients (department assistance/leader) + $to = $data['uid']. '@'. DOMAIN; + $html_table = $this->_renderData_LehrauftraegeToApprove($data); + + // Prepare mail content + $content_data_arr = array( + 'table' => $html_table + ); + + sendSanchoMail( + 'LehrauftragNeueBestellungen', + $content_data_arr, + $to, + 'Bestellung neuer Lehraufträge', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg' + ); + } + } + + /** + * Cluster the data array by entitled mail receiver. + * Returning array is clustered as follows: + * Array + * [uid] + * Array + * [studiensemester_kurzbz] // studiensemester of lehreinheit + * Array + * [oe_kurzbz] // oe of lehreinheits lehrveranstaltung + * [oe_bezeichnung] + * Array + * [stg_kz] // stg of lehreinheits lehrveranstaltung + * [stg_kurzbz] + * [stg_bezeichnung] + * [amount] // amount of new ordered lehrauftraege of that stg + * @param $data_arr + * @return array + * + */ + private function _clusterData_byReceiver($data_arr) + { + $mail_data_arr = array(); // final array with all data clustered by mail receiver + + // Loop through 'container' of studiensemester + foreach ($data_arr as $data) + { + $data_len = count($data) - 1; + + // Loop through 'container' of organisational units + for ($i = 0; $i < $data_len; $i++) + { + // Get all users entitled by organisational unit + $result = $this->BenutzerrolleModel->getBenutzerByBerechtigung(self::BERECHTIGUNG_LEHRAUFTRAG_ERTEILEN, $data[$i]['oe_kurzbz']); + + if ($berechtigung_arr = getData($result)) + { + // Loop through entitled users + foreach ($berechtigung_arr as $berechtigung) + { + // Search if UID exists inside mail_data_arr + $uid_index = array_search($berechtigung->uid, array_column($mail_data_arr, 'uid')); + + // If UID is new, add UID to final array + if ($uid_index === false) + { + // add UID with corresponding data + $mail_data_arr [] = array( + 'uid' => $berechtigung->uid, + array( + 'studiensemester_kurzbz' => $data['studiensemester_kurzbz'], + $data[$i] + ) + ); + } // Else if UID exists + else + { + // Search if studiensemester exists + $ss_index = array_search($data['studiensemester_kurzbz'], array_column($mail_data_arr, 'studiensemester_kurzbz')); + + // If studiensemester is new, add studiensemester to existing UID + if ($ss_index === false) + { + $mail_data_arr[$uid_index] []= array( + 'studiensemester_kurzbz' => $data['studiensemester_kurzbz'], + $data[$i] + ); + } + // Else if studiensemester exists + else + { + // Add corresponding data to existing studiensemester of UID + $mail_data_arr[$uid_index]['studiensemester_kurbz'][] = $data[$i]; + } + + } + } + } + } + } + + return $mail_data_arr; + } + + /** + * Render the data array for the mail template returing a HTML table. + * @param $data_arr Data to be used in HTML table + * @return string HTML table to be embedded in eMail + */ + private function _renderData_LehrauftraegeToApprove($data_arr) + { + $html = ''; + foreach ($data_arr as $studiensemester_container) + { + if (is_array($studiensemester_container)) // is_array 'trims' the outer associative key [uid] + { + if (isset($studiensemester_container['studiensemester_kurzbz'])) + { + $studiensemester = $studiensemester_container['studiensemester_kurzbz']; + + // Link to LehrauftragErteilen + $url = site_url(self::LEHRAUFTRAG_ERTEILEN_URI).'?studiensemester='. $studiensemester; + } + + // HTML table header + $html .= ' +
+ Studiensemester: '. $studiensemester. ' +

+ + + + + + + + + + ' + ; + + // HTML table body + foreach ($studiensemester_container as $oe_container) + { + if (is_array($oe_container)) // is_array 'trims' the outer associative key [studiensemester_kurzbz] + { + if (isset($oe_container['oe_bezeichnung'])) + { + $oe_bezeichnung = $oe_container['oe_bezeichnung']; + } + + foreach ($oe_container as $stg_data) + { + if (is_array($stg_data)) // is_array 'trims' the outer associative keys [oe_kurzbz] and [oe_bezeichnung] + { + $html .= ' + + + + + + + '; + } + } + } + } + + // HTML table body end and link + $html .= ' + +
LV-OrganisationseinheitStudiengangSTG-KurzbezeichnungAnzahl neu bestellter Lehraufträge
'. $oe_bezeichnung. ''. $stg_data['stg_bezeichnung']. ''. $stg_data['stg_kurzbz']. ''. $stg_data['amount']. '
+
+ '. anchor($url, 'Lehraufträge Übersicht '. $studiensemester). ' +

+ '; + } + } + + return $html; + } + + /** + * Send Sancho eMail about ordered Lehrauftraege. + * @param $data_arr + */ + private function _sendMail_toAccept($data_arr) + { + // Loop through 'container' of mail recipients + foreach($data_arr as $data) + { + // Set mail recipient (lector) + $to = $data['uid']. '@'. DOMAIN; + + // Link to LehrauftragAkzeptieren + $url = CIS_ROOT. 'cis/index.php?menu='. + CIS_ROOT. 'cis/menu.php?content_id=&content='. + CIS_ROOT. index_page(). self::LEHRAUFTRAG_AKZEPTIEREN_URI; + + // Get first name + $first_name = ''; + $this->load->model('person/Benutzer_model', 'BenutzerModel'); + $this->BenutzerModel->addSelect('vorname'); + $this->BenutzerModel->addJoin('public.tbl_person', 'person_id'); + $result = $this->BenutzerModel->loadWhere(array('uid' => $data['uid'])); + + if (hasData($result)) + { + $first_name = $result->retval[0]->vorname; + } + + // Prepare mail content + $content_data_arr = array( + 'vorname' => $first_name, + 'studiensemester' => $data['studiensemester'], + 'anzahl' => $data['amount'], + 'link' => anchor($url, 'Lehraufträge Übersicht') + ); + + sendSanchoMail( + 'LehrauftragNeueErteilte', + $content_data_arr, + $to, + 'Neu erteilte Lehraufträge zum Annehmen bereit' + ); + } + } +} diff --git a/application/controllers/jobs/Prestudentstatus.php b/application/controllers/jobs/Prestudentstatus.php index e5b015753..a3b765f07 100644 --- a/application/controllers/jobs/Prestudentstatus.php +++ b/application/controllers/jobs/Prestudentstatus.php @@ -109,7 +109,7 @@ class Prestudentstatus extends CLI_Controller } else { - show_error($status->retval); + show_error(getError($status)); } echo "Corrected:".$sum_corrected."\n"; echo "Not Corrected:".$sum_notcorrected."\n"; diff --git a/application/controllers/jobs/ReihungstestJob.php b/application/controllers/jobs/ReihungstestJob.php index 5aa355b5f..84a5fe614 100644 --- a/application/controllers/jobs/ReihungstestJob.php +++ b/application/controllers/jobs/ReihungstestJob.php @@ -35,7 +35,7 @@ class ReihungstestJob extends CLI_Controller } elseif (isError($result)) { - show_error($result->error); + show_error(getError($result)); } // Get free places @@ -48,7 +48,7 @@ class ReihungstestJob extends CLI_Controller } elseif (isError($result)) { - show_error($result->error); + show_error(getError($result)); } // Prepare data for mail template 'ReihungstestJob' @@ -103,7 +103,7 @@ class ReihungstestJob extends CLI_Controller } elseif (isError($result)) { - show_error($result->error); + show_error(getError($result)); } $applicants_arr = array(); @@ -118,7 +118,7 @@ class ReihungstestJob extends CLI_Controller } elseif (isError($applicants)) { - show_error($applicants->error); + show_error(getError($applicants)); } // Get all Bachelor-Degree-Programs with Mailadress @@ -131,7 +131,7 @@ class ReihungstestJob extends CLI_Controller } elseif (isError($bachelorStudiengeange)) { - show_error($bachelorStudiengeange->error); + show_error(getError($bachelorStudiengeange)); } // If a person ist an applicant of this degree-program send mail with application data @@ -222,7 +222,7 @@ class ReihungstestJob extends CLI_Controller } elseif (isError($result)) { - show_error($result->error); + show_error(getError($result)); } $studiengang = ''; @@ -382,7 +382,7 @@ class ReihungstestJob extends CLI_Controller } elseif (isError($resultTestsOnDate)) { - show_error($resultTestsOnDate->error); + show_error(getError($resultTestsOnDate)); } } @@ -399,7 +399,7 @@ class ReihungstestJob extends CLI_Controller } elseif (isError($applicants)) { - show_error($applicants->error); + show_error(getError($applicants)); } foreach ($applicants_arr as $applicant) @@ -479,7 +479,7 @@ class ReihungstestJob extends CLI_Controller } elseif (isError($yesterdays_applicants_arr)) { - show_error($yesterdays_applicants_arr->error); + show_error(getError($yesterdays_applicants_arr)); } // Get all other prestudenten of the given persons. @@ -503,7 +503,7 @@ class ReihungstestJob extends CLI_Controller // 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 + typ = \'b\' AND teilgenommen = \'t\' AND tbl_reihungstest.studiensemester_kurzbz IN ( SELECT @@ -548,7 +548,7 @@ class ReihungstestJob extends CLI_Controller $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); @@ -569,7 +569,7 @@ class ReihungstestJob extends CLI_Controller { // Prepare content for mail template $content_data_arr = $this->_getContentDataNewApplicant($content_arr); - + // Send mail sendSanchoMail( 'BewerberNachReihungstest', @@ -786,4 +786,3 @@ class ReihungstestJob extends CLI_Controller } } } - diff --git a/application/controllers/lehre/lehrauftrag/Lehrauftrag.php b/application/controllers/lehre/lehrauftrag/Lehrauftrag.php new file mode 100644 index 000000000..3c0808d42 --- /dev/null +++ b/application/controllers/lehre/lehrauftrag/Lehrauftrag.php @@ -0,0 +1,347 @@ + 'lehre/lehrauftrag_bestellen:r', + 'orderLehrauftrag' => 'lehre/lehrauftrag_bestellen:rw', + 'Dashboard' => array('lehre/lehrauftrag_bestellen:r', 'lehre/lehrauftrag_erteilen:rw'), + 'LehrendeUebersicht' => array('lehre/lehrauftrag_erteilen:r') + ) + ); + + // Load models + $this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); + $this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + $this->load->model('accounting/Vertrag_model', 'VertragModel'); + + // Load libraries + $this->load->library('WidgetLib'); + $this->load->library('PermissionLib'); + + // Load helpers + $this->load->helper('array'); + $this->load->helper('url'); + $this->load->helper('hlp_sancho_helper'); + + // Load language phrases + $this->loadPhrases( + array( + 'global', + 'ui', + 'lehre' + ) + ); + + $this->_setAuthUID(); // sets property uid + + $this->setControllerId(); // sets the controller id + } + + /** + * Display of Custom Dashboard for Lehraufträge App + * Charts are hooked from Reporting Addon + */ + public function Dashboard() + { + $this->load->view('lehre/lehrauftrag/Dashboard.php'); + } + + /** + * Display of Lehrauftragsübersicht report + */ + public function LehrendeUebersicht() + { + $this->load->view('lehre/lehrauftrag/LehrendeUebersicht.php'); + } + + // ----------------------------------------------------------------------------------------------------------------- + // Public methods + /** + * Main page of Lehrauftrag + */ + public function index() + { + // Set studiengang selected for studiengang dropdown + $studiengang_kz = $this->input->get('studiengang'); // if provided by selected studiengang + $studiengang_kz = ($studiengang_kz == 'null' ? null : $studiengang_kz); + + // Retrieve studiengaenge the user is entitled for to populate studiengang dropdown + if (!$studiengang_kz_arr = $this->permissionlib->getSTG_isEntitledFor(self::BERECHTIGUNG_LEHRAUFTRAG_BESTELLEN)) { + show_error('Fehler bei Berechtigungsprüfung'); + } + + // If studiengang_kz get param was set, check against entitled stg + if (!is_null($studiengang_kz)) + { + if (!in_array($studiengang_kz, $studiengang_kz_arr)) + { + show_error('Keine Berechtigung für diesen Studiengang'); + } + } + + // Set studiensemester selected for studiengang dropdown + $studiensemester_kurzbz = $this->input->get('studiensemester'); // if provided by selected studiensemester + if (is_null($studiensemester_kurzbz)) // else set next studiensemester as default value + { + $studiensemester = $this->StudiensemesterModel->getNext(); + if (hasData($studiensemester)) + { + $studiensemester_kurzbz = $studiensemester->retval[0]->studiensemester_kurzbz; + } + elseif (isError($studiensemester)) + { + show_error(getError($studiensemester)); + } + } + + // Set ausbildungssemester selected for ausbildungssemester dropdown + $ausbildungssemester = $this->input->get('ausbildungssemester'); // if provided by selected ausbildungssemester + $ausbildungssemester = ($ausbildungssemester == 'null' ? null : $ausbildungssemester); + + $view_data = array( + 'studiengang_selected' => $studiengang_kz, + 'studiengang' => $studiengang_kz_arr, + 'studiensemester_selected' => $studiensemester_kurzbz, + 'ausbildungssemester_selected' => $ausbildungssemester, + ); + + $this->load->view('lehre/lehrauftrag/orderLehrauftrag.php', $view_data); + } + + public function orderLehrauftrag() + { + $new_lehrvertrag_data_arr = array(); // information of new lehrvertraege to be used in mail + $lehrauftrag_arr = json_decode($this->input->post('selected_data')); + + // Loop through lehraufträge + if(is_array($lehrauftrag_arr)) + { + foreach($lehrauftrag_arr as $lehrauftrag) + { + $lehreinheit_id = (isset($lehrauftrag->lehreinheit_id)) ? $lehrauftrag->lehreinheit_id : null; + $lehrveranstaltung_id = (isset($lehrauftrag->lehrveranstaltung_id)) ? $lehrauftrag->lehrveranstaltung_id : null; + $person_id = (isset($lehrauftrag->person_id)) ? $lehrauftrag->person_id : null; + $mitarbeiter_uid = (isset($lehrauftrag->mitarbeiter_uid)) ? $lehrauftrag->mitarbeiter_uid : null; + $vertrag_id = (isset($lehrauftrag->vertrag_id)) ? $lehrauftrag->vertrag_id : null; + $projektarbeit_id = (isset($lehrauftrag->projektarbeit_id)) ? $lehrauftrag->projektarbeit_id : null; + $stunden = (isset($lehrauftrag->stunden)) ? $lehrauftrag->stunden : 0; + $betrag = (isset($lehrauftrag->betrag)) ? $lehrauftrag->betrag : 0; + $studiensemester_kurzbz = (isset($lehrauftrag->studiensemester_kurzbz)) ? $lehrauftrag->studiensemester_kurzbz : null; + $studiengang_kz = (isset($lehrauftrag->studiengang_kz)) ? $lehrauftrag->studiengang_kz : null; + + // Check if user is entitled to order this Lehrauftrag + if (!$this->permissionlib->isBerechtigt(self::BERECHTIGUNG_LEHRAUFTRAG_BESTELLEN, 'suid', $studiengang_kz)) + { + return $this->outputJsonError('Sie haben keine Bestellberechtigung für diesen Studiengang: '. $studiengang_kz); + } + + // update contract if contract exists and the betrag was changed + if (!is_null($vertrag_id)) + { + $this->VertragModel->addSelect('vertragsstunden, betrag'); + + if($result = getData($this->VertragModel->load($vertrag_id))) + { + $vertrag_betrag = $result[0]->betrag; + $vertrag_stunden = $result[0]->vertragsstunden; + } + elseif (isError($result)) + { + return $this->outputJsonError('Fehler beim Laden des Vertrags'); + } + + $hasChanged = ($betrag != floatval($vertrag_betrag) || $stunden != $vertrag_stunden) ? true : false; + + if ($hasChanged) + { + $result = $this->VertragModel->updateVertrag( + $vertrag_id, + $stunden, + $betrag, + $mitarbeiter_uid + ); + + if (isSuccess($result)) + { + $json []= array( + 'row_index' => $lehrauftrag->row_index, + 'bestellt' => date('Y-m-d'), + 'vertrag_betrag' => $betrag, + 'vertrag_stunden' => $stunden, + 'erteilt' => null + ); + } + else + { + return $this->outputJsonError('Fehler beim Vertragsupdate'); + } + } + } + // else save new contract + else + { + $result = $this->VertragModel->save( + $person_id, + $mitarbeiter_uid, + $lehrveranstaltung_id, + $lehreinheit_id, + $projektarbeit_id, + $stunden, + $betrag, + $studiensemester_kurzbz + ); + + if (isSuccess($result)) + { + $json []= array( + 'row_index' => $lehrauftrag->row_index, + 'bestellt' => date('Y-m-d'), + 'vertrag_betrag' => $betrag, + 'vertrag_stunden' => $stunden + ); + } + elseif (isError($result) && $result->retval) + { + return $this->outputJsonError($result->retval); + } + else + { + return $this->outputJsonError('Fehler beim Speichern des Vertrags'); + } + + $new_lehrvertrag_data_arr[] = array( + 'studiensemester_kurzbz' => $lehrauftrag->studiensemester_kurzbz, + 'studiengang_kz' => $lehrauftrag->studiengang_kz, + 'lv_oe_kurzbz' => $lehrauftrag->lv_oe_kurzbz + ); + } + } + } + else + { + return $this->outputJsonError('Fehler beim Übertragen der Daten.'); + } + + if (isset($json) && !isEmptyArray($json)) + { + $this->outputJsonSuccess($json); + } + } + + // ----------------------------------------------------------------------------------------------------------------- + // Private methods + + /** + * Retrieve the UID of the logged user and checks if it is valid + */ + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) show_error('User authentification failed'); + } + + private function _sendMail($lehrvertrag_data_arr) + { + // Cluster data of new lehrvertraege as needed to send mail + $lehrvertrag_data_arr = $this->_cluster_newVertragData($lehrvertrag_data_arr); + + foreach ($lehrvertrag_data_arr as $lehrvertrag_data) + { + // Get mail recipients + $result = $this->BenutzerrolleModel->getBenutzerByBerechtigung('lehre/lehrauftrag_erteilen', $lehrvertrag_data['lv_oe_kurzbz']); + + // If given lv organisational unit has no authorized user, check if is a Kompetenzfeld. + // If so, look up for authorized user on Department level. + if (!hasData($result)) { + $result = $this->OrganisationseinheitModel->getParent($lehrvertrag_data['lv_oe_kurzbz']); + + if (hasData($result)) { + if ($result->retval[0]->organisationseinheittyp_kurzbz === 'Department') { + $result = $this->BenutzerrolleModel->getBenutzerByBerechtigung('lehre/lehrauftrag_erteilen', $result->retval[0]->oe_kurzbz); + } + } + } + + // Set mail recipients (department assistance/leader) + $to = ''; + $to_arr = array(); + foreach ($result->retval as $berechtigung) { + $to_arr []= $berechtigung->uid . '@' . DOMAIN; // TODO: als array, dann splitten mit ;? oder als array lassen? + } + $to = implode(', ', $to_arr); + + // Set link to lehrauftrag-site with preselected studiengang and studiensemester of new lehrauftraege + $url = site_url(self::LEHRAUFTRAG_URI).'?studiensemester='. $lehrvertrag_data['studiensemester_kurzbz']. '&studiengang='. $lehrvertrag_data['studiengang_kz']; + + // Prepare mail content + $content_data_arr = array( + 'anzahl' => $lehrvertrag_data['amount_new_lehrvertraege'], + 'studiengang' => $lehrvertrag_data['studiengang_kz'], + 'studiensemester' => $lehrvertrag_data['studiensemester_kurzbz'], + 'link' => anchor($url, 'Lehrverträge Übersicht') + ); + + // Send mail + sendSanchoMail( + 'LehrauftragBestellMail', + $content_data_arr, + $to, + 'Bestellung neuer Lehraufträge', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg' + ); + } + } + + /** + * Clusters data as needed for _sendMail. + * Makes array of new lehrvertraege unique (by studiensemester, studiengang and lv_oe_kurzbz) + * Adds the amount of lehrvertraege of each unique array element. + * @param $new_lehrvertrag_data_arr + * @return array + */ + private function _cluster_newVertragData($new_lehrvertrag_data_arr) + { + $unique_new_lehrvertrag_data_arr = array_unique($new_lehrvertrag_data_arr, SORT_REGULAR); + foreach ($unique_new_lehrvertrag_data_arr as &$new_lehrvertrag) + { + $cnt = 1; + foreach ($new_lehrvertrag_data_arr as $item) + { + if ($new_lehrvertrag['studiensemester_kurzbz'] === $item['studiensemester_kurzbz'] && + $new_lehrvertrag['studiengang_kz'] === $item['studiengang_kz'] && + $new_lehrvertrag['lv_oe_kurzbz'] === $item['lv_oe_kurzbz']) + { + $new_lehrvertrag['amount_new_lehrvertraege'] = $cnt++; + } + } + } + + return $unique_new_lehrvertrag_data_arr; + } +} diff --git a/application/controllers/lehre/lehrauftrag/LehrauftragAkzeptieren.php b/application/controllers/lehre/lehrauftrag/LehrauftragAkzeptieren.php new file mode 100644 index 000000000..dfb1390d3 --- /dev/null +++ b/application/controllers/lehre/lehrauftrag/LehrauftragAkzeptieren.php @@ -0,0 +1,219 @@ + 'lehre/lehrauftrag_akzeptieren:r', + 'acceptLehrauftrag' => 'lehre/lehrauftrag_akzeptieren:rw', + 'checkInkludierteLehre' => 'lehre/lehrauftrag_akzeptieren:rw' + ) + ); + + // Load models + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + $this->load->model('accounting/Vertrag_model', 'VertragModel'); + $this->load->model('accounting/Vertragvertragsstatus_model', 'VertragvertragsstatusModel'); + $this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel'); + $this->load->model('codex/Bisverwendung_model', 'BisverwendungModel'); + $this->load->model('person/Benutzer_model', 'BenutzerModel'); + + // Load libraries + $this->load->library('WidgetLib'); + $this->load->library('PermissionLib'); + $this->load->library('AuthLib'); + + // Load helpers + $this->load->helper('array'); + $this->load->helper('url'); + + // Load language phrases + $this->loadPhrases( + array( + 'global', + 'ui', + 'lehre' + ) + ); + + $this->_setAuthUID(); // sets property uid + + $this->setControllerId(); // sets the controller id + } + + // ----------------------------------------------------------------------------------------------------------------- + // Public methods + + /** + * Main page of Lehrauftrag + */ + public function index() + { + // Set studiensemester selected for studiengang dropdown + $studiensemester_kurzbz = $this->input->get('studiensemester'); // if provided by selected studiensemester + if (is_null($studiensemester_kurzbz)) // else set next studiensemester as default value + { + $studiensemester = $this->StudiensemesterModel->getNext(); + if (hasData($studiensemester)) + { + $studiensemester_kurzbz = $studiensemester->retval[0]->studiensemester_kurzbz; + } + elseif (isError($studiensemester)) + { + show_error(getError($studiensemester)); + } + } + + $view_data = array( + 'studiensemester_selected' => $studiensemester_kurzbz + ); + + $this->load->view('lehre/lehrauftrag/acceptLehrauftrag.php', $view_data); + } + + /** + * Set the contract status of Lehrauftrag to 'akzeptiert'. + * Performed on ajax call. + */ + public function acceptLehrauftrag() + { + // Verify password + $password = $this->input->post('password'); + if (!isEmptyString($password)) + { + $result = $this->authlib->checkUserAuthByUsernamePassword($this->_uid, $password); + if (isError($result)) + { + return $this->outputJsonError('Passwort ist inkorrekt'); // exit if password is incorrect + } + } + else + { + return $this->outputJsonError('Passwort fehlt'); + } + + // Loop through lehraufträge + $lehrauftrag_arr = $this->input->post('selected_data'); + + if(is_array($lehrauftrag_arr)) + { + foreach($lehrauftrag_arr as $lehrauftrag) + { + $vertrag_id = (!is_null($lehrauftrag['vertrag_id'])) ? $lehrauftrag['vertrag_id'] : null; + + // Check if user is entitled to accept this Lehrauftrag + // * first retrieve person_id of the contract + $this->VertragModel->addSelect('person_id'); + + if ($result = getData($this->VertragModel->load($vertrag_id))) + { + // * then find the uid of that contracts person_id + $this->BenutzerModel->addSelect('uid'); + + if ($result = getData($this->BenutzerModel->getFromPersonId($result[0]->person_id))) + { + // * finally check uid of contract against the logged in user + $account_found = false; + foreach($result as $row_accounts) + { + if($row_accounts->uid == $this->_uid) + { + $account_found = true; + } + } + + if (!$account_found) + { + return $this->outputJsonError('Sie haben keine Berechtigung für einen Vertrag'); + } + } + else + { + return $this->outputJsonError('Fehler beim Laden der Benutzerdaten'); + } + } + else + { + return $this->outputJsonError('Fehler beim Laden des Vertrags'); + } + + // Set status to accepted + $result = $this->VertragvertragsstatusModel->setStatus($vertrag_id, $this->_uid, 'akzeptiert'); + + if ($result->retval) + { + $json []= array( + 'row_index' => $lehrauftrag['row_index'], + 'akzeptiert' => date('Y-m-d') + ); + } + else + { + return $this->outputJsonError($result->retval); + } + } + + // Output json to ajax + if (isset($json) && !isEmptyArray($json)) + { + $this->outputJsonSuccess($json); + } + } + else + { + return $this->outputJsonError('Fehler beim Übertragen der Daten.'); + } + } + + /** + * Check if lectors latest active Verwendung has inkludierte Lehre + * - inkludierte_lehre is null OR 0: freelancer lector -> has NO inkludierte Lehre + * - inkludierte_lehre -1: fix employed lector -> has inkludierte Lehre (all inclusive) + * - inkludierte_lehre > 0: fix employed lector -> has inkludierte Lehre (value is amount of hours included) + */ + public function checkInkludierteLehre() + { + $result = $this->BisverwendungModel->getLast($this->_uid); + + if (hasData($result)) + { + $this->outputJsonSuccess(!is_null($result->retval[0]->inkludierte_lehre) && $result->retval[0]->inkludierte_lehre != 0); + } + else + { + $this->outputJsonError(getError($result)); + } + } + + // ----------------------------------------------------------------------------------------------------------------- + // Private methods + + /** + * Retrieve the UID of the logged user and checks if it is valid + */ + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) show_error('User authentification failed'); + } + +} diff --git a/application/controllers/lehre/lehrauftrag/LehrauftragErteilen.php b/application/controllers/lehre/lehrauftrag/LehrauftragErteilen.php new file mode 100644 index 000000000..b70b6e2f9 --- /dev/null +++ b/application/controllers/lehre/lehrauftrag/LehrauftragErteilen.php @@ -0,0 +1,204 @@ + 'lehre/lehrauftrag_erteilen:r', + 'approveLehrauftrag' => 'lehre/lehrauftrag_erteilen:rw' + ) + ); + + // Load models + $this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); + $this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + $this->load->model('accounting/Vertrag_model', 'VertragModel'); + $this->load->model('accounting/Vertragvertragsstatus_model', 'VertragvertragsstatusModel'); + + // Load libraries + $this->load->library('WidgetLib'); + $this->load->library('PermissionLib'); + + // Load helpers + $this->load->helper('array'); + $this->load->helper('url'); + + // Load language phrases + $this->loadPhrases( + array( + 'global', + 'ui', + 'lehre' + ) + ); + + $this->_setAuthUID(); // sets property uid + + $this->setControllerId(); // sets the controller id + } + + // ----------------------------------------------------------------------------------------------------------------- + // Public methods + + /** + * Main page of Lehrauftrag + */ + public function index() + { + // Set studiengang to be selected in studiengang dropdown + $oe_kurzbz = $this->input->get('organisationseinheit'); // if provided by selected studiengang + $oe_kurzbz = ($oe_kurzbz == 'null' ? null : $oe_kurzbz); + + // Retrieve studiengaenge the user is entitled for to populate studiengang dropdown + if (!$oe_kurzbz_arr = $this->permissionlib->getOE_isEntitledFor(self::BERECHTIGUNG_LEHRAUFTRAG_ERTEILEN)) + { + show_error('Fehler bei Berechtigungsprüfung'); + } + + // If oe_kurzbz get param was set, check against entitled stg + if (!is_null($oe_kurzbz)) + { + if (!in_array($oe_kurzbz, $oe_kurzbz_arr)) + { + show_error('Keine Berechtigung für diese Organisationseinheit'); + } + } + + // Set studiensemester selected for studiengang dropdown + $studiensemester_kurzbz = $this->input->get('studiensemester'); // if provided by selected studiensemester + if (is_null($studiensemester_kurzbz)) // else set next studiensemester as default value + { + $studiensemester = $this->StudiensemesterModel->getNext(); + if (hasData($studiensemester)) + { + $studiensemester_kurzbz = $studiensemester->retval[0]->studiensemester_kurzbz; + } + elseif (isError($studiensemester)) + { + show_error(getError($studiensemester)); + } + } + + // Set ausbildungssemester selected for ausbildungssemester dropdown + $ausbildungssemester = $this->input->get('ausbildungssemester'); // if provided by selected ausbildungssemester + $ausbildungssemester = ($ausbildungssemester == 'null' ? null : $ausbildungssemester); + + $view_data = array( + 'organisationseinheit_selected' => $oe_kurzbz, + 'organisationseinheit' => $oe_kurzbz_arr, + 'studiensemester_selected' => $studiensemester_kurzbz, + 'ausbildungssemester_selected' => $ausbildungssemester, + ); + + $this->load->view('lehre/lehrauftrag/approveLehrauftrag.php', $view_data); + } + + /** + * Set the contract status of Lehrauftrag to 'erteilt'. + * Performed on ajax call. + */ + public function approveLehrauftrag() + { + $lehrauftrag_arr = json_decode($this->input->post('selected_data')); + + if (is_array($lehrauftrag_arr)) + { + foreach ($lehrauftrag_arr as $lehrauftrag) + { + $mitarbeiter_uid = (isset($lehrauftrag->mitarbeiter_uid)) ? $lehrauftrag->mitarbeiter_uid : null; + $vertrag_id = (isset($lehrauftrag->vertrag_id)) ? $lehrauftrag->vertrag_id : null; + + $lv_oe_kurzbz = null; + + // Retrieve organisational unit to which the lehrveranstaltung of the contract belongs to + // * first get lehrveranstaltung + $result = $this->VertragModel->getLehreinheitData($vertrag_id, 'lehrveranstaltung_id'); + if (hasData($result)) + { + // * then get corresponding organisational unit + $this->load->model('education/Lehrveranstaltung_model', 'Lehrveranstaltung_model'); + $result = $this->LehrveranstaltungModel->load($result->retval[0]->lehrveranstaltung_id); + if (hasData($result)) + { + $lv_oe_kurzbz = $result->retval[0]->oe_kurzbz; + } + elseif (isError(($result))) + { + return $this->outputJsonError('Fehler beim Laden einer Lehrveranstaltung.'); + } + } + elseif (isError($result)) + { + return $this->outputJsonError('Fehler beim Laden von Lehreinheitdaten.'); + } + + // Check if user is entitled to approve this lehrauftrag (by permission and organisational unit) + if (!$this->permissionlib->isBerechtigt(self::BERECHTIGUNG_LEHRAUFTRAG_ERTEILEN, 'suid', $lv_oe_kurzbz)) + { + return $this->outputJsonError('Sie haben keine Erteilberechtigung für diese Organisationseinheit: '. $lv_oe_kurzbz); + } + + // Approve lehrauftrag by setting vertragsstatus to 'erteilt' + $result = $this->VertragvertragsstatusModel->setStatus($vertrag_id, $mitarbeiter_uid, 'erteilt'); + + if (!isError($result)) + { + $json [] = array( + 'row_index' => $lehrauftrag->row_index, + 'erteilt' => date('Y-m-d') + ); + } + else + { + return $this->outputJsonError($result->retval); + } + } + } + else + { + return $this->outputJsonError('Fehler beim Übertragen der Daten.'); + } + + // output success json to ajax + if (isset($json) && !isEmptyArray($json)) + { + $this->outputJsonSuccess($json); + } + } + + // ----------------------------------------------------------------------------------------------------------------- + // Private methods + + /** + * Retrieve the UID of the logged user and checks if it is valid + */ + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) show_error('User authentification failed'); + } + +} diff --git a/application/controllers/organisation/Studienjahr.php b/application/controllers/organisation/Studienjahr.php index c3c841df9..ed8c0b6a1 100644 --- a/application/controllers/organisation/Studienjahr.php +++ b/application/controllers/organisation/Studienjahr.php @@ -20,7 +20,7 @@ class Studienjahr extends Auth_Controller 'editStudienjahr' => 'basis/studiensemester:rw', 'newStudienjahr' => 'basis/studiensemester:rw', 'insStudienjahr' => 'basis/studiensemester:rw', - 'saveStudienjahr' => 'basis/studiensemester:rw', + 'updateStudienjahr' => 'basis/studiensemester:rw', 'deleteStudienjahr' => 'basis/studiensemester:rw' ) ); @@ -44,7 +44,7 @@ class Studienjahr extends Auth_Controller $studienjahr = $this->StudienjahrModel->load(); if ($studienjahr->error) { - show_error($studienjahr->retval); + show_error(getError($studienjahr)); } $data = array( @@ -66,7 +66,7 @@ class Studienjahr extends Auth_Controller $studienjahr = $this->StudienjahrModel->load($studienjahr_kurzbez); if ($studienjahr->error) { - show_error($studienjahr->retval); + show_error(getError($studienjahr)); } $data = array( "studienjahr" => $studienjahr->retval @@ -86,7 +86,7 @@ class Studienjahr extends Auth_Controller $allstudienjahrkurzbz = $this->StudienjahrModel->load(); if ($allstudienjahrkurzbz->error) { - show_error($allstudienjahrkurzbz->retval); + show_error(getError($allstudienjahrkurzbz)); } $studienjahrkurzbz = $allstudienjahrkurzbz->retval[0]->studienjahr_kurzbz; $years = $this->__getYearsFromStudienjahr($studienjahrkurzbz); @@ -117,11 +117,15 @@ class Studienjahr extends Auth_Controller public function insStudienjahr() { $data = $this->__retrieveStudienjahrData(); + $studienjahr_exists = $this->StudienjahrModel->load($data['studienjahr_kurzbz']); + if (hasData($studienjahr_exists)) + show_error("Studienjahr existiert bereits"); + $studienjahr = $this->StudienjahrModel->insert($data); if ($studienjahr->error) { - show_error($studienjahr->retval); + show_error(getError($studienjahr)); } redirect("/organisation/studienjahr/editStudienjahr/".str_replace("/", "_", $data['studienjahr_kurzbz']."?saved=true")); @@ -149,7 +153,7 @@ class Studienjahr extends Auth_Controller return $data; } else { - show_error($validation->retval); + show_error(getError($validation)); } } @@ -177,14 +181,14 @@ class Studienjahr extends Auth_Controller * replaces slash in Kurzbezeichnung with underscore * saved=true is a GET parameter passed for showing save message */ - public function saveStudienjahr() + public function updateStudienjahr() { $data = $this->__retrieveStudienjahrData(); $studienjahr = $this->StudienjahrModel->update($data['studienjahr_kurzbz'], $data); if ($studienjahr->error) { - show_error($studienjahr->retval); + show_error(getError($studienjahr)); } redirect("/organisation/studienjahr/editStudienjahr/".str_replace("/", "_", $data['studienjahr_kurzbz']."?saved=true")); @@ -203,7 +207,7 @@ class Studienjahr extends Auth_Controller if ($studienjahr->error) { - show_error($studienjahr->retval); + show_error(getError($studienjahr)); } redirect("/organisation/studienjahr/listStudienjahr"); diff --git a/application/controllers/organisation/Studiensemester.php b/application/controllers/organisation/Studiensemester.php index cdca4997d..10fa5b3ad 100644 --- a/application/controllers/organisation/Studiensemester.php +++ b/application/controllers/organisation/Studiensemester.php @@ -20,7 +20,7 @@ class Studiensemester extends Auth_Controller 'editStudiensemester' => 'basis/studiensemester:rw', 'newStudiensemester' => 'basis/studiensemester:rw', 'insStudiensemester' => 'basis/studiensemester:rw', - 'saveStudiensemester' => 'basis/studiensemester:rw', + 'updateStudiensemester' => 'basis/studiensemester:rw', 'deleteStudiensemester' => 'basis/studiensemester:rw' ) ); @@ -45,7 +45,7 @@ class Studiensemester extends Auth_Controller $semester = $this->StudiensemesterModel->load(); if ($semester->error) { - show_error($semester->retval); + show_error(getError($semester)); } $data = array( @@ -64,13 +64,13 @@ class Studiensemester extends Auth_Controller $semester = $this->StudiensemesterModel->load($semester_kurzbez); if ($semester->error) { - show_error($semester->retval); + show_error(getError($semester)); } $this->StudienjahrModel->addOrder('studienjahr_kurzbz', "DESC"); $allstudienjahre = $this->StudienjahrModel->load(); if ($allstudienjahre->error) { - show_error($allstudienjahre->retval); + show_error(getError($allstudienjahre)); } $data = array( "semester" => $semester->retval, @@ -90,7 +90,7 @@ class Studiensemester extends Auth_Controller $allstudienjahre = $this->StudienjahrModel->load(); if ($allstudienjahre->error) { - show_error($allstudienjahre->retval); + show_error(getError($allstudienjahre)); } $data = array( @@ -108,11 +108,16 @@ class Studiensemester extends Auth_Controller public function insStudiensemester() { $data = $this->__retrieveStudiensemesterData(); + + $studiensemester_exists = $this->StudiensemesterModel->load($data['studiensemester_kurzbz']); + if (hasData($studiensemester_exists)) + show_error("Studiensemester existiert bereits"); + $semester = $this->StudiensemesterModel->insert($data); if ($semester->error) { - show_error($semester->retval); + show_error(getError($semester)); } redirect("/organisation/studiensemester/editStudiensemester/".$data['studiensemester_kurzbz']."?saved=true"); @@ -156,7 +161,7 @@ class Studiensemester extends Auth_Controller return $data; } else { - show_error($validation->retval); + show_error(getError($validation)); } } @@ -185,14 +190,14 @@ class Studiensemester extends Auth_Controller * redirects to edit page after inserting * saved=true is a GET parameter passed for showing save message */ - public function saveStudiensemester() + public function updateStudiensemester() { $data = $this->__retrieveStudiensemesterData(); $semester = $this->StudiensemesterModel->update($data['studiensemester_kurzbz'], $data); if ($semester->error) { - show_error($semester->retval); + show_error(getError($semester)); } redirect("/organisation/studiensemester/editStudiensemester/".$data['studiensemester_kurzbz']."?saved=true"); @@ -209,10 +214,9 @@ class Studiensemester extends Auth_Controller if ($semester->error) { - show_error($semester->retval); + show_error(getError($semester)); } redirect("/organisation/studiensemester/listStudiensemester"); } - } diff --git a/application/controllers/person/BPKWartung.php b/application/controllers/person/BPKWartung.php index a8e9b8829..52cb09c5c 100644 --- a/application/controllers/person/BPKWartung.php +++ b/application/controllers/person/BPKWartung.php @@ -71,7 +71,7 @@ class BPKWartung extends Auth_Controller $personexists = $this->PersonModel->load($person_id); if (isError($personexists)) - show_error($personexists->retval); + show_error(getError($personexists)); if (!hasData($personexists)) show_error('Person does not exist!'); @@ -122,7 +122,7 @@ class BPKWartung extends Auth_Controller if (isError($stammdaten)) { - show_error($stammdaten->retval); + show_error(getError($stammdaten)); } if (!isset($stammdaten->retval)) @@ -132,7 +132,7 @@ class BPKWartung extends Auth_Controller if (isError($adresse)) { - show_error($adresse->retval); + show_error(getError($adresse)); } $data = array( diff --git a/application/controllers/system/FASMessages.php b/application/controllers/system/FASMessages.php index 6928a919d..e656db790 100644 --- a/application/controllers/system/FASMessages.php +++ b/application/controllers/system/FASMessages.php @@ -123,7 +123,7 @@ class FASMessages extends Auth_Controller $msg = $this->messagelib->getMessage($msg_id, $receiver_id); if (isError($msg)) { - show_error(getData($msg)); + show_error(getError($msg)); } elseif (!hasData($msg)) { @@ -147,7 +147,7 @@ class FASMessages extends Auth_Controller if (isError($msgVarsData)) { - show_error(getData($msgVarsData)); + show_error(getError($msgVarsData)); } return $msgVarsData; @@ -160,7 +160,7 @@ class FASMessages extends Auth_Controller { $variables = $this->messagelib->getMessageVarsPerson(); - if (isError($variables)) show_error(getData($variables)); + if (isError($variables)) show_error(getError($variables)); return getData($variables); } @@ -172,7 +172,7 @@ class FASMessages extends Auth_Controller { $oe_kurzbz = $this->messagelib->getOeKurzbz($sender_id); - if (isError($oe_kurzbz)) show_error(getData($oe_kurzbz)); + if (isError($oe_kurzbz)) show_error(getError($oe_kurzbz)); return getData($oe_kurzbz); } @@ -184,7 +184,7 @@ class FASMessages extends Auth_Controller { $isAdmin = $this->messagelib->getIsAdmin($sender_id); - if (isError($isAdmin)) show_error(getData($isAdmin)); + if (isError($isAdmin)) show_error(getError($isAdmin)); return getData($isAdmin); } diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index ec630da1e..58ffbd0a7 100644 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -51,7 +51,7 @@ class Messages extends Auth_Controller $authUser = $this->CLMessagesModel->getAuthUser(); if (isError($authUser)) { - show_error(getData($authUser)); + show_error(getError($authUser)); } else { @@ -59,19 +59,19 @@ class Messages extends Auth_Controller } $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($person_id); - if (isError($msgVarsData)) show_error(getData($msgVarsData)); + if (isError($msgVarsData)) show_error(getError($msgVarsData)); // Retrieves message vars for a person from view view vw_msg_vars_person $variables = $this->messagelib->getMessageVarsPerson(); - if (isError($variables)) show_error(getData($variables)); + if (isError($variables)) show_error(getError($variables)); // Organisation units used to get the templates $oe_kurzbz = $this->messagelib->getOeKurzbz($sender_id); - if (isError($oe_kurzbz)) show_error(getData($oe_kurzbz)); + if (isError($oe_kurzbz)) show_error(getError($oe_kurzbz)); // Admin or commoner? $isAdmin = $this->messagelib->getIsAdmin($sender_id); - if (isError($isAdmin)) show_error(getData($isAdmin)); + if (isError($isAdmin)) show_error(getError($isAdmin)); $data = array ( 'recipients' => getData($msgVarsData), @@ -122,7 +122,7 @@ class Messages extends Auth_Controller $send = $this->CLMessagesModel->send($msgVarsData, null, $oe_kurzbz, $vorlage_kurzbz, $msgVars); if (isError($send)) { - $this->outputJsonError(getData($send)); + $this->outputJsonError(getError($send)); } else { @@ -152,7 +152,7 @@ class Messages extends Auth_Controller if (isError($result) || !hasData($result)) { - $this->outputJsonError(getData($result)); + $this->outputJsonError(getError($result)); } else { @@ -181,7 +181,7 @@ class Messages extends Auth_Controller if (isError($data) || !hasData($data)) { - $this->outputJsonError(getData($data)); + $this->outputJsonError(getError($data)); } else { diff --git a/application/controllers/system/Navigation.php b/application/controllers/system/Navigation.php index 1abf7d9a8..190f84acd 100644 --- a/application/controllers/system/Navigation.php +++ b/application/controllers/system/Navigation.php @@ -7,7 +7,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); * Provides data to the ajax get calls about the filter * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON */ -class Navigation extends Auth_Controller +class Navigation extends FHC_Controller { const NAVIGATION_PAGE_PARAM = 'navigation_page'; // Navigation page parameter name @@ -16,12 +16,9 @@ class Navigation extends Auth_Controller */ public function __construct() { - parent::__construct( - array( - 'menu' => 'basis/vilesci:r', - 'header' => 'basis/vilesci:r' - ) - ); + parent::__construct(); + + $this->load->library('AuthLib'); $this->_loadNavigationLib(); // Loads the NavigationLib with parameters } diff --git a/application/controllers/system/Phrases.php b/application/controllers/system/Phrases.php index 070750b7c..f589eaeb2 100644 --- a/application/controllers/system/Phrases.php +++ b/application/controllers/system/Phrases.php @@ -45,7 +45,7 @@ class Phrases extends Auth_Controller { $phrases = $this->phraseslib->getPhraseByApp('aufnahme'); if ($phrases->error) - show_error($phrases->retval); + show_error(getError($phrases)); $data = array( 'app' => 'aufnahme', @@ -67,7 +67,7 @@ class Phrases extends Auth_Controller $phrase_inhalt = $this->phraseslib->getPhraseInhalt($phrase_id); if ($phrase_inhalt->error) - show_error($phrase_inhalt->retval); + show_error(getError($phrase_inhalt)); $data = array( 'phrase_id' => $phrase_id, @@ -88,7 +88,7 @@ class Phrases extends Auth_Controller $phrase_inhalt = $this->phraseslib->delPhrasentext($phrasentext_id); if ($phrase_inhalt->error) - show_error($phrase_inhalt->retval); + show_error(getError($phrase_inhalt)); redirect('/system/Phrases/view/'.$phrase_id); } @@ -102,7 +102,7 @@ class Phrases extends Auth_Controller $phrase = $this->phraseslib->getPhrase($phrase_id); if ($phrase->error) - show_error($phrase->retval); + show_error(getError($phrase)); if (count($phrase->retval) != 1) show_error('Phrase nicht vorhanden! ID: '.$phrase_id); @@ -124,7 +124,7 @@ class Phrases extends Auth_Controller $phrase = $this->phraseslib->savePhrase($phrase_id, $data); if ($phrase->error) - show_error($phrase->retval); + show_error(getError($phrase)); $phrase_id = $phrase->retval; @@ -145,7 +145,7 @@ class Phrases extends Auth_Controller $resultOE = $this->OrganisationseinheitModel->loadWhere(array('aktiv' => true, 'oe_parent_kurzbz' => null)); if ($resultOE->error) - show_error($resultOE->retval); + show_error(getError($resultOE)); if (hasData($resultOE)) { @@ -161,7 +161,7 @@ class Phrases extends Auth_Controller $phrase_inhalt = $this->phraseslib->insertPhraseinhalt($data); if ($phrase_inhalt->error) - show_error($phrase_inhalt->retval); + show_error(getError($phrase_inhalt); $phrase_inhalt_id = $phrase_inhalt->retval; @@ -180,7 +180,7 @@ class Phrases extends Auth_Controller { $phrase_inhalt = $this->phraseslib->getPhrasentextById($phrasentext_id); if ($phrase_inhalt->error) - show_error($phrase_inhalt->retval); + show_error(getError($phrase_inhalt)); $data = $phrase_inhalt->retval[0]; @@ -204,7 +204,7 @@ class Phrases extends Auth_Controller $phrase_inhalt = $this->phraseslib->updatePhraseInhalt($phrase_inhalt_id, $data); if ($phrase_inhalt->error) - show_error($phrase_inhalt->retval); + show_error(getError($phrase_inhalt)); redirect('/system/Phrases/editText/'.$phrase_inhalt_id); diff --git a/application/controllers/system/Vorlage.php b/application/controllers/system/Vorlage.php index 4712d0e68..ba8b26137 100644 --- a/application/controllers/system/Vorlage.php +++ b/application/controllers/system/Vorlage.php @@ -49,7 +49,7 @@ class Vorlage extends Auth_Controller $vorlage = $this->vorlagelib->getVorlageByMimetype($mimetype); if ($vorlage->error) - show_error($vorlage->retval); + show_error(getError($vorlage)); $data = array ( 'mimetype' => $mimetype, @@ -66,7 +66,7 @@ class Vorlage extends Auth_Controller $vorlagentext = $this->vorlagelib->getVorlagetextByVorlage($vorlage_kurzbz); if ($vorlagentext->error) - show_error($vorlagentext->retval); + show_error(getError($vorlagentext)); $data = array ( 'vorlage_kurzbz' => $vorlage_kurzbz, @@ -83,7 +83,7 @@ class Vorlage extends Auth_Controller $vorlage = $this->vorlagelib->getVorlage($vorlage_kurzbz); if ($vorlage->error) - show_error($vorlage->retval); + show_error(getError($vorlage)); if (count($vorlage->retval) != 1) show_error('Nachricht nicht vorhanden! ID: '.$vorlage_kurzbz); @@ -119,7 +119,7 @@ class Vorlage extends Auth_Controller $vorlage = $this->vorlagelib->saveVorlage($vorlage_kurzbz, $data); if ($vorlage->error) - show_error($vorlage->retval); + show_error(getError($vorlage)); $vorlage_kurzbz = $vorlage->retval; @@ -137,7 +137,7 @@ class Vorlage extends Auth_Controller $resultOE = $this->OrganisationseinheitModel->loadWhere(array('aktiv' => true, 'oe_parent_kurzbz' => null)); if ($resultOE->error) - show_error($resultOE->retval); + show_error(getError($resultOE)); if (hasData($resultOE)) { @@ -153,7 +153,7 @@ class Vorlage extends Auth_Controller $vorlagetext = $this->vorlagelib->insertVorlagetext($data); if ($vorlagetext->error) - show_error($vorlagetext->retval); + show_error(getError($vorlagetext)); $vorlagestudiengang_id = $vorlagetext->retval; @@ -170,7 +170,7 @@ class Vorlage extends Auth_Controller $vorlagetext = $this->vorlagelib->getVorlagetextById($vorlagestudiengang_id); if ($vorlagetext->error) - show_error($vorlagetext->retval); + show_error(getError($vorlagetext)); $data = $vorlagetext->retval[0]; @@ -254,7 +254,7 @@ class Vorlage extends Auth_Controller $vorlagetext = $this->vorlagelib->updateVorlagetext($data['vorlagestudiengang_id'], $data); if ($vorlagetext->error) - show_error($vorlagetext->retval); + show_error(getError($vorlagetext)); redirect('/system/vorlage/editText/'.$data['vorlagestudiengang_id']); } @@ -266,7 +266,7 @@ class Vorlage extends Auth_Controller $vorlagetext = $this->vorlagelib->getVorlagetextById($vorlagestudiengang_id); if ($vorlagetext->error) - show_error($vorlagetext->retval); + show_error(getError($vorlagetext)); $data = array( 'text' => $this->vorlagelib->parseVorlagetext($vorlagetext->retval[0]->text, $jsonDecodedForm) diff --git a/application/controllers/system/aufnahme/PrestudentMultiAssign.php b/application/controllers/system/aufnahme/PrestudentMultiAssign.php index 30df81281..9906e83cb 100644 --- a/application/controllers/system/aufnahme/PrestudentMultiAssign.php +++ b/application/controllers/system/aufnahme/PrestudentMultiAssign.php @@ -61,7 +61,7 @@ class PrestudentMultiAssign extends Auth_Controller } else if (isError($returnUsers)) { - show_error($returnUsers->retval); + show_error(getError($returnUsers)); } } diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index 2f66e0e2d..4d775ad31 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -24,7 +24,6 @@ class InfoCenter extends Auth_Controller const FILTER_ID = 'filter_id'; const PREV_FILTER_ID = 'prev_filter_id'; - const RELOAD_DATASET = 'reloadDataset'; const KEEP_TABLESORTER_FILTER = 'keepTsFilter'; private $_uid; // contains the UID of the logged user @@ -194,7 +193,7 @@ class InfoCenter extends Auth_Controller $personexists = $this->PersonModel->load($person_id); if (isError($personexists)) - show_error($personexists->retval); + show_error(getError($personexists)); if (!hasData($personexists)) show_error('Person does not exist!'); @@ -205,8 +204,7 @@ class InfoCenter extends Auth_Controller // mark person as locked for editing $result = $this->PersonLockModel->lockPerson($person_id, $this->_uid, self::APP); - if (isError($result)) - show_error($result->retval); + if (isError($result)) show_error(getError($result)); } $persondata = $this->_loadPersonData($person_id); @@ -232,13 +230,12 @@ class InfoCenter extends Auth_Controller { $result = $this->PersonLockModel->unlockPerson($person_id, self::APP); - if (isError($result)) - show_error($result->retval); + if (isError($result)) show_error(getError($result)); $redirectLink = '/'.self::INFOCENTER_URI.'?'.self::FHC_CONTROLLER_ID.'='.$this->getControllerId(); // Force reload of Dataset after Unlock - $redirectLink .= '&'.self::RELOAD_DATASET.'=true&'.self::KEEP_TABLESORTER_FILTER.'=true'; + $redirectLink .= '&'.self::KEEP_TABLESORTER_FILTER.'=true'; $currentFilterId = $this->input->get(self::FILTER_ID); if (isset($currentFilterId)) @@ -665,7 +662,7 @@ class InfoCenter extends Auth_Controller if (isError($notizen)) { - show_error($notizen->retval); + show_error(getError($notizen)); } $this->load->view('system/infocenter/notizen.php', array('notizen' => $notizen->retval)); @@ -693,14 +690,14 @@ class InfoCenter extends Auth_Controller if (isError($akte)) { - show_error($akte->retval); + show_error(getError($akte)); } $aktecontent = $this->dmslib->getAkteContent($akte_id); if (isError($aktecontent)) { - show_error($aktecontent->retval); + show_error(getError($aktecontent)); } $this->output @@ -943,17 +940,12 @@ class InfoCenter extends Auth_Controller $freigegebenLink = site_url(self::INFOCENTER_URI.'/'.self::FREIGEGEBEN_PAGE); $reihungstestAbsolviertLink = site_url(self::INFOCENTER_URI.'/'.self::REIHUNGSTESTABSOLVIERT_PAGE); + $currentFilterId = $this->input->get(self::FILTER_ID); - $reloadDatasetParam = self::RELOAD_DATASET.'=true'; if (isset($currentFilterId)) { - $freigegebenLink .= '?'.self::PREV_FILTER_ID.'='.$currentFilterId.'&'.$reloadDatasetParam; - $reihungstestAbsolviertLink .= '?'.self::PREV_FILTER_ID.'='.$currentFilterId.'&'.$reloadDatasetParam; - } - else - { - $freigegebenLink .= '?'.$reloadDatasetParam; - $reihungstestAbsolviertLink .= '?'.$reloadDatasetParam; + $freigegebenLink .= '?'.self::PREV_FILTER_ID.'='.$currentFilterId; + $reihungstestAbsolviertLink .= '?'.self::PREV_FILTER_ID.'='.$currentFilterId; } $this->navigationlib->setSessionMenu( @@ -1019,7 +1011,7 @@ class InfoCenter extends Auth_Controller $prevFilterId = $this->input->get(self::PREV_FILTER_ID); if (isset($prevFilterId)) { - $link .= '?'.self::FILTER_ID.'='.$prevFilterId.'&'.self::RELOAD_DATASET.'=true&'.self::KEEP_TABLESORTER_FILTER.'=true'; + $link .= '?'.self::FILTER_ID.'='.$prevFilterId.'&'.self::KEEP_TABLESORTER_FILTER.'=true'; } $this->navigationlib->setSessionMenu( @@ -1049,10 +1041,9 @@ class InfoCenter extends Auth_Controller $this->load->library('NavigationLib', array(self::NAVIGATION_PAGE => self::INFOCENTER_URI.'/'.$page)); // Generate the home link with the eventually loaded filter - $reloadDatasetParam = '?'.self::RELOAD_DATASET.'=true'; - $homeLink = site_url(self::INFOCENTER_URI.'/'.self::INDEX_PAGE.$reloadDatasetParam); - $freigegebenLink = site_url(self::INFOCENTER_URI.'/'.self::FREIGEGEBEN_PAGE.$reloadDatasetParam); - $absolviertLink = site_url(self::INFOCENTER_URI.'/'.self::REIHUNGSTESTABSOLVIERT_PAGE.$reloadDatasetParam); + $homeLink = site_url(self::INFOCENTER_URI.'/'.self::INDEX_PAGE); + $freigegebenLink = site_url(self::INFOCENTER_URI.'/'.self::FREIGEGEBEN_PAGE); + $absolviertLink = site_url(self::INFOCENTER_URI.'/'.self::REIHUNGSTESTABSOLVIERT_PAGE); $prevFilterId = $this->input->get(self::PREV_FILTER_ID); if (isset($prevFilterId)) { @@ -1171,7 +1162,7 @@ class InfoCenter extends Auth_Controller if (isError($locked)) { - show_error($locked->retval); + show_error(getError($locked)); } $lockedby = null; @@ -1190,7 +1181,7 @@ class InfoCenter extends Auth_Controller if (isError($stammdaten)) { - show_error($stammdaten->retval); + show_error(getError($stammdaten)); } if (!isset($stammdaten->retval)) @@ -1200,21 +1191,21 @@ class InfoCenter extends Auth_Controller if (isError($dokumente)) { - show_error($dokumente->retval); + show_error(getError($dokumente)); } $dokumente_nachgereicht = $this->AkteModel->getAktenWithDokInfo($person_id, null, true); if (isError($dokumente_nachgereicht)) { - show_error($dokumente_nachgereicht->retval); + show_error(getError($dokumente_nachgereicht)); } $messages = $this->MessageModel->getMessagesOfPerson($person_id, 1); if (isError($messages)) { - show_error($messages->retval); + show_error(getError($messages)); } $logs = $this->personloglib->getLogs($person_id); @@ -1223,21 +1214,21 @@ class InfoCenter extends Auth_Controller if (isError($notizen)) { - show_error($notizen->retval); + show_error(getError($notizen)); } $notizen_bewerbung = $this->NotizModel->getNotizByTitel($person_id, 'Anmerkung zur Bewerbung%'); if (isError($notizen_bewerbung)) { - show_error($notizen_bewerbung->retval); + show_error(getError($notizen_bewerbung)); } $user_person = $this->PersonModel->getByUid($this->_uid); if (isError($user_person)) { - show_error($user_person->retval); + show_error(getError($user_person)); } $data = array ( @@ -1268,7 +1259,7 @@ class InfoCenter extends Auth_Controller if (isError($prestudenten)) { - show_error($prestudenten->retval); + show_error(getError($prestudenten)); } foreach ($prestudenten->retval as $prestudent) @@ -1277,7 +1268,7 @@ class InfoCenter extends Auth_Controller if (isError($prestudentWithZgv)) { - show_error($prestudentWithZgv->retval); + show_error(getError($prestudentWithZgv)); } $zgvpruefung = $prestudentWithZgv->retval[0]; @@ -1385,13 +1376,13 @@ class InfoCenter extends Auth_Controller $starta = $this->StudiensemesterModel->load($a->prestudentstatus->studiensemester_kurzbz); if (!hasData($starta)) { - show_error($starta->retval); + show_error(getError($starta)); } $startb = $this->StudiensemesterModel->load($b->prestudentstatus->studiensemester_kurzbz); if (!hasData($startb)) { - show_error($startb->retval); + show_error(getError($startb)); } $starta = date_format(date_create($starta->retval[0]->start), 'Y-m-d'); @@ -1463,7 +1454,7 @@ class InfoCenter extends Auth_Controller if (isError($prestudent)) { - show_error($prestudent->retval); + show_error(getError($prestudent)); } $person_id = $prestudent->retval[0]->person_id; diff --git a/application/controllers/system/Filters.php b/application/controllers/widgets/Filters.php similarity index 70% rename from application/controllers/system/Filters.php rename to application/controllers/widgets/Filters.php index b29bd2bb0..b5cbc07ea 100644 --- a/application/controllers/system/Filters.php +++ b/application/controllers/widgets/Filters.php @@ -3,7 +3,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); /** - * This controller operates between (interface) the JS (GUI) and the FiltersLib (back-end) + * This controller operates between (interface) the JS (GUI) and the FilterWidgetLib (back-end) * Provides data to the ajax get calls about the filter * Accepts ajax post calls to change the filter data * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON @@ -12,10 +12,10 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); */ class Filters extends FHC_Controller { - const FILTER_PAGE_PARAM = 'filter_page'; + const FILTER_UNIQUE_ID = 'filterUniqueId'; /** - * Calls the parent's constructor and loads the FiltersLib + * Calls the parent's constructor and loads the FilterWidgetLib */ public function __construct() { @@ -24,8 +24,8 @@ class Filters extends FHC_Controller // Loads authentication library and starts authentication $this->load->library('AuthLib'); - // Loads the FiltersLib with HTTP GET/POST parameters - $this->_loadFiltersLib(); + // Loads the FilterWidgetLib with HTTP GET/POST parameters + $this->_loadFilterWidgetLib(); // Checks if the caller is allow to read this data $this->_isAllowed(); @@ -39,7 +39,7 @@ class Filters extends FHC_Controller */ public function getFilter() { - $this->outputJsonSuccess($this->filterslib->getSession()); + $this->outputJsonSuccess($this->filterwidgetlib->getSession()); } /** @@ -48,7 +48,7 @@ class Filters extends FHC_Controller public function rowNumber() { $rowNumber = 0; - $dataset = $this->filterslib->getSessionElement(FiltersLib::SESSION_DATASET); + $dataset = $this->filterwidgetlib->getSessionElement(FilterWidgetLib::SESSION_DATASET); if (isset($dataset) && is_array($dataset)) { @@ -66,7 +66,7 @@ class Filters extends FHC_Controller { $selectedFields = $this->input->post('selectedFields'); - if ($this->filterslib->sortSelectedFields($selectedFields) == true) + if ($this->filterwidgetlib->sortSelectedFields($selectedFields) == true) { $this->getFilter(); } @@ -84,7 +84,7 @@ class Filters extends FHC_Controller { $selectedField = $this->input->post('selectedField'); - if ($this->filterslib->removeSelectedField($selectedField) == true) + if ($this->filterwidgetlib->removeSelectedField($selectedField) == true) { $this->getFilter(); } @@ -101,7 +101,7 @@ class Filters extends FHC_Controller { $selectedField = $this->input->post('selectedField'); - if ($this->filterslib->addSelectedField($selectedField) == true) + if ($this->filterwidgetlib->addSelectedField($selectedField) == true) { $this->getFilter(); } @@ -118,7 +118,7 @@ class Filters extends FHC_Controller { $appliedFilter = $this->input->post('appliedFilter'); - if ($this->filterslib->removeAppliedFilter($appliedFilter) == true) + if ($this->filterwidgetlib->removeAppliedFilter($appliedFilter) == true) { $this->outputJsonSuccess('Removed'); } @@ -138,7 +138,7 @@ class Filters extends FHC_Controller $appliedFiltersConditions = $this->input->post('appliedFiltersConditions'); $appliedFiltersOptions = $this->input->post('appliedFiltersOptions'); - if ($this->filterslib->applyFilters( + if ($this->filterwidgetlib->applyFilters( $appliedFilters, $appliedFiltersOperations, $appliedFiltersConditions, @@ -160,7 +160,7 @@ class Filters extends FHC_Controller { $filter = $this->input->post('filter'); - if ($this->filterslib->addFilter($filter) == true) + if ($this->filterwidgetlib->addFilter($filter) == true) { $this->getFilter(); } @@ -177,7 +177,7 @@ class Filters extends FHC_Controller { $customFilterDescription = $this->input->post('customFilterDescription'); - if ($this->filterslib->saveCustomFilter($customFilterDescription) == true) + if ($this->filterwidgetlib->saveCustomFilter($customFilterDescription) == true) { $this->outputJsonSuccess('Saved'); } @@ -194,7 +194,7 @@ class Filters extends FHC_Controller { $filter_id = $this->input->post('filter_id'); - if ($this->filterslib->removeCustomFilter($filter_id) == true) + if ($this->filterwidgetlib->removeCustomFilter($filter_id) == true) { $this->outputJsonSuccess('Removed'); } @@ -211,7 +211,7 @@ class Filters extends FHC_Controller public function setNavigationMenu() { // Generates the filters structure array - $filterMenu = $this->filterslib->generateFilterMenu($this->input->get(FiltersLib::NAVIGATION_PAGE)); + $filterMenu = $this->filterwidgetlib->generateFilterMenu($this->input->get(FilterWidgetLib::NAVIGATION_PAGE)); $this->outputJsonSuccess('Success'); } @@ -221,7 +221,7 @@ class Filters extends FHC_Controller */ public function reloadDataset() { - $this->filterslib->reloadDataset(); + $this->filterwidgetlib->reloadDataset(); $this->outputJsonSuccess('Success'); } @@ -234,38 +234,40 @@ class Filters extends FHC_Controller */ private function _isAllowed() { - if (!$this->filterslib->isAllowed()) + if (!$this->filterwidgetlib->isAllowed()) { $this->terminateWithJsonError('You are not allowed to access to this content'); } } /** - * Loads the FiltersLib with the FILTER_PAGE_PARAM parameter - * If the parameter FILTER_PAGE_PARAM is not given then the execution of the controller is terminated and + * Loads the FilterWidgetLib with the FILTER_UNIQUE_ID parameter + * If the parameter FILTER_UNIQUE_ID is not given then the execution of the controller is terminated and * an error message is printed */ - private function _loadFiltersLib() + private function _loadFilterWidgetLib() { - // If the parameter FILTER_PAGE_PARAM is present in the HTTP GET or POST - if (isset($_GET[self::FILTER_PAGE_PARAM]) || isset($_POST[self::FILTER_PAGE_PARAM])) + // If the parameter FILTER_UNIQUE_ID is present in the HTTP GET or POST + if (isset($_GET[self::FILTER_UNIQUE_ID]) || isset($_POST[self::FILTER_UNIQUE_ID])) { // If it is present in the HTTP GET - if (isset($_GET[self::FILTER_PAGE_PARAM])) + if (isset($_GET[self::FILTER_UNIQUE_ID])) { - $filterPage = $this->input->get(self::FILTER_PAGE_PARAM); // is retrieved from the HTTP GET + $filterUniqueId = $this->input->get(self::FILTER_UNIQUE_ID); // is retrieved from the HTTP GET } - elseif (isset($_POST[self::FILTER_PAGE_PARAM])) // Else if it is present in the HTTP POST + elseif (isset($_POST[self::FILTER_UNIQUE_ID])) // Else if it is present in the HTTP POST { - $filterPage = $this->input->post(self::FILTER_PAGE_PARAM); // is retrieved from the HTTP POST + $filterUniqueId = $this->input->post(self::FILTER_UNIQUE_ID); // is retrieved from the HTTP POST } - // Loads the FiltersLib that contains all the used logic - $this->load->library('FiltersLib', array(self::FILTER_PAGE_PARAM => $filterPage)); + // Loads the FilterWidgetLib that contains all the used logic + $this->load->library('FilterWidgetLib'); + + $this->filterwidgetlib->setFilterUniqueId($filterUniqueId); } else // Otherwise an error will be written in the output { - $this->terminateWithJsonError('Parameter "'.self::FILTER_PAGE_PARAM.'" not provided!'); + $this->terminateWithJsonError('Parameter "'.self::FILTER_UNIQUE_ID.'" not provided!'); } } } diff --git a/application/controllers/widgets/Tables.php b/application/controllers/widgets/Tables.php new file mode 100644 index 000000000..21161ff9f --- /dev/null +++ b/application/controllers/widgets/Tables.php @@ -0,0 +1,105 @@ +load->library('AuthLib'); + + // Loads the tablewidgetlib with HTTP GET/POST parameters + $this->_loadTableWidgetLib(); + + // Checks if the caller is allow to read this data + $this->_isAllowed(); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Retrieves data about the current filter from the session and will be written on the output in JSON format + */ + public function getTable() + { + $this->outputJsonSuccess($this->tablewidgetlib->getSession()); + } + + /** + * Retrieves the number of records present in the current dataset and will be written on the output in JSON format + */ + public function rowNumber() + { + $rowNumber = 0; + $dataset = $this->tablewidgetlib->getSessionElement(TableWidgetLib::SESSION_DATASET); + + if (isset($dataset) && is_array($dataset)) + { + $rowNumber = count($dataset); + } + + $this->outputJsonSuccess($rowNumber); + } + + //------------------------------------------------------------------------------------------------------------------ + // Private methods + + /** + * Checks if the user is allowed to use this filter + */ + private function _isAllowed() + { + if (!$this->tablewidgetlib->isAllowed()) + { + $this->terminateWithJsonError('You are not allowed to access to this content'); + } + } + + /** + * Loads the tablewidgetlib with the TABLE_UNIQUE_ID parameter + * If the parameter TABLE_UNIQUE_ID is not given then the execution of the controller is terminated and + * an error message is printed + */ + private function _loadTableWidgetLib() + { + // If the parameter TABLE_UNIQUE_ID is present in the HTTP GET or POST + if (isset($_GET[self::TABLE_UNIQUE_ID]) || isset($_POST[self::TABLE_UNIQUE_ID])) + { + // If it is present in the HTTP GET + if (isset($_GET[self::TABLE_UNIQUE_ID])) + { + $tableUniqueId = $this->input->get(self::TABLE_UNIQUE_ID); // is retrieved from the HTTP GET + } + elseif (isset($_POST[self::TABLE_UNIQUE_ID])) // Else if it is present in the HTTP POST + { + $tableUniqueId = $this->input->post(self::TABLE_UNIQUE_ID); // is retrieved from the HTTP POST + } + + // Loads the tablewidgetlib that contains all the used logic + $this->load->library('TableWidgetLib'); + + $this->tablewidgetlib->setTableUniqueId($tableUniqueId); + } + else // Otherwise an error will be written in the output + { + $this->terminateWithJsonError('Parameter "'.self::TABLE_UNIQUE_ID.'" not provided!'); + } + } +} diff --git a/application/helpers/hlp_return_object_helper.php b/application/helpers/hlp_return_object_helper.php index 03b56bbbc..cc896856d 100644 --- a/application/helpers/hlp_return_object_helper.php +++ b/application/helpers/hlp_return_object_helper.php @@ -125,3 +125,18 @@ function getCode($result) return $code; } + +/** + * Returns the property retval if present, otherwise null + */ +function getError($result) +{ + $error = null; + + if (isset($result->retval)) + { + $error = $result->retval; + } + + return $error; +} diff --git a/application/libraries/AuthLib.php b/application/libraries/AuthLib.php index bb2c6ce9b..67a527655 100644 --- a/application/libraries/AuthLib.php +++ b/application/libraries/AuthLib.php @@ -378,7 +378,8 @@ class AuthLib } else // otherwise { - $hta = $this->_createAuthObjByPerson(array('uid' => $_SERVER['PHP_AUTH_USER'])); + // NOTE: Username needs to be trimmed and lowered because htaccess is allowing login + $hta = $this->_createAuthObjByPerson(array('uid' => mb_strtolower(trim($_SERVER['PHP_AUTH_USER'])))); } // Invalid credentials @@ -390,7 +391,7 @@ class AuthLib } elseif (isError($hta)) // display error and stop execution { - $this->_showError(getData($hta)); + $this->_showError(getError($hta)); } return $hta; // if success then is returned! @@ -550,7 +551,7 @@ class AuthLib } elseif (isError($auth)) // blocking error { - $this->_showError(getData($auth)); // display a generic error message and logs the occurred error + $this->_showError(getError($auth)); // display a generic error message and logs the occurred error } } // else the user is already logged, then loads authentication helper and continue with the execution @@ -574,10 +575,11 @@ class AuthLib // Needed information $this->_ci->PersonModel->addSelect('person_id, vorname, nachname, uid'); - // Retrieves the uid if it is possible - $this->_ci->PersonModel->addJoin('public.tbl_benutzer', 'person_id', 'LEFT'); - - $queryParamsArray['tbl_person.aktiv'] = true; // only active users! + // Retrieves the uid if it is possible for active users + $this->_ci->PersonModel->addJoin( + '(SELECT uid, person_id FROM public.tbl_benutzer WHERE aktiv = TRUE) tb', 'person_id', + 'LEFT' + ); // Execute query with where clause $personResult = $this->_ci->PersonModel->loadWhere($queryParamsArray); diff --git a/application/libraries/DmsLib.php b/application/libraries/DmsLib.php index 6b86ce7f8..f32df5fd1 100644 --- a/application/libraries/DmsLib.php +++ b/application/libraries/DmsLib.php @@ -249,7 +249,7 @@ class DmsLib } else { - return error($dmscontent->retval); + return error(getError($dmscontent)); } } else @@ -259,7 +259,7 @@ class DmsLib } else { - return error($akte->retval); + return error(getError($akte)); } } diff --git a/application/libraries/DocumentLib.php b/application/libraries/DocumentLib.php index ed87a9f38..98e546b4e 100644 --- a/application/libraries/DocumentLib.php +++ b/application/libraries/DocumentLib.php @@ -68,7 +68,7 @@ class DocumentLib } else { - return error($ret->retval); + return error(getError($ret)); } case 'application/pdf': return success($filename); diff --git a/application/libraries/FiltersLib.php b/application/libraries/FilterWidgetLib.php similarity index 91% rename from application/libraries/FiltersLib.php rename to application/libraries/FilterWidgetLib.php index 6875d16ec..c2e57eed2 100644 --- a/application/libraries/FiltersLib.php +++ b/application/libraries/FilterWidgetLib.php @@ -5,10 +5,12 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); /** * FilterWidget logic */ -class FiltersLib +class FilterWidgetLib { - // Session parameters names - const SESSION_NAME = 'FHC_FILTER_WIDGET'; // Filter session name + // FilterWidget session name + const SESSION_NAME = 'FHC_FILTER_WIDGET'; + + // Session elements const SESSION_FILTER_NAME = 'filterName'; const SESSION_FIELDS = 'fields'; const SESSION_SELECTED_FIELDS = 'selectedFields'; @@ -17,11 +19,18 @@ class FiltersLib const SESSION_CHECKBOXES = 'checkboxes'; const SESSION_FILTERS = 'filters'; const SESSION_METADATA = 'datasetMetadata'; - const SESSION_DATASET = 'dataset'; const SESSION_ROW_NUMBER = 'rowNumber'; - const SESSION_RELOAD_DATASET = 'reloadDataset'; + const SESSION_TIMEOUT = 'sessionTimeout'; + + // Session dataset elements + const SESSION_DATASET = 'dataset'; + const SESSION_DATASET_RELOAD = 'reloadDataset'; const SESSION_DATASET_REPRESENTATION = 'datasetRepresentation'; const SESSION_DATASET_REP_OPTIONS = 'datasetRepresentationOptions'; + const SESSION_DATASET_REP_FIELDS_DEFS = 'datasetRepresentationFieldsDefinitions'; + + // Default session timeout + const SESSION_DEFAULT_TIMEOUT = 30; // Alias for the dynamic table used to retrieve the dataset const DATASET_TABLE_ALIAS = 'datasetFilterTable'; @@ -32,16 +41,16 @@ class FiltersLib // ...to identify a single filter widget in the DB const FILTER_ID = 'filter_id'; - const APP_PARAMETER = 'app'; - const DATASET_NAME_PARAMETER = 'datasetName'; - const FILTER_KURZBZ_PARAMETER = 'filterKurzbz'; - const DATASET_RELOAD_PARAMETER = 'reloadDataset'; + const APP = 'app'; + const DATASET_NAME = 'datasetName'; + const FILTER_KURZBZ = 'filterKurzbz'; + const DATASET_RELOAD = 'reloadDataset'; // ...to specify permissions that are needed to use this FilterWidget - const REQUIRED_PERMISSIONS_PARAMETER = 'requiredPermissions'; + const REQUIRED_PERMISSIONS = 'requiredPermissions'; // ...stament to retrieve the dataset - const QUERY_PARAMETER = 'query'; + const QUERY = 'query'; // ...to specify more columns or aliases for them const ADDITIONAL_COLUMNS = 'additionalColumns'; @@ -53,18 +62,23 @@ class FiltersLib const MARK_ROW = 'markRow'; // ...to hide the options for a filter - const HIDE_HEADER = 'hideHeader'; + const HIDE_OPTIONS = 'hideOptions'; + const HIDE_SELECT_FIELDS = 'hideSelectFields'; + const HIDE_SELECT_FILTERS = 'hideSelectFilters'; const HIDE_SAVE = 'hideSave'; const CUSTOM_MENU = 'customMenu'; // ...to specify if the menu for this filter is custom (true) or not (false) + const HIDE_MENU = 'hideMenu'; // ...to specify if the menu should be shown or not // ...to specify how to represent the dataset (ex: tablesorter, pivotUI, ...) const DATASET_REPRESENTATION = 'datasetRepresentation'; const DATASET_REP_OPTIONS = 'datasetRepOptions'; + const DATASET_REP_FIELDS_DEFS = 'datasetRepFieldsDefs'; // Different dataset representations const DATASET_REP_TABLESORTER = 'tablesorter'; const DATASET_REP_PIVOTUI = 'pivotUI'; + const DATASET_REP_TABULATOR = 'tabulator'; // Filter operations values const OP_EQUAL = 'equal'; @@ -84,7 +98,7 @@ class FiltersLib const FILTER_PHRASES_CATEGORY = 'FilterWidget'; // The category used to store phrases for the FilterWidget - const FILTER_PAGE_PARAM = 'filter_page'; // Filter page parameter name + const FILTER_UNIQUE_ID = 'filterUniqueId'; // Filter page parameter name const PERMISSION_FILTER_METHOD = 'FilterWidget'; // Name for fake method to be checked by the PermissionLib const PERMISSION_TYPE = 'rw'; @@ -107,8 +121,6 @@ class FiltersLib public function __construct($params = null) { $this->_ci =& get_instance(); // get code igniter instance - - $this->_filterUniqueId = $this->_getFilterUniqueId($params); // sets the id for the related filter widget } //------------------------------------------------------------------------------------------------------------------ @@ -127,7 +139,7 @@ class FiltersLib // Gets the required permissions from the session if they are not provided as parameter $rq = $requiredPermissions; - if ($rq == null) $rq = $this->getSessionElement(self::REQUIRED_PERMISSIONS_PARAMETER); + if ($rq == null) $rq = $this->getSessionElement(self::REQUIRED_PERMISSIONS); return $this->_ci->permissionlib->hasAtLeastOne($rq, self::PERMISSION_FILTER_METHOD, self::PERMISSION_TYPE); } @@ -175,6 +187,29 @@ class FiltersLib setSessionElement(self::SESSION_NAME, $this->_filterUniqueId, $session); // stores the single value } + /** + * + */ + public function dropExpiredFilterWidgets() + { + // Loads the session for all the filter widgets + $filterWidgetsSession = getSession(self::SESSION_NAME); + + // If something is present in session + if ($filterWidgetsSession != null) + { + // Loops in the session for all the filter widgets + foreach ($filterWidgetsSession as $filterWidget => $filterWidgetData) + { + // If this filter widget is not the currrent used filter widget and the it is expired... + if ($this->_filterUniqueId != $filterWidget && $filterWidgetData[self::SESSION_TIMEOUT] <= time()) + { + cleanSessionElement(self::SESSION_NAME, $filterWidget); // ...remove it + } + } + } + } + /** * Loads the definition data from DB for a filter widget */ @@ -467,7 +502,7 @@ class FiltersLib // Write changes into the session $this->setSessionElement(self::SESSION_FILTERS, $filters); - $this->setSessionElement(self::SESSION_RELOAD_DATASET, true); // the dataset must be reloaded + $this->setSessionElement(self::SESSION_DATASET_RELOAD, true); // the dataset must be reloaded $removeAppliedFilter = true; } @@ -519,7 +554,7 @@ class FiltersLib // Write changes into the session $this->setSessionElement(self::SESSION_FILTERS, $filters); - $this->setSessionElement(self::SESSION_RELOAD_DATASET, true); // the dataset must be reloaded + $this->setSessionElement(self::SESSION_DATASET_RELOAD, true); // the dataset must be reloaded $applyFilters = true; } @@ -533,7 +568,7 @@ class FiltersLib */ public function reloadDataset() { - $this->setSessionElement(self::SESSION_RELOAD_DATASET, true); + $this->setSessionElement(self::SESSION_DATASET_RELOAD, true); } /** @@ -599,8 +634,8 @@ class FiltersLib // Loads the definition to check if is already present in the DB $definition = $this->_ci->FiltersModel->loadWhere(array( - 'app' => $this->getSessionElement(self::APP_PARAMETER), - 'dataset_name' => $this->getSessionElement(self::DATASET_NAME_PARAMETER), + 'app' => $this->getSessionElement(self::APP), + 'dataset_name' => $this->getSessionElement(self::DATASET_NAME), 'description' => $descPGArray, 'person_id' => $authPersonId )); @@ -628,8 +663,8 @@ class FiltersLib // update it $this->_ci->FiltersModel->update( array( - 'app' => $this->getSessionElement(self::APP_PARAMETER), - 'dataset_name' => $this->getSessionElement(self::DATASET_NAME_PARAMETER), + 'app' => $this->getSessionElement(self::APP), + 'dataset_name' => $this->getSessionElement(self::DATASET_NAME), 'description' => $descPGArray, 'person_id' => $authPersonId ), @@ -644,8 +679,8 @@ class FiltersLib { $this->_ci->FiltersModel->insert( array( - 'app' => $this->getSessionElement(self::APP_PARAMETER), - 'dataset_name' => $this->getSessionElement(self::DATASET_NAME_PARAMETER), + 'app' => $this->getSessionElement(self::APP), + 'dataset_name' => $this->getSessionElement(self::DATASET_NAME), 'filter_kurzbz' => uniqid($authPersonId, true), 'description' => $descPGArray, 'person_id' => $authPersonId, @@ -689,7 +724,7 @@ class FiltersLib public function generateFilterMenu($navigationPage) { // Loads the NavigationLib for the current page (given as parameter) - $this->_ci->load->library('NavigationLib', array(FiltersLib::NAVIGATION_PAGE => $navigationPage)); + $this->_ci->load->library('NavigationLib', array(self::NAVIGATION_PAGE => $navigationPage)); $filterMenu = null; $currentMenu = $this->_ci->navigationlib->getSessionMenu(); // The navigation menu currently stored in session @@ -702,7 +737,7 @@ class FiltersLib // Loads all the filters related to this page (same dataset_name and same app name) $filters = $this->_ci->FiltersModel->getFiltersByAppDatasetName( - $session[self::APP_PARAMETER], $session[self::DATASET_NAME_PARAMETER] + $session[self::APP], $session[self::DATASET_NAME] ); // If filters were loaded @@ -771,7 +806,7 @@ class FiltersLib ); // Sets in the session only the element related to the filters menu - $this->_ci->navigationlib->setSessionElementMenu(FiltersLib::NAV_MENU_FILTER_KEY, $filterMenu); + $this->_ci->navigationlib->setSessionElementMenu(self::NAV_MENU_FILTER_KEY, $filterMenu); } } } @@ -784,14 +819,14 @@ class FiltersLib * NOTE: The default value is the URI where the FilterWidget is called * If the fhc_controller_id is present then is also used */ - private function _getFilterUniqueId($params) + public function setFilterUniqueIdByParams($params) { if ($params != null && is_array($params) - && isset($params[self::FILTER_PAGE_PARAM]) - && !isEmptyString($params[self::FILTER_PAGE_PARAM])) + && isset($params[self::FILTER_UNIQUE_ID]) + && !isEmptyString($params[self::FILTER_UNIQUE_ID])) { - $filterUniqueId = $params[self::FILTER_PAGE_PARAM]; + $filterUniqueId = $params[self::FILTER_UNIQUE_ID]; } else { @@ -799,6 +834,14 @@ class FiltersLib $filterUniqueId = $this->_ci->router->directory.$this->_ci->router->class.'/'.$this->_ci->router->method; } + $this->setFilterUniqueId($filterUniqueId); + } + + /** + * + */ + public function setFilterUniqueId($filterUniqueId) + { // If the FHC_CONTROLLER_ID parameter is present in the HTTP GET if (isset($_GET[self::FHC_CONTROLLER_ID])) { @@ -809,7 +852,7 @@ class FiltersLib $filterUniqueId .= '/'.$this->_ci->input->post(self::FHC_CONTROLLER_ID); // then use it } - return $filterUniqueId; + $this->_filterUniqueId = $filterUniqueId; } /** diff --git a/application/libraries/PermissionLib.php b/application/libraries/PermissionLib.php index b84359216..348c8b87b 100644 --- a/application/libraries/PermissionLib.php +++ b/application/libraries/PermissionLib.php @@ -254,6 +254,45 @@ class PermissionLib return !$this->_inLAPersonIdsBlacklist($person_id) && $this->_hasLAPermissions(); } + /** + * Returns the study programs the person is entitled for. + * @param null $berechtigung_kurzbz If given, only study programs are retrieved according to organisational units + * assigned to that permission. + * @return array|bool array of studiengang_kz the person is entitled for. False on error. + */ + public function getSTG_isEntitledFor($berechtigung_kurzbz = null) + { + $studiengang_kz_arr = array(); + + if (self::$bb->getStgKz($berechtigung_kurzbz)) + { + return $studiengang_kz_arr = self::$bb->getStgKz($berechtigung_kurzbz); + } + else + { + return false; + } + } + + /** + * Returns the organisational units the person is entitled for. + * @param null $berechtigung_kurzbz + * @return array|bool array of oe_kurzbz the person is entitled for. False on error. + */ + public function getOE_isEntitledFor($berechtigung_kurzbz = null) + { + $oe_kurzbz_arr = array(); + + if (self::$bb->getOEkurzbz($berechtigung_kurzbz)) + { + return $oe_kurzbz_arr = self::$bb->getOEkurzbz($berechtigung_kurzbz); + } + else + { + return false; + } + } + //------------------------------------------------------------------------------------------------------------------ // Private methods diff --git a/application/libraries/PersonLogLib.php b/application/libraries/PersonLogLib.php index 299fc8ce2..fe9a82504 100644 --- a/application/libraries/PersonLogLib.php +++ b/application/libraries/PersonLogLib.php @@ -76,7 +76,7 @@ class PersonLogLib return $decoded_logs; } else - show_error($result->retval); + show_error(getError($result)); } /** diff --git a/application/libraries/TableWidgetLib.php b/application/libraries/TableWidgetLib.php new file mode 100644 index 000000000..139e5d6cb --- /dev/null +++ b/application/libraries/TableWidgetLib.php @@ -0,0 +1,238 @@ +_ci =& get_instance(); // get code igniter instance + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Checks if at least one of the permissions given as parameter (requiredPermissions) belongs + * to the authenticated user, if confirmed then is allowed to use this FilterWidget. + * If the parameter requiredPermissions is NOT given or is not present in the session, + * then NO one is allow to use this FilterWidget + * Wrapper method to permissionlib->hasAtLeastOne + */ + public function isAllowed($requiredPermissions = null) + { + $this->_ci->load->library('PermissionLib'); // Load permission library + + // Gets the required permissions from the session if they are not provided as parameter + $rq = $requiredPermissions; + if ($rq == null) $rq = $this->getSessionElement(self::REQUIRED_PERMISSIONS); + + return $this->_ci->permissionlib->hasAtLeastOne($rq, self::PERMISSION_TABLE_METHOD, self::PERMISSION_TYPE); + } + + /** + * Wrapper method to the session helper funtions to retrieve the whole session for this table widget + */ + public function getSession() + { + return getSessionElement(self::SESSION_NAME, $this->_tableUniqueId); + } + + /** + * Wrapper method to the session helper funtions to retrieve one element from the session of this table widget + */ + public function getSessionElement($name) + { + $session = getSessionElement(self::SESSION_NAME, $this->_tableUniqueId); + + if (isset($session[$name])) + { + return $session[$name]; + } + + return null; + } + + /** + * Wrapper method to the session helper funtions to set the whole session for this table widget + */ + public function setSession($data) + { + setSessionElement(self::SESSION_NAME, $this->_tableUniqueId, $data); + } + + /** + * Wrapper method to the session helper funtions to set one element in the session for this table widget + */ + public function setSessionElement($name, $value) + { + $session = getSessionElement(self::SESSION_NAME, $this->_tableUniqueId); + + $session[$name] = $value; + + setSessionElement(self::SESSION_NAME, $this->_tableUniqueId, $session); // stores the single value + } + + /** + * + */ + public function dropExpiredTableWidgets() + { + // Loads the session for all the table widgets + $tableWidgetsSession = getSession(self::SESSION_NAME); + + // If something is present in session + if ($tableWidgetsSession != null) + { + // Loops in the session for all the table widgets + foreach ($tableWidgetsSession as $tableWidget => $tableWidgetData) + { + // If this table widget is not the currrent used table widget and the it is expired... + if ($this->_tableUniqueId != $tableWidget && $tableWidgetData[self::SESSION_TIMEOUT] <= time()) + { + cleanSessionElement(self::SESSION_NAME, $tableWidget); // ...remove it + } + } + } + } + + /** + * Generate the query to retrieve the dataset for a table widget + */ + public function generateDatasetQuery($query) + { + return 'SELECT * FROM ('.$query.') '.self::DATASET_TABLE_ALIAS; + } + + /** + * Retrieves the dataset from the DB + */ + public function getDataset($datasetQuery) + { + $dataset = null; + + if ($datasetQuery != null) + { + $this->_ci->load->model('system/Filters_model', 'FiltersModel'); + + // Execute the given SQL statement suppressing error messages + $dataset = @$this->_ci->FiltersModel->execReadOnlyQuery($datasetQuery); + } + + return $dataset; + } + + /** + * Retrieves metadata from the last executed query + */ + public function getExecutedQueryMetaData() + { + return $this->_ci->FiltersModel->getExecutedQueryMetaData(); + } + + /** + * Retrieves the list of fields from the last executed query + */ + public function getExecutedQueryListFields() + { + return $this->_ci->FiltersModel->getExecutedQueryListFields(); + } + + /** + * Return an unique string that identify this table widget + * NOTE: The default value is the URI where the FilterWidget is called + * If the fhc_controller_id is present then is also used + */ + public function setTableUniqueIdByParams($params) + { + if ($params != null + && is_array($params) + && isset($params[self::TABLE_UNIQUE_ID]) + && !isEmptyString($params[self::TABLE_UNIQUE_ID])) + { + $tableUniqueId = $this->_ci->router->directory.$this->_ci->router->class.'/'. + $this->_ci->router->method.'/'. + $params[self::TABLE_UNIQUE_ID]; + + $this->setTableUniqueId($tableUniqueId); + } + } + + /** + * Set the _tableUniqueId property + */ + public function setTableUniqueId($tableUniqueId) + { + $this->_tableUniqueId = $tableUniqueId; + } +} diff --git a/application/libraries/UDFLib.php b/application/libraries/UDFLib.php index 6166b44a9..bc8552c25 100644 --- a/application/libraries/UDFLib.php +++ b/application/libraries/UDFLib.php @@ -540,7 +540,7 @@ class UDFLib { if (is_object($udfResults) && isset($udfResults->retval)) { - show_error($udfResults->retval); + show_error(getError($udfResults)); } elseif (is_string($udfResults)) { diff --git a/application/models/accounting/Konto_model.php b/application/models/accounting/Konto_model.php index d76b2bd46..cbd7a6f2d 100644 --- a/application/models/accounting/Konto_model.php +++ b/application/models/accounting/Konto_model.php @@ -22,8 +22,7 @@ class Konto_model extends DB_Model $this->addJoin('wawi.tbl_konto_kostenstelle', 'konto_id'); $konten = $this->loadWhere(array('kostenstelle_id' => $kostenstelle_id)); - if ($konten->error) - return error($konten->retval); + if ($konten->error) return $konten; return $konten; } diff --git a/application/models/accounting/Vertrag_model.php b/application/models/accounting/Vertrag_model.php index cd4b466d6..8725cd98d 100644 --- a/application/models/accounting/Vertrag_model.php +++ b/application/models/accounting/Vertrag_model.php @@ -10,5 +10,324 @@ class Vertrag_model extends DB_Model parent::__construct(); $this->dbTable = 'lehre.tbl_vertrag'; $this->pk = 'vertrag_id'; + + $this->load->model('accounting/Vertragvertragsstatus_model', 'VertragvertragsstatusModel'); + $this->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel'); + $this->load->model('education/Projektbetreuer_model', 'ProjektbetreuerModel'); } + + /** + * Saves Vertrag for a Lehrauftrag and sets Vertragsstatus to 'bestellt'. + * Also updates vertrag_id in tbl_lehreinheitmitarbeiter or tbl_projektbetreuer. + * @param $person_id + * @param $lehrveranstaltung_id + * @param $lehreinheit_id + * @param $projektarbeit_id + * @param $betrag Monetary amount of that Lehreinheit / Projektbetreuung. + * @param $vertragsstunden Working hours of that Lehreinheit / Projektbetreuung. + * @param $studiensemester_kurzbz + * @param $vertragstyp_kurzbz + * @return array|null On success object. On failure null. + */ + public function save($person_id, $mitarbeiter_uid, $lehrveranstaltung_id, $lehreinheit_id, $projektarbeit_id = null, $vertragsstunden, $betrag, $studiensemester_kurzbz) + { + $person_id = (isset($person_id) && is_numeric($person_id)) + ? $person_id + : show_error('peron_id must be set and numeric.'); + $lehreinheit_id = (isset($lehreinheit_id) && is_numeric($lehreinheit_id)) + ? $lehreinheit_id + : show_error('lehreinheit_id must be set and numeric.'); + $lehrveranstaltung_id = (isset($lehrveranstaltung_id) && is_numeric($lehrveranstaltung_id)) + ? $lehrveranstaltung_id + : show_error('lehrveranstaltung_id must be set and numeric.'); + $projektarbeit_id = (isset($projektarbeit_id) && is_numeric($projektarbeit_id)) + ? $projektarbeit_id + : null; + $vertragsstunden = (isset($vertragsstunden) && is_numeric($vertragsstunden)) + ? $vertragsstunden + : 0; + $betrag = (isset($betrag) && is_numeric($betrag)) + ? $betrag + : 0; + $mitarbeiter_uid = (isset($mitarbeiter_uid) && is_string($mitarbeiter_uid)) + ? $mitarbeiter_uid + : show_error('mitarbeiter_uid must be set and a string value.');; + + $vertragstyp_kurzbz = (is_null($projektarbeit_id)) ? 'Lehrauftrag' : 'Betreuung'; + + // First check if Vertrag already exists for that Lehrauftrag or for that Projektbetreuerauftrag + if ($vertragstyp_kurzbz == 'Lehrauftrag') + { + if ($this->LehreinheitmitarbeiterModel->hasVertrag($mitarbeiter_uid, $lehreinheit_id)) + { + return error('Lehrauftrag existiert bereits'); // Exit if Lehrauftrag already has Vertrag + } + } + elseif ($vertragstyp_kurzbz == 'Betreuung') + { + if ($this->ProjektbetreuerModel->hasVertrag($person_id, $projektarbeit_id)) + { + return error('Lehrauftrag existiert bereits'); // Exit if Projektbetreuung already has Vertrag + } + } + + // If Vertrag does not exist, create now + // Vertragsbezeichnung + $bezeichnung = $this->_writeVertragsbezeichung($lehrveranstaltung_id, $studiensemester_kurzbz); + + // Start DB transaction + $this->db->trans_start(false); + + // Insert Vertragsdata + $result = $this->insert( + array( + 'person_id' => $person_id, + 'lehrveranstaltung_id' => $lehrveranstaltung_id, + 'vertragstyp_kurzbz' => $vertragstyp_kurzbz, + 'bezeichnung' => $bezeichnung, + 'betrag' => $betrag, + 'insertamum' => 'NOW()', + 'insertvon' => getAuthUID(), + 'vertragsdatum' => 'NOW()', + 'vertragsstunden' => $vertragsstunden, + 'vertragsstunden_studiensemester_kurzbz' => $studiensemester_kurzbz + ) + ); + + // Retrieve primary key + $vertrag_id = $result->retval; + + // If Vertrag was created successfully, update vertrag_id + if (isSuccess($result)) + { + // if Lehrtätigkeit, update vertrag_id in tbl_lehreinheitmitarbeiter + if ($vertragstyp_kurzbz == 'Lehrauftrag') + { + $this->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel'); + $result = $this->LehreinheitmitarbeiterModel->update( + array( + 'lehreinheit_id' => $lehreinheit_id, + 'mitarbeiter_uid' =>$mitarbeiter_uid + ), + array( + 'vertrag_id' => $vertrag_id + ) + ); + } + // if (Projekt-)Betreuung, update vertrag_id in tbl_projektbetreuer + elseif ($vertragstyp_kurzbz == 'Betreuung') + { + $this->load->model('education/Projektbetreuer_model', 'ProjektbetreuerModel'); + $result = $this->ProjektbetreuerModel->update( + array( + 'person_id' => $person_id, + 'projektarbeit_id' => $projektarbeit_id + ), + array( + 'vertrag_id' => $vertrag_id + ) + ); + } + } + + // If updating vertrag_id was successfully, set Status to 'bestellt' + if (isSuccess($result)) + { + $result = $this->VertragvertragsstatusModel->setStatus($vertrag_id, $mitarbeiter_uid, 'bestellt'); + } + + // Transaction complete! + $this->db->trans_complete(); + + // Check if everything went ok during the transaction + if ($this->db->trans_status() === false || isError($result)) + { + $this->db->trans_rollback(); + return error($result->msg, EXIT_ERROR); + } + else + { + $this->db->trans_commit(); + return success($vertrag_id); + } + } + + /** + * Updates Vertrag and, if resets vertragsstatus as follows: + * - if vertragsstatus 'erteilt': delete status 'erteilt' and update date of status 'bestellt' + * - if vertragsstatus 'bestellt': update date of status 'bestellt' + * @param $vertrag_obj Object with vertrag properties vertrag_id, vertragsstunden, betrag. + * @param $mitarbeiter_uid + */ + public function updateVertrag($vertrag_id, $vertragsstunden, $betrag, $mitarbeiter_uid) + { + $vertrag_id = (isset($vertrag_id) && is_numeric($vertrag_id)) + ? $vertrag_id + : show_error('vertrag_id must be set and numeric.'); + $vertragsstunden = (isset($vertragsstunden) && is_numeric($vertragsstunden)) + ? $vertragsstunden + : 0; + $betrag = (isset($betrag) && is_numeric($betrag)) + ? $betrag + : 0; + $mitarbeiter_uid = (isset($mitarbeiter_uid) && is_string($mitarbeiter_uid)) + ? $mitarbeiter_uid + : show_error('mitarbeiter_uid must be set and a string value.'); + + // Start DB transaction + $this->db->trans_start(false); + + // Update contract + $result = $this->update( + $vertrag_id, + array( + 'vertragsstunden' => $vertragsstunden, + 'betrag' => $betrag, + 'updateamum' => $this->escape('NOW()'), + 'updatevon' => getAuthUID() + ) + ); + + // If last vertragsstatus is 'erteilt', delete the status + if (isSuccess($result)) + { + $result = $this->VertragvertragsstatusModel->getLastStatus($vertrag_id, $mitarbeiter_uid); + + $lastStatus = getData($result)[0]->vertragsstatus_kurzbz; + + if ($lastStatus == 'erteilt') + { + $result = $this->VertragvertragsstatusModel->deleteStatus($vertrag_id, 'erteilt'); + } + } + + // Update date of status 'bestellt' + if (isSuccess($result)) + { + $result = $this->VertragvertragsstatusModel->updateStatus($vertrag_id, 'bestellt'); + } + + // Transaction complete! + $this->db->trans_complete(); + + // Check if everything went ok during the transaction + if ($this->db->trans_status() === false || isError($result)) + { + $this->db->trans_rollback(); + return error($result->msg, EXIT_ERROR); + } + else + { + $this->db->trans_commit(); + return success('Contract successfully updated.'); + } + } + + /** + * Gets Lehreinheit ID corresponding to the contract. + * @param $vertrag_id + * @return array + */ + public function getLehreinheitID($vertrag_id) + { + $vertragstyp_kurzbz = null; + + $this->addSelect('vertragstyp_kurzbz'); + if ($result = getData($this->load($vertrag_id))) + { + $vertragstyp_kurzbz = $result[0]->vertragstyp_kurzbz; + } + else + { + return error('Fehler beim Laden des Vertrags.'); + } + + if ($vertragstyp_kurzbz == 'Lehrauftrag') + { + $this->LehreinheitmitarbeiterModel->addSelect('lehreinheit_id'); + if ($result = $this->LehreinheitmitarbeiterModel->loadWhere(array('vertrag_id' => $vertrag_id))) + { + return success($result->retval); + } + else + { + return error('Fehler beim Ermitteln der Lehreinheit ID'); + } + + } + elseif ($vertragstyp_kurzbz == 'Betreuung') + { + $this->addSelect('lehreinheit_id'); + $this->addJoin('lehre.tbl_projektbetreuer', 'vertrag_id'); + $this->addJoin('lehre.tbl_projektarbeit', 'projektarbeit_id'); + if ($result = $this->loadWhere(array('vertrag_id' => $vertrag_id))) + { + return success($result->retval); + } + else + { + return error('Fehler beim Ermitteln der Lehreinheit ID'); + } + } + } + + /** + * Gets (table) data of lehreinheit_id corresponding to the contract. + * @param integer $vertrag_id + * @param string $select To restrict fields, pass select string. e.g. 'lehrveranstaltung_id'. + * @return array + */ + public function getLehreinheitData($vertrag_id, $select = '*') + { + if ($result = getData($this->getLehreinheitID($vertrag_id))) + { + $this->load->model('education/Lehreinheit_model', 'LehreinheitModel'); + $this->LehreinheitModel->addSelect($select); + + if($result = $this->LehreinheitModel->load($result[0]->lehreinheit_id)) + { + return success($result->retval); + } + else + { + return error('Fehler beim Laden der Lehreinheit'); + } + } + else + { + return error('Fehler beim Ermitteln der Lehreinheit ID'); + } + } + + // ----------------------------------------------------------------------------------------------------------------- + // Private methods + + /** + * Generate contract description. + * Example: WS2017-BEE3-LIA-LAB + * @param $lehrveranstaltung_id + * @param $studiensemester_kurzbz Studiensemester of Lehrauftrag (= when the lector will teach the lehrveranstaltung) + * @return string Returns e.g. WS2017-BBE5-GAP-LAB + */ + private function _writeVertragsbezeichung($lehrveranstaltung_id, $studiensemester_kurzbz) + { + $bezeichnung = ''; + $this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel'); + $this->LehrveranstaltungModel->addSelect('tbl_lehrveranstaltung.semester, tbl_lehrveranstaltung.kurzbz AS "lv_kurzbz", lehrform_kurzbz, public.tbl_studiengang.typ, public.tbl_studiengang.kurzbz'); + $this->LehrveranstaltungModel->addJoin('lehre.tbl_studienplan_lehrveranstaltung', 'lehrveranstaltung_id'); + $this->LehrveranstaltungModel->addJoin('lehre.tbl_studienplan', 'studienplan_id'); + $this->LehrveranstaltungModel->addJoin('lehre.tbl_studienordnung', 'studienordnung_id'); + $this->LehrveranstaltungModel->addJoin('public.tbl_studiengang', 'public.tbl_studiengang.studiengang_kz = lehre.tbl_studienordnung.studiengang_kz'); + $result = $this->LehrveranstaltungModel->load($lehrveranstaltung_id); + + if (hasData($result)) + { + $bezeichnung = $studiensemester_kurzbz. '-'; + $bezeichnung.= strtoupper($result->retval[0]->typ. $result->retval[0]->kurzbz). $result->retval[0]->semester. '-'; + $bezeichnung.= $result->retval[0]->lv_kurzbz. '-'; + $bezeichnung.= $result->retval[0]->lehrform_kurzbz; + } + + return $bezeichnung; + } } diff --git a/application/models/accounting/Vertragvertragsstatus_model.php b/application/models/accounting/Vertragvertragsstatus_model.php new file mode 100644 index 000000000..609394321 --- /dev/null +++ b/application/models/accounting/Vertragvertragsstatus_model.php @@ -0,0 +1,193 @@ +dbTable = 'lehre.tbl_vertrag_vertragsstatus'; + $this->pk = array('vertragsstatus_kurzbz', 'vertrag_id'); + $this->hasSequence = false; + } + + /** + * Check if Vertrag has the given Vertragsstatus. + * @param integer $vertrag_id + * @param string $mitarbeiter_uid + * @param string $vertragsstatus_kurzbz + * @return array + */ + public function hasStatus($vertrag_id, $mitarbeiter_uid, $vertragsstatus_kurzbz) + { + $this->addSelect('1'); + $this->addLimit(1); + + return $this->loadWhere(array( + 'vertrag_id' => $vertrag_id, + 'uid' => $mitarbeiter_uid, + 'vertragsstatus_kurzbz' => $vertragsstatus_kurzbz + )); + } + + /** + * Get the latest Vertragsstatus for the given Vertrag and Mitarbeiter + * @param integer $vertrag_id + * @param string $mitarbeiter_uid + * @return array + */ + public function getLastStatus($vertrag_id, $mitarbeiter_uid) + { + $this->addSelect('vertragsstatus_kurzbz'); + $this->addOrder('datum', 'DESC'); + $this->addLimit(1); + return $this->loadWhere( + array( + 'vertrag_id' => $vertrag_id, + 'uid' => $mitarbeiter_uid + ) + ); + } + + /** + * Set Vertragsstatus for the given Vertrag and Mitarbeiter. + * @param integer $vertrag_id + * @param string $mitarbeiter_uid + * @param string $vertragsstatus_kurzbz + * @return object On success, return success object. + * If status already exists or earlier status is missing, return error object. + */ + public function setStatus($vertrag_id, $mitarbeiter_uid, $vertragsstatus_kurzbz){ + + // Check if vertrag has already this status + $result = $this->hasStatus($vertrag_id, $mitarbeiter_uid, $vertragsstatus_kurzbz); + + // If status is already set, return error message + if (hasData($result)) + { + return error('Fehler: Status bereits vorhanden.'); + } + + // If new status should be 'akzeptiert', the latest status has to be 'erteilt' + if ($vertragsstatus_kurzbz == 'akzeptiert') + { + $result = $this->getLastStatus($vertrag_id, $mitarbeiter_uid); + $last_status = getData($result)[0]->vertragsstatus_kurzbz; + + // If latest status is not 'erteilt', return error message + if ($last_status != 'erteilt') + { + return error('Fehler: Vor Status \'angenommen\' muss erst Status \'erteilt\' gesetzt sein.'); + } + } + + // Set new status if passed all checks + return $this->insert( + array( + 'vertrag_id' => $vertrag_id, + 'vertragsstatus_kurzbz' => $vertragsstatus_kurzbz, + 'uid' => $mitarbeiter_uid, + 'datum' => $this->escape('NOW()'), + 'insertvon' => getAuthUID(), + 'insertamum' => $this->escape('NOW()') + ) + ); + } + + /** + * Updates the date of the given vertragsstatus. + * @param $vertrag_id + * @param $vertragsstatus_kurzbz + * @return array + */ + public function updateStatus($vertrag_id, $vertragsstatus_kurzbz) + { + $user = getAuthUID(); + return $this->update( + array( + 'vertrag_id' => $vertrag_id, + 'vertragsstatus_kurzbz' => $vertragsstatus_kurzbz + ), + array( + 'datum' => $this->escape('NOW()'), + 'updateamum' => $this->escape('NOW()'), + 'updatevon' => $user, + ) + ); + } + + /** + * Deletes the given vertragsstatus of the contract. + * @param $vertrag_id + * @param $vertragsstatus_kurbz + * @return array + */ + public function deleteStatus($vertrag_id, $vertragsstatus_kurzbz) + { + return $this->delete( + array( + 'vertrag_id' => $vertrag_id, + 'vertragsstatus_kurzbz' => $vertragsstatus_kurzbz + ) + ); + } + + /** + * Get all contracts, where the status had been set to 'bestellt' on given date + * @param string $string_date e.g. '01.11.2019' or special Date/Time inputs like 'YESTERDAY', 'TODAY', 'NOW' + * @param bool $further_processed If true, ALL ordered contracts of that day are retrieved, even if they were + * were ALSO approved/accepted/cancelled (further processed) on that same day. + * @return array + */ + public function getOrdered_fromDate($string_date = 'TODAY', $further_processed = false) + { + $condition = ' + vertragsstatus_kurzbz = \'bestellt\' AND + (datum)::date = date \''. $string_date .'\' + '; + + if (!$further_processed) + { + $condition .= ' + AND + vertrag_id NOT IN ( + SELECT vertrag_id + FROM lehre.tbl_vertrag_vertragsstatus + WHERE vertragsstatus_kurzbz IN (\'erteilt\', \'akzeptiert\', \'storno\') + ) + '; + } + + return $this->loadWhere($condition); + } + + /** + * Get all contracts, where the status had been set to 'erteilt' on given date + * @param string $string_date e.g. '01.11.2019' or special Date/Time inputs like 'YESTERDAY', 'TODAY', 'NOW' + * @param bool $further_processed If true, ALL contracts approved on that day are retrieved, even if they were + * were ALSO accepted/cancelled (further processed) on that same day. + * @return array + */ + public function getApproved_fromDate($string_date = 'TODAY', $further_processed = false) + { + $condition = ' + vertragsstatus_kurzbz = \'erteilt\' AND + (datum)::date = date \''. $string_date .'\' + '; + + if (!$further_processed) + { + $condition .= ' + AND + vertrag_id NOT IN ( + SELECT vertrag_id + FROM lehre.tbl_vertrag_vertragsstatus + WHERE vertragsstatus_kurzbz IN (\'akzeptiert\', \'storno\') + ) + '; + } + + return $this->loadWhere($condition); + } +} diff --git a/application/models/codex/Bisverwendung_model.php b/application/models/codex/Bisverwendung_model.php index fa2cf84d0..20f942865 100644 --- a/application/models/codex/Bisverwendung_model.php +++ b/application/models/codex/Bisverwendung_model.php @@ -11,4 +11,34 @@ class Bisverwendung_model extends DB_Model $this->dbTable = 'bis.tbl_bisverwendung'; $this->pk = 'bisverwendung_id'; } + + /** + * Get latest (active) Verwendung of the user. + * @param string $uid + * @param bool $active If false, returns latest Verwendung no matter if actual or not (ignores ending/beginning date). + * @return array + */ + public function getLast($uid, $active = true) + { + $this->addLimit(1); + + if ($active) + { + $condition = ' + mitarbeiter_uid = '. $this->escape($uid). ' + AND ( beginn <= NOW() OR beginn IS NULL ) + AND ( ende >= NOW() OR ende IS NULL ) + ORDER BY ende DESC NULLS LAST, beginn DESC NULLS LAST + '; + } + else + { + $condition = ' + mitarbeiter_uid = '. $this->escape($uid). ' + ORDER BY ende DESC NULLS LAST, beginn DESC NULLS LAST + '; + } + + return $this->loadWhere($condition); + } } diff --git a/application/models/crm/Akte_model.php b/application/models/crm/Akte_model.php index b30e175c3..fe9db5330 100644 --- a/application/models/crm/Akte_model.php +++ b/application/models/crm/Akte_model.php @@ -186,8 +186,7 @@ class Akte_model extends DB_Model $dokumente = $this->loadWhere($where); - if($dokumente->error) - return error($dokumente->retval); + if($dokumente->error) return $dokumente; return success($dokumente->retval); } diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index 32673d10d..d5c52a3c3 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -214,7 +214,7 @@ class Prestudent_model extends DB_Model if ($lastStatus->error) { - return error($lastStatus->retval); + return $lastStatus; } if (count($lastStatus->retval) > 0) @@ -222,7 +222,7 @@ class Prestudent_model extends DB_Model //get Studiengangname from Studienplan and -ordnung $studienordnung = $this->PrestudentstatusModel->getStudienordnungFromPrestudent($prestudent_id); if ($studienordnung->error) - return error($studienordnung->retval); + return $studienordnung; if (count($studienordnung->retval) > 0) { @@ -239,7 +239,7 @@ class Prestudent_model extends DB_Model $language = $this->SpracheModel->load($lastStatus->retval[0]->sprache); if ($language->error) - return error($language->retval); + return $language; if (count($language->retval) > 0) $lastStatus->retval[0]->sprachedetails = $language->retval[0]; @@ -257,7 +257,7 @@ class Prestudent_model extends DB_Model ) ); if ($bewerbungstermin->error) - return error($bewerbungstermin->retval); + return $bewerbungstermin; if (count($bewerbungstermin->retval) > 0) { diff --git a/application/models/crm/Prestudentstatus_model.php b/application/models/crm/Prestudentstatus_model.php index 719ddf884..d579037e1 100644 --- a/application/models/crm/Prestudentstatus_model.php +++ b/application/models/crm/Prestudentstatus_model.php @@ -123,7 +123,7 @@ class Prestudentstatus_model extends DB_Model if ($lastStatus->error) { - return error($lastStatus->retval); + return $lastStatus; } if (count($lastStatus->retval) > 0) @@ -158,7 +158,7 @@ class Prestudentstatus_model extends DB_Model if ($lastStatus->error) { - return error($lastStatus->retval); + return $lastStatus; } if (count($lastStatus->retval) > 0) diff --git a/application/models/education/Lehreinheitmitarbeiter_model.php b/application/models/education/Lehreinheitmitarbeiter_model.php index ee11dcd01..dd5c7c858 100644 --- a/application/models/education/Lehreinheitmitarbeiter_model.php +++ b/application/models/education/Lehreinheitmitarbeiter_model.php @@ -11,4 +11,34 @@ class Lehreinheitmitarbeiter_model extends DB_Model $this->dbTable = 'lehre.tbl_lehreinheitmitarbeiter'; $this->pk = array('mitarbeiter_uid', 'lehreinheit_id'); } + + /** + * Checks if Lehrauftrag has a contract. + * @param $mitarbeiter_uid + * @param $lehreinheit_id + * @return array|bool|int Returns vertrag_id if contract exists. False if doesnt exist. On error array. + */ + public function hasVertrag($mitarbeiter_uid, $lehreinheit_id) + { + if(is_string($mitarbeiter_uid) && is_numeric($lehreinheit_id)) + { + $result = $this->load(array( + 'mitarbeiter_uid' => $mitarbeiter_uid, + 'lehreinheit_id' => $lehreinheit_id + )); + + if (hasData($result)) + { + return (is_null($result->retval[0]->vertrag_id)) ? false : intval($result->retval[0]->vertrag_id); + } + else + { + return error($result->msg, EXIT_ERROR); + } + } + else + { + return error ('Incorrect parameter type'); + } + } } diff --git a/application/models/education/Lehrveranstaltung_model.php b/application/models/education/Lehrveranstaltung_model.php index 1235769ac..4941ba9bd 100644 --- a/application/models/education/Lehrveranstaltung_model.php +++ b/application/models/education/Lehrveranstaltung_model.php @@ -65,7 +65,7 @@ class Lehrveranstaltung_model extends DB_Model $result = $this->StudiensemesterModel->getAusbildungssemesterByStudiensemesterAndStudiengang($studiensemester_kurzbz, $studiengang_kz_item); if (isError($result)) - return error($result->retval); + return error(getError($result)); foreach ($result->retval as $semester) { @@ -104,7 +104,7 @@ class Lehrveranstaltung_model extends DB_Model if (count($studiengang_kz_arr) > 0) $query .= " AND tbl_lehrveranstaltung.studiengang_kz IN (". implode(", ", $studiengang_kz_arr).")"; - + if (count($lehrveranstaltung_id_arr) > 0) { $query .= " AND tbl_lehrveranstaltung.lehrveranstaltung_id IN (". implode(', ', $lehrveranstaltung_id_arr).")"; @@ -144,7 +144,7 @@ class Lehrveranstaltung_model extends DB_Model WHERE vw_student_lehrveranstaltung.studiensemester_kurzbz=? AND - vw_student_lehrveranstaltung.lehrveranstaltung_id=? + vw_student_lehrveranstaltung.lehrveranstaltung_id=? ORDER BY nachname, vorname, person_id, tbl_bisio.bis DESC"; return $this->execQuery($query, array($studiensemester_kurzbz, $lehrveranstaltung_id)); diff --git a/application/models/education/Projektbetreuer_model.php b/application/models/education/Projektbetreuer_model.php index 32743be82..746e4c052 100644 --- a/application/models/education/Projektbetreuer_model.php +++ b/application/models/education/Projektbetreuer_model.php @@ -11,4 +11,34 @@ class Projektbetreuer_model extends DB_Model $this->dbTable = 'lehre.tbl_projektbetreuer'; $this->pk = array('betreuerart_kurzbz', 'projektarbeit_id', 'person_id'); } + + /** + * Checks if Projektauftrag has a contract. + * @param $person_id + * @param $projektarbeit_id + * @return array|bool|int Returns vertrag_id if contract exists. False if doesnt exist. On error array. + */ + public function hasVertrag($person_id, $projektarbeit_id) + { + if (is_numeric($person_id) && is_numeric($projektarbeit_id)) + { + $result = $this->load(array( + 'person_id' => $person_id, + 'projektarbeit_id' => $projektarbeit_id + )); + + if (hasData($result)) + { + return (is_null($result->retval[0]->vertrag_id)) ? false : intval($result->retval[0]->vertrag_id); + } + else + { + return error($result->msg, EXIT_ERROR); + } + } + else + { + return error ('Incorrect parameter type'); + } + } } diff --git a/application/models/organisation/Organisationseinheit_model.php b/application/models/organisation/Organisationseinheit_model.php index f9353c7b3..3efc8472a 100644 --- a/application/models/organisation/Organisationseinheit_model.php +++ b/application/models/organisation/Organisationseinheit_model.php @@ -165,4 +165,27 @@ class Organisationseinheit_model extends DB_Model return $this->execQuery(sprintf($query, $aktivstring, $aktivstring), array($oe_kurzbz)); } + /** + * Get one parent only. + * Easily retrieve department of a studiengang or fakultät of department etc. + * @param $oe_kurzbz + * @return array|null + */ + public function getParent($oe_kurzbz) + { + if (is_string($oe_kurzbz)) + { + $condition = ' + oe_kurzbz = ( + SELECT + oe_parent_kurzbz + FROM + public.tbl_organisationseinheit + WHERE + oe_kurzbz = \''. $oe_kurzbz. '\' + ) + '; + } + return $this->loadWhere($condition); + } } diff --git a/application/models/organisation/Studiensemester_model.php b/application/models/organisation/Studiensemester_model.php index 9878ab5be..9cdde7a52 100644 --- a/application/models/organisation/Studiensemester_model.php +++ b/application/models/organisation/Studiensemester_model.php @@ -13,6 +13,22 @@ class Studiensemester_model extends DB_Model $this->hasSequence = false; } + // Get next study semester + public function getNext() + { + $query = ' + SELECT * + FROM + public.tbl_studiensemester + WHERE + start > now() + ORDER BY start + LIMIT 1; + '; + + return $this->execQuery($query); + } + /** * getLastOrAktSemester */ diff --git a/application/models/person/Benutzer_model.php b/application/models/person/Benutzer_model.php index 46e5bdb98..dc5b95779 100644 --- a/application/models/person/Benutzer_model.php +++ b/application/models/person/Benutzer_model.php @@ -15,8 +15,7 @@ class Benutzer_model extends DB_Model public function getFromPersonId($person_id) { - /*$this->addSelect('uid, aktiv, alias');*/ - $this->loadWhere(array('person_id' => $person_id)); + return $this->loadWhere(array('person_id' => $person_id, 'aktiv' => true)); } } diff --git a/application/models/person/Benutzerfunktion_model.php b/application/models/person/Benutzerfunktion_model.php index 02a27e87a..ceb427687 100644 --- a/application/models/person/Benutzerfunktion_model.php +++ b/application/models/person/Benutzerfunktion_model.php @@ -48,7 +48,7 @@ class Benutzerfunktion_model extends DB_Model if (is_string($funktion_kurzbz)) { - $query .= " AND funktion_kurzbz = ".$funktion_kurzbz.")"; + $query .= " AND funktion_kurzbz = '".$funktion_kurzbz."'"; } elseif (is_array($funktion_kurzbz) && count($funktion_kurzbz) > 0) { @@ -104,4 +104,38 @@ class Benutzerfunktion_model extends DB_Model return $this->execQuery($query, $parametersArray); } + + /** + * Get active Studiengangsleitung(en) of the user by UID. + * @param $uid + */ + public function getSTGLByUID($uid) + { + $query = ' + SELECT + uid, + oe_kurzbz, + studiengang_kz, + typ, + tbl_studiengang.bezeichnung + FROM + public.tbl_benutzerfunktion + JOIN public.tbl_studiengang USING (oe_kurzbz) + WHERE + funktion_kurzbz = \'Leitung\' + AND (datum_von IS NULL OR datum_von <= now()) + AND (datum_bis IS NULL OR datum_bis >= now()) + AND uid = ? + ORDER BY + oe_kurzbz + '; + + $parameters_array = array(); + if (is_string($uid)) + { + $parameters_array[] = $uid; + } + + return $this->execQuery($query, $parameters_array); + } } diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index 1291427b6..9c1146632 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -158,8 +158,7 @@ class Person_model extends DB_Model $person = $this->load($person_id); - if($person->error) - return error($person->retval); + if($person->error) return $person; //return null if not found if(count($person->retval) < 1) @@ -170,14 +169,13 @@ class Person_model extends DB_Model $this->KontaktModel->addOrder('kontakttyp'); $where = $zustellung_only === true ? array('person_id' => $person_id, 'zustellung' => true) : array('person_id' => $person_id); $kontakte = $this->KontaktModel->loadWhere($where); - if($kontakte->error) - return error($kontakte->retval); + if($kontakte->error) return $kontakte; + $where = $zustellung_only === true ? array('person_id' => $person_id, 'zustelladresse' => true) : array('person_id' => $person_id); $this->AdresseModel->addSelect('public.tbl_adresse.*, bis.tbl_nation.kurztext AS nationkurztext'); $this->AdresseModel->addJoin('bis.tbl_nation', 'tbl_adresse.nation = tbl_nation.nation_code', 'LEFT'); $adressen = $this->AdresseModel->loadWhere($where); - if($adressen->error) - return error($adressen->retval); + if($adressen->error) return $adressen; $stammdaten = $person->retval[0]; $stammdaten->kontakte = $kontakte->retval; diff --git a/application/models/ressource/Mitarbeiter_model.php b/application/models/ressource/Mitarbeiter_model.php index 1e03a0ecd..ccaeacd0d 100644 --- a/application/models/ressource/Mitarbeiter_model.php +++ b/application/models/ressource/Mitarbeiter_model.php @@ -11,4 +11,33 @@ class Mitarbeiter_model extends DB_Model $this->dbTable = 'public.tbl_mitarbeiter'; $this->pk = 'mitarbeiter_uid'; } + + /** + * Checks if the user is a Mitarbeiter. + * @param string $uid + * @param boolean null $fixangestellt + * @return array + */ + public function isMitarbeiter($uid, $fixangestellt = null) + { + $this->addSelect('1'); + + if (is_bool($fixangestellt)) + { + $result = $this->loadWhere(array('mitarbeiter_uid' => $uid, 'fixangestellt' => $fixangestellt)); + } + else // default + { + $result = $this->loadWhere(array('mitarbeiter_uid' => $uid)); + } + + if(hasData($result)) + { + return success(true); + } + else + { + return success(false); + } + } } diff --git a/application/models/system/Benutzerrolle_model.php b/application/models/system/Benutzerrolle_model.php index 13ebf57b6..765ad9bd4 100644 --- a/application/models/system/Benutzerrolle_model.php +++ b/application/models/system/Benutzerrolle_model.php @@ -11,7 +11,7 @@ class Benutzerrolle_model extends DB_Model $this->dbTable = 'system.tbl_benutzerrolle'; $this->pk = 'benutzerberechtigung_id'; } - + /** * Checks if the given user is an admin */ @@ -19,9 +19,9 @@ class Benutzerrolle_model extends DB_Model { // Join with the table tbl_benutzer $this->addJoin('public.tbl_benutzer', 'uid'); - + $result = $this->loadWhere(array('person_id' => $person_id, 'rolle_kurzbz' => 'admin')); - + if (!isError($result)) { if (hasData($result)) @@ -33,7 +33,35 @@ class Benutzerrolle_model extends DB_Model $result = success(false); } } - + return $result; } -} \ No newline at end of file + + /** + * Get user who are authorized with berechtigung and, if given, authorized for the specific organisational unit. + * @param $berechtigung_kurzbz + * @param null $oe_kurzbz + * @return array + */ + public function getBenutzerByBerechtigung($berechtigung_kurzbz, $oe_kurzbz = null) + { + $params = array(); + $query = ' + SELECT + * + FROM + system.vw_berechtigung_nichtrekursiv + WHERE + berechtigung_kurzbz = ?'; + + $params[] = $berechtigung_kurzbz; + + if (!is_null($oe_kurzbz)) + { + $query .= ' AND oe_kurzbz = ?'; + $params[] = $oe_kurzbz; + } + + return $this->execQuery($query, $params); + } +} diff --git a/application/models/system/MessageToken_model.php b/application/models/system/MessageToken_model.php index 2398bf57a..cf1745ea6 100644 --- a/application/models/system/MessageToken_model.php +++ b/application/models/system/MessageToken_model.php @@ -37,17 +37,7 @@ class MessageToken_model extends DB_Model WHERE r.token = ? LIMIT 1'; - $result = $this->db->query($sql, array(MSG_STATUS_DELETED, $token)); - - // If no errors occurred - if ($result) - { - return success($result->result()); - } - else - { - return error($this->db->error()); - } + return $this->execQuery($sql, array(MSG_STATUS_DELETED, $token)); } /** @@ -74,25 +64,24 @@ class MessageToken_model extends DB_Model WHERE r.token = ? LIMIT 1'; - $msgs = $this->db->query($sql, array(MSG_STATUS_ARCHIVED, $token)); + $msgsResult = $this->execQuery($sql, array(MSG_STATUS_ARCHIVED, $token)); // If no errors occurred - if ($msgs) + if (isSuccess($msgsResult)) { - $msgs_result = $msgs->result(); // If at least a record is present - if (count($msgs_result) > 0) + if (hasData($msgsResult)) { - $msg = $msgs_result[0]; + $msg = getData($msgsResult)[0]; + $msgStatusResult = error(); - $msgStatusResult = false; // pessimistic expectation + $this->load->model('system/MsgStatus_model', 'MsgStatusModel'); // If the status of the message is unread if ($msg->status == MSG_STATUS_UNREAD) { // Insert the read status - $msgStatusResult = $this->db->insert( - 'public.tbl_msg_status', + $msgStatusResult = $this->MsgStatusModel->insert( array( 'message_id' => $msg->message_id, 'person_id' => $msg->receiver_id, @@ -108,31 +97,23 @@ class MessageToken_model extends DB_Model // If the status of the message is read else if ($msg->status == MSG_STATUS_READ) { - // Update updateamum to current date - $this->db->set('updateamum', 'NOW()'); - - $this->db->where('message_id', $msg->message_id); - $this->db->where('person_id', $msg->receiver_id); - $this->db->where('status', MSG_STATUS_READ); - - $msgStatusResult = $this->db->update('public.tbl_msg_status'); + $msgStatusResult = $this->MsgStatusModel->update( + array( + 'message_id' => $msg->message_id, + 'person_id' => $msg->receiver_id, + 'status' => MSG_STATUS_READ + ), + array('updateamum' => 'NOW()') + ); } - // If some of the previous DB manipulation (update or insert) has failed - if (!$msgStatusResult) - { - return error($this->db->error()); - } + return $msgStatusResult; } - - return success($msgs_result); } else { - return error($this->db->error()); + return $msgsResult; } - - return success($result->result()); } /** @@ -152,17 +133,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()); - } + return $this->execQuery($sql, array($person_id)); } /** @@ -180,17 +151,7 @@ class MessageToken_model extends DB_Model 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(sprintf($sql, is_array($person_id) ? 'IN' : '='), array($person_id)); } /** @@ -200,35 +161,12 @@ class MessageToken_model extends DB_Model { $sql = 'SELECT m.mitarbeiter_uid FROM public.tbl_person p - LEFT JOIN public.tbl_benutzer b USING(person_id) - LEFT JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) + JOIN public.tbl_benutzer b USING(person_id) + JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) 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)); } /** @@ -254,28 +192,6 @@ class MessageToken_model extends DB_Model LIMIT 1 '; - $result = $this->db->query($sql, array($oe_kurzbz)); - if ($result) // If no errors occurred - { - $result_arr = $result->result(); - // If data are present - if (is_array($result_arr) - && count($result_arr) > 0 - && is_object($result_arr[0]) - && isset($result_arr[0]->oe_kurzbz)) - { - return success($result_arr[0]->oe_kurzbz); - } - else - { - return error(); - } - } - else - { - return error($this->db->error()); - } - - return $result; + return $this->execQuery($sql, array($oe_kurzbz)); } } diff --git a/application/models/system/PersonLock_model.php b/application/models/system/PersonLock_model.php index 1d106b789..f0aadd327 100644 --- a/application/models/system/PersonLock_model.php +++ b/application/models/system/PersonLock_model.php @@ -29,8 +29,7 @@ class PersonLock_model extends DB_Model $result = $this->loadWhere($lockdata); - if ($result->error) - return error($result->retval); + if ($result->error) return $result; if (count($result->retval) > 0) return success($result->retval); @@ -49,8 +48,7 @@ class PersonLock_model extends DB_Model { $locked = $this->checkIfLocked($person_id, $app); - if ($locked->error) - return error($locked->retval); + if ($locked->error) return $locked; //insert only if not already locked if ($locked->retval === null) @@ -77,8 +75,7 @@ class PersonLock_model extends DB_Model foreach ($locks->retval as $lock) { $result = $this->delete($lock->lock_id); - if ($result->error) - return error($result->retval); + if ($result->error) return $result; $deleted[] = $lock; } diff --git a/application/models/system/Variablenname_model.php b/application/models/system/Variablenname_model.php index ada1d330c..7b2a2cf88 100644 --- a/application/models/system/Variablenname_model.php +++ b/application/models/system/Variablenname_model.php @@ -27,7 +27,7 @@ class Variablenname_model extends DB_Model /** * Gets defaults for user variables. * If no default value present in table, SQL can be executed for retrieving the value. - * @param null $names optionally get only defaults for certain variables + * @param $names optionally get only defaults for certain variables * @return array */ public function getDefaults($names = null) @@ -36,13 +36,13 @@ class Variablenname_model extends DB_Model $qry = "SELECT name, defaultwert FROM public.tbl_variablenname"; - if (isset($names) && is_array($names)) + if (!isEmptyArray($names)) { - $qry .= " WHERE name IN ('".implode(',', $names)."')"; + $qry .= " WHERE name IN ?"; } $qry .= ";"; - $defaultsres = $this->execQuery($qry); + $defaultsres = $this->execQuery($qry, array('name' => $names)); if (hasData($defaultsres)) { diff --git a/application/views/lehre/lehrauftrag/Dashboard.php b/application/views/lehre/lehrauftrag/Dashboard.php new file mode 100644 index 000000000..a14cefa7a --- /dev/null +++ b/application/views/lehre/lehrauftrag/Dashboard.php @@ -0,0 +1,38 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Lehrauftrag bestellen', + 'jquery' => true, + 'jqueryui' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'navigationwidget' => true, + 'addons' => true, + ) +); +?> + + + widgetlib->widget('NavigationWidget'); ?> +
+
+ +
+
+ +
+
+ +
+ +
+
+ + +load->view('templates/FHC-Footer'); ?> diff --git a/application/views/lehre/lehrauftrag/LehrendeUebersicht.php b/application/views/lehre/lehrauftrag/LehrendeUebersicht.php new file mode 100644 index 000000000..1ad295392 --- /dev/null +++ b/application/views/lehre/lehrauftrag/LehrendeUebersicht.php @@ -0,0 +1,39 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Lehrauftrag bestellen', + 'jquery' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'ajaxlib' => true, + 'navigationwidget' => true, + ) +); +?> + + +widgetlib->widget('NavigationWidget'); ?> +
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+ + +load->view('templates/FHC-Footer'); ?> diff --git a/application/views/lehre/lehrauftrag/acceptLehrauftrag.php b/application/views/lehre/lehrauftrag/acceptLehrauftrag.php new file mode 100644 index 000000000..14ebacecb --- /dev/null +++ b/application/views/lehre/lehrauftrag/acceptLehrauftrag.php @@ -0,0 +1,204 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Lehrauftrag annehmen', + 'jquery' => true, + 'jqueryui' => true, + 'jquerycheckboxes' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => false, + 'tabulator' => true, + 'momentjs' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'tablewidget' => true, + 'phrases' => array( + 'global' => array('lehrauftraegeAnnehmen'), + ), + 'customJSs' => array( + 'public/js/bootstrapper.js', + 'public/js/lehre/lehrauftrag/acceptLehrauftrag.js') + ) +); + +?> + + +
+
+ + +
+ +
+ + +
+
+
+

Wie nehme ich Lehraufträge an?

+
+ Sobald Ihnen ein oder mehrere Lehraufträge erteilt wurden, können Sie diese annehmen. +
    +
  1. Klicken Sie unten auf das Status-Icon 'Nur erteilte anzeigen' oder 'Alle anzeigen'
  2. +
  3. Wählen Sie die Lehraufträge, die Sie annehmen möchten, selbst oder alle über den Button 'Alle auswählen'.
  4. +
  5. Geben Sie Ihr CIS-Passwort ein und klicken auf Lehrauftrag annehmen.
  6. +
+
+
+ +

Warum kann ich manche Lehraufträge nicht auswählen?

+
+ Nur Lehraufträge mit dem Status 'erteilt' können gewählt werden.
+ Angenommene Lehraufträge oder Lehraufträge in Bearbeitung werden nur zu Ihrer Information angezeigt. +
+
+ +

Filter

+
+
+ + + + + + + + + + + + + +
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
+
+
+
+ +

Auswahl

+
+
    +
  • Einzeln auswählen: Strg + Klick auf einzelne Zeile(n)
  • +
  • Bereich auswählen: Shift + Klick auf Anfangs- und Endzeile
  • +
  • Alle auswählen: Button 'Alle auswählen'
  • +
+
+
+ +

Ansicht

+
+ Spaltenbreite verändern +

+ Um die Spaltenbreite zu verändern, fährt man im Spaltenkopf langsam mit dem Mauszeiger auf + den rechten Rand der entprechenden Spalte.
+ Sobald sich der Mauszeiger in einen Doppelpfeil verwandelt, wird die Maustaste geklickt und + mit gedrückter Maustaste die Spalte nach rechts erweitert oder nach links verkleinert. +

+
+
+
+
+
+ + +
+
+
+
+ widgetlib->widget( + 'Studiensemester_widget', + array( + DropdownWidget::SELECTED_ELEMENT => $studiensemester_selected + ), + array( + 'name' => 'studiensemester', + 'id' => 'studiensemester' + ) + ); + ?> +
+ +
+
+
+ + +
+
+ load->view('lehre/lehrauftrag/acceptLehrauftragData.php'); ?> +
+
+
+ + +
+
+ +
+
+
+ + + + +
+
+
+
+
+ + +
+
+

+ p->t('global', 'stornierteLehrauftraege')); ?>: + + + + + +

+
+
+ load->view('lehre/lehrauftrag/cancelledLehrauftragData.php'); ?> +
+
+
+
+
+
+
+
+ + +load->view('templates/FHC-Footer'); ?> diff --git a/application/views/lehre/lehrauftrag/acceptLehrauftragData.php b/application/views/lehre/lehrauftrag/acceptLehrauftragData.php new file mode 100644 index 000000000..704ce5861 --- /dev/null +++ b/application/views/lehre/lehrauftrag/acceptLehrauftragData.php @@ -0,0 +1,398 @@ + $query, + 'tableUniqueId' => 'acceptLehrauftrag', + 'requiredPermissions' => 'lehre/lehrauftrag_akzeptieren', + 'datasetRepresentation' => 'tabulator', + 'columnsAliases' => array( // TODO: use phrasen + 'Status', // alias for row_index, because row_index is formatted to display the status icons + 'LV-Teil', + 'LV-ID', + 'PA-ID', + 'Studiensemester', + 'Studiengang-KZ', + 'Studiengang', + 'Semester', + 'OrgForm', + 'Person-ID', + 'Typ', + 'LV- / Projektbezeichnung', + 'Organisationseinheit', + 'Gruppe', + 'Stunden', + 'Betrag', + 'Vertrag-ID', + 'Vertrag-Stunden', + 'Vertrag-Betrag', + 'UID', + 'Bestellt', + 'Erteilt', + 'Angenommen', + 'Bestellt von', + 'Erteilt von', + 'Angenommen von' + ), + 'datasetRepOptions' => '{ + height: 550, + layout: "fitColumns", // fit columns to width of table + responsiveLayout: "hide", // hide columns that dont fit on the table + movableColumns: true, // allows changing column + placeholder: func_placeholder(), + headerFilterPlaceholder: " ", + index: "row_index", // assign specific column as unique id (important for row indexing) + selectable: true, // allow row selection + selectableRangeMode: "click", // allow range selection using shift end click on end of range + selectablePersistence:false, // deselect previously selected rows when table is filtered, sorted or paginated + selectableCheck: function(row){ + return func_selectableCheck(row); + }, + footerElement: func_footerElement(), + rowUpdated:function(row){ + func_rowUpdated(row); + }, + rowSelectionChanged:function(data, rows){ + func_rowSelectionChanged(data, rows); + }, + rowFormatter:function(row){ + func_rowFormatter(row); + }, + tableBuilt: function(){ + func_tableBuilt(this); + }, + renderComplete:function(){ + func_renderComplete(this); + }, + renderStarted:function(){ + func_renderStarted(this); + } + }', // tabulator properties + 'datasetRepFieldsDefs' => '{ + row_index: {visible:false}, // necessary for row indexing + lehreinheit_id: {headerFilter:"input", bottomCalc:"count", bottomCalcFormatter:function(cell){return "Anzahl: " + cell.getValue();}, width: "7%"}, + lehrveranstaltung_id: {headerFilter:"input", width: "5%"}, + projektarbeit_id: {visible: false}, + studiensemester_kurzbz: {visible: false}, + studiengang_kz: {visible: false}, + stg_typ_kurzbz: {headerFilter:"input", width: "5%"}, + semester: {headerFilter:"input"}, + orgform_kurzbz: {headerFilter:"input"}, + person_id: {visible: false}, + typ: {headerFilter:"input", width: "7%"}, + auftrag: {headerFilter:"input", width: "15%"}, + lv_oe_kurzbz: {headerFilter:"input", width: "8%"}, + gruppe: {headerFilter:"input", width: "5%"}, + stunden: {align:"right", formatter: form_formatNulltoStringNumber, formatterParams:{precision:1}, + headerFilter:"input", headerFilterFunc: hf_filterStringnumberWithOperator, + bottomCalc:"sum", bottomCalcParams:{precision:1}, width: "5%"}, + betrag: {align:"right", width: "6%", formatter: form_formatNulltoStringNumber, + headerFilter:"input", headerFilterFunc: hf_filterStringnumberWithOperator, + bottomCalc:"sum", bottomCalcParams:{precision:2}, bottomCalcFormatter:"money", bottomCalcFormatterParams:{decimal: ",", thousand: ".", symbol:"€"}, + width: "8%"}, + vertrag_id: {visible: false}, + vertrag_stunden: {visible: false}, + vertrag_betrag: {visible: false}, + mitarbeiter_uid: {visible: false}, + bestellt: {align:"center", headerFilter:"input", mutator: mut_formatStringDate, tooltip: bestellt_tooltip, width: "8%"}, + erteilt: {align:"center", headerFilter:"input", mutator: mut_formatStringDate, tooltip: erteilt_tooltip, width: "8%"}, + akzeptiert: {align:"center", headerFilter:"input", mutator: mut_formatStringDate, tooltip: akzeptiert_tooltip, width: "8%"}, + bestellt_von: {visible: false}, + erteilt_von: {visible: false}, + akzeptiert_von: {visible: false} + }', // col properties +); + +echo $this->widgetlib->widget('TableWidget', $filterWidgetArray); + +?> diff --git a/application/views/lehre/lehrauftrag/approveLehrauftrag.php b/application/views/lehre/lehrauftrag/approveLehrauftrag.php new file mode 100644 index 000000000..f36ae7dc7 --- /dev/null +++ b/application/views/lehre/lehrauftrag/approveLehrauftrag.php @@ -0,0 +1,240 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Lehrauftrag erteilen', + 'jquery' => true, + 'jqueryui' => true, + 'jquerycheckboxes' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'tabulator' => true, + 'momentjs' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'tablewidget' => true, + 'navigationwidget' => true, + 'phrases' => array( + 'global' => array('lehrauftraegeErteilen'), + ), + 'customJSs' => array( + 'public/js/bootstrapper.js', + 'public/js/lehre/lehrauftrag/approveLehrauftrag.js' + ) + ) +); + +?> + + + widgetlib->widget('NavigationWidget'); ?> +
+
+ + +
+ +
+ + +
+
+
+ +

Lehrauftrag Standard-Bestellprozess

+
+ + + + + + + + + + + + + + + +
BESTELLEN
(Studiengangsleitung)
ERTEILEN
(Department-/Kompetenzfeldleitung)
ANNEHMEN
(LektorIn)
+
+
+ +

Lehraufträge erteilen

+
+ Sobald Lehraufträge bestellt wurden, können Sie diese hier erteilen.
+ Erteilte Lehraufträge können von den Lehrenden angenommen werden.
+
    +
  1. Klicken Sie unten auf das Status-Icon 'Nur bestellte anzeigen' oder 'Alle anzeigen'
  2. +
  3. Wählen Sie die zu erteilenden Lehraufträge selbst oder alle über den Button 'Alle auswählen'.
  4. +
  5. Klicken Sie auf Lehrauftrag erteilen.
  6. +
+
+
+ +

Geänderte Lehraufträge

+
+ Im FAS können Änderungen an Stunden/Stundensatz eines Lehrauftrags durchgeführt werden, solange dieser nicht vom Lehrenden angenommen wurde.
+ Wenn Änderungen an bereits bestellten oder erteilten Lehraufträgen vorgenommen wurden, müssen diese vom Studiengang erneut bestellt werden.
+ Bei bereits erteilten Lehraufträgen wird zusätzlich der Status 'erteilt' zurückgesetzt. +
+
+ +

Warum kann ich manche Lehraufträge nicht auswählen?

+
+ Nur Lehraufträge mit dem Status 'bestellt' können gewählt werden.
+ Neue, Bestellte, Akzeptierte oder geänderte Lehraufträge werden nur zu Ihrer Information angezeigt und sind daher NICHT wählbar. +
+
+ +

Filter

+
+ + + + + + + + + + + + + + + + + + + + +
Alle
Alle Lehraufträge mit jedem Status, auch geänderte und Dummy-Aufträge
Neu
Nur Lehraufträge, die im FAS über die Zuteilung eines Lehrenden zu einer Lehreinheit/einem Projekt angelegt und noch nicht bestellt worden sind
Bestellt
Nur bestellte UND geänderte bestellte Lehraufträge
Erteilt
Nur erteilte UND geänderte erteilte Lehraufträge
Angenommen
Nur vom Lehrenden angenommene Lehraufträge
Geändert
Nur Lehraufträge, die geändert wurden, nachdem sie bereits bestellt oder erteilt worden sind
Dummies
Nur Lehraufträge, die mit einem Dummylektor angelegt sind
+
+
+ +

Auswahl

+
+
    +
  • Einzeln auswählen: Strg + Klick auf einzelne Zeile(n)
  • +
  • Bereich auswählen: Shift + Klick auf Anfangs- und Endzeile
  • +
  • Alle auswählen: Button 'Alle auswählen'
  • +
+
+
+ +

Ansicht

+
+ Spaltenbreite verändern +

+ Um die Spaltenbreite zu verändern, fährt man im Spaltenkopf langsam mit dem Mauszeiger auf + den rechten Rand der entprechenden Spalte.
+ Sobald sich der Mauszeiger in einen Doppelpfeil verwandelt, wird die Maustaste geklickt und + mit gedrückter Maustaste die Spalte nach rechts erweitert oder nach links verkleinert. +

+
+
+ +
+
+
+ + +
+
+
+
+ widgetlib->widget( + 'Studiensemester_widget', + array( + DropdownWidget::SELECTED_ELEMENT => $studiensemester_selected + ), + array( + 'name' => 'studiensemester', + 'id' => 'studiensemester' + ) + ); + ?> +
+
+ widgetlib->widget( + 'Organisationseinheit_widget', + array( + DropdownWidget::SELECTED_ELEMENT => $organisationseinheit_selected, + 'organisationseinheit' => $organisationseinheit + ), + array( + 'name' => 'organisationseinheit', + 'id' => 'organisationseinheit' + ) + ); + ?> +
+
+ widgetlib->widget( + 'Ausbildungssemester_widget', + array( + DropdownWidget::SELECTED_ELEMENT => $ausbildungssemester_selected, + 'number_semester' => 6 + ), + array( + 'name' => 'ausbildungssemester', + 'id' => 'ausbildungssemester' + ) + ); + ?> +
+ +
+
+
+ + +
+
+ load->view('lehre/lehrauftrag/approveLehrauftragData.php'); ?> +
+
+
+ + +
+
+ + +
+
+ +
+
+
+ + +load->view('templates/FHC-Footer'); ?> diff --git a/application/views/lehre/lehrauftrag/approveLehrauftragData.php b/application/views/lehre/lehrauftrag/approveLehrauftragData.php new file mode 100644 index 000000000..4db115626 --- /dev/null +++ b/application/views/lehre/lehrauftrag/approveLehrauftragData.php @@ -0,0 +1,418 @@ + $query, + 'tableUniqueId' => 'approveLehrauftrag', + 'requiredPermissions' => 'lehre/lehrauftrag_erteilen', + 'datasetRepresentation' => 'tabulator', + 'columnsAliases' => array( // TODO: use phrasen + 'Status', // alias for row_index, because row_index is formatted to display the status icons + 'Personalnummer', + 'LV-Teil', + 'LV-ID', + 'LV', + 'PA-ID', + 'Studiensemester', + 'Studiengang-KZ', + 'Studiengang', + 'Semester', + 'OrgForm', + 'Person-ID', + 'Typ', + 'LV- / Projektbezeichnung', + 'Organisationseinheit', + 'Gruppe', + 'Lektor', + 'Stunden', + 'Betrag', + 'Vertrag-ID', + 'Vertrag-Stunden', + 'Vertrag-Betrag', + 'UID', + 'Bestellt', + 'Erteilt', + 'Angenommen', + 'Bestellt von', + 'Erteilt von', + 'Angenommen von' + ), + 'datasetRepOptions' => '{ + height: 700, + layout: "fitColumns", // fit columns to width of table + responsiveLayout: "hide", // hide columns that dont fit on the table + movableColumns: true, // allows changing column + placeholder: func_placeholder(), + headerFilterPlaceholder: " ", + groupBy:"lehrveranstaltung_id", + groupToggleElement:"header", //toggle group on click anywhere in the group header + groupHeader: function(value, count, data, group){ + return func_groupHeader(data); + }, + columnCalcs:"both", // show column calculations at top and bottom of table and in groups + index: "row_index", // assign specific column as unique id (important for row indexing) + selectable: true, // allow row selection + selectableRangeMode: "click", // allow range selection using shift end click on end of range + selectablePersistence:false, // deselect previously selected rows when table is filtered, sorted or paginated + selectableCheck: function(row){ + return func_selectableCheck(row); + }, + initialFilter: func_initialFilter(), + footerElement: func_footerElement(), + rowUpdated:function(row){ + func_rowUpdated(row); + }, + rowSelectionChanged:function(data, rows){ + func_rowSelectionChanged(data, rows); + }, + rowFormatter:function(row) + { + func_rowFormatter(row); + }, + renderStarted:function(){ + func_renderStarted(this); + }, + tableBuilt: function(){ + func_tableBuilt(this); + } + }', // tabulator properties + 'datasetRepFieldsDefs' => '{ + // column status is built dynamically in funcTableBuilt(), + row_index: {visible:false}, // necessary for row indexing + personalnummer: {visible: false}, + lehreinheit_id: {headerFilter:"input", bottomCalc:"count", width: "7%", + bottomCalcFormatter:function(cell){return "Anzahl: " + cell.getValue();},}, + lehrveranstaltung_id: {headerFilter:"input"}, + lv_bezeichnung: {visible: false}, + projektarbeit_id: {visible: false}, + studiensemester_kurzbz: {headerFilter:"input"}, + studiengang_kz: {visible: false}, + stg_typ_kurzbz: {headerFilter:"input", width: "5%"}, + semester: {headerFilter:"input"}, + orgform_kurzbz: {headerFilter:"input"}, + person_id: {visible: false}, + typ: {headerFilter:"input"}, + auftrag: {headerFilter:"input", width:"20%"}, + lv_oe_kurzbz: {headerFilter:"input"}, + gruppe: {headerFilter:"input"}, + lektor: {headerFilter:"input", widthGrow: 3}, + stunden: {align:"right", formatter: form_formatNulltoStringNumber, formatterParams:{precision:1}, + headerFilter:"input", headerFilterFunc: hf_filterStringnumberWithOperator, + bottomCalc:"sum", bottomCalcParams:{precision:1}}, + betrag: {align:"right", width: "8%", formatter: form_formatNulltoStringNumber, + headerFilter:"input", headerFilterFunc: hf_filterStringnumberWithOperator, + bottomCalc:"sum", bottomCalcParams:{precision:2}, bottomCalcFormatter:"money", bottomCalcFormatterParams:{decimal: ",", thousand: ".", symbol:"€"}}, + vertrag_id: {visible: false}, + vertrag_stunden: {visible: false}, + vertrag_betrag: {visible: false}, + mitarbeiter_uid: {visible: false}, + bestellt: {align:"center", headerFilter:"input", mutator: mut_formatStringDate, tooltip: bestellt_tooltip, width: "8%"}, + erteilt: {align:"center", headerFilter:"input", mutator: mut_formatStringDate, tooltip: erteilt_tooltip, width: "8%"}, + akzeptiert: {align:"center", headerFilter:"input", mutator: mut_formatStringDate, tooltip: akzeptiert_tooltip, width: "8%"}, + bestellt_von: {visible: false}, + erteilt_von: {visible: false}, + akzeptiert_von: {visible: false}, + }', // col properties +); + +echo $this->widgetlib->widget('TableWidget', $filterWidgetArray); + +?> diff --git a/application/views/lehre/lehrauftrag/cancelledLehrauftragData.php b/application/views/lehre/lehrauftrag/cancelledLehrauftragData.php new file mode 100644 index 000000000..d5af1b081 --- /dev/null +++ b/application/views/lehre/lehrauftrag/cancelledLehrauftragData.php @@ -0,0 +1,104 @@ + $query, + 'tableUniqueId' => 'cancelledLehrauftrag', + 'requiredPermissions' => 'lehre/lehrauftrag_akzeptieren', + 'datasetRepresentation' => 'tabulator', + 'columnsAliases' => array( // TODO: use phrasen + 'Status', + 'Studiensemester', + 'Typ', + 'LV- / Projektbezeichnung', + 'Stunden', + 'Betrag', + 'Storniert am' + ), + 'datasetRepOptions' => '{ + layout: "fitColumns", // fit columns to width of table + responsiveLayout: "hide", // hide columns that dont fit on the table + movableColumns: true, // allows changing column + placeholder: func_placeholder(), + rowFormatter:function(row){ + func_rowFormatter(row); + }, + selectableCheck: function(row){ + return func_selectableCheck(row); + }, + renderComplete:function(){ + func_renderComplete(this); + }, + tableBuilt: function(){ + func_tableBuilt(this); + } + }', // tabulator properties + 'datasetRepFieldsDefs' => '{ + vertrag_id: {visible: false}, + vertragsstunden_studiensemester_kurzbz: {visible: false}, + vertragstyp_kurzbz: {widthGrow: 2}, + bezeichnung: {widthGrow: 2}, + vertragsstunden: { + align:"right", formatter: form_formatNulltoStringNumber, formatterParams:{precision:1}, + bottomCalc:"sum", bottomCalcParams:{precision:1} + }, + betrag: { + align:"right", formatter: form_formatNulltoStringNumber, + bottomCalc:"sum", bottomCalcParams:{precision:2}, bottomCalcFormatter:"money", bottomCalcFormatterParams:{decimal: ",", thousand: ".", symbol:"€"} + }, + storniert: {align:"center", mutator: mut_formatStringDate, tooltip: storniert_tooltip}, + storniert_von: {visible: false}, + letzterStatus_vorStorniert: {visible: false} + }', // col properties +); + +echo $this->widgetlib->widget('TableWidget', $tableWidgetArray); + +?> diff --git a/application/views/lehre/lehrauftrag/orderLehrauftrag.php b/application/views/lehre/lehrauftrag/orderLehrauftrag.php new file mode 100644 index 000000000..b04aa7985 --- /dev/null +++ b/application/views/lehre/lehrauftrag/orderLehrauftrag.php @@ -0,0 +1,242 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Lehrauftrag bestellen', + 'jquery' => true, + 'jqueryui' => true, + 'jquerycheckboxes' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'tabulator' => true, + 'momentjs' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'tablewidget' => true, + 'navigationwidget' => true, + 'phrases' => array( + 'global' => array('lehrauftraegeBestellen'), + ), + 'customJSs' => array( + 'public/js/bootstrapper.js', + 'public/js/lehre/lehrauftrag/orderLehrauftrag.js' + ) + ) +); +?> + + + widgetlib->widget('NavigationWidget'); ?> +
+
+ + +
+ +
+ + +
+
+
+ +

Lehrauftrag Standard-Bestellprozess

+
+ + + + + + + + + + + + + + + +
BESTELLEN
(Studiengangsleitung)
ERTEILEN
(Department-/Kompetenzfeldleitung)
ANNEHMEN
(LektorIn)
+
+
+ +

Lehraufträge bestellen

+
+ Sobald im FAS ein Lehrauftrag/eine Projektbetreuung angelegt wurde, können Sie diese hier bestellen.
+ Bestellte Lehraufträge sind zur Erteilung freigegeben.
+
    +
  1. Klicken Sie unten auf das Status-Icon 'Nur neue anzeigen', 'Nur geänderte anzeigen' oder 'Alle anzeigen'
  2. +
  3. Wählen Sie die zu bestellenden Lehraufträge selbst oder über den Button 'Alle auswählen'.
  4. +
  5. Klicken Sie auf Lehrauftrag bestellen.
  6. +
+ Für jeden bestellten Lehrauftrag legt das System einen Vertrag an. +
+
+ +

Geänderte Lehraufträge

+
+ Im FAS können Änderungen an Stunden/Stundensatz eines Lehrauftrags durchgeführt werden, solange dieser nicht vom Lehrenden angenommen wurde.
+ Diese müssen dann erneut bestellt werden.

+ Wenn Änderungen an bereits bestellten oder erteilten Lehraufträgen vorgenommen wurden, werden diese in einem tooltip angezeigt.
+ Fahren Sie dazu mit der Maus über dem Status-Icon am Beginn der Zeile.
+
+
+ +

Warum kann ich manche Lehraufträge nicht auswählen?

+
+ Nur Lehraufträge mit dem Status 'neu' und 'geändert' können bestellt werden.
+ Erteilte oder akzeptierte Lehraufträge werden nur zu Ihrer Information angezeigt und sind daher NICHT wählbar. +
+
+ +

Filter

+
+ + + + + + + + + + + + + + + + + + + + +
Alle
Alle Lehraufträge mit jedem Status, auch geänderte und Dummy-Aufträge
Neu
Nur Lehraufträge, die im FAS über die Zuteilung eines Lehrenden zu einer Lehreinheit/einem Projekt angelegt und noch nicht bestellt worden sind
Bestellt
Nur bestellte UND geänderte bestellte Lehraufträge
Erteilt
Nur erteilte UND geänderte erteilte Lehraufträge
Angenommen
Nur vom Lehrenden angenommene Lehraufträge
Geändert
Nur Lehraufträge, die geändert wurden, nachdem sie bereits bestellt oder erteilt worden sind
Dummies
Nur Lehraufträge, die mit einem Dummylektor angelegt sind
+
+
+ +

Auswahl

+
+
    +
  • Einzeln auswählen: Strg + Klick auf einzelne Zeile(n)
  • +
  • Bereich auswählen: Shift + Klick auf Anfangs- und Endzeile
  • +
  • Alle auswählen: Button 'Alle auswählen'
  • +
+
+
+ +

Ansicht

+
+ Spaltenbreite verändern +

+ Um die Spaltenbreite zu verändern, fährt man im Spaltenkopf langsam mit dem Mauszeiger auf + den rechten Rand der entprechenden Spalte.
+ Sobald sich der Mauszeiger in einen Doppelpfeil verwandelt, wird die Maustaste geklickt und + mit gedrückter Maustaste die Spalte nach rechts erweitert oder nach links verkleinert. +

+
+
+ +
+
+
+ + +
+
+
+
+ widgetlib->widget( + 'Studiensemester_widget', + array( + DropdownWidget::SELECTED_ELEMENT => $studiensemester_selected + ), + array( + 'name' => 'studiensemester', + 'id' => 'studiensemester' + ) + ); + ?> +
+
+ widgetlib->widget( + 'Studiengang_widget', + array( + DropdownWidget::SELECTED_ELEMENT => $studiengang_selected, + 'studiengang' => $studiengang + ), + array( + 'name' => 'studiengang', + 'id' => 'studiengang' + ) + ); + ?> +
+
+ widgetlib->widget( + 'Ausbildungssemester_widget', + array( + DropdownWidget::SELECTED_ELEMENT => $ausbildungssemester_selected, + 'number_semester' => 6 + ), + array( + 'name' => 'ausbildungssemester', + 'id' => 'ausbildungssemester' + ) + ); + ?> +
+ +
+
+
+ + +
+
+ load->view('lehre/lehrauftrag/orderLehrauftragData.php'); ?> +
+
+
+ + +
+
+ + +
+
+ +
+
+
+ + +load->view('templates/FHC-Footer'); ?> diff --git a/application/views/lehre/lehrauftrag/orderLehrauftragData.php b/application/views/lehre/lehrauftrag/orderLehrauftragData.php new file mode 100644 index 000000000..66468e541 --- /dev/null +++ b/application/views/lehre/lehrauftrag/orderLehrauftragData.php @@ -0,0 +1,456 @@ + $query, + 'tableUniqueId' => 'orderLehrauftrag', + 'requiredPermissions' => 'lehre/lehrauftrag_bestellen', + 'datasetRepresentation' => 'tabulator', + 'columnsAliases' => array( // TODO: use phrasen + 'Status', // alias for row_index, because row_index is formatted to display the status icons + 'Personalnummer', + 'LV-Teil', + 'LV-ID', + 'LV', + 'PA-ID', + 'Studiensemester', + 'Studiengang-KZ', + 'Studiengang', + 'Semester', + 'Studienplan', + 'OrgForm', + 'Person-ID', + 'Typ', + 'LV- / Projektbezeichnung', + 'Organisationseinheit', + 'Gruppe', + 'Lektor', + 'Stunden', + 'Stundensatz', + 'Betrag', + 'Vertrag-ID', + 'Vertrag-Stunden', + 'Vertrag-Betrag', + 'UID', + 'Bestellt', + 'Erteilt', + 'Angenommen', + 'Bestellt von', + 'Erteilt von', + 'Angenommen von' + ), + 'datasetRepOptions' => '{ + height: 700, + layout:"fitColumns", // fit columns to width of table + responsiveLayout:"hide", // hide columns that dont fit on the table + movableColumns: true, // allows changing column + placeholder: func_placeholder(), + headerFilterPlaceholder: " ", + groupBy:"lehrveranstaltung_id", + groupToggleElement:"header", //toggle group on click anywhere in the group header + groupHeader: function(value, count, data, group){ + return func_groupHeader(data); + }, + footerElement: func_footerElement(), + columnCalcs:"both", // show column calculations at top and bottom of table and in groups + index: "row_index", // assign specific column as unique id (important for row indexing) + selectable: true, // allows row selection + selectableRangeMode: "click", // allows range selection using shift end click on end of range + selectablePersistence:false, // deselect previously selected rows when table is filtered, sorted or paginated + selectableCheck: function(row){ + return func_selectableCheck(row); + }, + rowUpdated:function(row){ + func_rowUpdated(row); + }, + rowSelectionChanged:function(data, rows){ + func_rowSelectionChanged(data, rows); + }, + rowFormatter:function(row){ + func_rowFormatter(row); + }, + renderStarted:function(){ + func_renderStarted(this); + }, + tableBuilt: function(){ + func_tableBuilt(this); + }, + dataLoaded: function(data){ + func_dataLoaded(data, this); + }, + }', // tabulator properties + 'datasetRepFieldsDefs' => '{ + // column status is built dynamically in funcTableBuilt() + row_index: {visible: false}, + personalnummer: {visible: false}, + lehreinheit_id: {headerFilter:"input", bottomCalc:"count", width: "7%", + bottomCalcFormatter:function(cell){return "Anzahl: " + cell.getValue();}}, + lehrveranstaltung_id: {headerFilter:"input"}, + lv_bezeichnung: {visible: false}, + projektarbeit_id: {visible: false}, + studiensemester_kurzbz: {headerFilter:"input"}, + studiengang_kz: {visible: false}, + stg_typ_kurzbz: {headerFilter:"input", width: "5%"}, + semester: {headerFilter:"input"}, + studienplan_bezeichnung: {headerFilter:"input", width: "7%"}, + orgform_kurzbz: {headerFilter:"input"}, + person_id: {visible: false}, + typ: {headerFilter:"input"}, + auftrag: {headerFilter:"input", width:"15%"}, + lv_oe_kurzbz: {headerFilter:"input"}, + gruppe: {headerFilter:"input"}, + lektor: {headerFilter:"input", widthGrow: 3}, + stunden: {align:"right", formatter: form_formatNulltoStringNumber, formatterParams:{precision:1}, + headerFilter:"input", headerFilterFunc: hf_filterStringnumberWithOperator, + bottomCalc:"sum", bottomCalcParams:{precision:1}}, + stundensatz: {visible: false}, + betrag: {align:"right", width: "8%", formatter: form_formatNulltoStringNumber, + headerFilter:"input", headerFilterFunc: hf_filterStringnumberWithOperator, + bottomCalc:"sum", bottomCalcParams:{precision:2}, bottomCalcFormatter:"money", + bottomCalcFormatterParams:{decimal: ",", thousand: ".", symbol:"€"}}, + vertrag_id: {visible: false}, + vertrag_stunden: {visible: false}, + vertrag_betrag: {visible: false}, + mitarbeiter_uid: {visible: false}, + bestellt: {align:"center", headerFilter:"input", mutator: mut_formatStringDate, tooltip: bestellt_tooltip, width: "8%"}, + erteilt: {align:"center", headerFilter:"input", mutator: mut_formatStringDate, tooltip: erteilt_tooltip, width: "8%"}, + akzeptiert: {align:"center", headerFilter:"input", mutator: mut_formatStringDate, tooltip: akzeptiert_tooltip, width: "8%"}, + bestellt_von: {visible: false}, + erteilt_von: {visible: false}, + akzeptiert_von: {visible: false} + }', // col properties +); + +echo $this->widgetlib->widget('TableWidget', $filterWidgetArray); + +?> diff --git a/application/views/organisation/studienjahrEdit.php b/application/views/organisation/studienjahrEdit.php index 4a23217b1..df0397cdf 100644 --- a/application/views/organisation/studienjahrEdit.php +++ b/application/views/organisation/studienjahrEdit.php @@ -7,7 +7,7 @@ $this->load->view('templates/header', array('title' => 'StudienjahrEdit', 'jquer

Studienjahr bearbeiten: studienjahr_kurzbz; ?>

-
"> + "> diff --git a/application/views/organisation/studiensemesterEdit.php b/application/views/organisation/studiensemesterEdit.php index 9f0abc0cb..98c4ca243 100644 --- a/application/views/organisation/studiensemesterEdit.php +++ b/application/views/organisation/studiensemesterEdit.php @@ -8,7 +8,7 @@ $this->load->view('templates/header', array('title' => 'StudiensemesterEdit', 'd

Studiensemester bearbeiten: studiensemester_kurzbz; ?>

"> + action="">
diff --git a/application/views/system/infocenter/infocenterData.php b/application/views/system/infocenter/infocenterData.php index 49f0c7af6..0c7030059 100644 --- a/application/views/system/infocenter/infocenterData.php +++ b/application/views/system/infocenter/infocenterData.php @@ -101,7 +101,7 @@ FROM tbl_prestudentstatus spss WHERE spss.prestudent_id = pss.prestudent_id AND spss.status_kurzbz = '.$REJECTED_STATUS.' - AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > + AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > (SELECT start FROM public.tbl_studiensemester sss WHERE studiensemester_kurzbz = '.$STUDIENSEMESTER.')) ) ORDER BY pss.datum DESC, pss.insertamum DESC, pss.ext_id DESC @@ -127,7 +127,7 @@ FROM tbl_prestudentstatus spss WHERE spss.prestudent_id = pss.prestudent_id AND spss.status_kurzbz = '.$REJECTED_STATUS.' - AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > + AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > (SELECT start FROM public.tbl_studiensemester sss WHERE studiensemester_kurzbz = '.$STUDIENSEMESTER.')) ) LIMIT 1 @@ -152,7 +152,7 @@ FROM tbl_prestudentstatus spss WHERE spss.prestudent_id = pss.prestudent_id AND spss.status_kurzbz = '.$REJECTED_STATUS.' - AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > + AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > (SELECT start FROM public.tbl_studiensemester sss WHERE studiensemester_kurzbz = '.$STUDIENSEMESTER.')) ) LIMIT 1 @@ -178,7 +178,7 @@ FROM tbl_prestudentstatus spss WHERE spss.prestudent_id = pss.prestudent_id AND spss.status_kurzbz = '.$REJECTED_STATUS.' - AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > + AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > (SELECT start FROM public.tbl_studiensemester sss WHERE studiensemester_kurzbz = '.$STUDIENSEMESTER.')) ) LIMIT 1 @@ -202,7 +202,7 @@ FROM tbl_prestudentstatus spss WHERE spss.prestudent_id = pss.prestudent_id AND spss.status_kurzbz = '.$REJECTED_STATUS.' - AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > + AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > (SELECT start FROM public.tbl_studiensemester sss WHERE studiensemester_kurzbz = '.$STUDIENSEMESTER.')) ) LIMIT 1 @@ -274,7 +274,6 @@ 'filter_id' => $this->input->get('filter_id'), 'requiredPermissions' => 'infocenter', 'datasetRepresentation' => 'tablesorter', - 'reloadDataset' => ($this->input->get('reloadDataset')=='true'?true:false), 'customMenu' => true, 'checkboxes' => 'PersonId', 'additionalColumns' => array('Details'), @@ -394,7 +393,7 @@ if ($datasetRaw->OnholdDate != null) { - $mark = "text-success"; + $mark = "onhold"; } // Parking has priority over locking diff --git a/application/views/system/infocenter/infocenterFreigegebenData.php b/application/views/system/infocenter/infocenterFreigegebenData.php index 13a2c0563..729fabb04 100644 --- a/application/views/system/infocenter/infocenterFreigegebenData.php +++ b/application/views/system/infocenter/infocenterFreigegebenData.php @@ -135,7 +135,7 @@ FROM tbl_prestudentstatus spss WHERE spss.prestudent_id = pss.prestudent_id AND spss.status_kurzbz = '.$REJECTED_STATUS.' - AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > + AND spss.studiensemester_kurzbz IN (SELECT ss.studiensemester_kurzbz FROM public.tbl_studiensemester ss WHERE ss.ende > (SELECT start FROM public.tbl_studiensemester sss WHERE studiensemester_kurzbz = '.$STUDIENSEMESTER.')) ) LIMIT 1 @@ -206,6 +206,7 @@ FROM public.tbl_prestudent ps JOIN public.tbl_studiengang sg USING(studiengang_kz) WHERE ps.person_id = p.person_id + AND ps.reihungstestangetreten = FALSE AND (sg.typ IN ('.$STUDIENGANG_TYP.') OR sg.studiengang_kz in('.$ADDITIONAL_STG.') @@ -235,7 +236,6 @@ 'filter_id' => $this->input->get('filter_id'), 'requiredPermissions' => 'infocenter', 'datasetRepresentation' => 'tablesorter', - 'reloadDataset' => ($this->input->get('reloadDataset')=='true'?true:false), 'checkboxes' => 'PersonId', 'additionalColumns' => array('Details'), 'columnsAliases' => array( diff --git a/application/views/system/infocenter/infocenterReihungstestAbsolviertData.php b/application/views/system/infocenter/infocenterReihungstestAbsolviertData.php index 652ab4887..22b122bb0 100644 --- a/application/views/system/infocenter/infocenterReihungstestAbsolviertData.php +++ b/application/views/system/infocenter/infocenterReihungstestAbsolviertData.php @@ -204,7 +204,6 @@ 'filter_id' => $this->input->get('filter_id'), 'requiredPermissions' => 'infocenter', 'datasetRepresentation' => 'tablesorter', - 'reloadDataset' => ($this->input->get('reloadDataset')=='true'?true:false), 'checkboxes' => 'PersonId', 'additionalColumns' => array('Details'), 'columnsAliases' => array( diff --git a/application/views/system/logs/logsViewerData.php b/application/views/system/logs/logsViewerData.php index 14cd2902e..13a4207ab 100644 --- a/application/views/system/logs/logsViewerData.php +++ b/application/views/system/logs/logsViewerData.php @@ -14,7 +14,6 @@ ', 'requiredPermissions' => 'admin', 'datasetRepresentation' => 'tablesorter', - 'reloadDataset' => true, 'columnsAliases' => array( 'Log id', 'Request id', diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index 43112dd7b..3c1327d5f 100644 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -25,10 +25,13 @@ $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; + $tablewidget = isset($tablewidget) ? $tablewidget : false; + $tabulator = isset($tabulator) ? $tabulator : false; $tinymce = isset($tinymce) ? $tinymce : false; ?> @@ -79,6 +82,13 @@ 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'); + generateCSSsInclude('public/css/Tabulator.css'); + } + // -------------------------------------------------------------------------------------------------------- // From public folder @@ -134,6 +144,14 @@ // NOTE: keep it after jQuery includes if ($jquerytreetable === true) generateJSsInclude('vendor/ludo/jquery-treetable/jquery.treetable.js'); + // MomentJS + if ($momentjs === true) + { + 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 CSS if ($pivotui === true) { @@ -148,6 +166,13 @@ 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'); + generateJSsInclude('vendor/olifolkerd/tabulator/dist/js/jquery_wrapper.min.js'); + } + // Tinymce JS if ($tinymce === true) generateJSsInclude('vendor/tinymce/tinymce/tinymce.min.js'); @@ -179,6 +204,9 @@ // PhrasesLib JS if ($phrases != null) generateJSsInclude('public/js/PhrasesLib.js'); + // TableWidget JS + if ($tablewidget === true) generateJSsInclude('public/js/TableWidget.js'); + // Load addon hooks JS // NOTE: keep it as the latest but one if ($addons === true) generateAddonsJSsInclude($calledPath.'/'.$calledMethod); diff --git a/application/views/widgets/filter/filter.php b/application/views/widgets/filter/filter.php index dc20e58b6..a9b8ad1f1 100644 --- a/application/views/widgets/filter/filter.php +++ b/application/views/widgets/filter/filter.php @@ -1,4 +1,5 @@ -
+ +
@@ -6,40 +7,7 @@
- -
-
- -
-
- -
- -
- -
- - -
- -
- -
- - -
- -
-
-
-
-
- -
+
diff --git a/application/views/widgets/filter/filterOptions.php b/application/views/widgets/filter/filterOptions.php new file mode 100644 index 000000000..6f1dd3885 --- /dev/null +++ b/application/views/widgets/filter/filterOptions.php @@ -0,0 +1,35 @@ + + +
+
+ +
+
+ +
+ +
+ +
+ + +
+ +
+ +
+ + +
+ +
+
+
+
+
+ +
diff --git a/application/views/widgets/filter/tableDataset.php b/application/views/widgets/filter/tableDataset.php index ca917503a..2f1b94e61 100644 --- a/application/views/widgets/filter/tableDataset.php +++ b/application/views/widgets/filter/tableDataset.php @@ -1,8 +1,7 @@ -
+
-
diff --git a/application/views/widgets/filter/tabulatorDataset.php b/application/views/widgets/filter/tabulatorDataset.php new file mode 100644 index 000000000..f5efc50b3 --- /dev/null +++ b/application/views/widgets/filter/tabulatorDataset.php @@ -0,0 +1 @@ +
diff --git a/application/views/widgets/table/pivotUIDataset.php b/application/views/widgets/table/pivotUIDataset.php new file mode 100644 index 000000000..0b43fcdac --- /dev/null +++ b/application/views/widgets/table/pivotUIDataset.php @@ -0,0 +1 @@ +
diff --git a/application/views/widgets/table/table.php b/application/views/widgets/table/table.php new file mode 100644 index 000000000..e73aec335 --- /dev/null +++ b/application/views/widgets/table/table.php @@ -0,0 +1,17 @@ + +
+
+ + +
+ + +
+ +
+ + +
+ +
+
diff --git a/application/views/widgets/table/tableDataset.php b/application/views/widgets/table/tableDataset.php new file mode 100644 index 000000000..7c2f26ea5 --- /dev/null +++ b/application/views/widgets/table/tableDataset.php @@ -0,0 +1,7 @@ + + + + + + +
diff --git a/application/views/widgets/table/tabulatorDataset.php b/application/views/widgets/table/tabulatorDataset.php new file mode 100644 index 000000000..4984284bc --- /dev/null +++ b/application/views/widgets/table/tabulatorDataset.php @@ -0,0 +1 @@ +
diff --git a/application/widgets/Ausbildungssemester_widget.php b/application/widgets/Ausbildungssemester_widget.php new file mode 100644 index 000000000..8200d8a63 --- /dev/null +++ b/application/widgets/Ausbildungssemester_widget.php @@ -0,0 +1,43 @@ +id = $i; + $ausbildungssemester_obj->description = $i; + + $ausbildungssemester_arr []= $ausbildungssemester_obj; + } + + $this->setElementsArray( + success($ausbildungssemester_arr), + true, + $this->p->t('lehre', 'ausbildungssemester'), + 'No Ausbildungssemester found' + ); + + $this->loadDropDownView($widgetData); + } +} \ No newline at end of file diff --git a/application/widgets/FilterWidget.php b/application/widgets/FilterWidget.php index 84a4d138b..1cef91c15 100644 --- a/application/widgets/FilterWidget.php +++ b/application/widgets/FilterWidget.php @@ -7,9 +7,11 @@ class FilterWidget extends Widget { // Paths of the views const WIDGET_URL_FILTER = 'widgets/filter/filter'; + const WIDGET_URL_FILTER_OPTIONS = 'widgets/filter/filterOptions'; const WIDGET_URL_SELECT_FIELDS = 'widgets/filter/selectFields'; const WIDGET_URL_DATASET_TABLESORTER = 'widgets/filter/tableDataset'; const WIDGET_URL_DATASET_PIVOTUI = 'widgets/filter/pivotUIDataset'; + const WIDGET_URL_DATASET_TABULATOR = 'widgets/filter/tabulatorDataset'; const WIDGET_URL_SELECT_FILTERS = 'widgets/filter/selectFilters'; const WIDGET_URL_SAVE_FILTER = 'widgets/filter/saveFilter'; @@ -40,16 +42,23 @@ class FilterWidget extends Widget // To have a column in the GUI with checkboxes to select rows in the table private $_checkboxes; - // To hide the GUI to operate or save the filter widget - private $_hideHeader; - private $_hideSave; + // To hide the GUI to operate with the filter widget or to save a custom filter + private $_hideOptions; // if true hides all the options + private $_hideSelectFields; // if true hides the fields selection + private $_hideSelectFilters; // if true hides the filters selections + private $_hideSave; // if true hides the GUI to save a custom filter + private $_hideMenu; // if true then the menu is not shown private $_customMenu; // if true then method _setFilterMenu is NOT called private $_datasetRepresentation; // dataset representation (ex: tablesorter, pivotUI, ...) private $_datasetRepresentationOptions; // dataset representation options for tablesorter, pivotUI, ... + private $_datasetRepFieldsDefs; // dataset representation attributes for each record field + private $_reloadDataset; // Force Reload of Dataset + private $_sessionTimeout; // session expiring time + private static $_FilterWidgetInstance; // static property that contains the instance of itself /** @@ -61,18 +70,20 @@ class FilterWidget extends Widget self::$_FilterWidgetInstance = $this; // set static property $_FilterWidgetInstance with this instance - $this->load->library('FiltersLib'); // Loads the FiltersLib that contains all the used logic + $this->load->library('FilterWidgetLib'); // Loads the FilterWidgetLib that contains all the used logic $this->_initFilterWidget($args); // checks parameters and initialize properties + $this->filterwidgetlib->setFilterUniqueIdByParams($args); + // Let's start if it's allowed // NOTE: If it is NOT allowed then no data are loaded - if ($this->filterslib->isAllowed($this->_requiredPermissions)) + if ($this->filterwidgetlib->isAllowed($this->_requiredPermissions)) { $this->_startFilterWidget(); // If a custom menu is not used, then default menu is used - if ($this->_customMenu != true) $this->_setFilterMenu(); + if ($this->_hideMenu != true && $this->_customMenu != true) $this->_setFilterMenu(); } } @@ -84,18 +95,33 @@ class FilterWidget extends Widget */ public function display($widgetData) { - $this->view(self::WIDGET_URL_FILTER); // GUI starts here + $this->view(self::WIDGET_URL_FILTER, array( + 'app' => $this->_app, + 'dataset' => $this->_datasetName, + 'filterid' => $this->_filterId + )); // GUI starts here } //------------------------------------------------------------------------------------------------------------------ // Public static methods used to load views and to access statically to some properies of the FilterWidget + /** + * Loads the view related to the filter options + */ + public static function loadViewFilterOptions() + { + if (self::$_FilterWidgetInstance->_hideOptions != true) + { + self::_loadView(self::WIDGET_URL_FILTER_OPTIONS); + } + } + /** * Loads the view related to the selected fields */ public static function loadViewSelectFields() { - if (self::$_FilterWidgetInstance->_hideHeader != true) + if (self::$_FilterWidgetInstance->_hideSelectFields != true) { self::_loadView(self::WIDGET_URL_SELECT_FIELDS); } @@ -106,7 +132,7 @@ class FilterWidget extends Widget */ public static function loadViewSelectFilters() { - if (self::$_FilterWidgetInstance->_hideHeader != true) + if (self::$_FilterWidgetInstance->_hideSelectFilters != true) { self::_loadView(self::WIDGET_URL_SELECT_FILTERS); } @@ -128,15 +154,20 @@ class FilterWidget extends Widget */ public static function loadViewDataset() { - if (self::$_FilterWidgetInstance->_datasetRepresentation == FiltersLib::DATASET_REP_TABLESORTER) + if (self::$_FilterWidgetInstance->_datasetRepresentation == FilterWidgetLib::DATASET_REP_TABLESORTER) { self::_loadView(self::WIDGET_URL_DATASET_TABLESORTER); } - if (self::$_FilterWidgetInstance->_datasetRepresentation == FiltersLib::DATASET_REP_PIVOTUI) + if (self::$_FilterWidgetInstance->_datasetRepresentation == FilterWidgetLib::DATASET_REP_PIVOTUI) { self::_loadView(self::WIDGET_URL_DATASET_PIVOTUI); } + + if (self::$_FilterWidgetInstance->_datasetRepresentation == FilterWidgetLib::DATASET_REP_TABULATOR) + { + self::_loadView(self::WIDGET_URL_DATASET_TABULATOR); + } } //------------------------------------------------------------------------------------------------------------------ @@ -157,122 +188,158 @@ class FilterWidget extends Widget $this->_datasetName = null; $this->_filterKurzbz = null; $this->_filterId = null; - $this->_reloadDataset = null; + $this->_reloadDataset = true; // by default the dataset is NOT cached in session $this->_query = null; $this->_additionalColumns = null; $this->_columnsAliases = null; $this->_formatRow = null; $this->_markRow = null; $this->_checkboxes = null; - $this->_hideHeader = null; + $this->_hideOptions = null; + $this->_hideSelectFields = null; + $this->_hideSelectFilters = null; $this->_hideSave = null; + $this->_hideMenu = null; $this->_customMenu = null; $this->_datasetRepresentation = null; $this->_datasetRepresentationOptions = null; + $this->_datasetRepFieldsDefs = null; + $this->_sessionTimeout = FilterWidgetLib::SESSION_DEFAULT_TIMEOUT; // Retrieved the required permissions parameter if present - if (isset($args[FiltersLib::REQUIRED_PERMISSIONS_PARAMETER])) + if (isset($args[FilterWidgetLib::REQUIRED_PERMISSIONS])) { - $this->_requiredPermissions = $args[FiltersLib::REQUIRED_PERMISSIONS_PARAMETER]; + $this->_requiredPermissions = $args[FilterWidgetLib::REQUIRED_PERMISSIONS]; } // Parameters needed to retrieve univocally a filter from DB - if (isset($args[FiltersLib::APP_PARAMETER])) + if (isset($args[FilterWidgetLib::APP])) { - $this->_app = $args[FiltersLib::APP_PARAMETER]; + $this->_app = $args[FilterWidgetLib::APP]; } - if (isset($args[FiltersLib::DATASET_NAME_PARAMETER])) + if (isset($args[FilterWidgetLib::DATASET_NAME])) { - $this->_datasetName = $args[FiltersLib::DATASET_NAME_PARAMETER]; + $this->_datasetName = $args[FilterWidgetLib::DATASET_NAME]; } - if (isset($args[FiltersLib::FILTER_KURZBZ_PARAMETER])) + if (isset($args[FilterWidgetLib::FILTER_KURZBZ])) { - $this->_filterKurzbz = $args[FiltersLib::FILTER_KURZBZ_PARAMETER]; + $this->_filterKurzbz = $args[FilterWidgetLib::FILTER_KURZBZ]; } - if (isset($args[FiltersLib::FILTER_ID])) + if (isset($args[FilterWidgetLib::FILTER_ID])) { - $this->_filterId = $args[FiltersLib::FILTER_ID]; + $this->_filterId = $args[FilterWidgetLib::FILTER_ID]; } // How to retrieve data for the filter: SQL statement or a result from DB - if (isset($args[FiltersLib::QUERY_PARAMETER])) + if (isset($args[FilterWidgetLib::QUERY])) { - $this->_query = $args[FiltersLib::QUERY_PARAMETER]; + $this->_query = $args[FilterWidgetLib::QUERY]; } - if (isset($args[FiltersLib::DATASET_RELOAD_PARAMETER])) + if (isset($args[FilterWidgetLib::DATASET_RELOAD])) { - $this->_reloadDataset = $args[FiltersLib::DATASET_RELOAD_PARAMETER]; + $this->_reloadDataset = $args[FilterWidgetLib::DATASET_RELOAD]; } // Parameter is used to add extra columns to the dataset - if (isset($args[FiltersLib::ADDITIONAL_COLUMNS]) - && is_array($args[FiltersLib::ADDITIONAL_COLUMNS]) - && count($args[FiltersLib::ADDITIONAL_COLUMNS]) > 0) + if (isset($args[FilterWidgetLib::ADDITIONAL_COLUMNS]) + && is_array($args[FilterWidgetLib::ADDITIONAL_COLUMNS]) + && count($args[FilterWidgetLib::ADDITIONAL_COLUMNS]) > 0) { - $this->_additionalColumns = $args[FiltersLib::ADDITIONAL_COLUMNS]; + $this->_additionalColumns = $args[FilterWidgetLib::ADDITIONAL_COLUMNS]; } // Parameter is used to add use aliases for the columns fo the dataset - if (isset($args[FiltersLib::COLUMNS_ALIASES]) - && is_array($args[FiltersLib::COLUMNS_ALIASES]) - && count($args[FiltersLib::COLUMNS_ALIASES]) > 0) + if (isset($args[FilterWidgetLib::COLUMNS_ALIASES]) + && is_array($args[FilterWidgetLib::COLUMNS_ALIASES]) + && count($args[FilterWidgetLib::COLUMNS_ALIASES]) > 0) { - $this->_columnsAliases = $args[FiltersLib::COLUMNS_ALIASES]; + $this->_columnsAliases = $args[FilterWidgetLib::COLUMNS_ALIASES]; } // Parameter that contains a function to format the rows of the dataset - if (isset($args[FiltersLib::FORMAT_ROW]) && is_callable($args[FiltersLib::FORMAT_ROW])) + if (isset($args[FilterWidgetLib::FORMAT_ROW]) && is_callable($args[FilterWidgetLib::FORMAT_ROW])) { - $this->_formatRow = $args[FiltersLib::FORMAT_ROW]; + $this->_formatRow = $args[FilterWidgetLib::FORMAT_ROW]; } // Parameter that contains a function to mark in the GUI the rows of the dataset - if (isset($args[FiltersLib::MARK_ROW]) && is_callable($args[FiltersLib::MARK_ROW])) + if (isset($args[FilterWidgetLib::MARK_ROW]) && is_callable($args[FilterWidgetLib::MARK_ROW])) { - $this->_markRow = $args[FiltersLib::MARK_ROW]; + $this->_markRow = $args[FilterWidgetLib::MARK_ROW]; } // Parameter used to specify the column of the dataset that will be used // as id of the checkboxes column in the GUI - if (isset($args[FiltersLib::CHECKBOXES])) + if (isset($args[FilterWidgetLib::CHECKBOXES])) { - $this->_checkboxes = $args[FiltersLib::CHECKBOXES]; + $this->_checkboxes = $args[FilterWidgetLib::CHECKBOXES]; } - // To specify if the header to operate with the FilterWidget is shown or not - if (isset($args[FiltersLib::HIDE_HEADER]) && is_bool($args[FiltersLib::HIDE_HEADER])) + // To specify if the filter options are shown ot not + if (isset($args[FilterWidgetLib::HIDE_OPTIONS]) && is_bool($args[FilterWidgetLib::HIDE_OPTIONS])) { - $this->_hideHeader = $args[FiltersLib::HIDE_HEADER]; + $this->_hideOptions = $args[FilterWidgetLib::HIDE_OPTIONS]; + } + + // To specify if the form to select fields is shown or not + if (isset($args[FilterWidgetLib::HIDE_SELECT_FIELDS]) && is_bool($args[FilterWidgetLib::HIDE_SELECT_FIELDS])) + { + $this->_hideSelectFields = $args[FilterWidgetLib::HIDE_SELECT_FIELDS]; + } + + // To specify if the form to select filters is shown or not + if (isset($args[FilterWidgetLib::HIDE_SELECT_FILTERS]) && is_bool($args[FilterWidgetLib::HIDE_SELECT_FILTERS])) + { + $this->_hideSelectFilters = $args[FilterWidgetLib::HIDE_SELECT_FILTERS]; } // To specify if the form to save a custom FilterWidget is shown or not - if (isset($args[FiltersLib::HIDE_SAVE]) && is_bool($args[FiltersLib::HIDE_SAVE])) + if (isset($args[FilterWidgetLib::HIDE_SAVE]) && is_bool($args[FilterWidgetLib::HIDE_SAVE])) { - $this->_hideSave = $args[FiltersLib::HIDE_SAVE]; + $this->_hideSave = $args[FilterWidgetLib::HIDE_SAVE]; + } + + // If the menu should be shown or not + if (isset($args[FilterWidgetLib::HIDE_MENU]) && is_bool($args[FilterWidgetLib::HIDE_MENU])) + { + $this->_hideMenu = $args[FilterWidgetLib::HIDE_MENU]; } // If a custom menu is set - if (isset($args[FiltersLib::CUSTOM_MENU]) && is_bool($args[FiltersLib::CUSTOM_MENU])) + if (isset($args[FilterWidgetLib::CUSTOM_MENU]) && is_bool($args[FilterWidgetLib::CUSTOM_MENU])) { - $this->_customMenu = $args[FiltersLib::CUSTOM_MENU]; + $this->_customMenu = $args[FilterWidgetLib::CUSTOM_MENU]; } // To specify how to represent the dataset (ex: tablesorter, pivotUI, ...) - if (isset($args[FiltersLib::DATASET_REPRESENTATION]) - && ($args[FiltersLib::DATASET_REPRESENTATION] == FiltersLib::DATASET_REP_TABLESORTER - || $args[FiltersLib::DATASET_REPRESENTATION] == FiltersLib::DATASET_REP_PIVOTUI)) + if (isset($args[FilterWidgetLib::DATASET_REPRESENTATION]) + && ($args[FilterWidgetLib::DATASET_REPRESENTATION] == FilterWidgetLib::DATASET_REP_TABLESORTER + || $args[FilterWidgetLib::DATASET_REPRESENTATION] == FilterWidgetLib::DATASET_REP_PIVOTUI + || $args[FilterWidgetLib::DATASET_REPRESENTATION] == FilterWidgetLib::DATASET_REP_TABULATOR)) { - $this->_datasetRepresentation = $args[FiltersLib::DATASET_REPRESENTATION]; + $this->_datasetRepresentation = $args[FilterWidgetLib::DATASET_REPRESENTATION]; } // To specify options for the dataset representation (ex: tablesorter, pivotUI, ...) - if (isset($args[FiltersLib::DATASET_REP_OPTIONS]) && !isEmptyString($args[FiltersLib::DATASET_REP_OPTIONS])) + if (isset($args[FilterWidgetLib::DATASET_REP_OPTIONS]) && !isEmptyString($args[FilterWidgetLib::DATASET_REP_OPTIONS])) { - $this->_datasetRepresentationOptions = $args[FiltersLib::DATASET_REP_OPTIONS]; + $this->_datasetRepresentationOptions = $args[FilterWidgetLib::DATASET_REP_OPTIONS]; + } + + // To specify how to represent each record field + if (isset($args[FilterWidgetLib::DATASET_REP_FIELDS_DEFS]) && !isEmptyString($args[FilterWidgetLib::DATASET_REP_FIELDS_DEFS])) + { + $this->_datasetRepFieldsDefs = $args[FilterWidgetLib::DATASET_REP_FIELDS_DEFS]; + } + + // To specify the expiring session time + if (isset($args[FilterWidgetLib::SESSION_TIMEOUT]) && is_numeric($args[FilterWidgetLib::SESSION_TIMEOUT])) + { + $this->_sessionTimeout = $args[FilterWidgetLib::SESSION_TIMEOUT]; } } @@ -281,40 +348,55 @@ class FilterWidget extends Widget */ private function _checkParameters($args) { + // If no options are given to this widget... if (!is_array($args) || (is_array($args) && count($args) == 0)) { show_error('Second parameter of the widget call must be a NOT empty associative array'); } - else + else // ...otherwise { - if ((!isset($args[FiltersLib::APP_PARAMETER]) && !isset($args[FiltersLib::DATASET_NAME_PARAMETER])) - && !isset($args[FiltersLib::FILTER_ID])) + // Parameters (app AND dataset name) OR filter id are mandatory + if ((!isset($args[FilterWidgetLib::APP]) && !isset($args[FilterWidgetLib::DATASET_NAME])) + && !isset($args[FilterWidgetLib::FILTER_ID])) { show_error( - 'The parameters ("'.FiltersLib::APP_PARAMETER.'" and "'.FiltersLib::DATASET_NAME_PARAMETER.') OR "'. - FiltersLib::FILTER_ID.'" must be specified' + 'The parameters ("'.FilterWidgetLib::APP.'" AND "'.FilterWidgetLib::DATASET_NAME.') OR "'. + FilterWidgetLib::FILTER_ID.'" must be specified' ); } - if (!isset($args[FiltersLib::QUERY_PARAMETER])) + // The query parameter is mandatory + if (!isset($args[FilterWidgetLib::QUERY])) { - show_error('The parameters "'.FiltersLib::QUERY_PARAMETER.'" must be specified'); + show_error('The parameter "'.FilterWidgetLib::QUERY.'" must be specified'); } - if (!isset($args[FiltersLib::DATASET_REPRESENTATION])) + // The dataset representation parameter is mandatory + if (!isset($args[FilterWidgetLib::DATASET_REPRESENTATION])) { - show_error('The parameter "'.FiltersLib::DATASET_REPRESENTATION.'" must be specified'); + show_error('The parameter "'.FilterWidgetLib::DATASET_REPRESENTATION.'" must be specified'); } - if (isset($args[FiltersLib::DATASET_REPRESENTATION]) - && $args[FiltersLib::DATASET_REPRESENTATION] != FiltersLib::DATASET_REP_TABLESORTER - && $args[FiltersLib::DATASET_REPRESENTATION] != FiltersLib::DATASET_REP_PIVOTUI) + // Checks if the dataset representation parameter is valid + if (isset($args[FilterWidgetLib::DATASET_REPRESENTATION]) + && $args[FilterWidgetLib::DATASET_REPRESENTATION] != FilterWidgetLib::DATASET_REP_TABLESORTER + && $args[FilterWidgetLib::DATASET_REPRESENTATION] != FilterWidgetLib::DATASET_REP_PIVOTUI + && $args[FilterWidgetLib::DATASET_REPRESENTATION] != FilterWidgetLib::DATASET_REP_TABULATOR) { show_error( - 'The parameter "'.FiltersLib::DATASET_REPRESENTATION. - '" must be IN ("'.FiltersLib::DATASET_REP_TABLESORTER.'", "'.FiltersLib::DATASET_REP_PIVOTUI.'")' + 'The parameter "'.FilterWidgetLib::DATASET_REPRESENTATION. + '" must be IN ("' + .FilterWidgetLib::DATASET_REP_TABLESORTER.'", "' + .FilterWidgetLib::DATASET_REP_PIVOTUI.'", "' + .FilterWidgetLib::DATASET_REP_TABULATOR.'")' ); } + + // If given the session timeout parameter must be a number + if (isset($args[FilterWidgetLib::SESSION_TIMEOUT]) && !is_numeric($args[FilterWidgetLib::SESSION_TIMEOUT])) + { + show_error('The parameter "'.FilterWidgetLib::SESSION_TIMEOUT.'" must be a number'); + } } } @@ -323,52 +405,53 @@ class FilterWidget extends Widget */ private function _startFilterWidget() { + // Looks for expired filter widgets in session and drops them + $this->filterwidgetlib->dropExpiredFilterWidgets(); + // Read the all session for this filter widget - $session = $this->filterslib->getSession(); + $session = $this->filterwidgetlib->getSession(); // If session is NOT empty -> a filter was already loaded if ($session != null) { // Retrieve the filterId stored in the session - $sessionFilterId = $this->filterslib->getSessionElement(FiltersLib::FILTER_ID); + $sessionFilterId = $this->filterwidgetlib->getSessionElement(FilterWidgetLib::FILTER_ID); // If the filter loaded in session is NOT the same that is being requested then empty the session if ($this->_filterId != $sessionFilterId) { - $this->filterslib->setSession(null); + $this->filterwidgetlib->setSession(null); $session = null; } else // else if the filter loaded in session is the same that is being requested { - // Get SESSION_RELOAD_DATASET from the session - $sessionReloadDataset = $this->filterslib->getSessionElement(FiltersLib::SESSION_RELOAD_DATASET); + // Get SESSION_DATASET_RELOAD from the session + $sessionReloadDataset = $this->filterwidgetlib->getSessionElement(FilterWidgetLib::SESSION_DATASET_RELOAD); // if Filter changed or reload is forced by parameter then reload the Dataset if ($this->_reloadDataset === true || $sessionReloadDataset === true) { // Set as false to stop changing the dataset - $this->filterslib->setSessionElement(FiltersLib::SESSION_RELOAD_DATASET, false); + $this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_DATASET_RELOAD, false); // Generate dataset query using filters from the session - $datasetQuery = $this->filterslib->generateDatasetQuery( + $datasetQuery = $this->filterwidgetlib->generateDatasetQuery( $this->_query, - $this->filterslib->getSessionElement(FiltersLib::SESSION_FILTERS) + $this->filterwidgetlib->getSessionElement(FilterWidgetLib::SESSION_FILTERS) ); // Then retrieve dataset from DB - $dataset = $this->filterslib->getDataset($datasetQuery); + $dataset = $this->filterwidgetlib->getDataset($datasetQuery); // Save changes into session if data are valid if (!isError($dataset)) { $this->_formatDataset($dataset); // marks rows using markRow and format rowns using formatRow - $this->load->model('system/Filters_model', 'FiltersModel'); - // Set the new dataset and its attributes in the session - $this->filterslib->setSessionElement(FiltersLib::SESSION_METADATA, $this->FiltersModel->getExecutedQueryMetaData()); - $this->filterslib->setSessionElement(FiltersLib::SESSION_ROW_NUMBER, count($dataset->retval)); - $this->filterslib->setSessionElement(FiltersLib::SESSION_DATASET, $dataset->retval); + $this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_METADATA, $this->FiltersModel->getExecutedQueryMetaData()); + $this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_ROW_NUMBER, count($dataset->retval)); + $this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_DATASET, $dataset->retval); } } } @@ -378,7 +461,7 @@ class FilterWidget extends Widget if ($session == null) { // Load filter definition data from DB - $definition = $this->filterslib->loadDefinition( + $definition = $this->filterwidgetlib->loadDefinition( $this->_filterId, $this->_app, $this->_datasetName, @@ -386,53 +469,54 @@ class FilterWidget extends Widget ); // Checks and parse json present into the definition - $parsedFilterJson = $this->filterslib->parseFilterJson($definition); + $parsedFilterJson = $this->filterwidgetlib->parseFilterJson($definition); if ($parsedFilterJson != null) // if the json is valid { // Generate dataset query - $datasetQuery = $this->filterslib->generateDatasetQuery($this->_query, $parsedFilterJson->filters); + $datasetQuery = $this->filterwidgetlib->generateDatasetQuery($this->_query, $parsedFilterJson->filters); // Then retrieve dataset from DB - $dataset = $this->filterslib->getDataset($datasetQuery); + $dataset = $this->filterwidgetlib->getDataset($datasetQuery); // Try to load the name of the filter using the PhrasesLib - $filterName = $this->filterslib->getFilterName($parsedFilterJson); + $filterName = $this->filterwidgetlib->getFilterName($parsedFilterJson); // Save changes into session if data are valid if (!isError($dataset)) { $this->_formatDataset($dataset); // marks rows using markRow and format rowns using formatRow - $this->load->model('system/Filters_model', 'FiltersModel'); - // Stores an array that contains all the data useful for - $this->filterslib->setSession( + $this->filterwidgetlib->setSession( array( - FiltersLib::FILTER_ID => $this->_filterId, // the current filter id - FiltersLib::APP_PARAMETER => $this->_app, // the current app parameter - FiltersLib::DATASET_NAME_PARAMETER => $this->_datasetName, // the carrent dataset name - FiltersLib::SESSION_FILTER_NAME => $filterName, // the current filter name - FiltersLib::SESSION_FIELDS => $this->FiltersModel->getExecutedQueryListFields(), // all the fields of the dataset - FiltersLib::SESSION_SELECTED_FIELDS => $this->_getColumnsNames($parsedFilterJson->columns), // all the selected fields - FiltersLib::SESSION_COLUMNS_ALIASES => $this->_columnsAliases, // all the fields aliases - FiltersLib::SESSION_ADDITIONAL_COLUMNS => $this->_additionalColumns, // additional columns - FiltersLib::SESSION_CHECKBOXES => $this->_checkboxes, // the name of the field used to build the checkboxes column - FiltersLib::SESSION_FILTERS => $parsedFilterJson->filters, // all the filters used to filter the dataset - FiltersLib::SESSION_METADATA => $this->FiltersModel->getExecutedQueryMetaData(), // the metadata of the dataset - FiltersLib::SESSION_ROW_NUMBER => count($dataset->retval), // the number of loaded rows by this filter - FiltersLib::SESSION_DATASET => $dataset->retval, // the entire dataset - FiltersLib::SESSION_RELOAD_DATASET => false, // if the dataset must be reloaded, not needed the first time - FiltersLib::SESSION_DATASET_REPRESENTATION => $this->_datasetRepresentation, // the choosen dataset representation - FiltersLib::SESSION_DATASET_REP_OPTIONS => $this->_datasetRepresentationOptions // the choosen dataset representation options + FilterWidgetLib::FILTER_ID => $this->_filterId, // the current filter id + FilterWidgetLib::APP => $this->_app, // the current app parameter + FilterWidgetLib::DATASET_NAME => $this->_datasetName, // the carrent dataset name + FilterWidgetLib::SESSION_FILTER_NAME => $filterName, // the current filter name + FilterWidgetLib::SESSION_FIELDS => $this->FiltersModel->getExecutedQueryListFields(), // all the fields of the dataset + FilterWidgetLib::SESSION_SELECTED_FIELDS => $this->_getColumnsNames($parsedFilterJson->columns), // all the selected fields + FilterWidgetLib::SESSION_COLUMNS_ALIASES => $this->_columnsAliases, // all the fields aliases + FilterWidgetLib::SESSION_ADDITIONAL_COLUMNS => $this->_additionalColumns, // additional columns + FilterWidgetLib::SESSION_CHECKBOXES => $this->_checkboxes, // the name of the field used to build the checkboxes column + FilterWidgetLib::SESSION_FILTERS => $parsedFilterJson->filters, // all the filters used to filter the dataset + FilterWidgetLib::SESSION_METADATA => $this->FiltersModel->getExecutedQueryMetaData(), // the metadata of the dataset + FilterWidgetLib::SESSION_ROW_NUMBER => count($dataset->retval), // the number of loaded rows by this filter + FilterWidgetLib::SESSION_DATASET => $dataset->retval, // the entire dataset + FilterWidgetLib::SESSION_DATASET_RELOAD => false, // if the dataset must be reloaded, not needed the first time + FilterWidgetLib::SESSION_DATASET_REPRESENTATION => $this->_datasetRepresentation, // the choosen dataset representation + FilterWidgetLib::SESSION_DATASET_REP_OPTIONS => $this->_datasetRepresentationOptions, // the choosen dataset representation options + FilterWidgetLib::SESSION_DATASET_REP_FIELDS_DEFS => $this->_datasetRepFieldsDefs // the choosen dataset representation record fields definition ) ); } } } + // NOTE: latest operations to be performed in the session to be shure that they are always present // To be always stored in the session, otherwise is not possible to load data from Filters controller - // NOTE: must the latest operation to be performed in the session to be shure that is always present - $this->filterslib->setSessionElement(FiltersLib::REQUIRED_PERMISSIONS_PARAMETER, $this->_requiredPermissions); + $this->filterwidgetlib->setSessionElement(FilterWidgetLib::REQUIRED_PERMISSIONS, $this->_requiredPermissions); + // Renew or set the session expiring time + $this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_TIMEOUT, strtotime('+'.$this->_sessionTimeout.' minutes', time())); } /** @@ -441,7 +525,7 @@ class FilterWidget extends Widget private function _setFilterMenu() { // Generates the filters structure array - $filterMenu = $this->filterslib->generateFilterMenu( + $filterMenu = $this->filterwidgetlib->generateFilterMenu( $this->router->directory.$this->router->class.'/'.$this->router->method ); } diff --git a/application/widgets/Organisationseinheit_widget.php b/application/widgets/Organisationseinheit_widget.php index 67d1598b0..e4fbfe2ba 100644 --- a/application/widgets/Organisationseinheit_widget.php +++ b/application/widgets/Organisationseinheit_widget.php @@ -5,16 +5,34 @@ class Organisationseinheit_widget extends DropdownWidget public function display($widgetData) { $this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); - + if (isset($widgetData['typ'])) - $typ = $widgetData['typ']; + { + $this->setElementsArray($this->OrganisationseinheitModel->getRecursiveList($widgetData['typ'])); + } + // If 'organisationseinheit' (array of specific oe_kurzbz) is given, retrieve these organisational units only + elseif (isset($widgetData['organisationseinheit']) && !empty($widgetData['organisationseinheit'])) + { + $condition = ' + oe_kurzbz IN (\''. implode('\',\'', $widgetData['organisationseinheit']) . '\') AND + aktiv = TRUE + '; + $this->addSelectToModel($this->OrganisationseinheitModel, 'oe_kurzbz', 'organisationseinheittyp_kurzbz || \' \' || bezeichnung'); + $this->OrganisationseinheitModel->addOrder('organisationseinheittyp_kurzbz', 'ASC'); + $this->setElementsArray( + $this->OrganisationseinheitModel->loadWhere($condition), + true, + $this->p->t('lehre', 'organisationseinheit'), + 'No organisational units found' + ); + } + // Default: retrieve tree of all organisational units else - $typ = null; - - // NOTE: no need to call addSelectToModel because getRecursiveList already returns - // the correct names of the fields - - $this->setElementsArray($this->OrganisationseinheitModel->getRecursiveList($typ)); + { + // NOTE: no need to call addSelectToModel because getRecursiveList already returns + // the correct names of the fields + $this->setElementsArray($this->OrganisationseinheitModel->getRecursiveList()); + } $this->loadDropDownView($widgetData); } diff --git a/application/widgets/Studiengang_widget.php b/application/widgets/Studiengang_widget.php index a09c865f5..250f2a9bc 100644 --- a/application/widgets/Studiengang_widget.php +++ b/application/widgets/Studiengang_widget.php @@ -8,15 +8,29 @@ class Studiengang_widget extends DropdownWidget $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); $this->StudiengangModel->addOrder('kurzbzlang'); - $this->addSelectToModel($this->StudiengangModel, 'studiengang_kz', '\'(\' || kurzbzlang || \') \' || bezeichnung'); - - $this->setElementsArray( - $this->StudiengangModel->loadWhere(array('aktiv' => true)), - true, - 'Select a studiengang...', - 'No studiengaenge found' - ); - + $this->addSelectToModel($this->StudiengangModel, 'studiengang_kz', '\'(\' || upper(typ||kurzbz) || \') \' || tbl_studiengang.bezeichnung'); + + // If 'studiengang' (array of specific studiengaenge) is given, retrieve these studiengaenge only + if (isset($widgetData['studiengang']) && !empty($widgetData['studiengang'])) + { + $condition = ' + studiengang_kz IN ('. implode(',', $widgetData['studiengang']) . ') AND + aktiv = true + '; + } + // Default: retrieve all studiengaenge + else + { + $condition = array('aktiv' => true); + } + + $this->setElementsArray( + $this->StudiengangModel->loadWhere($condition), + true, + $this->p->t('lehre', 'studiengang'), + 'No studiengaenge found' + ); + $this->loadDropDownView(); } } \ No newline at end of file diff --git a/application/widgets/Studiensemester_widget.php b/application/widgets/Studiensemester_widget.php index bc1c0a201..dc6e28d38 100644 --- a/application/widgets/Studiensemester_widget.php +++ b/application/widgets/Studiensemester_widget.php @@ -6,14 +6,14 @@ class Studiensemester_widget extends DropdownWidget { // Studiensemester $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); - $this->StudiensemesterModel->addOrder('studiensemester_kurzbz', 'DESC'); + $this->StudiensemesterModel->addOrder('start', 'DESC'); $this->addSelectToModel($this->StudiensemesterModel, 'studiensemester_kurzbz', 'studiensemester_kurzbz'); $this->setElementsArray( $this->StudiensemesterModel->load(), true, - 'Select a studiensemester...', + $this->p->t('lehre', 'studiensemester'), 'No studiensemester found' ); diff --git a/application/widgets/TableWidget.php b/application/widgets/TableWidget.php new file mode 100644 index 000000000..5a000601f --- /dev/null +++ b/application/widgets/TableWidget.php @@ -0,0 +1,440 @@ +load->library('TableWidgetLib'); // Loads the TableWidgetLib that contains all the used logic + + $this->_initTableWidget($args); // checks parameters and initialize properties + + $this->tablewidgetlib->setTableUniqueIdByParams($args); + + // Let's start if it's allowed + // NOTE: If it is NOT allowed then no data are loaded + if ($this->tablewidgetlib->isAllowed($this->_requiredPermissions)) + { + $this->_startTableWidget($args[TableWidgetLib::TABLE_UNIQUE_ID]); + } + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Called when echoing the table widget call + */ + public function display($widgetData) + { + $this->view(self::WIDGET_URL_TABLE, array( + 'tableUniqueId' => $widgetData[TableWidgetLib::TABLE_UNIQUE_ID] + )); // GUI starts here + } + + //------------------------------------------------------------------------------------------------------------------ + // Public static methods used to load views and to access statically to some properies of the TableWidget + + /** + * Loads the view related to the dataset, here is decided how to represent the dataset (ex: tablesorter, pivotUI, ...) + */ + public static function loadViewDataset() + { + if (self::$_TableWidgetInstance->_datasetRepresentation == TableWidgetLib::DATASET_REP_TABLESORTER) + { + self::_loadView(self::WIDGET_URL_DATASET_TABLESORTER); + } + + if (self::$_TableWidgetInstance->_datasetRepresentation == TableWidgetLib::DATASET_REP_PIVOTUI) + { + self::_loadView(self::WIDGET_URL_DATASET_PIVOTUI); + } + + if (self::$_TableWidgetInstance->_datasetRepresentation == TableWidgetLib::DATASET_REP_TABULATOR) + { + self::_loadView(self::WIDGET_URL_DATASET_TABULATOR); + } + } + + //------------------------------------------------------------------------------------------------------------------ + // Private methods + + /** + * Checks parameters and initialize all the properties of this TableWidget + */ + private function _initTableWidget($args) + { + $this->_checkParameters($args); + + // If here then everything is ok + + // Initialize class properties + $this->_requiredPermissions = null; + $this->_reloadDataset = true; // by default the dataset is NOT cached in session + $this->_query = null; + $this->_additionalColumns = null; + $this->_columnsAliases = null; + $this->_formatRow = null; + $this->_markRow = null; + $this->_checkboxes = null; + $this->_datasetRepresentation = null; + $this->_datasetRepresentationOptions = null; + $this->_datasetRepFieldsDefs = null; + $this->_sessionTimeout = TableWidgetLib::SESSION_DEFAULT_TIMEOUT; + + // Retrieved the required permissions parameter if present + if (isset($args[TableWidgetLib::REQUIRED_PERMISSIONS])) + { + $this->_requiredPermissions = $args[TableWidgetLib::REQUIRED_PERMISSIONS]; + } + + // How to retrieve data for the table: SQL statement or a result from DB + if (isset($args[TableWidgetLib::QUERY])) + { + $this->_query = $args[TableWidgetLib::QUERY]; + } + + if (isset($args[TableWidgetLib::DATASET_RELOAD])) + { + $this->_reloadDataset = $args[TableWidgetLib::DATASET_RELOAD]; + } + + // Parameter is used to add extra columns to the dataset + if (isset($args[TableWidgetLib::ADDITIONAL_COLUMNS]) + && is_array($args[TableWidgetLib::ADDITIONAL_COLUMNS]) + && count($args[TableWidgetLib::ADDITIONAL_COLUMNS]) > 0) + { + $this->_additionalColumns = $args[TableWidgetLib::ADDITIONAL_COLUMNS]; + } + + // Parameter is used to add use aliases for the columns fo the dataset + if (isset($args[TableWidgetLib::COLUMNS_ALIASES]) + && is_array($args[TableWidgetLib::COLUMNS_ALIASES]) + && count($args[TableWidgetLib::COLUMNS_ALIASES]) > 0) + { + $this->_columnsAliases = $args[TableWidgetLib::COLUMNS_ALIASES]; + } + + // Parameter that contains a function to format the rows of the dataset + if (isset($args[TableWidgetLib::FORMAT_ROW]) && is_callable($args[TableWidgetLib::FORMAT_ROW])) + { + $this->_formatRow = $args[TableWidgetLib::FORMAT_ROW]; + } + + // Parameter that contains a function to mark in the GUI the rows of the dataset + if (isset($args[TableWidgetLib::MARK_ROW]) && is_callable($args[TableWidgetLib::MARK_ROW])) + { + $this->_markRow = $args[TableWidgetLib::MARK_ROW]; + } + + // Parameter used to specify the column of the dataset that will be used + // as id of the checkboxes column in the GUI + if (isset($args[TableWidgetLib::CHECKBOXES])) + { + $this->_checkboxes = $args[TableWidgetLib::CHECKBOXES]; + } + + // To specify how to represent the dataset (ex: tablesorter, pivotUI, ...) + if (isset($args[TableWidgetLib::DATASET_REPRESENTATION]) + && ($args[TableWidgetLib::DATASET_REPRESENTATION] == TableWidgetLib::DATASET_REP_TABLESORTER + || $args[TableWidgetLib::DATASET_REPRESENTATION] == TableWidgetLib::DATASET_REP_PIVOTUI + || $args[TableWidgetLib::DATASET_REPRESENTATION] == TableWidgetLib::DATASET_REP_TABULATOR)) + { + $this->_datasetRepresentation = $args[TableWidgetLib::DATASET_REPRESENTATION]; + } + + // To specify options for the dataset representation (ex: tablesorter, pivotUI, ...) + if (isset($args[TableWidgetLib::DATASET_REP_OPTIONS]) && !isEmptyString($args[TableWidgetLib::DATASET_REP_OPTIONS])) + { + $this->_datasetRepresentationOptions = $args[TableWidgetLib::DATASET_REP_OPTIONS]; + } + + // To specify how to represent each record field + if (isset($args[TableWidgetLib::DATASET_REP_FIELDS_DEFS]) && !isEmptyString($args[TableWidgetLib::DATASET_REP_FIELDS_DEFS])) + { + $this->_datasetRepFieldsDefs = $args[TableWidgetLib::DATASET_REP_FIELDS_DEFS]; + } + + // To specify the expiring session time + if (isset($args[TableWidgetLib::SESSION_TIMEOUT]) && is_numeric($args[TableWidgetLib::SESSION_TIMEOUT])) + { + $this->_sessionTimeout = $args[TableWidgetLib::SESSION_TIMEOUT]; + } + } + + /** + * Checks the required parameters used to call this TableWidget + */ + private function _checkParameters($args) + { + // If no options are given to this widget... + if (!is_array($args) || (is_array($args) && count($args) == 0)) + { + show_error('Second parameter of the widget call must be a NOT empty associative array'); + } + else // ...otherwise + { + // The unique id parameter is mandatory + if (!isset($args[TableWidgetLib::TABLE_UNIQUE_ID])) + { + show_error('The parameter "'.TableWidgetLib::TABLE_UNIQUE_ID.'" must be specified'); + } + + // The query parameter is mandatory + if (!isset($args[TableWidgetLib::QUERY])) + { + show_error('The parameter "'.TableWidgetLib::QUERY.'" must be specified'); + } + + // The dataset representation parameter is mandatory + if (!isset($args[TableWidgetLib::DATASET_REPRESENTATION])) + { + show_error('The parameter "'.TableWidgetLib::DATASET_REPRESENTATION.'" must be specified'); + } + + // Checks if the dataset representation parameter is valid + if (isset($args[TableWidgetLib::DATASET_REPRESENTATION]) + && $args[TableWidgetLib::DATASET_REPRESENTATION] != TableWidgetLib::DATASET_REP_TABLESORTER + && $args[TableWidgetLib::DATASET_REPRESENTATION] != TableWidgetLib::DATASET_REP_PIVOTUI + && $args[TableWidgetLib::DATASET_REPRESENTATION] != TableWidgetLib::DATASET_REP_TABULATOR) + { + show_error( + 'The parameter "'.TableWidgetLib::DATASET_REPRESENTATION. + '" must be IN ("' + .TableWidgetLib::DATASET_REP_TABLESORTER.'", "' + .TableWidgetLib::DATASET_REP_PIVOTUI.'", "' + .TableWidgetLib::DATASET_REP_TABULATOR.'")' + ); + } + + // If given the session timeout parameter must be a number + if (isset($args[TableWidgetLib::SESSION_TIMEOUT]) && !is_numeric($args[TableWidgetLib::SESSION_TIMEOUT])) + { + show_error('The parameter "'.TableWidgetLib::SESSION_TIMEOUT.'" must be a number'); + } + } + } + + /** + * Contains all the logic used to load all the data needed to the TableWidget + */ + private function _startTableWidget($tableUniqueId) + { + // Looks for expired table widgets in session and drops them + $this->tablewidgetlib->dropExpiredTableWidgets(); + + // Read the all session for this table widget + $session = $this->tablewidgetlib->getSession(); + + // If session is NOT empty -> a table was already loaded + if ($session != null) + { + // Get SESSION_DATASET_RELOAD from the session + $sessionReloadDataset = $this->tablewidgetlib->getSessionElement(TableWidgetLib::SESSION_DATASET_RELOAD); + + // if Filter changed or reload is forced by parameter then reload the Dataset + if ($this->_reloadDataset === true || $sessionReloadDataset === true) + { + // Set as false to stop changing the dataset + $this->tablewidgetlib->setSessionElement(TableWidgetLib::SESSION_DATASET_RELOAD, false); + + // Generate dataset query using tables from the session + $datasetQuery = $this->tablewidgetlib->generateDatasetQuery($this->_query); + + // Then retrieve dataset from DB + $dataset = $this->tablewidgetlib->getDataset($datasetQuery); + + // Save changes into session if data are valid + if (!isError($dataset)) + { + $this->_formatDataset($dataset); // marks rows using markRow and format rowns using formatRow + + // Set the new dataset and its attributes in the session + $this->tablewidgetlib->setSessionElement(TableWidgetLib::SESSION_METADATA, $this->tablewidgetlib->getExecutedQueryMetaData()); + $this->tablewidgetlib->setSessionElement(TableWidgetLib::SESSION_ROW_NUMBER, count($dataset->retval)); + $this->tablewidgetlib->setSessionElement(TableWidgetLib::SESSION_DATASET, $dataset->retval); + } + } + } + + // If the session is empty -> first time that this table is loaded + if ($session == null) + { + // Generate dataset query + $datasetQuery = $this->tablewidgetlib->generateDatasetQuery($this->_query); + + // Then retrieve dataset from DB + $dataset = $this->tablewidgetlib->getDataset($datasetQuery); + + // Save changes into session if data are valid + if (!isError($dataset)) + { + $this->_formatDataset($dataset); // marks rows using markRow and format rowns using formatRow + + // Stores an array that contains all the data useful for + $this->tablewidgetlib->setSession( + array( + TableWidgetLib::TABLE_UNIQUE_ID => $tableUniqueId, // table unique id + TableWidgetLib::SESSION_FIELDS => $this->tablewidgetlib->getExecutedQueryListFields(), // all the fields of the dataset + TableWidgetLib::SESSION_COLUMNS_ALIASES => $this->_columnsAliases, // all the fields aliases + TableWidgetLib::SESSION_ADDITIONAL_COLUMNS => $this->_additionalColumns, // additional columns + TableWidgetLib::SESSION_CHECKBOXES => $this->_checkboxes, // the name of the field used to build the checkboxes column + TableWidgetLib::SESSION_METADATA => $this->tablewidgetlib->getExecutedQueryMetaData(), // the metadata of the dataset + TableWidgetLib::SESSION_ROW_NUMBER => count($dataset->retval), // the number of loaded rows by this table + TableWidgetLib::SESSION_DATASET => $dataset->retval, // the entire dataset + TableWidgetLib::SESSION_DATASET_RELOAD => false, // if the dataset must be reloaded, not needed the first time + TableWidgetLib::SESSION_DATASET_REPRESENTATION => $this->_datasetRepresentation, // the choosen dataset representation + TableWidgetLib::SESSION_DATASET_REP_OPTIONS => $this->_datasetRepresentationOptions, // the choosen dataset representation options + TableWidgetLib::SESSION_DATASET_REP_FIELDS_DEFS => $this->_datasetRepFieldsDefs // the choosen dataset representation record fields definition + ) + ); + } + } + + // NOTE: must the latest operation to be performed in the session to be shure that is always present + // To be always stored in the session, otherwise is not possible to load data from Filters controller + $this->tablewidgetlib->setSessionElement(TableWidgetLib::REQUIRED_PERMISSIONS, $this->_requiredPermissions); + // Renew or set the session expiring time + $this->tablewidgetlib->setSessionElement(TableWidgetLib::SESSION_TIMEOUT, strtotime('+'.$this->_sessionTimeout.' minutes', time())); + } + + /** + * Calls the method _markRow and _formatRow to marks rows using markRow and format rowns using formatRow + * NOTE: this method operates directly on the retrieved dataset: parameter passed by reference + */ + private function _formatDataset(&$rawDataset) + { + if (hasData($rawDataset) && is_array($rawDataset->retval)) + { + // For each row of the data set + for ($rowCounter = 0; $rowCounter < count($rawDataset->retval); $rowCounter++) + { + // Calls the methods to mark and to format a row + // NOTE: keep this order! the markRow function given as parameter is supposing to work + // on a raw dataset, NOT on a formatted one + $rawDataset->retval[$rowCounter]->MARK_ROW_CLASS = $this->_markRow($rawDataset->retval[$rowCounter]); + $this->_formatRow($rawDataset->retval[$rowCounter]); + } + } + } + + /** + * Formats the columns of all the rows of the entire dataset + * - converts booleans into strings "true" and "false" + * - format dates using the format string defined in DEFAULT_DATE_FORMAT + * Calls the parameter formatRow if it was given and if it is a valid funtion + * NOTE: this method operates directly on the retrieved dataset: parameter passed by reference + */ + private function _formatRow(&$rawDatasetRow) + { + // For each column of the row + foreach ($rawDatasetRow as $columnName => $columnValue) + { + // Basic conversions + if (is_bool($columnValue)) + { + $rawDatasetRow->{$columnName} = ($columnValue === true ? 'true' : 'false'); + } + elseif (DateTime::createFromFormat('Y-m-d H:i:s', $columnValue) !== false) + { + $rawDatasetRow->{$columnName} = date(self::DEFAULT_DATE_FORMAT, strtotime($columnValue)); + } + } + + // If a valid function call the given formatRow + if ($this->_formatRow != null && is_callable($this->_formatRow)) + { + $formatRowFunction = $this->_formatRow; + $rawDatasetRow = $formatRowFunction($rawDatasetRow); + } + } + + /** + * Returns a string that contains a class name used to mark rows in the dataset table + * Calls the parameter markRow if it was given and if it is a valid funtion + */ + private function _markRow($rawDatasetRow) + { + // If a valid function call the given markRow + if ($this->_markRow != null && is_callable($this->_markRow)) + { + $markRowFunction = $this->_markRow; + $class = $markRowFunction($rawDatasetRow); + } + + return !isset($class) ? '' : $class; + } + + /** + * Utility method that retrieves the name of the columns present in a table JSON definition + */ + private function _getColumnsNames($columns) + { + $columnsNames = array(); + + foreach ($columns as $key => $obj) + { + if (isset($obj->name)) + { + $columnsNames[] = $obj->name; + } + } + + return $columnsNames; + } + + /** + * Loads a view using the given viewName and eventually other parameters + */ + private static function _loadView($viewName, $parameters = null) + { + $ci =& get_instance(); + $ci->load->view($viewName, $parameters); + } +} diff --git a/application/widgets/html/DropdownWidget.php b/application/widgets/html/DropdownWidget.php index ca3e30163..eba79900d 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,12 +102,12 @@ class DropdownWidget extends HTMLWidget ) { $tmpElements = array(); - + if (isError($elements)) { if (is_object($elements) && isset($elements->retval)) { - show_error($elements->retval); + show_error(getError($elements)); } else if (is_string($elements)) { @@ -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/cis/private/lehre/benotungstool/nachpruefungeintragen.php b/cis/private/lehre/benotungstool/nachpruefungeintragen.php index f1afe0420..0ad985e76 100644 --- a/cis/private/lehre/benotungstool/nachpruefungeintragen.php +++ b/cis/private/lehre/benotungstool/nachpruefungeintragen.php @@ -170,7 +170,9 @@ if (isset($_REQUEST["submit"]) && ($_REQUEST["student_uid"] != '') ) if($pr->getPruefungen($student_uid, "Termin1", $lvid, $stsem)) { if ($pr->result) + { $termin1 = 1; + } else { $lvnote = new lvgesamtnote(); @@ -183,6 +185,7 @@ if (isset($_REQUEST["submit"]) && ($_REQUEST["student_uid"] != '') ) else { $pr_note = 9; + $pr_punkte = ''; $benotungsdatum = $jetzt; } diff --git a/cis/private/lehre/fotoliste.pdf.php b/cis/private/lehre/fotoliste.pdf.php index 8565470c6..3fc04355f 100644 --- a/cis/private/lehre/fotoliste.pdf.php +++ b/cis/private/lehre/fotoliste.pdf.php @@ -1,308 +1,310 @@ - - * - * Description: This file creates a studentlist with students' profile fotos - * by a given studiengangs- and lehrveranstaltungs ID (and eventually a given lehreinheit ID). - * If fotos are locked by student, a dummy picture is inserted instead of the students foto. - * EXCEPTION: if user has admins or assitents rights, ALL students' fotos are iserted (even locked ones) - * - */ - -require_once('../../../config/cis.config.inc.php'); -require_once('../../../include/dokument_export.class.php'); -require_once('../../../include/lehrveranstaltung.class.php'); -require_once('../../../include/lehreinheit.class.php'); -require_once('../../../include/benutzerberechtigung.class.php'); -require_once('../../../include/studiensemester.class.php'); -require_once('../../../include/studiengang.class.php'); -require_once('../../../include/functions.inc.php'); -require_once('../../../include/erhalter.class.php'); -require_once('../../../include/datum.class.php'); - - -$doc = new dokument_export('fotoliste'); -$output = 'pdf'; -$show_all_fotos = false; - - -//check user access & $_GET vars -if (!$db = new basis_db()) - die('Es konnte keine Verbindung zum Server aufgebaut werden.'); - -$user = get_uid(); - - -if (isset($_GET['lvid']) && is_numeric($_GET['lvid'])) - $lvid = $_GET['lvid']; -else - die('Eine gueltige LvID muss uebergeben werden'); - -isset($_GET['stsem']) ? $studiensemester = $_GET['stsem'] : die('Ein Studiensemester muss uebergeben werden'); - -$lv = new lehrveranstaltung(); -$lv->load($lvid); - -$stg = new studiengang(); -$stg->load($lv->studiengang_kz); - -$berechtigung = new benutzerberechtigung(); -$berechtigung->getBerechtigungen($user); - -if (!$berechtigung->isBerechtigt('admin') && !$berechtigung->isBerechtigt('assistenz') && !$berechtigung->isBerechtigt('lehre', $lv->oe_kurzbz, 's') && !check_lektor_lehrveranstaltung($user, $lvid, $studiensemester)) - die('Sie muessen LektorIn der LV sein oder das Recht "ADMIN", "ASSISTENZ" oder "LEHRE" haben, um diese Seite aufrufen zu koennen'); - -if ($berechtigung->isBerechtigt('admin') || $berechtigung->isBerechtigt('assistenz')) - $show_all_fotos = true; - -if (isset($_GET['output']) && ($output = 'odt' || $output = 'doc')) - $output = $_GET['output']; -isset($_GET['stg_kz']) ? $studiengang = $_GET['stg_kz'] : $studiengang = NULL; -isset($_GET['lehreinheit_id']) ? $lehreinheit = $_GET['lehreinheit_id'] : $lehreinheit = NULL; - - -//**************************** overall lehrveranstaltungs data ******************************* -//load overall lehrveranstaltungs-data -$qry = "SELECT DISTINCT ON - (kuerzel, semester, verband, gruppe, gruppe_kurzbz) - UPPER(stg_typ || stg_kurzbz) as kuerzel, - lv_bezeichnung, - stg_bez, - semester, - verband, - gruppe, - gruppe_kurzbz, - stg_typ - FROM - campus.vw_lehreinheit - WHERE - lehrveranstaltung_id=" . $db->db_add_param($lvid, FHC_INTEGER) . " - AND - studiensemester_kurzbz=" . $db->db_add_param($studiensemester); -if ($lehreinheit != '') - $qry .= " AND lehreinheit_id=" . $db->db_add_param($lehreinheit, FHC_INTEGER); - -$gruppen_string = ''; -$gruppen_string_arr = array(); -$stg_typ = $stg->typ; -$stg_bezeichnung = $stg->bezeichnung; - -//structure overall lehrveranstaltungs data -if ($result = $db->db_query($qry)) { - while ($row = $db->db_fetch_object($result)) { - //lehrveranstaltung - $lv_bezeichnung = $row->lv_bezeichnung; - - //collect all gruppenkürzel - if ($row->gruppe_kurzbz == '') - $gruppen_string = trim($row->kuerzel . '-' . $row->semester . $row->verband . $row->gruppe); - else - $gruppen_string = $row->gruppe_kurzbz; - - $gruppen_string_arr[] = $gruppen_string; - } -} - -//concatinate distinct gruppenkürzel -$studiengruppe = implode(", ", array_unique($gruppen_string_arr)); - -//get studiengangstyp-bezeichnung -$qry = "SELECT - bezeichnung - FROM - public.tbl_studiengangstyp - WHERE - typ =" . $db->db_add_param($stg_typ); - -if ($result = $db->db_query($qry)) { - $row = $db->db_fetch_object($result); - $stg_typ_bezeichnung = $row->bezeichnung; -} - - -//add overall lehrveranstaltungs-data for XML -$data = array( - 'lehrveranstaltung' => $lv_bezeichnung, - 'studiengang' => $stg_bezeichnung, - 'studiengangs_typ' => $stg_typ_bezeichnung, - 'studiensemester' => $studiensemester, - 'studiengruppe' => $studiengruppe -); - - - -//**************************** students data ******************************* -//load students-data -$qry = 'SELECT DISTINCT ON - (nachname, vorname, person_id) - vorname, - nachname, - matrikelnr, - tbl_studentlehrverband.semester, - tbl_studentlehrverband.verband, - tbl_studentlehrverband.gruppe, - (SELECT - status_kurzbz - FROM - public.tbl_prestudentstatus - WHERE - prestudent_id=tbl_student.prestudent_id - ORDER BY - datum DESC, insertamum DESC, ext_id DESC LIMIT 1) as status, - tbl_studiengang.kurzbz, - tbl_studiengang.typ, - tbl_bisio.bisio_id, - tbl_bisio.von, - tbl_bisio.bis, - tbl_student.studiengang_kz AS stg_kz_student, - tbl_zeugnisnote.note, - tbl_mitarbeiter.mitarbeiter_uid, - tbl_person.matr_nr, - tbl_person.geschlecht, - tbl_person.foto, - tbl_person.foto_sperre - FROM - campus.vw_student_lehrveranstaltung - JOIN public.tbl_benutzer USING(uid) - JOIN public.tbl_person USING(person_id) - LEFT JOIN public.tbl_student ON(uid=student_uid) - LEFT JOIN public.tbl_studiengang ON(tbl_studiengang.studiengang_kz=tbl_student.studiengang_kz) - LEFT JOIN public.tbl_mitarbeiter ON(uid=mitarbeiter_uid) - LEFT JOIN public.tbl_studentlehrverband USING(student_uid,studiensemester_kurzbz) - LEFT JOIN lehre.tbl_zeugnisnote ON(vw_student_lehrveranstaltung.lehrveranstaltung_id=tbl_zeugnisnote.lehrveranstaltung_id - AND tbl_zeugnisnote.student_uid=tbl_student.student_uid - AND tbl_zeugnisnote.studiensemester_kurzbz=tbl_studentlehrverband.studiensemester_kurzbz) - LEFT JOIN bis.tbl_bisio ON(uid=tbl_bisio.student_uid) - WHERE - vw_student_lehrveranstaltung.lehrveranstaltung_id=' . $db->db_add_param($lvid, FHC_INTEGER) . ' AND - vw_student_lehrveranstaltung.studiensemester_kurzbz=' . $db->db_add_param($studiensemester); - -if ($lehreinheit != '') - $qry .= ' AND vw_student_lehrveranstaltung.lehreinheit_id=' . $db->db_add_param($lehreinheit, FHC_INTEGER); - -$qry .= ' ORDER BY nachname, vorname, person_id, tbl_bisio.bis DESC'; - -$stsem_obj = new studiensemester(); -$stsem_obj->load($studiensemester); -$stsemdatumvon = $stsem_obj->start; -$stsemdatumbis = $stsem_obj->ende; - -$erhalter = new erhalter(); -$erhalter->getAll(); - -$a_o_kz = '9' . sprintf("%03s", $erhalter->result[0]->erhalter_kz); //Stg_Kz AO-Studierende auslesen (9005 fuer FHTW) -$anzahl_studierende = 0; -$datum = new datum(); -$zusatz = ''; - -//structure students data -if ($result = $db->db_query($qry)) { - while ($row = $db->db_fetch_object($result)) { - if ($row->status != 'Abbrecher' && $row->status != 'Unterbrecher') { - $anzahl_studierende++; - - if ($row->status == 'Incoming') //Incoming - $zusatz = '(i)'; - else - $zusatz = ''; - - if ($row->bisio_id != '' && $row->status != 'Incoming' && ($row->bis > $stsemdatumvon || $row->bis == '') && $row->von < $stsemdatumbis) //Outgoing - $zusatz .= '(o)(ab ' . $datum->formatDatum($row->von, 'd.m.Y') . ')'; - - if ($row->note == 6) //angerechnet - $zusatz .= '(ar)'; - - if ($row->mitarbeiter_uid != '') //mitarbeiter - $zusatz .= '(ma)'; - - if ($row->stg_kz_student == $a_o_kz) //Außerordentliche Studierende - $zusatz .= '(a.o.)'; - - //allow admin and assistenz to see ALL fotos (even if locked by user) - if ($show_all_fotos) - $row->foto_sperre = 'f'; - - //create foto (if not locked by student OR if fotolist is created by admin or assistenz) - $foto_url = ''; - - if ($row->foto_sperre == 'f' && $row->foto != '') { - $foto_src = $row->foto; - $foto_url = sys_get_temp_dir() . '/foto' . trim($row->matrikelnr) . '.jpg'; - $foto_url_arr[] = $foto_url; - - //create writeable file - if (!$foto = fopen($foto_url, 'w')) - die("Das Bild konnte nicht erstellt werden"); - //add foto base64-code - if (!fwrite($foto, base64_decode($foto_src))) - { - die("Das Bild konnte nicht erstellt werden"); - } - - //add foto to document - $doc->addImage($foto_url, trim($row->matrikelnr) . '.jpg', 'image/jpg'); - } - elseif ($row->foto_sperre == 't') - { - $foto_url = 'gesperrt'; - } - - //create studiengruppe - $student_studiengruppe = strtoupper($row->typ.$row->kurzbz.'-'.$row->semester); - - //add studierenden data for XML - $data[] = array('studierende' => array( - 'vorname' => $row->vorname, - 'nachname' => mb_strtoupper($row->nachname, 'UTF-8'), - 'personenkennzeichen' => trim($row->matrikelnr), - 'geschlecht' => $row->geschlecht, - 'foto_gesperrt' => $row->foto_sperre, // f/t - 'foto_url' => $foto_url, - 'studiengruppe' => $student_studiengruppe, - 'verband' => trim($row->verband), - 'gruppe' => trim($row->gruppe), - 'zusatz' => $zusatz - )); - } - } - //Anzahl Studierende in Array $data (an erster Stelle) einfuegen - $data = array_reverse($data, true); - $data['anzahl_studierende'] = $anzahl_studierende; - $data = array_reverse($data, true); -} - -//add data to fotoliste.xsl -$doc->addDataArray($data, 'fotoliste'); - -//set doc name -$doc->setFilename('Fotoliste_'.$stg_bezeichnung.'_'.$studiensemester.'_'.$lv_bezeichnung); - -//create doc in format required -if (!$doc->create($output)) - die($doc->errormsg); - -//download doc -$doc->output(); - -//unlink doc from tmp-folder -$doc->close(); - -//unlink fotos from tmp-folder -foreach ($foto_url_arr as $foto_url) - unlink($foto_url); + + * + * Description: This file creates a studentlist with students' profile fotos + * by a given studiengangs- and lehrveranstaltungs ID (and eventually a given lehreinheit ID). + * If fotos are locked by student, a dummy picture is inserted instead of the students foto. + * EXCEPTION: if user has admins or assitents rights, ALL students' fotos are iserted (even locked ones) + * + */ + +require_once('../../../config/cis.config.inc.php'); +require_once('../../../include/dokument_export.class.php'); +require_once('../../../include/lehrveranstaltung.class.php'); +require_once('../../../include/lehreinheit.class.php'); +require_once('../../../include/benutzerberechtigung.class.php'); +require_once('../../../include/studiensemester.class.php'); +require_once('../../../include/studiengang.class.php'); +require_once('../../../include/functions.inc.php'); +require_once('../../../include/erhalter.class.php'); +require_once('../../../include/datum.class.php'); + + +$doc = new dokument_export('fotoliste'); +$output = 'pdf'; +$show_all_fotos = false; + + +//check user access & $_GET vars +if (!$db = new basis_db()) + die('Es konnte keine Verbindung zum Server aufgebaut werden.'); + +$user = get_uid(); + + +if (isset($_GET['lvid']) && is_numeric($_GET['lvid'])) + $lvid = $_GET['lvid']; +else + die('Eine gueltige LvID muss uebergeben werden'); + +isset($_GET['stsem']) ? $studiensemester = $_GET['stsem'] : die('Ein Studiensemester muss uebergeben werden'); + +$lv = new lehrveranstaltung(); +$lv->load($lvid); + +$stg = new studiengang(); +$stg->load($lv->studiengang_kz); + +$berechtigung = new benutzerberechtigung(); +$berechtigung->getBerechtigungen($user); + +if (!$berechtigung->isBerechtigt('admin') && !$berechtigung->isBerechtigt('assistenz') && !$berechtigung->isBerechtigt('lehre', $lv->oe_kurzbz, 's') && !check_lektor_lehrveranstaltung($user, $lvid, $studiensemester)) + die('Sie muessen LektorIn der LV sein oder das Recht "ADMIN", "ASSISTENZ" oder "LEHRE" haben, um diese Seite aufrufen zu koennen'); + +if ($berechtigung->isBerechtigt('admin') || $berechtigung->isBerechtigt('assistenz')) + $show_all_fotos = true; + +if (isset($_GET['output']) && ($output = 'odt' || $output = 'doc')) + $output = $_GET['output']; +isset($_GET['stg_kz']) ? $studiengang = $_GET['stg_kz'] : $studiengang = NULL; +isset($_GET['lehreinheit_id']) ? $lehreinheit = $_GET['lehreinheit_id'] : $lehreinheit = NULL; + + +//**************************** overall lehrveranstaltungs data ******************************* +//load overall lehrveranstaltungs-data +$qry = "SELECT DISTINCT ON + (kuerzel, semester, verband, gruppe, gruppe_kurzbz) + UPPER(stg_typ || stg_kurzbz) as kuerzel, + lv_bezeichnung, + stg_bez, + semester, + verband, + gruppe, + gruppe_kurzbz, + stg_typ + FROM + campus.vw_lehreinheit + WHERE + lehrveranstaltung_id=" . $db->db_add_param($lvid, FHC_INTEGER) . " + AND + studiensemester_kurzbz=" . $db->db_add_param($studiensemester); +if ($lehreinheit != '') + $qry .= " AND lehreinheit_id=" . $db->db_add_param($lehreinheit, FHC_INTEGER); + +$gruppen_string = ''; +$gruppen_string_arr = array(); +$stg_typ = $stg->typ; +$stg_bezeichnung = $stg->bezeichnung; + +//structure overall lehrveranstaltungs data +if ($result = $db->db_query($qry)) { + while ($row = $db->db_fetch_object($result)) { + //lehrveranstaltung + $lv_bezeichnung = $row->lv_bezeichnung; + + //collect all gruppenkürzel + if ($row->gruppe_kurzbz == '') + $gruppen_string = trim($row->kuerzel . '-' . $row->semester . $row->verband . $row->gruppe); + else + $gruppen_string = $row->gruppe_kurzbz; + + $gruppen_string_arr[] = $gruppen_string; + } +} + +//concatinate distinct gruppenkürzel +$studiengruppe = implode(", ", array_unique($gruppen_string_arr)); + +//get studiengangstyp-bezeichnung +$qry = "SELECT + bezeichnung + FROM + public.tbl_studiengangstyp + WHERE + typ =" . $db->db_add_param($stg_typ); + +if ($result = $db->db_query($qry)) { + $row = $db->db_fetch_object($result); + $stg_typ_bezeichnung = $row->bezeichnung; +} + + +//add overall lehrveranstaltungs-data for XML +$data = array( + 'lehrveranstaltung' => $lv_bezeichnung, + 'studiengang' => $stg_bezeichnung, + 'studiengangs_typ' => $stg_typ_bezeichnung, + 'studiensemester' => $studiensemester, + 'studiengruppe' => $studiengruppe +); + + + +//**************************** students data ******************************* +//load students-data +$qry = 'SELECT DISTINCT ON + (nachname, vorname, person_id) + vorname, + nachname, + matrikelnr, + tbl_studentlehrverband.semester, + tbl_studentlehrverband.verband, + tbl_studentlehrverband.gruppe, + (SELECT + status_kurzbz + FROM + public.tbl_prestudentstatus + WHERE + prestudent_id=tbl_student.prestudent_id + ORDER BY + datum DESC, insertamum DESC, ext_id DESC LIMIT 1) as status, + tbl_studiengang.kurzbz, + tbl_studiengang.typ, + tbl_bisio.bisio_id, + tbl_bisio.von, + tbl_bisio.bis, + tbl_student.studiengang_kz AS stg_kz_student, + tbl_zeugnisnote.note, + tbl_mitarbeiter.mitarbeiter_uid, + tbl_person.person_id, + tbl_person.matr_nr, + tbl_person.geschlecht, + tbl_person.foto, + tbl_person.foto_sperre + FROM + campus.vw_student_lehrveranstaltung + JOIN public.tbl_benutzer USING(uid) + JOIN public.tbl_person USING(person_id) + LEFT JOIN public.tbl_student ON(uid=student_uid) + LEFT JOIN public.tbl_studiengang ON(tbl_studiengang.studiengang_kz=tbl_student.studiengang_kz) + LEFT JOIN public.tbl_mitarbeiter ON(uid=mitarbeiter_uid) + LEFT JOIN public.tbl_studentlehrverband USING(student_uid,studiensemester_kurzbz) + LEFT JOIN lehre.tbl_zeugnisnote ON(vw_student_lehrveranstaltung.lehrveranstaltung_id=tbl_zeugnisnote.lehrveranstaltung_id + AND tbl_zeugnisnote.student_uid=tbl_student.student_uid + AND tbl_zeugnisnote.studiensemester_kurzbz=tbl_studentlehrverband.studiensemester_kurzbz) + LEFT JOIN bis.tbl_bisio ON(uid=tbl_bisio.student_uid) + WHERE + vw_student_lehrveranstaltung.lehrveranstaltung_id=' . $db->db_add_param($lvid, FHC_INTEGER) . ' AND + vw_student_lehrveranstaltung.studiensemester_kurzbz=' . $db->db_add_param($studiensemester); + +if ($lehreinheit != '') + $qry .= ' AND vw_student_lehrveranstaltung.lehreinheit_id=' . $db->db_add_param($lehreinheit, FHC_INTEGER); + +$qry .= ' ORDER BY nachname, vorname, person_id, tbl_bisio.bis DESC'; + +$stsem_obj = new studiensemester(); +$stsem_obj->load($studiensemester); +$stsemdatumvon = $stsem_obj->start; +$stsemdatumbis = $stsem_obj->ende; + +$erhalter = new erhalter(); +$erhalter->getAll(); + +$a_o_kz = '9' . sprintf("%03s", $erhalter->result[0]->erhalter_kz); //Stg_Kz AO-Studierende auslesen (9005 fuer FHTW) +$anzahl_studierende = 0; +$datum = new datum(); +$zusatz = ''; +$foto_url_arr = array(); + +//structure students data +if ($result = $db->db_query($qry)) { + while ($row = $db->db_fetch_object($result)) { + if ($row->status != 'Abbrecher' && $row->status != 'Unterbrecher') { + $anzahl_studierende++; + + if ($row->status == 'Incoming') //Incoming + $zusatz = '(i)'; + else + $zusatz = ''; + + if ($row->bisio_id != '' && $row->status != 'Incoming' && ($row->bis > $stsemdatumvon || $row->bis == '') && $row->von < $stsemdatumbis) //Outgoing + $zusatz .= '(o)(ab ' . $datum->formatDatum($row->von, 'd.m.Y') . ')'; + + if ($row->note == 6) //angerechnet + $zusatz .= '(ar)'; + + if ($row->mitarbeiter_uid != '') //mitarbeiter + $zusatz .= '(ma)'; + + if ($row->stg_kz_student == $a_o_kz) //Außerordentliche Studierende + $zusatz .= '(a.o.)'; + + //allow admin and assistenz to see ALL fotos (even if locked by user) + if ($show_all_fotos) + $row->foto_sperre = 'f'; + + //create foto (if not locked by student OR if fotolist is created by admin or assistenz) + $foto_url = ''; + + if ($row->foto_sperre == 'f' && $row->foto != '') { + $foto_src = $row->foto; + $foto_url = sys_get_temp_dir() . '/foto' . trim($row->person_id) . '.jpg'; + $foto_url_arr[] = $foto_url; + + //create writeable file + if (!$foto = fopen($foto_url, 'w')) + die("Das Bild konnte nicht erstellt werden"); + //add foto base64-code + if (!fwrite($foto, base64_decode($foto_src))) + { + die("Das Bild konnte nicht erstellt werden"); + } + + //add foto to document + $doc->addImage($foto_url, trim($row->person_id) . '.jpg', 'image/jpg'); + } + elseif ($row->foto_sperre == 't') + { + $foto_url = 'gesperrt'; + } + + //create studiengruppe + $student_studiengruppe = strtoupper($row->typ.$row->kurzbz.'-'.$row->semester); + + //add studierenden data for XML + $data[] = array('studierende' => array( + 'vorname' => $row->vorname, + 'nachname' => mb_strtoupper($row->nachname, 'UTF-8'), + 'personenkennzeichen' => trim($row->matrikelnr), + 'geschlecht' => $row->geschlecht, + 'foto_gesperrt' => $row->foto_sperre, // f/t + 'foto_url' => $foto_url, + 'studiengruppe' => $student_studiengruppe, + 'verband' => trim($row->verband), + 'gruppe' => trim($row->gruppe), + 'zusatz' => $zusatz + )); + } + } + //Anzahl Studierende in Array $data (an erster Stelle) einfuegen + $data = array_reverse($data, true); + $data['anzahl_studierende'] = $anzahl_studierende; + $data = array_reverse($data, true); +} + +//add data to fotoliste.xsl +$doc->addDataArray($data, 'fotoliste'); + +//set doc name +$doc->setFilename('Fotoliste_'.$stg_bezeichnung.'_'.$studiensemester.'_'.$lv_bezeichnung); + +//create doc in format required +if (!$doc->create($output)) + die($doc->errormsg); + +//download doc +$doc->output(); + +//unlink doc from tmp-folder +$doc->close(); + +//unlink fotos from tmp-folder +foreach ($foto_url_arr as $foto_url) + unlink($foto_url); diff --git a/cis/private/lehre/pruefung/pruefung.js.php b/cis/private/lehre/pruefung/pruefung.js.php index 9ef84e889..b207c94e5 100644 --- a/cis/private/lehre/pruefung/pruefung.js.php +++ b/cis/private/lehre/pruefung/pruefung.js.php @@ -575,8 +575,8 @@ function saveAnmeldung(lehrveranstaltung_id, termin_id) studienverpflichtung_id = $("#studienverpflichtung option:selected").val(); var studiengang_kz = null; - if($('#select_studiengang').length) - studiengang_kz = $('#select_studiengang option:selected').val(); + if($('#prestudent_studiengang').length) + studiengang_kz = $('#prestudent_studiengang option:selected').val(); $.ajax({ dataType: 'json', @@ -758,9 +758,10 @@ function convertDateTime(string, type) * Lädt die Anmeldungen zu einer Prüfung * @param {type} pruefungstermin_id ID des Prüfungstermins * @param {type} lehrveranstaltung_id ID der Lehrveranstaltung + * @param saveReihungAfterShow speichert Reihung neu wenn true * @returns {undefined} */ -function showAnmeldungen(pruefungstermin_id, lehrveranstaltung_id) +function showAnmeldungen(pruefungstermin_id, lehrveranstaltung_id, saveReihungAfterShow = false) { $("#kommentar").empty(); $("#kommentarSpeichernButton").empty(); @@ -778,6 +779,9 @@ function showAnmeldungen(pruefungstermin_id, lehrveranstaltung_id) writeAnmeldungen(data); $("#sortable").sortable(); $("#sortable").disableSelection(); + + if(saveReihungAfterShow) + saveReihung(pruefungstermin_id, lehrveranstaltung_id); } }); } @@ -806,7 +810,8 @@ function writeAnmeldungen(data) { case 'angemeldet': liste += "
  • "+vorname+" "+nachname+""; - liste += "
    "+count+"
    ' onclick='anmeldungBestaetigen(\""+d.pruefungsanmeldung_id+"\", \""+terminId+"\", \""+lehrveranstaltung_id+"\");'>
    "; + liste += "
    "+count+"
    ' onclick='anmeldungBestaetigen(\""+d.pruefungsanmeldung_id+"\", \""+terminId+"\", \""+lehrveranstaltung_id+"\");'>"; + liste += "
    "; if(d.wuensche !== null) { liste += ""; @@ -887,28 +892,31 @@ function saveReihung(terminId, lehrveranstaltung_id) anmeldung.uid = v.id; reihung.push(anmeldung); }); - $.ajax({ - dataType: 'json', - url: "./pruefungsanmeldung.json.php", - type: "POST", - data: { - method: "saveReihung", - reihung: reihung - }, - error: loadError, - success: function(data){ - if(data.error === 'false' && data.result === true) - { - messageBox("message", "t('pruefung/reihunghErfolgreichGeaendert'); ?>", "green", "highlight", 1000); - } - else - { - messageBox("message", data.errormsg, "red", "highlight", 1000); - } - showAnmeldungen(terminId, lehrveranstaltung_id); - } - }); + if (reihung.length > 0) { + $.ajax({ + dataType: 'json', + url: "./pruefungsanmeldung.json.php", + type: "POST", + data: { + method: "saveReihung", + reihung: reihung + }, + error: loadError, + success: function(data){ + if(data.error === 'false' && data.result === true) + { + messageBox("message", "t('pruefung/reihunghErfolgreichGeaendert'); ?>", "green", "highlight", 1000); + } + else + { + messageBox("message", data.errormsg, "red", "highlight", 1000); + } + + showAnmeldungen(terminId, lehrveranstaltung_id); + } + }); + } } /** @@ -945,6 +953,43 @@ function anmeldungBestaetigen(pruefungsanmeldung_id, termin_id, lehrveranstaltun }); } +/** + * Löscht eine Prüfungsanmeldung + * @param {type} pruefungsanmeldung_id ID der Prüfungsanmeldung + * @param {type} termin_id ID des Prüfungstermines + * @param {type} lehrveranstaltung_id ID der Lehrveranstaltung + * @returns {undefined} + */ +function anmeldungLoeschen(pruefungsanmeldung_id, termin_id, lehrveranstaltung_id) +{ + if (!confirm("Möchten Sie die Anmeldung wirklich löschen?")) + return undefined; + + $.ajax({ + dataType: 'json', + url: "./pruefungsanmeldung.json.php", + type: "POST", + data: { + method: "anmeldungLoeschen", + pruefungsanmeldung_id: pruefungsanmeldung_id + }, + error: loadError, + success: function(data){ + if(data.error === 'false' && data.result === true) + { + if(termin_id !== 'undefined' && lehrveranstaltung_id !== 'undefined') + { + showAnmeldungen(termin_id, lehrveranstaltung_id, true); + } + } + else + { + messageBox("message", data.errormsg, "red", "highlight", 1000); + } + } + }); +} + /** * Ändert den Status aller Anmeldungen eines Termins auf "bestätigt" * @param {type} termin_id ID des Prüfungstermines @@ -1174,7 +1219,8 @@ function loadStudiensemester() url: "./pruefungstermin.json.php", type: "POST", data: { - method: "loadStudiensemester" + method: "loadStudiensemester", + prevSemester: 5 }, error: loadError, success: function(data){ diff --git a/cis/private/lehre/pruefung/pruefungsanmeldung.json.php b/cis/private/lehre/pruefung/pruefungsanmeldung.json.php index b4eba2f6d..ce7479cf0 100644 --- a/cis/private/lehre/pruefung/pruefungsanmeldung.json.php +++ b/cis/private/lehre/pruefung/pruefungsanmeldung.json.php @@ -97,6 +97,9 @@ switch($method) case 'anmeldungBestaetigen': $data = anmeldungBestaetigen($uid); break; + case 'anmeldungLoeschen': + $data = anmeldungLoeschen(); + break; case 'alleBestaetigen': $data = alleBestaetigen($uid); break; @@ -629,24 +632,11 @@ function saveAnmeldung($aktStudiensemester = null, $uid = null) { foreach ($prestudenten as $ps) { - if($ps->studiengang_kz === $studiengang_kz) + if ($ps->getLaststatus($ps->prestudent_id, $stdsem)) { - if ($ps->getLaststatus($ps->prestudent_id, $stdsem)) + if (($ps->status_kurzbz == "Student") || ($ps->status_kurzbz == "Unterbrecher")) { - if (($ps->status_kurzbz == "Student") || ($ps->status_kurzbz == "Unterbrecher")) - { - $prestudent_id = $ps->prestudent_id; - } - else - { - if ($ps->getLaststatus($ps->prestudent_id, $stdsem_lv_besuch)) - { - if (($ps->status_kurzbz == "Student") || ($ps->status_kurzbz == "Unterbrecher")) - { - $prestudent_id = $ps->prestudent_id; - } - } - } + $prestudent_id = $ps->prestudent_id; } else { @@ -659,6 +649,16 @@ function saveAnmeldung($aktStudiensemester = null, $uid = null) } } } + else + { + if ($ps->getLaststatus($ps->prestudent_id, $stdsem_lv_besuch)) + { + if (($ps->status_kurzbz == "Student") || ($ps->status_kurzbz == "Unterbrecher")) + { + $prestudent_id = $ps->prestudent_id; + } + } + } } } else @@ -1066,6 +1066,30 @@ function anmeldungBestaetigen($uid) return $data; } +/** + * Löscht eine Prüfungsanmeldung + * @return Array + */ +function anmeldungLoeschen() +{ + $pruefungsanmeldung_id = $_REQUEST["pruefungsanmeldung_id"]; + $anmeldung = new pruefungsanmeldung(); + + if($anmeldung->delete($pruefungsanmeldung_id)) + { + $data['result']=true; + $data['error']='false'; + $data['errormsg']=''; + } + else + { + $data['error']='true'; + $data['errormsg']=$anmeldung->errormsg; + } + + return $data; +} + /** * Lädt alle Studiengänge * @return Array @@ -1177,7 +1201,12 @@ function getAllFreieRaeume($terminId) $teilnehmer = $teilnehmer !== false ? $teilnehmer : 0; $pruefungstermin->getAll($pruefungstermin->von, $pruefungstermin->bis, TRUE); - if($ort->search($datum_von[0], $datum_von[1], $datum_bis[1], null, $teilnehmer, true)) + if(defined('CIS_PRUEFUNGSANMELDUNG_ERLAUBE_TERMINKOLLISION') && CIS_PRUEFUNGSANMELDUNG_ERLAUBE_TERMINKOLLISION) + $ortSuccess = $ort->getOrte(true, null, true); + else + $ortSuccess = $ort->search($datum_von[0], $datum_von[1], $datum_bis[1], null, $teilnehmer, true); + + if($ortSuccess) { foreach($pruefungstermin->result as $termin) { diff --git a/cis/private/lehre/pruefung/pruefungsanmeldungen_verwalten.php b/cis/private/lehre/pruefung/pruefungsanmeldungen_verwalten.php index 21de64fcc..22bca21cc 100644 --- a/cis/private/lehre/pruefung/pruefungsanmeldungen_verwalten.php +++ b/cis/private/lehre/pruefung/pruefungsanmeldungen_verwalten.php @@ -252,7 +252,7 @@ if (empty($pruefung->result) && !$rechte->isBerechtigt('lehre/pruefungsanmeldung '; $aktuellesSemester = $studiensemester->getaktorNext(); - $studiensemester->getAll(); + $studiensemester->getPlusMinus(null, 5); foreach($studiensemester->studiensemester as $sem) { /*@var $sem studiensemester */ diff --git a/cis/private/lehre/pruefung/pruefungstermin.json.php b/cis/private/lehre/pruefung/pruefungstermin.json.php index 36ca332bd..978c3e69e 100644 --- a/cis/private/lehre/pruefung/pruefungstermin.json.php +++ b/cis/private/lehre/pruefung/pruefungstermin.json.php @@ -61,7 +61,8 @@ switch($method) case 'loadStudiensemester': $studiensemester = new studiensemester(); $aktStudiensemester = $studiensemester->getaktorNext(); - $data = loadStudiensemester($aktStudiensemester); + $prevSemester = empty($_POST["prevSemester"]) ? 0 : $_POST["prevSemester"]; + $data = loadStudiensemester($aktStudiensemester, $prevSemester); break; case 'getPruefungsfensterByStudiensemester': $studiensemester = new studiensemester(); @@ -223,12 +224,15 @@ function loadPruefungstypen($abschluss) /** * Lädt alle Studiensemester aus der Datenbank * @param String $aktStudiensemester das Aktuelle Studiensemester + * @param int $prevSemester wie viele vergangene Semester sollen geladen werden * @return Array */ -function loadStudiensemester($aktStudiensemester = null) +function loadStudiensemester($aktStudiensemester = null, $prevSemester = 0) { $studiensemester = new studiensemester(); - if($studiensemester->getAll()) + $prevSemester == 0 ? $studiensemester->getAll() : $studiensemester->getPlusMinus(null, $prevSemester); + + if(!empty($studiensemester->studiensemester)) { $data['result']=$studiensemester->studiensemester; if(!is_null($aktStudiensemester)) diff --git a/cis/private/lvplan/stpl_detail.php b/cis/private/lvplan/stpl_detail.php index 3612a15db..87d4a70ff 100644 --- a/cis/private/lvplan/stpl_detail.php +++ b/cis/private/lvplan/stpl_detail.php @@ -156,9 +156,12 @@ $num_rows_stpl = $db->db_num_rows($erg_stpl); $sql_query=" SELECT vw_reservierung.*, vw_mitarbeiter.titelpre, vw_mitarbeiter.titelpost, - vw_mitarbeiter.vorname,vw_mitarbeiter.nachname + vw_mitarbeiter.vorname, vw_mitarbeiter.nachname, reserviert_von.titelpre AS titelpre_reserviertvon, reserviert_von.titelpost AS titelpost_reserviertvon, + reserviert_von.vorname AS vorname_reserviertvon, reserviert_von.nachname AS nachname_reserviertvon FROM - campus.vw_reservierung, campus.vw_mitarbeiter + campus.vw_reservierung + JOIN campus.vw_mitarbeiter ON vw_reservierung.uid=vw_mitarbeiter.uid + LEFT JOIN campus.vw_mitarbeiter reserviert_von ON vw_reservierung.insertvon=reserviert_von.uid WHERE datum=".$db->db_add_param($datum)." AND stunde=".$db->db_add_param($stunde); @@ -167,7 +170,6 @@ if (isset($ort_kurzbz) && $type=='ort') $sql_query.=" AND vw_reservierung.ort_kurzbz=".$db->db_add_param($ort_kurzbz); if ($type=='lektor') $sql_query.=" AND vw_reservierung.uid=".$db->db_add_param($pers_uid); -$sql_query.=" AND vw_reservierung.uid=vw_mitarbeiter.uid"; if ($type=='verband' || $type=='student') { $sql_query.=" AND studiengang_kz=".$db->db_add_param($stg_kz)." @@ -271,7 +273,7 @@ if ($num_rows_repl>0) { echo '

    '.$p->t('lvplan/reservierungen').'

    '; echo ''; - echo ''; + echo ''; $i=0; $ort = new ort(); while($row = $db->db_fetch_object($erg_repl)) @@ -285,13 +287,20 @@ if ($num_rows_repl>0) $pers_nachname=$row->nachname; $pers_email=$row->uid.'@'.DOMAIN; $beschreibung=$row->beschreibung; + $reserviertvon=$row->insertvon; + $titelpre_reserviertvon=$row->titelpre_reserviertvon; + $titelpost_reserviertvon=$row->titelpost_reserviertvon; + $pers_vorname_reserviertvon=$row->vorname_reserviertvon; + $pers_nachname_reserviertvon=$row->nachname_reserviertvon; + $ort->load($ortkurzbz); echo ''; - echo ''; + echo ''; echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; } echo '
    '.$p->t('global/titel').''.$p->t('lvplan/ort').''.$p->t('global/person').''.$p->t('global/beschreibung').'
    '.$p->t('global/titel').''.$p->t('lvplan/ort').''.$p->t('global/person').''.$p->t('global/beschreibung').''.$p->t('lvplan/reserviertVon').'
    '.$db->convert_html_chars($titel).''.$db->convert_html_chars($titel).''.(!empty($ortkurzbz)?($ort->content_id!=''?''.$db->convert_html_chars($ortkurzbz).'':$db->convert_html_chars($ortkurzbz)):$db->convert_html_chars($ortkurzbz)).''.$db->convert_html_chars($titelpre.' '.$pers_vorname.' '.$pers_nachname.' '.$titelpost).''.$db->convert_html_chars($beschreibung).'
    '.$db->convert_html_chars($titelpre.' '.$pers_vorname.' '.$pers_nachname.' '.$titelpost).''.$db->convert_html_chars($beschreibung).''.$db->convert_html_chars($titelpre_reserviertvon.' '.$pers_vorname_reserviertvon.' '.$pers_nachname_reserviertvon.' '.$titelpost_reserviertvon).'

    '; } diff --git a/cis/private/lvplan/stpl_reserve_list.php b/cis/private/lvplan/stpl_reserve_list.php index 5e6e1fa85..21328050b 100644 --- a/cis/private/lvplan/stpl_reserve_list.php +++ b/cis/private/lvplan/stpl_reserve_list.php @@ -88,9 +88,15 @@ if(!$rechte->isBerechtigt('lehre/reservierung:begrenzt', null, 'suid')) $datum = date("Y-m-d",$datum); //EIGENE - $sql_query="SELECT * FROM campus.vw_reservierung + $sql_query="SELECT vw_reservierung.*, vw_mitarbeiter.titelpre, vw_mitarbeiter.titelpost, + vw_mitarbeiter.vorname, vw_mitarbeiter.nachname, reserviert_von.titelpre AS titelpre_reserviertvon, + reserviert_von.titelpost AS titelpost_reserviertvon, reserviert_von.vorname AS vorname_reserviertvon, + reserviert_von.nachname AS nachname_reserviertvon + FROM campus.vw_reservierung + JOIN campus.vw_mitarbeiter ON vw_reservierung.uid=vw_mitarbeiter.uid + LEFT JOIN campus.vw_mitarbeiter reserviert_von ON vw_reservierung.insertvon=reserviert_von.uid WHERE datum>=".$db->db_add_param($datum)." - AND (uid=".$db->db_add_param($uid)." OR insertvon=".$db->db_add_param($uid).") + AND (vw_reservierung.uid=".$db->db_add_param($uid)." OR vw_reservierung.insertvon=".$db->db_add_param($uid).") ORDER BY datum, titel, ort_kurzbz, stunde"; if (!$erg_res=$db->db_query($sql_query)) @@ -108,8 +114,9 @@ if(!$rechte->isBerechtigt('lehre/reservierung:begrenzt', null, 'suid')) '.$p->t('global/titel').' '.$p->t('global/stunde').' '.$p->t('lvplan/raum').' - '.$p->t('global/uid').' + '.$p->t('global/person').' '.$p->t('global/beschreibung').' + '.$p->t('lvplan/reserviertVon').' '.$p->t('global/aktion').' '; for ($i=0; $i<$num_rows_res; $i++) @@ -124,6 +131,14 @@ if(!$rechte->isBerechtigt('lehre/reservierung:begrenzt', null, 'suid')) $beschreibung=$db->db_result($erg_res,$i,"beschreibung"); $insertamum=$db->db_result($erg_res,$i,"insertamum"); $insertvon=$db->db_result($erg_res,$i,"insertvon"); + $titelpre=$db->db_result($erg_res,$i,"titelpre"); + $titelpost=$db->db_result($erg_res,$i,"titelpost"); + $pers_vorname=$db->db_result($erg_res,$i,"vorname"); + $pers_nachname=$db->db_result($erg_res,$i,"nachname"); + $titelpre_reserviertvon=$db->db_result($erg_res,$i,"titelpre_reserviertvon"); + $titelpost_reserviertvon=$db->db_result($erg_res,$i,"titelpost_reserviertvon"); + $pers_vorname_reserviertvon=$db->db_result($erg_res,$i,"vorname_reserviertvon"); + $pers_nachname_reserviertvon=$db->db_result($erg_res,$i,"nachname_reserviertvon"); $datum1 = $datum_obj->formatDatum($datum1, 'd.m.Y'); if($insertamum!='') $insertamum = $datum_obj->formatDatum($insertamum, 'd.m.Y H:i:s'); @@ -132,8 +147,9 @@ if(!$rechte->isBerechtigt('lehre/reservierung:begrenzt', null, 'suid')) echo ''.$db->convert_html_chars($titel).''; echo ''.$db->convert_html_chars($stunde).''; echo ''.$db->convert_html_chars($ort_kurzbz).''; - echo ''.$db->convert_html_chars($pers_uid).''; + echo ''.$db->convert_html_chars($titelpre.' '.$pers_vorname.' '.$pers_nachname.' '.$titelpost).''; echo ''.$db->convert_html_chars($beschreibung).' '; + echo ''.$db->convert_html_chars($titelpre_reserviertvon.' '.$pers_vorname_reserviertvon.' '.$pers_nachname_reserviertvon.' '.$titelpost_reserviertvon).''; $z=$i-1; if (($pers_uid==$uid || $insertvon==$uid) && $rechte->isBerechtigt('lehre/reservierung:begrenzt', null, 'suid')) echo 'Delete'; diff --git a/cis/private/tools/zeitaufzeichnung.php b/cis/private/tools/zeitaufzeichnung.php index cd40391e1..2d96380f6 100644 --- a/cis/private/tools/zeitaufzeichnung.php +++ b/cis/private/tools/zeitaufzeichnung.php @@ -55,6 +55,7 @@ if (!$db = new basis_db()) $user = get_uid(); +$passuid = false; $rechte = new benutzerberechtigung(); $rechte->getBerechtigungen($user); @@ -67,6 +68,7 @@ if(isset($_GET['uid'])) $user = $_GET['uid']; $rechte = new benutzerberechtigung(); $rechte->getBerechtigungen($user); + $passuid = true; } else { @@ -1021,7 +1023,7 @@ if($projekt->getProjekteMitarbeiter($user, true)) CSV Export"; if($anzprojekte > 0) - echo " | ".$p->t("zeitaufzeichnung/projektexport").""; + echo " | ".$p->t("zeitaufzeichnung/projektexport").""; echo " "; if ($p->t("dms_link/handbuchZeitaufzeichnung")!='') @@ -1054,19 +1056,21 @@ if($projekt->getProjekteMitarbeiter($user, true)) echo '
    '; echo ''.$p->t('zeitaufzeichnung/projektexport').''; echo ''.$p->t('zeitaufzeichnung/monat').' '; echo ''.$p->t('zeitaufzeichnung/jahr').' '; + if ($passuid) + echo ''; echo ''; echo '
    '; echo ''; @@ -1490,16 +1494,19 @@ if($projekt->getProjekteMitarbeiter($user, true)) } list($h2, $m2) = explode(':', $elsumme); $elsumme = $h2*3600+$m2*60; - if ($tagessaldo > 18000 && $tagessaldo < 19800 && $pflichtpause==false && $elsumme == 0) + if ($datum->formatDatum($tag, 'Y-m-d') >= '2019-11-06') { - //$pausesumme = $tagessaldo-18000; $pausesumme = $pausesumme; } + else if ($tagessaldo > 18000 && $tagessaldo < 19800 && $pflichtpause==false && $elsumme == 0) + { + $pausesumme = $tagessaldo-18000; + } else if ($tagessaldo>18000 && $pflichtpause==false && $elsumme == 0) { - //$pausesumme = $pausesumme+1800; - $pausesumme = $pausesumme; + $pausesumme = $pausesumme+1800; } + if ($elsumme > 0){ $pausesumme = $pausesumme + $elsumme; $pflichtpause = true; diff --git a/cis/private/tools/zeitaufzeichnung_projektliste.php b/cis/private/tools/zeitaufzeichnung_projektliste.php index b8b19a0a9..c578ccb88 100644 --- a/cis/private/tools/zeitaufzeichnung_projektliste.php +++ b/cis/private/tools/zeitaufzeichnung_projektliste.php @@ -29,6 +29,7 @@ require_once('../../../include/phrasen.class.php'); require_once('../../../include/datum.class.php'); require_once('../../../include/Excel/excel.php'); require_once('../../../include/benutzer.class.php'); +require_once('../../../include/benutzerberechtigung.class.php'); require_once('../../../include/mitarbeiter.class.php'); require_once('../../../include/zeitaufzeichnung.class.php'); require_once('../../../include/projekt.class.php'); @@ -46,6 +47,24 @@ $sprache_obj->load($sprache); $sprache_index = $sprache_obj->index; $uid = get_uid(); + +//Wenn User Administrator ist und UID uebergeben wurde, dann die Zeitaufzeichnung +//des uebergebenen Users anzeigen +if (isset($_GET['uid'])) +{ + $rechte = new benutzerberechtigung(); + $rechte->getBerechtigungen($uid); + + if ($rechte->isBerechtigt('admin')) + { + $uid = $_GET['uid']; + } + else + { + die($p->t('global/FuerDieseAktionBenoetigenSieAdministrationsrechte')); + } +} + $benutzer = new benutzer(); if (!$benutzer->load($uid)) die($p->t("zeitaufzeichnung/benutzerWurdeNichtGefunden", array($uid))); @@ -602,12 +621,12 @@ foreach ($projektnames as $projektname) $lastspalte = 4 + $nrPhases; //calculating spaces for centering global header texts - $usernamelength = strlen($username) * 1.77; +/* $usernamelength = strlen($username) * 1.77; $numberspacesfirstrow = $totalwidth - $daywidth * 2 - $worktimewidth - $usernamelength; $numberspacessecondrow = $numberspacesfirstrow + $usernamelength - strlen($p->t('zeitaufzeichnung/personalnr').$persnr) - 4; $spacesstringfirstrow = str_repeat(' ', $numberspacesfirstrow); - $spacesstringsecondrow = str_repeat(' ', $numberspacessecondrow); + $spacesstringsecondrow = str_repeat(' ', $numberspacessecondrow);*/ $spalte = $zeile = 0; @@ -626,14 +645,14 @@ foreach ($projektnames as $projektname) } $worksheet->setMerge($zeile, $spalte + 3, $zeile, $lastspalte); $worksheet->setMerge($zeile + 1, $spalte + 3, $zeile + 1, $lastspalte); - $worksheet->write($zeile, $spalte + 3, $p->t('zeitaufzeichnung/projektlistegedruckt').$spacesstringfirstrow.$username, $format_heading_right); + $worksheet->write($zeile, $spalte + 3, /*$p->t('zeitaufzeichnung/projektlistegedruckt').$spacesstringfirstrow.*/$username, $format_heading_right); for ($i = 4; $i < $lastspalte; $i++) { $worksheet->write($zeile, $i, '', $format_heading_topline); $worksheet->write($zeile + 1, $i, '', $format_heading_bottomline); } $worksheet->write($zeile, $lastspalte, '', $format_heading_right); - $worksheet->write($zeile + 1, $spalte + 3, date('d.m.Y H:i').$spacesstringsecondrow.$p->t('zeitaufzeichnung/personalnr').$persnr, $format_heading_right_bottomline); + $worksheet->write($zeile + 1, $spalte + 3, /*date('d.m.Y H:i').$spacesstringsecondrow.*/$p->t('zeitaufzeichnung/personalnr').$persnr, $format_heading_right_bottomline); $worksheet->write($zeile + 1, $lastspalte, '', $format_heading_right_bottomline); $zeile += 3; diff --git a/cis/public/coodle.php b/cis/public/coodle.php index da557217b..48c585d6b 100644 --- a/cis/public/coodle.php +++ b/cis/public/coodle.php @@ -158,7 +158,9 @@ if (isset($_POST['auswahl_termin']))
  • '; } else + { $saveOk = true; + } $coodle_status = new coodle(); $coodle_status->load($coodle_id); @@ -283,6 +285,7 @@ if (isset($_GET['resend'])) $(this).remove(); }); }, 1500); + + + +
    +'; + +$stg_kz = (isset($_GET['stg_kz'])?$_GET['stg_kz']:'-1'); +$gebietToCopy = (isset($_POST['gebietToCopy'])?$_POST['gebietToCopy']:(isset($_GET['gebietToCopy'])?$_GET['gebietToCopy']:'')); +$gebiet = new gebiet(); + +echo 'Zurück zur Admin Seite

    '; +echo '

    Gebiet kopieren

    '; +echo '

    Kopiert ein Gebiet mit allen Fragen und Antworten aber ohne Zuordnungen zu Studiengängen und dgl.

    '; + +if(!$rechte->isBerechtigt('basis/testtool')) + die($rechte->errormsg); + +$returnmsg = ''; +//Speichern der Daten +if (isset($_POST['copyGebiet']) && $_POST['copyGebiet'] == 'copyGebiet') +{ + if (!$rechte->isBerechtigt('basis/testtool', null, 'suid')) + die($rechte->errormsg); + + if (isset($_POST['kurzbz']) && $_POST['kurzbz'] != '') + { + //Test, ob kurzbz schon vorhanden + if ($result = $db->db_query('SELECT kurzbz FROM testtool.tbl_gebiet WHERE kurzbz = '.$db->db_add_param($_POST['kurzbz']).' LIMIT 1;')) + { + if ($db->db_num_rows($result) == 0) + { + $gebietToCopy = $_POST['gebietToCopy']; + + // Zu kopierendes Gebiet laden + $gebiet = new gebiet($gebietToCopy); + + $bezeichnung_mehrsprachig = array(); + foreach ($sprache->result as $row_sprache) + { + $bezeichnung_mehrsprachig[$row_sprache->sprache] = $_POST['bezeichnung_mehrsprachig_'.$row_sprache->sprache]; + } + $gebiet->bezeichnung_mehrsprachig = $bezeichnung_mehrsprachig; + + $gebiet->kurzbz = $_POST['kurzbz']; + $gebiet->bezeichnung = $_POST['bezeichnung_intern']; + $gebiet->beschreibung = $_POST['beschreibung']; + $gebiet->insertamum = date('Y-m-d H:i:s'); + $gebiet->insertvon = $user; + + // Neues Gebiet speichern + if ($gebiet->save(true)) + { + $returnmsg .= '

    Gebiet erfolgreich kopiert

    '; + + // Array mit allen Fragen und Antworten anlegen + $frageAntwortArray = array(); + + // Fragen laden + $fragenToCopy = new frage(); + $fragenToCopy->getFragenGebiet($gebietToCopy); + // Sprachen laden und für jede Sprache die Fragen und Antworten laden + foreach ($sprache->result as $row_sprache) + { + $fragenSpracheToCopy = new frage(); + $indexFrageSprache = 0; + foreach ($fragenToCopy->result AS $copyFrage) + { + if ($fragenSpracheToCopy->getFrageSprache($copyFrage->frage_id, $row_sprache->sprache, true)) + { + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['nummer'] = $fragenSpracheToCopy->nummer; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['demo'] = $fragenSpracheToCopy->demo; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['kategorie_kurzbz'] = $fragenSpracheToCopy->kategorie_kurzbz; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['level'] = $fragenSpracheToCopy->level; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['aktiv'] = $fragenSpracheToCopy->aktiv; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['text'] = $fragenSpracheToCopy->text; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['bild'] = $fragenSpracheToCopy->bild; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['audio'] = $fragenSpracheToCopy->audio; + + // Vorschläge laden + $vorschlagSprachenToCopy = new vorschlag(); + $vorschlagSprachenToCopy->getVorschlag($copyFrage->frage_id, $row_sprache->sprache, false); + + $indexVorschlagSprache = 0; + foreach ($vorschlagSprachenToCopy->result AS $vorschlagSprache) + { + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['vorschlaege'][$indexVorschlagSprache]['nummer'] = $vorschlagSprache->nummer; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['vorschlaege'][$indexVorschlagSprache]['punkte'] = $vorschlagSprache->punkte; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['vorschlaege'][$indexVorschlagSprache]['text'] = $vorschlagSprache->text; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['vorschlaege'][$indexVorschlagSprache]['bild'] = $vorschlagSprache->bild; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['vorschlaege'][$indexVorschlagSprache]['audio'] = $vorschlagSprache->audio; + $frageAntwortArray[$row_sprache->sprache][$indexFrageSprache]['vorschlaege'][$indexVorschlagSprache]['aktiv'] = $vorschlagSprache->aktiv; + $indexVorschlagSprache++; + } + } + $indexFrageSprache++; + } + } + + // Einfügen der Fragen und Antworten aus dem Array in das neue Gebiet + $anzahlFragenKopiert = 0; + + foreach ($frageAntwortArray AS $fragesprache => $index) + { + foreach ($index AS $frage => $value) + { + $newfragen = new frage(); + $newfragen->new = true; + + $newfragen->kategorie_kurzbz = $value["kategorie_kurzbz"]; + $newfragen->gebiet_id = $gebiet->gebiet_id; + $newfragen->level = $value["level"]; + $newfragen->nummer = $value["nummer"]; + $newfragen->demo = $value["demo"]; + $newfragen->insertamum = date('Y-m-d H:i:s'); + $newfragen->insertvon = $user; + $newfragen->aktiv = $value["aktiv"]; + + if ($newfragen->save()) + { + $newfragen->sprache = $fragesprache; + $newfragen->text = $value["text"]; + $newfragen->bild = $value["bild"]; + $newfragen->audio = $value["audio"]; + $newfragen->insertamum = date('Y-m-d H:i:s'); + $newfragen->insertvon = $user; + + if ($newfragen->save_fragesprache()) + { + if (isset($value["vorschlaege"])) + { + foreach ($value["vorschlaege"] AS $vorschlag => $content) + { + // Vorschläge speichern + $newvorschlaege = new vorschlag(); + $newvorschlaege->new = true; + + $newvorschlaege->frage_id = $newfragen->frage_id; + $newvorschlaege->nummer = $content["nummer"]; + $newvorschlaege->punkte = $content["punkte"]; + $newvorschlaege->aktiv = $content["aktiv"]; + $newvorschlaege->insertamum = date('Y-m-d H:i:s'); + $newvorschlaege->insertvon = $user; + + if ($newvorschlaege->save()) + { + $newvorschlaege->sprache = $fragesprache; + $newvorschlaege->text = $content["text"]; + $newvorschlaege->bild = $content["bild"]; + $newvorschlaege->audio = $content["audio"]; + $newvorschlaege->insertamum = date('Y-m-d H:i:s'); + $newvorschlaege->insertvon = $user; + + if ($newvorschlaege->save_vorschlagsprache()) + { + $anzahlFragenKopiert++; + } + } + } + } + } + else + { + $returnmsg .= '

    Fehler beim Speichern der Fragesprache '.$fragesprache.' bei Frage: '.$newfragen->frage_id.'

    '; + } + } + else + { + $returnmsg .= '

    Fehler beim Speichern der Frage: '.$newfragen->frage_id.'

    '; + } + } + } + } + else + { + $returnmsg .= '

    Fehler beim Speichern: '.$gebiet->errormsg.'

    '; + } + } + else + $returnmsg .= '

    Kurzbezeichnung ist schon vorhanden

    '; + } + } + else + { + $returnmsg .= '

    Bitte füllen Sie alle Pflichtfelder aus

    '; + } +} + + +$studiengang = new studiengang(); +$studiengang->getAll('typ, kurzbz', false); + +echo '

    '.$returnmsg.'

    '; +echo ' +
    + + + + + + + + + + + + + + '; + +foreach ($sprache->result as $row) +{ + echo ' + + + '; +} +echo ' + + + + + + + + +
    Zu kopierendes Gebiet: '; + //Dropdown bestehender Gebiete + $gebiete = new gebiet(); + $gebiete->getAll(); + echo ''; +echo '
    Daten neues Gebiet
    Kurzbezeichnung
    Bezeichnung (intern)
    Bezeichnung '.$row->bezeichnung_arr[$sprache_user].'
    Beschreibung (intern)
    + +
    +'; + +echo ''; +?> diff --git a/cis/testtool/admin/index.php b/cis/testtool/admin/index.php index d433a747e..6da5040ed 100644 --- a/cis/testtool/admin/index.php +++ b/cis/testtool/admin/index.php @@ -160,6 +160,18 @@ textarea { font-size: 10pt; } +.nummern +{ + border: 1px solid lightgrey; + border-collapse: collapse; + border-spacing: 0; + padding: 2px; +} +td.nummern +{ + width: 15px; + text-align: center; +} @@ -690,6 +702,7 @@ if (($anzahl !== 0) || ($stg_kz == '-1') && ($stg_kz !== '')) echo " Prüfen | "; echo " Bearbeiten |"; echo " Neues Gebiet | "; + echo " Gebiet kopieren"; //echo " PDF exportieren"; //echo "
    Gebiet_id=".$gebiet_id.""; echo ''; @@ -717,19 +730,29 @@ if (($anzahl !== 0) || ($stg_kz == '-1') && ($stg_kz !== '')) // Liste der Fragen if ($filter == 'aktiv') { - $qry = "SELECT distinct nummer, aktiv FROM testtool.tbl_frage WHERE gebiet_id=".$db->db_add_param($gebiet_id)." AND aktiv ORDER BY nummer"; + $qry = "SELECT distinct nummer, aktiv, level, demo FROM testtool.tbl_frage WHERE gebiet_id=".$db->db_add_param($gebiet_id)." AND aktiv ORDER BY nummer"; } elseif ($filter == 'inaktiv') { - $qry = "SELECT distinct nummer, aktiv FROM testtool.tbl_frage WHERE gebiet_id=".$db->db_add_param($gebiet_id)." AND NOT aktiv ORDER BY nummer"; + $qry = "SELECT distinct nummer, aktiv, level, demo FROM testtool.tbl_frage WHERE gebiet_id=".$db->db_add_param($gebiet_id)." AND NOT aktiv ORDER BY nummer"; } else { - $qry = "SELECT distinct nummer, aktiv FROM testtool.tbl_frage WHERE gebiet_id=".$db->db_add_param($gebiet_id)." ORDER BY nummer"; + $qry = "SELECT distinct nummer, aktiv, level, demo FROM testtool.tbl_frage WHERE gebiet_id=".$db->db_add_param($gebiet_id)." ORDER BY nummer"; } if ($result = $db->db_query($qry)) { + $resultArray = array(); + $i = 0; + while ($row = $db->db_fetch_object($result)) + { + $resultArray[$i]['nummer'] = $row->nummer; + $resultArray[$i]['aktiv'] = $row->aktiv; + $resultArray[$i]['level'] = $row->level; + $resultArray[$i]['demo'] = $row->demo; + $i++; + } // Aktiv / Inaktiv Checkboxes $aktivchecked = ($filter == 'aktiv' || $filter == '')?'checked="checked"':''; $inaktivchecked = ($filter == 'inaktiv' || $filter == '')?'checked="checked"':''; @@ -755,21 +778,45 @@ if (($anzahl !== 0) || ($stg_kz == '-1') && ($stg_kz !== '')) inaktiv'; } - echo '
    Nummer: '; - while ($row = $db->db_fetch_object($result)) + echo '
    + '; + foreach ($resultArray AS $key=>$value) { if ($nummer == '') - $nummer = $row->nummer; + $nummer = $value['nummer']; $style = ''; - if ($db->db_parse_bool($row->aktiv) == false) + if ($db->db_parse_bool($value['aktiv']) == false) $style = 'style="color: lightgrey"'; - if ($nummer == $row->nummer) - echo " $row->nummer -"; - else - echo " $row->nummer -"; + $styleSelected = ''; + if ($nummer == $value['nummer']) + { + $styleSelected = 'style="background-color: lightblue"'; + } + + echo ''; } + echo ' + '; + $leveltext = ''; + foreach ($resultArray AS $key=>$value) + { + if ($value['level'] == '') + { + $leveltext = '-'; + } + else + { + $leveltext = $value['level']; + if ($value['demo'] == 't') + { + $leveltext .= '*'; + } + } + echo ''; + } + echo '
    Nummer:'.$value['nummer'].'
    Level:'.$leveltext.'
    '; echo " neue Frage hinzufuegen"; $frage_obj = new frage(); if ($filter == 'aktiv') @@ -965,7 +1012,7 @@ if ($frage_id != '') echo ""; echo ""; echo ''; - echo "Punkte:"; + echo "Punkte:"; echo ""; echo ""; echo ""; diff --git a/composer.json b/composer.json index c37ee91c6..636c6da42 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": { @@ -173,6 +184,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": { @@ -253,6 +275,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", @@ -261,6 +284,8 @@ "netcarver/textile": "^3.5", "nicolaskruchten/pivottable": "^2.21.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 e5b050e96..0b869361a 100644 --- a/composer.lock +++ b/composer.lock @@ -1134,6 +1134,17 @@ ], "time": "2018-11-18T20:26:18+00:00" }, + { + "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", @@ -1237,16 +1248,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": { @@ -1331,18 +1342,29 @@ ], "time": "2018-11-04T18:21:09+00:00" }, + { + "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.20", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "11cf67cf78dc4acb18dc9149a57be4aee5036ce0" + "reference": "d6819a55b05e123db1e881d8b230d57f912126be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/11cf67cf78dc4acb18dc9149a57be4aee5036ce0", - "reference": "11cf67cf78dc4acb18dc9149a57be4aee5036ce0", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/d6819a55b05e123db1e881d8b230d57f912126be", + "reference": "d6819a55b05e123db1e881d8b230d57f912126be", "shasum": "" }, "require": { @@ -2138,16 +2160,16 @@ }, { "name": "tinymce/tinymce", - "version": "4.9.4", + "version": "4.9.5", "source": { "type": "git", "url": "https://github.com/tinymce/tinymce-dist.git", - "reference": "3a997f24eb54d890b1c88f22cff03092e0b73378" + "reference": "5c6d8f4a6dda33b379068bb12678a2b2b2271fb4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/tinymce/tinymce-dist/zipball/3a997f24eb54d890b1c88f22cff03092e0b73378", - "reference": "3a997f24eb54d890b1c88f22cff03092e0b73378", + "url": "https://api.github.com/repos/tinymce/tinymce-dist/zipball/5c6d8f4a6dda33b379068bb12678a2b2b2271fb4", + "reference": "5c6d8f4a6dda33b379068bb12678a2b2b2271fb4", "shasum": "" }, "type": "component", @@ -2245,16 +2267,16 @@ }, { "name": "twig/twig", - "version": "v1.41.0", + "version": "v1.42.2", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "575cd5028362da591facde1ef5d7b94553c375c9" + "reference": "21707d6ebd05476854805e4f91b836531941bcd4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/575cd5028362da591facde1ef5d7b94553c375c9", - "reference": "575cd5028362da591facde1ef5d7b94553c375c9", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/21707d6ebd05476854805e4f91b836531941bcd4", + "reference": "21707d6ebd05476854805e4f91b836531941bcd4", "shasum": "" }, "require": { @@ -2264,12 +2286,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": { diff --git a/config/global.config-default.inc.php b/config/global.config-default.inc.php index fa131a8aa..308058fba 100644 --- a/config/global.config-default.inc.php +++ b/config/global.config-default.inc.php @@ -126,6 +126,12 @@ define('FAS_UDF', true); // Legt fest ob Aufnahmegruppen bei Reihungstests verwaltet werden true|false define('FAS_REIHUNGSTEST_AUFNAHMEGRUPPEN',false); +// Legt fest, ob Vertragsdetails zum Lehrauftrag im Reiter LektorInnenzuteilung angezeigt werden +define('FAS_LV_LEKTORINNENZUTEILUNG_VERTRAGSDETAILS_ANZEIGEN', false); + +// Legt fest, ob Vertragsdetails zum Projektauftrag im Reiter Projektarbeit angezeigt werden +define('FAS_STUDIERENDE_PROJEKTARBEIT_VERTRAGSDETAILS_ANZEIGEN', false); + // Anzeigeoptionen für LV-Plan Menü define('CIS_LVPLAN_EXPORT_ANZEIGEN',true); define('CIS_LVPLAN_PERSONENAUSWAHL_ANZEIGEN',true); diff --git a/content/lvplanung/lehrveranstaltungDBDML.php b/content/lvplanung/lehrveranstaltungDBDML.php index a150a0262..d506f0459 100644 --- a/content/lvplanung/lehrveranstaltungDBDML.php +++ b/content/lvplanung/lehrveranstaltungDBDML.php @@ -17,7 +17,8 @@ * * Authors: Christian Paminger , * Andreas Oesterreicher and - * Rudolf Hangl . + * Rudolf Hangl + * Cristina Hainberger . */ // **************************************** @@ -31,6 +32,7 @@ // * - Lehreinheitmitarbeiter Zuteilung hinzufuegen/bearbeiten/loeschen // * - Lehreinheitgruppe Zutelung hinzufuegen/loeschen // * - Lehreinheit anlegen/bearbeiten/loeschen +// * - Lehrauftrag (Vertrag) loeschen (stornieren) // **************************************** require_once('../../config/vilesci.config.inc.php'); @@ -691,50 +693,61 @@ if(!$error) //Lehreinheitmitarbeiterzuteilung loeschen if(isset($_POST['lehreinheit_id']) && is_numeric($_POST['lehreinheit_id']) && isset($_POST['mitarbeiter_uid'])) { - //Wenn der Mitarbeiter im Stundenplan verplant ist, dann wird das Loeschen verhindert - $qry = "SELECT stundenplandev_id as id FROM lehre.tbl_stundenplandev WHERE lehreinheit_id=".$db->db_add_param($_POST['lehreinheit_id'], FHC_INTEGER)." AND mitarbeiter_uid=".$db->db_add_param($_POST['mitarbeiter_uid'])." - UNION - SELECT stundenplan_id as id FROM lehre.tbl_stundenplan WHERE lehreinheit_id=".$db->db_add_param($_POST['lehreinheit_id'], FHC_INTEGER)." AND mitarbeiter_uid=".$db->db_add_param($_POST['mitarbeiter_uid']); - if($db->db_query($qry)) + // Wenn der Mitarbeiter schon einen Vertrag hat UND + // der config Eintrag zum Anzeigen der Vertragsdetails true ist, + // wird das Loeschen verhindert + if (isset($_POST['vertrag_id']) && is_numeric($_POST['vertrag_id']) && + (defined('FAS_LV_LEKTORINNENZUTEILUNG_VERTRAGSDETAILS_ANZEIGEN') && FAS_LV_LEKTORINNENZUTEILUNG_VERTRAGSDETAILS_ANZEIGEN)) { - if($db->db_num_rows()>0) + $return = false; + $errormsg = 'Löschen nur nach Stornierung des Vertrags möglich.'; + } + else + { + //Wenn der Mitarbeiter im Stundenplan verplant ist, dann wird das Loeschen verhindert + $qry = "SELECT stundenplandev_id as id FROM lehre.tbl_stundenplandev WHERE lehreinheit_id=".$db->db_add_param($_POST['lehreinheit_id'], FHC_INTEGER)." AND mitarbeiter_uid=".$db->db_add_param($_POST['mitarbeiter_uid'])." + UNION + SELECT stundenplan_id as id FROM lehre.tbl_stundenplan WHERE lehreinheit_id=".$db->db_add_param($_POST['lehreinheit_id'], FHC_INTEGER)." AND mitarbeiter_uid=".$db->db_add_param($_POST['mitarbeiter_uid']); + if($db->db_query($qry)) { - $return = false; - $errormsg = 'Diese/r LektorIn kann nicht gelöscht werden da er schon verplant ist'; - } - else - { - $leg = new lehreinheitmitarbeiter(); - if($leg->load($_POST['lehreinheit_id'], $_POST['mitarbeiter_uid'])) + if($db->db_num_rows()>0) { - // Wenn ein Vertrag dazu angelegt ist, dann diesen mitloeschen - if($leg->vertrag_id!='') + $return = false; + $errormsg = 'Diese/r LektorIn kann nicht gelöscht werden da er schon verplant ist'; + } + else + { + $leg = new lehreinheitmitarbeiter(); + if($leg->load($_POST['lehreinheit_id'], $_POST['mitarbeiter_uid'])) { - $vertrag = new vertrag(); - $vertrag->delete($leg->vertrag_id); - } - - if($leg->delete($_POST['lehreinheit_id'], $_POST['mitarbeiter_uid'])) - { - $return = true; + // Wenn ein Vertrag dazu angelegt ist, dann diesen mitloeschen + if($leg->vertrag_id!='') + { + $vertrag = new vertrag(); + $vertrag->delete($leg->vertrag_id); + } + if($leg->delete($_POST['lehreinheit_id'], $_POST['mitarbeiter_uid'])) + { + $return = true; + } + else + { + $return = false; + $errormsg = $leg->errormsg; + } } else { $return = false; - $errormsg = $leg->errormsg; + $errormsg='Fehlgeschlagen:'.$leg->errormsg; } } - else - { - $return = false; - $errormsg='Fehlgeschlagen:'.$leg->errormsg; - } } - } - else - { - $return = false; - $errormsg = 'Fehler:'.$qry; + else + { + $return = false; + $errormsg = 'Fehler:'.$qry; + } } } else @@ -1715,6 +1728,102 @@ if(!$error) } } } + elseif(isset($_POST['type']) && $_POST['type']=='getLastVertragsstatus') + { + if(isset($_POST['vertrag_id'])) + { + $vertrag = new vertrag(); + if($vertrag->getAllStatus($_POST['vertrag_id'])) + { + $vertraege = $vertrag->result; + foreach($vertraege as $vertrag) + { + $data = $vertrag->vertragsstatus_kurzbz; + $return = true; + break; // exit loop because only last (most actual) vertrag item is needed + } + + } + else + { + $errormsg = 'Fehler beim Laden des Vertragsstatus'; + $return = false; + } + } + else + { + $errormsg = 'VertragsID muss uebergeben werden'; + $return = false; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='cancelVertrag') + { + $error = false; + + // Check if user is entitled to cancel this contract + if (isset($_POST['vertrag_id']) && is_numeric($_POST['vertrag_id'])) + { + // * first find lehrveranstaltung_id of the contracts lehrveranstaltung + $vertrag = new vertrag(); + $vertrag->load($_POST['vertrag_id']); + $lva = new lehrveranstaltung($vertrag->lehrveranstaltung_id); + + // * then check if the user has permissions to cancel the corresponding lv-organisational units + if (!$rechte->isBerechtigtMultipleOe('admin', $lva->getAllOe(), 'suid') && + !$rechte->isBerechtigtMultipleOe('lehre/lehrauftrag_bestellen', $lva->getAllOe(), 'suid')) + { + $error = true; + $return = false; + $errormsg = 'Keine Berechtigung'; + } + } + + if (!$error) + { + if(isset($_POST['mitarbeiter_uid'])) + { + $vertrag = new vertrag(); + if($vertrag->cancel($_POST['vertrag_id'], $_POST['mitarbeiter_uid'])) + { + $return = true; + } + else + { + $errormsg = 'Fehler beim Ausführen des Vertragsstornos'; + $return = false; + } + } + elseif(isset($_POST['person_id'])) + { + $benutzer = new Benutzer(); + if($benutzer->getBenutzerFromPerson($_POST['person_id'])) + { + $mitarbeiter_uid = $benutzer->result[0]->uid; + + $vertrag = new vertrag(); + if($vertrag->cancel($_POST['vertrag_id'], $mitarbeiter_uid)) + { + $return = true; + } + else + { + $errormsg = 'Fehler beim Ausführen des Vertragsstornos'; + $return = false; + } + } + else + { + $errormsg = 'Benutzer konnte nicht von PersonID geladen werden'; + $return = false; + } + } + } + else + { + $errormsg = 'VertragsID und MitarbeiterUID müssen uebergeben werden'; + $return = false; + } + } else { $return = false; diff --git a/content/lvplanung/lehrveranstaltungdetailoverlay.xul.php b/content/lvplanung/lehrveranstaltungdetailoverlay.xul.php index de6c7cf17..57338add2 100644 --- a/content/lvplanung/lehrveranstaltungdetailoverlay.xul.php +++ b/content/lvplanung/lehrveranstaltungdetailoverlay.xul.php @@ -35,6 +35,9 @@ $rechte->getBerechtigungen($user); echo ''; +// Vertragsdetails: Anzeige wird über config Eintrag bestimmt +$is_hidden = (!defined('FAS_LV_LEKTORINNENZUTEILUNG_VERTRAGSDETAILS_ANZEIGEN') || FAS_LV_LEKTORINNENZUTEILUNG_VERTRAGSDETAILS_ANZEIGEN == true) ? 'false' : 'true'; + ?> '; - + isBerechtigt('lv-plan/lektorentfernen')) { @@ -429,10 +432,10 @@ echo ''; - + - + - - + + + +