update form barang
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -490,6 +490,7 @@ body {
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:50px">No</th>
|
||||
<th>Tanggal</th>
|
||||
<th>Barcode</th>
|
||||
<th>Nama Barang</th>
|
||||
<th>Serial Number</th>
|
||||
@@ -531,7 +532,9 @@ body {
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<small class="text-muted">Tanggal</small><br>
|
||||
<strong id="fbTanggal">-</strong>
|
||||
<select class="form-select form-select-sm d-inline-block" id="fbTanggalList" style="max-width:2000px">
|
||||
<option value="">-- Pilih Tanggal --</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<small class="text-muted">Teknisi</small><br>
|
||||
@@ -549,6 +552,7 @@ body {
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:50px">No</th>
|
||||
<th style="width:85px">Tanggal</th>
|
||||
<th>Barcode</th>
|
||||
<th>Nama Barang</th>
|
||||
<th>Serial Number</th>
|
||||
@@ -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("<?= base_url('teknisi/get_date_by_employee_id'); ?>", {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='<option value="">-- Pilih Tanggal --</option><option value="all">ALL</option>';
|
||||
r.data.forEach(d=>{
|
||||
let parts = d.tanggal.split('-');
|
||||
let display = parts[2] + '/' + parts[1] + '/' + parts[0];
|
||||
opt += `<option value="${d.tanggal}">${display}</option>`;
|
||||
});
|
||||
$('#fbTanggalList').html(opt);
|
||||
}, 'json');
|
||||
}
|
||||
|
||||
$.get("<?= base_url('teknisi/get_form_barang_bawaan_data'); ?>", {user_id: userId}, function(r){
|
||||
function loadFormBarangData() {
|
||||
let tanggalVal = $('#fbTanggalList').val();
|
||||
|
||||
if (!tanggalVal) {
|
||||
$('#fbNoFaktur').text('Memuat...');
|
||||
if (dtFormBarang) {
|
||||
dtFormBarang.clear().draw();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$.get("<?= base_url('teknisi/get_form_barang_bawaan_data'); ?>", {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 = "<?= base_url('teknisi/generate_pdf_barang_bawaan/'); ?>" + _formBarangUserId;
|
||||
let tanggalVal = $('#fbTanggalList').val();
|
||||
let url = "<?= base_url('teknisi/generate_pdf_barang_bawaan/'); ?>" + _formBarangUserId + '?tanggal=' + encodeURIComponent(tanggalVal);
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user