FEAT_LEVEL_CONTACT_REMOVE_API : RV
This commit is contained in:
parent
bb78dada40
commit
6bb00ab266
@ -360,6 +360,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
|||||||
$routes->get('removeInstallments', 'LeadsController::removeInstallments');
|
$routes->get('removeInstallments', 'LeadsController::removeInstallments');
|
||||||
$routes->get('viewHrAccessData', 'ClientController::viewHrAccessData');
|
$routes->get('viewHrAccessData', 'ClientController::viewHrAccessData');
|
||||||
$routes->post('saveHrAccessData', 'ClientController::saveHrAccessData');
|
$routes->post('saveHrAccessData', 'ClientController::saveHrAccessData');
|
||||||
|
$routes->post('removeLevelContacts', 'ClientController::removeLevelContacts');
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
|
$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
|
||||||
|
|||||||
@ -143,7 +143,7 @@ class ClientController extends AdminController
|
|||||||
|
|
||||||
// Perform the query
|
// Perform the query
|
||||||
$builder = $db->table($table);
|
$builder = $db->table($table);
|
||||||
$isDuplicate = $builder->where($field, $value)->countAllResults() > 0;
|
$isDuplicate = $builder->where($field, $value)->where('is_active', 1)->countAllResults() > 0;
|
||||||
|
|
||||||
// Return the result
|
// Return the result
|
||||||
return $this->response->setJSON(['isDuplicate' => $isDuplicate]);
|
return $this->response->setJSON(['isDuplicate' => $isDuplicate]);
|
||||||
@ -1171,6 +1171,40 @@ class ClientController extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function removeLevelContacts()
|
||||||
|
{
|
||||||
|
$id = $this->request->getGet('id');
|
||||||
|
try {
|
||||||
|
if (empty($id)) {
|
||||||
|
return $this->respond([
|
||||||
|
'status' => false,
|
||||||
|
'message' => 'Invalid ID provided. ID is empty',
|
||||||
|
'data' => $id
|
||||||
|
], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$updated = $this->levelContactModel->update($id, ['is_active' => 0]);
|
||||||
|
|
||||||
|
if ($updated === false) {
|
||||||
|
return $this->respond([
|
||||||
|
'status' => false,
|
||||||
|
'message' => 'Failed to remove contact'
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->respond([
|
||||||
|
'status' => true,
|
||||||
|
'message' => 'Contact removed successfully'
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->respond([
|
||||||
|
'status' => false,
|
||||||
|
'message' => 'An error occurred: ' . $e->getMessage()
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function createClientPolicy()
|
public function createClientPolicy()
|
||||||
|
|||||||
@ -580,12 +580,12 @@ $('body').on('click', '.btnBranchEdit', function() {
|
|||||||
console.log(branch_form_action);
|
console.log(branch_form_action);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#remove_btn").click(function() {
|
// $("#remove_btn").click(function() {
|
||||||
$("#name").val('');
|
// $("#name").val('');
|
||||||
$("#email").val('');
|
// $("#email").val('');
|
||||||
$("#mobile").val('');
|
// $("#mobile").val('');
|
||||||
$("#designation").val('');
|
// $("#designation").val('');
|
||||||
})
|
// })
|
||||||
|
|
||||||
// Initialize the contact count
|
// Initialize the contact count
|
||||||
function appendContactHtml(contact = false, reset = false) {
|
function appendContactHtml(contact = false, reset = false) {
|
||||||
@ -644,21 +644,68 @@ function appendContactHtml(contact = false, reset = false) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// function removeContact(button) {
|
||||||
|
// var uniqueId = button.id.split("_")[0];
|
||||||
|
// var contactSection = document.getElementById(uniqueId);
|
||||||
|
|
||||||
|
// if (contactSection) {
|
||||||
|
// contactSection.parentNode.removeChild(contactSection);
|
||||||
|
// contactCount--;
|
||||||
|
|
||||||
|
// if (contactCount < 3) {
|
||||||
|
// var addButton = document.querySelector('.ac');
|
||||||
|
// if (addButton) {
|
||||||
|
// addButton.style.display = 'block';
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
function removeContact(button) {
|
function removeContact(button) {
|
||||||
|
|
||||||
var uniqueId = button.id.split("_")[0];
|
var uniqueId = button.id.split("_")[0];
|
||||||
|
console.log('uniqueId', uniqueId);
|
||||||
var contactSection = document.getElementById(uniqueId);
|
var contactSection = document.getElementById(uniqueId);
|
||||||
|
console.log('contactSection', contactSection);
|
||||||
|
|
||||||
if (contactSection) {
|
confirmActionSweertAlert("Do you want to remove this contact?", "Yes, Proceed!", "No, Cancel").then((confirmed) => {
|
||||||
contactSection.parentNode.removeChild(contactSection);
|
if(confirmed){
|
||||||
contactCount--;
|
if (contactSection) {
|
||||||
|
|
||||||
if (contactCount < 3) {
|
let unique_param = uniqueId + '_branch_table_pk';
|
||||||
var addButton = document.querySelector('.ac');
|
console.log('unique_param', unique_param);
|
||||||
if (addButton) {
|
let other_id = $('#' + unique_param).val();
|
||||||
addButton.style.display = 'block';
|
console.log('other_id', other_id);
|
||||||
|
|
||||||
|
contactSection.parentNode.removeChild(contactSection);
|
||||||
|
contactCount--;
|
||||||
|
|
||||||
|
if (contactCount < 3) {
|
||||||
|
var addButton = document.querySelector('.ac');
|
||||||
|
if (addButton) {
|
||||||
|
addButton.style.display = 'block';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(other_id){
|
||||||
|
removeLevelContacts(other_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$("#name").val('');
|
||||||
|
$("#email").val('');
|
||||||
|
$("#mobile").val('');
|
||||||
|
$("#designation").val('');
|
||||||
|
|
||||||
|
let first_id = $('#branch_table_pk').val();
|
||||||
|
console.log('first_id', first_id);
|
||||||
|
if(first_id){
|
||||||
|
removeLevelContacts(first_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function storeButtonId(id) {
|
function storeButtonId(id) {
|
||||||
@ -839,6 +886,30 @@ function getContactsData() {
|
|||||||
return contacts;
|
return contacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeLevelContacts(id){
|
||||||
|
|
||||||
|
let url = '<?= base_url('util/removeLevelContacts') ?>';
|
||||||
|
|
||||||
|
let requestData = {
|
||||||
|
id: id,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Send AJAX request
|
||||||
|
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
||||||
|
|
||||||
|
console.log('Data fetched successfully:', response);
|
||||||
|
if (response.status == true) {
|
||||||
|
toastr.success(response.message, 'SUCCESS');
|
||||||
|
} else {
|
||||||
|
toastr.warning(response.message, 'WARNING');
|
||||||
|
}
|
||||||
|
|
||||||
|
}, function(xhr, status, error) {
|
||||||
|
console.error('Error fetching data:', error);
|
||||||
|
console.error(xhr.responseText);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user