111 lines
5.5 KiB
PHP
111 lines
5.5 KiB
PHP
<?php
|
|
include('../../koneksi.php');
|
|
$jenis=$_POST['jenis'];
|
|
$satker_id=$_POST['satker_id'];
|
|
?>
|
|
|
|
<script type="text/javascript">
|
|
$('button[name="edit_user"]').popover();
|
|
$('button[name="delete_user"]').popover();
|
|
$("#tabel_data_user").DataTable({"stateSave": true,"paging": true,"lengthChange": true,"searching": true,"ordering": false,"info": true,"autoWidth": false});
|
|
</script>
|
|
|
|
<table id="tabel_data_user" class="table table-striped table-condensed table-bordered" cellpadding="1" style="font-family:Arial;font-size:13px">
|
|
<thead>
|
|
<tr style="text-align:center;color:black;font-weight:bold">
|
|
<td>No</td>
|
|
<td width="400">Nama</td>
|
|
<td width="200">Satker</td>
|
|
<td>Username</td>
|
|
<td>Password</td>
|
|
<td width="60">Jenis</td>
|
|
<td width="50">Aktif</td>
|
|
<td align="center" width="60px;">Tools</td>
|
|
</tr>
|
|
</thead>
|
|
<tbody style="color:black">
|
|
<?php
|
|
$no=1;
|
|
$data = pg_query("SELECT u.id,s.nama,u.nama,u.password,j.jenis,u.aktif,p.nama,COALESCE(s2.nama,s.nama)
|
|
FROM data_user u
|
|
LEFT OUTER JOIN satuan_kerja s ON (u.satuan_kerja_id=s.id)
|
|
INNER JOIN jenis_user j ON (j.id=u.jenis_user)
|
|
LEFT OUTER JOIN data_pegawai p ON (p.id=u.data_pegawai_id)
|
|
LEFT OUTER JOIN satuan_kerja s2 ON (s2.id=p.satuan_kerja)
|
|
".($jenis== 'Kordik' ? "WHERE s2.id=$satker_id" : "")."
|
|
ORDER BY u.id DESC");
|
|
while($row=pg_fetch_array($data)) {
|
|
$jns=$row[4];
|
|
if (($jns=='Staf') || ($jns=='Kordik')) {$nama=$row[6];} else {$nama=$row[1];}
|
|
?>
|
|
<tr>
|
|
<td class="kiri" align="center"><?php echo $no; ?></td>
|
|
<td><?php echo $nama; ?></td>
|
|
<td><?php echo $row[7]; ?></td>
|
|
<td><?php echo $row[2]; ?></td>
|
|
<td><?php echo $row[3]; ?></td>
|
|
<td><?php echo $row[4]; ?></td>
|
|
<td align="center"><?php if ($row[5]=='t') {echo 'ON';} else {echo 'OFF';} ?></td>
|
|
<td class="kanan" align="center">
|
|
<button type="button" name="edit_user" style="height:22px;" class="btn btn-teal btn-xs edit_user" id="<?php echo $row['id'];?>" data-content="Edit Data" rel="popover" data-placement="top" data-trigger="hover">
|
|
<i class="fa fa fa-pencil"></i>
|
|
</button>
|
|
<?php if ($row[4]=='Bidang') { ?>
|
|
<button type="button" name="delete_user" style="height:22px;"class="btn btn-danger btn-xs delete_user" id="<?php echo $row['id'];?>" data-content="Hapus" rel="popover" data-placement="top" data-trigger="hover">
|
|
<i class="fa fa-remove"></i>
|
|
</button>
|
|
<?php } else {} ?>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
$no++;
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
$("#tabel_data_user").on('click','.edit_user',function(){
|
|
var id = $(this).attr('id');
|
|
var sess_jenis = $('#cek_jenis').val();
|
|
var sess_satker = $('#cek_satker').val();
|
|
$('#modal_user').modal('show');
|
|
$('#modal_body_user').html("");
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "app/master/user/modal.php",
|
|
data: 'id='+id
|
|
+'&jenis='+sess_jenis
|
|
+'&satker_id='+sess_satker,
|
|
success: function(data){
|
|
$('#modal_body_user').html(data);
|
|
$('#nama').first().focus().selected();
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
$("#tabel_data_user").on('click','.delete_user',function(){
|
|
var x = confirm("Anda yakin ingin menghapus ?");
|
|
if (x) {
|
|
var key = "delete_user";
|
|
var id = $(this).attr('id');
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "app/master/user/crud.php",
|
|
data: 'id='+id
|
|
+'&key='+key,
|
|
success: function(data){
|
|
var sess_jenis = $('#cek_jenis').val();
|
|
var sess_satker = $('#cek_satker').val();
|
|
$('#tabel_user').load("app/master/user/tabel.php",{jenis:sess_jenis,satker_id:sess_satker});
|
|
}
|
|
});
|
|
} else {}
|
|
});
|
|
|
|
</script>
|
|
|