mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-13 10:09:27 +00:00
BewerberZuStudent: new action turnIntoStudent
This commit is contained in:
@@ -11,14 +11,17 @@ class Status extends FHCAPI_Controller
|
||||
parent::__construct([
|
||||
'getHistoryPrestudent' => ['admin:r', 'assistenz:r'],
|
||||
'addNewStatus' => ['admin:r', 'assistenz:r', 'student/keine_studstatuspruefung'],
|
||||
'turnIntoStudent' => ['admin:r', 'assistenz:r', 'student/keine_studstatuspruefung'],
|
||||
'getStatusgruende' => self::PERM_LOGGED,
|
||||
'getLastBismeldestichtag' => self::PERM_LOGGED,
|
||||
'isLastStatus' => self::PERM_LOGGED,
|
||||
'isErsterStudent' => self::PERM_LOGGED,
|
||||
'deleteStatus' => ['admin:r','assistenz:r'],
|
||||
'loadStatus' => ['admin:r', 'assistenz:r'],
|
||||
'updateStatus' => ['admin:r', 'assistenz:r'],
|
||||
'advanceStatus' => ['admin:r', 'assistenz:r'],
|
||||
'confirmStatus' => ['admin:r', 'assistenz:r']
|
||||
'confirmStatus' => ['admin:r', 'assistenz:r'],
|
||||
|
||||
]);
|
||||
|
||||
//Load Models
|
||||
@@ -91,6 +94,23 @@ class Status extends FHCAPI_Controller
|
||||
return $this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function isErsterStudent($prestudent_id)
|
||||
{
|
||||
//check if studentrolle already exists
|
||||
$this->load->model('crm/Student_model','StudentModel');
|
||||
$result = $this->StudentModel->checkIfExistingStudentRolle($prestudent_id);
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if($result->retval == "0")
|
||||
{
|
||||
return $this->terminateWithSuccess($result);
|
||||
}
|
||||
return $this->terminateWithSuccess($result);
|
||||
|
||||
}
|
||||
|
||||
public function addNewStatus($prestudent_id)
|
||||
{
|
||||
//get Studiengang von prestudent_id
|
||||
@@ -129,7 +149,7 @@ class Status extends FHCAPI_Controller
|
||||
$statusgrund_id = $this->input->post('statusgrund_id');
|
||||
$rt_stufe = $this->input->post('rt_stufe');
|
||||
$bestaetigtvon = $uid;
|
||||
$name = $this->input->post('name');
|
||||
//$name = $this->input->post('name');
|
||||
|
||||
//Form Validation
|
||||
$this->load->library('form_validation');
|
||||
@@ -213,6 +233,7 @@ class Status extends FHCAPI_Controller
|
||||
}
|
||||
$result = current(getData($result));
|
||||
$typ = $result->typ;
|
||||
//$stgkzl = $result->kurzbz;
|
||||
|
||||
if(!defined("ZGV_CHECK") || ZGV_CHECK)
|
||||
{
|
||||
@@ -413,14 +434,248 @@ class Status extends FHCAPI_Controller
|
||||
]
|
||||
);
|
||||
|
||||
if (isError($result)) {
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
} else
|
||||
}
|
||||
else
|
||||
$this->terminateWithSuccess($prestudent_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function turnIntoStudent($prestudent_id)
|
||||
{
|
||||
//get Studiengang von prestudent_id
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
$this->PrestudentModel->addJoin('public.tbl_person p', 'ON (p.person_id = public.tbl_prestudent.person_id)');
|
||||
$this->PrestudentModel->addJoin('public.tbl_studiengang sg', 'ON (sg.studiengang_kz = public.tbl_prestudent.studiengang_kz)');
|
||||
$result = $this->PrestudentModel->load([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
]);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$result = current(getData($result));
|
||||
|
||||
$stg = $result->studiengang_kz;
|
||||
$stgkzl = $result->kurzbz;
|
||||
$person_id = $result->person_id;
|
||||
|
||||
if (!$this->permissionlib->isBerechtigt('admin', 'suid', $stg) && !$this->permissionlib->isBerechtigt('assistenz', 'suid', $stg)) {
|
||||
$result = $this->p->t('lehre', 'error_keineSchreibrechte');
|
||||
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
|
||||
$uid = getAuthUID();
|
||||
$status_kurzbz = $this->input->post('status_kurzbz');
|
||||
$ausbildungssemester = $this->input->post('ausbildungssemester');
|
||||
$bestaetigtam = $this->input->post('bestaetigtam');
|
||||
$studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz');
|
||||
$bestaetigtvon = $uid;
|
||||
|
||||
//Form Validation
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('ausbildungssemester', 'Ausbildungssemester', 'integer', [
|
||||
'integer' => $this->p->t('ui', 'error_fieldNotInteger', ['field' => 'Ausbildungssemester'])
|
||||
]);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
//GET lastStatus
|
||||
$result = $this->PrestudentstatusModel->getLastStatus($prestudent_id);
|
||||
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
} elseif (!hasData($result)) {
|
||||
$lastStatusData = [];
|
||||
} else
|
||||
$lastStatusData = current(getData($result));
|
||||
|
||||
//check if studentrolle already exists
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$result = $this->StudentModel->checkIfExistingStudentRolle($prestudent_id);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if ($result->retval == "0") {
|
||||
$isStudent = false;
|
||||
} else
|
||||
$isStudent = true;
|
||||
|
||||
if (!$isStudent) {
|
||||
//check if bewerberstatus exists
|
||||
$result = $result = $this->prestudentstatuschecklib->checkIfExistingBewerberstatus($prestudent_id);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
//Check ZGV
|
||||
if ($status_kurzbz == Prestudentstatus_model::STATUS_BEWERBER) {
|
||||
$result = $this->prestudentstatuschecklib->checkIfZGVEingetragen($prestudent_id);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
|
||||
//Check ZGV-Master
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
$result = $this->StudiengangModel->load([
|
||||
'studiengang_kz' => $stg
|
||||
]);
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
return $this->outputJson(getError($result));
|
||||
}
|
||||
$result = current(getData($result));
|
||||
$typ = $result->typ;
|
||||
|
||||
if (!defined("ZGV_CHECK") || ZGV_CHECK) {
|
||||
if ($status_kurzbz == Prestudentstatus_model::STATUS_BEWERBER && $typ == 'm') {
|
||||
$result = $this->prestudentstatuschecklib->checkIfZGVEingetragen($prestudent_id, $typ);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//checkIf Kaution bezahlt
|
||||
//TODO(Manu)
|
||||
|
||||
//generate Personenkennzeichen(matrikelnr)
|
||||
//TODO(manu) check if generateMatrikelnummer verwenden or use new version2 (with Type Param)
|
||||
$resultMat = $this->StudentModel->generateMatrikelnummer2($stg, $studiensemester_kurzbz, $typ);
|
||||
if (isError($resultMat)) {
|
||||
return $this->terminateWithError($resultMat, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$matrikelnr = getData($resultMat);
|
||||
$jahr = mb_substr($matrikelnr, 0, 2);
|
||||
|
||||
//generate UID
|
||||
//TODO(Manu) check ausbildungssemester: testfall prestudent_id 26381
|
||||
$resultUid = $this->StudentModel->generateUID($stgkzl, $jahr, $typ, $matrikelnr);
|
||||
if (isError($resultMat)) {
|
||||
return $this->terminateWithError("in generateUid" . $resultUid, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$uidStudent = getData($resultUid);
|
||||
|
||||
//Check for additional logic (config entries, addons)
|
||||
//TODO(Manu) check include/tw/generatematrikelnr.inc.php
|
||||
//(1) addons durchsuchen, ob eigene Logik für Matrikelnr-erstellung existiert
|
||||
//Default: keine Matrikelnummer wird generiert
|
||||
|
||||
//(2) personenkz = uid
|
||||
if (defined('SET_UID_AS_PERSONENKENNZEICHEN') && SET_UID_AS_PERSONENKENNZEICHEN) {
|
||||
$matrikelnr = $uidStudent;
|
||||
}
|
||||
|
||||
//(3) Matrikelnummer = uid
|
||||
if (defined('SET_UID_AS_MATRIKELNUMMER') && SET_UID_AS_MATRIKELNUMMER) {
|
||||
//update person
|
||||
$result = $this->PersonModel->update(
|
||||
[
|
||||
'person_id' => $person_id,
|
||||
],
|
||||
[
|
||||
'matr_nr' => $uidStudent,
|
||||
]
|
||||
);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError("uidAsMatrikelnummer" . getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO(Manu) check if benutzer already exists ok?
|
||||
//person kann mehrere Benutzer haben...
|
||||
//add benutzerdatensatz mit Aktierungscode
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$result = $this->BenutzerModel->checkIfExistingBenutzer($person_id);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if ($result->retval == "0") {
|
||||
|
||||
//activation key
|
||||
$aktivierungscode = null;
|
||||
$result = $this->BenutzerModel->generateActivationKey();
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError("in Error " . $result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$aktivierungscode = getData($result);
|
||||
|
||||
|
||||
//Alias generieren
|
||||
$result = $this->PersonModel->generateAliasByPersonId($person_id);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError("in generate alias " . $result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$alias = getData($result) ?: null;
|
||||
$alias = $alias->retval[0];
|
||||
|
||||
$sanitizedVorname = $this->_sanitizeAliasName($alias->vorname);
|
||||
$sanitizedNachname = $this->_sanitizeAliasName($alias->nachname);
|
||||
|
||||
// Erstelle den Alias
|
||||
$alias = $sanitizedVorname . '.' . $sanitizedNachname;
|
||||
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$result = $this->BenutzerModel->insert(
|
||||
[
|
||||
'person_id' => $person_id,
|
||||
'uid' => $uidStudent,
|
||||
'aktiv' => true,
|
||||
'aktivierungscode' => $aktivierungscode,
|
||||
'alias' => $alias,
|
||||
'insertvon' => $uid,
|
||||
'insertamum' => date('c'),
|
||||
]
|
||||
);
|
||||
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
} else
|
||||
return $this->terminateWithError("Benutzer already existing" . $person_id, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
//Student anlegen
|
||||
$result = $this->StudentModel->insert(
|
||||
[
|
||||
'student_uid' => $uidStudent,
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'matrikelnr' => $matrikelnr,
|
||||
'studiengang_kz' => $stg,
|
||||
'semester' => $ausbildungssemester,
|
||||
'verband' => '',
|
||||
'gruppe' => '',
|
||||
'insertvon' => $uid,
|
||||
'insertamum' => date('c')
|
||||
]
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$this->load->library('PrestudentLib');
|
||||
$result = $this->prestudentlib->setFirstStudent($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, null, $bestaetigtam, $bestaetigtvon, $stg, $uidStudent);
|
||||
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
} else
|
||||
$this->terminateWithSuccess($prestudent_id);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function loadStatus()
|
||||
{
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
@@ -1331,4 +1586,10 @@ class Status extends FHCAPI_Controller
|
||||
}
|
||||
return $this->outputJsonSuccess(true);
|
||||
}
|
||||
|
||||
private function _sanitizeAliasName($str)
|
||||
{
|
||||
$str = sanitizeProblemChars($str);
|
||||
return mb_strtolower(str_replace(' ','_', $str));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,7 +421,6 @@ class PrestudentLib
|
||||
return success();
|
||||
}
|
||||
|
||||
|
||||
public function setStudent($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id, $bestaetigtAm, $bestaetigtVon)
|
||||
{
|
||||
$insertvon = getAuthUID();
|
||||
@@ -522,6 +521,101 @@ class PrestudentLib
|
||||
return success();
|
||||
}
|
||||
|
||||
public function setFirstStudent($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id, $bestaetigtAm, $bestaetigtVon, $stg_kz, $uidStudent)
|
||||
{
|
||||
$insertvon = getAuthUID();
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$resultStatus = getData($result);
|
||||
|
||||
//check if ausbildungssemester is last
|
||||
$this->_ci->StudiengangModel->addJoin('public.tbl_prestudent p', 'studiengang_kz');
|
||||
$resultStg = $this->_ci->StudiengangModel->loadWhere(['p.prestudent_id' => $prestudent_id]);
|
||||
if(isError($resultStg))
|
||||
return $resultStg;
|
||||
/* if(!hasData($resultStg))
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_stg_for_prestudent', [
|
||||
'prestudent_id' => $prestudent_id
|
||||
]));*/
|
||||
|
||||
|
||||
$studiengang = current(getData($resultStg)) ?: null;
|
||||
|
||||
$prestudent_status = ($resultStatus[0]);
|
||||
if(!$prestudent_status)
|
||||
{
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_prestudent_in_sem', [
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz
|
||||
]));
|
||||
}
|
||||
|
||||
/* $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);*/
|
||||
|
||||
//Status updaten
|
||||
$result = $this->_ci->PrestudentstatusModel->insert([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_STUDENT,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'ausbildungssemester' => $ausbildungssemester,
|
||||
'datum' => date('c'),
|
||||
'insertvon' => $insertvon,
|
||||
'insertamum' => date('c'),
|
||||
'orgform_kurzbz'=> $prestudent_status->orgform_kurzbz,
|
||||
'studienplan_id'=> $prestudent_status->studienplan_id,
|
||||
'bestaetigtvon' => $bestaetigtVon,
|
||||
'bestaetigtam' => $bestaetigtAm
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
/* $result = $this->_ci->StudentModel->checkIfUid($prestudent_id);
|
||||
if (isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
$student_uid = $result->retval;*/
|
||||
|
||||
//load student
|
||||
/* $result = $this->_ci->StudentModel->loadWhere(
|
||||
array(
|
||||
'student_uid' => $uidStudent
|
||||
)
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
|
||||
$studentData = current(getData($result) ? : []);*/
|
||||
$verband = '';
|
||||
$gruppe = '';
|
||||
$studiengang_kz = $stg_kz;
|
||||
|
||||
//process studentlehrverband
|
||||
$this->_ci->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel');
|
||||
$result = $this->_ci->StudentlehrverbandModel->processStudentlehrverband(
|
||||
$uidStudent,
|
||||
$studiengang_kz,
|
||||
$ausbildungssemester,
|
||||
$verband,
|
||||
$gruppe,
|
||||
$studiensemester_kurzbz
|
||||
);
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
public function setDiplomand($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester)
|
||||
{
|
||||
$insertvon = getAuthUID();
|
||||
|
||||
@@ -43,9 +43,106 @@ class Student_model extends DB_Model
|
||||
$max = 0;
|
||||
|
||||
$max += 1;
|
||||
|
||||
return $matrikelnummer.sprintf("%03d", $max);
|
||||
}
|
||||
|
||||
// ****
|
||||
// * Generiert die Matrikelnummer
|
||||
// * FORMAT: 0710254001
|
||||
// * 07 = Jahr
|
||||
// * 1/2/0 = WS/SS/incoming
|
||||
// * 0254 = Studiengangskennzahl vierstellig
|
||||
// * 001 = Laufende Nummer
|
||||
// * copy of generateMatrikelnummer plus
|
||||
// * logic FH Burgenland
|
||||
// ****
|
||||
public function generateMatrikelnummer2($studiengang_kz, $studiensemester_kurzbz, $typ = null)
|
||||
{
|
||||
// Validierung der Eingabewerte
|
||||
if (strlen($studiensemester_kurzbz) < 6) {
|
||||
throw new InvalidArgumentException("Ungültiges studiensemester_kurzbz Format.");
|
||||
}
|
||||
|
||||
$jahr = mb_substr($studiensemester_kurzbz, 4);
|
||||
$art = substr($studiensemester_kurzbz, 0, 2);
|
||||
|
||||
if (($studiengang_kz < 0) || (isset($typ) && ($typ == 'l')))
|
||||
{
|
||||
$studiengang_kz=abs($studiengang_kz);
|
||||
//Lehrgang
|
||||
switch($art)
|
||||
{
|
||||
case 'WS': $art = '3'; break;
|
||||
case 'SS': $art = '4'; break;
|
||||
default: $art = '0'; break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Studiengang
|
||||
switch($art)
|
||||
{
|
||||
case 'WS': $art = '1'; break;
|
||||
case 'SS': $art = '2'; break;
|
||||
default: $art = '0'; break;
|
||||
}
|
||||
}
|
||||
if($art=='2' || $art=='4')
|
||||
$jahr = $jahr-1;
|
||||
|
||||
//FH-Burgenland - weil leider die AO Studiengänge aufgeteilt sind
|
||||
//(AO sind normal 9+erhalter Nummer, matrikelnr/personenkz wird auch im DVUH Extension berücksichtigt)
|
||||
if ($studiengang_kz >= 90010 && $studiengang_kz <= 90019)
|
||||
{
|
||||
$matrikelnummer = sprintf("%02d",$jahr).$art.substr($studiengang_kz, 0, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
$matrikelnummer = sprintf("%02d",$jahr).$art.sprintf("%04d",$studiengang_kz);
|
||||
}
|
||||
|
||||
$qry = "SELECT matrikelnr FROM public.tbl_student WHERE matrikelnr LIKE ? ORDER BY matrikelnr DESC LIMIT 1";
|
||||
$matrikelnrres = $this->execQuery($qry, array($matrikelnummer.'%'));
|
||||
|
||||
$max = 0;
|
||||
if ($matrikelnrres && hasData($matrikelnrres)) {
|
||||
$max = mb_substr($matrikelnrres->retval[0]->matrikelnr, 7);
|
||||
if (!is_numeric($max)) {
|
||||
$max = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$max += 1;
|
||||
return success ($matrikelnummer.sprintf("%03d", $max));
|
||||
}
|
||||
|
||||
// ****
|
||||
// * Generiert die UID
|
||||
// * FORMAT: el07b001
|
||||
// * $stgkzl: el = studiengangskuerzel
|
||||
// * $jahr: 07 = Jahr
|
||||
// * $stgtyp: b/m/d/x = Bachelor/Master/Diplom/Incoming
|
||||
// * $matrikelnummer
|
||||
// * 001 = Laufende Nummer Wenn StSem==SS dann wird zur Nummer 500 dazugezaehlt
|
||||
// * Bei Incoming im Masterstudiengang wird auch 500 dazugezaehlt
|
||||
// ****
|
||||
function generateUID($stgkzl, $jahr, $stgtyp, $matrikelnummer)
|
||||
{
|
||||
$art = mb_substr($matrikelnummer, 2, 1);
|
||||
$nr = mb_substr($matrikelnummer, mb_strlen(trim($matrikelnummer))-3);
|
||||
if($art=='2') //Sommersemester
|
||||
$nr = $nr+500;
|
||||
elseif($art=='0' && $stgtyp=='m') //Incoming im Masterstudiengang
|
||||
$nr = $nr+500;
|
||||
elseif($art=='4' && $stgtyp=='l') // Lehrgangsteilnehmer im Sommersemester
|
||||
$nr = $nr+500;
|
||||
|
||||
|
||||
return success (mb_strtolower($stgkzl.$jahr.($art!='0'?$stgtyp:'x').$nr));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get students UID by PrestudentID.
|
||||
* @param $prestudent_id
|
||||
|
||||
@@ -89,9 +89,31 @@ class Benutzer_model extends DB_Model
|
||||
if (hasData($aliasexists) && !getData($aliasexists)[0])
|
||||
$aliasres = $alias;
|
||||
}
|
||||
|
||||
return success($aliasres);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates alias for a uid.
|
||||
* @param $uid
|
||||
* @return array the alias if newly generated
|
||||
*/
|
||||
public function generateAliasByPersonId($person_id)
|
||||
{
|
||||
$sql = 'SELECT p.vorname, p.nachname
|
||||
FROM public.tbl_person p
|
||||
where person_id = ?';
|
||||
|
||||
$nameresult = $this->execQuery($sql, array($person_id));
|
||||
|
||||
$nameresult = getData($nameresult) ?: null;
|
||||
|
||||
// if($aliasdata)
|
||||
// $alias = $this->_sanitizeAliasName($aliasdata->vorname).'.'.$this->_sanitizeAliasName($aliasdata->nachname);
|
||||
|
||||
return success($nameresult->vorname . " " . $nameresult->nachname);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
@@ -105,4 +127,58 @@ class Benutzer_model extends DB_Model
|
||||
$str = sanitizeProblemChars($str);
|
||||
return mb_strtolower(str_replace(' ','_', $str));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generiert einen Aktivierungscode
|
||||
*/
|
||||
function generateActivationKey()
|
||||
{
|
||||
$keyvalues=array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
|
||||
$key='';
|
||||
for($i=0;$i<32;$i++)
|
||||
$key.=$keyvalues[mt_rand(0,15)];
|
||||
|
||||
return success(md5(encryptData(uniqid(mt_rand(), true),$key)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Benutzer already exists
|
||||
* @param integer $person_id
|
||||
* @return 0 if not exists, 1 if it does
|
||||
*/
|
||||
public function checkIfExistingBenutzer($person_id)
|
||||
{
|
||||
$qry = "SELECT
|
||||
count(*) as anzahl
|
||||
FROM
|
||||
public.tbl_benutzer
|
||||
WHERE
|
||||
person_id = ? ";
|
||||
|
||||
$result = $this->execQuery($qry, array($person_id));
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return error($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$resultObject = current(getData($result));
|
||||
|
||||
if (property_exists($resultObject, 'anzahl')) {
|
||||
$resultValue = (int) $resultObject->anzahl;
|
||||
|
||||
if ($resultValue > 0)
|
||||
{
|
||||
return success("1");
|
||||
}
|
||||
else
|
||||
{
|
||||
return success("0");
|
||||
}
|
||||
} else {
|
||||
return error("BenutzerModel: Error During Check if Existing Benutzer.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,6 @@ class Notiz_model extends DB_Model
|
||||
{
|
||||
$notiz_id = $result->retval;
|
||||
|
||||
//TODO(Manu) neue Function assign Notiz
|
||||
if($type == "software_id")
|
||||
{
|
||||
// Loads extension Model
|
||||
|
||||
@@ -374,5 +374,54 @@ class Person_model extends DB_Model
|
||||
'prestudent_id' => $prestudent_id
|
||||
]);
|
||||
}
|
||||
|
||||
public function generateAliasByPersonId($person_id)
|
||||
{
|
||||
|
||||
$this->addSelect('vorname, nachname');
|
||||
|
||||
return success ($this->loadWhere(array('person_id' => $person_id)));
|
||||
}
|
||||
|
||||
/* public function generateAliasByPersonId($person_id)
|
||||
{
|
||||
|
||||
$this->addSelect('vorname, nachname');
|
||||
|
||||
$result = $this->loadWhere(array('person_id' => $person_id));
|
||||
|
||||
// Überprüfe, ob ein Ergebnis zurückgegeben wurde
|
||||
if ($result) {
|
||||
$result = getData($result);
|
||||
$result = $result->retval[0];
|
||||
$vorname = $result->vorname;
|
||||
$nachname = $result->nachname;
|
||||
|
||||
// Sanitize the extracted names
|
||||
$sanitizedVorname = $this->sanitizeAliasName($vorname);
|
||||
$sanitizedNachname = $this->sanitizeAliasName($nachname);
|
||||
|
||||
// Erstelle den Alias
|
||||
$alias = $sanitizedVorname . '.' . $sanitizedNachname;
|
||||
|
||||
// Gib den Erfolg zurück mit dem generierten Alias
|
||||
return success($alias);
|
||||
} else {
|
||||
// Falls kein Ergebnis gefunden wurde, gib einen Fehler zurück
|
||||
return error('Person not found');
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Sanitizes a string used for alias. Replaces special characters, spaces, sets lower case.
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
public function sanitizeAliasName($str)
|
||||
{
|
||||
$str = sanitizeProblemChars($str);
|
||||
return success (mb_strtolower(str_replace(' ','_', $str)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -275,7 +275,8 @@ export default{
|
||||
newArray: {},
|
||||
abbruchData: {},
|
||||
newStatus: '',
|
||||
statusNew: true
|
||||
statusNew: true,
|
||||
isErsterStudent: false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -411,7 +412,8 @@ export default{
|
||||
};
|
||||
|
||||
this.newArray = this.updateData.map(objekt => ({ ...objekt, ...deltaData, ausbildungssemester: this.actionSem}));
|
||||
this.addNewStatus(prestudentIds);
|
||||
//BewerberZuStudent
|
||||
this.turnIntoStudent(prestudentIds);
|
||||
},
|
||||
changeStatusToWiederholer(prestudentIds){
|
||||
this.hideModal('askForAusbildungssemester');
|
||||
@@ -457,6 +459,98 @@ export default{
|
||||
/* console.log("in changeStatusToAbsolvent" + prestudentIds);
|
||||
this.hideModal('addMultiStatus');*/
|
||||
this.addNewStatus(prestudentIds);
|
||||
},
|
||||
turnIntoStudent(prestudentIds){
|
||||
|
||||
//erste Voraussetzung: kein check auf checkIfExistingStudent
|
||||
// macht aus einem Bewerber einen Studenten
|
||||
// Voraussetzungen:
|
||||
// - ZGV muss ausgefuellt sein (bei Master beide)
|
||||
// - Kaution muss bezahlt sein
|
||||
// - Rolle Bewerber muss existieren
|
||||
// Wenn die Voraussetzungen erfuellt sind, dann wird die Matrikelnr
|
||||
// und UID generiert und der Studentendatensatz angelegt.
|
||||
let changeData = {};
|
||||
|
||||
//for Feedback Sucess, Error
|
||||
let countSuccess = 0;
|
||||
let countError = 0;
|
||||
|
||||
const promises = prestudentIds.map(prestudentId => {
|
||||
|
||||
this.checkIfErsterStudent(prestudentId).then(() => {
|
||||
|
||||
if(this.isErsterStudent)
|
||||
{
|
||||
console.log(prestudentId + ": isersterStudent: " + this.isErsterStudent + " Logik turnIntoStudent");
|
||||
|
||||
changeData = this.newArray.find(item => item.prestudent_id === prestudentId);
|
||||
|
||||
return this.$fhcApi.post('api/frontend/v1/stv/status/turnIntoStudent/' + prestudentId,
|
||||
changeData
|
||||
).then(response => {
|
||||
countSuccess++;
|
||||
return response;
|
||||
})
|
||||
//.catch(this.$fhcAlert.handleSystemError)
|
||||
.catch(error => {
|
||||
countError++;
|
||||
//For each Prestudent show Error in Alert
|
||||
this.$fhcAlert.handleSystemError(error);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log(prestudentId + ": isersterStudent: " + this.isErsterStudent + " Add New Status");
|
||||
|
||||
changeData = this.newArray.find(item => item.prestudent_id === prestudentId);
|
||||
|
||||
return this.$fhcApi.post('api/frontend/v1/stv/status/addNewStatus/' + prestudentId,
|
||||
changeData
|
||||
).then(response => {
|
||||
countSuccess++;
|
||||
return response;
|
||||
})
|
||||
//.catch(this.$fhcAlert.handleSystemError)
|
||||
.catch(error => {
|
||||
countError++;
|
||||
//For each Prestudent show Error in Alert
|
||||
this.$fhcAlert.handleSystemError(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Promise
|
||||
.allSettled(promises)
|
||||
.then(values => {
|
||||
|
||||
//Feedback Success als infoalert
|
||||
if (countSuccess > 0) {
|
||||
this.$fhcAlert.alertInfo(this.$p.t('ui', 'successNewStatus', {
|
||||
'countSuccess': countSuccess,
|
||||
'status': this.newStatus,
|
||||
'countError': countError
|
||||
}));
|
||||
}
|
||||
|
||||
/* if (this.modelValue.prestudent_id) {
|
||||
this.reload();
|
||||
//TODO(manu) reload Detailtab after Abbrecher to see current status activ, verband and gruppe
|
||||
//TODO(manu) reload Tab STatus after turned Into Student to see new status
|
||||
}*/
|
||||
if(this.isErsterStudent) {
|
||||
this.reload();
|
||||
this.isErsterStudent = false;
|
||||
}
|
||||
else {
|
||||
this.$reloadList();
|
||||
}
|
||||
this.hideModal('statusModal');
|
||||
this.resetModal();
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
addNewStatus(prestudentIds){
|
||||
//Array.isArray(prestudentIds) ? this.modelValue.prestudent_id : [prestudentIds];
|
||||
@@ -600,6 +694,16 @@ export default{
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
},
|
||||
checkIfErsterStudent(prestudent_id){
|
||||
return this.$fhcApi
|
||||
.get('api/frontend/v1/stv/status/isErsterStudent/' + prestudent_id)
|
||||
.then(
|
||||
result => {
|
||||
this.isErsterStudent = result.data.retval == 0 ? 1 : 0;
|
||||
return result;
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
},
|
||||
loadStatus(status_id){
|
||||
this.statusNew = false;
|
||||
return this.$fhcApi.post('api/frontend/v1/stv/status/loadStatus/',
|
||||
@@ -659,7 +763,6 @@ export default{
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
},
|
||||
mounted(){},
|
||||
template: `
|
||||
<div class="stv-list h-100 pt-3">
|
||||
|
||||
@@ -863,75 +966,7 @@ export default{
|
||||
</div>
|
||||
</template>
|
||||
</BsModal>
|
||||
|
||||
<!-- <BsModal ref="addMultiStatus" id="addMultiStatus">
|
||||
<template #title>Status ändern zu</template>
|
||||
<template #default>
|
||||
<button type="button" class="btn btn-primary d-block mb-2" data-bs-toggle="collapse" data-bs-target="#submenu1">
|
||||
Abbrecher
|
||||
</button>
|
||||
<div class="collapse" id="submenu1">
|
||||
<button type="button" class="btn btn-light d-block mb-2" @click="actionConfirmDialogue(updateData, 'abbrecherStgl', 'Abbrecher')">durch Stgl</button>
|
||||
<button type="button" class="btn btn-light d-block mb-2" @click="actionConfirmDialogue(updateData, 'abbrecherStud','Abbrecher')">durch Student</button>
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn btn-primary d-block mb-2" @click="actionConfirmDialogue(updateData, 'unterbrecher','Unterbrecher')">
|
||||
Unterbrecher
|
||||
</button>
|
||||
|
||||
<button type="button" class="btn btn-primary d-block mb-2" data-bs-toggle="collapse" data-bs-target="#submenu2">
|
||||
Student
|
||||
</button>
|
||||
<div class="collapse" id="submenu2">
|
||||
<button type="button" class="btn btn-light d-block mb-2" @click="actionConfirmDialogue(updateData, 'student','Student')">Student</button>
|
||||
<button type="button" class="btn btn-light d-block mb-2" @click="actionConfirmDialogue(updateData, 'student','Wiederholer')">Wiederholer</button>
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn btn-primary d-block mb-2" @click="changeStatusToDiplomand(prestudentIds)">
|
||||
Diplomand
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary d-block mb-2" @click="changeStatusToAbsolvent(prestudentIds)">
|
||||
Absolvent
|
||||
</button>
|
||||
|
||||
</template>
|
||||
<template #footer>
|
||||
<div v-if="actionButton=='abbrecherStgl'">
|
||||
<button ref="Close" type="button" class="btn btn-primary" @click="changeStatusToAbbrecherStgl(prestudentIds)">OK</button>
|
||||
</div>
|
||||
<div v-if="actionButton=='abbrecherStud'">
|
||||
<button ref="Close" type="button" class="btn btn-primary" @click="changeStatusToAbbrecherStud(prestudentIds)">OK</button>
|
||||
</div>
|
||||
<div v-if="actionButton=='unterbrecher'">
|
||||
<button ref="Close" type="button" class="btn btn-primary" @click="changeStatusToUnterbrecher(prestudentIds)">OK</button>
|
||||
</div>
|
||||
</template>
|
||||
</BsModal>-->
|
||||
|
||||
<!-- <ul class="dropdown-menu" ref="addMultiStatus3" id="addMultiStatus3">
|
||||
<li class="dropdown-submenu">
|
||||
<a class="dropdown-item" @click="actionConfirmDialogue(updateData, 'abbrecherStgl', 'Abbrecher')">Abbrecher durch Stgl 5</a>
|
||||
</li>
|
||||
<li class="dropdown-submenu">
|
||||
<a class="dropdown-item" @click="actionConfirmDialogue(updateData, 'abbrecherStud','Abbrecher')">Abbrecher durch Student</a>
|
||||
</li>
|
||||
<li class="dropdown-submenu">
|
||||
<a class="dropdown-item" @click="actionConfirmDialogue(updateData, 'unterbrecher','Unterbrecher')">Unterbrecher</a>
|
||||
</li>
|
||||
<li class="dropdown-submenu">
|
||||
<a class="dropdown-item" @click="actionConfirmDialogue(updateData, 'student','Student')">Student</a>
|
||||
</li>
|
||||
<li class="dropdown-submenu">
|
||||
<a class="dropdown-item" @click="actionConfirmDialogue(updateData, 'student','Wiederholer')">Wiederholer</a>
|
||||
</li>
|
||||
<li class="dropdown-submenu">
|
||||
<a class="dropdown-item" @click="changeStatusToDiplomand(prestudentIds)">Diplomand</a>
|
||||
</li>
|
||||
<li class="dropdown-submenu">
|
||||
<a class="dropdown-item" @click="changeStatusToAbsolvent(prestudentIds)">Absolvent</a>
|
||||
</li>
|
||||
</ul>-->
|
||||
|
||||
|
||||
<!--Modal: askForAusbildungssemester-->
|
||||
<BsModal ref="askForAusbildungssemester">
|
||||
<template #title>{{$p.t('lehre', 'status_edit')}}</template>
|
||||
@@ -1029,7 +1064,7 @@ export default{
|
||||
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Status Ändern
|
||||
</button>
|
||||
|
||||
|
||||
<ul class="dropdown-menu">
|
||||
<li class="dropdown-submenu">
|
||||
<a class="dropdown-item" @click="actionConfirmDialogue(updateData, 'abbrecherStgl', 'Abbrecher')">Abbrecher durch Stgl</a>
|
||||
|
||||
@@ -25974,27 +25974,7 @@ array(
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'lehre',
|
||||
'phrase' => 'modal_askAusbildungssemPlural2',
|
||||
'insertvon' => 'system',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'In welches Semester sollen diese {count} PrestudentInnen ({status}) verschoben werden?',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'To which education semester should these {count} prestudents ({status}) be moved?',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
)
|
||||
//Prestudent
|
||||
array(
|
||||
'app' => 'core',
|
||||
|
||||
Reference in New Issue
Block a user