diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 204e2f3d..34a9466e 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -374,6 +374,7 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { $routes->get("getFileErr/(:any)", "PolicyTransactionController::getFileErr/$1"); $routes->get("getInsurerStatementMonth", "PolicyTransactionController::getInsurerStatementMonth"); $routes->get("deleteStatement/(:any)", "PolicyTransactionController::deleteStatement/$1"); + //$routes->post('failedStatement',"PolicyTransactionController::failedStatementList"); }); }); @@ -430,7 +431,8 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) { $routes->post("logined", "RestAuthenticationController::logined"); $routes->post("getId", "RestAuthenticationController::getUserIdFromToken"); }); -// $routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy"); +$routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy"); +$routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy"); $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData"); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index ec4f7478..409d6b5a 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -1085,7 +1085,7 @@ class EmployeeRestController extends AdminController $keysToRemove = ["removable_keys"]; // Retrieve employee policy data by passing the employee primary key $empPolicy = $this->employeeModel->getEmployeePolicy($id); - +// dd($empPolicy); // Retrieve employee and dependents data by passing the employee code $employeeData = $this->employeeModel->where('emp_code',$emp_code) ->where('client_id',$client_id) @@ -1123,11 +1123,18 @@ class EmployeeRestController extends AdminController { $si_value = 0; + $si_premium_value = 0; + $si_gst_value = 0; // Filter employee data where the family_floater_key is 'self' $selfData = array_filter($empData, fn($arr) => trim(strtolower($arr['family_floater_key'])) === 'self'); $employee_policy = $this->employeePolicyModel->where('employee_id',$selfData[0]['id'])->where('client_policy_id',$array->ClientPolicyId)->where('is_active', 1 )->get()->getRow(); $si_value = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : 0; + if(isset($employee_policy->payable_employee) && $employee_policy->payable_employee == 1) + { + $si_premium_value = $si_premium_value + $employee_policy->rata_premimum; + $si_gst_value = $si_gst_value + $employee_policy->gst; + } $self['is_value_exist'] = true; $self['data']['family_floater_key'] = 'self'; @@ -1142,6 +1149,8 @@ class EmployeeRestController extends AdminController $array->mapped_family_floaters = $self; $array->type = 'GPA'; $array->si_value = $si_value; + $array->si_premium_value = $si_premium_value; + $array->si_gst_value = $si_gst_value; @@ -1201,8 +1210,11 @@ class EmployeeRestController extends AdminController if ($value['family_floater_key'] === $dependent) { $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array->ClientPolicyId)->where('is_active', 1 )->get()->getRow(); if(isset($employee_policy->basic_cover_si)){ $dependent_and_si_value = ($dependent_and_si_value == 0) ? $employee_policy->basic_cover_si : $dependent_and_si_value; } - if(isset($employee_policy->rata_premimum)){ $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->rata_premimum;} - if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;} + if(isset($employee_policy->payable_employee) && $employee_policy->payable_employee == 1) + { + if(isset($employee_policy->rata_premimum)){ $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->rata_premimum;} + if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;} + } $temp['is_value_exist'] = true; $temp['data']['family_floater_key'] = $familyFloatesValue; @@ -1404,8 +1416,11 @@ class EmployeeRestController extends AdminController if ($value['family_floater_key'] === $dependent) { $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array->ClientPolicyId)->where('is_active', 1 )->get()->getRow(); if(isset($employee_policy->basic_cover_si)){ $dependent_and_si_value = ($dependent_and_si_value == 0) ? $employee_policy->basic_cover_si : $dependent_and_si_value; } - if(isset($employee_policy->rata_premimum)){ $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->rata_premimum;} - if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;} + if(isset($employee_policy->payable_employee) && $employee_policy->payable_employee == 1) + { + if(isset($employee_policy->rata_premimum)){ $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->rata_premimum;} + if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;} + } $temp['is_value_exist'] = true; $temp['data']['family_floater_key'] = $familyFloatesValue; @@ -1504,16 +1519,25 @@ class EmployeeRestController extends AdminController $decodedArray = json_decode($array->Policy_Terms); $array->Policy_Terms = $decodedArray; $si_value = 0; + $si_premium_value = 0; + $si_gst_value = 0; // Filter employee data where the family_floater_key is 'self' $selfData = array_filter($empData, fn($arr) => trim(strtolower($arr['family_floater_key'])) === 'self'); $employee_policy = $this->employeePolicyModel->where('employee_id',$selfData[0]['id'])->where('client_policy_id',$array->ClientPolicyId)->where('is_active', 1 )->get()->getRow(); $si_value = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : 0; + if(isset($employee_policy->payable_employee) && $employee_policy->payable_employee == 1) + { + $si_premium_value = $si_premium_value + $employee_policy->rata_premimum; + $si_gst_value = $si_gst_value + $employee_policy->gst; + } $policyTypeData = $this->policyTypeModel->where('id',$policy_type)->get()->getRow(); $array->type = $policyTypeData->policy_type; $array->Policy_Name = $policyTypeData->long_name; $array->si_value = $si_value; + $array->si_premium_value = $si_premium_value; + $array->si_gst_value = $si_gst_value; if($employee_policy){ @@ -1808,8 +1832,11 @@ class EmployeeRestController extends AdminController if ($value['family_floater_key'] === $dependent) { $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow(); if(isset($employee_policy->basic_cover_si)){ $dependent_and_si_value = ($dependent_and_si_value == 0) ? $employee_policy->basic_cover_si : $dependent_and_si_value; } - if(isset($employee_policy->rata_premimum)){ $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->rata_premimum;} - if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;} + if(isset($employee_policy->payable_employee) && $employee_policy->payable_employee == 1) + { + if(isset($employee_policy->rata_premimum)){ $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->rata_premimum;} + if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;} + } $temp['is_value_exist'] = true; $temp['data']['family_floater_key'] = $familyFloatesValue; @@ -1929,8 +1956,11 @@ class EmployeeRestController extends AdminController $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow(); if(isset($employee_policy->basic_cover_si)){ $only_si_value = ($only_si_value == 0) ? $employee_policy->basic_cover_si : $only_si_value; } - if(isset($employee_policy->rata_premimum)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;} - if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;} + if(isset($employee_policy->payable_employee) && $employee_policy->payable_employee == 1) + { + if(isset($employee_policy->rata_premimum)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;} + if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;} + } $temp3['is_value_exist'] = true; $temp3['data']['employee_id'] = $value['id']; $temp3['data']['relationship'] = $value['relationship']; @@ -1982,8 +2012,11 @@ class EmployeeRestController extends AdminController $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow(); if(isset($employee_policy->basic_cover_si)){ $only_si_value = ($only_si_value == 0) ? $employee_policy->basic_cover_si : $only_si_value; } - if(isset($employee_policy->rata_premimum)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;} - if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;} + if(isset($employee_policy->payable_employee) && $employee_policy->payable_employee == 1) + { + if(isset($employee_policy->rata_premimum)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;} + if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;} + } $temp3['is_value_exist'] = true; $temp3['data']['employee_id'] = $value['id']; $temp3['data']['relationship'] = $value['relationship']; diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index d7f9628a..921a9f3d 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -1658,7 +1658,7 @@ class MasterController extends AdminController $email_id = CLI::getOption('to') ? CLI::getOption('to') : $email_id; $res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments,'common'=>$common]); echo "Inside the master controller"; - print_r($res); + print_r($res['data']['zepto_api']); } @@ -1669,10 +1669,11 @@ class MasterController extends AdminController ["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"], ["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"] ]; - $email_id = 'srinivas.saravanan@venbainfotech.com'; + $email_id = 'hariharan@nhanceindia.in'; $common = ['mail_type'=>'test_mail_cli']; + $bcc = "vijayalakshmi@nhanceindia.in,vitvelz@gmail.com,velmurugan.s@venbainfotech.com,hariharan@nhanceindia.in,hariharan@jubiliant.in,srinivas.saravanan@venbainfotech.com"; // Send email and get response - $result = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments,'common'=>$common]); + $result = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI','bcc'=>$bcc ,'message' => $message,'attachments' => $attachments,'common'=>$common]); log_message('error',json_encode($result)); diff --git a/app/Controllers/NotificationController.php b/app/Controllers/NotificationController.php index a3c8efe9..0dd29522 100755 --- a/app/Controllers/NotificationController.php +++ b/app/Controllers/NotificationController.php @@ -52,6 +52,7 @@ class NotificationController extends AdminController $form_data['subject'] = $this->request->getPost('subject'); $form_data['mail_content'] = $this->request->getPost('mailContent'); $form_data['client_id'] = $this->request->getPost('client_id'); + $form_data['mail_content_json'] = $this->request->getPost('mailJson'); $notificationModel = new NotificationModel(); $find_notification = $notificationModel->where('client_id',$form_data['client_id'])->where('template_name',$form_data['template_name'])->first(); diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 0e4466fd..ca4a1d66 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -1779,7 +1779,7 @@ class PolicyTransactionController extends BaseController //Actual data for the list $data['report_list'] = $this->policyTransactionModel->getBDSReportList($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $client_branch_id, $insurer_branch_id, $client_policy_id); - // dd($data['report_list']); + //!dd($data['report_list']); $this->loadLayout('report_bds_filter', $data); } @@ -1828,6 +1828,7 @@ class PolicyTransactionController extends BaseController $data['varience_list'] = $this->policyTransactionModel->getVarienceReportLIst($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $client_branch_id, $insurer_branch_id, $client_policy_id); + // !dd($data['varience_list']); $this->loadLayout('variance_report_list', $data); } @@ -1959,7 +1960,7 @@ class PolicyTransactionController extends BaseController // dd($this->validateInsurerStatement(['file_id' => 30])); // $data['insurers'] = $this->insurerModel->where('is_active',1)->findAll(); $today = date('Y-m-d'); - $fromday = $from_date = date('Y-m-d', strtotime('-60 days', strtotime($today))); + $fromday = $from_date = date('Y-m-d', strtotime('-180 days', strtotime($today))); // echo $fromday;die(); $data['invoice_status_array'] = $this->invoiceStatus; $data['insurers'] = $this->insurerBranchModel ->getInsurerBranchesWithInsurerNames(); @@ -1986,6 +1987,7 @@ class PolicyTransactionController extends BaseController ->join('insurer_branch', 'insurer_statements.branch_id = insurer_branch.id') ->join('user_profiles', 'insurer_statements.created_by = user_profiles.id') ->where('insurer_statements.is_active', 1) + // ->where('insurer_statements.file_status','success') ->where('date(insurer_statements.created_at) >= ', $from_date) ->where('date(insurer_statements.created_at) <= ', $today) ->orderBy('insurer_statements.id', 'DESC') @@ -1997,6 +1999,48 @@ class PolicyTransactionController extends BaseController $this->loadLayout('insurer_statement_list', $data); } + // public function failedStatementList(){ + // $today = date('Y-m-d'); + // $fromday = $from_date = date('Y-m-d', strtotime('-180 days', strtotime($today))); + // // echo $fromday;die(); + // $data['invoice_status_array'] = $this->invoiceStatus; + // $data['insurers'] = $this->insurerBranchModel ->getInsurerBranchesWithInsurerNames(); + + // // dd( $data['insurers']); + // $data['insurer_statement_list'] = $this->insurerStatements + // ->select('insurer_statements.*, + // insurers.name AS insurer_name, + // insurers.short_name, + // user_profiles.first_name, + // insurer_branch.branch_code, + // (SELECT SUM(pt_co_share_details.exp_amt) + // FROM pt_co_share_details + // WHERE pt_co_share_details.is_active = 1 + // AND pt_co_share_details.statement_id = insurer_statements.id + // ) AS exp_inv_amt, + // (SELECT SUM(inv_payment_details.inv_amt) + SUM(inv_payment_details.tds) + SUM(inv_payment_details.gst) + // FROM inv_payment_details + // WHERE inv_payment_details.is_active = 1 + // AND inv_payment_details.statement_id = insurer_statements.id + // ) AS received_inv_amt' + // ) + // ->join('insurers', 'insurer_statements.insurer_id = insurers.id') + // ->join('insurer_branch', 'insurer_statements.branch_id = insurer_branch.id') + // ->join('user_profiles', 'insurer_statements.created_by = user_profiles.id') + // ->where('insurer_statements.is_active', 1) + // ->where('insurer_statements.file_status','failed') + // ->where('date(insurer_statements.created_at) >= ', $from_date) + // ->where('date(insurer_statements.created_at) <= ', $today) + // ->orderBy('insurer_statements.id', 'DESC') + // ->findAll(); + // if($data['insurer_statement_list']){ + // return $this->respond(['status' => true, 'code' => 200,'data'=>$data ], 200); + // }else{ + // return $this->respond(['status'=>false,'message'=>'Data Not Fount'],404); + // } + + // } + public function uploadInsurerStatement() { @@ -2067,6 +2111,12 @@ class PolicyTransactionController extends BaseController return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'file not uploaded', 'error_data' => $validation_result['error_data'],'error_code' => $validation_result['error_code']], 200); } + if (isset($file_id) || $validation_result['status']) { + $this->insurerStatements->where('id', $file_id)->set(['invoice_status' => 'pending'])->update(); + } + + + return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => 'file upload success'], 200); } diff --git a/app/Helpers/ExcelSanitizeHelper.php b/app/Helpers/ExcelSanitizeHelper.php index b4950b34..67aaa55e 100644 --- a/app/Helpers/ExcelSanitizeHelper.php +++ b/app/Helpers/ExcelSanitizeHelper.php @@ -15,7 +15,7 @@ class ExcelSanitizeHelper "\x0A", "\x0B", "\x0C", "\x0D", "\x0E", "\x0F", "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1A", "\x1B", "\x1C", "\x1D", "\x1E", "\x1F", "\x7F", "_x000D_", "_x000A_", "_x0009_", "_x0008_", "_x0007_", - "_x0006_", "_x0005_", "_x0004_", "_x0003_", "_x0002_", "_x0001_" + "_x0006_", "_x0005_", "_x0004_", "_x0003_", "_x0002_", "_x0001_","\u200C" ]; /** diff --git a/app/Helpers/MailHelper.php b/app/Helpers/MailHelper.php index c55c2796..99490bde 100755 --- a/app/Helpers/MailHelper.php +++ b/app/Helpers/MailHelper.php @@ -325,31 +325,42 @@ class MailHelper // Add CC recipients if provided if (!empty($cc)) { - $postData['cc'] = []; - // Handle both string and array inputs for CC - $ccEmails = is_array($cc) ? $cc : [$cc]; - foreach ($ccEmails as $ccEmail) { - $postData['cc'][] = [ + $ccList = explode(',', $cc); + $ccList = array_map('trim', $ccList); + $postData['cc'] = array_map(function($email) { + return [ 'email_address' => [ - 'address' => $ccEmail + 'address' => $email ] ]; - } + }, $ccList); + } + // Add BCC if present + if (!empty($bcc)) { + $bccList = explode(',', $bcc); + $bccList = array_map('trim', $bccList); + $postData['bcc'] = array_map(function($email) { + return [ + 'email_address' => [ + 'address' => $email + ] + ]; + }, $bccList); } // Add BCC recipients if provided - if (!empty($bcc)) { - $postData['bcc'] = []; - // Handle both string and array inputs for BCC - $bccEmails = is_array($bcc) ? $bcc : [$bcc]; - foreach ($bccEmails as $bccEmail) { - $postData['bcc'][] = [ - 'email_address' => [ - 'address' => $bccEmail - ] - ]; - } - } + // if (!empty($bcc)) { + // $postData['bcc'] = []; + // // Handle both string and array inputs for BCC + // $bccEmails = is_array($bcc) ? $bcc : [$bcc]; + // foreach ($bccEmails as $bccEmail) { + // $postData['bcc'][] = [ + // 'email_address' => [ + // 'address' => $bccEmail + // ] + // ]; + // } + // } // Handle attachments if (!empty($attachments)) { diff --git a/app/Models/NotificationModel.php b/app/Models/NotificationModel.php index d78d2a69..edc3069d 100755 --- a/app/Models/NotificationModel.php +++ b/app/Models/NotificationModel.php @@ -4,9 +4,9 @@ namespace App\Models; use CodeIgniter\Model; -class NotificationModel extends Model +class NotificationModel extends Model { protected $table = 'notifications'; protected $primaryKey = 'id'; - protected $allowedFields = ["id","client_id","template_name","subject","mail_content","enabled","created_by","updated_by","is_active",]; + protected $allowedFields = ["id","client_id","template_name","subject","mail_content","enabled","created_by","updated_by","is_active",'mail_content_json']; } \ No newline at end of file diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php index c0af578c..36fc097e 100644 --- a/app/Models/PolicyTransactionModel.php +++ b/app/Models/PolicyTransactionModel.php @@ -365,7 +365,6 @@ class PolicyTransactionModel extends Model vehicle.vehicle_no, tpa.name as tpa_name, pt_co_share_details.remark as remarks, - pt_co_share_details.reward, pt_co_share_details.bp_amt, pt_co_share_details.exp_amt, pt_co_share_details.id as pt_id, @@ -385,7 +384,6 @@ class PolicyTransactionModel extends Model (pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per) AS agreed_tp_or_ter_per, pt_co_share_details.agreed_bp_per, - ROUND( ( SELECT @@ -407,6 +405,24 @@ class PolicyTransactionModel extends Model ), 2 ) AS total_irda_amt, + ROUND( + ( + SELECT + ( + SUM(co_share_stmt_details.reward) + + ) AS reward + FROM + co_share_stmt_details + JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id + WHERE + co_share_stmt_details.co_share_id = pt_co_share_details.id + AND co_share_stmt_details.is_active = 1 + AND insurer_statements.is_active = 1 + $date_condition + ), + 2 + ) AS reward, ROUND( ( @@ -426,7 +442,7 @@ class PolicyTransactionModel extends Model AND co_share_stmt_details.is_active = 1 AND pt_table.is_active = 1 AND insurer_statements.is_active = 1 - AND insurer_statements.invoice_no IS NOT NULL + AND insurer_statements.invoice_status IS NOT NULL $date_condition ), @@ -469,7 +485,7 @@ class PolicyTransactionModel extends Model AND co_share_stmt_details.is_active = 1 AND pt_table.is_active = 1 AND insurer_statements.is_active = 1 - AND insurer_statements.invoice_no IS NULL + AND insurer_statements.invoice_status IS NULL $date_condition ) ), @@ -737,16 +753,55 @@ class PolicyTransactionModel extends Model pt_co_share_details.exp_amt, pt_co_share_details.variance, + ROUND ( (pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt),2) as original_premium, + ROUND( + ( + SELECT + ( + SUM(co_share_stmt_details.actual_bp_amt) + SUM(co_share_stmt_details.actual_tp_amt) + SUM(co_share_stmt_details.actual_bp_per) + ) AS total_stmt_amt + FROM + co_share_stmt_details + JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id and insurer_statements.is_active = 1 + WHERE + co_share_stmt_details.co_share_id = pt_co_share_details.id + AND co_share_stmt_details.is_active = 1 + ), + 2 + ) AS statement_premium, + + COALESCE( + (pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 0 + ) - + COALESCE( + ( + SELECT + SUM(co_share_stmt_details.actual_bp_amt) + + SUM(co_share_stmt_details.actual_tp_amt) + + SUM(co_share_stmt_details.actual_bp_per) + FROM + co_share_stmt_details + JOIN + insurer_statements + ON + co_share_stmt_details.statement_id = insurer_statements.id + AND insurer_statements.is_active = 1 + WHERE + co_share_stmt_details.co_share_id = pt_co_share_details.id + AND co_share_stmt_details.is_active = 1 + ), 0 + ) AS premium_variance_amt, + ROUND( ( SELECT ( - SUM(co_share_stmt_details.actual_bp_brokerage_amt) + SUM(co_share_stmt_details.actual_tp_brokerage_amt) + SUM(co_share_stmt_details.actual_tep_brokerage_amt) + SUM(co_share_stmt_details.actual_bp_brokerage_amt) + SUM(co_share_stmt_details.actual_tp_brokerage_amt) + SUM(co_share_stmt_details.actual_tep_brokerage_amt) + SUM(co_share_stmt_details.reward) ) AS total_irda_amt FROM co_share_stmt_details - JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id + JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id and insurer_statements.is_active = 1 WHERE co_share_stmt_details.co_share_id = pt_co_share_details.id AND co_share_stmt_details.is_active = 1 @@ -761,11 +816,11 @@ class PolicyTransactionModel extends Model ( SUM(co_share_stmt_details.actual_bp_brokerage_amt) + SUM(co_share_stmt_details.actual_tp_brokerage_amt) + - SUM(co_share_stmt_details.actual_tep_brokerage_amt) + SUM(co_share_stmt_details.actual_tep_brokerage_amt) + SUM(co_share_stmt_details.reward) ) FROM co_share_stmt_details JOIN insurer_statements - ON co_share_stmt_details.statement_id = insurer_statements.id + ON co_share_stmt_details.statement_id = insurer_statements.id and insurer_statements.is_active = 1 WHERE co_share_stmt_details.co_share_id = pt_co_share_details.id AND co_share_stmt_details.is_active = 1 @@ -785,7 +840,18 @@ class PolicyTransactionModel extends Model ->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left') ->where('policy_transaction.is_active', 1) ->where('pt_co_share_details.is_active', 1) - ->having('variance_amt IS NOT NULL'); + // ->where('insurer_statements.is_active',1); + // ->having('variance_amt IS NOT NULL') + // ->having('variance_amt !=',0) + // ->having('premium_variance_amt IS NOT NULL') + // ->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); diff --git a/app/Models/PolicyTypeModel.php b/app/Models/PolicyTypeModel.php index 3edd01f1..29126484 100755 --- a/app/Models/PolicyTypeModel.php +++ b/app/Models/PolicyTypeModel.php @@ -22,6 +22,6 @@ class PolicyTypeModel extends Model "etp", "iep", "itp", - "question_json", + "question_json",'itep','etep' ]; } diff --git a/app/Views/insurer_statement_list.php b/app/Views/insurer_statement_list.php index 83dee914..ff994fad 100644 --- a/app/Views/insurer_statement_list.php +++ b/app/Views/insurer_statement_list.php @@ -141,13 +141,38 @@ table.dataTable tbody td {
-
+

Insurer Statement List

+
+ -
- +
+
+
+
+
+ + +
+
+
+
+ +
+
+
@@ -356,7 +381,7 @@ table.dataTable tbody td {
- +
@@ -388,7 +413,7 @@ table.dataTable tbody td { @@ -415,7 +440,7 @@ table.dataTable tbody td { - + @@ -633,7 +658,8 @@ document.addEventListener("DOMContentLoaded", function () { // alert($('#invoice_date_modal').val()); if((!form.checkValidity())) { - // console.log('error2'); + console.log('error2'); + console.log(form.checkValidity()); return false; } @@ -667,7 +693,7 @@ document.addEventListener("DOMContentLoaded", function () { var jsonData = JSON.stringify(formDataJSON); console.log(jsonData); $('.loader').fadeIn(); - $('.loader-mask').fadeIn(); + $('.loader-mask').fadeIn(); // Send the JSON data to the backend using AJAX $.ajax({ url: 'saveInvoicePaymentDetails', // Replace with your backend URL @@ -705,7 +731,7 @@ document.addEventListener("DOMContentLoaded", function () { newRow.innerHTML = ` - + @@ -848,7 +874,7 @@ function showInvoiceStatusModal(event) var row = paymentTableBody.insertRow(); row.innerHTML = ` - + @@ -1299,6 +1325,146 @@ function deleteStatement(id) }); } +// $(document).ready(function() { +// $('#failedSwitch').change(function() { +// if ($(this).prop('checked')) { +// getFailedStatementList(); +// } else { +// console.log("Inside Reload Function"); +// fetch(window.location.href) // Fetch the current page's content +// .then(response => response.text()) +// .then(html => { +// const parser = new DOMParser(); +// const doc = parser.parseFromString(html, 'text/html'); +// document.body.innerHTML = doc.body.innerHTML; // Replace the body content +// $('.loader').fadeOut(); +// $('.loader-mask').delay(100).fadeOut('slow'); +// }) +// .catch(error => console.error('Error reloading body:', error)); +// } +// }); +// }); + +// function checkSwitchStatus(){ +// $('#failedSwitch').change(function() { +// if ($(this).prop('checked')) { +// getFailedStatementList(); +// } else { +// console.log("Inside Reload Function"); +// fetch(window.location.href) // Fetch the current page's content +// .then(response => response.text()) +// .then(html => { +// const parser = new DOMParser(); +// const doc = parser.parseFromString(html, 'text/html'); +// document.body.innerHTML = doc.body.innerHTML; // Replace the body content +// $('.loader').fadeOut(); +// $('.loader-mask').delay(250).fadeOut('slow'); +// }) +// .catch(error => console.error('Error reloading body:', error)); +// } +// }); +// } +// function getFailedStatementList(){ +// $('.loader').fadeIn(); +// $('.loader-mask').fadeIn(); +// $.ajax({ +// url:'', +// type:'POST', +// success:function(response){ +// console.log(response); +// var table = $('#tickets-table').DataTable(); +// table.clear(); +// $('#tickets-table').addClass('table-fixed'); +// var failedList = response.data.insurer_statement_list; +// console.log('failed list'+failedList); +// failedList.forEach(function(row) { +// var newRow = [ +// '', +// row.short_name + '-' + row.branch_code, +// formatDate(row.month), +// row.stmt_sno, +// row.file_name, +// row.line_items, +// row.file_status + +// (row.file_status == 'failed' ? ' ' : ''), +// (row.invoice_status ? row.invoice_status : ' - ') + +// (row.file_status == 'success' ? ' ' : ''), +// formatDate(row.created_at) + ' by
' + row.first_name, +// (row.file_status != 'failed' ? +// '' : '...') +// ]; + +// // Append the new row to the table body +// table.row.add(newRow); +// }); +// table.draw(); +// table.columns.adjust().draw(); // Ensures correct alignment +// $('.loader').fadeOut(); +// $('.loader-mask').delay(250).fadeOut('slow'); +// }, +// error: function(xhr, status, error) { +// let message = 'Failed to load Data '; +// toastr.error(response.message, 'Failed'); +// $('.loader').fadeOut(); +// $('.loader-mask').delay(250).fadeOut('slow'); +// } + +// }) +// } +// $(document).ready(function() { +// var table = $('#tickets-table').DataTable({ +// // responsive: true, // Ensures table adjusts to smaller screens +// stateSave: true, // Saves the table's state +// }); +// }); + + + + + \ No newline at end of file diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index 8d7bd1f9..e8f0dd11 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -79,7 +79,10 @@ - + + + +
@@ -526,7 +549,7 @@
-
+
+ Total Premium: 0.00 | + Total Rewards: 0.00 | + Total IRDA Revenue INR: 0.00 | + Total Billed Amount: 0.00 | + Total Unbilled Amount: 0.00 +
@@ -61,10 +68,11 @@ table.dataTable tbody td { + - + @@ -97,11 +105,17 @@ table.dataTable tbody td { - + + + + - - + + @@ -191,7 +205,21 @@ $(document).ready(function() { // Append the new total row to the sheet $(sheet).find('sheetData').append(totalRow); - } + }, + exportOptions: { + orthogonal: 'sort' + }, + customizeData: function (data) { + for (var i = 0; i < data.body.length; i++) { + for (var j = 0; j < data.body[i].length; j++) { + // Check if the column is the 9th index (10th column) + if (j === 9) { + data.body[i][j] = '\u200C' + data.body[i][j]; + } + } + } +} + } ], @@ -201,7 +229,38 @@ $(document).ready(function() { }, paging: true, // Enable pagination pageLength: 25, // Set default number of rows per page (optional) - ordering: false, + ordering: false, + "footerCallback": function(row, data, start, end, display) { + var api = this.api(); + + // Calculate column totals + var totalPremium = api.column(23).data().reduce(function(a, b) { + return parseFloat(a) + parseFloat(b) || 0; + }, 0); + + var total_rewards = api.column(26).data().reduce(function(a,b){ + return parseFloat(a) + parseFloat(b) || 0; + }) + + var totalIrda = api.column(27).data().reduce(function(a, b) { + return parseFloat(a) + parseFloat(b) || 0; + }, 0); + + var totalBilled = api.column(28).data().reduce(function(a, b) { + return parseFloat(a) + parseFloat(b) || 0; + }, 0); + + var totalUnbilled = api.column(29).data().reduce(function(a, b) { + return parseFloat(a) + parseFloat(b) || 0; + }, 0); + + // Update the totals in the div above the table + $('#total_premium').text(totalPremium.toFixed(2)); + $('#total_rewards').text(total_rewards.toFixed(2)) + $('#total_irda').text(totalIrda.toFixed(2)); + $('#total_billed').text(totalBilled.toFixed(2)); + $('#total_unbilled').text(totalUnbilled.toFixed(2)); + } }); } else { console.error("Table atet found."); diff --git a/app/Views/variance_report_list.php b/app/Views/variance_report_list.php index 07387337..28d85d44 100644 --- a/app/Views/variance_report_list.php +++ b/app/Views/variance_report_list.php @@ -170,6 +170,9 @@ table.dataTable tbody td { + + + @@ -186,9 +189,12 @@ table.dataTable tbody td { + + + - - + +
Total Premium Base
Revenue %
TP / Terrorism
Revenue %
Rewards Total IRDA
Revenue INR
Billed Amount UnBilled AmountRewards
 %  %
Insurer Branch Policy Endorsement NoPremiumStatement PremiumPremium Variance Expected Amount Statement Amount Variance