Merge remote-tracking branch 'origin/feature-30660/FHC4_StudierendenGUI_Prototyp' into feature-30660/FHC4_StudierendenGUI_Prototyp

This commit is contained in:
cgfhtw
2024-04-18 15:12:55 +02:00
11 changed files with 926 additions and 385 deletions
@@ -2,15 +2,28 @@
if (! defined('BASEPATH')) exit('No direct script access allowed');
use \DateTime as DateTime;
class Notiz extends FHC_Controller
class Notiz extends FHCAPI_Controller
{
public function __construct()
{
parent::__construct();
parent::__construct([
'getUid' => ['admin:r', 'assistenz:r'],
'getNotizen' => ['admin:r', 'assistenz:r'],
'loadNotiz' => 'assistenz:r', // TODO(manu): self::PERM_LOGGED
'addNewNotiz' => 'assistenz:r', // TODO(manu): self::PERM_LOGGED
'updateNotiz' => 'assistenz:r', // TODO(manu): self::PERM_LOGGED
'deleteNotiz' => ['admin:r', 'assistenz:r'],
'loadDokumente' => ['admin:r', 'assistenz:r'],
'getMitarbeiter' => ['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('AuthLib');
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
// Load language phrases
@@ -21,19 +34,11 @@ class Notiz extends FHC_Controller
public function getUid()
{
// Load Libraries
$this->load->library('AuthLib');
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
$result = getAuthUid();
$this->outputJsonError($result);
$this->terminateWithSuccess(getAuthUID());
}
public function getNotizen($id, $type)
{
$this->load->model('person/Notiz_model', 'NotizModel');
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
//check if valid type
$isValidType = $this->NotizzuordnungModel->isValidType($type);
@@ -42,23 +47,23 @@ class Notiz extends FHC_Controller
$result = $this->NotizModel->getNotizWithDocEntries($id, $type);
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
$this->outputJson(getError($result));
} else {
$this->outputJson(getData($result) ?: []);
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess(getData($result) ?: []);
}
else
{
//Todo manu (phrases, response?)
$result = "datatype not yet implemented for notes";
$this->outputJson(getError($result));
return $this->terminateWithError("type not valid", self::ERROR_TYPE_GENERAL);
}
}
public function loadNotiz($notiz_id)
public function loadNotiz()
{
$this->load->model('person/Notiz_model', 'NotizModel');
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
$notiz_id = $this->input->post('notiz_id');
//$this->load->model('person/Notiz_model', 'NotizModel');
$this->NotizModel->addJoin('public.tbl_notiz_dokument', 'notiz_id', 'LEFT');
$this->NotizModel->addSelect('*');
$this->NotizModel->addSelect("TO_CHAR(CASE WHEN public.tbl_notiz.updateamum >= public.tbl_notiz.insertamum
@@ -68,23 +73,23 @@ class Notiz extends FHC_Controller
$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);
if (isError($result))
{
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
elseif (!hasData($result)) {
$this->outputJson($result);
elseif (!hasData($result))
{
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL);
}
else
{
$this->outputJsonSuccess(current(getData($result)));
$this->terminateWithSuccess(current(getData($result)));
}
}
public function addNewNotiz($id, $paramTyp = null)
{
$this->load->model('person/Notiz_model', 'NotizModel');
//$this->load->model('person/Notiz_model', 'NotizModel');
$this->load->library('DmsLib');
$this->load->library('form_validation');
@@ -101,12 +106,17 @@ class Notiz extends FHC_Controller
}
//Form Validation
$this->form_validation->set_rules('titel', 'titel', 'callback_titel_required');
$this->form_validation->set_rules('text', 'text', 'callback_text_required');
$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)
{
return $this->outputJsonError($this->form_validation->error_array());
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$titel = $this->input->post('titel');
@@ -115,15 +125,14 @@ class Notiz extends FHC_Controller
$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('Von');
$ende = $this->input->post('Bis');
$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))
{
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
return $this->outputJson(getError($result));
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$notiz_id = $result->retval;
@@ -141,12 +150,12 @@ class Notiz extends FHC_Controller
);
//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']);*/
/* $result = $this->dmslib->upload($dms, $k, ['application/pdf','application/x.fhc-dms+json']);*/
if (isError($result))
{
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
return $this->outputJson(getError($result));
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$dms_id_arr[] = $result->retval['dms_id'];
}
@@ -161,20 +170,16 @@ class Notiz extends FHC_Controller
$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));
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
}
}
return $this->outputJsonSuccess(true);
return $this->terminateWithSuccess($result);
}
public function updateNotiz($notiz_id)
public function updateNotiz()
{
$this->load->model('person/Notiz_model', 'NotizModel');
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
$this->load->library('form_validation');
$this->load->library('DmsLib');
@@ -187,18 +192,25 @@ class Notiz extends FHC_Controller
}
}
$notiz_id = $this->input->post('notiz_id');
if(!$notiz_id)
{
return $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
$this->terminateWithError($this->p->t('ui','error_missingId',['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL);
}
//Form Validation
$this->form_validation->set_rules('titel', 'titel', 'callback_titel_required');
$this->form_validation->set_rules('text', 'text', 'callback_text_required');
$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)
{
return $this->outputJsonError($this->form_validation->error_array());
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
//update Notiz
@@ -208,9 +220,8 @@ class Notiz extends FHC_Controller
$verfasser_uid = $this->input->post('verfasser');
$bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : $uid;
$erledigt = $this->input->post('erledigt');
//$type = $this->input->post('typeId'); //soll auch dieser geändert werden können?
$start = $this->input->post('von');
$ende = $this->input->post('bis');
$start = $this->input->post('start');
$ende = $this->input->post('ende');
$result = $this->NotizModel->update(
[
@@ -230,8 +241,7 @@ class Notiz extends FHC_Controller
);
if (isError($result))
{
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
return $this->outputJson(getError($result));
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
//update(1) laden aller bereits mit dieser notiz_id verknüpften DMS-Einträge
@@ -242,8 +252,7 @@ class Notiz extends FHC_Controller
$result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id));
if (isError($result))
{
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
$this->outputJson(getError($result));
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
elseif (!hasData($result))
{
@@ -256,7 +265,7 @@ class Notiz extends FHC_Controller
$dms_id_arr[] = array(
'name' => $doc->name,
'dms_id' => $doc->dms_id
);
);
}
}
@@ -281,20 +290,19 @@ class Notiz extends FHC_Controller
);
//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, array('*'));
if (isError($result))
{
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
return $this->outputJson(getError($result));
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$dms_id = $result->retval['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));
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
}
}
@@ -302,11 +310,18 @@ class Notiz extends FHC_Controller
//update(3) check if Dateien gelöscht wurden
if(count($dms_uploaded) != count($dms_id_arr))
{
$upload_new_names = array_column($dms_uploaded, "name");
if (count($dms_uploaded) == 0)
{
$filesDeleted = $dms_id_arr;
}
else
{
$upload_new_names = array_column($dms_uploaded, "name");
$filesDeleted = array_filter($dms_id_arr, function ($file) use ($upload_new_names) {
return !in_array($file["name"], $upload_new_names);
});
$filesDeleted = array_filter($dms_id_arr, function ($file) use ($upload_new_names) {
return !in_array($file["name"], $upload_new_names);
});
}
foreach ($filesDeleted as $file)
{
@@ -314,18 +329,20 @@ class Notiz extends FHC_Controller
if (isError($result))
{
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
return $this->outputJson(getError($result));
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
else
$this->outputJson($result);
}
}
return $this->outputJsonSuccess(true);
return $this->terminateWithSuccess($result);
}
public function deleteNotiz($notiz_id)
public function deleteNotiz()
{
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
$notiz_id = $this->input->post('notiz_id');
//dms_id auslesen aus notizdokument wenn vorhanden
$dms_id_arr = [];
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
@@ -334,17 +351,13 @@ class Notiz extends FHC_Controller
if (isError($result))
{
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
$this->outputJson(getError($result));
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
elseif (!hasData($result))
{
$this->outputJson($result);
}
else
if(hasData($result))
{
$result = getData($result);
foreach($result as $doc) {
foreach ($result as $doc) {
$dms_id_arr[] = $doc->dms_id;
}
}
@@ -358,15 +371,13 @@ class Notiz extends FHC_Controller
if (isError($result))
{
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
return $this->outputJson(getError($result));
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
else
$this->outputJson($result);
$this->outputJson($result);
}
}
//Todo(manu) rollback?
//delete Notiz und Notizzuordnung
$this->load->model('person/Notiz_model', 'NotizModel');
$this->NotizModel->addJoin('public.tbl_notizzuordnung', 'notiz_id');
@@ -377,20 +388,20 @@ class Notiz extends FHC_Controller
if (isError($result))
{
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
$this->outputJson($result);
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
elseif (!hasData($result)) {
$this->outputJson($result);
if(!hasData($result))
{
return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL);
}
return $this->outputJsonSuccess(current(getData($result)));
return $this->terminateWithSuccess(current(getData($result)));
}
public function loadDokumente($notiz_id)
public function loadDokumente()
{
$this->load->model('person/Notiz_model', 'NotizModel');
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
$notiz_id = $this->input->post('notiz_id');
$this->NotizModel->addSelect('campus.tbl_dms_version.*');
@@ -401,51 +412,24 @@ class Notiz extends FHC_Controller
array('public.tbl_notiz.notiz_id' => $notiz_id)
);
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
$this->outputJson($result);
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
elseif (!hasData($result)) {
$this->outputJson($result);
}
else
if(!hasData($result))
{
$this->outputJsonSuccess(getData($result));
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)
{
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
$result = $this->MitarbeiterModel->searchMitarbeiter($searchString);
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
$this->outputJson($result);
return $this->terminateWithSuccess($result);
}
public function titel_required($value)
{
if (empty($value)) {
$this->form_validation->set_message('titel_required', $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel']));
return false;
}
else
{
return true;
}
}
public function text_required($value)
{
if (empty($value)) {
$this->form_validation->set_message('text_required', $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text']));
return false;
}
else
{
return true;
}
}
}
}
+4 -15
View File
@@ -271,20 +271,6 @@ class Notiz_model extends DB_Model
*/
public function getNotizWithDocEntries($id, $type)
{
// ci query builder returns null
/* $this->db->select('n.*, count(dms_id) as countDoc, z.notizzuordnung_id');
$this->db->select('(CASE WHEN n.updateamum >= n.insertamum THEN n.updateamum ELSE n.insertamum END) AS lastUpdate');
$this->db->from('public.tbl_notiz n');
$this->db->join('public.tbl_notizzuordnung z', 'n.notiz_id = z.notiz_id');
$this->db->join('public.tbl_notiz_dokument dok', 'n.notiz_id = dok.notiz_id', 'left');
$this->db->join('campus.tbl_dms_version', 'dok.notiz_id = campus.tbl_dms_version.dms_id', 'left');
$this->db->where("z.$type", $id);
$this->db->group_by('n.notiz_id, z.notizzuordnung_id');
$query = $this->db->get();
return $query->result();*/
$qry = "
SELECT
n.*, count(dms_id) as countDoc, z.notizzuordnung_id,
@@ -292,7 +278,10 @@ class Notiz_model extends DB_Model
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
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
@@ -137,6 +137,11 @@ export default {
filteredInventar: []
}
},
watch: {
uid(){
this.$refs.table.tabulator.setData('api/frontend/v1/stv/Betriebsmittel/getAllBetriebsmittel/' + this.uid + '/' + this.person_id);
}
},
methods: {
actionEditBetriebsmittel(betriebsmittelperson_id){
this.statusNew = false;
+7 -1
View File
@@ -53,8 +53,14 @@ export default {
},
watch: {
modelValue(n) {
if (n instanceof FileList)
if (!n)
return;
if (n instanceof FileList) {
if (!this.$refs.upload) {
return;
}
return this.$refs.upload.files = n;
}
const dt = new DataTransfer();
const dms = [];
File diff suppressed because it is too large Load Diff
@@ -168,6 +168,11 @@ export default{
}, {}));
}
},
watch: {
uid(){
this.$refs.table.tabulator.setData('api/frontend/v1/stv/Kontakt/getAdressen/' + this.uid);
}
},
methods:{
actionNewAdress(){
this.$refs.newAdressModal.show();
@@ -266,9 +271,6 @@ export default{
this.filteredFirmen = result.data.retval;
});
},
reload(){
this.$refs.table.reloadTable();
},
hideModal(modalRef){
this.$refs[modalRef].hide();
},
@@ -114,6 +114,11 @@ export default{
}
}
},
watch: {
uid(){
this.$refs.table.tabulator.setData('api/frontend/v1/stv/Kontakt/getBankverbindung/' + this.uid);
}
},
methods:{
actionNewBankverbindung(){
this.$refs.newBankverbindungModal.show();
@@ -111,6 +111,11 @@ export default{
filteredStandorte: null
}
},
watch: {
uid(){
this.$refs.table.tabulator.setData('api/frontend/v1/stv/Kontakt/getKontakte/' + this.uid);
}
},
methods:{
actionNewContact(){
this.$refs.newContactModal.show();
@@ -14,13 +14,50 @@ export default {
ref="formc"
typeId="person_id"
:id="modelValue.person_id"
:showErweitert=true
:showDocument=true
:showTinyMCE="true"
notizLayout="twoColumnsFormLeft"
:showErweitert="false"
:showDocument="false"
:showTinyMCE="false"
:visibleColumns=['titel','text','verfasser','bearbeiter']
>
</NotizComponent>
<!-- <br><br>
<!--
---------------------------------------------------------------------------------------------
-------------------- DESCRIPTION FOR PARAMETER PROPS ----------------------------------------
---------------------------------------------------------------------------------------------
notizLayout: "classicFas", "twoColumnsFormLeft", twoColumnsFormRight"
showErweitert: if true: section with following fields will be displayed:
'verfasser', 'bearbeiter', 'von', 'bis'
showDocument: if true: section with documentHandling will be displayed
showTinyMCE: if true: section with WYSIWYG Editor for Text will be displayed
typeId: id to which table the notizdata should be connected... eg. person_id, prestudent_id, mitarbeiter_uid, projekt_kurzbz, projektphase_id, projekttask_id,
bestellung_id, lehreinheit_id, anrechnung_id, uid
in progress for extensions
visibleColumns: list, which fields shoult be showed as default in filter component
fullVersion: :visibleColumns=['titel','text','bearbeiter','verfasser','von','bis','erledigt']
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
-->
<!--
---------------------------------------------------------------------------------------------
------------------------ SOME TESTDATA -----------------------------------------------------
---------------------------------------------------------------------------------------------
<br><br>
<h3>Test prestudentId</h3>
<NotizComponent
ref="formc"
@@ -84,6 +84,9 @@ export default {
this.deltaArray = delta;
},
deep: true
},
modelValue(n){
this.loadPrestudent(n);
}
},
@@ -233,6 +233,9 @@ export default{
const start = this.status_kurzbz;
},
deep: true
},
prestudent_id(){
this.$refs.table.tabulator.setData('api/frontend/v1/stv/Status/getHistoryPrestudent/' + this.prestudent_id);
}
},
methods: {