accounting workflows
This commit is contained in:
@@ -30,10 +30,8 @@
|
||||
|
||||
if (!empty($_FILES['product_image']['name'])) {
|
||||
if ($id > 0) {
|
||||
$sql = "SELECT `product_image` FROM md_product WHERE company_id = :company_id AND id = :id";
|
||||
$sth = $pdo2->prepare($sql);
|
||||
$sth->execute([':company_id' => $company_id, ':id' => $id]);
|
||||
$uploader->cleanup($sth->fetchColumn(), '');
|
||||
$product = new ProductManager($pdo2, $company_id);
|
||||
$uploader->cleanup($product->getProductImage($id), '');
|
||||
}
|
||||
|
||||
$errors = $uploader->upload('product_image');
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
<?php
|
||||
session_start();
|
||||
require '../../../assets/utils/db_auth.php';
|
||||
require '../../../assets/utils/classes/UserManager.php';
|
||||
|
||||
require_role($user_role, ['owner', 'admin']);
|
||||
|
||||
$sth = $pdo1->prepare(
|
||||
"SELECT u.user_id, u.name, u.surname, u.email
|
||||
FROM user u
|
||||
INNER JOIN company_map_user m
|
||||
ON m.user_id = u.user_id
|
||||
AND m.company_id = :company_id
|
||||
ORDER BY u.name ASC"
|
||||
);
|
||||
$sth->execute([':company_id' => $company_id]);
|
||||
db_check($sth, $answer);
|
||||
try {
|
||||
$users = new UserManager($pdo1, $company_id, $user_id);
|
||||
$answer['output'] = $users->getCompanyUsers();
|
||||
$answer['success'] = 1;
|
||||
} catch (Exception $e) {
|
||||
$answer['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
$answer['output'] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||
$answer['success'] = 1;
|
||||
exit(json_encode($answer));
|
||||
?>
|
||||
|
||||
@@ -107,6 +107,18 @@
|
||||
<option value="0">inactive</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-3 mb-3">
|
||||
<label for="sales_account" class="form-label">Sales Account</label>
|
||||
<input type="text" class="form-control account_search" id="sales_account"
|
||||
placeholder="Search account..." autocomplete="off">
|
||||
<input type="hidden" id="sales_account_code">
|
||||
</div>
|
||||
<div class="col-md-3 mb-3">
|
||||
<label for="purchase_account" class="form-label">Purchase Account</label>
|
||||
<input type="text" class="form-control account_search" id="purchase_account"
|
||||
placeholder="Search account..." autocomplete="off">
|
||||
<input type="hidden" id="purchase_account_code">
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<!-- Remove d-none from file input so it shows by default -->
|
||||
<div class="mb-3">
|
||||
@@ -160,6 +172,8 @@
|
||||
formData.append('barcode', $('#barcode').val() || '')
|
||||
formData.append('cost_price', $('#cost_price').val() || 0)
|
||||
formData.append('uom', $('#uom').val() || 'pcs')
|
||||
formData.append('sales_account_code', $('#sales_account_code').val() || '')
|
||||
formData.append('purchase_account_code', $('#purchase_account_code').val() || '')
|
||||
|
||||
return ajax_request({
|
||||
url: "<?php echo $server_url?>inventory/api/engine/manage_product.php",
|
||||
@@ -217,6 +231,9 @@
|
||||
el.val(item);
|
||||
});
|
||||
|
||||
set_account_field('#sales_account', '#sales_account_code', res.output.sales_account_code || '');
|
||||
set_account_field('#purchase_account', '#purchase_account_code', res.output.purchase_account_code || '');
|
||||
|
||||
// Handle image field
|
||||
if (res.output.product_image) {
|
||||
$('#current_file_label').val(res.output.product_image);
|
||||
@@ -243,12 +260,55 @@
|
||||
$(async function() {
|
||||
try {
|
||||
await retrieve_category();
|
||||
await load_accounts();
|
||||
await retrieve_for_edit();
|
||||
init_account_search_inputs(null, window.account_search_accounts || []);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
|
||||
function load_accounts() {
|
||||
return ajax_request({
|
||||
url: "<?php echo $server_url?>accounting/api/engine/account.php",
|
||||
autoPrepare: true,
|
||||
checkRequired: 0,
|
||||
noLoading: true,
|
||||
action: 'read',
|
||||
onSuccess: function(res) {
|
||||
window.account_search_accounts = res.output || [];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function set_account_field(input_selector, hidden_selector, account_code) {
|
||||
var account = (window.account_search_accounts || []).find(function(row) {
|
||||
return String(row.account_code) === String(account_code);
|
||||
});
|
||||
var display = account ? account.account_code + ' - ' + account.account_name : account_code;
|
||||
$(input_selector)
|
||||
.val(display || '')
|
||||
.attr('secondary', display || '')
|
||||
.attr('data-account-code', account_code || '');
|
||||
$(hidden_selector).val(account_code || '');
|
||||
}
|
||||
|
||||
$(document).on('account:selected', '#sales_account', function(e, account) {
|
||||
$('#sales_account_code').val(account.account_code || '');
|
||||
});
|
||||
|
||||
$(document).on('account:selected', '#purchase_account', function(e, account) {
|
||||
$('#purchase_account_code').val(account.account_code || '');
|
||||
});
|
||||
|
||||
$(document).on('account:cleared', '#sales_account', function() {
|
||||
$('#sales_account_code').val('');
|
||||
});
|
||||
|
||||
$(document).on('account:cleared', '#purchase_account', function() {
|
||||
$('#purchase_account_code').val('');
|
||||
});
|
||||
|
||||
|
||||
function validate_stock_thresholds() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user