Orders: order, return, invoice
This commit is contained in:
+43
-50
@@ -22,9 +22,10 @@
|
||||
</div>
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<label class="mb-0 text-nowrap fw-semibold">Month</label>
|
||||
<select id="month_filter" class="form-select" style="min-width:160px;">
|
||||
<option value="">Loading...</option>
|
||||
</select>
|
||||
<div class="input-group" style="min-width:160px;">
|
||||
<span class="input-group-text"><i class="ti ti-calendar"></i></span>
|
||||
<input type="text" id="month_filter" class="form-control" readonly placeholder="Select month" style="cursor:pointer;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -70,38 +71,39 @@
|
||||
<div class="card p-4 bg-success bg-opacity-10 border border-success border-opacity-25 rounded-2" style="position:relative;">
|
||||
<div class="d-flex gap-3">
|
||||
<div class="icon-shape icon-md bg-success text-white rounded-2">
|
||||
<i class="ti ti-package fs-4"></i>
|
||||
<i class="ti ti-shopping-cart fs-4"></i>
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="mb-3 fs-6">Active Products</h2>
|
||||
<h3 class="fw-bold mb-0" id="stat_active_products">—</h3>
|
||||
<p class="text-success mb-0 small">SKUs with movement</p>
|
||||
<h2 class="mb-3 fs-6">Total Orders</h2>
|
||||
<h3 class="fw-bold mb-0" id="stat_total_orders">—</h3>
|
||||
<p class="text-success mb-0 small">Orders this month</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-loader-overlay" id="overlay_active">
|
||||
<div class="card-loader-overlay" id="overlay_orders">
|
||||
<div class="spinner-border spinner-border-sm text-primary"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-sm-6 col-12">
|
||||
<div class="card p-4 bg-warning bg-opacity-10 border border-warning border-opacity-25 rounded-2" style="position:relative;">
|
||||
<div class="card p-4 bg-info bg-opacity-10 border border-info border-opacity-25 rounded-2" style="position:relative;">
|
||||
<div class="d-flex gap-3">
|
||||
<div class="icon-shape icon-md bg-warning text-white rounded-2">
|
||||
<i class="ti ti-alert-triangle fs-4"></i>
|
||||
<div class="icon-shape icon-md bg-info text-white rounded-2">
|
||||
<i class="ti ti-currency-baht fs-4"></i>
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="mb-3 fs-6">Low Stock Alerts</h2>
|
||||
<h3 class="fw-bold mb-0" id="stat_low_stock">—</h3>
|
||||
<p class="text-warning mb-0 small">Products below min stock</p>
|
||||
<h2 class="mb-3 fs-6">Total Revenue</h2>
|
||||
<h3 class="fw-bold mb-0" id="stat_total_revenue">—</h3>
|
||||
<p class="text-info mb-0 small">Grand total this month</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-loader-overlay" id="overlay_low">
|
||||
<div class="card-loader-overlay" id="overlay_revenue">
|
||||
<div class="spinner-border spinner-border-sm text-primary"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Stock Movement Chart -->
|
||||
<div class="row g-5 mb-5">
|
||||
<div class="col-12">
|
||||
@@ -182,7 +184,7 @@
|
||||
|
||||
// ── Show all overlays ─────────────────────────────────────────────────
|
||||
function show_overlays() {
|
||||
$('#overlay_in, #overlay_out, #overlay_active, #overlay_low, #overlay_chart, #overlay_moved, #overlay_low_list, #overlay_activity').show();
|
||||
$('#overlay_in, #overlay_out, #overlay_orders, #overlay_revenue, #overlay_chart, #overlay_moved, #overlay_low_list, #overlay_activity').show();
|
||||
}
|
||||
|
||||
|
||||
@@ -192,9 +194,9 @@
|
||||
// Stats
|
||||
$('#stat_total_in').text(format_number(d.total_in, 2));
|
||||
$('#stat_total_out').text(format_number(d.total_out, 2));
|
||||
$('#stat_active_products').text(format_number(d.active_products));
|
||||
$('#stat_low_stock').text(format_number(d.low_stock));
|
||||
$('#overlay_in, #overlay_out, #overlay_active, #overlay_low').hide();
|
||||
$('#stat_total_orders').text(format_number(d.total_orders));
|
||||
$('#stat_total_revenue').text(format_number(d.total_revenue, 2));
|
||||
$('#overlay_in, #overlay_out, #overlay_orders, #overlay_revenue').hide();
|
||||
|
||||
// Chart
|
||||
var mv = d.stock_movement;
|
||||
@@ -308,7 +310,10 @@
|
||||
// ── Fetch + render ────────────────────────────────────────────────────
|
||||
function retrieve_dashboard() {
|
||||
|
||||
var month = $('#month_filter').val() || '<?php echo date('Y-m'); ?>';
|
||||
var fpDate = monthPicker.selectedDates[0];
|
||||
var month = fpDate
|
||||
? fpDate.getFullYear() + '-' + String(fpDate.getMonth() + 1).padStart(2, '0')
|
||||
: '<?php echo date('Y-m'); ?>';
|
||||
show_overlays();
|
||||
|
||||
return ajax_request({
|
||||
@@ -344,45 +349,33 @@
|
||||
|
||||
|
||||
// ── Boot ─────────────────────────────────────────────────────────────
|
||||
var monthPicker = flatpickr('#month_filter', {
|
||||
plugins: [
|
||||
new monthSelectPlugin({
|
||||
shorthand: true,
|
||||
dateFormat: 'M Y',
|
||||
altFormat: 'M Y',
|
||||
theme: 'light'
|
||||
})
|
||||
],
|
||||
disableMobile: true,
|
||||
onChange: function() {
|
||||
retrieve_dashboard();
|
||||
}
|
||||
});
|
||||
monthPicker.setDate('<?php echo date('M Y'); ?>', false); // false = don't trigger onChange
|
||||
|
||||
$(async function() {
|
||||
try {
|
||||
var month = '<?php echo date('Y-m'); ?>';
|
||||
show_overlays();
|
||||
|
||||
await ajax_request({
|
||||
url: "<?php echo $server_url?>dashboard/api/engine_report/reports_stats.php",
|
||||
autoPrepare: true,
|
||||
checkRequired: 0,
|
||||
action: 'read',
|
||||
data: { "month": month },
|
||||
onSuccess: async function(res) {
|
||||
|
||||
// Populate month picker
|
||||
var option = '';
|
||||
var months = res.output.months || [month];
|
||||
$.each(months, function(i, m) {
|
||||
var sel = (m === month) ? 'selected' : '';
|
||||
option += `<option value="${m}" ${sel}>${format_month(m)}</option>`;
|
||||
});
|
||||
if (!months.length) {
|
||||
option = `<option value="${month}">${format_month(month)}</option>`;
|
||||
}
|
||||
$('#month_filter').html(option);
|
||||
|
||||
await render(res.output, month);
|
||||
}
|
||||
});
|
||||
|
||||
await retrieve_dashboard();
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// ── Month filter change ───────────────────────────────────────────────
|
||||
$('#month_filter').on('change', function() {
|
||||
retrieve_dashboard();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user