mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-19 16:02:15 +00:00
Notiz löschen mit Dokumenten, Start Umbau Funktionen von person_id auf typ
This commit is contained in:
@@ -22,6 +22,7 @@ class Notiz extends FHC_Controller
|
||||
public function getNotizen($person_id)
|
||||
{
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
$type = 'person';
|
||||
|
||||
$result = $this->NotizModel->getNotizWithDocEntries($person_id);
|
||||
|
||||
@@ -37,9 +38,7 @@ class Notiz extends FHC_Controller
|
||||
{
|
||||
$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(
|
||||
@@ -60,19 +59,25 @@ class Notiz extends FHC_Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function addNewNotiz($person_id)
|
||||
public function addNewNotiz($id)
|
||||
{
|
||||
/* var_dump($this->input->post('titel'));
|
||||
var_dump($this->input->post('anhang'));*/
|
||||
|
||||
var_dump($_FILES);
|
||||
var_dump($_FILES["anhang"]["name"]);
|
||||
|
||||
$this->load->library('form_validation');
|
||||
$this->load->library('DmsLib');
|
||||
$dms_id = null;
|
||||
|
||||
//DMS-Logik zum Speichern des Anhangs
|
||||
/* var_dump("im Backend: addNewNotiz, dmslogik");
|
||||
var_dump($_FILES);*/
|
||||
|
||||
$this->load->library('DmsLib');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$uid = getAuthUID();
|
||||
|
||||
//single
|
||||
$dms_id = null;
|
||||
$dms = array(
|
||||
'kategorie_kurzbz' => 'notiz',
|
||||
'version' => 0,
|
||||
@@ -82,22 +87,61 @@ class Notiz extends FHC_Controller
|
||||
'insertvon' => $uid
|
||||
);
|
||||
|
||||
var_dump($dms);
|
||||
//var_dump($dms);
|
||||
|
||||
$result = $this->dmslib->upload($dms, 'anhang', array('pdf'));
|
||||
//var_dump($result);
|
||||
|
||||
if (isSuccess($result))
|
||||
{
|
||||
//TODO(Manu) change to array
|
||||
$dms_id = $result->retval['dms_id'];
|
||||
//var_dump($dms_id);
|
||||
}
|
||||
|
||||
//var_dump($dms_id);
|
||||
|
||||
/* //multiple files
|
||||
$dms_id = [];
|
||||
foreach ($_FILES as $file)
|
||||
{
|
||||
//var_dump($file["name"]);
|
||||
var_dump($file);
|
||||
$dms = array(
|
||||
'kategorie_kurzbz' => 'notiz',
|
||||
'version' => 0,
|
||||
'name' => $file["name"],
|
||||
'mimetype' => $file["type"],
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => $uid
|
||||
);
|
||||
|
||||
$result = $this->dmslib->upload($dms, 'file', array('pdf'));
|
||||
var_dump($result);
|
||||
|
||||
if (isSuccess($result))
|
||||
{
|
||||
//TODO(Manu) change to array
|
||||
$dms_id[] = $result->retval['dms_id'];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
var_dump($dms_id);
|
||||
return;*/
|
||||
|
||||
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
|
||||
//var_dump($_POST);
|
||||
|
||||
$uid = getAuthUID();
|
||||
$titel = isset($_POST['titel']) ? $_POST['titel'] : null;
|
||||
$text = isset($_POST['text']) ? $_POST['text'] : null;
|
||||
$verfasser_uid = $uid;
|
||||
$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'];
|
||||
|
||||
/* $start = isset($_POST['bis']) ? ($_POST['bis'] : null;
|
||||
$ende = isset($_POST['bis']) ? $_POST['bis'] : null;*/
|
||||
@@ -125,18 +169,24 @@ class Notiz extends FHC_Controller
|
||||
if(isset($_POST['bis']))
|
||||
{
|
||||
//Todo(manu) check input format datepicker
|
||||
$ende = strtotime($_POST['bis']);
|
||||
/* $ende = strtotime($_POST['bis']);
|
||||
$ende = new DateTime($ende);
|
||||
$ende = $ende->format('Y-m-d');
|
||||
$ende = $ende->format('Y-m-d');*/
|
||||
|
||||
$ende = '2023-01-01';
|
||||
}
|
||||
else
|
||||
$ende = null;
|
||||
|
||||
|
||||
//Todo(manu) multiple files
|
||||
$result = $this->NotizModel->addNotizForType($type, $id, $titel, $text, $uid, $dms_id, $start, $ende, $erledigt, $verfasser_uid, $bearbeiter_uid);
|
||||
|
||||
//vorher
|
||||
//$result = $this->NotizModel->addNotizForPersonWithDoc($id, $titel, $text, $erledigt, $verfasser_uid, $start, $ende, $dms_id);
|
||||
|
||||
|
||||
$erledigt = $_POST['erledigt'];
|
||||
|
||||
$result = $this->NotizModel->addNotizForPersonWithDoc($person_id, $titel, $text, $erledigt, $verfasser_uid, $start, $ende, $dms_id);
|
||||
|
||||
// var_dump($result);
|
||||
|
||||
@@ -220,8 +270,51 @@ class Notiz extends FHC_Controller
|
||||
|
||||
public function deleteNotiz ($notiz_id)
|
||||
{
|
||||
//Todo(manu) Notizzuordnung und NotizDokument ebenfalls berücksichtigen
|
||||
//dms_id auslesen aus notizdokument wenn vorhanden
|
||||
$dms_id = null;
|
||||
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
|
||||
|
||||
$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($result);
|
||||
}
|
||||
elseif (!hasData($result))
|
||||
{
|
||||
$this->outputJson($result);
|
||||
$dms_id = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Todo(manu( umbau auf array)
|
||||
$result = current(getData($result));
|
||||
$dms_id = $result->dms_id;
|
||||
}
|
||||
|
||||
if($dms_id)
|
||||
{
|
||||
$this->load->library('DmsLib');
|
||||
$result = $this->dmslib->removeAll($dms_id);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
$this->outputJson($result);
|
||||
}
|
||||
else
|
||||
$this->outputJson($result);
|
||||
|
||||
//return $this->outputJsonSuccess(current(getData($result)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Todo(manu) rollback?
|
||||
//delete Notiz und Notizzuordnung
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
$this->NotizModel->addJoin('public.tbl_notizzuordnung', 'notiz_id');
|
||||
|
||||
$result = $this->NotizModel->delete(
|
||||
array('notiz_id' => $notiz_id)
|
||||
@@ -235,6 +328,7 @@ class Notiz extends FHC_Controller
|
||||
elseif (!hasData($result)) {
|
||||
$this->outputJson($result);
|
||||
}
|
||||
|
||||
return $this->outputJsonSuccess(current(getData($result)));
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,65 @@ class Notiz_model extends DB_Model
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Notiz for a given person
|
||||
* Add a Notiz with Notizuordnung for a given type
|
||||
* @param type type of id for Notizzuordnung (example: person, prestudent, mitarbeiter, projekt, projektphase, projekttask,
|
||||
* bestellung, lehreinheit, anrechnung)
|
||||
* @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)
|
||||
{
|
||||
// Loads model Notizzuordnung_model
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
|
||||
// Start DB transaction
|
||||
$this->db->trans_start(false);
|
||||
|
||||
$result = $this->insert(array('titel' => $titel, 'text' => $text, 'erledigt' => $erledigt, 'verfasser_uid' => $verfasser_uid,
|
||||
"insertvon" => $insertvon, 'start' => $start, 'ende' => $ende, 'bearbeiter_uid' => $bearbeiter_uid));
|
||||
|
||||
if (isSuccess($result))
|
||||
{
|
||||
//cases für alle types
|
||||
|
||||
$notiz_id = $result->retval;
|
||||
|
||||
if($dms_id)
|
||||
{
|
||||
// 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));
|
||||
}
|
||||
|
||||
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!
|
||||
$this->db->trans_complete();
|
||||
|
||||
// Check if everything went ok during the transaction
|
||||
if ($this->db->trans_status() === false || isError($result))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
$result = error($result->msg, EXIT_ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->trans_commit();
|
||||
$result = success($notiz_id);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Notiz for a given person with DMS_id
|
||||
*/
|
||||
//TODO(manu) add type for Notizzuordnung
|
||||
public function addNotizForPersonWithDoc($person_id, $titel, $text, $erledigt, $verfasser_uid, $von, $bis, $dms_id=null)
|
||||
@@ -157,6 +215,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));
|
||||
}
|
||||
}
|
||||
@@ -192,15 +251,19 @@ class Notiz_model extends DB_Model
|
||||
}
|
||||
|
||||
/**
|
||||
* gets all Notizen with Documententries for a person
|
||||
* gets all Notizen with Documententries for a certain type and type_id
|
||||
* @param $person_id
|
||||
*/
|
||||
//Todo(Manu) rewrite in CI-Style
|
||||
public function getNotizWithDocEntries($person_id)
|
||||
public function getNotizWithDocEntries($id)
|
||||
{
|
||||
$type = 'writeFunction';
|
||||
//$type_id = 'z.person_id';
|
||||
|
||||
|
||||
$qry = "
|
||||
SELECT
|
||||
n.*, count(dms_id) as countDoc
|
||||
n.*, count(dms_id) as countDoc, z.notizzuordnung_id
|
||||
FROM
|
||||
public.tbl_notiz n
|
||||
JOIN
|
||||
@@ -210,12 +273,12 @@ class Notiz_model extends DB_Model
|
||||
LEFT JOIN
|
||||
campus.tbl_dms_version USING (dms_id)
|
||||
WHERE
|
||||
z.person_id = ?
|
||||
z.person_id = ?
|
||||
GROUP BY
|
||||
notiz_id
|
||||
notiz_id, z.notizzuordnung_id
|
||||
";
|
||||
|
||||
return $this->execQuery($qry, array($person_id));
|
||||
return $this->execQuery($qry, array($id));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ export default {
|
||||
//SingleFile
|
||||
},
|
||||
props: [
|
||||
'typeId',
|
||||
'titel',
|
||||
'text',
|
||||
'von',
|
||||
@@ -96,24 +97,32 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
/* mounted(){
|
||||
showZuordnung(){
|
||||
this.idTyp = 'Person';
|
||||
}
|
||||
},*/
|
||||
methods: {
|
||||
handleFileChange(event) {
|
||||
//single
|
||||
this.intAnhang = event.target.files[0];
|
||||
|
||||
//multiple
|
||||
//multiple not working
|
||||
//this.intAnhang = event.target.files;
|
||||
},
|
||||
},
|
||||
template: `
|
||||
<div>
|
||||
|
||||
component: {{intTitel}} {{intVon}} || {{intAnhang.name}} {{intAnhang}}
|
||||
component: {{intTitel}} {{intVon}} || {{intAnhang.name}} {{intAnhang}} {{typeId}}
|
||||
<form class="row">
|
||||
<div>
|
||||
<div class="row mb-3">
|
||||
<b>{{action}}</b>
|
||||
</div>
|
||||
<div>
|
||||
<p>Zuordnung {{this.typeId}}</p>
|
||||
</div>
|
||||
<div class="notizTitle row mb-3">
|
||||
<label for="titel" class="form-label col-sm-2">Titel</label>
|
||||
<div class="col-sm-7">
|
||||
@@ -181,7 +190,7 @@ component: {{intTitel}} {{intVon}} || {{intAnhang.name}} {{intAnhang}}
|
||||
<div class="row mb-3">
|
||||
<label for="von" class="form-label col-sm-2">von</label>
|
||||
<div class="col-sm-2">
|
||||
<vue-date-picker id="von" v-model="intVon" clearable="false" auto-apply enable-time-picker="true" format="Y-m-d" preview-format="dd.MM.yyyy"></vue-date-picker>
|
||||
<vue-date-picker id="von" v-model="intVon" clearable="false" auto-apply enable-time-picker="true" format="dd.MM.yyyy" preview-format="dd.MM.yyyy"></vue-date-picker>
|
||||
</div>
|
||||
|
||||
<label for="bis" class="form-label col-sm-1">bis</label>
|
||||
|
||||
@@ -24,6 +24,7 @@ export default {
|
||||
return {
|
||||
tabulatorOptions: {
|
||||
ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Notiz/getNotizen/' + this.modelValue.person_id),
|
||||
// + this.modelValue.person_id, 'person'),
|
||||
columns: [
|
||||
{title: "Titel", field: "titel"},
|
||||
{title: "Text", field: "text", width: 350},
|
||||
@@ -58,6 +59,7 @@ export default {
|
||||
tabulatorEvents: [],
|
||||
notizen: [],
|
||||
formData: {
|
||||
typeId: 'person',
|
||||
titel: null,
|
||||
action: 'Neue Notiz',
|
||||
text: null,
|
||||
@@ -102,6 +104,7 @@ export default {
|
||||
});
|
||||
},
|
||||
actionNewNotiz(){
|
||||
this.formData.typeId = 'person';
|
||||
this.formData.titel = '';
|
||||
this.formData.action = 'Neue Notiz2';
|
||||
this.formData.text = null;
|
||||
@@ -114,10 +117,20 @@ export default {
|
||||
this.formData.anhang = [];
|
||||
},
|
||||
addNewNotiz(notizData) {
|
||||
//console.log(this.formData);
|
||||
/* console.log("here: anhang noch empty");
|
||||
console.log(this.formData);*/
|
||||
const formData = new FormData();
|
||||
|
||||
Object.entries(this.formData).forEach(([k, v]) => formData.append(k, v));
|
||||
//console.log(formData);
|
||||
|
||||
/* for( var i = 0; i < this.formData.anhang.length; i++ ){
|
||||
let file = this.formData.anhang[i];
|
||||
|
||||
formData.append('files[' + i + ']', file);
|
||||
}*/
|
||||
|
||||
console.log("after append");
|
||||
console.log(formData);
|
||||
CoreRESTClient.post('components/stv/Notiz/addNewNotiz/' + this.modelValue.person_id,
|
||||
formData,
|
||||
{ Headers: { "Content-Type": "multipart/form-data" } }
|
||||
@@ -263,6 +276,7 @@ export default {
|
||||
<Notiz
|
||||
:showErweitert="showErweitert"
|
||||
:showDocument="showDocument"
|
||||
v-model:typeId="formData.typeId"
|
||||
v-model:titel="formData.titel"
|
||||
v-model:text="formData.text"
|
||||
v-model:action="formData.action"
|
||||
@@ -281,7 +295,7 @@ export default {
|
||||
|
||||
|
||||
<div>
|
||||
parent: {{formData.anhang}} | {{formData.anhang.name}}
|
||||
parent: {{formData.anhang}} {{formData.typeId}} | {{formData.anhang.name}}
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user