diff --git a/application/config/anrechnung.php b/application/config/anrechnung.php
new file mode 100644
index 000000000..d1f4f0958
--- /dev/null
+++ b/application/config/anrechnung.php
@@ -0,0 +1,22 @@
+ true,
'sort' => 10,
'requiredPermissions' => 'basis/vilesci:r'
+ ),
+ 'oehbeitragsverwaltung' => array(
+ 'link' => site_url('codex/Oehbeitrag'),
+ 'icon' => '',
+ 'description' => 'Öhbeitragsverwaltung',
+ 'expand' => true,
+ 'sort' => 20,
+ 'requiredPermissions' => 'admin:w'
)
)
),
@@ -125,6 +133,13 @@ $config['navigation_header'] = array(
'expand' => true,
'sort' => 20,
'requiredPermissions' => 'system/developer:r'
+ ),
+ 'errormonitoring' => array(
+ 'link' => site_url('system/issues/Issues'),
+ 'description' => 'Fehler Monitoring',
+ 'expand' => true,
+ 'sort' => 20,
+ 'requiredPermissions' => 'system/issues_verwalten:r'
)
)
)
diff --git a/application/config/udfmasterschema.json b/application/config/udfmasterschema.json
index fa06dc80d..ab3faa8c9 100644
--- a/application/config/udfmasterschema.json
+++ b/application/config/udfmasterschema.json
@@ -9,6 +9,13 @@
"name": {
"type": "string"
},
+ "type": {
+ "type": "string",
+ "enum": ["checkbox", "textfield", "textarea", "date", "dropdown", "multipledropdown"]
+ },
+ "requiredPermissions": {
+ "type": "array"
+ },
"description": {
"type": "array",
},
@@ -18,10 +25,6 @@
"title": {
"type": "array",
},
- "type": {
- "type": "string",
- "enum": ["checkbox", "textfield", "textarea", "date", "dropdown", "multipledropdown"]
- },
"sort": {
"type": "integer"
},
@@ -67,5 +70,6 @@
}
}
},
- "required": ["type", "name"]
-}
\ No newline at end of file
+ "required": ["type", "name", "requiredPermissions"]
+}
+
diff --git a/application/controllers/codex/Oehbeitrag.php b/application/controllers/codex/Oehbeitrag.php
new file mode 100644
index 000000000..fa27d1ebb
--- /dev/null
+++ b/application/controllers/codex/Oehbeitrag.php
@@ -0,0 +1,261 @@
+ 'admin:r',// TODO which Berechtigung?
+ 'getOehbeitraege' => 'admin:r',
+ 'getValidStudiensemester' => 'admin:r',
+ 'addOehbeitrag' => 'admin:rw',
+ 'updateOehbeitrag' => 'admin:rw',
+ 'deleteOehbeitrag' => 'admin:rw'
+ )
+ );
+
+ $this->load->model('codex/Oehbeitrag_model', 'OehbeitragModel');
+ $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
+
+ $this->load->library('WidgetLib');
+ }
+
+ public function index()
+ {
+ $oehbeitraege = array();
+
+ $oehbeitragRes = $this->_loadOehbeitraege();
+
+ if (isError($oehbeitragRes))
+ show_error(getError($oehbeitragRes));
+
+ if (hasData($oehbeitragRes))
+ $oehbeitraege = getData($oehbeitragRes);
+
+ $this->load->view("codex/oehbeitrag.php", array('oehbeitraege' => $oehbeitraege));
+ }
+
+ /**
+ * Gets all valid, i.e. unassigned, Studiensemester.
+ */
+ public function getValidStudiensemester()
+ {
+ $oehbeitrag_id = $this->input->get('oehbeitrag_id');
+ $oehbeitrag_id_arr = isset($oehbeitrag_id) ? array($oehbeitrag_id) : null;
+
+ $studiensemester = array();
+
+ $studiensemesterres = $this->OehbeitragModel->getUnassignedStudiensemester(self::STUDIENSEMESTER_START, $oehbeitrag_id_arr);
+ if (isError($studiensemesterres))
+ {
+ $this->outputJsonError(getError($studiensemesterres));
+ return;
+ }
+
+ if (hasData($studiensemesterres))
+ $studiensemester = getData($studiensemesterres);
+
+ $this->outputJsonSuccess($studiensemester);
+ }
+
+ /**
+ * Gets all Öhbeiträge. Wrapper function for output as JSON.
+ */
+ public function getOehbeitraege()
+ {
+ $this->outputJson($this->_loadOehbeitraege());
+ }
+
+ /**
+ * Adds an Öhbeitrag. Checks for errors beforehand.
+ */
+ public function addOehbeitrag()
+ {
+ $studierendenbeitrag = $this->input->post('studierendenbeitrag');
+ $versicherung = $this->input->post('versicherung');
+ $von_studiensemester_kurzbz = $this->input->post('von_studiensemester_kurzbz');
+ $bis_studiensemester_kurzbz = $this->input->post('bis_studiensemester_kurzbz');
+ if ($bis_studiensemester_kurzbz == 'null')
+ $bis_studiensemester_kurzbz = null;
+
+ if (!$this->_checkAmount($studierendenbeitrag))
+ $this->outputJsonError('Ungültiger Studierendenbeitrag');
+ elseif (!$this->_checkAmount($versicherung))
+ $this->outputJsonError('Ungültige Versicherung');
+ else
+ {
+ $vonBisCheck = $this->_checkVonBisStudiensemester($von_studiensemester_kurzbz, $bis_studiensemester_kurzbz);
+
+ if (isError($vonBisCheck))
+ $this->outputJsonError(getError($vonBisCheck));
+ else
+ {
+ $data = array(
+ 'studierendenbeitrag' => $studierendenbeitrag,
+ 'versicherung' => $versicherung,
+ 'von_studiensemester_kurzbz' => $von_studiensemester_kurzbz,
+ 'bis_studiensemester_kurzbz' => $bis_studiensemester_kurzbz
+ );
+
+ $this->outputJson($this->OehbeitragModel->insert($data));
+ }
+ }
+ }
+
+ /**
+ * Updates an Öhbeitrag. Checks for errors beforehand.
+ */
+ public function updateOehbeitrag()
+ {
+ $oehbeitrag_id = $this->input->post("oehbeitrag_id");
+ $data = $this->input->post("data");
+
+ if (!is_numeric($oehbeitrag_id) || isEmptyArray($data))
+ {
+ $this->outputJsonError("Ungültige Parameter");
+ return;
+ }
+
+ foreach ($data as $idx => $value)
+ {
+ if ($idx == 'studierendenbeitrag' || $idx == 'versicherung')
+ {
+ if (!$this->_checkAmount($value))
+ {
+ $this->outputJsonError("Ungültige(r) $idx");
+ return;
+ }
+ }
+ elseif ($idx == 'von_studiensemester_kurzbz' || $idx == 'bis_studiensemester_kurzbz')
+ {
+ $this->OehbeitragModel->addSelect('von_studiensemester_kurzbz, bis_studiensemester_kurzbz');
+ $vonBisStudiensemesterRes = $this->OehbeitragModel->load($oehbeitrag_id);
+
+ if (!hasData($vonBisStudiensemesterRes))
+ {
+ $this->outputJsonError("Fehler beim Holen des Öhbeitrags");
+ return;
+ }
+
+ $vonBisStudiensemester = getData($vonBisStudiensemesterRes);
+
+ $von_studiensemester_kurzbz = isset($data['von_studiensemester_kurzbz'])
+ ? $data['von_studiensemester_kurzbz']
+ : $vonBisStudiensemester[0]->von_studiensemester_kurzbz;
+
+ if (isset($data['bis_studiensemester_kurzbz']))
+ {
+ $bis_studiensemester_kurzbz = $data['bis_studiensemester_kurzbz'] = $data['bis_studiensemester_kurzbz'] == 'null' ? null : $data['bis_studiensemester_kurzbz'];
+ }
+ else
+ $bis_studiensemester_kurzbz = $vonBisStudiensemester[0]->bis_studiensemester_kurzbz;
+
+ $checkStudiensemester = $this->_checkVonBisStudiensemester($von_studiensemester_kurzbz, $bis_studiensemester_kurzbz, $oehbeitrag_id);
+
+ if (isError($checkStudiensemester))
+ {
+ $this->outputJsonError(getError($checkStudiensemester));
+ return;
+ }
+ }
+ }
+
+ $this->outputJson($this->OehbeitragModel->update($oehbeitrag_id, $data));
+ }
+
+ /**
+ * Deletes an Öhbeitrag.
+ */
+ public function deleteOehbeitrag()
+ {
+ $oehbeitrag_id = $this->input->post("oehbeitrag_id");
+
+ $this->outputJson($this->OehbeitragModel->delete($oehbeitrag_id));
+ }
+
+ /**
+ * Loads all Öhbeiträge sorted by date descending.
+ * @return object
+ */
+ private function _loadOehbeitraege()
+ {
+ $this->OehbeitragModel->addSelect('oehbeitrag_id, von_studiensemester_kurzbz, bis_studiensemester_kurzbz, studierendenbeitrag, versicherung, sem_von.start as von_datum, sem_bis.ende as bis_datum');
+ $this->OehbeitragModel->addJoin('public.tbl_studiensemester sem_von', 'tbl_oehbeitrag.von_studiensemester_kurzbz = sem_von.studiensemester_kurzbz');
+ $this->OehbeitragModel->addJoin('public.tbl_studiensemester sem_bis', 'tbl_oehbeitrag.bis_studiensemester_kurzbz = sem_bis.studiensemester_kurzbz', 'LEFT');
+ $this->OehbeitragModel->addOrder('sem_von.start', 'DESC');
+ return $this->OehbeitragModel->load();
+ }
+
+ /**
+ * Checks if an amount is numeric and not too big.
+ * @param $amount
+ * @return bool true if valid amount, false otherwise
+ */
+ private function _checkAmount($amount)
+ {
+ return is_numeric($amount) && (float) $amount <= 99999.99;
+ }
+
+ /**
+ * Checks if a certain Von-Studiensemester is valid together with a Bis-Studiensemester.
+ * Checks for correct format, Von-Studiensemester cannot be after the Bis-Studiensemester,
+ * checks that semester are not overlapping with semester for existent Öhbeiträge.
+ * @param string $von_studiensemester_kurzbz
+ * @param string $bis_studiensemester_kurzbz
+ * @param int $oehbeitrag_id öhbeitrag to ignore, i.e. which is assignable (id of Öhbeitrag of the passed semesters)
+ * @return object array with true if assignable, with false if not
+ */
+ private function _checkVonBisStudiensemester($von_studiensemester_kurzbz, $bis_studiensemester_kurzbz, $oehbeitrag_id = null)
+ {
+ $regex = "/^(WS|SS)\d{4}$/";
+ if (!preg_match($regex, $von_studiensemester_kurzbz))
+ return error("Ungültiges Von-Studiensemester");
+
+ if (!preg_match($regex, $bis_studiensemester_kurzbz) && $bis_studiensemester_kurzbz != null)
+ return error("Ungültiges Bis-Studiensemester");
+
+ $this->StudiensemesterModel->addSelect("start");
+ $vonStudiensemesterRes = $this->StudiensemesterModel->load($von_studiensemester_kurzbz);
+
+ if (!hasData($vonStudiensemesterRes))
+ return error("Fehler beim Holen von Von-Studiensemester");
+
+ $this->StudiensemesterModel->addSelect("start");
+ $bisStudiensemesterRes = $this->StudiensemesterModel->load($bis_studiensemester_kurzbz);
+
+ if (!hasData($bisStudiensemesterRes))
+ return error("Fehler beim Holen von Bis-Studiensemester");
+
+ $vonStudiensemester = getData($vonStudiensemesterRes)[0]->start;
+ $bisStudiensemester = getData($bisStudiensemesterRes)[0]->start;
+
+ if ($bis_studiensemester_kurzbz != null && new DateTime($vonStudiensemester) > new DateTime($bisStudiensemester))
+ return error("Von-Studiensemester größer als Bis-Studiensemester");
+
+ $oehbeitrag_id_arr = isset($oehbeitrag_id) ? array($oehbeitrag_id) : null;
+
+ $assignableRes = $this->OehbeitragModel->checkIfStudiensemesterAssignable(
+ $von_studiensemester_kurzbz,
+ $bis_studiensemester_kurzbz,
+ $oehbeitrag_id_arr
+ );
+
+ if (isError($assignableRes))
+ return $assignableRes;
+
+ if (hasData($assignableRes))
+ {
+ $assignable = getData($assignableRes)[0];
+
+ if (!$assignable)
+ return error("Keine Zuweisung möglich, Semesterüberschneidung");
+ }
+
+ return success("Studiensemester gültig");
+ }
+}
diff --git a/application/controllers/crm/Statusgrund.php b/application/controllers/crm/Statusgrund.php
index 344ac06dc..3c7e43736 100644
--- a/application/controllers/crm/Statusgrund.php
+++ b/application/controllers/crm/Statusgrund.php
@@ -129,6 +129,7 @@ class Statusgrund extends Auth_Controller
$aktiv = $this->input->post("aktiv") != null && $this->input->post("aktiv") == "on" ? true : false;
$bezeichnung_mehrsprachig = $this->input->post("bezeichnung_mehrsprachig");
$beschreibung = $this->input->post("beschreibung");
+ $statusgrund_kurzbz = $this->input->post("statusgrund_kurzbz");
for ($i = 0; $i < count($bezeichnung_mehrsprachig); $i++)
{
@@ -177,7 +178,8 @@ class Statusgrund extends Auth_Controller
$data = array(
"aktiv" => $aktiv,
"bezeichnung_mehrsprachig" => $bezeichnung_mehrsprachig,
- "beschreibung" => $beschreibung
+ "beschreibung" => $beschreibung,
+ "statusgrund_kurzbz" => $statusgrund_kurzbz
);
$statusgrund = $this->StatusgrundModel->update($statusgrund_id, $data);
@@ -196,6 +198,7 @@ class Statusgrund extends Auth_Controller
$bezeichnung_mehrsprachig = $this->input->post("bezeichnung_mehrsprachig");
$beschreibung = $this->input->post("beschreibung");
$status_kurzbz = $this->input->post("status_kurzbz");
+ $statusgrund_kurzbz = $this->input->post("statusgrund_kurzbz");
for ($i = 0; $i < count($bezeichnung_mehrsprachig); $i++)
{
@@ -245,7 +248,8 @@ class Statusgrund extends Auth_Controller
"status_kurzbz" => $status_kurzbz,
"aktiv" => $aktiv,
"bezeichnung_mehrsprachig" => $bezeichnung_mehrsprachig,
- "beschreibung" => $beschreibung
+ "beschreibung" => $beschreibung,
+ "statusgrund_kurzbz" => $statusgrund_kurzbz
);
$statusgrund = $this->StatusgrundModel->insert($data);
diff --git a/application/controllers/jobs/AnrechnungJob.php b/application/controllers/jobs/AnrechnungJob.php
index 2868a8052..f92410dbc 100644
--- a/application/controllers/jobs/AnrechnungJob.php
+++ b/application/controllers/jobs/AnrechnungJob.php
@@ -15,6 +15,11 @@ if (!defined('BASEPATH')) exit('No direct script access allowed');
class AnrechnungJob extends JOB_Controller
{
+ const APPROVE_ANRECHNUNG_URI = '/lehre/anrechnung/ApproveAnrechnungUebersicht';
+
+ const ANRECHNUNGSTATUS_APPROVED = 'approved';
+ const ANRECHNUNGSTATUS_REJECTED = 'rejected';
+ const ANRECHNUNG_NOTIZTITEL_NOTIZ_BY_STGL = 'AnrechnungNotizSTGL';
/**
* Constructor
@@ -23,6 +28,11 @@ class AnrechnungJob extends JOB_Controller
{
parent::__construct();
$this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel');
+ $this->load->model('education/Anrechnung_model', 'AnrechnungModel');
+ $this->load->model('organisation/Studiengang_model', 'StudiengangModel');
+
+ $this->load->helper('url');
+ $this->load->helper('hlp_sancho_helper');
}
/**
@@ -84,4 +94,320 @@ class AnrechnungJob extends JOB_Controller
}
$this->logInfo('End Anrechnung Grades Job', array('Number of Grades added'=>$cnt));
}
+
+ /**
+ * Deletes Zeugnisnoten 'angerechnet', when Anrechnung is rejected afterwards.
+ * E.g., when STGL first accepts, then withdraws and finally rejects the approvement.
+ */
+ public function deleteAnrechnungGrades()
+ {
+ $this->logInfo('Start AnrechnungJob to delete Grades');
+
+ // Get all Zeungisnoten,
+ // WHERE note is angerechnet
+ // AND Anrechnung was rejected AFTER the Zeugnisnote was created
+ $qry = '
+ SELECT DISTINCT ON (status.anrechnung_id) anrechnung_id,
+ status.status_kurzbz AS "last_anrechnungstatus",
+ status.insertamum AS "last_anrechnungstatus_insertamum",
+ zeugnisnote.insertamum AS "zeugnisdatum_insertamum",
+ student.student_uid,
+ zeugnisnote.lehrveranstaltung_id,
+ zeugnisnote.studiensemester_kurzbz,
+ note
+ FROM lehre.tbl_zeugnisnote zeugnisnote
+ JOIN public.tbl_student student USING (student_uid)
+ JOIN lehre.tbl_anrechnung anrechnung
+ ON (zeugnisnote.lehrveranstaltung_id = anrechnung.lehrveranstaltung_id)
+ AND (student.prestudent_id = anrechnung.prestudent_id)
+ AND (zeugnisnote.studiensemester_kurzbz = anrechnung.studiensemester_kurzbz)
+ JOIN lehre.tbl_anrechnung_anrechnungstatus status USING (anrechnung_id)
+ WHERE note = 6
+ AND status.insertamum > zeugnisnote.insertamum
+ AND status.status_kurzbz = '. $this->db->escape(self::ANRECHNUNGSTATUS_REJECTED). '
+ ORDER BY status.anrechnung_id, status.insertamum DESC
+ ';
+
+ $db = new DB_Model();
+ $result = $db->execReadOnlyQuery($qry);
+ $cnt = 0;
+
+ if (hasData($result))
+ {
+ $this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel');
+
+ foreach (getData($result) as $row)
+ {
+ // Delete Zeugnisnote
+ $this->ZeugnisnoteModel->delete(array(
+ 'lehrveranstaltung_id' => $row->lehrveranstaltung_id,
+ 'student_uid' => $row->student_uid,
+ 'studiensemester_kurzbz' => $row->studiensemester_kurzbz
+ ));
+
+ // Count up
+ $cnt++;
+ }
+ }
+
+ $this->logInfo('End AnrechnungJob to delete Grades', array('Number of Grades deleted: ' => $cnt));
+ }
+
+ // Send Sancho mail to STGL with yesterdays new Anrechnungen
+ public function sendMailToSTGL()
+ {
+ $this->logInfo('Start AnrechnungJob to send emails to STGL about yesterdays new Anrechnungen.');
+
+ // Get all yesterdays Anrechnungen, that did not process further than first status
+ // (If Anrechnung is new, but STGL already started the process yesterday,
+ // he does not need to be informed about this new Anrechnung anymore)
+ $this->AnrechnungModel->addSelect('anrechnung_id, studiensemester_kurzbz, lv.studiengang_kz, lv.bezeichnung, vorname, nachname');
+ $this->AnrechnungModel->addJoin('lehre.tbl_lehrveranstaltung lv', 'lehrveranstaltung_id');
+ $this->AnrechnungModel->addJoin('public.tbl_student student', 'prestudent_id');
+ $this->AnrechnungModel->addJoin('public.tbl_benutzer benutzer', 'ON (benutzer.uid = student.student_uid)');
+ $this->AnrechnungModel->addJoin('public.tbl_person person', 'person_id');
+ $this->AnrechnungModel->addOrder('lv.studiengang_kz, lv.bezeichnung');
+
+ $result = $this->AnrechnungModel->loadWhere(
+ '(lehre.tbl_anrechnung.insertamum)::date = (NOW() - INTERVAL \'24 HOURS\')::DATE
+ AND 1 = (SELECT COUNT(*) FROM lehre.tbl_anrechnung_anrechnungstatus status WHERE status.anrechnung_id = tbl_anrechnung.anrechnung_id)'
+ );
+
+ // Exit if there are no Anrechnungen
+ if (!$anrechnungen = getData($result)) {
+ $this->logInfo('ABORTED: Sending emails to STGL about yesterdays new Anrechnungen aborted - No new Anrechnungen found.');
+ exit;
+ }
+
+ $unique_studiengang_kz_arr = array_unique(array_column($anrechnungen, 'studiengang_kz'));
+
+ foreach ($unique_studiengang_kz_arr as $studiengang_kz)
+ {
+ // Get STG bezeichnung
+ $this->StudiengangModel->addSelect('UPPER( typ || kurzbz ) AS "stg_bezeichnung"');
+ $studiengang_bezeichnung = $this->StudiengangModel->load($studiengang_kz)->retval[0]->stg_bezeichnung;
+
+ // Get STGL mail address
+ list ($to, $vorname) = self::_getSTGLMailAddress($studiengang_kz);
+
+ // Get HTML table with new Anrechnungen of that STG plus amount of them
+ list ($anrechnungen_amount, $anrechnungen_table) = self::_getSTGLMailDataTable($studiengang_kz, $anrechnungen);
+
+ // Link to Antrag genehmigen dashboard
+ $url =
+ CIS_ROOT. 'cis/index.php?menu='.
+ CIS_ROOT. 'cis/menu.php?content_id=&content='.
+ CIS_ROOT. index_page(). self::APPROVE_ANRECHNUNG_URI;
+
+ // Prepare mail content
+ $body_fields = array(
+ 'vorname' => $vorname,
+ 'studiengang' => $studiengang_bezeichnung,
+ 'anzahl' => $anrechnungen_amount,
+ 'datentabelle' => $anrechnungen_table,
+ 'link' => anchor($url, 'Anrechnungsanträge Übersicht')
+ );
+
+ // Send mail
+ sendSanchoMail(
+ 'AnrechnungAntragStellen',
+ $body_fields,
+ $to,
+ 'Anerkennung nachgewiesener Kenntnisse: Neuer Antrag wurde gestellt'
+ );
+ }
+
+ $this->logInfo('SUCCEDED: Sending emails to STGL about yesterdays new Anrechnungen succeded.');
+ }
+
+ /**
+ * Send Sancho mail to students, whose Anrechnungen were approved 24 hours ago.
+ */
+ public function sendMailApproved(){
+
+ $this->logInfo('Start AnrechnungJob to send emails to students, whose Anrechnungen were approved.');
+
+ // Get all yesterdays approvements
+ $this->AnrechnungModel->addSelect('student.student_uid, vorname, nachname, geschlecht, lv.bezeichnung');
+ $this->AnrechnungModel->addJoin('lehre.tbl_anrechnung_anrechnungstatus status', 'anrechnung_id');
+ $this->AnrechnungModel->addJoin('lehre.tbl_lehrveranstaltung lv', 'lehrveranstaltung_id');
+ $this->AnrechnungModel->addJoin('public.tbl_student student', 'prestudent_id');
+ $this->AnrechnungModel->addJoin('public.tbl_benutzer benutzer', 'ON (benutzer.uid = student.student_uid)');
+ $this->AnrechnungModel->addJoin('public.tbl_person person', 'person_id');
+
+ $result = $this->AnrechnungModel->loadWhere(
+ '(status.insertamum)::date = (NOW() - INTERVAL \'24 HOURS\')::DATE AND
+ status.status_kurzbz = '. $this->db->escape(self::ANRECHNUNGSTATUS_APPROVED)
+ );
+
+ // Exit if there are no approved Anrechnungen
+ if (!hasData($result))
+ {
+ $this->logInfo('ABORTED sending emails to students, whose Anrechnungen were approved. No new approvements found.');
+ exit;
+ }
+
+ // Loop through students
+ foreach ($result->retval as $student)
+ {
+ $to = $student->student_uid. '@'. DOMAIN;
+
+ $anrede = $student->geschlecht == 'w' ? 'Sehr geehrte Frau ' : 'Sehr geehrter Herr ';
+
+ $text = 'Ihrem Antrag auf Anerkennung nachgewiesener Kenntnisse der Lehrveranstaltung "'.
+ $student->bezeichnung. '" wurde stattgegeben.';
+
+ // Prepare mail content
+ $body_fields = array(
+ 'anrede_name' => $anrede. $student->vorname. ' '. $student->nachname,
+ 'text' => $text
+ );
+
+ // Send mail
+ sendSanchoMail(
+ 'AnrechnungGenehmigen',
+ $body_fields,
+ $to,
+ 'Anerkennung nachgewiesener Kenntnisse: Ihr Antrag ist abgeschlossen'
+ );
+ }
+ }
+
+ /**
+ * Send Sancho mail to students, whose Anrechnungen were rejected 24 hours ago.
+ */
+ public function sendMailRejected(){
+
+ $this->logInfo('Start AnrechnungJob to send emails to students, whose Anrechnungen were rejected.');
+
+ $qry = '
+ SELECT
+ student.student_uid, vorname, nachname, geschlecht, lv.bezeichnung,
+ (SELECT text FROM public.tbl_notizzuordnung JOIN public.tbl_notiz USING(notiz_id)
+ WHERE tbl_notizzuordnung.anrechnung_id=tbl_anrechnung.anrechnung_id
+ AND tbl_notiz.titel='. $this->db->escape(self::ANRECHNUNG_NOTIZTITEL_NOTIZ_BY_STGL).'
+ ORDER BY tbl_notiz.insertamum DESC LIMIT 1) as text
+ FROM lehre.tbl_anrechnung
+ JOIN lehre.tbl_lehrveranstaltung lv USING(lehrveranstaltung_id)
+ JOIN public.tbl_student student USING(prestudent_id)
+ JOIN public.tbl_benutzer benutzer ON (benutzer.uid = student.student_uid)
+ JOIN public.tbl_person person USING(person_id)
+
+ WHERE EXISTS(SELECT 1 FROM lehre.tbl_anrechnung_anrechnungstatus status WHERE
+ anrechnung_id=tbl_anrechnung.anrechnung_id AND
+ (status.insertamum)::date = (NOW() - INTERVAL \'24 HOURS\')::DATE AND
+ status_kurzbz = '. $this->db->escape(self::ANRECHNUNGSTATUS_REJECTED). ')
+ ';
+
+ $db = new DB_Model();
+ $result = $db->execReadOnlyQuery($qry);
+
+ // Exit if there are no rejected Anrechnungen
+ if (!hasData($result))
+ {
+ $this->logInfo('ABORTED sending emails to students, whose Anrechnungen were rejected. No new rejectments found.');
+ exit;
+ }
+
+ // Loop through students
+ foreach ($result->retval as $student)
+ {
+ $to = $student->student_uid. '@'. DOMAIN;
+
+ $anrede = $student->geschlecht == 'w' ? 'Sehr geehrte Frau ' : 'Sehr geehrter Herr ';
+
+ $text = <<bezeichnung" leider nicht anrechnen, weil die Gleichwertigkeit nicht festgestellt werden konnte.
+ Begründung: $student->text
+html;
+
+ // Prepare mail content
+ $body_fields = array(
+ 'anrede_name' => $anrede. $student->vorname. ' '. $student->nachname,
+ 'text' => $text
+ );
+
+ // Send mail
+ sendSanchoMail(
+ 'AnrechnungGenehmigen',
+ $body_fields,
+ $to,
+ 'Anerkennung nachgewiesener Kenntnisse: Ihr Antrag ist abgeschlossen'
+ );
+ }
+
+ }
+
+ // Get STGL mail address
+ private function _getSTGLMailAddress($studiengang_kz)
+ {
+ $result = $this->StudiengangModel->getLeitung($studiengang_kz);
+
+ // Get STGL mail address
+ if (hasData($result))
+ {
+ return array(
+ $result->retval[0]->uid. '@'. DOMAIN,
+ $result->retval[0]->vorname
+ );
+ }
+ // If not available, get assistance mail address
+ else
+ {
+ $result = $this->StudiengangModel->load($studiengang_kz);
+
+ if (hasData($result))
+ {
+ return array(
+ $result->retval[0]->email,
+ ''
+ );
+ }
+ }
+ }
+
+ // Build HTML table with yesterdays new Anrechnungen of the given STG
+ private function _getSTGLMailDataTable($studiengang_kz, $anrechnungen)
+ {
+ $html = '';
+ $lv_bezeichnung = '';
+
+ // Filter Anrechnungen of given STG
+ $anrechnungen = array_filter(
+ $anrechnungen,
+ function ($anrechnung) use (&$studiengang_kz) {
+ return $anrechnung->studiengang_kz == $studiengang_kz;
+ });
+
+ // Amount of Anrechnungen
+ $amount = count($anrechnungen);
+
+ // HTML table body
+ $html .= '
+
+
+ ';
+
+ foreach ($anrechnungen as $anrechnung)
+ {
+ // Head line for each LV bezeichnung
+ if ($anrechnung->bezeichnung != $lv_bezeichnung)
+ {
+ $html .= '' . $anrechnung->bezeichnung . ' ';
+ }
+
+ $lv_bezeichnung = $anrechnung->bezeichnung;
+
+ // Row for each Anrechnung / student
+ $html .= ''. $anrechnung->vorname. ' '. $anrechnung->nachname. ' ';
+ }
+
+ $html .= '
+
+
+ ';
+
+ return array($amount, $html);
+ }
}
diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php
index c5e4b94d8..8982b9970 100644
--- a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php
+++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php
@@ -1,6 +1,6 @@
'lehre/anrechnung_genehmigen:rw',
'approve' => 'lehre/anrechnung_genehmigen:rw',
'reject' => 'lehre/anrechnung_genehmigen:rw',
- 'requestRecommendation' => 'lehre/anrechnung_genehmigen:rw'
+ 'requestRecommendation' => 'lehre/anrechnung_genehmigen:rw',
+ 'withdraw' => 'lehre/anrechnung_genehmigen:rw',
+ 'withdrawRequestRecommendation' => 'lehre/anrechnung_genehmigen:rw',
+ 'saveEmpfehlungsNotiz' => 'lehre/anrechnung_genehmigen:rw'
)
);
@@ -80,29 +84,23 @@ class approveAnrechnungDetail extends Auth_Controller
self::_checkIfEntitledToReadAnrechnung($anrechnung_id);
// Get Anrechung data
- if (!$anrechnungData = getData($this->anrechnunglib->getAnrechnungData($anrechnung_id)))
- {
- show_error('Missing data for Anrechnung.');
- }
+ $anrechnungData = $this->anrechnunglib->getAnrechnungData($anrechnung_id);
+
+ // Get Antrag data
+ $antragData = $this->anrechnunglib->getAntragData(
+ $anrechnungData->prestudent_id,
+ $anrechnungData->studiensemester_kurzbz,
+ $anrechnungData->lehrveranstaltung_id
+ );
// Get Empfehlung data
- if(!$empfehlungData = getData($this->anrechnunglib->getEmpfehlungData($anrechnung_id)))
- {
- show_error('Missing data for recommendation');
- }
+ $empfehlungData = $this->anrechnunglib->getEmpfehlungData($anrechnung_id);
// Get Genehmigung data
- if(!$genehmigungData = getData($this->anrechnunglib->getGenehmigungData($anrechnung_id)))
- {
- show_error('Missing data for recommendation');
- }
+ $genehmigungData = $this->anrechnunglib->getGenehmigungData($anrechnung_id);
$viewData = array(
- 'antragData' => $this->anrechnunglib->getAntragData(
- $student_uid = $this->StudentModel->getUID($anrechnungData->prestudent_id),
- $anrechnungData->studiensemester_kurzbz,
- $anrechnungData->lehrveranstaltung_id
- ),
+ 'antragData' => $antragData,
'anrechnungData' => $anrechnungData,
'empfehlungData' => $empfehlungData,
'genehmigungData' => $genehmigungData
@@ -118,40 +116,30 @@ class approveAnrechnungDetail extends Auth_Controller
{
$data = $this->input->post('data');
- if(isEmptyArray($data))
+ // Validate data
+ if (isEmptyArray($data))
{
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
}
- // Get statusbezeichnung for 'approved'
- $this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
- $approved = getData($this->AnrechnungstatusModel->load('approved'))[0];
- $approved = getUserLanguage() == 'German'
- ? $approved->bezeichnung_mehrsprachig[0]
- : $approved->bezeichnung_mehrsprachig[1];
-
+ // Get STGLs person data
if (!$person = getData($this->PersonModel->getByUID($this->_uid))[0])
{
show_error('Failed retrieving person data');
}
+ // Approve Anrechnung
foreach ($data as $item)
{
- // Approve Anrechnung
- if(getData($this->anrechnunglib->approveAnrechnung($item['anrechnung_id'])))
+ if ($this->anrechnunglib->approveAnrechnung($item['anrechnung_id']))
{
$json[]= array(
'anrechnung_id' => $item['anrechnung_id'],
'status_kurzbz' => self::ANRECHNUNGSTATUS_APPROVED,
- 'status_bezeichnung' => $approved,
- 'abgeschlossen_am' => (new DateTime())->format('d.m.Y'),
- 'abgeschlossen_von' => $person->vorname. ' '. $person->nachname
+ 'status_bezeichnung' => $this->anrechnunglib->getStatusbezeichnung(self::ANRECHNUNGSTATUS_APPROVED),
+ 'abgeschlossen_am' => (new DateTime())->format('d.m.Y'),
+ 'abgeschlossen_von' => $person->vorname. ' '. $person->nachname
);
-
- if(!$this->_sendSanchoMailToStudent($item['anrechnung_id'], self::ANRECHNUNGSTATUS_APPROVED))
- {
- show_error('Failed sending mail');
- }
}
}
@@ -173,40 +161,30 @@ class approveAnrechnungDetail extends Auth_Controller
{
$data = $this->input->post('data');
- if(isEmptyArray($data))
+ // Validate data
+ if (isEmptyArray($data))
{
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
}
- // Get statusbezeichnung for 'rejected'
- $this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
- $rejected = getData($this->AnrechnungstatusModel->load('rejected'))[0];
- $rejected = getUserLanguage() == 'German'
- ? $rejected->bezeichnung_mehrsprachig[0]
- : $rejected->bezeichnung_mehrsprachig[1];
-
+ // Get STGLs person data
if (!$person = getData($this->PersonModel->getByUID($this->_uid))[0])
{
show_error('Failed retrieving person data');
}
+ // Reject Anrechnung
foreach ($data as $item)
{
- // Reject Anrechnung
- if(getData($this->anrechnunglib->rejectAnrechnung($item['anrechnung_id'], $item['begruendung'])))
+ if ($this->anrechnunglib->rejectAnrechnung($item['anrechnung_id'], $item['begruendung']))
{
$json[]= array(
'anrechnung_id' => $item['anrechnung_id'],
'status_kurzbz' => self::ANRECHNUNGSTATUS_REJECTED,
- 'status_bezeichnung' => $rejected,
+ 'status_bezeichnung' => $this->anrechnunglib->getStatusbezeichnung(self::ANRECHNUNGSTATUS_REJECTED),
'abgeschlossen_am' => (new DateTime())->format('d.m.Y'),
'abgeschlossen_von' => $person->vorname. ' '. $person->nachname
);
-
- if(!$this->_sendSanchoMailToStudent($item['anrechnung_id'], self::ANRECHNUNGSTATUS_REJECTED))
- {
- show_error('Failed sending mail');
- }
}
}
@@ -217,7 +195,7 @@ class approveAnrechnungDetail extends Auth_Controller
}
else
{
- return $this->outputJsonError('Es wurden keine Anrechnungen genehmigt.');
+ return $this->outputJsonError($this->p->t('ui', 'errorNichtAusgefuehrt'));
}
}
@@ -233,47 +211,165 @@ class approveAnrechnungDetail extends Auth_Controller
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
}
- // Get statusbezeichnung for 'inProgressLektor'
- $this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
- $inProgressLektor = getData($this->AnrechnungstatusModel->load('inProgressLektor'))[0];
- $inProgressLektor = getUserLanguage() == 'German'
- ? $inProgressLektor->bezeichnung_mehrsprachig[0]
- : $inProgressLektor->bezeichnung_mehrsprachig[1];
+ $retval = array();
+ $counter = 0;
foreach ($data as $item)
{
- // Approve Anrechnung
- if(getData($this->anrechnunglib->requestRecommendation($item['anrechnung_id'])))
+ // Check if Anrechnungs-LV has lector
+ if (!$this->anrechnunglib->LVhasLector($item['anrechnung_id']))
{
- $json[]= array(
+ // Count up LV with no lector
+ $counter++;
+
+ // Break, if LV has no lector
+ break;
+ }
+
+ // Get full name of LV Leitung.
+ // If LV Leitung is not present, get full name of LV lectors.
+ $lector_arr = $this->anrechnunglib->getLectors($item['anrechnung_id']);
+ $empfehlungsanfrage_an = !isEmptyArray($lector_arr)
+ ? implode(', ', array_column($lector_arr, 'fullname'))
+ : '';
+
+ // Request Recommendation
+ if($this->anrechnunglib->requestRecommendation($item['anrechnung_id']))
+ {
+ $retval[]= array(
'anrechnung_id' => $item['anrechnung_id'],
'status_kurzbz' => self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR,
- 'status_bezeichnung' => $inProgressLektor,
+ 'status_bezeichnung' => $this->anrechnunglib->getStatusbezeichnung(self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR),
'empfehlung_anrechnung' => null,
- 'empfehlung_angefordert_am' => (new DateTime())->format('d.m.Y')
+ 'empfehlungsanfrageAm' => (new DateTime())->format('d.m.Y'),
+ 'empfehlungsanfrageAn' => $empfehlungsanfrage_an
);
}
}
- // Output json to ajax
- if (isset($json) && !isEmptyArray($json))
+ /**
+ * Send mails to lectors
+ * NOTE: mails are sent at the end to ensure sending only ONE mail to each LV-Leitung or lector
+ * even if they are required for more recommendations
+ * */
+ if (!isEmptyArray($retval))
{
- /**
- * Send mails to lectors
- * NOTE: mails are sent at the end to ensure sending only ONE mail to each LV-Leitung or lector
- * even if they are required for more recommendations
- * */
- if (!$this->_sendSanchoMailToLectors($json))
- {
- show_error('Failed sending emails');
- }
+ self::_sendSanchoMailToLectors($retval);
- return $this->outputJsonSuccess($json);
+ // Output json to ajax
+ return $this->outputJsonSuccess($retval);
}
- else
+
+ // Output json to ajax
+ if (isEmptyArray($retval) && $counter > 0)
{
- return $this->outputJsonError('Es wurden keine Empfehlungen angefordert');
+ return $this->outputJsonError(
+ "Empfehlung wurde nicht angefordert,\nDer LV sind keine LektorInnen zugeteilt."
+ );
}
+
+ return $this->outputJsonError($this->p->t('ui', 'errorNichtAusgefuehrt'));
+ }
+
+ /**
+ * Withdraw approved / rejected Anrechnung and reset to 'inProgressDP'.
+ */
+ public function withdraw()
+ {
+ $anrechnung_id = $this->input->post('anrechnung_id');
+
+ if (!is_numeric($anrechnung_id))
+ {
+ $this->terminateWithJsonError($this->p->t('ui', 'errorFelderFehlen'));
+ }
+
+ // Delete last status approved / rejected.
+ // If last status is 'approved', Genehmigung is resetted.
+ $result = $this->AnrechnungModel->withdrawApprovement($anrechnung_id);
+
+ if (isError($result))
+ {
+ $this->terminateWithJsonError(getError($result));
+ }
+
+ // Success output to AJAX
+ $this->outputJsonSuccess(array(
+ 'status_bezeichnung' => $this->anrechnunglib->getLastAnrechnungstatus($anrechnung_id))
+ );
+ }
+
+ /**
+ * Withdraw request for reommendation and reset to 'inProgressDP'.
+ * This is only possible if the lector has not provided a recommendation yet.
+ */
+ public function withdrawRequestRecommendation()
+ {
+ $anrechnung_id = $this->input->post('anrechnung_id');
+
+ if (!is_numeric($anrechnung_id))
+ {
+ show_error('Wrong parameter.');
+ }
+
+ // Get boolean empfehlung of given Anrechnung
+ if (!$result = getData($this->AnrechnungModel->load($anrechnung_id))[0])
+ {
+ show_error('Failed loading Anrechnung');
+ }
+
+ $empfehlung = $result->empfehlung_anrechnung;
+
+ // Get last Anrechnungstatus
+ if (!$result = getData($this->AnrechnungModel->getLastAnrechnungstatus($anrechnung_id))[0])
+ {
+ show_error('Failed loading last Anrechnungstatus');
+ }
+
+ $last_status = $result->status_kurzbz;
+ $anrechnungstatus_id = $result->anrechnungstatus_id;
+
+ // Return if Anrechnung was not waiting for recommendation or if Anrechnung has already been recommended
+ if ($last_status != self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR || !is_null($empfehlung))
+ {
+ return $this->outputJsonError('No recommendation to withdraw.');
+ }
+
+ // Reset status to 'inProgressDP'
+ $result = $this->AnrechnungModel->deleteAnrechnungstatus($anrechnungstatus_id);
+
+ if (isError($result))
+ {
+ return $this->outputJsonError('Could not withdraw this application.');
+ }
+
+ // Success output to AJAX
+ return $this->outputJsonSuccess(array(
+ 'status_bezeichnung' => $this->anrechnunglib->getLastAnrechnungstatus($anrechnung_id))
+ );
+ }
+
+ public function saveEmpfehlungsNotiz()
+ {
+ $anrechnung_id = $this->input->post('anrechnung_id');
+ $notiz_id = $this->input->post('notiz_id');
+ $empfehlungstext = $this->input->post('empfehlung_text');
+
+ // Validate data
+ if (isEmptyString($anrechnung_id))
+ {
+ $this->terminateWithJsonError($this->p->t('ui', 'systemFehler'));
+ }
+
+ // Save Empfehlungstext
+ $result = self::_saveEmpfehlungsNotiz($anrechnung_id, $empfehlungstext, $notiz_id);
+
+ if (isError($result))
+ {
+ $this->terminateWithJsonError($this->p->t('ui', 'fehlerBeimSpeichern'));
+ }
+
+ // Output success message
+ $this->outputJsonSuccess($this->p->t('ui', 'gespeichert'));
}
/**
@@ -291,7 +387,11 @@ class approveAnrechnungDetail extends Auth_Controller
// Check if user is entitled to read dms doc
self::_checkIfEntitledToReadDMSDoc($dms_id);
- $this->dmslib->download($dms_id);
+ // Set filename to be used on downlaod
+ $filename = $this->anrechnunglib->setFilenameOnDownload($dms_id);
+
+ // Download file
+ $this->dmslib->download($dms_id, $filename);
}
/**
@@ -376,41 +476,6 @@ class approveAnrechnungDetail extends Auth_Controller
show_error('You are not entitled to read this document');
}
- /**
- * Send mail to student to inform if Anrechnung was approved or rejected
- * @param $mail_params
- */
- private function _sendSanchoMailToStudent($anrechnung_id, $status_kurzbz)
- {
- $result = getData($this->anrechnunglib->getStudentData($anrechnung_id))[0];
-
- // Get student name and mail address
- $to = $result->uid. '@'. DOMAIN;
-
- $anrede = $result->geschlecht == 'w' ? 'Sehr geehrte Frau ' : 'Sehr geehrter Herr ';
-
- $text = $status_kurzbz == self::ANRECHNUNGSTATUS_APPROVED
- ? 'Ihrem Antrag auf Anerkennung nachgewiesener Kenntnisse der Lehrveranstaltung "'.
- $result->lv_bezeichnung. '" wurde stattgegeben.'
- : 'wir haben Ihren Antrag auf Anerkennung nachgewiesener Kenntnisse geprüft und können die Lehrveranstaltung "'.
- $result->lv_bezeichnung. '" leider nicht anrechnen, weil die Gleichwertigkeit nicht festgestellt werden konnte.';
-
- // Prepare mail content
- $body_fields = array(
- 'anrede_name' => $anrede. $result->vorname. ' '. $result->nachname,
- 'text' => $text
- );
-
- sendSanchoMail(
- 'AnrechnungGenehmigen',
- $body_fields,
- $to,
- 'Anerkennung nachgewiesener Kenntnisse: Ihr Antrag ist abgeschlossen'
- );
-
- return true;
- }
-
/**
* Send mail to lectors asking for recommendation. (first to LV-Leitung, if not present to all lectors of lv)
* @param $mail_params
@@ -439,6 +504,8 @@ class approveAnrechnungDetail extends Auth_Controller
* **/
$lector_arr = $this->_getLectors($anrechnung_arr);
+
+
// Send mail to lectors
foreach ($lector_arr as $lector)
{
@@ -476,8 +543,8 @@ class approveAnrechnungDetail extends Auth_Controller
}
/**
- * 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.
+ * Get unique array of LV lectors.
+ * Only get LV Leitung if present, otherwise all lectors of LV.
* @param $anrechnung_arr
* @return array
*/
@@ -521,11 +588,37 @@ class approveAnrechnungDetail extends Auth_Controller
unset($lector->lvleiter);
}
- // Now make the lector array aka mail receivers unique
+ // Make the lector array unique
$lector_arr = array_unique($lector_arr, SORT_REGULAR);
return $lector_arr;
}
+ private function _saveEmpfehlungsNotiz($anrechnung_id, $empfehlungstext, $notiz_id)
+ {
+ $this->load->model('person/Notiz_model', 'NotizModel');
+
+ if (!isEmptyString($notiz_id))
+ {
+ return $this->NotizModel->update(
+ $notiz_id,
+ array(
+ 'text' => $empfehlungstext,
+ 'updateamum' => (new DateTime())->format('Y-m-d H:i:s'),
+ 'updatevon' => $this->_uid
+ )
+ );
+ }
+
+ return $this->NotizModel->addNotizForAnrechnung(
+ $anrechnung_id,
+ self::ANRECHNUNG_NOTIZTITEL_EMPFEHLUNGSNOTIZ_BY_STGL,
+ trim($empfehlungstext),
+ $this->_uid
+ );
+
+
+ }
+
}
diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php
index b2d09fbe1..d59d97514 100644
--- a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php
+++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php
@@ -62,27 +62,21 @@ class approveAnrechnungUebersicht extends Auth_Controller
public function index()
{
+ // Get study semester
$studiensemester_kurzbz = $this->input->get('studiensemester');
- // Retrieve studiengaenge the user is entitled for
+ 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))
{
show_error(getError($studiengang_kz_arr));
}
- if (!is_string($studiensemester_kurzbz))
- {
- $studiensemester = $this->StudiensemesterModel->getNearest();
- if (hasData($studiensemester))
- {
- $studiensemester_kurzbz = $studiensemester->retval[0]->studiensemester_kurzbz;
- }
- elseif (isError($studiensemester))
- {
- show_error(getError($studiensemester));
- }
- }
-
$viewData = array(
'studiensemester_selected' => $studiensemester_kurzbz,
'studiengaenge_entitled' => $studiengang_kz_arr
@@ -98,33 +92,22 @@ class approveAnrechnungUebersicht extends Auth_Controller
{
$data = $this->input->post('data');
- if(isEmptyArray($data))
+ // Validate data
+ if (isEmptyArray($data))
{
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
}
- // Get statusbezeichnung for 'approved'
- $this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
- $approved = getData($this->AnrechnungstatusModel->load('approved'))[0];
- $approved = getUserLanguage() == 'German'
- ? $approved->bezeichnung_mehrsprachig[0]
- : $approved->bezeichnung_mehrsprachig[1];
-
+ // Approve Anrechnung
foreach ($data as $item)
{
- // Approve Anrechnung
- if(getData($this->anrechnunglib->approveAnrechnung($item['anrechnung_id'])))
+ if ($this->anrechnunglib->approveAnrechnung($item['anrechnung_id']))
{
$json[]= array(
'anrechnung_id' => $item['anrechnung_id'],
'status_kurzbz' => self::ANRECHNUNGSTATUS_APPROVED,
- 'status_bezeichnung' => $approved
+ 'status_bezeichnung' => $this->anrechnunglib->getStatusbezeichnung(self::ANRECHNUNGSTATUS_APPROVED)
);
-
- if(!$this->_sendSanchoMailToStudent($item['anrechnung_id'], self::ANRECHNUNGSTATUS_APPROVED))
- {
- show_error('Failed sending mail');
- }
}
}
@@ -146,33 +129,22 @@ class approveAnrechnungUebersicht extends Auth_Controller
{
$data = $this->input->post('data');
- if(isEmptyArray($data))
+ // Validate data
+ if (isEmptyArray($data))
{
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
}
- // Get statusbezeichnung for 'rejected'
- $this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
- $rejected = getData($this->AnrechnungstatusModel->load('rejected'))[0];
- $rejected = getUserLanguage() == 'German'
- ? $rejected->bezeichnung_mehrsprachig[0]
- : $rejected->bezeichnung_mehrsprachig[1];
-
+ // Reject Anrechnung
foreach ($data as $item)
{
- // Reject Anrechnung
- if(getData($this->anrechnunglib->rejectAnrechnung($item['anrechnung_id'], $item['begruendung'])))
+ if ($this->anrechnunglib->rejectAnrechnung($item['anrechnung_id'], $item['begruendung']))
{
$json[]= array(
'anrechnung_id' => $item['anrechnung_id'],
'status_kurzbz' => self::ANRECHNUNGSTATUS_REJECTED,
- 'status_bezeichnung' => $rejected
+ 'status_bezeichnung' => $this->anrechnunglib->getStatusbezeichnung(self::ANRECHNUNGSTATUS_REJECTED)
);
-
- if(!$this->_sendSanchoMailToStudent($item['anrechnung_id'], self::ANRECHNUNGSTATUS_REJECTED))
- {
- show_error('Failed sending mail');
- }
}
}
@@ -199,46 +171,59 @@ class approveAnrechnungUebersicht extends Auth_Controller
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
}
- // Get statusbezeichnung for 'inProgressLektor'
- $this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
- $inProgressLektor = getData($this->AnrechnungstatusModel->load('inProgressLektor'))[0];
- $inProgressLektor = getUserLanguage() == 'German'
- ? $inProgressLektor->bezeichnung_mehrsprachig[0]
- : $inProgressLektor->bezeichnung_mehrsprachig[1];
+ $retval = array();
+ $counter = 0;
foreach ($data as $item)
{
- // Approve Anrechnung
- if(getData($this->anrechnunglib->requestRecommendation($item['anrechnung_id'])))
+ // Check if Anrechnungs-LV has lector
+ if (!$this->anrechnunglib->LVhasLector($item['anrechnung_id']))
{
- $json[]= array(
+ // Count up LV with no lector
+ $counter++;
+
+ // Continue loop, if LV has no lector
+ continue;
+ }
+
+ // Request Recommendation
+ if($this->anrechnunglib->requestRecommendation($item['anrechnung_id']))
+ {
+ // Get full name of LV Leitung.
+ // If LV Leitung is not present, get full name of LV lectors.
+ $lector_arr = $this->anrechnunglib->getLectors($item['anrechnung_id']);
+ $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,
- 'status_bezeichnung' => $inProgressLektor,
- 'empfehlung_anrechnung' => null
+ 'status_bezeichnung' => $this->anrechnunglib->getStatusbezeichnung(self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR),
+ 'empfehlung_anrechnung' => null,
+ 'empfehlungsanfrageAm' => (new DateTime())->format('Y-m-d H:i:s'),
+ 'empfehlungsanfrageAn' => $empfehlungsanfrage_an
);
}
}
- // Output json to ajax
- if (isset($json) && !isEmptyArray($json))
+ /**
+ * Send mails to lectors
+ * NOTE: mails are sent at the end to ensure sending only ONE mail to each LV-Leitung or lector
+ * even if they are required for more recommendations
+ * */
+ if (!isEmptyArray($retval))
{
- /**
- * Send mails to lectors
- * NOTE: mails are sent at the end to ensure sending only ONE mail to each LV-Leitung or lector
- * even if they are required for more recommendations
- * */
- if (!$this->_sendSanchoMailToLectors($json))
- {
- show_error('Failed sending emails');
- }
-
- return $this->outputJsonSuccess($json);
+ self::_sendSanchoMailToLectors($retval);
}
- else
+
+ // Output json to ajax
+ if (isEmptyArray($retval) && $counter == 0)
{
return $this->outputJsonError('Es wurden keine Empfehlungen angefordert');
}
+
+ return $this->outputJsonSuccess($retval);
}
/**
@@ -256,7 +241,11 @@ class approveAnrechnungUebersicht extends Auth_Controller
// Check if user is entitled to read dms doc
self::_checkIfEntitledToReadDMSDoc($dms_id);
- $this->dmslib->download($dms_id);
+ // Set filename to be used on downlaod
+ $filename = $this->anrechnunglib->setFilenameOnDownload($dms_id);
+
+ // Download file
+ $this->dmslib->download($dms_id, $filename);
}
@@ -307,41 +296,6 @@ class approveAnrechnungUebersicht extends Auth_Controller
show_error('You are not entitled to read this document');
}
- /**
- * Send mail to student to inform if Anrechnung was approved or rejected
- * @param $mail_params
- */
- private function _sendSanchoMailToStudent($anrechnung_id, $status_kurzbz)
- {
- $result = getData($this->anrechnunglib->getStudentData($anrechnung_id))[0];
-
- // Get student name and mail address
- $to = $result->uid. '@'. DOMAIN;
-
- $anrede = $result->geschlecht == 'w' ? 'Sehr geehrte Frau ' : 'Sehr geehrter Herr ';
-
- $text = $status_kurzbz == self::ANRECHNUNGSTATUS_APPROVED
- ? 'Ihrem Antrag auf Anerkennung nachgewiesener Kenntnisse der Lehrveranstaltung "'.
- $result->lv_bezeichnung. '" wurde stattgegeben.'
- : 'wir haben Ihren Antrag auf Anerkennung nachgewiesener Kenntnisse geprüft und können die Lehrveranstaltung "'.
- $result->lv_bezeichnung. '" leider nicht anrechnen, weil die Gleichwertigkeit nicht festgestellt werden konnte.';
-
- // Prepare mail content
- $body_fields = array(
- 'anrede_name' => $anrede. $result->vorname. ' '. $result->nachname,
- 'text' => $text
- );
-
- sendSanchoMail(
- 'AnrechnungGenehmigen',
- $body_fields,
- $to,
- 'Anerkennung nachgewiesener Kenntnisse: Ihr Antrag ist abgeschlossen'
- );
-
- return true;
- }
-
/**
* Send mail to lectors asking for recommendation. (first to LV-Leitung, if not present to all lectors of lv)
* @param $mail_params
@@ -456,6 +410,5 @@ class approveAnrechnungUebersicht extends Auth_Controller
$lector_arr = array_unique($lector_arr, SORT_REGULAR);
return $lector_arr;
-
}
}
\ No newline at end of file
diff --git a/application/controllers/lehre/anrechnung/CreateAnrechnung.php b/application/controllers/lehre/anrechnung/CreateAnrechnung.php
new file mode 100644
index 000000000..bc594371d
--- /dev/null
+++ b/application/controllers/lehre/anrechnung/CreateAnrechnung.php
@@ -0,0 +1,271 @@
+ 'lehre/anrechnung_anlegen:r',
+ 'getLVsByStudent' => 'lehre/anrechnung_anlegen:r',
+ 'create' => 'lehre/anrechnung_anlegen:rw'
+ )
+ );
+
+ // Load models
+ $this->load->model('education/Anrechnung_model', 'AnrechnungModel');
+ $this->load->model('education/Anrechnungstatus_model', 'AnrechnungstatusModel');
+ $this->load->model('content/DmsVersion_model', 'DmsVersionModel');
+ $this->load->model('crm/Student_model', 'StudentModel');
+ $this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
+
+ // 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');
+
+ // Load language phrases
+ $this->loadPhrases(
+ array(
+ 'global',
+ 'ui',
+ 'anrechnung',
+ 'person',
+ 'lehre'
+ )
+ );
+
+ // Load configs
+ $this->load->config('anrechnung');
+
+ $this->_setAuthUID();
+
+ $this->setControllerId();
+ }
+
+ public function index()
+ {
+ // Get Studiensemester
+ $studiensemester_kurzbz = $this->input->get('studiensemester');
+
+ // If no Studiensemester is given
+ if (isEmptyString($studiensemester_kurzbz))
+ {
+ //...use the nearest Studiensemester
+ $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_ANLEGEN))
+ {
+ show_error('Failed retrieving Studiengaenge');
+ }
+
+ // Get Anrechnungsbegruendungen
+ $this->load->model('education/Anrechnungbegruendung_model', 'AnrechnungbegruendungModel');
+ $begruendung_arr = getData($this->AnrechnungbegruendungModel->load());
+
+ $viewData = array(
+ 'studiensemester_selected' => $studiensemester_kurzbz,
+ 'studiengaenge_entitled' => $studiengang_kz_arr,
+ 'begruendungen' => $begruendung_arr
+ );
+
+ $this->load->view('lehre/anrechnung/createAnrechnung.php', $viewData);
+ }
+
+ /**
+ * Get Lehrveranstaltungen from Student.
+ */
+ public function getLVsByStudent()
+ {
+ $prestudent_id = $this->input->post('prestudent_id');
+ $studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz');
+
+ // Get Student UID
+ $student_uid = $this->StudentModel->getUID($prestudent_id);
+
+ // Retrieve Lehrveranstaltungen from student
+ $result = $this->LehrveranstaltungModel->getLvsByStudent($student_uid, $studiensemester_kurzbz);
+
+ // Exit, if student has no Lehrveranstaltungen
+ if (!hasData($result))
+ {
+ $this->terminateWithJsonError($this->p->t('ui', 'keineLVzugeteilt'));
+ }
+
+ // Success response to AJAX
+ $this->outputJsonSuccess(getData($result));
+ }
+
+ /**
+ * Create Anrechnungsantrag.
+ *
+ * Saves Anrechnung and Anrechnungstatus.
+ * Also saves Nachweisdokument to DMS.
+ */
+ public function create()
+ {
+ $prestudent_id = $this->input->post('prestudent_id');
+ $studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz');
+ $lehrveranstaltung_id = $this->input->post('lehrveranstaltung_id');
+ $begruendung_id = $this->input->post('begruendung_id');
+ $herkunftKenntnisse = $this->input->post('herkunftKenntnisse');
+
+ // Validate upload file
+ if (empty($_FILES['uploadfile']['name']))
+ {
+ $this->terminateWithJsonError($this->p->t('ui', 'errorUploadFehlt'));
+ }
+
+ // Validate required data
+ if (isEmptyString($begruendung_id) || isEmptyString($lehrveranstaltung_id))
+ {
+ $this->terminateWithJsonError($this->p->t('ui', 'errorFelderFehlen'));
+ }
+
+ // Exit if application already exists
+ if (self::_applicationExists($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id))
+ {
+ $this->terminateWithJsonError($this->p->t('global', 'antragBereitsGestellt'));
+ }
+
+ // Exit if Lehrveranstaltung was already graded with application blocking grades
+ if (self::_LVhasBlockingGrades($studiensemester_kurzbz, $lehrveranstaltung_id, $prestudent_id))
+ {
+ $this->terminateWithJsonError($this->p->t('anrechnung', 'antragBenotungBlockiert'));
+ }
+
+ // Upload document
+ $result = self::_uploadFile();
+
+ if (isError($result))
+ {
+ $this->terminateWithJsonError($result->retval);
+ }
+
+ // Hold just inserted DMS ID
+ $lastInsert_dms_id = $result->retval['dms_id'];
+
+ // Save Anrechnung and Anrechnungstatus
+ $result = $this->AnrechnungModel->createAnrechnungsantrag(
+ $prestudent_id,
+ $studiensemester_kurzbz,
+ $lehrveranstaltung_id,
+ $begruendung_id,
+ $lastInsert_dms_id,
+ $herkunftKenntnisse
+ );
+
+ if (isError($result))
+ {
+ $this->terminateWithJsonError(getError($result));
+ }
+
+ $lastInsert_anrechnung_id = getData($result);
+
+ // Success response to AJAX
+ $this->outputJsonSuccess(array(
+ 'anrechnung_id' => $lastInsert_anrechnung_id,
+ 'msg' => $this->p->t('global', 'antragWurdeAngelegt')
+ ));
+ }
+
+
+ /**
+ * 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 application already exists.
+ *
+ * @param $lehrveranstaltung_id
+ * @param $studiensemester_kurzbz
+ * @param $prestudent_id
+ * @return bool
+ */
+ private function _applicationExists($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id)
+ {
+ $result = $this->AnrechnungModel->loadWhere(array(
+ 'lehrveranstaltung_id' => $lehrveranstaltung_id,
+ 'studiensemester_kurzbz' => $studiensemester_kurzbz,
+ 'prestudent_id' => $prestudent_id
+ ));
+
+ if (isError($result))
+ {
+ show_error(getError($result));
+ }
+
+ return hasData($result);
+ }
+
+ /**
+ * Upload file via DMS library.
+ *
+ * @return mixed
+ * @throws Exception
+ */
+ private function _uploadFile()
+ {
+ $dms = array(
+ 'kategorie_kurzbz' => 'anrechnung',
+ 'version' => 0,
+ 'name' => $_FILES['uploadfile']['name'],
+ 'mimetype' => $_FILES['uploadfile']['type'],
+ 'insertamum' => (new DateTime())->format('Y-m-d H:i:s'),
+ 'insertvon' => $this->_uid
+ );
+
+ // Upload document
+ return $this->dmslib->upload($dms, 'uploadfile', array('pdf'));
+ }
+
+ private function _LVhasBlockingGrades($studiensemester_kurzbz, $lehrveranstaltung_id, $prestudent_id)
+ {
+ // Get Student UID
+ $student_uid = $this->StudentModel->getUID($prestudent_id);
+
+ // Get Note of Lehrveranstaltung
+ $this->load->model('education/Lvgesamtnote_model', 'LvgesamtnoteModel');
+ $result = $this->LvgesamtnoteModel->load(array(
+ 'student_uid' => $student_uid,
+ 'studiensemester_kurzbz' => $studiensemester_kurzbz,
+ 'lehrveranstaltung_id' => $lehrveranstaltung_id
+ )
+ );
+
+ // If Lehrveranstaltung has Note
+ if (hasData($result))
+ {
+ $note = getData($result)[0]->note;
+
+ // Check if Note is a blocking grade
+ if (in_array($note, $this->config->item('grades_blocking_application')))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
\ No newline at end of file
diff --git a/application/controllers/lehre/anrechnung/RequestAnrechnung.php b/application/controllers/lehre/anrechnung/RequestAnrechnung.php
index 4f589e5f5..45a770cf5 100644
--- a/application/controllers/lehre/anrechnung/RequestAnrechnung.php
+++ b/application/controllers/lehre/anrechnung/RequestAnrechnung.php
@@ -6,15 +6,13 @@ class requestAnrechnung extends Auth_Controller
{
const REQUEST_ANRECHNUNG_URI = '/lehre/anrechnung/RequestAnrechnung';
const APPROVE_ANRECHNUNG_URI = '/lehre/anrechnung/ApproveAnrechnungUebersicht';
-
+
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';
-
- const DEADLINE_INTERVAL_NACH_SEMESTERSTART = 'P1M'; // Deadline for application
-
+
public function __construct()
{
// Set required permissions
@@ -25,22 +23,25 @@ class requestAnrechnung extends Auth_Controller
'download' => 'student/anrechnung_beantragen:rw',
)
);
-
+
// Load models
$this->load->model('education/Anrechnung_model', 'AnrechnungModel');
$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 configs
+ $this->load->config('anrechnung');
+
// Load language phrases
$this->loadPhrases(
array(
@@ -51,63 +52,59 @@ class requestAnrechnung extends Auth_Controller
'lehre'
)
);
-
+
$this->_setAuthUID();
-
+
$this->setControllerId();
}
-
+
public function index()
{
$studiensemester_kurzbz = $this->input->get('studiensemester');
$lehrveranstaltung_id = $this->input->get('lv_id');
-
- if (!is_numeric($lehrveranstaltung_id) || !is_string($studiensemester_kurzbz))
+
+ if (isEmptyString($lehrveranstaltung_id) || isEmptyString($studiensemester_kurzbz))
{
show_error('Missing correct parameter');
}
-
+
+ // Exit if user is not a student
+ $result = $this->StudentModel->load(array('student_uid' => $this->_uid));
+
+ if (!hasData($result))
+ {
+ show_error('Cant load user');
+ }
+
+ // Get Prestudent ID
+ $prestudent_id = getData($result)[0]->prestudent_id;
+
// Check if application deadline is expired
- // $is_expired = $this->_checkAntragDeadline($studiensemester_kurzbz);
- $is_expired = false; // Set to false until Deadline is defined
-
- $student = $this->StudentModel->load(array('student_uid' => $this->_uid));
- if (isSuccess($student) && hasData($student))
- {
- $prestudent_id = getData($student)[0]->prestudent_id;
- }
- else
- show_error('Cant load User');
-
+ $is_expired = self::_checkAntragDeadline(
+ $this->config->item('submit_application_start'),
+ $this->config->item('submit_application_end'),
+ $studiensemester_kurzbz
+ );
+
+ // Check if Lehrveranstaltung was already graded with application blocking grades
+ $is_blocked = self::_LVhasBlockingGrades($studiensemester_kurzbz, $lehrveranstaltung_id);
+
// Get Anrechung data
- $result = $this->anrechnunglib->getAnrechnungDataByLv($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id);
- if (!$anrechnungData = getData($result))
- {
- show_error(getError($anrechnungData));
- }
-
- // Dont show who is progressing the application to the student
- if ($anrechnungData->status_kurzbz == self::ANRECHNUNGSTATUS_PROGRESSED_BY_STGL ||
- $anrechnungData->status_kurzbz == self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR ||
- $anrechnungData->status_kurzbz == self::ANRECHNUNGSTATUS_PROGRESSED_BY_KF)
- {
- $anrechnungData->status = getUserLanguage() == 'German' ? 'in Bearbeitung' : 'in process';
- }
-
- $antragData = $this->anrechnunglib->getAntragData($this->_uid, $studiensemester_kurzbz, $lehrveranstaltung_id);
+ $anrechnungData = $this->anrechnunglib->getAnrechnungDataByLv($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id);
+ // Get Antrag data
+ $antragData = $this->anrechnunglib->getAntragData($prestudent_id, $studiensemester_kurzbz, $lehrveranstaltung_id);
+
$viewData = array(
'antragData' => $antragData,
'anrechnungData' => $anrechnungData,
'is_expired' => $is_expired,
- 'disabled' => $is_expired && empty($anrechnungData->anrechnung_id) || !empty($anrechnungData->anrechnung_id)
- ? 'disabled'
- : ''
+ 'is_blocked' => $is_blocked
);
-
+
$this->load->view('lehre/anrechnung/requestAnrechnung.php', $viewData);
}
-
+
/**
* Apply Anrechnungsantrag and send to STGL
*/
@@ -117,104 +114,82 @@ class requestAnrechnung extends Auth_Controller
$begruendung_id = $this->input->post('begruendung');
$lehrveranstaltung_id = $this->input->post('lv_id');
$studiensemester_kurzbz = $this->input->post('studiensemester');
+ $bestaetigung = $this->input->post('bestaetigung');
+ // Validate data
if (empty($_FILES['uploadfile']['name']))
{
- show_error('Missing upload file');
+ return $this->outputJsonError($this->p->t('ui', 'errorUploadFehlt'));
}
- if (!is_numeric($begruendung_id) || !is_numeric($lehrveranstaltung_id) || !is_string($studiensemester_kurzbz))
+ if (isEmptyString($begruendung_id) ||
+ isEmptyString($anmerkung) ||
+ isEmptyString($lehrveranstaltung_id) ||
+ isEmptyString($studiensemester_kurzbz))
{
- show_error('Missing correct parameter');
+ return $this->outputJsonError($this->p->t('ui', 'errorFelderFehlen'));
}
-
- $student = $this->StudentModel->load(array('student_uid' => $this->_uid));
- if (isSuccess($student) && hasData($student))
+
+ if (isEmptyString($bestaetigung))
{
- $prestudent_id = getData($student)[0]->prestudent_id;
+ return $this->outputJsonError($this->p->t('ui', 'errorBestaetigungFehlt'));
}
- else
- show_error('Cant load User');
-
- $result = $this->_getAnrechnung($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id);
- if (hasData($result))
+
+ // Exit if user is not a student
+ $result = $this->StudentModel->load(array('student_uid' => $this->_uid));
+
+ if (!hasData($result))
{
- show_error('Der Antrag wurde bereits gestellt');
+ return $this->outputJsonError('Cant load user');
}
-
- // Start DB transaction
- $this->db->trans_start(false);
-
+
+ // Get Prestudent ID
+ $prestudent_id = getData($result)[0]->prestudent_id;
+
+ // Exit if application already exists
+ if (self::_applicationExists($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id))
+ {
+ return $this->outputJsonError($this->p->t('anrechnung', 'antragBereitsGestellt'));
+ }
+
+ // Exit if application is not for actual studysemester
+ if (!self::_applicationIsForActualSS($studiensemester_kurzbz))
+ {
+ return $this->outputJsonError($this->p->t('anrechnung', 'antragNurImAktSS'));
+ }
+
// Upload document
- $dms = array(
- 'kategorie_kurzbz' => 'anrechnung',
- 'version' => 0,
- 'name' => $_FILES['uploadfile']['name'],
- 'mimetype' => $_FILES['uploadfile']['type'],
- 'insertamum' => (new DateTime())->format('Y-m-d H:i:s'),
- 'insertvon' => $this->_uid
+ $result = self::_uploadFile();
+
+ if (isError($result))
+ {
+ return $this->outputJsonError($result->retval);
+ }
+
+ // Hold just inserted DMS ID
+ $lastInsert_dms_id = $result->retval['dms_id'];
+
+ // Save Anrechnung and Anrechnungstatus
+ $result = $this->AnrechnungModel->createAnrechnungsantrag(
+ $prestudent_id,
+ $studiensemester_kurzbz,
+ $lehrveranstaltung_id,
+ $begruendung_id,
+ $lastInsert_dms_id,
+ $anmerkung
);
-
- if(isError($uploaddata = $this->dmslib->upload($dms, array('pdf'))))
+
+ if (isError($result))
{
- show_error(getError($uploaddata));
+ $this->terminateWithJsonError(getError($result));
}
-
- // Get PrestudentID
- $result = $this->_loadPrestudent($this->_uid, $studiensemester_kurzbz);
-
- if (!$prestudent = getData($result)[0])
- {
- show_error('Failed retrieving prestudent');
- }
-
- // Save Anrechnung
- $result = $this->AnrechnungModel->insert(array(
- 'prestudent_id' => $prestudent->prestudent_id,
- 'lehrveranstaltung_id' => $lehrveranstaltung_id,
- 'begruendung_id' => $begruendung_id,
- 'dms_id' => $uploaddata->retval['dms_id'],
- 'studiensemester_kurzbz' => $studiensemester_kurzbz,
- 'anmerkung_student' => $anmerkung,
- 'insertvon' => $this->_uid
+
+ // Output to AJAX
+ $this->outputJsonSuccess(array(
+ 'antragdatum' => (new DateTime())->format('d.m.Y'),
+ 'dms_id' => $lastInsert_dms_id,
+ 'filename' => $_FILES['uploadfile']['name']
));
-
- if (isError($result))
- {
- show_error('Failed inserting Anrechnung');
- }
-
- // Save Anrechnungstatus 'inProgressSTGL'
- $result = $this->AnrechnungModel->saveAnrechnungstatus($result->retval, self::ANRECHNUNGSTATUS_PROGRESSED_BY_STGL);
-
- if (isError($result))
- {
- show_error('Failed saving Anrechnungstatus');
- }
-
- // Transaction complete!
- $this->db->trans_complete();
-
- if ($this->db->trans_status() === false || isError($result))
- {
- $this->db->trans_rollback();
- show_error($result->msg, EXIT_ERROR);
- }
-
- // Send mail to STGL
- $mail_params = array(
- 'studiengang_kz' => $prestudent->studiengang_kz,
- 'lehrveranstaltung_id' => $lehrveranstaltung_id
- );
-
- if(!$this->_sendSanchoMail($mail_params))
- {
- show_error('Failed sending mail');
- }
- else
- {
- redirect(site_url(). self::REQUEST_ANRECHNUNG_URI. '?studiensemester='. $studiensemester_kurzbz. '&lv_id='. $lehrveranstaltung_id);
- }
}
/**
@@ -241,53 +216,50 @@ class requestAnrechnung extends Auth_Controller
private function _setAuthUID()
{
$this->_uid = getAuthUID();
-
+
if (!$this->_uid) show_error('User authentification failed');
}
-
- /**
- * Load Prestudent by uid and Studiensemester.
- * @param $uid
- * @param $studiensemester_kurzbz
- * @return mixed
- */
- private function _loadPrestudent($uid, $studiensemester_kurzbz)
- {
- $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
- $this->load->model('crm/Student_model', 'StudentModel');
-
- $this->PrestudentstatusModel->addJoin('public.tbl_student', 'prestudent_id');
- return $this->PrestudentstatusModel->loadWhere(array(
- 'student_uid' => $uid,
- 'studiensemester_kurzbz' => $studiensemester_kurzbz
- )
- );
- }
-
+
/**
* Check if application deadline is expired.
+ *
+ * @param $start Start date for application submission.
+ * @param $ende End date for application submission.
* @param $studiensemester_kurzbz
- * @return bool True if semester start is more then 1 week ago
+ * @return bool True if today is not during the start- and ending deadlines (= if is expired)
* @throws Exception
*/
- private function _checkAntragDeadline($studiensemester_kurzbz)
+ private function _checkAntragDeadline($start, $ende, $studiensemester_kurzbz)
{
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
- $this->StudiensemesterModel->addSelect('start');
- if (!$start = getData($this->StudiensemesterModel->load($studiensemester_kurzbz)))
+
+ // If start is not given, set to Semesterstart.
+ if (!isset($start) || isEmptyString($start))
{
- show_error(getError($start));
+ $this->StudiensemesterModel->addSelect('start');
+ $result = $this->StudiensemesterModel->load($studiensemester_kurzbz);
+ $start = getData($result)[0]->start;
}
-
- $start = new DateTime($start[0]->start);
+
+ // If ende is not given, set to Semesterende.
+ if (!isset($ende) || isEmptyString($ende))
+ {
+ $this->StudiensemesterModel->addSelect('ende');
+ $result = $this->StudiensemesterModel->load($studiensemester_kurzbz);
+ $ende = getData($result)[0]->ende;
+ }
+
$today = new DateTime('today midnight');
-
- // True if today > application deadline
- return ($today > $start->add((new DateInterval(self::DEADLINE_INTERVAL_NACH_SEMESTERSTART))));
+ $start = new DateTime($start);
+ $ende = new DateTime($ende);
+
+ // True if today is not during the start- and ending deadlines (= if is expired)
+ return ($today <= $start || $today >= $ende);
}
-
+
/**
- * Check if user is entitled to read dms doc
+ * Check if user is entitled to read dms doc.
+ *
* @param $dms_id
*/
private function _checkIfEntitledToReadDMSDoc($dms_id)
@@ -298,7 +270,7 @@ class requestAnrechnung extends Auth_Controller
}
$result = $this->AnrechnungModel->loadWhere(array('dms_id' => $dms_id));
-
+
if($result = getData($result)[0])
{
if ($result->prestudent_id == $student->prestudent_id)
@@ -306,104 +278,92 @@ class requestAnrechnung extends Auth_Controller
return;
}
}
-
+
show_error('You are not entitled to read this document');
}
-
+
/**
- * Get Anrechnung by Lehrveranstaltung
+ * Check if application already exists.
+ *
* @param $lehrveranstaltung_id
- * @return mixed
+ * @param $studiensemester_kurzbz
+ * @param $prestudent_id
+ * @return bool
*/
- private function _getAnrechnung($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id)
+ private function _applicationExists($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id)
{
$result = $this->AnrechnungModel->loadWhere(array(
'lehrveranstaltung_id' => $lehrveranstaltung_id,
'studiensemester_kurzbz' => $studiensemester_kurzbz,
'prestudent_id' => $prestudent_id
));
-
+
if (isError($result))
{
show_error(getError($result));
}
-
- return $result;
+
+ return hasData($result);
}
-
+
/**
- * Send mail to STGL (if not available, send to STGL assistance)
- * @param $mail_params
+ * Check if applications' study semester is actual study semester.
+ *
+ * @param $studiensemester_kurzbz
+ * @return bool
*/
- private function _sendSanchoMail($mail_params)
+ private function _applicationIsForActualSS($studiensemester_kurzbz)
{
- // Get STGL mail address, if available, otherwise get assistance mail address
- list ($to, $vorname) = $this->_getSTGLMailAddress($mail_params['studiengang_kz']);
-
- // Get full name of student
- $this->load->model('person/Person_model', 'PersonModel');
- if (!$student_name = getData($this->PersonModel->getFullName($this->_uid)))
- {
- show_error ('Failed retrieving person');
- }
-
- // Get lehrveranstaltung bezeichnung
- $this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
- if (!$lehrveranstaltung = getData($this->LehrveranstaltungModel->load($mail_params['lehrveranstaltung_id']))[0])
- {
- 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::APPROVE_ANRECHNUNG_URI;
-
- // Prepare mail content
- $body_fields = array(
- 'vorname' => $vorname,
- 'student_name' => $student_name,
- 'lehrveranstaltung_bezeichnung' => $lehrveranstaltung->bezeichnung,
- 'link' => anchor($url, 'Anrechnungsanträge Übersicht')
- );
-
- sendSanchoMail(
- 'AnrechnungAntragStellen',
- $body_fields,
- $to,
- 'Anerkennung nachgewiesener Kenntnisse: Neuer Antrag wurde gestellt'
- );
-
- return true;
+ $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
+ $result = $this->StudiensemesterModel->getNearest();
+ $actual_ss = getData($result)[0]->studiensemester_kurzbz;
+
+ return $studiensemester_kurzbz == $actual_ss;
}
-
- // Get STGL mail address, if available, otherwise get assistance mail address
- private function _getSTGLMailAddress($stg_kz)
+
+ private function _LVhasBlockingGrades($studiensemester_kurzbz, $lehrveranstaltung_id)
{
- $this->load->model('organisation/Studiengang_model', 'StudiengangModel');
- $result = $this->StudiengangModel->getLeitung($stg_kz);
-
- // Get STGL mail address, if available
+ // Get Note of Lehrveranstaltung
+ $this->load->model('education/Lvgesamtnote_model', 'LvgesamtnoteModel');
+ $result = $this->LvgesamtnoteModel->load(array(
+ 'student_uid' => $this->_uid,
+ 'studiensemester_kurzbz' => $studiensemester_kurzbz,
+ 'lehrveranstaltung_id' => $lehrveranstaltung_id
+ )
+ );
+
+ // If Lehrveranstaltung has Note
if (hasData($result))
{
- return array(
- $result->retval[0]->uid. '@'. DOMAIN,
- $result->retval[0]->vorname
- );
- }
- // ...otherwise get assistance mail address
- else
- {
- $result = $this->StudiengangModel->load($stg_kz);
-
- if (hasData($result))
+ $note = getData($result)[0]->note;
+
+ // Check if Note is a blocking grade
+ if (in_array($note, $this->config->item('grades_blocking_application')))
{
- return array(
- $result->retval[0]->email,
- ''
- );
+ return true;
}
}
+ return false;
}
-}
+
+ /**
+ * Upload file via DMS library.
+ *
+ * @return mixed
+ * @throws Exception
+ */
+ private function _uploadFile()
+ {
+ $dms = array(
+ 'kategorie_kurzbz' => 'anrechnung',
+ 'version' => 0,
+ 'name' => $_FILES['uploadfile']['name'],
+ 'mimetype' => $_FILES['uploadfile']['type'],
+ 'insertamum' => (new DateTime())->format('Y-m-d H:i:s'),
+ 'insertvon' => $this->_uid
+ );
+
+ // 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 b9c723eee..78175f4e6 100644
--- a/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php
+++ b/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php
@@ -1,6 +1,6 @@
anrechnunglib->getAnrechnungData($anrechnung_id)))
- {
- show_error('Missing data for Anrechnung.');
- }
+ $anrechnungData = $this->anrechnunglib->getAnrechnungData($anrechnung_id);
+
+ // Get Antrag data
+ $antragData = $this->anrechnunglib->getAntragData(
+ $anrechnungData->prestudent_id,
+ $anrechnungData->studiensemester_kurzbz,
+ $anrechnungData->lehrveranstaltung_id
+ );
// Get Empfehlung data
- if(!$empfehlungData = getData($this->anrechnunglib->getEmpfehlungData($anrechnung_id)))
- {
- show_error('Missing data for recommendation');
- }
+ $empfehlungData = $this->anrechnunglib->getEmpfehlungData($anrechnung_id);
$viewData = array(
- 'antragData' => $this->anrechnunglib->getAntragData(
- $student_uid = $this->StudentModel->getUID($anrechnungData->prestudent_id),
- $anrechnungData->studiensemester_kurzbz,
- $anrechnungData->lehrveranstaltung_id
- ),
+ 'antragData' => $antragData,
'anrechnungData' => $anrechnungData,
'empfehlungData' => $empfehlungData
);
@@ -113,29 +110,23 @@ class reviewAnrechnungDetail extends Auth_Controller
{
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
}
-
- // Get statusbezeichnung for 'inProgressDP'
- $this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
- $inProgressDP = getData($this->AnrechnungstatusModel->load('inProgressDP'))[0];
- $inProgressDP = getUserLanguage() == 'German'
- ? $inProgressDP->bezeichnung_mehrsprachig[0]
- : $inProgressDP->bezeichnung_mehrsprachig[1];
-
+
+ // Get lectors person data
if (!$person = getData($this->PersonModel->getByUID($this->_uid))[0])
{
- show_error('Failed retrieving person data');
+ return $this->outputJsonError('Failed retrieving person data');
}
foreach ($data as $item)
{
// Approve Anrechnung
- if(getData($this->anrechnunglib->recommendAnrechnung($item['anrechnung_id'])))
+ if($this->anrechnunglib->recommendAnrechnung($item['anrechnung_id']))
{
$json[]= array(
'anrechnung_id' => $item['anrechnung_id'],
'empfehlung_anrechnung' => 'true',
'status_kurzbz' => self::ANRECHNUNGSTATUS_PROGRESSED_BY_STGL,
- 'status_bezeichnung' => $inProgressDP,
+ 'status_bezeichnung' => $this->anrechnunglib->getStatusbezeichnung(self::ANRECHNUNGSTATUS_PROGRESSED_BY_STGL),
'empfehlung_am' => (new DateTime())->format('d.m.Y'),
'empfehlung_von' => $person->vorname. ' '. $person->nachname
);
@@ -151,14 +142,14 @@ class reviewAnrechnungDetail extends Auth_Controller
* */
if (!$this->_sendSanchoMails($json, true))
{
- show_error('Failed sending emails');
+ return $this->outputJsonError('Failed sending emails');
}
return $this->outputJsonSuccess($json);
}
else
{
- return $this->outputJsonError('Empfehlungen wurden nicht durchgeführt');
+ return $this->outputJsonError($this->p->t('ui', 'errorNichtAusgefuehrt'));
}
}
@@ -174,29 +165,23 @@ class reviewAnrechnungDetail extends Auth_Controller
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
}
- // Get statusbezeichnung for 'inProgressDP'
- $this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
- $inProgressDP = getData($this->AnrechnungstatusModel->load('inProgressDP'))[0];
- $inProgressDP = getUserLanguage() == 'German'
- ? $inProgressDP->bezeichnung_mehrsprachig[0]
- : $inProgressDP->bezeichnung_mehrsprachig[1];
-
+ // Get lectors person data
if (!$person = getData($this->PersonModel->getByUID($this->_uid))[0])
{
- show_error('Failed retrieving person data');
+ return $this->outputJsonError('Failed retrieving person data');
}
foreach ($data as $item)
{
// Approve Anrechnung
- if(getData($this->anrechnunglib->dontRecommendAnrechnung($item['anrechnung_id'], $item['begruendung'])))
+ if($this->anrechnunglib->dontRecommendAnrechnung($item['anrechnung_id'], $item['begruendung']))
{
$json[]= array(
'anrechnung_id' => $item['anrechnung_id'],
'empfehlung_anrechnung' => 'false',
'status_kurzbz' => self::ANRECHNUNGSTATUS_PROGRESSED_BY_STGL,
- 'status_bezeichnung' => $inProgressDP,
- 'empfehlumg_am' => (new DateTime())->format('d.m.Y'),
+ 'status_bezeichnung' => $this->anrechnunglib->getStatusbezeichnung(self::ANRECHNUNGSTATUS_PROGRESSED_BY_STGL),
+ 'empfehlung_am' => (new DateTime())->format('d.m.Y'),
'empfehlung_von' => $person->vorname. ' '. $person->nachname
);
}
@@ -208,14 +193,14 @@ class reviewAnrechnungDetail extends Auth_Controller
// Send mails to STGL (if not present STGL, send to STGL assistance)
if (!$this->_sendSanchoMails($json, false))
{
- show_error('Failed sending emails');
+ return $this->outputJsonError('Failed sending emails');
}
return $this->outputJsonSuccess($json);
}
else
{
- return $this->outputJsonError('Empfehlungen wurden nicht durchgeführt');
+ return $this->outputJsonError($this->p->t('ui', 'errorNichtAusgefuehrt'));
}
}
@@ -233,8 +218,12 @@ class reviewAnrechnungDetail extends Auth_Controller
// Check if user is entitled to read dms doc
self::_checkIfEntitledToReadDMSDoc($dms_id);
-
- $this->dmslib->download($dms_id);
+
+ // Set filename to be used on downlaod
+ $filename = $this->anrechnunglib->setFilenameOnDownload($dms_id);
+
+ // Download file
+ $this->dmslib->download($dms_id, $filename);
}
diff --git a/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php
index 005cde97a..cd0b7afaf 100644
--- a/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php
+++ b/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php
@@ -62,19 +62,13 @@ class reviewAnrechnungUebersicht extends Auth_Controller
public function index()
{
+ // Get study semester
$studiensemester_kurzbz = $this->input->get('studiensemester');
- if (!is_string($studiensemester_kurzbz))
+ if (isEmptyString($studiensemester_kurzbz))
{
- $studiensemester = $this->StudiensemesterModel->getNearest();
- if (hasData($studiensemester))
- {
- $studiensemester_kurzbz = $studiensemester->retval[0]->studiensemester_kurzbz;
- }
- elseif (isError($studiensemester))
- {
- show_error(getError($studiensemester));
- }
+ $result = $this->StudiensemesterModel->getNearest();
+ $studiensemester_kurzbz = getData($result)[0]->studiensemester_kurzbz;
}
$viewData = array(
@@ -95,24 +89,17 @@ class reviewAnrechnungUebersicht extends Auth_Controller
{
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
}
-
- // Get statusbezeichnung for 'inProgressDP'
- $this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
- $inProgressDP = getData($this->AnrechnungstatusModel->load('inProgressDP'))[0];
- $inProgressDP = getUserLanguage() == 'German'
- ? $inProgressDP->bezeichnung_mehrsprachig[0]
- : $inProgressDP->bezeichnung_mehrsprachig[1];
foreach ($data as $item)
{
// Approve Anrechnung
- if(getData($this->anrechnunglib->recommendAnrechnung($item['anrechnung_id'])))
+ if($this->anrechnunglib->recommendAnrechnung($item['anrechnung_id']))
{
$json[]= array(
'anrechnung_id' => $item['anrechnung_id'],
'empfehlung_anrechnung' => 'true',
'status_kurzbz' => self::ANRECHNUNGSTATUS_PROGRESSED_BY_STGL,
- 'status_bezeichnung' => $inProgressDP
+ 'status_bezeichnung' => $this->anrechnunglib->getStatusbezeichnung(self::ANRECHNUNGSTATUS_PROGRESSED_BY_STGL)
);
}
}
@@ -133,7 +120,7 @@ class reviewAnrechnungUebersicht extends Auth_Controller
}
else
{
- return $this->outputJsonError('Empfehlungen wurden nicht durchgeführt');
+ return $this->outputJsonError($this->p->t('ui', 'errorNichtAusgefuehrt'));
}
}
@@ -149,24 +136,16 @@ class reviewAnrechnungUebersicht extends Auth_Controller
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
}
- // Get statusbezeichnung for 'inProgressDP'
- $this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
- $inProgressDP = getData($this->AnrechnungstatusModel->load('inProgressDP'))[0];
- $inProgressDP = getUserLanguage() == 'German'
- ? $inProgressDP->bezeichnung_mehrsprachig[0]
- : $inProgressDP->bezeichnung_mehrsprachig[1];
-
foreach ($data as $item)
{
// Approve Anrechnung
- if(getData($this->anrechnunglib
- ->dontRecommendAnrechnung($item['anrechnung_id'], $item['begruendung'])))
+ if($this->anrechnunglib->dontRecommendAnrechnung($item['anrechnung_id'], $item['begruendung']))
{
$json[]= array(
'anrechnung_id' => $item['anrechnung_id'],
'empfehlung_anrechnung' => 'false',
'status_kurzbz' => self::ANRECHNUNGSTATUS_PROGRESSED_BY_STGL,
- 'status_bezeichnung' => $inProgressDP
+ 'status_bezeichnung' => $this->anrechnunglib->getStatusbezeichnung(self::ANRECHNUNGSTATUS_PROGRESSED_BY_STGL)
);
}
}
@@ -184,7 +163,7 @@ class reviewAnrechnungUebersicht extends Auth_Controller
}
else
{
- return $this->outputJsonError('Empfehlungen wurden nicht durchgeführt');
+ return $this->outputJsonError($this->p->t('ui', 'errorNichtAusgefuehrt'));
}
}
@@ -203,7 +182,11 @@ class reviewAnrechnungUebersicht extends Auth_Controller
// Check if user is entitled to read dms doc
self::_checkIfEntitledToReadDMSDoc($dms_id);
- $this->dmslib->download($dms_id);
+ // Set filename to be used on downlaod
+ $filename = $this->anrechnunglib->setFilenameOnDownload($dms_id);
+
+ // Download file
+ $this->dmslib->download($dms_id, $filename);
}
diff --git a/application/controllers/system/FAS_UDF.php b/application/controllers/system/FAS_UDF.php
index febe266c7..ecaa44393 100644
--- a/application/controllers/system/FAS_UDF.php
+++ b/application/controllers/system/FAS_UDF.php
@@ -31,7 +31,7 @@ class FAS_UDF extends Auth_Controller
if (isset($person_id) && is_numeric($person_id))
{
- if ($this->PersonModel->hasUDF())
+ if ($this->PersonModel->udfsExistAndDefined())
{
$personUdfs = $this->PersonModel->getUDFs($person_id);
$data['person_id'] = $person_id;
@@ -41,7 +41,7 @@ class FAS_UDF extends Auth_Controller
if (isset($prestudent_id) && is_numeric($prestudent_id))
{
- if ($this->PrestudentModel->hasUDF())
+ if ($this->PrestudentModel->udfsExistAndDefined())
{
$prestudentUdfs = $this->PrestudentModel->getUDFs($prestudent_id);
$data['prestudent_id'] = $prestudent_id;
diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php
index 44a1cf327..cd88f814a 100644
--- a/application/controllers/system/infocenter/InfoCenter.php
+++ b/application/controllers/system/infocenter/InfoCenter.php
@@ -124,20 +124,20 @@ class InfoCenter extends Auth_Controller
'saveAbsage' => 'infocenter:rw',
'saveFreigabe' => 'infocenter:rw',
'getNotiz' => 'infocenter:r',
- 'saveNotiz' => 'infocenter:rw',
+ 'saveNotiz' => array('infocenter:rw', 'lehre/zgvpruefung:rw'),
'updateNotiz' => 'infocenter:rw',
'reloadZgvPruefungen' => 'infocenter:r',
'reloadMessages' => 'infocenter:r',
'reloadDoks' => 'infocenter:r',
- 'reloadNotizen' => 'infocenter:r',
+ 'reloadNotizen' => array('infocenter:r', 'lehre/zgvpruefung:r'),
'reloadLogs' => 'infocenter:r',
- 'outputAkteContent' => 'infocenter:r',
- 'getPostponeDate' => 'infocenter:r',
+ 'outputAkteContent' => array('infocenter:r', 'lehre/zgvpruefung:r'),
+ 'getPostponeDate' => array('infocenter:r', 'lehre/zgvpruefung:r'),
'park' => 'infocenter:rw',
'unpark' => 'infocenter:rw',
'setOnHold' => 'infocenter:rw',
- 'removeOnHold' => 'infocenter:rw',
- 'getStudienjahrEnd' => 'infocenter:r',
+ 'removeOnHold' => array('infocenter:rw', 'lehre/zgvpruefung:rw'),
+ 'getStudienjahrEnd' => array('infocenter:r', 'lehre/zgvpruefung:r'),
'setNavigationMenuArrayJson' => 'infocenter:r',
'getAbsageData' => 'infocenter:r',
'saveAbsageForAll' => 'infocenter:rw'
diff --git a/application/controllers/system/issues/Issues.php b/application/controllers/system/issues/Issues.php
new file mode 100644
index 000000000..f942b50d9
--- /dev/null
+++ b/application/controllers/system/issues/Issues.php
@@ -0,0 +1,142 @@
+ array(self::BERECHTIGUNG_KURZBZ.':r'),
+ 'changeIssueStatus' => array(self::BERECHTIGUNG_KURZBZ.':rw')
+ )
+ );
+
+ // Load libraries
+ $this->load->library('IssuesLib');
+ $this->load->library('PermissionLib');
+ $this->load->library('WidgetLib');
+
+ $this->loadPhrases(
+ array(
+ 'global',
+ 'ui',
+ 'filter'
+ )
+ );
+
+ // Load models
+ $this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
+ $this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel');
+
+ $this->_setAuthUID(); // sets property uid
+ }
+
+ public function index()
+ {
+ $oes_for_issues = $this->_getOesForIssues();
+
+ $this->load->view(
+ 'system/issues/issues',
+ $oes_for_issues
+ );
+ }
+
+ /**
+ * Initializes issues status change
+ */
+ public function changeIssueStatus()
+ {
+ $issue_ids = $this->input->post('issue_ids');
+ $status_kurzbz = $this->input->post('status_kurzbz');
+ $verarbeitetvon = $this->_uid;
+
+ $errors = array();
+ foreach ($issue_ids as $issue_id)
+ {
+ $issueRes = $this->issueslib->changeIssueStatus($issue_id, $status_kurzbz, $verarbeitetvon);
+
+ if (isError($issueRes))
+ $errors[] = getError($issueRes);
+ }
+
+ if (!isEmptyArray($errors))
+ $this->outputJsonError(implode(", ", $errors));
+ else
+ $this->outputJsonSuccess("Status erfolgreich aktualisiert");
+ }
+
+ /**
+ * 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');
+ }
+
+ /**
+ * Gets oes of logged in user, which are needed to display issues of the user.
+ * This includes oes assigned by a funktio and as the issue permission.
+ * @return array
+ */
+ private function _getOesForIssues()
+ {
+ // get oes of uid for which there is a current funktion
+ $all_funktionen_oe_kurzbz = array();
+ $oe_kurzbz_for_funktion = array();
+ $benutzerfunktionRes = $this->BenutzerfunktionModel->getBenutzerFunktionByUid($this->_uid, null, date('Y-m-d'), date('Y-m-d'));
+
+ if (isError($benutzerfunktionRes))
+ show_error(getError($benutzerfunktionRes));
+
+ if (hasData($benutzerfunktionRes))
+ {
+ foreach (getData($benutzerfunktionRes) as $benutzerfunktion)
+ {
+ $all_funktionen_oe_kurzbz[$benutzerfunktion->oe_kurzbz][] = $benutzerfunktion->funktion_kurzbz;
+
+ // separate oes for the funktion needed for displaying issues
+ if ($benutzerfunktion->funktion_kurzbz == self::FUNKTION_KURZBZ)
+ {
+ $oe_kurzbz_for_funktion[] = $benutzerfunktion->oe_kurzbz;
+
+ // permission also for all oes under the oe for which funktion is assigend
+ $childOesFunktionRes = $this->OrganisationseinheitModel->getChilds($benutzerfunktion->oe_kurzbz);
+
+ if (isError($childOesFunktionRes))
+ show_error(getError($childOesFunktionRes));
+
+ if (hasData($childOesFunktionRes))
+ {
+ $childOesFunktion = getData($childOesFunktionRes);
+
+ foreach ($childOesFunktion as $childOeFunktion)
+ {
+ if (!in_array($childOeFunktion->oe_kurzbz, $oe_kurzbz_for_funktion))
+ $oe_kurzbz_for_funktion[] = $childOeFunktion->oe_kurzbz;
+ }
+ }
+ }
+ }
+ }
+
+ // add oes for which there is the "manage issues" Berechtigung
+ if (!$oe_kurzbz_berechtigt = $this->permissionlib->getOE_isEntitledFor(self::BERECHTIGUNG_KURZBZ))
+ show_error('Keine Berechtigung oder Fehler bei Berechtigungsprüfung');
+
+ $all_oe_kurzbz_berechtigt = array_unique(array_merge($oe_kurzbz_for_funktion, $oe_kurzbz_berechtigt));
+
+ return array(
+ 'all_funktionen_oe_kurzbz' => $all_funktionen_oe_kurzbz,
+ 'all_oe_kurzbz_berechtigt' => $all_oe_kurzbz_berechtigt
+ );
+ }
+}
diff --git a/application/controllers/widgets/Filters.php b/application/controllers/widgets/Filters.php
index 748272f09..e87b2d331 100644
--- a/application/controllers/widgets/Filters.php
+++ b/application/controllers/widgets/Filters.php
@@ -211,7 +211,7 @@ class Filters extends FHC_Controller
public function setNavigationMenu()
{
// Generates the filters structure array
- $filterMenu = $this->filterwidgetlib->generateFilterMenu($this->input->get(FilterWidgetLib::NAVIGATION_PAGE));
+ $this->filterwidgetlib->generateFilterMenu($this->input->get(FilterWidgetLib::NAVIGATION_PAGE));
$this->outputJsonSuccess('Success');
}
@@ -271,3 +271,4 @@ class Filters extends FHC_Controller
}
}
}
+
diff --git a/application/controllers/widgets/UDF.php b/application/controllers/widgets/UDF.php
index 5b4c45776..26c30293c 100644
--- a/application/controllers/widgets/UDF.php
+++ b/application/controllers/widgets/UDF.php
@@ -26,9 +26,6 @@ class UDF extends FHC_Controller
// Loads the UDFLib with HTTP GET/POST parameters
$this->_loadUDFLib();
-
- // Checks if the caller is allow to use this UDF widget
- $this->_isAllowed();
}
//------------------------------------------------------------------------------------------------------------------
@@ -39,7 +36,6 @@ class UDF extends FHC_Controller
*/
public function saveUDFs()
{
- $udfUniqueId = $this->input->post(self::UDF_UNIQUE_ID);
$udfs = $this->input->post(UDFLib::UDFS_ARG_NAME);
if (!isEmptyString($udfs))
@@ -47,7 +43,7 @@ class UDF extends FHC_Controller
$jsonDecodedUDF = json_decode($udfs);
if ($jsonDecodedUDF != null)
{
- $this->outputJson($this->udflib->saveUDFs($udfUniqueId, $jsonDecodedUDF));
+ $this->outputJson($this->udflib->saveUDFs($jsonDecodedUDF));
}
else
{
@@ -63,17 +59,6 @@ class UDF extends FHC_Controller
//------------------------------------------------------------------------------------------------------------------
// Private methods
- /**
- * Checks if the user is allowed to use this UDFWidget
- */
- private function _isAllowed()
- {
- if (!$this->udflib->isAllowed())
- {
- $this->terminateWithJsonError('You are not allowed to access to this content');
- }
- }
-
/**
* Loads the UDFLib with the UDF_UNIQUE_ID parameter
* If the parameter UDF_UNIQUE_ID is not given then the execution of the controller is terminated and
@@ -105,3 +90,4 @@ class UDF extends FHC_Controller
}
}
}
+
diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php
index 4b89ae5bf..4e555be6c 100644
--- a/application/core/DB_Model.php
+++ b/application/core/DB_Model.php
@@ -86,7 +86,7 @@ class DB_Model extends CI_Model
if (is_null($this->dbTable)) return error('The given database table name is not valid', EXIT_MODEL);
// If this table has UDF and the validation of them is ok
- if (isError($validate = $this->_manageUDFs($data, $this->dbTable))) return $validate;
+ if (isError($validate = $this->_prepareUDFsWrite($data, $this->dbTable))) return $validate;
// DB-INSERT
$insert = $this->db->insert($this->dbTable, $data);
@@ -137,7 +137,7 @@ class DB_Model extends CI_Model
if (is_null($this->dbTable)) return error('The given database table name is not valid', EXIT_MODEL);
// If this table has UDF and the validation of them is ok
- if (isError($validate = $this->_manageUDFs($data, $this->dbTable, $id))) return $validate;
+ if (isError($validate = $this->_prepareUDFsWrite($data, $this->dbTable, $id))) return $validate;
$tmpId = $id;
@@ -670,6 +670,7 @@ class DB_Model extends CI_Model
/**
* Returns all the UDF contained in this table ($dbTable)
* If no UDF are present, an empty array will be returned
+ * NOTE: only the UDFs that the logged user is allowed to read are loaded by this method
*/
public function getUDFs($id, $udfName = null)
{
@@ -700,9 +701,9 @@ class DB_Model extends CI_Model
}
/**
- * Checks if this table has the field udf_values
+ * Checks if this table has the field udf_values and if there is a UDF definition for this table
*/
- public function hasUDF()
+ public function udfsExistAndDefined()
{
if ($this->fieldExists(UDFLib::COLUMN_NAME))
{
@@ -844,25 +845,25 @@ class DB_Model extends CI_Model
}
/**
- * Wrapper method for UDFLib->manageUDFs
+ * Wrapper method for UDFLib->prepareUDFsWrite
*/
- private function _manageUDFs(&$data, $schemaAndTable, $id = null)
+ private function _prepareUDFsWrite(&$data, $schemaAndTable, $id = null)
{
- $manageUDFs = success();
+ $prepareUDFsWrite = success();
- if ($this->hasUDF())
+ if ($this->udfsExistAndDefined())
{
if ($id != null)
{
- $manageUDFs = $this->udflib->manageUDFs($data, $this->dbTable, $this->getUDFs($id));
+ $prepareUDFsWrite = $this->udflib->prepareUDFsWrite($data, $this->dbTable, $this->_getUDFsNoPerms($id));
}
else
{
- $manageUDFs = $this->udflib->manageUDFs($data, $this->dbTable);
+ $prepareUDFsWrite = $this->udflib->prepareUDFsWrite($data, $this->dbTable);
}
}
- return $manageUDFs;
+ return $prepareUDFsWrite;
}
/**
@@ -874,9 +875,10 @@ class DB_Model extends CI_Model
*/
private function _toPhp($result)
{
+ $udfs = false; // if UDFs are inside the given result set
$toPhp = $result; // if there is nothing to convert then return the result from DB
- // If it's an object its fields will be parsed to find booleans and arrays types
+ // If it's an object its fields will be parsed to find booleans, arrays and UDFs types
if (is_object($result))
{
$toBeConverterdArray = array(); // Fields to be converted
@@ -884,40 +886,48 @@ class DB_Model extends CI_Model
$this->executedQueryMetaData = $result->field_data(); // Fields information
$this->executedQueryListFields = $result->list_fields(); // List of the retrieved fields
- for ($i = 0; $i < count($this->executedQueryMetaData); $i++) // Looking for booleans and arrays
+ // Looking for booleans, arrays and UDFs
+ foreach ($this->executedQueryMetaData as $eqmd)
{
// If array type, boolean type OR a UDF
- if (strpos($this->executedQueryMetaData[$i]->type, DB_Model::PGSQL_ARRAY_TYPE) !== false
- || $this->executedQueryMetaData[$i]->type == DB_Model::PGSQL_BOOLEAN_TYPE
- || $this->udflib->isUDFColumn($this->executedQueryMetaData[$i]->name, $this->executedQueryMetaData[$i]->type))
+ if (strpos($eqmd->type, DB_Model::PGSQL_ARRAY_TYPE) !== false
+ || $eqmd->type == DB_Model::PGSQL_BOOLEAN_TYPE
+ || $this->udflib->isUDFColumn($eqmd->name, $eqmd->type))
{
- // Name and type of the field to be converted
- $toBeConverted = new stdClass();
- // Set the type of the field to be converted
- $toBeConverted->type = $this->executedQueryMetaData[$i]->type;
- // Set the name of the field to be converted
- $toBeConverted->name = $this->executedQueryMetaData[$i]->name;
- // Add the field to be converted to $toBeConverterdArray
- array_push($toBeConverterdArray, $toBeConverted);
+ // If UDFs are inside this result set
+ if ($this->udflib->isUDFColumn($eqmd->name, $eqmd->type))
+ {
+ $udfs = true;
+ }
+ else // all the other cases
+ {
+ // Name and type of the field to be converted
+ $toBeConverted = new stdClass();
+ // Set the type of the field to be converted
+ $toBeConverted->type = $eqmd->type;
+ // Set the name of the field to be converted
+ $toBeConverted->name = $eqmd->name;
+ // Add the field to be converted to $toBeConverterdArray
+ array_push($toBeConverterdArray, $toBeConverted);
+ }
}
}
- // If there is something to convert, otherwhise don't lose time
- if (count($toBeConverterdArray) > 0)
- {
- // Returns the array of objects, each of them represents a DB record
- $resultsArray = $result->result();
- // Looping on results
- for ($i = 0; $i < count($resultsArray); $i++)
- {
- // Single element
- $resultElement = $resultsArray[$i];
- // Looping on fields to be converted
- for ($j = 0; $j < count($toBeConverterdArray); $j++)
- {
- // Single element
- $toBeConverted = $toBeConverterdArray[$j];
+ // Returns the array of objects, each of them represents a DB record
+ $resultsArray = $result->result();
+ // If in this result set there are UDFs then prepare them
+ if ($udfs) $this->udflib->prepareUDFsRead($resultsArray, $this->dbTable);
+
+ // If there is something to convert, otherwhise don't waste time
+ if (!isEmptyArray($toBeConverterdArray))
+ {
+ // Looping on results
+ foreach ($resultsArray as $resultElement)
+ {
+ // Looping on fields to be converted
+ foreach ($toBeConverterdArray as $toBeConverted)
+ {
// Array type
if (strpos($toBeConverted->type, DB_Model::PGSQL_ARRAY_TYPE) !== false)
{
@@ -931,30 +941,12 @@ class DB_Model extends CI_Model
{
$resultElement->{$toBeConverted->name} = $this->pgBoolPhp($resultElement->{$toBeConverted->name});
}
- // UDF
- elseif ($this->udflib->isUDFColumn($toBeConverted->name, $toBeConverted->type))
- {
- $jsonValues = json_decode($resultElement->{$toBeConverted->name}); // decode UDFs values
- if ($jsonValues != null) // if decode is ok
- {
- // For every UDF
- foreach ($jsonValues as $key => $value)
- {
- $resultElement->{$key} = $value; // create a new element called like the UDF
- }
- }
- unset($resultElement->{UDFLib::COLUMN_NAME}); // remove udf_values from the response
- }
}
}
- // Returns DB data as an array
- $toPhp = $resultsArray;
- }
- // And returns DB data as an array
- else
- {
- $toPhp = $result->result();
}
+
+ // Returns DB data as an array
+ $toPhp = $resultsArray;
}
return $toPhp;
@@ -998,4 +990,48 @@ class DB_Model extends CI_Model
{
if ($this->debugMode) $this->loglib->logDebug($this->db->last_query());
}
+
+ /**
+ * Returns all the UDF contained in this table ($dbTable)
+ * If no UDF are present, an empty array will be returned
+ * NOTE: it returns all the UDFs, does _not_ check the permissions
+ */
+ private function _getUDFsNoPerms($id)
+ {
+ $udfs = array();
+
+ $this->db->select(UDFLib::COLUMN_NAME, true); // get only the UDF column
+
+ // Primary key management
+ $tmpId = $id;
+
+ // Check for composite Primary Key
+ if (is_array($id))
+ {
+ if (isset($id[0]))
+ {
+ $tmpId = $this->_arrayCombine($this->pk, $id);
+ }
+ }
+ elseif ($id != null)
+ {
+ $tmpId = array($this->pk => $id);
+ }
+
+ // Read the record from the table
+ $result = $this->db->get_where($this->dbTable, $tmpId);
+
+ // If was a success and there are data
+ if ($result && count($result->result()) == 1)
+ {
+ // Get the UDF column and decode it from JSON
+ $jsonValues = json_decode($result->result()[0]->{UDFLib::COLUMN_NAME});
+
+ // If the JSON convertion was fine convert the object to an array
+ if ($jsonValues != null) $udfs = get_object_vars($jsonValues);
+ }
+
+ return $udfs;
+ }
}
+
diff --git a/application/core/FHC_Controller.php b/application/core/FHC_Controller.php
index 93c324b21..ce8748c5a 100644
--- a/application/core/FHC_Controller.php
+++ b/application/core/FHC_Controller.php
@@ -132,6 +132,32 @@ abstract class FHC_Controller extends CI_Controller
{
$this->output->set_content_type('application/json')->set_output(json_encode($mixed));
}
+
+ protected function outputFile($fileObj)
+ {
+ if (file_exists($fileObj->file))
+ {
+ $finfo = new finfo(FILEINFO_MIME);
+
+ header('Content-Description: File Transfer');
+ header('Content-Type: '. $finfo->file($fileObj->file));
+ 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'))
+ {
+ header('Content-Disposition: '. $fileObj->disposition. '; filename="'. $fileObj->name. '"');
+ }
+
+ readfile($fileObj->file);
+
+ exit;
+ }
+
+ return false;
+ }
//------------------------------------------------------------------------------------------------------------------
// Private methods
diff --git a/application/core/JQW_Controller.php b/application/core/JQW_Controller.php
index 361efd998..1bc4cd346 100644
--- a/application/core/JQW_Controller.php
+++ b/application/core/JQW_Controller.php
@@ -70,6 +70,19 @@ abstract class JQW_Controller extends JOB_Controller
return $jobs;
}
+ /**
+ * To get all the jobs specified by the given parameters
+ */
+ protected function getJobsByTypeStatus($type, $status)
+ {
+ $jobs = $this->jobsqueuelib->getJobsByTypeStatus($type, $status);
+
+ // If an error occurred then log it in database
+ if (isError($jobs)) $this->logError(getError($jobs), array($type, $status));
+
+ return $jobs;
+ }
+
/**
* To get all the jobs specified by the given parameters
*/
diff --git a/application/libraries/AnrechnungLib.php b/application/libraries/AnrechnungLib.php
index c32b8a91c..3bec62dce 100644
--- a/application/libraries/AnrechnungLib.php
+++ b/application/libraries/AnrechnungLib.php
@@ -12,6 +12,7 @@ class AnrechnungLib
const ANRECHNUNG_NOTIZTITEL_NOTIZ_BY_LEKTOR = 'AnrechnungNotizLektor';
const ANRECHNUNG_NOTIZTITEL_NOTIZ_BY_STGL = 'AnrechnungNotizSTGL';
+ const ANRECHNUNG_NOTIZTITEL_EMPFEHLUNGSNOTIZ_BY_STGL = 'AnrechnungEmpfehlungsnotizSTGL';
public function __construct()
{
@@ -23,6 +24,10 @@ class AnrechnungLib
$this->ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
$this->ci->load->model('crm/Student_model', 'StudentModel');
$this->ci->load->model('content/DmsVersion_model', 'DmsVersionModel');
+ $this->ci->load->model('crm/Prestudent_model', 'PrestudentModel');
+ $this->ci->load->model('person/Notiz_model', 'NotizModel');
+
+ $this->ci->load->library('DmsLib');
}
/**
@@ -32,16 +37,19 @@ class AnrechnungLib
* @param $lv_id
* @return StdClass
*/
- public function getAntragData($uid, $studiensemester_kurzbz, $lv_id)
+ public function getAntragData($prestudent_id, $studiensemester_kurzbz, $lv_id)
{
$antrag_data = new StdClass();
-
+
+ // Get students UID.
+ $uid = $this->ci->StudentModel->getUID($prestudent_id);
+
// Get lehrveranstaltung data. Break, if course is not assigned to student.
if(!$lv = getData($this->ci->LehrveranstaltungModel->getLvByStudent($uid, $studiensemester_kurzbz, $lv_id))[0])
{
show_error('You are not assigned to this course yet.');
}
-
+
// Get the students personal data
if (!$person = getData($this->ci->PersonModel->getByUid($uid))[0])
{
@@ -61,12 +69,18 @@ class AnrechnungLib
}
// Get lectors of lehrveranstaltung
- $antrag_data->lektoren = array();
- if (!$lv_lektoren = getData($this->ci->LehrveranstaltungModel->getLecturersByLv($studiensemester_kurzbz, $lv_id)))
+ $result = $this->ci->LehrveranstaltungModel->getLecturersByLv($studiensemester_kurzbz, $lv_id);
+ if (isError($result))
{
show_error('Failed loading course lectors.');
}
-
+
+ $lv_lektoren_arr = hasData($result) ? getData($result) : array();
+
+ // Get latest ZGV
+ $result = $this->ci->PrestudentModel->getLatestZGVBezeichnung($prestudent_id);
+ $latest_zgv_bezeichnung = hasData($result) ? getData($result)[0]->bezeichnung : '';
+
// Set the given studiensemester
$antrag_data->lv_id = $lv_id;
$antrag_data->lv_bezeichnung = $lv->bezeichnung;
@@ -76,7 +90,8 @@ class AnrechnungLib
$antrag_data->nachname = $person->nachname;
$antrag_data->matrikelnr = $student->matrikelnr;
$antrag_data->stg_bezeichnung = $studiengang->bezeichnung;
- $antrag_data->lektoren = $lv_lektoren;
+ $antrag_data->lektoren = $lv_lektoren_arr;
+ $antrag_data->zgv = $latest_zgv_bezeichnung;
return $antrag_data;
}
@@ -107,8 +122,12 @@ class AnrechnungLib
{
$anrechnung_data = $this->_setAnrechnungDataObject($anrechnung);
}
+ else
+ {
+ show_error('No Anrechnung with this anrechnung_id.');
+ }
- return success($anrechnung_data);
+ return $anrechnung_data;
}
@@ -153,7 +172,7 @@ class AnrechnungLib
$anrechnung_data = $this->_setAnrechnungDataObject($anrechnung);
}
- return success($anrechnung_data);
+ return $anrechnung_data;
}
/**
@@ -171,8 +190,8 @@ class AnrechnungLib
$this->ci->AnrechnungModel->addSelect('tbl_benutzer.uid, tbl_prestudent.prestudent_id, tbl_person.person_id, tbl_anrechnung.studiensemester_kurzbz, vorname, nachname, geschlecht, tbl_lehrveranstaltung.bezeichnung AS "lv_bezeichnung"');
$this->ci->AnrechnungModel->addJoin('public.tbl_prestudent', 'prestudent_id');
$this->ci->AnrechnungModel->addJoin('public.tbl_student', 'prestudent_id');
- $this->ci->AnrechnungModel->addJoin('public.tbl_benutzer', 'uid=student_uid');
- $this->ci->AnrechnungModel->addJoin('public.tbl_person', 'tbl_benutzer.person_id=tbl_person.person_id');
+ $this->ci->AnrechnungModel->addJoin('public.tbl_benutzer', 'uid = student_uid');
+ $this->ci->AnrechnungModel->addJoin('public.tbl_person', 'tbl_benutzer.person_id = tbl_person.person_id');
$this->ci->AnrechnungModel->addJoin('lehre.tbl_lehrveranstaltung', 'lehrveranstaltung_id');
$result = $this->ci->AnrechnungModel->load($anrechnung_id);
@@ -207,28 +226,53 @@ class AnrechnungLib
$empfehlung_data->empfehlung = null;
$empfehlung_data->empfehlung_von = '-';
$empfehlung_data->empfehlung_am = '-';
- $empfehlung_data->empfehlung_angefordert_am = '-';
- $empfehlung_data->notiz = ''; // Begruendung, if not recommended
-
+ $empfehlung_data->empfehlungsanfrageAm = '-';
+ $empfehlung_data->empfehlungsanfrageAn = '-';
+ $empfehlung_data->begruendung = '-'; // Begruendung, if not recommended
+ $empfehlung_data->notiz_id = ''; // Empfehlungsnotiz from STGL
+ $empfehlung_data->notiz = ''; // Empfehlungsnotiz from STGL
+
if(!$anrechnung = getData($this->ci->AnrechnungModel->load($anrechnung_id))[0])
{
show_error('Failed loading Anrechnung');
}
+
+ // Get Empfehlungsnotiz
+ $result = $this->ci->NotizModel->getNotizByAnrechnung(
+ $anrechnung_id,
+ self::ANRECHNUNG_NOTIZTITEL_EMPFEHLUNGSNOTIZ_BY_STGL
+ );
+
+ if ($notiz = getData($result)[0])
+ {
+ $empfehlung_data->notiz_id = $notiz->notiz_id;
+ $empfehlung_data->notiz = $notiz->text;
+ }
// Get date, where recommendation was last requested
$result = $this->ci->AnrechnungModel->getLastAnrechnungstatus(
$anrechnung_id,
self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR // when STLG asks for recommendation, status is set to in progress lektor
);
- if ($result = getData($result)[0])
+
+ // If request for recommendation exists
+ if (hasData($result))
{
- $empfehlung_data->empfehlung_angefordert_am = (new DateTime($result->insertamum))->format('d.m.Y');
+ $empfehlung_data->empfehlungsanfrageAm = (new DateTime($result->retval[0]->insertamum))->format('d.m.Y');
+
+ // Get lectors who received request for recommendation
+ $lector_arr = self::getLectors($anrechnung_id);
+
+ if (!isEmptyArray($lector_arr))
+ {
+ $empfehlung_data->empfehlungsanfrageAn = implode(', ', array_column($lector_arr, 'fullname'));
+ }
}
if (is_null($anrechnung->empfehlung_anrechnung))
{
- return success($empfehlung_data);
+ return $empfehlung_data;
}
// If Empfehlung is true or false
@@ -260,15 +304,14 @@ class AnrechnungLib
if (!$anrechnung->empfehlung_anrechnung)
{
// Get Ablehnungsbegruendung (only set, if Anrechnung was not recommended yet)
- $this->ci->load->model('person/Notiz_model', 'NotizModel');
$result = $this->ci->NotizModel->getNotizByAnrechnung($anrechnung_id, self::ANRECHNUNG_NOTIZTITEL_NOTIZ_BY_LEKTOR);
if ($notiz = getData($result)[0])
{
- $empfehlung_data->notiz = $notiz->text;
+ $empfehlung_data->begruendung = $notiz->text;
}
}
- return success($empfehlung_data);
+ return $empfehlung_data;
}
@@ -300,9 +343,10 @@ class AnrechnungLib
// Get date of approvement or rejection
$result = $this->ci->AnrechnungModel->getApprovedOrRejected($anrechnung_id);
+ // If no approved or rejected Anrechnung exist, return basic genehmigung data object
if (!$result = getData($result)[0])
{
- return success($genehmigung_data);
+ return $genehmigung_data;
}
@@ -331,9 +375,30 @@ class AnrechnungLib
}
}
- return success($genehmigung_data);
+ return $genehmigung_data;
}
+
+ /**
+ * Get Anrechnungstatusbezeichnung of given status_kurzbz in users language.
+ *
+ * @param $status_kurzbz
+ * @return mixed
+ */
+ public function getStatusbezeichnung ($status_kurzbz)
+ {
+ $this->ci->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
+ $result = $this->ci->AnrechnungstatusModel->load($status_kurzbz);
+
+ if (!hasData($result))
+ {
+ show_error('Failed retrieving Anrechnungstatusbezeichung');
+ }
+
+ return getUserLanguage() == 'German'
+ ? $result->retval[0]->bezeichnung_mehrsprachig[0]
+ : $result->retval[0]->bezeichnung_mehrsprachig[1];
+ }
/**
* Get last Anrechnungstatusbezeichnung in users language.
@@ -370,7 +435,7 @@ class AnrechnungLib
// Exit if already approved or rejected
if ($status_kurzbz == self::ANRECHNUNGSTATUS_APPROVED || $status_kurzbz == self::ANRECHNUNGSTATUS_REJECTED)
{
- return success(false); // dont approve
+ return false; // dont approve
}
// Start DB transaction
@@ -395,10 +460,10 @@ class AnrechnungLib
if ($this->ci->db->trans_status() === false)
{
$this->ci->db->trans_rollback();
- return error($result->msg, EXIT_ERROR);
+ return false;
}
- return success(true); // approved
+ return true; // approved
}
/**
@@ -419,16 +484,14 @@ class AnrechnungLib
// Exit if already approved or rejected
if ($status_kurzbz == self::ANRECHNUNGSTATUS_APPROVED || $status_kurzbz == self::ANRECHNUNGSTATUS_REJECTED)
{
- return success(false); // dont reject
+ return false; // dont reject
}
+
+ // Start DB transaction
+ $this->ci->db->trans_start(false);
// Insert new status rejected
- $result = $this->ci->AnrechnungModel->saveAnrechnungstatus($anrechnung_id, self::ANRECHNUNGSTATUS_REJECTED);
-
- if (isError($result))
- {
- show_error(getError($result));
- }
+ $this->ci->AnrechnungModel->saveAnrechnungstatus($anrechnung_id, self::ANRECHNUNGSTATUS_REJECTED);
// Add begruendung as notiz
$this->ci->load->model('person/Notiz_model', 'NotizModel');
@@ -438,8 +501,17 @@ class AnrechnungLib
$begruendung,
getAuthUID()
);
+
+ // Transaction complete
+ $this->ci->db->trans_complete();
+
+ if ($this->ci->db->trans_status() === false)
+ {
+ $this->ci->db->trans_rollback();
+ return false;
+ }
- return success(true); // rejected
+ return true; // rejected
}
/**
@@ -462,7 +534,7 @@ class AnrechnungLib
|| $status_kurzbz == self::ANRECHNUNGSTATUS_REJECTED
|| $status_kurzbz == self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR)
{
- return success(false); // dont ask for recommendation
+ return false; // dont ask for recommendation
}
// Start DB transaction
@@ -492,7 +564,7 @@ class AnrechnungLib
return error($result->msg, EXIT_ERROR);
}
- return success(true); // recommended
+ return true; // recommended
}
/**
@@ -537,10 +609,10 @@ class AnrechnungLib
if ($this->ci->db->trans_status() === false)
{
$this->ci->db->trans_rollback();
- return error($result->msg, EXIT_ERROR);
+ return false;
}
- return success(true); // recommended
+ return true; // recommended
}
/**
@@ -562,7 +634,7 @@ class AnrechnungLib
// Exit if already approved or rejected
if ($status_kurzbz == self::ANRECHNUNGSTATUS_APPROVED || $status_kurzbz == self::ANRECHNUNGSTATUS_REJECTED)
{
- return success(false); // dont approve
+ return false; // dont approve
}
// Start DB transaction
@@ -596,10 +668,125 @@ class AnrechnungLib
if ($this->ci->db->trans_status() === false)
{
$this->ci->db->trans_rollback();
- return error($result->msg, EXIT_ERROR);
+ return false;
}
- return success(true); // recommended
+ return true; // recommended
+ }
+
+ /**
+ * Set Filename that should be used on download
+ * @param $dms_id
+ * @return string|null
+ */
+ public function setFilenameOnDownload($dms_id)
+ {
+ // Load Anrechnung
+ $result = $this->ci->AnrechnungModel->loadWhere(array('dms_id' => $dms_id));
+
+ // Return null if no data found
+ if (!hasData($result))
+ {
+ return null;
+ }
+
+ $prestudent_id = $result->retval[0]->prestudent_id;
+ $lehrveranstaltung_id = $result->retval[0]->lehrveranstaltung_id;
+
+ // Get LV OrgForm
+ $this->ci->LehrveranstaltungModel->addSelect('stg.orgform_kurzbz');
+ $this->ci->LehrveranstaltungModel->addJoin('public.tbl_studiengang AS stg', 'studiengang_kz');
+ $result = $this->ci->LehrveranstaltungModel->load($lehrveranstaltung_id);
+ $orgform_kurzbz = hasData($result) ? '_'. $result->retval[0]->orgform_kurzbz : '';
+
+ // Get full name of student
+ $this->ci->load->model('crm/Prestudent_model', 'PrestudentModel');
+ $this->ci->PrestudentModel->addSelect('vorname, nachname');
+ $this->ci->PrestudentModel->addJoin('public.tbl_person', 'person_id');
+ $result = $this->ci->PrestudentModel->load($prestudent_id);
+ $fullname = hasData($result) ? $result->retval[0]->vorname. $result->retval[0]->nachname : '';
+
+ // Return filename
+ return 'Anrechnungsantrag'. $orgform_kurzbz .'_LV-'. $lehrveranstaltung_id. '_'. $fullname;
+ }
+
+ public function LVhasLector($anrechnung_id)
+ {
+ $result = $this->ci->AnrechnungModel->load($anrechnung_id);
+ if (!hasData($result))
+ {
+ showError('Anrechnung existiert nicht');
+ }
+
+ // Get lectors of lehrveranstaltung
+ $result = $this->ci->LehrveranstaltungModel->getLecturersByLv(
+ $result->retval[0]->studiensemester_kurzbz,
+ $result->retval[0]->lehrveranstaltung_id
+ );
+
+ // Continue, if LV has no lector (there is no one to ask for recommendation)
+ return hasData($result) ? true : false;
+ }
+
+ /**
+ * Get LV Leitung. If not present, get all LV lectors.
+ *
+ * @param $anrechnung_id
+ * @return array|bool
+ */
+ public function getLectors($anrechnung_id)
+ {
+ $this->ci->AnrechnungModel->addSelect('lehrveranstaltung_id, studiensemester_kurzbz');
+ $result = $this->ci->AnrechnungModel->load($anrechnung_id);
+
+ if (!hasData($result))
+ {
+ return false;
+ }
+
+ $lehrveranstaltung_id = getData($result)[0]->lehrveranstaltung_id;
+ $studiensemester_kurzbz = getData($result)[0]->studiensemester_kurzbz;
+
+ // Get lectors
+ $lector_arr = array();
+
+ $this->ci->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
+ $result = $this->ci->LehrveranstaltungModel->getLecturersByLv($studiensemester_kurzbz, $lehrveranstaltung_id);
+
+ if (!$result = getData($result))
+ {
+ return false;
+ }
+
+ // Check if lv has LV-Leitung
+ $key = array_search(true, array_column($result, 'lvleiter'));
+
+ // If lv has LV-Leitung, keep only the one
+ if ($key !== false)
+ {
+ $lector_arr[]= $result[$key];
+ }
+ // ...otherwise keep all lectors
+ else
+ {
+ $lector_arr = array_merge($lector_arr, $result);
+ }
+
+ /**
+ * 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.
+ * But we wish to send only one email by to that one person)
+ * **/
+ foreach ($lector_arr as $lector)
+ {
+ unset($lector->lvleiter);
+ $lector->fullname = $lector->vorname. ' '. $lector->nachname;
+ }
+
+ // Now make the lector array aka mail receivers unique
+ $lector_arr = array_unique($lector_arr, SORT_REGULAR);
+
+ return $lector_arr;
}
// Return an object with Anrechnungdata
@@ -631,12 +818,7 @@ class AnrechnungLib
$this->ci->DmsVersionModel->addSelect('name');
$result = $this->ci->DmsVersionModel->loadWhere(array('dms_id' => $anrechnung->dms_id));
- if (isError($result))
- {
- show_error(getError($result));
- }
-
- $anrechnung_data->dokumentname = $result->retval[0]->name;
+ $anrechnung_data->dokumentname = hasData($result) ? getData($result)[0]->name : '';
return $anrechnung_data;
}
diff --git a/application/libraries/DmsLib.php b/application/libraries/DmsLib.php
index da0dd84b6..eae1a9ac4 100644
--- a/application/libraries/DmsLib.php
+++ b/application/libraries/DmsLib.php
@@ -2,11 +2,10 @@
if (! defined('BASEPATH')) exit('No direct script access allowed');
-class DmsLib
+class DmsLib extends FHC_Controller
{
const FILE_CONTENT_PROPERTY = 'file_content';
-
- const FILE_INPUT_NAME = 'uploadfile'; // name of the HTML input tag containing the uploaded file
+
private $UPLOAD_PATH = DMS_PATH; // temporary directory to store the upload file
/**
@@ -21,6 +20,34 @@ class DmsLib
$this->ci->load->model('content/DmsVersion_model', 'DmsVersionModel');
$this->ci->load->model('content/DmsFS_model', 'DmsFSModel');
}
+
+ /**
+ * Load a DMS Document.
+ * If no version is particularly given, the latest version is loaded.
+ *
+ * @param $dms_id
+ * @param integer $version
+ * @return array
+ */
+ public function load($dms_id, $version = null)
+ {
+ 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);
+
+ if (!is_numeric($version))
+ {
+ return $this->ci->DmsModel->load($dms_id);
+ }
+ else
+ {
+ return $this->ci->DmsModel->loadWhere(array('dms_id' => $dms_id, 'version' => $version));
+ }
+ }
+ return error('The parameter DMS ID must be a number');
+ }
/**
* Read a DMS Document from the Filesystem
@@ -95,19 +122,20 @@ class DmsLib
return $result;
}
-
+
/**
* Uploads a document and saves it to DMS
* @param $dms DMS assoc array
- * @param array $allowed_types Default: all. Param example: array(jpg, pdf)
+ * @param $field_name Name of the HTML uploadfile input name attribute
+ * @param array $allowed_types Default: all. Param example: array(jpg, pdf)
* @return array
*/
- public function upload($dms, $allowed_types = array('*'))
+ public function upload($dms, $field_name, $allowed_types = array('*'))
{
// Init upload configs
$this->_loadUploadLibrary($allowed_types);
- if (!$this->ci->upload->do_upload(DmsLib::FILE_INPUT_NAME))
+ if (!$this->ci->upload->do_upload($field_name))
{
return error($this->ci->upload->display_errors());
}
@@ -132,46 +160,80 @@ class DmsLib
// return result of uploaded data
return success($upload_data); // data about the uploaded file
}
-
+
/**
- * Download a document
+ * Download a document.
+ *
* @param $dms_id
+ * @param string $filename $filename If String is given, it will be used as filename on download
+ * @param string $disposition [inline | attachment]
+ * Inline opens doc in new tab. Attachment displays download dialog box.
*/
- public function download($dms_id)
+ public function download($dms_id, $filename = null, $disposition = 'inline')
{
- if (!is_numeric($dms_id))
- {
- show_error('Wrong parameter');
- }
-
- $this->ci->DmsVersionModel->addSelect('filename');
- $result = $this->ci->DmsVersionModel->loadWhere(array('dms_id' => $dms_id));
-
+ $result = $this->getFileInfo($dms_id);
+
if (isError($result))
{
- show_error(getError($result));
+ return error(getError($result));
}
- $filename = $result->retval[0]->filename;
- $file = DMS_PATH. $filename;
-
- if (file_exists($file))
+ $fileObj = getData($result);
+
+ // Change filename, if filename is provided
+ if (is_string($filename))
{
- $finfo = new finfo(FILEINFO_MIME);
-
- header('Content-Description: File Transfer');
- header('Content-Type: '.$finfo->file($file));
- header('Expires: 0');
- header('Cache-Control: must-revalidate');
- header('Pragma: public');
- header('Content-Length: ' . filesize($file));
- readfile($file);
- exit;
+ $fileObj->name = $filename;
+ }
+
+ // Add file disposition
+ if ($disposition == 'attachment')
+ {
+ $fileObj->disposition = 'attachment';
}
else
{
- show_error('File does not exist');
+ $fileObj->disposition = 'inline';
}
+
+ // Output file
+ if(!$this->outputFile($fileObj))
+ {
+ return error('Error on file output');
+ }
+ }
+
+ /**
+ * Get file information.
+ *
+ * @param $dms_id
+ * @param integer $version
+ * @return array with File Object.
+ */
+ public function getFileInfo($dms_id, $version = null)
+ {
+ if (!is_numeric($dms_id))
+ {
+ return error('Wrong parameter');
+ }
+
+ // Load file
+ $result = $this->load($dms_id, $version);
+
+ if (isError($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 users filename
+ $fileObj->mimetype = DMS_PATH. getData($result)[0]->mimetype;
+
+ return success($fileObj);
+
}
/**
diff --git a/application/libraries/FilterWidgetLib.php b/application/libraries/FilterWidgetLib.php
index 0a4526680..cdf0cac3c 100644
--- a/application/libraries/FilterWidgetLib.php
+++ b/application/libraries/FilterWidgetLib.php
@@ -266,6 +266,7 @@ class FilterWidgetLib
$whereParameters = array(
'app' => $app,
'dataset_name' => $datasetName,
+ 'person_id' => null,
'default_filter' => true
);
@@ -738,8 +739,10 @@ class FilterWidgetLib
$this->_ci->load->model('system/Filters_model', 'FiltersModel');
// Loads all the filters related to this page (same dataset_name and same app name)
- $filters = $this->_ci->FiltersModel->getFiltersByAppDatasetName(
- $session[self::APP], $session[self::DATASET_NAME]
+ $filters = $this->_ci->FiltersModel->getFiltersByAppDatasetNamePersonId(
+ $session[self::APP],
+ $session[self::DATASET_NAME],
+ getAuthPersonId()
);
// If filters were loaded
@@ -813,9 +816,6 @@ class FilterWidgetLib
}
}
- //------------------------------------------------------------------------------------------------------------------
- // Private methods
-
/**
* Return an unique string that identify this filter widget
* NOTE: The default value is the URI where the FilterWidget is called
@@ -857,6 +857,9 @@ class FilterWidgetLib
$this->_filterUniqueId = $filterUniqueId;
}
+ //------------------------------------------------------------------------------------------------------------------
+ // Private methods
+
/**
* Generates a condition for a SQL where clause using the given applied filter definition.
* By default an empty string is returned.
@@ -972,3 +975,4 @@ class FilterWidgetLib
return $pos;
}
}
+
diff --git a/application/libraries/IssuesLib.php b/application/libraries/IssuesLib.php
new file mode 100644
index 000000000..1b06db333
--- /dev/null
+++ b/application/libraries/IssuesLib.php
@@ -0,0 +1,244 @@
+_ci =& get_instance();
+
+ // Properties default values
+ $this->_app = 'core';
+ $this->_insertvon = 'system';
+ $this->_fallbackFehlercode = 'UNKNOWN_ERROR';
+
+ // If parameters are given then overwrite the default values
+ if (!isEmptyArray($params)) $this->setConfigs($params);
+
+ // load models
+ $this->_ci->load->model('system/Issue_model', 'IssueModel');
+ $this->_ci->load->model('system/Fehler_model', 'FehlerModel');
+ }
+
+ // --------------------------------------------------------------------------------------------------------------
+ // Public methods
+
+ /**
+ * Store configuration parameters for this lib
+ */
+ public function setConfigs($params)
+ {
+ // If parameters are given then overwrite the default values
+ if (!isEmptyArray($params))
+ {
+ if (isset($params[self::APP_INDEX])) $this->_app = $params[self::APP_INDEX];
+ if (isset($params[self::INSERTVON_INDEX])) $this->_insertvon = $params[self::INSERTVON_INDEX];
+ if (isset($params[self::FALLBACK_FEHLERCODE_INDEX])) $this->_fallbackFehlercode = $params[self::FALLBACK_FEHLERCODE_INDEX];
+ }
+ }
+
+ /**
+ * Adds an Fhc issue, i.e. an internal, self-defined issue.
+ * @param string $fehler_kurzbz short unique text name of the issue
+ * @param int $person_id
+ * @param string $oe_kurzbz
+ * @param array $fehlertext_params params for sprint replace of error text in system.tbl_fehler
+ * @return object success or error
+ */
+ public function addFhcIssue($fehler_kurzbz, $person_id = null, $oe_kurzbz = null, $fehlertext_params = null)
+ {
+ $fehlerRes = $this->_ci->FehlerModel->loadWhere(array('fehler_kurzbz' => $fehler_kurzbz));
+
+ if (hasData($fehlerRes))
+ {
+ $fehlercode = getData($fehlerRes)[0]->fehlercode;
+ return $this->_addIssue($fehlercode, $person_id, $oe_kurzbz, $fehlertext_params);
+ }
+ else
+ return error("Fehler $fehler_kurzbz nicht gefunden");
+ }
+
+ /**
+ * Adds an external issue, already defined externally by another system.
+ * @param string $fehlercode_extern the error code in the external system
+ * @param string $inhalt_extern error text in external system
+ * @param int $person_id
+ * @param int $oe_kurzbz
+ * @param array $fehlertext_params params for replacement of parts of error text
+ * @param bool $force_predefined if true, only predefined external issues are added
+ * @return object success or error
+ */
+ public function addExternalIssue($fehlercode_extern, $inhalt_extern, $person_id = null, $oe_kurzbz = null, $fehlertext_params = null, $force_predefined = false)
+ {
+ if (isEmptyString($fehlercode_extern))
+ return error("fehlercode_extern fehlt");
+
+ // get external fehlercode (unique for each app)
+ $this->_ci->FehlerModel->addSelect('fehlercode');
+ $fehlerRes = $this->_ci->FehlerModel->loadWhere(
+ array(
+ 'fehlercode_extern' => $fehlercode_extern,
+ 'app' => $this->_app
+ )
+ );
+
+ if (isError($fehlerRes))
+ return $fehlerRes;
+
+ $fehlerData = getData($fehlerRes)[0];
+
+ // check if there is a predefined custom error for the external issue
+ if (hasData($fehlerRes))
+ {
+ // if found, use the code
+ $fehlercode = $fehlerData->fehlercode;
+ }
+ elseif ($force_predefined === true)
+ {
+ // only added if predefined
+ return success("No definition found - not added");
+ }
+ else
+ {
+ // if predefined error is not found, insert with fallback code
+ $fehlercode = $this->_fallbackFehlercode;
+ }
+
+ // add external issue
+ return $this->_addIssue($fehlercode, $person_id, $oe_kurzbz, $fehlertext_params, $fehlercode_extern, $inhalt_extern);
+ }
+
+ /**
+ * Changes status of an issue.
+ * @param int $issue_id
+ * @param string $status_kurzbz the new status
+ * @param string $verarbeitetvon uid of person changing the status (needed for in Bearbeitung and behoben)
+ * @return success or error
+ */
+ public function changeIssueStatus($issue_id, $status_kurzbz, $verarbeitetvon = null)
+ {
+ if (!isset($issue_id) || !is_numeric($issue_id))
+ return error("Issue Id muss korrekt gesetzt sein.");
+
+ // check if given status is same as existing
+ $this->_ci->IssueModel->addSelect('status_kurzbz');
+ $currStatus = $this->_ci->IssueModel->load($issue_id);
+
+ if (hasData($currStatus))
+ {
+ if (getData($currStatus)[0]->status_kurzbz == $status_kurzbz)
+ return success("Gleicher Status bereits gesetzt");
+ }
+ else
+ return error("Fehler beim Holen des Status");
+
+ $data = array(
+ 'status_kurzbz' => $status_kurzbz,
+ 'updatevon' => $verarbeitetvon,
+ 'updateamum' => date('Y-m-d H:i:s')
+ );
+
+ if ($status_kurzbz == self::STATUS_NEU)
+ {
+
+ $data['verarbeitetvon'] = null;
+ }
+
+ if ($status_kurzbz == self::STATUS_NEU || $status_kurzbz == self::STATUS_IN_BEARBEITUNG)
+ {
+ $data['verarbeitetamum'] = null;
+ }
+
+ if ($status_kurzbz == self::STATUS_IN_BEARBEITUNG || $status_kurzbz == self::STATUS_BEHOBEN)
+ {
+ if (isset($verarbeitetvon))
+ $data['verarbeitetvon'] = $verarbeitetvon;
+ else
+ return error("Verarbeitetvon nicht gesetzt");
+ }
+
+ if ($status_kurzbz == self::STATUS_BEHOBEN)
+ $data['verarbeitetamum'] = date('Y-m-d H:i:s');
+
+ return $this->_ci->IssueModel->update(
+ array(
+ 'issue_id' => $issue_id
+ ),
+ $data
+ );
+ }
+
+ /**
+ * Adds an issue.
+ * @param $fehlercode
+ * @param int $person_id
+ * @param string $oe_kurzbz
+ * @param array $fehlertext_params
+ * @param string $fehlercode_extern
+ * @param string $inhalt_extern
+ * @return object success or error
+ */
+ private function _addIssue($fehlercode, $person_id = null, $oe_kurzbz = null, $fehlertext_params = null, $fehlercode_extern = null, $inhalt_extern = null)
+ {
+ if (isEmptyString($person_id) && isEmptyString($oe_kurzbz))
+ return error("Person_id oder oe_kurzbz muss gesetzt sein.");
+
+ // get fehlertextVorlage and replace it with params
+ $fehlerRes = $this->_ci->FehlerModel->load($fehlercode);
+
+ if (hasData($fehlerRes))
+ {
+ $fehlertextVorlage = getData($fehlerRes)[0]->fehlertext;
+ $fehlertext = isEmptyArray($fehlertext_params) ? $fehlertextVorlage : vsprintf($fehlertextVorlage, $fehlertext_params);
+
+ $openIssuesCountRes = $this->_ci->IssueModel->getOpenIssueCount($fehlercode, $person_id, $oe_kurzbz, $fehlercode_extern);
+
+ if (hasData($openIssuesCountRes))
+ {
+ // don't insert if issue is already open
+ // already open - status new with same fehlercode or same fehlercode-extern (if set)
+ $openIssueCount = getData($openIssuesCountRes)[0]->anzahl_open_issues;
+
+ if ($openIssueCount == 0)
+ {
+ return $this->_ci->IssueModel->insert(
+ array(
+ 'fehlercode' => $fehlercode,
+ 'fehlercode_extern' => $fehlercode_extern,
+ 'inhalt' => $fehlertext,
+ 'inhalt_extern' => $inhalt_extern,
+ 'person_id' => $person_id,
+ 'oe_kurzbz' => $oe_kurzbz,
+ 'datum' => date('Y-m-d H:i:s'),
+ 'status_kurzbz' => self::STATUS_NEU,
+ 'insertvon' => $this->_insertvon
+ )
+ );
+ }
+ else
+ return success($openIssueCount);
+ }
+ else
+ return error("Anzahl offener Issues konnte nicht ermittelt werden.");
+ }
+ else
+ return error("Fehler $fehlercode nicht gefunden");
+ }
+}
diff --git a/application/libraries/JobsQueueLib.php b/application/libraries/JobsQueueLib.php
index d264f7119..5871a3767 100644
--- a/application/libraries/JobsQueueLib.php
+++ b/application/libraries/JobsQueueLib.php
@@ -72,6 +72,18 @@ class JobsQueueLib
return $this->_ci->JobsQueueModel->loadWhere(array('status' => self::STATUS_NEW, 'type' => $type));
}
+ /**
+ * To get all the jobs specified by the given parameters
+ */
+ public function getJobsByTypeStatus($type, $status)
+ {
+ $this->_ci->JobsQueueModel->resetQuery();
+
+ $this->_ci->JobsQueueModel->addOrder('creationtime', 'DESC');
+
+ return $this->_ci->JobsQueueModel->loadWhere(array('status' => $status, 'type' => $type));
+ }
+
/**
* To get all the jobs specified by the given parameters
*/
diff --git a/application/libraries/UDFLib.php b/application/libraries/UDFLib.php
index f9ad7d20d..827bdc989 100644
--- a/application/libraries/UDFLib.php
+++ b/application/libraries/UDFLib.php
@@ -30,13 +30,14 @@ class UDFLib
// ...to specify permissions that are needed to use this TableWidget
const REQUIRED_PERMISSIONS_PARAMETER = 'requiredPermissions';
+ const PERMISSION_TABLE_METHOD = 'UDFWidget'; // Name for fake method to be checked by the PermissionLib
+ const PERMISSION_TYPE_READ = 'r';
+ const PERMISSION_TYPE_WRITE = 'w';
+
// ...to specify the primary key name and value
const PRIMARY_KEY_NAME = 'primaryKeyName';
const PRIMARY_KEY_VALUE = 'primaryKeyValue';
- const PERMISSION_TABLE_METHOD = 'UDFWidget'; // Name for fake method to be checked by the PermissionLib
- const PERMISSION_TYPE = 'rw';
-
// HTML components
const LABEL = 'title';
const TITLE = 'description';
@@ -76,10 +77,10 @@ class UDFLib
// Public methods
/**
- * UDFWidget
- */
- public function UDFWidget($args, $htmlArgs = array())
- {
+ * UDFWidget
+ */
+ public function UDFWidget($args, $htmlArgs = array())
+ {
if ((isset($args[self::SCHEMA_ARG_NAME]) && !isEmptyString($args[self::SCHEMA_ARG_NAME]))
&& (isset($args[self::TABLE_ARG_NAME]) && !isEmptyString($args[self::TABLE_ARG_NAME])))
{
@@ -112,16 +113,17 @@ class UDFLib
show_error(self::TABLE_ARG_NAME.' parameter is missing!');
}
}
- }
+ }
- /**
+ /**
* It renders the HTML of the UDF
*
* NOTE: When this method is called $widgetData contains different data from
* parameter $args in the constructor
*/
- public function displayUDFWidget(&$widgetData)
+ public function displayUDFWidget(&$widgetData)
{
+ $field = null;
$schema = $widgetData[self::SCHEMA_ARG_NAME]; // schema attribute
$table = $widgetData[self::TABLE_ARG_NAME]; // table attribute
@@ -133,7 +135,7 @@ class UDFLib
$udfResults = $this->_loadUDF($schema, $table); // loads UDF definition
if (hasData($udfResults))
{
- $udf = $udfResults->retval[0]; // only one record is loaded
+ $udf = getData($udfResults)[0]; // only one record is loaded
if (isset($udf->jsons))
{
$jsonSchemas = json_decode($udf->jsons); // decode the json schema
@@ -155,7 +157,7 @@ class UDFLib
$found = false; // used to check if the field is found or not in the json schema
$this->_sortJsonSchemas($jsonSchemasArray); // Sort the list of UDF by sort property
-
+
// Loops through json schemas
foreach ($jsonSchemasArray as $jsonSchema)
{
@@ -169,21 +171,37 @@ class UDFLib
{
show_error(sprintf('%s.%s: Attribute "name" not present in the json schema', $schema, $table));
}
+ // If the requiredPermissions property is not present then show an error
+ if (!isset($jsonSchema->{self::REQUIRED_PERMISSIONS_PARAMETER}))
+ {
+ show_error(sprintf('%s.%s: Attribute "requiredPermissions" not present in the json schema', $schema, $table));
+ }
+
+ // Set the required permissions for this UDF
+ $this->_setRequiredPermissions($jsonSchema->{self::NAME}, $jsonSchema->{self::REQUIRED_PERMISSIONS_PARAMETER});
// If a UDF is specified and is present in the json schemas list or no UDF is specified
if ((isset($field) && $field == $jsonSchema->{self::NAME}) || !isset($field))
{
- // Set attributes using phrases
- $this->_setAttributesWithPhrases($jsonSchema, $widgetData[HTMLWidget::HTML_ARG_NAME]);
+ // If the user has the permissions to read this field
+ if ($this->_readAllowed($jsonSchema->{self::REQUIRED_PERMISSIONS_PARAMETER}))
+ {
+ // Set attributes using phrases
+ $this->_setAttributesWithPhrases($jsonSchema, $widgetData[HTMLWidget::HTML_ARG_NAME]);
- // Set validation attributes
- $this->_setValidationAttributes($jsonSchema, $widgetData[HTMLWidget::HTML_ARG_NAME]);
+ // Set validation attributes
+ $this->_setValidationAttributes($jsonSchema, $widgetData[HTMLWidget::HTML_ARG_NAME]);
- // Set name and id attributes
- $this->_setNameAndId($jsonSchema, $widgetData[HTMLWidget::HTML_ARG_NAME]);
+ // Set name and id attributes
+ $this->_setNameAndId($jsonSchema, $widgetData[HTMLWidget::HTML_ARG_NAME]);
- // Render the HTML for this UDF
- $this->_render($jsonSchema, $widgetData);
+ // Set if the field is in read only mode
+ $this->_setReadOnly($jsonSchema, $widgetData[HTMLWidget::HTML_ARG_NAME]);
+
+ // Render the HTML for this UDF
+ $this->_render($jsonSchema, $widgetData);
+ }
+ // otherwise the UDF is not displayed
// If a UDf is specified and it was found then stop looking through this list
if (isset($field) && $field == $jsonSchema->{self::NAME})
@@ -213,12 +231,97 @@ class UDFLib
show_error(sprintf('%s.%s: Does not contain "jsons" field', $schema, $table));
}
}
- }
+ }
/**
- * Manage UDFs
+ * UDFs permissions check and convertion to read them from database
*/
- public function manageUDFs(&$data, $schemaAndTable, $udfValues = null)
+ public function prepareUDFsRead(&$data, $schemaAndTable, $udfValues = null)
+ {
+ $this->_ci->load->model('system/UDF_model', 'UDFModel');
+
+ // Retrieves UDFs definitions for this table
+ $resultUDFsDefinitions = $this->_ci->UDFModel->getUDFsDefinitions($schemaAndTable);
+
+ // If an error occurred while reading from database
+ if (isError($resultUDFsDefinitions))
+ {
+ $data = array(); // then set data as an empty array
+ return; // and exit from this method
+ }
+
+ // If there are no UDFs defined for this table the return
+ if (!hasData($resultUDFsDefinitions)) return;
+
+ // If not an error and has data, decodes json that define the UDFs for this table
+ $decodedUDFDefinitions = json_decode(
+ getData($resultUDFsDefinitions)[0]->{self::COLUMN_JSON_DESCRIPTION}
+ );
+
+ // Looping on results, resultElement is an object that represent a database record
+ foreach ($data as $resultElement)
+ {
+ // Decode the JSON column udf_values
+ $udfColumn = json_decode($resultElement->{self::COLUMN_NAME});
+
+ // If this is not a valid JSON then skip to the next database record
+ if ($udfColumn == null) continue;
+
+ // For each UDF column of this database record
+ foreach (get_object_vars($udfColumn) as $columnName => $columnValue)
+ {
+ $udfColumnToBeRemoved = $columnName; // let's try to remove it
+
+ // Loops through the UDFs definitions
+ foreach ($decodedUDFDefinitions as $decodedUDFDefinition)
+ {
+ // If the column exists in the UDF definition
+ if ($columnName == $decodedUDFDefinition->{self::NAME})
+ {
+ $udfColumnToBeRemoved = null; // then keep it
+ }
+ }
+
+ // If in this record have been found a _not_ defined UDF then remove it
+ if (!isEmptyString($udfColumnToBeRemoved)) unset($udfColumn->{$udfColumnToBeRemoved});
+ }
+
+ // Loops through the UDFs definitions
+ foreach ($decodedUDFDefinitions as $decodedUDFDefinition)
+ {
+ // Checks if the requiredPermissions is available and it is a valid array or a valid string
+ if (isset($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})
+ && (!isEmptyArray($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})
+ || !isEmptyString($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})))
+ {
+ // Then check if the user has the permissions to read such UDF
+ if (!$this->_readAllowed($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER}))
+ {
+ // If not then remove the UDF from the result set
+ unset($udfColumn->{$decodedUDFDefinition->{self::NAME}});
+ }
+ }
+ else // If not then remove the UDF from the result set
+ {
+ unset($udfColumn->{$decodedUDFDefinition->{self::NAME}});
+ }
+ }
+
+ // Add the defined and permitted UDF columns to the record set
+ foreach (get_object_vars($udfColumn) as $columnName => $columnValue)
+ {
+ $resultElement->{$columnName} = $columnValue;
+ }
+ }
+
+ // And finally remove the UDFs column
+ unset($resultElement->{self::COLUMN_NAME});
+ }
+
+ /**
+ * UDFs validation and permissions check to write them into database
+ */
+ public function prepareUDFsWrite(&$data, $schemaAndTable, $udfValues = null)
{
$validate = success(true); // returned value
// Contains a list of validation errors for the UDFs that have not passed the validation
@@ -241,18 +344,34 @@ class UDFLib
// Decodes json that define the UDFs for this table
$decodedUDFDefinitions = json_decode(
- $resultUDFsDefinitions->retval[0]->{self::COLUMN_JSON_DESCRIPTION}
+ getData($resultUDFsDefinitions)[0]->{self::COLUMN_JSON_DESCRIPTION}
);
// Loops through the UDFs definitions
- for ($i = 0; $i < count($decodedUDFDefinitions); $i++)
+ foreach ($decodedUDFDefinitions as $decodedUDFDefinition)
{
- $decodedUDFDefinition = $decodedUDFDefinitions[$i]; // Definition of a single UDF
+ // Checks if the requiredPermissions is available and it is a valid array or a valid string
+ if (isset($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})
+ && (!isEmptyArray($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})
+ || !isEmptyString($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})))
+ {
+ // Then check if the user has the permissions to write such UDF
+ if (!$this->_writeAllowed($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER}))
+ {
+ // If the logged user has no permissions then remove the UDF
+ unset($udfsParameters[$decodedUDFDefinition->{self::NAME}]);
+ }
+ }
+ else
+ {
+ // If no permissions have been defined for this UDF then remove it
+ unset($udfsParameters[$decodedUDFDefinition->{self::NAME}]);
+ }
// Loops through the UDFs values that should be stored
foreach ($udfsParameters as $key => $val)
{
- $tmpValidate = success(true); // temporary variable used to store the returned value from _validateUDFs
+ $tmpValidateArray = array(); // temporary variable used to store the returned value from _validateUDFs
// If this is the definition of this UDF
if ($decodedUDFDefinition->{self::NAME} == $key)
@@ -314,7 +433,7 @@ class UDFLib
if ($toBeValidated === true) // Checks if validation should be performed
{
- $tmpValidate = $this->_validateUDFs(
+ $tmpValidateArray = $this->_validateUDFs(
$decodedUDFDefinition->{self::VALIDATION},
$decodedUDFDefinition->{self::NAME},
$val
@@ -324,13 +443,13 @@ class UDFLib
}
// If validation is ok copy the value that is to be stored into $toBeStoredUDFsArray
- if (isSuccess($tmpValidate))
+ if (isEmptyArray($tmpValidateArray))
{
$toBeStoredUDFsArray[$key] = $val;
}
- else // otherwise store the validation error in $notValidUDFsArray
+ else // otherwise store the validation errors in $notValidUDFsArray
{
- $notValidUDFsArray[] = $tmpValidate;
+ $notValidUDFsArray = array_merge($notValidUDFsArray, $tmpValidateArray);
}
}
}
@@ -344,11 +463,11 @@ class UDFLib
}
// If the validation of all the supplied UDFs is ok
- if (count($notValidUDFsArray) == 0)
+ if (isEmptyArray($notValidUDFsArray))
{
// An update is performed, then in this case it preserves the values
// of the UDF that are not updated
- if (is_array($udfValues) && count($udfValues) > 0)
+ if (!isEmptyArray($udfValues))
{
foreach ($udfValues as $fieldName => $fieldValue)
{
@@ -379,7 +498,7 @@ class UDFLib
/**
* isUDFColumn
*/
- public function isUDFColumn($columnName, $columnType)
+ public function isUDFColumn($columnName, $columnType = self::COLUMN_TYPE)
{
$isUDFColumn = false;
@@ -466,7 +585,7 @@ class UDFLib
/**
* Save UDFs
*/
- public function saveUDFs($udfUniqueId, $udfs)
+ public function saveUDFs($udfs)
{
// Read the all session for this udf widget
$session = $this->getSession();
@@ -490,30 +609,80 @@ class UDFLib
// Returns the result of the database update operation to save UDFs
return $dbModel->update(
array($session[self::PRIMARY_KEY_NAME] => $session[self::PRIMARY_KEY_VALUE]),
- (array)$udfs
+ get_object_vars($udfs)
);
}
- /**
- * Checks if at least one of the permissions given as parameter (requiredPermissions) belongs
- * to the authenticated user, if confirmed then is allowed to use this UDFWidget.
- * If the parameter requiredPermissions is NOT given or is not present in the session,
- * then NO one is allow to use this UDFWidget
- * Wrapper method to permissionlib->hasAtLeastOne
- */
- public function isAllowed($requiredPermissions = null)
- {
- $this->_ci->load->library('PermissionLib'); // Load permission library
-
- // Gets the required permissions from the session if they are not provided as parameter
- $rq = $requiredPermissions;
- if ($rq == null) $rq = $this->getSessionElement(self::REQUIRED_PERMISSIONS_PARAMETER);
-
- return $this->_ci->permissionlib->hasAtLeastOne($rq, self::PERMISSION_TABLE_METHOD, self::PERMISSION_TYPE);
- }
-
// -------------------------------------------------------------------------------------------------
// Private methods
+ //
+
+ /**
+ * Checks if at least one of the permissions given as parameter belongs to the authenticated user in read mode
+ * Wrapper method to permissionlib->hasAtLeastOne
+ */
+ private function _readAllowed($requiredPermissions)
+ {
+ $readAllowed = false;
+
+ // If the user is logged then it is possible to check the permissions
+ if (isLogged())
+ {
+ $this->_ci->load->library('PermissionLib'); // Load permission library
+
+ $readAllowed = $this->_ci->permissionlib->hasAtLeastOne(
+ $requiredPermissions,
+ self::PERMISSION_TABLE_METHOD,
+ self::PERMISSION_TYPE_READ
+ );
+ } // otherwise it is not possible to check the permissions
+
+ return $readAllowed;
+ }
+
+ /**
+ * Checks if at least one of the permissions given as parameter belongs to the authenticated user in write mode
+ * Wrapper method to permissionlib->hasAtLeastOne
+ */
+ private function _writeAllowed($requiredPermissions)
+ {
+ $writeAllowed = false;
+
+ // If the user is logged then it is possible to check the permissions
+ if (isLogged())
+ {
+ $this->_ci->load->library('PermissionLib'); // Load permission library
+
+ $writeAllowed = $this->_ci->permissionlib->hasAtLeastOne(
+ $requiredPermissions,
+ self::PERMISSION_TABLE_METHOD,
+ self::PERMISSION_TYPE_WRITE
+ );
+ } // otherwise it is not possible to check the permissions
+
+ return $writeAllowed;
+ }
+
+ /**
+ * Set an array of required permissions for a UDF into the session
+ */
+ private function _setRequiredPermissions($udfName, $permissions)
+ {
+ // Get the session for this UDFWidget
+ $session = $this->getSession();
+
+ // If does _not_ exist yet in the session
+ if (!isset($session[self::REQUIRED_PERMISSIONS_PARAMETER]))
+ {
+ $session[self::REQUIRED_PERMISSIONS_PARAMETER] = array();
+ }
+
+ // Set the required permission in the session for this UDFWidget
+ $session[self::REQUIRED_PERMISSIONS_PARAMETER][$udfName] = $permissions;
+
+ // Write into the session
+ $this->setSession($session);
+ }
/**
* Print the block for UDFs
@@ -544,12 +713,12 @@ class UDFLib
{
$udfsParameters = array();
- foreach ($data as $key => $val)
+ foreach ($data as $columnName => $columnValue)
{
- if (substr($key, 0, 4) == self::COLUMN_PREFIX)
+ if ($this->isUDFColumn($columnName))
{
- $udfsParameters[$key] = $val; // stores UDF value into property UDFs
- unset($data[$key]); // remove from data
+ $udfsParameters[$columnName] = $columnValue; // stores UDF value into property UDFs
+ unset($data[$columnName]); // remove from data
}
}
@@ -645,29 +814,39 @@ class UDFLib
}
}
- // If no UDF validation errors were raised, it's a success!!
- if (count($returnArrayValidation) == 0)
- {
- $returnArrayValidation = success(true);
- }
-
return $returnArrayValidation;
}
- /**
- * Set the name and id attribute of the HTML element
- */
- private function _setNameAndId($jsonSchema, &$htmlParameters)
- {
+ /**
+ * Disable the HTML element if in read only mode
+ */
+ private function _setReadOnly($jsonSchema, &$htmlParameters)
+ {
+ // If write permissions _not_ exist then set the field as disabled
+ if (!$this->_writeAllowed($jsonSchema->{self::REQUIRED_PERMISSIONS_PARAMETER}))
+ {
+ $htmlParameters[HTMLWidget::DISABLED] = HTMLWidget::DISABLED; // any values is fine
+ }
+ else // otherwise restore to default
+ {
+ if (isset($htmlParameters[HTMLWidget::DISABLED])) unset($htmlParameters[HTMLWidget::DISABLED]);
+ }
+ }
+
+ /**
+ * Set the name and id attribute of the HTML element
+ */
+ private function _setNameAndId($jsonSchema, &$htmlParameters)
+ {
$htmlParameters[HTMLWidget::HTML_ID] = $jsonSchema->{self::NAME};
$htmlParameters[HTMLWidget::HTML_NAME] = $jsonSchema->{self::NAME};
- }
-
- /**
- * Sort the list of UDF by sort property
- */
- private function _sortJsonSchemas(&$jsonSchemasArray)
- {
+ }
+
+ /**
+ * Sort the list of UDF by sort property
+ */
+ private function _sortJsonSchemas(&$jsonSchemasArray)
+ {
usort($jsonSchemasArray, function ($a, $b) {
if (!isset($a->{self::SORT}))
{
@@ -684,13 +863,13 @@ class UDFLib
return ($a->{self::SORT} < $b->{self::SORT}) ? -1 : 1;
});
- }
-
- /**
- * Loads the UDF description by the given schema and table
- */
- private function _loadUDF($schema, $table)
- {
+ }
+
+ /**
+ * Loads the UDF description by the given schema and table
+ */
+ private function _loadUDF($schema, $table)
+ {
// Loads UDF model
$this->_ci->load->model('system/UDF_model', 'UDFModel');
@@ -703,18 +882,7 @@ class UDFLib
if (isError($udfResults))
{
- if (is_object($udfResults) && isset($udfResults->retval))
- {
- show_error(getError($udfResults));
- }
- elseif (is_string($udfResults))
- {
- show_error($udfResults);
- }
- else
- {
- show_error('UDFWidget: generic error occurred');
- }
+ show_error(getError($udfResults));
}
elseif (!hasData($udfResults))
{
@@ -722,13 +890,13 @@ class UDFLib
}
return $udfResults;
- }
+ }
- /**
- * Render the HTML for the UDF
- */
- private function _render($jsonSchema, &$widgetData)
- {
+ /**
+ * Render the HTML for the UDF
+ */
+ private function _render($jsonSchema, &$widgetData)
+ {
// Checkbox
if ($jsonSchema->{self::TYPE} == 'checkbox')
{
@@ -759,11 +927,11 @@ class UDFLib
{
$this->_renderDropdown($jsonSchema, $widgetData, true);
}
- }
+ }
- /**
- * Renders a dropdown element
- */
+ /**
+ * Renders a dropdown element
+ */
private function _renderDropdown($jsonSchema, &$widgetData, $multiple = false)
{
// Selected element/s
@@ -792,7 +960,7 @@ class UDFLib
$queryResult = $this->_ci->UDFModel->execReadOnlyQuery($jsonSchema->{self::LIST_VALUES}->sql);
if (hasData($queryResult))
{
- $parameters = $queryResult->retval;
+ $parameters = getData($queryResult);
}
}
@@ -805,8 +973,8 @@ class UDFLib
}
/**
- * Renders a textarea element
- */
+ * Renders a textarea element
+ */
private function _renderTextarea($jsonSchema, &$widgetData)
{
$text = null; // text value
@@ -823,8 +991,8 @@ class UDFLib
}
/**
- * Renders an input text element
- */
+ * Renders an input text element
+ */
private function _renderTextfield($jsonSchema, &$widgetData)
{
$text = null; // text value
@@ -841,8 +1009,8 @@ class UDFLib
}
/**
- * Renders a checkbox element
- */
+ * Renders a checkbox element
+ */
private function _renderCheckbox($jsonSchema, &$widgetData)
{
// Set checkbox value if present in the DB
@@ -861,11 +1029,11 @@ class UDFLib
$checkboxWidgetUDF->render();
}
- /**
- * Sets the attributes of the HTML element using the phrases system
- */
- private function _setAttributesWithPhrases($jsonSchema, &$htmlParameters)
- {
+ /**
+ * Sets the attributes of the HTML element using the phrases system
+ */
+ private function _setAttributesWithPhrases($jsonSchema, &$htmlParameters)
+ {
// By default set to null all the attributes
$htmlParameters[HTMLWidget::LABEL] = null;
$htmlParameters[HTMLWidget::TITLE] = null;
@@ -893,7 +1061,7 @@ class UDFLib
);
if (hasData($tmpResult))
{
- $htmlParameters[HTMLWidget::LABEL] = $tmpResult->retval[0]->text;
+ $htmlParameters[HTMLWidget::LABEL] = getData($tmpResult)[0]->text;
}
}
@@ -911,7 +1079,7 @@ class UDFLib
);
if (hasData($tmpResult))
{
- $htmlParameters[HTMLWidget::TITLE] = $tmpResult->retval[0]->text;
+ $htmlParameters[HTMLWidget::TITLE] = getData($tmpResult)[0]->text;
}
}
@@ -929,17 +1097,17 @@ class UDFLib
);
if (hasData($tmpResult))
{
- $htmlParameters[HTMLWidget::PLACEHOLDER] = $tmpResult->retval[0]->text;
+ $htmlParameters[HTMLWidget::PLACEHOLDER] = getData($tmpResult)[0]->text;
}
}
}
- }
+ }
- /**
- * Sets the validation attributes of the HTML element using the configuration inside the json schema
- */
- private function _setValidationAttributes($jsonSchema, &$htmlParameters)
- {
+ /**
+ * Sets the validation attributes of the HTML element using the configuration inside the json schema
+ */
+ private function _setValidationAttributes($jsonSchema, &$htmlParameters)
+ {
// Validation attributes set by default to null
$htmlParameters[HTMLWidget::REGEX] = null;
$htmlParameters[HTMLWidget::REQUIRED] = null;
@@ -998,3 +1166,4 @@ class UDFLib
}
}
}
+
diff --git a/application/models/codex/Aufenthaltfoerderung_model.php b/application/models/codex/Aufenthaltfoerderung_model.php
new file mode 100644
index 000000000..b650b3a05
--- /dev/null
+++ b/application/models/codex/Aufenthaltfoerderung_model.php
@@ -0,0 +1,14 @@
+dbTable = 'bis.tbl_aufenthaltfoerderung';
+ $this->pk = 'aufenthaltfoerderung_code';
+ }
+}
diff --git a/application/models/codex/Oehbeitrag_model.php b/application/models/codex/Oehbeitrag_model.php
new file mode 100644
index 000000000..0df016ba8
--- /dev/null
+++ b/application/models/codex/Oehbeitrag_model.php
@@ -0,0 +1,107 @@
+dbTable = 'bis.tbl_oehbeitrag';
+ $this->pk = 'oehbeitrag_id';
+ }
+
+ /**
+ * Gets oehbeitrag data valid for a certain Studiensemester.
+ * @param string $studiensemester_kurzbz
+ * @return object
+ */
+ public function getByStudiensemester($studiensemester_kurzbz)
+ {
+ $qry = "WITH semstart AS (
+ SELECT start FROM public.tbl_studiensemester
+ WHERE studiensemester_kurzbz = ?
+ )
+ SELECT * FROM bis.tbl_oehbeitrag oehb
+ JOIN public.tbl_studiensemester semvon ON oehb.von_studiensemester_kurzbz = semvon.studiensemester_kurzbz
+ LEFT JOIN public.tbl_studiensemester sembis ON oehb.bis_studiensemester_kurzbz = sembis.studiensemester_kurzbz
+ JOIN semstart ON semstart.start::date >= semvon.start::date AND (sembis.studiensemester_kurzbz IS NULL OR semstart.start::date <= sembis.start::date)
+ ORDER BY semvon.start
+ LIMIT 1";
+
+ return $this->execQuery($qry, array($studiensemester_kurzbz));
+ }
+
+ /**
+ * Gets all Studiensemester for which no Oehbeitrag value assignment exists.
+ * @param string $start_studiensemester_kurzbz semester before the given semester are ignored
+ * @param array $excluded_oehbeitrag_id oehbeitraege to be ignored, i.e. which are assigned
+ * @return object
+ */
+ public function getUnassignedStudiensemester($start_studiensemester_kurzbz, $excluded_oehbeitrag_id = array())
+ {
+ $params = array($start_studiensemester_kurzbz);
+
+ $qry = "SELECT * FROM public.tbl_studiensemester sem
+ WHERE sem.start >= (SELECT start FROM public.tbl_studiensemester WHERE studiensemester_kurzbz = ?)
+ AND NOT EXISTS (SELECT 1 FROM bis.tbl_oehbeitrag oeh
+ JOIN public.tbl_studiensemester oeh_von ON oeh.von_studiensemester_kurzbz = oeh_von.studiensemester_kurzbz
+ LEFT JOIN public.tbl_studiensemester oeh_bis ON oeh.bis_studiensemester_kurzbz = oeh_bis.studiensemester_kurzbz
+ WHERE sem.start::date >= oeh_von.start::date AND (sem.start::date <= oeh_bis.start::date OR oeh_bis.studiensemester_kurzbz IS NULL)";
+
+ if (!isEmptyArray($excluded_oehbeitrag_id))
+ {
+ $qry .= " AND oehbeitrag_id NOT IN ?";
+ $params[] = $excluded_oehbeitrag_id;
+ }
+
+ $qry .= ") ORDER BY sem.start";
+
+ return $this->execQuery($qry, $params);
+ }
+
+ /**
+ * Checks if a Öhbeitrag can be assigned for a Studiensemester range.
+ * @param string $von_studiensemester_kurzbz
+ * @param string $bis_studiensemester_kurzbz
+ * @param array $excluded_oehbeitrag_id oehbeitraege to ignore, i.e. which are assignable
+ * @return object array with true if assignable, with false if not
+ */
+ public function checkIfStudiensemesterAssignable($von_studiensemester_kurzbz, $bis_studiensemester_kurzbz = null, $excluded_oehbeitrag_id = array())
+ {
+ $params = array($von_studiensemester_kurzbz);
+
+ $allStdSemSpanQry = "SELECT count(studiensemester_kurzbz) as number_assigned FROM public.tbl_studiensemester sem
+ WHERE start >= (SELECT start FROM public.tbl_studiensemester WHERE studiensemester_kurzbz = ?)";
+
+ if ($bis_studiensemester_kurzbz != null)
+ {
+ $allStdSemSpanQry .= " AND (start <= (SELECT start FROM public.tbl_studiensemester WHERE studiensemester_kurzbz = ?))";
+ $params[] = $bis_studiensemester_kurzbz;
+ }
+
+ $allStdSemSpanQry .= " AND EXISTS (SELECT 1 FROM bis.tbl_oehbeitrag
+ JOIN public.tbl_studiensemester sem_von ON tbl_oehbeitrag.von_studiensemester_kurzbz = sem_von.studiensemester_kurzbz
+ LEFT JOIN public.tbl_studiensemester sem_bis ON tbl_oehbeitrag.bis_studiensemester_kurzbz = sem_bis.studiensemester_kurzbz
+ WHERE sem.start >= sem_von.start AND (sem.start <= sem_bis.start OR sem_bis.studiensemester_kurzbz IS NULL)";
+
+ if (!isEmptyArray($excluded_oehbeitrag_id))
+ {
+ $allStdSemSpanQry .= " AND oehbeitrag_id NOT IN ?";
+ $params[] = $excluded_oehbeitrag_id;
+ }
+
+ $allStdSemSpanQry .= ")";
+
+ $nrAssigned = $this->execQuery($allStdSemSpanQry, $params);
+
+ if (isError($nrAssigned))
+ return $nrAssigned;
+
+ if (!hasData($nrAssigned))
+ return error("Fehler bei Überprüfung der Möglichkeit der Semesterzuweisung");
+
+ return success(array(getData($nrAssigned)[0]->number_assigned == 0));
+ }
+}
diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php
index 52ba4d9f3..4111e5f19 100644
--- a/application/models/crm/Prestudent_model.php
+++ b/application/models/crm/Prestudent_model.php
@@ -291,7 +291,7 @@ class Prestudent_model extends DB_Model
$prestudentdata->prestudentstatus = $lastStatusData;
- if ($this->hasUDF())
+ if ($this->udfsExistAndDefined())
{
$prestudentdata->prestudentUdfs = $this->getUDFs($prestudent_id);
}
@@ -581,6 +581,35 @@ class Prestudent_model extends DB_Model
return $this->execQuery($query, array($person_id));
}
+
+ /**
+ * Get latest ZGV Bezeichnung of Prestudent.
+ *
+ * @param $prestudent_id
+ */
+ public function getLatestZGVBezeichnung($prestudent_id)
+ {
+ if (!is_numeric($prestudent_id))
+ {
+ show_error('Prestudent_id is not numeric.');
+ }
+
+ $language_index = getUserLanguage() == 'German' ? 0 : 1;
+
+ $this->addSelect('
+ COALESCE(
+ array_to_json(zgvmaster.bezeichnung::varchar[])->>' . $language_index . ',
+ array_to_json(zgv.bezeichnung::varchar[])->>' . $language_index . '
+ ) AS bezeichnung'
+ );
+
+ $this->addJoin('bis.tbl_zgv zgv', 'zgv_code', 'LEFT');
+ $this->addJoin('bis.tbl_zgvmaster zgvmaster', 'zgvmas_code', 'LEFT');
+
+ return $this->loadWhere(array(
+ 'prestudent_id' => $prestudent_id
+ ));
+ }
public function getPrestudentByStudiengangAndPerson($studiengang, $person, $studienSemester)
{
@@ -596,4 +625,34 @@ class Prestudent_model extends DB_Model
return $this->execQuery($query, array($person, $studiengang, $studienSemester));
}
+
+ /**
+ * Gets förderrelevant flag for a prestudent, from prestudent, or, if not set on prestudent level, from studiengang
+ * @param int $prestudent_id
+ * @return object
+ */
+ public function getFoerderrelevant($prestudent_id)
+ {
+ $query = 'SELECT COALESCE (ps.foerderrelevant, stg.foerderrelevant) AS foerderrelevant
+ FROM public.tbl_prestudent ps
+ LEFT JOIN public.tbl_studiengang stg USING (studiengang_kz)
+ WHERE prestudent_id = ?';
+
+ return $this->execQuery($query, array($prestudent_id));
+ }
+
+ /**
+ * Gets bis standort_code for a prestudent, from prestudent, or, if not set on prestudent level, from studiengang
+ * @param int $prestudent_id
+ * @return object
+ */
+ public function getStandortCode($prestudent_id)
+ {
+ $query = 'SELECT COALESCE (ps.standort_code, stg.standort_code) AS standort_code
+ FROM public.tbl_prestudent ps
+ LEFT JOIN public.tbl_studiengang stg USING (studiengang_kz)
+ WHERE prestudent_id = ?';
+
+ return $this->execQuery($query, array($prestudent_id));
+ }
}
diff --git a/application/models/crm/Statusgrund_model.php b/application/models/crm/Statusgrund_model.php
index 7ab17a45b..d488e12d1 100644
--- a/application/models/crm/Statusgrund_model.php
+++ b/application/models/crm/Statusgrund_model.php
@@ -12,7 +12,7 @@ class Statusgrund_model extends DB_Model
$this->pk = "statusgrund_id";
}
- public function getStatus($status_kurzbz = null, $aktiv = null)
+ public function getStatus($status_kurzbz = null, $aktiv = null, $statusgrund_kurzbz = null)
{
$this->addOrder('bezeichnung_mehrsprachig');
$where = array();
@@ -20,6 +20,8 @@ class Statusgrund_model extends DB_Model
$where['status_kurzbz'] = $status_kurzbz;
if (!is_null($aktiv))
$where['aktiv'] = $aktiv;
+ if (!is_null($statusgrund_kurzbz))
+ $where['statusgrund_kurzbz'] = $statusgrund_kurzbz;
$status = $this->loadWhere($where);
diff --git a/application/models/education/Anrechnung_model.php b/application/models/education/Anrechnung_model.php
index b4c7de835..ebecf4118 100644
--- a/application/models/education/Anrechnung_model.php
+++ b/application/models/education/Anrechnung_model.php
@@ -1,7 +1,11 @@
pk = 'anrechnung_id';
}
+ /**
+ * Creates new Anrechnungsantrag.
+ * Saves new Anrechnung and sets Anrechnungstatus for the new Anrechnung.
+ *
+ * @param $prestudent_id
+ * @param $studiensemester_kurzbz
+ * @param $lehrveranstaltung_id
+ * @param $begruendung_id
+ * @param $dms_id DMS ID of uploaded Nachweisdokument
+ * @param null $anmerkung_student = Herkunft der Kenntnisse
+ * @return array
+ */
+ public function createAnrechnungsantrag(
+ $prestudent_id, $studiensemester_kurzbz, $lehrveranstaltung_id,
+ $begruendung_id, $dms_id, $anmerkung_student = null
+ )
+ {
+ // Start DB transaction
+ $this->db->trans_start(false);
+
+ // Save Anrechnung
+ $result = $this->AnrechnungModel->insert(array(
+ 'prestudent_id' => $prestudent_id,
+ 'lehrveranstaltung_id' => $lehrveranstaltung_id,
+ 'begruendung_id' => $begruendung_id,
+ 'dms_id' => $dms_id,
+ 'studiensemester_kurzbz' => $studiensemester_kurzbz,
+ 'anmerkung_student' => $anmerkung_student,
+ 'insertvon' => $this->_uid
+ ));
+
+ // Store just inserted Anrechnung ID
+ $lastInsert_anrechnung_id = $result->retval;
+
+ // Save Anrechnungstatus
+ $this->AnrechnungModel->saveAnrechnungstatus($lastInsert_anrechnung_id, self::ANRECHNUNGSTATUS_PROGRESSED_BY_STGL);
+
+ // Transaction complete
+ $this->db->trans_complete();
+
+ if ($this->db->trans_status() === false)
+ {
+ $this->db->trans_rollback();
+ return error('Failed inserting Anrechnung', EXIT_ERROR);
+ }
+
+ return success($lastInsert_anrechnung_id);
+ }
+
/**
* Save Anrechnungstatus.
* @param $anrechnung_id
@@ -83,4 +136,68 @@ class Anrechnung_model extends DB_Model
return $this->execQuery($qry, array($anrechnung_id));
}
+
+ /**
+ * Delete Anrechnungstatus.
+ *
+ * @param $anrechnungstatus_id
+ */
+ public function deleteAnrechnungstatus($anrechnungstatus_id){
+
+ $qry = '
+ DELETE FROM lehre.tbl_anrechnung_anrechnungstatus
+ WHERE anrechnungstatus_id = ?
+ ';
+
+ return $this->execQuery($qry, array($anrechnungstatus_id));
+ }
+
+ /**
+ * Delete last status approved / rejected.
+ * If last status is 'approved', Genehmigung is resetted.
+ *
+ * @param $anrechnung_id
+ * @return array
+ */
+ public function withdrawApprovement($anrechnung_id)
+ {
+ // Get last Anrechnungstatus
+ if (!$result = getData($this->AnrechnungModel->getLastAnrechnungstatus($anrechnung_id))[0])
+ {
+ return error('Failed loading Anrechnung');
+ }
+
+ $last_status = $result->status_kurzbz;
+ $anrechnungstatus_id = $result->anrechnungstatus_id;
+
+ // Exit, if last status is not approved / rejected
+ if ($last_status != self::ANRECHNUNGSTATUS_APPROVED && $last_status != self::ANRECHNUNGSTATUS_REJECTED)
+ {
+ return error('Nothing to withdraw. Application is still in progress');
+ }
+
+ // Start DB transaction
+ $this->db->trans_start(false);
+
+ // If Anrechnung was approved
+ if ($last_status == self::ANRECHNUNGSTATUS_APPROVED)
+ {
+ // Reset Genehmigung
+ $this->AnrechnungModel->update($anrechnung_id, array('genehmigt_von' => NULL));
+ }
+
+ // Delete last status approved / rejected
+ $this->AnrechnungModel->deleteAnrechnungstatus($anrechnungstatus_id);
+
+ // Transaction complete
+ $this->db->trans_complete();
+
+ if ($this->db->trans_status() === false)
+ {
+ $this->db->trans_rollback();
+ return error('Failed withdrawing Genehmigung', EXIT_ERROR);
+ }
+ return success();
+
+ }
}
diff --git a/application/models/education/Anrechnungbegruendung_model.php b/application/models/education/Anrechnungbegruendung_model.php
new file mode 100644
index 000000000..81f1ef614
--- /dev/null
+++ b/application/models/education/Anrechnungbegruendung_model.php
@@ -0,0 +1,15 @@
+dbTable = 'lehre.tbl_anrechnung_begruendung';
+ $this->pk = 'begruendung_id';
+ }
+}
diff --git a/application/models/education/Lehrveranstaltung_model.php b/application/models/education/Lehrveranstaltung_model.php
index ef5373f5f..8517d7f9d 100644
--- a/application/models/education/Lehrveranstaltung_model.php
+++ b/application/models/education/Lehrveranstaltung_model.php
@@ -169,18 +169,34 @@ class Lehrveranstaltung_model extends DB_Model
*/
public function getLecturersByLv($studiensemester_kurzbz, $lehrveranstaltung_id)
{
- $query = "SELECT * FROM (SELECT distinct on(uid) vorname, nachname, tbl_benutzer.uid as uid,
- CASE WHEN lehrfunktion_kurzbz='LV-Leitung' THEN true ELSE false END as lvleiter
- FROM lehre.tbl_lehreinheit, lehre.tbl_lehreinheitmitarbeiter, public.tbl_benutzer, public.tbl_person
- WHERE
- tbl_lehreinheit.lehreinheit_id=tbl_lehreinheitmitarbeiter.lehreinheit_id AND
- tbl_lehreinheitmitarbeiter.mitarbeiter_uid=tbl_benutzer.uid AND
- tbl_person.person_id=tbl_benutzer.person_id AND
- lehrveranstaltung_id=? AND
- tbl_lehreinheitmitarbeiter.mitarbeiter_uid NOT like '_Dummy%' AND
- tbl_benutzer.aktiv=true AND tbl_person.aktiv=true AND
- studiensemester_kurzbz=?) AS a
- ORDER BY lvleiter DESC, nachname, vorname";
+ $query = "SELECT
+ *
+ FROM
+ (SELECT distinct on(uid) vorname, nachname, tbl_benutzer.uid as uid,
+ CASE WHEN
+ EXISTS(
+ SELECT
+ 1
+ FROM
+ lehre.tbl_lehreinheitmitarbeiter lvllem
+ JOIN lehre.tbl_lehreinheit lvlle USING(lehreinheit_id)
+ WHERE
+ lehrfunktion_kurzbz='LV-Leitung'
+ AND lehrveranstaltung_id=tbl_lehreinheit.lehrveranstaltung_id
+ AND studiensemester_kurzbz=tbl_lehreinheit.studiensemester_kurzbz
+ AND mitarbeiter_uid=tbl_benutzer.uid
+ ) THEN true ELSE false END as lvleiter
+ FROM lehre.tbl_lehreinheit, lehre.tbl_lehreinheitmitarbeiter, public.tbl_benutzer, public.tbl_person
+ WHERE
+ tbl_lehreinheit.lehreinheit_id=tbl_lehreinheitmitarbeiter.lehreinheit_id AND
+ tbl_lehreinheitmitarbeiter.mitarbeiter_uid=tbl_benutzer.uid AND
+ tbl_person.person_id=tbl_benutzer.person_id AND
+ lehrveranstaltung_id=? AND
+ tbl_lehreinheitmitarbeiter.mitarbeiter_uid NOT like '_Dummy%' AND
+ tbl_benutzer.aktiv=true AND tbl_person.aktiv=true AND
+ studiensemester_kurzbz=?
+ ) AS a
+ ORDER BY lvleiter DESC, nachname, vorname";
return $this->execQuery($query, array($lehrveranstaltung_id, $studiensemester_kurzbz));
}
@@ -273,7 +289,7 @@ class Lehrveranstaltung_model extends DB_Model
return $this->execQuery($query, $parametersarray);
}
-
+
/**
* Gets Lehrveranstaltung and its Lehreinheiten (multiple rows possible).
* Returns empty array if student has no Lehrveranstaltung.
@@ -290,7 +306,7 @@ class Lehrveranstaltung_model extends DB_Model
AND studiensemester_kurzbz = ?
AND lehrveranstaltung_id = ?;
';
-
+
return $this->execQuery($query, array($uid, $studiensemester_kurzbz, $lehrveranstaltung_id));
}
}
diff --git a/application/models/education/Pruefung_model.php b/application/models/education/Pruefung_model.php
index d10364979..e3776c4ad 100644
--- a/application/models/education/Pruefung_model.php
+++ b/application/models/education/Pruefung_model.php
@@ -11,4 +11,29 @@ class Pruefung_model extends DB_Model
$this->dbTable = 'campus.tbl_pruefung';
$this->pk = 'pruefung_id';
}
+
+ /**
+ * Gets Pruefungen of a person for a Studiensemester.
+ * @param int $person_id
+ * @param string $studiensemester_kurzbz
+ * @return object
+ */
+ public function getByPerson($person_id, $studiensemester_kurzbz)
+ {
+ $qry = '
+ SELECT prfg.*, pers.matr_nr, lv.ects, stg.studiengang_kz, prst.prestudent_id,
+ UPPER(stg.typ||stg.kurzbz) AS studiengang, stg.bezeichnung AS studiengang_bezeichnung
+ FROM public.tbl_person pers
+ JOIN public.tbl_prestudent prst USING (person_id)
+ JOIN public.tbl_student USING (prestudent_id)
+ JOIN lehre.tbl_pruefung prfg USING (student_uid)
+ JOIN lehre.tbl_lehreinheit le USING (lehreinheit_id)
+ JOIN lehre.tbl_lehrveranstaltung lv USING (lehrveranstaltung_id)
+ JOIN public.tbl_studiengang stg ON prst.studiengang_kz = stg.studiengang_kz
+ WHERE pers.person_id = ?
+ AND le.studiensemester_kurzbz = ?
+ ORDER BY prfg.datum, pruefung_id';
+
+ return $this->execQuery($qry, array($person_id, $studiensemester_kurzbz));
+ }
}
diff --git a/application/models/education/Zeugnisnote_model.php b/application/models/education/Zeugnisnote_model.php
index 7ed0e6456..65607e252 100644
--- a/application/models/education/Zeugnisnote_model.php
+++ b/application/models/education/Zeugnisnote_model.php
@@ -12,4 +12,125 @@ class Zeugnisnote_model extends DB_Model
$this->pk = array('studiensemester_kurzbz', 'student_uid', 'lehrveranstaltung_id');
$this->hasSequence = false;
}
+
+ /**
+ * Gets ECTS sums of completed courses (Zeugnisnoten) of a person for a Studiensemester.
+ * If no valid Noten for the course were entered, 0 ects is returned.
+ * @param int $person_id
+ * @param string $studiensemester_kurzbz
+ * @param bool $aktiv
+ * @param bool $lehre
+ * @param bool $offiziell
+ * @param bool $positiv
+ * @return object
+ */
+ public function getEctsSumsByPerson($person_id, $studiensemester_kurzbz, $aktiv = true, $lehre = null, $offiziell = null, $positiv = null)
+ {
+ $params = array();
+
+ $qry = "SELECT DISTINCT ON (prst.prestudent_id) pers.matr_nr, stg.studiengang_kz, prst.prestudent_id, stg.erhalter_kz,
+ UPPER(stg.typ||stg.kurzbz) AS studiengang, stg.bezeichnung AS studiengang_bezeichnung, COALESCE(summen.summe_ects, 0) AS summe_ects
+ FROM public.tbl_person pers
+ JOIN public.tbl_prestudent prst USING (person_id)
+ JOIN public.tbl_prestudentstatus prstst USING (prestudent_id)
+ JOIN public.tbl_studiengang stg ON prst.studiengang_kz = stg.studiengang_kz
+ LEFT JOIN (
+ SELECT zgnisnote.student_uid, prestudent_id, zgnisnote.studiensemester_kurzbz, sum(ects) AS summe_ects
+ FROM public.tbl_student
+ LEFT JOIN lehre.tbl_zeugnisnote zgnisnote USING(student_uid)
+ LEFT JOIN lehre.tbl_note note ON zgnisnote.note = note.note
+ LEFT JOIN lehre.tbl_lehrveranstaltung lv USING (lehrveranstaltung_id)
+ WHERE TRUE";
+
+ if (isset($aktiv))
+ {
+ $qry .= ' AND (note.aktiv = ?)';
+ $params[] = $aktiv;
+ }
+
+ if (isset($lehre))
+ {
+ $qry .= ' AND (note.lehre = ?)';
+ $params[] = $lehre;
+ }
+
+ if (isset($offiziell))
+ {
+ $qry .= ' AND (note.offiziell = ?)';
+ $params[] = $offiziell;
+ }
+
+ if (isset($positiv))
+ {
+ $qry .= ' AND (note.positiv = ?)';
+ $params[] = $positiv;
+ }
+
+ $qry .= " GROUP BY zgnisnote.studiensemester_kurzbz, zgnisnote.student_uid, prestudent_id
+ ) summen ON prst.prestudent_id = summen.prestudent_id AND prstst.studiensemester_kurzbz = summen.studiensemester_kurzbz
+ WHERE pers.person_id = ?
+ AND prstst.studiensemester_kurzbz = ?
+ ORDER BY prst.prestudent_id";
+
+ $params[] = $person_id;
+ $params[] = $studiensemester_kurzbz;
+
+ return $this->execQuery($qry, $params);
+ }
+
+ /**
+ * Gets courses (Zeugnisnoten) of a person for a Studiensemester.
+ * @param int $person_id
+ * @param string $studiensemester_kurzbz
+ * @param bool $aktiv
+ * @param bool $lehre
+ * @param bool $offiziell
+ * @param bool $positiv
+ * @return object
+ */
+ public function getByPerson($person_id, $studiensemester_kurzbz, $aktiv = true, $lehre = null, $offiziell = null, $positiv = null)
+ {
+ $params = array($person_id, $studiensemester_kurzbz);
+
+ $qry = "SELECT zgnisnote.*, pers.matr_nr, lv.ects, stg.studiengang_kz, prst.prestudent_id, stg.erhalter_kz,
+ UPPER(stg.typ||stg.kurzbz) AS studiengang, stg.bezeichnung AS studiengang_bezeichnung, note.note,
+ note.bezeichnung AS note_bezeichnung
+ FROM public.tbl_person pers
+ JOIN public.tbl_prestudent prst USING (person_id)
+ JOIN public.tbl_student USING (prestudent_id)
+ JOIN lehre.tbl_zeugnisnote zgnisnote USING (student_uid)
+ JOIN lehre.tbl_note note ON zgnisnote.note = note.note
+ JOIN lehre.tbl_lehrveranstaltung lv USING (lehrveranstaltung_id)
+ JOIN public.tbl_studiengang stg ON prst.studiengang_kz = stg.studiengang_kz
+ WHERE pers.person_id = ?
+ AND zgnisnote.studiensemester_kurzbz = ?";
+
+ if (isset($aktiv))
+ {
+ $qry .= ' AND note.aktiv = ?';
+ $params[] = $aktiv;
+ }
+
+ if (isset($lehre))
+ {
+ $qry .= ' AND note.lehre = ?';
+ $params[] = $lehre;
+ }
+
+ if (isset($offiziell))
+ {
+ $qry .= ' AND note.offiziell = ?';
+ $params[] = $offiziell;
+ }
+
+ if (isset($positiv))
+ {
+ $qry .= ' AND note.positiv = ?';
+ $params[] = $positiv;
+ }
+
+ $qry .= ' ORDER BY zgnisnote.benotungsdatum';
+
+ return $this->execQuery($qry, $params);
+ }
}
diff --git a/application/models/organisation/Studiengang_model.php b/application/models/organisation/Studiengang_model.php
index 41bdabd11..6358ca81e 100644
--- a/application/models/organisation/Studiengang_model.php
+++ b/application/models/organisation/Studiengang_model.php
@@ -475,7 +475,7 @@ class Studiengang_model extends DB_Model
funktion_kurzbz = \'Leitung\'
AND ( datum_von <= NOW() OR datum_von IS NULL )
AND ( datum_bis >= NOW() OR datum_bis IS NULL )
- AND studiengang_kz = ' . $this->db->escape($studiengang_kz, FHC_INTEGER)
+ AND studiengang_kz = ' . $this->db->escape($studiengang_kz)
;
}
diff --git a/application/models/person/Notiz_model.php b/application/models/person/Notiz_model.php
index fd08cc384..bfd8aa258 100644
--- a/application/models/person/Notiz_model.php
+++ b/application/models/person/Notiz_model.php
@@ -152,6 +152,7 @@ class Notiz_model extends DB_Model
*/
public function getNotizByTitel($person_id, $titel)
{
+ $this->addSelect('public.tbl_notiz.insertamum as insertnotiz, *');
// Join with the table public.tbl_notizzuordnung using notiz_id
$this->addJoin('public.tbl_notizzuordnung', 'notiz_id');
$this->addJoin('public.tbl_prestudent', 'prestudent_id', 'LEFT');
diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php
index e005e243c..085c3f826 100644
--- a/application/models/person/Person_model.php
+++ b/application/models/person/Person_model.php
@@ -152,34 +152,36 @@ class Person_model extends DB_Model
*/
public function getPersonStammdaten($person_id, $zustellung_only = false)
{
- $this->addSelect('public.tbl_person.*, s.kurztext as staatsbuergerschaft, g.kurztext as geburtsnation');
+ $this->addSelect('public.tbl_person.*, tbl_person.staatsbuergerschaft AS staatsbuergerschaft_code, tbl_person.geburtsnation AS geburtsnation_code,
+ s.kurztext as staatsbuergerschaft, g.kurztext as geburtsnation');
$this->addJoin('bis.tbl_nation s', 'public.tbl_person.staatsbuergerschaft = s.nation_code', 'LEFT');
$this->addJoin('bis.tbl_nation g', 'public.tbl_person.geburtsnation = g.nation_code', 'LEFT');
$person = $this->load($person_id);
- if($person->error) return $person;
+ if (isError($person)) return $person;
//return null if not found
- if(count($person->retval) < 1)
+ if (!hasData($person))
return success(null);
- $this->KontaktModel->addDistinct();
$this->KontaktModel->addSelect('kontakttyp, anmerkung, kontakt, zustellung');
$this->KontaktModel->addOrder('kontakttyp');
+ $this->KontaktModel->addOrder('insertamum', 'DESC');
$where = $zustellung_only === true ? array('person_id' => $person_id, 'zustellung' => true) : array('person_id' => $person_id);
$kontakte = $this->KontaktModel->loadWhere($where);
- if($kontakte->error) return $kontakte;
+ if (isError($kontakte)) return $kontakte;
$where = $zustellung_only === true ? array('person_id' => $person_id, 'zustelladresse' => true) : array('person_id' => $person_id);
$this->AdresseModel->addSelect('public.tbl_adresse.*, bis.tbl_nation.kurztext AS nationkurztext');
$this->AdresseModel->addJoin('bis.tbl_nation', 'tbl_adresse.nation = tbl_nation.nation_code', 'LEFT');
+ $this->AdresseModel->addOrder('insertamum', 'DESC');
$adressen = $this->AdresseModel->loadWhere($where);
- if($adressen->error) return $adressen;
+ if (isError($adressen)) return $adressen;
- $stammdaten = $person->retval[0];
- $stammdaten->kontakte = $kontakte->retval;
- $stammdaten->adressen = $adressen->retval;
+ $stammdaten = getData($person)[0];
+ $stammdaten->kontakte = hasData($kontakte) ? getData($kontakte) : array();
+ $stammdaten->adressen = hasData($adressen) ? getData($adressen) : array();
return success($stammdaten);
}
diff --git a/application/models/system/Fehler_model.php b/application/models/system/Fehler_model.php
new file mode 100644
index 000000000..28618f6d9
--- /dev/null
+++ b/application/models/system/Fehler_model.php
@@ -0,0 +1,14 @@
+dbTable = 'system.tbl_fehler';
+ $this->pk = 'fehlercode';
+ }
+}
diff --git a/application/models/system/Filters_model.php b/application/models/system/Filters_model.php
index 20394b36d..581be65e1 100644
--- a/application/models/system/Filters_model.php
+++ b/application/models/system/Filters_model.php
@@ -57,19 +57,34 @@ class Filters_model extends DB_Model
/**
* Loads all filters by their app and dataset_name
*/
- public function getFiltersByAppDatasetName($app, $dataset_name)
+ public function getFiltersByAppDatasetNamePersonId($app, $dataset_name, $person_id)
{
- $this->resetQuery(); // reset any previous built query
+ $query = '
+ (
+ -- Global filters
+ SELECT gs.filter_id,
+ gs.person_id,
+ gs.description
+ FROM system.tbl_filters gs
+ WHERE gs.app = ?
+ AND gs.dataset_name = ?
+ AND gs.person_id IS NULL
+ ORDER BY gs.person_id DESC, gs.sort ASC
+ )
+ UNION ALL
+ (
+ -- Personal filters
+ SELECT ps.filter_id,
+ ps.person_id,
+ ps.description
+ FROM system.tbl_filters ps
+ WHERE ps.app = ?
+ AND ps.dataset_name = ?
+ AND ps.person_id = ?
+ ORDER BY ps.person_id DESC, ps.sort ASC
+ )';
- $this->addSelect('filter_id, person_id, description');
- $this->addOrder('person_id', 'DESC'); // sort descending on column person_id
- $this->addOrder('sort', 'ASC'); // sort on column sort
-
- $filterParametersArray = array(
- 'app' => $app,
- 'dataset_name' => $dataset_name
- );
-
- return $this->loadWhere($filterParametersArray);
+ return $this->execQuery($query, array($app, $dataset_name, $app, $dataset_name, $person_id));
}
}
+
diff --git a/application/models/system/Issue_model.php b/application/models/system/Issue_model.php
new file mode 100644
index 000000000..5dac85066
--- /dev/null
+++ b/application/models/system/Issue_model.php
@@ -0,0 +1,51 @@
+dbTable = 'system.tbl_issue';
+ $this->pk = 'issue_id';
+ }
+
+ /**
+ * Gets number of open (non-resolved) issues.
+ * @param string $fehlercode unique error code
+ * @param int $person_id if provided, only issues with this person_id are counted.
+ * @param string $oe_kurzbz if provided, only issues with this oe_kurzbz are counted.
+ * @param string $fehlercode_extern if provided, only issues with this external fehlercode are counted (for identifying issues from external systems).
+ * @return Object success with number of issues or error
+ */
+ public function getOpenIssueCount($fehlercode, $person_id = null, $oe_kurzbz = null, $fehlercode_extern = null)
+ {
+ $params = array($fehlercode);
+ // issue exists for a fehlercode (or fehlercode_extern), person_id, oe_kurzbz, if not verarbeitet yet
+ $qry = 'SELECT count(*) as anzahl_open_issues FROM system.tbl_issue
+ WHERE fehlercode = ?
+ AND verarbeitetamum IS NULL';
+
+ if (!isEmptyString($fehlercode_extern))
+ {
+ $qry .= ' AND fehlercode_extern = ?';
+ $params[] = $fehlercode_extern;
+ }
+
+ if (isset($person_id))
+ {
+ $qry .= ' AND person_id = ?';
+ $params[] = $person_id;
+ }
+
+ if (isset($oe_kurzbz))
+ {
+ $qry .= ' AND oe_kurzbz = ?';
+ $params[] = $oe_kurzbz;
+ }
+
+ return $this->execQuery($qry, $params);
+ }
+}
diff --git a/application/views/codex/oehbeitrag.php b/application/views/codex/oehbeitrag.php
new file mode 100644
index 000000000..7cfb18fe8
--- /dev/null
+++ b/application/views/codex/oehbeitrag.php
@@ -0,0 +1,60 @@
+load->view(
+ 'templates/FHC-Header',
+ array(
+ 'title' => 'ÖH-Beitragsverwaltung',
+ 'jquery' => true,
+ 'jqueryui' => true,
+ 'bootstrap' => true,
+ 'fontawesome' => true,
+ 'sbadmintemplate' => true,
+ 'tablesorter' => true,
+ 'dialoglib' => true,
+ 'ajaxlib' => true,
+ 'navigationwidget' => true,
+ 'customCSSs' => array('public/css/sbadmin2/tablesort_bootstrap.css', 'public/css/codex/oehbeitrag.css'),
+ 'customJSs' => array('public/js/tablesort/tablesort.js', 'public/js/codex/oehbeitrag.js')
+ )
+);
+?>
+
+
+
+
+ widgetlib->widget('NavigationWidget'); ?>
+
+
+
+
+
+
+
Neuen Öhbeitrag hinzufügen
+
+
+
+
+
+ Gültig von
+ Gültig bis
+ Studierendenbetrag
+ Versicherungsbetrag
+ Aktion
+
+
+
+
+
+
+
+
+
+
+
+
+load->view('templates/FHC-Footer'); ?>
diff --git a/application/views/crm/statusGrundList.php b/application/views/crm/statusGrundList.php
index e128856d3..ab8f096bb 100644
--- a/application/views/crm/statusGrundList.php
+++ b/application/views/crm/statusGrundList.php
@@ -15,6 +15,7 @@
Aktiv
Bezeichnung mehrsprachig
Beschreibung
+ Statusgrund
@@ -25,6 +26,7 @@
aktiv); ?>
bezeichnung_mehrsprachig); ?>
beschreibung); ?>
+ statusgrund_kurzbz); ?>
Edit
@@ -33,4 +35,4 @@
-