Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
8a20073515
@ -90,11 +90,13 @@ $routes->group("/dashboard", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->group("/client", ["filter" => "authMVC"], function ($routes) {
|
||||
|
||||
$routes->get("list", "ClientController::index");
|
||||
$routes->get("type/(:any)", "ClientController::type/$1");
|
||||
$routes->get("create", "ClientController::clientOnboarding");
|
||||
$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');
|
||||
$routes->get("typeList/(:any)", "ClientController::typeList/$1");
|
||||
|
||||
// application/config/routes.php
|
||||
|
||||
|
||||
@ -471,7 +471,7 @@ class ClientController extends AdminController
|
||||
$this->myLogger->logme('error', 'Client list function called');
|
||||
$headerData['tab_name'] = 'Client List';
|
||||
$headerData['page_name'] = 'Clients'; // Both Browser Tab name And Page name are same.
|
||||
$data['clientList'] = $this->clientModel->getCreatedByUserName();
|
||||
$data['clientList'] = $this->clientModel->getCreatedByUserName(1); // passing client_type
|
||||
$data['client_rm'] = $this->clientRMModel->getAllClientRM();
|
||||
$data['lead_data'] = $this->leadsModel->getLeadForInsertClientList();
|
||||
|
||||
@ -484,6 +484,29 @@ class ClientController extends AdminController
|
||||
// $this->loadLayout('client_onboarding', $data);
|
||||
}
|
||||
|
||||
|
||||
public function typeList($id = null)
|
||||
{
|
||||
try {
|
||||
$data = $this->clientModel->getCreatedByUserName($id); // passing client_type
|
||||
if (empty($data)) {
|
||||
return $this->response
|
||||
->setJSON(['status' => 'error', 'message' => 'No Records found'])
|
||||
->setStatusCode(404);
|
||||
}
|
||||
|
||||
return $this->response
|
||||
->setJSON(['status' => 'success', 'data' => $data])
|
||||
->setStatusCode(200);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
return $this->response
|
||||
->setJSON(['status' => 'error', 'message' => $e->getMessage()])
|
||||
->setStatusCode(500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function updateEmpAndPolicyStatus()
|
||||
{
|
||||
|
||||
|
||||
@ -108,7 +108,7 @@ class ClientModel extends Model
|
||||
}
|
||||
|
||||
|
||||
public function getCreatedByUserName(){
|
||||
public function getCreatedByUserName($client_type = null){
|
||||
|
||||
$role_id = get_role_id();
|
||||
$user_id = get_session_userid();
|
||||
@ -118,6 +118,10 @@ class ClientModel extends Model
|
||||
->join('client_rm', 'client_rm.client_id = clients.id','left')
|
||||
->where('clients.is_active', 1);
|
||||
|
||||
if (!empty($client_type)) {
|
||||
$query->where('clients.client_type', $client_type);
|
||||
}
|
||||
|
||||
if (in_array($role_id, [2, 3])) {
|
||||
|
||||
// If the user is a Account Manager or Manager, filter by user_id
|
||||
|
||||
@ -294,10 +294,10 @@ table.dataTable thead th {
|
||||
$(document).ready(function(){
|
||||
$('#lead_id').select2();
|
||||
})
|
||||
|
||||
var table;
|
||||
$(document).ready(function()
|
||||
{
|
||||
$('#tickets-table').DataTable({
|
||||
table = $('#tickets-table').DataTable({
|
||||
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
||||
@ -340,13 +340,108 @@ $(document).ready(function()
|
||||
_INPUT_
|
||||
<i class="mdi mdi-magnify datatable-search-icon"></i>
|
||||
</div>`,
|
||||
searchPlaceholder: "Search"
|
||||
searchPlaceholder: "Search",
|
||||
emptyTable: '<div class="text-center text-muted">No Data found</div>'
|
||||
},
|
||||
paging: true ,
|
||||
// pagingType: 'full_numbers'
|
||||
});
|
||||
|
||||
// $(".datatable-buttons").prepend(`
|
||||
// <label class="switch">
|
||||
// <input type="checkbox" id="toggleButtons">
|
||||
// <span">Group</span>
|
||||
// </label>
|
||||
// `);
|
||||
|
||||
$(".datatable-buttons").prepend(`
|
||||
<span id="statusSwitchWrapper" class="dt-switch-wrapper">
|
||||
<span class="custom-switch" style="text-align: left;">
|
||||
<input type="checkbox" class="custom-control-input" id="toggleButtons">
|
||||
<label class="custom-control-label" for="toggleButtons" style="vertical-align: middle !important;">Group Client</label>
|
||||
</span>
|
||||
</span>
|
||||
`);
|
||||
$("#toggleButtons").prop("checked", true); // default checked.
|
||||
$('#toggleButtons').on('change', function() {
|
||||
if ($(this).is(':checked')) {
|
||||
console.log("Checked na gro");
|
||||
loadTableData(1);
|
||||
} else {
|
||||
console.log("UnChecked na indi");
|
||||
loadTableData(2);
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
function loadTableData(type) {
|
||||
let url = '<?= base_url('client/typeList/') ?>' + type
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: 'GET',
|
||||
success: function(response) {
|
||||
if (response.status === "success" && Array.isArray(response.data)) {
|
||||
renderRows(response.data);
|
||||
} else {
|
||||
renderRows([]);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error("Error loading :", error);
|
||||
renderRows([]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderRows(data) {
|
||||
table.clear();
|
||||
if (Array.isArray(data) && data.length) {
|
||||
data.forEach((row, index) => {
|
||||
let clientrm = <?= json_encode($client_rm) ?>;
|
||||
let account_managers = "";
|
||||
|
||||
clientrm.forEach(client => {
|
||||
if (client.client_id == row.id) {
|
||||
account_managers += client.account_manager + ", ";
|
||||
}
|
||||
});
|
||||
account_managers = account_managers.replace(/,\s*$/, "");
|
||||
if (account_managers === "") account_managers = "N/A";
|
||||
|
||||
let rowData = [
|
||||
index + 1,
|
||||
`<span class="client_info" data-id="${row.id}">${row.client_name} (${row.short_name})</span>`,
|
||||
account_managers,
|
||||
`<div class="btn-group dropdown">
|
||||
<a href="javascript:void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown">
|
||||
<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>`
|
||||
];
|
||||
|
||||
let newRow = table.row.add(rowData);
|
||||
$(newRow.node()).find('td:eq(0)').addClass('text-center');
|
||||
$(newRow.node()).find('td:eq(1)').addClass('client_info').attr('data-id', row.id);
|
||||
|
||||
});
|
||||
}
|
||||
table.draw();
|
||||
}
|
||||
|
||||
//DO NOT REMOVE THIS FUNCTION >>> THI FUNCTION FOR CLIENT SOFT DELETE
|
||||
// function removeClient(element)
|
||||
// {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user