mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 02:12:17 +00:00
Merge branch 'feature-10965/beurteilungsformular_pdf_export' into feature-10963/Beurteilungsformular_datenbankanpassungen
This commit is contained in:
@@ -45,4 +45,25 @@ class Student_model extends DB_Model
|
||||
$max += 1;
|
||||
return $matrikelnummer.sprintf("%03d", $max);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get students UID by PrestudentID.
|
||||
* @param $prestudent_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUID($prestudent_id)
|
||||
{
|
||||
$this->addSelect('student_uid');
|
||||
|
||||
$result = $this->loadWhere(
|
||||
array('prestudent_id' => $prestudent_id)
|
||||
);
|
||||
|
||||
if (!hasData($result))
|
||||
{
|
||||
show_error('Failed getting UID by prestudent_id');
|
||||
}
|
||||
|
||||
return $result->retval[0]->student_uid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,76 @@ class Anrechnung_model extends DB_Model
|
||||
$this->dbTable = 'lehre.tbl_anrechnung';
|
||||
$this->pk = 'anrechnung_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Anrechnungstatus.
|
||||
* @param $anrechnung_id
|
||||
* @param $status_kurzbz
|
||||
* @return array|null
|
||||
*/
|
||||
public function saveAnrechnungstatus($anrechnung_id, $status_kurzbz)
|
||||
{
|
||||
$qry = '
|
||||
INSERT INTO lehre.tbl_anrechnung_anrechnungstatus (
|
||||
anrechnung_id, status_kurzbz, insertvon
|
||||
) VALUES ( ?, ?, ?);
|
||||
';
|
||||
|
||||
return $this->execQuery($qry, array($anrechnung_id, $status_kurzbz, getAuthUID()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last inserted Anrechnungstatus
|
||||
* @param $anrechnung_id
|
||||
* @return array|null
|
||||
*/
|
||||
public function getLastAnrechnungstatus($anrechnung_id, $status_kurzbz = null)
|
||||
{
|
||||
if (is_string($status_kurzbz))
|
||||
{
|
||||
$qry = '
|
||||
SELECT *
|
||||
FROM lehre.tbl_anrechnungstatus
|
||||
JOIN lehre.tbl_anrechnung_anrechnungstatus USING (status_kurzbz)
|
||||
WHERE anrechnung_id = ?
|
||||
AND status_kurzbz = ?
|
||||
ORDER BY insertamum DESC
|
||||
LIMIT 1
|
||||
';
|
||||
|
||||
return $this->execQuery($qry, array($anrechnung_id, $status_kurzbz));
|
||||
}
|
||||
|
||||
|
||||
$qry = '
|
||||
SELECT *
|
||||
FROM lehre.tbl_anrechnungstatus
|
||||
JOIN lehre.tbl_anrechnung_anrechnungstatus USING (status_kurzbz)
|
||||
WHERE anrechnung_id = ?
|
||||
ORDER BY insertamum DESC
|
||||
LIMIT 1
|
||||
';
|
||||
|
||||
return $this->execQuery($qry, array($anrechnung_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get status approved / rejected, if present.
|
||||
* @param $anrechnung_id
|
||||
* @return array|null
|
||||
*/
|
||||
public function getApprovedOrRejected($anrechnung_id)
|
||||
{
|
||||
$qry = '
|
||||
SELECT *
|
||||
FROM lehre.tbl_anrechnungstatus
|
||||
JOIN lehre.tbl_anrechnung_anrechnungstatus USING (status_kurzbz)
|
||||
WHERE anrechnung_id = ?
|
||||
AND (status_kurzbz = \'approved\' OR status_kurzbz = \'rejected\')
|
||||
ORDER BY insertamum DESC
|
||||
LIMIT 1
|
||||
';
|
||||
|
||||
return $this->execQuery($qry, array($anrechnung_id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Anrechnungstatus_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'lehre.tbl_anrechnungstatus';
|
||||
$this->pk = 'status_kurzbz';
|
||||
}
|
||||
}
|
||||
@@ -273,4 +273,24 @@ 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.
|
||||
* @param $uid
|
||||
* @param $studiensemester_kurzbz
|
||||
* @param $lehrveranstaltung_id
|
||||
* @return array|null
|
||||
*/
|
||||
public function getLvByStudent($uid, $studiensemester_kurzbz, $lehrveranstaltung_id)
|
||||
{
|
||||
$query = '
|
||||
SELECT * FROM campus.vw_student_lehrveranstaltung
|
||||
WHERE uid = ?
|
||||
AND studiensemester_kurzbz = ?
|
||||
AND lehrveranstaltung_id = ?;
|
||||
';
|
||||
|
||||
return $this->execQuery($query, array($uid, $studiensemester_kurzbz, $lehrveranstaltung_id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,5 +10,6 @@ class Zeugnisnote_model extends DB_Model
|
||||
parent::__construct();
|
||||
$this->dbTable = 'lehre.tbl_zeugnisnote';
|
||||
$this->pk = array('studiensemester_kurzbz', 'student_uid', 'lehrveranstaltung_id');
|
||||
$this->hasSequence = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,4 +448,37 @@ class Studiengang_model extends DB_Model
|
||||
|
||||
return $this->execQuery($query, array($typ));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Studiengangsleitung
|
||||
* @param null $studiengang_kz
|
||||
* @return array
|
||||
*/
|
||||
public function getLeitung($studiengang_kz = null)
|
||||
{
|
||||
$this->addSelect('uid, studiengang_kz, oe_kurzbz, vorname, nachname, email');
|
||||
$this->addJoin('public.tbl_benutzerfunktion', 'oe_kurzbz');
|
||||
$this->addJoin('public.tbl_benutzer', 'uid');
|
||||
$this->addJoin('public.tbl_person', 'person_id');
|
||||
|
||||
if (is_null($studiengang_kz))
|
||||
{
|
||||
$condition = '
|
||||
funktion_kurzbz = \'Leitung\'
|
||||
AND ( datum_von <= NOW() OR datum_von IS NULL )
|
||||
AND ( datum_bis >= NOW() OR datum_bis IS NULL )
|
||||
';
|
||||
}
|
||||
elseif (is_numeric($studiengang_kz))
|
||||
{
|
||||
$condition = '
|
||||
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)
|
||||
;
|
||||
}
|
||||
|
||||
return $this->loadWhere($condition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,6 +158,76 @@ class Notiz_model extends DB_Model
|
||||
|
||||
return $this->loadWhere(array('person_id' => $person_id, 'titel LIKE' => $titel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Notiz for a given Anrechnung
|
||||
* @param $anrechnung_id
|
||||
* @param $titel
|
||||
* @param $text
|
||||
* @param $verfasser_uid
|
||||
* @return array
|
||||
*/
|
||||
public function addNotizForAnrechnung($anrechnung_id, $titel, $text, $verfasser_uid)
|
||||
{
|
||||
// Loads model Notizzuordnung_model
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
|
||||
// Start DB transaction
|
||||
$this->db->trans_start(false);
|
||||
|
||||
$result = $this->insert(array(
|
||||
'titel' => $titel,
|
||||
'text' => $text,
|
||||
'erledigt' => true,
|
||||
'verfasser_uid' => $verfasser_uid,
|
||||
"insertvon" => $verfasser_uid
|
||||
));
|
||||
|
||||
if (isSuccess($result))
|
||||
{
|
||||
$notiz_id = $result->retval;
|
||||
$result = $this->NotizzuordnungModel->insert(array('notiz_id' => $notiz_id, 'anrechnung_id' => $anrechnung_id));
|
||||
}
|
||||
|
||||
// Transaction complete!
|
||||
$this->db->trans_complete();
|
||||
|
||||
// Check if everything went ok during the transaction
|
||||
if ($this->db->trans_status() === false || isError($result))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
$result = error($result->msg, EXIT_ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->trans_commit();
|
||||
$result = success($notiz_id);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Notizen by Anrechnung and title ordered last first
|
||||
*
|
||||
* @param $anrechnung_id
|
||||
* @return array
|
||||
*/
|
||||
public function getNotizByAnrechnung($anrechnung_id, $titel = null)
|
||||
{
|
||||
$this->addJoin('public.tbl_notizzuordnung', 'notiz_id');
|
||||
$this->addOrder('insertamum', 'DESC');
|
||||
|
||||
if (is_string($titel))
|
||||
{
|
||||
return $this->loadWhere(array(
|
||||
'anrechnung_id' => $anrechnung_id,
|
||||
'titel' => $titel
|
||||
));
|
||||
}
|
||||
|
||||
return $this->loadWhere(array('anrechnung_id' => $anrechnung_id));
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ class Person_model extends DB_Model
|
||||
*/
|
||||
public function getByUid($uid)
|
||||
{
|
||||
$this->addSelect('vorname, nachname, gebdatum, person_id');
|
||||
$this->addSelect('vorname, nachname, gebdatum, person_id, bpk, matr_nr');
|
||||
$this->addJoin('tbl_benutzer', 'person_id');
|
||||
|
||||
return $this->loadWhere(array('uid' => $uid));
|
||||
@@ -248,4 +248,19 @@ class Person_model extends DB_Model
|
||||
|
||||
return $this->execQuery($qry, $parametersArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full name of given uid. (Vorname Nachname)
|
||||
* @param $uid
|
||||
* @return array
|
||||
*/
|
||||
public function getFullName($uid)
|
||||
{
|
||||
if (!$result = getData($this->getByUid($uid))[0])
|
||||
{
|
||||
show_error('Failed loading person');
|
||||
}
|
||||
|
||||
return success($result->vorname. ' '. $result->nachname);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user