mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-21 17:02:19 +00:00
Refactor Notizcomponent: add Endpoint and core NotizController
This commit is contained in:
@@ -4,7 +4,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
|
||||
class Notiz extends FHCAPI_Controller
|
||||
class Notiz extends Notiz_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
@@ -32,32 +32,33 @@ class Notiz extends FHCAPI_Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function getUid()
|
||||
/* public function getUid()
|
||||
{
|
||||
$this->terminateWithSuccess(getAuthUID());
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
public function getNotizen($id, $type)
|
||||
{
|
||||
|
||||
//check if valid type
|
||||
$isValidType = $this->NotizzuordnungModel->isValidType($type);
|
||||
$result = $this->NotizzuordnungModel->isValidType($type);
|
||||
if(isError($result))
|
||||
$this->terminateWithError($result->retval, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if($isValidType)
|
||||
{
|
||||
$result = $this->NotizModel->getNotizWithDocEntries($id, $type);
|
||||
//$this->terminateWithError(" after check type not valid", self::ERROR_TYPE_GENERAL);
|
||||
$result = $this->NotizModel->getNotizWithDocEntries($id, $type);
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(getData($result) ?: []);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->terminateWithError("type not valid", self::ERROR_TYPE_GENERAL);
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(getData($result) ?: []);
|
||||
|
||||
// return $this->terminateWithError("type not valid", self::ERROR_TYPE_GENERAL);
|
||||
|
||||
}
|
||||
|
||||
public function loadNotiz()
|
||||
/* public function loadNotiz()
|
||||
{
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
|
||||
@@ -87,96 +88,6 @@ class Notiz extends FHCAPI_Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function addNewNotiz($id, $paramTyp = null)
|
||||
{
|
||||
//$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
|
||||
$this->load->library('DmsLib');
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$uid = getAuthUID();
|
||||
|
||||
if (isset($_POST['data']))
|
||||
{
|
||||
$data = json_decode($_POST['data']);
|
||||
unset($_POST['data']);
|
||||
foreach ($data as $k => $v) {
|
||||
$_POST[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
//Form Validation
|
||||
$this->form_validation->set_rules('titel', 'Titel', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('text', 'Text', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$titel = $this->input->post('titel');
|
||||
$text = $this->input->post('text');
|
||||
$erledigt = $this->input->post('erledigt');
|
||||
$verfasser_uid = isset($_POST['verfasser']) ? $_POST['verfasser'] : $uid;
|
||||
$bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : null;
|
||||
$type = $this->input->post('typeId');
|
||||
$start = $this->input->post('start');
|
||||
$ende = $this->input->post('ende');
|
||||
|
||||
//Speichern der Notiz und Notizzuordnung inkl Prüfung ob valid type
|
||||
$result = $this->NotizModel->addNotizForType($type, $id, $titel, $text, $uid, $start, $ende, $erledigt, $verfasser_uid, $bearbeiter_uid);
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$notiz_id = $result->retval;
|
||||
|
||||
//Speichern der Files
|
||||
$dms_id_arr = [];
|
||||
foreach ($_FILES as $k => $file)
|
||||
{
|
||||
$dms = array(
|
||||
'kategorie_kurzbz' => 'notiz',
|
||||
'version' => 0,
|
||||
'name' => $file["name"],
|
||||
'mimetype' => $file["type"],
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => $uid
|
||||
);
|
||||
|
||||
//Todo(manu) check if filetypes weiter eingeschränkt werden sollen
|
||||
//Todo(manu)check name files: nicht gleiches file 2mal hochladen
|
||||
$result = $this->dmslib->upload($dms, $k, ['*']);
|
||||
/* $result = $this->dmslib->upload($dms, $k, ['application/pdf','application/x.fhc-dms+json']);*/
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$dms_id_arr[] = $result->retval['dms_id'];
|
||||
}
|
||||
|
||||
//Eintrag in Notizdokument speichern
|
||||
if($dms_id_arr)
|
||||
{
|
||||
// Loads model Notizdokument_model
|
||||
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
|
||||
foreach($dms_id_arr as $dms_id)
|
||||
{
|
||||
$result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id));
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function updateNotiz()
|
||||
{
|
||||
@@ -336,12 +247,15 @@ class Notiz extends FHCAPI_Controller
|
||||
}
|
||||
}
|
||||
return $this->terminateWithSuccess($result);
|
||||
}
|
||||
}*/
|
||||
|
||||
public function deleteNotiz()
|
||||
|
||||
/* public function deleteNotiz()
|
||||
{
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
$notiz_id = $this->input->post('notiz_id');
|
||||
$type = $this->input->post('type_id');
|
||||
$id = $this->input->post('id');
|
||||
|
||||
//dms_id auslesen aus notizdokument wenn vorhanden
|
||||
$dms_id_arr = [];
|
||||
@@ -378,10 +292,33 @@ class Notiz extends FHCAPI_Controller
|
||||
}
|
||||
}
|
||||
|
||||
//delete Notiz und Notizzuordnung
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
$this->NotizModel->addJoin('public.tbl_notizzuordnung', 'notiz_id');
|
||||
//delete Notizzuordnung
|
||||
if($type == "software_id")
|
||||
{
|
||||
// Loads extension Model
|
||||
$this->load->model('extensions/FHC-Core-Softwarebereitstellung/Softwarenotizzuordnung_model', 'ExtensionnotizzuordnungModel');
|
||||
$result = $this->ExtensionnotizzuordnungModel->delete([
|
||||
'notiz_id' => $notiz_id,
|
||||
'id' => strval($id)
|
||||
],
|
||||
[
|
||||
'type_id' => $type
|
||||
]);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//notizzuordnungsid!
|
||||
$result = $this->NotizzuordnungModel->delete(['notiz_id' => $notiz_id, $type => $id]);
|
||||
}
|
||||
|
||||
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
//$this->NotizModel->addJoin('public.tbl_notizzuordnung', 'notiz_id');
|
||||
|
||||
//TODO (erweitern um Type_id) für Extensions, damit auch Notizzuordnung gelöscht werden kann
|
||||
|
||||
//Löschen von Notiz
|
||||
$result = $this->NotizModel->delete(
|
||||
array('notiz_id' => $notiz_id)
|
||||
);
|
||||
@@ -396,9 +333,9 @@ class Notiz extends FHCAPI_Controller
|
||||
}
|
||||
|
||||
return $this->terminateWithSuccess(current(getData($result)));
|
||||
}
|
||||
}*/
|
||||
|
||||
public function loadDokumente()
|
||||
/* public function loadDokumente()
|
||||
{
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
$notiz_id = $this->input->post('notiz_id');
|
||||
@@ -420,9 +357,9 @@ class Notiz extends FHCAPI_Controller
|
||||
return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(getData($result));
|
||||
}
|
||||
}*/
|
||||
|
||||
public function getMitarbeiter($searchString)
|
||||
/* public function getMitarbeiter($searchString)
|
||||
{
|
||||
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
|
||||
$result = $this->MitarbeiterModel->searchMitarbeiter($searchString);
|
||||
@@ -430,6 +367,18 @@ class Notiz extends FHCAPI_Controller
|
||||
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess($result);
|
||||
}*/
|
||||
|
||||
public function isBerechtigt($id, $typeId)
|
||||
{
|
||||
if(!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid'))
|
||||
{
|
||||
$result = $this->p->t('lehre','error_keineSchreibrechte');
|
||||
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return success("berechtigt in überschreibender Funktion");
|
||||
/* return $this->terminateWithError('keine Berechtigung bro', self::ERROR_TYPE_GENERAL);*/
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,8 +4,9 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
|
||||
class Notiz_Controller extends FHCAPI_Controller
|
||||
abstract class Notiz_Controller extends FHCAPI_Controller
|
||||
{
|
||||
//public function __construct($zuordnung = 'person/Notizzuordnung_model')
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
@@ -16,12 +17,12 @@ class Notiz_Controller extends FHCAPI_Controller
|
||||
'updateNotiz' => 'assistenz:r', // TODO(manu): self::PERM_LOGGED
|
||||
'deleteNotiz' => ['admin:r', 'assistenz:r'],
|
||||
'loadDokumente' => ['admin:r', 'assistenz:r'],
|
||||
'getMitarbeiter' => ['admin:r', 'assistenz:r']
|
||||
'getMitarbeiter' => ['admin:r', 'assistenz:r'],
|
||||
'isBerechtigt' => ['admin:r', 'assistenz:r']
|
||||
]);
|
||||
|
||||
//Load Models
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
@@ -37,24 +38,47 @@ class Notiz_Controller extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess(getAuthUID());
|
||||
}
|
||||
|
||||
public function getNotizen($id, $type)
|
||||
|
||||
//Standardfall: für extensions überschreiben: speichern der Zuordnung in eigene Extensiontabelle angeben
|
||||
protected function assignNotiz($notiz_id, $id, $type)
|
||||
{
|
||||
|
||||
//check if valid type
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
$result = $this->NotizzuordnungModel->isValidType($type);
|
||||
if(isError($result))
|
||||
$this->terminateWithError($result->retval, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
//$this->terminateWithError(" after check type not valid", self::ERROR_TYPE_GENERAL);
|
||||
$result = $this->NotizModel->getNotizWithDocEntries($id, $type);
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(getData($result) ?: []);
|
||||
$result = $this->NotizzuordnungModel->insert(array('notiz_id' => $notiz_id, $type => $id));
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return success(getData($result));
|
||||
}
|
||||
|
||||
// return $this->terminateWithError("type not valid", self::ERROR_TYPE_GENERAL);
|
||||
//Standardfall: für extensions überschreiben: speichern der Zuordnung in eigene Extensiontabelle angeben
|
||||
protected function deleteNotizzuordnung($notiz_id, $id, $type)
|
||||
{
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
$result = $this->NotizzuordnungModel->isValidType($type);
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError('type not in table notizzuordnung enthalten..', self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$result = $this->NotizzuordnungModel->delete(['notiz_id' => $notiz_id, $type => $id]);
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return success(getData($result));
|
||||
}
|
||||
|
||||
|
||||
|
||||
//TODO(manu) abstract
|
||||
protected function getNotizen($id, $type) {}
|
||||
|
||||
//TODO(manu) to abstract
|
||||
protected function isBerechtigt($id, $typeId){
|
||||
return $this->terminateWithError("in abstract function: define right in extension", self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
public function loadNotiz()
|
||||
@@ -89,8 +113,6 @@ class Notiz_Controller extends FHCAPI_Controller
|
||||
|
||||
public function addNewNotiz($id, $paramTyp = null)
|
||||
{
|
||||
//$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
|
||||
$this->load->library('DmsLib');
|
||||
$this->load->library('form_validation');
|
||||
|
||||
@@ -122,21 +144,37 @@ class Notiz_Controller extends FHCAPI_Controller
|
||||
$titel = $this->input->post('titel');
|
||||
$text = $this->input->post('text');
|
||||
$erledigt = $this->input->post('erledigt');
|
||||
$verfasser_uid = isset($_POST['verfasser']) ? $_POST['verfasser'] : $uid;
|
||||
$bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : null;
|
||||
$verfasser_uid = isset($_POST['verfasser_uid']) ? $_POST['verfasser_uid'] : $uid;
|
||||
$bearbeiter_uid = isset($_POST['bearbeiter_uid']) ? $_POST['bearbeiter_uid'] : null;
|
||||
$type = $this->input->post('typeId');
|
||||
$start = $this->input->post('start');
|
||||
$ende = $this->input->post('ende');
|
||||
|
||||
//Speichern der Notiz und Notizzuordnung inkl Prüfung ob valid type
|
||||
$result = $this->NotizModel->addNotizForType($type, $id, $titel, $text, $uid, $start, $ende, $erledigt, $verfasser_uid, $bearbeiter_uid);
|
||||
// Start DB transaction
|
||||
$this->db->trans_start();
|
||||
|
||||
//Speichern der Notiz
|
||||
$result = $this->NotizModel->insert(array('titel' => $titel, 'text' => $text, 'erledigt' => $erledigt, 'verfasser_uid' => $verfasser_uid,
|
||||
"insertvon" => $verfasser_uid, 'start' => $start, 'ende' => $ende, 'bearbeiter_uid' => $bearbeiter_uid));
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$this->db->trans_rollback();
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$notiz_id = $result->retval;
|
||||
|
||||
//Speichern der Files
|
||||
//Speichern der Notizzuordnung
|
||||
$result = $this->assignNotiz($notiz_id, $id, $type);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
//Speichern der Dokumente
|
||||
$dms_id_arr = [];
|
||||
foreach ($_FILES as $k => $file)
|
||||
{
|
||||
@@ -155,6 +193,7 @@ class Notiz_Controller extends FHCAPI_Controller
|
||||
/* $result = $this->dmslib->upload($dms, $k, ['application/pdf','application/x.fhc-dms+json']);*/
|
||||
if (isError($result))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$dms_id_arr[] = $result->retval['dms_id'];
|
||||
@@ -170,11 +209,12 @@ class Notiz_Controller extends FHCAPI_Controller
|
||||
$result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id));
|
||||
if (isError($result))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
return $this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
@@ -217,8 +257,8 @@ class Notiz_Controller extends FHCAPI_Controller
|
||||
$uid = getAuthUID();
|
||||
$titel = $this->input->post('titel');
|
||||
$text = $this->input->post('text');
|
||||
$verfasser_uid = $this->input->post('verfasser');
|
||||
$bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : $uid;
|
||||
$verfasser_uid = $this->input->post('verfasser_uid');
|
||||
$bearbeiter_uid = isset($_POST['bearbeiter_uid']) ? $_POST['bearbeiter_uid'] : $uid;
|
||||
$erledigt = $this->input->post('erledigt');
|
||||
$start = $this->input->post('start');
|
||||
$ende = $this->input->post('ende');
|
||||
@@ -338,14 +378,20 @@ class Notiz_Controller extends FHCAPI_Controller
|
||||
return $this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
|
||||
public function deleteNotiz()
|
||||
{
|
||||
$this->load->library('DmsLib');
|
||||
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
$notiz_id = $this->input->post('notiz_id');
|
||||
$type = $this->input->post('type_id');
|
||||
$typeId = $this->input->post('type_id');
|
||||
$id = $this->input->post('id');
|
||||
|
||||
if(!$this->isBerechtigt($id, $typeId))
|
||||
{
|
||||
$this->terminateWithError($this->p->t('ui', 'keineBerechtigung'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
//dms_id auslesen aus notizdokument wenn vorhanden
|
||||
$dms_id_arr = [];
|
||||
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
|
||||
@@ -367,13 +413,20 @@ class Notiz_Controller extends FHCAPI_Controller
|
||||
|
||||
if($dms_id_arr)
|
||||
{
|
||||
// Start DB transaction
|
||||
$this->db->trans_start();
|
||||
|
||||
//return $this->terminateWithError("dms_id kommt: " . $notiz_id, self::ERROR_TYPE_GENERAL);
|
||||
$this->load->library('DmsLib');
|
||||
|
||||
|
||||
foreach($dms_id_arr as $dms_id)
|
||||
{
|
||||
$result = $this->dmslib->removeAll($dms_id);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
@@ -382,30 +435,14 @@ class Notiz_Controller extends FHCAPI_Controller
|
||||
}
|
||||
|
||||
//delete Notizzuordnung
|
||||
if($type == "software_id")
|
||||
$result = $this-> deleteNotizzuordnung($notiz_id, $id, $typeId);
|
||||
if (isError($result))
|
||||
{
|
||||
// Loads extension Model
|
||||
$this->load->model('extensions/FHC-Core-Softwarebereitstellung/Softwarenotizzuordnung_model', 'ExtensionnotizzuordnungModel');
|
||||
$result = $this->ExtensionnotizzuordnungModel->delete([
|
||||
'notiz_id' => $notiz_id,
|
||||
'id' => strval($id)
|
||||
],
|
||||
[
|
||||
'type_id' => $type
|
||||
]);
|
||||
|
||||
$this->db->trans_rollback();
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
//notizzuordnungsid!
|
||||
$result = $this->NotizzuordnungModel->delete(['notiz_id' => $notiz_id, $type => $id]);
|
||||
}
|
||||
|
||||
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
//$this->NotizModel->addJoin('public.tbl_notizzuordnung', 'notiz_id');
|
||||
|
||||
//TODO (erweitern um Type_id) für Extensions, damit auch Notizzuordnung gelöscht werden kann
|
||||
|
||||
//Löschen von Notiz
|
||||
$result = $this->NotizModel->delete(
|
||||
@@ -414,6 +451,7 @@ class Notiz_Controller extends FHCAPI_Controller
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if(!hasData($result))
|
||||
@@ -421,11 +459,16 @@ class Notiz_Controller extends FHCAPI_Controller
|
||||
return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$this->db->trans_rollback();
|
||||
return $this->terminateWithSuccess(current(getData($result)));
|
||||
}
|
||||
|
||||
public function loadDokumente()
|
||||
{
|
||||
if(!$this->isBerechtigt('$id', '$typeId'))
|
||||
{
|
||||
$this->terminateWithError($this->p->t('ui', 'keineBerechtigung'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
$notiz_id = $this->input->post('notiz_id');
|
||||
|
||||
|
||||
@@ -180,13 +180,29 @@ class Notiz_model extends DB_Model
|
||||
{
|
||||
$notiz_id = $result->retval;
|
||||
|
||||
if (isSuccess($result))
|
||||
//TODO(Manu) neue Function assign Notiz
|
||||
if($type == "software_id")
|
||||
{
|
||||
// Loads extension Model
|
||||
$this->load->model('extensions/FHC-Core-Softwarebereitstellung/Softwarenotizzuordnung_model', 'ExtensionnotizzuordnungModel');
|
||||
$result = $this->ExtensionnotizzuordnungModel->insert([
|
||||
'notiz_id' => $notiz_id,
|
||||
'id' => $id,
|
||||
'type_id' => $type
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$notiz_id = $result->retval;
|
||||
$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 error('Fehler Insert Zuordnungstabelle');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Transaction complete!
|
||||
$this->db->trans_complete();
|
||||
|
||||
@@ -207,8 +223,10 @@ class Notiz_model extends DB_Model
|
||||
|
||||
/**
|
||||
* Add a Notiz for a given person with DMS_id
|
||||
*
|
||||
*/
|
||||
public function addNotizForPersonWithDoc($person_id, $titel, $text, $erledigt, $verfasser_uid, $von, $bis, $dms_id = null)
|
||||
//Todo(manu) deprecated?
|
||||
/* public function addNotizForPersonWithDoc($person_id, $titel, $text, $erledigt, $verfasser_uid, $von, $bis, $dms_id = null)
|
||||
{
|
||||
// Loads model Notizzuordnung_model
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
@@ -228,7 +246,7 @@ class Notiz_model extends DB_Model
|
||||
{
|
||||
// Loads model Notizdokument_model
|
||||
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
|
||||
//Todo(manu) change for multiple files
|
||||
|
||||
$result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id));
|
||||
}
|
||||
}
|
||||
@@ -249,7 +267,7 @@ class Notiz_model extends DB_Model
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* gets all Notizen for a person
|
||||
@@ -271,32 +289,33 @@ class Notiz_model extends DB_Model
|
||||
*/
|
||||
public function getNotizWithDocEntries($id, $type)
|
||||
{
|
||||
$qry = "
|
||||
SELECT
|
||||
n.*, count(dms_id) as countDoc, z.notizzuordnung_id,
|
||||
TO_CHAR (CASE
|
||||
WHEN n.updateamum >= n.insertamum THEN n.updateamum
|
||||
ELSE n.insertamum
|
||||
END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate,
|
||||
regexp_replace(n.text, '<[^>]*>', '', 'g') as text_stripped,
|
||||
TO_CHAR(n.start::timestamp, 'DD.MM.YYYY') AS start_format,
|
||||
TO_CHAR(n.ende::timestamp, 'DD.MM.YYYY') AS ende_format
|
||||
|
||||
FROM
|
||||
public.tbl_notiz n
|
||||
JOIN
|
||||
public.tbl_notizzuordnung z USING (notiz_id)
|
||||
LEFT JOIN
|
||||
public.tbl_notiz_dokument dok USING (notiz_id)
|
||||
LEFT JOIN
|
||||
campus.tbl_dms_version USING (dms_id)
|
||||
WHERE
|
||||
z.$type = ?
|
||||
GROUP BY
|
||||
notiz_id, z.notizzuordnung_id
|
||||
";
|
||||
$qry = "
|
||||
SELECT
|
||||
n.*, count(dms_id) as countDoc, z.notizzuordnung_id,
|
||||
TO_CHAR (CASE
|
||||
WHEN n.updateamum >= n.insertamum THEN n.updateamum
|
||||
ELSE n.insertamum
|
||||
END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate,
|
||||
regexp_replace(n.text, '<[^>]*>', '', 'g') as text_stripped,
|
||||
TO_CHAR(n.start::timestamp, 'DD.MM.YYYY') AS start_format,
|
||||
TO_CHAR(n.ende::timestamp, 'DD.MM.YYYY') AS ende_format,
|
||||
z.notiz_id, z.person_id as id, ? as type_id
|
||||
|
||||
FROM
|
||||
public.tbl_notiz n
|
||||
JOIN
|
||||
public.tbl_notizzuordnung z USING (notiz_id)
|
||||
LEFT JOIN
|
||||
public.tbl_notiz_dokument dok USING (notiz_id)
|
||||
LEFT JOIN
|
||||
campus.tbl_dms_version USING (dms_id)
|
||||
WHERE
|
||||
z.$type = ?
|
||||
GROUP BY
|
||||
notiz_id, z.notizzuordnung_id
|
||||
";
|
||||
|
||||
return $this->execQuery($qry, array($id));
|
||||
return $this->execQuery($qry, array($type, $id));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -32,14 +32,17 @@ class Notizzuordnung_model extends DB_Model
|
||||
$validTypes[] = $t->column_name;
|
||||
}
|
||||
|
||||
if (in_array($type, $validTypes))
|
||||
//TODO(manu) param id
|
||||
if (in_array($type, $validTypes) )
|
||||
//if (in_array($type, $validTypes) ||($type == 'software_id')) //Just for testing
|
||||
{
|
||||
$result = success('Type of Id is valid');
|
||||
return success("Type " . $type . " is valid");
|
||||
// $result = success('Type of Id is valid');
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = error('Type of Id is not valid');
|
||||
return error("Type " . $type . " is NOT valid");
|
||||
}
|
||||
return $result;
|
||||
//return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user