<?php
$dir="output/reps/";
$files = glob("output/reps/*.pdf");
$fileNames=array('expenses'=>'/Expenses/','outstanding'=>'/Invoice Outstanding/','paid'=>'/Invoice Paid/','outgoings_cat'=>'/Outgoings by Category/','reciepts_cat'=>'/Receipts by Category/','reciepts'=>'/Receipts/i','vi'=>'/VAT In/','vo'=>'/VAT Out/');


foreach($fileNames as $k=>$v){
$$k = preg_grep($v, $files);
}
?>

<script src="packages/fileupload/sortable.min.js" type="text/javascript"></script>
<link href="packages/fileupload/fileinput.min.css" media="all" rel="stylesheet" type="text/css"/>
<script src="packages/fileupload/fileinput.min.js" type="text/javascript"></script>
<link href="packages/fileupload/theme.css" media="all" rel="stylesheet" type="text/css"/>
<script src="packages/fileupload/theme.js" type="text/javascript"></script>



<div class="form-group">
<h3>Expenses</h3>
<div class="file-loading">
<input id="file-1" class="file" type="file" name="images" data-preview-file-type="any" >
</div>
</div>
</form>	
<?php
$key=1;
$ipv="";
$ipvc="";
foreach($expenses as $v){
$ipv.="'".$v."',";
$ipvc.='{type: "pdf", size: '.filesize($v).', caption: "'.$v.'", url: "resources/delete_resource.php", key: '.$key++.',extra: {file: "'.$v.'"}},';
}
?>
<script>
$("#file-1").fileinput({
theme: 'fas',
showUpload: false,
showBrowse: false,
initialPreviewShowDelete: false,
showRemove: false,
uploadUrl: 'resources/save_resource.php',
//deleteUrl: 'resources/delete_resource.php',
allowedFileExtensions: ['jpg', 'png', 'gif','pdf','html','doc','xlsx'],
overwriteInitial: false,
hideThumbnailContent: true,
uploadAsync: false,
maxFileSize: 40000,
maxFilesNum: 0,
uploadExtraData: function() {
return {folder: '<?php echo $dir?>'};
},
slugCallback: function (filename) {return filename.replace('(', '_').replace(']', '_');},
initialPreviewAsData: true,
initialPreviewDownloadUrl: '{filename}',
initialPreview: [<?php echo $ipv?>],
initialPreviewConfig: [<?php echo $ipvc?>],
append: true
});
</script>

<div class="form-group">
<h3>Invoice Outstanding</h3>
<div class="file-loading">
<input id="file-2" class="file" type="file" name="images" data-preview-file-type="any" >
</div>
</div>
</form>	
<?php
$key=1;
$ipv="";
$ipvc="";
foreach($outstanding as $v){
$ipv.="'".$v."',";
$ipvc.='{type: "pdf", size: '.filesize($v).', caption: "'.$v.'", url: "resources/delete_resource.php", key: '.$key++.',extra: {file: "'.$v.'"}},';
}
?>
<script>
$("#file-2").fileinput({
theme: 'fas',
showUpload: false,
showBrowse: false,
initialPreviewShowDelete: false,
showRemove: false,
uploadUrl: 'resources/save_resource.php',
//deleteUrl: 'resources/delete_resource.php',
allowedFileExtensions: ['jpg', 'png', 'gif','pdf','html','doc','xlsx'],
overwriteInitial: false,
hideThumbnailContent: true,
uploadAsync: false,
maxFileSize: 40000,
maxFilesNum: 0,
uploadExtraData: function() {
return {folder: '<?php echo $dir?>'};
},
slugCallback: function (filename) {return filename.replace('(', '_').replace(']', '_');},
initialPreviewAsData: true,
initialPreviewDownloadUrl: '{filename}',
initialPreview: [<?php echo $ipv?>],
initialPreviewConfig: [<?php echo $ipvc?>],
append: true
});
</script>

<div class="form-group">
<h3>Invoice Paid</h3>
<div class="file-loading">
<input id="file-3" class="file" type="file" name="images" data-preview-file-type="any" >
</div>
</div>
</form>	
<?php
$key=1;
$ipv="";
$ipvc="";
foreach($paid as $v){
$ipv.="'".$v."',";
$ipvc.='{type: "pdf", size: '.filesize($v).', caption: "'.$v.'", url: "resources/delete_resource.php", key: '.$key++.',extra: {file: "'.$v.'"}},';
}
?>
<script>
$("#file-3").fileinput({
theme: 'fas',
showUpload: false,
showBrowse: false,
initialPreviewShowDelete: false,
showRemove: false,
uploadUrl: 'resources/save_resource.php',
//deleteUrl: 'resources/delete_resource.php',
allowedFileExtensions: ['jpg', 'png', 'gif','pdf','html','doc','xlsx'],
overwriteInitial: false,
hideThumbnailContent: true,
uploadAsync: false,
maxFileSize: 40000,
maxFilesNum: 0,
uploadExtraData: function() {
return {folder: '<?php echo $dir?>'};
},
slugCallback: function (filename) {return filename.replace('(', '_').replace(']', '_');},
initialPreviewAsData: true,
initialPreviewDownloadUrl: '{filename}',
initialPreview: [<?php echo $ipv?>],
initialPreviewConfig: [<?php echo $ipvc?>],
append: true
});
</script>

<div class="form-group">
<h3>Outgoings by Category</h3>
<div class="file-loading">
<input id="file-4" class="file" type="file" name="images" data-preview-file-type="any" >
</div>
</div>
</form>	
<?php
$key=1;
$ipv="";
$ipvc="";
foreach($outgoings_cat as $v){
$ipv.="'".$v."',";
$ipvc.='{type: "pdf", size: '.filesize($v).', caption: "'.$v.'", url: "resources/delete_resource.php", key: '.$key++.',extra: {file: "'.$v.'"}},';
}
?>
<script>
$("#file-4").fileinput({
theme: 'fas',
showUpload: false,
showBrowse: false,
initialPreviewShowDelete: false,
showRemove: false,
uploadUrl: 'resources/save_resource.php',
//deleteUrl: 'resources/delete_resource.php',
allowedFileExtensions: ['jpg', 'png', 'gif','pdf','html','doc','xlsx'],
overwriteInitial: false,
hideThumbnailContent: true,
uploadAsync: false,
maxFileSize: 40000,
maxFilesNum: 0,
uploadExtraData: function() {
return {folder: '<?php echo $dir?>'};
},
slugCallback: function (filename) {return filename.replace('(', '_').replace(']', '_');},
initialPreviewAsData: true,
initialPreviewDownloadUrl: '{filename}',
initialPreview: [<?php echo $ipv?>],
initialPreviewConfig: [<?php echo $ipvc?>],
append: true
});
</script>

<div class="form-group">
<h3>Receipts by Category</h3>
<div class="file-loading">
<input id="file-5" class="file" type="file" name="images" data-preview-file-type="any" >
</div>
</div>
</form>	
<?php
$key=1;
$ipv="";
$ipvc="";
foreach($reciepts_cat as $v){
$ipv.="'".$v."',";
$ipvc.='{type: "pdf", size: '.filesize($v).', caption: "'.$v.'", url: "resources/delete_resource.php", key: '.$key++.',extra: {file: "'.$v.'"}},';
}
?>
<script>
$("#file-5").fileinput({
theme: 'fas',
showUpload: false,
showBrowse: false,
initialPreviewShowDelete: false,
showRemove: false,
uploadUrl: 'resources/save_resource.php',
//deleteUrl: 'resources/delete_resource.php',
allowedFileExtensions: ['jpg', 'png', 'gif','pdf','html','doc','xlsx'],
overwriteInitial: false,
hideThumbnailContent: true,
uploadAsync: false,
maxFileSize: 40000,
maxFilesNum: 0,
uploadExtraData: function() {
return {folder: '<?php echo $dir?>'};
},
slugCallback: function (filename) {return filename.replace('(', '_').replace(']', '_');},
initialPreviewAsData: true,
initialPreviewDownloadUrl: '{filename}',
initialPreview: [<?php echo $ipv?>],
initialPreviewConfig: [<?php echo $ipvc?>],
append: true
});
</script>

<div class="form-group">
<h3>Reciepts</h3>
<div class="file-loading">
<input id="file-6" class="file" type="file" name="images" data-preview-file-type="any" >
</div>
</div>
</form>	
<?php
$key=1;
$ipv="";
$ipvc="";
foreach($reciepts as $v){
$ipv.="'".$v."',";
$ipvc.='{type: "pdf", size: '.filesize($v).', caption: "'.$v.'", url: "resources/delete_resource.php", key: '.$key++.',extra: {file: "'.$v.'"}},';
}
?>
<script>
$("#file-6").fileinput({
theme: 'fas',
showUpload: false,
showBrowse: false,
initialPreviewShowDelete: false,
showRemove: false,
uploadUrl: 'resources/save_resource.php',
//deleteUrl: 'resources/delete_resource.php',
allowedFileExtensions: ['jpg', 'png', 'gif','pdf','html','doc','xlsx'],
overwriteInitial: false,
hideThumbnailContent: true,
uploadAsync: false,
maxFileSize: 40000,
maxFilesNum: 0,
uploadExtraData: function() {
return {folder: '<?php echo $dir?>'};
},
slugCallback: function (filename) {return filename.replace('(', '_').replace(']', '_');},
initialPreviewAsData: true,
initialPreviewDownloadUrl: '{filename}',
initialPreview: [<?php echo $ipv?>],
initialPreviewConfig: [<?php echo $ipvc?>],
append: true
});
</script>

<div class="form-group">
<h3>VAT In</h3>
<div class="file-loading">
<input id="file-7" class="file" type="file" name="images" data-preview-file-type="any" >
</div>
</div>
</form>	
<?php
$key=1;
$ipv="";
$ipvc="";
foreach($vi as $v){
$ipv.="'".$v."',";
$ipvc.='{type: "pdf", size: '.filesize($v).', caption: "'.$v.'", url: "resources/delete_resource.php", key: '.$key++.',extra: {file: "'.$v.'"}},';
}
?>
<script>
$("#file-7").fileinput({
theme: 'fas',
showUpload: false,
showBrowse: false,
initialPreviewShowDelete: false,
showRemove: false,
uploadUrl: 'resources/save_resource.php',
//deleteUrl: 'resources/delete_resource.php',
allowedFileExtensions: ['jpg', 'png', 'gif','pdf','html','doc','xlsx'],
overwriteInitial: false,
hideThumbnailContent: true,
uploadAsync: false,
maxFileSize: 40000,
maxFilesNum: 0,
uploadExtraData: function() {
return {folder: '<?php echo $dir?>'};
},
slugCallback: function (filename) {return filename.replace('(', '_').replace(']', '_');},
initialPreviewAsData: true,
initialPreviewDownloadUrl: '{filename}',
initialPreview: [<?php echo $ipv?>],
initialPreviewConfig: [<?php echo $ipvc?>],
append: true
});
</script>

<div class="form-group">
<h3>VAT Out</h3>
<div class="file-loading">
<input id="file-8" class="file" type="file" name="images" data-preview-file-type="any" >
</div>
</div>
</form>	
<?php
$key=1;
$ipv="";
$ipvc="";
foreach($vi as $v){
$ipv.="'".$v."',";
$ipvc.='{type: "pdf", size: '.filesize($v).', caption: "'.$v.'", url: "resources/delete_resource.php", key: '.$key++.',extra: {file: "'.$v.'"}},';
}
?>
<script>
$("#file-8").fileinput({
theme: 'fas',
showUpload: false,
showBrowse: false,
initialPreviewShowDelete: false,
showRemove: false,
uploadUrl: 'resources/save_resource.php',
//deleteUrl: 'resources/delete_resource.php',
allowedFileExtensions: ['jpg', 'png', 'gif','pdf','html','doc','xlsx'],
overwriteInitial: false,
hideThumbnailContent: true,
uploadAsync: false,
maxFileSize: 40000,
maxFilesNum: 0,
uploadExtraData: function() {
return {folder: '<?php echo $dir?>'};
},
slugCallback: function (filename) {return filename.replace('(', '_').replace(']', '_');},
initialPreviewAsData: true,
initialPreviewDownloadUrl: '{filename}',
initialPreview: [<?php echo $ipv?>],
initialPreviewConfig: [<?php echo $ipvc?>],
append: true
});
</script>

<script>

$('.kv-file-remove').css('display','none');
$('.fileinput-remove').css('display','none');
$('.file-caption-main').css('display','none');
$('.file-drag-handle').css('display','none');
</script>