164 lines
6.9 KiB
PHP
164 lines
6.9 KiB
PHP
<?php
|
|
session_start();
|
|
require '../config.php';
|
|
require '../include_header.php';
|
|
?>
|
|
|
|
<body>
|
|
<?php require '../include_topbar.php'; ?>
|
|
<?php require '../include_setting_sidebar.php'; ?>
|
|
|
|
<main id="content" class="content py-15">
|
|
<div class="container-fluid">
|
|
|
|
<!-- Page header -->
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="d-flex flex-column flex-md-row justify-content-between align-items-md-center mb-6 gap-3">
|
|
<div>
|
|
<h1 class="fs-3 mb-1">System Configuration</h1>
|
|
<p class="mb-0">Per-company settings that control application behaviour</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Stock Settings -->
|
|
<div class="row">
|
|
<div class="col-12 col-lg-7">
|
|
<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>
|
|
<div class="card-body">
|
|
|
|
<div class="mb-4">
|
|
<label class="form-label fw-semibold">Default Stock Status</label>
|
|
<p class="text-muted small mb-2">
|
|
Controls whether new stock-in, stock-out, and transfer records are saved
|
|
as <strong>Draft</strong> (requires manual approval) or
|
|
<strong>Auto-approved</strong> (approved immediately on save).
|
|
Only approved records appear in reports and balance calculations.
|
|
</p>
|
|
<div class="d-flex flex-column gap-2" id="default_stock_status_group">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="radio" name="default_stock_status"
|
|
id="status_auto" value="1">
|
|
<label class="form-check-label" for="status_auto">
|
|
<span class="fw-semibold">Auto-approve</span>
|
|
<span class="text-muted ms-1 small">— records are approved immediately on save</span>
|
|
</label>
|
|
</div>
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="radio" name="default_stock_status"
|
|
id="status_draft" value="0">
|
|
<label class="form-check-label" for="status_draft">
|
|
<span class="fw-semibold">Draft</span>
|
|
<span class="text-muted ms-1 small">— records must be manually approved before affecting reports</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>
|
|
|
|
<!-- 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 & Credit Note Settings</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
|
|
<div class="mb-4">
|
|
<label class="form-label fw-semibold">Invoice & 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>
|
|
|
|
</div>
|
|
</main>
|
|
|
|
<?php require '../include_ending.php'; ?>
|
|
|
|
<script>
|
|
|
|
// ── Load ──────────────────────────────────────────────────────────────────
|
|
$(function() {
|
|
ajax_request({
|
|
url: server_url + 'setting/api/engine/company_setting.php',
|
|
autoPrepare: true,
|
|
checkRequired: 0,
|
|
action: 'read',
|
|
onSuccess: function(res) {
|
|
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 stock_status = $('input[name="default_stock_status"]:checked').val();
|
|
var auto_invoice_and_cn = $('input[name="auto_invoice_and_credit_note"]:checked').val();
|
|
|
|
if (stock_status === undefined || auto_invoice_and_cn === undefined) {
|
|
bootbox.alert('Please select all settings before saving.');
|
|
return;
|
|
}
|
|
|
|
ajax_request({
|
|
url: server_url + 'setting/api/engine/company_setting.php',
|
|
autoPrepare: true,
|
|
checkRequired: 0,
|
|
action: 'update',
|
|
data: {
|
|
default_stock_status: stock_status,
|
|
auto_invoice_and_credit_note: auto_invoice_and_cn,
|
|
},
|
|
onSuccess: function(res) {
|
|
bootbox.alert('Settings saved.');
|
|
}
|
|
});
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|