mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-03 20:09:29 +00:00
Refactor Functions in Prestudent Lib, Unterbrecher as single Action
This commit is contained in:
@@ -73,17 +73,17 @@ class Status extends FHCAPI_Controller
|
||||
|
||||
public function isLastStatus($prestudent_id)
|
||||
{
|
||||
//TODO(Manu) translate here
|
||||
$this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
|
||||
$result = $this->PrestudentstatusModel->checkIfLastStatusEntry($prestudent_id);
|
||||
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if($result->retval == "1")
|
||||
{
|
||||
//return $this->outputJson($result->retval);
|
||||
return $this->terminateWithError("Die letzte Rolle kann nur durch den Administrator geloescht werden", self::ERROR_TYPE_GENERAL);
|
||||
$this->terminateWithError($this->p->t('lehre','error_lastRole'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess($result);
|
||||
}
|
||||
@@ -313,7 +313,7 @@ class Status extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($prestudent_id);
|
||||
}
|
||||
|
||||
//TODO(Manu) setUnterbrecher FasLogic!
|
||||
//TODO(Manu) documentation: here setUnterbrecher FasLogic!
|
||||
if($status_kurzbz == 'Unterbrecher')
|
||||
{
|
||||
$ausbildungssemester = $lastStatusData->ausbildungssemester;
|
||||
@@ -329,6 +329,57 @@ class Status extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($prestudent_id);
|
||||
}
|
||||
|
||||
//TODO(Manu) documentation: here setStudent Logic!
|
||||
if($status_kurzbz == 'Student')
|
||||
{
|
||||
//return $this->terminateWithError($studiensemester_kurzbz . " - " . $ausbildungssemester, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->load->library('PrestudentLib');
|
||||
$result = $this->prestudentlib->setStudent($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id, $bestaetigtam, $bestaetigtvon);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
else
|
||||
$this->terminateWithSuccess($prestudent_id);
|
||||
|
||||
}
|
||||
|
||||
if($status_kurzbz == 'Diplomand')
|
||||
{
|
||||
//return $this->terminateWithError("in setDiplomand", self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->load->library('PrestudentLib');
|
||||
$result = $this->prestudentlib->setDiplomand($prestudent_id, $studiensemester_kurzbz,$ausbildungssemester, $bestaetigtam, $bestaetigtvon);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
else
|
||||
$this->terminateWithSuccess($prestudent_id);
|
||||
|
||||
}
|
||||
|
||||
if($status_kurzbz == 'Absolvent')
|
||||
{
|
||||
//return $this->terminateWithError("in setAbsolvent", self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->load->library('PrestudentLib');
|
||||
$result = $this->prestudentlib->setAbsolvent($prestudent_id, $studiensemester_kurzbz,$ausbildungssemester, $bestaetigtam, $bestaetigtvon);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
else
|
||||
$this->terminateWithSuccess($prestudent_id);
|
||||
|
||||
}
|
||||
|
||||
return $this->terminateWithError("Warning! not in setStatus Mode", self::ERROR_TYPE_GENERAL);
|
||||
|
||||
// Start DB transaction
|
||||
$this->db->trans_begin(); // Beginnen der Transaktion
|
||||
|
||||
|
||||
@@ -612,5 +612,331 @@ class PrestudentLib
|
||||
return success();
|
||||
}
|
||||
|
||||
public function setStudent($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id, $bestaetigtAm, $bestaetigtVon)
|
||||
{
|
||||
$insertvon = getAuthUID();
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id, $studiensemester_kurzbz);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$result = getData($result);
|
||||
if (!$result)
|
||||
{
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$result = getData($result);
|
||||
|
||||
if($statusgrund_id != 16)
|
||||
{
|
||||
//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))
|
||||
return $res;
|
||||
if(!hasData($res))
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_stg_for_prestudent', [
|
||||
'prestudent_id' => $prestudent_id
|
||||
]));
|
||||
|
||||
$studiengang = current(getData($res));
|
||||
$prestudent_status = current($result);
|
||||
if($prestudent_status->ausbildungssemester + 1 < $studiengang->max_semester)
|
||||
$ausbildungssemester_plus = 1;
|
||||
|
||||
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);
|
||||
|
||||
//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' => date('c'),
|
||||
'insertvon' => $insertvon,
|
||||
'insertamum' => date('c'),
|
||||
'orgform_kurzbz'=> $prestudent_status->orgform_kurzbz,
|
||||
'studienplan_id'=> $prestudent_status->studienplan_id,
|
||||
'bestaetigtvon' => $insertvon,
|
||||
'bestaetigtam' => date('c'),
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
$result = $this->_ci->StudentModel->checkIfUid($prestudent_id);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$student_uid = $result->retval;
|
||||
|
||||
//load student
|
||||
$result = $this->_ci->StudentModel->loadWhere(
|
||||
array(
|
||||
'student_uid' => $student_uid
|
||||
)
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$studentData = current(getData($result) ? : []);
|
||||
$verband = $studentData->verband == '' ? '' : $studentData->verband;
|
||||
$gruppe = $studentData->gruppe == '' ? '' : $studentData->gruppe;
|
||||
$studiengang_kz = $studentData->studiengang_kz;
|
||||
|
||||
//process studentlehrverband
|
||||
$this->_ci->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel');
|
||||
$result = $this->_ci->StudentlehrverbandModel->processStudentlehrverband(
|
||||
$student_uid,
|
||||
$studiengang_kz,
|
||||
$ausbildungssemester,
|
||||
$verband,
|
||||
$gruppe,
|
||||
$studiensemester_kurzbz
|
||||
);
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
public function setDiplomand($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester,$bestaetigtAm, $bestaetigtVon)
|
||||
{
|
||||
$insertvon = getAuthUID();
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id, $studiensemester_kurzbz);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$result = getData($result);
|
||||
if (!$result)
|
||||
{
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$result = getData($result);
|
||||
|
||||
if($statusgrund_id != 16)
|
||||
{
|
||||
//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))
|
||||
return $res;
|
||||
if(!hasData($res))
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_stg_for_prestudent', [
|
||||
'prestudent_id' => $prestudent_id
|
||||
]));
|
||||
|
||||
$studiengang = current(getData($res));
|
||||
$prestudent_status = current($result);
|
||||
if($prestudent_status->ausbildungssemester + 1 < $studiengang->max_semester)
|
||||
$ausbildungssemester_plus = 1;
|
||||
|
||||
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);
|
||||
|
||||
//Status updaten
|
||||
$result = $this->_ci->PrestudentstatusModel->insert([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_DIPLOMAND,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
// 'statusgrund_id' => $statusgrund_id,
|
||||
// 'ausbildungssemester' => $ausbildungssemester,
|
||||
'datum' => date('c'),
|
||||
'insertvon' => $insertvon,
|
||||
'insertamum' => date('c'),
|
||||
'orgform_kurzbz'=> $prestudent_status->orgform_kurzbz,
|
||||
'studienplan_id'=> $prestudent_status->studienplan_id,
|
||||
'bestaetigtvon' => $insertvon,
|
||||
'bestaetigtam' => date('c'),
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
$result = $this->_ci->StudentModel->checkIfUid($prestudent_id);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$student_uid = $result->retval;
|
||||
|
||||
//load student
|
||||
$result = $this->_ci->StudentModel->loadWhere(
|
||||
array(
|
||||
'student_uid' => $student_uid
|
||||
)
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$studentData = current(getData($result) ? : []);
|
||||
$verband = $studentData->verband == '' ? '' : $studentData->verband;
|
||||
$gruppe = $studentData->gruppe == '' ? '' : $studentData->gruppe;
|
||||
$studiengang_kz = $studentData->studiengang_kz;
|
||||
|
||||
//process studentlehrverband
|
||||
$this->_ci->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel');
|
||||
$result = $this->_ci->StudentlehrverbandModel->processStudentlehrverband(
|
||||
$student_uid,
|
||||
$studiengang_kz,
|
||||
$ausbildungssemester,
|
||||
$verband,
|
||||
$gruppe,
|
||||
$studiensemester_kurzbz
|
||||
);
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
public function setAbsolvent($prestudent_id,$studiensemester_kurzbz, $ausbildungssemester, $bestaetigtAm, $bestaetigtVon)
|
||||
{
|
||||
$insertvon = getAuthUID();
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id, $studiensemester_kurzbz);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$result = getData($result);
|
||||
if (!$result)
|
||||
{
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$result = getData($result);
|
||||
|
||||
if($statusgrund_id != 16)
|
||||
{
|
||||
//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))
|
||||
return $res;
|
||||
if(!hasData($res))
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_stg_for_prestudent', [
|
||||
'prestudent_id' => $prestudent_id
|
||||
]));
|
||||
|
||||
$studiengang = current(getData($res));
|
||||
$prestudent_status = current($result);
|
||||
if($prestudent_status->ausbildungssemester + 1 < $studiengang->max_semester)
|
||||
$ausbildungssemester_plus = 1;
|
||||
|
||||
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);
|
||||
|
||||
//Status updaten
|
||||
$result = $this->_ci->PrestudentstatusModel->insert([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_ABSOLVENT,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
// 'statusgrund_id' => $statusgrund_id,
|
||||
// 'ausbildungssemester' => $ausbildungssemester,
|
||||
'datum' => date('c'),
|
||||
'insertvon' => $insertvon,
|
||||
'insertamum' => date('c'),
|
||||
'orgform_kurzbz'=> $prestudent_status->orgform_kurzbz,
|
||||
'studienplan_id'=> $prestudent_status->studienplan_id,
|
||||
'bestaetigtvon' => $insertvon,
|
||||
'bestaetigtam' => date('c'),
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
$result = $this->_ci->StudentModel->checkIfUid($prestudent_id);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$student_uid = $result->retval;
|
||||
|
||||
//load student
|
||||
$result = $this->_ci->StudentModel->loadWhere(
|
||||
array(
|
||||
'student_uid' => $student_uid
|
||||
)
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$studentData = current(getData($result) ? : []);
|
||||
$verband = $studentData->verband == '' ? '' : $studentData->verband;
|
||||
$gruppe = $studentData->gruppe == '' ? '' : $studentData->gruppe;
|
||||
$studiengang_kz = $studentData->studiengang_kz;
|
||||
|
||||
//process studentlehrverband
|
||||
$this->_ci->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel');
|
||||
$result = $this->_ci->StudentlehrverbandModel->processStudentlehrverband(
|
||||
$student_uid,
|
||||
$studiengang_kz,
|
||||
$ausbildungssemester,
|
||||
$verband,
|
||||
$gruppe,
|
||||
$studiensemester_kurzbz
|
||||
);
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ class Prestudentstatus_model extends DB_Model
|
||||
|
||||
const STATUS_ABBRECHER = 'Abbrecher';
|
||||
const STATUS_UNTERBRECHER = 'Unterbrecher';
|
||||
const STATUS_STUDENT = 'Student';
|
||||
const STATUS_DIPLOMAND = 'Diplomand';
|
||||
const STATUS_ABSOLVENT = 'Absolvent';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
||||
@@ -706,8 +706,7 @@ export default{
|
||||
<option value="Bewerber">BewerberIn</option>
|
||||
<option value="Aufgenommener">Aufgenommene/r</option>
|
||||
<option value="Student">StudentIn</option>
|
||||
<!-- TODO(Manu) handle Unterbrecher from here
|
||||
<option value="Unterbrecher">UnterbrecherIn</option>-->
|
||||
<option value="Unterbrecher">UnterbrecherIn</option>
|
||||
<option value="Diplomand">DiplomandIn</option>
|
||||
<option value="Incoming">Incoming</option>
|
||||
</form-input>
|
||||
@@ -873,8 +872,7 @@ export default{
|
||||
<option value="Bewerber">BewerberIn</option>
|
||||
<option value="Aufgenommener">Aufgenommene/r</option>
|
||||
<option value="Student">StudentIn</option>
|
||||
<!-- TODO(Manu) check: is handle Unterbrecher from here necessary?
|
||||
<option value="Unterbrecher">UnterbrecherIn</option>-->
|
||||
<option value="Unterbrecher">UnterbrecherIn</option>
|
||||
<option value="Diplomand">DiplomandIn</option>
|
||||
<option value="Incoming">Incoming</option>
|
||||
</form-input>
|
||||
|
||||
Reference in New Issue
Block a user