pivi_vault_system/uploads.php

215 lines
7.6 KiB
PHP
Raw Normal View History

2024-02-28 15:55:13 +08:00
<!DOCTYPE html>
<html>
<head>
<?php
include 'header.php';
include 'config.php';
$user_id = $_GET['user_id'];
$name = $_GET['name'];
$company = $_GET['company'];
$role = $_GET['role'];
$visible = false;
if ($role === $urole || $role === $arole || $role === $rrole || $role === $arole2 || $role === $arole3 || $role === $arole4 ) {
$visible = true;
}
?>
<script type="text/javascript" language="javascript" class="init">
var editor; // use a global for the submit and return data rendering in the examples
$(document).ready(function () {
editor = new $.fn.dataTable.Editor({
ajax: {
url:"upload.php",
type: "POST",
data: function (d) {
// You can dynamically provide the data here
d.id = <?php echo $user_id ?>;
d.user = '<?php echo $name ?>';
d.company = '<?php echo $company ?>';
// Make sure to return the updated data object
return d;
}},
table: "#example",
fields: [{
label: "Type:",
name: "documents.type",
type: "select",
placeholder: "Select document type"
}, {
label: "Description:",
name: "documents.description",
type: "textarea"
}, {
label: "Company:",
name: "documents.company",
type: "select",
placeholder: "Select company"
}, {
label: "Department:",
name: "documents.department",
type: "select",
placeholder: "Select department"
}, {
label: "Region:",
name: "documents.region",
type: "select"
}, {
label: "Province:",
name: "documents.province",
type: "select"
}, {
label: "City/Municipality:",
name: "documents.city",
type: "select"
}, {
label: "TCT Number:",
name: "documents.number"
}, {
label: "Total Area:",
name: "documents.area"
}, {
label: "Unit of Measure:",
name: "documents.unit",
type: "select",
placeholder: "Select unit of measure"
}, {
label: "File:",
name: "documents.file",
visible: <?php echo $visible ? 'true' : 'false'; ?>,
type: "upload",
display: function ( file_id ) {
return '<img src="'+editor.file( 'files', file_id ).web_path+'"/>';
},
clearText: "Clear",
noImageText: 'No image',
// ajax: {
// data: function (d) {
// // Customize and return the data object for the AJAX request
// return d;
// }
// }
}, {
label: "Vault Number:",
name: "documents.vault",
visible: <?php echo $visible ? 'true' : 'false'; ?>
}, {
label: "Folder Number:",
name: "documents.folder",
visible: <?php echo $visible ? 'true' : 'false'; ?>
}
]
});
editor.dependent( 'documents.region', '/api/province/index.php' );
editor.dependent( 'documents.province', '/api/city/index.php' );
$('#example').DataTable({
dom: "Bfrtip",
ajax: {
url:"upload.php",
type: "POST",
data: function (d) {
// You can dynamically provide the data here
d.id = <?php echo $user_id ?>;
d.user = '<?php echo $name ?>';
d.company = '<?php echo $company ?>';
// Make sure to return the updated data object
return d;
}},
columns: [
{ data: "documents.id" },
{ data: "documents.date" },
{ data: "type.name" },
{ data: "documents.description" },
{ data: "company.name" },
{ data: "department.name" },
{ data: "city.name" },
{ data: "province.name" },
{ data: "region.name" },
{ data: "documents.number" },
{ data: "documents.area" },
{ data: "unit.name" },
{ data: "documents.file" ,
render: function (file_id) {
return file_id
? `<img src="${editor.file('files', file_id).web_path}"/>`
: null;
},
defaultContent: 'No image',
title: 'Image'
},
{ data: "documents.vault" },
{ data: "documents.folder" }
],
select: true,
buttons: [{
extend: "create",
editor: editor
},
{
extend: "edit",
editor: editor
},
{
extend: "remove",
editor: editor
}
]
});
});
</script>
</head>
<body class="dt-example dt-example-bootstrap" style="background-color: rgba(0, 0, 0, 0);">
<div class="demo-html">
<table id="example" class="display responsive nowrap" style="width:100%">
<!-- <table id="example" class="table table-striped table-bordered responsive" style="width:100%"> -->
<thead>
<tr>
<th>ID</th>
<th>Date</th>
<th>Type</th>
<th>Description</th>
<th>Company</th>
<th>Department</th>
<th>City/Municipality</th>
<th>Province</th>
<th>Region</th>
<th>TCT Number</th>
<th>Total Area</th>
<th>Unit of Measure</th>
<th>File</th>
<th>Vault Number</th>
<th>Folder Number</th>
</tr>
</thead>
<tfoot>
<tr>
<th>ID</th>
<th>Date</th>
<th>Type</th>
<th>Description</th>
<th>Company</th>
<th>Department</th>
<th>City/Municipality</th>
<th>Province</th>
<th>Region</th>
<th>TCT Number</th>
<th>Total Area</th>
<th>Unit of Measure</th>
<th>File</th>
<th>Vault Number</th>
<th>Folder Number</th>
</tr>
</tfoot>
</table>
</div>
</body>
</html>