diff --git a/app/Config/Constants.php b/app/Config/Constants.php index 47b92f83..d86cf312 100755 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -92,3 +92,25 @@ define('EVENT_PRIORITY_NORMAL', 100); * @deprecated Use \CodeIgniter\Events\Events::PRIORITY_HIGH instead. */ define('EVENT_PRIORITY_HIGH', 10); + +/** + * @User Role Constant + */ + +define('ENROLLMENT_TEAM_ID', '1'); +define('CLAIMS_TEAM_ID', '2'); +define('BUSINESS_TEAM_ID', '3'); +define('FINANCE_TEAM_ID', '4'); +define('SALES_TEAM_ID', '5'); + +/** + * @User Teams Constant + */ + +define('ADMIN_ROLE_ID', 1); +define('MANAGER_ROLE_ID', 2); +define('ACCOUNT_MANAGER_ROLE_ID', 3); +define('STAFF_ROLE_ID', 4); +define('HEAD_ROLE_ID', 5); + + 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..07512fc2 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(); @@ -3127,14 +3135,17 @@ class ClientController extends AdminController // Fetch policies in a single query $policies = $this->clientPolicyModel - ->select(' + ->select(" client_policy.*, policy_type.policy_type, policy_type.ebp, policy_type.etp, policy_type.iep, - policy_type.itp - ') + policy_type.itp, + policy_type.bap, + DATE_FORMAT(client_policy.policy_start_date, '%d/%m/%Y') as policy_start_date, + DATE_FORMAT(client_policy.policy_end_date, '%d/%m/%Y') as policy_end_date + ") ->join('policy_type', 'policy_type.id = client_policy.policy_type_id') ->whereIn('client_policy.client_id', $clientIds) ->where('client_policy.is_active', 1) @@ -3212,6 +3223,7 @@ class ClientController extends AdminController 'aadhar' => $postData['aadhar'], 'phone' => $postData['phone'], 'email' => $postData['email'], + 'entity_type_id' => 7 ]); } else { $client_data['entity_type_id'] = $postData['entity_type_id']; @@ -3389,8 +3401,4 @@ class ClientController extends AdminController } } - - - - } \ No newline at end of file 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/LoginController.php b/app/Controllers/LoginController.php
index 42c885d2..10c42716 100755
--- a/app/Controllers/LoginController.php
+++ b/app/Controllers/LoginController.php
@@ -41,13 +41,20 @@ class LoginController extends BaseController
$user = $UserModel->getUserByEmail($value->email);
if($user){
if($user->is_active !== '0'){
+
+ $user_team = $UserModel->getUserTeamsByUserID($user->id);
+ // dd($user_team);
+
$session_data = [
'isLoggedIn' => True ,
'userid' => $user->id,
'userData' => $user,
'userProfile' => $value->picture,
+ 'user_team' => $user_team,
];
+
set_session_data($session_data);
+
log_message('error', 'Set The UserId : `'. $user->id .'` in Session');
log_message('error', 'User Login Sucessfully');
diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php
index 51dee015..aa1fcd06 100755
--- a/app/Controllers/MasterController.php
+++ b/app/Controllers/MasterController.php
@@ -56,6 +56,7 @@ class MasterController extends AdminController
protected $clientModel;
protected $clientDepositModel;
protected $insurerTemplateModel;
+ protected $cli_colors;
@@ -84,6 +85,13 @@ class MasterController extends AdminController
$this->clientModel = new ClientModel();
$this->clientDepositModel = new ClientDepositModel();
$this->insurerTemplateModel = new InsurerExcelExportTemplateModel();
+ $this->cli_colors = [
+ 'red' => "\033[31m",
+ 'green' => "\033[32m",
+ 'yellow' => "\033[33m",
+ 'blue' => "\033[34m",
+ 'reset' => "\033[0m"
+ ];
}
@@ -1260,6 +1268,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']
@@ -1378,7 +1388,7 @@ class MasterController extends AdminController
$cd_data = $this->CDMasterModel->where('client_id', $data['client_id'])->where('insurer_id', $data['insurer_id'])->findAll();
- return $this->respond(['status' => true, 'data' => $cd_data, 'message' => 'CD Account number created successfully'], 200);
+ return $this->respond(['status' => true, 'data' => $cd_data, 'cd_ac_no'=>$data['cd_ac_no'], 'message' => 'CD Account number created successfully'], 200);
}else{
return $this->respond(['status' => false, 'message' => 'Failed to created CD Account number'], 200);
}
@@ -1544,6 +1554,7 @@ class MasterController extends AdminController
$this->checkAndCreateDirectories();
$this->checkGoogleOAuthCredentialsinDB();
$this->getCronJobsList();
+ $this->checkGdriveRootFolderID();
}
@@ -1592,7 +1603,7 @@ class MasterController extends AdminController
$token = $settingsModel->where('id', 1)->first();
echo "################ CHECKING GMAIL OAUTH FOR EMAIL ###################\n";
- if (is_array($token) && !is_null($token['gmail_api_oauth_credentials'])) {
+ if (is_array($token) && is_null($token['gmail_api_oauth_credentials'])) {
echo "Email OAuth credentials not found in database.\n";
echo "Check the following..!\n";
@@ -1630,4 +1641,20 @@ class MasterController extends AdminController
echo "################################################################\n\n";
}
+ //check gdrive root folder id in env file
+ function checkGdriveRootFolderID()
+ {
+ echo "#################### CHECKING GDRIVE FOLDER ID IN ENV FILE ############################\n";
+ $id = getenv('GDRIVE_ROOT_FOLDER_ID');
+ if($id)
+ {
+ echo $this->cli_colors['green'] . "ID is :". $id . $this->cli_colors['reset']. "\n";
+ }
+ else
+ {
+ echo $this->cli_colors['red'] ."Gdrive Folder id not set in env file. set it under 'GDRIVE_ROOT_FOLDER_ID' in env file.". $this->cli_colors['reset'] ."\n";
+ }
+ echo "################################################################\n\n";
+ }
+
}
\ No newline at end of file
diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php
index ce165798..a001d0f3 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);
}
@@ -207,14 +205,36 @@ class PolicyTransactionController extends BaseController
$data = $this->request->getPost();
// print_r($data); die;
+ // var_dump($data); die;
// Format dates
- $data['policy_issue_date'] = date('Y-m-d', strtotime($data['policy_issue_date'])) ?? null;
- $data['policy_start_date'] = date('Y-m-d', strtotime($data['policy_start_date'])) ?? null;
- $data['policy_end_date'] = date('Y-m-d', strtotime($data['policy_end_date'])) ?? null;
- $data['renewal_date'] = date('Y-m-d', strtotime($data['renewal_date'])) ?? null;
- $data['rollover_date'] = date('Y-m-d', strtotime($data['rollover_date'])) ?? null;
-
+ // $data['policy_issue_date'] = change_date_format($this->request->getPost('policy_issue_date'), 'd/m/Y', 'Y-m-d') ?? null;
+ // $data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd/m/Y', 'Y-m-d') ?? null;
+ // $data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd/m/Y', 'Y-m-d') ?? null;
+ // $data['renewal_date'] = change_date_format($this->request->getPost('renewal_date'), 'd/m/Y', 'Y-m-d') ?? null;
+ // $data['rollover_date'] = change_date_format($this->request->getPost('rollover_date'), 'd/m/Y', 'Y-m-d') ?? 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;
+
+
// Separate Insurer and TPA Branch IDs and IDs
if(isset($data['insurer_id']) && !empty($data['insurer_id'])){
list($data['insurer_branch_id'], $data['insurer_id']) = explode('-', $data['insurer_id']);
@@ -243,11 +263,20 @@ class PolicyTransactionController extends BaseController
} elseif ($data['same_as_proposer']) {
$data['same_as_proposer'] = 1;
}
+
+ if($data['ct_type'] == ""){
+ $data['ct_type'] = 1;
+ }
+
+ $month = '01-'.(string)$this->request->getPost('month');
+ $data['month'] = empty($data['month']) ? null : date('Y-m-d', strtotime($month));
// Determine $is_addon value
$data['is_addon'] = in_array($data['policy_type_id'], [1, 2, 6, 7]) ? 1 :
(in_array($data['policy_type_id'], [4, 5]) ? 2 : ($data['policy_type_id'] == 3 && $data['base_policy'] ? 3 : 1));
+ // print_r($data); die;
+
return $data;
}
@@ -271,7 +300,7 @@ class PolicyTransactionController extends BaseController
$this->policyTransactionModel->update($insert, ['client_policy_id' => $client_policy_id]);
$emp_policy_insert = $this->InsertIndividualEmpPolicyTable($emp_data, $client_policy_id);
- if ($data['status'] == 'completed') {
+ if ($data['client_type'] == 1 && $data['status'] == 'completed') {
$this->processCompletedStatus($data, $client_policy_id, $data['insurer_id']);
}
}
@@ -299,6 +328,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) {
@@ -316,12 +349,18 @@ class PolicyTransactionController extends BaseController
}
if ($data['status'] == 'completed' && $data['ct_type'] == 2) {
- $this->processCompletedStatus($data, $data['client_policy_id'], $data['insurer_id']);
+ if($data['client_type'] == 1){
+ $this->processCompletedStatus($data, $data['client_policy_id'], $data['insurer_id']);
+ }
}
$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);
}
@@ -336,76 +375,89 @@ class PolicyTransactionController extends BaseController
// print_r($data);
// die;
- foreach ($data['follow_insurer_id'] as $index => $insurer) {
- // Separate the insurer and insurer branch
- list($insurer_branch_id, $insurer_id) = explode('-', $insurer);
-
- // Prepare each co-share detail entry
- $coShareDetails[] = [
- 'pt_id' => $pt_id,
- 'insurer_id' => $insurer_id ?? 0,
- 'insurer_branch_id' => $insurer_branch_id ?? 0,
- 'co_share_type' => isset($data['co_share_type'][$index]) ? 2 : 1,
- 'co_share_per' => $data['co_share_per'][$index] ?? 0,
- 'bp_amt' => $data['base_premium'][$index] ?? 0,
- 'bp_gst_amt' => $data['gst_amount'][$index] ?? 0,
- 'bp_igst' => $data['igst'][$index] ?? 0,
- 'bp_sgst' => $data['sgst'][$index] ?? 0,
- 'bp_cgst' => $data['cgst'][$index] ?? 0,
- 'tp_amt' => $data['tp_premium'][$index] ?? 0,
- 'tep_amt' => $data['ter_premium'][$index] ?? 0,
- 'agreed_amt' => $data['agreed_amount'][$index] ?? 0,
- 'agreed_bp_per' => $data['agreed_bp'][$index] ?? 0,
- 'agreed_tp_per' => $data['agreed_tp'][$index] ?? 0,
- 'agreed_tep_per' => $data['agreed_ter'][$index] ?? 0,
- 'standerd_bp_per' => $data['standard_bp'][$index] ?? 0,
- 'standerd_tp_per' => $data['standard_tp'][$index] ?? 0,
- 'standerd_tep_per' => $data['standard_ter'][$index] ?? 0,
- 'actual_bp_amt' => $data['actual_bp_amt'][$index] ?? 0,
- 'actual_tp_amt' => $data['actual_tp_amt'][$index] ?? 0,
- 'actual_tep_amt' => $data['actual_tep_amt'][$index] ?? 0,
- 'actual_bp_per' => $data['actual_bp_per'][$index] ?? 0,
- 'actual_tp_per' => $data['actual_tp_per'][$index] ?? 0,
- 'actual_tep_per' => $data['actual_tep_per'][$index] ?? 0,
- 'actual_bp_brokerage_amt' => $data['actual_bp_brokerage_amt'][$index] ?? 0,
- 'actual_tp_brokerage_amt' => $data['actual_tp_brokerage_amt'][$index] ?? 0,
- 'actual_tep_brokerage_amt' => $data['actual_tep_brokerage_amt'][$index] ?? 0,
- 'exp_amt' => $data['exp_amt'][$index] ?? 0,
- 'amount' => $data['total'][$index] ?? 0,
- 'stamp_duty' => $data['stamp_duty'][$index] ?? 0,
- 'cop_amt' => $data['co_premium'][$index] ?? 0,
- 'variance' => $data['variance'][$index] ?? 0,
- 'reward' => $data['reward'][$index] ?? null,
- 'created_by' => get_session_userid() ?? null,
- 'updated_by' => get_session_userid() ?? null,
- 'id' => $data['co_share_id'][$index] ?? null, // Assuming this is the ID to identify existing records
- ];
- }
+ if(isset($data['follow_insurer_id'])){
- // print_r($coShareDetails); die;
-
- // Separate data into insert and update batches
- $insertData = array_filter($coShareDetails, function($detail) {
- return empty($detail['id']); // Only insert new records
- });
-
- $updateData = array_filter($coShareDetails, function($detail) {
- return !empty($detail['id']); // Only update existing records
- });
-
- // Insert new records
- if (!empty($insertData)) {
- $this->PTCOShareDetailsModel->insertBatch($insertData);
- }
-
- // Update existing records
- if (!empty($updateData)) {
- $this->PTCOShareDetailsModel->updateBatch($updateData, 'id'); // Assuming 'id' is the unique identifier
- }
+ foreach ($data['follow_insurer_id'] as $index => $insurer) {
+
+ // Separate the insurer and insurer branch
+ list($insurer_branch_id, $insurer_id) = explode('-', $insurer);
+
+ // Prepare each co-share detail entry
+ $coShareDetails[] = [
+ 'pt_id' => $pt_id,
+ 'insurer_id' => $insurer_id ?? 0,
+ 'insurer_branch_id' => $insurer_branch_id ?? 0,
+ 'co_share_type' => $data['co_share_type'][$index] ?? null,
+ 'co_share_per' => $data['co_share_per'][$index] ?? 0,
+ 'bp_amt' => $data['base_premium'][$index] ?? 0,
+ 'bp_gst_amt' => $data['gst_amount'][$index] ?? 0,
+ 'bp_igst' => $data['igst'][$index] ?? 0,
+ 'bp_sgst' => $data['sgst'][$index] ?? 0,
+ 'bp_cgst' => $data['cgst'][$index] ?? 0,
+ 'tp_amt' => $data['tp_premium'][$index] ?? 0,
+ 'tep_amt' => $data['ter_premium'][$index] ?? 0,
+ 'agreed_amt' => $data['agreed_amount'][$index] ?? 0,
+ 'agreed_bp_per' => $data['agreed_bp'][$index] ?? 0,
+ 'agreed_tp_per' => $data['agreed_tp'][$index] ?? 0,
+ 'agreed_tep_per' => $data['agreed_ter'][$index] ?? 0,
+ 'standerd_bp_per' => $data['standard_bp'][$index] ?? 0,
+ 'standerd_tp_per' => $data['standard_tp'][$index] ?? 0,
+ 'standerd_tep_per' => $data['standard_ter'][$index] ?? 0,
+ 'actual_bp_amt' => $data['actual_bp_amt'][$index] ?? 0,
+ 'actual_tp_amt' => $data['actual_tp_amt'][$index] ?? 0,
+ 'actual_tep_amt' => $data['actual_tep_amt'][$index] ?? 0,
+ 'actual_bp_per' => $data['actual_bp_per'][$index] ?? 0,
+ 'actual_tp_per' => $data['actual_tp_per'][$index] ?? 0,
+ 'actual_tep_per' => $data['actual_tep_per'][$index] ?? 0,
+ 'actual_bp_brokerage_amt' => $data['actual_bp_brokerage_amt'][$index] ?? 0,
+ 'actual_tp_brokerage_amt' => $data['actual_tp_brokerage_amt'][$index] ?? 0,
+ 'actual_tep_brokerage_amt' => $data['actual_tep_brokerage_amt'][$index] ?? 0,
+ 'exp_amt' => $data['exp_amt'][$index] ?? 0,
+ 'amount' => $data['total'][$index] ?? 0,
+ 'stamp_duty' => $data['stamp_duty'][$index] ?? 0,
+ 'cop_amt' => $data['co_premium'][$index] ?? 0,
+ 'variance' => $data['variance'][$index] ?? 0,
+ 'reward' => $data['reward'][$index] ?? null,
+ 'created_by' => get_session_userid() ?? null,
+ 'updated_by' => get_session_userid() ?? null,
+ 'id' => $data['co_share_id'][$index] ?? null, // Assuming this is the ID to identify existing records
+ ];
+ }
+
+ // print_r($pt_id);
+ // print_r($coShareDetails);
+ // die;
- // print_r($this->PTCOShareDetailsModel->getLastQuery()); die;
+ // Separate data into insert and update batches
+ $insertData = array_filter($coShareDetails, function($detail) {
+ return empty($detail['id']); // Only insert new records
+ });
+
+ $updateData = array_filter($coShareDetails, function($detail) {
+ return !empty($detail['id']); // Only update existing records
+ });
+
+ // Insert new records
+ if (!empty($insertData)) {
+ $this->PTCOShareDetailsModel->insertBatch($insertData);
+ }
+
+ // Update existing records
+ if (!empty($updateData)) {
+ $this->PTCOShareDetailsModel->updateBatch($updateData, 'id'); // Assuming 'id' is the unique identifier
+ }
+
+ // print_r($this->PTCOShareDetailsModel->getLastQuery()); die;
- return true;
+ // print_r($coShareDetails);
+ // die;
+
+ return true;
+
+ }
+
+ // print_r($data);
+ // die;
}
private function prepareClientPolicyInsertData($data)
@@ -542,7 +594,7 @@ class PolicyTransactionController extends BaseController
];
}
- print_r($emp_policy_data); die;
+ // print_r($emp_policy_data); die;
// Insert new records
if (!empty($emp_policy_data)) {
@@ -588,15 +640,72 @@ 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['month'] = (isset($data['month']) && $data['month'] !== null && $data['month'] !== '')
+ // ? date('M/Y', strtotime($data['month']))
+ // : 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;
+
+
+ if(!empty($data['policy_issue_date'])){
+ $data['policy_issue_date'] = change_date_format($data['policy_issue_date'], 'Y-m-d', 'd/m/Y');
+ }
+
+ if(!empty($data['policy_start_date'])){
+ $data['policy_start_date'] = change_date_format($data['policy_start_date'], 'Y-m-d', 'd/m/Y');
+ }
+
+ if(!empty($data['policy_end_date'])){
+ $data['policy_end_date'] = change_date_format($data['policy_end_date'], 'Y-m-d', 'd/m/Y');
+ }
+
+ if(!empty($data['renewal_date'])){
+ $data['renewal_date'] = change_date_format($data['renewal_date'], 'Y-m-d', 'd/m/Y');
+ }
+
+ if(!empty($data['rollover_date'])){
+ $data['rollover_date'] = change_date_format($data['rollover_date'], 'Y-m-d', 'd/m/Y');
+ }
+
+ if(!empty($data['endorse_eff_date'])){
+ $data['endorse_eff_date'] = change_date_format($data['endorse_eff_date'], 'Y-m-d', 'd/m/Y');
+ }
+
+ if(!empty($data['month'])){
+ $data['month'] = change_date_format($data['month'], 'Y-m-d', 'M/Y');
+ }
+
+
// print_r($data); die;
+
$data['renewal_policy'] = $this->clientPolicyModel
->select('client_policy.*, policy_type.policy_type')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
@@ -605,16 +714,23 @@ class PolicyTransactionController extends BaseController
->where('client_policy.is_active', 1)
->findAll();
- $data['base_policy_data'] = $this->clientPolicyModel
- ->select('client_policy.*, policy_type.policy_type')
- ->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
- ->where('client_policy.client_id', $data['client_id'])
- ->where('client_policy.client_branch_id', $data['client_branch_id'])
- ->where('client_policy.policy_type_id', 2)
- ->where('client_policy.is_active', 1)
- ->findAll();
+
+ // $data['base_policy_data'] = $this->clientPolicyModel
+ // ->select('client_policy.*, policy_type.policy_type')
+ // ->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
+ // ->where('client_policy.client_id', $data['client_id'])
+ // ->where('client_policy.client_branch_id', $data['client_branch_id'])
+ // ->where('client_policy.policy_type_id', 2)
+ // ->where('client_policy.is_active', 1)
+ // ->findAll();
- $data['pt_files'] = $this->PTFileModel->where('pt_id', $id)->where('is_active', 1)->findAll();
+ $data['base_policy_data'] = $this->clientPolicyModel->getPolicyDetailsForRemainder($data['client_id']);
+
+ $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')
@@ -642,8 +758,12 @@ class PolicyTransactionController extends BaseController
// Policy Transaction Endorsement
public function viewEndorsement()
{
+ // echo '';
+ // !dd($this->getEndorsementDataForEdit(17));
+
$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 +798,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();
@@ -727,17 +853,48 @@ class PolicyTransactionController extends BaseController
private function preparePolicyTransactionData()
{
$data = $this->request->getPost();
- // print_r($data); die;
- $data_received_date = (string)$this->request->getPost('data_received_date');
- $closure_date = (string)$this->request->getPost('closure_date');
- $data['data_received_date'] = date('Y-m-d', strtotime($data_received_date));
- $data['closure_date'] = date('Y-m-d', strtotime($closure_date));
+ // echo '';
+ // print_r($data);
+ // die;
+
+ // $data_received_date = (string)$this->request->getPost('data_received_date');
+ // $closure_date = (string)$this->request->getPost('closure_date');
+ // $endorse_eff_date = (string)$this->request->getPost('endorse_eff_date');
+ // $month = (string)$this->request->getPost('month');
+
+ // $data['data_received_date'] = empty($data['data_received_date']) ? null : date('Y-m-d', strtotime($data_received_date));
+ // $data['closure_date'] = empty($data['closure_date']) ? null : date('Y-m-d', strtotime($closure_date));
+ // $data['endorse_eff_date'] = empty($data['endorse_eff_date']) ? null : date('Y-m-d', strtotime($endorse_eff_date));
+
+ // $month = '01-'.$data['month'];
+ // $data['month'] = empty($data['month']) ? null : date('Y-m-d', strtotime($month));
+
+
+
+ if(!empty($data['data_received_date'])){
+ $data['data_received_date'] = change_date_format($data['data_received_date'], 'd/m/Y', 'Y-m-d');
+ }
+
+ if(!empty($data['closure_date'])){
+ $data['closure_date'] = change_date_format($data['closure_date'], 'd/m/Y', 'Y-m-d');
+ }
+
+ if(!empty($data['endorse_eff_date'])){
+ $data['endorse_eff_date'] = change_date_format($data['endorse_eff_date'], 'd/m/Y', 'Y-m-d');
+ }
+
+ if(!empty($data['month'])){
+ $month = '01/'.$data['month'];
+ $data['month'] = change_date_format($month, 'd/M/Y', 'Y-m-d');
+ }
+
+ // print_r($data); die;
// Separate Insurer and TPA Branch IDs and IDs
if(isset($data['insurer_id']) && !empty($data['insurer_id'])){
list($data['insurer_branch_id'], $data['insurer_id']) = explode('-', $data['insurer_id']);
- if ($data['tpa']) {
+ if (isset($data['tpa'])) {
list($data['tpa_branch_id'], $data['tpa_id']) = explode('-', $data['tpa']);
}
}
@@ -756,6 +913,7 @@ class PolicyTransactionController extends BaseController
}
if(!$data['id']){
+
$data += [
'issuer' => $issue_type['issuer'] ?? null,
'client_type' => $data['client_type'] ?? $issue_type['client_type'] ?? null,
@@ -793,6 +951,7 @@ class PolicyTransactionController extends BaseController
$data['client_branch_id'] = $client_branch_id;
}
+
// print_r($issue_type);
// print_r($data);
// die;
@@ -836,7 +995,7 @@ class PolicyTransactionController extends BaseController
{
if ($data['status'] == 'completed' && $data['ct_type'] == 2) {
- $tolamt = $data['total'][0];
+ $tolamt = $data['total'][0] ?? 0;
$description = 'The following amount of Rs. ' . round($tolamt, 2) . '/- has been' .
($data['action_type'] == 'deletion' ? ' Credit ' : ' Debit ') . 'from the policy transaction';
@@ -867,21 +1026,53 @@ class PolicyTransactionController extends BaseController
policy_transaction.*,
clients.short_name as client_short_name,
clients.client_type,
- client_policy.policy_start_date as s_date,
- client_policy.policy_end_date as e_date,
')
->join('clients', 'clients.id = policy_transaction.client_id')
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
->where('policy_transaction.id', $id)
->first();
- $data['policy_start_date'] = date('d-m-Y', strtotime($data['s_date']));
- $data['policy_end_date'] = date('d-m-Y', strtotime($data['e_date']));
- $data['data_received_date'] = date('d-m-Y', strtotime($data['data_received_date']));
- $data['closure_date'] = date('d-m-Y', strtotime($data['closure_date']));
+ // $data['policy_start_date'] = empty($data['policy_start_date']) ? '' : date('d/m/Y', strtotime($data['s_date']));
+ // $data['policy_end_date'] = empty($data['policy_end_date']) ? '' : date('d/m/Y', strtotime($data['e_date']));
+ // $data['data_received_date'] = empty($data['data_received_date']) ? '' : date('d/m/Y', strtotime($data['data_received_date']));
+ // $data['closure_date'] = empty($data['closure_date']) ? '' : date('d/m/Y', strtotime($data['closure_date']));
+ // $data['endorse_eff_date'] = empty($data['endorse_eff_date']) ? '' : date('d/m/Y', strtotime($data['endorse_eff_date']));
+
+ // $data['month'] = (isset($data['month']) && $data['month'] !== null && $data['month'] !== '')
+ // ? date('M/Y', strtotime($data['month']))
+ // : null;
+
+
+ if(!empty($data['policy_start_date'])){
+ $data['policy_start_date'] = change_date_format($data['policy_start_date'], 'Y-m-d', 'd/m/Y');
+ }
+
+ if(!empty($data['policy_end_date'])){
+ $data['policy_end_date'] = change_date_format($data['policy_end_date'], 'Y-m-d', 'd/m/Y');
+ }
+
+ if(!empty($data['data_received_date'])){
+ $data['data_received_date'] = change_date_format($data['data_received_date'], 'Y-m-d', 'd/m/Y');
+ }
+
+ if(!empty($data['closure_date'])){
+ $data['closure_date'] = change_date_format($data['closure_date'], 'Y-m-d', 'd/m/Y');
+ }
+
+ if(!empty($data['endorse_eff_date'])){
+ $data['endorse_eff_date'] = change_date_format($data['endorse_eff_date'], 'Y-m-d', 'd/m/Y');
+ }
+
+ if(!empty($data['month'])){
+ $data['month'] = change_date_format($data['month'], 'Y-m-d', 'M/Y');
+ }
+
+ // print_r($data); die;
+
$data['pt_co_share_details'] = $this->PTCOShareDetailsModel->where('pt_id', $id)->where('is_active', 1)->findAll();
+ // print_r($data['endorse_eff_date']); die;
if($data){
return $this->respond(['status' => true, 'data' => $data], 200);
@@ -895,20 +1086,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 +1265,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,11 +1291,133 @@ 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()
{
- // dd($this->updateInsurerStatement(['file_id' => 13]));
+ // 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)));
+ // echo $fromday;die();
$data['invoice_status_array'] = $this->invoiceStatus;
$data['insurers'] = $this->insurerBranchModel ->getInsurerBranchesWithInsurerNames();
@@ -1078,7 +1433,7 @@ class PolicyTransactionController extends BaseController
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)
+ (SELECT SUM(inv_payment_details.inv_amt) + SUM(inv_payment_details.tds)
FROM inv_payment_details
WHERE inv_payment_details.is_active = 1
AND inv_payment_details.statement_id = insurer_statements.id
@@ -1088,10 +1443,12 @@ 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('date(insurer_statements.created_at) >= ', $from_date)
+ ->where('date(insurer_statements.created_at) <= ', $today)
->orderBy('insurer_statements.id', 'DESC')
->findAll();
- // dd( $data['insurer_statement_list']);
+ // dd( $this->insurerStatements->getLastQuery());
$this->loadLayout('insurer_statement_list', $data);
}
@@ -1107,7 +1464,7 @@ class PolicyTransactionController extends BaseController
'max_size[statement,16384]',
],
]);
- $this->createStatementFolder();
+ // $this->createStatementFolder();
if ($validated)
{
$avatar = $this->request->getFile('statement');
@@ -1144,6 +1501,8 @@ class PolicyTransactionController extends BaseController
// print_r($branch_id);
// die();
$month = $this->request->getPost('statement_month');
+ $month = $month.'-01';
+ // print_r($month);die;
$month = change_date_format($month,'Y-M-d','Y-m-d');
// print_r($month);die;
@@ -1232,27 +1591,28 @@ class PolicyTransactionController extends BaseController
// dd($highestRowAndColumn);
$excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
unset($excel_data[0]);
- // dd($excel_data);
+ // Kint::dump($excel_data);
//get no of line items and update in DB
$line_items = count($excel_data);
// get uploaded month transactions data
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(month:$month,year:$year,insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
// var_dump($source_data);die();
- // Kint::dump($excel_data);
+ // Kint::dump($source_data);//die();
// check policy no,insurer and etc in DB for this month
// if all good return true, otherwise return false with messssage
foreach ($excel_data as $excel_key => $excel_row)
{
$is_source_found = 0;
- $excel_row[4] = trim($excel_row[4]);
- $excel_row[5] = trim($excel_row[5]);
- // Kint::dump(change_date_format($excel_row[4],'d-m-Y','Y-m-d'));
- // echo $excel_row[1].'#'.$excel_row[2] .'#'.$excel_row[3].'#'.change_date_format($excel_row[4],'d-m-Y','Y-m-d').'#'.change_date_format($excel_row[5],'d-m-Y','Y-m-d').'
';
+ $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]);//policy_start_date from excel
+ $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]);//policy_end_date from excel
+ $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]);//policy_end_date from excel
+ $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]);//clientname from excel
+ $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]);//policy_end_date from excel
+
foreach ($source_data as $source_key => $source_row)
{
- // Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d'));
- if( (trim($excel_row[1]) == $source_row['policy_no']) && trim($excel_row[2]) == $source_row['endorsement_no'] && trim($excel_row[3]) == $source_row['client_name'] && change_date_format($excel_row[4],'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($excel_row[5],'d-m-Y','Y-m-d') == $source_row['policy_end_date'])
+ if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_row['endorsement_no'] && change_date_format($policy_start_date,'d/m/Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d/m/Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name'])
{
$is_source_found = 1;
unset($source_data[$source_key]);
@@ -1268,7 +1628,6 @@ class PolicyTransactionController extends BaseController
$error_data['error_data'] = array_merge($error_data['error_data'],[$excel_row[0]]);//match not found
}
}
-
if($error_data['error_code'])
{
$status = 'failed';
@@ -1336,13 +1695,16 @@ class PolicyTransactionController extends BaseController
foreach ($excel_data as $excel_key => $excel_row)
{
$is_source_found = 0;
- $excel_row[4] = trim($excel_row[4]);
- $excel_row[5] = trim($excel_row[5]);
+ $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]);//policy_start_date from excel
+ $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]);//policy_end_date from excel
+ $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]);//policy_end_date from excel
+ $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]);//clientname from excel
+ $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]);//policy_end_date from excel
foreach ($source_data as $source_key => $source_row)
{
- // Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d'));
- if( (trim($excel_row[1]) == $source_row['policy_no']) && trim($excel_row[2]) == $source_row['endorsement_no'] && trim($excel_row[3]) == $source_row['client_name'] && change_date_format($excel_row[4],'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($excel_row[5],'d-m-Y','Y-m-d') == $source_row['policy_end_date'])
+ // Kint::dump(change_date_format($excel_row[3],'d/m/Y','Y-m-d'));
+ if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_row['endorsement_no'] && change_date_format($policy_start_date,'d/m/Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d/m/Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name'])
{
$is_source_found = 1;
@@ -1439,10 +1801,11 @@ class PolicyTransactionController extends BaseController
->where('is_active',1)
->get()
->getResultArray();
- // print_r($inv_details);
+ // ~dd($inv_details);
$data = [ 'invoice_status' => $inv_details['invoice_status'],
'invoice_no' => $inv_details['invoice_no'],
- 'invoice_date' => $inv_details['invoice_date'] ];
+ 'invoice_amount' => $inv_details['invoice_amount'],
+ 'invoice_date' => isset($inv_details['invoice_date']) ? change_date_format($inv_details['invoice_date'],'Y-m-d','d/m/Y') : null ];
$data['payments'] = $inv_payment_details;
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $data], 200);
@@ -1459,13 +1822,15 @@ class PolicyTransactionController extends BaseController
$invoiceStatus = $jsonData['invoice_status'];
$hiddenStatementId = $jsonData['hidden_statement_id'];
$invoiceNo = $jsonData['invoice_no'];
- $invoiceDate = $jsonData['invoice_date'];
+ $invoiceDate = change_date_format($jsonData['invoice_date'],'d/m/Y','Y-m-d');
+ $invoice_amount = $jsonData['invoice_amount'];
//Update statement table
$parentData = [
'invoice_status' => $invoiceStatus,
'invoice_no' => $invoiceNo,
'invoice_date' => $invoiceDate,
+ 'invoice_amount' => $invoice_amount,
'updated_by' => get_session_userid()
];
@@ -1474,21 +1839,24 @@ class PolicyTransactionController extends BaseController
$this->insurerStatements->update($hiddenStatementId, $parentData);
// Process child data
- $invoiceAmounts = $jsonData['invoice_amount'];
+ $receivedAmounts = $jsonData['received_amount'];
$utrNos = $jsonData['utr_no'];
+ $tdsTotal = $jsonData['tds'];
$paymentDates = $jsonData['payment_date'];
$pks = $jsonData['pk'];
- foreach ($invoiceAmounts as $index => $invoiceAmount) {
+ foreach ($receivedAmounts as $index => $receivedAmount) {
$pk = $pks[$index]; // Get the pk for the current record
$utrNo = $utrNos[$index];
+ $tds = $tdsTotal[$index];
$paymentDate = $paymentDates[$index];
// Prepare data for insert/update
$childData = [
- 'inv_amt' => $invoiceAmount,
+ 'inv_amt' => $receivedAmount,
'utr_no' => $utrNo,
- 'received_date' => $paymentDate,
+ 'tds' => $tds,
+ 'received_date' => change_date_format($paymentDate,'d/m/Y','Y-m-d'),
'statement_id' => $hiddenStatementId
];
if($pk){
@@ -1540,7 +1908,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/Helpers/session_helper.php b/app/Helpers/session_helper.php
index 92f443d2..4a13df4d 100755
--- a/app/Helpers/session_helper.php
+++ b/app/Helpers/session_helper.php
@@ -140,6 +140,15 @@ if (!function_exists('get_session_context')) {
}
}
+if (!function_exists('user_team')) {
+ function user_team()
+ {
+ // $CI =& get_instance();
+ $session = \Config\Services::session();
+ return $session->get('user_team');
+ }
+}
+
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/InsurerStatements.php b/app/Models/InsurerStatements.php
index 6b85ed0f..0e2dc2ec 100644
--- a/app/Models/InsurerStatements.php
+++ b/app/Models/InsurerStatements.php
@@ -21,6 +21,7 @@ class InsurerStatements extends Model
"reason",
"invoice_status",
"invoice_no",
+ "invoice_amount",
"invoice_date",
"updated_by"
diff --git a/app/Models/InvPaymentDetailsModel.php b/app/Models/InvPaymentDetailsModel.php
index 6b2d9dac..262f76d6 100644
--- a/app/Models/InvPaymentDetailsModel.php
+++ b/app/Models/InvPaymentDetailsModel.php
@@ -15,6 +15,7 @@ class InvPaymentDetailsModel extends Model
'statement_id',
'inv_amt',
'utr_no',
+ 'tds',
'received_date',
'created_by',
'is_active',
diff --git a/app/Models/PTCOShareDetailsModel.php b/app/Models/PTCOShareDetailsModel.php
index 274b572b..385645ed 100644
--- a/app/Models/PTCOShareDetailsModel.php
+++ b/app/Models/PTCOShareDetailsModel.php
@@ -87,16 +87,18 @@ class PTCOShareDetailsModel extends Model
pt_co.bp_amt,
pt_co.tp_amt,
pt_co.tep_amt,
- pt_co.exp_amt
+ pt_co.exp_amt,
+ pt_co.statement_id
')
->join('policy_transaction pt', 'pt_co.pt_id = pt.id')
->join('clients c', 'pt.client_id = c.id')
->where('pt_co.is_active', 1)
- ->where('MONTH(pt.created_at)', $month)
- ->where('YEAR(pt.created_at)', $year)
+ ->where('MONTH(pt.month)', $month)
+ ->where('YEAR(pt.month)', $year)
->where('pt_co.insurer_id', $insurer_id)
->where('pt_co.insurer_branch_id', $insurer_branch_id)
->where('pt_co.statement_id is null')
+ ->where('pt.status','completed')
// ->where('pt_co.exp_amt', 0.00)
// ->orWhere('pt_co.exp_amt is null')
->get()
diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php
index 3649e768..dca5d9b4 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 %Y') AS policy_issue_month,
CASE
WHEN clients.client_type = 1 THEN 'Group'
WHEN clients.client_type = 2 THEN 'Retail'
@@ -147,31 +152,110 @@ 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')
->join('user_profiles', 'policy_transaction.created_by = user_profiles.id', 'left')
->join('vehicle', 'policy_transaction.vehicle_id = vehicle.id', 'left')
- ->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
+ ->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
->join('insurers', 'policy_transaction.insurer_id = insurers.id', 'left')
->join('insurer_branch', 'policy_transaction.insurer_branch_id = insurer_branch.id', 'left')
->join('tpa', 'policy_transaction.tpa_id = tpa.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 23:59:59');
+
+ // $builder->where('policy_transaction.created_at >=', $fromDate)
+ // ->where('policy_transaction.created_at <=', $toDate);
}
if ($client_id != 0) {
@@ -205,8 +296,395 @@ 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 23:59:59');
+
+ $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 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 23:59:59');
+
+ // $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 23:59:59');
+
+ $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 23:59:59');
+
+ // $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 23:59:59');
+
+ $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,
+ CASE
+ WHEN policy_transaction.action_type = 'inception' THEN 'I'
+ ELSE 'E'
+ END AS action_type,
+ pt_co_share_details.exp_amt,
+ pt_co_share_details.variance,
+ insurer_statements.invoice_amount,
+ insurer_statements.invoice_status,
+
+ ROUND((pt_co_share_details.actual_bp_brokerage_amt + pt_co_share_details.actual_tp_brokerage_amt + pt_co_share_details.actual_tep_brokerage_amt), 2) AS realization_amount2,
+
+ (
+ 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,
+
+ ")
+ ->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('inv_payment_details', 'insurer_statements.id = inv_payment_details.statement_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('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) {
+
+ $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);
+ }
+
+ 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',
+ "CASE
+ WHEN policy_transaction.action_type = 'inception' THEN 'I'
+ ELSE 'E'
+ END AS action_type",
+ 'policy_transaction.action_type as action_type_full',
+ '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 23:59:59');
+
+ $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,
+ CASE
+ WHEN policy_transaction.action_type = 'inception' THEN 'I'
+ ELSE 'E'
+ END AS action_type,
+ policy_transaction.action_type AS action_type_full,
+ 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('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');
+
+
+ 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);
+ }
+
+ 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/Models/UserModel.php b/app/Models/UserModel.php
index 94ab4d18..8eb0e6f7 100755
--- a/app/Models/UserModel.php
+++ b/app/Models/UserModel.php
@@ -105,5 +105,24 @@ class UserModel extends Model
->getResult();
}
+ public function getUserTeamsByUserID($user_id){
+
+ $user_teams = $this->db->table('user_profiles')
+ ->select('user_teams.team_id')
+ ->join('user_teams', 'user_profiles.id = user_teams.user_id')
+ ->where('user_profiles.id', $user_id)
+ ->where('user_teams.is_active', 1)
+ ->get()
+ ->getResultArray();
+
+ if (!empty($user_teams)) {
+ // Extract only the 'team_id' values
+ $team_ids = array_column($user_teams, 'team_id');
+ return $team_ids; // Return array of team IDs
+ } else {
+ return []; // Return empty array if no teams found
+ }
+ }
+
}
?>
\ No newline at end of file
diff --git a/app/Views/DashBoard.php b/app/Views/DashBoard.php
index 8f2a5aff..b931e838 100755
--- a/app/Views/DashBoard.php
+++ b/app/Views/DashBoard.php
@@ -62,10 +62,23 @@ body {
Enrolment
+
+
+
+ +
+
+
+
| + + | '.$row['first_name'] ?> | - + + | @@ -203,7 +203,7 @@ table.dataTable tbody td {