mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 02:12:17 +00:00
Start Component Notiz und Tab Notizen
This commit is contained in:
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
|
||||
class Notiz 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 getNotizen($person_id)
|
||||
{
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
|
||||
$result = $this->NotizModel->getNotiz($person_id, true);
|
||||
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
$this->outputJson(getError($result));
|
||||
} else {
|
||||
$this->outputJson(getData($result) ?: []);
|
||||
}
|
||||
}
|
||||
|
||||
public function loadNotiz($notiz_id)
|
||||
{
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
$this->NotizModel->addJoin('public.tbl_notiz_dokument', 'notiz_id', 'LEFT');
|
||||
|
||||
$this->NotizModel->addSelect('*');
|
||||
|
||||
$this->NotizModel->addLimit(1);
|
||||
|
||||
$result = $this->NotizModel->loadWhere(
|
||||
array('notiz_id' => $notiz_id)
|
||||
);
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
$this->outputJson($result);
|
||||
}
|
||||
|
||||
elseif (!hasData($result)) {
|
||||
$this->outputJson($result); //success mit Wert null
|
||||
// $this->outputJson(getData($result) ?: []);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->outputJsonSuccess(current(getData($result)));
|
||||
}
|
||||
}
|
||||
|
||||
public function addNewNotiz($person_id)
|
||||
{
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
$this->load->library('form_validation');
|
||||
|
||||
|
||||
$this->form_validation->set_rules('titel', 'titel', 'required');
|
||||
$this->form_validation->set_rules('text', 'Text', 'required');
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
|
||||
$uid = getAuthUID();
|
||||
$titel = isset($_POST['titel']) ? $_POST['titel'] : null;
|
||||
$text = isset($_POST['text']) ? $_POST['text'] : null;
|
||||
//$verfasser_uid = isset($_POST['verfasser_uid']) ? $_POST['verfasser_uid'] : null;
|
||||
$verfasser_uid = $uid;
|
||||
$start = isset($_POST['von']) ? $_POST['von'] : null;
|
||||
$ende = isset($_POST['bis']) ? $_POST['bis'] : null;
|
||||
$erledigt = $_POST['erledigt'];
|
||||
|
||||
/* $dms_id = isset($_POST['dms_id']) ? $_POST['dms_id'] : null;
|
||||
$bearbeiter_uid = isset($_POST['bearbeiter_uid']) ? $_POST['bearbeiter_uid'] : null;
|
||||
|
||||
*/
|
||||
|
||||
$result = $this->NotizModel->addNotizForPersonWithDoc($person_id, $titel, $text, $erledigt, $verfasser_uid, $start, $ende);
|
||||
|
||||
// var_dump($result);
|
||||
|
||||
/* $result = $this->NotizModel->insert(
|
||||
[
|
||||
'titel' => $titel,
|
||||
'text' => $text,
|
||||
'insertvon' => $uid,
|
||||
'insertamum' => date('c'),
|
||||
'verfasser_uid' => $verfasser_uid,
|
||||
'bearbeiter_uid' => $bearbeiter_uid,
|
||||
'start' => $start,
|
||||
'ende' => $ende,
|
||||
'erledigt' => $_POST['erledigt'],
|
||||
//'dms_id' => $dms_id
|
||||
]
|
||||
);*/
|
||||
if (isError($result))
|
||||
{
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
return $this->outputJson($result);
|
||||
}
|
||||
return $this->outputJsonSuccess(true);
|
||||
}
|
||||
|
||||
public function updateNotiz($notiz_id)
|
||||
{
|
||||
$uid = getAuthUID();
|
||||
$this->load->library('form_validation');
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$this->form_validation->set_rules('titel', 'titel', 'required');
|
||||
$this->form_validation->set_rules('text', 'Text', 'required');
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
|
||||
if(!$notiz_id)
|
||||
{
|
||||
return $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
// $person_id = isset($_POST['person_id']) ? $_POST['person_id'] : null;
|
||||
$uid = getAuthUID();
|
||||
$titel = isset($_POST['titel']) ? $_POST['titel'] : null;
|
||||
$text = isset($_POST['text']) ? $_POST['text'] : null;
|
||||
$verfasser_uid = isset($_POST['verfasser_uid']) ? $_POST['verfasser_uid'] : null;
|
||||
$bearbeiter_uid = $uid;
|
||||
$start = isset($_POST['von']) ? $_POST['von'] : null;
|
||||
$ende = isset($_POST['bis']) ? $_POST['bis'] : null;
|
||||
$erledigt = $_POST['erledigt'];
|
||||
|
||||
$result = $this->NotizModel->update(
|
||||
[
|
||||
'notiz_id' => $notiz_id
|
||||
],
|
||||
[
|
||||
'titel' => $titel,
|
||||
'updatevon' => $uid,
|
||||
'updateamum' => date('c'),
|
||||
'text' => $text,
|
||||
'verfasser_uid' => $verfasser_uid,
|
||||
'bearbeiter_uid' => $bearbeiter_uid,
|
||||
'start' => $start,
|
||||
'ende' => $ende,
|
||||
'erledigt' => $erledigt
|
||||
]
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
return $this->outputJson(getError($result));
|
||||
}
|
||||
return $this->outputJsonSuccess(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user