mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
Merge branch 'master' into feature-36185/requestAnrechnung_bootstrap3_zu_bootstrap5
This commit is contained in:
@@ -121,7 +121,7 @@ class AntragLib
|
||||
public function unpauseAntrag($antrag_id, $insertvon)
|
||||
{
|
||||
if ($insertvon == Studierendenantragstatus_model::INSERTVON_DEREGISTERED)
|
||||
return error($this->p->t('studierendenantrag', 'error_no_right'));
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_right'));
|
||||
if ($insertvon == Studierendenantragstatus_model::INSERTVON_ABMELDUNGSTGL) {
|
||||
return $this->_ci->StudierendenantragstatusModel->resumeAntraegeForAbmeldungStgl($antrag_id);
|
||||
}
|
||||
@@ -257,18 +257,28 @@ class AntragLib
|
||||
if (isError($result))
|
||||
$errors[] = getError($result);
|
||||
|
||||
$this->_ci->load->model('crm/Statusgrund_model', 'StatusgrundModel');
|
||||
$result = $this->_ci->StatusgrundModel->loadWhere(['statusgrund_kurzbz' => 'abbrecherStud']);
|
||||
if (isError($result)) {
|
||||
$errors[] = getError($result);
|
||||
continue;
|
||||
} elseif (!hasData($result)) {
|
||||
$errors[] = $this->_ci->p->t('lehre', 'error_noStatusgrund', ['statusgrund_kurzbz' => 'abbrecherStud']);
|
||||
continue;
|
||||
}
|
||||
$statusgrund = current(getData($result));
|
||||
|
||||
$result = $this->_ci->prestudentlib->setAbbrecher(
|
||||
$antrag->prestudent_id,
|
||||
$antrag->studiensemester_kurzbz,
|
||||
$insertvon,
|
||||
'abbrecherStud',
|
||||
$statusgrund->statusgrund_id,
|
||||
$antrag->datum,
|
||||
$insertam
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
if (isError($result)) {
|
||||
$errors[] = getError($result);
|
||||
return $errors;
|
||||
continue;
|
||||
}
|
||||
|
||||
$result = $this->_ci->PersonModel->loadPrestudent($antrag->prestudent_id);
|
||||
@@ -421,11 +431,20 @@ class AntragLib
|
||||
// NOTE(chris): here we should have error handling but at the
|
||||
// moment there is no way to notify the user for "soft" errors
|
||||
|
||||
$this->_ci->load->model('crm/Statusgrund_model', 'StatusgrundModel');
|
||||
$result = $this->_ci->StatusgrundModel->loadWhere(['statusgrund_kurzbz' => 'abbrecherStgl']);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return error($this->_ci->p->t('lehre', 'error_noStatusgrund', ['statusgrund_kurzbz' => 'abbrecherStgl']));
|
||||
|
||||
$statusgrund = current(getData($result));
|
||||
|
||||
$result = $this->_ci->prestudentlib->setAbbrecher(
|
||||
$antrag->prestudent_id,
|
||||
$antrag->studiensemester_kurzbz,
|
||||
$insertvon,
|
||||
'abbrecherStgl',
|
||||
$statusgrund->statusgrund_id,
|
||||
$status->insertamum
|
||||
);
|
||||
|
||||
@@ -911,7 +930,7 @@ class AntragLib
|
||||
public function createWiederholung($prestudent_id, $studiensemester_kurzbz, $insertvon, $repeat)
|
||||
{
|
||||
$result = $this->_ci->StudierendenantragModel->loadIdAndStatusWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'tbl_studierendenantrag.prestudent_id' => $prestudent_id,
|
||||
'studiensemester_kurzbz'=> $studiensemester_kurzbz,
|
||||
'typ' => Studierendenantrag_model::TYP_WIEDERHOLUNG
|
||||
]);
|
||||
@@ -1341,7 +1360,7 @@ class AntragLib
|
||||
|
||||
if (!in_array($result->status_kurzbz, $this->_ci->config->item('antrag_prestudentstatus_whitelist_abmeldung'))) {
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'tbl_studierendenantrag.prestudent_id' => $prestudent_id,
|
||||
's.studierendenantrag_statustyp_kurzbz' => Studierendenantragstatus_model::STATUS_APPROVED
|
||||
], [
|
||||
Studierendenantrag_model::TYP_ABMELDUNG,
|
||||
@@ -1353,7 +1372,7 @@ class AntragLib
|
||||
return success(-1);
|
||||
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'tbl_studierendenantrag.prestudent_id' => $prestudent_id,
|
||||
's.studierendenantrag_statustyp_kurzbz' => Studierendenantragstatus_model::STATUS_PAUSE
|
||||
], [
|
||||
Studierendenantrag_model::TYP_ABMELDUNG,
|
||||
@@ -1367,7 +1386,7 @@ class AntragLib
|
||||
return success(0);
|
||||
}
|
||||
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere(['prestudent_id' => $prestudent_id]);
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere(['tbl_studierendenantrag.prestudent_id' => $prestudent_id]);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
@@ -1428,7 +1447,7 @@ class AntragLib
|
||||
&& $result->status_kurzbz != 'Unterbrecher') {
|
||||
return success(0);
|
||||
}
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere(['prestudent_id' => $prestudent_id]);
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere(['tbl_studierendenantrag.prestudent_id' => $prestudent_id]);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
@@ -1444,12 +1463,6 @@ class AntragLib
|
||||
elseif($antrag->status == Studierendenantragstatus_model::STATUS_APPROVED && $antrag->datum > $datumStatus)
|
||||
return success(-2);
|
||||
}
|
||||
if ($antrag->typ == Studierendenantrag_model::TYP_UNTERBRECHUNG)
|
||||
{
|
||||
// NOTE(chris): Ignore canceled ones
|
||||
if ($antrag->status == Studierendenantragstatus_model::STATUS_CANCELLED)
|
||||
continue;
|
||||
}
|
||||
if ($antrag->typ == Studierendenantrag_model::TYP_WIEDERHOLUNG)
|
||||
{
|
||||
if($antrag->status == Studierendenantragstatus_model::STATUS_PASS)
|
||||
@@ -1510,7 +1523,7 @@ class AntragLib
|
||||
$datumStatus = $result->datum;
|
||||
if (!in_array($result->status_kurzbz, $this->_ci->config->item('antrag_prestudentstatus_whitelist'))) {
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'tbl_studierendenantrag.prestudent_id' => $prestudent_id,
|
||||
'typ' => Studierendenantrag_model::TYP_WIEDERHOLUNG,
|
||||
's.studierendenantrag_statustyp_kurzbz' => Studierendenantragstatus_model::STATUS_APPROVED
|
||||
]);
|
||||
@@ -1520,7 +1533,7 @@ class AntragLib
|
||||
return success(-1);
|
||||
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'tbl_studierendenantrag.prestudent_id' => $prestudent_id,
|
||||
'typ' => Studierendenantrag_model::TYP_WIEDERHOLUNG,
|
||||
's.studierendenantrag_statustyp_kurzbz' => Studierendenantragstatus_model::STATUS_DEREGISTERED
|
||||
]);
|
||||
@@ -1530,7 +1543,7 @@ class AntragLib
|
||||
return success(-1);
|
||||
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'tbl_studierendenantrag.prestudent_id' => $prestudent_id,
|
||||
'typ' => Studierendenantrag_model::TYP_WIEDERHOLUNG,
|
||||
's.studierendenantrag_statustyp_kurzbz' => Studierendenantragstatus_model::STATUS_PAUSE
|
||||
]);
|
||||
@@ -1541,7 +1554,7 @@ class AntragLib
|
||||
|
||||
return success(0);
|
||||
}
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere(['prestudent_id' => $prestudent_id]);
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere(['tbl_studierendenantrag.prestudent_id' => $prestudent_id]);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
@@ -1594,7 +1607,7 @@ class AntragLib
|
||||
public function getDetailsForLastAntrag($prestudent_id, $typ = null)
|
||||
{
|
||||
$where = [
|
||||
'prestudent_id' => $prestudent_id
|
||||
'tbl_studierendenantrag.prestudent_id' => $prestudent_id
|
||||
];
|
||||
$types = null;
|
||||
if ($typ) {
|
||||
@@ -2058,7 +2071,7 @@ class AntragLib
|
||||
*/
|
||||
public function isEntitledToUnpauseAntrag($antrag_id)
|
||||
{
|
||||
return $this->hasAccessToAntrag($antrag_id, 'student/studierendenantrag');
|
||||
return ($this->hasAccessToAntrag($antrag_id, 'student/antragfreigabe') || $this->hasAccessToAntrag($antrag_id, 'student/studierendenantrag'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2180,4 +2193,4 @@ class AntragLib
|
||||
$result = $this->_ci->StudierendenantraglehrveranstaltungModel->getLvsForPrestudent($prestudent_id, $studiensemester_kurzbz);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,7 +246,27 @@ class IssuesLib
|
||||
$fehlertext = vsprintf($fehlertextVorlage, $fehlertext_params);
|
||||
}
|
||||
|
||||
$openIssuesCountRes = $this->_ci->IssueModel->getOpenIssueCount($fehlercode, $person_id, $oe_kurzbz, $fehlercode_extern);
|
||||
if (isset($resolution_params))
|
||||
{
|
||||
if (is_array($resolution_params))
|
||||
{
|
||||
foreach ($resolution_params as $resolution_key => $resolution_param)
|
||||
{
|
||||
if (!is_string($resolution_key))
|
||||
return error("Invalid parameter for resolution, must be an associative array");
|
||||
}
|
||||
}
|
||||
else
|
||||
return error("Invalid parameters for resolution");
|
||||
}
|
||||
|
||||
$openIssuesCountRes = $this->_ci->IssueModel->getOpenIssueCount(
|
||||
$fehlercode,
|
||||
$person_id,
|
||||
$oe_kurzbz,
|
||||
$fehlercode_extern,
|
||||
$resolution_params
|
||||
);
|
||||
|
||||
if (hasData($openIssuesCountRes))
|
||||
{
|
||||
@@ -256,20 +276,6 @@ class IssuesLib
|
||||
|
||||
if ($openIssueCount == 0)
|
||||
{
|
||||
if (isset($resolution_params))
|
||||
{
|
||||
if (is_array($resolution_params))
|
||||
{
|
||||
foreach ($resolution_params as $resolution_key => $resolution_param)
|
||||
{
|
||||
if (!is_string($resolution_key))
|
||||
return error("Invalid parameter for resolution, must be an associative array");
|
||||
}
|
||||
}
|
||||
else
|
||||
return error("Invalid parameters for resolution");
|
||||
}
|
||||
|
||||
// insert new issue
|
||||
return $this->_ci->IssueModel->insert(
|
||||
array(
|
||||
|
||||
@@ -21,6 +21,8 @@ require_once(FHCPATH.'include/functions.inc.php');
|
||||
require_once(FHCPATH.'include/wawi_kostenstelle.class.php');
|
||||
require_once(FHCPATH.'include/benutzerberechtigung.class.php');
|
||||
|
||||
use \benutzerberechtigung as benutzerberechtigung;
|
||||
|
||||
class PermissionLib
|
||||
{
|
||||
// Available rights in the DB
|
||||
@@ -65,8 +67,10 @@ class PermissionLib
|
||||
if (!is_cli())
|
||||
{
|
||||
// API Caller rights initialization
|
||||
$authObj = $this->_ci->authlib->getAuthObj();
|
||||
self::$bb = new benutzerberechtigung();
|
||||
self::$bb->getBerechtigungen(($this->_ci->authlib->getAuthObj())->{AuthLib::AO_USERNAME});
|
||||
if ($authObj)
|
||||
self::$bb->getBerechtigungen($authObj->{AuthLib::AO_USERNAME});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,19 +147,7 @@ class PermissionLib
|
||||
if (strpos($permissions[$pCounter], PermissionLib::PERMISSION_SEPARATOR) !== false)
|
||||
{
|
||||
// Retrieves permission and required access type from the $requiredPermissions array
|
||||
list($permission, $requiredAccessType) = explode(PermissionLib::PERMISSION_SEPARATOR, $permissions[$pCounter]);
|
||||
|
||||
$accessType = '';
|
||||
|
||||
// Set the access type
|
||||
if (strpos($requiredAccessType, PermissionLib::READ_RIGHT) !== false)
|
||||
{
|
||||
$accessType = PermissionLib::SELECT_RIGHT; // S
|
||||
}
|
||||
if (strpos($requiredAccessType, PermissionLib::WRITE_RIGHT) !== false)
|
||||
{
|
||||
$accessType .= PermissionLib::REPLACE_RIGHT.PermissionLib::DELETE_RIGHT; // UID
|
||||
}
|
||||
list($permission, $accessType) = $this->convertAccessType($permissions[$pCounter]);
|
||||
|
||||
if (!isEmptyString($accessType)) // if compliant
|
||||
{
|
||||
@@ -166,6 +158,16 @@ class PermissionLib
|
||||
if ($checkPermissions === true) break;
|
||||
}
|
||||
}
|
||||
elseif ($permissions[$pCounter] == Auth_Controller::PERM_ANONYMOUS)
|
||||
{
|
||||
$checkPermissions = true;
|
||||
break;
|
||||
}
|
||||
elseif ($permissions[$pCounter] == Auth_Controller::PERM_LOGGED)
|
||||
{
|
||||
$checkPermissions = isLogged();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error('The given permission does not use the correct format');
|
||||
@@ -195,6 +197,24 @@ class PermissionLib
|
||||
return $checkPermissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves permission and required access type from the newly formatted permission string
|
||||
*
|
||||
* @param string $permission
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function convertAccessType($permission)
|
||||
{
|
||||
list($permission, $reqAccessType) = explode(PermissionLib::PERMISSION_SEPARATOR, $permission);
|
||||
$accessType = '';
|
||||
if (strpos($reqAccessType, PermissionLib::READ_RIGHT) !== false)
|
||||
$accessType = PermissionLib::SELECT_RIGHT;
|
||||
if (strpos($reqAccessType, PermissionLib::WRITE_RIGHT) !== false)
|
||||
$accessType = PermissionLib::REPLACE_RIGHT.PermissionLib::DELETE_RIGHT;
|
||||
return [$permission, $accessType];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if at least one of the permissions given as parameter (requiredPermissions) belongs to the authenticated user
|
||||
* It checks the given permissions against a given method (controller method name) and a given permission type (R and/or W)
|
||||
|
||||
@@ -35,8 +35,15 @@ class PrestudentLib
|
||||
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
}
|
||||
|
||||
public function setAbbrecher($prestudent_id, $studiensemester_kurzbz, $insertvon = null, $statusgrund_kurzbz = null, $datum = null, $bestaetigtam = null, $bestaetigtvon = null)
|
||||
{
|
||||
public function setAbbrecher(
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$insertvon = null,
|
||||
$statusgrund_id = null,
|
||||
$datum = null,
|
||||
$bestaetigtam = null,
|
||||
$bestaetigtvon = null
|
||||
) {
|
||||
if (!$insertvon)
|
||||
$insertvon = getAuthUID();
|
||||
if (!$bestaetigtvon)
|
||||
@@ -70,8 +77,8 @@ class PrestudentLib
|
||||
if(!$bestaetigtam)
|
||||
$bestaetigtam = date('c');
|
||||
|
||||
//Status und Statusgrund updaten
|
||||
$result = $this->_ci->PrestudentstatusModel->withGrund($statusgrund_kurzbz)->insert([
|
||||
// Status und Statusgrund updaten
|
||||
$result = $this->_ci->PrestudentstatusModel->insert([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_ABBRECHER,
|
||||
'studiensemester_kurzbz' => $prestudent_status->studiensemester_kurzbz,
|
||||
@@ -82,13 +89,13 @@ class PrestudentLib
|
||||
'orgform_kurzbz'=> $prestudent_status->orgform_kurzbz,
|
||||
'studienplan_id'=> $prestudent_status->studienplan_id,
|
||||
'bestaetigtvon' => $bestaetigtvon,
|
||||
'bestaetigtam' => $bestaetigtam
|
||||
'bestaetigtam' => $bestaetigtam,
|
||||
'statusgrund_id' => $statusgrund_id
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
//Verband anlegen
|
||||
$result = $this->_ci->LehrverbandModel->load([
|
||||
'studiengang_kz' => $student->studiengang_kz,
|
||||
@@ -134,7 +141,7 @@ class PrestudentLib
|
||||
]);
|
||||
}
|
||||
|
||||
//noch nicht eingetragene Zeugnisnoten auf 9 setzen
|
||||
// noch nicht eingetragene Zeugnisnoten auf 9 setzen
|
||||
$result = $this->_ci->ZeugnisnoteModel->getZeugnisnoten($student->student_uid, $prestudent_status->studiensemester_kurzbz);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
@@ -166,9 +173,9 @@ class PrestudentLib
|
||||
}
|
||||
|
||||
|
||||
//Update Aktionen
|
||||
// Update Aktionen
|
||||
|
||||
//StudentModel updaten
|
||||
// StudentModel updaten
|
||||
$this->_ci->StudentModel->update([
|
||||
'student_uid' => $student->student_uid
|
||||
], [
|
||||
@@ -192,7 +199,7 @@ class PrestudentLib
|
||||
'updatevon' => $insertvon
|
||||
]);
|
||||
|
||||
//Benutzer inaktiv setzen
|
||||
// Benutzer inaktiv setzen
|
||||
$this->_ci->BenutzerModel->update([
|
||||
'uid' => $student->student_uid
|
||||
], [
|
||||
@@ -206,17 +213,28 @@ class PrestudentLib
|
||||
return success();
|
||||
}
|
||||
|
||||
public function setUnterbrecher($prestudent_id, $studiensemester_kurzbz, $studierendenantrag_id, $insertvon = null)
|
||||
{
|
||||
public function setUnterbrecher(
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$studierendenantrag_id = null,
|
||||
$insertvon = null,
|
||||
$ausbildungssemester = null,
|
||||
$statusgrund_id = null
|
||||
) {
|
||||
$ausbildungssemester_plus = 0;
|
||||
|
||||
if (!$insertvon)
|
||||
$insertvon = getAuthUID();
|
||||
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id, $studiensemester_kurzbz);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
$result = getData($result);
|
||||
if (!$result) {
|
||||
|
||||
if (!$result) { // NOTE(chris): no status in target stdsem
|
||||
//NOTE(manu): only valid if nextSemester focus max
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id);
|
||||
@@ -224,7 +242,7 @@ class PrestudentLib
|
||||
return $result;
|
||||
$result = getData($result);
|
||||
|
||||
//check if ausbildungssemester is last
|
||||
// check if ausbildungssemester is last
|
||||
$this->_ci->StudiengangModel->addJoin('public.tbl_prestudent p', 'studiengang_kz');
|
||||
$res = $this->_ci->StudiengangModel->loadWhere(['p.prestudent_id' => $prestudent_id]);
|
||||
if(isError($res))
|
||||
@@ -236,7 +254,7 @@ class PrestudentLib
|
||||
|
||||
$studiengang = current(getData($res));
|
||||
$prestudent_status = current($result);
|
||||
if($prestudent_status->ausbildungssemester + 1 < $studiengang->max_semester)
|
||||
if ($prestudent_status->status_kurzbz != Prestudentstatus_model::STATUS_UNTERBRECHER && $prestudent_status->ausbildungssemester + 1 < $studiengang->max_semester)
|
||||
$ausbildungssemester_plus = 1;
|
||||
|
||||
if(!$result)
|
||||
@@ -246,34 +264,79 @@ class PrestudentLib
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz
|
||||
]));
|
||||
}
|
||||
} elseif (current($result)->status_kurzbz == Prestudentstatus_model::STATUS_UNTERBRECHER) {
|
||||
if ($studierendenantrag_id)
|
||||
{
|
||||
$resultAntrag = $this->_ci->StudierendenantragModel->load($studierendenantrag_id);
|
||||
if (isError($resultAntrag))
|
||||
return $resultAntrag;
|
||||
$resultAntrag = getData($resultAntrag);
|
||||
if (!$resultAntrag)
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_antrag_found', ['id' => $studierendenantrag_id]));
|
||||
|
||||
$antrag = current($resultAntrag);
|
||||
$anmerkung = current($result)->anmerkung . ' Wiedereinstieg ' . $antrag->datum_wiedereinstieg;
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->update([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_UNTERBRECHER,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'ausbildungssemester' => current($result)->ausbildungssemester
|
||||
], [
|
||||
'updatevon' => $insertvon,
|
||||
'updateamum' => date('c'),
|
||||
'anmerkung'=> $anmerkung
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
$prestudent_status = current($result);
|
||||
|
||||
|
||||
$result = $this->_ci->StudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
$result = getData($result);
|
||||
|
||||
if (!$result)
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_student_for_prestudent', ['prestudent_id' => $prestudent_id]));
|
||||
|
||||
$student = current($result);
|
||||
|
||||
$resultAntrag = $this->_ci->StudierendenantragModel->load($studierendenantrag_id);
|
||||
if (isError($resultAntrag))
|
||||
return $resultAntrag;
|
||||
$resultAntrag = getData($resultAntrag);
|
||||
if (!$resultAntrag)
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_antrag_found', ['id' => $studierendenantrag_id]));
|
||||
|
||||
$antrag = current($resultAntrag);
|
||||
if ($studierendenantrag_id)
|
||||
{
|
||||
$resultAntrag = $this->_ci->StudierendenantragModel->load($studierendenantrag_id);
|
||||
if (isError($resultAntrag))
|
||||
return $resultAntrag;
|
||||
$resultAntrag = getData($resultAntrag);
|
||||
if (!$resultAntrag)
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_antrag_found', ['id' => $studierendenantrag_id]));
|
||||
|
||||
//Status updaten
|
||||
$antrag = current($resultAntrag);
|
||||
$anmerkung = 'Wiedereinstieg ' . $antrag->datum_wiedereinstieg;
|
||||
}
|
||||
else
|
||||
$anmerkung = '';
|
||||
|
||||
if ($ausbildungssemester)
|
||||
$semester = $ausbildungssemester;
|
||||
else
|
||||
$semester = $prestudent_status->ausbildungssemester + $ausbildungssemester_plus;
|
||||
|
||||
// Status updaten
|
||||
$result = $this->_ci->PrestudentstatusModel->insert([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_UNTERBRECHER,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'ausbildungssemester' => $prestudent_status->ausbildungssemester + $ausbildungssemester_plus,
|
||||
'ausbildungssemester' => $semester,
|
||||
'datum' => date('c'),
|
||||
'insertvon' => $insertvon,
|
||||
'insertamum' => date('c'),
|
||||
@@ -281,7 +344,8 @@ class PrestudentLib
|
||||
'studienplan_id'=> $prestudent_status->studienplan_id,
|
||||
'bestaetigtvon' => $insertvon,
|
||||
'bestaetigtam' => date('c'),
|
||||
'anmerkung'=> 'Wiedereinstieg ' . $antrag->datum_wiedereinstieg
|
||||
'anmerkung'=> $anmerkung,
|
||||
'statusgrund_id' => $statusgrund_id
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
@@ -332,7 +396,7 @@ class PrestudentLib
|
||||
]);
|
||||
}
|
||||
|
||||
//noch nicht eingetragene Zeugnisnoten auf 9 setzen
|
||||
// noch nicht eingetragene Zeugnisnoten auf 9 setzen
|
||||
$result = $this->_ci->ZeugnisnoteModel->getZeugnisnoten($student->student_uid, $studiensemester_kurzbz);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
@@ -363,10 +427,9 @@ class PrestudentLib
|
||||
}
|
||||
}
|
||||
|
||||
// Update Aktionen
|
||||
|
||||
//Update Aktionen
|
||||
|
||||
//StudentModel updaten
|
||||
// StudentModel updaten
|
||||
$this->_ci->StudentModel->update([
|
||||
'student_uid' => $student->student_uid
|
||||
], [
|
||||
@@ -409,4 +472,463 @@ class PrestudentLib
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
public function setStudent($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
|
||||
{
|
||||
$authUID = getAuthUID();
|
||||
$now = date('c');
|
||||
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_prestudentstatus', [
|
||||
'prestudent_id' => $prestudent_id
|
||||
]));
|
||||
|
||||
$prestudent_status = current(getData($result));
|
||||
|
||||
|
||||
$result = $this->_ci->StudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_student_for_prestudent', ['prestudent_id' => $prestudent_id]));
|
||||
|
||||
$student = current(getData($result));
|
||||
|
||||
|
||||
$this->_ci->load->library('VariableLib', ['uid' => $authUID]);
|
||||
$semester_aktuell = $this->_ci->variablelib->getVar('semester_aktuell');
|
||||
|
||||
|
||||
// Update Aktionen
|
||||
|
||||
// Status updaten
|
||||
$result = $this->_ci->PrestudentstatusModel->insert([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_STUDENT,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'statusgrund_id' => $statusgrund_id,
|
||||
'ausbildungssemester' => $ausbildungssemester,
|
||||
'datum' => $now,
|
||||
'insertvon' => $authUID,
|
||||
'insertamum' => $now,
|
||||
'orgform_kurzbz'=> $prestudent_status->orgform_kurzbz,
|
||||
'studienplan_id'=> $prestudent_status->studienplan_id,
|
||||
'bestaetigtvon' => $authUID,
|
||||
'bestaetigtam' => $now
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
// Student updaten
|
||||
$result = $this->_ci->StudentModel->update([
|
||||
'student_uid' => $student->student_uid
|
||||
], [
|
||||
'semester' => $ausbildungssemester,
|
||||
'verband' => '',
|
||||
'gruppe' => '',
|
||||
'updatevon' => $authUID,
|
||||
'updateamum' => $now
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
// Studentlehrverband updaten
|
||||
$result = $this->_ci->StudentlehrverbandModel->update([
|
||||
'student_uid' => $student->student_uid,
|
||||
'studiensemester_kurzbz' => $semester_aktuell
|
||||
], [
|
||||
'semester' => $ausbildungssemester,
|
||||
'verband' => '',
|
||||
'gruppe' => '',
|
||||
'updatevon' => $authUID,
|
||||
'updateamum' => $now
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
// Benutzer updaten
|
||||
$result = $this->_ci->BenutzerModel->load([$student->student_uid]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return error($this->_ci->p->t('person', 'error_noBenutzer'));
|
||||
|
||||
$benutzer = current(getData($result));
|
||||
$updateData = [
|
||||
'aktiv' => true,
|
||||
'updateamum' => $now,
|
||||
'updatevon' => $authUID
|
||||
];
|
||||
if (!$benutzer->aktiv) {
|
||||
$updateData['updateaktivam'] = $now;
|
||||
$updateData['updateaktivvon'] = $authUID;
|
||||
}
|
||||
|
||||
|
||||
$this->_ci->BenutzerModel->update([$student->student_uid], $updateData);
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
public function setFirstStudent(
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$ausbildungssemester,
|
||||
$orgform_kurzbz,
|
||||
$studienplan_id,
|
||||
$statusgrund_id
|
||||
) {
|
||||
$this->_ci->PrestudentModel->addJoin('public.tbl_person p', 'person_id');
|
||||
$this->_ci->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz');
|
||||
$result = $this->_ci->PrestudentModel->load($prestudent_id);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
if (!hasData($result))
|
||||
return error('No prestudent');
|
||||
|
||||
$student_data = current(getData($result));
|
||||
|
||||
|
||||
$authUID = getAuthUID();
|
||||
$now = date('c');
|
||||
$today = date('Y-m-d');
|
||||
|
||||
$jahr = mb_substr($studiensemester_kurzbz, 4, 2);
|
||||
|
||||
|
||||
// Genererate Personenkennzeichen
|
||||
$personenkennzeichen = $this->_ci->StudentModel->generateMatrikelnummer2(
|
||||
$student_data->studiengang_kz,
|
||||
$studiensemester_kurzbz,
|
||||
$student_data->typ
|
||||
);
|
||||
if (isError($personenkennzeichen))
|
||||
return $personenkennzeichen;
|
||||
$personenkennzeichen = getData($personenkennzeichen);
|
||||
|
||||
|
||||
// Generate UID
|
||||
$uid = $this->_ci->StudentModel->generateUID(
|
||||
$student_data->kurzbz,
|
||||
$jahr,
|
||||
$student_data->typ,
|
||||
$personenkennzeichen,
|
||||
$student_data->vorname,
|
||||
$student_data->nachname
|
||||
);
|
||||
if (isError($uid))
|
||||
return $uid;
|
||||
$uid = getData($uid);
|
||||
|
||||
|
||||
// Generate Matrikelnummer
|
||||
$matrikelnummer = $this->_ci->BenutzerModel->generateMatrikelnummer(
|
||||
$student_data->oe_kurzbz
|
||||
);
|
||||
if (isError($matrikelnummer))
|
||||
return $matrikelnummer;
|
||||
$matrikelnummer = getData($matrikelnummer);
|
||||
|
||||
|
||||
// Generate Alias
|
||||
$alias = '';
|
||||
if (!defined('GENERATE_ALIAS_STUDENT')
|
||||
|| GENERATE_ALIAS_STUDENT === true
|
||||
) {
|
||||
$result = $this->_ci->BenutzerModel->generateAliasFromName($student_data->vorname, $student_data->nachname);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$alias = getData($result);
|
||||
}
|
||||
|
||||
// Generate Activation Key
|
||||
$activationkey = $this->_ci->BenutzerModel->generateActivationkey();
|
||||
|
||||
|
||||
// Overwrite stuff
|
||||
if (defined('SET_UID_AS_MATRIKELNUMMER')
|
||||
&& SET_UID_AS_MATRIKELNUMMER)
|
||||
$matrikelnummer = $uid;
|
||||
if (defined('SET_UID_AS_PERSONENKENNZEICHEN')
|
||||
&& SET_UID_AS_PERSONENKENNZEICHEN)
|
||||
$personenkennzeichen = $uid;
|
||||
|
||||
|
||||
// Update Person
|
||||
$this->_ci->load->model('person/Person_model', 'PersonModel');
|
||||
$result = $this->_ci->PersonModel->update([
|
||||
'person_id' => $student_data->person_id,
|
||||
'matr_nr' => null
|
||||
], [
|
||||
'matr_nr' => $matrikelnummer
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
// Add Benutzer
|
||||
$result = $this->_ci->BenutzerModel->insert([
|
||||
'uid' => $uid,
|
||||
'person_id' => $student_data->person_id,
|
||||
'aktiv' => true,
|
||||
'aktivierungscode' => $activationkey,
|
||||
'alias' => $alias,
|
||||
'insertvon' => $authUID,
|
||||
'insertamum' => $now,
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
// Add Student
|
||||
$result = $this->_ci->StudentModel->insert([
|
||||
'student_uid' => $uid,
|
||||
'matrikelnr' => $personenkennzeichen,
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'studiengang_kz' => $student_data->studiengang_kz,
|
||||
'semester' => $ausbildungssemester,
|
||||
'verband' => ' ',
|
||||
'gruppe' => ' ',
|
||||
'insertvon' => $authUID,
|
||||
'insertamum' => $now
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
// Add Lehrverband if it does not exist
|
||||
$result = $this->_ci->LehrverbandModel->load([' ', ' ', $ausbildungssemester, $student_data->studiengang_kz]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
if (!hasData($result)) {
|
||||
$result = $this->_ci->LehrverbandModel->insert([
|
||||
'studiengang_kz' => $student_data->studiengang_kz,
|
||||
'semester' => $ausbildungssemester,
|
||||
'verband' => ' ',
|
||||
'gruppe' => ' ',
|
||||
'aktiv' => true
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
// Add Rolle
|
||||
$result = $this->_ci->PrestudentstatusModel->insert([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_STUDENT,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'ausbildungssemester' => $ausbildungssemester,
|
||||
'orgform_kurzbz'=> $orgform_kurzbz,
|
||||
'studienplan_id'=> $studienplan_id,
|
||||
'datum' => $today,
|
||||
'insertamum' => $now,
|
||||
'insertvon' => $authUID,
|
||||
'bestaetigtam' => $today,
|
||||
'bestaetigtvon' => $authUID,
|
||||
'statusgrund_id' => $statusgrund_id
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
// Add Studentlehrverband
|
||||
$result = $this->_ci->StudentlehrverbandModel->insert([
|
||||
'student_uid' => $uid,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'studiengang_kz' => $student_data->studiengang_kz,
|
||||
'semester' => $ausbildungssemester,
|
||||
'verband' => ' ',
|
||||
'gruppe' => ' ',
|
||||
'insertamum' => $now,
|
||||
'insertvon' => $authUID
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
public function setDiplomand($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
|
||||
{
|
||||
return $this->setBasic(
|
||||
getAuthUID(),
|
||||
date('c'),
|
||||
Prestudentstatus_model::STATUS_DIPLOMAND,
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$ausbildungssemester,
|
||||
$statusgrund_id
|
||||
);
|
||||
}
|
||||
|
||||
public function setAbsolvent($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
|
||||
{
|
||||
$authUID = getAuthUID();
|
||||
$now = date('c');
|
||||
|
||||
|
||||
$result = $this->setBasic(
|
||||
$authUID,
|
||||
$now,
|
||||
Prestudentstatus_model::STATUS_ABSOLVENT,
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$ausbildungssemester,
|
||||
$statusgrund_id
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
// Load Student
|
||||
$result = $this->_ci->StudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_student_for_prestudent', ['prestudent_id' => $prestudent_id]));
|
||||
|
||||
$student = current(getData($result));
|
||||
|
||||
|
||||
// Benutzer inaktiv setzen
|
||||
$this->_ci->BenutzerModel->update([
|
||||
'uid' => $student->student_uid
|
||||
], [
|
||||
'aktiv' => false,
|
||||
'updateaktivvon' => $authUID,
|
||||
'updateaktivam' => $now,
|
||||
'updatevon' => $authUID,
|
||||
'updateamum' => $now
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
public function setBewerber($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
|
||||
{
|
||||
$result = $this->setBasic(
|
||||
getAuthUID(),
|
||||
date('c'),
|
||||
Prestudentstatus_model::STATUS_BEWERBER,
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$ausbildungssemester,
|
||||
$statusgrund_id
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
if (SEND_BEWERBER_INFOMAIL) {
|
||||
// TODO(chris): IMPLEMENT!
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
public function setAufgenommener($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
|
||||
{
|
||||
return $this->setBasic(
|
||||
getAuthUID(),
|
||||
date('c'),
|
||||
Prestudentstatus_model::STATUS_AUFGENOMMENER,
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$ausbildungssemester,
|
||||
$statusgrund_id
|
||||
);
|
||||
}
|
||||
|
||||
public function setAbgewiesener($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
|
||||
{
|
||||
return $this->setBasic(
|
||||
getAuthUID(),
|
||||
date('c'),
|
||||
Prestudentstatus_model::STATUS_ABGEWIESENER,
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$ausbildungssemester,
|
||||
$statusgrund_id
|
||||
);
|
||||
}
|
||||
|
||||
public function setWartender($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
|
||||
{
|
||||
return $this->setBasic(
|
||||
getAuthUID(),
|
||||
date('c'),
|
||||
Prestudentstatus_model::STATUS_WARTENDER,
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$ausbildungssemester,
|
||||
$statusgrund_id
|
||||
);
|
||||
}
|
||||
|
||||
protected function setBasic($authUID, $now, $status_kurzbz, $prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id = null)
|
||||
{
|
||||
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_prestudentstatus', [
|
||||
'prestudent_id' => $prestudent_id
|
||||
]));
|
||||
|
||||
$prestudent_status = current(getData($result));
|
||||
|
||||
|
||||
// Update Aktionen
|
||||
|
||||
// Status updaten
|
||||
$result = $this->_ci->PrestudentstatusModel->insert([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => $status_kurzbz,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'ausbildungssemester' => $ausbildungssemester,
|
||||
'datum' => $now,
|
||||
'insertvon' => $authUID,
|
||||
'insertamum' => $now,
|
||||
'orgform_kurzbz'=> $prestudent_status->orgform_kurzbz,
|
||||
'studienplan_id'=> $prestudent_status->studienplan_id,
|
||||
'bestaetigtvon' => $authUID,
|
||||
'bestaetigtam' => $now,
|
||||
'statusgrund_id' => $statusgrund_id
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,922 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class PrestudentstatusCheckLib
|
||||
{
|
||||
const INTERESSENT_STATUS = 'Interessent';
|
||||
const BEWERBER_STATUS = 'Bewerber';
|
||||
const AUFGENOMMENER_STATUS = 'Aufgenommener';
|
||||
const UNTERBRECHER_STATUS = 'Unterbrecher';
|
||||
const STUDENT_STATUS = 'Student';
|
||||
const DIPLOMAND_STATUS = 'Diplomand';
|
||||
const ABSOLVENT_STATUS = 'Absolvent';
|
||||
const ABBRECHER_STATUS = 'Abbrecher';
|
||||
|
||||
private $_ci;
|
||||
private $_statusAbfolgeVorStudent = [self::INTERESSENT_STATUS, self::BEWERBER_STATUS, self::AUFGENOMMENER_STATUS];
|
||||
private $_endStatusArr = [self::ABSOLVENT_STATUS, self::ABBRECHER_STATUS];
|
||||
|
||||
private $_cache_history = [];
|
||||
|
||||
/**
|
||||
* Object initialization
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
$this->_ci->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
$this->_ci->load->model('person/Person_model', 'PersonModel');
|
||||
$this->_ci->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
|
||||
$this->_ci->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
$this->_ci->load->model('crm/Student_model', 'StudentModel');
|
||||
$this->_ci->load->model('organisation/Studienplan_model', 'StudienplanModel');
|
||||
$this->_ci->load->model('codex/Bismeldestichtag_model', 'BismeldestichtagModel');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a status add is valid.
|
||||
* @return object error if invalid
|
||||
*/
|
||||
public function checkStatusAdd(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_status_studiensemester_kurzbz,
|
||||
$new_status_datum,
|
||||
$new_status_ausbildungssemester,
|
||||
$new_studienplan_id
|
||||
) {
|
||||
$studentName = '';
|
||||
|
||||
$nameRes = $this->_ci->PersonModel->loadPrestudent($prestudent_id);
|
||||
|
||||
if (hasData($nameRes))
|
||||
{
|
||||
$nameData = getData($nameRes)[0];
|
||||
$studentName = $nameData->vorname.' '.$nameData->nachname;
|
||||
}
|
||||
|
||||
// Datum des neuen Status darf nicht in Vergangenheit liegen, sonst Probleme wenn neues Datum < Bismeldedatum
|
||||
if (new DateTime($new_status_datum) < new DateTime('today'))
|
||||
return error($studentName . $this->_ci->p->t('lehre', 'error_entryInPast'));
|
||||
|
||||
return $this->_checkIfValidStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_status_studiensemester_kurzbz,
|
||||
$new_status_datum,
|
||||
$new_status_ausbildungssemester,
|
||||
$new_studienplan_id
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a status update is valid.
|
||||
* @return error if invalid
|
||||
*/
|
||||
public function checkStatusUpdate(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_status_studiensemester_kurzbz,
|
||||
$new_status_datum,
|
||||
$new_status_ausbildungssemester,
|
||||
$new_studienplan_id,
|
||||
$old_status_studiensemester,
|
||||
$old_status_ausbildungssemester
|
||||
) {
|
||||
|
||||
return $this->_checkIfValidStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_status_studiensemester_kurzbz,
|
||||
$new_status_datum,
|
||||
$new_status_ausbildungssemester,
|
||||
$new_studienplan_id,
|
||||
$old_status_studiensemester,
|
||||
$old_status_ausbildungssemester
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a student already exists.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkIfExistingStudent($prestudent_id)
|
||||
{
|
||||
$result = $this->_ci->StudentModel->loadWhere([
|
||||
'prestudent_id' => $prestudent_id
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(hasData($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Reihungstest was admitted
|
||||
*
|
||||
* @param stdClass $prestudent
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkIfAngetreten($prestudent)
|
||||
{
|
||||
return success($prestudent->reihungstestangetreten);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if ZGV-Code is registered
|
||||
*
|
||||
* @param stdClass $prestudent
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkIfZGVEingetragen($prestudent_person)
|
||||
{
|
||||
return success((boolean)$prestudent_person->zgv_code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Master ZGV-Code is registered
|
||||
*
|
||||
* @param stdClass $prestudent
|
||||
*
|
||||
* @return booleans $zgv_code, error if not registered
|
||||
*/
|
||||
public function checkIfZGVEingetragenMaster($prestudent)
|
||||
{
|
||||
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
$result = $this->_ci->StudiengangModel->load($prestudent->studiengang_kz);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_stg', ['studiengang_kz' => $prestudent->studiengang_kz]));
|
||||
|
||||
if (current($result->retval)->typ != 'm')
|
||||
return success(true); // NOTE(chris): we only test master stgs, all other stgs should default to true
|
||||
|
||||
return success((boolean)$prestudent->zgvmas_code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a bewerber status already exists.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkIfExistingBewerberstatus($prestudent_id)
|
||||
{
|
||||
$result = $this->_ci->PrestudentstatusModel->loadWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_BEWERBER
|
||||
]);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(hasData($result));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if status aufgenommen already exists.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkIfExistingAufgenommenerstatus($prestudent_id)
|
||||
{
|
||||
$result = $this->_ci->PrestudentstatusModel->loadWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_AUFGENOMMENER
|
||||
]);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(hasData($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the last Bewerber status and the last Aufgenommener status
|
||||
* have the same studiensemester and ausbildungssemester.
|
||||
*
|
||||
* Attention:
|
||||
* If one of those two status is missing the function returns true!
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkIfLastBewerberAndAufgenommenerShareSemesters($prestudent_id)
|
||||
{
|
||||
$this->_ci->PrestudentstatusModel->addOrder('datum', 'DESC');
|
||||
$this->_ci->PrestudentstatusModel->addOrder('insertamum', 'DESC');
|
||||
$this->_ci->PrestudentstatusModel->addLimit(1);
|
||||
$result = $this->_ci->PrestudentstatusModel->loadWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_BEWERBER
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return success(true);
|
||||
|
||||
$bewerber = current(getData($result));
|
||||
|
||||
$this->_ci->PrestudentstatusModel->addOrder('datum', 'DESC');
|
||||
$this->_ci->PrestudentstatusModel->addOrder('insertamum', 'DESC');
|
||||
$this->_ci->PrestudentstatusModel->addLimit(1);
|
||||
$result = $this->_ci->PrestudentstatusModel->loadWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_AUFGENOMMENER
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
return success(true);
|
||||
|
||||
$aufgenommener = current(getData($result));
|
||||
|
||||
return success(
|
||||
$bewerber->studiensemester_kurzbz == $aufgenommener->studiensemester_kurzbz
|
||||
&& $bewerber->ausbildungssemester == $aufgenommener->ausbildungssemester
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Bismeldestichtag erreicht
|
||||
*
|
||||
* @param DateTime $statusDatum
|
||||
* @param string $studiensemester_kurzbz
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkIfMeldestichtagErreicht($statusDatum, $studiensemester_kurzbz = null)
|
||||
{
|
||||
$result = $this->_ci->BismeldestichtagModel->checkIfMeldestichtagErreicht($statusDatum, $studiensemester_kurzbz);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(getData($result) == "1");
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs all checks on Status History and saves it in cache.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
* @param string $status_kurzbz
|
||||
* @param DateTime $new_date
|
||||
* @param string $new_studiensemester_kurzbz
|
||||
* @param integer $new_ausbildungssemester
|
||||
* @param string $old_studiensemester_kurzbz
|
||||
* @param integer $old_ausbildungssemester
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
protected function prepareStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
) {
|
||||
// Generate key for caching
|
||||
$primary = implode('|', [
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date->format('Y-m-d'),
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
]);
|
||||
|
||||
if (isset($this->_cache_history[$primary]))
|
||||
return $this->_cache_history[$primary];
|
||||
|
||||
$this->_ci->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
|
||||
|
||||
// Get the history
|
||||
$result = $this->_ci->PrestudentstatusModel->getHistoryWithNewOrEditedState(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
if (!hasData($result))
|
||||
return error('This is impossible');
|
||||
|
||||
$history = getData($result);
|
||||
$historyCount = count($history);
|
||||
|
||||
// Run checks
|
||||
$checks = [
|
||||
'timesequence' => true,
|
||||
'laststatus' => true,
|
||||
'unterbrechersemester' => true,
|
||||
'abbrechersemester' => true,
|
||||
'diplomant' => true,
|
||||
'student' => true
|
||||
];
|
||||
|
||||
for ($n = 0, $c = 1; $c < $historyCount; $n++, $c++) {
|
||||
if (!$checks['timesequence']
|
||||
&& !$checks['laststatus']
|
||||
&& !$checks['unterbrechersemester']
|
||||
&& !$checks['abbrechersemester']
|
||||
&& !$checks['diplomant']
|
||||
&& !$checks['student']
|
||||
)
|
||||
break; // early out
|
||||
|
||||
$next = $history[$n];
|
||||
$current = $history[$c];
|
||||
|
||||
// Zeitabfolge ungültig?
|
||||
if ($checks['timesequence']
|
||||
&& $next->start < $current->start
|
||||
)
|
||||
$checks['timesequence'] = false;
|
||||
|
||||
// Abbrecher- oder Absolventenstatus muss Endstatus sein
|
||||
if ($checks['laststatus']
|
||||
&& in_array($current->status_kurzbz, [self::ABSOLVENT_STATUS, self::ABBRECHER_STATUS])
|
||||
)
|
||||
$checks['laststatus'] = false;
|
||||
|
||||
// wenn Unterbrecher auf Unterbrecher folgt, muss Ausbildungssemester gleich sein
|
||||
if ($checks['unterbrechersemester']
|
||||
&& $current->status_kurzbz == self::UNTERBRECHER_STATUS
|
||||
&& $next->status_kurzbz == self::UNTERBRECHER_STATUS
|
||||
&& $current->ausbildungssemester != $next->ausbildungssemester
|
||||
)
|
||||
$checks['unterbrechersemester'] = false;
|
||||
|
||||
// wenn Abbrecher auf Unterbrecher folgt, muss Ausbildungssemester gleich sein
|
||||
if ($checks['abbrechersemester']
|
||||
&& $current->status_kurzbz == self::UNTERBRECHER_STATUS
|
||||
&& $next->status_kurzbz == self::ABBRECHER_STATUS
|
||||
&& $current->ausbildungssemester != $next->ausbildungssemester
|
||||
)
|
||||
$checks['abbrechersemester'] = false;
|
||||
|
||||
if (($checks['diplomant']
|
||||
|| $checks['student'])
|
||||
&& $next->status_kurzbz == self::STUDENT_STATUS
|
||||
) {
|
||||
$restl_stati = array_unique(array_column(array_slice($history, $c), 'status_kurzbz'));
|
||||
|
||||
// keine Studenten nach Diplomand Status
|
||||
if ($checks['diplomant']
|
||||
&& in_array(self::DIPLOMAND_STATUS, $restl_stati)
|
||||
)
|
||||
$checks['diplomant'] = false;
|
||||
|
||||
// vor Studentenstatus müssen bestimmte Status vorhanden sein
|
||||
if ($checks['student']
|
||||
&& array_values(array_intersect($restl_stati, $this->_statusAbfolgeVorStudent)) != array_values($this->_statusAbfolgeVorStudent)
|
||||
)
|
||||
$checks['student'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_cache_history[$primary] = success($checks);
|
||||
|
||||
return success($checks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the time sequence of the status history is valid.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
* @param string $status_kurzbz
|
||||
* @param DateTime $new_date
|
||||
* @param string $new_studiensemester_kurzbz
|
||||
* @param integer $new_ausbildungssemester
|
||||
* @param string $old_studiensemester_kurzbz
|
||||
* @param integer $old_ausbildungssemester
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkStatusHistoryTimesequence(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
) {
|
||||
$result = $this->prepareStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(getData($result)['timesequence']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the last status of the status history is not Abbrecher or
|
||||
* Absolvent.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
* @param string $status_kurzbz
|
||||
* @param DateTime $new_date
|
||||
* @param string $new_studiensemester_kurzbz
|
||||
* @param integer $new_ausbildungssemester
|
||||
* @param string $old_studiensemester_kurzbz
|
||||
* @param integer $old_ausbildungssemester
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkStatusHistoryLaststatus(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
) {
|
||||
$result = $this->prepareStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(getData($result)['laststatus']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if two consecutively Unterbrecher have the same
|
||||
* ausbildungssemester in the status history.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
* @param string $status_kurzbz
|
||||
* @param DateTime $new_date
|
||||
* @param string $new_studiensemester_kurzbz
|
||||
* @param integer $new_ausbildungssemester
|
||||
* @param string $old_studiensemester_kurzbz
|
||||
* @param integer $old_ausbildungssemester
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkStatusHistoryUnterbrechersemester(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
) {
|
||||
$result = $this->prepareStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(getData($result)['unterbrechersemester']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an Unterbrecher followed by an Abbrecher have the same
|
||||
* ausbildungssemester in the status history.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
* @param string $status_kurzbz
|
||||
* @param DateTime $new_date
|
||||
* @param string $new_studiensemester_kurzbz
|
||||
* @param integer $new_ausbildungssemester
|
||||
* @param string $old_studiensemester_kurzbz
|
||||
* @param integer $old_ausbildungssemester
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkStatusHistoryAbbrechersemester(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
) {
|
||||
$result = $this->prepareStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(getData($result)['abbrechersemester']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if no Diplomant is followed by a Student in the status history.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
* @param string $status_kurzbz
|
||||
* @param DateTime $new_date
|
||||
* @param string $new_studiensemester_kurzbz
|
||||
* @param integer $new_ausbildungssemester
|
||||
* @param string $old_studiensemester_kurzbz
|
||||
* @param integer $old_ausbildungssemester
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkStatusHistoryDiplomant(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
) {
|
||||
$result = $this->prepareStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(getData($result)['diplomant']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a Student precedes given stati in the status history.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
* @param string $status_kurzbz
|
||||
* @param DateTime $new_date
|
||||
* @param string $new_studiensemester_kurzbz
|
||||
* @param integer $new_ausbildungssemester
|
||||
* @param string $old_studiensemester_kurzbz
|
||||
* @param integer $old_ausbildungssemester
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkStatusHistoryStudent(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
) {
|
||||
// TODO(chris): TEST
|
||||
$result = $this->prepareStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_date,
|
||||
$new_studiensemester_kurzbz,
|
||||
$new_ausbildungssemester,
|
||||
$old_studiensemester_kurzbz,
|
||||
$old_ausbildungssemester
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(getData($result)['student']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if Personenkennzeichen is set correctly.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkPersonenkennzeichen($prestudent_id)
|
||||
{
|
||||
// TODO(chris): TEST
|
||||
$this->_ci->PrestudentstatusModel->addSelect('tbl_prestudentstatus.prestudent_id');
|
||||
$this->_ci->PrestudentstatusModel->addSelect('tbl_student.matrikelnr');
|
||||
|
||||
$this->_ci->PrestudentstatusModel->addJoin('public.tbl_student', 'prestudent_id');
|
||||
|
||||
$this->_ci->PrestudentstatusModel->addOrder('tbl_prestudentstatus.datum', 'DESC');
|
||||
$this->_ci->PrestudentstatusModel->addOrder('tbl_prestudentstatus.insertamum', 'DESC');
|
||||
$this->_ci->PrestudentstatusModel->addOrder('tbl_prestudentstatus.ext_id', 'DESC');
|
||||
|
||||
$this->_ci->PrestudentstatusModel->addLimit(1);
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->loadWhere([
|
||||
'tbl_prestudentstatus.prestudent_id' => $prestudent_id,
|
||||
'tbl_prestudentstatus.status_kurzbz' => self::STATUS_STUDENT
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
if (!hasData($result))
|
||||
return success(true); // Not a student yet so no wrong personenkennzeichen
|
||||
|
||||
$data = current(getData($result));
|
||||
|
||||
$jahr = $this->_ci->StudiensemesterModel->getStudienjahrNumberFromStudiensemester($data->studiensemester_kurzbz);
|
||||
|
||||
|
||||
return success($jahr == mb_substr($data->matrikelnr, 0, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if Orgform of Student status and Bewerber status match.
|
||||
*
|
||||
* @param integer $prestudent_id
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function checkStudentOrgform($prestudent_id)
|
||||
{
|
||||
// TODO(chris): TEST
|
||||
$result = $this->_ci->PrestudentstatusModel->getBewerberWhereOrgformNotStudent($prestudent_id);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
return success(!hasData($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if History of StatusData is valid
|
||||
* @param integer $prestudent_id
|
||||
* @return error if not valid, array StatusArr if valid
|
||||
*/
|
||||
private function _checkIfValidStatusHistory(
|
||||
$prestudent_id,
|
||||
$status_kurzbz,
|
||||
$new_status_studiensemester_kurzbz,
|
||||
$new_status_datum,
|
||||
$new_status_ausbildungssemester,
|
||||
$new_studienplan_id,
|
||||
$old_status_studiensemester = null,
|
||||
$old_status_ausbildungssemester = null
|
||||
) {
|
||||
//get start studiensemester
|
||||
$semResult = $this->_ci->StudiensemesterModel->load([
|
||||
'studiensemester_kurzbz' => $new_status_studiensemester_kurzbz
|
||||
]);
|
||||
|
||||
if (isError($semResult))
|
||||
{
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
return $this->outputJson(getError($semResult));
|
||||
}
|
||||
|
||||
if (!hasData($semResult)) {
|
||||
return error($this->_ci->p->t('lehre', 'error_noStudiensemester') . $new_status_studiensemester_kurzbz);
|
||||
}
|
||||
|
||||
$studiensemester = getData($semResult)[0];
|
||||
$new_status_semesterstart = $studiensemester->start;
|
||||
|
||||
// get studienplan orgform
|
||||
$new_studienplan_orgform_kurzbz = '';
|
||||
$this->_ci->StudienplanModel->addSelect('orgform_kurzbz');
|
||||
$stplResult = $this->_ci->StudienplanModel->load([
|
||||
'studienplan_id' => $new_studienplan_id
|
||||
]);
|
||||
|
||||
if (isError($stplResult))
|
||||
{
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
return $this->outputJson(getError($stplResult));
|
||||
}
|
||||
|
||||
if (hasData($stplResult)) $new_studienplan_orgform_kurzbz = getData($stplResult)[0]->orgform_kurzbz;
|
||||
|
||||
|
||||
//get all prestudentstati
|
||||
$resultPs = $this->_ci->PrestudentstatusModel->getAllPrestudentstatiWithStudiensemester($prestudent_id);
|
||||
|
||||
if (isError($resultPs)) return $resultPs;
|
||||
|
||||
$resultArr = hasData($resultPs) ? getData($resultPs) : [];
|
||||
$statusArr = [];
|
||||
|
||||
$newStatusInserted = false;
|
||||
$new_status_datum_form = new DateTime($new_status_datum);
|
||||
$new_status_semesterstart_form = new DateTime($new_status_semesterstart);
|
||||
|
||||
if (!isEmptyArray($resultArr))
|
||||
{
|
||||
// neuen Status zum Hinzufügen
|
||||
$first_status = $resultArr[0];
|
||||
$neuer_status = new stdClass();
|
||||
$neuer_status->status_kurzbz = $status_kurzbz;
|
||||
$neuer_status->studiensemester_kurzbz = $new_status_studiensemester_kurzbz;
|
||||
$neuer_status->datum = $new_status_datum;
|
||||
$neuer_status->ausbildungssemester = $new_status_ausbildungssemester;
|
||||
$neuer_status->studienplan_orgform_kurzbz = $new_studienplan_orgform_kurzbz;
|
||||
$neuer_status->matrikelnr = $first_status->matrikelnr;
|
||||
$neuer_status->vorname = $first_status->vorname;
|
||||
$neuer_status->nachname = $first_status->nachname;
|
||||
|
||||
// Status, welcher gerade geändert wird, holen
|
||||
$status_to_change = array_filter(
|
||||
$resultArr,
|
||||
function ($status) use ($status_kurzbz, $old_status_studiensemester, $old_status_ausbildungssemester) {
|
||||
return
|
||||
$status->status_kurzbz == $status_kurzbz
|
||||
&& $status->studiensemester_kurzbz == $old_status_studiensemester
|
||||
&& $status->ausbildungssemester == $old_status_ausbildungssemester;
|
||||
}
|
||||
);
|
||||
|
||||
if (!isEmptyArray($status_to_change))
|
||||
{
|
||||
$status_to_change_index = key($status_to_change);
|
||||
|
||||
// wenn sich Studiensemester und Ausbildungssemester nicht geändert haben...
|
||||
if ($new_status_studiensemester_kurzbz == $old_status_studiensemester
|
||||
&& $new_status_ausbildungssemester == $old_status_ausbildungssemester)
|
||||
{
|
||||
// ...neuen status an selber stelle einfügen wie zu ändernder Status
|
||||
$resultArr[$status_to_change_index] = (object)array_merge((array)$resultArr[$status_to_change_index], (array)$neuer_status);
|
||||
$newStatusInserted = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// bei Status mit neuem Semester: alten Status entfernen
|
||||
unset($resultArr[$status_to_change_index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($resultArr as $row)
|
||||
{
|
||||
$studiensemester_start = new DateTime($row->studiensemester_start);
|
||||
$status_datum = new DateTime($row->datum);
|
||||
|
||||
if ($new_status_datum_form >= $status_datum && $new_status_semesterstart_form >= $studiensemester_start)
|
||||
{
|
||||
if (!$newStatusInserted)
|
||||
{
|
||||
// neuer Status erstmals größer als Datum eines bestehenden Status -> neuen Status EINMALIG einfügen für spätere Statusprüfung
|
||||
$statusArr[] = $neuer_status;
|
||||
$newStatusInserted = true;
|
||||
}
|
||||
$statusArr[] = $row;
|
||||
}
|
||||
elseif ($new_status_datum_form <= $status_datum && $new_status_semesterstart_form <= $studiensemester_start)
|
||||
{
|
||||
$statusArr[] = $row;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Zeitabfolge ungültig, Fehler
|
||||
return error($this->_ci->p->t('lehre', 'error_statuseintrag_zeitabfolge'));
|
||||
}
|
||||
}
|
||||
|
||||
// erster Studentstatus
|
||||
$ersterStudent = null;
|
||||
|
||||
// Über alle gespeicherten Status gehen und Statusabfolge prüfen
|
||||
for ($i = 0; $i < count($statusArr); $i++)
|
||||
{
|
||||
$curr_status = $statusArr[$i];
|
||||
$curr_status_kurzbz = $curr_status->status_kurzbz;
|
||||
$curr_status_ausbildungssemester = $curr_status->ausbildungssemester;
|
||||
$next_idx = $i - 1; //absteigend sortiert, nächster Status ist vorheriger Eintrag
|
||||
$next_status = isset($statusArr[$next_idx]) ? $statusArr[$next_idx] : null;
|
||||
|
||||
$studentName = $curr_status->vorname . ' ' . $curr_status->nachname;
|
||||
|
||||
if ($curr_status_kurzbz == self::STUDENT_STATUS) $ersterStudent = $curr_status;
|
||||
|
||||
// Abbrecher- oder Absolventenstatus muss Endstatus sein
|
||||
if (isset($next_status) && in_array($curr_status_kurzbz, $this->_endStatusArr))
|
||||
{
|
||||
return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_endstatus'));
|
||||
}
|
||||
|
||||
// wenn Unterbrecher auf Unterbrecher folgt, muss Ausbildungssemester gleich sein
|
||||
if
|
||||
($curr_status_kurzbz == self::UNTERBRECHER_STATUS && isset($next_status) && $next_status->status_kurzbz == self::UNTERBRECHER_STATUS
|
||||
&& $curr_status_ausbildungssemester != $next_status->ausbildungssemester)
|
||||
{
|
||||
return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_consecutiveUnterbrecher'));
|
||||
}
|
||||
|
||||
// wenn Abbrecher auf Unterbrecher folgt, muss Ausbildungssemester gleich sein
|
||||
if (isset($next_status)
|
||||
&& $curr_status_kurzbz == self::UNTERBRECHER_STATUS
|
||||
&& $next_status->status_kurzbz == self::ABBRECHER_STATUS && $curr_status_ausbildungssemester != $next_status->ausbildungssemester)
|
||||
{
|
||||
return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_consecutiveUnterbrecherAbbrecher'));
|
||||
}
|
||||
|
||||
if (isset($next_status) && $next_status->status_kurzbz == self::STUDENT_STATUS)
|
||||
{
|
||||
$restliche_status_obj = array_slice($statusArr, $i);
|
||||
$restliche_status = array_unique(array_column($restliche_status_obj, 'status_kurzbz'));
|
||||
$status_intersected = array_intersect($restliche_status, $this->_statusAbfolgeVorStudent);
|
||||
|
||||
// Vor Studentstatus darf kein Diplomand Status vorhanden sein
|
||||
if (in_array(self::DIPLOMAND_STATUS, $restliche_status))
|
||||
{
|
||||
return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_consecutiveDiplomandStudent'));
|
||||
}
|
||||
|
||||
// Vor Studentstatus müssen bestimmte Status vorhanden sein
|
||||
if (array_values($status_intersected) != array_values(array_reverse($this->_statusAbfolgeVorStudent)))
|
||||
{
|
||||
return error(
|
||||
$studentName . ' '
|
||||
. $this->_ci->p->t('lehre', 'error_wrongStatusOrderBeforeStudent', array(implode(', ', $this->_statusAbfolgeVorStudent)))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($ersterStudent))
|
||||
{
|
||||
$studentName = $ersterStudent->vorname . ' ' . $ersterStudent->nachname;
|
||||
|
||||
// wenn erster Studentstatus, checken ob Personenkennzeichen passt
|
||||
$studienjahrNumber = $this->_ci->StudiensemesterModel->getStudienjahrNumberFromStudiensemester($ersterStudent->studiensemester_kurzbz);
|
||||
|
||||
if ($studienjahrNumber != mb_substr($ersterStudent->matrikelnr, 0, 2))
|
||||
{
|
||||
return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_personenkennzeichenPasstNichtZuStudiensemester'));
|
||||
}
|
||||
|
||||
// wenn erster Studentstatus, checken ob Orgform des Bewerbers mit Studenten übereinstimmt
|
||||
if (!isEmptyArray(
|
||||
array_filter(
|
||||
$restliche_status_obj,
|
||||
function ($s) use ($ersterStudent) {
|
||||
return
|
||||
$s->status_kurzbz == self::BEWERBER_STATUS
|
||||
&& (
|
||||
$s->studienplan_orgform_kurzbz != $ersterStudent->studienplan_orgform_kurzbz
|
||||
);
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_bewerberOrgformUngleichStudentOrgform'));
|
||||
}
|
||||
}
|
||||
|
||||
return $resultPs;
|
||||
}
|
||||
}
|
||||
@@ -358,6 +358,35 @@ EOSC;
|
||||
*/
|
||||
private function _student($searchstr, $type)
|
||||
{
|
||||
$dbModel = new DB_Model();
|
||||
|
||||
$students = $dbModel->execReadOnlyQuery('
|
||||
SELECT
|
||||
\''.$type.'\' AS type,
|
||||
s.student_uid AS uid,
|
||||
s.matrikelnr,
|
||||
p.person_id AS person_id,
|
||||
p.vorname || \' \' || p.nachname AS name,
|
||||
k.kontakt as email ,
|
||||
p.foto
|
||||
FROM public.tbl_student s
|
||||
JOIN public.tbl_benutzer b ON(b.uid = s.student_uid)
|
||||
JOIN public.tbl_person p USING(person_id)
|
||||
LEFT JOIN (
|
||||
SELECT kontakt, person_id
|
||||
FROM public.tbl_kontakt
|
||||
WHERE kontakttyp = \'email\'
|
||||
) as k USING(person_id)
|
||||
WHERE b.uid ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
OR p.vorname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
OR p.nachname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
GROUP BY type, s.student_uid, s.matrikelnr, p.person_id, name, email, p.foto
|
||||
');
|
||||
|
||||
// If something has been found then return it
|
||||
if (hasData($students)) return getData($students);
|
||||
|
||||
// Otherwise return an empty array
|
||||
return array();
|
||||
}
|
||||
|
||||
@@ -366,6 +395,41 @@ EOSC;
|
||||
*/
|
||||
private function _prestudent($searchstr, $type)
|
||||
{
|
||||
$dbModel = new DB_Model();
|
||||
|
||||
$prestudent = $dbModel->execReadOnlyQuery('
|
||||
SELECT
|
||||
\''.$type.'\' AS type,
|
||||
ps.prestudent_id,
|
||||
ps.studiengang_kz,
|
||||
p.person_id AS person_id,
|
||||
b.uid,
|
||||
p.vorname || \' \' || p.nachname AS name,
|
||||
(
|
||||
SELECT kontakt
|
||||
FROM public.tbl_kontakt
|
||||
WHERE kontakttyp = \'email\'
|
||||
AND person_id = p.person_id
|
||||
LIMIT 1
|
||||
) as email,
|
||||
p.foto,
|
||||
sg.bezeichnung
|
||||
FROM public.tbl_prestudent ps
|
||||
LEFT JOIN public.tbl_student s USING (prestudent_id)
|
||||
LEFT JOIN public.tbl_benutzer b ON (b.uid = s.student_uid)
|
||||
JOIN public.tbl_person p ON (p.person_id = ps.person_id)
|
||||
LEFT JOIN public.tbl_studiengang sg ON (sg.studiengang_kz = ps.studiengang_kz)
|
||||
WHERE b.uid ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
OR p.vorname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
OR p.nachname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
or cast(ps.prestudent_id as text) ILIKE \'%'.$dbModel->escapeLIKE($searchstr).'%\'
|
||||
GROUP BY type, b.uid, ps.prestudent_id, ps.studiengang_kz, sg.bezeichnung, s.student_uid, s.matrikelnr, p.person_id, name, email, p.foto
|
||||
');
|
||||
|
||||
// If something has been found then return it
|
||||
if (hasData($prestudent)) return getData($prestudent);
|
||||
|
||||
// Otherwise return an empty array
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,8 @@ class UDFLib
|
||||
|
||||
private $_udfUniqueId; // Property that contains the UDF widget unique id
|
||||
|
||||
private $_definition_cache = [];
|
||||
|
||||
/**
|
||||
* Gets CI instance
|
||||
*/
|
||||
@@ -157,7 +159,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)
|
||||
{
|
||||
@@ -292,7 +294,7 @@ class UDFLib
|
||||
// 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})))
|
||||
|| !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}))
|
||||
@@ -353,7 +355,7 @@ class UDFLib
|
||||
// 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})))
|
||||
|| !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}))
|
||||
@@ -613,6 +615,162 @@ class UDFLib
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the UDF definitions for a model
|
||||
*
|
||||
* @param DB_Model $targetModel
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getDefinitionForModel($targetModel)
|
||||
{
|
||||
$dbTable = $targetModel->getDbTable();
|
||||
if (!isset($this->_definition_cache[$dbTable])) {
|
||||
$this->_ci->load->model('system/UDF_model', 'UDFModel');
|
||||
list($schema, $table) = explode('.', $dbTable);
|
||||
$result = $this->_ci->UDFModel->loadWhere([
|
||||
'schema' => $schema,
|
||||
'table' => $table
|
||||
]);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (!hasData($result))
|
||||
$this->_definition_cache[$dbTable] = [];
|
||||
else
|
||||
$this->_definition_cache[$dbTable] = json_decode(current($result->retval)->jsons, true);
|
||||
}
|
||||
return success($this->_definition_cache[$dbTable]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the UDFs for db entry with translated params and resolved listValues for dropdowns
|
||||
*
|
||||
* @param DB_Model $targetModel
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getFieldArray($targetModel, $id)
|
||||
{
|
||||
// Load Libraries
|
||||
$this->_ci->load->library('PhrasesLib');
|
||||
$this->_ci->load->library('PermissionLib');
|
||||
|
||||
$result = $this->getDefinitionForModel($targetModel);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$definitions = $result->retval;
|
||||
|
||||
usort($definitions, function ($a, $b) {
|
||||
return $a[self::SORT] - $b[self::SORT];
|
||||
});
|
||||
|
||||
$values = $targetModel->getUDFs($id);
|
||||
|
||||
$fields = [];
|
||||
foreach ($definitions as $field) {
|
||||
// check read permissions
|
||||
if (!$this->_ci->permissionlib->hasAtLeastOne(
|
||||
$field[self::REQUIRED_PERMISSIONS_PARAMETER],
|
||||
self::PERMISSION_TABLE_METHOD,
|
||||
self::PERMISSION_TYPE_READ
|
||||
))
|
||||
continue;
|
||||
|
||||
// set value
|
||||
if (isset($values[$field[self::NAME]])) {
|
||||
$field['value'] = $values[$field[self::NAME]];
|
||||
} elseif (isset($field['defaultValue'])) {
|
||||
$field['value'] = $field['defaultValue'];
|
||||
} elseif (isset($field[self::TYPE]) && $field[self::TYPE] == 'checkbox') {
|
||||
$field['value'] = false;
|
||||
} else {
|
||||
$field['value'] = '';
|
||||
}
|
||||
|
||||
// translate params
|
||||
foreach ([self::LABEL, self::TITLE, self::PLACEHOLDER] as $key) {
|
||||
if (isset($field[$key])) {
|
||||
$res = $this->_ci->phraseslib->getPhrases(self::PHRASES_APP_NAME, getUserLanguage(), $field[$key], null, null, 'no');
|
||||
if (hasData($res))
|
||||
$field[$key] = current(getData($res))->text;
|
||||
}
|
||||
}
|
||||
|
||||
// check write permissions
|
||||
$field['disabled'] = !$this->_ci->permissionlib->hasAtLeastOne(
|
||||
$field[self::REQUIRED_PERMISSIONS_PARAMETER],
|
||||
self::PERMISSION_TABLE_METHOD,
|
||||
self::PERMISSION_TYPE_WRITE
|
||||
);
|
||||
|
||||
// set listValues for dropdowns
|
||||
if (isset($field[self::LIST_VALUES])) {
|
||||
if (isset($field[self::LIST_VALUES]['enum'])) {
|
||||
$field['options'] = $field[self::LIST_VALUES]['enum'];
|
||||
} elseif (isset($field[self::LIST_VALUES]['sql'])) {
|
||||
$res = $this->_ci->UDFModel->execReadOnlyQuery($field[self::LIST_VALUES]['sql']);
|
||||
$field['options'] = hasData($res) ? getData($res) : [];
|
||||
}
|
||||
}
|
||||
|
||||
// add to array
|
||||
$fields[] = $field;
|
||||
}
|
||||
return success($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a validation config array for CI form_validation
|
||||
*
|
||||
* @param DB_Model $targetModel
|
||||
* @param array (optional) $filter
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getCiValidations($targetModel, $filter = null)
|
||||
{
|
||||
$result = $this->getDefinitionForModel($targetModel);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$definitions = getData($result);
|
||||
|
||||
$result = [];
|
||||
foreach ($definitions as $def) {
|
||||
if ($filter && !isset($filter[$def['name']]))
|
||||
continue;
|
||||
$validations = [];
|
||||
if (isset($def['requiredPermissions']))
|
||||
$validations[] = 'has_write_permissions[' . implode(',', $def['requiredPermissions']) . ']';
|
||||
if (isset($def['required']))
|
||||
$validations[] = 'required';
|
||||
if (isset($def['validation'])) {
|
||||
if (isset($def['validation']['max-value']))
|
||||
$validations[] = 'less_than_equal_to[' . $def['validation']['max-value'] . ']';
|
||||
if (isset($def['validation']['min-value']))
|
||||
$validations[] = 'greater_than_equal_to[' . $def['validation']['min-value'] . ']';
|
||||
if (isset($def['validation']['max-length']))
|
||||
$validations[] = 'max_length[' . $def['validation']['max-length'] . ']';
|
||||
if (isset($def['validation']['min-length']))
|
||||
$validations[] = 'min_length[' . $def['validation']['min-length'] . ']';
|
||||
if (isset($def['validation']['regex']) && is_array($def['validation']['regex'])) {
|
||||
foreach ($def['validation']['regex'] as $regex) {
|
||||
if ($regex['language'] == 'php') {
|
||||
$validations[] = 'regex_match[' . $regex['expression'] . ']';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($validations)
|
||||
$result[] = [
|
||||
'field' => $def['name'],
|
||||
'label' => $def['title'],
|
||||
'rules' => $validations
|
||||
];
|
||||
}
|
||||
return success($result);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
//
|
||||
@@ -841,7 +999,7 @@ class UDFLib
|
||||
$htmlParameters[HTMLWidget::HTML_ID] = $jsonSchema->{self::NAME};
|
||||
$htmlParameters[HTMLWidget::HTML_NAME] = $jsonSchema->{self::NAME};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sort the list of UDF by sort property
|
||||
*/
|
||||
@@ -864,7 +1022,7 @@ class UDFLib
|
||||
return ($a->{self::SORT} < $b->{self::SORT}) ? -1 : 1;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads the UDF description by the given schema and table
|
||||
*/
|
||||
|
||||
@@ -15,7 +15,6 @@ class PlausicheckDefinitionLib
|
||||
'AktSemesterNull' => 'AktSemesterNull',
|
||||
'AktiverStudentOhneStatus' => 'AktiverStudentOhneStatus',
|
||||
'AusbildungssemPrestudentUngleichAusbildungssemStatus' => 'AusbildungssemPrestudentUngleichAusbildungssemStatus',
|
||||
'BewerberNichtZumRtAngetreten' => 'BewerberNichtZumRtAngetreten',
|
||||
'DatumAbschlusspruefungFehlt' => 'DatumAbschlusspruefungFehlt',
|
||||
'DatumSponsionFehlt' => 'DatumSponsionFehlt',
|
||||
'DatumStudiensemesterFalscheReihenfolge' => 'DatumStudiensemesterFalscheReihenfolge',
|
||||
@@ -33,8 +32,10 @@ class PlausicheckDefinitionLib
|
||||
'PrestudentMischformOhneOrgform' => 'PrestudentMischformOhneOrgform',
|
||||
'StgPrestudentUngleichStgStudienplan' => 'StgPrestudentUngleichStgStudienplan',
|
||||
'StgPrestudentUngleichStgStudent' => 'StgPrestudentUngleichStgStudent',
|
||||
'StudentstatusNachAbbrecher' => 'StudentstatusNachAbbrecher'
|
||||
'StudentstatusNachAbbrecher' => 'StudentstatusNachAbbrecher',
|
||||
'DualesStudiumOhneMarkierung' => 'DualesStudiumOhneMarkierung'
|
||||
//'StudienplanUngueltig' => 'StudienplanUngueltig'
|
||||
//'BewerberNichtZumRtAngetreten' => 'BewerberNichtZumRtAngetreten'
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,19 +12,25 @@ class PlausicheckProducerLib
|
||||
|
||||
private $_ci; // ci instance
|
||||
private $_extensionName; // name of extension
|
||||
private $_app; // name of application
|
||||
private $_konfiguration = array(); // konfigratio parameters
|
||||
private $_konfiguration = []; // configuration parameters
|
||||
private $_fehlerLibMappings = []; // mappings of fehler and libraries for producing them
|
||||
private $_isForResolutionCheck = false; // mappings of fehler and libraries for producing them
|
||||
|
||||
public function __construct($params = null)
|
||||
{
|
||||
// set extension name if called from extension
|
||||
if (isset($params['extensionName'])) $this->_extensionName = $params['extensionName'];
|
||||
if (isset($params['fehlerLibMappings'])) $this->_fehlerLibMappings = $params['fehlerLibMappings'];
|
||||
if (isset($params['isForResolutionCheck'])) $this->_isForResolutionCheck = $params['isForResolutionCheck'];
|
||||
|
||||
// set application
|
||||
$app = isset($params['app']) ? $params['app'] : null;
|
||||
|
||||
$this->_ci =& get_instance(); // get ci instance
|
||||
|
||||
// load libraries
|
||||
$this->_ci->load->library('IssuesLib');
|
||||
|
||||
// load models
|
||||
$this->_ci->load->model('system/Fehlerkonfiguration_model', 'FehlerkonfigurationModel');
|
||||
|
||||
@@ -42,6 +48,52 @@ class PlausicheckProducerLib
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces multiple plausicheck issues at once and saved them to db.
|
||||
* @param array $params passed to each plausicheck
|
||||
* @return result object with occured error and info
|
||||
*/
|
||||
public function producePlausicheckIssues($params)
|
||||
{
|
||||
$result = new StdClass();
|
||||
$result->errors = [];
|
||||
$result->infos = [];
|
||||
|
||||
foreach ($this->_fehlerLibMappings as $fehler_kurzbz => $libName)
|
||||
{
|
||||
$plausicheckRes = $this->producePlausicheckIssue(
|
||||
$libName,
|
||||
$fehler_kurzbz,
|
||||
$params
|
||||
);
|
||||
|
||||
if (hasData($plausicheckRes))
|
||||
{
|
||||
$plausicheckData = getData($plausicheckRes);
|
||||
|
||||
foreach ($plausicheckData as $plausiData)
|
||||
{
|
||||
// get the data needed for issue production
|
||||
$person_id = isset($plausiData['person_id']) ? $plausiData['person_id'] : null;
|
||||
$oe_kurzbz = isset($plausiData['oe_kurzbz']) ? $plausiData['oe_kurzbz'] : null;
|
||||
$fehlertext_params = isset($plausiData['fehlertext_params']) ? $plausiData['fehlertext_params'] : null;
|
||||
$resolution_params = isset($plausiData['resolution_params']) ? $plausiData['resolution_params'] : null;
|
||||
|
||||
// write the issue
|
||||
$addIssueRes = $this->_ci->issueslib->addFhcIssue($fehler_kurzbz, $person_id, $oe_kurzbz, $fehlertext_params, $resolution_params);
|
||||
|
||||
// log if error, or log info if inserted new issue
|
||||
if (isError($addIssueRes))
|
||||
$result->errors[] = getError($addIssueRes);
|
||||
elseif (hasData($addIssueRes) && is_integer(getData($addIssueRes)))
|
||||
$result->infos[] = "Plausicheck issue " . $fehler_kurzbz . " successfully produced, person_id: " . $person_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes plausicheck using a given library, returns the result.
|
||||
* @param $libName string name of library producing the issue
|
||||
@@ -67,7 +119,10 @@ class PlausicheckProducerLib
|
||||
$config = isset($this->_konfiguration[$fehler_kurzbz]) ? $this->_konfiguration[$fehler_kurzbz] : null;
|
||||
|
||||
// load library connected to fehlercode
|
||||
$this->_ci->load->library($issuesLibPath . $libName, $config);
|
||||
$this->_ci->load->library(
|
||||
$issuesLibPath . $libName,
|
||||
['configurationParams' => $config, 'isForResolutionCheck' => $this->_isForResolutionCheck]
|
||||
);
|
||||
|
||||
$lowercaseLibName = mb_strtolower($libName);
|
||||
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class PlausicheckResolverLib
|
||||
{
|
||||
const CI_PATH = 'application';
|
||||
const CI_LIBRARY_FOLDER = 'libraries';
|
||||
const EXTENSIONS_FOLDER = 'extensions';
|
||||
const ISSUE_RESOLVERS_FOLDER = 'issues/resolvers';
|
||||
const CHECK_ISSUE_RESOLVED_METHOD_NAME = 'checkIfIssueIsResolved';
|
||||
|
||||
private $_ci; // ci instance
|
||||
private $_extensionName; // name of extension
|
||||
private $_codeLibMappings = []; // mappings for issues which explicitly defined resolver
|
||||
private $_codeProducerLibMappings = []; // mappings for issues which are resolved as produced
|
||||
|
||||
public function __construct($params = null)
|
||||
{
|
||||
// set extension name if called from extension
|
||||
if (isset($params['extensionName'])) $this->_extensionName = $params['extensionName'];
|
||||
if (isset($params['codeLibMappings'])) $this->_codeLibMappings = $params['codeLibMappings'];
|
||||
if (isset($params['codeProducerLibMappings'])) $this->_codeProducerLibMappings = $params['codeProducerLibMappings'];
|
||||
|
||||
$this->_ci =& get_instance(); // get ci instance
|
||||
|
||||
$this->_ci->load->library('IssuesLib');
|
||||
$this->_ci->load->library('issues/PlausicheckProducerLib', ['extensionName' => $this->_extensionName, 'isForResolutionCheck' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reseolves multiple plausicheck issues at once.
|
||||
* @param array $codeLibMappings contains fehler type to check and library responsible for check (fehlercode => libName)
|
||||
* @param array $openIssues passed issues to resolve
|
||||
* @return result object with occured error and info
|
||||
*/
|
||||
public function resolvePlausicheckIssues($openIssues)
|
||||
{
|
||||
$result = new StdClass();
|
||||
$result->errors = [];
|
||||
$result->infos = [];
|
||||
|
||||
foreach ($openIssues as $issue)
|
||||
{
|
||||
// add person id and oe kurzbz automatically as params, merge it with additional params
|
||||
// decode bewerbung_parameter into assoc array
|
||||
$params = array_merge(
|
||||
array('issue_id' => $issue->issue_id, 'issue_person_id' => $issue->person_id, 'issue_oe_kurzbz' => $issue->oe_kurzbz),
|
||||
isset($issue->behebung_parameter) ? json_decode($issue->behebung_parameter, true) : array()
|
||||
);
|
||||
|
||||
$issueResolved = false;
|
||||
|
||||
// ignore if Fehlercode is not in libmappings (shouldn't be checked)
|
||||
if (isset($this->_codeLibMappings[$issue->fehlercode]))
|
||||
{
|
||||
$libName = $this->_codeLibMappings[$issue->fehlercode];
|
||||
|
||||
// if called from extension (extension name set), path includes extension names
|
||||
$libRootPath = isset($this->_extensionName) ? self::EXTENSIONS_FOLDER . '/' . $this->_extensionName . '/' : '';
|
||||
|
||||
// path for loading issue library
|
||||
$issuesLibPath = $libRootPath . self::ISSUE_RESOLVERS_FOLDER . '/';
|
||||
|
||||
// file path of library for check if file exists
|
||||
$issuesLibFilePath = DOC_ROOT . self::CI_PATH
|
||||
. '/' . $libRootPath . self::CI_LIBRARY_FOLDER . '/' . self::ISSUE_RESOLVERS_FOLDER . '/' . $libName . '.php';
|
||||
|
||||
// check if library file exists
|
||||
if (!file_exists($issuesLibFilePath))
|
||||
{
|
||||
// log error and continue with next issue if not
|
||||
$result->errors[] = "Issue library file " . $issuesLibFilePath . " does not exist";
|
||||
continue;
|
||||
}
|
||||
|
||||
// load library connected to fehlercode
|
||||
$this->_ci->load->library($issuesLibPath . $libName);
|
||||
|
||||
$lowercaseLibName = mb_strtolower($libName);
|
||||
|
||||
// check if method is defined in library class
|
||||
if (!is_callable(array($this->_ci->{$lowercaseLibName}, self::CHECK_ISSUE_RESOLVED_METHOD_NAME)))
|
||||
{
|
||||
// log error and continue with next issue if not
|
||||
$result->errors[] = "Method " . self::CHECK_ISSUE_RESOLVED_METHOD_NAME . " is not defined in library $lowercaseLibName";
|
||||
continue;
|
||||
}
|
||||
|
||||
// call the function for checking for issue resolution
|
||||
$issueResolvedRes = $this->_ci->{$lowercaseLibName}->{self::CHECK_ISSUE_RESOLVED_METHOD_NAME}($params);
|
||||
|
||||
if (isError($issueResolvedRes))
|
||||
{
|
||||
$result->errors[] = getError($issueResolvedRes);
|
||||
}
|
||||
else
|
||||
{
|
||||
$issueResolved = getData($issueResolvedRes) === true;
|
||||
}
|
||||
}
|
||||
elseif (isset($this->_codeProducerLibMappings[$issue->fehlercode]))
|
||||
{
|
||||
$libName = $this->_codeProducerLibMappings[$issue->fehlercode];
|
||||
|
||||
$issueResolvedRes = $this->_ci->plausicheckproducerlib->producePlausicheckIssue(
|
||||
$libName,
|
||||
$issue->fehler_kurzbz,
|
||||
$params
|
||||
);
|
||||
|
||||
if (isError($issueResolvedRes))
|
||||
{
|
||||
$result->errors[] = getError($issueResolvedRes);
|
||||
}
|
||||
else
|
||||
{
|
||||
$issueResolved = !hasData($issueResolvedRes);
|
||||
}
|
||||
}
|
||||
|
||||
// set issue to resolved if needed
|
||||
if ($issueResolved)
|
||||
{
|
||||
$behobenRes = $this->_ci->issueslib->setBehoben($issue->issue_id, null);
|
||||
|
||||
if (isError($behobenRes))
|
||||
$result->errors[] = getError($behobenRes);
|
||||
else
|
||||
$result->infos[] = "Issue " . $issue->issue_id . " successfully resolved";
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -9,83 +9,21 @@ require_once('PlausiChecker.php');
|
||||
*/
|
||||
class AbbrecherAktiv extends PlausiChecker
|
||||
{
|
||||
public function executePlausiCheck($params)
|
||||
{
|
||||
$results = array();
|
||||
protected $_base_sql = "
|
||||
SELECT
|
||||
pre.person_id, pre.prestudent_id, stg.oe_kurzbz AS prestudent_stg_oe_kurzbz
|
||||
FROM
|
||||
public.tbl_prestudentstatus pre_status
|
||||
JOIN public.tbl_prestudent pre USING(prestudent_id)
|
||||
JOIN public.tbl_student student USING(prestudent_id)
|
||||
JOIN public.tbl_benutzer benutzer on(benutzer.uid=student.student_uid)
|
||||
JOIN public.tbl_studiengang stg ON pre.studiengang_kz = stg.studiengang_kz
|
||||
WHERE
|
||||
pre_status.status_kurzbz ='Abbrecher'
|
||||
AND benutzer.aktiv=true";
|
||||
|
||||
// get parameters from config
|
||||
$exkludierte_studiengang_kz = isset($this->_config['exkludierteStudiengaenge']) ? $this->_config['exkludierteStudiengaenge'] : null;
|
||||
|
||||
// pass parameters needed for plausicheck
|
||||
$studiengang_kz = isset($params['studiengang_kz']) ? $params['studiengang_kz'] : null;
|
||||
|
||||
// get all students failing the plausicheck
|
||||
$prestudentRes = $this->getAbbrecherAktiv($studiengang_kz, null, $exkludierte_studiengang_kz);
|
||||
|
||||
if (isError($prestudentRes)) return $prestudentRes;
|
||||
|
||||
if (hasData($prestudentRes))
|
||||
{
|
||||
$prestudents = getData($prestudentRes);
|
||||
|
||||
// populate results with data necessary for writing issues
|
||||
foreach ($prestudents as $prestudent)
|
||||
{
|
||||
$results[] = array(
|
||||
'person_id' => $prestudent->person_id,
|
||||
'oe_kurzbz' => $prestudent->prestudent_stg_oe_kurzbz,
|
||||
'fehlertext_params' => array('prestudent_id' => $prestudent->prestudent_id),
|
||||
'resolution_params' => array('prestudent_id' => $prestudent->prestudent_id)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// return the results
|
||||
return success($results);
|
||||
}
|
||||
|
||||
/**
|
||||
* Abbrecher cannot be active.
|
||||
* @param studiengang_kz int if check is to be executed for certain Studiengang
|
||||
* @param prestudent_id int if check is to be executed only for one prestudent
|
||||
* @param exkludierte_studiengang_kz array if certain Studiengänge have to be excluded from check
|
||||
* @return success with prestudents or error
|
||||
*/
|
||||
public function getAbbrecherAktiv($studiengang_kz = null, $prestudent_id = null, $exkludierte_studiengang_kz = null)
|
||||
{
|
||||
$params = array();
|
||||
|
||||
$qry = "
|
||||
SELECT
|
||||
pre.person_id, pre.prestudent_id, stg.oe_kurzbz AS prestudent_stg_oe_kurzbz
|
||||
FROM
|
||||
public.tbl_prestudentstatus pre_status
|
||||
JOIN public.tbl_prestudent pre USING(prestudent_id)
|
||||
JOIN public.tbl_student student USING(prestudent_id)
|
||||
JOIN public.tbl_benutzer benutzer on(benutzer.uid=student.student_uid)
|
||||
JOIN public.tbl_studiengang stg ON pre.studiengang_kz = stg.studiengang_kz
|
||||
WHERE
|
||||
pre_status.status_kurzbz ='Abbrecher'
|
||||
AND benutzer.aktiv=true";
|
||||
|
||||
if (isset($studiengang_kz))
|
||||
{
|
||||
$qry .= " AND stg.studiengang_kz = ?";
|
||||
$params[] = $studiengang_kz;
|
||||
}
|
||||
|
||||
if (isset($prestudent_id))
|
||||
{
|
||||
$qry .= " AND pre.prestudent_id = ?";
|
||||
$params[] = $prestudent_id;
|
||||
}
|
||||
|
||||
if (isset($exkludierte_studiengang_kz) && !isEmptyArray($exkludierte_studiengang_kz))
|
||||
{
|
||||
$qry .= " AND stg.studiengang_kz NOT IN ?";
|
||||
$params[] = $exkludierte_studiengang_kz;
|
||||
}
|
||||
|
||||
return $this->_db->execReadOnlyQuery($qry, $params);
|
||||
}
|
||||
protected $_config_params = ['exkludierteStudiengaenge' => " AND stg.studiengang_kz NOT IN ?"];
|
||||
protected $_params_for_checking = ['studiengang_kz' => " AND stg.studiengang_kz = ?", 'prestudent_id' => " AND pre.prestudent_id = ?"];
|
||||
protected $_fehlertext_params = ['prestudent_id'];
|
||||
protected $_resolution_params = ['prestudent_id'];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
require_once('PlausiChecker.php');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class DualesStudiumOhneMarkierung extends PlausiChecker
|
||||
{
|
||||
public function executePlausiCheck($params)
|
||||
{
|
||||
$results = array();
|
||||
|
||||
// get parameters from config
|
||||
$exkludierte_studiengang_kz = isset($this->_config['exkludierteStudiengaenge']) ? $this->_config['exkludierteStudiengaenge'] : null;
|
||||
|
||||
// pass parameters needed for plausicheck
|
||||
$studiensemester_kurzbz = isset($params['studiensemester_kurzbz']) ? $params['studiensemester_kurzbz'] : null;
|
||||
$studiengang_kz = isset($params['studiengang_kz']) ? $params['studiengang_kz'] : null;
|
||||
|
||||
// get all students failing the plausicheck
|
||||
$prestudentRes = $this->getDualesStudiumOhneMarkierung(
|
||||
$studiensemester_kurzbz,
|
||||
$studiengang_kz,
|
||||
null,
|
||||
$exkludierte_studiengang_kz
|
||||
);
|
||||
|
||||
if (isError($prestudentRes)) return $prestudentRes;
|
||||
|
||||
if (hasData($prestudentRes))
|
||||
{
|
||||
$prestudents = getData($prestudentRes);
|
||||
|
||||
// populate results with data necessary for writing issues
|
||||
foreach ($prestudents as $prestudent)
|
||||
{
|
||||
$results[] = array(
|
||||
'person_id' => $prestudent->person_id,
|
||||
'oe_kurzbz' => $prestudent->prestudent_stg_oe_kurzbz,
|
||||
'fehlertext_params' => array(
|
||||
'prestudent_id' => $prestudent->prestudent_id,
|
||||
'studienplan' => $prestudent->studienplan
|
||||
),
|
||||
'resolution_params' => array(
|
||||
'prestudent_id' => $prestudent->prestudent_id,
|
||||
'studiensemester_kurzbz' => $prestudent->studiensemester_kurzbz
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// return the results
|
||||
return success($results);
|
||||
}
|
||||
|
||||
/**
|
||||
* All prestudents in dual Studiengang should have set the dual flag to true.
|
||||
* @param studiensemester_kurzbz string check is to be executed for certain Studiensemester
|
||||
* @param studiengang_kz int if check is to be executed for certain Studiengang
|
||||
* @param prestudent_id int if check is to be executed only for one prestudent
|
||||
* @param exkludierte_studiengang_kz array if certain Studiengänge have to be excluded from check
|
||||
* @return success with prestudents or error
|
||||
*/
|
||||
public function getDualesStudiumOhneMarkierung(
|
||||
$studiensemester_kurzbz,
|
||||
$studiengang_kz = null,
|
||||
$prestudent_id = null,
|
||||
$exkludierte_studiengang_kz = null
|
||||
) {
|
||||
$params = array($studiensemester_kurzbz);
|
||||
|
||||
$qry = "
|
||||
SELECT
|
||||
DISTINCT pre.person_id, pre.prestudent_id,
|
||||
stpl.bezeichnung AS studienplan,
|
||||
status.studiensemester_kurzbz,
|
||||
status.ausbildungssemester,
|
||||
stg.oe_kurzbz AS prestudent_stg_oe_kurzbz
|
||||
FROM
|
||||
public.tbl_prestudent pre
|
||||
JOIN public.tbl_prestudentstatus status USING(prestudent_id)
|
||||
JOIN public.tbl_person USING(person_id)
|
||||
JOIN lehre.tbl_studienplan stpl USING(studienplan_id)
|
||||
JOIN public.tbl_studiengang stg ON pre.studiengang_kz = stg.studiengang_kz
|
||||
JOIN public.tbl_studiensemester sem USING(studiensemester_kurzbz)
|
||||
WHERE
|
||||
(stpl.orgform_kurzbz = 'DUA' OR status.orgform_kurzbz = 'DUA')
|
||||
AND pre.dual = FALSE
|
||||
AND status.studiensemester_kurzbz=?
|
||||
AND pre.bismelden
|
||||
AND stg.melderelevant
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM
|
||||
public.tbl_prestudentstatus
|
||||
JOIN lehre.tbl_studienplan USING(studienplan_id)
|
||||
JOIN public.tbl_studiensemester USING(studiensemester_kurzbz)
|
||||
WHERE
|
||||
prestudent_id = pre.prestudent_id
|
||||
AND
|
||||
(
|
||||
-- if there is a newer non-dual status, dual has not to be set
|
||||
(
|
||||
(
|
||||
tbl_studienplan.orgform_kurzbz <> stpl.orgform_kurzbz
|
||||
OR status.orgform_kurzbz <> tbl_prestudentstatus.orgform_kurzbz
|
||||
)
|
||||
AND
|
||||
(
|
||||
tbl_studiensemester.ende::date > sem.ende::date
|
||||
OR (tbl_studiensemester.ende::date = sem.ende::date AND tbl_prestudentstatus.datum::date > status.datum::date)
|
||||
)
|
||||
)
|
||||
OR
|
||||
-- exclude Abgewiesene - they are not reported
|
||||
tbl_prestudentstatus.status_kurzbz = 'Abgewiesener'
|
||||
)
|
||||
)";
|
||||
|
||||
if (isset($studiengang_kz))
|
||||
{
|
||||
$qry .= " AND stg.studiengang_kz = ?";
|
||||
$params[] = $studiengang_kz;
|
||||
}
|
||||
|
||||
if (isset($prestudent_id))
|
||||
{
|
||||
$qry .= " AND pre.prestudent_id = ?";
|
||||
$params[] = $prestudent_id;
|
||||
}
|
||||
|
||||
if (isset($exkludierte_studiengang_kz) && !isEmptyArray($exkludierte_studiengang_kz))
|
||||
{
|
||||
$qry .= " AND stg.studiengang_kz NOT IN ?";
|
||||
$params[] = $exkludierte_studiengang_kz;
|
||||
}
|
||||
|
||||
return $this->_db->execReadOnlyQuery($qry, $params);
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,7 @@ class InaktiverStudentAktiverStatus extends PlausiChecker
|
||||
$prestudent_id = null,
|
||||
$exkludierte_studiengang_kz = null
|
||||
) {
|
||||
$this->_ci->load->model('organisation/studiensemester_model', 'StudiensemesterModel');
|
||||
$aktStudiensemesterRes = $this->_ci->StudiensemesterModel->getAkt();
|
||||
|
||||
if (isError($aktStudiensemesterRes)) return $aktStudiensemesterRes;
|
||||
|
||||
@@ -6,15 +6,25 @@
|
||||
abstract class PlausiChecker
|
||||
{
|
||||
protected $_ci; // code igniter instance
|
||||
protected $_config; // configuration parameters for this plausicheck
|
||||
protected $_config; // all applicable configuration parameters for this plausicheck
|
||||
protected $_db; // database for queries
|
||||
|
||||
public function __construct($configurationParams = null)
|
||||
protected $_isForResolutionCheck; // if true, additional parameters only needed for resolution are checked
|
||||
|
||||
protected $_config_params = []; // name of all config params which should be applied for this plausicheck, with sql [name] => [sql]
|
||||
protected $_params_for_checking = []; // name of all passed params for checking, with sql [name] => [sql]
|
||||
|
||||
protected $_fehlertext_params = []; // parameter names for fehlertext params used for this plausicheck
|
||||
protected $_resolution_params = []; // parameter names for resolution params used for this plausicheck
|
||||
|
||||
public function __construct($params = null)
|
||||
{
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
|
||||
// set configuration
|
||||
$this->_config = $configurationParams;
|
||||
$this->_config = $params['configurationParams'] ?? [];
|
||||
|
||||
$this->_isForResolutionCheck = $params['isForResolutionCheck'] ?? false;
|
||||
|
||||
// get database for queries
|
||||
$this->_db = new DB_Model();
|
||||
@@ -25,5 +35,83 @@ abstract class PlausiChecker
|
||||
* @param $paramsForChecking array parameters needed for executing the check
|
||||
* @return array with objects which failed the plausi check
|
||||
*/
|
||||
abstract public function executePlausiCheck($paramsForChecking);
|
||||
public function executePlausiCheck($paramsForChecking)
|
||||
{
|
||||
$results = [];
|
||||
$params = [];
|
||||
$qry = $this->_base_sql;
|
||||
|
||||
if ($this->_isForResolutionCheck == true)
|
||||
{
|
||||
foreach ($this->_resolution_params as $resParam)
|
||||
{
|
||||
if (!isset($paramsForChecking[$resParam]))
|
||||
return error("$resParam missing".(isset($paramsForChecking['issue_id']) ? ", issue ID: ".$paramsForChecking['issue_id'] : ""));
|
||||
}
|
||||
}
|
||||
|
||||
// add config params to query
|
||||
if (isset($this->_config_params) && !isEmptyArray($this->_config_params))
|
||||
{
|
||||
foreach ($this->_config_params as $param_name => $param_sql)
|
||||
{
|
||||
if (isset($this->_config[$param_name]))
|
||||
{
|
||||
$qry .= $param_sql;
|
||||
$params[] = $this->_config[$param_name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add check params to query
|
||||
if (isset($this->_params_for_checking) && !isEmptyArray($this->_params_for_checking))
|
||||
{
|
||||
foreach ($this->_params_for_checking as $param_name => $param_sql)
|
||||
{
|
||||
if (isset($paramsForChecking[$param_name]))
|
||||
{
|
||||
$qry .= $param_sql;
|
||||
$params[] = $paramsForChecking[$param_name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->_db->execReadOnlyQuery($qry, $params);
|
||||
|
||||
if (isError($result)) return $result;
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
$data = getData($result);
|
||||
|
||||
// populate results with data necessary for writing issues
|
||||
foreach ($data as $d)
|
||||
{
|
||||
$fehlertext_params = [];
|
||||
$resolution_params = [];
|
||||
|
||||
// add params for error texts
|
||||
foreach ($this->_fehlertext_params as $param)
|
||||
{
|
||||
if (isset($d->{$param})) $fehlertext_params[$param] = $d->{$param};
|
||||
}
|
||||
|
||||
// add params for resolution of issue
|
||||
foreach ($this->_resolution_params as $param)
|
||||
{
|
||||
if (isset($d->{$param})) $resolution_params[$param] = $d->{$param};
|
||||
}
|
||||
|
||||
$results[] = array(
|
||||
'person_id' => $d->person_id,
|
||||
'oe_kurzbz' => $d->prestudent_stg_oe_kurzbz,
|
||||
'fehlertext_params' => $fehlertext_params,
|
||||
'resolution_params' => $resolution_params
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// return the results
|
||||
return success($results);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Student in dual Studiengang should have set the dual flag to true.
|
||||
*/
|
||||
class CORE_STUDENTSTATUS_0016 implements IIssueResolvedChecker
|
||||
{
|
||||
public function checkIfIssueIsResolved($params)
|
||||
{
|
||||
if (!isset($params['prestudent_id']) || !is_numeric($params['prestudent_id']))
|
||||
return error('Prestudent Id missing, issue_id: '.$params['issue_id']);
|
||||
|
||||
if (!isset($params['studiensemester_kurzbz']) || isEmptyString($params['studiensemester_kurzbz']))
|
||||
return error('Studiensemester missing, issue_id: '.$params['issue_id']);
|
||||
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
|
||||
$this->_ci->load->library('issues/plausichecks/DualesStudiumOhneMarkierung');
|
||||
|
||||
// check if issue persists
|
||||
$checkRes = $this->_ci->dualesstudiumohnemarkierung->getDualesStudiumOhneMarkierung(
|
||||
$params['studiensemester_kurzbz'],
|
||||
null,
|
||||
$params['prestudent_id']
|
||||
);
|
||||
|
||||
if (isError($checkRes)) return $checkRes;
|
||||
|
||||
if (hasData($checkRes))
|
||||
return success(false); // not resolved if issue is still present
|
||||
else
|
||||
return success(true); // resolved otherwise
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,9 @@ class Dienstverhaeltnis extends AbstractBestandteil {
|
||||
protected $updateamum;
|
||||
protected $updatevon;
|
||||
|
||||
protected $dvendegrund_kurzbz;
|
||||
protected $dvendegrund_anmerkung;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -49,6 +52,8 @@ class Dienstverhaeltnis extends AbstractBestandteil {
|
||||
isset($data->insertvon) && $this->setInsertvon($data->insertvon);
|
||||
isset($data->updateamum) && $this->setUpdateamum($data->updateamum);
|
||||
isset($data->updatevon) && $this->setUpdatevon($data->updatevon);
|
||||
isset($data->dvendegrund_kurzbz) && $this->setDvendegrund_kurzbz($data->dvendegrund_kurzbz);
|
||||
isset($data->dvendegrund_anmerkung) && $this->setDvendegrund_anmerkung($data->dvendegrund_anmerkung);
|
||||
$this->fromdb = false;
|
||||
}
|
||||
|
||||
@@ -64,7 +69,9 @@ class Dienstverhaeltnis extends AbstractBestandteil {
|
||||
'insertamum' => $this->getInsertamum(),
|
||||
'insertvon' => $this->getInsertvon(),
|
||||
'updateamum' => $this->getUpdateamum(),
|
||||
'updatevon' => $this->getUpdatevon()
|
||||
'updatevon' => $this->getUpdatevon(),
|
||||
'dvendegrund_kurzbz' => $this->getDvendegrund_kurzbz(),
|
||||
'dvendegrund_anmerkung' => $this->getDvendegrund_anmerkung()
|
||||
);
|
||||
|
||||
$tmp = array_filter($tmp, function($k) {
|
||||
@@ -139,6 +146,16 @@ EOTXT;
|
||||
return $this->updatevon;
|
||||
}
|
||||
|
||||
public function getDvendegrund_kurzbz()
|
||||
{
|
||||
return $this->dvendegrund_kurzbz;
|
||||
}
|
||||
|
||||
public function getDvendegrund_anmerkung()
|
||||
{
|
||||
return $this->dvendegrund_anmerkung;
|
||||
}
|
||||
|
||||
public function setDienstverhaeltnis_id($dienstverhaeltnis_id)
|
||||
{
|
||||
$this->markDirty('dienstverhaeltnis_id', $this->dienstverhaeltnis_id, $dienstverhaeltnis_id);
|
||||
@@ -214,6 +231,20 @@ EOTXT;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDvendegrund_kurzbz($dvendegrund_kurzbz)
|
||||
{
|
||||
$this->markDirty('dvendegrund_kurzbz', $this->dvendegrund_kurzbz, $dvendegrund_kurzbz);
|
||||
$this->dvendegrund_kurzbz = $dvendegrund_kurzbz;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDvendegrund_anmerkung($dvendegrund_anmerkung)
|
||||
{
|
||||
$this->markDirty('dvendegrund_anmerkung', $this->dvendegrund_anmerkung, $dvendegrund_anmerkung);
|
||||
$this->dvendegrund_anmerkung = $dvendegrund_anmerkung;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function validate() {
|
||||
//do Validation here
|
||||
$ci = get_instance();
|
||||
|
||||
@@ -201,6 +201,10 @@ class Gehaltsbestandteil extends AbstractBestandteil implements \JsonSerializabl
|
||||
|
||||
public function setGrundbetrag($grundbetrag)
|
||||
{
|
||||
if(is_float($grundbetrag))
|
||||
{
|
||||
$grundbetrag = number_format($grundbetrag, 2, '.', '');
|
||||
}
|
||||
$this->markDirty('grundbetrag', $this->grundbetrag, $grundbetrag);
|
||||
$this->grundbetrag = $grundbetrag;
|
||||
return $this;
|
||||
@@ -208,6 +212,10 @@ class Gehaltsbestandteil extends AbstractBestandteil implements \JsonSerializabl
|
||||
|
||||
public function setBetrag_valorisiert($betrag_valorisiert)
|
||||
{
|
||||
if(is_float($betrag_valorisiert))
|
||||
{
|
||||
$betrag_valorisiert = number_format($betrag_valorisiert, 2, '.', '');
|
||||
}
|
||||
$this->markDirty('betrag_valorisiert', $this->betrag_valorisiert, $betrag_valorisiert);
|
||||
$this->betrag_valorisiert = $betrag_valorisiert;
|
||||
return $this;
|
||||
|
||||
@@ -435,7 +435,7 @@ class VertragsbestandteilLib
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function endDienstverhaeltnis(Dienstverhaeltnis $dv, $enddate)
|
||||
public function endDienstverhaeltnis(Dienstverhaeltnis $dv, $enddate, $dvendegrund_kurzbz=null, $dvendegrund_anmerkung=null)
|
||||
{
|
||||
if( $dv->getBis() !== null && $dv->getBis() < $enddate )
|
||||
{
|
||||
@@ -460,6 +460,14 @@ class VertragsbestandteilLib
|
||||
$this->endVertragsbestandteil($vb, $enddate);
|
||||
}
|
||||
|
||||
if( $dvendegrund_kurzbz !== null )
|
||||
{
|
||||
$dv->setDvendegrund_kurzbz($dvendegrund_kurzbz);
|
||||
}
|
||||
if( $dvendegrund_anmerkung !== null )
|
||||
{
|
||||
$dv->setDvendegrund_anmerkung($dvendegrund_anmerkung);
|
||||
}
|
||||
$dv->setBis($enddate);
|
||||
$this->updateDienstverhaeltnis($dv);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user