mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-08 07:39:27 +00:00
setAbbrecherNeu
This commit is contained in:
@@ -437,33 +437,22 @@ class Status extends FHCAPI_Controller
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
|
||||
$this->load->library('PrestudentLib');
|
||||
|
||||
$this->db->trans_start();
|
||||
|
||||
switch($status_kurzbz){
|
||||
case Prestudentstatus_model::STATUS_ABBRECHER:
|
||||
$this->load->model('crm/Statusgrund_model', 'StatusgrundModel');
|
||||
$result = $this->StatusgrundModel->load($statusgrund_id);
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$result = current(getData($result));
|
||||
$statusgrund_kurzbz = $result->statusgrund_kurzbz;
|
||||
|
||||
$this->load->library('PrestudentLib');
|
||||
$result = $this->prestudentlib->setAbbrecher(
|
||||
$result = $this->prestudentlib->setAbbrecherNeu(
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
null,
|
||||
$statusgrund_kurzbz,
|
||||
$statusgrund_id,
|
||||
$datum_string,
|
||||
null,
|
||||
null
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result));
|
||||
}
|
||||
else
|
||||
$this->terminateWithSuccess($prestudent_id);
|
||||
break;
|
||||
case Prestudentstatus_model::STATUS_UNTERBRECHER:
|
||||
$ausbildungssemester = $lastStatusData->ausbildungssemester;
|
||||
@@ -558,6 +547,12 @@ class Status extends FHCAPI_Controller
|
||||
default:
|
||||
$this->terminateWithError("Action not yet defined in Prestudentlib", self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->trans_complete();
|
||||
|
||||
$this->terminateWithSuccess($prestudent_id);
|
||||
}
|
||||
|
||||
public function addStudent($prestudent_id)
|
||||
|
||||
@@ -35,6 +35,141 @@ class PrestudentLib
|
||||
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
}
|
||||
|
||||
public function setAbbrecherNeu(
|
||||
$prestudent_id,
|
||||
$studiensemester_kurzbz,
|
||||
$insertvon = null,
|
||||
$statusgrund_id = null,
|
||||
$datum = null,
|
||||
$bestaetigtam = null,
|
||||
$bestaetigtvon = null
|
||||
) {
|
||||
if (!$insertvon)
|
||||
$insertvon = getAuthUID();
|
||||
if (!$bestaetigtvon)
|
||||
$bestaetigtvon = $insertvon;
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id, $studiensemester_kurzbz);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$result = getData($result);
|
||||
if (!$result)
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_prestudent_in_sem', [
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz
|
||||
]));
|
||||
|
||||
$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);
|
||||
|
||||
if(!$datum)
|
||||
$datum = date('c');
|
||||
|
||||
if(!$bestaetigtam)
|
||||
$bestaetigtam = date('c');
|
||||
|
||||
//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,
|
||||
'ausbildungssemester' => $prestudent_status->ausbildungssemester,
|
||||
'datum' => $datum,
|
||||
'insertvon' => $insertvon,
|
||||
'insertamum' => date('c'),
|
||||
'orgform_kurzbz'=> $prestudent_status->orgform_kurzbz,
|
||||
'studienplan_id'=> $prestudent_status->studienplan_id,
|
||||
'bestaetigtvon' => $bestaetigtvon,
|
||||
'bestaetigtam' => $bestaetigtam,
|
||||
'statusgrund_id' => $statusgrund_id
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
//refactored with processStudentlehrverband
|
||||
$result = $this->_ci->StudentlehrverbandModel->processStudentlehrverband(
|
||||
$student->student_uid,
|
||||
$student->studiengang_kz,
|
||||
0,
|
||||
'A',
|
||||
'',
|
||||
$studiensemester_kurzbz,
|
||||
Prestudentstatus_model::STATUS_ABBRECHER
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
//noch nicht eingetragene Zeugnisnoten auf 9 setzen
|
||||
$result = $this->_ci->ZeugnisnoteModel->getZeugnisnoten($student->student_uid, $prestudent_status->studiensemester_kurzbz);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$result = getData($result) ?: [];
|
||||
|
||||
foreach ($result as $lv)
|
||||
{
|
||||
if (!$lv->note)
|
||||
{
|
||||
$result = $this->_ci->ZeugnisnoteModel->insert([
|
||||
'note' => 9,
|
||||
'studiensemester_kurzbz' => $lv->studiensemester_kurzbz,
|
||||
'student_uid' => $lv->uid,
|
||||
'lehrveranstaltung_id' => $lv->lehrveranstaltung_id
|
||||
]);
|
||||
if (isError($result)) {
|
||||
$result = $this->_ci->ZeugnisnoteModel->update([
|
||||
'studiensemester_kurzbz' => $lv->studiensemester_kurzbz,
|
||||
'student_uid' => $lv->uid,
|
||||
'lehrveranstaltung_id' => $lv->lehrveranstaltung_id
|
||||
], [
|
||||
'note' => 9
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Update Aktionen
|
||||
|
||||
//StudentModel updaten
|
||||
$this->_ci->StudentModel->update([
|
||||
'student_uid' => $student->student_uid
|
||||
], [
|
||||
'verband' => 'A',
|
||||
'gruppe' => '',
|
||||
'semester' => 0,
|
||||
'updatevon' => $insertvon,
|
||||
'updateamum' => date('c')
|
||||
]);
|
||||
|
||||
//Benutzer inaktiv setzen
|
||||
$this->_ci->BenutzerModel->update([
|
||||
'uid' => $student->student_uid
|
||||
], [
|
||||
'aktiv' => false,
|
||||
'updateaktivvon' => $insertvon,
|
||||
'updateaktivam' => date('c'),
|
||||
'updatevon' => $insertvon,
|
||||
'updateamum' => date('c')
|
||||
]);
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
public function setAbbrecher($prestudent_id, $studiensemester_kurzbz, $insertvon = null, $statusgrund_kurzbz = null, $datum = null, $bestaetigtam = null, $bestaetigtvon = null)
|
||||
{
|
||||
if (!$insertvon)
|
||||
@@ -134,6 +269,9 @@ class PrestudentLib
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(chris): student updaten (hier oder in studentlehrverband)
|
||||
// TODO(chris): db transaction
|
||||
|
||||
//Benutzer inaktiv setzen
|
||||
$this->_ci->BenutzerModel->update([
|
||||
'uid' => $student->student_uid
|
||||
@@ -285,6 +423,20 @@ class PrestudentLib
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Update Aktionen
|
||||
|
||||
//StudentModel updaten
|
||||
$this->_ci->StudentModel->update([
|
||||
'student_uid' => $student->student_uid
|
||||
], [
|
||||
'verband' => 'B',
|
||||
'gruppe' => '',
|
||||
'semester' => 0,
|
||||
'updatevon' => $insertvon,
|
||||
'updateamum' => date('c')
|
||||
]);
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user