Update besar apk finance
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
<?php $inventory_title='Kelola Barcode & Serial';$inventory_subtitle='Lengkapi serial unit pending sebelum diaktifkan.';$this->load->view('inventory_professional/_module_nav',get_defined_vars());?>
|
||||
<style>
|
||||
body {
|
||||
background: #f5f7fb;
|
||||
@@ -21,13 +22,13 @@ body {
|
||||
.header-gradient {
|
||||
background: linear-gradient(135deg, #f59e0b, #d97706);
|
||||
color: #fff;
|
||||
padding: 22px 28px;
|
||||
padding: 14px 28px;
|
||||
}
|
||||
|
||||
.info-box {
|
||||
background: rgba(255,255,255,.18);
|
||||
border-radius: 12px;
|
||||
padding: 12px 16px;
|
||||
padding: 10px 16px;
|
||||
}
|
||||
|
||||
.progress {
|
||||
@@ -140,10 +141,10 @@ body {
|
||||
<div class="header-gradient">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-md-8">
|
||||
<h3 class="mb-1">
|
||||
<h5 class="mb-1">
|
||||
<i class="fa fa-barcode"></i>
|
||||
Input Serial Number
|
||||
</h3>
|
||||
</h5>
|
||||
<div class="small">
|
||||
Silahkan scan Serial Number perangkat.
|
||||
Data akan otomatis tersimpan.
|
||||
@@ -154,9 +155,9 @@ body {
|
||||
<div class="small">
|
||||
Progress
|
||||
</div>
|
||||
<h5 class="font-weight-bold mb-2" id="progress_text">
|
||||
<h6 class="font-weight-bold mb-2" id="progress_text">
|
||||
0 / 0 Barcode
|
||||
</h5>
|
||||
</h6>
|
||||
<div class="progress">
|
||||
<div class="progress-bar bg-success" style="width:35%"></div>
|
||||
</div>
|
||||
@@ -259,13 +260,21 @@ body {
|
||||
<div class="col-lg-8">
|
||||
<div class="card table-card">
|
||||
<div class="card-header bg-white">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div class="d-flex flex-wrap justify-content-between align-items-center gap-2">
|
||||
<h5 class="mb-0">
|
||||
Daftar Barcode
|
||||
</h5>
|
||||
<span class="badge badge-warning px-3 py-2">
|
||||
20 Data
|
||||
</span>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<input type="search" id="barcodeSearch" class="form-control form-control-sm" placeholder="Cari barcode / SN" autocomplete="off">
|
||||
<span class="badge badge-warning px-3 py-2" id="barcodeCount">0 Data</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer bg-white d-flex justify-content-between align-items-center">
|
||||
<small id="barcodePageInfo" class="text-muted">Memuat data...</small>
|
||||
<div class="btn-group btn-group-sm">
|
||||
<button type="button" class="btn btn-outline-secondary" id="barcodePrev">Sebelumnya</button>
|
||||
<button type="button" class="btn btn-outline-secondary" id="barcodeNext">Berikutnya</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
@@ -277,7 +286,7 @@ body {
|
||||
<th>Barcode</th>
|
||||
<th>Serial Number</th>
|
||||
<th width="120">Status</th>
|
||||
<th width="80" class="text-center">Action</th>
|
||||
<th width="150" class="text-center">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -313,9 +322,18 @@ body {
|
||||
|
||||
let ITEM_ID = `<?= $item_id; ?>` ;
|
||||
let isSaving = false;
|
||||
let barcodeStart = 0;
|
||||
const barcodeLength = 50;
|
||||
let barcodeSearchTimer = null;
|
||||
|
||||
$(document).ready(function () {
|
||||
loadData();
|
||||
$("#barcodeSearch").on("input", function () {
|
||||
clearTimeout(barcodeSearchTimer);
|
||||
barcodeSearchTimer = setTimeout(function () { barcodeStart = 0; loadData(); }, 300);
|
||||
});
|
||||
$("#barcodePrev").on("click", function () { barcodeStart = Math.max(0, barcodeStart - barcodeLength); loadData(); });
|
||||
$("#barcodeNext").on("click", function () { barcodeStart += barcodeLength; loadData(); });
|
||||
$("#serial_number").focus();
|
||||
$("#serial_number").on("keypress", function (e) {
|
||||
if (e.which == 13) {
|
||||
@@ -328,7 +346,11 @@ $(document).ready(function () {
|
||||
});
|
||||
|
||||
function loadData() {
|
||||
$.getJSON( "<?= base_url(); ?>" + "items/load_data_barcode/" + ITEM_ID)
|
||||
$.getJSON( "<?= base_url(); ?>" + "items/load_data_barcode/" + ITEM_ID, {
|
||||
start: barcodeStart,
|
||||
length: barcodeLength,
|
||||
search: $("#barcodeSearch").val() || ""
|
||||
})
|
||||
.done(function (r) {
|
||||
render(r);
|
||||
})
|
||||
@@ -360,7 +382,7 @@ function saveSerial() {
|
||||
},
|
||||
success: function (r) {
|
||||
isSaving = false;
|
||||
render(r);
|
||||
if (r.status) loadData(); else render(r);
|
||||
},
|
||||
error: function () {
|
||||
isSaving = false;
|
||||
@@ -455,18 +477,20 @@ function render(r) {
|
||||
// =======================
|
||||
|
||||
let html = "";
|
||||
const escapeHtml = function (value) { return $("<div>").text(value == null ? "" : String(value)).html(); };
|
||||
|
||||
$.each(r.list, function (i, v) {
|
||||
|
||||
html += "<tr>";
|
||||
html += "<td>" + (i + 1) + "</td>";
|
||||
html += "<td><strong>" + v.barcode + "</strong></td>";
|
||||
html += "<td>" + (v.serial_number ? v.serial_number : "-") + "</td>";
|
||||
|
||||
html += "<td>" + (r.start + i + 1) + "</td>";
|
||||
html += "<td><strong>" + escapeHtml(v.barcode) + "</strong></td>";
|
||||
html += "<td>" + escapeHtml(v.serial_number ? v.serial_number : "-") + "</td>";
|
||||
html += "<td>";
|
||||
|
||||
if (v.serial_number) {
|
||||
html += '<span class="badge-success-soft"><i class="fa fa-check mr-1"></i>Selesai</span>';
|
||||
if (v.status === 'available') {
|
||||
html += '<span class="badge-success-soft"><i class="fa fa-check mr-1"></i>Aktif</span>';
|
||||
} else if (v.serial_number) {
|
||||
html += '<span class="badge-warning-soft">Siap Diposting</span>';
|
||||
} else {
|
||||
html += '<span class="badge-warning-soft">Menunggu</span>';
|
||||
}
|
||||
@@ -475,14 +499,12 @@ function render(r) {
|
||||
|
||||
html += '<td class="text-center">';
|
||||
|
||||
if (r.item_status == "draft") {
|
||||
|
||||
html += '<button class="btn btn-sm btn-outline-danger btnDelete" data-id="' + v.id + '">Delete</button>';
|
||||
|
||||
if (v.status === 'available') {
|
||||
html += '<button class="btn btn-sm btn-outline-secondary" disabled>Sudah Aktif</button>';
|
||||
} else if (v.serial_number) {
|
||||
html += '<button class="btn btn-sm btn-outline-danger btnDelete" data-id="' + v.id + '">Hapus SN</button>';
|
||||
} else {
|
||||
|
||||
html += '<button class="btn btn-sm btn-outline-secondary" disabled>Locked</button>';
|
||||
|
||||
html += '<button class="btn btn-sm btn-outline-secondary" disabled>Belum Siap</button>';
|
||||
}
|
||||
|
||||
html += "</td>";
|
||||
@@ -491,75 +513,15 @@ function render(r) {
|
||||
});
|
||||
|
||||
$("#tableBarcode tbody").html(html);
|
||||
$("#barcodeCount").text(r.total + " Data");
|
||||
const shownTo = Math.min(r.start + r.list.length, r.filtered);
|
||||
$("#barcodePageInfo").text(r.filtered ? ((r.start + 1) + "–" + shownTo + " dari " + r.filtered) : "Tidak ada data");
|
||||
$("#barcodePrev").prop("disabled", r.start <= 0);
|
||||
$("#barcodeNext").prop("disabled", r.start + r.length >= r.filtered);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// function render(r) {
|
||||
// if (!r.status) {
|
||||
// $("#serial_number")
|
||||
// .val("")
|
||||
// .prop("disabled", false)
|
||||
// .focus();
|
||||
// Swal.fire({
|
||||
// icon: "error",
|
||||
// title: "Oops...",
|
||||
// text: r.message
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
// if (r.next == null) {
|
||||
// $("#barcode_id").val("");
|
||||
// $(".barcode-code").html("SELESAI");
|
||||
// $("#serial_number")
|
||||
// .val("")
|
||||
// .prop("disabled", true);
|
||||
// $(".progress-bar")
|
||||
// .css("width", "100%");
|
||||
// $("#progress_text").html(r.done + " / " + r.total);
|
||||
// Swal.fire({
|
||||
// icon: "success",
|
||||
// title: "Selesai",
|
||||
// text: "Semua Serial Number berhasil diinput."
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
// // Barcode Aktif
|
||||
// $("#barcode_id").val(r.next.id);
|
||||
// $(".barcode-code").text(r.next.barcode);
|
||||
// // Progress
|
||||
// $("#progress_text").text(r.done + " / " + r.total);
|
||||
// $(".progress-bar")
|
||||
// .css("width", r.percent + "%");
|
||||
// // Table
|
||||
// let html = "";
|
||||
// $.each(r.list, function (i, v) {
|
||||
// html += "<tr>";
|
||||
// html += "<td>" + (i + 1) + "</td>";
|
||||
// html += "<td><strong>" + v.barcode + "</strong></td>";
|
||||
// html += "<td>" + (v.serial_number ? v.serial_number : "-") + "</td>";
|
||||
// html += "<td>";
|
||||
// if (v.serial_number) {
|
||||
// html += '<span class="badge-success-soft"><i class="fa fa-check mr-1"></i>Selesai</span>';
|
||||
// } else {
|
||||
// html += '<span class="badge-warning-soft">Menunggu</span>';
|
||||
// }
|
||||
// html += "</td>";
|
||||
// html += '<td class="text-center">';
|
||||
// html += '<button class="btn btn-sm btn-outline-danger btnDelete" data-id="' + v.id + '">';
|
||||
// html += 'Delete';
|
||||
// html += '</button>';
|
||||
// html += '</td>';
|
||||
// html += "</tr>";
|
||||
// });
|
||||
// $("#tableBarcode tbody").html(html);
|
||||
// // Reset Input
|
||||
// $("#serial_number")
|
||||
// .val("")
|
||||
// .prop("disabled", false)
|
||||
// .focus();
|
||||
// }
|
||||
|
||||
$(document).on("click", ".btnDelete", function () {
|
||||
let id = $(this).data("id");
|
||||
Swal.fire({
|
||||
@@ -576,7 +538,7 @@ $(document).on("click", ".btnDelete", function () {
|
||||
barcode_id: id
|
||||
},
|
||||
function (r) {
|
||||
render(r);
|
||||
if (r.status) loadData(); else render(r);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user