diff --git a/application/config/navigation.php b/application/config/navigation.php index d76b8a7f2..033a65f86 100644 --- a/application/config/navigation.php +++ b/application/config/navigation.php @@ -71,6 +71,16 @@ $config['navigation_header'] = array( 'lehre/lehrauftrag_erteilen:r' ) ), + 'zverfueg' => array( + 'link' => site_url('lehre/lvplanung/AdminZeitverfuegbarkeit'), + 'description' => 'Zeitverfügbarkeit', + 'expand' => true, + 'sort' => 45, + 'requiredPermissions' => array( + 'lehre/zeitverfuegbarkeit:rw', + 'lehre/zeitverfuegbarkeit:rw' + ) + ), 'zgvueberpruefung' => array( 'link' => site_url('system/infocenter/ZGVUeberpruefung'), 'description' => 'ZGV Überprüfung', @@ -235,3 +245,14 @@ $config['navigation_menu']['lehre/lehrauftrag/LehrauftragErteilen/*'] = array( 'requiredPermissions' => array('lehre/lehrauftrag_erteilen:r') ) ); + +$config['navigation_menu']['system/issues/Issues/*'] = array( + 'fehlerzustaendigkeiten' => array( + 'link' => site_url('system/issues/IssuesZustaendigkeiten'), + 'description' => 'Fehler Zuständigkeiten', + 'icon' => 'cogs', + 'sort' => 100, + 'target' => '_blank', + 'requiredPermissions' => array('admin:rw') + ) +); diff --git a/application/controllers/jobs/AnrechnungJob.php b/application/controllers/jobs/AnrechnungJob.php index f32a8268a..7aae80d54 100644 --- a/application/controllers/jobs/AnrechnungJob.php +++ b/application/controllers/jobs/AnrechnungJob.php @@ -16,9 +16,11 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); class AnrechnungJob extends JOB_Controller { const APPROVE_ANRECHNUNG_URI = '/lehre/anrechnung/ApproveAnrechnungUebersicht'; + const REVIEW_ANRECHNUNG_URI = '/lehre/anrechnung/ReviewAnrechnungUebersicht'; const ANRECHNUNGSTATUS_APPROVED = 'approved'; const ANRECHNUNGSTATUS_REJECTED = 'rejected'; + const ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR = 'inProgressLektor'; const ANRECHNUNG_NOTIZTITEL_NOTIZ_BY_STGL = 'AnrechnungNotizSTGL'; /** @@ -33,6 +35,8 @@ class AnrechnungJob extends JOB_Controller $this->load->helper('url'); $this->load->helper('hlp_sancho_helper'); + + $this->load->library('AnrechnungLib'); } /** @@ -342,6 +346,79 @@ html; } + /** + * Send Sancho mail to remind lecturers to provide their recommendation if not done until one week after request. + */ + public function sendMailRemindRecommendation(){ + + $this->logInfo('Start AnrechnungJob sendMailRemindRecommendation to remind lecturers to provide their recommendation.'); + + // Get Anrechnungen with pending recommendations, that were requested 1 week before today. + // Restrict query for Anrechnungen of actual semester. + $this->AnrechnungModel->addSelect('astat.anrechnung_id, astat.datum, astat.insertamum'); + $this->AnrechnungModel->addDistinct('astat.anrechnung_id'); + $this->AnrechnungModel->addJoin('lehre.tbl_anrechnung_anrechnungstatus astat', 'anrechnung_id'); + + $result = $this->AnrechnungModel->loadWhere(' + studiensemester_kurzbz = ( + SELECT studiensemester_kurzbz FROM tbl_studiensemester WHERE now()::date BETWEEN start AND ende) + ) + AND genehmigt_von IS NULL + AND empfehlung_anrechnung IS NULL + AND status_kurzbz = '. $this->db->escape(self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR) .' -- in Bearbeitung durch Lektor + AND NOW()::date = (astat.datum + interval \'1 week\') -- eine Woche nach Empfehlungsanfrage + ORDER BY astat.anrechnung_id, astat.datum DESC, astat.insertamum DESC -- nur letzten status dabei prüfen + '); + + // Exit if there are no pending recommendations + if (!hasData($result)) + { + $this->logInfo('End AnrechnungJob sendMailRemindRecommendation, because no recommendations to be done.'); + exit; + } + + $anrechnung_id_arr = array_column(getData($result), 'anrechnung_id'); + + $arr_lvLector_arr = array(); + foreach ($anrechnung_id_arr as $anrechnung_id) + { + $arr_lvLector_arr[]= $this->anrechnunglib->getLectors($anrechnung_id); // Returns LV Leitung. If not present, then all lectors of LV. + } + + // Unique lector array to send only one mail per lector + $arr_lvLector_arr = array_unique($arr_lvLector_arr, SORT_REGULAR); + + // Link to 'Anrechnungen prüfen' dashboard + $url = + CIS_ROOT. 'cis/index.php?menu='. + CIS_ROOT. 'cis/menu.php?content_id=&content='. + CIS_ROOT. index_page(). self::REVIEW_ANRECHNUNG_URI; + + foreach ($arr_lvLector_arr as $lvLector_arr) + { + foreach ($lvLector_arr as $lector) + { + // Prepare mail content + $fields = array( + 'vorname' => $lector->vorname, + 'stgl_name' => 'Die Studiengangsleitung', + 'link' => anchor($url, 'Anrechnungsanträge Übersicht') + ); + + // Send mail + sendSanchoMail( + 'AnrechnungEmpfehlungAnfordern', + $fields, + $lector->uid. '@'. DOMAIN, + 'Erinnerung: Deine Empfehlung wird benötigt zur Anerkennung nachgewiesener Kenntnisse' + ); + } + } + + $this->logInfo('SUCCEDED AnrechnungJob sendMailRemindRecommendation'); + + } + // Get STGL mail address private function _getSTGLMailAddress($studiengang_kz) { diff --git a/application/controllers/jobs/LVPlanJob.php b/application/controllers/jobs/LVPlanJob.php index 2688e5cc9..c3fe5495a 100644 --- a/application/controllers/jobs/LVPlanJob.php +++ b/application/controllers/jobs/LVPlanJob.php @@ -19,7 +19,7 @@ */ if (!defined('BASEPATH')) exit('No direct script access allowed'); -class LVPlanJob extends CLI_Controller +class LVPlanJob extends JOB_Controller { /** * Initialize LVPlanJob Class @@ -149,4 +149,315 @@ class LVPlanJob extends CLI_Controller echo "Failed ".$fail."\n"; } } + + /** + * Send Mail to STGL, Kompetenzfeld and LV Planung about todays updated Zeitwuensche. + * STGL gets list only of lectors who updated future assigend courses concerning their STG. + * Kompetenzleitung gets list only of lectors who updated future assigend courses concerning their KF. + * LVPlanung gets list of lectors who updated future assigend courses. + */ + public function mailUpdatedZeitwuensche() + { + // Load models + $this->load->model('ressource/Stundenplandev_model', 'StundenplandevModel'); + $this->load->model('organisation/Studiensemester_model', 'StundiensemesterModel'); + $this->load->model('education/Lehreinheit_model', 'LehreinheitModel'); + $this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel'); + $this->load->model('person/Person_model', 'PersonModel'); + + // Load libs + $this->load->library('MailLib'); + + // Load helpers + $this->load->helper('hlp_sancho_helper'); + + // Start Log Message + $this->logInfo('Mail updated Zeitwuensche started.'); + + // Get all lectors, who updated their Zeitwunsch today + $db = new DB_Model(); + $result = $db->execReadOnlyQuery(' + SELECT + zwg.mitarbeiter_uid, tbl_lehrveranstaltung.studiengang_kz, tbl_lehrveranstaltung.oe_kurzbz + FROM + campus.tbl_zeitwunsch_gueltigkeit zwg + JOIN lehre.tbl_stundenplandev stpl + ON( + stpl.mitarbeiter_uid=zwg.mitarbeiter_uid + AND stpl.datum BETWEEN zwg.von AND COALESCE(zwg.bis, \'2999-12-31\') + AND (zwg.insertamum::date = (NOW()-\'1 days\'::interval)::date + OR + zwg.updateamum::date = (NOW()-\'1 days\'::interval)::date) + AND stpl.datum > now() + ) + JOIN lehre.tbl_lehreinheit USING(lehreinheit_id) + JOIN lehre.tbl_lehrveranstaltung USING(lehrveranstaltung_id) + GROUP BY + zwg.mitarbeiter_uid, tbl_lehrveranstaltung.studiengang_kz, tbl_lehrveranstaltung.oe_kurzbz + '); + + if (!hasData($result)) + { + return; // No updated Zeitwuensche today + } + + $uidByStg_arr = array(); // Mail data for Studiengang + $uidByOe_arr = array(); // Mail data for Kompetenzfeld + $uid_arr = array(); // Mail data for Kompetenzfeld + + // Loop through lectors, who updated their Zeitwunsch today + $changed_arr = getData($result); + foreach ($changed_arr as $row) + { + + // Add unique lector array + if (!in_array($row->mitarbeiter_uid, $uid_arr)) + { + $uid_arr[]= $row->mitarbeiter_uid; + } + + // Build unique Studiengang array + if (!array_key_exists($row->studiengang_kz, $uidByStg_arr)) + { + $uidByStg_arr[$row->studiengang_kz] = array($row->mitarbeiter_uid); + + } + elseif (!in_array($row->mitarbeiter_uid, $uidByStg_arr[$row->studiengang_kz])) + { + $uidByStg_arr[$row->studiengang_kz][]= $row->mitarbeiter_uid; + } + + // Build unique Kompetenzfeld array + if (!array_key_exists($row->oe_kurzbz, $uidByOe_arr)) + { + $uidByOe_arr[$row->oe_kurzbz] = array($row->mitarbeiter_uid); + + } + elseif (!in_array($row->mitarbeiter_uid, $uidByOe_arr[$row->oe_kurzbz])) + { + $uidByOe_arr[$row->oe_kurzbz][]= $row->mitarbeiter_uid; + } + } + + // Send mail to STG Assistenz + /* + $result = $this->_sendMailToStg($uidByStg_arr); + if (isError($result)) + { + $this->logError(getError($result)); + } + */ + + // Send mail to Kompetenzfeld Leitung + $result = $this->_sendMailToKF($uidByOe_arr); + if (isError($result)) + { + $this->logError(getError($result)); + } + + // Send mail to LV Planung + $result = $this->_sendMailToLvPlanung($uid_arr); + if (isError($result)) + { + $this->logError(getError($result)); + } + + // End Log Message + $this->logInfo('Mail updated Zeitwuensche ended.'); + } + + /** + * Send Mail to STGL Assistance about lectors, who teach LV assigend to the STG, and who updated Zeitwuensche. + * + * @param $data_arr + * @param $stg_bezeichnung + */ + private function _sendMailToStg($data_arr) + { + foreach ($data_arr as $stg_kurzbz => $uid_arr) + { + // Get STG eMail + $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + $result = $this->StudiengangModel->load($stg_kurzbz); + $stgMail = $result->retval[0]->email; + + $lektorenTabelle = ' + + + + + + + '; + + foreach($uid_arr as $uid) + { + $person = $this->PersonModel->getByUid($uid); + $lektorenTabelle.= ' + + + + + '; + } + + $lektorenTabelle.= '
NameUID
'. getData($person)[0]->vorname. ' '. getData($person)[0]->nachname. '['. $uid. ']
'; + + $contentData_arr = array( + 'datentabelle' => $lektorenTabelle + ); + + // Send mail + if (!sendSanchoMail( + 'ZeitwunschUpdateMail', + $contentData_arr, + $stgMail, + 'Änderung von Zeitwünschen', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg' + )) + { + $errorReceiverUid_arr[]= $stgMail; + } + } + + if (isset($errorReceiverUid_arr)) + { + return error('Mail updated Zeitwuensche could not be sent to :'. implode($errorReceiverUid_arr, ',')); + } + + return success(); + } + + /** + * Send Mail to Kompetenzfeld about lectors, who teach LV assigend to the Kompetenzfeld, and who updated Zeitwuensche. + * + * @param $data_arr + * @param $stg_bezeichnung + */ + private function _sendMailToKF($data_arr) + { + // Send mail to Komepetenzfeld Leitung + foreach ($data_arr as $oe_kurzbz => $uid_arr) + { + // Get KF Leitung eMail + $this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); + $result = $this->BenutzerfunktionModel->getBenutzerFunktionen( + 'Leitung', + $oe_kurzbz, + $activeoeonly = true, + $activebenonly = true + ); + + if(isSuccess($result) && hasData($result)) + { + $empfaenger = array(); + + foreach(getData($result) as $row) + $empfaenger[] = $row->uid. '@'. DOMAIN; + $kfMail = implode(',',$empfaenger); + + $lektorenTabelle = ' + + + + + + + '; + + foreach($uid_arr as $uid) + { + $person = $this->PersonModel->getByUid($uid); + $lektorenTabelle.= ' + + + + + '; + } + + $lektorenTabelle.= '
NameUID
'. getData($person)[0]->vorname. ' '. getData($person)[0]->nachname. '['. $uid. ']
'; + + $contentData_arr = array( + 'datentabelle' => $lektorenTabelle + ); + + // Send mail + if (!sendSanchoMail( + 'ZeitwunschUpdateMail', + $contentData_arr, + $kfMail, + 'Änderung von Zeitwünschen', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg' + )) + { + $errorReceiverUid_arr[]= $kfMail; + } + } + } + + if (isset($errorReceiverUid_arr)) + { + return error('Mail updated Zeitwuensche could not be sent to :'. implode($errorReceiverUid_arr, ',')); + } + + return success(); + } + + /** + * Send Mail to LV Planung about all lectors who updated Zeitwuensche. + * + * @param $data_arr + * @param $stg_bezeichnung + */ + private function _sendMailToLvPlanung($data_arr) + { + $lektorenTabelle = ' + + + + + + + '; + + foreach($data_arr as $lector) + { + $person = $this->PersonModel->getByUid($lector); + $lektorenTabelle.= ' + + + + + '; + } + + $lektorenTabelle.= '
NameUID
'. getData($person)[0]->vorname. ' '. getData($person)[0]->nachname. '['. $lector. ']
'; + + $contentData_arr = array( + 'datentabelle' => $lektorenTabelle + ); + + // Send mail + if (!sendSanchoMail( + 'ZeitwunschUpdateMail', + $contentData_arr, + MAIL_LVPLAN, + 'Änderung von Zeitwünschen', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg' + )) + { + $errorReceiver = MAIL_LVPLAN; + } + + if (isset($errorReceiver)) + { + return error('Mail updated Zeitwuensche could not be sent to :'. $errorReceiver); + } + + return success(); + } } diff --git a/application/controllers/jobs/LehrauftragJob.php b/application/controllers/jobs/LehrauftragJob.php index 7f5754595..f1974c8a5 100644 --- a/application/controllers/jobs/LehrauftragJob.php +++ b/application/controllers/jobs/LehrauftragJob.php @@ -359,7 +359,7 @@ class LehrauftragJob extends JOB_Controller 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']); + $result = $this->BenutzerrolleModel->getBenutzerByBerechtigung(self::BERECHTIGUNG_LEHRAUFTRAG_ERTEILEN, $data[$i]['oe_kurzbz'], 'suid'); if ($berechtigung_arr = getData($result)) { diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php index 28edf4824..1f5c853db 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php @@ -395,8 +395,12 @@ class approveAnrechnungDetail extends Auth_Controller // Set filename to be used on downlaod $filename = $this->anrechnunglib->setFilenameOnDownload($dms_id); + // Get file to be downloaded from DMS + $download = $this->dmslib->download($dms_id, $filename); + if (isError($download)) return $download; + // Download file - $this->dmslib->download($dms_id, $filename); + $this->outputFile(getData($download)); } /** diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php index 053988848..9eb0c9734 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php @@ -8,13 +8,13 @@ class approveAnrechnungUebersicht extends Auth_Controller const BERECHTIGUNG_ANRECHNUNG_ANLEGEN = 'lehre/anrechnung_anlegen'; const REVIEW_ANRECHNUNG_URI = '/lehre/anrechnung/ReviewAnrechnungUebersicht'; - + const ANRECHNUNGSTATUS_PROGRESSED_BY_STGL = 'inProgressDP'; const ANRECHNUNGSTATUS_PROGRESSED_BY_KF = 'inProgressKF'; const ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR = 'inProgressLektor'; const ANRECHNUNGSTATUS_APPROVED = 'approved'; const ANRECHNUNGSTATUS_REJECTED = 'rejected'; - + public function __construct() { // Set required permissions @@ -27,23 +27,23 @@ class approveAnrechnungUebersicht extends Auth_Controller 'requestRecommendation' => 'lehre/anrechnung_genehmigen:rw' ) ); - + // Load models $this->load->model('education/Anrechnung_model', 'AnrechnungModel'); $this->load->model('education/Anrechnungstatus_model', 'AnrechnungstatusModel'); $this->load->model('content/DmsVersion_model', 'DmsVersionModel'); - + // Load libraries $this->load->library('WidgetLib'); $this->load->library('PermissionLib'); $this->load->library('AnrechnungLib'); $this->load->library('DmsLib'); - + // Load helpers $this->load->helper('form'); $this->load->helper('url'); $this->load->helper('hlp_sancho_helper'); - + // Load language phrases $this->loadPhrases( array( @@ -55,23 +55,23 @@ class approveAnrechnungUebersicht extends Auth_Controller 'table' ) ); - + $this->_setAuthUID(); - + $this->setControllerId(); } - + public function index() { // Get study semester $studiensemester_kurzbz = $this->input->get('studiensemester'); - + if (isEmptyString($studiensemester_kurzbz)) { $result = $this->StudiensemesterModel->getNearest(); $studiensemester_kurzbz = getData($result)[0]->studiensemester_kurzbz; } - + // Get studiengaenge the user is entitled for if (!$studiengang_kz_arr = $this->permissionlib->getSTG_isEntitledFor(self::BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN)) { @@ -91,10 +91,10 @@ class approveAnrechnungUebersicht extends Auth_Controller 'hasReadOnlyAccess' => $hasReadOnlyAccess, 'hasCreateAnrechnungAccess' => $hasCreateAnrechnungAccess ); - + $this->load->view('lehre/anrechnung/approveAnrechnungUebersicht.php', $viewData); } - + /** * Approve Anrechnungen. */ @@ -107,22 +107,30 @@ class approveAnrechnungUebersicht extends Auth_Controller { return $this->outputJsonError('Fehler beim Übertragen der Daten.'); } - + + $json = array( + 'status_kurzbz' => self::ANRECHNUNGSTATUS_APPROVED, + 'status_bezeichnung' => $this->anrechnunglib->getStatusbezeichnung(self::ANRECHNUNGSTATUS_APPROVED), + 'prestudenten' => [] + ); + // Approve Anrechnung foreach ($data as $item) { - if ($this->anrechnunglib->approveAnrechnung($item['anrechnung_id'])) + // Get Prestudent + $this->AnrechnungModel->addSelect('prestudent_id'); + $result = $this->AnrechnungModel->load($item['anrechnung_id']); + $prestudent_id = getData($result)[0]->prestudent_id; + + // Approve + if ($this->anrechnunglib->approveAnrechnung($item['anrechnung_id'])) { - $json[]= array( - 'anrechnung_id' => $item['anrechnung_id'], - 'status_kurzbz' => self::ANRECHNUNGSTATUS_APPROVED, - 'status_bezeichnung' => $this->anrechnunglib->getStatusbezeichnung(self::ANRECHNUNGSTATUS_APPROVED) - ); + $json['prestudenten'][$prestudent_id][] = $item['anrechnung_id']; } } - + // Output json to ajax - if (isset($json) && !isEmptyArray($json)) + if (isset($json) && !isEmptyArray($json['prestudenten'])) { return $this->outputJsonSuccess($json); } @@ -131,20 +139,20 @@ class approveAnrechnungUebersicht extends Auth_Controller return $this->outputJsonError('Es wurden keine Anrechnungen genehmigt.'); } } - + /** * Reject Anrechnungen. */ public function reject() { $data = $this->input->post('data'); - + // Validate data if (isEmptyArray($data)) { return $this->outputJsonError('Fehler beim Übertragen der Daten.'); } - + // Reject Anrechnung foreach ($data as $item) { @@ -157,7 +165,7 @@ class approveAnrechnungUebersicht extends Auth_Controller ); } } - + // Output json to ajax if (isset($json) && !isEmptyArray($json)) { @@ -168,22 +176,22 @@ class approveAnrechnungUebersicht extends Auth_Controller return $this->outputJsonError('Es wurden keine Anrechnungen genehmigt.'); } } - + /** * Request recommendation for Anrechnungen. */ public function requestRecommendation() { $data = $this->input->post('data'); - + if(isEmptyArray($data)) { return $this->outputJsonError('Fehler beim Übertragen der Daten.'); } - + $retval = array(); $counter = 0; - + foreach ($data as $item) { // Check if Anrechnungs-LV has lector @@ -191,7 +199,7 @@ class approveAnrechnungUebersicht extends Auth_Controller { // Count up LV with no lector $counter++; - + // Continue loop, if LV has no lector continue; } @@ -205,7 +213,7 @@ class approveAnrechnungUebersicht extends Auth_Controller $empfehlungsanfrage_an = !isEmptyArray($lector_arr) ? implode(', ', array_column($lector_arr, 'fullname')) : ''; - + $retval[]= array( 'anrechnung_id' => $item['anrechnung_id'], 'status_kurzbz' => self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR, @@ -216,7 +224,7 @@ class approveAnrechnungUebersicht extends Auth_Controller ); } } - + /** * Send mails to lectors * NOTE: mails are sent at the end to ensure sending only ONE mail to each LV-Leitung or lector @@ -226,16 +234,16 @@ class approveAnrechnungUebersicht extends Auth_Controller { self::_sendSanchoMailToLectors($retval); } - + // Output json to ajax if (isEmptyArray($retval) && $counter == 0) { return $this->outputJsonError('Es wurden keine Empfehlungen angefordert'); } - + return $this->outputJsonSuccess($retval); } - + /** * Download and open uploaded document (Nachweisdokument). */ @@ -250,25 +258,28 @@ class approveAnrechnungUebersicht extends Auth_Controller // Check if user is entitled to read dms doc $this->_checkIfEntitledToReadDMSDoc($dms_id); - + // Set filename to be used on downlaod $filename = $this->anrechnunglib->setFilenameOnDownload($dms_id); - + + // Get file to be downloaded from DMS + $download = $this->dmslib->download($dms_id, $filename); + if (isError($download)) return $download; + // Download file - $this->dmslib->download($dms_id, $filename); + $this->outputFile(getData($download)); } - - + /** * 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'); } - + /** * Check if user is entitled to read dms doc * @param $dms_id @@ -276,31 +287,30 @@ class approveAnrechnungUebersicht extends Auth_Controller private function _checkIfEntitledToReadDMSDoc($dms_id) { $result = $this->AnrechnungModel->loadWhere(array('dms_id' => $dms_id)); - + if(!$result = getData($result)[0]) { show_error('Failed retrieving Anrechnung'); } - + $result = $this->LehrveranstaltungModel->loadWhere(array( 'lehrveranstaltung_id' => $result->lehrveranstaltung_id )); - - + if(!$result = getData($result)[0]) { show_error('Failed loading Lehrveranstaltung'); } $studiengang_kz = $result->studiengang_kz; - + // Check if user is entitled if (!$this->permissionlib->isBerechtigt(self::BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN, 's', $studiengang_kz)) { show_error('You are not entitled to read this document'); } } - + /** * Send mail to lectors asking for recommendation. (first to LV-Leitung, if not present to all lectors of lv) * @param $mail_params @@ -310,7 +320,7 @@ class approveAnrechnungUebersicht extends Auth_Controller { // Get Lehrveranstaltungen $anrechnung_arr = array(); - + foreach ($mail_params as $item) { $this->AnrechnungModel->addSelect('lehrveranstaltung_id, studiensemester_kurzbz'); @@ -319,10 +329,10 @@ class approveAnrechnungUebersicht extends Auth_Controller 'studiensemester_kurzbz' => $this->AnrechnungModel->load($item['anrechnung_id'])->retval[0]->studiensemester_kurzbz ); } - + $anrechnung_arr = array_unique($anrechnung_arr, SORT_REGULAR); - + /** * Get lectors (prio for LV-Leitung, if not present to all lectors of LV. * Anyway this function will receive a unique array to avoid sending more mails to one and the same lector. @@ -334,27 +344,27 @@ class approveAnrechnungUebersicht extends Auth_Controller { $to = $lector->uid; $vorname = $lector->vorname; - + // Get full name of stgl $this->load->model('person/Person_model', 'PersonModel'); if (!$stgl_name = getData($this->PersonModel->getFullName($this->_uid))) { show_error ('Failed retrieving person'); } - + // Link to Antrag genehmigen $url = CIS_ROOT. 'cis/index.php?menu='. CIS_ROOT. 'cis/menu.php?content_id=&content='. CIS_ROOT. index_page(). self::REVIEW_ANRECHNUNG_URI; - + // Prepare mail content $body_fields = array( 'vorname' => $vorname, 'stgl_name' => $stgl_name, 'link' => anchor($url, 'Anrechnungsanträge Übersicht') ); - + sendSanchoMail( 'AnrechnungEmpfehlungAnfordern', $body_fields, @@ -364,7 +374,7 @@ class approveAnrechnungUebersicht extends Auth_Controller } return true; } - + /** * Get lectors (prio for LV-Leitung, if not present to all lectors of LV. * Anyway this function will receive a unique array to avoid sending more mails to one and the same lector. @@ -374,18 +384,18 @@ class approveAnrechnungUebersicht extends Auth_Controller private function _getLectors($anrechnung_arr) { $lector_arr = array(); - + // Get lectors foreach($anrechnung_arr as $anrechnung) { $this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel'); $result = $this->LehrveranstaltungModel->getLecturersByLv($anrechnung['studiensemester_kurzbz'], $anrechnung['lehrveranstaltung_id']); - + if (!hasData($result)) { show_error('Failed retrieving lectors of Lehrveranstaltung'); } - + $lecturersByLv = getData($result); // Check if lv has LV-Leitung @@ -401,7 +411,7 @@ class approveAnrechnungUebersicht extends Auth_Controller $lector_arr = array_merge($lector_arr, $lecturersByLv); } } - + /** * NOTE: This step is only done to make the array unique by uid, vorname and nachname in the following step * (e.g. if same lector is ones LV-Leitung and another time not, then array_unique would leave both. @@ -411,10 +421,10 @@ class approveAnrechnungUebersicht extends Auth_Controller { unset($lector->lvleiter); } - + // Now make the lector array aka mail receivers unique $lector_arr = array_unique($lector_arr, SORT_REGULAR); - + return $lector_arr; } -} \ No newline at end of file +} diff --git a/application/controllers/lehre/anrechnung/RequestAnrechnung.php b/application/controllers/lehre/anrechnung/RequestAnrechnung.php index bf98e1c59..bc8ab562e 100644 --- a/application/controllers/lehre/anrechnung/RequestAnrechnung.php +++ b/application/controllers/lehre/anrechnung/RequestAnrechnung.php @@ -205,9 +205,14 @@ class requestAnrechnung extends Auth_Controller } // Check if user is entitled to read dms doc - self::_checkIfEntitledToReadDMSDoc($dms_id); + $this->_checkIfEntitledToReadDMSDoc($dms_id); - $this->dmslib->download($dms_id); + // Get file to be downloaded from DMS + $download = $this->dmslib->download($dms_id, $filename); + if (isError($download)) return $download; + + // Download file + $this->outputFile(getData($download)); } /** @@ -366,4 +371,4 @@ class requestAnrechnung extends Auth_Controller // Upload document return $this->dmslib->upload($dms, 'uploadfile', array('pdf')); } -} \ No newline at end of file +} diff --git a/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php b/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php index 7981f0ac8..f574e7dfc 100644 --- a/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php +++ b/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php @@ -217,15 +217,18 @@ class reviewAnrechnungDetail extends Auth_Controller } // Check if user is entitled to read dms doc - self::_checkIfEntitledToReadDMSDoc($dms_id); + $this->_checkIfEntitledToReadDMSDoc($dms_id); // Set filename to be used on downlaod $filename = $this->anrechnunglib->setFilenameOnDownload($dms_id); - // Download file - $this->dmslib->download($dms_id, $filename); - } + // Get file to be downloaded from DMS + $download = $this->dmslib->download($dms_id, $filename); + if (isError($download)) return $download; + // Download file + $this->outputFile(getData($download)); + } /** * Retrieve the UID of the logged user and checks if it is valid diff --git a/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php index e5475d0d0..974b32393 100644 --- a/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php +++ b/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php @@ -180,13 +180,17 @@ class reviewAnrechnungUebersicht extends Auth_Controller } // Check if user is entitled to read dms doc - self::_checkIfEntitledToReadDMSDoc($dms_id); + $this->_checkIfEntitledToReadDMSDoc($dms_id); // Set filename to be used on downlaod $filename = $this->anrechnunglib->setFilenameOnDownload($dms_id); + // Get file to be downloaded from DMS + $download = $this->dmslib->download($dms_id, $filename); + if (isError($download)) return $download; + // Download file - $this->dmslib->download($dms_id, $filename); + $this->outputFile(getData($download)); } diff --git a/application/controllers/lehre/lvplanung/AdminZeitverfuegbarkeit.php b/application/controllers/lehre/lvplanung/AdminZeitverfuegbarkeit.php new file mode 100644 index 000000000..007b6974d --- /dev/null +++ b/application/controllers/lehre/lvplanung/AdminZeitverfuegbarkeit.php @@ -0,0 +1,310 @@ + 'lehre/zeitverfuegbarkeit:rw', + 'saveZeitverfuegbarkeit' => 'lehre/zeitverfuegbarkeit:rw', + 'deleteZeitverfuegbarkeit' => 'lehre/zeitverfuegbarkeit:rw' + ) + ); + + // Load models + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + $this->load->model('person/Benutzer_model', 'BenutzerModel'); + $this->load->model('person/Person_model', 'PersonModel'); + $this->load->model('ressource/Zeitsperre_model', 'ZeitsperreModel'); + + // Load libraries + $this->load->library('PermissionLib'); + $this->load->library('AuthLib'); + $this->load->library('WidgetLib'); + + // Load helpers + $this->load->helper('array'); + + // Load language phrases + $this->loadPhrases( + array( + 'global', + 'ui', + 'lehre' + ) + ); + + $this->_setAuthUID(); // sets property uid + + $this->setControllerId(); // sets the controller id + } + + // ----------------------------------------------------------------------------------------------------------------- + // Public methods + + public function index() + { + // Get Studiengaenge the user is entitled for + $result = $this->permissionlib->getSTG_isEntitledFor(self::BERECHTIGUNG_ZEITVERFUEGBARKEIT); + $studiengang_kz_arr = !isEmptyArray($result) ? $result : array(); + + // Get lectors of that Studiengaenge + $result = $this->_getLehreinheitmitarbeiterByStg($studiengang_kz_arr); + $lektor_arr = hasData($result) ? getData($result) : array(); + + // Get available Stundenplan Stunden + $result = $this->_getStunden(); + $stunde_arr = hasData($result) ? getData($result) : array(); + + // Get actual Studiensemester to set min-limit Datepicker + $result = $this->StudiensemesterModel->getAkt(); + $studsemStart = hasData($result) ? getData($result)[0]->start : ''; + + $view_data = array( + 'studiengang_kz_arr' => $studiengang_kz_arr, + 'lektor_arr' => $lektor_arr, + 'stunde_arr' => $stunde_arr, + 'studsemStart' => $studsemStart + ); + + $this->load->view('lehre/lvplanung/adminZeitverfuegbarkeit.php', $view_data); + } + + /** + * Save or update Zeitverfuegbarkeit. + */ + public function saveZeitverfuegbarkeit() + { + $zeitsperre_id = $this->input->post('zeitsperre_id'); + $mitarbeiter_uid = $this->input->post('mitarbeiter_uid'); + $zeitsperretyp_kurzbz = $this->input->post('zeitsperretyp_kurzbz'); + $bezeichnung = $this->input->post('bezeichnung'); + $vonDatum = $this->input->post('vondatum'); + $vonStunde = isEmptyString($this->input->post('vonstunde')) ? null : $this->input->post('vonstunde'); + $bisDatum = $this->input->post('bisdatum'); + $bisStunde = isEmptyString($this->input->post('bisstunde')) ? null : $this->input->post('bisstunde'); + + $result = $this->_validate($this->input->post()); + if (isSuccess($result)) + { + if (is_numeric($zeitsperre_id)) + { + $result = $this->ZeitsperreModel->update( + $zeitsperre_id, + array( + 'vondatum' => $vonDatum, + 'vonstunde' => $vonStunde, + 'bisdatum' => $bisDatum, + 'bisstunde' => $bisStunde, + 'bezeichnung' => $bezeichnung + ) + ); + } + else + { + $result = $this->ZeitsperreModel->save( + $zeitsperretyp_kurzbz, + $mitarbeiter_uid, + $vonDatum, + $bisDatum, + $vonStunde, + $bisStunde, + $bezeichnung + ); + } + } + + if (isError($result)) + { + $this->terminateWithJsonError(getError($result)); + } + + $zeitsperre_id = getData($result); + + // Success response to AJAX + $this->outputJsonSuccess(array( + 'zeitsperre_id' => $zeitsperre_id, + 'msg' => $this->p->t('ui', 'gespeichert') + )); + } + + /** + * Delete Zeitverfuegbarkeit. + */ + public function deleteZeitverfuegbarkeit() + { + $zeitsperre_id = $this->input->post('zeitsperre_id'); + + if (!is_numeric($zeitsperre_id)) + { + $this->terminateWithJsonError('Wählen Sie einen Lehrenden aus der Zeitverfügbarkeit-Tabelle aus.'); + } + + // Load Zeitsperre + $result = $this->ZeitsperreModel->load($zeitsperre_id); + $delZsp = getData($result)[0]; + + // Delete + $result = $this->ZeitsperreModel->delete($zeitsperre_id); + + if (isError($result)) + { + $this->terminateWithJsonError(getError($result)); + } + + // Store Deletion query + $delQry = $this->db->last_query(); + + // Log deletion + $this->_logDeletion($delZsp, $delQry); + + $this->outputJsonSuccess(array('msg' => $this->p->t('ui', 'geloescht'))); + } + + // ----------------------------------------------------------------------------------------------------------------- + // 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'); + } + + /** + * Get all lectors that are assigend to Lehreinheiten in actual or future semester. + * + * @param $studiengang_kz_arr Restrict only to given stg- + * @return mixed + */ + private function _getLehreinheitmitarbeiterByStg($studiengang_kz_arr) + { + $this->MitarbeiterModel->addSelect('lema.mitarbeiter_uid, nachname, vorname'); + $this->MitarbeiterModel->addDistinct('lema.mitarbeiter_uid'); + $this->MitarbeiterModel->addJoin('lehre.tbl_lehreinheitmitarbeiter lema', 'tbl_mitarbeiter.mitarbeiter_uid = lema.mitarbeiter_uid'); + $this->MitarbeiterModel->addJoin('public.tbl_benutzer b', 'lema.mitarbeiter_uid = b.uid'); + $this->MitarbeiterModel->addJoin('public.tbl_person p', 'person_id'); + $this->MitarbeiterModel->addJoin('lehre.tbl_lehreinheit le', 'lehreinheit_id'); + $this->MitarbeiterModel->addJoin('lehre.tbl_lehrveranstaltung lv', 'lehrveranstaltung_id'); + $this->MitarbeiterModel->addJoin('public.tbl_studiensemester ss', 'studiensemester_kurzbz'); + $this->MitarbeiterModel->addOrder('lema.mitarbeiter_uid'); + + // Return lektoren assigned to actual or future lehreinheiten + return $this->MitarbeiterModel->loadWhere(' + lv.studiengang_kz IN (' . implode(', ', $studiengang_kz_arr) . ') + AND b.aktiv + AND personalnummer > 0 + AND NOW() <= ss.ende' + ); + } + + /** + * Get all available Stunden of Stundentabelle. + * + * @return mixed + */ + private function _getStunden() + { + $this->load->model('ressource/Stunde_model', 'StundeModel'); + $this->StundeModel->addOrder('stunde'); + + return $this->StundeModel->load(); + } + + /** + * Validaton checks performed on post data. + * + * @param $post + * @return array|stdClass + * @throws Exception + */ + private function _validate($post) + { + if (isEmptyString($post['mitarbeiter_uid'])) + { + return (error('LektorIn fehlt')); + } + + if (isEmptyString($post['bezeichnung'])) + { + return (error('Notiz fehlt')); + } + + if (isEmptyString($post['vondatum'])) + { + return error('Startdatum fehlt'); + } + + if (isEmptyString($post['bisdatum'])) + { + return error('Endedatum fehlt'); + } + + if (new DateTime($post['bisdatum']) < new DateTime($post['vondatum'])) + { + return error('Endedatum darf nicht VOR dem Startdatum liegen'); + } + + // Check bisstunde not after vonstunde within same day + if (new DateTime($post['bisdatum']) == new DateTime($post['vondatum'])) + { + if (is_numeric($post['vonstunde']) && is_numeric($post['bisstunde']) + && $post['bisstunde'] < $post['vonstunde']) + { + return error('Am gleichen Tag darf Endstunde nicht VOR der Startstunde liegen'); + } + } + + // Check dates are > then start of actual Studiensemester + $result = $this->StudiensemesterModel->getAkt(); + $studsemStart = hasData($result) ? getData($result)[0]->start : ''; + + if (new DateTime($post['vondatum']) < new DateTime($studsemStart) || + new DateTime($post['bisdatum']) < new DateTime($studsemStart)) + { + return error('Start- und Endedatum können nur für das aktuelle oder künftige Studiensemester geplant werden'); + } + + return success(); + } + + /** + * Log information of deleted Zeitsperre into log table. + * + * @param $delZsp object of deleted Zeitsperre + * @param $delQry string of performed delete query + * @return mixed + * @throws Exception + */ + private function _logDeletion($delZsp, $delQry) + { + $beschreibung = 'Zeitverfügbarkeitlöschung ' + . $delZsp->mitarbeiter_uid. ' ' + . (new DateTime($delZsp->vondatum))->format('d.m.Y') + . (is_null($delZsp->vonstunde) ? '(*)' : '('. $delZsp->vonstunde. ')') + . '-' + . (new DateTime($delZsp->bisdatum))->format('d.m.Y') + . (is_null($delZsp->bisstunde) ? '(*)' : '('. $delZsp->bisstunde. ')') + . ''; + + $this->load->model('system/Log_model', 'LogModel'); + return $this->LogModel->insert(array( + 'mitarbeiter_uid' => $this->_uid, + 'beschreibung' => substr($beschreibung, 0, 64), + 'sql' => $delQry + )); + } +} diff --git a/application/controllers/system/Variables.php b/application/controllers/system/Variables.php index c56407416..3cc246301 100644 --- a/application/controllers/system/Variables.php +++ b/application/controllers/system/Variables.php @@ -18,10 +18,10 @@ class Variables extends Auth_Controller { parent::__construct( array( - 'setVar' => 'basis/variable:rw', - 'getVar' => 'basis/variable:rw', - 'changeStudiensemesterVar' => 'basis/variable:rw', - 'changeStudengangsTypVar' => 'basis/variable:rw' + 'setVar' => array('basis/variable:rw','basis/variable_persoenlich:rw'), + 'getVar' => array('basis/variable:rw','basis/variable_persoenlich:rw'), + 'changeStudiensemesterVar' => array('basis/variable:rw','basis/variable_persoenlich:rw'), + 'changeStudengangsTypVar' => array('basis/variable:rw','basis/variable_persoenlich:rw') ) ); diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index 25ee96b60..76011dc04 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -125,9 +125,9 @@ class InfoCenter extends Auth_Controller 'zgvStatusUpdate' => 'lehre/zgvpruefung:rw', 'saveAbsage' => 'infocenter:rw', 'saveFreigabe' => 'infocenter:rw', - 'getNotiz' => 'infocenter:r', + 'getNotiz' => array('infocenter:r', 'lehre/zgvpruefung:r'), 'saveNotiz' => array('infocenter:rw', 'lehre/zgvpruefung:rw'), - 'updateNotiz' => 'infocenter:rw', + 'updateNotiz' => array('infocenter:rw', 'lehre/zgvpruefung:rw'), 'reloadZgvPruefungen' => 'infocenter:r', 'reloadMessages' => 'infocenter:r', 'reloadDoks' => 'infocenter:r', diff --git a/application/controllers/system/infocenter/ZGVUeberpruefung.php b/application/controllers/system/infocenter/ZGVUeberpruefung.php index bb0c36b66..7d178a529 100644 --- a/application/controllers/system/infocenter/ZGVUeberpruefung.php +++ b/application/controllers/system/infocenter/ZGVUeberpruefung.php @@ -4,6 +4,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class ZGVUeberpruefung extends Auth_Controller { + const BERECHTIGUNG_KURZBZ = 'lehre/zgvpruefung'; + /** * Constructor */ @@ -12,14 +14,15 @@ class ZGVUeberpruefung extends Auth_Controller // Set required permissions parent::__construct( array( - 'index' => 'lehre/zgvpruefung:r', - 'getZgvStatusByPrestudent' => 'lehre/zgvpruefung:r' + 'index' => self::BERECHTIGUNG_KURZBZ.':r', + 'getZgvStatusByPrestudent' => self::BERECHTIGUNG_KURZBZ.':r' ) ); $this->load->model('crm/ZGVPruefungStatus_model', 'ZGVPruefungStatusModel'); $this->load->model('crm/ZGVPruefung_model', 'ZGVPruefungModel'); $this->load->library('WidgetLib'); + $this->load->library('PermissionLib'); $this->setControllerId(); $this->loadPhrases( @@ -31,7 +34,14 @@ class ZGVUeberpruefung extends Auth_Controller public function index() { - $this->load->view('system/infocenter/infocenterZgvUeberpruefung.php'); + $oeKurzbz = $this->permissionlib->getOE_isEntitledFor(self::BERECHTIGUNG_KURZBZ); + + if (!$oeKurzbz) + show_error('Keine Berechtigung.'); + + $data['oeKurz'] = $oeKurzbz; + + $this->load->view('system/infocenter/infocenterZgvUeberpruefung.php', $data); } public function getZgvStatusByPrestudent() diff --git a/application/controllers/system/issues/Issues.php b/application/controllers/system/issues/Issues.php index e0103cfec..da92c251c 100644 --- a/application/controllers/system/issues/Issues.php +++ b/application/controllers/system/issues/Issues.php @@ -6,7 +6,7 @@ class Issues extends Auth_Controller { private $_uid; - const FUNKTION_KURZBZ = 'ass'; // // user having this funktion can see issues for oes assigned with this funktion + const FUNKTION_KURZBZ = 'ass'; // user having this funktion can see issues for oes assigned with this funktion const BERECHTIGUNG_KURZBZ = 'system/issues_verwalten'; // user having this permission can see issues for oes assigned with this permission public function __construct() @@ -39,6 +39,7 @@ class Issues extends Auth_Controller ); $this->_setAuthUID(); // sets property uid + $this->setControllerId(); // sets the controller id } public function index() @@ -127,7 +128,7 @@ class Issues extends Auth_Controller { $all_funktionen_oe_kurzbz[$benutzerfunktion->oe_kurzbz][] = $benutzerfunktion->funktion_kurzbz; - // separate oes for the funktion needed for displaying issues + // separate oes for the additional funktion which enables displaying issues if ($benutzerfunktion->funktion_kurzbz == self::FUNKTION_KURZBZ) { $oe_kurzbz_for_funktion[] = $benutzerfunktion->oe_kurzbz; @@ -153,7 +154,9 @@ class Issues extends Auth_Controller } // add oes for which there is the "manage issues" Berechtigung - if (!$oe_kurzbz_berechtigt = $this->permissionlib->getOE_isEntitledFor(self::BERECHTIGUNG_KURZBZ)) + $oe_kurzbz_berechtigt = $this->permissionlib->getOE_isEntitledFor(self::BERECHTIGUNG_KURZBZ); + + if (!$oe_kurzbz_berechtigt) show_error('No permission or error when checking permissions'); $all_oe_kurzbz_berechtigt = array_unique(array_merge($oe_kurzbz_for_funktion, $oe_kurzbz_berechtigt)); diff --git a/application/controllers/system/issues/IssuesZustaendigkeiten.php b/application/controllers/system/issues/IssuesZustaendigkeiten.php new file mode 100644 index 000000000..fd3e6192a --- /dev/null +++ b/application/controllers/system/issues/IssuesZustaendigkeiten.php @@ -0,0 +1,217 @@ + 'admin:r', + 'getApps' => 'admin:r', + 'getFehlercodes' => 'admin:r', + 'getNonAssignedZustaendigkeiten' => 'admin:r', + 'addZustaendigkeit' => 'admin:rw', + 'deleteZustaendigkeit' => 'admin:rw' + ) + ); + + // Load libraries + $this->load->library('IssuesLib'); + $this->load->library('WidgetLib'); + + // Load models + $this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); + $this->load->model('system/Fehler_model', 'FehlerModel'); + $this->load->model('system/Fehler_model', 'FehlerModel'); + $this->load->model('system/Fehlerzustaendigkeiten_model', 'FehlerzustaendigkeitenModel'); + + $this->loadPhrases( + array( + 'global', + 'ui', + 'filter', + 'lehre', + 'person', + 'fehlermonitoring' + ) + ); + + $this->_setAuthUID(); // sets property uid + $this->setControllerId(); // sets the controller id + } + + public function index() + { + $this->load->view("system/issues/issuesZustaendigkeiten.php"); + } + + /** + * Loads all Apps to which Fehler exist. + */ + public function getApps() + { + $this->FehlerModel->addDistinct(); + $this->FehlerModel->addSelect('app'); + $this->FehlerModel->addOrder('app'); + + $appRes = $this->FehlerModel->load(); + + $this->outputJson($appRes); + } + + /** + * Gets all fehlercodes, optionally by app. + */ + public function getFehlercodes() + { + $app = $this->input->get('app'); + + //$this->FehlerModel->addSelect('fehlercode, fehler_kurzbz, fehlertext, fehlertyp_kurzbz'); + $this->FehlerModel->addOrder('fehlercode'); + + $fehlerRes = isset($app) ? $this->FehlerModel->loadWhere(array('app' => $app)) : $this->FehlerModel->load(); + + $this->outputJson($fehlerRes); + } + + /** + * Gets all Mitarbeiter, Organisationseinheiten, Funktionen not assigned to a Fehler yet. + */ + public function getNonAssignedZustaendigkeiten() + { + $fehlercode = $this->input->get('fehlercode'); + + $mitarbeiterRes = $this->FehlerzustaendigkeitenModel->getNonAssignedMitarbeiter($fehlercode); + + if (isError($mitarbeiterRes)) + { + $this->outputJsonError(getError($mitarbeiterRes)); + return; + } + + $this->OrganisationseinheitModel->addSelect('oe_kurzbz, bezeichnung, organisationseinheittyp_kurzbz'); + $this->OrganisationseinheitModel->addOrder('organisationseinheittyp_kurzbz, bezeichnung'); + $oeRes = $this->OrganisationseinheitModel->loadWhere(array('aktiv' => true)); + + if (isError($oeRes)) + { + $this->outputJsonError(getError($oeRes)); + return; + } + + $oe_funktionen = array(); + + if (hasData($oeRes)) + { + $oes = getData($oeRes); + + foreach ($oes as $oe) + { + $oe->funktionen = array(); + $funktionRes = $this->FehlerzustaendigkeitenModel->getNonAssignedFunktionen($fehlercode, $oe->oe_kurzbz); + + if (isError($funktionRes)) + { + $this->outputJsonError(getError($oeRes)); + return; + } + + $funktionData = getData($funktionRes); + $oe->funktionen = $funktionData; + $oe_funktionen[] = $oe; + } + } + + if (isError($funktionRes)) + { + $this->outputJsonError(getError($funktionRes)); + return; + } + + $result = array( + 'mitarbeiter' => getData($mitarbeiterRes), + 'oe_funktionen' => $oe_funktionen + ); + + $this->outputJsonSuccess($result); + } + + /** + * Adds a Zuständigkeit after performing error checks. + */ + public function addZustaendigkeit() + { + $fehlercode = $this->input->post('fehlercode'); + $mitarbeiter_person_id = $this->input->post('mitarbeiter_person_id'); + $oe_kurzbz = $this->input->post('oe_kurzbz'); + $funktion_kurzbz = $this->input->post('funktion_kurzbz'); + + if (isEmptyString($fehlercode)) + $this->outputJsonError($this->p->t('fehlermonitoring', 'fehlercodeFehlt')); + elseif (isEmptyString($mitarbeiter_person_id) && isEmptyString($oe_kurzbz)) + $this->outputJsonError($this->p->t('fehlermonitoring', 'mitarbeiterUndOeFehlt')); + elseif (!isEmptyString($mitarbeiter_person_id) && !isEmptyString($oe_kurzbz)) + $this->outputJsonError($this->p->t('fehlermonitoring', 'nurOeOderMitarbeiterSetzen')); + elseif (isset($mitarbeiter_person_id) && !is_numeric($mitarbeiter_person_id)) + $this->outputJsonError($this->p->t('fehlermonitoring', 'ungueltigeMitarbeiterId')); + else + { + $data = array( + 'fehlercode' => $fehlercode + ); + + if (!isEmptyString($mitarbeiter_person_id)) + $data['person_id'] = $mitarbeiter_person_id; + + if (!isEmptyString($oe_kurzbz)) + $data['oe_kurzbz'] = $oe_kurzbz; + + if (!isEmptyString($funktion_kurzbz)) + $data['funktion_kurzbz'] = $funktion_kurzbz; + + $zustaendigkeitExistsRes = $this->FehlerzustaendigkeitenModel->loadWhere($data); + + if (isError($zustaendigkeitExistsRes)) + $this->outputJsonError(getError($zustaendigkeitExistsRes)); + elseif (hasData($zustaendigkeitExistsRes)) + $this->outputJsonError($this->p->t('fehlermonitoring', 'zustaendigkeitExistiert')); + else + { + $data['insertvon'] = $this->_uid; + + $this->outputJson($this->FehlerzustaendigkeitenModel->insert($data)); + } + } + } + + /** + * Deletes a Zuständigkeit. + */ + public function deleteZustaendigkeit() + { + $fehlerzustaendigkeiten_id = $this->input->post('fehlerzustaendigkeiten_id'); + + // check if Id correctly passed + if (!isset($fehlerzustaendigkeiten_id) || !is_numeric($fehlerzustaendigkeiten_id)) + { + $this->outputJsonError($this->p->t('fehlermonitoring', 'ungueltigeZustaendigkeitenId')); + return; + } + + $this->outputJson($this->FehlerzustaendigkeitenModel->delete($fehlerzustaendigkeiten_id)); + } + + /** + * Retrieve the UID of the logged user and checks if it is valid + */ + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) show_error('User authentification failed'); + } +} diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php index 4e555be6c..bdd5316e7 100644 --- a/application/core/DB_Model.php +++ b/application/core/DB_Model.php @@ -22,11 +22,16 @@ class DB_Model extends CI_Model const PGSQL_BOOLEAN_FALSE = 'f'; const PGSQL_BOOLEAN_TYPE = 'bool'; const PGSQL_BOOLEAN_ARRAY_TYPE = '_bool'; + const PGSQL_INT2_TYPE = 'int2'; + const PGSQL_INT4_TYPE = 'int4'; + const PGSQL_INT8_TYPE = 'int8'; + const PGSQL_FLOAT4_TYPE = 'float4'; + const PGSQL_FLOAT8_TYPE = 'float8'; protected $dbTable; // Name of the DB-Table for CI-Insert, -Update, ... - protected $pk; // Name of the PrimaryKey for DB-Update, Load, ... + protected $pk; // Name of the PrimaryKey for DB-Update, Load, ... protected $hasSequence; // False if this table has a composite primary key that is not using a sequence - // True if this table has a primary key that uses a sequence + // True if this table has a primary key that uses a sequence private $executedQueryMetaData; private $executedQueryListFields; @@ -271,11 +276,6 @@ class DB_Model extends CI_Model /** * Load data and convert a record into a list of data from the main table, * and linked to every element, the data from the side tables - * - * TODO: - * - Adding support for composed primary key - * - Adding support for cascading side tables (useful?) - * * NOTE: sub queries are not supported in the from clause * * @return array @@ -598,6 +598,28 @@ class DB_Model extends CI_Model return $val; } + /** + * Convert PG-Int* to PHP-Integer + */ + public function pgIntPhp($val) + { + // If it is null, let it be null + if ($val == null) return $val; + + return intval($val); + } + + /** + * Convert PG-Float* to PHP-Float + */ + public function pgFloatPhp($val) + { + // If it is null, let it be null + if ($val == null) return $val; + + return floatval($val); + } + /** * Converts from PostgreSQL array to php array * It also takes care about array of booleans @@ -892,6 +914,11 @@ class DB_Model extends CI_Model // If array type, boolean type OR a UDF if (strpos($eqmd->type, DB_Model::PGSQL_ARRAY_TYPE) !== false || $eqmd->type == DB_Model::PGSQL_BOOLEAN_TYPE + || $eqmd->type == DB_Model::PGSQL_INT2_TYPE + || $eqmd->type == DB_Model::PGSQL_INT4_TYPE + || $eqmd->type == DB_Model::PGSQL_INT8_TYPE + || $eqmd->type == DB_Model::PGSQL_FLOAT4_TYPE + || $eqmd->type == DB_Model::PGSQL_FLOAT8_TYPE || $this->udflib->isUDFColumn($eqmd->name, $eqmd->type)) { // If UDFs are inside this result set @@ -941,6 +968,19 @@ class DB_Model extends CI_Model { $resultElement->{$toBeConverted->name} = $this->pgBoolPhp($resultElement->{$toBeConverted->name}); } + // Integer type + elseif ($toBeConverted->type == DB_Model::PGSQL_INT2_TYPE + || $toBeConverted->type == DB_Model::PGSQL_INT4_TYPE + || $toBeConverted->type == DB_Model::PGSQL_INT8_TYPE) + { + $resultElement->{$toBeConverted->name} = $this->pgIntPhp($resultElement->{$toBeConverted->name}); + } + // Float type + elseif ($toBeConverted->type == DB_Model::PGSQL_FLOAT4_TYPE + || $toBeConverted->type == DB_Model::PGSQL_FLOAT8_TYPE) + { + $resultElement->{$toBeConverted->name} = $this->pgFloatPhp($resultElement->{$toBeConverted->name}); + } } } } diff --git a/application/core/FHC_Controller.php b/application/core/FHC_Controller.php index ce8748c5a..c71d5f6d0 100644 --- a/application/core/FHC_Controller.php +++ b/application/core/FHC_Controller.php @@ -121,7 +121,7 @@ abstract class FHC_Controller extends CI_Controller protected function terminateWithJsonError($message) { header('Content-Type: application/json'); - echo json_encode(error($message)); + echo json_encode(error($message)); // KEEP IT!!! exit; } @@ -132,31 +132,41 @@ abstract class FHC_Controller extends CI_Controller { $this->output->set_content_type('application/json')->set_output(json_encode($mixed)); } - + + /** + * To download the given file represented by the fileObj parameter. + * fileObj has the following structure: + * $fileObj->filename + * $fileObj->file + * $fileObj->name + * $fileObj->mimetype + * $fileObj->disposition + */ protected function outputFile($fileObj) { - if (file_exists($fileObj->file)) + // If the file exists + if (isset($fileObj->file) && !isEmptyString($fileObj->file) && file_exists($fileObj->file)) { - $finfo = new finfo(FILEINFO_MIME); - header('Content-Description: File Transfer'); - header('Content-Type: '. $finfo->file($fileObj->file)); + header('Content-Type: '. $fileObj->mimetype); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($fileObj->file)); - - if (isset($fileObj->disposition) && ($fileObj->disposition == 'inline' || $fileObj->disposition == 'attachment')) + + if (isset($fileObj->disposition) + && ($fileObj->disposition == 'inline' || $fileObj->disposition == 'attachment')) { header('Content-Disposition: '. $fileObj->disposition. '; filename="'. $fileObj->name. '"'); } - - readfile($fileObj->file); - - exit; + + readfile($fileObj->file); // reads the file content to the output buffer + } + else + { + // Otherwise print an error + show_error('The provided file does not exist: '.(isset($fileObj->file) ? $fileObj->file : 'file not given')); } - - return false; } //------------------------------------------------------------------------------------------------------------------ diff --git a/application/core/FS_Model.php b/application/core/FS_Model.php index 03a0ee095..0d696d378 100644 --- a/application/core/FS_Model.php +++ b/application/core/FS_Model.php @@ -3,113 +3,238 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); /** - * + * Model to work with the filesystem, it represents a directory + * It could be extended or could be used directly to work on the given path */ -abstract class FS_Model extends CI_Model +class FS_Model extends CI_Model { - protected $filepath; // Path of the file + const READ_MODE = 'r'; + const READ_WRITE_MODE = 'w+'; + const READ_APPEND_MODE = 'a+'; + const BLOCK_SIZE = 8192; + const META_URI = 'uri'; + + private $_path; // Directory where this model can operate /** - * Loads FilesystemLib and set properties + * Set properties */ - public function __construct($filepath = null) + public function __construct($path) { parent::__construct(); - // Load the filesystem library - $this->load->library('FilesystemLib'); + $this->_path = $path; + } - $this->filepath = $filepath; + // ------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Opens a file in read mode and returns its file handle + */ + public function openRead($filename) + { + return $this->_open($filename, self::READ_MODE); } /** - * Read data from file system - * - * @return array + * Opens a file in read and write mode and returns its file handle + * If the file does not exist then it is created */ - public function read($filename) + public function openReadWrite($filename) { - // Check Class-Attributes - if (is_null($this->filepath)) return error('The given filepath in not valid', EXIT_ERROR); - - // Check method parameters - if (is_null($filename)) return error('The given filename is not valid', EXIT_ERROR); - - if (!is_null($data = $this->filesystemlib->read($this->filepath, $filename))) - { - return success(base64_encode($data)); - } - else - { - return error('An error occurred while reading a file', EXIT_ERROR); - } + return $this->_open($filename, self::READ_WRITE_MODE); } /** - * Writing data to file system - * - * @param string $fileContent File content - * @return object + * Opens a file in read and append mode and returns its file handle + * If the file does not exist then it is created */ - public function write($filename, $content) + public function openReadAppend($filename) { - // Check Class-Attributes - if (is_null($this->filepath)) return error('The given filepath in not valid', EXIT_ERROR); + return $this->_open($filename, self::READ_APPEND_MODE); + } - // Check method parameters - if (is_null($content)) return error('The given file content is not valid', EXIT_ERROR); - if (is_null($filename)) return error('The given filename is not valid', EXIT_ERROR); + /** + * Closes a file handle + */ + public function close($fileHandle) + { + return fclose($fileHandle) === true ? success() : error('Error while closing the file handler'); + } - if ($this->filesystemlib->write($this->filepath, $filename, base64_decode($content)) === true) + /** + * Reads a block of bytes from the given file + * Returns a success that contains the block + * On failure returns an error + */ + public function readBlock($fileHandle) + { + // Reads a block of bytes from the file + $block = fread($fileHandle, self::BLOCK_SIZE); + + // If an error occurred + if ($block === false) + { + // Prepare the error message + $errorMsg = 'An error occurred while reading a file'; + + // Tries to get the file name and to concatenate it to the error message + $fileMetaData = stream_get_meta_data($fileHandle); + if (isset($fileMetaData[self::META_URI])) $errorMsg .= ': '.$fileMetaData[self::META_URI]; + + return error($errorMsg); // returns the error + } + + return success($block); // return success if everything was fine + } + + /** + * Writes/appends (depending on how the file was opened) a content into a file + * Returns a success that contains the written number of bytes + * On failure returns an error + */ + public function write($fileHandle, $content) + { + // Writes the provided content to the file + $writeResult = fwrite($fileHandle, $content); + + // If an error occurred + if ($writeResult === false) + { + $errorMsg = 'An error occurred while writing a file'; + + // Tries to get the file name and to concatenate it to the error message + $fileMetaData = stream_get_meta_data($fileHandle); + if (isset($fileMetaData[self::META_URI])) $errorMsg .= ': '.$fileMetaData[self::META_URI]; + + return error($errorMsg); // returns the error + } + + return success($writeResult); + } + + /** + * Removes a given file + */ + public function remove($filename) + { + // Check if the property _path represents a valid directory + $checkResult = $this->_checkPath(); + + if (isError($checkResult)) return $checkResult; // If not then return the error + + // Check filename + if (isEmptyString($filename)) return error('The given filename is not valid'); + + // remove file + if (unlink($this->_path.DIRECTORY_SEPARATOR.$filename) === true) { return success(); } else { - return error('An error occurred while writing a file', EXIT_ERROR); + return error('An error occurred while removing a file'); } } + // ------------------------------------------------------------------------------------------------------------------ + // Old public methods that work with the base64 encoding, not to be used! + /** - * Append data to a file - * - * @param array $data File content - * @return array + * Read data from the given file and encode its content to base64 */ - public function append($filename, $content) + public function readBase64($filename) { - // Check Class-Attributes - if (is_null($this->filepath)) return error('The given filepath in not valid', EXIT_ERROR); + // Open the file in read mode + $openReadResult = $this->openRead($filename); + if (isError($openReadResult)) return $openReadResult; // if an error occurred then return it - // Check method parameters - if (is_null($content)) return error('The given file content is not valid', EXIT_ERROR); - if (is_null($filename)) return error('The given filename is not valid', EXIT_ERROR); + $fileContent = ''; // to store the file content + $fileHandle = getData($openReadResult); // get the file handle - if ($this->filesystemlib->append($this->filepath, $filename, base64_decode($content)) === true) + // While the end of the file is not reached and the read does not fail + while (!feof($fileHandle) && isSuccess($readBlockResult = $this->readBlock($fileHandle))) { - return success(); - } - else - { - return error('An error occurred while appending to a file', EXIT_ERROR); + // Concatenate the content of the file + $fileContent .= getData($readBlockResult); } + + // If an error occurred while reading then return it + if (isError($readBlockResult)) return $readBlockResult; + + // Close the file handler + $closeResult = $this->close($fileHandle); + if (isError($closeResult)) return $closeResult; // if it fails then return the error + + // If everything was fine encode the file content into base64 and return it as a success + return success(base64_encode($fileContent)); + } + + /** + * Writes the given content into the given file. The content is base64 encoded + */ + public function writeBase64($filename, $content) + { + // Open the file in read and write mode + $openWriteResult = $this->openReadWrite($filename); + if (isError($openWriteResult)) return $openWriteResult; // if an error occurred then return it + + $fileHandle = getData($openWriteResult); // get the file handle + + // Writes the given base64 encoded content into to given file + $writeResult = $this->write($fileHandle, base64_decode($content)); + // If an error occurred while writing then return it + if (isError($writeResult)) return $writeResult; + + // Close the file handler + $closeResult = $this->close($fileHandle); + if (isError($closeResult)) return $closeResult; // if it fails then return the error + + // If everything was fine + return success(); + } + + /** + * Appends the given content into the given file. The content is base64 encoded + */ + public function appendBase64($filename, $content) + { + // Open the file in read and append mode + $openWriteResult = $this->openReadAppend($filename); + if (isError($openWriteResult)) return $openWriteResult; // if an error occurred then return it + + $fileHandle = getData($openWriteResult); // get the file handle + + // Writes the given base64 encoded content into to given file + $writeResult = $this->write($fileHandle, base64_decode($content)); + // If an error occurred while writing then return it + if (isError($writeResult)) return $writeResult; + + // Close the file handler + $closeResult = $this->close($fileHandle); + if (isError($closeResult)) return $closeResult; // if it fails then return the error + + // If everything was fine + return success(); } /** * Delete data from file system + * NOTE: it does not work with the base64 encoding but it has been kept for retro compatibility * * @param string $id Primary Key for DELETE * @return array */ - public function remove($filename) + public function removeBase64($filename) { // Check Class-Attributes - if (is_null($this->filepath)) return error('The given filepath in not valid', EXIT_ERROR); + if (is_null($this->_path)) return error('The given _path in not valid', EXIT_ERROR); // Check method parameters if (is_null($filename)) return error('The given filename is not valid', EXIT_ERROR); - if ($this->filesystemlib->remove($this->filepath, $filename) === true) + if (unlink($this->_path.DIRECTORY_SEPARATOR.$filename) === true) { return success(); } @@ -121,20 +246,21 @@ abstract class FS_Model extends CI_Model /** * Rename a file + * NOTE: it does not work with the base64 encoding but it has been kept for retro compatibility * * @param string $id Primary Key for DELETE * @return array */ - public function rename($filename, $newFilename) + public function renameBase64($filename, $newFilename) { // Check Class-Attributes - if (is_null($this->filepath)) return error('The given filepath in not valid', EXIT_ERROR); + if (is_null($this->_path)) return error('The given _path in not valid', EXIT_ERROR); // Check method parameters if (is_null($filename)) return error('The given filename is not valid', EXIT_ERROR); if (is_null($newFilename)) return error('The given new filename is not valid', EXIT_ERROR); - if ($this->filesystemlib->rename($this->filepath, $filename, $this->filepath, $newFilename) === true) + if (rename($this->_path.DIRECTORY_SEPARATOR.$filename, $this->_path.DIRECTORY_SEPARATOR.$newFilename) === true) { return success(); } @@ -143,4 +269,67 @@ abstract class FS_Model extends CI_Model return error('An error occurred while renaming a file', EXIT_ERROR); } } + + // ------------------------------------------------------------------------------------------------------------------ + // Private methods + + /** + * Checks if the given $this->_path is a valid directory + */ + private function _checkPath() + { + // If _path... + if (!isEmptyString($this->_path) // ...is a not empty string... + && file_exists($this->_path) && is_dir($this->_path)) // ...exists on the file system and it is a directory... + { + return success(); // return a success + } + + // If not a valid path return an error + return error('The given path is not valid: '.$this->_path); + } + + /** + * Open a file using the provided mode + * It returns a file handle + * Or write and append if the file does not exist then creates it + */ + private function _open($filename, $mode) + { + // Check if the property _path represents a valid directory + $checkResult = $this->_checkPath(); + if (isError($checkResult)) return $checkResult; // If not then return the error + + // Full file path: path + filename + $fileFullPath = $this->_path.DIRECTORY_SEPARATOR.$filename; + + // If needed then check if the file exists and really it is a file + if ($mode == self::READ_MODE && (!file_exists($fileFullPath) || !is_file($fileFullPath))) + { + return error('Trying to read a not existing file'); + } + + // If needed then check if it is possible to read from the path and the file + if ($mode == self::READ_MODE && (!is_readable($this->_path) || !is_readable($fileFullPath))) + { + return error('The given path or filename are not readable: '.$fileFullPath); + } + + // If needed then check if the path and the filename are writable + if (($mode == self::READ_WRITE_MODE || $mode == self::READ_APPEND_MODE) + && (!is_writable($this->_path) || (file_exists($fileFullPath) && !is_writable($fileFullPath)))) + { + return error('The given path or filename are not writable: '.$fileFullPath); + } + + // Open the file in read mode + $fileHandle = fopen($fileFullPath, $mode); + + // If it was a failure the return the error + if ($fileHandle === false) return error('An error occurred while opening a file in '.$mode.' mode'); + + // Otherwise return the file handle + return success($fileHandle); + } } + diff --git a/application/helpers/hlp_sancho_helper.php b/application/helpers/hlp_sancho_helper.php index 1653c44e7..d599e40bc 100644 --- a/application/helpers/hlp_sancho_helper.php +++ b/application/helpers/hlp_sancho_helper.php @@ -74,7 +74,7 @@ function sendSanchoMail($vorlage_kurzbz, $vorlage_data, $to, $subject, $headerIm $body = _parseMailContent('Sancho_Mail_Template', $layout); // Send mail - $ci->maillib->send($from, $to, $subject, $body, $alias = '', $cc, $bcc, $altMessage = '', $bulk = true, $autogenerated = true); + return $ci->maillib->send($from, $to, $subject, $body, $alias = '', $cc, $bcc, $altMessage = '', $bulk = true, $autogenerated = true); } /** diff --git a/application/libraries/AkteLib.php b/application/libraries/AkteLib.php new file mode 100644 index 000000000..c4aee0095 --- /dev/null +++ b/application/libraries/AkteLib.php @@ -0,0 +1,268 @@ +_ci =& get_instance(); + + // Set the the _who property + $this->_who = 'Akte system'; // default + // It is possible to set it using the who parameter + if (!isEmptyArray($params) && isset($params['who']) && !isEmptyString($params['who'])) $this->_who = $params['who']; + + $this->_ci->load->model('crm/Akte_model', 'AkteModel'); + $this->_ci->load->model('content/DmsFS_model', 'DmsFSModel'); + + $this->_ci->load->library('DmsLib'); + } + + /** + * Writes a new file, adds a new dms entry with given akte data, + * adds a new dms version 0 for the written file, and adds Akte if dms add was successfull + * Returns success with inserted akte id or error + */ + public function add( + $person_id, $dokument_kurzbz, $titel, $mimetype, $fileHandle, // Required parameters + $bezeichnung = null, $archiv = false, $signiert = false, $stud_selfservice = false + ) + { + // add new dms entry and new dms version for the Akte, using Akte data (title, mimetype, file content as handle) + $dmsAddResult = $this->_ci->dmslib->add($titel, $mimetype, $fileHandle, self::AKTE_KATEGORIE_KURZBZ, $dokument_kurzbz, $bezeichnung); + + if (isError($dmsAddResult)) return $dmsAddResult; + + if (!hasData($dmsAddResult)) return error("Dms document could not be added"); + + $dmsAddData = getData($dmsAddResult); + + // insert the Akte + return $this->_ci->AkteModel->insert( + array( + 'person_id' => $person_id, + 'dokument_kurzbz' => $dokument_kurzbz, + 'titel' => $titel, + 'mimetype' => $mimetype, + 'bezeichnung' => $bezeichnung, + 'erstelltam' => date('Y-m-d'), + 'dms_id' => $dmsAddData->dms_id, + 'archiv' => $archiv, + 'signiert' => $signiert, + 'stud_selfservice' => $stud_selfservice, + 'insertamum' => date('Y-m-d H:i:s'), + 'insertvon' => $this->_who + ) + ); + } + + /** + * Writes a new file, adds a new dms version 0 for the written file, and updates Akte if dms version add was successfull + * Returns success with updated akte id or error + */ + public function update($akte_id, $titel, $mimetype, $fileHandle, $bezeichnung = null, $archiv = false, $signiert = false, $stud_selfservice = false) + { + // check if Akte with dms exists + $this->_ci->AkteModel->addSelect('dms_id'); + $akteResult = $this->_ci->AkteModel->load($akte_id); + + if (isError($akteResult)) return $akteResult; + + if (!hasData($akteResult)) return error("Akte not found"); + + $dms_id = getData($akteResult)[0]->dms_id; + + if (isEmptyString($dms_id)) return error("Akte has no dms document"); + + // if Akte with dms found, update the last dms version + $dmsUpdateResult = $this->_ci->dmslib->updateLastVersion($dms_id, $fileHandle, $titel, $mimetype, $bezeichnung); + + if (isError($dmsUpdateResult)) return $dmsUpdateResult; + + if (!hasData($dmsUpdateResult)) return error("Dms document could not be updated"); + + // update the Akte + return $this->_ci->AkteModel->update( + $akte_id, + array( + 'titel' => $titel, + 'mimetype' => $mimetype, + 'bezeichnung' => $bezeichnung, + 'erstelltam' => date('Y-m-d'), + 'dms_id' => $dms_id, + 'archiv' => $archiv, + 'signiert' => $signiert, + 'stud_selfservice' => $stud_selfservice, + 'updateamum' => date('Y-m-d H:i:s'), + 'updatevon' => $this->_who + ) + ); + } + + /** + * Gets akte data and associated dms data by akte Id + * Returns success with akte and dms data or error + */ + public function get($akte_id) + { + // get Akte data + $this->_ci->AkteModel->addSelect('person_id, dokument_kurzbz, mimetype, erstelltam, titel, bezeichnung, + gedruckt, uid, dms_id, nachgereicht, nachgereicht_am, anmerkung, + ausstellungsnation, formal_geprueft_amum, archiv, signiert, + stud_selfservice, akzeptiertamum, insertvon, insertamum, updatevon, updateamum'); + $this->_ci->AkteModel->load($akte_id); + $akteResult = $this->_ci->AkteModel->load($akte_id); + + if (isError($akteResult)) return $akteResult; + + if (!hasData($akteResult)) return error("Akte not found"); + + $resultObject = getData($akteResult)[0]; + + // set properties with same name in Akte and Dms table + $resultObject->akte_mimetype = $resultObject->mimetype; + + // get dms data + $dmsResult = $this->_ci->dmslib->getLastVersion($resultObject->dms_id); + + if (isError($dmsResult)) return $dmsResult; + + // properties to retrieve from dms + $dmsProperties = array('version', 'filename', 'mimetype', 'name', 'beschreibung', 'cis_suche', 'schlagworte', DmsLib::FILE_CONTENT_PROPERTY); + + // set dms properties + if (hasData($dmsResult)) + { + $dmsData = getData($dmsResult); + + foreach ($dmsProperties as $dmsProperty) + { + $resultObject->{$dmsProperty} = $dmsData->{$dmsProperty}; + } + } + else + { + // set null if no dms result found + foreach ($dmsProperties as $dmsProperty) + { + $resultObject->{$dmsProperty} = null; + } + } + + // return the object containing akte and dms data + return success($resultObject); + } + + /** + * Gets Akte data and associated dms data by person Id and dokument_kurzbz + * Returns success with result array with akte and dms data or error + */ + public function getByPersonIdAndDocumentType($person_id, $dokument_kurzbz) + { + // load all Akte entries for given person and dokument_kurzbz + $this->_ci->AkteModel->addSelect('akte_id'); + $akteResult = $this->_ci->AkteModel->loadWhere( + array( + 'person_id' => $person_id, + 'dokument_kurzbz' => $dokument_kurzbz + ) + ); + + if (!hasData($akteResult)) return error("Akte not found"); + + $akteData = getData($akteResult); + + $resultArr = array(); + + // for each found akte entry + foreach ($akteData as $akte) + { + // get dms and akte data from akte Id + $getAkteDmsResult = $this->get($akte->akte_id); + + if (isError($getAkteDmsResult)) return $getAkteDmsResult; + + $resultArr[] = getData($getAkteDmsResult); + } + + // return all found entries + return success($resultArr); + } + + /** + * Removes Akte by akte Id, removes all associated dms entries and versions, and deletes all associated files + * Returns success with removed version numbers or error + */ + public function remove($akte_id) + { + // get dms_id for akte + $this->_ci->AkteModel->addSelect('dms_id'); + $akteResult = $this->_ci->AkteModel->load($akte_id); + + if (isError($akteResult)) return $akteResult; + + if (!hasData($akteResult)) return error("Akte not found"); + + $dms_id = getData($akteResult)[0]->dms_id; + $error = null; + + // Start DB transaction to avoid deleting only part of the data + $this->_ci->db->trans_begin(); + + // delete Akte + $deleteResult = $this->_ci->AkteModel->delete($akte_id); + + if (isError($deleteResult)) + { + $error = $deleteResult; + } + else + { + // remove all dms entry for dms of the akte + $removeAllResult = $this->_ci->dmslib->removeAll($dms_id); + + if (isError($removeAllResult)) + $error = $removeAllResult; + } + + // Transaction complete! + $this->_ci->db->trans_complete(); + + // Check if everything went ok during the transaction + if ($this->_ci->db->trans_status() === false || isset($error)) + { + $this->_ci->db->trans_rollback(); + + // return occured error + if (isset($error)) + return $error; + else + return error("Error occured when deleting, rolled back"); + } + else + { + $this->_ci->db->trans_commit(); + + // return removed dms entry data + return $removeAllResult; + } + } +} diff --git a/application/libraries/AnrechnungLib.php b/application/libraries/AnrechnungLib.php index ee197ab05..86a81fb55 100644 --- a/application/libraries/AnrechnungLib.php +++ b/application/libraries/AnrechnungLib.php @@ -80,14 +80,24 @@ class AnrechnungLib // Get latest ZGV $result = $this->ci->PrestudentModel->getLatestZGVBezeichnung($prestudent_id); $latest_zgv_bezeichnung = hasData($result) ? getData($result)[0]->bezeichnung : ''; - + + // Get Sum of berufliche and schulische ECTS + $result = $this->ci->LehrveranstaltungModel->getEctsSumSchulisch($uid, $prestudent_id, $lv->studiengang_kz); + $sumEctsSchulisch = getData($result)[0]->ectssumschulisch; + + $result = $this->ci->LehrveranstaltungModel->getEctsSumBeruflich($uid); + $sumEctsBeruflich = getData($result)[0]->ectssumberuflich; + // Set the given studiensemester $antrag_data->lv_id = $lv_id; $antrag_data->lv_bezeichnung = $lv->bezeichnung; $antrag_data->ects = $lv->ects; + $antrag_data->sumEctsSchulisch = $sumEctsSchulisch; + $antrag_data->sumEctsBeruflich = $sumEctsBeruflich; $antrag_data->studiensemester_kurzbz = $studiensemester_kurzbz; $antrag_data->vorname = $person->vorname; $antrag_data->nachname = $person->nachname; + $antrag_data->student_uid = $uid; $antrag_data->matrikelnr = $student->matrikelnr; $antrag_data->studiengang_kz = $studiengang->studiengang_kz; $antrag_data->stg_bezeichnung = $studiengang->bezeichnung; @@ -112,6 +122,7 @@ class AnrechnungLib $anrechnung_data = new StdClass(); + $this->ci->AnrechnungModel->addJoin('lehre.tbl_anrechnung_begruendung', 'begruendung_id'); $result = $this->ci->AnrechnungModel->load($anrechnung_id); if (isError($result)) @@ -145,6 +156,7 @@ class AnrechnungLib $anrechnung_data->prestudent_id = ''; $anrechnung_data->lehrveranstaltung = ''; $anrechnung_data->begruendung_id = ''; + $anrechnung_data->begruendung = ''; $anrechnung_data->anmerkung = ''; $anrechnung_data->dms_id = ''; $anrechnung_data->insertamum = ''; @@ -155,6 +167,7 @@ class AnrechnungLib $anrechnung_data->status = getUserLanguage() == 'German' ? 'neu' : 'new'; $anrechnung_data->dokumentname = ''; + $this->ci->AnrechnungModel->addJoin('lehre.tbl_anrechnung_begruendung', 'begruendung_id'); $result = $this->ci->AnrechnungModel->loadWhere( array( 'lehrveranstaltung_id' => $lehrveranstaltung_id, @@ -800,6 +813,7 @@ class AnrechnungLib $anrechnung_data->prestudent_id = $anrechnung->prestudent_id; $anrechnung_data->lehrveranstaltung_id = $anrechnung->lehrveranstaltung_id; $anrechnung_data->begruendung_id = $anrechnung->begruendung_id; + $anrechnung_data->begruendung = $anrechnung->bezeichnung; $anrechnung_data->anmerkung = $anrechnung->anmerkung_student; $anrechnung_data->dms_id = $anrechnung->dms_id; $anrechnung_data->insertamum = (new DateTime($anrechnung->insertamum))->format('d.m.Y'); @@ -823,4 +837,110 @@ class AnrechnungLib return $anrechnung_data; } + + /** + * If Student is a Quereinsteiger, get ECTS Summe of all angerechnete Studiensemester. + * + * @param $prestudent_id + * @param $studiengang_kz Studiengang_kz der LV + * @return int|mixed + */ + public function getQuereinsteigerEctsSumme($prestudent_id, $studiengang_kz) + { + $sumEctsQuereinsteiger = 0; + + // Check, if student is Quereinsteiger + $this->ci->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); + $result = $this->ci->PrestudentstatusModel->getFirstStatus($prestudent_id, 'Student'); + + $prestudentFirstStudentStatus = getData($result)[0]; + + // If Prestudent is not a Quereinsteiger + if ($prestudentFirstStudentStatus->ausbildungssemester == 1) + { + return $sumEctsQuereinsteiger; // return 0 + } + + $anzahlAngerechneteStudiensemester = $prestudentFirstStudentStatus->ausbildungssemester - 1; + + // If Prestudent is a Quereinsteiger + if ($prestudentFirstStudentStatus->ausbildungssemester > 1) + { + // Get the 'angerechnete Studiensemester' + $this->ci->load->model('organisations/Studiensemester_model', 'StudiensemesterModel'); + $result = $this->ci->StudiensemesterModel->getPreviousFrom( + $prestudentFirstStudentStatus->studiensemester_kurzbz, + $anzahlAngerechneteStudiensemester + ); + + // Get ECTS Summe of each 'angerechnetes Studiensemester' + foreach (getData($result) as $studiensemester) + { + $result = $this->ci->LehrveranstaltungModel->getSumQuereinstiegsECTSProSemester( + $studiengang_kz, + $studiensemester->studiensemester_kurzbz, + $anzahlAngerechneteStudiensemester--, + $prestudentFirstStudentStatus->orgform_kurzbz + ); + + if (hasData($result)) + { + $sumEctsQuereinsteiger = $sumEctsQuereinsteiger + getData($result)[0]->sum_ects; + } + } + } + return $sumEctsQuereinsteiger; // return sum of ects of all 'angerechnete Studiensemester' + } + + /** + * Get ECTS Summe of all Anrechnungen based on schulische Kenntnisse. + * + * @param $student_uid + * @return int|mixed + */ + public function getSchulischeAnrechnungenEctsSumme($student_uid) + { + $sumEctsSchule = 0; + + $result = $this->ci->LehrveranstaltungModel->getSumAngerechneteECTSByBegruendung($student_uid); + + if (hasData($result)) + { + foreach (getData($result) as $ects) + { + if ($ects->begruendung_id != 4) + { + $sumEctsSchule = $sumEctsSchule + $ects->sum; + } + } + } + + return $sumEctsSchule; + } + + /** + * Get ECTS Summe of all Anrechnungen based on berufliche Kenntnisse. + * + * @param $student_uid + * @return int + */ + public function getBeruflicheAnrechnungenEctsSumme($student_uid) + { + $sumEctsBeruflich = 0; + + $result = $this->ci->LehrveranstaltungModel->getSumAngerechneteECTSByBegruendung($student_uid); + + if (hasData($result)) + { + foreach (getData($result) as $ects) + { + if ($ects->begruendung_id == 4) + { + $sumEctsBeruflich = $ects->sum; + } + } + } + + return $sumEctsBeruflich; + } } diff --git a/application/libraries/DmsLib.php b/application/libraries/DmsLib.php index eae1a9ac4..b2c53a7d9 100644 --- a/application/libraries/DmsLib.php +++ b/application/libraries/DmsLib.php @@ -1,25 +1,532 @@ ci =& get_instance(); + $this->_ci =& get_instance(); - $this->ci->load->model('crm/Akte_model', 'AkteModel'); - $this->ci->load->model('content/Dms_model', 'DmsModel'); - $this->ci->load->model('content/DmsVersion_model', 'DmsVersionModel'); - $this->ci->load->model('content/DmsFS_model', 'DmsFSModel'); + // Set the the _who property + $this->_who = 'DMS system'; // default + // It is possible to set it using the who parameter + if (!isEmptyArray($params) && isset($params['who']) && !isEmptyString($params['who'])) $this->_who = $params['who']; + + $this->_ci->load->model('crm/Akte_model', 'AkteModel'); // deprecated, should not be used here! + $this->_ci->load->model('content/Dms_model', 'DmsModel'); + $this->_ci->load->model('content/DmsVersion_model', 'DmsVersionModel'); + $this->_ci->load->model('content/DmsFS_model', 'DmsFSModel'); } + + // ----------------------------------------------------------------------------------------------------------- + // Public methods + + /** + * Writes a new file, adds a new dms entry and a new dms version 0 for the written file + * Returns success info of added dms entry (dms_id, version, filename) or error + */ + public function add( + $name, $mimetype, $fileHandle, // Required parameters + $kategorie_kurzbz = null, $dokument_kurzbz = null, $beschreibung = null, $cis_suche = false, $schlagworte = null + ) + { + // write file with content of fileHandle + $writeFileResult = $this->_writeNewFile($name, $fileHandle); + + if (isError($writeFileResult)) return $writeFileResult; + + if (hasData($writeFileResult)) + { + $writeFileData = getData($writeFileResult); + $filename = $writeFileData->filename; + + // if file written successful, insert dms + $dmsResult = $this->_ci->DmsModel->insert( + array( + 'kategorie_kurzbz' => $kategorie_kurzbz, + 'dokument_kurzbz' => $dokument_kurzbz + ) + ); + + if (isError($dmsResult)) return $dmsResult; + + if (hasData($dmsResult)) + { + $dms_id = getData($dmsResult); + $version = 0; + + // insert dms version + $dmsVersion = array( + 'dms_id' => $dms_id, + 'version' => $version, + 'filename' => $filename, + 'mimetype' => $mimetype, + 'name' => $name, + 'beschreibung' => $beschreibung, + 'cis_suche' => $cis_suche, + 'schlagworte' => $schlagworte, + 'insertvon' => $this->_who, + 'insertamum' => date('Y-m-d H:i:s') + ); + + $dmsVersionResult = $this->_ci->DmsVersionModel->insert($dmsVersion); + + if (isError($dmsVersionResult)) return $dmsVersionResult; + + // return dms info + $resObj = new stdClass(); + $resObj->dms_id = $dms_id; + $resObj->version = $version; + $resObj->filename = $filename; + + return success($resObj); + } + else + return error("error when inserting DMS"); + } + else + return error("file could not be written"); + } + + /** + * Writes a new file with content of fileHandle, adds a new dms version (max version number + 1) for the written file + * Returns success with info of added dms version (version, filename) or error + */ + public function addNewVersion($dms_id, $fileHandle, $name = null, $mimetype = null, $beschreibung = null, $cis_suche = false, $schlagworte = null) + { + // get the latest version + $lastVersionResult = $this->getLastVersion($dms_id); + + if (isError($lastVersionResult)) return $lastVersionResult; + + if (hasData($lastVersionResult)) + { + $lastVersion = getData($lastVersionResult); + + $originalName = isset($name) ? $name : $lastVersion->name; + + // write new file with content of fileHandle + $writeFileResult = $this->_writeNewFile($originalName, $fileHandle); + + if (isError($writeFileResult)) return $writeFileResult; + + if (hasData($writeFileResult)) + { + $writeFileData = getData($writeFileResult); + $filename = $writeFileData->filename; + + // insert new version + $newVersionNumber = $lastVersion->version + 1; + + // if new parameters given, use them, otherwise use parameters from last version + $newVersion = array( + 'dms_id' => $dms_id, + 'name' => $originalName, + 'filename' => $filename, + 'version' => $newVersionNumber, + 'mimetype' => isset($mimetype) ? $mimetype : $lastVersion->mimetype, + 'beschreibung' => isset($beschreibung) ? $beschreibung : $lastVersion->beschreibung, + 'cis_suche' => isset($cis_suche) ? $cis_suche : $lastVersion->cis_suche, + 'schlagworte' => isset($schlagworte) ? $schlagworte : $lastVersion->schlagworte, + 'insertvon' => $this->_who, + 'insertamum' => date('Y-m-d H:i:s') + ); + + $addVersionResult = $this->_ci->DmsVersionModel->insert($newVersion); + + if (isError($addVersionResult)) return $addVersionResult; + + // return dms info + $resObj = new stdClass(); + $resObj->version = $newVersionNumber; + $resObj->filename = $filename; + + return success($resObj); + } + else + return error("file could not be written"); + } + else + return error("last version not found"); + } + + /** + * Updates the last version (max version number) of a dms entry + * Overwrites the file associated with this version with content read from fileHandle + * Returns success with info of added dms version (version, filename) or error + */ + public function updateLastVersion($dms_id, $fileHandle, $name = null, $mimetype = null, $beschreibung = null, $cis_suche = false, $schlagworte = null) + { + // get the latest version + $lastVersionResult = $this->getLastVersion($dms_id); + + if (isError($lastVersionResult)) return $lastVersionResult; + + if (hasData($lastVersionResult)) + { + $lastVersion = getData($lastVersionResult); + + // update file in filesystem + $writeFileResult = $this->_writeFile($lastVersion->filename, $fileHandle); + + if (isError($writeFileResult)) return $writeFileResult; + + if (hasData($writeFileResult)) + { + $writeFileData = getData($writeFileResult); + $filename = $writeFileData->filename; + + // if new parameters given, use them, otherwise use parameters from last version + $newVersion = array( + 'name' => isset($name) ? $name : $lastVersion->name, + 'filename' => $filename, + 'mimetype' => isset($mimetype) ? $mimetype : $lastVersion->mimetype, + 'beschreibung' => isset($beschreibung) ? $beschreibung : $lastVersion->beschreibung, + 'cis_suche' => isset($cis_suche) ? $cis_suche : $lastVersion->cis_suche, + 'schlagworte' => isset($schlagworte) ? $schlagworte : $lastVersion->schlagworte, + ); + + // update last dms version + $addVersionResult = $this->_ci->DmsVersionModel->update( + array($dms_id, $lastVersion->version), + $newVersion + ); + + if (isError($addVersionResult)) return $addVersionResult; + + // return dms info + $resObj = new stdClass(); + $resObj->version = $lastVersion->version; + $resObj->filename = $filename; + + return success($resObj); + } + else + return error("file could not be written"); + } + else + return error("last version not found"); + } + + /** + * Gets dms version with highest number + * Returns success with dms data and fileHandle with file content or error + */ + public function getLastVersion($dms_id) + { + // get the latest version number + $this->_ci->DmsVersionModel->addSelect('version'); + $this->_ci->DmsVersionModel->addOrder('version', 'DESC'); + $this->_ci->DmsVersionModel->addOrder('insertamum', 'DESC'); + $this->_ci->DmsVersionModel->addLimit(1); + $lastDmsVersionResult = $this->_ci->DmsVersionModel->loadWhere( + array('dms_id' => $dms_id) + ); + + if (isError($lastDmsVersionResult)) return $lastDmsVersionResult; + + if (hasData($lastDmsVersionResult)) + { + $lastDmsVersionData = getData($lastDmsVersionResult)[0]; + $lastDmsVersion = $lastDmsVersionData->version; + + // call get Version with last version number + return $this->getVersion($dms_id, $lastDmsVersion); + } + else + return error("Dms last version not found"); + } + + /** + * Gets specified dms version + * Returns success with dms data and fileHandle with file content or error + */ + public function getVersion($dms_id, $version) + { + $this->_ci->DmsVersionModel->addSelect('dms_id, version, filename, mimetype, name, beschreibung, cis_suche, schlagworte'); + $dmsVersionResult = $this->_ci->DmsVersionModel->loadWhere( + array( + 'dms_id' => $dms_id, + 'version' => $version + ) + ); + + if (isError($dmsVersionResult)) return $dmsVersionResult; + + if (hasData($dmsVersionResult)) + { + $dmsVersion = getData($dmsVersionResult)[0]; + + // get file content as file pointer + $fileHandleResult = $this->_ci->DmsFSModel->openRead($dmsVersion->filename); + + if (isError($fileHandleResult)) return $fileHandleResult; + + if (hasData($fileHandleResult)) + { + $fileHandle = getData($fileHandleResult); + $dmsVersion->{self::FILE_CONTENT_PROPERTY} = $fileHandle; + + // close file pointer + $closeResult = $this->_ci->DmsFSModel->close($fileHandle); + + if (isError($closeResult)) return $closeResult; + + return success($dmsVersion); + } + else + return error("File could not be opened"); + } + else + return error("Dms version not found"); + } + + /** + * Removes dms entry and all its versions, deletes all associated files + * Returns success with removed version numbers or error + */ + public function removeAll($dms_id) + { + $versionsRemoved = array(); + + $this->_ci->DmsVersionModel->addSelect('version, filename'); + $allVersionsResult = $this->_ci->DmsVersionModel->loadWhere(array('dms_id' => $dms_id)); + + if (hasData($allVersionsResult)) + { + $allVersionsData = getData($allVersionsResult); + + $error = null; + + // Start DB transaction to avoid deleting only part of the data + $this->_ci->db->trans_begin(); + + // remove all versions of the dms Id + foreach ($allVersionsData as $version) + { + $removeVersionResult = $this->removeVersion($dms_id, $version->version); + + if (isError($removeVersionResult)) + { + $error = $removeVersionResult; + break; + } + else + $versionsRemoved[] = $version; // return removed versions + } + + // Transaction complete! + $this->_ci->db->trans_complete(); + + // Check if everything went ok during the transaction + if ($this->_ci->db->trans_status() === false || isset($error)) + { + $this->_ci->db->trans_rollback(); + + if (isset($error)) + return $error; + else + return error("Error occured when deleting, rolled back"); + } + else + { + $this->_ci->db->trans_commit(); + } + } + + return success($versionsRemoved); + } + + /** + * Removes latest version and its associated file + * Returns success with removed dms version data (dms_id, version, filename) or error + */ + public function removeLastVersion($dms_id) + { + $lastVersionNumber = 0; + // get the latest version + $lastVersionResult = $this->getLastVersion($dms_id); + + if (isError($lastVersionResult)) return $lastVersionResult; + + if (hasData($lastVersionResult)) + { + $lastVersion = getData($lastVersionResult); + $lastVersionNumber = $lastVersion->version; + } + + // call remove method for latest version + return $this->removeVersion($dms_id, $lastVersionNumber); + } + + /** + * Removes latest version and its associated file + * Returns success with removed dms version data (dms_id, version, filename) or error + */ + public function removeVersion($dms_id, $version) + { + $removeVersionResultObj = new stdClass(); + $removeVersionResultObj->dms_id = null; + $removeVersionResultObj->version = null; + $removeVersionResultObj->filename = null; + + // load dms version and check how many versions there are + $db = new DB_Model(); + + $checkDeleteResult = $db->execReadOnlyQuery( + "SELECT filename, + (SELECT count(version) + FROM campus.tbl_dms_version dv_anzahl + WHERE dv_anzahl.dms_id = dv.dms_id) AS anzahl_versionen + FROM campus.tbl_dms_version dv + WHERE dms_id=? + AND version=?", + array($dms_id, $version) + ); + + if (isError($checkDeleteResult)) return $checkDeleteResult; + + if (hasData($checkDeleteResult)) + { + $checkDeleteData = getData($checkDeleteResult)[0]; + + // delete version + $deleteVersionResult = $this->_ci->DmsVersionModel->delete(array($dms_id, $version)); + + if (isError($deleteVersionResult)) return $deleteVersionResult; + + $removeVersionResultObj->version = $version; + $removeVersionResultObj->filename = $checkDeleteData->filename; + + // delete dms too if no versions left + if ($checkDeleteData->anzahl_versionen <= 1) + { + $deleteDmsResult = $this->_ci->DmsModel->delete($dms_id); + + if (isError($deleteDmsResult)) return $deleteDmsResult; + + $removeVersionResultObj->dms_id = $dms_id; + } + + // delete file from file system + $removeResult = $this->_ci->DmsFSModel->remove($checkDeleteData->filename); + + if (isError($removeResult)) return $removeResult; + } + + return success($removeVersionResultObj); + } + + // ----------------------------------------------------------------------------------------------------------- + // Private methods + + /** + * Writes file with content of fileHandle using original document name for file extension + */ + private function _writeNewFile($originalName, $fileHandle) + { + // create unique filename, using original document name to detect file extension + $filename = $this->_getUniqueFilename($originalName); + + // write the file + return $this->_writeFile($filename, $fileHandle); + } + + /** + * Writes file with content of fileHandle + * Returns number of bytes written and filename + */ + private function _writeFile($filename, $fileHandle) + { + // file content provided by fileHandle + $fileContent = ''; + + $readBlockResult = success(); + + // While the end of the file is not reached and the read does not fail + while (!feof($fileHandle) && isSuccess($readBlockResult = $this->_ci->DmsFSModel->readBlock($fileHandle))) + { + // Concatenate the content of the file + $fileContent .= getData($readBlockResult); + } + + // If an error occurred while reading then return it + if (isError($readBlockResult)) return $readBlockResult; + + // open file for writing + $openFileResult = $this->_ci->DmsFSModel->openReadWrite($filename); + + if (isError($openFileResult)) return $openFileResult; + + if (!hasData($openFileResult)) return error("File could not be opened"); + + $newFileHandle = getData($openFileResult); + + // write file + $writeFileResult = $this->_ci->DmsFSModel->write($newFileHandle, $fileContent); + + if (isError($writeFileResult)) return $writeFileResult; + + // return number of bytes written and filename + $resObj = new stdClass(); + $resObj->bytesWritten = 0; + $resObj->filename = ''; + + if (hasData($writeFileResult)) + { + $resObj->bytesWritten = getData($writeFileResult); + $resObj->filename = $filename; + } + + // close handle + $closeResult = $this->_ci->DmsFSModel->close($newFileHandle, $fileContent); + + if (isError($closeResult)) return $closeResult; + + return success($resObj); + } + + /** + * Generates unique filename, appends file extension from document name + * Returns the filename string + */ + private function _getUniqueFilename($dokname) + { + // create unique id + $uniqueFilename = uniqid(); + + // getting extension of file from document name + $fileExtension = pathinfo($dokname, PATHINFO_EXTENSION); + + // if file extension found, append it + if (!isEmptyString($fileExtension)) + $uniqueFilename .= '.'.$fileExtension; + + return $uniqueFilename; + } + + // ----------------------------------------------------------------------------------------------------------- + // Deprecated methods, not to be used /** * Load a DMS Document. @@ -33,19 +540,20 @@ class DmsLib extends FHC_Controller { if (is_numeric($dms_id)) { - $this->ci->DmsModel->addJoin('campus.tbl_dms_version', 'dms_id'); - $this->ci->DmsModel->addOrder('version', 'DESC'); - $this->ci->DmsModel->addLimit(1); + $this->_ci->DmsModel->addJoin('campus.tbl_dms_version', 'dms_id'); + $this->_ci->DmsModel->addOrder('version', 'DESC'); + $this->_ci->DmsModel->addLimit(1); if (!is_numeric($version)) { - return $this->ci->DmsModel->load($dms_id); + return $this->_ci->DmsModel->load($dms_id); } else { - return $this->ci->DmsModel->loadWhere(array('dms_id' => $dms_id, 'version' => $version)); + return $this->_ci->DmsModel->loadWhere(array('dms_id' => $dms_id, 'version' => $version)); } } + return error('The parameter DMS ID must be a number'); } @@ -57,34 +565,30 @@ class DmsLib extends FHC_Controller */ public function read($dms_id, $version = null) { - $result = null; + $result = error('Wrong dms_id parameter'); if (isset($dms_id)) { - $this->ci->DmsModel->addJoin('campus.tbl_dms_version', 'dms_id'); - $this->ci->DmsModel->addOrder('version', 'DESC'); - $this->ci->DmsModel->addLimit(1); + $this->_ci->DmsModel->addJoin('campus.tbl_dms_version', 'dms_id'); + $this->_ci->DmsModel->addOrder('version', 'DESC'); + $this->_ci->DmsModel->addLimit(1); if (!isset($version)) { - $result = $this->ci->DmsModel->load($dms_id); + $result = $this->_ci->DmsModel->load($dms_id); } else { - $result = $this->ci->DmsModel->loadWhere(array('dms_id' => $dms_id, 'version' => $version)); + $result = $this->_ci->DmsModel->loadWhere(array('dms_id' => $dms_id, 'version' => $version)); } - } - if (hasData($result)) - { - $resultFS = $this->ci->DmsFSModel->read($result->retval[0]->filename); - if (isSuccess($resultFS)) + // If a dms has been found + if (hasData($result)) { - $result->retval[0]->{DmsLib::FILE_CONTENT_PROPERTY} = $resultFS->retval; - } - else - { - $result = $resultFS; + $resultFS = $this->_ci->DmsFSModel->readBase64(getData($result)[0]->filename); + if (isError($resultFS)) return $resultFS; // if an error occurred return it + + $result->retval[0]->{self::FILE_CONTENT_PROPERTY} = getData($resultFS); } } @@ -101,22 +605,16 @@ class DmsLib extends FHC_Controller */ public function getAktenAcceptedDms($person_id, $dokument_kurzbz = null, $no_file = null) { - $result = $this->ci->AkteModel->getAktenAcceptedDms($person_id, $dokument_kurzbz); + $result = $this->_ci->AkteModel->getAktenAcceptedDms($person_id, $dokument_kurzbz); if (hasData($result) && $no_file == null) { - $cnt = count($result->retval); - for ($i = 0; $i < $cnt; $i++) + for ($i = 0; $i < count(getData($result)); $i++) { - $resultFS = $this->ci->DmsFSModel->read($result->retval[$i]->filename); - if (isSuccess($resultFS)) - { - $result->retval[$i]->{DmsLib::FILE_CONTENT_PROPERTY} = $resultFS->retval; - } - else - { - $result = $resultFS; - } + $resultFS = $this->_ci->DmsFSModel->readBase64(getData($result)[$i]->filename); + if (isError($resultFS)) return $resultFS; // if an error occurred return it + + $result->retval[$i]->{self::FILE_CONTENT_PROPERTY} = getData($resultFS); } } @@ -135,30 +633,31 @@ class DmsLib extends FHC_Controller // Init upload configs $this->_loadUploadLibrary($allowed_types); - if (!$this->ci->upload->do_upload($field_name)) + if (!$this->_ci->upload->do_upload($field_name)) { - return error($this->ci->upload->display_errors()); + return error($this->_ci->upload->display_errors()); } - $upload_data = $this->ci->upload->data(); // data about the uploaded file - $filename = $upload_data['file_name']; + $upload_data = $this->_ci->upload->data(); // data about the uploaded file // Insert to DMS table - if (!$result = $this->ci->DmsModel->insert($this->ci->DmsModel->filterFields($dms))) - { - return error('Failed inserting to DMS'); - } - $upload_data['dms_id'] = $result->retval; + $insDmsResult = $this->_ci->DmsModel->insert($this->_ci->DmsModel->filterFields($dms)); + if (isError($insDmsResult)) return $insDmsResult; + + $upload_data['dms_id'] = getData($insDmsResult); // Insert DMS version - if (!$result = $this->ci->DmsVersionModel->insert( - $this->ci->DmsVersionModel->filterFields($dms, $result->retval, $filename))) - { - return error('Failed inserting DMS version'); - } + $insVersionResult = $this->_ci->DmsVersionModel->insert( + $this->_ci->DmsVersionModel->filterFields( + $dms, + $upload_data['dms_id'], + $upload_data['file_name'] + ) + ); + if (isError($insVersionResult)) return $insVersionResult; - // return result of uploaded data - return success($upload_data); // data about the uploaded file + // Return result of uploaded data + return success($upload_data); } /** @@ -171,36 +670,29 @@ class DmsLib extends FHC_Controller */ public function download($dms_id, $filename = null, $disposition = 'inline') { - $result = $this->getFileInfo($dms_id); - - if (isError($result)) + // Retrieves info about the given dms + $fileInfoResult = $this->getFileInfo($dms_id); + if (isError($fileInfoResult)) return error(getError($fileInfoResult)); + + // If data have been found + if (hasData($fileInfoResult)) { - return error(getError($result)); + $fileObj = getData($fileInfoResult); + + // Change filename, if filename is provided + if (!isEmptyString($filename)) $fileObj->name = $filename; + + // Add file disposition if disposition has a valid value + if ($disposition == 'attachment' || $disposition == 'inline') + { + $fileObj->disposition = $disposition; + } + + return success($fileObj); } - $fileObj = getData($result); - - // Change filename, if filename is provided - if (is_string($filename)) - { - $fileObj->name = $filename; - } - - // Add file disposition - if ($disposition == 'attachment') - { - $fileObj->disposition = 'attachment'; - } - else - { - $fileObj->disposition = 'inline'; - } - - // Output file - if(!$this->outputFile($fileObj)) - { - return error('Error on file output'); - } + // If no data have been found then return an empty success + return success(); } /** @@ -212,28 +704,28 @@ class DmsLib extends FHC_Controller */ public function getFileInfo($dms_id, $version = null) { - if (!is_numeric($dms_id)) - { - return error('Wrong parameter'); - } + // Checks the dms_id parameter + if (!is_numeric($dms_id)) return error('Wrong parameter'); - // Load file + // Load DMS from database $result = $this->load($dms_id, $version); + if (isError($result)) return error(getError($result)); - if (isError($result)) + // If data have been found + if (hasData($result)) { - return error(getError($result)); + // Store file information in fileObj + $fileObj = new stdClass(); + $fileObj->filename = getData($result)[0]->filename; + $fileObj->file = DMS_PATH.getData($result)[0]->filename; + $fileObj->name = DMS_PATH.getData($result)[0]->name; // original user filename + $fileObj->mimetype = getData($result)[0]->mimetype; + + return success($fileObj); } - // Store file information in fileObj - $fileObj = new StdClass(); - $fileObj->filename = getData($result)[0]->filename; - $fileObj->file = DMS_PATH. getData($result)[0]->filename; - $fileObj->name = DMS_PATH. getData($result)[0]->name; // original users filename - $fileObj->mimetype = DMS_PATH. getData($result)[0]->mimetype; - - return success($fileObj); - + // If no data have been found return an empty success + return success(); } /** @@ -253,20 +745,20 @@ class DmsLib extends FHC_Controller $result = $this->_saveFileOnInsert($dms); if (isSuccess($result)) { - $filename = $result->retval; + $filename = getData($result); if (isset($dms['dms_id']) && $dms['dms_id'] != '') { - $result = $this->ci->DmsVersionModel->insert( - $this->ci->DmsVersionModel->filterFields($dms, $dms['dms_id'], $filename) + $result = $this->_ci->DmsVersionModel->insert( + $this->_ci->DmsVersionModel->filterFields($dms, $dms['dms_id'], $filename) ); } else { - $result = $this->ci->DmsModel->insert($this->ci->DmsModel->filterFields($dms)); + $result = $this->_ci->DmsModel->insert($this->_ci->DmsModel->filterFields($dms)); if (isSuccess($result)) { - $result = $this->ci->DmsVersionModel->insert( - $this->ci->DmsVersionModel->filterFields($dms, $result->retval, $filename) + $result = $this->_ci->DmsVersionModel->insert( + $this->_ci->DmsVersionModel->filterFields($dms, getData($result), $filename) ); } } @@ -277,15 +769,15 @@ class DmsLib extends FHC_Controller $result = $this->_saveFileOnUpdate($dms); if (isSuccess($result)) { - $result = $this->ci->DmsModel->update($dms['dms_id'], $this->ci->DmsModel->filterFields($dms)); + $result = $this->_ci->DmsModel->update($dms['dms_id'], $this->_ci->DmsModel->filterFields($dms)); if (isSuccess($result)) { - $result = $this->ci->DmsVersionModel->update( + $result = $this->_ci->DmsVersionModel->update( array( $dms['dms_id'], $dms['version'] ), - $this->ci->DmsVersionModel->filterFields($dms) + $this->_ci->DmsVersionModel->filterFields($dms) ); } } @@ -308,56 +800,54 @@ class DmsLib extends FHC_Controller if (is_numeric($person_id) && is_numeric($dms_id)) { // Start DB transaction - $this->ci->db->trans_start(false); + $this->_ci->db->trans_start(false); // Get akte_id from table tbl_akte - $result = $this->ci->AkteModel->loadWhere(array('person_id' => $person_id, 'dms_id' => $dms_id)); + $result = $this->_ci->AkteModel->loadWhere(array('person_id' => $person_id, 'dms_id' => $dms_id)); if (isSuccess($result)) { // Delete all entries in tbl_akte - $cnt = count($result->retval); - for ($i = 0; $i < $cnt; $i++) + for ($i = 0; $i < count(getData($result)); $i++) { - $this->ci->AkteModel->delete($result->retval[$i]->akte_id); + $this->_ci->AkteModel->delete(getData($result)[$i]->akte_id); } // Get all filenames related to this dms - $resultFileNames = $this->ci->DmsVersionModel->loadWhere(array('dms_id' => $dms_id)); + $resultFileNames = $this->_ci->DmsVersionModel->loadWhere(array('dms_id' => $dms_id)); if (isSuccess($resultFileNames)) { // Delete from tbl_dms_version - $result = $this->ci->DmsVersionModel->delete(array('dms_id' => $dms_id)); + $result = $this->_ci->DmsVersionModel->delete(array('dms_id' => $dms_id)); if (isSuccess($result)) { // Delete from tbl_dms - $result = $this->ci->DmsModel->delete($dms_id); + $result = $this->_ci->DmsModel->delete($dms_id); } } } // Transaction complete! - $this->ci->db->trans_complete(); + $this->_ci->db->trans_complete(); // Check if everything went ok during the transaction - if ($this->ci->db->trans_status() === false || isError($result)) + if ($this->_ci->db->trans_status() === false || isError($result)) { - $this->ci->db->trans_rollback(); + $this->_ci->db->trans_rollback(); $result = error('An error occurred while performing a delete operation', EXIT_ERROR); } else { - $this->ci->db->trans_commit(); + $this->_ci->db->trans_commit(); $result = success('Dms successfully removed from DB'); } // If everything is ok if (isSuccess($result)) { - $cnt = count($resultFileNames->retval); // Remove all files related to this person and dms - for ($i = 0; $i < $cnt; $i++) + for ($i = 0; $i < count(getData($resultFileNames)); $i++) { - $this->ci->DmsFSModel->remove($resultFileNames->retval[$i]->filename); + $this->_ci->DmsFSModel->removeBase64(getData($resultFileNames)[$i]->filename); } } } @@ -376,19 +866,19 @@ class DmsLib extends FHC_Controller */ public function getAkteContent($akte_id) { - $akte = $this->ci->AkteModel->load($akte_id); + $akte = $this->_ci->AkteModel->load($akte_id); if (hasData($akte)) { - if ($akte->retval[0]->inhalt != '') + if (getData($akte)[0]->inhalt != '') { - return success(base64_decode($akte->retval[0]->inhalt)); + return success(base64_decode(getData($akte)[0]->inhalt)); } - elseif ($akte->retval[0]->dms_id != '') + elseif (getData($akte)[0]->dms_id != '') { - $dmscontent = $this->read($akte->retval[0]->dms_id); + $dmscontent = $this->read(getData($akte)[0]->dms_id); if (isSuccess($dmscontent)) { - return success(base64_decode($dmscontent->retval[0]->file_content)); + return success(base64_decode(getData($dmscontent)[0]->file_content)); } else { @@ -415,10 +905,10 @@ class DmsLib extends FHC_Controller { $filename = uniqid().'.'.pathinfo($dms['name'], PATHINFO_EXTENSION); - $result = $this->ci->DmsFSModel->write($filename, $dms['file_content']); + $result = $this->_ci->DmsFSModel->writeBase64($filename, $dms['file_content']); if (isSuccess($result)) { - $result->retval = $filename; + $result = success($filename); } return $result; @@ -439,7 +929,7 @@ class DmsLib extends FHC_Controller if (hasData($result)) { - $result = $this->ci->DmsFSModel->write($result->retval[0]->filename, $dms['file_content']); + $result = $this->_ci->DmsFSModel->writeBase64(getData($result)[0]->filename, $dms['file_content']); } } @@ -451,12 +941,14 @@ class DmsLib extends FHC_Controller */ private function _loadUploadLibrary($allowed_types) { - $config['upload_path'] = $this->UPLOAD_PATH; - $config['allowed_types'] = implode('|', $allowed_types); - $config['overwrite'] = true; - $config['file_name'] = uniqid().'.pdf'; + $config = array(); + $config['upload_path'] = DMS_PATH; + $config['allowed_types'] = implode('|', $allowed_types); + $config['overwrite'] = true; + $config['file_name'] = uniqid().'.pdf'; - $this->ci->load->library('upload', $config); - $this->ci->upload->initialize($config); + $this->_ci->load->library('upload', $config); + $this->_ci->upload->initialize($config); } } + diff --git a/application/libraries/FilesystemLib.php b/application/libraries/FilesystemLib.php deleted file mode 100644 index c940acede..000000000 --- a/application/libraries/FilesystemLib.php +++ /dev/null @@ -1,142 +0,0 @@ -checkParameters($filepath, $filename)) - { - $resource = $filepath.DIRECTORY_SEPARATOR.$filename; - if (file_exists($resource) && $fileHandle = fopen($resource, 'r')) - { - $result = ''; - while (!feof($fileHandle)) - { - $result .= fread($fileHandle, 8192); - } - fclose($fileHandle); - } - } - - return $result; - } - - /** - * write - */ - public function write($filepath, $filename, $content) - { - $result = null; - - if ($this->checkParameters($filepath, $filename) && isset($content)) - { - $resource = $filepath.DIRECTORY_SEPARATOR.$filename; - if (is_writable($filepath) && $fileHandle = fopen($resource, 'w')) - { - if (fwrite($fileHandle, $content) !== false) - { - $result = true; - } - fclose($fileHandle); - } - } - - return $result; - } - - /** - * append - */ - public function append($filepath, $filename, $content) - { - $result = null; - - if ($this->checkParameters($filepath, $filename) && isset($content)) - { - $resource = $filepath.DIRECTORY_SEPARATOR.$filename; - if (is_writable($resource) && $fileHandle = fopen($resource, 'a')) - { - if (fwrite($fileHandle, $content) !== false) - { - $result = true; - } - fclose($fileHandle); - } - } - - return $result; - } - - /** - * remove - */ - public function remove($filepath, $filename) - { - $result = null; - - if ($this->checkParameters($filepath, $filename)) - { - if (is_writable($filepath)) - { - $resource = $filepath.DIRECTORY_SEPARATOR.$filename; - $result = unlink($resource); - } - } - - return $result; - } - - /** - * rename - */ - public function rename($filepath, $filename, $newFilepath, $newFilename) - { - $result = null; - - if ($this->checkParameters($filepath, $filename) && $this->checkParameters($newFilepath, $newFilename)) - { - $resource = $filepath.DIRECTORY_SEPARATOR.$filename; - if (is_writable($filepath) && is_writable($newFilepath) && file_exists($resource)) - { - $destination = $newFilepath.DIRECTORY_SEPARATOR.$newFilename; - $result = rename($resource, $destination); - } - } - - return $result; - } -} diff --git a/application/models/accounting/Vertragvertragsstatus_model.php b/application/models/accounting/Vertragvertragsstatus_model.php index 609394321..78a065540 100644 --- a/application/models/accounting/Vertragvertragsstatus_model.php +++ b/application/models/accounting/Vertragvertragsstatus_model.php @@ -135,7 +135,7 @@ class Vertragvertragsstatus_model extends DB_Model /** * 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 string $string_date e.g. 'YYYY-MM-DD' 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 diff --git a/application/models/content/DmsFS_model.php b/application/models/content/DmsFS_model.php index 38a72d853..81443805f 100644 --- a/application/models/content/DmsFS_model.php +++ b/application/models/content/DmsFS_model.php @@ -7,7 +7,7 @@ class DmsFS_model extends FS_Model */ public function __construct() { - parent::__construct(); - $this->filepath = DMS_PATH; + parent::__construct(DMS_PATH); } -} \ No newline at end of file +} + diff --git a/application/models/content/TempFS_model.php b/application/models/content/TempFS_model.php new file mode 100644 index 000000000..ac55a24d7 --- /dev/null +++ b/application/models/content/TempFS_model.php @@ -0,0 +1,16 @@ +execQuery($query); + } + + public function checkStudienbeitrag($uid, $stsem, $buchungstypen) + { + $query = 'SELECT tbl_konto.buchungsnr, + tbl_konto.buchungsdatum + FROM public.tbl_konto, + public.tbl_benutzer, + public.tbl_student + WHERE + tbl_konto.studiensemester_kurzbz = \'' . $stsem . '\' + AND tbl_benutzer.uid = \'' . $uid . '\' + AND tbl_benutzer.uid = tbl_student.student_uid + AND tbl_benutzer.person_id = tbl_konto.person_id + AND tbl_konto.studiengang_kz=tbl_student.studiengang_kz + AND tbl_konto.buchungstyp_kurzbz IN (\'' . $buchungstypen . '\') + AND 0 >= ( + SELECT sum(betrag) + FROM public.tbl_konto skonto + WHERE skonto.buchungsnr = tbl_konto.buchungsnr_verweis + OR skonto.buchungsnr_verweis = tbl_konto.buchungsnr_verweis + ) + ORDER BY buchungsnr DESC LIMIT 1 + '; + + return $this->execQuery($query); + } } diff --git a/application/models/crm/Prestudentstatus_model.php b/application/models/crm/Prestudentstatus_model.php index 3335de021..f39a41fda 100644 --- a/application/models/crm/Prestudentstatus_model.php +++ b/application/models/crm/Prestudentstatus_model.php @@ -52,6 +52,24 @@ class Prestudentstatus_model extends DB_Model return $this->execQuery($query, $parametersArray); } + /** + * Liefert den Ersten Status eines Prestudenten mit der übergebenen Statuskurzbezeichnung. + * + * @param $prestudent_id + * @param $status_kurzbz + * @return array + */ + public function getFirstStatus($prestudent_id, $status_kurzbz) + { + $this->addOrder('datum, insertamum, ext_id'); + $this->addLimit(1); + + return $this->loadWhere(array( + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => $status_kurzbz + )); + } + /** * updateStufe */ diff --git a/application/models/crm/Student_model.php b/application/models/crm/Student_model.php index 4d1c84521..4404beb54 100644 --- a/application/models/crm/Student_model.php +++ b/application/models/crm/Student_model.php @@ -66,4 +66,20 @@ class Student_model extends DB_Model return $result->retval[0]->student_uid; } + + public function searchStudent($filter) + { + $this->addSelect('vorname, nachname, gebdatum, person.person_id, student_uid'); + $this->addJoin('public.tbl_prestudent ps', 'prestudent_id'); + $this->addJoin('public.tbl_person person', 'person_id'); + + $result = $this->loadWhere( + "lower(student_uid) like ".$this->db->escape('%'.$filter.'%')." + OR lower(person.nachname) like ".$this->db->escape('%'.$filter.'%')." + OR lower(person.vorname) like ".$this->db->escape('%'.$filter.'%')." + OR lower(person.nachname || ' ' || person.vorname) like ".$this->db->escape('%'.$filter.'%')." + OR lower(person.vorname || ' ' || person.nachname) like ".$this->db->escape('%'.$filter.'%')); + + return $result; + } } diff --git a/application/models/education/Lehrveranstaltung_model.php b/application/models/education/Lehrveranstaltung_model.php index 8517d7f9d..f54443955 100644 --- a/application/models/education/Lehrveranstaltung_model.php +++ b/application/models/education/Lehrveranstaltung_model.php @@ -309,4 +309,166 @@ class Lehrveranstaltung_model extends DB_Model return $this->execQuery($query, array($uid, $studiensemester_kurzbz, $lehrveranstaltung_id)); } + + /** + * Sucht nach LV Templates und gibt Id und Label ("bezeichnung [kurzbz]") aus + * Diese funktion ist für autocomplete gedacht + * + * @param string $filter Suchfilter + * @return \stdClass A return object + */ + public function loadTemplates($filter) + { + $filter = strtolower($filter); + $qry = "SELECT + tbl_lehrveranstaltung.lehrveranstaltung_id, tbl_lehrveranstaltung.bezeichnung, tbl_lehrveranstaltung.kurzbz + FROM + lehre.tbl_lehrveranstaltung + WHERE + tbl_lehrveranstaltung.lehrtyp_kurzbz = 'tpl' AND ( + CAST(tbl_lehrveranstaltung.lehrveranstaltung_id AS TEXT) LIKE '%".$this->db_escape($filter)."%' OR + LOWER(tbl_lehrveranstaltung.bezeichnung) LIKE '%".$this->db_escape($filter). "%' OR + LOWER(tbl_lehrveranstaltung.kurzbz) LIKE '%".$this->db_escape($filter). "%' + ) + "; + return $this->execQuery($qry); + } + + /** + * Lädt Template und gibt Id und Label ("bezeichnung [kurzbz]") zurück + * Diese funktion ist für autocomplete gedacht + * + * @param string $name + * @return \stdClass A return object + */ + public function loadTemplateByName($name) + { + $qry = "SELECT + tbl_lehrveranstaltung.lehrveranstaltung_id as id, CONCAT(tbl_lehrveranstaltung.bezeichnung, ' [', tbl_lehrveranstaltung.kurzbz, ']') as label + FROM + lehre.tbl_lehrveranstaltung + WHERE + tbl_lehrveranstaltung.lehrtyp_kurzbz = 'tpl' AND ( + CAST(tbl_lehrveranstaltung.lehrveranstaltung_id AS TEXT) = '".($name ? $this->db_escape($name) : 0)."' OR tbl_lehrveranstaltung.bezeichnung = '".$this->db_escape($name). "' OR tbl_lehrveranstaltung.kurzbz = '".$this->db_escape($name). "' + ) + "; + return $this->execQuery($qry); + } + + + /** + * Get ECTS Summe pro angerechnetes Quereinstiegssemester. + * + * @param $studiengang_kz + * @param $studiensemester_kurzbz + * @param $ausbildungssemester + * @param $orgform_kurzbz + * @return array|stdClass|null + */ + public function getSumQuereinstiegsECTSProSemester($studiengang_kz, $studiensemester_kurzbz, $ausbildungssemester, $orgform_kurzbz) + { + $qry = ' + SELECT + sum(tbl_lehrveranstaltung.ects) as "sum_ects" + FROM + lehre.tbl_studienplan + JOIN lehre.tbl_studienplan_lehrveranstaltung USING (studienplan_id) + JOIN lehre.tbl_lehrveranstaltung USING (lehrveranstaltung_id) + WHERE + tbl_studienplan.studienplan_id = ( + SELECT + studienplan_id + FROM + lehre.tbl_studienordnung + JOIN lehre.tbl_studienplan USING (studienordnung_id) + JOIN lehre.tbl_studienplan_semester USING (studienplan_id) + WHERE tbl_studienordnung.studiengang_kz = ? + AND tbl_studienplan_semester.semester = ? + AND tbl_studienplan_semester.studiensemester_kurzbz = ? + AND tbl_studienplan.orgform_kurzbz = ? + + LIMIT 1 + ) + AND tbl_studienplan_lehrveranstaltung.semester = ? + AND studienplan_lehrveranstaltung_id_parent IS NULL -- auf Modulebene + AND tbl_studienplan_lehrveranstaltung.export = TRUE + '; + + return $this->execQuery($qry, array( + $studiengang_kz, $ausbildungssemester, $studiensemester_kurzbz, $orgform_kurzbz, $ausbildungssemester) + ); + } + + /** + * Get ECTS Summe aller bisher angerechneten LVs. + * Wenn keine explizite Begruendung angegeben ist, wird eine schulische Begruendung angenommen. + * + * @param $student_uid + * @return array|stdClass|null + */ + public function getSumAngerechneteECTSByBegruendung($student_uid) + { + $qry = ' + SELECT sum(ects), begruendung_id FROM ( + SELECT + lehrveranstaltung_id, studiensemester_kurzbz, ects, COALESCE(begruendung_id, 1) as begruendung_id -- fallback auf externes Zeugnis + FROM + lehre.tbl_zeugnisnote + LEFT JOIN lehre.tbl_anrechnung USING(lehrveranstaltung_id, studiensemester_kurzbz) + JOIN lehre.tbl_lehrveranstaltung USING(lehrveranstaltung_id) + JOIN public.tbl_student USING(student_uid) + WHERE + tbl_zeugnisnote.note = 6 + AND student_uid = ? + AND (lehre.tbl_anrechnung.prestudent_id = tbl_student.prestudent_id + OR lehre.tbl_anrechnung.prestudent_id is null) + + UNION + + SELECT + lehrveranstaltung_id, studiensemester_kurzbz, ects, begruendung_id -- fallback auf externes Zeugnis + FROM + lehre.tbl_anrechnung + JOIN lehre.tbl_lehrveranstaltung USING(lehrveranstaltung_id) + JOIN public.tbl_student USING(prestudent_id) + WHERE + genehmigt_von is not null + AND student_uid = ? + ) lvsangerechnet + GROUP BY begruendung_id + '; + + return $this->execQuery($qry, array($student_uid, $student_uid)); + } + + /** + * Get ECTS Summe aller bisher schulisch begruendeten angerechneten LVs. + * Derzeit wird auch jede Anrechnung, die nicht beruflich ist, als schulisch angenommen. + * + * @param $student_uid + * @return array|stdClass|null + */ + public function getEctsSumSchulisch($student_uid, $prestudent_id, $studiengang_kz) + { + $qry = ' + SELECT get_ects_summe_schulisch(?, ?, ?) AS ectsSumSchulisch + '; + + return $this->execQuery($qry, array($student_uid, $prestudent_id, $studiengang_kz)); + } + + /** + * Get ECTS Summe aller bisher beruflich angerechneten LVs. + * + * @param $student_uid + * @return array|stdClass|null + */ + public function getEctsSumBeruflich($student_uid) + { + $qry = ' + SELECT get_ects_summe_beruflich(?) AS ectsSumBeruflich + '; + + return $this->execQuery($qry, array($student_uid)); + } } diff --git a/application/models/education/Projektbetreuer_model.php b/application/models/education/Projektbetreuer_model.php index 4da88e344..0200f6468 100644 --- a/application/models/education/Projektbetreuer_model.php +++ b/application/models/education/Projektbetreuer_model.php @@ -42,6 +42,34 @@ class Projektbetreuer_model extends DB_Model } } + /** + * Gets Betreuer of a certain Type of a Projektarbeit. + * Returns one row for each person. + * @param int $projektarbeit_id + * @param string $betreuerart_kurzbz + * @return array success with number of Betreuer or error + */ + public function getBetreuerOfProjektarbeit($projektarbeit_id, $betreuerart_kurzbz) + { + $qry = "SELECT DISTINCT ON (pers.person_id) pers.person_id, betreuerart_kurzbz, vorname, nachname, + trim(COALESCE(titelpre,'')||' '||COALESCE(vorname,'')||' '||COALESCE(nachname,'')||' '||COALESCE(titelpost,'')) as voller_name, + anrede, titelpre, titelpost, gebdatum, geschlecht, pa.projekttyp_kurzbz, + ben.uid, ben.alias, ma.personalnummer, mitarbeiter_uid, student_uid + FROM lehre.tbl_projektarbeit pa + JOIN lehre.tbl_projektbetreuer USING (projektarbeit_id) + JOIN public.tbl_person pers USING (person_id) + LEFT JOIN public.tbl_benutzer ben USING (person_id) + LEFT JOIN public.tbl_mitarbeiter ma ON ben.uid = ma.mitarbeiter_uid + WHERE ben.aktiv + AND projektarbeit_id = ? + AND betreuerart_kurzbz = ? + ORDER BY pers.person_id, CASE WHEN ma.mitarbeiter_uid IS NULL THEN 1 ELSE 0 END, /*Mitarbeiter account first*/ + CASE WHEN ben.uid IS NULL THEN 1 ELSE 0 END, /*user with account first*/ + ben.insertamum"; + + return $this->execQuery($qry, array($projektarbeit_id, $betreuerart_kurzbz)); + } + /** * Get Projektbetreuer data by authentification token * @param $zugangstoken @@ -60,4 +88,83 @@ class Projektbetreuer_model extends DB_Model return $this->execQuery($qry, array($zugangstoken)); } + + /** + * Holt Zweitbegutachter einer Projektarbeit mit Mail. + * @param $erstbegutachter_person_id int person_id des Erstbegutachters + * @param $projektarbeit_id int + * @param $student_uid string uid des Studenten der Arbeit abgibt + * @return object | bool + */ + public function getZweitbegutachterWithToken($erstbegutachter_person_id, $projektarbeit_id, $student_uid) + { + $qry_betr = "SELECT betr.person_id, betr.projektarbeit_id, pers.anrede, betr.zugangstoken, betr.zugangstoken_gueltigbis, tbl_benutzer.uid, kontakt, + trim(COALESCE(titelpre,'')||' '||COALESCE(vorname,'')||' '||COALESCE(nachname,'')||' '||COALESCE(titelpost,'')) as voller_name, + CASE WHEN tbl_benutzer.uid IS NULL THEN kontakt ELSE tbl_benutzer.uid || '@".DOMAIN."' END AS email, abg.abgabedatum + FROM lehre.tbl_projektbetreuer betr + JOIN lehre.tbl_projektarbeit parb ON betr.projektarbeit_id = parb.projektarbeit_id + JOIN public.tbl_person pers ON betr.person_id = pers.person_id + LEFT JOIN public.tbl_kontakt ON pers.person_id = tbl_kontakt.person_id AND kontakttyp = 'email' AND zustellung = true + LEFT JOIN public.tbl_benutzer ON pers.person_id = tbl_benutzer.person_id + LEFT JOIN campus.tbl_paabgabe abg ON betr.projektarbeit_id = abg.projektarbeit_id AND abg.paabgabetyp_kurzbz = 'end' + WHERE betr.betreuerart_kurzbz = 'Zweitbegutachter' + AND betr.projektarbeit_id = ? + AND parb.student_uid = ? + AND EXISTS ( + SELECT 1 FROM lehre.tbl_projektbetreuer + WHERE person_id = ? + AND betreuerart_kurzbz = 'Erstbegutachter' + AND projektarbeit_id = betr.projektarbeit_id + ) + AND (tbl_benutzer.aktiv OR tbl_benutzer.aktiv IS NULL) + ORDER BY betr.insertamum DESC + LIMIT 1"; + + return $this->execQuery($qry_betr, array($projektarbeit_id, $student_uid, $erstbegutachter_person_id)); + } + + /** + * Generiert neuen Token für externen Zweitbetreuer. + * @param int $zweitbegutachter_person_id + * @param int $projektarbeit_id + * @return array + */ + public function generateZweitbegutachterToken($zweitbegutachter_person_id, $projektarbeit_id) + { + $betreuerUidQry = "SELECT uid, zugangstoken, zugangstoken_gueltigbis, tbl_projektbetreuer.person_id + FROM lehre.tbl_projektbetreuer + JOIN public.tbl_person USING(person_id) + LEFT JOIN public.tbl_benutzer USING(person_id) + WHERE projektarbeit_id = ? + AND tbl_projektbetreuer.person_id = ? + AND betreuerart_kurzbz = 'Zweitbegutachter' + LIMIT 1"; + + $betreueruidres = $this->execQuery($betreuerUidQry, array($projektarbeit_id, $zweitbegutachter_person_id)); + + if (!hasData($betreueruidres)) + return error('Zweitbegutachter nicht gefunden'); + + $row_betr = getData($betreueruidres)[0]; + + if (!isset($row_betr->uid)) + { + do { + $token = generateToken(16); + $qry_tokencheck = $this->load(array('zugangstoken' => $token)); + } while(hasData($qry_tokencheck)); + + $result = $this->update( + array('projektarbeit_id' => $projektarbeit_id, + 'person_id' => $row_betr->person_id, + 'betreuerart_kurzbz' => 'Zweitbegutachter'), + array('zugangstoken' => $token, + 'zugangstoken_gueltigbis' => date('Y-m-d', strtotime('+1 year'))) + ); + + return $result; + } + else + return success("Account vorhanden, kein Token benötigt"); + } } diff --git a/application/models/organisation/Studiensemester_model.php b/application/models/organisation/Studiensemester_model.php index 07783cf0d..bb9b94c92 100644 --- a/application/models/organisation/Studiensemester_model.php +++ b/application/models/organisation/Studiensemester_model.php @@ -13,6 +13,20 @@ class Studiensemester_model extends DB_Model $this->hasSequence = false; } + /** + * Get actual Studiensemester. + * + * @return array + */ + public function getAkt() + { + return $this->loadWhere(array( + 'start <= ' => 'NOW()', + 'ende >= ' => 'NOW()' + ) + ); + } + // Get next study semester public function getNext() { @@ -91,7 +105,7 @@ class Studiensemester_model extends DB_Model /** * getPreviousFrom */ - public function getPreviousFrom($studiensemester_kurzbz) + public function getPreviousFrom($studiensemester_kurzbz, $limit = 1) { $query = 'SELECT studiensemester_kurzbz, start, @@ -103,9 +117,9 @@ class Studiensemester_model extends DB_Model WHERE studiensemester_kurzbz = ? ) ORDER BY start DESC - LIMIT 1'; + LIMIT ?'; - return $this->execQuery($query, array($studiensemester_kurzbz)); + return $this->execQuery($query, array($studiensemester_kurzbz, $limit)); } /** @@ -167,15 +181,13 @@ class Studiensemester_model extends DB_Model if (date_format(date_create($from), 'Y-m-d') > (date_format(date_create($to), 'Y-m-d'))) return success(array()); - $query = "SELECT * - FROM public.tbl_studiensemester - WHERE - (ende > ?::date AND start < ?::date) - OR start = ?::date - OR ende = ?::date - ORDER BY start DESC"; + $query = " + SELECT * + FROM public.tbl_studiensemester + WHERE ( ?::date < ende AND ?::date > start ) + ORDER BY start DESC"; - return $this->execQuery($query, array($from, $to, $from, $to)); + return $this->execQuery($query, array($from, $to)); } /** diff --git a/application/models/person/Fotostatusperson_model.php b/application/models/person/Fotostatusperson_model.php new file mode 100644 index 000000000..7f701063d --- /dev/null +++ b/application/models/person/Fotostatusperson_model.php @@ -0,0 +1,22 @@ +dbTable = 'public.tbl_person_fotostatus'; + $this->pk = 'person_fotostatus_id'; + } + + public function getLastFotoStatus($person_id) + { + $this->addOrder('datum', 'DESC'); + $this->addOrder('person_fotostatus_id', 'DESC'); + $this->addLimit(1); + + return $this->loadWhere(array('person_id' => $person_id)); + } + +} \ No newline at end of file diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index 559700390..8875fd4c5 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -82,7 +82,7 @@ class Person_model extends DB_Model } else { - $person['svnr'] = $person['svnr'] . 'v' . ($result->retval[0]->svnr{11} + 1); + $person['svnr'] = $person['svnr'] . 'v' . ($result->retval[0]->svnr[11] + 1); } } } @@ -193,7 +193,7 @@ class Person_model extends DB_Model */ public function getByUid($uid) { - $this->addSelect('vorname, nachname, gebdatum, person_id, bpk, matr_nr'); + $this->addSelect('vorname, nachname, gebdatum, person_id, bpk, matr_nr, foto'); $this->addJoin('tbl_benutzer', 'person_id'); return $this->loadWhere(array('uid' => $uid)); @@ -283,8 +283,8 @@ class Person_model extends DB_Model SELECT p2.person_id FROM public.tbl_person p JOIN public.tbl_person p2 - ON p.vorname = p2.vorname - AND p.nachname = p2.nachname + ON lower(p.vorname) = lower(p2.vorname) + AND lower(p.nachname) = lower(p2.nachname) AND p.gebdatum = p2.gebdatum AND p.person_id = ? ) @@ -310,8 +310,8 @@ class Person_model extends DB_Model SELECT p2.person_id FROM public.tbl_person p JOIN public.tbl_person p2 - ON p.vorname = p2.vorname - AND p.nachname = p2.nachname + ON lower(p.vorname) = lower(p2.vorname) + AND lower(p.nachname) = lower(p2.nachname) AND p.gebdatum = p2.gebdatum AND p.person_id = ? ) @@ -321,8 +321,18 @@ class Person_model extends DB_Model JOIN public.tbl_status USING(status_kurzbz) WHERE status_kurzbz = 'Abbrecher' ) - "; - return $this->execQuery($qry, array($person_id, $person_id)); + UNION + + SELECT p2.person_id + FROM tbl_person p1 + INNER JOIN ( + SELECT vorname, nachname, gebdatum, person_id + FROM tbl_person + ) p2 + ON (lower(p1.vorname) = lower(p2.vorname) AND lower(p1.nachname) = lower(p2.nachname) AND p1.gebdatum = p2.gebdatum) + WHERE p1.person_id != p2.person_id AND (p1.person_id = ?)"; + + return $this->execQuery($qry, array($person_id, $person_id, $person_id)); } } diff --git a/application/models/ressource/Betriebsmittelperson_model.php b/application/models/ressource/Betriebsmittelperson_model.php index 1a97d9e38..04878a9ad 100644 --- a/application/models/ressource/Betriebsmittelperson_model.php +++ b/application/models/ressource/Betriebsmittelperson_model.php @@ -55,4 +55,45 @@ class Betriebsmittelperson_model extends DB_Model return $this->loadWhere($condition); } + + public function getBetriebsmittelZuordnung($cardIdentifier, $typ = 'Zutrittskarte', $ausgegeben = true) + { + $this->addJoin('wawi.tbl_betriebsmittel', 'betriebsmittel_id'); + + $where = 'wawi.tbl_betriebsmittel.nummer2 = \'' . $cardIdentifier . '\' + AND wawi.tbl_betriebsmittel.betriebsmitteltyp = \''. $typ .'\' + AND (retouram >= now() OR retouram IS NULL) + '; + + if ($ausgegeben) + $where .= 'AND ausgegebenam <= now()'; + else + $where .= 'AND (ausgegebenam <= now() OR ausgegebenam IS NULL)'; + + return $this->loadWhere($where); + } + + public function getBetriebsmittelByUid($uid, $betriebsmitteltyp = null, $isRetourniert = false) + { + $this->addJoin('wawi.tbl_betriebsmittel', 'betriebsmittel_id'); + + $condition = ' wawi.tbl_betriebsmittelperson.uid = '. $this->escape($uid); + + if (is_string($betriebsmitteltyp)) + { + $condition .= ' AND betriebsmitteltyp = ' . $this->escape($betriebsmitteltyp); + } + + if ($isRetourniert === true) { + $condition .= ' AND retouram IS NOT NULL'; + } + elseif ($isRetourniert === false) + { + $condition .= ' AND retouram IS NULL'; + } + + $this->addOrder('ausgegebenam', 'DESC'); + + return $this->loadWhere($condition); + } } diff --git a/application/models/ressource/Stundenplandev_model.php b/application/models/ressource/Stundenplandev_model.php index 9fa92ae5e..a498e209b 100644 --- a/application/models/ressource/Stundenplandev_model.php +++ b/application/models/ressource/Stundenplandev_model.php @@ -61,4 +61,98 @@ class Stundenplandev_model extends DB_Model return $this->execQuery($qry, $parametersArray); } + + /** + * Get Stundenplan data. + * + * @param null $lehrveranstaltung_id + * @param null $studiensemester_kurzbz + * @param null $lehreinheit_id + * @param null $mitarbeiter_uid + * @param null $student_uid + * @param false $nurBevorstehende If true, only future data is retrieved. + * @return array|false|stdClass|null + */ + public function getStundenplanData($lehrveranstaltung_id=null, $studiensemester_kurzbz=null, $lehreinheit_id=null, $mitarbeiter_uid=null, $student_uid=null, $nurBevorstehende = false) + { + $params = array(); + + $qry = "SELECT + stpl.datum, min(stpl.stunde) as stundevon, max(stpl.stunde) as stundebis, + stpl.lehreinheit_id, lehrfach.bezeichnung as lehrfach_bezeichnung, + array_agg( + CASE WHEN gruppe_kurzbz is not null THEN gruppe_kurzbz + ELSE (SELECT UPPER(typ || kurzbz) FROM public.tbl_studiengang WHERE studiengang_kz=stpl.studiengang_kz) || COALESCE(stpl.semester,'0') || COALESCE(stpl.verband,'') || COALESCE(stpl.gruppe,'') + END) as gruppen, array_agg(mitarbeiter_uid) as lektoren, + array_agg(ort_kurzbz) as orte, + array_agg(titel) as titel + FROM + lehre.tbl_stundenplandev as stpl + JOIN lehre.tbl_lehreinheit USING(lehreinheit_id) + JOIN lehre.tbl_lehrveranstaltung as lehrfach ON(tbl_lehreinheit.lehrfach_id=lehrfach.lehrveranstaltung_id) + WHERE "; + + if ($lehrveranstaltung_id != '') + { + $qry.=" + lehreinheit_id IN ( + SELECT lehreinheit_id FROM lehre.tbl_lehreinheit + WHERE lehrveranstaltung_id = ? + AND studiensemester_kurzbz = ? + )"; + + $params[]= $lehrveranstaltung_id; + $params[]= $studiensemester_kurzbz; + + } + elseif ($lehreinheit_id!='') + { + $qry.=" lehreinheit_id = ?"; + + $params[]= $lehreinheit_id; + } + elseif ($mitarbeiter_uid != '') + { + $qry.= " + mitarbeiter_uid = ? + AND lehreinheit_id IN ( + SELECT lehreinheit_id + FROM lehre.tbl_lehreinheitmitarbeiter + JOIN lehre.tbl_lehreinheit USING (lehreinheit_id) + WHERE mitarbeiter_uid = ? + AND studiensemester_kurzbz IN ( ? ) + )"; + $params[] = $mitarbeiter_uid; + $params[] = $mitarbeiter_uid; + $params[] = $studiensemester_kurzbz; + } + elseif ($student_uid != '') + { + $qry.=" + lehreinheit_id IN ( + SELECT lehreinheit_id + FROM campus.vw_student_lehrveranstaltung + WHERE uid = ? + AND studiensemester_kurzbz = ? + )"; + + $params[] = $student_uid; + $params[] = $studiensemester_kurzbz; + } + else + return false; + + if($nurBevorstehende) + { + $qry.= " AND stpl.datum >= NOW()::date "; + } + + $qry.= " + GROUP BY stpl.datum, stpl.unr, stpl.lehreinheit_id, lehrfach.bezeichnung + ORDER BY stpl.datum, min(stpl.stunde), stpl.unr, stpl.lehreinheit_id + "; + + return $this->execQuery($qry, $params); + } + } diff --git a/application/models/ressource/Zeitsperre_model.php b/application/models/ressource/Zeitsperre_model.php index 350a7be58..078d29d8b 100644 --- a/application/models/ressource/Zeitsperre_model.php +++ b/application/models/ressource/Zeitsperre_model.php @@ -12,6 +12,47 @@ class Zeitsperre_model extends DB_Model $this->pk = 'zeitsperre_id'; } + /** + * Save or update Zeitsperre. + * + * @param $zeitsperretyp_kurzbz + * @param $mitarbeiter_uid + * @param $vonDatum + * @param $bisDatum + * @param null $vonStunde + * @param null $bisStunde + * @param null $bezeichnung + * @param null $vertretung_uid + * @param null $erreichbarkeit_kurzbz + * @param null $freigabeamum + * @param null $freigabevon + * @return array + */ + public function save($zeitsperretyp_kurzbz, $mitarbeiter_uid, $vonDatum, $bisDatum, + $vonStunde = null, $bisStunde = null, $bezeichnung = null, $vertretung_uid = null, + $erreichbarkeit_kurzbz = null, $freigabeamum = null, $freigabevon = null) + { + return $this->insert(array( + 'zeitsperretyp_kurzbz' => $zeitsperretyp_kurzbz, + 'mitarbeiter_uid' => $mitarbeiter_uid, + 'vondatum' => $vonDatum, + 'bisdatum' => $bisDatum, + 'vonstunde' => $vonStunde, + 'bisstunde' => $bisStunde, + 'bezeichnung' => $bezeichnung, + 'vertretung_uid' => $vertretung_uid, + 'insertvon' => getAuthUID(), + 'insertamum' => (new DateTime())->format('Y-m-d H:i:s'), + 'erreichbarkeit_kurzbz' => $erreichbarkeit_kurzbz, + 'freigabeamum' => $freigabeamum, + 'freigabevon' => $freigabevon + )); + } + + /** + * Delete Zeitsperre. + * @return array|stdClass|null + */ public function deleteEntriesForCurrentDay() { $today = date('Y-m-d'); diff --git a/application/models/ressource/Zeitwunsch_gueltigkeit_model.php b/application/models/ressource/Zeitwunsch_gueltigkeit_model.php new file mode 100644 index 000000000..f26e06d3c --- /dev/null +++ b/application/models/ressource/Zeitwunsch_gueltigkeit_model.php @@ -0,0 +1,14 @@ +dbTable = 'campus.tbl_zeitwunsch_gueltigkeit'; + $this->pk = 'zeitwunsch_gueltigkeit_id'; + } +} \ No newline at end of file diff --git a/application/models/system/Benutzerrolle_model.php b/application/models/system/Benutzerrolle_model.php index 765ad9bd4..0714a1f8f 100644 --- a/application/models/system/Benutzerrolle_model.php +++ b/application/models/system/Benutzerrolle_model.php @@ -43,7 +43,7 @@ class Benutzerrolle_model extends DB_Model * @param null $oe_kurzbz * @return array */ - public function getBenutzerByBerechtigung($berechtigung_kurzbz, $oe_kurzbz = null) + public function getBenutzerByBerechtigung($berechtigung_kurzbz, $oe_kurzbz = null, $art = null) { $params = array(); $query = ' @@ -62,6 +62,12 @@ class Benutzerrolle_model extends DB_Model $params[] = $oe_kurzbz; } + if (!is_null($art)) + { + $query .= ' AND art = ?'; + $params[] = $art; + } + return $this->execQuery($query, $params); } } diff --git a/application/models/system/Fehlerzustaendigkeiten_model.php b/application/models/system/Fehlerzustaendigkeiten_model.php new file mode 100644 index 000000000..9277f3609 --- /dev/null +++ b/application/models/system/Fehlerzustaendigkeiten_model.php @@ -0,0 +1,58 @@ +dbTable = 'system.tbl_fehler_zustaendigkeiten'; + $this->pk = 'fehlerzustaendigkeiten_id'; + } + + /** + * Gets active Mitarbeiter not assigned to a Fehler. + * @param $fehlercode + * @return object + */ + public function getNonAssignedMitarbeiter($fehlercode) + { + $query = "SELECT person_id, ben.uid, vorname, nachname, titelpre, titelpost, personalnummer + FROM public.tbl_mitarbeiter + JOIN public.tbl_benutzer ben ON tbl_mitarbeiter.mitarbeiter_uid = ben.uid + JOIN public.tbl_person pers USING (person_id) + WHERE ben.aktiv + AND NOT EXISTS ( + SELECT 1 FROM system.tbl_fehler_zustaendigkeiten + WHERE person_id = pers.person_id + AND fehlercode = ? + ) + ORDER BY nachname, vorname, uid"; + + return $this->execReadOnlyQuery($query, array($fehlercode)); + } + + /** + * Gets Funktionen not assigned to a Fehler (over an organisational unit). + * @param $fehlercode + * @param $oe_kurzbz + * @return object + */ + public function getNonAssignedFunktionen($fehlercode, $oe_kurzbz) + { + $query = "SELECT funktion_kurzbz, beschreibung + FROM public.tbl_funktion funk + WHERE aktiv + AND NOT EXISTS ( + SELECT 1 FROM system.tbl_fehler_zustaendigkeiten + WHERE funktion_kurzbz = funk.funktion_kurzbz + AND fehlercode = ? + AND oe_kurzbz = ? + ) + ORDER BY beschreibung"; + + return $this->execReadOnlyQuery($query, array($fehlercode, $oe_kurzbz)); + } +} diff --git a/application/models/system/Variablenname_model.php b/application/models/system/Variablenname_model.php index 869a03275..33ace3c8d 100644 --- a/application/models/system/Variablenname_model.php +++ b/application/models/system/Variablenname_model.php @@ -12,7 +12,14 @@ class Variablenname_model extends DB_Model ) sem WHERE start > now() LIMIT 1;', - 'infocenter_studiensgangtyp' => 'SELECT infocenter_studiensgangtyp FROM public.tbl_variablenname LIMIT 1' + 'infocenter_studiensgangtyp' => 'SELECT infocenter_studiensgangtyp FROM public.tbl_variablenname LIMIT 1;', + 'projektuebersicht_studiensemester' => 'SELECT studiensemester_kurzbz FROM ( + SELECT DISTINCT ON (studienjahr_kurzbz) start, studiensemester_kurzbz + FROM public.tbl_studiensemester + ORDER BY studienjahr_kurzbz, start + ) sem + WHERE start > now() + LIMIT 1;' ); /** diff --git a/application/views/lehre/anrechnung/approveAnrechnungDetail.php b/application/views/lehre/anrechnung/approveAnrechnungDetail.php index cd38fd9ac..248dd33ca 100644 --- a/application/views/lehre/anrechnung/approveAnrechnungDetail.php +++ b/application/views/lehre/anrechnung/approveAnrechnungDetail.php @@ -44,7 +44,8 @@ $this->load->view( 'empfehlungsanforderungWirklichZuruecknehmen', 'erfolgreichZurueckgenommen', 'empfehlungPositivConfirmed', - 'empfehlungNegativConfirmed' + 'empfehlungNegativConfirmed', + 'anrechnungEctsTooltipTextBeiUeberschreitung' ) ), 'customCSSs' => array( @@ -59,7 +60,6 @@ $this->load->view( ); ?> -
@@ -124,11 +124,27 @@ $this->load->view( p->t('lehre', 'ects'); ?> - ects ?> + ects ?> + + + p->t('anrechnung', 'bisherAngerechneteEcts'); ?> + + + + + + Total: sumEctsSchulisch + $antragData->sumEctsBeruflich, 1) ?> + [Schulisch: sumEctsSchulisch ?> / + Beruflich: sumEctsBeruflich ?> ] + + + p->t('lehre', 'lektorInnen'); ?> - + lektoren) - 1 ?> lektoren as $key => $lektor): ?> vorname . ' ' . $lektor->nachname; @@ -138,19 +154,23 @@ $this->load->view( p->t('global', 'zgv')); ?> - zgv ?> + zgv ?> p->t('anrechnung', 'herkunftDerKenntnisse'); ?> - anmerkung ?> + anmerkung ?> p->t('anrechnung', 'nachweisdokumente'); ?> - + dokumentname) ?> + + p->t('global', 'begruendung'); ?> + begruendung ?> +
@@ -178,8 +198,10 @@ $this->load->view(
- + + + + @@ -291,38 +313,44 @@ $this->load->view( -load->view('templates/FHC-Footer'); ?> diff --git a/application/views/lehre/anrechnung/approveAnrechnungUebersicht.php b/application/views/lehre/anrechnung/approveAnrechnungUebersicht.php index 308f702a3..e2452fb13 100644 --- a/application/views/lehre/anrechnung/approveAnrechnungUebersicht.php +++ b/application/views/lehre/anrechnung/approveAnrechnungUebersicht.php @@ -87,7 +87,6 @@ $this->load->view( ); ?> -
@@ -134,28 +133,34 @@ $this->load->view( id="approveAnrechnungUebersicht-begruendung-panel">

p->t('anrechnung', 'genehmigungenNegativQuestion'); ?>

-  p->t('anrechnung', 'bitteBegruendungAngeben'); ?>

-
    -
  1. p->t('anrechnung', 'genehmigungNegativPruefungNichtMoeglich'); ?> - - - -
  2. -
  3. p->t('anrechnung', 'genehmigungNegativKenntnisseNichtGleichwertig'); ?> - - - -
  4. -
  5. p->t('anrechnung', 'andereBegruendung'); ?>
  6. -
-
+  p->t('anrechnung', 'bitteBegruendungAngeben'); ?> p->t('anrechnung', 'begruendungWirdFuerAlleUebernommen'); ?> -

+
+

+
    +
  1. p->t('anrechnung', 'genehmigungNegativPruefungNichtMoeglich'); ?> + + + +
  2. +
  3. p->t('anrechnung', 'genehmigungNegativKenntnisseNichtGleichwertig'); ?> + + + +
  4. +
  5. p->t('anrechnung', 'genehmigungNegativEctsHoechstgrenzeUeberschritten'); ?> + + + +
  6. +
+ rows="2" + placeholder="p->t('anrechnung', 'textUebernehmenOderEigenenBegruendungstext'); ?>" required>

@@ -249,6 +254,5 @@ $this->load->view(
-load->view('templates/FHC-Footer'); ?> diff --git a/application/views/lehre/anrechnung/approveAnrechnungUebersichtData.php b/application/views/lehre/anrechnung/approveAnrechnungUebersichtData.php index 31e848481..83370769f 100644 --- a/application/views/lehre/anrechnung/approveAnrechnungUebersichtData.php +++ b/application/views/lehre/anrechnung/approveAnrechnungUebersichtData.php @@ -16,15 +16,20 @@ $query = ' anrechnung.dms_id, anrechnung.studiensemester_kurzbz, stg.studiengang_kz, - stg.bezeichnung AS "stg_bezeichnung", + stg.bezeichnung AS stg_bezeichnung, lv.orgform_kurzbz, (SELECT ausbildungssemester FROM public.tbl_prestudentstatus press WHERE press.prestudent_id = anrechnung.prestudent_id AND press.studiensemester_kurzbz = anrechnung.studiensemester_kurzbz - AND press.status_kurzbz = \'Student\'), - lv.bezeichnung AS "lv_bezeichnung", - lv.ects, + AND press.status_kurzbz = \'Student\' + ORDER BY press.datum DESC + LIMIT 1 + ), + lv.bezeichnung AS lv_bezeichnung, + lv.ects::numeric(4,1), + get_ects_summe_schulisch(student.student_uid, anrechnung.prestudent_id, stg.studiengang_kz) AS ectsSumSchulisch, + get_ects_summe_beruflich(student.student_uid) AS ectsSumBeruflich, (person.nachname || \' \' || person.vorname) AS "student", begruendung.bezeichnung AS "begruendung", dmsversion.name AS "dokument_bezeichnung", @@ -46,7 +51,9 @@ $query = ' WHERE anrechnung_id = anrechnung.anrechnung_id ORDER BY insertamum DESC LIMIT 1 - ) AS status_kurzbz + ) AS status_kurzbz, + student.student_uid, + anrechnung.prestudent_id FROM lehre.tbl_anrechnung AS anrechnung JOIN public.tbl_prestudent USING (prestudent_id) JOIN public.tbl_person AS person USING (person_id) @@ -55,44 +62,69 @@ $query = ' LEFT JOIN campus.tbl_dms_version AS dmsversion USING (dms_id) JOIN lehre.tbl_anrechnung_anrechnungstatus USING (anrechnung_id) JOIN lehre.tbl_anrechnung_begruendung AS begruendung USING (begruendung_id) + JOIN public.tbl_student student USING (prestudent_id) + WHERE anrechnung.studiensemester_kurzbz = \'' . $STUDIENSEMESTER . '\' + AND stg.studiengang_kz IN (' . $STUDIENGAENGE_ENTITLED . ') ) - - SELECT anrechnungen.*, - array_to_json(anrechnungstatus.bezeichnung_mehrsprachig::varchar[])->>' . $LANGUAGE_INDEX . ' AS "status_bezeichnung", - CASE - WHEN (anrechnungen.empfehlung_anrechnung IS NULL AND anrechnungen.status_kurzbz = \'' . ANRECHNUNGSTATUS_PROGRESSED_BY_STGL . '\') THEN NULL - ELSE - (SELECT insertamum::date - FROM lehre.tbl_anrechnungstatus - JOIN lehre.tbl_anrechnung_anrechnungstatus USING (status_kurzbz) - WHERE anrechnung_id = anrechnungen.anrechnung_id - AND status_kurzbz = \'' . ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR . '\' - ORDER BY insertamum DESC - LIMIT 1) - END "empfehlungsanfrageAm", - CASE - WHEN (anrechnungen.empfehlung_anrechnung IS NULL AND anrechnungen.status_kurzbz = \'' . ANRECHNUNGSTATUS_PROGRESSED_BY_STGL . '\') THEN NULL - ELSE - (SELECT COALESCE( - STRING_AGG(CONCAT_WS(\' \', vorname, nachname), \', \') FILTER (WHERE lvleiter = TRUE), - STRING_AGG(CONCAT_WS(\' \', vorname, nachname), \', \') FILTER (WHERE lvleiter = FALSE) - ) empfehlungsanfrageAn - FROM ( - SELECT DISTINCT ON (benutzer.uid) uid, vorname, nachname, - CASE WHEN lehrfunktion_kurzbz = \'LV-Leitung\' THEN TRUE ELSE FALSE END AS lvleiter - FROM lehre.tbl_lehreinheit - JOIN lehre.tbl_lehreinheitmitarbeiter lema USING (lehreinheit_id) - JOIN public.tbl_benutzer benutzer ON lema.mitarbeiter_uid = benutzer.uid - JOIN public.tbl_person USING (person_id) - WHERE studiensemester_kurzbz = \'' . $STUDIENSEMESTER . '\' - AND lehrveranstaltung_id = anrechnungen.lehrveranstaltung_id - AND lema.mitarbeiter_uid NOT like \'_Dummy%\' - AND benutzer.aktiv = TRUE - AND tbl_person.aktiv = TRUE - ORDER BY benutzer.uid, lvleiter DESC, nachname, vorname - ) as tmp_lvlektoren - ) - END "empfehlungsanfrageAn" + + SELECT anrechnungen.anrechnung_id, + anrechnungen.lehrveranstaltung_id, + anrechnungen.begruendung_id, + anrechnungen.dms_id, + anrechnungen.studiensemester_kurzbz, + anrechnungen.studiengang_kz, + anrechnungen.stg_bezeichnung, + anrechnungen.orgform_kurzbz, + anrechnungen.ausbildungssemester, + anrechnungen.lv_bezeichnung, + anrechnungen.ects::float4 AS ects, + NULL AS "ectsSumBisherUndNeu", + anrechnungen.ectsSumSchulisch::float4 AS "ectsSumSchulisch", + anrechnungen.ectsSumBeruflich::float4 AS "ectsSumBeruflich", + anrechnungen.begruendung, + anrechnungen.student, + anrechnungen.dokument_bezeichnung, + anrechnungen.anmerkung_student, + anrechnungen.zgv, + anrechnungen.antragsdatum, + anrechnungen.empfehlung_anrechnung, + anrechnungen.status_kurzbz, + array_to_json(anrechnungstatus.bezeichnung_mehrsprachig::varchar[])->>' . $LANGUAGE_INDEX . ' AS "status_bezeichnung", + anrechnungen.prestudent_id, + CASE + WHEN (anrechnungen.empfehlung_anrechnung IS NULL AND anrechnungen.status_kurzbz = \'' . ANRECHNUNGSTATUS_PROGRESSED_BY_STGL . '\') THEN NULL + ELSE + (SELECT insertamum::date + FROM lehre.tbl_anrechnungstatus + JOIN lehre.tbl_anrechnung_anrechnungstatus USING (status_kurzbz) + WHERE anrechnung_id = anrechnungen.anrechnung_id + AND status_kurzbz = \'' . ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR . '\' + ORDER BY insertamum DESC + LIMIT 1) + END "empfehlungsanfrageAm", + CASE + WHEN (anrechnungen.empfehlung_anrechnung IS NULL AND anrechnungen.status_kurzbz = \'' . ANRECHNUNGSTATUS_PROGRESSED_BY_STGL . '\') THEN NULL + ELSE + (SELECT COALESCE( + STRING_AGG(CONCAT_WS(\' \', vorname, nachname), \', \') FILTER (WHERE lvleiter = TRUE), + STRING_AGG(CONCAT_WS(\' \', vorname, nachname), \', \') FILTER (WHERE lvleiter = FALSE) + ) empfehlungsanfrageAn + FROM ( + SELECT DISTINCT ON (benutzer.uid) uid, vorname, nachname, + CASE WHEN lehrfunktion_kurzbz = \'LV-Leitung\' THEN TRUE ELSE FALSE END AS lvleiter + FROM lehre.tbl_lehreinheit + JOIN lehre.tbl_lehreinheitmitarbeiter lema USING (lehreinheit_id) + JOIN public.tbl_benutzer benutzer ON lema.mitarbeiter_uid = benutzer.uid + JOIN public.tbl_person USING (person_id) + WHERE studiensemester_kurzbz = \'' . $STUDIENSEMESTER . '\' + AND lehrveranstaltung_id = anrechnungen.lehrveranstaltung_id + AND lema.mitarbeiter_uid NOT like \'_Dummy%\' + AND benutzer.aktiv = TRUE + AND tbl_person.aktiv = TRUE + ORDER BY benutzer.uid, lvleiter DESC, nachname, vorname + ) as tmp_lvlektoren + ) + END "empfehlungsanfrageAn" FROM anrechnungen JOIN lehre.tbl_anrechnungstatus as anrechnungstatus ON (anrechnungstatus.status_kurzbz = anrechnungen.status_kurzbz) WHERE studiensemester_kurzbz = \'' . $STUDIENSEMESTER . '\' @@ -115,9 +147,12 @@ $filterWidgetArray = array( ucfirst($this->p->t('lehre', 'organisationsform')), 'Semester', ucfirst($this->p->t('lehre', 'lehrveranstaltung')), - 'ECTS', - ucfirst($this->p->t('person', 'studentIn')), + 'ECTS (LV)', + 'ECTS (LV + Bisher)', + 'ECTS (Bisher schulisch)', + 'ECTS (Bisher beruflich', ucfirst($this->p->t('global', 'begruendung')), + ucfirst($this->p->t('person', 'studentIn')), ucfirst($this->p->t('anrechnung', 'nachweisdokumente')), ucfirst($this->p->t('anrechnung', 'herkunft')), ucfirst($this->p->t('global', 'zgv')), @@ -125,6 +160,7 @@ $filterWidgetArray = array( ucfirst($this->p->t('anrechnung', 'empfehlung')), 'status_kurzbz', 'Status', + 'PrestudentID', ucfirst($this->p->t('anrechnung', 'empfehlungsanfrageAm')), ucfirst($this->p->t('anrechnung', 'empfehlungsanfrageAn')) ), @@ -152,8 +188,8 @@ $filterWidgetArray = array( rowFormatter:function(row){ func_rowFormatter(row); }, - rowUpdated:function(row){ - func_rowUpdated(row); + rowSelectionChanged:function(data, rows){ + func_rowSelectionChanged(data, rows); }, tooltips: function(cell){ return func_tooltips(cell); @@ -171,8 +207,11 @@ $filterWidgetArray = array( ausbildungssemester: {headerFilter:"input"}, lv_bezeichnung: {headerFilter:"input"}, ects: {headerFilter:"input", align:"center"}, + ectsSumBisherUndNeu: {formatter: format_ectsSumBisherUndNeu}, + ectsSumSchulisch: {visible: false, headerFilter:"input", align:"right"}, + ectsSumBeruflich: {visible: false, headerFilter:"input", align:"right"}, + begruendung: {headerFilter:"input", visible: true}, student: {headerFilter:"input"}, - begruendung: {headerFilter:"input"}, zgv: {visible: false, headerFilter:"input"}, dokument_bezeichnung: {headerFilter:"input", formatter:"link", formatterParams:{ labelField:"dokument_bezeichnung", @@ -184,6 +223,7 @@ $filterWidgetArray = array( empfehlung_anrechnung: {headerFilter:"input", align:"center", formatter: format_empfehlung_anrechnung, headerFilterFunc: hf_filterTrueFalse}, status_kurzbz: {visible: false, headerFilter:"input"}, status_bezeichnung: {headerFilter:"input"}, + prestudent_id: {visible: false, headerFilter:"input"}, empfehlungsanfrageAm: {visible: false, align:"center", headerFilter:"input", mutator: mut_formatStringDate}, empfehlungsanfrageAn: {visible: false, headerFilter:"input"} }', // col properties @@ -191,4 +231,4 @@ $filterWidgetArray = array( echo $this->widgetlib->widget('TableWidget', $filterWidgetArray); -?> \ No newline at end of file +?> diff --git a/application/views/lehre/anrechnung/createAnrechnung.php b/application/views/lehre/anrechnung/createAnrechnung.php index 58b0757b9..2d2193b80 100644 --- a/application/views/lehre/anrechnung/createAnrechnung.php +++ b/application/views/lehre/anrechnung/createAnrechnung.php @@ -38,7 +38,6 @@ $this->load->view( ); ?> -
@@ -170,4 +169,5 @@ $this->load->view(
- + +load->view('templates/FHC-Footer'); ?> diff --git a/application/views/lehre/anrechnung/requestAnrechnung.php b/application/views/lehre/anrechnung/requestAnrechnung.php index 978dd5606..8931546f6 100644 --- a/application/views/lehre/anrechnung/requestAnrechnung.php +++ b/application/views/lehre/anrechnung/requestAnrechnung.php @@ -31,7 +31,9 @@ $this->load->view( ), 'anrechnung' => array( 'deadlineUeberschritten', - 'benotungDerLV' + 'benotungDerLV', + 'anrechnungEctsTextBeiUeberschreitung', + 'anrechnungEctsTooltipTextBeiUeberschreitung' ), 'person' => array( 'student', @@ -60,7 +62,6 @@ $this->load->view( } -
@@ -80,9 +81,13 @@ $this->load->view(
+ - + + + +
@@ -119,8 +124,23 @@ $this->load->view(
- + + + + + '; $html_user_daten.=''; $html_user_daten.=''; - /* - - $html_user_daten.=''; - for($i=0;$i<$nr_mg;$i++) - { - $row=$db->db_fetch_object($erg_mg,$i); - - $html_user_daten.=''; - $html_user_daten.=''; - $html_user_daten.=''; - $html_user_daten.=''; - } - - if (isset($matrikelnr)) - { - $html_user_daten.=''; - $html_user_daten.="\n"; - $html_user_daten.=''; - $html_user_daten.="\n"; - $html_user_daten.=''; - $html_user_daten.="\n"; - $html_user_daten.=''; - $html_user_daten.="\n"; - } - $html_user_daten.='
p->t('lehre', 'ects'); ?>ects ?>ects, 1) ?> ECTS
+ p->t('anrechnung', 'bisherAngerechneteEcts'); ?> + + + + + Total ECTS: sumEctsSchulisch + $antragData->sumEctsBeruflich, 1) ?> + [ Schulisch: sumEctsSchulisch ?> | + Beruflich: sumEctsBeruflich ?> ] + +
p->t('lehre', 'lektorInnen')); ?> @@ -152,6 +172,17 @@ $this->load->view( +
+ +
- load->view('templates/FHC-Footer'); ?> diff --git a/application/views/lehre/anrechnung/reviewAnrechnungDetail.php b/application/views/lehre/anrechnung/reviewAnrechnungDetail.php index 18c70e5af..13b830731 100644 --- a/application/views/lehre/anrechnung/reviewAnrechnungDetail.php +++ b/application/views/lehre/anrechnung/reviewAnrechnungDetail.php @@ -52,7 +52,6 @@ $this->load->view( ); ?> -
@@ -225,31 +224,29 @@ $this->load->view(
- load->view('templates/FHC-Footer'); ?> diff --git a/application/views/lehre/anrechnung/reviewAnrechnungUebersicht.php b/application/views/lehre/anrechnung/reviewAnrechnungUebersicht.php index 54d0b49d1..a7b0e02b9 100644 --- a/application/views/lehre/anrechnung/reviewAnrechnungUebersicht.php +++ b/application/views/lehre/anrechnung/reviewAnrechnungUebersicht.php @@ -80,7 +80,6 @@ $this->load->view( ); ?> -
@@ -127,30 +126,31 @@ $this->load->view( id="reviewAnrechnungUebersicht-begruendung-panel">

p->t('anrechnung', 'empfehlungenNegativQuestion'); ?>

- p->t('anrechnung', 'bitteBegruendungAngeben'); ?>

-
    -
  • - p->t('anrechnung', 'empfehlungNegativPruefungNichtMoeglich'); ?> - - - -
  • -
  • - p->t('anrechnung', 'empfehlungNegativKenntnisseNichtGleichwertig'); ?> - - - -
  • -
  • p->t('anrechnung', 'andereBegruendung'); ?>
  • -
-
- + p->t('anrechnung', 'bitteBegruendungAngeben'); ?> + p->t('anrechnung', 'begruendungWirdFuerAlleUebernommen'); ?> -

+
+

+
    +
  • + p->t('anrechnung', 'empfehlungNegativPruefungNichtMoeglich'); ?> + + + +
  • +
  • + p->t('anrechnung', 'empfehlungNegativKenntnisseNichtGleichwertig'); ?> + + + +
  • +
+ rows="2" + placeholder="p->t('anrechnung', 'textUebernehmenOderEigenenBegruendungstext'); ?>" + required>

@@ -235,7 +235,6 @@ $this->load->view(
- load->view('templates/FHC-Footer'); ?> diff --git a/application/views/lehre/lvplanung/adminZeitverfuegbarkeit.php b/application/views/lehre/lvplanung/adminZeitverfuegbarkeit.php new file mode 100644 index 000000000..893a9c760 --- /dev/null +++ b/application/views/lehre/lvplanung/adminZeitverfuegbarkeit.php @@ -0,0 +1,166 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Zeitverfuegbarkeit verwalten', + 'jquery' => true, + 'jqueryui' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'momentjs' => true, + 'ajaxlib' => true, + 'tabulator' => true, + 'tablewidget' => true, + 'navigationwidget' => true, + 'sbadmintemplate' => true, + 'phrases' => array( + 'global' => array( + 'bis', + 'notiz' + ), + 'ui' => array( + 'systemfehler', + 'keineDatenVorhanden', + 'von', + 'bitteWaehlen', + 'speichern', + 'loeschen', + 'abbrechen' + ), + 'lehre' => array( + 'lektor' + ) + ), + 'widgets' => true, + 'dialoglib' => true, + 'customJSs' => array( + 'public/js/bootstrapper.js', + 'public/js/lehre/lvplanung/zverfueg.js' + ) + ) +); +?> + + +widgetlib->widget('NavigationWidget'); ?> +
+
+ + +
+ +
+ + +
+
+ + + + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+ +
+ + + +
+ +
+
+ + +
+
+ load->view('lehre/lvplanung/adminZeitverfuegbarkeitData.php'); ?> +
+
+ +
+
+
+ + +load->view('templates/FHC-Footer'); ?> diff --git a/application/views/lehre/lvplanung/adminZeitverfuegbarkeitData.php b/application/views/lehre/lvplanung/adminZeitverfuegbarkeitData.php new file mode 100644 index 000000000..81a683cff --- /dev/null +++ b/application/views/lehre/lvplanung/adminZeitverfuegbarkeitData.php @@ -0,0 +1,70 @@ += ss.start + AND zeitsperretyp_kurzbz = \'ZVerfueg\' + ORDER BY zeitsperre_id, zsp.mitarbeiter_uid + ) as tmp + ORDER BY vondatum DESC +'; + +$filterWidgetArray = array( + 'query' => $qry, + 'tableUniqueId' => 'adminZeitverfuegbarkeit', + 'requiredPermissions' => 'lehre/zeitverfuegbarkeit', + 'datasetRepresentation' => 'tabulator', + 'columnsAliases' => array( + 'ZeitsperreID', + 'UID', + ucfirst($this->p->t('lehre', 'lektor')), + ucfirst($this->p->t('ui', 'von')), + 'VonStunde', + ucfirst($this->p->t('global', 'bis')), + 'BisStunde', + ucfirst($this->p->t('global', 'notiz')) + ), + 'datasetRepOptions' => '{ + layout: "fitColumns", // fit columns to width of table + autoResize: false, // prevent auto resizing of table (false to allow adapting table size when cols are (de-)activated + headerFilterPlaceholder: " ", + index: "zeitsperre_id", // assign specific column as unique id (important for row indexing) + selectable: 1, // allow row selection + tableWidgetHeader: false, + rowSelected: function(row) { + func_rowSelected(row); + }, + rowDeselected: function(row) { + func_rowDeselected(row); + } + }', // tabulator properties + 'datasetRepFieldsDefs' => '{ + zeitsperre_id: {visible:false}, + mitarbeiter_uid: {visible: true, headerFilter:"input"}, + lektor: {visible: true, headerFilter:"input"}, + vondatum: {visible: true, headerFilter:"input"}, + vonstunde: {visible: true, headerFilter:"input"}, + bisdatum: {visible: true, headerFilter:"input"}, + bisstunde: {visible: true, headerFilter:"input"}, + bezeichnung: {visible: true, headerFilter:"input"} + }', // col properties +); + +echo $this->widgetlib->widget('TableWidget', $filterWidgetArray); + +?> diff --git a/application/views/system/infocenter/infocenterData.php b/application/views/system/infocenter/infocenterData.php index 49cc33326..acf8944d6 100644 --- a/application/views/system/infocenter/infocenterData.php +++ b/application/views/system/infocenter/infocenterData.php @@ -6,7 +6,7 @@ $INTERESSENT_STATUS = '\'Interessent\''; $STUDIENGANG_TYP = '\''.$this->variablelib->getVar('infocenter_studiensgangtyp').'\''; $TAETIGKEIT_KURZBZ = '\'bewerbung\', \'kommunikation\''; - $LOGDATA_NAME = '\'Login with code\', \'Login with user\', \'Interessent rejected\', \'Attempt to register with existing mailadress\''; + $LOGDATA_NAME = '\'Login with code\', \'Login with user\', \'Interessent rejected\', \'Attempt to register with existing mailadress\', \'Access code sent\', \'Personal data saved\''; $LOGDATA_NAME_PARKED = '\'Parked\''; $LOGDATA_NAME_ONHOLD = '\'Onhold\''; $LOGTYPE_KURZBZ = '\'Processstate\''; @@ -254,6 +254,22 @@ ORDER BY ps.zgvmanation DESC NULLS LAST, ps.prestudent_id DESC LIMIT 1 ) AS "ZGVMNation", + ( + SELECT upper(tbl_nation.nationengruppe_kurzbz) + FROM public.tbl_prestudent ps + JOIN bis.tbl_nation ON ps.zgvnation = tbl_nation.nation_code + WHERE ps.person_id = p.person_id + ORDER BY ps.zgvnation DESC NULLS LAST, ps.prestudent_id DESC + LIMIT 1 + ) AS "ZGVNationGruppe", + ( + SELECT upper(tbl_nation.nationengruppe_kurzbz) + FROM public.tbl_prestudent ps + JOIN bis.tbl_nation ON ps.zgvmanation = tbl_nation.nation_code + WHERE ps.person_id = p.person_id + ORDER BY ps.zgvmanation DESC NULLS LAST, ps.prestudent_id DESC + LIMIT 1 + ) AS "ZGVMNationGruppe", ( SELECT tbl_organisationseinheit.bezeichnung FROM public.tbl_benutzerfunktion @@ -361,6 +377,8 @@ ucfirst($this->p->t('lehre', 'studiengang')).' ('.$this->p->t('global', 'aktiv').')', 'ZGV Nation BA', 'ZGV Nation MA', + 'ZGV Gruppe BA', + 'ZGV Gruppe MA', 'InfoCenter Mitarbeiter' ), 'formatRow' => function($datasetRaw) { @@ -452,6 +470,16 @@ $datasetRaw->{'ZGVMNation'} = '-'; } + if ($datasetRaw->{'ZGVNationGruppe'} == null) + { + $datasetRaw->{'ZGVNationGruppe'} = '-'; + } + + if ($datasetRaw->{'ZGVMNationGruppe'} == null) + { + $datasetRaw->{'ZGVMNationGruppe'} = '-'; + } + if ($datasetRaw->{'InfoCenterMitarbeiter'} === null) { $datasetRaw->{'InfoCenterMitarbeiter'} = 'Nein'; diff --git a/application/views/system/infocenter/infocenterFreigegebenData.php b/application/views/system/infocenter/infocenterFreigegebenData.php index 5c0adb165..75d60a179 100644 --- a/application/views/system/infocenter/infocenterFreigegebenData.php +++ b/application/views/system/infocenter/infocenterFreigegebenData.php @@ -5,7 +5,7 @@ $INTERESSENT_STATUS = '\'Interessent\''; $STUDIENGANG_TYP = '\''.$this->variablelib->getVar('infocenter_studiensgangtyp').'\''; $TAETIGKEIT_KURZBZ = '\'bewerbung\', \'kommunikation\''; - $LOGDATA_NAME = '\'Login with code\', \'Login with user\', \'Attempt to register with existing mailadress\''; + $LOGDATA_NAME = '\'Login with code\', \'Login with user\', \'Attempt to register with existing mailadress\', \'Access code sent\', \'Personal data saved\''; $REJECTED_STATUS = '\'Abgewiesener\''; $ADDITIONAL_STG = $this->config->item('infocenter_studiengang_kz'); $STATUS_KURZBZ = '\'Wartender\', \'Bewerber\', \'Aufgenommener\', \'Student\''; @@ -199,14 +199,15 @@ $query = ' LIMIT 1 ) AS "ReihungstestApplied", ( - SELECT rtp.datum + SELECT CONCAT(rtp.datum, rtp.uhrzeit) FROM public.tbl_prestudentstatus pss JOIN public.tbl_prestudent ps USING(prestudent_id) LEFT JOIN ( SELECT rtp.person_id, rt.studiensemester_kurzbz, rtp.teilgenommen, - rt.datum + rt.datum, + rt.uhrzeit FROM public.tbl_rt_person rtp JOIN tbl_reihungstest rt ON(rtp.rt_id = rt.reihungstest_id) WHERE rt.stufe = 1 @@ -409,13 +410,13 @@ $query = ' $datasetRaw->{'ReihungstestApplied'} = 'Nein'; } - if ($datasetRaw->{'ReihungstestDate'} == null) + if ($datasetRaw->{'ReihungstestDate'} == '') { $datasetRaw->{'ReihungstestDate'} = '-'; } else { - $datasetRaw->{'ReihungstestDate'} = date_format(date_create($datasetRaw->{'ReihungstestDate'}),'Y-m-d'); + $datasetRaw->{'ReihungstestDate'} = date_format(date_create($datasetRaw->{'ReihungstestDate'}),'Y-m-d H:i'); } if ($datasetRaw->{'ZGVNation'} == null) diff --git a/application/views/system/infocenter/infocenterReihungstestAbsolviertData.php b/application/views/system/infocenter/infocenterReihungstestAbsolviertData.php index 1aeac022b..ea1fab83c 100644 --- a/application/views/system/infocenter/infocenterReihungstestAbsolviertData.php +++ b/application/views/system/infocenter/infocenterReihungstestAbsolviertData.php @@ -5,7 +5,7 @@ $INTERESSENT_STATUS = '\'Interessent\''; $STUDIENGANG_TYP = '\''.$this->variablelib->getVar('infocenter_studiensgangtyp').'\''; $TAETIGKEIT_KURZBZ = '\'bewerbung\', \'kommunikation\''; - $LOGDATA_NAME = '\'Login with code\', \'Login with user\', \'Attempt to register with existing mailadress\''; + $LOGDATA_NAME = '\'Login with code\', \'Login with user\', \'Attempt to register with existing mailadress\', \'Access code sent\', \'Personal data saved\''; $ADDITIONAL_STG = $this->config->item('infocenter_studiengang_kz'); $STUDIENSEMESTER = '\''.$this->variablelib->getVar('infocenter_studiensemester').'\''; $ORG_NAME = '\'InfoCenter\''; diff --git a/application/views/system/infocenter/infocenterZgvUeberpruefungData.php b/application/views/system/infocenter/infocenterZgvUeberpruefungData.php index 6614e6b2a..5bfa5b078 100644 --- a/application/views/system/infocenter/infocenterZgvUeberpruefungData.php +++ b/application/views/system/infocenter/infocenterZgvUeberpruefungData.php @@ -4,11 +4,6 @@ $APP = '\'infocenter\''; $INTERESSENT_STATUS = '\'Interessent\''; $TAETIGKEIT_KURZBZ = '\'bewerbung\', \'kommunikation\''; $LOGDATA_NAME = '\'Login with code\', \'Login with user\', \'New application\''; - -$uid = get_uid(); -$rechte = new benutzerberechtigung(); -$rechte->getBerechtigungen($uid); -$oeKurz = $rechte->getOEkurzbz('lehre/zgvpruefung'); $oeKurz = '\''. implode('\',\'', $oeKurz) . '\''; $query = ' diff --git a/application/views/system/issues/issuesData.php b/application/views/system/issues/issuesData.php index c9a1d3828..ce05ecf8a 100644 --- a/application/views/system/issues/issuesData.php +++ b/application/views/system/issues/issuesData.php @@ -1,7 +1,9 @@ ps_finished.prestudent_id AND tbl_studiensemester.start::date > sem_finished.start::date) @@ -111,7 +148,7 @@ $filterWidgetArray = array( 'datasetName' => 'issues', 'filter_id' => $this->input->get('filter_id'), 'tableUniqueId' => 'issues', - 'requiredPermissions' => 'admin', + 'requiredPermissions' => 'system/issues_verwalten', 'datasetRepresentation' => 'tablesorter', 'checkboxes' => 'issue_id', 'columnsAliases' => array( @@ -132,7 +169,10 @@ $filterWidgetArray = array( ucfirst($this->p->t('fehlermonitoring', 'statuscode')), ucfirst($this->p->t('person', 'vorname')), ucfirst($this->p->t('person', 'nachname')), - ucfirst($this->p->t('fehlermonitoring', 'hauptzustaendig')) + ucfirst($this->p->t('fehlermonitoring', 'zugehoerigkeit')), + ucfirst($this->p->t('fehlermonitoring', 'hauptzustaendig')), + ucfirst($this->p->t('fehlermonitoring', 'zustaendigePersonen')), + ucfirst($this->p->t('fehlermonitoring', 'zustaendigeOrganisationseinheiten')) ), 'formatRow' => function($datasetRaw) { @@ -161,16 +201,26 @@ $filterWidgetArray = array( $datasetRaw->{'OE'} = '-'; } - if ($datasetRaw->{'Verarbeitet am'} == null) - { - $datasetRaw->{'Verarbeitet am'} = '-'; - } - if ($datasetRaw->{'Verarbeitet von'} == null) { $datasetRaw->{'Verarbeitet von'} = '-'; } + if ($datasetRaw->{'Zugehörigkeit'} == null) + { + $datasetRaw->{'Zugehörigkeit'} = '-'; + } + + if ($datasetRaw->{'Person Zuständigkeiten'} == null) + { + $datasetRaw->{'Person Zuständigkeiten'} = '-'; + } + + if ($datasetRaw->{'Organisationseinheit Zuständigkeiten'} == null) + { + $datasetRaw->{'Organisationseinheit Zuständigkeiten'} = '-'; + } + return $datasetRaw; }, 'markRow' => function($datasetRaw) { diff --git a/application/views/system/issues/issuesZustaendigkeiten.php b/application/views/system/issues/issuesZustaendigkeiten.php new file mode 100644 index 000000000..c22eaaee5 --- /dev/null +++ b/application/views/system/issues/issuesZustaendigkeiten.php @@ -0,0 +1,168 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Fehler Zuständigkeiten', + 'jquery' => true, + 'jqueryui' => true, + 'jquerycheckboxes' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'tablesorter' => true, + 'ajaxlib' => true, + 'filterwidget' => true, + 'navigationwidget' => true, + 'dialoglib' => true, + 'phrases' => array( + 'ui', + 'fehlermonitoring' + ), + 'customCSSs' => array('public/css/issues/issuesZustaendigkeiten.css', 'public/css/sbadmin2/tablesort_bootstrap.css'), + 'customJSs' => array('public/js/issues/issuesZustaendigkeiten.js', 'public/js/bootstrapper.js') + ) +); +?> + + +
+ + widgetlib->widget('NavigationWidget'); ?> + +
+
+
+
+ +
+
+
+
+
+ + + + + + +
+ + + + + +
+
+
+
+
+ + + + + + + +
+ + + + + p->t('fehlermonitoring', 'oder') ?> +
+ +
+ + + + + +
+
+
+
+
+
+ +
+
+
+ load->view('system/issues/issuesZustaendigkeitenData.php'); ?> +
+ +
+
+ +
+ + +load->view('templates/FHC-Footer'); ?> diff --git a/application/views/system/issues/issuesZustaendigkeitenData.php b/application/views/system/issues/issuesZustaendigkeitenData.php new file mode 100644 index 000000000..d4cedd192 --- /dev/null +++ b/application/views/system/issues/issuesZustaendigkeitenData.php @@ -0,0 +1,84 @@ + $query, + 'app' => 'core', + 'datasetName' => 'fehlerZustaendigkeiten', + 'filter_id' => $this->input->get('filter_id'), + 'tableUniqueId' => 'issuesZustaendigkeiten', + 'requiredPermissions' => 'admin', + 'datasetRepresentation' => 'tablesorter', + 'additionalColumns' => array('Delete'), + 'columnsAliases' => array( + 'ID', + ucfirst($this->p->t('fehlermonitoring', 'fehlercode')), + ucfirst($this->p->t('fehlermonitoring', 'fehlercodeExtern')), + ucfirst($this->p->t('fehlermonitoring', 'fehlerkurzbz')), + ucfirst($this->p->t('fehlermonitoring', 'fehlertext')), + ucfirst($this->p->t('fehlermonitoring', 'fehlertyp')), + 'app', + 'PersonId', + ucfirst($this->p->t('person', 'vorname')), + ucfirst($this->p->t('person', 'nachname')), + ucfirst($this->p->t('fehlermonitoring', 'oeKurzbz')), + ucfirst($this->p->t('fehlermonitoring', 'oeBezeichnung')), + ucfirst($this->p->t('fehlermonitoring', 'funktionKurzbz')), + ucfirst($this->p->t('fehlermonitoring', 'funktionBeschreibung')) + ), + 'formatRow' => function($datasetRaw) { + + $datasetRaw->{'Delete'} = + ""; + + if ($datasetRaw->{'person_id'} == null) + { + $datasetRaw->{'person_id'} = '-'; + } + + if ($datasetRaw->{'vorname'} == null) + { + $datasetRaw->{'vorname'} = '-'; + } + + if ($datasetRaw->{'nachname'} == null) + { + $datasetRaw->{'nachname'} = '-'; + } + + if ($datasetRaw->{'oe_kurzbz'} == null) + { + $datasetRaw->{'oe_kurzbz'} = '-'; + } + + if ($datasetRaw->{'oe_bezeichnung'} == null) + { + $datasetRaw->{'oe_bezeichnung'} = '-'; + } + + if ($datasetRaw->{'funktion_kurzbz'} == null) + { + $datasetRaw->{'funktion_kurzbz'} = '-'; + } + + if ($datasetRaw->{'funktion_beschreibung'} == null) + { + $datasetRaw->{'funktion_beschreibung'} = '-'; + } + + return $datasetRaw; + } +); + +echo $this->widgetlib->widget('FilterWidget', $filterWidgetArray); diff --git a/cis/infoterminal/index.php b/cis/infoterminal/index.php index a3a7dfb91..82da8ab4e 100644 --- a/cis/infoterminal/index.php +++ b/cis/infoterminal/index.php @@ -22,21 +22,21 @@ */ session_start(); - require_once('../../config/cis.config.inc.php'); - require_once('../../include/wochenplan.class.php'); - require_once('../../include/benutzerberechtigung.class.php'); - require_once('../../include/betriebsmittel.class.php'); - require_once('../../include/betriebsmittelperson.class.php'); - require_once('../../include/betriebsmitteltyp.class.php'); - require_once('../../include/mail.class.php'); - require_once('../../include/news.class.php'); - require_once('../../include/content.class.php'); - require_once('../../include/studiensemester.class.php'); - require_once('../../include/konto.class.php'); - require_once('../../include/functions.inc.php'); - require_once('../../include/authentication.class.php'); - require_once('../../include/addon.class.php'); - require_once('../../include/'.EXT_FKT_PATH.'/serviceterminal.inc.php'); +require_once('../../config/cis.config.inc.php'); +require_once('../../include/wochenplan.class.php'); +require_once('../../include/benutzerberechtigung.class.php'); +require_once('../../include/betriebsmittel.class.php'); +require_once('../../include/betriebsmittelperson.class.php'); +require_once('../../include/betriebsmitteltyp.class.php'); +require_once('../../include/mail.class.php'); +require_once('../../include/news.class.php'); +require_once('../../include/content.class.php'); +require_once('../../include/studiensemester.class.php'); +require_once('../../include/konto.class.php'); +require_once('../../include/functions.inc.php'); +require_once('../../include/authentication.class.php'); +require_once('../../include/addon.class.php'); +require_once('../../include/'.EXT_FKT_PATH.'/serviceterminal.inc.php'); if (!$db = new basis_db()) $db=false; @@ -679,10 +679,6 @@ function meine_uid_informationen($db,$uid,$user="") if ($db) $user_array=personen_id_read_mitarbeiter_oder_student($db,$user->person_id); -#echo '
'; -##var_dump($user_array); -#var_dump($_SESSION[constSESSIONNAME]["ldap_get_entries"]); - if (isset($user_array) && is_array($user_array) && count($user_array)>1) { $html_user_daten.=''; @@ -724,54 +720,6 @@ function meine_uid_informationen($db,$uid,$user="") $html_user_daten.='
'; - // eMail senden nach anforderung - /* - $send_mail=(isset($_REQUEST['send_mail']) ? $_REQUEST['send_mail']:false); - if ($send_mail) - { - $to=$uid.'@'.DOMAIN; - $from=MAIL_CIS; - $subject=CAMPUS_NAME.' Informationen'; - - $mail=new mail($to, $from, $subject, $html_user_daten_detail); - if (isset($user_array) && is_array($user_array) && count($user_array)>1) - { - reset($user_array); - for ($i=0;$iuid && ($user_array[$i]->aktiv='t' || ($user_array[$i]->aktiv !='f' && $user_array[$i]->aktiv)) ) - $mail->setCCRecievers($user_array[$i]->uid.'@'.DOMAIN); - } - } - $mail->setHTMLContent($html_user_daten_detail); - if ($mail->send()) - $html_user_daten.='

email gesendet an '.$mail->to.' '.($mail->CC_recievers?$mail->CC_recievers:'').'

'; - else - $html_user_daten.='

email nicht gesendet an '.$mail->to.'

'; - } - // Send eMail Auswahl anzeigen - else - { - $farbe='gruen'; - $html_user_daten.='
'; - $html_user_daten.=''; - $html_user_daten.=''; - $html_user_daten.=''; - $html_user_daten.='
'; - $html_user_daten.=''; - $html_user_daten.=' - - - '; - $html_user_daten.='Informationen per Mail senden'; - $html_user_daten.=' - - - - '; - $html_user_daten.=''; - $html_user_daten.='
'; - }*/ return $html_user_daten; } #------------------------------------------------------------------------------------------- @@ -952,33 +900,6 @@ function meine_uid_informationen_detail($db,$uid,$count=0) die($db->db_last_error()); $nr_mg=$db->db_num_rows($erg_mg); - // Betriebsmittel zur Person lesen - /* - $betriebsmittelperson=array(); - $qry="SELECT nummer,betriebsmitteltyp FROM public.vw_betriebsmittelperson where uid='".addslashes(trim($uid))."' and aktiv and benutzer_aktiv and ( retouram IS NULL ) LIMIT 50 ; "; - if(!$result=$db->db_query($qry)) - die('Probleme beim Lesen der Benutzer uid '.$db->db_last_error()); - if ($result) - { - while($rows = $db->db_fetch_object($result)) - { - $rows->asco='ASCO Datensätze gefunden'; - if (is_numeric($rows->nummer) && $mssql_verbindung) - { - $card_no=$rows->nummer; - $anfrage = mssql_query('SELECT * FROM view_fh_technikum_mitarbeiterkarten_berechtigungen where card_no='.$card_no); - if (mssql_num_rows($anfrage)) - { - $rows->asco=array(); - while ($datensatz = mssql_fetch_object($anfrage)) - $rows->asco[]=$datensatz; - } - mssql_free_result($anfrage); - } - $betriebsmittelperson[]=$rows; - } - }*/ - if ($count==0) { $html_user_daten.='

Persönliche Daten

'; @@ -1022,49 +943,6 @@ function meine_uid_informationen_detail($db,$uid,$count=0) $html_user_daten.='
Email
Intern'.$email.'
Alias'.$email_alias.'
Mitglied in folgenden Verteilern
'.strtolower($row->gruppe_kurzbz).' '.$row->beschreibung.' 
'.strtolower($stgkz).'_std  Alle Studierdenden von $stgbez
'.strtolower($stgkz).$semester.'  Alle Studierenden von $stgkz $semester
'.strtolower($stgkz).$semester.strtolower($verband).'  Alle Studierenden von $stgkz $semester$verband
'.strtolower($stgkz).$semester.strtolower($verband).$gruppe.'  Alle Studierenden von $stgkz $semester$verband$gruppe
 '; - - $html_user_daten.=''; - if ($stud_num_rows==1) - { - $html_user_daten.=''; - $html_user_daten.="'; - } - else if ($lekt_num_rows==1) - { - $html_user_daten.=''; - $html_user_daten.=''; - }*/ $html_user_daten.='
StudentIn
- Studiengang: $stgbez
- Semester: $semester
- Verband: $verband
- Gruppe: $gruppe
- Matrikelnummer: $matrikelnr"; - $html_user_daten.='
Lektor
Kurzzeichen: '.$kurzbz.'
Standort: '.$ort.'
'.($tel!=''?'Telefon TW: '.$vorwahl.' '.$tel:'').'
'; $html_user_daten.=' '; @@ -1096,30 +974,6 @@ function alle_uid_stundenplan_informationen($db,$uid,$user_array="") return $html_liste_raum; } -// ------------------------------------------------------------------------------------------ -// Kalenderwoche und Tage Initialisieren -// ------------------------------------------------------------------------------------------ -/* - $date = date('d'); - $month = date('m'); - $year = date('y'); - $weekday = date('w'); - $kalenderweek = ((int)date('W')<10?'0'.(int)date('W'):date('W')); - - // Montag ermitteln - if($weekday == 0) - { - $datum=mktime(0, 0, 0, $month, $date-$weekday -6, $year); - $ersterTagMonat=date('m', mktime(0, 0, 0, $month, $date-$weekday -6, $year)); - $ersterTag=date('d', mktime(0, 0, 0, $month, $date-$weekday -6, $year)); - } - else - { - $datum=mktime(0, 0, 0, $month, $date-$weekday +1, $year); - $ersterTagMonat=date('m', mktime(0, 0, 0, $month, $date-$weekday +1, $year)); - $ersterTag=date('d', mktime(0, 0, 0, $month, $date-$weekday +1, $year)); - } -*/ // ------------------------------------------------------------------------------------------ // Alle Termine zum User lesen // ------------------------------------------------------------------------------------------ @@ -1334,18 +1188,19 @@ function alle_raum_informationen($db,$raumtyp_kurzbz,$ort_kurzbz, $standort_id) $qry.=" SELECT DISTINCT "; $qry.=" tbl_ortraumtyp.ort_kurzbz "; $qry.=" ,tbl_ort.bezeichnung ,tbl_ort.aktiv "; + $qry.=" , (SELECT 'gesperrt'::text FROM public.tbl_ortraumtyp WHERE raumtyp_kurzbz='Gesperrt' AND ort_kurzbz=tbl_ort.ort_kurzbz) as gesperrt"; $qry.=" FROM tbl_raumtyp , tbl_ortraumtyp , tbl_ort "; $qry.=" WHERE tbl_ortraumtyp.raumtyp_kurzbz=tbl_raumtyp.raumtyp_kurzbz "; $qry.=" AND tbl_ort.ort_kurzbz=tbl_ortraumtyp.ort_kurzbz "; $qry.=" AND tbl_ort.aktiv "; $qry.=" AND lower(tbl_raumtyp.raumtyp_kurzbz) like lower('%".$db->db_escape(trim($raumtyp_kurzbz))."%') "; if($standort_id!='') - $qry.=" AND (tbl_ort.standort_id=".$db->db_add_param($standort_id, FHC_INTEGER).' OR tbl_ort.standort_id is null)'; + $qry.=" AND (tbl_ort.standort_id=".$db->db_add_param($standort_id, FHC_INTEGER)." OR tbl_ort.standort_id is null)"; $qry.=" order by tbl_ortraumtyp.ort_kurzbz "; $qry.=" ; "; if(!$result=$db->db_query($qry)) - die('Probleme beim lesen der Raumtyptabelle '.$db->db_last_error()); + die('Probleme beim lesen der Raumtyptabelle '); $num_rows_stunde=$db->db_num_rows($result); if($num_rows_stunde==0) @@ -1372,7 +1227,6 @@ function alle_raum_informationen($db,$raumtyp_kurzbz,$ort_kurzbz, $standort_id) // Raumreservierungen fuer Aktive Raumauswahl // -------------------------------------------------------------- - // Die aktive Stunde ermitteln - zum lesen welcher Raum jetzt besetzt ist - aktive Lehreinheit $row_stunde=array(); @@ -1382,9 +1236,6 @@ function alle_raum_informationen($db,$raumtyp_kurzbz,$ort_kurzbz, $standort_id) $qry.=" WHERE ".$db->db_add_param(constAktuelleZeitHHMi,FHC_STRING)." between to_char(tbl_stunde.beginn, 'HH24MI') and to_char(tbl_stunde.ende, 'HH24MI') "; $qry.=" ORDER BY stunde LIMIT 1 ; "; -# $qry.=" WHERE '". constAktuelleZeitHH."' between to_char(tbl_stunde.beginn, 'HH24') and to_char(tbl_stunde.ende, 'HH24') "; -# $qry.=" ORDER BY stunde desc LIMIT 1; "; - if(!$result=$db->db_query($qry)) die('Probleme beim lesen der Raumtyptabelle '.$db->db_last_error()); @@ -1436,8 +1287,8 @@ function alle_raum_informationen($db,$raumtyp_kurzbz,$ort_kurzbz, $standort_id) $farbe="gruen"; } -# if ($farbe=="orange") -# var_dump($info); + if ($row_raum[$i]->gesperrt=="gesperrt") + $farbe="rot"; // Nach 4 Raumanzeigen eine Neuezeile erzeugen $html_liste_raum.=($i==0 || $i%4?"":""); @@ -1461,7 +1312,7 @@ function alle_raum_informationen($db,$raumtyp_kurzbz,$ort_kurzbz, $standort_id) $html_liste_raum.='
   Mindestens nächsten 2 Einheiten frei
'; $html_liste_raum.='
   Derzeit frei
'; - $html_liste_raum.='
   Raum derzeit besetzt
'; + $html_liste_raum.='
   Raum derzeit besetzt / gesperrt
'; $html_liste_raum.=''; $html_liste_raum.=''; $html_liste_raum.='
'; @@ -1506,7 +1357,6 @@ function alle_raum_informationen($db,$raumtyp_kurzbz,$ort_kurzbz, $standort_id) // dh. Letztes Ende ist gleich Start aktueller Datensatz if ($lastEnde && $row->time_beginn!=$lastEnde) { -# echo "

Zeit korr. Funktion:alle_raum_informationen ".$row->beginn_show." wird zu ".$lastShowEnde."

"; $row->time_beginn=$lastEnde; } @@ -1900,7 +1750,7 @@ function uid_read_mitarbeiter_oder_student($db,$uid) // Wenn kein Mitarbeiter pruefen ob Student $qry="SELECT uid,person_id,anrede,titelpre,vorname,vornamen,nachname,aktiv FROM campus.vw_student where uid=".$db->db_add_param(trim($uid), FHC_STRING)." LIMIT 1 ; "; if(!$result=$db->db_query($qry)) - die('Probleme beim Lesen der Studierenden '.$db->db_last_error()); + die('Probleme beim Lesen der Studierenden '); if ($num_rows_stunde=$db->db_num_rows($result)) { while($rows = $db->db_fetch_object($result)) @@ -1976,7 +1826,7 @@ function read_create_html_news($db,$fachbereich_kurzbz,$studiengang_kz,$semester { if(defined('CIS_INFOSCREEN_NEWS_ANZEIGEN') && CIS_INFOSCREEN_NEWS_ANZEIGEN==false) return ''; - + // ------------------------------------------------------------------------------------------ // Lesen Newstickerzeilen // ------------------------------------------------------------------------------------------ diff --git a/cis/infoterminal/informationsbildschirm.php b/cis/infoterminal/informationsbildschirm.php index caf174846..75cabdc62 100644 --- a/cis/infoterminal/informationsbildschirm.php +++ b/cis/infoterminal/informationsbildschirm.php @@ -169,21 +169,22 @@ echo ' echo ''; if($infoscreen_id!='' && isset($content[$aktuellerContentIdx])) { - echo '
'; } else { - echo '


-
-

Informationsbildschirm - '.CAMPUS_NAME.'

-


- Dieser Informationsbildschirm wurde noch nicht registriert -

- IP-Adresse:'.$ip.' -
'; + echo ' + + + + + + +
+ +
'.$ip.'
+'; } - echo ' '; diff --git a/cis/private/info/ersthelfer.php b/cis/private/info/ersthelfer.php index 6441f5439..12805c5b9 100644 --- a/cis/private/info/ersthelfer.php +++ b/cis/private/info/ersthelfer.php @@ -48,11 +48,11 @@ if(check_lektor($user)) - - - - - + + + + + +
- +
- -
-

Zustimmung zur Verplanung in geteilter Arbeitszeit

+

Zustimmung zur Verplanung in geteilter Arbeitszeit

t('zeitwunsch/geteilteArbeitszeit'); + echo '

'; $gd = new zeitaufzeichnung_gd(); - $gd->load($uid, $current_ss); + $gd->load($uid, $akt_ss->studiensemester_kurzbz); if ( ! $gd->uid ) { - echo '

Zustimmung für '.$current_ss.': '; - echo 'ja'; - echo 'nein'; - echo '




'; + echo '
'; + echo '
'; + echo '
'; + echo 'Zustimmung für '.$akt_ss->studiensemester_kurzbz.': '; + echo ''; + echo ''; + echo '
'; + echo '
'; + + echo '
'; + echo '
'; + echo '
'; + + echo '
'; + echo '
'; + echo '
'; } else { $zustimmung = ($gd->selbstverwaltete_pause) ? ' erteilt' : 'abgelehnt'; - echo '

Zustimmung für '.$current_ss.': '.$zustimmung.' am '.$datum_obj->formatDatum($gd->insertamum,'d.m.Y H:i:s').'

'; + echo '

Zustimmung für '.$akt_ss->studiensemester_kurzbz.': '.$zustimmung.' am '.$datum_obj->formatDatum($gd->insertamum,'d.m.Y H:i:s').''; } $gd = new zeitaufzeichnung_gd(); - $gd->load($uid, $next_ss); + $gd->load($uid, $next_ss->studiensemester_kurzbz); if ( ! $gd->uid ) { - echo '

Zustimmung für '.$next_ss.': '; - echo 'ja'; - echo 'nein'; - echo '




'; + echo '
'; + echo '
'; + echo '
'; + echo 'Zustimmung für '.$next_ss->studiensemester_kurzbz.': '; + echo ''; + echo ''; + echo '
'; + echo '
'; + + echo '
'; + echo ''; + echo '
'; + + echo '
'; + echo '
'; + echo '
'; } else { $zustimmung = ($gd->selbstverwaltete_pause) ? ' erteilt' : 'abgelehnt'; - echo '

Zustimmung für '.$next_ss.': '.$zustimmung.' am '.$datum_obj->formatDatum($gd->insertamum,'d.m.Y H:i:s').'

'; + echo '
Zustimmung für '.$next_ss->studiensemester_kurzbz.': '.$zustimmung.' am '.$datum_obj->formatDatum($gd->insertamum,'d.m.Y H:i:s').''; } - //var_dump($gd); ?>

-

-

t('zeitwunsch/zeitwunsch');?>

- ".$p->t('zeitwunsch/zeitwunschVon')." $person->titelpre $person->vorname $person->nachname $person->titelpost
"; - echo $p->t('zeitwunsch/tragenSieInDiesesNormwochenraster')."

"; - echo '
- - '; - echo ''; - for ($i=0;$i<$num_rows_stunde; $i++) - { - $beginn=$db->db_result($result_stunde,$i,'"beginn"'); - $beginn=substr($beginn,0,5); - $ende=$db->db_result($result_stunde,$i,'"ende"'); - $ende=substr($ende,0,5); - $stunde=$db->db_result($result_stunde,$i,'"stunde"'); - echo ""; - } + // FORM Begin + echo ''; + echo ''; + echo ''; - echo ''; + // Mein Zeitwunsch-Semesterplan Dropdown, Default = naechstes Studiensemester + $next_ss_selected = $next_ss->studiensemester_kurzbz == $selected_ss ? 'selected' : ''; + $akt_ss_selected = $akt_ss->studiensemester_kurzbz == $selected_ss ? 'selected' : ''; - for ($j=1; $j<7; $j++) - { - echo ''; - for ($i=0;$i<$num_rows_stunde;$i++) - { - if (isset($wunsch[$j][$i+1])) - $index=$wunsch[$j][$i+1]; - else - $index=1; - //$id='bgcolor'; - //$id.=$index+3; - $bgcolor=$cfgStdBgcolor[$index+3]; - echo ''; - } - echo ''; - } + echo '

'. $p->t('zeitwunsch/gueltigIm'); + echo ''; + echo '


'; - echo ' -
'.$p->t('global/stunde').'
'.$p->t('global/beginn').'
'.$p->t('global/ende').'
$stunde
$beginn
$ende
'.$tagbez[$lang->index][$j].'

- - - '; + // Tabelle Zeitwunsch-Semesterplan + echo ''; + // Tabelle Kopfzeile + echo ''; + echo ''; + for ($i=0;$i<$num_rows_stunde; $i++) + { + $beginn=$db->db_result($result_stunde,$i,'"beginn"'); + $beginn=substr($beginn,0,5); + $ende=$db->db_result($result_stunde,$i,'"ende"'); + $ende=substr($ende,0,5); + $stunde=$db->db_result($result_stunde,$i,'"stunde"'); + echo ""; + } + echo ''; + // Tabelle Zellen + for ($j=1; $j<7; $j++) + { + echo ''; + for ($i=0;$i<$num_rows_stunde;$i++) + { + if (isset($wunsch[$j][$i+1])) + $index=$wunsch[$j][$i+1]; + else + $index=1; // Defaultwert, wenn kein Zeitwunsch vorhanden - if($zw->updateamum!='') - { - echo ''.$p->t('zeitwunsch/letzteAenderung').': '.$datum_obj->formatDatum($zw->updateamum,'d.m.Y H:i:s').' '.$p->t('zeitwunsch/von').' '.$zw->updatevon.''; - } - ?> + $bgcolor=$cfgStdBgcolor[$index+3]; + echo ''; + } + echo ''; + } + echo '
'.$p->t('global/stunde').'
'.$p->t('global/beginn').'
'.$p->t('global/ende').'
$stunde
$beginn
$ende
'.$tagbez[$lang->index][$j].'
'; -
+ // Zeitwunsch aendern / kopieren + echo '
'; + echo '
'; + echo ''. $p->t('zeitwunsch/erklaerungstext'). '
'; + echo '
'; + echo '
'; // end col-xs-12 + echo '
'; // end row -
+ echo '
'; -

t('zeitwunsch/erklärung');?>:

+ echo '
'; + // Radiobuttons aendern / kopieren + $radioChangeChecked = is_null($selected_past_ss) ? 'checked' : ''; + $radioCopyChecked = !is_null($selected_past_ss) ? 'checked' : ''; - "; - echo $p->t('zeitwunsch/formularZumEintragenDerZeitsperren', array($href)); - ?> - -

t('zeitwunsch/kontrollierenSieIhreZeitwuensche');?>!

-

- - - - - - - - - - - - - - - - - - - - - - -
t('zeitwunsch/wert');?> -
t('zeitwunsch/bedeutung');?>
-
-
2
-
  t('zeitwunsch/hierMoechteIchUnterrichten');?>
-
1
-
  t('zeitwunsch/hierKannIchUnterrichten');?>
-
-1
-
  t('zeitwunsch/nurInNotfaellen');?>
-
-2
-
  t('zeitwunsch/hierAufGarKeinenFall');?>
-

t('zeitwunsch/folgendePunkteSindZuBeachten');?>:

-
    -
  1. t('zeitwunsch/verwendenSieDenWertNur');?>
  2. -
  3. t('zeitwunsch/sperrenSieNurTermine');?>
  4. -
  5. t('zeitwunsch/esSolltenFuerJedeStunde');?>
  6. -
-

t('lvplan/fehlerUndFeedback');?> t('lvplan/lvKoordinationsstelle');?>.

-
-
+ echo '
'; + echo ''.$p->t('zeitwunsch/fuer', array($selected_ss)). ''; + echo ''; + echo ''; + if ($isGesperrt) + { + echo ''.$p->t('zeitwunsch/stundenBereitsVerplant', array($selected_ss)). ''; + } + echo '
'; + echo '
'; // end col-xs-9 + + echo ''; // end col-xs-3 + + $divChangeHidden = !is_null($selected_past_ss) || $isGesperrt ? 'hidden' : ''; + $divCopyHidden = is_null($selected_past_ss) || $isGesperrt ? 'hidden' : ''; + $divisGesperrtHidden = $isGesperrt ? '' : 'hidden'; + + echo '
'; + echo '
'; + echo '' . $p->t('zeitwunsch/tragenSieInDiesesNormwochenraster') .''; + echo '
'; // end col + echo '
'; + // BLANK + echo '
'; // end col + echo '
'; // end divChangeZWG + + echo '
'; + echo '
'; + echo '' . $p->t('zeitwunsch/kopierenText') .''; + echo '
'; // end col + + $studiensemester = new Studiensemester(); + $tmp_ss = $selected_ss == $akt_ss->studiensemester_kurzbz ? $studiensemester->getPrevious() : $akt_ss->studiensemester_kurzbz; + $studiensemester->load($tmp_ss); + + $zwg = new Zeitwunsch_gueltigkeit(); + $zwg->getByUID($uid, 4, true, $studiensemester->ende); + $past_zwg_arr = $zwg->result; + echo '
'; + echo ''; + echo '
'; // end col + echo '
'; // end divCopyZWG + + echo '
'; + + // Mail Adressen der Studiengaenge, wo Lektor ueber eine LV bereits verplant ist + $stgKzOfVerplant_arr = getStgOfVerplant($uid, $selected_ss); + $stgMail_arr = getStgMail($stgKzOfVerplant_arr); + + echo '
'; + echo '
'; + echo '
'; + echo ''. $p->t("zeitwunsch/bearbeitungDeaktiviert"). ': '; + echo $p->t("zeitwunsch/bearbeitungDeaktiviertText", array($selected_ss, implode($stgMail_arr, '; '))). ' + '. $p->t("zeitwunsch/bearbeitungAktivieren"). '
+ '. $p->t("zeitwunsch/kompetenzfeldWirdInformiert") . ' + '; + echo '
'; // end panel heading + echo '
'; // end panel + echo '
'; // end col + echo '
'; // end divisGesperrt + + // Speichern - Button + echo '
'; + echo ''; + echo '
'; + + echo '
'; // end row + echo '
'; + ?> + + + +
+
+ t('zeitwunsch/folgendePunkteSindZuBeachten');?>: +
    +
  • t('zeitwunsch/verwendenSieDenWertNur');?>
  • +
  • t('zeitwunsch/sperrenSieNurTermine');?>
  • +
  • t('zeitwunsch/esSolltenFuerJedeStunde');?>
  • +

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
t('zeitwunsch/wert');?> +
t('zeitwunsch/bedeutung');?>
+
+
2
+
  t('zeitwunsch/hierMoechteIchUnterrichten');?>
+
1
+
  t('zeitwunsch/hierKannIchUnterrichten');?>
+
-1
+
  t('zeitwunsch/nurInNotfaellen');?>
+
-2
+
  t('zeitwunsch/hierAufGarKeinenFall');?>
+
+
+ + +
+
+

t('zeitsperre/zeitsperren');?>:

+ "; + echo $p->t('zeitwunsch/formularZumEintragenDerZeitsperren', array($href)); + ?> +
+
+ + + + +
diff --git a/cis/private/tools/suche.php b/cis/private/tools/suche.php index b4574a95f..15d75c546 100644 --- a/cis/private/tools/suche.php +++ b/cis/private/tools/suche.php @@ -275,7 +275,7 @@ function searchOE($searchItems) $oe->result[] = new organisationseinheit($row->oe_kurzbz); } - if(count($oe->result)>0) + if(is_array($oe->result) && count($oe->result)>0) { echo '

',$p->t('global/organisationseinheiten'),'

'; echo ' diff --git a/cis/testtool/frage.php b/cis/testtool/frage.php index 12d9d8d26..69dc9496c 100644 --- a/cis/testtool/frage.php +++ b/cis/testtool/frage.php @@ -37,6 +37,7 @@ require_once('../../include/gebiet.class.php'); require_once('../../include/sprache.class.php'); require_once '../../include/phrasen.class.php'; require_once '../../include/reihungstest.class.php'; +require_once '../../include/pruefling.class.php'; if (!$db = new basis_db()) die('Fehler beim Oeffnen der Datenbankverbindung'); @@ -157,6 +158,12 @@ echo ' if(!isset($_SESSION['pruefling_id'])) die($p->t('testtool/bitteZuerstAnmelden')); +$pruefling = new pruefling(); +$pruefling->load($_SESSION['pruefling_id']); + +if ($pruefling->gesperrt === 't') + die(""); + $gebiet = new gebiet($gebiet_id); if($gebiet->level_start!='') diff --git a/cis/testtool/prueflinggesperrt.php b/cis/testtool/prueflinggesperrt.php new file mode 100644 index 000000000..f0ab2b1ad --- /dev/null +++ b/cis/testtool/prueflinggesperrt.php @@ -0,0 +1,39 @@ + + + + + + + + + + +




+

t('testtool/prueflingGesperrt');?>

+
+ + diff --git a/cms/content_uebersicht.php b/cms/content_uebersicht.php index 2752efecc..ad02e5167 100644 --- a/cms/content_uebersicht.php +++ b/cms/content_uebersicht.php @@ -175,7 +175,7 @@ SELECT SELECT 'Verlinkung von '||content_id AS art FROM campus.tbl_contentsprache - WHERE content::text LIKE '%content.php?content_id='||content.content_id||'%' + WHERE content::text LIKE '%content.php?content_id='||content.content_id /*WHERE content::text ~* '[\w\d\s]*content\.php\?content_id=1245[\w\d\s]*'*/ ) verwendung ) AS verwendung_in, diff --git a/composer.json b/composer.json index 14e2ab141..6a23a8526 100644 --- a/composer.json +++ b/composer.json @@ -246,6 +246,8 @@ "afarkas/html5shiv": "3.7.*", + "chillerlan/php-qrcode": "2.0.*", + "chriskacerguis/codeigniter-restserver": "3.0.3", "christianbach/tablesorter": "1.0.*", "codeigniter/framework": "3.*", diff --git a/composer.lock b/composer.lock index ea8f24af0..7d9d977d0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "7e7441d3ba7b9b2be1f647b9bfc2c941", - "content-hash": "d59d1c1f4957fc2e3dc019cbb99b5aa2", + "hash": "6bab4617977e08b2939bf959929632d4", + "content-hash": "3e499134721f682f298dda20263ab686", "packages": [ { "name": "BlackrockDigital/startbootstrap-sb-admin-2", @@ -71,6 +71,105 @@ }, "type": "library" }, + { + "name": "chillerlan/php-qrcode", + "version": "2.0.8", + "source": { + "type": "git", + "url": "https://github.com/chillerlan/php-qrcode.git", + "reference": "bf0382aaf2f79fa41c2dcb0f216675f74d633fe7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/chillerlan/php-qrcode/zipball/bf0382aaf2f79fa41c2dcb0f216675f74d633fe7", + "reference": "bf0382aaf2f79fa41c2dcb0f216675f74d633fe7", + "shasum": "" + }, + "require": { + "chillerlan/php-traits": "^1.1", + "php": ">=7.0.3" + }, + "require-dev": { + "chillerlan/php-authenticator": "^2.0", + "phpunit/phpunit": "^6.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "chillerlan\\QRCode\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kazuhiko Arase", + "homepage": "https://github.com/kazuhikoarase" + }, + { + "name": "Smiley", + "email": "smiley@chillerlan.net", + "homepage": "https://github.com/codemasher" + } + ], + "description": "A QR code generator. PHP 7+", + "homepage": "https://github.com/chillerlan/php-qrcode", + "keywords": [ + "qr code" + ], + "time": "2020-04-12 07:38:35" + }, + { + "name": "chillerlan/php-traits", + "version": "1.1.13", + "source": { + "type": "git", + "url": "https://github.com/chillerlan/php-traits.git", + "reference": "264759946b6aaeb427346b749fc9639b790b8e7f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/chillerlan/php-traits/zipball/264759946b6aaeb427346b749fc9639b790b8e7f", + "reference": "264759946b6aaeb427346b749fc9639b790b8e7f", + "shasum": "" + }, + "require": { + "php": ">=7.0.3" + }, + "require-dev": { + "phpunit/phpunit": "^6.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "chillerlan\\Traits\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Smiley", + "email": "smiley@chillerlan.net", + "homepage": "https://github.com/codemasher" + } + ], + "description": "Some useful traits for PHP 7+", + "homepage": "https://github.com/chillerlan/php-traits", + "keywords": [ + "PHP7", + "container", + "dotenv", + "helper", + "trait" + ], + "abandoned": true, + "time": "2018-06-22 00:30:47" + }, { "name": "chriskacerguis/codeigniter-restserver", "version": "3.0.3", @@ -1248,26 +1347,26 @@ }, { "name": "netcarver/textile", - "version": "v3.7.6", + "version": "v3.7.7", "source": { "type": "git", "url": "https://github.com/textile/php-textile.git", - "reference": "1846fd5aeace2a0dd57c4f770f693d12bcd7fa26" + "reference": "e5c32b4485741e656cfd94932da8ba7dd4a19da5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/textile/php-textile/zipball/1846fd5aeace2a0dd57c4f770f693d12bcd7fa26", - "reference": "1846fd5aeace2a0dd57c4f770f693d12bcd7fa26", + "url": "https://api.github.com/repos/textile/php-textile/zipball/e5c32b4485741e656cfd94932da8ba7dd4a19da5", + "reference": "e5c32b4485741e656cfd94932da8ba7dd4a19da5", "shasum": "" }, "require": { "php": ">=5.3.0" }, "require-dev": { - "php-coveralls/php-coveralls": "2.1.*", - "phpunit/phpunit": "5.7.*", + "phpstan/phpstan": "1.6.3", + "phpunit/phpunit": "^9.5.20", "squizlabs/php_codesniffer": "3.*", - "symfony/yaml": "2.4.*" + "symfony/yaml": "^4.4.3" }, "type": "library", "extra": { @@ -1297,7 +1396,7 @@ "plaintext", "textile" ], - "time": "2020-01-08 21:13:37" + "time": "2022-05-01 17:05:16" }, { "name": "nicolaskruchten/pivottable", diff --git a/config/vilesci.config-default.inc.php b/config/vilesci.config-default.inc.php index fd03cf844..5285eef3b 100644 --- a/config/vilesci.config-default.inc.php +++ b/config/vilesci.config-default.inc.php @@ -249,8 +249,8 @@ define('BIS_FUNKTIONSCODE_6_ARR', array( 'Team' )); -// Standortcode fuer Lehrgaenge -define('BIS_STANDORTCODE_LEHRGAENGE', '0'); +// Standortcode fuer Lehrgaenge - Obsolete da Standort nun aus DB geholt wird +//define('BIS_STANDORTCODE_LEHRGAENGE', '0'); // bPk Abfrage define('BPK_FUER_ALLE_BENUTZER_ABFRAGEN', false); diff --git a/content/dragboard.js.php b/content/dragboard.js.php index 2a96e0cda..6510cfc47 100644 --- a/content/dragboard.js.php +++ b/content/dragboard.js.php @@ -172,7 +172,7 @@ var LeLvbgrpDDObserver= if(lehreinheit_id=='') { - alert('Eine Gruppe kann nur zu einer Lehreinheit hinzugefügt werden. Nicht aber zu einer Lehrveranstaltung'); + alert('Eine Gruppe kann nur zu einem LV-Teil hinzugefügt werden, nicht aber zu einer Lehrveranstaltung'); return false; } diff --git a/content/fas.xul.php b/content/fas.xul.php index 19b24b0f0..449f917b7 100644 --- a/content/fas.xul.php +++ b/content/fas.xul.php @@ -26,6 +26,7 @@ require_once('../include/benutzerberechtigung.class.php'); require_once('../include/studiensemester.class.php'); require_once('../include/variable.class.php'); require_once('../include/addon.class.php'); +require_once('../include/datum.class.php'); $user=get_uid(); @@ -45,6 +46,8 @@ if(!$variable->loadVariables($user)) $rechte = new benutzerberechtigung(); $rechte->getBerechtigungen($user); +$datum_obj = new datum(); + if(!$rechte->isBerechtigt('basis/fas')) die('Sie haben keine Berechtigung für diese Seite'); @@ -239,7 +242,7 @@ foreach($addon_obj->result as $addon) getAll(); + $stsemobj->getAll('desc'); foreach ($stsemobj->studiensemester as $stsem) { echo " @@ -248,6 +251,7 @@ foreach($addon_obj->result as $addon) label = '$stsem->studiensemester_kurzbz' type = 'radio' command = 'menu-properties-studiensemester:command' + tooltiptext = '(".$datum_obj->formatDatum($stsem->start, "d.m.Y")." - ".$datum_obj->formatDatum($stsem->ende, "d.m.Y").")' checked = ".($variable->variable->semester_aktuell==$stsem->studiensemester_kurzbz?"'true' ":"'false'")." />"; } ?> @@ -934,6 +938,9 @@ foreach($addon_obj->result as $addon) oncommand="studiensemesterChange('', 1)" /> + + + diff --git a/content/fasDBDML.php b/content/fasDBDML.php index 1c5a7a4c4..899f0096c 100644 --- a/content/fasDBDML.php +++ b/content/fasDBDML.php @@ -493,6 +493,14 @@ if(!$error) $variable->name = 'semester_aktuell'; $variable->wert = $studiensemester_kurzbz; } + elseif(isset($_POST['stsem_aktuell'])) + { + $stsem = new studiensemester(); + $studiensemester_kurzbz = $stsem->getNearest(); + + $variable->name = 'semester_aktuell'; + $variable->wert = $studiensemester_kurzbz; + } elseif(isset($_POST['kontofilterstg'])) { $variable->name = 'kontofilterstg'; diff --git a/content/lvplanung/lehrveranstaltungDBDML.php b/content/lvplanung/lehrveranstaltungDBDML.php index 438844071..9827dec4f 100644 --- a/content/lvplanung/lehrveranstaltungDBDML.php +++ b/content/lvplanung/lehrveranstaltungDBDML.php @@ -216,14 +216,14 @@ if(!$error) { $error = true; $return = false; - $errormsg = 'Lehreinheit wurde nicht gefunden'; + $errormsg = 'LV-Teil wurde nicht gefunden'; } } else { $error = true; $return = false; - $errormsg = 'Lehreinheit wurde nicht gefunden'; + $errormsg = 'LV-Teil wurde nicht gefunden'; } if(!$error) @@ -507,14 +507,14 @@ if(!$error) { $error = true; $return = false; - $errormsg = 'Lehreinheit wurde nicht gefunden'; + $errormsg = 'LV-Teil wurde nicht gefunden'; } } else { $error = true; $return = false; - $errormsg = 'Lehreinheit wurde nicht gefunden'; + $errormsg = 'LV-Teil wurde nicht gefunden'; } if(!$error) @@ -731,14 +731,14 @@ if(!$error) { $error = true; $return = false; - $errormsg = 'Lehreinheit wurde nicht gefunden'; + $errormsg = 'LV-Teil wurde nicht gefunden'; } } else { $error = true; $return = false; - $errormsg = 'Lehreinheit wurde nicht gefunden'; + $errormsg = 'LV-Teil wurde nicht gefunden'; } if(!$error) @@ -838,14 +838,14 @@ if(!$error) { $error = true; $return = false; - $errormsg = 'Lehreinheit wurde nicht gefunden'; + $errormsg = 'LV-Teil wurde nicht gefunden'; } } else { $error = true; $return = false; - $errormsg = 'Lehreinheit wurde nicht gefunden'; + $errormsg = 'LV-Teil wurde nicht gefunden'; } if(!$error) @@ -954,14 +954,14 @@ if(!$error) { $error = true; $return = false; - $errormsg = 'Lehreinheit wurde nicht gefunden'; + $errormsg = 'LV-Teil wurde nicht gefunden'; } } else { $error = true; $return = false; - $errormsg = 'Lehreinheit wurde nicht gefunden'; + $errormsg = 'LV-Teil wurde nicht gefunden'; } // Wenn nur noch dieser Lektor im LVPlan verplant ist, dann wird das loeschen verhindert @@ -1055,14 +1055,14 @@ if(!$error) { $error = true; $return = false; - $errormsg = 'Lehreinheit wurde nicht gefunden'; + $errormsg = 'LV-Teil wurde nicht gefunden'; } } else { $error = true; $return = false; - $errormsg = 'Lehreinheit wurde nicht gefunden'; + $errormsg = 'LV-Teil wurde nicht gefunden'; } // Wenn nur noch diese eine Gruppe im LVPlan verplant ist, dann wird das loeschen verhindert @@ -1180,14 +1180,14 @@ if(!$error) { $error = true; $return = false; - $errormsg = 'Lehreinheit wurde nicht gefunden'; + $errormsg = 'LV-Teil wurde nicht gefunden'; } } else { $error = true; $return = false; - $errormsg = 'Lehreinheit wurde nicht gefunden'; + $errormsg = 'LV-Teil wurde nicht gefunden'; } if(!$error) @@ -1234,7 +1234,7 @@ if(!$error) else { $return = false; - $errormsg = 'Bitte zuerst eine Lehreinheit auswaehlen'; + $errormsg = 'Bitte zuerst einen LV-Teil auswaehlen'; } } } @@ -1265,19 +1265,19 @@ if(!$error) { $error = true; $return = false; - $errormsg = 'Lehreinheit wurde nicht gefunden'; + $errormsg = 'LV-Teil wurde nicht gefunden'; } } else { $error = true; $return = false; - $errormsg = 'Lehreinheit wurde nicht gefunden'; + $errormsg = 'LV-Teil wurde nicht gefunden'; } if(!$error) { - $leDAO=new lehreinheit(); + $leDAO = new lehreinheit(); if ($_POST['do']=='create' || ($_POST['do']=='update')) { if($_POST['do']=='update') @@ -1286,7 +1286,7 @@ if(!$error) { $return = false; $error = true; - $errormsg = 'Fehler beim Laden der Lehreinheit'; + $errormsg = 'Fehler beim Laden des LV-Teils'; } if(!$rechte->isBerechtigtMultipleOe('admin', $lva->getAllOe(), 'suid') && @@ -1388,6 +1388,118 @@ if(!$error) } } } + else if ($_POST['do']=='copy') + { + if(!$rechte->isBerechtigtMultipleOe('admin', $lva->getAllOe(), 'sui') + && !$rechte->isBerechtigtMultipleOe('assistenz', $lva->getAllOe(), 'sui') + && !$rechte->isBerechtigtMultipleOe('lv-plan', $lva->getAllOe(), 'sui')) + { + $error = true; + $return = false; + $errormsg = 'Keine Berechtigung'; + } + + if(!$leDAO->load($_POST['lehreinheit_id'])) + { + $return = false; + $error = true; + $errormsg = 'Fehler beim Laden des LV-Teils'; + } + + if(!$error) + { + // Neue Lehreinheit anlegen + $leDAO->new = true; + $leDAO->unr = ''; + $leDAO->updateamum = date('Y-m-d H:i:s'); + $leDAO->updatevon = $user; + $leDAO->insertamum = date('Y-m-d H:i:s'); + $leDAO->insertvon = $user; + + if ($leDAO->save()) + { + // Wenn Art "alle" oder "gruppen" ist, werden auch alle Lehreinheitgruppe kopiert + if(isset($_POST['art']) && ($_POST['art'] == 'alle' || $_POST['art'] == 'gruppen')) + { + $legruppe = new lehreinheitgruppe(); + $legruppe->getLehreinheitgruppe($_POST['lehreinheit_id']); + + if (count($legruppe->lehreinheitgruppe) > 0) + { + foreach ($legruppe->lehreinheitgruppe as $row) + { + $legruppe_new = new lehreinheitgruppe(); + $legruppe_new->lehreinheit_id = $leDAO->lehreinheit_id; + $legruppe_new->studiengang_kz = $row->studiengang_kz; + $legruppe_new->semester = $row->semester; + $legruppe_new->verband = $row->verband; + $legruppe_new->gruppe = $row->gruppe; + $legruppe_new->gruppe_kurzbz = $row->gruppe_kurzbz; + $legruppe_new->updateamum = date('Y-m-d H:i:s'); + $legruppe_new->updatevon = $user; + $legruppe_new->insertamum = date('Y-m-d H:i:s'); + $legruppe_new->insertvon = $user; + + if (!$legruppe_new->save(true)) + { + $errormsg = 'Fehler beim Kopieren der Gruppe: '.$legruppe_new->errormsg; + $return = false; + } + else + { + $return = true; + } + } + } + } + // Wenn Art "alle" oder "lektoren" ist, werden auch alle Lehreinheitmitarbeiter kopiert + if(isset($_POST['art']) && ($_POST['art'] == 'alle' || $_POST['art'] == 'lektoren')) + { + $lema = new lehreinheitmitarbeiter(); + $lema->getLehreinheitmitarbeiter($_POST['lehreinheit_id']); + + if (count($lema->lehreinheitmitarbeiter) > 0) + { + foreach ($lema->lehreinheitmitarbeiter as $row) + { + $lema_new = new lehreinheitmitarbeiter(); + $lema_new->lehreinheit_id = $leDAO->lehreinheit_id; + $lema_new->mitarbeiter_uid = $row->mitarbeiter_uid; + $lema_new->lehrfunktion_kurzbz = $row->lehrfunktion_kurzbz; + $lema_new->semesterstunden = $row->semesterstunden; + $lema_new->planstunden = $row->planstunden; + $lema_new->stundensatz = $row->stundensatz; + $lema_new->faktor = $row->faktor; + $lema_new->anmerkung = $row->anmerkung; + $lema_new->bismelden = $row->bismelden; + $lema_new->updateamum = date('Y-m-d H:i:s'); + $lema_new->updatevon = $user; + $lema_new->insertamum = date('Y-m-d H:i:s'); + $lema_new->insertvon = $user; + $lema_new->ext_id = $row->ext_id; + $lema_new->vertrag_id = ''; + + if (!$lema_new->save(true)) + { + $errormsg = 'Fehler beim Kopieren der MitarbeiterInnen: '.$lema_new->errormsg; + $return = false; + } + else + { + $return = true; + } + } + } + } + $return = true; + } + else + { + $return = false; + $errormsg = $leDAO->errormsg; + } + } + } else if ($_POST['do']=='delete') //Lehreinheit loeschen { if(!$rechte->isBerechtigtMultipleOe('admin', $lva->getAllOe(), 'suid') && @@ -1409,7 +1521,7 @@ if(!$error) if($db->db_num_rows()>0) { $return = false; - $errormsg = 'Diese Lehreinheit ist bereits im LV-Plan verplant und kann daher nicht geloescht werden!'; + $errormsg = 'Dieser LV-Teil ist bereits im LV-Plan verplant und kann daher nicht geloescht werden!'; } else { @@ -1420,7 +1532,7 @@ if(!$error) else { $return = false; - $errormsg = 'Fehler beim Loeschen der Lehreinheit '.$leDAO->errormsg; + $errormsg = 'Fehler beim Loeschen des LV-Teils '.$leDAO->errormsg; } } } @@ -1795,13 +1907,13 @@ if(!$error) } else { - $errormsg = 'Gruppe passt nicht zur Lehreinheit'; + $errormsg = 'Gruppe passt nicht zum LV-Teil'; $return = false; } } else { - $errormsg = 'Gruppe passt nicht zur Lehreinheit'; + $errormsg = 'Gruppe passt nicht zum LV-Teil'; $return = false; } } diff --git a/content/lvplanung/lehrveranstaltungoverlay.js.php b/content/lvplanung/lehrveranstaltungoverlay.js.php index dfb1bf4ec..436c48eb8 100644 --- a/content/lvplanung/lehrveranstaltungoverlay.js.php +++ b/content/lvplanung/lehrveranstaltungoverlay.js.php @@ -521,7 +521,7 @@ function LeDelete() } //Abfrage ob wirklich geloescht werden soll - if (confirm('Wollen Sie diese Lehreinheit wirklich loeschen?')) + if (confirm('Wollen Sie diesen LV-Teil wirklich loeschen?')) { //Script zum loeschen der Lehreinheit aufrufen var req = new phpRequest('lvplanung/lehrveranstaltungDBDML.php','',''); @@ -541,6 +541,52 @@ function LeDelete() } } +// **** +// * LV-Teile kopieren +// **** +function LeCopy(art) +{ + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var tree = document.getElementById('lehrveranstaltung-tree'); + + if (tree.currentIndex==-1) + return; + + try + { + //Ausgewaehlte LV-Teile holen + var col = tree.columns ? tree.columns["lehrveranstaltung-treecol-lehreinheit_id"] : "lehrveranstaltung-treecol-lehreinheit_id"; + var lehreinheit_id = tree.view.getCellText(tree.currentIndex,col); + if(lehreinheit_id == '') + { + alert('Lehreinheit_id konnte nicht ermittelt werden'); + return false; + } + } + catch(e) + { + alert(e); + return false; + } + + //Script zum kopieren des LV-Teils aufrufen + var req = new phpRequest('lvplanung/lehrveranstaltungDBDML.php','',''); + + req.add('type','lehreinheit'); + req.add('do','copy'); + req.add('art',art); + req.add('lehreinheit_id',lehreinheit_id); + var response = req.executePOST(); + + var val = new ParseReturnValue(response) + if(!val.dbdml_return) + alert(val.dbdml_errormsg) + + LvTreeRefresh(); + LeDetailReset(); + LeDetailDisableFields(true); +} + // **** // * Leert alle Eingabe- und Auswahlfelder // **** @@ -2673,7 +2719,7 @@ function LeMitarbeiterGesamtkosten() /* * Oeffnet alle Subtrees */ -function LvTreeOpenAllSubtrees() +function LvTreeOpenAllSubtrees(art) { var tree=document.getElementById('lehrveranstaltung-tree'); @@ -2682,10 +2728,21 @@ function LvTreeOpenAllSubtrees() else return false; - for(var i=items-1;i>=0;i--) + if (art == 'aus') { - if(!tree.view.isContainerOpen(i)) - tree.view.toggleOpenState(i); + for(var i=items-1;i>=0;i--) + { + if(!tree.view.isContainerOpen(i)) + tree.view.toggleOpenState(i); + } + } + else if (art == 'ein') + { + for(var i=items-1;i>=0;i--) + { + if(tree.view.isContainerOpen(i)) + tree.view.toggleOpenState(i); + } } } diff --git a/content/lvplanung/lehrveranstaltungoverlay.xul.php b/content/lvplanung/lehrveranstaltungoverlay.xul.php index f2cc27b2d..4fde1fcc3 100644 --- a/content/lvplanung/lehrveranstaltungoverlay.xul.php +++ b/content/lvplanung/lehrveranstaltungoverlay.xul.php @@ -54,13 +54,21 @@ echo ' + + + + - - + +