diff --git a/application/controllers/api/frontend/v1/stv/Student.php b/application/controllers/api/frontend/v1/stv/Student.php index d5737dc2f..dbe977cd8 100644 --- a/application/controllers/api/frontend/v1/stv/Student.php +++ b/application/controllers/api/frontend/v1/stv/Student.php @@ -666,30 +666,31 @@ class Student extends FHCAPI_Controller $prestudent_id = getData($result); - // Prestudent Rolle Anlegen - $this->prestudentlib->setFirstStatus( - $prestudent_id, - $incoming ? 'Incoming' : 'Interessent', - $studiensemester_kurzbz, - $this->input->post('ausbildungssemester'), - $this->input->post('orgform_kurzbz'), - $this->input->post('studienplan_id') - ); - if (!hasData($result)) return error('error when adding status'); - if (isError($result)) return $result; - + // wenn Incoming, Incoming Daten hinzufügen if ($incoming) { - $result = $this->prestudentlib->setIncoming($prestudent_id, $studiengang_kz, $studiensemester_kurzbz); - if (isError($result)) return $result; + $statusResult = $this->prestudentlib->setFirstIncoming( + $prestudent_id, + $studiengang_kz, + $studiensemester_kurzbz, + $this->input->post('orgform_kurzbz'), + $this->input->post('studienplan_id') + ); } - // TODO(chris): DEBUG - /*$result = $this->PrestudentModel->loadWhere([ - 'pestudent_id' => 1 - ]); - if (isError($result)) { - return $result; - }*/ + else + { + // Prestudent Rolle Anlegen + $statusResult = $this->prestudentlib->setFirstStatus( + $prestudent_id, + $this->PrestudentstatusModel::STATUS_INTERESSENT, + $studiensemester_kurzbz, + $this->input->post('ausbildungssemester'), + $this->input->post('orgform_kurzbz'), + $this->input->post('studienplan_id') + ); + } + if (!hasData($statusResult)) return error('error when adding status'); + if (isError($statusResult)) return $statusResult; return success($prestudent_id); } diff --git a/application/libraries/PrestudentLib.php b/application/libraries/PrestudentLib.php index fe1fa3a00..eda800842 100644 --- a/application/libraries/PrestudentLib.php +++ b/application/libraries/PrestudentLib.php @@ -977,7 +977,7 @@ class PrestudentLib * @param $studiensemester_kurzbz start semester for incoming * @return object success if incoming successfully saved, or error */ - public function setIncoming($prestudent_id, $studiengang_kz, $studiensemester_kurzbz) + public function setFirstIncoming($prestudent_id, $studiengang_kz, $studiensemester_kurzbz, $orgform_kurzbz, $studienplan_id) { // Verband and Ausbildungssemester for incoming $authUID = getAuthUID(); @@ -994,6 +994,17 @@ class PrestudentLib $student_data = getData($result)[0]; + $result = $this->setFirstStatus( + $prestudent_id, + $this->_ci->PrestudentstatusModel::STATUS_INCOMING, + $studiensemester_kurzbz, + $incomingAusbildungssemester, + $orgform_kurzbz, + $studienplan_id + ); + if (isError($result)) return $result; + if (!hasData($result)) return error('Error when adding prestudentstatus'); + // generate Personenkennzeichen $result = $this->_ci->StudentModel->generateMatrikelnummer2($studiengang_kz, $studiensemester_kurzbz); if (isError($result)) return $result; @@ -1061,18 +1072,23 @@ class PrestudentLib 'gruppe' => ' ' ]; - // Add Lehrverband if it does not exist - $result = $this->_ci->LehrverbandModel->load([' ', ' ', $incomingAusbildungssemester, $student_data->studiengang_kz]); + $result = $this->_ci->LehrverbandModel->loadWhere([ + 'studiengang_kz' => $student['studiengang_kz'], + 'semester' => $student['semester'], + 'verband' => $student['verband'], + 'gruppe' => $student['gruppe'] + ]); if (isError($result)) return $result; if (!hasData($result)) { + // Add Lehrverband if it does not exist $result = $this->_ci->LehrverbandModel->insert([ 'studiengang_kz' => $student_data->studiengang_kz, - 'semester' => $incomingAusbildungssemester, - 'verband' => $incomingVerband, - 'gruppe' => $student_data->gruppe, + 'semester' => $student['semester'], + 'verband' => $student['verband'], + 'gruppe' => $student['gruppe'], 'bezeichnung' => 'Incoming', 'aktiv' => true ]);