Files
eletter-backup/app/kirim/tabel2.php
2024-05-31 14:18:00 +07:00

164 lines
8.8 KiB
PHP

<?php
include("../koneksi.php");
$satuan_kerja_id=$_POST['satker'];
$jenis_user=$_POST['jenis'];
$sess_nama=$_POST['sess_nama'];
?>
<script type="text/javascript">$("#tabel_data_kirim").DataTable({"paging": true,"lengthChange": true,"searching": true,"ordering": false,"info": true,"autoWidth": false});</script>
<input type="hidden" id="jenis" value="<?php echo $jenis_user; ?>">
<input type="hidden" id="sess_nama" value="<?php echo $sess_nama; ?>">
<input type="hidden" id="satuan_kerja_id" value="<?php echo $satuan_kerja_id; ?>">
<table id="tabel_data_kirim" class="table table-striped table-condensed" cellpadding="1">
<thead>
<tr>
<td width="120px;"><b>Tanggal</b></td>
<td><b>Perihal</b></td>
<td width="380px;"><b>Tools</b></td>
</tr>
</thead>
<tbody style="color:black">
<?php
$data=pg_query("SELECT tgl_surat_keluar,perihal,satuan_kerja_id,id FROM surat WHERE satuan_kerja_id='$satuan_kerja_id'
AND jenis_surat_id='3' AND jenis_disposisi_id='3'
ORDER BY tgl_surat_keluar DESC
");
while($r=pg_fetch_array($data)) {
$surat_id=$r[3];
$k=pg_query("SELECT COUNT(*)
FROM kirim k INNER JOIN surat s ON (k.surat_id=s.id)
WHERE k.kepada IS NOT NULL AND k.surat_id='$surat_id'");
while($rk=pg_fetch_array($k)) {$kpd=$rk[0];}
$l=pg_query("SELECT COUNT(*)
FROM scan k INNER JOIN surat s ON (k.surat_id=s.id)
WHERE k.surat_id='$surat_id' AND LOWER(k.file) LIKE '%jpg'");
while($rl=pg_fetch_array($l)) {$tj=$rl[0];}
$m=pg_query("SELECT COUNT(*)
FROM scan k INNER JOIN surat s ON (k.surat_id=s.id)
WHERE k.surat_id='$surat_id' AND LOWER(k.file) NOT LIKE '%jpg'");
while($rm=pg_fetch_array($m)) {$tm=$rm[0];}
?>
<tr>
<td class="kiri"><b><?php echo date('d-m-Y H:i',strtotime($r['tgl_surat_keluar'])); ?></b></td>
<td><b><?php echo $r['perihal']; ?></b></td>
<td class="kanan">
<button type="button" name="jpg_kirim" style="height:22px;"class="btn btn-default btn-xs jpg_kirim" id="<?php echo $r[3];?>" data-content="File" rel="popover" data-placement="top" data-trigger="hover"
>
<i class="fa fa-file-picture-o m-r-5"></i>Scan Surat<span class="sq<?php echo $r[3];?>" idne="jpg<?php echo $r[3];?>">&nbsp;<?php echo '('.$tj.')'?></span>
</button>
<button type="button" name="file_kirim" style="height:22px;"class="btn btn-default btn-xs file_kirim" id="<?php echo $r[3];?>" data-content="File" rel="popover" data-placement="top" data-trigger="hover"
>
<i class="fa fa-file m-r-5"></i>Lampiran<span class="sr<?php echo $r[3];?>" idne="pdf<?php echo $r[3];?>">&nbsp;<?php echo '('.$tm.')'?></span>
</button>
<button type="button" name="kepada_kirim" style="height:22px;"class="btn btn-default btn-xs kepada_kirim" id="<?php echo $r[3];?>" data-content="Kepada" rel="popover" data-placement="top" data-trigger="hover"
>
<i class="fa fa-user m-r-5"></i>Kepada<span class="sp<?php echo $r[3];?>" idne="kpd<?php echo $r[3];?>">&nbsp;<?php echo '('.$kpd.')'?></span>
</button>
<button type="button" name="edit_kirim" style="height:22px;"class="btn btn-primary btn-xs edit_kirim" id="<?php echo $r[3];?>" data-content="Edit" rel="popover" data-placement="top" data-trigger="hover"
>
<i class="fa fa-pencil"></i>
</button>
<button type="button" name="hapus_kirim" style="height:22px;"class="btn btn-danger btn-xs hapus_kirim" id="<?php echo $r[3];?>" data-content="Hapus" rel="popover" data-placement="top" data-trigger="hover"
>
<i class="fa fa-remove"></i>
</button>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<script type="text/javascript">
/*$('button[name="file_kirim"]').popover();
$('button[name="kepada_kirim"]').popover();*/
$('button[name="edit_kirim"]').popover();
$('button[name="hapus_kirim"]').popover();
$("#tabel_data_kirim").on('click','.edit_kirim',function(){
var id = $(this).attr('id');
$('#modal_kirim').modal('show');
$('#modal_body_kirim').html("");
$.ajax({
type: "POST",
url: "app/kirim/modal.php",
data: 'id='+id,
success: function(data){
$('#modal_body_kirim').html(data);
$('#perihal').first().focus().selected();
}
});
});
$("#tabel_data_kirim").on('click','.kepada_kirim',function(){
var id = $(this).attr('id');
$('#modal_kepada').modal('show');
$('#modal_body_kepada').html("");
$.ajax({
type: "POST",
url: "app/kirim/modal_kepada.php",
data: 'id='+id,
success: function(data){
$('#modal_body_kepada').html(data);
$('#kepada_k').first().focus().selected();
}
});
});
$("#tabel_data_kirim").on('click','.jpg_kirim',function(){
var id = $(this).attr('id');
$('#modal_pic').modal('show');
$('#modal_body_pic').html("");
$.ajax({
type: "POST",
url: "app/kirim/modal_dok.php",
data: 'id='+id,
success: function(data){
$('#modal_body_pic').html(data);
}
});
});
$("#tabel_data_kirim").on('click','.file_kirim',function(){
var id = $(this).attr('id');
$('#modal_file').modal('show');
$('#modal_body_file').html("");
$.ajax({
type: "POST",
url: "app/kirim/upd_file.php",
data: 'id='+id,
success: function(data){
$('#modal_body_file').html(data);
}
});
});
$("#tabel_data_kirim").on('click','.hapus_kirim',function(){
var x = confirm("Anda yakin ingin menghapus ?");
if (x) {
var key = "hapus_kirim";
var id = $(this).attr('id');
var rowElement = $(this).parent().parent();
$.ajax({
type: "POST",
url: "app/kirim/crud.php",
data: 'id='+id
+'&key='+key,
success: function(data){
rowElement.fadeOut(500).remove();
}
});
} else {}
});
</script>