accounting workflows
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user