remove actions and data integrity

This commit is contained in:
Thanakorn S
2026-04-24 14:25:39 +07:00
parent a75e180686
commit 92d116fd21
26 changed files with 1325 additions and 249 deletions
+29
View File
@@ -0,0 +1,29 @@
<?php
session_start();
require '../../../assets/utils/db_auth.php';
require '../../../assets/utils/classes/ContactManager.php';
try {
dbTransaction($pdo2, function($pdo) use ($data, $company_id) {
$contactMgmt = new ContactManager($pdo, $company_id);
$contactMgmt->deleteContact((int)$data['id']);
});
$answer["success"] = 1;
} catch (PDOException $e) {
$answer["success"] = 0;
$answer["message"] = "Database error, please try again";
http_response_code(500);
} catch (Exception $e) {
$answer["success"] = 0;
$answer["message"] = $e->getMessage();
http_response_code(400);
}
exit(json_encode($answer));
?>
@@ -0,0 +1,29 @@
<?php
session_start();
require '../../../assets/utils/db_auth.php';
require '../../../assets/utils/classes/ContactManager.php';
try {
dbTransaction($pdo2, function($pdo) use ($data, $company_id) {
$contactMgmt = new ContactManager($pdo, $company_id);
$contactMgmt->deleteContactType((int)$data['id']);
});
$answer["success"] = 1;
} catch (PDOException $e) {
$answer["success"] = 0;
$answer["message"] = "Database error, please try again";
http_response_code(500);
} catch (Exception $e) {
$answer["success"] = 0;
$answer["message"] = $e->getMessage();
http_response_code(400);
}
exit(json_encode($answer));
?>
+44 -2
View File
@@ -268,7 +268,7 @@
</td>
<td class="py-3">
<a href="<?php echo $server_url?>contact/manage_contact_type.php?id=${item['id']}" class=""><i class="ti ti-eye fs-5"></i></a>
<a href="#" class="link-danger"><i class="ti ti-trash ms-2 fs-5"></i></a>
<a href="javascript:;" class="link-danger" onclick="remove_contact_type(${item['id']},$(this))"><i class="ti ti-trash ms-2 fs-5"></i></a>
</td>
</tr>`;
})
@@ -331,7 +331,7 @@
</td>
<td class="py-3">
<a href="<?php echo $server_url?>contact/manage_contact.php?id=${item['id']}" class=""><i class="ti ti-eye fs-5"></i></a>
<a href="#" class="link-danger"><i class="ti ti-trash ms-2 fs-5"></i></a>
<a href="javascript:;" class="link-danger" onclick="remove_contact(${item['id']},$(this))"><i class="ti ti-trash ms-2 fs-5"></i></a>
</td>
</tr>`;
})
@@ -340,6 +340,48 @@
}
function remove_contact_type(id,element) {
return ajax_request({
url: "<?php echo $server_url?>contact/api/engine/remove_contact_type.php",
autoPrepare: true,
checkRequired: 0,
debugMode: 0,
data: {
id: id
},
action: 'delete',
onSuccess: function(res) {
element.parent().parent().remove();
}
});
}
function remove_contact(id,element) {
return ajax_request({
url: "<?php echo $server_url?>contact/api/engine/remove_contact.php",
autoPrepare: true,
checkRequired: 0,
debugMode: 0,
data: {
id: id
},
action: 'delete',
onSuccess: function(res) {
element.parent().parent().remove();
}
});
}
$(async function() {
try {
await retrieve_contact_type();