Filestore Beta

This commit is contained in:
Spitzer_Daniel
2023-04-06 17:55:33 +02:00
parent d6e46e7644
commit 98196e32a3
5 changed files with 226 additions and 33 deletions
+45 -3
View File
@@ -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>&nbsp;</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">
+99 -13
View File
@@ -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 + `&amp;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 + `&amp;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>