diff --git a/Layout/default/Filestore/Form.php b/Layout/default/Filestore/Form.php index 3293e4f32..cca8082c7 100644 --- a/Layout/default/Filestore/Form.php +++ b/Layout/default/Filestore/Form.php @@ -8,7 +8,7 @@ - +

Datei

@@ -16,6 +16,16 @@ +permissions->isAdmin) { + foreach ($networkaddresses as $networkaddress) { + if ($me->address->id == $networkaddress->address_id) { + $allowedNetworks[$networkaddress->network_id] = "ok"; + } + } +} + +?>
@@ -23,18 +33,50 @@

id) ? "Datei bearbeiten" : "Neue Datei" ?>

-
">
+
- + + + + name ?> + +
+
+
+ +
+ + + $network): + if (($file->network_id == $network->id)) : + $networkName = $network->name; + endif; + endforeach; + ?> + +
diff --git a/Layout/default/Filestore/Index.php b/Layout/default/Filestore/Index.php index 36395207d..b6afd6abf 100644 --- a/Layout/default/Filestore/Index.php +++ b/Layout/default/Filestore/Index.php @@ -1,5 +1,5 @@ - +
@@ -33,17 +33,25 @@
- - + + permissions->isAdmin) { + foreach ($networkaddresses as $networkaddress) { + if ($me->address->id == $networkaddress->address_id) { + $allowedNetworks[$networkaddress->network_id] = "ok"; + } + } + } + ?> - + - + @@ -54,16 +62,42 @@ - + permissions->isAdmin) { + if (!array_key_exists($file->networkid, $allowedNetworks)) { + continue; + } + } + ?> + - + + + creator->name + ?> + create) + ?> @@ -72,7 +106,6 @@
Name BeschreibungErstellerNetzgebiet Bearbeiter
name ?> description ?>creator->name ?> (create) ?>)network ?> editor->name ?> (edit) ?>) - $file->file_id, 's' => $pagination['start']])?>"> - $file->id, 's' => $pagination['start']])?>"> - $file->id, 's' => $pagination['start']])?>" onclick="if(!confirm('Person/Firma wirklich löschen?')) return false;" class="text-danger" title="Löschen"> + $file->file_id]) ?>"> + $file->id, "mode" => "add-version"]) ?>"> + + + $file->id]) ?>"> + + permissions->isAdmin || $me->id == $file->edit_by) : ?> + $file->id]) ?>" + onclick="if(!confirm('Datei wirklich löschen?')) return false;" + class="text-danger" title="Löschen"> +
-
@@ -81,13 +114,66 @@ - + diff --git a/application/Filestore/FilestoreController.php b/application/Filestore/FilestoreController.php index ba33a710f..9f0401545 100644 --- a/application/Filestore/FilestoreController.php +++ b/application/Filestore/FilestoreController.php @@ -19,26 +19,20 @@ class FilestoreController extends mfBaseController { $this->layout()->setTemplate("Filestore/Index"); $files = FilestoreModel::getAll(); + $networkaddress = NetworkAddressModel::getAll(); - - // pagination defaults - $pagination = []; - $pagination['start'] = 0; - $pagination['count'] = 25; - $pagination['maxItems'] = 0; - if(is_numeric($this->request->s)) { - $pagination['start'] = intval($this->request->s); - } - $pagination['maxItems'] = FilestoreModel::count(); $this->layout()->set("files", $files); - $this->layout()->set("pagination", $pagination); + $this->layout()->set("networkaddresses", $networkaddress); + } protected function addAction() { + $this->layout()->set("networks", NetworkModel::getAll()); + $this->layout()->set("networkaddresses", NetworkAddressModel::getAll()); $this->layout()->setTemplate("Filestore/Form"); } @@ -46,9 +40,12 @@ class FilestoreController extends mfBaseController { $r = $this->request; $id = $r->id; + $editmode=$r->mode; + //var_dump($r->get());exit; if (is_numeric($id) && $id > 0) { $mode = "edit"; + $filestore = new Filestore($id); if (!$filestore->id) { $this->layout()->setFlash("Datei nicht gefunden", "error"); @@ -59,17 +56,23 @@ class FilestoreController extends mfBaseController $dataHistory['name'] = $filestore->name; $dataHistory['description'] = $filestore->description; $dataHistory['file_id'] = $filestore->file_id; + $dataHistory['network_id'] = $filestore->network_id; $dataHistory['filestore_id'] = $filestore->id; $dataHistory['create'] = $filestore->create; $dataHistory['create_by'] = $filestore->create_by; - $dataHistory['edit'] = date("U"); + $dataHistory['edit_by'] = $filestore->edit_by; +// $dataHistory['edit'] = date("U"); + $dataHistory['edit'] = $filestore->edit; + } else { $mode = "add"; } $data = []; $data['name'] = trim($r->name); + $data['network_id'] = trim($r->network_id); $data['description'] = trim($r->description); + $data['edit_by'] = trim($this->me->id); if (!$data['name']) { $this->layout()->setFlash("Name darf nicht leer sein", "error"); @@ -114,7 +117,6 @@ class FilestoreController extends mfBaseController $data['file_id'] = $file_id; if ($mode == "edit") { - $fsh = FilestoreHistoryModel::create($dataHistory); } } else { @@ -141,7 +143,7 @@ class FilestoreController extends mfBaseController $id = $filestore->save(); if (!$id) { - $this->layout()->setFlash("Dateiupload fehlgeschlagen33", "error"); + $this->layout()->setFlash("Dateiupload fehlgeschlagen", "error"); $this->redirect("Filestore"); } if ($fsh) { @@ -155,19 +157,28 @@ class FilestoreController extends mfBaseController { $r = $this->request; $id = $r->id; - //var_dump($r->get());exit; + if ($r->mode) { + $mode = $r->mode; + } else { + $mode = ""; + } if (!is_numeric($id) && $id < 1) { $this->layout()->setFlash("Datei nicht gefunden", "error"); $this->redirect("Filestore"); } - $filestore = new Filestore($id); + $filestore = new Filestore($id); + $filestorehistory = new FilestoreHistory($id); if (!$filestore->id) { $this->layout()->setFlash("Datei nicht gefunden", "error"); $this->redirect("Filestore"); } + if ($mode) { + $this->layout()->set("mode", $mode); + } + $this->layout()->set("filestorehistory", $filestorehistory); $this->layout()->set("file", $filestore); return $this->addAction(); @@ -194,4 +205,35 @@ class FilestoreController extends mfBaseController $filstore->delete(); $this->redirect("Filestore"); } + + protected function apiAction() + { + if (!$this->me->is(["Admin", "netowner", "pipeplanner", "lineplanner", "pipeworker", "netoperator", "lineworker"])) { + $this->redirect("Dashboard"); + } + $id = $this->request->id; + + $filestorehistory = FilestoreHistoryModel::getAllhistory($id); + $counter = 0; + foreach ($filestorehistory as $history) { + $data[$counter]['id'] = $history->id; + $data[$counter]['file_id'] = $history->data->file_id; + $data[$counter]['name'] = $history->data->name; + $data[$counter]['description'] = $history->data->description; + $data[$counter]['workername'] = $history->data->workername; + $data[$counter]['workerid'] = $history->data->workerid; + $data[$counter]['edit'] = $history->edit; + if (trim($this->me->id) == $history->data->workerid) { + $data[$counter]['is_delete'] = 1; + } else { + $data[$counter]['is_delete'] = 0; + } + + + $counter++; + } + echo json_encode($data); + exit; + + } } \ No newline at end of file diff --git a/application/Filestore/FilestoreModel.php b/application/Filestore/FilestoreModel.php index f11111366..a9ad20eef 100644 --- a/application/Filestore/FilestoreModel.php +++ b/application/Filestore/FilestoreModel.php @@ -4,6 +4,7 @@ class FilestoreModel { public $order_id; public $file_id; + public $network_id; public $name; public $description; @@ -54,11 +55,13 @@ class FilestoreModel public static function getAll() { + $items = []; $db = FronkDB::singleton(); - $sql = "SELECT Filestore.* FROM Filestore + $sql = "SELECT Filestore.*,Network.name network,Network.id networkid FROM Filestore LEFT JOIN File ON (Filestore.file_id = File.id) + LEFT JOIN Network ON (Filestore.network_id = Network.id) ORDER BY name"; $res = $db->query($sql); if ($db->num_rows($res)) { diff --git a/application/FilestoreHistory/FilestoreHistoryModel.php b/application/FilestoreHistory/FilestoreHistoryModel.php index 3faae0e21..0800185c0 100644 --- a/application/FilestoreHistory/FilestoreHistoryModel.php +++ b/application/FilestoreHistory/FilestoreHistoryModel.php @@ -70,6 +70,26 @@ class FilestoreHistoryModel } + public static function getAllhistory($id) + { + $items = []; + + $db = FronkDB::singleton(); + $sql = "SELECT FilestoreHistory.*,Worker.name workername,Worker.id workerid FROM FilestoreHistory + LEFT JOIN File ON (FilestoreHistory.file_id = File.id) + INNER JOIN Worker ON (FilestoreHistory.edit_by=Worker.id) + WHERE `filestore_id` ='" . $id . "' + ORDER BY edit DESC"; + $res = $db->query($sql); + if ($db->num_rows($res)) { + while ($data = $db->fetch_object($res)) { + $items[] = new FilestoreHistory($data); + } + } + return $items; + + } + public static function getFirst() { $db = FronkDB::singleton();