accounting workflows

This commit is contained in:
Thanakorn S
2026-05-20 10:17:02 +07:00
parent 04a683bd02
commit 7396db6ffc
199 changed files with 23539 additions and 5345 deletions
+8 -20
View File
@@ -1,32 +1,20 @@
<?php
session_start();
require '../../../assets/utils/db_auth.php';
require '../../../assets/utils/classes/QuotationManager.php';
$id = (int)($data['id'] ?? 0);
$qm = new QuotationManager($pdo2, $company_id);
if ($id) {
// Single quotation
$sql = "SELECT q.*, c.contact_name
FROM ac_quotation q
LEFT JOIN md_contact c ON c.id = q.contact_id
WHERE q.id = :id AND q.company_id = :cid
LIMIT 1";
$sth = $pdo2->prepare($sql);
$sth->execute([':id' => $id, ':cid' => $company_id]);
$row = $sth->fetch(PDO::FETCH_ASSOC);
if (!$row) { exit(json_encode(['success' => 0, 'message' => 'Not found'])); }
$row['items'] = json_decode($row['items'] ?? '[]', true);
$row = $qm->getById($id);
if (!$row) {
http_response_code(404);
exit(json_encode(['success' => 0, 'message' => 'Not found.']));
}
$answer['output'] = $row;
} else {
// List
$sql = "SELECT q.*, c.contact_name
FROM ac_quotation q
LEFT JOIN md_contact c ON c.id = q.contact_id
WHERE q.company_id = :cid
ORDER BY q.id DESC";
$sth = $pdo2->prepare($sql);
$sth->execute([':cid' => $company_id]);
$answer['output'] = $sth->fetchAll(PDO::FETCH_ASSOC);
$answer['output'] = $qm->getList();
}
$answer['success'] = 1;