Start Actions New, Edit, Delete

This commit is contained in:
ma0068
2024-02-15 17:02:16 +01:00
parent 7ec24bfc7b
commit 6a5b2db79d
4 changed files with 774 additions and 145 deletions
@@ -160,18 +160,6 @@ class Prestudent extends FHC_Controller
$this->outputJson(getData($result) ?: []);
}
public function getHistoryPrestudent($prestudent_id)
{
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
$result = $this->PrestudentModel->getHistoryPrestudent($prestudent_id);
if (isError($result))
{
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
}
$this->outputJson(getData($result) ?: []);
}
public function getBezeichnungZgv()
{
$this->load->model('codex/Zgv_model', 'ZgvModel');
@@ -268,5 +256,45 @@ class Prestudent extends FHC_Controller
$this->outputJson($result);
}
public function getStudiensemester()
{
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$this->StudiensemesterModel->addOrder('start', 'DESC');
$this->StudiensemesterModel->addLimit(20);
$result = $this->StudiensemesterModel->load();
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
}
$this->outputJson($result);
}
public function getStudienplaene($prestudent_id)
{
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
$result = $this->PrestudentModel->loadWhere(
array('prestudent_id' => $prestudent_id)
);
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
}
$result = current(getData($result));
$studiengang_kz = $result->studiengang_kz;
$this->load->model('organisation/Studienplan_model', 'StudienplanModel');
$this->StudienplanModel->addOrder('studienplan_id', 'DESC');
$result = $this->StudienplanModel->getStudienplaene($studiengang_kz);
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
}
$this->outputJson($result);
}
}
@@ -0,0 +1,171 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
use \DateTime as DateTime;
class Status extends FHC_Controller
{
public function __construct()
{
parent::__construct();
// Load Libraries
$this->load->library('AuthLib');
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
// Load language phrases
/* $this->loadPhrases([
'ui'
]);*/
}
public function getHistoryPrestudent($prestudent_id)
{
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
$result = $this->PrestudentModel->getHistoryPrestudent($prestudent_id);
if (isError($result))
{
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
}
$this->outputJson(getData($result) ?: []);
}
public function getStatusgruende()
{
$this->load->model('crm/Statusgrund_model', 'StatusgrundModel');
$result = $this->StatusgrundModel->load();
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
}
$this->outputJson($result);
}
public function addNewStatus($prestudent_id)
{
/* $this->load->library('form_validation');
if ($this->form_validation->run() == false)
{
return $this->outputJsonError($this->form_validation->error_array());
}*/
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
$this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
//var_dump($_POST);
$status_kurzbz = $this->input->post('status_kurzbz');
$ausbildungssemester = $this->input->post('ausbildungssemester');
$datum = $this->input->post('datum');
$bestaetigtam = $this->input->post('bestaetigtam');
$bewerbung_abgeschicktamum = $this->input->post('bewerbung_abgeschicktamum');
$studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz');
$studienplan_id = $this->input->post('studienplan_id');
$anmerkung = $this->input->post('anmerkung ');
$statusgrund_id = $this->input->post('statusgrund_id');
$rt_stufe = $this->input->post('rt_stufe');
$bestaetigtvon = $this->input->post('bestaetigtvon');
// Start DB transaction
//$this->db->trans_start(false);
$result = $this->PrestudentstatusModel->insert(
[
'prestudent_id' => $prestudent_id,
'status_kurzbz' => $status_kurzbz,
'bewerbung_abgeschicktamum' => $bewerbung_abgeschicktamum,
'studiensemester_kurzbz' => $studiensemester_kurzbz,
'studienplan_id' => $studienplan_id,
'ausbildungssemester' => $ausbildungssemester,
'anmerkung' => $anmerkung,
'statusgrund_id' => $statusgrund_id,
'insertvon' => 'uid',
'insertamum' => date('c'),
'bestaetigtam' => $bestaetigtam,
'bestaetigtvon' => $bestaetigtvon,
'datum' => $datum,
'rt_stufe' => $rt_stufe
]
);
if (isError($result))
{
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
return $this->outputJson(getError($result));
}
return $this->outputJsonSuccess(true);
}
public function loadStatus()
{
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
$prestudent_id = $this->input->post('prestudent_id');
$status_kurzbz = $this->input->post('status_kurzbz');
$ausbildungssemester = $this->input->post('ausbildungssemester');
$studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz');
//echo $prestudent_id . $status_kurzbz . $ausbildungssemester . $studiensemester_kurzbz;
$this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
$result = $this->PrestudentstatusModel->loadWhere(
array(
'prestudent_id' => $prestudent_id,
'status_kurzbz' => $status_kurzbz,
'ausbildungssemester' => $ausbildungssemester,
'studiensemester_kurzbz' => $studiensemester_kurzbz
)
);
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
$this->outputJson($result);
}
elseif (!hasData($result)) {
$this->outputJson($result);
}
else
{
//var_dump($result);
$this->outputJsonSuccess(current(getData($result)));
}
}
public function deleteStatus()
{
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
$prestudent_id = $this->input->post('prestudent_id');
$status_kurzbz = $this->input->post('status_kurzbz');
$ausbildungssemester = $this->input->post('ausbildungssemester');
$studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz');
$this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
$result = $this->PrestudentstatusModel->delete(
array(
'prestudent_id' => $prestudent_id,
'status_kurzbz' => $status_kurzbz,
'ausbildungssemester' => $ausbildungssemester,
'studiensemester_kurzbz' => $studiensemester_kurzbz
)
);
if (isError($result))
{
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
$this->outputJson($result);
}
elseif (!hasData($result)) {
$this->outputJson($result);
}
return $this->outputJsonSuccess(current(getData($result)));
}
}