mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 02:12:17 +00:00
refactoring Fkt addNewNotiz
This commit is contained in:
@@ -61,20 +61,24 @@ class Notiz extends FHC_Controller
|
||||
|
||||
public function addNewNotiz($id)
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
//$this->load->library('form_validation');
|
||||
//$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
//TODO(Manu) Validation
|
||||
|
||||
$this->form_validation->set_rules('titel', 'titel', 'required');
|
||||
$this->form_validation->set_rules('text', 'Text', 'required');
|
||||
/* $this->form_validation->set_rules('titel', 'titel', 'required');
|
||||
$this->form_validation->set_rules('text', 'Text', 'required');*/
|
||||
|
||||
//TODO(Manu) form validation - schon für type hier?,
|
||||
|
||||
//Speichern der Files
|
||||
$this->load->library('DmsLib');
|
||||
$uid = getAuthUID();
|
||||
|
||||
//multiple files
|
||||
$dms_id = [];
|
||||
$dms_id_arr = [];
|
||||
$notiz_id = null;
|
||||
foreach ($_FILES as $k => $file)
|
||||
{
|
||||
$dms = array(
|
||||
@@ -90,7 +94,7 @@ class Notiz extends FHC_Controller
|
||||
|
||||
if (isSuccess($result))
|
||||
{
|
||||
$dms_id[] = $result->retval['dms_id'];
|
||||
$dms_id_arr[] = $result->retval['dms_id'];
|
||||
}
|
||||
/* else {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
@@ -104,27 +108,67 @@ class Notiz extends FHC_Controller
|
||||
|
||||
}
|
||||
|
||||
//Speichern der Notiz mit Notizzuordnung
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
|
||||
$uid = getAuthUID();
|
||||
$titel = isset($_POST['titel']) ? $_POST['titel'] : null;
|
||||
$text = isset($_POST['text']) ? $_POST['text'] : null;
|
||||
$bearbeiter_uid = isset($_POST['bearbeiter_uid']) ? $_POST['bearbeiter_uid'] : null;
|
||||
$verfasser_uid = isset($_POST['verfasser_uid']) ? $_POST['verfasser_uid'] : $uid;
|
||||
$erledigt = $_POST['erledigt'];
|
||||
$type = $_POST['typeId'];
|
||||
$titel = $this->input->post('titel');
|
||||
$text = $this->input->post('text');
|
||||
$bearbeiter_uid = $this->input->post('bearbeiter_uid');
|
||||
$erledigt = $this->input->post('erledigt');
|
||||
$type = $this->input->post('typeId');
|
||||
|
||||
//get rid of null value error
|
||||
$start = $this->input->post(date('von'));
|
||||
$ende = $this->input->post(date('bis'));
|
||||
|
||||
$result = $this->NotizModel->addNotizForType($type, $id, $titel, $text, $uid, $dms_id, $start, $ende, $erledigt, $verfasser_uid, $bearbeiter_uid);
|
||||
|
||||
$result = $this->NotizModel->addNotizForType($type, $id, $titel, $text, $uid, $start, $ende, $erledigt, $verfasser_uid, $bearbeiter_uid);
|
||||
if (isError($result))
|
||||
{
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
return $this->outputJson($result);
|
||||
return $this->outputJson(getError($result));
|
||||
}
|
||||
$notiz_id = $result->retval;
|
||||
|
||||
//Zuordnung speichern
|
||||
/* $result = $this->NotizzuordnungModel->insert(array('notiz_id' => $notiz_id, $type=> $id));
|
||||
if (isError($result))
|
||||
{
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
return $this->outputJson(getError($result));
|
||||
}*/
|
||||
|
||||
|
||||
//Eintrag in Notizdokument speichern
|
||||
if($dms_id_arr)
|
||||
{
|
||||
// Loads model Notizdokument_model
|
||||
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
|
||||
//Todo(manu) change for multiple files
|
||||
foreach($dms_id_arr as $dms_id)
|
||||
{
|
||||
$result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id));
|
||||
if (isError($result))
|
||||
{
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
return $this->outputJson(getError($result));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//$result = $this->NotizModel->addNotizForType($type, $id, $titel, $text, $uid, $dms_id, $start, $ende, $erledigt, $verfasser_uid, $bearbeiter_uid);
|
||||
/*
|
||||
$result = $this->NotizModel->addNotizForPerson($id, $titel, $text, $erledigt, $verfasser_uid);
|
||||
if (isError($result))
|
||||
{
|
||||
//$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
return $this->outputJson($result);
|
||||
}*/
|
||||
return $this->outputJsonSuccess(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ class Notiz_model extends DB_Model
|
||||
* @param id for Dokumentzuordnung (person_id, prestudent_id, uid, projekt_id...)
|
||||
* @param titel, text, start, ende, erledigt, verfasser_uid, bearbeiter_uid, insertvon Parameter for notiz
|
||||
*/
|
||||
public function addNotizForType($type, $id, $titel, $text, $insertvon, $dms_id=null, $start=null, $ende=null, $erledigt=false, $verfasser_uid=null, $bearbeiter_uid=null)
|
||||
public function addNotizForType($type, $id, $titel, $text, $insertvon, $start=null, $ende=null, $erledigt=false, $verfasser_uid=null, $bearbeiter_uid=null)
|
||||
{
|
||||
// Loads model Notizzuordnung_model
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
@@ -153,30 +153,13 @@ class Notiz_model extends DB_Model
|
||||
|
||||
if (isSuccess($result))
|
||||
{
|
||||
//cases für alle types
|
||||
|
||||
$notiz_id = $result->retval;
|
||||
|
||||
if($dms_id)
|
||||
if (isSuccess($result))
|
||||
{
|
||||
// Loads model Notizdokument_model
|
||||
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
|
||||
//Todo(manu) change for multiple files
|
||||
foreach ($dms_id as $file)
|
||||
{
|
||||
$result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $file));
|
||||
}
|
||||
|
||||
//single File
|
||||
//$result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id));
|
||||
$notiz_id = $result->retval;
|
||||
$result = $this->NotizzuordnungModel->insert(array('notiz_id' => $notiz_id, $type => $id));
|
||||
}
|
||||
|
||||
if ($type == 'person')
|
||||
$result = $this->NotizzuordnungModel->insert(array('notiz_id' => $notiz_id, 'person_id' => $id));
|
||||
elseif ($type == 'prestudent')
|
||||
$result = $this->NotizzuordnungModel->insert(array('notiz_id' => $notiz_id, 'prestudent_id' => $id));
|
||||
else
|
||||
$result = error($result->msg, "Type nicht vorhanden");
|
||||
}
|
||||
|
||||
// Transaction complete!
|
||||
|
||||
Reference in New Issue
Block a user