Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
68c4c38b02
@ -801,6 +801,8 @@ class ClientController extends AdminController
|
|||||||
$editData['api_data'] = $this->clientApi->where("client_id", $id)->where("is_active", 1)->first();
|
$editData['api_data'] = $this->clientApi->where("client_id", $id)->where("is_active", 1)->first();
|
||||||
// dd($editData);
|
// dd($editData);
|
||||||
|
|
||||||
|
$edit['pre_branch_id'] = $this->clientBranchModel->select('pre_branch_id')->where('client_id',$id)->get()->getResultArray()[0]['pre_branch_id']??"";
|
||||||
|
|
||||||
$editData['auto_fetch_client_list'] = $this->getClientListFromPre();
|
$editData['auto_fetch_client_list'] = $this->getClientListFromPre();
|
||||||
|
|
||||||
|
|
||||||
@ -6857,7 +6859,15 @@ class ClientController extends AdminController
|
|||||||
return $combinedHrAccessData;
|
return $combinedHrAccessData;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pre_client_data = $db2->table('clients')->where('is_active', 1)->where('short_name', $post_client_data['short_name'])->get()->getRowArray();
|
$post_branch = $this->clientBranchModel->select('pre_branch_id')->where('client_id',$client_id)->get()->getResultArray()[0]??[];
|
||||||
|
|
||||||
|
$pre_client_data = $db2->table('client_branch cb')
|
||||||
|
->join('clients c', "c.id = cb.client_id")
|
||||||
|
->where('c.is_active',1)
|
||||||
|
->where('cb.is_active', 1)
|
||||||
|
->where('cb.id', $post_branch['pre_branch_id']??'')
|
||||||
|
->get()->getRowArray();
|
||||||
|
|
||||||
|
|
||||||
if (empty($pre_client_data)) {
|
if (empty($pre_client_data)) {
|
||||||
|
|
||||||
@ -7093,11 +7103,16 @@ class ClientController extends AdminController
|
|||||||
$post = array_values(array_filter($allowed_modules, fn($v) => $v !== 1));
|
$post = array_values(array_filter($allowed_modules, fn($v) => $v !== 1));
|
||||||
$value['allowed_modules'] = json_encode(['pre' => $pre, 'post' => $post]);
|
$value['allowed_modules'] = json_encode(['pre' => $pre, 'post' => $post]);
|
||||||
|
|
||||||
|
$post_client_id = $value['post_client_id'];
|
||||||
|
$post_branch_id = $value['post_branch_id'];
|
||||||
|
$post_hr_id = $value['post_hr_id'];
|
||||||
|
|
||||||
|
$value['pre_client_id'] = $this->getPreClientId($post_branch_id);
|
||||||
|
$value['pre_branch_id'] = $this->getPreBranchId($post_branch_id);
|
||||||
|
$value["pre_hr_id"] = $this->getPreHrId($post_branch_id);
|
||||||
|
|
||||||
// INSERT or UPDATE
|
// INSERT or UPDATE
|
||||||
if (empty($value['pk']) || (int)$value['pk'] === 0) {
|
if (empty($value['pk']) || (int)$value['pk'] === 0) {
|
||||||
print_rr("inside insert block");
|
|
||||||
print_rr($value);die;
|
|
||||||
|
|
||||||
|
|
||||||
unset($value['pk']); // Prevent insert error
|
unset($value['pk']); // Prevent insert error
|
||||||
$insertedId = $this->HRAccessControlModel->insert($value);
|
$insertedId = $this->HRAccessControlModel->insert($value);
|
||||||
@ -7107,8 +7122,6 @@ class ClientController extends AdminController
|
|||||||
$success[] = "Inserted row at index {$index} with ID {$insertedId}.";
|
$success[] = "Inserted row at index {$index} with ID {$insertedId}.";
|
||||||
} else {
|
} else {
|
||||||
$update = $this->HRAccessControlModel->update($value['pk'], $value);
|
$update = $this->HRAccessControlModel->update($value['pk'], $value);
|
||||||
print_rr("inside update block");
|
|
||||||
print_rr($value);die;
|
|
||||||
|
|
||||||
if ($update === false) {
|
if ($update === false) {
|
||||||
throw new \Exception('Update failed for ID ' . $value['pk'] . ': ' . json_encode($this->HRAccessControlModel->errors()));
|
throw new \Exception('Update failed for ID ' . $value['pk'] . ': ' . json_encode($this->HRAccessControlModel->errors()));
|
||||||
@ -7163,6 +7176,26 @@ class ClientController extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getPreClientId($post_branch_id){
|
||||||
|
$db2 = \Config\Database::connect('preDB');
|
||||||
|
$pre_client_id = $db2->table('client_branch')->where('post_branch_id',$post_branch_id)->where('is_Active',1)->get()->getResultArray()[0]['client_id']??[];
|
||||||
|
return $pre_client_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getPreBranchId($post_branch_id){
|
||||||
|
$db2 = \Config\Database::connect('preDB');
|
||||||
|
$pre_branch_id = $db2->table('client_branch')->where('post_branch_id',$post_branch_id)->where('is_Active',1)->get()->getResultArray()[0]['id']??[];
|
||||||
|
return $pre_branch_id;
|
||||||
|
}
|
||||||
|
private function getPreHrId($post_branch_id){
|
||||||
|
$db2 = \Config\Database::connect('preDB');
|
||||||
|
$pre_hr_id = $db2->table('client_branch cb')
|
||||||
|
->select('lc.id')
|
||||||
|
->join('level_contacts lc','lc.ref_id = cb.id')
|
||||||
|
->where('post_branch_id',$post_branch_id)->where('is_Active',1)->get()->getResultArray()[0]['id']??[];
|
||||||
|
return $pre_hr_id;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------- DEMO CLIENT FUNCTION --------------------------------------------------------------------------------
|
// ------------------- DEMO CLIENT FUNCTION --------------------------------------------------------------------------------
|
||||||
|
|
||||||
public function wipeDemoClient()
|
public function wipeDemoClient()
|
||||||
|
|||||||
@ -533,14 +533,14 @@ class RestAuthenticationController extends AdminController
|
|||||||
log_message('error', ' ');
|
log_message('error', ' ');
|
||||||
log_message('error', '************************ POST END ********************************');
|
log_message('error', '************************ POST END ********************************');
|
||||||
log_message('error', ' ');
|
log_message('error', ' ');
|
||||||
return $this->respond(['status' => 'failed','code' => 404,'data' => "", 'message' => 'No data found'],200);
|
return $this->respond(['status' => 'failed','code' => 404,'data' => "", 'message' => 'Invalid OTP'],200);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - getVerifiedUserData: Exception: " . $e->getMessage() . " --- Line: " . $e->getLine() . " --- Trace: " . $e->getTraceAsString());
|
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - getVerifiedUserData: Exception: " . $e->getMessage() . " --- Line: " . $e->getLine() . " --- Trace: " . $e->getTraceAsString());
|
||||||
log_message('error', ' ');
|
log_message('error', ' ');
|
||||||
log_message('error', ' ************************************* POST END **************************************** ');
|
log_message('error', ' ************************************* POST END **************************************** ');
|
||||||
log_message('error', ' ');
|
log_message('error', ' ');
|
||||||
return $this->respond(['status' => 'failed','code' => 500,'data' => "", 'message' => $e->getMessage()],500);
|
return $this->respond(['status' => 'failed','code' => 500,'data' => "", 'message' => "Invalid OTP", 'error' => $e->getMessage()],500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -627,17 +627,24 @@ class UserController extends AdminController
|
|||||||
if (!$staff) {
|
if (!$staff) {
|
||||||
return $this->response->setJSON(['status' => 'error','message' => 'Staff not found'])->setStatusCode(404);
|
return $this->response->setJSON(['status' => 'error','message' => 'Staff not found'])->setStatusCode(404);
|
||||||
}
|
}
|
||||||
|
$role = $staff['role_id'];
|
||||||
|
$text = $role == 1 ? "Manager" : "Staff";
|
||||||
|
|
||||||
if ($staff['is_active'] == 1) {
|
if ($staff['is_active'] == 1) {
|
||||||
|
if($role == 1){ // manager
|
||||||
|
$result = $this->partnerStaffModel->updateByKey($id);
|
||||||
|
$message = $result;
|
||||||
|
}else{ // staff
|
||||||
$result = $this->partnerStaffModel->update($id, ['is_active' => 0]);
|
$result = $this->partnerStaffModel->update($id, ['is_active' => 0]);
|
||||||
$message = "Staff deleted successfully";
|
$message = $text." deleted successfully";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return $this->response->setJSON(['status' => 'error','message' => 'Staff already deleted'])->setStatusCode(400);
|
return $this->response->setJSON(['status' => 'error','message' => $text.' already deleted'])->setStatusCode(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->response->setJSON([
|
return $this->response->setJSON([
|
||||||
'status' => $result ? 'success' : 'error',
|
'status' => $result ? 'success' : 'error',
|
||||||
'message' => $result ? $message : "Unable to delete staff. Please try again.",
|
'message' => $result ? $message : "Unable to delete ".$text.". Please try again.",
|
||||||
'id' => $id
|
'id' => $id
|
||||||
])->setStatusCode($result ? 200 : 400);
|
])->setStatusCode($result ? 200 : 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,4 +47,55 @@ class PartnerStaffModel extends Model
|
|||||||
// ];
|
// ];
|
||||||
|
|
||||||
// protected $skipValidation = false;
|
// protected $skipValidation = false;
|
||||||
|
public function updateByKey($key)
|
||||||
|
{
|
||||||
|
$db = \Config\Database::connect();
|
||||||
|
$message = "";
|
||||||
|
|
||||||
|
// Start transaction
|
||||||
|
$db->transStart();
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 1. Update manager
|
||||||
|
$db->table('partner_staff')
|
||||||
|
->where('id', $key)
|
||||||
|
->set('is_active', 0)
|
||||||
|
->update();
|
||||||
|
$managerRows = $db->affectedRows();
|
||||||
|
$message = "{$managerRows} manager(s), ";
|
||||||
|
|
||||||
|
// 2. Update agents under manager
|
||||||
|
$db->table('partner_agent')
|
||||||
|
->where('manager_id', $key)
|
||||||
|
->set('is_active', 0)
|
||||||
|
->update();
|
||||||
|
$agentRows = $db->affectedRows();
|
||||||
|
$message .= "{$agentRows} agent(s), ";
|
||||||
|
|
||||||
|
// 3. Update staff under manager
|
||||||
|
$db->table('partner_staff')
|
||||||
|
->where('manager_id', $key)
|
||||||
|
->set('is_active', 0)
|
||||||
|
->update();
|
||||||
|
$staffRows = $db->affectedRows();
|
||||||
|
$message .= "{$staffRows} staff(s)";
|
||||||
|
|
||||||
|
// Complete transaction
|
||||||
|
$db->transComplete();
|
||||||
|
|
||||||
|
// Check transaction status
|
||||||
|
if ($db->transStatus() === false) {
|
||||||
|
return "Transaction failed. No updates were applied.";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $message . " are deleted successfully";
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Rollback in case of exception
|
||||||
|
$db->transRollback();
|
||||||
|
return "Error: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,10 +37,10 @@ table.dataTable tbody td {
|
|||||||
</style> -->
|
</style> -->
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
body {
|
/* body {
|
||||||
font-family: Arial, sans-serif;
|
font-family: Arial, sans-serif;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
} */
|
||||||
|
|
||||||
#mobile::placeholder,
|
#mobile::placeholder,
|
||||||
#mobile_no::placeholder {
|
#mobile_no::placeholder {
|
||||||
@ -353,8 +353,7 @@ table.dataTable tbody td {
|
|||||||
<h4 style="position: relative;">Users</h4>
|
<h4 style="position: relative;">Users</h4>
|
||||||
</div>
|
</div>
|
||||||
</div> -->
|
</div> -->
|
||||||
<table data-custom-table-css="table" class="table table-sm table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="1" id="user-table">
|
<table data-custom-table-css="table" class="table table-sm m-0 table-centered dt-responsive nowrap w-100" cellspacing="a" id="user-table">
|
||||||
|
|
||||||
<thead class="bg-light">
|
<thead class="bg-light">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="font-weight-medium">Name</th>
|
<th class="font-weight-medium">Name</th>
|
||||||
@ -874,13 +873,19 @@ table.dataTable tbody td {
|
|||||||
{
|
{
|
||||||
extend: 'csv',
|
extend: 'csv',
|
||||||
text: '<i class="mdi mdi-file-delimited"></i><span class="btn-custom"> CSV </span>',
|
text: '<i class="mdi mdi-file-delimited"></i><span class="btn-custom"> CSV </span>',
|
||||||
className: 'app-btn-primary'
|
className: 'app-btn-primary',
|
||||||
|
exportOptions: {
|
||||||
|
columns: ':not(:last-child)'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
extend: 'excel',
|
extend: 'excel',
|
||||||
text: '<i class="mdi mdi-file-excel"></i><span class="btn-custom"> EXCEL </span>',
|
text: '<i class="mdi mdi-file-excel"></i><span class="btn-custom"> EXCEL </span>',
|
||||||
exportOptions: { orthogonal: 'sort' },
|
exportOptions: { orthogonal: 'sort' },
|
||||||
className: 'app-btn-primary'
|
className: 'app-btn-primary',
|
||||||
|
exportOptions: {
|
||||||
|
columns: ':not(:last-child)'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -1027,9 +1032,17 @@ table.dataTable tbody td {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.btnPartnerDelete', function () {
|
$('body').on('click', '.btnPartnerDelete', function () {
|
||||||
|
var partner_role = $(this).attr('data-role');
|
||||||
|
var alertText = "You need to remove this user";
|
||||||
|
if (partner_role == 2) {
|
||||||
|
alertText = "You need to remove this Staff";
|
||||||
|
} else if (partner_role == 1) {
|
||||||
|
alertText = "You need to remove this Manager and related agent and staff are also delete";
|
||||||
|
}
|
||||||
|
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: "Are you sure?",
|
title: "Are you sure?",
|
||||||
text: "You need to remove this user",
|
text: alertText,
|
||||||
icon: "info",
|
icon: "info",
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonColor: "#3085d6",
|
confirmButtonColor: "#3085d6",
|
||||||
@ -1165,6 +1178,9 @@ table.dataTable tbody td {
|
|||||||
complete: function() {
|
complete: function() {
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
btn.innerText = "Submit";
|
btn.innerText = "Submit";
|
||||||
|
$('#nhance-partner-modal').removeClass('show').hide();
|
||||||
|
$('.modal-backdrop').remove();
|
||||||
|
loadPartner();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1263,7 +1279,7 @@ table.dataTable tbody td {
|
|||||||
row.name,
|
row.name,
|
||||||
row.email,
|
row.email,
|
||||||
row.mobile,
|
row.mobile,
|
||||||
'Staff',
|
row.role_id == 1 ? "Manager" : "Staff",
|
||||||
`<span class="badge ${statusClass}">${statusText}</span>`,
|
`<span class="badge ${statusClass}">${statusText}</span>`,
|
||||||
`<div class="btn-group dropdown">
|
`<div class="btn-group dropdown">
|
||||||
<a href="javascript:void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown">
|
<a href="javascript:void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown">
|
||||||
@ -1273,8 +1289,8 @@ table.dataTable tbody td {
|
|||||||
<a data-toggle="modal" data-target="#nhance-partner-modal" class="dropdown-item btnPartnerEdit" data-obj='${JSON.stringify(row)}'>
|
<a data-toggle="modal" data-target="#nhance-partner-modal" class="dropdown-item btnPartnerEdit" data-obj='${JSON.stringify(row)}'>
|
||||||
<i data-obj='${JSON.stringify(row)}' class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle btnPartnerEdit"></i>Edit
|
<i data-obj='${JSON.stringify(row)}' class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle btnPartnerEdit"></i>Edit
|
||||||
</a>
|
</a>
|
||||||
<a class="dropdown-item btnPartnerDelete" data-id="${row.id}">
|
<a class="dropdown-item btnPartnerDelete" data-id="${row.id}" data-role="${row.role_id}">
|
||||||
<i data-id="${row.id}" class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle btnPartnerDelete"></i>Delete
|
<i data-id="${row.id}" data-role="${row.role_id}" class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle btnPartnerDelete"></i>Delete
|
||||||
</a>
|
</a>
|
||||||
<a class="dropdown-item btnPartnerPerformance" data-id="${row.id}">
|
<a class="dropdown-item btnPartnerPerformance" data-id="${row.id}">
|
||||||
<i data-id="${row.id}" class="mdi mdi-speedometer mr-2 text-muted font-18 vertical-middle btnPartnerPerformance"></i>View Performance
|
<i data-id="${row.id}" class="mdi mdi-speedometer mr-2 text-muted font-18 vertical-middle btnPartnerPerformance"></i>View Performance
|
||||||
@ -1699,10 +1715,11 @@ table.dataTable tbody td {
|
|||||||
});
|
});
|
||||||
$(document).on('click', '#btnNhancePartnerAdd', function(){
|
$(document).on('click', '#btnNhancePartnerAdd', function(){
|
||||||
$('#partner_name').val('');
|
$('#partner_name').val('');
|
||||||
$('#email').val('');
|
$('#email_addr').val('');
|
||||||
$('#partner_id').val('');
|
$('#partner_id').val('');
|
||||||
$('#mobile_no').val('');
|
$('#mobile_no').val('');
|
||||||
$('#locn').val('');
|
$('#locn').val('');
|
||||||
|
$('.modal-title').html('Add Nhance Partner');
|
||||||
$('#PartnerForm').attr('action', '<?php echo base_url('/user/partner');?>');
|
$('#PartnerForm').attr('action', '<?php echo base_url('/user/partner');?>');
|
||||||
let myModal = new bootstrap.Modal(document.getElementById('nhance-partner-modal'));
|
let myModal = new bootstrap.Modal(document.getElementById('nhance-partner-modal'));
|
||||||
myModal.show(); // open modal
|
myModal.show(); // open modal
|
||||||
|
|||||||
@ -546,6 +546,7 @@ $('body').on('click', '.btnBranchEdit', function() {
|
|||||||
$('#district').val(res.data.district);
|
$('#district').val(res.data.district);
|
||||||
$('#branch_city').val(res.data.city);
|
$('#branch_city').val(res.data.city);
|
||||||
$('#branch_PrimaryKey').val(res.data.id);
|
$('#branch_PrimaryKey').val(res.data.id);
|
||||||
|
$('#pre_branch_id').val(res.data.pre_branch_id)
|
||||||
|
|
||||||
if(res.data.sez == 1){
|
if(res.data.sez == 1){
|
||||||
$('#sez').prop('checked', true);
|
$('#sez').prop('checked', true);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user