Merge branch 'dev' of bitbucket.org:jubilian/nhance-enrollment into dev

This commit is contained in:
vadivelJ96 2025-08-04 15:00:36 +05:30
commit 0d1b2d4a91
4 changed files with 620 additions and 317 deletions

View File

@ -70,6 +70,7 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) {
$routes->get('deposit/(:num)', 'ClientController::deposit/$1');
$routes->get('remove/(:num)', 'ClientController::removeClient/$1');
$routes->get("list/(:any)", "ClientController::editClientOnboarding/$1");
$routes->post('wipe', 'ClientController::wipeDemoClient');
// application/config/routes.php
// Add a route for the view_Deposit method

View File

@ -4880,4 +4880,246 @@ class ClientController extends AdminController
return $this->respond(['status'=> false,'code'=>404,'message'=>'Mapping Deletion Failed'],200);
}
}
// -------------------- DEMO CLIENT FUNCTION --------------------------------------------------------------------------------------------
public function wipeDemoClient()
{
$this->myLogger->logme('error', "========================================");
$this->myLogger->logme('error', "WIPE DEMO CLIENT FUNCTION STARTED");
$this->myLogger->logme('error', "========================================");
$this->myLogger->logme('error', "Request Payload: " . json_encode($this->request->getPost() ?? []));
$client_id = $this->request->getPost('client_id');
if (empty($client_id)) {
$this->myLogger->logme('error', "ERROR: Client ID is required");
return $this->respond(['status' => false, 'message' => 'Client id required'], 404);
}
$this->myLogger->logme('error', "Client ID to wipe: " . $client_id);
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 1. CLIENT MODEL DELETION
// ========================================
$this->myLogger->logme('error', "1. PROCESSING CLIENT MODEL");
$client_data = $this->clientModel->where('id', $client_id)->where('is_active', 1)->first();
$this->myLogger->logme('error', " Found Client Data: " . json_encode($client_data ?? []));
if (!empty($client_data)) {
$is_deleted = $this->clientModel->where('id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Client data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete client record");
}
} else {
$this->myLogger->logme('error', " ✗ Client not found or inactive");
return $this->respond(['status' => false, 'message' => 'Client not found'], 404);
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 2. CLIENT RM MODEL DELETION
// ========================================
$this->myLogger->logme('error', "2. PROCESSING CLIENT RM MODEL");
$client_rm_data = $this->clientRMModel->where('client_id', $client_id)->first();
$this->myLogger->logme('error', " Found Client RM Data: " . json_encode($client_rm_data ?? []));
if (!empty($client_rm_data)) {
$is_deleted = $this->clientRMModel->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Client RM data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Client RM record");
}
} else {
$this->myLogger->logme('error', " No Client RM data found");
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 3. CLIENT KYC DOCS MODEL DELETION
// ========================================
$this->myLogger->logme('error', "3. PROCESSING CLIENT KYC DOCS MODEL");
$client_kyc_data = $this->clientKYCDocsModel->where('client_id', $client_id)->findAll();
$this->myLogger->logme('error', " Found Client KYC Records: " . count($client_kyc_data ?? []));
$this->myLogger->logme('error', " Client KYC Data: " . json_encode($client_kyc_data ?? []));
if (!empty($client_kyc_data)) {
$is_deleted = $this->clientKYCDocsModel->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Client KYC Docs data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Client KYC Docs records");
}
} else {
$this->myLogger->logme('error', " No Client KYC Docs data found");
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 4. CLIENT BRANCH MODEL DELETION
// ========================================
$this->myLogger->logme('error', "4. PROCESSING CLIENT BRANCH MODEL");
$client_branch_data = $this->clientBranchModel->where('client_id', $client_id)->findAll();
$branch_ids = array_column($client_branch_data, 'id') ?? [];
$this->myLogger->logme('error', " Found Client Branch Records: " . count($client_branch_data ?? []));
$this->myLogger->logme('error', " Branch IDs: " . json_encode($branch_ids));
$this->myLogger->logme('error', " Client Branch Data: " . json_encode($client_branch_data ?? []));
if (!empty($client_branch_data)) {
$is_deleted = $this->clientBranchModel->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Client Branch data removed successfully");
// Delete related Level Contact data
if (!empty($branch_ids)) {
$this->myLogger->logme('error', " 4a. PROCESSING RELATED LEVEL CONTACT DATA");
$level_contact_data = $this->levelContactModel->where('contact_type', 'client')->whereIn('ref_id', $branch_ids)->findAll();
$this->myLogger->logme('error', " Found Level Contact Records: " . count($level_contact_data ?? []));
$this->myLogger->logme('error', " Level Contact Data: " . json_encode($level_contact_data ?? []));
$is_deleted = $this->levelContactModel->where('contact_type', 'client')->whereIn('ref_id', $branch_ids)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Level Contact data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Level Contact records");
}
} else {
$this->myLogger->logme('error', " No Branch IDs available for Level Contact deletion");
}
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Client Branch records");
}
} else {
$this->myLogger->logme('error', " No Client Branch data found");
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 5. CLIENT POLICY MODEL DELETION
// ========================================
$this->myLogger->logme('error', "5. PROCESSING CLIENT POLICY MODEL");
$client_policy_data = $this->clientPolicyModel->where('client_id', $client_id)->findAll();
$policy_ids = array_column($client_policy_data, 'id') ?? [];
$this->myLogger->logme('error', " Found Client Policy Records: " . count($client_policy_data ?? []));
$this->myLogger->logme('error', " Policy IDs: " . json_encode($policy_ids));
$this->myLogger->logme('error', " Client Policy Data: " . json_encode($client_policy_data ?? []));
if (!empty($client_policy_data)) {
$is_deleted = $this->clientPolicyModel->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Client Policy data removed successfully");
// Delete related Employee Policy data
if (!empty($policy_ids)) {
$this->myLogger->logme('error', " 5a. PROCESSING RELATED EMPLOYEE POLICY DATA");
$employee_policy_data = $this->employeePolicyModel->whereIn('client_policy_id', $policy_ids)->findAll();
$this->myLogger->logme('error', " Found Employee Policy Records: " . count($employee_policy_data ?? []));
$is_deleted = $this->employeePolicyModel->whereIn('client_policy_id', $policy_ids)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Employee Policy data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Employee Policy records");
}
} else {
$this->myLogger->logme('error', " No Policy IDs available for Employee Policy deletion");
}
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Client Policy records");
}
} else {
$this->myLogger->logme('error', " No Client Policy data found");
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 6. EMPLOYEE MODEL DELETION
// ========================================
$this->myLogger->logme('error', "6. PROCESSING EMPLOYEE MODEL");
$employee_data = $this->employeeModel->where('client_id', $client_id)->findAll();
$this->myLogger->logme('error', " Found Employee Records: " . count($employee_data ?? []));
if (!empty($employee_data)) {
$is_deleted = $this->employeeModel->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Employee data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Employee records");
}
} else {
$this->myLogger->logme('error', " No Employee data found");
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 7. POLICY PREMIUM 1 MODEL DELETION
// ========================================
$this->myLogger->logme('error', "8. PROCESSING POLICY PREMIUM 1 MODEL");
$policy_premium1_data = $this->policyPremium1Model->where('client_id', $client_id)->findAll();
$this->myLogger->logme('error', " Found Policy Premium 1 Records: " . count($policy_premium1_data ?? []));
if (!empty($policy_premium1_data)) {
$is_deleted = $this->policyPremium1Model->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Policy Premium 1 data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Policy Premium 1 records");
}
} else {
$this->myLogger->logme('error', " No Policy Premium 1 data found");
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 8. POLICY PREMIUM 2 MODEL DELETION
// ========================================
$this->myLogger->logme('error', "9. PROCESSING POLICY PREMIUM 2 MODEL");
$policy_premium2_data = $this->policyPremium2Model->where('client_id', $client_id)->findAll();
$this->myLogger->logme('error', " Found Policy Premium 2 Records: " . count($policy_premium2_data ?? []));
if (!empty($policy_premium2_data)) {
$is_deleted = $this->policyPremium2Model->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Policy Premium 2 data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Policy Premium 2 records");
}
} else {
$this->myLogger->logme('error', " No Policy Premium 2 data found");
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 9. NOTIFICATION MODEL DELETION
// ========================================
$this->myLogger->logme('error', "10. PROCESSING NOTIFICATION MODEL");
$notification_data = $this->notificationModel->where('client_id', $client_id)->findAll();
$this->myLogger->logme('error', " Found Notification Records: " . count($notification_data ?? []));
$this->myLogger->logme('error', " Notification Data: " . json_encode($notification_data ?? []));
if (!empty($notification_data)) {
$is_deleted = $this->notificationModel->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Notification data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Notification records");
}
} else {
$this->myLogger->logme('error', " No Notification data found");
}
$this->myLogger->logme('error', "----------------------------------------");
$this->myLogger->logme('error', "========================================");
$this->myLogger->logme('error', "WIPE DEMO CLIENT FUNCTION COMPLETED");
$this->myLogger->logme('error', "Client ID: " . $client_id . " - Successfully processed");
$this->myLogger->logme('error', "========================================");
return $this->respond(['status' => true, 'message' => 'Demo client data wiped successfully'], 200);
}
}

View File

@ -425,6 +425,7 @@ class RestAuthenticationController extends AdminController
// print_r($employeeData); die;
unset($employeeData['employee_id']);
$employeeData['token_type'] = "pre";
$result = JWTToken::encode($employeeData);
if(isset($this->request->getJSON()->otp)){
@ -959,6 +960,7 @@ class RestAuthenticationController extends AdminController
}
unset($employeeData['employee_id']);
$employeeData['token_type'] = "pre";
$result = JWTToken::encode($employeeData);
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyMpin: Calling third-party API - verifyMpin to get the POST employee data");

View File

@ -1,48 +1,48 @@
<style>
.table th,
.table td {
padding: 8px;
}
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
table.dataTable thead th {
padding: 4px 4px !important;
}
table.dataTable thead th {
padding: 4px 4px !important;
}
.col-12{
.col-12{
max-width: 98% !important;
}
max-width: 98% !important;
}
.custom-dropdown-menu {
display: none;
position: absolute;
background-color: #ffffff !important;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.custom-dropdown-menu {
display: none;
position: absolute;
background-color: #ffffff !important;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
color: #212529 !important;
text-decoration: none !important;
background-color: transparent !important;
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
color: #212529 !important;
text-decoration: none !important;
background-color: transparent !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
</style>
<div class="row" id="client_list">
@ -71,33 +71,31 @@ table.dataTable thead th {
</thead>
<tbody>
<?php foreach($clientList as $row){ ?>
<tr >
<td class="client_info" data-id="<?php echo $row->id; ?>"><?php echo $row->client_name; ?> ( <?php echo $row->short_name; ?> ) </td>
<td>
<?php $account_managers = ''; ?>
<?php foreach ($client_rm as $client): ?>
<?php if ($client->client_id == $row->id): ?>
<?php $account_managers .= $client->account_manager . ', '; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php echo rtrim($account_managers, ', '); ?>
</td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="<?= base_url("client/list/"); ?><?= $row->id;?>"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<!-- <a class="dropdown-item" href="<?= base_url("client/deposit/{$row->id}"); ?>"><i class="mdi mdi-cash mr-2 text-muted font-18 vertical-middle"></i>CD Transactions</a> -->
<?php if(get_role_id() != 3 && get_role_id() != 4) { ?>
<a class="dropdown-item" data-id="<?= $row->id;?>" onclick="removeClient(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
<?php } ?>
<?php foreach($clientList as $row){ ?>
<tr >
<td class="client_info" data-id="<?php echo $row->id; ?>"><?php echo $row->client_name; ?> ( <?php echo $row->short_name; ?> ) </td>
<td>
<?php $account_managers = ''; ?>
<?php foreach ($client_rm as $client): ?>
<?php if ($client->client_id == $row->id): ?>
<?php $account_managers .= $client->account_manager . ', '; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php echo rtrim($account_managers, ', '); ?>
</td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="<?= base_url("client/list/"); ?><?= $row->id;?>"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<!-- <a class="dropdown-item" href="<?= base_url("client/deposit/{$row->id}"); ?>"><i class="mdi mdi-cash mr-2 text-muted font-18 vertical-middle"></i>CD Transactions</a> -->
<?php if(in_array(get_role_id(), [1, 5])) { ?>
<a class="dropdown-item" data-id="<?= $row->id;?>" onclick="removeClient(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
<?php } ?>
</div>
</div>
</div>
</td>
</tr>
</td>
</tr>
<?php } ?>
</tbody>
</table>
@ -107,7 +105,6 @@ table.dataTable thead th {
</div>
<!-- end row -->
<div id="append_client_info"></div>
@ -142,111 +139,302 @@ table.dataTable thead th {
</div><!-- /.modal -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
customDropdown.innerHTML = originalDropdown.innerHTML;
// Add 'Open Client Details' option in the dropdown
const clientId = row.querySelector('.client_info').dataset.id;
const openDetailsOption = document.createElement('a');
openDetailsOption.href = "javascript:void(0);";
openDetailsOption.className = 'dropdown-item';
openDetailsOption.innerHTML = `<i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>Open Client Details`;
openDetailsOption.addEventListener('click', function() {
openClientDetailsPage(clientId); // Open the client details page when clicked
});
customDropdown.appendChild(openDetailsOption);
// Create custom dropdown
function createCustomDropdown(row) {
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
customDropdown.innerHTML = originalDropdown.innerHTML;
// Add 'Open Client Details' option in the dropdown
const clientId = row.querySelector('.client_info').dataset.id;
const openDetailsOption = document.createElement('a');
openDetailsOption.href = "javascript:void(0);";
openDetailsOption.className = 'dropdown-item';
openDetailsOption.innerHTML = `<i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>Open Client Details`;
openDetailsOption.addEventListener('click', function() {
openClientDetailsPage(clientId); // Open the client details page when clicked
});
customDropdown.appendChild(openDetailsOption);
return customDropdown;
}
return customDropdown;
}
let activeDropdown = null;
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Show the action dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
const rect = event.target.getBoundingClientRect();
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // 5px gap
activeDropdown = customDropdown;
event.stopPropagation();
});
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
e.preventDefault();
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Show the action dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
const rect = event.target.getBoundingClientRect();
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // 5px gap
activeDropdown = customDropdown;
event.stopPropagation();
});
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
e.preventDefault();
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
// Open client details page
function openClientDetailsPage(clientId) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: "<?= base_url('util/get-client-details/') ?>" + clientId,
type: "GET",
dataType: 'json',
success: function(res) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$('#append_client_info').empty().append(res.data);
$('#client_info').show();
$('#client_list').hide();
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
}
});
</script>
<script>
$(document).ready(function(){
$('#lead_id').select2();
})
$(document).ready(function(){
$('#tickets-table').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-7 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
buttons: [{
extend: 'csv',
text: 'CSV',
title: 'ClientList',
className: 'my_class',
exportOptions: {
columns: ':not(:last-child)'
},
}],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true ,
// pagingType: 'full_numbers'
});
})
//DO NOT REMOVE THIS FUNCTION >>> THI FUNCTION FOR CLIENT SOFT DELETE
// function removeClient(element)
// {
// Swal.fire({
// title: "Are you sure?",
// text: "You need to remove this client.",
// icon: "info",
// showCancelButton: true,
// confirmButtonColor: "#3085d6",
// confirmButtonText: "Yes",
// }).then((result) => {
// if (result.isConfirmed) {
// $('.loader').fadeIn();
// $('.loader-mask').fadeIn();
// var id = element.getAttribute('data-id');
// var form_action = '<?= base_url("client/remove/") ?>' + id;
// $.ajax({
// url: form_action,
// type: "GET",
// dataType: 'json',
// processData: false,
// contentType: false,
// success: function(res) {
// $('.loader').fadeOut();
// $('.loader-mask').delay(350).fadeOut('slow');
// if(res){
// if (res.status == true) {
// toastr.success('Client removed successfully.', 'success');
// location.reload();
// } else {
// Swal.fire({
// title: "warning!",
// text: res.message,
// icon: "warning"
// });
// // toastr.warning(res.message, 'warning');
// }
// }
// },
// error: function (xhr, status, error) {
// console.error(xhr.responseText);
// console.error(status, error);
// $('.loader').fadeOut();
// $('.loader-mask').delay(350).fadeOut('slow');
// console.log('Something Wrong!', 'warning');
// }
// });
// }
// });
// }
function removeClient(element) {
console.log("Remove client function called")
console.log('element', element);
Swal.fire({
title: "Are you sure?",
html: `Is this a Demo Client?, Please reconfirm by clicking Yes to delete. <br> <span style = "color : red; font-size : 14px;">Note : This data will be deleted permanently and cannot be recovered.</span>`,
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
console.log('Print the result : ', result)
if (result.isConfirmed) {
console.log('Click Yes : ', result.isConfirmed);
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var id = element.getAttribute('data-id');
console.log('client_id', id);
var form_action = '<?= base_url("/client/wipe") ?>';
console.log('URL : ', form_action);
$.ajax({
url: form_action,
type: "POST",
data: {client_id : id},
dataType: 'json',
success: function(res) {
console.log('Client remove function response : ', res);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (res.status == true) {
toastr.success(res.message, 'success');
location.reload();
} else {
Swal.fire({
title: "warning!",
text: res.message,
icon: "warning"
});
// toastr.warning(res.message, 'warning');
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
}
});
}
});
}
$(document).on('click', '.client_info', function() {
// Open client details page
function openClientDetailsPage(clientId) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var client_id = $(this).data('id')
$('#append_client_info').empty();
console.log(client_id);
console.log('client_info');
$('#client_info').show();
$('#client_list').hide();
$.ajax({
url: "<?= base_url('util/get-client-details/') ?>" + clientId,
url: "<?= base_url('util/get-client-details/') ?>" + client_id,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$('#append_client_info').empty().append(res.data);
$('#client_info').show();
$('#client_list').hide();
console.log(res);
console.log(res.data.length);
$('#append_client_info').append(res.data);
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
@ -255,189 +443,59 @@ table.dataTable thead th {
$('.loader-mask').delay(350).fadeOut('slow');
}
});
});
$(document).on('click', '.client_info_close', function() {
console.log('client_info_close');
$('#client_info').hide();
$('#client_list').show();
});
function showModal(){
var myModal = new bootstrap.Modal(document.getElementById('lead_modal'));
myModal.show();
}
});
</script>
function featchClient(){
<script>
let lead_id = $('#lead_id').val();
console.log('lead_id : ', lead_id)
let url = '<?= base_url('leads/featchLeadDataAndInsertClient/') ?>' + lead_id
$(document).ready(function(){
$('#lead_id').select2();
})
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$(document).ready(function()
{
$('#tickets-table').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-7 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
buttons: [{
extend: 'csv',
text: 'CSV',
title: 'ClientList',
className: 'my_class',
exportOptions: {
columns: ':not(:last-child)'
},
}],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true ,
// pagingType: 'full_numbers'
});
})
$.ajax({
url: url,
type: "GET",
dataType: 'json',
success: function (res) {
console.log(res);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
function removeClient(element)
{
Swal.fire({
title: "Are you sure?",
text: "You need to remove this client.",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
if (result.isConfirmed) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("client/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if(res){
if (res.status == true) {
toastr.success('Client removed successfully.', 'success');
location.reload();
} else {
Swal.fire({
title: "warning!",
text: res.message,
icon: "warning"
});
// toastr.warning(res.message, 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
if(res.status == true){
let client_url = '<?= base_url('client/list/') ?>' + res.client_id + '?client_policy_id=' + res.client_policy_id+'#police-tab';
toastr.success(res.message, 'SUCCESS')
window.location.href = client_url
}else{
toastr.success(res.message, 'WARNING')
}
});
}
});
$('.close').click()
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$('.close').click()
}
$(document).on('click', '.client_info', function() {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var client_id = $(this).data('id')
$('#append_client_info').empty();
console.log(client_id);
console.log('client_info');
$('#client_info').show();
$('#client_list').hide();
$.ajax({
url: "<?= base_url('util/get-client-details/') ?>" + client_id,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log(res);
console.log(res.data.length);
$('#append_client_info').append(res.data);
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
});
$(document).on('click', '.client_info_close', function() {
console.log('client_info_close');
$('#client_info').hide();
$('#client_list').show();
});
function showModal(){
var myModal = new bootstrap.Modal(document.getElementById('lead_modal'));
myModal.show();
}
function featchClient(){
let lead_id = $('#lead_id').val();
console.log('lead_id : ', lead_id)
let url = '<?= base_url('leads/featchLeadDataAndInsertClient/') ?>' + lead_id
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: url,
type: "GET",
dataType: 'json',
success: function (res) {
console.log(res);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if(res.status == true){
let client_url = '<?= base_url('client/list/') ?>' + res.client_id + '?client_policy_id=' + res.client_policy_id+'#police-tab';
toastr.success(res.message, 'SUCCESS')
window.location.href = client_url
}else{
toastr.success(res.message, 'WARNING')
}
$('.close').click()
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$('.close').click()
}
});
}
}
});
}
</script>