diff --git a/.gitignore b/.gitignore index 0cc1c95..247a8ba 100644 --- a/.gitignore +++ b/.gitignore @@ -37,5 +37,6 @@ user_guide_src/cilexer/pycilexer.egg-info/* /tests/results/ /dev-docs/ /ai-rules/ +*.omo/ diff --git a/.omo/run-continuation/ses_068c091cfffeSZ25RoesHkRZHA.json b/.omo/run-continuation/ses_068c091cfffeSZ25RoesHkRZHA.json new file mode 100644 index 0000000..0a17f80 --- /dev/null +++ b/.omo/run-continuation/ses_068c091cfffeSZ25RoesHkRZHA.json @@ -0,0 +1,10 @@ +{ + "sessionID": "ses_068c091cfffeSZ25RoesHkRZHA", + "updatedAt": "2026-07-25T03:09:04.625Z", + "sources": { + "background-task": { + "state": "idle", + "updatedAt": "2026-07-25T03:09:04.625Z" + } + } +} \ No newline at end of file diff --git a/.omo/run-continuation/ses_0690d5681fferVVn0tDzMM9Ow7.json b/.omo/run-continuation/ses_0690d5681fferVVn0tDzMM9Ow7.json new file mode 100644 index 0000000..ac6c241 --- /dev/null +++ b/.omo/run-continuation/ses_0690d5681fferVVn0tDzMM9Ow7.json @@ -0,0 +1,10 @@ +{ + "sessionID": "ses_0690d5681fferVVn0tDzMM9Ow7", + "updatedAt": "2026-07-25T08:09:46.929Z", + "sources": { + "background-task": { + "state": "idle", + "updatedAt": "2026-07-25T08:09:46.929Z" + } + } +} \ No newline at end of file diff --git a/application/controllers/Items.php b/application/controllers/Items.php index a8bd40f..b576320 100644 --- a/application/controllers/Items.php +++ b/application/controllers/Items.php @@ -1087,6 +1087,7 @@ class Items extends CI_Controller { ib.id as barcode_id, ib.item_id, ib.qty_sisa, + ib.barcode, ib.warehouse_id, ib.status as barcode_status, i.nama_barang, @@ -1182,6 +1183,9 @@ class Items extends CI_Controller { 'qty_sisa' => $new_qty_sisa, 'status' => $new_qty_sisa <= 0 ? 'installed' : $barcode->barcode_status ]); + + $this->db->where('barcode', $barcode->barcode)->where('status', 'active')->update('item_technician', ['status' => 'inactive', 'deleted_at' => date('Y-m-d H:i:s')]); + // END - Item Movement & item barcodes update status $this->db->trans_complete(); diff --git a/application/controllers/Teknisi.php b/application/controllers/Teknisi.php index 53c17d2..a948aa5 100644 --- a/application/controllers/Teknisi.php +++ b/application/controllers/Teknisi.php @@ -88,6 +88,18 @@ class Teknisi extends CI_Controller { ]); } + function get_date_by_employee_id() + { + $user_id = (int)$this->input->get('user_id'); + if (!$user_id) { + echo json_encode(['status' => false, 'message' => 'ID teknisi tidak valid']); + return; + } + + $dates = $this->ptm->get_dates_by_employee_id($user_id); + echo json_encode(['status' => true, 'data' => $dates]); + } + public function batch_kembalikan() { $barcodes = $this->input->post('barcodes'); @@ -209,6 +221,7 @@ class Teknisi extends CI_Controller { $result[] = [ $no++, + $row->tanggal ?? date('d/m/Y'), htmlspecialchars($row->barcode, ENT_QUOTES, 'UTF-8'), htmlspecialchars($row->nama_barang, ENT_QUOTES, 'UTF-8'), htmlspecialchars($row->serial_number, ENT_QUOTES, 'UTF-8') ?: '-', @@ -240,15 +253,32 @@ class Teknisi extends CI_Controller { return; } - $items = $this->ptm->get_teknisi_items_full($user_id); - $noFaktur = 'GRJN/K/' . date('d/m/Y'); - $tanggal = date('d F Y'); + $tanggal_param = $this->input->get('tanggal'); + $items = []; + if ($tanggal_param) { + $items = $this->ptm->get_teknisi_items_full($user_id, $tanggal_param); + } + + if ($tanggal_param) { + if ($tanggal_param === 'all') { + $noFaktur = 'GRJN/K/ALL' . date('/m/Y'); + $tanggal = date('d F Y'); + } else { + $ts = strtotime($tanggal_param); + $noFaktur = 'GRJN/K/' . date('d/m/Y', $ts); + $tanggal = date('d F Y', $ts); + } + } else { + $noFaktur = 'GRJN/K/' . date('d/m/Y'); + $tanggal = date('d F Y'); + } $itemsData = []; $no = 1; foreach ($items as $item) { $itemsData[] = [ 'no' => $no++, + 'tanggal' => $item->tanggal ?? date('d/m/Y'), 'barcode' => $item->barcode ?? '-', 'nama_barang' => $item->nama_barang ?? '-', 'serial_number' => $item->serial_number ?? '-', @@ -275,9 +305,6 @@ class Teknisi extends CI_Controller { public function generate_pdf_barang_bawaan($user_id = null) { - if ($this->session->userdata('role') != 'Admin') { - show_error('Akses ditolak', 403); - } $user_id = (int)$user_id; if (!$user_id) { @@ -293,9 +320,22 @@ class Teknisi extends CI_Controller { show_error('Teknisi tidak ditemukan', 404); } - $items = $this->ptm->get_teknisi_items_full($user_id); - $noFaktur = 'GRJN/K/' . date('d/m/Y'); - $tanggal = date('d F Y'); + $tanggal_param = $this->input->get('tanggal'); + + if ($tanggal_param === 'all') { + $items = $this->ptm->get_teknisi_items_full($user_id); + $noFaktur = 'GRJN/K/ALL' . date('/m/Y'); + $tanggal = 'Semua Tanggal'; + } elseif ($tanggal_param) { + $ts = strtotime($tanggal_param); + $items = $this->ptm->get_teknisi_items_full($user_id, $tanggal_param); + $noFaktur = 'GRJN/K/' . date('d/m/Y', $ts); + $tanggal = date('d/m/Y', $ts); + } else { + $items = $this->ptm->get_teknisi_items_full($user_id); + $noFaktur = 'GRJN/K/' . date('d/m/Y'); + $tanggal = date('d/m/Y'); + } require_once(APPPATH . 'third_party/fpdf/fpdf.php'); require_once(APPPATH . 'libraries/PDF_BarangBawaan.php'); diff --git a/application/libraries/PDF_BarangBawaan.php b/application/libraries/PDF_BarangBawaan.php index c0b54b4..1d072b9 100644 --- a/application/libraries/PDF_BarangBawaan.php +++ b/application/libraries/PDF_BarangBawaan.php @@ -8,7 +8,7 @@ class PDF_BarangBawaan extends FPDF private $tanggal; private $teknisi; - private $colWidths = [10, 28, 48, 30, 12, 62]; + private $colWidths = [8, 18, 27, 44, 26, 10, 57]; public function __construct($orientation = 'L', $unit = 'mm', $size = 'A5') { @@ -57,7 +57,7 @@ class PDF_BarangBawaan extends FPDF $this->SetTextColor(255, 255, 255); $this->SetFont('Arial', 'B', 7); - $headers = ['No', 'Barcode', 'Nama Barang', 'Serial Number', 'Jumlah', 'Keterangan']; + $headers = ['No', 'Tanggal', 'Barcode', 'Nama Barang', 'Serial Number', 'Jumlah', 'Keterangan']; foreach ($headers as $i => $h) { $this->Cell($this->colWidths[$i], 7, $h, 1, 0, 'C', true); } @@ -73,8 +73,8 @@ class PDF_BarangBawaan extends FPDF $minRowH = 8; $no = 1; - $colsMultiCell = [false, false, true, true, false, true]; - $cellAligns = ['C', 'L', 'L', 'L', 'C', 'L']; + $colsMultiCell = [false, false, true, true, true, false, true]; + $cellAligns = ['C', 'C', 'L', 'L', 'L', 'C', 'L']; foreach ($items as $item) { $keterangan = isset($item->keterangan) ? $item->keterangan : ''; @@ -85,6 +85,7 @@ class PDF_BarangBawaan extends FPDF $cellValues = [ (string)$no, + $item->tanggal ?? '-', $barcode, $namaBarang, $serial, diff --git a/application/models/PeralatanTeknisi_model.php b/application/models/PeralatanTeknisi_model.php index 89d1699..911d9ae 100644 --- a/application/models/PeralatanTeknisi_model.php +++ b/application/models/PeralatanTeknisi_model.php @@ -65,6 +65,7 @@ class PeralatanTeknisi_model extends CI_Model { ->from('item_barcodes ib') ->join('items i', 'i.id = ib.item_id', 'left') ->where('ib.barcode', $barcode) + ->where('ib.qty_sisa >', 0) ->get() ->row(); @@ -74,6 +75,7 @@ class PeralatanTeknisi_model extends CI_Model { ->from('item_barcodes ib') ->join('items i', 'i.id = ib.item_id', 'left') ->where('ib.serial_number', $barcode) + ->where('ib.qty_sisa >', 0) ->get() ->row(); } @@ -163,6 +165,19 @@ class PeralatanTeknisi_model extends CI_Model { return ['status' => true, 'message' => $msg, 'errors' => $errors]; } + + public function get_dates_by_employee_id($user_id) + { + return $this->db + ->select("DATE(it.created_at) as tanggal") + ->from('item_technician it') + ->where('it.user_id', $user_id) + ->where('it.status', 'active') + ->group_by("DATE(it.created_at)") + ->order_by("DATE(it.created_at)", "DESC") + ->get() + ->result(); + } public function batch_dibawa(array $barcodes, $user_id) { @@ -362,10 +377,11 @@ class PeralatanTeknisi_model extends CI_Model { public function get_teknisi_items_data($user_id, $start, $length, $search, $order_col, $order_dir) { $sort_cols = [ - 1 => 'it.barcode', - 2 => 'i.nama_barang', - 3 => 'ib.serial_number', - 4 => 'it.status' + 1 => 'it.created_at', + 2 => 'it.barcode', + 3 => 'i.nama_barang', + 4 => 'ib.serial_number', + 5 => 'it.status' ]; $this->db @@ -375,7 +391,7 @@ class PeralatanTeknisi_model extends CI_Model { ib.serial_number, ib.qty_sisa, it.status, - it.created_at + DATE_FORMAT(it.created_at, '%d/%m/%Y') as tanggal ") ->from('item_technician it') ->join('items i', 'i.id = it.item_id', 'left') @@ -484,21 +500,28 @@ class PeralatanTeknisi_model extends CI_Model { ->row(); } - public function get_teknisi_items_full($user_id) + public function get_teknisi_items_full($user_id, $tanggal = null) { - return $this->db + $this->db ->select(" it.barcode, i.nama_barang, ib.serial_number, ib.qty_sisa, - it.status + it.status, + DATE_FORMAT(it.created_at, '%d/%m/%Y') as tanggal ") ->from('item_technician it') ->join('items i', 'i.id = it.item_id', 'left') ->join('item_barcodes ib', 'ib.barcode = it.barcode', 'left') ->where('it.user_id', $user_id) - ->where('it.status', 'active') + ->where('it.status', 'active'); + + if ($tanggal AND $tanggal != 'all') { + $this->db->where('DATE(it.created_at)', $tanggal); + } + + return $this->db ->order_by('it.created_at', 'ASC') ->get() ->result(); diff --git a/application/views/peralatan_teknisi/layout.php b/application/views/peralatan_teknisi/layout.php index c6b17ae..9d3bc00 100644 --- a/application/views/peralatan_teknisi/layout.php +++ b/application/views/peralatan_teknisi/layout.php @@ -490,6 +490,7 @@ body { No + Tanggal Barcode Nama Barang Serial Number @@ -531,7 +532,9 @@ body {
Tanggal
- - +
Teknisi
@@ -549,6 +552,7 @@ body { No + Tanggal Barcode Nama Barang Serial Number @@ -751,9 +755,10 @@ $(function(){ { data: 2 }, { data: 3 }, { data: 4 }, - { data: 5, className: 'text-center' } + { data: 5 }, + { data: 6, className: 'text-center' } ], - order: [[1, 'asc']], + order: [[1, 'desc']], // language: { url: "//cdn.datatables.net/plug-ins/1.13.6/i18n/id.json" }, pageLength: 10, lengthMenu: [[10, 25, 50, -1], [10, 25, 50, 'All']] @@ -769,16 +774,35 @@ $(function(){ let dtFormBarang; let _formBarangUserId = null; - $(document).on('click', '.btn-form-barang-bawaan', function(){ - let userId = $(this).data('id'); - let nama = $(this).data('nama'); - _formBarangUserId = userId; + function loadListTanggal(userId) { + $.get("", {user_id: userId}, function(r){ + if (!r.status) { + Swal.fire({icon:'error', text:r.message}); + return; + } - $('#fbNoFaktur').text('Memuat...'); - $('#fbTanggal').text('-'); - $('#fbTeknisi').text(nama); + let opt=''; + r.data.forEach(d=>{ + let parts = d.tanggal.split('-'); + let display = parts[2] + '/' + parts[1] + '/' + parts[0]; + opt += ``; + }); + $('#fbTanggalList').html(opt); + }, 'json'); + } - $.get("", {user_id: userId}, function(r){ + function loadFormBarangData() { + let tanggalVal = $('#fbTanggalList').val(); + + if (!tanggalVal) { + $('#fbNoFaktur').text('Memuat...'); + if (dtFormBarang) { + dtFormBarang.clear().draw(); + } + return; + } + + $.get("", {user_id: _formBarangUserId, tanggal: tanggalVal}, function(r){ if (!r.status) { Swal.fire({icon:'error', text:r.message}); return; @@ -786,8 +810,6 @@ $(function(){ let d = r.data; $('#fbNoFaktur').text(d.no_faktur); - $('#fbTanggal').text(d.tanggal); - $('#fbTeknisi').text(d.teknisi); if (dtFormBarang) { dtFormBarang.destroy(); @@ -797,24 +819,63 @@ $(function(){ data: d.items, columns: [ { data: 'no' }, + { data: 'tanggal' }, { data: 'barcode' }, { data: 'nama_barang' }, { data: 'serial_number' }, { data: 'jumlah', className: 'text-center' } ], - // language: { url: "//cdn.datatables.net/plug-ins/1.13.6/i18n/id.json" }, pageLength: 10, lengthMenu: [[10, 25, 50, -1], [10, 25, 50, 'All']], order: [] }); }, 'json'); + } + + $('#fbTanggalList').on('change', function() { + loadFormBarangData(); + }); + + $(document).on('click', '.btn-form-barang-bawaan', function(){ + let userId = $(this).data('id'); + let nama = $(this).data('nama'); + _formBarangUserId = userId; + + $('#fbNoFaktur').text('Memuat...'); + $('#fbTanggalList').val(''); + $('#fbTeknisi').text(nama); + + if (!dtFormBarang) { + dtFormBarang = $('#tableFormBarang').DataTable({ + data: [], + columns: [ + { data: 'no' }, + { data: 'tanggal' }, + { data: 'barcode' }, + { data: 'nama_barang' }, + { data: 'serial_number' }, + { data: 'jumlah', className: 'text-center' } + ], + pageLength: 10, + lengthMenu: [[10, 25, 50, -1], [10, 25, 50, 'All']], + order: [], + language: { + emptyTable: "No data available" + } + }); + } else { + dtFormBarang.clear().draw(); + } + + loadListTanggal(userId); $('#modalFormBarangBawaan').modal('show'); }); $('#btnCetakPDF').click(function(){ if (_formBarangUserId) { - let url = "" + _formBarangUserId; + let tanggalVal = $('#fbTanggalList').val(); + let url = "" + _formBarangUserId + '?tanggal=' + encodeURIComponent(tanggalVal); window.open(url, '_blank'); } });