update log barang teknisi

This commit is contained in:
2026-07-24 15:41:19 +07:00
parent f145b9e2ec
commit abbabf4af8
3 changed files with 152 additions and 1 deletions
+28
View File
@@ -80,6 +80,7 @@ class Teknisi extends CI_Controller {
'serial_number' => $item->serial_number,
'barcode_id' => $item->barcode_id,
'item_id' => $item->item_id,
'barcode_status' => $item->barcode_status,
'teknisi_id' => $teknisi ? $teknisi->user_id : null,
'teknisi_name' => $teknisi ? $teknisi->full_name : null,
'teknisi_code' => $teknisi ? $teknisi->employee_code : null
@@ -436,4 +437,31 @@ class Teknisi extends CI_Controller {
echo json_encode(['status' => true, 'message' => $msg, 'errors' => $errors]);
}
public function get_log_data()
{
$data = $this->ptm->get_log_barang();
$result = [];
$no = 1;
foreach ($data as $row) {
$status_badge = $row->status === 'active'
? '<span class="badge bg-success">ACTIVE</span>'
: '<span class="badge bg-secondary">INACTIVE</span>';
$result[] = [
$no++,
htmlspecialchars($row->teknisi_name ?? '-', ENT_QUOTES, 'UTF-8'),
htmlspecialchars($row->item_code ?? '-', ENT_QUOTES, 'UTF-8'),
htmlspecialchars($row->barcode, ENT_QUOTES, 'UTF-8'),
htmlspecialchars($row->nama_barang ?? '-', ENT_QUOTES, 'UTF-8'),
$row->created_at ? date('d/m/Y H:i', strtotime($row->created_at)) : '-',
$row->status === 'inactive' && $row->deleted_at ? date('d/m/Y H:i', strtotime($row->deleted_at)) : '-',
$status_badge,
];
}
echo json_encode(['data' => $result]);
}
}
@@ -508,4 +508,26 @@ class PeralatanTeknisi_model extends CI_Model {
{
return 'GRJN/K/' . date('d/m/Y');
}
public function get_log_barang()
{
return $this->db
->select("
it.barcode,
it.item_id,
it.user_id,
it.status,
it.created_at,
it.deleted_at,
ke.full_name as teknisi_name,
i.kode_detail as item_code,
i.nama_barang
")
->from('item_technician it')
->join('k_employees ke', 'ke.id = it.user_id', 'left')
->join('items i', 'i.id = it.item_id', 'left')
->order_by('it.created_at', 'DESC')
->get()
->result();
}
}
+102 -1
View File
@@ -198,10 +198,15 @@ body {
<div class="bg-warning text-white p-2 rounded-3 d-flex align-items-center justify-content-center" style="width:38px;height:38px;">
<i class="bi bi-tools fs-5"></i>
</div>
<div>
<div class="flex-grow-1">
<h5 class="mb-0 fw-bold" style="color:#1a1a2e;">Peralatan Teknisi</h5>
<small class="text-muted">Kelola barang bawaan, pengembalian, dan transfer antar teknisi</small>
</div>
<div>
<button type="button" class="btn btn-warning" id="btnLogBarang">
<i class="bi bi-journal-text me-1"></i> Log Barang Teknisi
</button>
</div>
</div>
<div class="row g-3">
@@ -565,6 +570,40 @@ body {
</div>
</div>
<!-- Modal Log Barang Teknisi -->
<div class="modal fade tech-modal" id="modalLogBarang" tabindex="-1" data-bs-backdrop="static">
<div class="modal-dialog modal-xl modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><i class="bi bi-journal-text me-2"></i> Log Barang Teknisi</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div class="table-responsive">
<table class="table table-tech table-striped w-100" id="tblLogBarang">
<thead>
<tr>
<th>No</th>
<th>Nama Teknisi</th>
<th>Kode Barang</th>
<th>Barcode</th>
<th>Nama Barang</th>
<th>Tanggal Dibawa</th>
<th>Tanggal Kembali</th>
<th>Status</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tutup</button>
</div>
</div>
</div>
</div>
<script>
let kembalikanData = [];
let dibawaData = [];
@@ -970,6 +1009,16 @@ $(function(){
return;
}
if (r.data.barcode_status === 'sold_out') {
Swal.fire({
icon: 'warning',
title: 'Barang Tidak Dapat Dibawa',
text: 'Barcode ' + r.data.barcode + ' sudah berstatus SOLD OUT sehingga tidak dapat diproses.'
});
$('#scanDibawa').val('').focus();
return;
}
let data = r.data;
let no = dibawaData.length + 1;
@@ -1267,5 +1316,57 @@ $(function(){
$(this).data('original-text', $(this).html());
});
// =============================================================
// LOG BARANG TEKNISI
// =============================================================
let tblLogBarang;
$('#btnLogBarang').click(function(){
$('#modalLogBarang').modal('show');
});
$('#modalLogBarang').on('shown.bs.modal', function(){
if (tblLogBarang) {
tblLogBarang.ajax.reload();
return;
}
tblLogBarang = $('#tblLogBarang').DataTable({
processing: true,
serverSide: false,
ajax: {
url: "<?= base_url('teknisi/get_log_data'); ?>",
dataSrc: 'data'
},
columns: [
{ data: 0 },
{ data: 1 },
{ data: 2 },
{ data: 3 },
{ data: 4 },
{ data: 5 },
{ data: 6 },
{ data: 7 }
],
responsive: true,
searching: true,
paging: true,
ordering: true,
info: true,
language: {
search: "Cari:",
lengthMenu: "Tampilkan _MENU_ data",
info: "Menampilkan _START_ - _END_ dari _TOTAL_ data",
zeroRecords: "Tidak ada data",
paginate: {
first: "Awal",
last: "Akhir",
next: "&raquo;",
previous: "&laquo;"
}
}
});
});
});
</script>