accounting modules
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
session_start();
|
||||
require '../../../assets/utils/db_auth.php';
|
||||
|
||||
$id = (int)($data['id'] ?? 0);
|
||||
|
||||
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);
|
||||
$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['success'] = 1;
|
||||
exit(json_encode($answer));
|
||||
Reference in New Issue
Block a user