accounting workflows
This commit is contained in:
@@ -8,19 +8,17 @@
|
||||
$data['items'] = json_decode($data['items'] ?? '[]', true) ?: [];
|
||||
|
||||
try {
|
||||
$new_id = null;
|
||||
$quotation_id = (int)($data['quotation_id'] ?? 0);
|
||||
$new_id = null;
|
||||
$source = trim((string)($data['source'] ?? ''));
|
||||
$source_id = (int)($data['source_id'] ?? 0);
|
||||
|
||||
dbTransaction($pdo2, function($pdo) use ($data, $company_id, $logging, $quotation_id, &$new_id) {
|
||||
dbTransaction($pdo2, function($pdo) use ($data, $company_id, $logging, $source, $source_id, &$new_id) {
|
||||
$order = new OrderManager($pdo, $company_id);
|
||||
$new_id = $order->saveOrder($data, $logging);
|
||||
|
||||
// On new order created from a quotation: link both records
|
||||
if ($new_id && $quotation_id > 0) {
|
||||
$pdo->prepare(
|
||||
"UPDATE ac_quotation SET order_id = :order_id, status = 5
|
||||
WHERE id = :id AND company_id = :cid AND status = 2"
|
||||
)->execute([':order_id' => $new_id, ':id' => $quotation_id, ':cid' => $company_id]);
|
||||
if ($new_id && $source === 'quotation' && $source_id > 0) {
|
||||
$order->linkQuotationToOrder($source_id, $new_id);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -39,4 +37,4 @@
|
||||
}
|
||||
|
||||
exit(json_encode($answer));
|
||||
?>
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user