Filestore Beta
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<li class="breadcrumb-item"><a href="<?= self::getUrl("Dashboard") ?>"><?= MFAPPNAME_SLUG ?></a>
|
||||
</li>
|
||||
<li class="breadcrumb-item"><a href="<?= self::getUrl("Filestore") ?>">Dateiablage</a></li>
|
||||
<li class="breadcrumb-item active"><?= ($building->id) ? "bearbeiten" : "Neu" ?></li>
|
||||
<li class="breadcrumb-item active"><?= ($file->id) ? "bearbeiten" : "Neu" ?></li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Datei</h4>
|
||||
@@ -16,6 +16,16 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
<?php
|
||||
if (!$me->permissions->isAdmin) {
|
||||
foreach ($networkaddresses as $networkaddress) {
|
||||
if ($me->address->id == $networkaddress->address_id) {
|
||||
$allowedNetworks[$networkaddress->network_id] = "ok";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
@@ -23,18 +33,50 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title mb-2"><?= ($file->id) ? "Datei bearbeiten" : "Neue Datei" ?></h4>
|
||||
|
||||
<form class="form-horizontal" method="post" enctype="multipart/form-data"
|
||||
action="<?= self::getUrl("Filestore", "save") ?>">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<input type="hidden" name="id" value="<?= $file->id ?>"/>
|
||||
<input type="hidden" name="mode" value="<?= $mode ?>"/>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="name">Name *</label>
|
||||
<div class="col-lg-10">
|
||||
<input value="<?= $file->name ?>" class="form-control" name="name" id="name">
|
||||
<?php if (empty($mode)) : ?>
|
||||
<input value="<?= $file->name ?>" class="form-control" name="name"
|
||||
id="name">
|
||||
<?php elseif ($mode == "add-version") : ?>
|
||||
<span><?= $file->name ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="network_id">Netzgebiet *</label>
|
||||
<div class="col-lg-10">
|
||||
<?php if (empty($mode)) : ?>
|
||||
<select class="select2 form-control " name="network_id" id="network_id">
|
||||
<option> </option>
|
||||
<?php foreach ($networks as $key => $network):
|
||||
if (!$me->permissions->isAdmin) {
|
||||
if (!array_key_exists($network->id, $allowedNetworks)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<option value="<?= $network->id ?>" <?= ($file->network_id == $network->id) ? "selected='selected'" : "" ?>><?= ($network->name) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php elseif ($mode == "add-version") :
|
||||
foreach ($networks as $key => $network):
|
||||
if (($file->network_id == $network->id)) :
|
||||
$networkName = $network->name;
|
||||
endif;
|
||||
endforeach;
|
||||
?>
|
||||
<span class="col-form-label"><?= $networkName ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
||||
<link href="<?=self::getResourcePath()?>assets/css/datatables-std.css" rel="stylesheet" type="text/css" />
|
||||
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css" rel="stylesheet" type="text/css"/>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
@@ -33,17 +33,25 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination-summary.php"); ?>
|
||||
|
||||
<?php
|
||||
if (!$me->permissions->isAdmin) {
|
||||
foreach ($networkaddresses as $networkaddress) {
|
||||
if ($me->address->id == $networkaddress->address_id) {
|
||||
$allowedNetworks[$networkaddress->network_id] = "ok";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<table id="datatable" class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Beschreibung</th>
|
||||
<th>Ersteller</th>
|
||||
<th>Netzgebiet</th>
|
||||
<th>Bearbeiter</th>
|
||||
<th ></th>
|
||||
<th class="edit-width-large"></th>
|
||||
</tr>
|
||||
<tr id="filterrow">
|
||||
<th></th>
|
||||
@@ -54,16 +62,42 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($files as $file): ?>
|
||||
<?php foreach ($files as $file):
|
||||
|
||||
if (!$me->permissions->isAdmin) {
|
||||
if (!array_key_exists($file->networkid, $allowedNetworks)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><?= $file->name ?></td>
|
||||
<td><?= $file->description ?></td>
|
||||
<td><?= $file->creator->name ?> (<?= date("d.m.Y , H:i", $file->create) ?>)</td>
|
||||
<td><?= $file->network ?></td>
|
||||
|
||||
<!--<td>--><?php //= $file->creator->name
|
||||
?><!-- (-->
|
||||
<?php //= date("d.m.Y , H:i", $file->create)
|
||||
?><!--)</td>-->
|
||||
<td><?= $file->editor->name ?> (<?= date("d.m.Y , H:i", $file->edit) ?>)</td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<a href="<?=self::getUrl("File", "download", ["id" => $file->file_id, 's' => $pagination['start']])?>"><i class="far fa-download" title="Download"></i></a>
|
||||
<a href="<?=self::getUrl("Filestore", "edit", ["id" => $file->id, 's' => $pagination['start']])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Filestore", "delete", ["id" => $file->id, 's' => $pagination['start']])?>" onclick="if(!confirm('Person/Firma wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
|
||||
<a href="<?= self::getUrl("File", "download", ["id" => $file->file_id]) ?>"><i
|
||||
class="far fa-download" title="Download"></i></a>
|
||||
<a href="<?= self::getUrl("Filestore", "edit", ["id" => $file->id, "mode" => "add-version"]) ?>"><i
|
||||
class="far fa-file-circle-plus" title="Dateiversion hinzufügen"></i></a>
|
||||
|
||||
<i data-id="<?= $file->id ?>" title="Versionsverlauf"
|
||||
class="fa-solid fa-clock-rotate-left history-ico check-history"></i>
|
||||
<a href="<?= self::getUrl("Filestore", "edit", ["id" => $file->id]) ?>"><i
|
||||
class="far fa-edit" title="Bearbeiten"></i></a>
|
||||
|
||||
<?php if ($me->permissions->isAdmin || $me->id == $file->edit_by) : ?>
|
||||
<a style="float: right"
|
||||
href="<?= self::getUrl("Filestore", "delete", ["id" => $file->id]) ?>"
|
||||
onclick="if(!confirm('Datei wirklich löschen?')) return false;"
|
||||
class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -72,7 +106,6 @@
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -81,13 +114,66 @@
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var hidesearch=[2,3,4];
|
||||
var hidesearch = [3, 4];
|
||||
var cstmdom = "flrtip";
|
||||
$(document).ready(function () {
|
||||
$(".check-history").click(function () {
|
||||
let dataobject = $(this);
|
||||
let fsiid = $(this).data('id');
|
||||
if ($('.filestore-history-' + fsiid).length) {
|
||||
$('.filestore-history-' + fsiid).remove();
|
||||
} else {
|
||||
$.getJSON("/Filestore/api",
|
||||
{id: $(this).data('id')},
|
||||
|
||||
function (data) {
|
||||
let expandtr;
|
||||
|
||||
expandtr = `<tr class="filestore-history-tr filestore-history-` + fsiid + `">
|
||||
<td colspan="5" class="filestore-history-td" >
|
||||
<table class="float-right table table-bordered table-condensed" style="width: auto;">
|
||||
<thead>
|
||||
<tr style="background-color: #fff">
|
||||
<th>Beschreibung</th>
|
||||
<th>Bearbeiter</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
`;
|
||||
$.each(data, function (i, item) {
|
||||
let isdelete = '';
|
||||
console.log(item.edit);
|
||||
var date = new Date(item.edit * 1000);
|
||||
var day = "0" + date.getDay();
|
||||
var month = "0" + date.getMonth();
|
||||
var year = date.getFullYear();
|
||||
var hours = date.getHours();
|
||||
var minutes = "0" + date.getMinutes();
|
||||
var formattedTime = day + '.' + month + '.' + year + ', ' + hours + ':' + minutes.substr(-2);
|
||||
if (item.is_delete == "1") {
|
||||
isdelete = `<a style="float: right" href="/Filestore/delete/?id=` + item.file_id + `&s=0" onclick="if(!confirm('Datei wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>`;
|
||||
}
|
||||
|
||||
expandtr = expandtr + `<tr class="filestore-history">
|
||||
|
||||
<td>` + item.description + `</td>
|
||||
|
||||
<td>` + item.workername + ` (` + formattedTime + `)</td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;width: 140px;">
|
||||
<a href="/File/download/?id=` + item.file_id + `&s=0"><i class="far fa-download" title="Download"></i></a>
|
||||
` + isdelete + `
|
||||
</td>
|
||||
</tr>`;
|
||||
|
||||
});
|
||||
expandtr = expandtr + `</table></td></tr>`;
|
||||
dataobject.closest('tr').after(expandtr);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/datatables-std.js"></script>
|
||||
<script type="text/javascript" src="<?= self::getResourcePath() ?>assets/js/datatables-std.js"></script>
|
||||
<script>
|
||||
|
||||
</script>
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user