Files
eletter/src/app/smasuk/pdf/tabel_upl_cv.php

82 lines
3.0 KiB
PHP

<?php
include('../../koneksi.php');
if ($_POST['surat_idzz']) {
$surat_id = $_POST['surat_idzz'];
} else {
$surat_id = '0';
}
// if ($_POST['gambar'] != 'img') {
$baseURL = '../../../public/doc/smasuk/dok/';
$data_pdf = pg_query($koneksi, "SELECT file,id FROM scan WHERE surat_id='$surat_id'
AND LOWER(file) NOT LIKE '%.jpg'
AND LOWER(file) NOT LIKE '%.JPG'
AND LOWER(file) NOT LIKE '%.png'
AND LOWER(file) NOT LIKE '%.PNG'
AND LOWER(file) NOT LIKE '%.jpeg'
AND LOWER(file) NOT LIKE '%.JPEG'
ORDER BY id DESC");
// } else {
// $baseURL = '../../../public/doc/smasuk/img/';
// $data_pdf = pg_query($koneksi, "SELECT file,id FROM scan WHERE surat_id='$surat_id'
// AND ( LOWER(file) LIKE '%.jpg'
// OR LOWER(file) LIKE '%.jpeg'
// OR LOWER(file) LIKE '%.png' )
// ORDER BY id DESC");
// }
?>
<input type="hidden" value="<?php echo $surat_id; ?>" id="surat_idxx">
<?php
while ($rdata_pdf = pg_fetch_assoc($data_pdf)) {
$pdf = $rdata_pdf['file'];
if (!empty($pdf)) {
?>
<div class="gal-detail thumb" style="height:345px;background-color:#ece9d8;">
<input type="hidden" id="id_file" value="<?=$rdata_pdf['id']?>">
<embed src="<?= htmlspecialchars($baseURL . $pdf); ?>#toolbar=0" width="100%" height="300"></embed>
<button type="button" name="cv_delete" style="height:22px;border-radius: 50%" class="btn btn-danger btn-xs pull-right" id="<?= htmlspecialchars($rdata_pdf['id']); ?>" data-content="Hapus" rel="popover" data-placement="bottom" data-trigger="hover">
<i class="fa fa-remove"></i>
</button>
</div>
<?php
}
}
?>
<script>
$('button[name="cv_delete"]').click(function() {
var x = confirm("Anda yakin ingin menghapus ?");
if (x) {
var key = "delete_cv";
var id = $(this).attr('id');
var rowElement = $(this).closest('.gal-detail');
$.ajax({
type: "POST",
url: "app/smasuk/pdf/crud.php",
data: { id: id, key: key },
success: function(response) {
var result = JSON.parse(response);
// if (result.icon === 'success') {
infoToast(result.icon, result.message);
$('#tabel_upl_cv').load("app/smasuk/pdf/tabel_upl_cv.php",
{ surat_idzz: result.surat_id });
// }
},
error: function(xhr) {
var result = JSON.parse(xhr.responseText);
infoToast(result.icon, result.message);
}
});
}
});
function infoToast(icone, infone) {
Swal.fire({
// position: posisine,
icon: icone,
title: infone,
showConfirmButton: false,
timer: 2500
});
}
</script>