diff --git a/app/Config/Routes.php b/app/Config/Routes.php index abec6e2d..e2c4773c 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -326,6 +326,9 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { $routes->group("report", ["filter" => "authMVC"], function ($routes) { $routes->get("list", "PolicyTransactionController::reportBDS"); + $routes->get("report-varience-list", "PolicyTransactionController::reportVarience"); + $routes->get("report-business-list", "PolicyTransactionController::reportBusinessList"); + $routes->get("report-finance-list", "PolicyTransactionController::reportFinanceList"); }); $routes->group("statement", ["filter" => "authMVC"], function ($routes) { diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 17e6f11d..e40b7c1f 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -39,6 +39,7 @@ use App\Models\PolicyTransactionStatusModel; use App\Models\VehicleModel; use App\Controllers\EmpDataServiceController; +use App\Controllers\GoogleDriveController; class ClientController extends AdminController @@ -320,10 +321,10 @@ class ClientController extends AdminController $data['subTypeOptions'] = $subTypeOptions; $headerData['page_name'] = 'Client Deposit'; - $data['insurerName']= $this->insurerModel->getInsurerName($insurerId); $loggedInUserID = get_session_userid(); // $data['clientData']= $this->clientPolicyModel->getinsurerswithinsurenceid($insurerId); $clientId = $this->request->getGet('client_id'); + $data['insurerName']= $this->insurerModel->getInsurerName($insurerId, $clientId); $data['depositdata']= $this->clientPolicyModel->getdepositData($clientId,$insurerId); $data['clientData'] = $this->clientPolicyModel->getClientById($clientId); $data['deposiamount'] = $this->clientPolicyModel->getDepositSummary($clientId, $insurerId); @@ -331,7 +332,7 @@ class ClientController extends AdminController // dd($data['depositdata']); // print_r($data['depositdata'] );die; - // Load the view for the new list page + // Load the view for the new list page; echo view('layout/header', $headerData); echo view('view_deposit',$data); echo view('layout/footer'); @@ -481,6 +482,8 @@ class ClientController extends AdminController } } + + public function createClientKYCInfo() { $this->myLogger->logme('error','create Client kyc function called'); @@ -490,7 +493,12 @@ class ClientController extends AdminController $uploadFilePath = WRITEPATH . 'uploads/client_kyc_documents'; $File = file_Upload($this->request->getFile('file_name'), $uploadFilePath); if(!empty($File)){ + $data['file_name'] = $File; + $uploadFilePath = $uploadFilePath . '/' .$File; + $GoogleDriveController = new GoogleDriveController(); + $GoogleDriveController->uploadFiletoGdrive(client_id: $data['client_id'], doc_type: 'KYC', file_path: $uploadFilePath, file_name: $data['file_name']); + } $data['created_by'] = get_session_userid(); diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index fe61b51f..4786af5f 100755 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -13,6 +13,7 @@ use CodeIgniter\API\ResponseTrait; use App\Models\MessageModel; use App\Models\UserMessageModel; use App\Models\ClientModel; +use App\Models\PolicyTransactionModel; use App\Models\JobModel; use App\Models\ClientPolicyModel; @@ -30,6 +31,7 @@ class DashboardController extends AdminController protected $clientPolicyModel; protected $notificationModel; protected $employeePolicyModel; + protected $policyTransactionModel; protected $myLogger; @@ -42,6 +44,7 @@ class DashboardController extends AdminController $this->notificationModel = new NotificationModel(); $this->employeePolicyModel = new EmployeePolicyModel(); $this->clientModel = new ClientModel(); + $this->policyTransactionModel = new PolicyTransactionModel(); $this->myLogger = \Config\Services::mylogger(); @@ -65,8 +68,9 @@ class DashboardController extends AdminController $pendingActionsController = new PendingActionsController; $pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard(); - - + $businessTeamData = $this->policyTransactionModel->getBusinessReportList(); + $financeTeamData = $this->policyTransactionModel->getFinanceReportList(); + $groupedData = []; foreach ($results as $row) { @@ -157,6 +161,8 @@ class DashboardController extends AdminController $session->set('enrollment_data', json_encode($data)); // echo "
";
$data['pendingActionsData'] = $pendingActionsData;
+ $data['businessTeamCount'] = count($businessTeamData) ?? 0;
+ $data['financeTeamCount'] = count($financeTeamData) ?? 0;
// print_r($data);die;
diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php
index 51dee015..0d5e76e3 100755
--- a/app/Controllers/MasterController.php
+++ b/app/Controllers/MasterController.php
@@ -1260,6 +1260,8 @@ class MasterController extends AdminController
$insert = $this->CDMasterModel->where('id', $id)->set($data)->update();
+ $data = $this->CDMasterModel->where('id', $id)->first();
+
$cd_transaction_updated_data = [
'balance' => $data['opening_bal'],
'amount' => $data['opening_bal']
diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php
index ce165798..2607f41c 100644
--- a/app/Controllers/PolicyTransactionController.php
+++ b/app/Controllers/PolicyTransactionController.php
@@ -3,6 +3,8 @@
namespace App\Controllers;
use App\Controllers\BaseController;
+use App\Controllers\GoogleDriveController;
+
use App\Helpers\DepositHelper;
use CodeIgniter\API\ResponseTrait;
@@ -93,18 +95,10 @@ class PolicyTransactionController extends BaseController
// Policy Transaction Inception
public function viewInception()
- {
+ {
$data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
$data['client_type'] = [1 => 'Group', 2 => 'Individual'];
$data['issuing_type'] = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over'];
- // $data['policy_status'] = [
- // 'pending' => 'Pending',
- // 'exported_to_insurer' => 'Exported to Insurer',
- // 'imported_from_insurer' => 'Imported from Insurer',
- // 'exported_to_tpa' => 'Exported to TPA',
- // 'imported_from_tpa' => 'Imported from TPA',
- // 'completed' => 'Completed'
- // ];
$data['policy_status'] = [
'under_process' => 'Under Process',
'client_pending' => 'Client Pending',
@@ -136,53 +130,57 @@ class PolicyTransactionController extends BaseController
'commercial' => 'Commercial',
'private' => 'Private',
];
+ $data['date_type'] = [
+ 'policy_issue_date' => 'Policy Issue Date',
+ 'policy_start_date' => 'Policy Start Date',
+ 'policy_end_date' => 'Policy End Date',
+ ];
+
+ //filter datas
+ $start_date = $this->request->getGet('start_date');
+ $end_date = $this->request->getGet('end_date');
+ $client_id = $this->request->getGet('client_id');
+ $insurer_id = $this->request->getGet('insurer_id');
+ $policy_type_id = $this->request->getGet('policy_type_id');
+ $date_type = $this->request->getGet('date_type');
+ $issuer = $this->request->getGet('issuer');
+ $status = $this->request->getGet('status');
- $data['inception_data_list'] = $this->policyTransactionModel
- ->select('
- policy_transaction.*,
- clients.short_name AS client_short_name,
- clients.client_code,
- clients.client_type,
- clients.client_name,
- client_branch.branch_name AS client_branch_name,
- insurers.name AS insurer_name,
- insurers.short_name AS insurer_short_name,
- policy_type.policy_type,
- pt_co_share_details.agreed_amt AS amount,
- pt_co_share_details.bp_amt AS bp,
- pt_co_share_details.tp_amt AS tp
- ')
- ->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
- ->join('clients', 'clients.id = policy_transaction.client_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('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)
- ->where('policy_transaction.action_type', 'inception')
- ->orderBy('policy_transaction.id', 'desc')
- ->findAll();
+ $start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : $start_date;
+ $end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : $end_date;
+
+ $client_id = (!isset($client_id) || $client_id === '' || $client_id === null) ? 0 : $client_id;
+ $insurer_id = (!isset($insurer_id) || $insurer_id === '' || $insurer_id === null) ? 0 : $insurer_id;
+ $policy_type_id = (!isset($policy_type_id) || $policy_type_id === '' || $policy_type_id === null) ? 0 : $policy_type_id;
+ $date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
+ $issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer;
+ $status = (!isset($issuer) || $status === '' || $status === null) ? 0 : $status;
+
+
+ $data['inception_data_list'] = $this->policyTransactionModel->getInceptionTranctionListData($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $status);
$data['client'] = $this->clientModel->where('is_active', 1)->findAll();
$data['policy_type'] = $this->policyTypeModel->where('is_active', 1)->findAll();
$data['insurer'] = $this->insurerModel->where('is_active', 1)->findAll();
$data['entity'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll();
$data['policy_types'] = $this->policyTypeModel->where('is_active', 1)->findAll();
- $data['insurer_branch'] = $this->insurerBranchModel ->getInsurerBranchesWithInsurerNames();
- $data['tpa'] = $this->tpaBranchModel ->getTpaBranchesWithTpaNames();
+ $data['insurer_branch'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames();
+ $data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames();
+
$data['salse_team'] = $this->userModel
- ->select('user_profiles.*')
- ->join('user_teams', 'user_profiles.id = user_teams.user_id')
- ->where('user_teams.team_id', 5)
- ->where('user_teams.is_active', 1)
- ->where('user_profiles.is_active', 1)
- ->findAll();
+ ->select('user_profiles.*')
+ ->join('user_teams', 'user_profiles.id = user_teams.user_id')
+ ->where('user_teams.team_id', 5)
+ ->where('user_teams.is_active', 1)
+ ->where('user_profiles.is_active', 1)
+ ->findAll();
$data['ACM'] = $this->userModel
- ->where('user_profiles.role', 3)
- ->where('user_profiles.is_active', 1)
- ->findAll();
+ ->where('user_profiles.role', 3)
+ ->where('user_profiles.is_active', 1)
+ ->findAll();
+
$this->loadLayout('policy_transaction_inception_list', $data);
}
@@ -243,6 +241,9 @@ class PolicyTransactionController extends BaseController
} elseif ($data['same_as_proposer']) {
$data['same_as_proposer'] = 1;
}
+
+ $month = '01-'.$data['month'];
+ $data['month'] = date('Y-m-d', strtotime($month));
// Determine $is_addon value
$data['is_addon'] = in_array($data['policy_type_id'], [1, 2, 6, 7]) ? 1 :
@@ -299,6 +300,10 @@ class PolicyTransactionController extends BaseController
if (isset($data['follow_insurer_id']) && !empty($data['follow_insurer_id'][0])) {
$this->insertOrUpdateCoShareDetails($data, $id);
+
+ if ($data['ct_type'] == 1) {
+ $this->policyTransactionModel->update($id, ['client_policy_id' => $data['client_policy_id']]);
+ }
if (empty($data['client_policy_id']) || $data['client_policy_id'] == 0) {
@@ -322,6 +327,10 @@ class PolicyTransactionController extends BaseController
$data['pt_co_share_details'] = $this->PTCOShareDetailsModel->where('pt_id', $id)->where('is_active', 1)->findAll();
}
+ $client_data = $this->clientModel->where('id', $data['client_id'])->first();
+ $data['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $data['client_id'])->findAll();
+ $data['entity_type_id'] = $client_data['entity_type_id'];
+
return $this->respondSuccess($id, "Policy transaction updated successfully", $data);
}
@@ -588,13 +597,38 @@ class PolicyTransactionController extends BaseController
->where('policy_transaction.id', $id)
->first();
- $data['policy_issue_date'] = !empty($data['policy_issue_date']) ? date('d-m-Y', strtotime($data['policy_issue_date'])) : null;
- $data['policy_start_date'] = !empty($data['policy_start_date']) ? date('d-m-Y', strtotime($data['policy_start_date'])) : null;
- $data['policy_end_date'] = !empty($data['policy_end_date']) ? date('d-m-Y', strtotime($data['policy_end_date'])) : null;
- $data['renewal_date'] = !empty($data['renewal_date']) ? date('d-m-Y', strtotime($data['renewal_date'])) : null;
- $data['rollover_date'] = !empty($data['rollover_date']) ? date('d-m-Y', strtotime($data['rollover_date'])) : null;
- $data['created_at'] = !empty($data['created_at']) ? date('d-m-Y h:i:s A', strtotime($data['created_at'])) : null;
- $data['updated_at'] = !empty($data['updated_at']) ? date('d-m-Y h:i:s A', strtotime($data['updated_at'])) : null;
+ $data['policy_issue_date'] = (isset($data['policy_issue_date']) && $data['policy_issue_date'] !== null && $data['policy_issue_date'] !== '')
+ ? date('d-m-Y', strtotime($data['policy_issue_date']))
+ : null;
+
+ $data['policy_start_date'] = (isset($data['policy_start_date']) && $data['policy_start_date'] !== null && $data['policy_start_date'] !== '')
+ ? date('d-m-Y', strtotime($data['policy_start_date']))
+ : null;
+
+ $data['policy_end_date'] = (isset($data['policy_end_date']) && $data['policy_end_date'] !== null && $data['policy_end_date'] !== '')
+ ? date('d-m-Y', strtotime($data['policy_end_date']))
+ : null;
+
+ $data['renewal_date'] = (isset($data['renewal_date']) && $data['renewal_date'] !== null && $data['renewal_date'] !== '')
+ ? date('d-m-Y', strtotime($data['renewal_date']))
+ : null;
+
+ $data['rollover_date'] = (isset($data['rollover_date']) && $data['rollover_date'] !== null && $data['rollover_date'] !== '')
+ ? date('d-m-Y', strtotime($data['rollover_date']))
+ : null;
+
+ $data['created_at'] = (isset($data['created_at']) && $data['created_at'] !== null && $data['created_at'] !== '')
+ ? date('d-m-Y h:i:s A', strtotime($data['created_at']))
+ : null;
+
+ $data['updated_at'] = (isset($data['updated_at']) && $data['updated_at'] !== null && $data['updated_at'] !== '')
+ ? date('d-m-Y h:i:s A', strtotime($data['updated_at']))
+ : null;
+
+ $data['month'] = (isset($data['month']) && $data['month'] !== null && $data['month'] !== '')
+ ? date('M-Y', strtotime($data['month']))
+ : null;
+
// print_r($data); die;
$data['renewal_policy'] = $this->clientPolicyModel
@@ -614,7 +648,11 @@ class PolicyTransactionController extends BaseController
->where('client_policy.is_active', 1)
->findAll();
- $data['pt_files'] = $this->PTFileModel->where('pt_id', $id)->where('is_active', 1)->findAll();
+ $data['pt_files'] = $this->PTFileModel
+ ->join('policy_transaction', 'pt_files.pt_id = policy_transaction.id')
+ ->where('pt_files.pt_id', $id)
+ ->where('pt_files.is_active', 1)
+ ->findAll();
$data['pt_co_share_details'] = $this->PTCOShareDetailsModel->where('pt_id', $id)->where('is_active', 1)->findAll();
$data['emp_data'] = $this->employeeModel
->select('employees.*, employee_polices.id as emp_policy_id')
@@ -644,6 +682,7 @@ class PolicyTransactionController extends BaseController
{
$data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
$data['client_type'] = [1 => 'Group', 2 => 'Individual'];
+
$data['policy_status'] = [
'under_process' => 'Under Process',
'client_pending' => 'Client Pending',
@@ -678,32 +717,38 @@ class PolicyTransactionController extends BaseController
'policy_cancellation' => 'Policy Cancellation',
];
-
- $data['endorsement_data_list'] = $this->policyTransactionModel
- ->select('
- policy_transaction.*,
- clients.short_name as client_short_name,
- clients.client_code,
- client_branch.branch_name as client_branch_name,
- insurers.name AS insurer_name,
- insurers.short_name AS insurer_short_name,
- policy_type.policy_type
- ')
- ->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('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)
- ->where('policy_transaction.action_type !=', 'inception')
- ->orderBy('policy_transaction.id', 'desc')
- ->findAll();
+ $data['date_type'] = [
+ 'policy_issue_date' => 'Policy Issue Date',
+ 'policy_start_date' => 'Policy Start Date',
+ 'policy_end_date' => 'Policy End Date',
+ ];
+ //filter datas
+ $start_date = $this->request->getGet('start_date');
+ $end_date = $this->request->getGet('end_date');
+ $client_id = $this->request->getGet('client_id');
+ $insurer_id = $this->request->getGet('insurer_id');
+ $policy_type_id = $this->request->getGet('policy_type_id');
+ $date_type = $this->request->getGet('date_type');
+ $issuer = $this->request->getGet('issuer');
+ $status = $this->request->getGet('status');
+
+ $start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : $start_date;
+ $end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : $end_date;
+
+ $client_id = (!isset($client_id) || $client_id === '' || $client_id === null) ? 0 : $client_id;
+ $insurer_id = (!isset($insurer_id) || $insurer_id === '' || $insurer_id === null) ? 0 : $insurer_id;
+ $policy_type_id = (!isset($policy_type_id) || $policy_type_id === '' || $policy_type_id === null) ? 0 : $policy_type_id;
+ $date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
+ $issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer;
+ $status = (!isset($issuer) || $status === '' || $status === null) ? 0 : $status;
+
+
+ $data['endorsement_data_list'] = $this->policyTransactionModel->getEndorsementTranctionListData($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $status);
$data['client'] = $this->clientModel->where('is_active', 1)->findAll();
$data['policy_type'] = $this->policyTypeModel->where('is_active', 1)->findAll();
- // $data['insurer'] = $this->insurerModel->where('is_active', 1)->findAll();
+ $data['insurer'] = $this->insurerModel->where('is_active', 1)->findAll();
// $data['tpa'] = $this->tpaModel->where('is_active', 1)->findAll();
$data['insurer_branch'] = $this->insurerBranchModel ->getInsurerBranchesWithInsurerNames();
$data['tpa'] = $this->tpaBranchModel ->getTpaBranchesWithTpaNames();
@@ -895,20 +940,63 @@ class PolicyTransactionController extends BaseController
//file upload function
public function uploadFile()
- {
+ {
+ $GoogleDriveController = new GoogleDriveController();
$files = $this->request->getFiles();
$doc_name = $this->request->getPost('doc_name[]');
$pt_id = $this->request->getPost('pt_id');
-
- $uploadData = uploadFilesToGoogleDrive($files['file'], $doc_name, $pt_id);
- $insert = false;
- if(!isset($uploadData['status'])){
- $this->PTFileModel->insertBatch($uploadData);
- $insert = true;
+ $client_policy_id = $this->request->getPost('client_policy_id');
+ $data = $this->request->getPost();
+
+ $uploadFilePath = WRITEPATH . 'uploads/client_kyc_documents';
+
+ $uploadData = [];
+
+ foreach ($data['doc_name'] as $key => $docName) {
+
+ // Get the corresponding file for this document name
+ $file = $files['file'][$key];
+
+ if (!empty($docName) && $file->isValid() && !$file->hasMoved()) {
+
+ // Upload the file
+ $uploadedFileName = file_Upload($file, $uploadFilePath);
+
+ if ($uploadedFileName) {
+ // Prepare data for each document upload
+ $docData = [
+ 'pt_id' => $pt_id,
+ 'doc_name' => $docName,
+ 'file_name' => $uploadedFileName,
+ 'created_by' => get_session_userid(),
+ ];
+
+ $uploadFilePath = $uploadFilePath . '/' . $uploadedFileName;
+
+ $GoogleDriveController->uploadFiletoGdrive(client_policy_id: $client_policy_id, doc_type: 'POLICY', file_path: $uploadFilePath, file_name: $uploadedFileName);
+
+ // Insert into database
+ $insert = $this->PTFileModel->insert($docData);
+
+ if ($insert) {
+ $uploadData[] = $docData;
+ }
+ }
+ }
}
- if ($insert) {
- $data['pt_files'] = $this->PTFileModel->where('pt_id', $pt_id)->where('is_active', 1)->findAll();
+ // print_r($uploadData); die;
+
+ // $uploadData = uploadFilesToGoogleDrive($files['file'], $doc_name, $pt_id);
+
+ if (!empty($uploadData)) {
+
+ $data['pt_files'] = $this->PTFileModel
+ ->join('policy_transaction', 'pt_files.pt_id = policy_transaction.id')
+ ->where('pt_files.pt_id', $pt_id)
+ ->where('pt_files.is_active', 1)
+ ->findAll();
+
return $this->respond(['status' => true, 'message' => 'File uploaded successfully in G-Drive', 'data' => $data]);
} else {
return $this->respond(['status' => false, 'message' => 'Failed to upload file in G-Drive']);
@@ -1031,7 +1119,6 @@ class PolicyTransactionController extends BaseController
$data['policy_types'] = $this->policyTypeModel->where('is_active', 1)->findAll();
$data['clients'] = $this->clientModel->where('is_active', 1)->findAll();
-
//filter datas
$start_date = $this->request->getGet('start_date');
$end_date = $this->request->getGet('end_date');
@@ -1058,6 +1145,126 @@ class PolicyTransactionController extends BaseController
$this->loadLayout('report_bds_filter', $data);
}
+ public function reportVarience()
+ {
+ $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
+ $data['insurer'] = $this->insurerModel->where('is_active', 1)->findAll();
+ $data['policy_types'] = $this->policyTypeModel->where('is_active', 1)->findAll();
+ $data['clients'] = $this->clientModel->where('is_active', 1)->findAll();
+ $data['date_type'] = [
+ 'policy_issue_date' => 'Policy Issue Date',
+ 'policy_start_date' => 'Policy Start Date',
+ 'policy_end_date' => 'Policy End Date',
+ 'data_received_date' => 'Data Received Date',
+ 'closure_date' => 'Closure Date',
+ ];
+
+ //filter datas
+ $start_date = $this->request->getGet('start_date');
+ $end_date = $this->request->getGet('end_date');
+ $client_id = $this->request->getGet('client_id');
+ $insurer_id = $this->request->getGet('insurer_id');
+ $policy_type_id = $this->request->getGet('policy_type_id');
+ $date_type = $this->request->getGet('date_type');
+ $issuer = $this->request->getGet('issuer');
+
+ $start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : $start_date;
+ $end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : $end_date;
+
+ $client_id = (!isset($client_id) || $client_id === '' || $client_id === null) ? 0 : $client_id;
+ $insurer_id = (!isset($insurer_id) || $insurer_id === '' || $insurer_id === null) ? 0 : $insurer_id;
+ $policy_type_id = (!isset($policy_type_id) || $policy_type_id === '' || $policy_type_id === null) ? 0 : $policy_type_id;
+ $date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
+ $issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer;
+
+
+
+ $data['varience_list'] = $this->policyTransactionModel->getVarienceReportLIst($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer);
+ $this->loadLayout('variance_report_list', $data);
+
+ }
+
+
+ public function reportBusinessList()
+ {
+ $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
+ $data['insurer'] = $this->insurerModel->where('is_active', 1)->findAll();
+ $data['policy_types'] = $this->policyTypeModel->where('is_active', 1)->findAll();
+ $data['clients'] = $this->clientModel->where('is_active', 1)->findAll();
+ $data['date_type'] = [
+ 'policy_issue_date' => 'Policy Issue Date',
+ 'policy_start_date' => 'Policy Start Date',
+ 'policy_end_date' => 'Policy End Date',
+ 'data_received_date' => 'Data Received Date',
+ 'closure_date' => 'Closure Date',
+ ];
+
+ //filter datas
+ $start_date = $this->request->getGet('start_date');
+ $end_date = $this->request->getGet('end_date');
+ $client_id = $this->request->getGet('client_id');
+ $insurer_id = $this->request->getGet('insurer_id');
+ $policy_type_id = $this->request->getGet('policy_type_id');
+ $date_type = $this->request->getGet('date_type');
+ $issuer = $this->request->getGet('issuer');
+
+ $start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : $start_date;
+ $end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : $end_date;
+
+ $client_id = (!isset($client_id) || $client_id === '' || $client_id === null) ? 0 : $client_id;
+ $insurer_id = (!isset($insurer_id) || $insurer_id === '' || $insurer_id === null) ? 0 : $insurer_id;
+ $policy_type_id = (!isset($policy_type_id) || $policy_type_id === '' || $policy_type_id === null) ? 0 : $policy_type_id;
+ $date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
+ $issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer;
+
+
+
+ $data['business_list'] = $this->policyTransactionModel->getBusinessReportList($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer);
+ $this->loadLayout('business_team_list', $data);
+ }
+
+
+ public function reportFinanceList()
+ {
+ $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
+ $data['insurer'] = $this->insurerModel->where('is_active', 1)->findAll();
+ $data['policy_types'] = $this->policyTypeModel->where('is_active', 1)->findAll();
+ $data['clients'] = $this->clientModel->where('is_active', 1)->findAll();
+ $data['date_type'] = [
+ 'policy_issue_date' => 'Policy Issue Date',
+ 'policy_start_date' => 'Policy Start Date',
+ 'policy_end_date' => 'Policy End Date',
+ 'data_received_date' => 'Data Received Date',
+ 'closure_date' => 'Closure Date',
+ ];
+
+ //filter datas
+ $start_date = $this->request->getGet('start_date');
+ $end_date = $this->request->getGet('end_date');
+ $client_id = $this->request->getGet('client_id');
+ $insurer_id = $this->request->getGet('insurer_id');
+ $policy_type_id = $this->request->getGet('policy_type_id');
+ $date_type = $this->request->getGet('date_type');
+ $issuer = $this->request->getGet('issuer');
+
+ $start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : $start_date;
+ $end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : $end_date;
+
+ $client_id = (!isset($client_id) || $client_id === '' || $client_id === null) ? 0 : $client_id;
+ $insurer_id = (!isset($insurer_id) || $insurer_id === '' || $insurer_id === null) ? 0 : $insurer_id;
+ $policy_type_id = (!isset($policy_type_id) || $policy_type_id === '' || $policy_type_id === null) ? 0 : $policy_type_id;
+ $date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
+ $issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer;
+
+
+
+ $data['finance_list'] = $this->policyTransactionModel->getFinanceReportList($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer);
+ $this->loadLayout('finance_team_list', $data);
+ }
+
+
+ //---------------------------------------------------------------------------------------------------
+
//insurer statement list page
public function statementList()
{
@@ -1540,7 +1747,6 @@ class PolicyTransactionController extends BaseController
return $this->respond(['dataStatus' => true, 'code' => 200,'data' => $file['reason']], 200);
}
-
public function dmsSearch()
{
// echo 'scbsc';die();
diff --git a/app/Helpers/DepositHelper.php b/app/Helpers/DepositHelper.php
index 5d45709e..aa5950f0 100755
--- a/app/Helpers/DepositHelper.php
+++ b/app/Helpers/DepositHelper.php
@@ -50,13 +50,13 @@ class DepositHelper
'amount' => $data['amount'],
'sub_type' => $data['sub_type_id'],
'client_id' => $data['client_id'],
- 'client_policy_id' => $data['client_policy_id'],
+ 'client_policy_id' => $data['client_policy_id'] ?? 0,
'cd_ac_no' => $data['cd_ac_no'],
'endorsement_no' => $data['endorsement_no'],
'insurer_id' => $data['insurer_id'],
'unit' => $data['unit'] ?? null,
- 'description' => $data['description'],
- 'event_name' => $data['event_name'],
+ 'description' => $data['description'] ?? null,
+ 'event_name' => $data['event_name'] ?? null,
'transaction_type' => $data['transaction_type'],
'is_active' => 1,
'created_by' => $loggedInUserID,
@@ -99,17 +99,17 @@ class DepositHelper
$getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE cd_ac_no = ? AND is_active = 1 ORDER BY created_at DESC LIMIT 1";
$getLastBalanceParams = [$cd_ac_no];
- $lastBalance = $model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->balance ?? null;
+ $lastBalance = $model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->balance ?? 0;
- if(empty($lastBalance) && $lastBalance == null){
+ // if(empty($lastBalance) && $lastBalance == null){
- $cd_model = new ClientDepositModel();
+ // $cd_model = new ClientDepositModel();
- $getLastBalanceQuery = "SELECT opening_bal FROM cd_master WHERE client_id = ? AND insurer_id = ? AND cd_ac_no = ? AND is_active = 1 ORDER BY created_at DESC LIMIT 1";
- $getLastBalanceParams = [$clientId, $insurerId, $cd_ac_no];
+ // $getLastBalanceQuery = "SELECT opening_bal FROM cd_master WHERE client_id = ? AND insurer_id = ? AND cd_ac_no = ? AND is_active = 1 ORDER BY created_at DESC LIMIT 1";
+ // $getLastBalanceParams = [$clientId, $insurerId, $cd_ac_no];
- $lastBalance = $cd_model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->opening_bal ?? 0;
- }
+ // $lastBalance = $cd_model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->opening_bal ?? 0;
+ // }
return $lastBalance;
}
diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php
index e66bfc88..470bbb0a 100755
--- a/app/Models/ClientPolicyModel.php
+++ b/app/Models/ClientPolicyModel.php
@@ -139,7 +139,7 @@ class ClientPolicyModel extends Model
->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 = 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)
->groupBy('client_policy.insurer_id')
->groupBy('client_policy.client_id', $id) // Group by insurer_id
diff --git a/app/Models/InsurerModel.php b/app/Models/InsurerModel.php
index e05b76a0..a19cd02a 100755
--- a/app/Models/InsurerModel.php
+++ b/app/Models/InsurerModel.php
@@ -37,13 +37,16 @@ class InsurerModel extends Model
->getResult();
}
- public function getInsurerName($insurerId)
+ public function getInsurerName($insurerId, $client_id)
{
// Fetch the insurer name based on the insurer ID
- $query = $this->select('insurers.id,insurers.name, cd_master.cd_ac_no')
- ->join('cd_master', 'cd_master.insurer_id = insurers.id')
- ->where('insurers.id', $insurerId)
- ->get();
+ $query = $this->db->table('client_policy')
+ ->select('insurers.id, insurers.name, cd_master.cd_ac_no')
+ ->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.insurer_id', $insurerId)
+ ->where('client_policy.client_id', $client_id)
+ ->get();
if ($query->resultID->num_rows > 0) {
$result = $query->getRow();
diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php
index 3649e768..40e1f828 100644
--- a/app/Models/PolicyTransactionModel.php
+++ b/app/Models/PolicyTransactionModel.php
@@ -75,6 +75,7 @@ class PolicyTransactionModel extends Model
'ct_type',
'ct_tran_id',
'remarks',
+ 'month',
];
@@ -119,7 +120,11 @@ class PolicyTransactionModel extends Model
->select("
policy_transaction.*,
DATE_FORMAT(policy_transaction.policy_issue_date, '%d %b %Y') AS policy_issue_date,
- DATE_FORMAT(policy_transaction.policy_issue_date, '%b') AS policy_issue_month,
+ DATE_FORMAT(
+ IF(policy_transaction.month IS NULL,
+ policy_transaction.policy_issue_date,
+ policy_transaction.month),
+ '%b') AS policy_issue_month,
CASE
WHEN clients.client_type = 1 THEN 'Group'
WHEN clients.client_type = 2 THEN 'Retail'
@@ -147,25 +152,104 @@ 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,
sales_user.first_name as salse_person_name,
service_user.first_name as service_person_name,
ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) AS premium_wo_gst,
+
ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) * 18 / 100), 2) AS gst_amount,
+
ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) + ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) * 18 / 100), 2)), 2) AS total_premium,
+
ROUND((pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) AS tp_or_ter,
+
DATEDIFF(policy_transaction.policy_end_date, CURDATE()) AS days,
+
(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((pt_co_share_details.bp_amt * pt_co_share_details.agreed_bp_per + (pt_co_share_details.tp_amt + pt_co_share_details.tep_amt) * (pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per)), 2) AS total_irda,
- ROUND((ROUND((pt_co_share_details.bp_amt * pt_co_share_details.agreed_bp_per + (pt_co_share_details.tp_amt + pt_co_share_details.tep_amt) * (pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per)), 2) * 18 / 100), 2) AS gst_on_revenue,
+
ROUND(
- (ROUND((pt_co_share_details.bp_amt * pt_co_share_details.agreed_bp_per + (pt_co_share_details.tp_amt + pt_co_share_details.tep_amt) * (pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per)), 2) +
- ROUND((ROUND((pt_co_share_details.bp_amt * pt_co_share_details.agreed_bp_per + (pt_co_share_details.tp_amt + pt_co_share_details.tep_amt) * (pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per)), 2) * 18 / 100), 2)),
- 2) AS total_amt_received
+ (pt_co_share_details.bp_amt * pt_co_share_details.agreed_bp_per +
+ (pt_co_share_details.tp_amt + pt_co_share_details.tep_amt) *
+ (pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per)) / 100,
+ 2) AS total_irda,
+
+ ROUND(
+ (ROUND(
+ (pt_co_share_details.bp_amt * pt_co_share_details.agreed_bp_per +
+ (pt_co_share_details.tp_amt + pt_co_share_details.tep_amt) *
+ (pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per)) / 100,
+ 2) * 18 / 100),
+ 2) AS gst_on_revenue,
+
+ ROUND(
+ (ROUND(
+ (pt_co_share_details.bp_amt * pt_co_share_details.agreed_bp_per +
+ (pt_co_share_details.tp_amt + pt_co_share_details.tep_amt) *
+ (pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per)) / 100,
+ 2) +
+ ROUND(
+ (ROUND(
+ (pt_co_share_details.bp_amt * pt_co_share_details.agreed_bp_per +
+ (pt_co_share_details.tp_amt + pt_co_share_details.tep_amt) *
+ (pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per)) / 100,
+ 2) * 18 / 100),
+ 2)),
+ 2) AS total_amt_received,
+ insurer_statements.invoice_date,
+ insurer_statements.invoice_no,
+ insurer_statements.invoice_amount,
+
+ (
+ SELECT
+ (SUM(inv_payment_details.inv_amt) + SUM(inv_payment_details.tds)) AS realization_amount
+ FROM
+ inv_payment_details
+ WHERE
+ inv_payment_details.statement_id = insurer_statements.id
+ AND inv_payment_details.is_active = 1
+
+ ) AS realization_amount,
+
+ ROUND(
+ insurer_statements.invoice_amount -
+ (
+ SELECT
+ (SUM(inv_payment_details.inv_amt) + SUM(inv_payment_details.tds))
+ FROM
+ inv_payment_details
+ WHERE
+ inv_payment_details.statement_id = insurer_statements.id
+ AND inv_payment_details.is_active = 1
+ ),
+ 2) AS outstanding_amount,
+
+ (
+ SELECT
+ GROUP_CONCAT(inv_payment_details.utr_no SEPARATOR ', ') AS utr_numbers
+ FROM
+ inv_payment_details
+ WHERE
+ inv_payment_details.statement_id = insurer_statements.id
+ AND inv_payment_details.is_active = 1
+ ) AS utr_numbers,
+
+ (
+ SELECT
+ GROUP_CONCAT(inv_payment_details.received_date SEPARATOR ', ') AS payment_dates
+ FROM
+ inv_payment_details
+ WHERE
+ inv_payment_details.statement_id = insurer_statements.id
+ AND inv_payment_details.is_active = 1
+ ) AS payment_dates
+
")
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
+ ->join('insurer_statements', 'pt_co_share_details.statement_id = insurer_statements.id', 'left')
->join('clients', 'clients.id = policy_transaction.client_id')
->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left')
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
@@ -188,6 +272,13 @@ class PolicyTransactionModel extends Model
$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');
+
+ // $builder->where('policy_transaction.created_at >=', $fromDate)
+ // ->where('policy_transaction.created_at <=', $toDate);
}
if ($client_id != 0) {
@@ -205,8 +296,362 @@ class PolicyTransactionModel extends Model
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){
+
+ $fromDate = date('Y-m-d', strtotime('-30 days'));
+ $toDate = date('Y-m-d');
+
+ $builder->where('policy_transaction.created_at >=', $fromDate)
+ ->where('policy_transaction.created_at <=', $toDate);
+
+ }
return $builder->get()->getResultArray();
}
+ 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);
+ $builder = $this->db->table('policy_transaction')
+ ->select('
+ policy_transaction.*,
+ clients.short_name AS client_short_name,
+ clients.client_code,
+ clients.client_type,
+ clients.client_name,
+ client_branch.branch_name AS client_branch_name,
+ insurers.name AS insurer_name,
+ insurers.short_name AS insurer_short_name,
+ policy_type.policy_type,
+ pt_co_share_details.agreed_amt AS amount,
+ pt_co_share_details.bp_amt AS bp,
+ pt_co_share_details.tp_amt AS tp
+ ')
+ ->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
+ ->join('clients', 'clients.id = policy_transaction.client_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('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)
+ ->where('policy_transaction.action_type', 'inception');
+
+ 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');
+
+ // $builder->where('policy_transaction.created_at >=', $fromDate)
+ // ->where('policy_transaction.created_at <=', $toDate);
+ }
+
+ 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);
+ }
+
+ 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');
+
+ $builder->where('policy_transaction.created_at >=', $fromDate)
+ ->where('policy_transaction.created_at <=', $toDate);
+
+ }
+
+ $builder->orderBy('policy_transaction.id', 'desc');
+
+ 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);
+ $builder = $this->db->table('policy_transaction')
+ ->select('
+ policy_transaction.*,
+ clients.short_name as client_short_name,
+ clients.client_code,
+ client_branch.branch_name as client_branch_name,
+ insurers.name AS insurer_name,
+ insurers.short_name AS insurer_short_name,
+ policy_type.policy_type
+ ')
+ ->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('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)
+ ->where('policy_transaction.action_type !=', 'inception');
+
+
+ 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');
+
+ // $builder->where('policy_transaction.created_at >=', $fromDate)
+ // ->where('policy_transaction.created_at <=', $toDate);
+ }
+
+ 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);
+ }
+
+ 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');
+
+ $builder->where('policy_transaction.created_at >=', $fromDate)
+ ->where('policy_transaction.created_at <=', $toDate);
+
+ }
+
+ $builder->orderBy('policy_transaction.id', 'desc');
+
+ return $builder->get()->getResultArray();
+ }
+
+ public function getVarienceReportLIst($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
+ {
+ $builder = $this->db->table('policy_transaction')
+ ->select('
+ policy_transaction.id,
+ clients.client_name,
+ insurers.name AS insurer_name,
+ policy_type.policy_type,
+ policy_transaction.policy_no,
+ policy_transaction.endorsement_no,
+ pt_co_share_details.exp_amt,
+ pt_co_share_details.variance
+ ')
+ ->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
+ ->join('clients', 'clients.id = policy_transaction.client_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', 'policy_transaction.policy_type_id = policy_type.id', 'left')
+ ->where('policy_transaction.is_active', 1)
+ ->groupStart() // Group the conditions for variance
+ ->where('pt_co_share_details.variance IS NULL')
+ ->orWhere('pt_co_share_details.variance', 0)
+ ->groupEnd();
+
+ 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');
+
+ $builder->where('policy_transaction.created_at >=', $fromDate)
+ ->where('policy_transaction.created_at <=', $toDate);
+ }
+
+ 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);
+ }
+
+ $builder->orderBy('policy_transaction.id', 'desc');
+
+ return $builder->get()->getResultArray();
+ }
+
+ 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)
+ {
+ $builder = $this->db->table('policy_transaction')
+ ->select([
+ 'policy_transaction.id AS policy_trns_id',
+ 'clients.client_name',
+ 'insurers.name AS insurer_name',
+ 'policy_type.policy_type',
+ 'policy_transaction.policy_no',
+ 'policy_transaction.endorsement_no',
+ 'pt_co_share_details.bp_amt',
+ 'pt_co_share_details.tp_amt',
+ 'pt_co_share_details.tep_amt'
+ ])
+ ->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
+ ->join('clients', 'clients.id = policy_transaction.client_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', 'policy_transaction.policy_type_id = policy_type.id', 'left')
+ ->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');
+
+ 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');
+
+ $builder->where('policy_transaction.created_at >=', $fromDate)
+ ->where('policy_transaction.created_at <=', $toDate);
+ }
+
+ 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);
+ }
+
+ $builder->orderBy('policy_transaction.id', 'desc');
+
+ return $builder->get()->getResultArray();
+ }
+
+ 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)
+ {
+ $builder = $this->db->table('policy_transaction')
+ ->select('
+ policy_transaction.id,
+ clients.client_name,
+ insurers.name AS insurer_name,
+ policy_type.policy_type,
+ policy_transaction.policy_no,
+ policy_transaction.endorsement_no,
+ pt_co_share_details.exp_amt,
+ pt_co_share_details.variance
+ ')
+ ->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
+ ->join('clients', 'clients.id = policy_transaction.client_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', 'policy_transaction.policy_type_id = policy_type.id', 'left')
+ ->where('policy_transaction.is_active', 1)
+ ->where('policy_transaction.status', 'completed')
+ ->where('pt_co_share_details.actual_bp_amt IS NULL OR pt_co_share_details.actual_bp_amt = 0')
+ ->where('pt_co_share_details.actual_bp_brokerage_amt IS NULL OR pt_co_share_details.actual_bp_brokerage_amt = 0');
+
+
+
+ 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');
+
+ $builder->where('policy_transaction.created_at >=', $fromDate)
+ ->where('policy_transaction.created_at <=', $toDate);
+ }
+
+ 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);
+ }
+
+ $builder->orderBy('policy_transaction.id', 'desc');
+
+ return $builder->get()->getResultArray();
+ }
}
diff --git a/app/Views/DashBoard.php b/app/Views/DashBoard.php
index 8f2a5aff..e167e919 100755
--- a/app/Views/DashBoard.php
+++ b/app/Views/DashBoard.php
@@ -62,10 +62,17 @@ body {
Enrolment
+ +
+
+
+