accounting workflows
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
session_start();
|
||||
require '../../../assets/utils/db_auth.php';
|
||||
require '../../../assets/utils/classes/PurchaseRequestManager.php';
|
||||
require_role($user_role, ['owner', 'admin', 'staff']);
|
||||
|
||||
$id = (int)($data['id'] ?? 0);
|
||||
$action = $data['action_type'] ?? '';
|
||||
|
||||
if (!$id || !$action) {
|
||||
exit(json_encode(['success' => 0, 'message' => 'ID and action are required.']));
|
||||
}
|
||||
|
||||
$prm = new PurchaseRequestManager($pdo2, $company_id);
|
||||
|
||||
try {
|
||||
$prm->updateStatus($id, $action, $logging);
|
||||
$answer['success'] = 1;
|
||||
$answer['message'] = 'Status updated.';
|
||||
} catch (PDOException $e) {
|
||||
$answer['message'] = 'Database error, please try again.';
|
||||
http_response_code(500);
|
||||
} catch (Exception $e) {
|
||||
$answer['message'] = $e->getMessage();
|
||||
http_response_code(400);
|
||||
}
|
||||
|
||||
exit(json_encode($answer));
|
||||
Reference in New Issue
Block a user