mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-18 07:22:17 +00:00
finished Handling of Fileuploads
This commit is contained in:
@@ -50,7 +50,7 @@ class Notiz extends FHC_Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
//Todo manu (correct return to ajax)
|
||||
//Todo manu (phrases, response?)
|
||||
$result = "datatype not yet implemented for notes";
|
||||
$this->outputJson(getError($result));
|
||||
}
|
||||
@@ -107,6 +107,8 @@ class Notiz extends FHC_Controller
|
||||
if(isset($_POST['typeId']))
|
||||
$type = $this->input->post('typeId');
|
||||
|
||||
//var_dump($_POST);
|
||||
|
||||
if(!$type)
|
||||
{
|
||||
$result = error('kein Type für ID vorhanden', EXIT_ERROR);
|
||||
@@ -155,7 +157,9 @@ class Notiz extends FHC_Controller
|
||||
'insertvon' => $uid
|
||||
);
|
||||
|
||||
$result = $this->dmslib->upload($dms, $k, array('pdf'));
|
||||
//Todo(manu) check if filetypes weiter eingeschränkt werden sollen
|
||||
$result = $this->dmslib->upload($dms, $k, ['*']);
|
||||
/* $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);
|
||||
@@ -221,7 +225,7 @@ class Notiz extends FHC_Controller
|
||||
$verfasser_uid = isset($_POST['verfasser_uid']) ? $_POST['verfasser_uid'] : null;
|
||||
$bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : $uid;
|
||||
$erledigt = $this->input->post('erledigt');
|
||||
$type = $this->input->post('typeId');
|
||||
//$type = $this->input->post('typeId'); //soll auch dieser geändert werden können?
|
||||
$start = $this->input->post('von');
|
||||
$ende = $this->input->post('bis');
|
||||
|
||||
@@ -247,34 +251,90 @@ class Notiz extends FHC_Controller
|
||||
return $this->outputJson(getError($result));
|
||||
}
|
||||
|
||||
//Todo(manu) update von Notizzuordnung?? typeId?
|
||||
//update(1) laden aller bereits mit dieser notiz_id verknüpften DMS-Einträge
|
||||
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
|
||||
$this->NotizdokumentModel->addJoin('campus.tbl_dms_version', 'dms_id');
|
||||
|
||||
$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));
|
||||
}
|
||||
elseif (!hasData($result))
|
||||
{
|
||||
$dms_id_arr = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = getData($result);
|
||||
foreach($result as $doc) {
|
||||
$dms_id_arr[] = array(
|
||||
'name' => $doc->name,
|
||||
'dms_id' => $doc->dms_id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//neue Files speichern
|
||||
//Todo(manu) update files
|
||||
foreach ($_FILES as $k => $file)
|
||||
{
|
||||
$dms = array(
|
||||
'kategorie_kurzbz' => 'notiz',
|
||||
'version' => 0,
|
||||
'name' => $file["name"],
|
||||
'mimetype' => $file["type"],
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => $uid
|
||||
);
|
||||
|
||||
$result = $this->dmslib->upload($dms, $k, array('pdf'));
|
||||
if (isError($result))
|
||||
//update(2) alle neuen files (alle außer type application/x.fhc-dms+json) anhängen
|
||||
if($file["type"] == 'application/x.fhc-dms+json')
|
||||
{
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
return $this->outputJson(getError($result));
|
||||
$dms_uploaded[] = array(
|
||||
'name' => $file["name"]
|
||||
);
|
||||
}
|
||||
$dms_id = $result->retval['dms_id'];
|
||||
|
||||
$result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id));
|
||||
if (isError($result))
|
||||
else
|
||||
{
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
return $this->outputJson(getError($result));
|
||||
$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
|
||||
$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));
|
||||
}
|
||||
$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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//update(3) check if Dateien gelöscht wurden
|
||||
if(count($dms_uploaded) != count($dms_id_arr))
|
||||
{
|
||||
$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);
|
||||
});
|
||||
|
||||
foreach ($filesDeleted as $file)
|
||||
{
|
||||
$result = $this->dmslib->removeAll($file['dms_id']);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
return $this->outputJson(getError($result));
|
||||
}
|
||||
else
|
||||
$this->outputJson($result);
|
||||
}
|
||||
}
|
||||
return $this->outputJsonSuccess(true);
|
||||
|
||||
@@ -32,7 +32,6 @@ export default {
|
||||
multiupload: true,
|
||||
mitarbeiter: [],
|
||||
filteredMitarbeiter: [],
|
||||
zwischenvar: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -52,14 +51,6 @@ export default {
|
||||
this.$emit('update:text', value);
|
||||
}
|
||||
},
|
||||
/* intPropText: {
|
||||
get() {
|
||||
return this.propText;
|
||||
},
|
||||
set(value) {
|
||||
this.$emit('update:propText', value);
|
||||
}
|
||||
},*/
|
||||
intVon: {
|
||||
get() {
|
||||
return this.von;
|
||||
@@ -179,8 +170,8 @@ export default {
|
||||
},
|
||||
template: `
|
||||
<div class="notiz-notiz">
|
||||
<!-- <p>testausgaben child</p>
|
||||
<span v-for="(anhang,index) in intAnhang"> {{anhang.name}} {{index}}<br></span>-->
|
||||
|
||||
<!-- <span v-for="(anhang,index) in intAnhang"> {{anhang.name}} | {{anhang.type}} | {{anhang.size}} {{index}}<br></span>-->
|
||||
<form ref="form" @submit.prevent class="row">
|
||||
<div>
|
||||
<div class="row mb-3">
|
||||
@@ -225,7 +216,7 @@ export default {
|
||||
<label for="text" class="form-label col-sm-2">Dokument</label>
|
||||
<div class="col-sm-7 py-3">
|
||||
<!--Upload Component-->
|
||||
<FormUploadDms ref="upload" id="file" multiple v-model="intAnhang" ></FormUploadDms>
|
||||
<FormUploadDms ref="upload" id="file" multiple v-model="intAnhang"></FormUploadDms>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -289,8 +280,10 @@ export default {
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<!-- files: {{files}} <hr>
|
||||
intText: {{intText}} |<br>propText: {{propText}} |<br> text: {{text}} <br> {{intPropText}}-->
|
||||
|
||||
intText: {{intText}} |<br>propText: {{propText}} |<br> text: {{text}} <br> {{intPropText}}
|
||||
<!-- {{intAnhang}}-->
|
||||
|
||||
|
||||
</div>`
|
||||
|
||||
Reference in New Issue
Block a user