mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-12 17:49:28 +00:00
172 lines
4.9 KiB
PHP
172 lines
4.9 KiB
PHP
<?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)));
|
|
}
|
|
|
|
|
|
|
|
}
|