softDelete features

This commit is contained in:
Thanakorn S
2026-05-22 14:07:22 +07:00
parent 738f600fe8
commit 648efee991
59 changed files with 1783 additions and 16 deletions
+33
View File
@@ -0,0 +1,33 @@
<?php
session_start();
require '../../../assets/utils/db_auth.php';
require_role($user_role, ['owner', 'admin']);
require '../../../assets/utils/classes/PaymentManager.php';
$id = (int)($data['id'] ?? 0);
if (!$id) {
$answer['message'] = 'Invalid payment ID.';
http_response_code(400);
exit(json_encode($answer));
}
try {
dbTransaction($pdo2, function($pdo) use ($id, $company_id) {
$mgr = new PaymentManager($pdo, $company_id);
$mgr->softDelete($id);
});
$answer['success'] = 1;
$answer['message'] = 'Payment deleted.';
} 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));