FIX_CLAIMS_TAT,FEAT_DASHBOARD_USERROLE_BASED
This commit is contained in:
parent
c40e5bbc64
commit
25e7296e85
@ -376,7 +376,7 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
|
||||
});
|
||||
|
||||
$routes->group("report", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("list", "PolicyTransactionController::reportBDS");
|
||||
$routes->match(['get', 'post'],"list", "PolicyTransactionController::reportBDS");
|
||||
$routes->get("report-varience-list", "PolicyTransactionController::reportVarience");
|
||||
$routes->get("report-business-list", "PolicyTransactionController::reportBusinessList");
|
||||
$routes->get("report-finance-list", "PolicyTransactionController::reportFinanceList");
|
||||
|
||||
@ -244,10 +244,20 @@ class DashboardController extends AdminController
|
||||
$data['policyStatus'] = $this->policyStatus;
|
||||
$data['colorShades'] = $this->colorShades;
|
||||
}
|
||||
if ((get_role_id() == STAFF_ROLE_ID && in_array(CLAIMS_TEAM_ID,user_team())) || in_array(get_role_id(),[1,5])){
|
||||
$data['claim_data'] = $this->getClaimData();
|
||||
$data['colorShades'] = $this->colorShades;
|
||||
|
||||
$data['claim_data'] = $this->getClaimData();
|
||||
$data['lead_data'] = $this->getLeadData();
|
||||
}
|
||||
if ((get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_team())) || in_array(get_role_id(),[1,5])){
|
||||
$data['lead_data'] = $this->leadModel->getDashData();
|
||||
$data['bds_renewal'] = $this->policyTransactionModel->getBDSRenewalData();
|
||||
$data['colorShades'] = $this->colorShades;
|
||||
|
||||
}
|
||||
|
||||
// dd(get_role_id(),user_team());
|
||||
|
||||
$data['page_name'] = 'Dashboard';
|
||||
|
||||
echo view('layout/header', $data);
|
||||
@ -255,9 +265,6 @@ class DashboardController extends AdminController
|
||||
echo view('layout/footer');
|
||||
}
|
||||
|
||||
public function getLeadData(){
|
||||
|
||||
}
|
||||
|
||||
public function getClaimData()
|
||||
{
|
||||
@ -281,7 +288,6 @@ class DashboardController extends AdminController
|
||||
$claim_status[$typeId] = [];
|
||||
}
|
||||
|
||||
// Use associative array keys to mimic a set
|
||||
$claim_status[$typeId][$status] = true;
|
||||
}
|
||||
|
||||
@ -291,15 +297,8 @@ class DashboardController extends AdminController
|
||||
}
|
||||
$data = $this->ticketModel->getDashData($claim_status, $this->claimDashLimit);
|
||||
|
||||
// dd($data);
|
||||
// foreach ($data as $dat){
|
||||
// foreach ($dat as $key => $value){
|
||||
// echo($key . " => ". $value);
|
||||
// }
|
||||
// }
|
||||
// die();
|
||||
return $data;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
@ -765,8 +764,9 @@ class DashboardController extends AdminController
|
||||
return $groupedData;
|
||||
}
|
||||
|
||||
public function prepareClaimSearchData(){
|
||||
|
||||
public function prepareClaimSearchData()
|
||||
{
|
||||
|
||||
$received_data = $this->request->getPost();
|
||||
$ticketTypeId = $received_data['ticketTypeId'];
|
||||
$status = $received_data['status'];
|
||||
@ -780,6 +780,6 @@ class DashboardController extends AdminController
|
||||
->where("tcs.claim_status", $status)
|
||||
->first();
|
||||
$data['ticket_type_id'] = $ticketTypeId;
|
||||
return $this->respond(['status' => "success","data" => $data],200);
|
||||
return $this->respond(['status' => "success", "data" => $data], 200);
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,19 +146,36 @@ class LeadsController extends BaseController
|
||||
$this->loadLayout('lead_filter', $data);
|
||||
} else {
|
||||
|
||||
$search_data = $this->request->getPost();
|
||||
// print_r($search_data);
|
||||
$isFromDashboard = $this->request->getPost("is_dashboard");
|
||||
|
||||
$where = [];
|
||||
foreach ($search_data as $search_objects => $key) {
|
||||
if ($key != null && $key != '' && $key != 0) {
|
||||
$where[$search_objects] = $key;
|
||||
if (isset($isFromDashboard) && !empty($isFromDashboard) && $isFromDashboard == 1) {
|
||||
$ids = $this->request->getPost('ids');
|
||||
$ids = array_filter(explode(',', $ids));
|
||||
|
||||
if (!empty($ids)) {
|
||||
$idsStr = implode(',', array_map('intval', $ids)); // sanitize IDs to be integers
|
||||
$where = "leads.id IN ($idsStr)";
|
||||
} else {
|
||||
$where = '1 = 0'; // No valid IDs, return empty result
|
||||
}
|
||||
}
|
||||
// dd($where );
|
||||
$data['lead_data_list'] = $this->leadsModel->getLeadDataForLising($where);
|
||||
$this->loadLayout('lead_filter', $data);
|
||||
} else {
|
||||
$search_data = $this->request->getPost();
|
||||
|
||||
$data['lead_data_list'] = $this->leadsModel->getLeadDataForLising($where);
|
||||
$html = view('leads_list', $data);
|
||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||
$where = [];
|
||||
foreach ($search_data as $search_objects => $key) {
|
||||
if ($key != null && $key != '' && $key != 0 && $search_objects != 'is_dashboard') {
|
||||
$where[$search_objects] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
$data['lead_data_list'] = $this->leadsModel->getLeadDataForLising($where);
|
||||
|
||||
$html = view('leads_list', $data);
|
||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -602,7 +619,7 @@ class LeadsController extends BaseController
|
||||
return $this->respond(['status' => false, 'message' => 'File could not be removed.'], 200);
|
||||
}
|
||||
}
|
||||
//--------RFQ-----------------------------------------------------------------------------------------------
|
||||
//--------RFQ-----------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
public function viewRFQ($id, $type = 1)
|
||||
@ -678,11 +695,10 @@ class LeadsController extends BaseController
|
||||
|
||||
";
|
||||
|
||||
if ($data['lead_data']['policy_end_date'] != null){
|
||||
if ($data['lead_data']['policy_end_date'] != null) {
|
||||
$subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}} {{POLICY_END_DATE}}";
|
||||
}else{
|
||||
} else {
|
||||
$subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}}";
|
||||
|
||||
}
|
||||
|
||||
$data['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $data['page_name']);
|
||||
@ -690,7 +706,7 @@ class LeadsController extends BaseController
|
||||
|
||||
$data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->where('is_active', 1)->findAll() ?? null;
|
||||
$data['attachment_html'] = view('rfq/attachment_files', $data) ?? "";
|
||||
$data['user_team'] = $this->userModel->select("ut.team_id")->join("user_teams ut","ut.user_id = user_profiles.id and ut.is_active = 1")->where("user_profiles.is_active",1)->first()['team_id'];
|
||||
$data['user_team'] = $this->userModel->select("ut.team_id")->join("user_teams ut", "ut.user_id = user_profiles.id and ut.is_active = 1")->where("user_profiles.is_active", 1)->first()['team_id'];
|
||||
// dd($data);
|
||||
|
||||
if ($data['lead_data']['lead_form_type'] == 1) {
|
||||
@ -866,7 +882,7 @@ class LeadsController extends BaseController
|
||||
if ($subKey !== 'Quote Asked' && isset($subVal['Total'])) {
|
||||
$proposals[$key] = $value;
|
||||
break;
|
||||
}else{
|
||||
} else {
|
||||
$proposals[$key] = $value;
|
||||
}
|
||||
}
|
||||
@ -1546,7 +1562,7 @@ class LeadsController extends BaseController
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
||||
// Set filename
|
||||
$string = ($type == 2) ? 'QCR' : 'RFQ';
|
||||
@ -1554,15 +1570,14 @@ class LeadsController extends BaseController
|
||||
$next_year = $current_year + 1;
|
||||
$policy_year = "$current_year-$next_year";
|
||||
|
||||
if (!empty($rfq_data['policy_end_date'])){
|
||||
if (!empty($rfq_data['policy_end_date'])) {
|
||||
$policy_expiry = strtotime($lead_data['policy_end_date']);
|
||||
|
||||
$formatted_policy = date("d-m-Y",$policy_expiry);
|
||||
$formatted_policy = date("d-m-Y", $policy_expiry);
|
||||
|
||||
$filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_" .$policy_year.'(Due On '.$formatted_policy . ')' .'.xlsx';
|
||||
|
||||
}else{
|
||||
$filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_".$policy_year.'_' . '.xlsx';
|
||||
$filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_" . $policy_year . '(Due On ' . $formatted_policy . ')' . '.xlsx';
|
||||
} else {
|
||||
$filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_" . $policy_year . '_' . '.xlsx';
|
||||
}
|
||||
|
||||
|
||||
@ -2190,12 +2205,11 @@ class LeadsController extends BaseController
|
||||
|
||||
} else if ($recipient_type == 'client') {
|
||||
|
||||
$mailIDS = explode(',',$params['contact_mail']);
|
||||
$mailIDS = explode(',', $params['contact_mail']);
|
||||
$recipient_data = [];
|
||||
foreach ($mailIDS as $mail){
|
||||
foreach ($mailIDS as $mail) {
|
||||
$recipient_data[] = ['name' => $lead_data['contact_person_name'], 'email' => $mail];
|
||||
}
|
||||
|
||||
} else {
|
||||
$recipient_data = [['name' => "Team", 'email' => $params['to']]];
|
||||
}
|
||||
@ -2902,10 +2916,10 @@ class LeadsController extends BaseController
|
||||
|
||||
$policy_expiry = strtotime($lead_data['policy_end_date']);
|
||||
|
||||
$formatted_policy = date("d-m-Y",$policy_expiry);
|
||||
$formatted_policy = date("d-m-Y", $policy_expiry);
|
||||
$logged_user_id = get_session_userid();
|
||||
|
||||
$logged_user_data = $this->userModel->where("id",$logged_user_id)->where("is_active",1)->first();
|
||||
$logged_user_data = $this->userModel->where("id", $logged_user_id)->where("is_active", 1)->first();
|
||||
|
||||
if ($lead_data) {
|
||||
|
||||
@ -2916,11 +2930,11 @@ class LeadsController extends BaseController
|
||||
$message = str_replace("{{POLICY_TYPE}}", $lead_data['policy_type'] ?? "Insurance Policy", $message);
|
||||
$message = str_replace("{{RFQ_OR_QCR}}", $page_name, $message);
|
||||
$message = str_replace("{{POLICY_YEAR}}", $policy_year, $message);
|
||||
$message = str_replace("{{POLICY_END_DATE}}"," (Due On ".$formatted_policy.")",$message);
|
||||
$message = str_replace("{{POLICY_END_DATE}}", " (Due On " . $formatted_policy . ")", $message);
|
||||
|
||||
$message = str_replace("{{LOGGED_USER_NAME}}",ucfirst($logged_user_data['first_name'])." ".ucfirst($logged_user_data['last_name']),$message);
|
||||
$message = str_replace("{{LOGGED_USER_EMAIL}}",$logged_user_data['email'],$message);
|
||||
$message = str_replace("{{LOGGED_USER_MOBILE}}",$logged_user_data['mobile'],$message);
|
||||
$message = str_replace("{{LOGGED_USER_NAME}}", ucfirst($logged_user_data['first_name']) . " " . ucfirst($logged_user_data['last_name']), $message);
|
||||
$message = str_replace("{{LOGGED_USER_EMAIL}}", $logged_user_data['email'], $message);
|
||||
$message = str_replace("{{LOGGED_USER_MOBILE}}", $logged_user_data['mobile'], $message);
|
||||
|
||||
return $message;
|
||||
} else {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -181,15 +181,16 @@ class TicketController extends BaseController
|
||||
return $this->loadLayout('ticket_search', $data);
|
||||
} else {
|
||||
|
||||
$data['ticket_data'] = $this->ticketSearch();
|
||||
$isFromDashboard = $this->request->getPost("is_dashboard");
|
||||
|
||||
if (isset($isFromDashboard) && !empty($isFromDashboard) && $isFromDashboard == 1) {
|
||||
$data['page_name'] = "Claims";
|
||||
$data['ticket_data'] = $this->ticketSearch(3);
|
||||
$data['claim_status'] = $this->claimStatus->select('id,ticket_type,claim_status')->where('is_active', 1)->findAll();
|
||||
$data['client_list'] = $this->clientModel->select('id,client_name')->where('is_active', 1)->findAll();
|
||||
return $this->loadLayout('ticket_search', $data);
|
||||
}else{
|
||||
$data['ticket_data'] = $this->ticketSearch();
|
||||
$html = view('ticket_list', $data);
|
||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||
}
|
||||
@ -201,39 +202,38 @@ class TicketController extends BaseController
|
||||
{
|
||||
$db = db_connect();
|
||||
|
||||
$subquery = $db->table('ticket_history th')
|
||||
->select([
|
||||
'th.ticket_id',
|
||||
"CASE
|
||||
WHEN DATEDIFF(
|
||||
th.created_at,
|
||||
COALESCE(
|
||||
(SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id),
|
||||
tm.created_at
|
||||
)
|
||||
) BETWEEN 0 AND 6 THEN '0-6 Days'
|
||||
WHEN DATEDIFF(
|
||||
th.created_at,
|
||||
COALESCE(
|
||||
(SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id),
|
||||
tm.created_at
|
||||
)
|
||||
) BETWEEN 7 AND 12 THEN '7-12 Days'
|
||||
WHEN DATEDIFF(
|
||||
th.created_at,
|
||||
COALESCE(
|
||||
(SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id),
|
||||
tm.created_at
|
||||
)
|
||||
) BETWEEN 13 AND 20 THEN '13-20 Days'
|
||||
ELSE 'Above 20 Days'
|
||||
END AS tat"
|
||||
])
|
||||
->join('ticket_master tm', 'tm.id = th.ticket_id', 'right')
|
||||
->where('tm.is_active', 1)
|
||||
->groupBy('th.ticket_id, tm.created_at');
|
||||
$subquery = $db->table('ticket_master tm')
|
||||
->select([
|
||||
'tm.id AS ticket_id',
|
||||
"CASE
|
||||
WHEN DATEDIFF(
|
||||
CURDATE(),
|
||||
COALESCE(latest_history.created_at, tm.created_at)
|
||||
) BETWEEN 0 AND 6 THEN '0-6 Days'
|
||||
WHEN DATEDIFF(
|
||||
CURDATE(),
|
||||
COALESCE(latest_history.created_at, tm.created_at)
|
||||
) BETWEEN 7 AND 12 THEN '7-12 Days'
|
||||
WHEN DATEDIFF(
|
||||
CURDATE(),
|
||||
COALESCE(latest_history.created_at, tm.created_at)
|
||||
) BETWEEN 13 AND 20 THEN '13-20 Days'
|
||||
ELSE 'Above 20 Days'
|
||||
END AS tat"
|
||||
])
|
||||
->join(
|
||||
'(SELECT th.ticket_id, MAX(th.created_at) AS created_at
|
||||
FROM ticket_history th
|
||||
WHERE th.field_name = "claim_status_id"
|
||||
GROUP BY th.ticket_id) AS latest_history',
|
||||
'latest_history.ticket_id = tm.id',
|
||||
'left'
|
||||
)
|
||||
->where('tm.is_active', 1)
|
||||
->groupBy('tm.id, tm.created_at, latest_history.created_at');
|
||||
|
||||
//action 1 get last 100 rows, action 2 filter and get all rows related to that
|
||||
|
||||
//action 1 get last 100 rows, action 2 filter and get all rows related to that and action 3 gets according to dashboard
|
||||
if ($action == 1) {
|
||||
|
||||
$query = $db->table('ticket_master tm')
|
||||
@ -268,6 +268,18 @@ class TicketController extends BaseController
|
||||
|
||||
return $data;
|
||||
|
||||
}else if ($action == 3) {
|
||||
$ids = $this->request->getPost('ids');
|
||||
$ids = array_filter(explode(',', $ids));
|
||||
|
||||
if (!empty($ids)) {
|
||||
$idsStr = implode(',', array_map('intval', $ids)); // sanitize IDs to be integers
|
||||
$where = "tm.id IN ($idsStr)";
|
||||
} else {
|
||||
$where = '1 = 0'; // No valid IDs, return empty result
|
||||
}
|
||||
// dd($where);
|
||||
|
||||
} else {
|
||||
$search_data = $this->request->getPost();
|
||||
// print_r($search_data); die()
|
||||
@ -278,7 +290,9 @@ class TicketController extends BaseController
|
||||
}
|
||||
}
|
||||
// print_rr($where);
|
||||
$query = $db->table('ticket_master tm')
|
||||
|
||||
}
|
||||
$query = $db->table('ticket_master tm')
|
||||
->select([
|
||||
'tm.id',
|
||||
'tm.ticket_type_id',
|
||||
@ -311,7 +325,6 @@ class TicketController extends BaseController
|
||||
// print_rr($data);die();
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
public function ticket_form($ticket_type)
|
||||
|
||||
@ -71,7 +71,7 @@ class ClientPolicyModel extends Model
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['created_by'])) {
|
||||
if (empty($data['data']['created_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
@ -82,7 +82,7 @@ class ClientPolicyModel extends Model
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
@ -90,100 +90,100 @@ class ClientPolicyModel extends Model
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getClientPolicyById($id){
|
||||
public function getClientPolicyById($id)
|
||||
{
|
||||
|
||||
return $this->db->table('client_policy')
|
||||
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('tpa.name as tpa_name, tpa.short_name as tpa_short')
|
||||
->select('policies.name as policy_name')
|
||||
->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
|
||||
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
|
||||
->join('tpa', 'tpa.id = client_policy.tpa_id')
|
||||
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id')
|
||||
->join('policies', 'policies.id = client_policy.policy_id')
|
||||
->where('client_policy.id', $id)
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('tpa.name as tpa_name, tpa.short_name as tpa_short')
|
||||
->select('policies.name as policy_name')
|
||||
->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
|
||||
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
|
||||
->join('tpa', 'tpa.id = client_policy.tpa_id')
|
||||
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id')
|
||||
->join('policies', 'policies.id = client_policy.policy_id')
|
||||
->where('client_policy.id', $id)
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function getClientPolicyByClientId($client_id){
|
||||
|
||||
public function getClientPolicyByClientId($client_id)
|
||||
{
|
||||
|
||||
|
||||
return $this->db->table('client_policy')
|
||||
->select('client_policy.*')
|
||||
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('tpa.name as tpa_name, tpa.short_name as tpa_short')
|
||||
->select('policy_type.policy_type as policy_type_name')
|
||||
->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
|
||||
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
|
||||
->select('policy_type.policy_type as policy_type_name')
|
||||
->select('client_branch.branch_name as branch_name')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
|
||||
->join('tpa', 'tpa.id = client_policy.tpa_id', 'left')
|
||||
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id', 'left')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->join('client_branch', 'client_branch.id = client_policy.client_branch_id')
|
||||
->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.policy_status', 1)
|
||||
->where('client_policy.is_active', 1)
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
|
||||
|
||||
->select('client_policy.*')
|
||||
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('tpa.name as tpa_name, tpa.short_name as tpa_short')
|
||||
->select('policy_type.policy_type as policy_type_name')
|
||||
->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
|
||||
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
|
||||
->select('policy_type.policy_type as policy_type_name')
|
||||
->select('client_branch.branch_name as branch_name')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
|
||||
->join('tpa', 'tpa.id = client_policy.tpa_id', 'left')
|
||||
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id', 'left')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->join('client_branch', 'client_branch.id = client_policy.client_branch_id')
|
||||
->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.policy_status', 1)
|
||||
->where('client_policy.is_active', 1)
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function getPolicyPremium($policy_id){
|
||||
public function getPolicyPremium($policy_id)
|
||||
{
|
||||
|
||||
return $this->db->table('policies')
|
||||
->select('policy_type.*')
|
||||
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
||||
->where('policies.id', $policy_id)
|
||||
->get()
|
||||
->getResult();
|
||||
->select('policy_type.*')
|
||||
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
||||
->where('policies.id', $policy_id)
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function getPolicyPremiumPolicyTypeId($policy_type_id){
|
||||
public function getPolicyPremiumPolicyTypeId($policy_type_id)
|
||||
{
|
||||
|
||||
return $this->db->table('policies')
|
||||
->select('policy_type.*')
|
||||
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
||||
->where('policies.id', $policy_type_id)
|
||||
->get()
|
||||
->getResult();
|
||||
->select('policy_type.*')
|
||||
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
||||
->where('policies.id', $policy_type_id)
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
|
||||
public function getPolicyDetails($client_id,$policy_id)
|
||||
public function getPolicyDetails($client_id, $policy_id)
|
||||
{
|
||||
return $this->select('*')
|
||||
->where('client_id',$client_id)
|
||||
->where('id',$policy_id)
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
->where('client_id', $client_id)
|
||||
->where('id', $policy_id)
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
|
||||
public function getinsurerswithclientid($id){
|
||||
public function getinsurerswithclientid($id)
|
||||
{
|
||||
|
||||
return $this->db->table('client_policy')
|
||||
->select('client_policy.*, cd_master.cd_ac_no as cd_master_account_no')
|
||||
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('clients.client_name as client_name')
|
||||
->join('clients','clients.id=client_policy.client_id')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('cd_master', 'cd_master.insurer_id = insurers.id AND cd_master.client_id = client_policy.client_id')
|
||||
->where('client_policy.client_id', $id)
|
||||
->where('cd_master.id = client_policy.cd_ac_pk')
|
||||
->groupBy('client_policy.insurer_id')
|
||||
->groupBy('client_policy.client_id', $id) // Group by insurer_id
|
||||
->get()
|
||||
->getResult();
|
||||
->select('client_policy.*, cd_master.cd_ac_no as cd_master_account_no')
|
||||
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('clients.client_name as client_name')
|
||||
->join('clients', 'clients.id=client_policy.client_id')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('cd_master', 'cd_master.insurer_id = insurers.id AND cd_master.client_id = client_policy.client_id')
|
||||
->where('client_policy.client_id', $id)
|
||||
->where('cd_master.id = client_policy.cd_ac_pk')
|
||||
->groupBy('client_policy.insurer_id')
|
||||
->groupBy('client_policy.client_id', $id) // Group by insurer_id
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
// return $this->db->table('client_policy')
|
||||
// ->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
@ -198,26 +198,28 @@ class ClientPolicyModel extends Model
|
||||
// ->getResult();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getinsurerswithinsurenceid($insurerId){
|
||||
|
||||
public function getinsurerswithinsurenceid($insurerId)
|
||||
{
|
||||
|
||||
return $this->db->table('client_policy')
|
||||
->select('client_policy.*')
|
||||
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('clients.client_name as clientname, clients.short_name as clientshort')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('clients', 'clients.id = client_policy.client_id')
|
||||
->where('client_policy.insurer_id', $insurerId)
|
||||
->groupBy('client_policy.client_id') // Group by insurer_id
|
||||
->get()
|
||||
->getResult();
|
||||
->select('client_policy.*')
|
||||
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('clients.client_name as clientname, clients.short_name as clientshort')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('clients', 'clients.id = client_policy.client_id')
|
||||
->where('client_policy.insurer_id', $insurerId)
|
||||
->groupBy('client_policy.client_id') // Group by insurer_id
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
|
||||
public function getClientById($id) {
|
||||
public function getClientById($id)
|
||||
{
|
||||
$query = $this->db->table('clients')->getWhere(['id' => $id]);
|
||||
// Debug statement
|
||||
// Debug statement
|
||||
return $query->getRow();
|
||||
}
|
||||
|
||||
@ -248,112 +250,113 @@ class ClientPolicyModel extends Model
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function getDepositSummary($clientId, $insurerId)
|
||||
{
|
||||
// Fetch the sum of credit and debit transactions and calculate the balance
|
||||
return $this->db->table('cash_deposit')
|
||||
->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE 0 END) AS total_credit')
|
||||
->select('SUM(CASE WHEN transaction_type = "Debit" THEN amount ELSE 0 END) AS total_withdraw')
|
||||
->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance')
|
||||
->select('SUM(CASE WHEN sub_type = 3 THEN amount ELSE 0 END) AS total_refund')
|
||||
->where('client_id', $clientId)
|
||||
->where('insurer_id', $insurerId)
|
||||
->where('cash_deposit.is_active', 1)
|
||||
->get()
|
||||
->getRow();
|
||||
}
|
||||
// Inside your clientPolicyModel
|
||||
// Inside your clientPolicyModel
|
||||
// public function getDepositDataWithBalance($clientId, $insurerId)
|
||||
// {
|
||||
// // Fetch deposit data with balance information
|
||||
// $builder = $this->db->table('cash_deposit');
|
||||
// $builder->select('id, created_at, description, sub_type, amount, transaction_type');
|
||||
{
|
||||
// Fetch the sum of credit and debit transactions and calculate the balance
|
||||
return $this->db->table('cash_deposit')
|
||||
->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE 0 END) AS total_credit')
|
||||
->select('SUM(CASE WHEN transaction_type = "Debit" THEN amount ELSE 0 END) AS total_withdraw')
|
||||
->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance')
|
||||
->select('SUM(CASE WHEN sub_type = 3 THEN amount ELSE 0 END) AS total_refund')
|
||||
->where('client_id', $clientId)
|
||||
->where('insurer_id', $insurerId)
|
||||
->where('cash_deposit.is_active', 1)
|
||||
->get()
|
||||
->getRow();
|
||||
}
|
||||
// Inside your clientPolicyModel
|
||||
// Inside your clientPolicyModel
|
||||
// public function getDepositDataWithBalance($clientId, $insurerId)
|
||||
// {
|
||||
// // Fetch deposit data with balance information
|
||||
// $builder = $this->db->table('cash_deposit');
|
||||
// $builder->select('id, created_at, description, sub_type, amount, transaction_type');
|
||||
|
||||
// $builder->where('client_id', $clientId);
|
||||
// $builder->where('insurer_id', $insurerId);
|
||||
// $builder->orderBy('created_at', 'asc');
|
||||
// $builder->where('client_id', $clientId);
|
||||
// $builder->where('insurer_id', $insurerId);
|
||||
// $builder->orderBy('created_at', 'asc');
|
||||
|
||||
// $depositData = $builder->get()->getResult();
|
||||
// $depositData = $builder->get()->getResult();
|
||||
|
||||
// $currentBalance = 0;
|
||||
// $currentBalance = 0;
|
||||
|
||||
// foreach ($depositData as $transaction) {
|
||||
// if ($transaction->transaction_type == 'Credit') {
|
||||
// $currentBalance += $transaction->amount;
|
||||
// } elseif ($transaction->transaction_type == 'Debit') {
|
||||
// $currentBalance -= $transaction->amount;
|
||||
// }
|
||||
// foreach ($depositData as $transaction) {
|
||||
// if ($transaction->transaction_type == 'Credit') {
|
||||
// $currentBalance += $transaction->amount;
|
||||
// } elseif ($transaction->transaction_type == 'Debit') {
|
||||
// $currentBalance -= $transaction->amount;
|
||||
// }
|
||||
|
||||
// $transaction->balance = $currentBalance;
|
||||
// }
|
||||
// $transaction->balance = $currentBalance;
|
||||
// }
|
||||
|
||||
// return $depositData;
|
||||
// }
|
||||
// return $depositData;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
public function getBalances($clientId)
|
||||
{
|
||||
$depositsummary = $this->getDepositlistsummary($clientId);
|
||||
$balances = [];
|
||||
public function getBalances($clientId)
|
||||
{
|
||||
$depositsummary = $this->getDepositlistsummary($clientId);
|
||||
$balances = [];
|
||||
|
||||
foreach ($depositsummary as $summary) {
|
||||
$insurerId = $summary->insurer_id;
|
||||
$balances[$insurerId] = $summary;
|
||||
foreach ($depositsummary as $summary) {
|
||||
$insurerId = $summary->insurer_id;
|
||||
$balances[$insurerId] = $summary;
|
||||
}
|
||||
|
||||
return $balances;
|
||||
}
|
||||
|
||||
return $balances;
|
||||
}
|
||||
|
||||
public function getDepositlistsummary($id)
|
||||
{
|
||||
return $this->db->table('cash_deposit')
|
||||
->select('insurer_id')
|
||||
->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance')
|
||||
->where('client_id', $id)
|
||||
->groupBy('insurer_id')
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
public function getDepositlistsummary($id)
|
||||
{
|
||||
return $this->db->table('cash_deposit')
|
||||
->select('insurer_id')
|
||||
->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance')
|
||||
->where('client_id', $id)
|
||||
->groupBy('insurer_id')
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
|
||||
public function updateStatus(){
|
||||
public function updateStatus()
|
||||
{
|
||||
|
||||
// Update client_policy table
|
||||
$client = $this->db->query("UPDATE client_policy SET policy_status = 0 WHERE policy_end_date < CURDATE()");
|
||||
$client_count = $this->db->affectedRows();
|
||||
// Update employee_polices table
|
||||
$employee = $this->db->query("UPDATE employee_polices SET status = 'expired' WHERE policy_end_date < CURDATE()");
|
||||
$emp_count = $this->db->affectedRows();
|
||||
// Update client_policy table
|
||||
$client = $this->db->query("UPDATE client_policy SET policy_status = 0 WHERE policy_end_date < CURDATE()");
|
||||
$client_count = $this->db->affectedRows();
|
||||
// Update employee_polices table
|
||||
$employee = $this->db->query("UPDATE employee_polices SET status = 'expired' WHERE policy_end_date < CURDATE()");
|
||||
$emp_count = $this->db->affectedRows();
|
||||
|
||||
return ['client'=>$client_count, 'emp' => $emp_count];
|
||||
return ['client' => $client_count, 'emp' => $emp_count];
|
||||
}
|
||||
|
||||
public function getpolicyWithPattern($client_id)
|
||||
{
|
||||
|
||||
$query = $this->db->table('client_policy')
|
||||
->select('client_policy.*, policies.name, policies.policy_type_id, policy_type.policy_type')
|
||||
->join('policies', 'policies.id = client_policy.policy_id')
|
||||
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
||||
// ->where('policy_type.policy_type', 'GMC')
|
||||
->whereIn('policy_type.id', [2, 3])
|
||||
->where('client_policy.client_id', $client_id)
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function getpolicyWithPattern($client_id){
|
||||
public function getTopUpPolicy($client_id, $type)
|
||||
{
|
||||
|
||||
$query = $this->db->table('client_policy')
|
||||
->select('client_policy.*, policies.name, policies.policy_type_id, policy_type.policy_type')
|
||||
->join('policies', 'policies.id = client_policy.policy_id')
|
||||
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
||||
// ->where('policy_type.policy_type', 'GMC')
|
||||
->whereIn('policy_type.id', [2, 3])
|
||||
->where('client_policy.client_id', $client_id)
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function getTopUpPolicy($client_id, $type){
|
||||
|
||||
$query = "
|
||||
$query = "
|
||||
SELECT client_policy.*, policies.name, policies.policy_type_id
|
||||
FROM client_policy
|
||||
JOIN policies ON policies.id = client_policy.policy_id
|
||||
@ -361,65 +364,63 @@ public function getTopUpPolicy($client_id, $type){
|
||||
WHERE policy_type.policy_type = '{$type}'
|
||||
AND client_policy.client_id = {$client_id}";
|
||||
|
||||
$result = $this->db->query($query)->getResult();
|
||||
$result = $this->db->query($query)->getResult();
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getClientPolicyByPolicyType($client_id, $type){
|
||||
|
||||
|
||||
$query = $this->db->table('client_policy')
|
||||
->select('client_policy.*, insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('tpa.name as tpa_name, tpa.short_name as tpa_short')
|
||||
->select('policies.name as policy_name, policies.policy_type_id')
|
||||
->select('policy_type.policy_type as policy_type_name')
|
||||
->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
|
||||
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
|
||||
->join('tpa', 'tpa.id = client_policy.tpa_id')
|
||||
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id')
|
||||
->join('policies', 'policies.id = client_policy.policy_id')
|
||||
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
||||
->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.policy_status', 1);
|
||||
|
||||
if ($type == 2) {
|
||||
$query->where('policy_type.policy_type', 'GMC - Top-up');
|
||||
} else if ($type == 3) {
|
||||
$query->whereIn('policy_type.policy_type', ['GMC - Parents', 'GMC - Top-up(Parents)']);
|
||||
return $result;
|
||||
}
|
||||
|
||||
$result = $query->get()->getResult();
|
||||
|
||||
return $result;
|
||||
public function getClientPolicyByPolicyType($client_id, $type)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
$query = $this->db->table('client_policy')
|
||||
->select('client_policy.*, insurers.name as insurer_name, insurers.short_name as insurer_short')
|
||||
->select('tpa.name as tpa_name, tpa.short_name as tpa_short')
|
||||
->select('policies.name as policy_name, policies.policy_type_id')
|
||||
->select('policy_type.policy_type as policy_type_name')
|
||||
->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
|
||||
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
|
||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
||||
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
|
||||
->join('tpa', 'tpa.id = client_policy.tpa_id')
|
||||
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id')
|
||||
->join('policies', 'policies.id = client_policy.policy_id')
|
||||
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
||||
->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.policy_status', 1);
|
||||
|
||||
if ($type == 2) {
|
||||
$query->where('policy_type.policy_type', 'GMC - Top-up');
|
||||
} else if ($type == 3) {
|
||||
$query->whereIn('policy_type.policy_type', ['GMC - Parents', 'GMC - Top-up(Parents)']);
|
||||
}
|
||||
|
||||
$result = $query->get()->getResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function getPolicyTypeForPolicyBinding($client_id){
|
||||
public function getPolicyTypeForPolicyBinding($client_id)
|
||||
{
|
||||
|
||||
$result = $this->table('client_policy')
|
||||
->select('policy_type.*, client_policy.id as client_policy_id, client_policy.policy_no')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.is_active', 1)
|
||||
->whereIn('policy_type.id', [2,3])
|
||||
->findAll();
|
||||
$result = $this->table('client_policy')
|
||||
->select('policy_type.*, client_policy.id as client_policy_id, client_policy.policy_no')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.is_active', 1)
|
||||
->whereIn('policy_type.id', [2, 3])
|
||||
->findAll();
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public function getCliendDataForExcelFileName($client_policy_id)
|
||||
{
|
||||
|
||||
|
||||
public function getCliendDataForExcelFileName($client_policy_id){
|
||||
|
||||
return $this->table('client_policy')
|
||||
return $this->table('client_policy')
|
||||
->select('clients.short_name, policy_type.policy_type, client_branch.branch_code')
|
||||
->join('clients', 'clients.id = client_policy.client_id')
|
||||
->join('client_branch', 'client_branch.id = client_policy.client_branch_id')
|
||||
@ -427,49 +428,48 @@ public function getCliendDataForExcelFileName($client_policy_id){
|
||||
->where('client_policy.id', $client_policy_id)
|
||||
->where('client_policy.is_active', 1)
|
||||
->first();
|
||||
|
||||
}
|
||||
|
||||
//for this using in CRONE JOB
|
||||
public function getPolicyDetailsForRemainder($client_id = null, $branch_id = null, $policy_id = null)
|
||||
{
|
||||
$builder = $this->table('client_policy')
|
||||
->where('client_policy.is_active', 1)
|
||||
->where('client_policy.policy_status', 1)
|
||||
// ->where('client_policy.is_addon', 1)
|
||||
// ->where('client_policy.inception_type', 2)
|
||||
->where('client_policy.open_for_enrollment', 1);
|
||||
|
||||
if ($client_id && $branch_id) {
|
||||
$builder->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.client_branch_id', $branch_id);
|
||||
}
|
||||
|
||||
if(empty($policy_id)){
|
||||
$builder->whereIn('client_policy.policy_type_id', [2, 3, 4, 5]);
|
||||
}else{
|
||||
$builder->where('client_policy.id', $policy_id);
|
||||
//for this using in CRONE JOB
|
||||
public function getPolicyDetailsForRemainder($client_id = null, $branch_id = null, $policy_id = null)
|
||||
{
|
||||
$builder = $this->table('client_policy')
|
||||
->where('client_policy.is_active', 1)
|
||||
->where('client_policy.policy_status', 1)
|
||||
// ->where('client_policy.is_addon', 1)
|
||||
// ->where('client_policy.inception_type', 2)
|
||||
->where('client_policy.open_for_enrollment', 1);
|
||||
|
||||
if ($client_id && $branch_id) {
|
||||
$builder->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.client_branch_id', $branch_id);
|
||||
}
|
||||
|
||||
if (empty($policy_id)) {
|
||||
$builder->whereIn('client_policy.policy_type_id', [2, 3, 4, 5]);
|
||||
} else {
|
||||
$builder->where('client_policy.id', $policy_id);
|
||||
}
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
//for this using in CRONE JOB
|
||||
public function getPolicyDetailsForEnrollment($client_id = null, $branch_id = null)
|
||||
{
|
||||
$builder = $this->table('client_policy')
|
||||
->where('client_policy.is_active', 1)
|
||||
->where('client_policy.policy_status', 1)
|
||||
->where('client_policy.open_date IS NOT NULL')
|
||||
->where('client_policy.close_date IS NOT NULL');
|
||||
|
||||
//for this using in CRONE JOB
|
||||
public function getPolicyDetailsForEnrollment($client_id = null, $branch_id = null)
|
||||
{
|
||||
$builder = $this->table('client_policy')
|
||||
->where('client_policy.is_active', 1)
|
||||
->where('client_policy.policy_status', 1)
|
||||
->where('client_policy.open_date IS NOT NULL')
|
||||
->where('client_policy.close_date IS NOT NULL');
|
||||
if ($client_id && $branch_id) {
|
||||
$builder->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.client_branch_id', $branch_id);
|
||||
}
|
||||
|
||||
if ($client_id && $branch_id) {
|
||||
$builder->where('client_policy.client_id', $client_id)
|
||||
->where('client_policy.client_branch_id', $branch_id);
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -30,17 +30,17 @@ class LeadsModel extends Model
|
||||
'source_policy_id',
|
||||
'policy_type_id',
|
||||
'salse_person_id',
|
||||
'insurer_id',
|
||||
'insurer_branch_id',
|
||||
'tpa_id',
|
||||
'tpa_branch_id',
|
||||
'policy_start_date',
|
||||
'policy_end_date',
|
||||
'no_of_lives',
|
||||
'incurred_claims',
|
||||
'location',
|
||||
'proposed_insurer_id',
|
||||
'proposed_insurer_branch_id',
|
||||
'insurer_id',
|
||||
'insurer_branch_id',
|
||||
'tpa_id',
|
||||
'tpa_branch_id',
|
||||
'policy_start_date',
|
||||
'policy_end_date',
|
||||
'no_of_lives',
|
||||
'incurred_claims',
|
||||
'location',
|
||||
'proposed_insurer_id',
|
||||
'proposed_insurer_branch_id',
|
||||
'proposed_tpa_id',
|
||||
'proposed_tpa_branch_id',
|
||||
'proposel_data',
|
||||
@ -90,7 +90,7 @@ class LeadsModel extends Model
|
||||
|
||||
'source_policy_start_date',
|
||||
'source_policy_end_date',
|
||||
|
||||
|
||||
'payment_date',
|
||||
'is_cd'
|
||||
];
|
||||
@ -110,7 +110,7 @@ class LeadsModel extends Model
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['created_by'])) {
|
||||
if (empty($data['data']['created_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
@ -121,7 +121,7 @@ class LeadsModel extends Model
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
@ -153,10 +153,10 @@ class LeadsModel extends Model
|
||||
|
||||
) AS rfq_count
|
||||
')
|
||||
->join('kyc_entity_type', 'leads.entity_type_id = kyc_entity_type.id', 'left')
|
||||
->join('user_profiles', 'leads.salse_person_id = user_profiles.id', 'left')
|
||||
->join('policy_type', 'leads.policy_type_id = policy_type.id', 'left')
|
||||
->where('leads.is_active', 1);
|
||||
->join('kyc_entity_type', 'leads.entity_type_id = kyc_entity_type.id', 'left')
|
||||
->join('user_profiles', 'leads.salse_person_id = user_profiles.id', 'left')
|
||||
->join('policy_type', 'leads.policy_type_id = policy_type.id', 'left')
|
||||
->where('leads.is_active', 1);
|
||||
|
||||
if (!empty($where)) {
|
||||
$data->where($where);
|
||||
@ -168,12 +168,12 @@ class LeadsModel extends Model
|
||||
public function getLeadForInsertClientList($type = null, $client_id = null)
|
||||
{
|
||||
$query = $this->db->table('leads')
|
||||
->select('leads.*, user_profiles.first_name as user_name')
|
||||
->join('user_profiles', 'leads.created_by = user_profiles.id')
|
||||
->where('leads.is_active', 1)
|
||||
->where('leads.status', 'won')
|
||||
->where("leads.proposel_data IS NOT NULL AND leads.proposel_data <> ''")
|
||||
->where("(leads.is_client_created = '' OR leads.is_client_created IS NULL)");
|
||||
->select('leads.*, user_profiles.first_name as user_name')
|
||||
->join('user_profiles', 'leads.created_by = user_profiles.id')
|
||||
->where('leads.is_active', 1)
|
||||
->where('leads.status', 'won')
|
||||
->where("leads.proposel_data IS NOT NULL AND leads.proposel_data <> ''")
|
||||
->where("(leads.is_client_created = '' OR leads.is_client_created IS NULL)");
|
||||
|
||||
|
||||
|
||||
@ -183,11 +183,83 @@ class LeadsModel extends Model
|
||||
if ($client_id) {
|
||||
$query->where('leads.client_id', $client_id);
|
||||
}
|
||||
|
||||
|
||||
$result = $query->get()->getResultArray();
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
public function getDashData()
|
||||
{
|
||||
$statuses = $this->db->table('leads')
|
||||
->select('status')
|
||||
->where("is_active", 1)
|
||||
->groupBy('status')
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
$selectParts = [];
|
||||
|
||||
foreach ($statuses as $status) {
|
||||
$s = $status['status'];
|
||||
$alias = strtolower(str_replace(' ', '_', $s));
|
||||
|
||||
// Count alias
|
||||
$selectParts[] = "SUM(CASE WHEN status = '{$s}' THEN 1 ELSE 0 END) AS `{$alias}`";
|
||||
|
||||
// IDs alias
|
||||
$selectParts[] = "GROUP_CONCAT(CASE WHEN status = '{$s}' THEN leads.id ELSE NULL END) AS `{$alias}_ids`";
|
||||
}
|
||||
|
||||
$select = implode(", ", $selectParts);
|
||||
|
||||
// Start query builder
|
||||
$builder = $this->db->table('leads');
|
||||
|
||||
$builder->select($select);
|
||||
|
||||
// Auditing subquery
|
||||
$subquery = "(SELECT pk, MAX(created_at) AS last_claim_status_change
|
||||
FROM auditing_history
|
||||
WHERE table_name = 'leads' AND field_name = 'status'
|
||||
GROUP BY pk)";
|
||||
|
||||
$builder->join("{$subquery} AS th", 'leads.id = th.pk', 'left');
|
||||
|
||||
// Date filtering for last status change
|
||||
$dateLimit = 3;
|
||||
$dateThreshold = date('Y-m-d H:i:s', strtotime("-{$dateLimit} days"));
|
||||
|
||||
$builder->groupStart()
|
||||
->where('th.last_claim_status_change <=', $dateThreshold)
|
||||
->orWhere('th.last_claim_status_change IS NULL')
|
||||
->groupEnd();
|
||||
|
||||
// Add only active
|
||||
$builder->where("leads.is_active", 1);
|
||||
|
||||
$lead_data = $builder->get()->getResultArray();
|
||||
|
||||
// Fallback for empty results
|
||||
if (empty($lead_data)) {
|
||||
$lead_data[0] = ['total' => 0];
|
||||
foreach ($statuses as $status) {
|
||||
$alias = strtolower(str_replace(' ', '_', $status['status']));
|
||||
$lead_data[0][$alias] = 0;
|
||||
$lead_data[0]["{$alias}_ids"] = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate total
|
||||
$total = 0;
|
||||
foreach ($lead_data[0] as $key => $value) {
|
||||
if (!str_ends_with($key, '_ids') && $key != "won") {
|
||||
$total += (int) $value;
|
||||
}
|
||||
}
|
||||
$lead_data[0]['total'] = $total;
|
||||
|
||||
// dd($lead_data[0]);
|
||||
return $lead_data[0];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ class PolicyTransactionModel extends Model
|
||||
'policy_with_corr',
|
||||
'is_cd_reduce_from_bds',
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
// Callbacks
|
||||
@ -98,7 +98,7 @@ class PolicyTransactionModel extends Model
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['created_by'])) {
|
||||
if (empty($data['data']['created_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
@ -109,7 +109,7 @@ class PolicyTransactionModel extends Model
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
@ -267,21 +267,21 @@ class PolicyTransactionModel extends Model
|
||||
->join('tpa_branch', 'policy_transaction.tpa_branch_id = tpa_branch.id', 'left')
|
||||
->join('user_profiles AS sales_user', 'policy_transaction.sales_generated_by = sales_user.id', 'left')
|
||||
->join('user_profiles AS service_user', 'policy_transaction.serviced_by = service_user.id', 'left')
|
||||
->where('policy_transaction.is_active', 1);
|
||||
|
||||
->where('policy_transaction.is_active', 1);
|
||||
|
||||
// Check if the start date and end date are provided
|
||||
if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
|
||||
|
||||
$startDate = date('Y-m-d 00:00:00', strtotime($start_date));
|
||||
$endDate = date('Y-m-d 23:59:59', strtotime($end_date));
|
||||
|
||||
$builder->where('policy_transaction.'.$date_type.'>=', $startDate)
|
||||
->where('policy_transaction.'.$date_type.'<=', $endDate);
|
||||
}else{
|
||||
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
|
||||
->where('policy_transaction.' . $date_type . '<=', $endDate);
|
||||
} else {
|
||||
|
||||
// $fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
// $toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
|
||||
// $builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
// ->where('policy_transaction.created_at <=', $toDate);
|
||||
}
|
||||
@ -289,31 +289,30 @@ class PolicyTransactionModel extends Model
|
||||
if ($client_id != 0) {
|
||||
$builder->where('policy_transaction.client_id', $client_id);
|
||||
}
|
||||
|
||||
|
||||
if ($insurer_id != 0) {
|
||||
$builder->where('policy_transaction.insurer_id', $insurer_id);
|
||||
}
|
||||
|
||||
|
||||
if ($policy_type_id != 0) {
|
||||
$builder->where('client_policy.policy_type_id', $policy_type_id);
|
||||
}
|
||||
|
||||
|
||||
if ($issuer != 0) {
|
||||
$builder->where('policy_transaction.issuer', $issuer);
|
||||
}
|
||||
|
||||
if($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0){
|
||||
if ($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0) {
|
||||
|
||||
$fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
$toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
$builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
|
||||
$builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
}
|
||||
|
||||
$builder->orderBy('policy_transaction.id', 'desc');
|
||||
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
@ -446,7 +445,7 @@ class PolicyTransactionModel extends Model
|
||||
// AND insurer_statements.is_active = 1
|
||||
// AND insurer_statements.invoice_status IS NOT NULL
|
||||
// $date_condition
|
||||
|
||||
|
||||
// ),
|
||||
// 2
|
||||
// ) AS billed_amt,
|
||||
@ -511,7 +510,7 @@ class PolicyTransactionModel extends Model
|
||||
// ->join('user_profiles AS service_user', 'policy_transaction.serviced_by = service_user.id', 'left')
|
||||
// ->where('policy_transaction.is_active', 1)
|
||||
// ->where('pt_co_share_details.is_active', 1);
|
||||
|
||||
|
||||
// // Check if the start date and end date are provided
|
||||
// if ($start_date != 0 && $end_date != 0 && $date_type != 0 && $date_type != 'statement_month') {
|
||||
|
||||
@ -547,7 +546,7 @@ class PolicyTransactionModel extends Model
|
||||
// if ($client_id != 0) {
|
||||
// $builder->where('policy_transaction.client_id', $client_id);
|
||||
// }
|
||||
|
||||
|
||||
// if ($insurer_id != 0) {
|
||||
// $builder->where('policy_transaction.insurer_id', $insurer_id);
|
||||
// }
|
||||
@ -555,7 +554,7 @@ class PolicyTransactionModel extends Model
|
||||
// if ($client_branch_id != 0) {
|
||||
// $builder->where('policy_transaction.client_branch_id', $client_branch_id);
|
||||
// }
|
||||
|
||||
|
||||
// if ($insurer_branch_id != 0) {
|
||||
// $builder->where('policy_transaction.insurer_branch_id', $insurer_branch_id);
|
||||
// }
|
||||
@ -565,11 +564,11 @@ class PolicyTransactionModel extends Model
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// if ($policy_type_id != 0) {
|
||||
// $builder->where('client_policy.policy_type_id', $policy_type_id);
|
||||
// }
|
||||
|
||||
|
||||
// if ($issuer != 0) {
|
||||
// $builder->where('policy_transaction.issuer', $issuer);
|
||||
// }
|
||||
@ -578,7 +577,7 @@ class PolicyTransactionModel extends Model
|
||||
|
||||
// $fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
// $toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
|
||||
// $builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
// ->where('policy_transaction.created_at <=', $toDate);
|
||||
|
||||
@ -589,18 +588,18 @@ class PolicyTransactionModel extends Model
|
||||
// $result = $builder->get()->getResultArray();
|
||||
|
||||
// // dd($this->db->getLastQuery());
|
||||
|
||||
|
||||
// return $result;
|
||||
// }
|
||||
|
||||
public function getBDSReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $client_branch_id = 0, $insurer_branch_id = 0, $client_policy_id = 0)
|
||||
{
|
||||
public function getBDSReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $client_branch_id = 0, $insurer_branch_id = 0, $client_policy_id = 0, $where = [])
|
||||
{
|
||||
|
||||
$date_condition = '';
|
||||
if($date_type == 'statement_month' && $start_date != 0 && $end_date != 0) {
|
||||
if ($date_type == 'statement_month' && $start_date != 0 && $end_date != 0) {
|
||||
$date_condition = "
|
||||
AND insurer_statements.month >= '".$start_date ."'
|
||||
AND insurer_statements.month <= '".$end_date ."'
|
||||
AND insurer_statements.month >= '" . $start_date . "'
|
||||
AND insurer_statements.month <= '" . $end_date . "'
|
||||
";
|
||||
}
|
||||
|
||||
@ -782,7 +781,7 @@ class PolicyTransactionModel extends Model
|
||||
->join('tpa_branch', 'policy_transaction.tpa_branch_id = tpa_branch.id', 'left')
|
||||
->join('user_profiles AS sales_user', 'policy_transaction.sales_generated_by = sales_user.id', 'left')
|
||||
->join('user_profiles AS service_user', 'policy_transaction.serviced_by = service_user.id', 'left')
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->where('pt_co_share_details.is_active', 1);
|
||||
|
||||
if (
|
||||
@ -797,16 +796,18 @@ class PolicyTransactionModel extends Model
|
||||
$builder->where('policy_transaction.created_by', get_session_userid());
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($where)) {
|
||||
log_message('info', 'Where condition: ' . json_encode($where));
|
||||
$builder->where($where);
|
||||
}
|
||||
// Check if the start date and end date are provided
|
||||
if ($start_date != 0 && $end_date != 0 && $date_type != 0 && $date_type != 'statement_month') {
|
||||
|
||||
$startDate = date('Y-m-d 00:00:00', strtotime($start_date));
|
||||
$endDate = date('Y-m-d 23:59:59', strtotime($end_date));
|
||||
|
||||
$builder->where('policy_transaction.'.$date_type.'>=', $startDate)
|
||||
->where('policy_transaction.'.$date_type.'<=', $endDate);
|
||||
|
||||
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
|
||||
->where('policy_transaction.' . $date_type . '<=', $endDate);
|
||||
}
|
||||
|
||||
// if($date_type == 'statement_month' && $start_date != 0 && $end_date != 0){
|
||||
@ -823,17 +824,17 @@ class PolicyTransactionModel extends Model
|
||||
$endDate = date('Y-m-d', strtotime($end_date));
|
||||
|
||||
$builder->join('co_share_stmt_details', 'pt_co_share_details.id = co_share_stmt_details.co_share_id', 'left')
|
||||
->join('insurer_statements', 'co_share_stmt_details.statement_id = insurer_statements.id','left')
|
||||
->where('insurer_statements.is_active', 1)
|
||||
->where('insurer_statements.month >=', $startDate)
|
||||
->where('insurer_statements.month <=', $endDate)
|
||||
->groupBy('co_share_stmt_details.co_share_id');
|
||||
->join('insurer_statements', 'co_share_stmt_details.statement_id = insurer_statements.id', 'left')
|
||||
->where('insurer_statements.is_active', 1)
|
||||
->where('insurer_statements.month >=', $startDate)
|
||||
->where('insurer_statements.month <=', $endDate)
|
||||
->groupBy('co_share_stmt_details.co_share_id');
|
||||
}
|
||||
|
||||
if ($client_id != 0) {
|
||||
$builder->where('policy_transaction.client_id', $client_id);
|
||||
}
|
||||
|
||||
|
||||
if ($insurer_id != 0) {
|
||||
$builder->where('policy_transaction.insurer_id', $insurer_id);
|
||||
}
|
||||
@ -841,7 +842,7 @@ class PolicyTransactionModel extends Model
|
||||
if ($client_branch_id != 0) {
|
||||
$builder->where('policy_transaction.client_branch_id', $client_branch_id);
|
||||
}
|
||||
|
||||
|
||||
if ($insurer_branch_id != 0) {
|
||||
$builder->where('policy_transaction.insurer_branch_id', $insurer_branch_id);
|
||||
}
|
||||
@ -851,23 +852,24 @@ class PolicyTransactionModel extends Model
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ($policy_type_id != 0) {
|
||||
$builder->where('client_policy.policy_type_id', $policy_type_id);
|
||||
}
|
||||
|
||||
|
||||
if ($issuer != 0) {
|
||||
$builder->where('policy_transaction.issuer', $issuer);
|
||||
}
|
||||
|
||||
if($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0){
|
||||
if ($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0) {
|
||||
|
||||
$fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
$toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
$builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
|
||||
if (empty($where)) {
|
||||
$builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
}
|
||||
}
|
||||
|
||||
$builder->orderBy('policy_transaction.id', 'desc');
|
||||
@ -875,10 +877,10 @@ class PolicyTransactionModel extends Model
|
||||
$result = $builder->get()->getResultArray();
|
||||
|
||||
// dd($this->db->getLastQuery());
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
// public function getInceptionTranctionListData($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
|
||||
// {
|
||||
// // dd($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $status);
|
||||
@ -917,7 +919,7 @@ class PolicyTransactionModel extends Model
|
||||
|
||||
// // $fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
// // $toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
|
||||
// // $builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
// // ->where('policy_transaction.created_at <=', $toDate);
|
||||
// }
|
||||
@ -925,15 +927,15 @@ class PolicyTransactionModel extends Model
|
||||
// if ($client_id != 0) {
|
||||
// $builder->where('policy_transaction.client_id', $client_id);
|
||||
// }
|
||||
|
||||
|
||||
// if ($insurer_id != 0) {
|
||||
// $builder->where('policy_transaction.insurer_id', $insurer_id);
|
||||
// }
|
||||
|
||||
|
||||
// if ($policy_type_id != 0) {
|
||||
// $builder->where('client_policy.policy_type_id', $policy_type_id);
|
||||
// }
|
||||
|
||||
|
||||
// if ($issuer != 0) {
|
||||
// $builder->where('policy_transaction.issuer', $issuer);
|
||||
// }
|
||||
@ -945,12 +947,12 @@ class PolicyTransactionModel extends Model
|
||||
|
||||
// $fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
// $toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
|
||||
// $builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
// ->where('policy_transaction.created_at <=', $toDate);
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// $builder->orderBy('policy_transaction.id', 'desc')->limit(10);
|
||||
|
||||
// $result = $builder->get()->getResultArray();
|
||||
@ -1003,7 +1005,7 @@ class PolicyTransactionModel extends Model
|
||||
// Optimize Date Filtering
|
||||
if (!empty($start_date) && !empty($end_date) && !empty($date_type)) {
|
||||
$builder->where("policy_transaction.$date_type >=", date('Y-m-d 00:00:00', strtotime($start_date)))
|
||||
->where("policy_transaction.$date_type <=", date('Y-m-d 23:59:59', strtotime($end_date)));
|
||||
->where("policy_transaction.$date_type <=", date('Y-m-d 23:59:59', strtotime($end_date)));
|
||||
}
|
||||
|
||||
// Apply Filters Only When Necessary
|
||||
@ -1029,7 +1031,7 @@ class PolicyTransactionModel extends Model
|
||||
$toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
$builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
}
|
||||
|
||||
// Optimize Query Execution
|
||||
@ -1038,7 +1040,7 @@ class PolicyTransactionModel extends Model
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getEndorsementTranctionListData($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
|
||||
{
|
||||
// dd($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $status);
|
||||
@ -1055,7 +1057,7 @@ class PolicyTransactionModel extends Model
|
||||
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
|
||||
->join('clients', 'policy_transaction.client_id = clients.id', 'left')
|
||||
->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left')
|
||||
->join('insurers', 'pt_co_share_details.insurer_id = insurers.id','left')
|
||||
->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left')
|
||||
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
|
||||
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
|
||||
->where('policy_transaction.is_active', 1)
|
||||
@ -1073,20 +1075,20 @@ class PolicyTransactionModel extends Model
|
||||
$builder->where('policy_transaction.created_by', get_session_userid());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
|
||||
|
||||
$startDate = date('Y-m-d 00:00:00', strtotime($start_date));
|
||||
$endDate = date('Y-m-d 23:59:59', strtotime($end_date));
|
||||
|
||||
$builder->where('policy_transaction.'.$date_type.'>=', $startDate)
|
||||
->where('policy_transaction.'.$date_type.'<=', $endDate);
|
||||
}else{
|
||||
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
|
||||
->where('policy_transaction.' . $date_type . '<=', $endDate);
|
||||
} else {
|
||||
|
||||
// $fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
// $toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
|
||||
// $builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
// ->where('policy_transaction.created_at <=', $toDate);
|
||||
}
|
||||
@ -1094,15 +1096,15 @@ class PolicyTransactionModel extends Model
|
||||
if ($client_id != 0) {
|
||||
$builder->where('policy_transaction.client_id', $client_id);
|
||||
}
|
||||
|
||||
|
||||
if ($insurer_id != 0) {
|
||||
$builder->where('policy_transaction.insurer_id', $insurer_id);
|
||||
}
|
||||
|
||||
|
||||
if ($policy_type_id != 0) {
|
||||
$builder->where('client_policy.policy_type_id', $policy_type_id);
|
||||
}
|
||||
|
||||
|
||||
if ($issuer != 0) {
|
||||
$builder->where('policy_transaction.issuer', $issuer);
|
||||
}
|
||||
@ -1110,16 +1112,15 @@ class PolicyTransactionModel extends Model
|
||||
$builder->where('policy_transaction.status', $status);
|
||||
}
|
||||
|
||||
if($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0){
|
||||
if ($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0) {
|
||||
|
||||
$fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
$toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
$builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
|
||||
$builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
}
|
||||
|
||||
|
||||
$builder->orderBy('policy_transaction.id', 'desc');
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
@ -1235,14 +1236,14 @@ class PolicyTransactionModel extends Model
|
||||
// ->having('premium_variance_amt !=',0);
|
||||
|
||||
// ->group_start()
|
||||
->having('variance_amt IS NOT NULL')
|
||||
->orHaving('variance_amt !=', 0)
|
||||
->having('premium_variance_amt IS NOT NULL')
|
||||
->orHaving('premium_variance_amt !=', 0);
|
||||
// ->group_end();
|
||||
// ->where('pt_co_share_details.actual_bp_brokerage_amt IS NOT NULL AND pt_co_share_details.actual_bp_brokerage_amt != 0');
|
||||
// ->where('pt_co_share_details.variance IS NOT NULL')
|
||||
// ->where('pt_co_share_details.variance !=', 0);
|
||||
->having('variance_amt IS NOT NULL')
|
||||
->orHaving('variance_amt !=', 0)
|
||||
->having('premium_variance_amt IS NOT NULL')
|
||||
->orHaving('premium_variance_amt !=', 0);
|
||||
// ->group_end();
|
||||
// ->where('pt_co_share_details.actual_bp_brokerage_amt IS NOT NULL AND pt_co_share_details.actual_bp_brokerage_amt != 0');
|
||||
// ->where('pt_co_share_details.variance IS NOT NULL')
|
||||
// ->where('pt_co_share_details.variance !=', 0);
|
||||
|
||||
if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
|
||||
|
||||
@ -1279,7 +1280,7 @@ class PolicyTransactionModel extends Model
|
||||
if ($client_branch_id != 0) {
|
||||
$builder->where('policy_transaction.client_branch_id', $client_branch_id);
|
||||
}
|
||||
|
||||
|
||||
if ($insurer_branch_id != 0) {
|
||||
$builder->where('policy_transaction.insurer_branch_id', $insurer_branch_id);
|
||||
}
|
||||
@ -1296,6 +1297,7 @@ class PolicyTransactionModel extends Model
|
||||
|
||||
public function getBusinessReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
|
||||
{
|
||||
$dateThreshold = date('Y-m-d H:i:s', strtotime("- 3 days"));
|
||||
$builder = $this->db->table('policy_transaction')
|
||||
->select([
|
||||
'policy_transaction.id AS policy_trns_id',
|
||||
@ -1319,9 +1321,19 @@ class PolicyTransactionModel extends Model
|
||||
->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left')
|
||||
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
|
||||
->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
|
||||
->join(
|
||||
'(SELECT policy_tran_id, MAX(created_at) AS last_policy_status_change,is_active
|
||||
FROM policy_transaction_status
|
||||
WHERE is_active = 1
|
||||
GROUP BY policy_tran_id) th',
|
||||
'policy_transaction.id = th.policy_tran_id'
|
||||
|
||||
)
|
||||
->where("th.last_policy_status_change <= '{$dateThreshold}'", null, false)
|
||||
->where('policy_transaction.is_active', 1)
|
||||
// ->where('policy_transaction.status', 'completed')
|
||||
->where('pt_co_share_details.bp_amt IS NULL OR pt_co_share_details.bp_amt = 0');
|
||||
->where('(pt_co_share_details.bp_amt IS NULL OR pt_co_share_details.bp_amt = 0)', null, false);
|
||||
|
||||
|
||||
if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
|
||||
|
||||
@ -1360,15 +1372,21 @@ class PolicyTransactionModel extends Model
|
||||
}
|
||||
|
||||
$builder->orderBy('policy_transaction.id', 'desc');
|
||||
// echo $builder->getCompiledSelect();
|
||||
// exit;
|
||||
|
||||
$returnData = $builder->get()->getResultArray();
|
||||
|
||||
|
||||
|
||||
// dd($returnData);
|
||||
return $returnData;
|
||||
}
|
||||
|
||||
public function getFinanceReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
|
||||
{
|
||||
$dateThreshold = date('Y-m-d H:i:s', strtotime("- 3 days"));
|
||||
|
||||
$builder = $this->db->table('policy_transaction')
|
||||
->select("
|
||||
policy_transaction.id,
|
||||
@ -1391,11 +1409,20 @@ class PolicyTransactionModel extends Model
|
||||
->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left')
|
||||
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
|
||||
->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
|
||||
->join(
|
||||
'(SELECT policy_tran_id, MAX(created_at) AS last_policy_status_change,is_active
|
||||
FROM policy_transaction_status
|
||||
WHERE is_active = 1
|
||||
GROUP BY policy_tran_id) th',
|
||||
'policy_transaction.id = th.policy_tran_id'
|
||||
|
||||
)
|
||||
->where("th.last_policy_status_change <= '{$dateThreshold}'", null, false)
|
||||
->where('policy_transaction.is_active', 1)
|
||||
// ->where('policy_transaction.status', 'completed')
|
||||
->where('COALESCE(pt_co_share_details.agreed_bp_per, 0) + COALESCE(pt_co_share_details.agreed_tp_per, 0) + COALESCE(pt_co_share_details.agreed_tep_per, 0) = 0')
|
||||
->where('COALESCE(pt_co_share_details.actual_bp_amt, 0) + COALESCE(pt_co_share_details.actual_tp_amt, 0) + COALESCE(pt_co_share_details.actual_tep_amt, 0) = 0')
|
||||
->where('COALESCE(pt_co_share_details.actual_bp_brokerage_amt, 0) + COALESCE(pt_co_share_details.actual_tp_brokerage_amt, 0) + COALESCE(pt_co_share_details.actual_tep_brokerage_amt, 0) = 0');
|
||||
->where('COALESCE(pt_co_share_details.actual_bp_brokerage_amt, 0) + COALESCE(pt_co_share_details.actual_tp_brokerage_amt, 0) + COALESCE(pt_co_share_details.actual_tep_brokerage_amt, 0) = 0');
|
||||
|
||||
|
||||
if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
|
||||
@ -1492,55 +1519,55 @@ class PolicyTransactionModel extends Model
|
||||
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
|
||||
->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
|
||||
->where('policy_transaction.is_active', 1);
|
||||
|
||||
|
||||
// Date range filtering
|
||||
if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
|
||||
$startDate = date('Y-m-d 00:00:00', strtotime($start_date));
|
||||
$endDate = date('Y-m-d 23:59:59', strtotime($end_date));
|
||||
|
||||
|
||||
$builder->where('policy_transaction.' . $date_type . '>=', $startDate)
|
||||
->where('policy_transaction.' . $date_type . '<=', $endDate);
|
||||
} else {
|
||||
$fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
$toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
|
||||
$builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
}
|
||||
|
||||
|
||||
// Additional filters
|
||||
if ($client_id != 0) {
|
||||
$builder->where('policy_transaction.client_id', $client_id);
|
||||
}
|
||||
|
||||
|
||||
if ($insurer_id != 0) {
|
||||
$builder->where('policy_transaction.insurer_id', $insurer_id);
|
||||
}
|
||||
|
||||
|
||||
if ($policy_type_id != 0) {
|
||||
$builder->where('client_policy.policy_type_id', $policy_type_id);
|
||||
}
|
||||
|
||||
|
||||
if ($issuer != 0) {
|
||||
$builder->where('policy_transaction.issuer', $issuer);
|
||||
}
|
||||
|
||||
|
||||
if ($status != 0) {
|
||||
$builder->where('policy_transaction.status', $status);
|
||||
}
|
||||
|
||||
|
||||
// Filter where outstanding_amount is not null
|
||||
$builder->having('outstanding_amount IS NOT NULL');
|
||||
|
||||
|
||||
$builder->orderBy('policy_transaction.id', 'desc');
|
||||
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
public function getOutstandingReportList($start_date = 0, $end_date = 0, $insurer_id = 0,$insurer_branch_id = 0)
|
||||
public function getOutstandingReportList($start_date = 0, $end_date = 0, $insurer_id = 0, $insurer_branch_id = 0)
|
||||
{
|
||||
$builder = $this->db->table('insurer_statements s')
|
||||
->select('
|
||||
->select('
|
||||
s.id,
|
||||
s.insurer_id,
|
||||
s.branch_id,
|
||||
@ -1556,32 +1583,32 @@ class PolicyTransactionModel extends Model
|
||||
COALESCE(SUM(p.inv_amt) + SUM(p.tds) + SUM(p.gst), 0) AS total_paid,
|
||||
(s.invoice_amount - COALESCE(SUM(p.inv_amt) + SUM(p.tds) + SUM(p.gst), 0)) AS outstanding_amount
|
||||
')
|
||||
->join('inv_payment_details p', 's.id = p.statement_id', 'left')
|
||||
->join('insurers ins', 's.insurer_id = ins.id')
|
||||
->join('insurer_branch ib', 's.branch_id = ib.id')
|
||||
->where('s.is_active', 1)
|
||||
->where('p.is_active', 1)
|
||||
->groupBy('s.id, s.invoice_no, s.invoice_date, s.invoice_amount')
|
||||
->having('outstanding_amount >', 0);
|
||||
// ->get();
|
||||
->join('inv_payment_details p', 's.id = p.statement_id', 'left')
|
||||
->join('insurers ins', 's.insurer_id = ins.id')
|
||||
->join('insurer_branch ib', 's.branch_id = ib.id')
|
||||
->where('s.is_active', 1)
|
||||
->where('p.is_active', 1)
|
||||
->groupBy('s.id, s.invoice_no, s.invoice_date, s.invoice_amount')
|
||||
->having('outstanding_amount >', 0);
|
||||
// ->get();
|
||||
|
||||
|
||||
|
||||
// Date range filtering
|
||||
if ($start_date != 0 && $end_date != 0) {
|
||||
|
||||
|
||||
$builder->where('s.month >=', $start_date)
|
||||
->where('s.month <=', $end_date);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($insurer_id != 0) {
|
||||
$builder->where('s.insurer_id', $insurer_id);
|
||||
}
|
||||
if ($insurer_branch_id != 0) {
|
||||
if ($insurer_branch_id != 0) {
|
||||
$builder->where('s.branch_id', $insurer_branch_id);
|
||||
}
|
||||
|
||||
$builder->orderBy('s.id', 'desc');
|
||||
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
@ -1591,12 +1618,12 @@ class PolicyTransactionModel extends Model
|
||||
{
|
||||
$fromDate = date('Y-m-d', strtotime('-60 days'));
|
||||
$toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
|
||||
if (!empty($start_date) && !empty($end_date)) {
|
||||
$fromDate = change_date_format($start_date);
|
||||
$toDate = change_date_format($end_date);
|
||||
}
|
||||
|
||||
|
||||
$query = $this->db->table('policy_transaction pt')
|
||||
->select('
|
||||
pt.*,
|
||||
@ -1621,7 +1648,7 @@ class PolicyTransactionModel extends Model
|
||||
->where('pt.is_active', 1)
|
||||
->where('pt_co.is_active', 1)
|
||||
->where('pt.action_type', "inception");
|
||||
|
||||
|
||||
// Apply filters if parameters are provided
|
||||
if (!empty($client_type)) {
|
||||
$query->where('c.client_type', $client_type);
|
||||
@ -1632,7 +1659,7 @@ class PolicyTransactionModel extends Model
|
||||
if (!empty($issuer)) { // Corrected condition to check $issuer
|
||||
$query->where('pt.issuer', $issuer);
|
||||
}
|
||||
|
||||
|
||||
$query->groupBy('pt.id');
|
||||
$query->orderBy('pt.id', 'DESC');
|
||||
// Fetch and return results
|
||||
@ -1640,6 +1667,47 @@ class PolicyTransactionModel extends Model
|
||||
// print($this->db->getLastQuery()); die;
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getBDSRenewalData()
|
||||
{
|
||||
// Increase GROUP_CONCAT limit
|
||||
$this->db->query("SET SESSION group_concat_max_len = 1000000;");
|
||||
|
||||
$builder = $this->db->table('policy_transaction pt');
|
||||
|
||||
$builder->select([
|
||||
'SUM(CASE WHEN pt.policy_end_date < CURDATE() THEN 1 ELSE 0 END) AS Expired',
|
||||
'SUM(CASE WHEN pt.policy_end_date BETWEEN CURDATE() AND (CURDATE() + INTERVAL 1 MONTH) THEN 1 ELSE 0 END) AS `Renewal Pending`',
|
||||
'GROUP_CONCAT(CASE WHEN pt.policy_end_date < CURDATE() THEN pt.id ELSE NULL END) AS Expired_ids',
|
||||
'GROUP_CONCAT(CASE WHEN pt.policy_end_date BETWEEN CURDATE() AND (CURDATE() + INTERVAL 1 MONTH) THEN pt.id ELSE NULL END) AS Renewal_Pending_ids'
|
||||
]);
|
||||
$builder->where("pt.policy_end_date IS NOT NULL", null, false);
|
||||
$builder->where('pt.is_active', 1);
|
||||
|
||||
// Self join to check if a policy has been renewed
|
||||
$builder->join('policy_transaction renewed', 'renewed.source_client_policy_id = pt.client_policy_id and renewed.client_id = pt.client_id and renewed.client_branch_id = pt.client_branch_id', 'left');
|
||||
|
||||
// Filter for expired or expiring policies
|
||||
$builder->where("(pt.policy_end_date < CURDATE() OR pt.policy_end_date BETWEEN CURDATE() AND (CURDATE() + INTERVAL 1 MONTH))", null, false);
|
||||
|
||||
$builder->where('renewed.id IS NULL', null, false);
|
||||
$query = $builder->get();
|
||||
$result = $query->getResultArray();
|
||||
|
||||
$total = 0;
|
||||
foreach ($result[0] as $key => $value) {
|
||||
if ($key !== 'Expired_ids' && $key !== 'Renewal_Pending_ids') {
|
||||
$total += $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure ID fields are arrays (not null)
|
||||
$result[0]['Expired_ids'] = $result[0]['Expired_ids'] ? $result[0]['Expired_ids'] : [];
|
||||
$result[0]['Renewal Pending_ids'] = $result[0]['Renewal_Pending_ids'] ? $result[0]['Renewal_Pending_ids'] : [];
|
||||
|
||||
// Add total count
|
||||
$result[0]['total'] = $total;
|
||||
|
||||
return $result[0];
|
||||
}
|
||||
}
|
||||
|
||||
@ -726,76 +726,145 @@ class TicketMasterModel extends Model
|
||||
$finalResults = [];
|
||||
|
||||
foreach ($claim_statuses as $typeId => $statuses) {
|
||||
$builder = $this->db->table('ticket_master tm');
|
||||
// Get all active, non-null claim status tickets for this type
|
||||
$builder = $this->db->table('ticket_master tm')
|
||||
->select('tm.id, tm.ticket_type_id, tcs.claim_status, th.last_claim_status_change')
|
||||
->join('ticket_claim_status tcs', 'tm.claim_status_id = tcs.id', 'left')
|
||||
->join(
|
||||
'(SELECT ticket_id, MAX(created_at) AS last_claim_status_change
|
||||
FROM ticket_history
|
||||
WHERE field_name = \'claim_status_id\'
|
||||
GROUP BY ticket_id) th',
|
||||
'tm.id = th.ticket_id',
|
||||
'left'
|
||||
)
|
||||
->where('tm.ticket_type_id', $typeId)
|
||||
->where('tm.is_active', 1)
|
||||
->where('tm.claim_status_id IS NOT NULL');
|
||||
|
||||
// Start with ticket_type_id in SELECT
|
||||
$selects = ['tm.ticket_type_id'];
|
||||
$results = $builder->get()->getResultArray();
|
||||
|
||||
// Dynamically build status counts with COALESCE to handle missing values
|
||||
foreach ($statuses as $status) {
|
||||
$alias = strtolower($status);
|
||||
$alias = str_replace(' ', '_', $alias);
|
||||
$selects[] = "COALESCE(SUM(CASE WHEN tcs.claim_status = " . $this->db->escape($status) . " AND tm.ticket_type_id = {$typeId} THEN 1 ELSE 0 END), 0) AS `{$alias}`";
|
||||
}
|
||||
$summary = [
|
||||
'ticket_type_id' => $typeId,
|
||||
];
|
||||
|
||||
$builder->select(implode(',', $selects));
|
||||
$builder->join('ticket_claim_status tcs', 'tm.claim_status_id = tcs.id', 'left');
|
||||
|
||||
// Subquery for latest status change, with LEFT JOIN to avoid missing ticket_type_id
|
||||
$builder->join(
|
||||
'(SELECT ticket_id, MAX(created_at) AS last_claim_status_change
|
||||
FROM ticket_history
|
||||
WHERE field_name = \'claim_status_id\'
|
||||
GROUP BY ticket_id) th',
|
||||
'tm.id = th.ticket_id',
|
||||
'left'
|
||||
);
|
||||
|
||||
// Set the date limit based on the status
|
||||
foreach ($statuses as $status) {
|
||||
$dateLimit = $limit[$typeId][$status] ?? 3;
|
||||
$dateThreshold = date('Y-m-d H:i:s', strtotime("-{$dateLimit} days"));
|
||||
|
||||
$builder->groupStart()
|
||||
->where('th.last_claim_status_change <=', $dateThreshold)
|
||||
->orWhere('th.last_claim_status_change IS NULL')
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
|
||||
$builder->where('tm.ticket_type_id', $typeId);
|
||||
$builder->where('tm.is_active', 1);
|
||||
$builder->where('tm.claim_status_id is not null');
|
||||
|
||||
$builder->groupBy('tm.ticket_type_id');
|
||||
|
||||
$query = $builder->get();
|
||||
$result = $query->getRowArray();
|
||||
|
||||
// Add Total count
|
||||
$total = 0;
|
||||
foreach ($result as $key => $res) {
|
||||
// Ensure that ticket_type_id is excluded from the sum
|
||||
if ($key !== 'ticket_type_id') {
|
||||
$total += $res;
|
||||
}
|
||||
}
|
||||
$result['total'] = $total;
|
||||
foreach ($statuses as $status) {
|
||||
$alias = strtolower(str_replace(' ', '_', $status));
|
||||
$summary[$alias] = 0;
|
||||
$summary[$alias . '_ids'] = '';
|
||||
|
||||
// If no result, initialize an empty result for the ticket_type_id
|
||||
if (!$result) {
|
||||
$result = ['ticket_type_id' => $typeId, 'total' => 0];
|
||||
foreach ($statuses as $status) {
|
||||
$alias = strtolower($status);
|
||||
$alias = str_replace(' ', '_', $alias);
|
||||
$result[$alias] = 0;
|
||||
$dateLimit = $limit[$typeId][$status] ?? 3;
|
||||
$threshold = date('Y-m-d H:i:s', strtotime("-{$dateLimit} days"));
|
||||
|
||||
$ticketIds = [];
|
||||
// dd($results);
|
||||
foreach ($results as $row) {
|
||||
if (
|
||||
$row['claim_status'] === $status &&
|
||||
(
|
||||
!$row['last_claim_status_change'] ||
|
||||
$row['last_claim_status_change'] <= $threshold
|
||||
)
|
||||
) {
|
||||
$summary[$alias]++;
|
||||
$ticketIds[] = $row['id'];
|
||||
if ($status == "APPROVED"|| $status == "SETTLED"|| $status == "CLOSED" ){
|
||||
continue;
|
||||
}
|
||||
|
||||
$total++;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Convert ticket IDs array to a comma-separated string
|
||||
$summary[$alias . '_ids'] = implode(',', $ticketIds);
|
||||
}
|
||||
|
||||
// Add the result to the final array
|
||||
$finalResults[$typeId] = $result;
|
||||
$summary['total'] = $total;
|
||||
|
||||
// Add approved but not settled IDs and count
|
||||
$approvedNotSettled = $this->getNotSettledbutApprovedCount($typeId);
|
||||
$summary['approved_not_settled'] = $approvedNotSettled['count'];
|
||||
$summary['approved_not_settled_ids'] = $approvedNotSettled['ticket_ids'];
|
||||
|
||||
$finalResults[$typeId] = $summary;
|
||||
}
|
||||
|
||||
// dd($finalResults);
|
||||
return $finalResults;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getNotSettledbutApprovedCount($ticket_type)
|
||||
{
|
||||
// Fetch the approved and settled claim_status IDs
|
||||
$builder = $this->db->table("ticket_claim_status approved")
|
||||
->select("approved.id AS approved_id, settled.id AS settled_id")
|
||||
->join("ticket_claim_status settled", "approved.ticket_type = settled.ticket_type")
|
||||
->where("approved.claim_status", "APPROVED")
|
||||
->where("settled.claim_status", "SETTLED")
|
||||
->where("approved.ticket_type", $ticket_type)
|
||||
->where("approved.is_active", 1)
|
||||
->where("settled.is_active", 1);
|
||||
|
||||
$ids = $builder->get()->getRowArray();
|
||||
|
||||
// If no matching status IDs are found, return empty
|
||||
if (!$ids) {
|
||||
return ['count' => 0, 'ticket_ids' => ''];
|
||||
}
|
||||
|
||||
// Extract approved and settled status IDs
|
||||
$approved_id = $ids['approved_id'];
|
||||
$settled_id = $ids['settled_id'];
|
||||
|
||||
// Subquery to get the latest approval time for each ticket
|
||||
$subquery = $this->db->table('ticket_history')
|
||||
->select('ticket_id, MAX(created_at) AS approved_time')
|
||||
->where('field_name', 'claim_status_id')
|
||||
->where('new_value', $approved_id)
|
||||
->groupBy('ticket_id');
|
||||
|
||||
// Main query to find tickets that are approved but not settled
|
||||
$builder = $this->db->table('ticket_master tm');
|
||||
|
||||
$builder->join("({$subquery->getCompiledSelect()}) latest_approval", 'tm.id = latest_approval.ticket_id', 'inner');
|
||||
|
||||
// Left join to find if there is a settled status for each ticket after approval
|
||||
$builder->join(
|
||||
'ticket_history th_settled',
|
||||
"th_settled.ticket_id = tm.id
|
||||
AND th_settled.field_name = 'claim_status_id'
|
||||
AND th_settled.new_value = {$settled_id}
|
||||
AND th_settled.created_at > latest_approval.approved_time",
|
||||
'left',
|
||||
false // Important for raw ON condition
|
||||
);
|
||||
|
||||
// Filtering conditions: not settled and approved time older than 12 days
|
||||
$builder->where('tm.claim_status_id !=', $settled_id);
|
||||
$builder->where('tm.is_active', 1);
|
||||
$builder->where("latest_approval.approved_time <= DATE_SUB(NOW(), INTERVAL 12 DAY)", null, false);
|
||||
$builder->where('th_settled.id IS NULL', null, false);
|
||||
|
||||
// Final select to get ticket IDs of approved but not settled tickets
|
||||
$builder->select('tm.id');
|
||||
|
||||
// Execute the query
|
||||
$query = $builder->get();
|
||||
$ticketIds = array_column($query->getResultArray(), 'id'); // Extract the IDs
|
||||
|
||||
// Convert ticket IDs array to a comma-separated string
|
||||
$ticketIdsString = implode(',', $ticketIds);
|
||||
|
||||
// Return the count and comma-separated ticket IDs
|
||||
return [
|
||||
'count' => count($ticketIds),
|
||||
'ticket_ids' => $ticketIdsString
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@
|
||||
|
||||
</style>
|
||||
|
||||
<?php if(in_array(get_role_id(), [1,2,3,5]) || (in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { ?>
|
||||
<?php if(in_array(get_role_id(), [1,2,3,4,5]) || (in_array(ENROLLMENT_TEAM_ID, user_team()) || in_array(CLAIMS_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { ?>
|
||||
|
||||
<div class="row" id="client_add" style="margin-top: -32px;">
|
||||
<div class="col-12">
|
||||
@ -217,28 +217,43 @@
|
||||
</li>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php if ((get_role_id() == STAFF_ROLE_ID && in_array(CLAIMS_TEAM_ID,user_team())) || in_array(get_role_id(),[1,5])) :?>
|
||||
<?php
|
||||
$isActive = get_role_id() == STAFF_ROLE_ID && in_array(CLAIMS_TEAM_ID,user_team()) ? 'active show' : '';
|
||||
?>
|
||||
<li class="nav-item">
|
||||
<a href="#claims-dash-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="claims_tab">
|
||||
<a href="#claims-dash-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2 <?= $isActive?>" id="claims_tab">
|
||||
<span class="mr-1"><i class="fa fa-file-alt"></i> </span>
|
||||
<span class="d-none d-sm-inline-block">Claims</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<?php endif; ?>
|
||||
<?php if ((get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_team())) || in_array(get_role_id(),[1,5])) :?>
|
||||
<?php
|
||||
$isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_team()) ? 'active show' : '';
|
||||
?>
|
||||
<li class="nav-item">
|
||||
<a href="#leads-dash-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="leads_tab">
|
||||
<a href="#leads-dash-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2 <?= $isActive?>" id="leads_tab">
|
||||
<span class="mr-1"><i class="fa fa-file-alt"></i> </span>
|
||||
<span class="d-none d-sm-inline-block">Leads and Renewals</span>
|
||||
<span class="d-none d-sm-inline-block">Leads and BDS Renewals</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<?php include("claims_dash.php") ?>
|
||||
<?php if ((get_role_id() == STAFF_ROLE_ID && in_array(CLAIMS_TEAM_ID,user_team())) || in_array(get_role_id(),[1,5])) :?>
|
||||
<?php include("claims_dash.php") ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if(in_array(get_role_id(), [1,2,3,5]) || (get_role_id() == 4 && in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { ?>
|
||||
<?php include('bds_dash.php'); ?>
|
||||
<?php } ?>
|
||||
<?php include("leads_dash.php") ?>
|
||||
<?php if ((get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_team())) || in_array(get_role_id(),[1,5])) :?>
|
||||
<?php include("leads_dash.php") ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if(in_array(get_role_id(), [1,2,3,5])) { ?>
|
||||
<?php include('endorsement_dash.php'); ?>
|
||||
|
||||
@ -131,11 +131,14 @@ body{
|
||||
|
||||
|
||||
<div class="tab-pane <?= isset($add_active_calss) ? $add_active_calss : 'fade' ?>" id="bds-dash-tab" style="padding-right: 35px;">
|
||||
|
||||
<div class="StatusTileHide" style="display: none; position: relative; bottom: 15px;">
|
||||
<a href="#" onclick="hide_status_show_pending_tile()" >show all pending Tile</a>
|
||||
<div class="row">
|
||||
<div class="StatusTileHide" style="display: none; padding-bottom: 10px;padding-left: 17px">
|
||||
<a href="#" onclick="hide_status_show_pending_tile()" ><i class="fas fa-arrow-left"></i> Back to Overview</a>
|
||||
</div>
|
||||
<div class="StatusTileHide" style="display: none;padding-left: 30px;">
|
||||
<a href="#" id="mainMenuTiles">Current Tile : </a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<?php if (in_array(BUSINESS_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team())) { ?>
|
||||
@ -224,6 +227,10 @@ body{
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function(){
|
||||
$(".StatusTileHide").hide();
|
||||
})
|
||||
|
||||
function linkRedirectForBDS(input, team)
|
||||
{
|
||||
var link = "";
|
||||
@ -244,6 +251,7 @@ function show_business_status_tile(){
|
||||
|
||||
$('.businessStatusTile').show()
|
||||
$('.StatusTileHide').show()
|
||||
$("#mainMenuTiles").text("Viewing Details of Business Team Pending");
|
||||
|
||||
$('.businessPendingTile').hide()
|
||||
$('.financePendingTile').hide()
|
||||
@ -257,6 +265,8 @@ function show_finance_status_tile(){
|
||||
|
||||
$('.financePendingTile').hide()
|
||||
$('.businessPendingTile').hide()
|
||||
$("#mainMenuTiles").text("Viewing Details of Finance Team Pending");
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -267,6 +277,6 @@ function hide_status_show_pending_tile(){
|
||||
$('.businessStatusTile').hide()
|
||||
$('.financePendingTile').show()
|
||||
$('.businessPendingTile').show()
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -124,8 +124,10 @@
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="tab-pane fade" id="claims-dash-tab">
|
||||
<?php
|
||||
$isActive = get_role_id() == STAFF_ROLE_ID && in_array(CLAIMS_TEAM_ID,user_team()) ? 'active show' : '';
|
||||
?>
|
||||
<div class="tab-pane fade <?= $isActive ?>" id="claims-dash-tab">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-xl-3 claimTypeTile">
|
||||
<div class="card bg-c-Pelorous order-card" onclick="hideAndShowTile(1,1)">
|
||||
@ -172,9 +174,13 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="goBack">
|
||||
<a href="#" onclick="hideAndShowTile('2')">show all pending Tile<br></a>
|
||||
<div class="row">
|
||||
<div class="goBack" style="padding-bottom: 10px;padding-left: 17px;">
|
||||
<a href="#" onclick="hideAndShowTile('2')" ><i class="fas fa-arrow-left"></i> Back to Overview<br></a>
|
||||
</div>
|
||||
<div class="goBack" style="display: none;padding-left: 30px;">
|
||||
<a href="#" id="current_tile">Current Tile : </a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<?php
|
||||
@ -196,7 +202,7 @@
|
||||
<?php foreach ($statuses as $status => $count) : ?>
|
||||
<?php
|
||||
// Skip metadata fields
|
||||
if ($status === 'ticket_type_id' || $status === 'total') {
|
||||
if ($status === 'ticket_type_id'|| $status == "approved"|| $status == "settled"|| $status == "closed" || $status === 'total' || substr($status, -4) === "_ids") {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -208,7 +214,7 @@
|
||||
$showTooltip = strlen($formattedStatus) > 20;
|
||||
?>
|
||||
<div class="col-md-2 col-xl-1 claimStatusTitle_<?= $ticketTypeId ?>" style="display: none;">
|
||||
<div class="card order-card" style="background: <?= $bgColor ?>;" onclick="linkRedirectForClaims(<?= $ticketTypeId ?>, '<?= $status ?>')">
|
||||
<div class="card order-card" style="background: <?= $bgColor ?>;" onclick="linkRedirectForClaims(<?= $ticketTypeId ?>, '<?= $status ?>','<?= $statuses[$status . '_ids'] ?? '' ?>')">
|
||||
<h2 class="text-center"><span><?= $count ?></span></h2>
|
||||
<h6 class="m-b-20 font-15 text-center"
|
||||
<?= $showTooltip ? 'data-toggle="tooltip" title="' . htmlspecialchars($formattedStatus, ENT_QUOTES, 'UTF-8') . '"' : '' ?>>
|
||||
@ -248,39 +254,58 @@
|
||||
|
||||
$('.claimTypeTile').hide();
|
||||
$('.claimStatusTitle_' + claimType).show();
|
||||
|
||||
if (claimType == 1) {
|
||||
$('#current_tile').text("Viewing Details For : GMC");
|
||||
} else if (claimType == 2) {
|
||||
$('#current_tile').text("Viewing Details For : GPA");
|
||||
} else if (claimType == 3) {
|
||||
$('#current_tile').text("Viewing Details For : EDLI");
|
||||
} else if (claimType == 4) {
|
||||
$('#current_tile').text("Viewing Details For : GTLI");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function linkRedirectForClaims(ticketTypeId, status) {
|
||||
function linkRedirectForClaims(ticketTypeId, status,ids) {
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
$.ajax({
|
||||
url: "<?= base_url("/dashboard/prepareClaimSearchData") ?>",
|
||||
type: "POST",
|
||||
data: {
|
||||
ticketTypeId: ticketTypeId,
|
||||
status: status
|
||||
},
|
||||
success: function(response) {
|
||||
// Handle the response from the server
|
||||
if (response.status === 'success') {
|
||||
// Redirect to the claims list page with the selected filters
|
||||
console.log("response", response);
|
||||
// alert(JSON.stringify(response));
|
||||
data = response.data;
|
||||
data.is_dashboard = 1;
|
||||
redirectWithPost("<?= base_url("ticket/list") ?>", data);
|
||||
} else {
|
||||
// Handle error case
|
||||
console.log('Error: ' + response.message);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle AJAX error
|
||||
console.error('AJAX Error:', error);
|
||||
// alert('An error occurred while processing your request.');
|
||||
}
|
||||
})
|
||||
// $.ajax({
|
||||
// url: "<?= base_url("/dashboard/prepareClaimSearchData") ?>",
|
||||
// type: "POST",
|
||||
// data: {
|
||||
// ticketTypeId: ticketTypeId,
|
||||
// status: status
|
||||
// },
|
||||
// success: function(response) {
|
||||
// // Handle the response from the server
|
||||
// if (response.status === 'success') {
|
||||
// // Redirect to the claims list page with the selected filters
|
||||
// console.log("response", response);
|
||||
// // alert(JSON.stringify(response));
|
||||
// data = response.data;
|
||||
// data.is_dashboard = 1;
|
||||
// redirectWithPost("<?= base_url("ticket/list") ?>", data);
|
||||
// } else {
|
||||
// // Handle error case
|
||||
// console.log('Error: ' + response.message);
|
||||
// }
|
||||
// },
|
||||
// error: function(xhr, status, error) {
|
||||
// // Handle AJAX error
|
||||
// console.error('AJAX Error:', error);
|
||||
// // alert('An error occurred while processing your request.');
|
||||
// }
|
||||
// })
|
||||
|
||||
data = {
|
||||
is_dashboard: 1,
|
||||
ids : ids
|
||||
}
|
||||
|
||||
|
||||
|
||||
redirectWithPost("<?= base_url("ticket/list") ?>", data);
|
||||
}
|
||||
|
||||
function redirectWithPost(url, data = {}) {
|
||||
|
||||
@ -179,7 +179,7 @@
|
||||
<textarea class="form-control" name="pull_emp_obj" onchange="checkValidJson(this)" id="pull_emp_obj" rows="3" placeholder="Enter the object type"><?= isset($api_data) ? htmlspecialchars($api_data['pull_emp_obj']) : "" ?></textarea>
|
||||
</div>
|
||||
|
||||
</div><hr>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<label>Webhook Action</label>
|
||||
@ -222,6 +222,7 @@
|
||||
<div class="d-flex justify-content-end">
|
||||
<button class="btn btn-primary waves-effect waves-light mr-1" type="submit" id="formSubmit">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -88,12 +88,12 @@ body {
|
||||
<span class="d-none d-sm-inline-block">Policies</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<!-- <li class="nav-item">
|
||||
<a href="#api-tab" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2" id="api_tab">
|
||||
<span class="mdi mdi-api"></span>
|
||||
<span class="d-none d-sm-inline-block">API</span>
|
||||
</a>
|
||||
</li>
|
||||
</li> -->
|
||||
<li class="nav-item">
|
||||
<a href="#others-tab" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2" id="others_tab">
|
||||
<span class="mr-1"><i class="mdi mdi-tag-text-outline"></i></span>
|
||||
|
||||
@ -124,23 +124,26 @@ body{
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
</style>
|
||||
<div class="tab-pane fade" id="leads-dash-tab">
|
||||
<?php
|
||||
$isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_team()) ? 'show active' : '';
|
||||
?>
|
||||
<div class="tab-pane fade <?= $isActive ?>" id="leads-dash-tab">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-xl-3 leadTypeTile">
|
||||
<div class="card bg-c-Pelorous order-card" onclick="hide_and_show_tile(1)">
|
||||
<div class="card bg-c-Pelorous order-card" onclick="hide_and_show_tile(1,1)">
|
||||
<div class="card-block">
|
||||
<h6 class="m-b-20 font-15">Leads</h6>
|
||||
<h2 class="text-right"><i class="mdi mdi-playlist-check f-left"></i><span></span></h2>
|
||||
<h2 class="text-right"><i class="mdi mdi-playlist-check f-left"></i><span><?= isset($lead_data)? $lead_data['total'] : 0 ?></span></h2>
|
||||
<p class="m-b-1"> <span class="f-right"></span></p>
|
||||
<p class="m-b-1"> <span class="f-right"></span></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-xl-3 leadTypeTile">
|
||||
<div class="card bg-c-Pelorous order-card" onclick="hide_and_show_tile(1)">
|
||||
<div class="card bg-c-Pelorous order-card" onclick="hide_and_show_tile(1,2)">
|
||||
<div class="card-block">
|
||||
<h6 class="m-b-20 font-15">Renewals</h6>
|
||||
<h2 class="text-right"><i class="mdi mdi-playlist-check f-left"></i><span></span></h2>
|
||||
<h6 class="m-b-20 font-15">BDS Renewals</h6>
|
||||
<h2 class="text-right"><i class="mdi mdi-playlist-check f-left"></i><span><?= isset($bds_renewal) ? $bds_renewal['total'] : 0?></span></h2>
|
||||
<p class="m-b-1"> <span class="f-right"></span></p>
|
||||
<p class="m-b-1"> <span class="f-right"></span></p>
|
||||
</div>
|
||||
@ -148,26 +151,162 @@ body{
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="status_tile" style="padding-bottom: 10px;padding-left: 17px; ">
|
||||
<a href="#" onclick="hide_and_show_tile(2)" ><i class="fas fa-arrow-left"></i> Back to Overview</a>
|
||||
</div>
|
||||
<div class="status_tile" style="padding-left: 30px;">
|
||||
<a href="#" id="main_tile" >Current Tile : </a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<?php
|
||||
|
||||
$colorSetCount = count($colorShades); // Number of color sets
|
||||
$shadeCount = count($colorShades[0]); // Number of shades per set
|
||||
$index = 0;
|
||||
foreach ($lead_data as $key => $value) : ?>
|
||||
<?php
|
||||
if ($key == "total"|| $key == "won" || substr($key, -4) === "_ids") { continue; } // Skip the total key
|
||||
?>
|
||||
<?php
|
||||
// Initialize color set and shade indexes
|
||||
$colorSetIndex = floor($index / $shadeCount) % $colorSetCount; // Reset color set after each set
|
||||
$shadeIndex = $index % $shadeCount; // Cycle through shades within the set
|
||||
|
||||
<div class="status_tile" style="display: none; position: relative; bottom: 15px;">
|
||||
<a href="#" onclick="hide_and_show_tile(2)" >show all pending Tile</a>
|
||||
// Get the background color for the current tile
|
||||
$bgColor = $colorShades[$colorSetIndex][$shadeIndex];
|
||||
?>
|
||||
<?php
|
||||
$formattedStatus = strlen($key) < 5 ? strtoupper($key): ucwords(str_replace('_', ' ', $key));
|
||||
$truncatedStatus = strlen($formattedStatus) > 20 ? substr($formattedStatus, 0, 15) . '...' : $formattedStatus;
|
||||
$showTooltip = strlen($formattedStatus) > 20;
|
||||
?>
|
||||
<div class="col-md-2 col-xl-1 leadStatusTitle_1" style="display: none;">
|
||||
<div class="card order-card" style="background: <?= $bgColor ?>;" onclick="linkRedirectForLeads('<?= esc(strtolower(str_replace(' ', '_', $key)), 'js') ?>','<?= $lead_data[$key . '_ids'] ?? '' ?>')">
|
||||
<h2 class="text-center"><span><?= $value ?></span></h2>
|
||||
<h6 class="m-b-20 font-15 text-center"
|
||||
<?= $showTooltip ? 'data-toggle="tooltip" title="' . htmlspecialchars($formattedStatus, ENT_QUOTES, 'UTF-8') . '"' : '' ?>>
|
||||
<?= $truncatedStatus ?>
|
||||
</h6>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
<?php
|
||||
$colorSetCount = count($colorShades); // Number of color sets
|
||||
$shadeCount = count($colorShades[0]); // Number of shades per set
|
||||
$index = 0;
|
||||
|
||||
foreach ($bds_renewal as $key => $value) : ?>
|
||||
<?php
|
||||
if ($key == "total" || substr($key, -4) === "_ids"){ continue; } // Skip the total key
|
||||
?>
|
||||
<?php
|
||||
// Initialize color set and shade indexes
|
||||
$colorSetIndex = floor($index / $shadeCount) % $colorSetCount; // Reset color set after each set
|
||||
$shadeIndex = $index % $shadeCount; // Cycle through shades within the set
|
||||
|
||||
// Get the background color for the current tile
|
||||
$bgColor = $colorShades[$colorSetIndex][$shadeIndex];
|
||||
?>
|
||||
<?php
|
||||
$formattedStatus = strlen($key) < 5 ? strtoupper($key): ucwords(str_replace('_', ' ', $key));
|
||||
$truncatedStatus = strlen($formattedStatus) > 20 ? substr($formattedStatus, 0, 15) . '...' : $formattedStatus;
|
||||
$showTooltip = strlen($formattedStatus) > 20;
|
||||
?>
|
||||
<div class="col-md-2 col-xl-1 leadStatusTitle_2" style="display: none;">
|
||||
<div class="card order-card" style="background: <?= $bgColor ?>;" onclick="linkRedirectForPolicy('<?= isset($bds_renewal[$key . '_ids']) ? str_replace(' ', '_', $bds_renewal[$key . '_ids']) : '' ?>')">
|
||||
<h2 class="text-center"><span><?= $value ?></span></h2>
|
||||
<h6 class="m-b-20 font-15 text-center"
|
||||
<?= $showTooltip ? 'data-toggle="tooltip" title="' . htmlspecialchars($formattedStatus, ENT_QUOTES, 'UTF-8') . '"' : '' ?>>
|
||||
<?= $truncatedStatus ?>
|
||||
</h6>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function hide_and_show_tile(type) {
|
||||
|
||||
$(document).ready(function() {
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
$(".status_tile").hide();
|
||||
});
|
||||
function hide_and_show_tile(type,leadType = null) {
|
||||
|
||||
if (type == 1) {
|
||||
|
||||
$('.leadTypeTile').hide();
|
||||
$('.status_tile').show();
|
||||
|
||||
} else {
|
||||
|
||||
$('.leadTypeTile').show();
|
||||
$('.status_tile').hide();
|
||||
$('.leadStatusTitle_1').hide();
|
||||
$('.leadStatusTitle_2').hide();
|
||||
$(".status_tile").hide();
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (type == 1 && leadType != null && leadType == 1){
|
||||
$('.leadStatusTitle_1').show();
|
||||
$('#main_tile').text("Viewing Details For : Leads");
|
||||
|
||||
}
|
||||
if (type == 1 && leadType != null && leadType == 2){
|
||||
$('.leadStatusTitle_2').show();
|
||||
$("#main_tile").text("Viewing Details For : BDS Renewals");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function linkRedirectForPolicy(ids){
|
||||
var url = "<?= base_url("policy_tranction/report/list") ?>";
|
||||
var data = {
|
||||
ids : ids,
|
||||
is_dashboard : 1
|
||||
}
|
||||
|
||||
redirectWithPost(url,data);
|
||||
}
|
||||
|
||||
function linkRedirectForLeads(status,ids){
|
||||
|
||||
var url = "<?= base_url("leads/list") ?>";
|
||||
var data = {
|
||||
ids : ids,
|
||||
is_dashboard : 1
|
||||
}
|
||||
|
||||
redirectWithPost(url,data);
|
||||
}
|
||||
|
||||
function redirectWithPost(url, data = {}) {
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
const form = document.createElement('form');
|
||||
form.method = 'POST';
|
||||
form.action = url;
|
||||
|
||||
for (const key in data) {
|
||||
if (data.hasOwnProperty(key)) {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'hidden';
|
||||
input.name = key;
|
||||
input.value = data[key];
|
||||
form.appendChild(input);
|
||||
}
|
||||
}
|
||||
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -344,6 +344,7 @@
|
||||
$('#primaryKey').val('');
|
||||
$('#policy_type').val('').change();
|
||||
$('#trigger_type').val('').change();
|
||||
$("#claim_status_for_template").val("").change;
|
||||
editor.setEditorValue('');
|
||||
$('#primaryKey').val(null);
|
||||
$('#statusSwitch').prop('checked', false);
|
||||
|
||||
@ -255,153 +255,162 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('input[name="transactionMode"]').change(function() {
|
||||
if ($(this).val() === 'adjustment') {
|
||||
$('#transactionTypeRow').show();
|
||||
} else {
|
||||
$('#transactionTypeRow').hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
var record_date = flatpickr("#record_date",{
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false,
|
||||
|
||||
});
|
||||
$('#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: 'CD TransactionDetails',
|
||||
exportOptions: {
|
||||
columns: ''
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'pdf',
|
||||
text: 'PDF',
|
||||
title: 'TransactionDetails',
|
||||
exportOptions: {
|
||||
columns: ''
|
||||
}
|
||||
}
|
||||
],
|
||||
language: {
|
||||
search: "_INPUT_",
|
||||
searchPlaceholder: "Search..."
|
||||
},
|
||||
ordering: false,
|
||||
paging: true ,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
// // Event listener for radio buttons
|
||||
// $('input[name="transactionMode"]').change(function() {
|
||||
// if ($(this).val() === 'add') {
|
||||
// // Set the hidden input value to 'Deposit' when 'Deposit' radio button is selected
|
||||
// $('#subType').val('Deposit');
|
||||
// } else if ($(this).val() === 'adjustment') {
|
||||
// // Set the hidden input value to 'Adjustment' when 'Adjustment' radio button is selected
|
||||
// $('#subType').val('Adjustment');
|
||||
// }
|
||||
// });
|
||||
|
||||
$('#saveTransactionBtn').on('click', function() {
|
||||
|
||||
var amount = $('#amount').val();
|
||||
var description = $('#description').val();
|
||||
var clientId = '<?php echo $clientData->id; ?>';
|
||||
var insurerId = '<?php echo $insurerName->id; ?>';
|
||||
var transactionTypeValue = $('input[name="transactionMode"]:checked').val();
|
||||
var subType = "";
|
||||
var record_date = $('#record_date').val();
|
||||
|
||||
if(amount == ""){
|
||||
toastr.warning('Amount field is required')
|
||||
return;
|
||||
}
|
||||
|
||||
if(description == ""){
|
||||
toastr.warning('Description field is required')
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//tranction type
|
||||
if(transactionTypeValue == 1){
|
||||
transactionType = 'Credit';
|
||||
subType = '1'; // Replenishment or Deposite
|
||||
}else if(transactionTypeValue == 2){
|
||||
transactionType = 'Credit'
|
||||
subType = '2'; // Adjustment add
|
||||
}else if(transactionTypeValue == 3){
|
||||
transactionType = 'Debit'
|
||||
subType = '2'; // Adjustment reduce
|
||||
}else if(transactionTypeValue == 4){
|
||||
transactionType = 'Credit'
|
||||
subType = '5'; // Asset Policy add
|
||||
}else if(transactionTypeValue == 5){
|
||||
transactionType = 'Debit'
|
||||
subType = '5'; // Asset Policy reduce
|
||||
}else if(transactionTypeValue == 6){
|
||||
transactionType = 'Debit'
|
||||
subType = '6'; // Refund by indurer
|
||||
}
|
||||
|
||||
console.log('transactionTypeValue', transactionTypeValue)
|
||||
console.log('transactionType', transactionType)
|
||||
console.log('description ', description)
|
||||
console.log('amount ', amount)
|
||||
console.log('clientId ', clientId)
|
||||
console.log('insurerId ', insurerId)
|
||||
console.log('subType ', subType)
|
||||
|
||||
|
||||
// Send data to the server using Ajax
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '<?= base_url()."client/save_deposit" ?>',
|
||||
data: {
|
||||
amount: amount,
|
||||
description: description,
|
||||
transaction_type: transactionType,
|
||||
sub_type_id: subType, // Include sub_type_id
|
||||
client_id: clientId,
|
||||
insurer_id: insurerId,
|
||||
record_date : record_date
|
||||
},
|
||||
success: function(response) {
|
||||
// Handle success response
|
||||
toastr.success("Transaction saved successfully", "Success");
|
||||
// Reload the page or perform other actions as needed
|
||||
location.reload();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
toastr.error("Transaction save failed", "Error");
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
location.reload(); // Uncomment if you need to reload the page on error
|
||||
$(document).ready(function() {
|
||||
$('input[name="transactionMode"]').change(function() {
|
||||
if ($(this).val() === 'adjustment') {
|
||||
$('#transactionTypeRow').show();
|
||||
} else {
|
||||
$('#transactionTypeRow').hide();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
var record_date = flatpickr("#record_date", {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false,
|
||||
|
||||
});
|
||||
$('#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: 'CD TransactionDetails',
|
||||
exportOptions: {
|
||||
columns: ''
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'pdf',
|
||||
text: 'PDF',
|
||||
title: 'TransactionDetails',
|
||||
exportOptions: {
|
||||
columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||||
format: {
|
||||
body: function(data, row, column, node) {
|
||||
return data.replace(/<.*?>/g, '');
|
||||
}
|
||||
}
|
||||
},
|
||||
customize: function(doc) {
|
||||
doc.pageOrientation = 'landscape';
|
||||
doc.styles.tableHeader.alignment = 'left';
|
||||
doc.defaultStyle.alignment = 'left';
|
||||
doc.content[1].table.widths = ['9%', '9%', '8%', '9%', '10%', '9%', '9%', '9%', '9%', '11%', '8%'];
|
||||
}
|
||||
}
|
||||
|
||||
],
|
||||
language: {
|
||||
search: "_INPUT_",
|
||||
searchPlaceholder: "Search..."
|
||||
},
|
||||
ordering: false,
|
||||
paging: true,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
// // Event listener for radio buttons
|
||||
// $('input[name="transactionMode"]').change(function() {
|
||||
// if ($(this).val() === 'add') {
|
||||
// // Set the hidden input value to 'Deposit' when 'Deposit' radio button is selected
|
||||
// $('#subType').val('Deposit');
|
||||
// } else if ($(this).val() === 'adjustment') {
|
||||
// // Set the hidden input value to 'Adjustment' when 'Adjustment' radio button is selected
|
||||
// $('#subType').val('Adjustment');
|
||||
// }
|
||||
// });
|
||||
|
||||
$('#saveTransactionBtn').on('click', function() {
|
||||
|
||||
var amount = $('#amount').val();
|
||||
var description = $('#description').val();
|
||||
var clientId = '<?php echo $clientData->id; ?>';
|
||||
var insurerId = '<?php echo $insurerName->id; ?>';
|
||||
var transactionTypeValue = $('input[name="transactionMode"]:checked').val();
|
||||
var subType = "";
|
||||
var record_date = $('#record_date').val();
|
||||
|
||||
if (amount == "") {
|
||||
toastr.warning('Amount field is required')
|
||||
return;
|
||||
}
|
||||
|
||||
if (description == "") {
|
||||
toastr.warning('Description field is required')
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//tranction type
|
||||
if (transactionTypeValue == 1) {
|
||||
transactionType = 'Credit';
|
||||
subType = '1'; // Replenishment or Deposite
|
||||
} else if (transactionTypeValue == 2) {
|
||||
transactionType = 'Credit'
|
||||
subType = '2'; // Adjustment add
|
||||
} else if (transactionTypeValue == 3) {
|
||||
transactionType = 'Debit'
|
||||
subType = '2'; // Adjustment reduce
|
||||
} else if (transactionTypeValue == 4) {
|
||||
transactionType = 'Credit'
|
||||
subType = '5'; // Asset Policy add
|
||||
} else if (transactionTypeValue == 5) {
|
||||
transactionType = 'Debit'
|
||||
subType = '5'; // Asset Policy reduce
|
||||
} else if (transactionTypeValue == 6) {
|
||||
transactionType = 'Debit'
|
||||
subType = '6'; // Refund by indurer
|
||||
}
|
||||
|
||||
console.log('transactionTypeValue', transactionTypeValue)
|
||||
console.log('transactionType', transactionType)
|
||||
console.log('description ', description)
|
||||
console.log('amount ', amount)
|
||||
console.log('clientId ', clientId)
|
||||
console.log('insurerId ', insurerId)
|
||||
console.log('subType ', subType)
|
||||
|
||||
|
||||
// Send data to the server using Ajax
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '<?= base_url() . "client/save_deposit" ?>',
|
||||
data: {
|
||||
amount: amount,
|
||||
description: description,
|
||||
transaction_type: transactionType,
|
||||
sub_type_id: subType, // Include sub_type_id
|
||||
client_id: clientId,
|
||||
insurer_id: insurerId,
|
||||
record_date: record_date
|
||||
},
|
||||
success: function(response) {
|
||||
// Handle success response
|
||||
toastr.success("Transaction saved successfully", "Success");
|
||||
// Reload the page or perform other actions as needed
|
||||
location.reload();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
toastr.error("Transaction save failed", "Error");
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
location.reload(); // Uncomment if you need to reload the page on error
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user