Orders: order, return, invoice

This commit is contained in:
Thanakorn S
2026-05-02 16:49:21 +07:00
parent ac4fd9a5ad
commit a90975d9f1
47 changed files with 4838 additions and 99 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ $action = $data['action'] ?? '';
if ($action === 'read') {
$sth = $pdo1->prepare(
"SELECT cl.company_id, cl.company_name, cl.branch, cmu.role
"SELECT cl.company_id, cl.channel_name, cl.company_name, cl.branch, cmu.role
FROM company_map_user cmu
JOIN company_list cl ON cl.company_id = cmu.company_id
WHERE cmu.user_id = :user_id
+52 -7
View File
@@ -26,7 +26,7 @@
<!-- Stock Settings -->
<div class="row">
<div class="col-12 col-lg-7">
<div class="card border-0 shadow-sm">
<div class="card border-0 shadow-sm mb-5">
<div class="card-header bg-transparent border-bottom">
<h6 class="mb-0"><i class="ti ti-package me-2"></i>Stock Settings</h6>
</div>
@@ -66,6 +66,48 @@
</div>
</div>
<!-- Invoice & Credit Note Settings -->
<div class="card border-0 shadow-sm">
<div class="card-header bg-transparent border-bottom">
<h6 class="mb-0"><i class="ti ti-file-invoice me-2"></i>Invoice &amp; Credit Note Settings</h6>
</div>
<div class="card-body">
<div class="mb-4">
<label class="form-label fw-semibold">Invoice &amp; Credit Note Generation</label>
<p class="text-muted small mb-2">
Controls automatic document generation.
When <strong>Auto</strong> is selected, a draft invoice is created when an order is confirmed,
and a credit note is created automatically when a return is confirmed.
When <strong>Manual</strong>, staff create these documents themselves from the order or return detail page.
</p>
<div class="d-flex flex-column gap-2" id="auto_invoice_and_credit_note_group">
<div class="form-check">
<input class="form-check-input" type="radio" name="auto_invoice_and_credit_note"
id="invoice_auto" value="1">
<label class="form-check-label" for="invoice_auto">
<span class="fw-semibold">Auto</span>
<span class="text-muted ms-1 small">— invoice on order confirm, credit note on return confirm</span>
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="auto_invoice_and_credit_note"
id="invoice_manual" value="0">
<label class="form-check-label" for="invoice_manual">
<span class="fw-semibold">Manual</span>
<span class="text-muted ms-1 small">— staff create invoice and credit note manually</span>
</label>
</div>
</div>
</div>
<button class="btn btn-primary" onclick="save_config();">
<i class="ti ti-device-floppy me-1"></i>Save
</button>
</div>
</div>
</div>
</div>
@@ -84,18 +126,20 @@
checkRequired: 0,
action: 'read',
onSuccess: function(res) {
var val = res.output.default_stock_status ?? 1;
$('input[name="default_stock_status"][value="' + val + '"]').prop('checked', true);
var s = res.output;
$('input[name="default_stock_status"][value="' + (s.default_stock_status ?? 1) + '"]').prop('checked', true);
$('input[name="auto_invoice_and_credit_note"][value="' + (s.auto_invoice_and_credit_note ?? 0) + '"]').prop('checked', true);
}
});
});
// ── Save ──────────────────────────────────────────────────────────────────
function save_config() {
var status = $('input[name="default_stock_status"]:checked').val();
var stock_status = $('input[name="default_stock_status"]:checked').val();
var auto_invoice_and_cn = $('input[name="auto_invoice_and_credit_note"]:checked').val();
if (status === undefined) {
bootbox.alert('Please select a default stock status.');
if (stock_status === undefined || auto_invoice_and_cn === undefined) {
bootbox.alert('Please select all settings before saving.');
return;
}
@@ -105,7 +149,8 @@
checkRequired: 0,
action: 'update',
data: {
default_stock_status: status,
default_stock_status: stock_status,
auto_invoice_and_credit_note: auto_invoice_and_cn,
},
onSuccess: function(res) {
bootbox.alert('Settings saved.');