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 + + + + + + +
+
diff --git a/app/Views/bds_dash.php b/app/Views/bds_dash.php new file mode 100644 index 00000000..4418c119 --- /dev/null +++ b/app/Views/bds_dash.php @@ -0,0 +1,195 @@ + + +
+
+ + +
+
+
+
Business Team Pending
+

+

 

+

 

+
+
+
+ + + + + +
+
+
+
Finance Team Pending
+

+

 

+

 

+
+
+
+ + +
+
+ + \ No newline at end of file diff --git a/app/Views/business_team_list.php b/app/Views/business_team_list.php new file mode 100644 index 00000000..33c99426 --- /dev/null +++ b/app/Views/business_team_list.php @@ -0,0 +1,440 @@ + + +
+
+
+
+
+ + + +
+
+
+
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ +
+ + +
+ + + + + +
+ + +
+
+
+
+ +
+
+
+ +
+
+
+
+
+

Business Team

+
+ +
+
+ + + + + + + + + + + + + + + + $row){ ?> + + + + + + + + + + + + + +
S.NoClient NameInsurerPolicyPolicy NoEndorsement NoEvent TypeAction
+ +
+ +
+
+
+
+
+
+ + \ No newline at end of file diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 2867a42c..40e04f54 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -11,6 +11,20 @@ .select2-container .select2-selection--multiple .select2-selection__choice { color: #000000; } + /* .select2-search__field{ + height: 2px !important; + } */ + + .select2-selection__choice { + background-color: #0a8794 !important; + color: white !important; + font-weight: bold; + } + + .select2-selection__choice__remove { + color: white !important; + margin-right: 5px; + } + +
+
+
+
+
+ + + +
+
+
+
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ +
+ + +
+ + + + + +
+ + +
+
+
+
+ +
+
+
+ +
+
+
+
+
+

Finance Team

+
+ +
+
+ + + + + + + + + + + + + + + + $row){ ?> + + + + + + + + + + + + + +
S.NoClient NameInsurerPolicyPolicy NoEndorsement NoEvent TypeAction
+ +
+ +
+
+
+
+
+
+ + \ No newline at end of file diff --git a/app/Views/insurer_statement_list.php b/app/Views/insurer_statement_list.php index cf14f29d..4407c302 100644 --- a/app/Views/insurer_statement_list.php +++ b/app/Views/insurer_statement_list.php @@ -113,13 +113,10 @@ table.dataTable tbody td {

Insurer Statement List

- - - - - + +
- +
@@ -155,18 +152,20 @@ table.dataTable tbody td { @@ -203,7 +203,7 @@ table.dataTable tbody td {
-
+
-
+
- +
-
+ @@ -254,7 +254,7 @@ table.dataTable tbody td {
-
- + + @@ -324,9 +329,10 @@ table.dataTable tbody td { - + + - + @@ -354,19 +360,24 @@ table.dataTable tbody td { const invoiceNoDiv = document.getElementById('invoice_no_div_modal'); // const invoiceDateDiv = document.getElementById('invoice_date_div_modal'); const paymentTableDiv = document.getElementById('payment_table_div_modal'); + const totalReceivedAmtDiv = document.getElementById('modal_received_amt_div'); // Hide everything initially invoiceNoDiv.style.display = 'none'; // invoiceDateDiv.style.display = 'none'; paymentTableDiv.style.display = 'none'; + totalReceivedAmtDiv.style.display = 'none'; // Show fields based on selected status if (invoiceStatus === 'generated' || invoiceStatus === 'sent') { invoiceNoDiv.style.display = 'flex'; + totalReceivedAmtDiv.style.display = 'none'; switchRequired('invoice_no_modal',true); switchRequired('invoice_date_modal',true); + switchRequired('invoice_amount_no_modal',true); - switchRequired('invoice_amount',false,'name'); + switchRequired('received_amount',false,'name'); + switchRequired('tds',false,'name'); switchRequired('utr_no',false,'name'); switchRequired('payment_date',false,'name'); switchRequired('pk',false,'name'); @@ -374,24 +385,32 @@ table.dataTable tbody td { } else if (invoiceStatus === 'payment_received') { invoiceNoDiv.style.display = 'flex'; paymentTableDiv.style.display = 'block'; + totalReceivedAmtDiv.style.display = 'block'; switchRequired('invoice_no_modal',true); switchRequired('invoice_date_modal',true); - - switchRequired('invoice_amount',true,'name'); + switchRequired('invoice_amount_no_modal',true); + + + switchRequired('received_amount',true,'name'); switchRequired('utr_no',true,'name'); + switchRequired('tds',true,'name'); switchRequired('payment_date',true,'name'); switchRequired('pk',true,'name'); }else if(invoiceStatus === 'pending') { invoiceNoDiv.style.display = 'none'; paymentTableDiv.style.display = 'none'; + totalReceivedAmtDiv.style.display = 'none'; + // switchRequired('modal_received_amt_div',false); switchRequired('invoice_no_modal',false); switchRequired('invoice_date_modal',false); + switchRequired('invoice_amount_no_modal',false); - switchRequired('invoice_amount',false,'name'); + switchRequired('received_amount',false,'name'); switchRequired('utr_no',false,'name'); switchRequired('payment_date',false,'name'); switchRequired('pk',false,'name'); + switchRequired('tds',false,'name'); } }); @@ -417,12 +436,21 @@ table.dataTable tbody td { $('#invoiceForm').on('submit', function (e) { e.preventDefault(); // Prevent default form submission var form = document.getElementById('invoiceForm'); - if(!form.checkValidity()) + // alert(form.checkValidity()); + // alert($('#invoice_date_modal').val()); + if((!form.checkValidity())) { + // console.log('error2'); return false; } - - + + if($('#invoice_date_modal').val().trim() === '' && $('#invoice_status').val() != 'pending') + { + // console.log('error1'); + return false; + } + // console.log('final'); + // return false; // Serialize form data to array and then convert to JSON var formData = new FormData(form); var formDataJSON = {}; @@ -456,14 +484,13 @@ table.dataTable tbody td { success: function (response) { console.log(response); // Close the modal - var myModal = new bootstrap.Modal(document.getElementById('invoice_modal')); - myModal.hide(); - + + $('.close').click() // Reset the form data $('#invoiceForm')[0].reset(); - - // Optionally display success message or perform further actions + alert('Invoice updated successfully!'); + location.reload(); }, error: function (xhr, status, error) { // Handle any errors @@ -471,6 +498,7 @@ table.dataTable tbody td { alert('An error occurred while updating the invoice.'); } }); + // location.reload(); $('.loader').fadeOut(); $('.loader-mask').delay(10).fadeOut('slow'); }); @@ -484,13 +512,18 @@ table.dataTable tbody td { newRow.innerHTML = ` - + + - + `; tableBody.appendChild(newRow); + $('.payment_date').datepicker({ + format: 'dd-mm-yyyy', + autoclose: true + }); }); // Remove row @@ -529,33 +562,7 @@ table.dataTable tbody td { }); - function switchRequired(elementId, isRequired, type = 'id') { - - if(type == 'id')//id attribute - { - let element = document.getElementById(elementId); - if (isRequired) { - element.setAttribute('required', 'required'); - } else { - element.removeAttribute('required'); - } - } - else //name attribute - { - var name_attribute = elementId+'[]'; - // Select all elements with the name 'invoice_amt[]' - var elements = document.getElementsByName(name_attribute); - - // Loop through the elements and set or remove the 'required' attribute - elements.forEach(function(element) { - if (isRequired) { - element.setAttribute('required', 'required'); // Make required - } else { - element.removeAttribute('required'); // Remove required - } - }); - } -} + @@ -568,16 +575,31 @@ function showFileUploadModal(input) // $(input).val(''); } +function formatDate(date) { + var day = ("0" + date.getDate()).slice(-2); + var month = ("0" + (date.getMonth() + 1)).slice(-2); + var year = date.getFullYear(); + return day + "-" + month + "-" + year; +} +function formatDateToDMY(dateStr) { + // Split the date string by the hyphen + var parts = dateStr.split('-'); + return parts[2] + '-' + parts[1] + '-' + parts[0]; // Rearrange to DD-MM-YYYY +} function showInvoiceStatusModal(event) { + var modal_received_amt_div = document.getElementById('modal_received_amt_div'); + modal_received_amt_div.style.display = 'none'; + // alert(); // console.log(event.target.data) var dataId = event.target.getAttribute('data-id'); var dataExpAmt = event.target.getAttribute('data-exp-amt'); var dataReceivedAmt = event.target.getAttribute('data-received-amt'); // Set the value to a hidden input field in the modal document.getElementById('hidden_statement_id').value = dataId; - document.getElementById('modal_exp_amt').value = dataExpAmt; + // document.getElementById('modal_exp_amt').value = dataExpAmt; document.getElementById('modal_received_amt').value = dataReceivedAmt; + $('.loader').fadeIn(); $('.loader-mask').fadeIn(); // AJAX call to get the invoice details based on data-id @@ -602,8 +624,14 @@ function showInvoiceStatusModal(event) } document.getElementById('invoice_no_modal').value = response.data.invoice_no; - document.getElementById('invoice_date_modal').value = response.data.invoice_date; + document.getElementById('invoice_date_modal').value = response.data.invoice_date === '' ? : response.data.invoice_date; + document.getElementById('invoice_amount_no_modal').value = response.data.invoice_amount; + if (!$('#invoice_date_modal').val()) { + // alert('nope'); + // Set today's date as the default date + $('#invoice_date_modal').datepicker('setDate', new Date()); + } // Clear existing rows in the payment table var paymentTableBody = document.querySelector('#payment_table_modal tbody'); @@ -616,14 +644,15 @@ function showInvoiceStatusModal(event) var row = paymentTableBody.insertRow(); row.innerHTML = ` - + + - + `; }); } - + $('.payment_date').datepicker({ format: 'dd-mm-yyyy',autoclose: true}); // Show the modal var myModal = new bootstrap.Modal(document.getElementById('invoice_modal')); myModal.show(); @@ -641,17 +670,51 @@ function showInvoiceStatusModal(event) }); $('.loader').fadeOut(); $('.loader-mask').delay(10).fadeOut('slow'); - var myModal = new bootstrap.Modal(document.getElementById('invoice_modal')); - myModal.show(); + // var myModal = new bootstrap.Modal(document.getElementById('invoice_modal')); + // myModal.show(); // $(input).val(''); } $(document).ready(function(){ - var rollover_date = flatpickr("#statement_month", { - dateFormat: "Y-M-d", - allowInput: true + // var rollover_date = flatpickr("#statement_month", { + // dateFormat: "Y-M", + // allowInput: true + // }); + $('#statement_month').datepicker({ + format: 'yyyy-M', + viewMode: 'months', + minViewMode: 'months', + autoclose: true }); + + + $('.payment_date').datepicker({ + format: 'dd-mm-yyyy', + autoclose: true + }); + + // Get today's date +var today = new Date(); + +// Calculate the minimum date (60 days before today) +var minDate = new Date(); +minDate.setDate(today.getDate() - 180); + +// Calculate the maximum date (60 days after today) +var maxDate = new Date(); +maxDate.setDate(today.getDate() + 180); + $('#invoice_date_modal').datepicker({ + format: 'dd-mm-yyyy', + autoclose: true, + startDate: minDate, + endDate: maxDate + }); + + // var invoice_date_modal = flatpickr("#invoice_date_modal", { + // dateFormat: "d-m-Y", + // allowInput: true + // }); }); @@ -692,7 +755,7 @@ $(document).ready(function(){ toastr.success( 'File upload successs', 'success'); - $('.close').click() + $('.close').click(); window.location.reload(true); } else if (response.code === 404 && response.dataStatus === false) { console.error('no data found', response); @@ -765,19 +828,59 @@ $(document).ready(function(){ } -function checkInvAmont(event) -{ +function checkInvAmont(event) { var total = 0; - document.querySelectorAll('input[name="invoice_amount[]"]').forEach(function(el) { - let val = parseFloat(el.value) || 0; - total += val; - }); - var exp_amt = document.getElementById('modal_exp_amt').value; - if(exp_amt < total) - { - alert('Exceeds expected amt'); - event.target.value = ''; + var receivedAmounts = document.querySelectorAll('input[name="received_amount[]"]'); + var tdsAmounts = document.querySelectorAll('input[name="tds[]"]'); + // console.log(); + receivedAmounts.forEach(function(el, index) { + // Get the received amount + let receivedVal = parseFloat(el.value) || 0; + // Get the corresponding tds amount (paired with the received amount) + let tdsVal = parseFloat(tdsAmounts[index].value) || 0; + // Add received amount and tds amount + // console.log(); + total += (receivedVal + tdsVal); + }); + // console.log(total); + // Get the expected invoice amount + var exp_amt = parseFloat(document.getElementById('invoice_amount_no_modal').value) || 0; + + // Check if the total exceeds the expected amount + if (exp_amt < total) { + alert('Exceeds Invoice amount'); + event.target.value = ''; // Reset the value of the element that triggered the event } } + +function switchRequired(elementId, isRequired, type = 'id') { + // console.log('switchRequired: ' + elementId+' - '+' - '+ type); + if(type == 'id')//id attribute + { + let element = document.getElementById(elementId); + if (isRequired) { + element.setAttribute('required', 'required'); + } else { + element.removeAttribute('required'); + } + } + else //name attribute + { + var name_attribute = elementId+'[]'; + // Select all elements with the name 'invoice_amt[]' + var elements = document.getElementsByName(name_attribute); + + // Loop through the elements and set or remove the 'required' attribute + elements.forEach(function(element) { + if (isRequired) { + element.setAttribute('required', 'required'); // Make required + } else { + element.removeAttribute('required'); // Remove required + } + }); + } +} + + \ No newline at end of file diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index 5d7450ef..6f7dcf21 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -652,6 +652,7 @@ +
  • @@ -667,18 +668,44 @@
  • Endorsement
  • + + + +
  • + Statement upload +
  • + +
  • + BDS +
  • +
  • + Variance +
  • +
  • + Finance Team +
  • + + + + + +
  • + Business Team +
  • + +
  • - BDS + CD Master
  • - Statement upload -
  • -
  • - DMS Search + Documents
  • + + + diff --git a/app/Views/policy_transaction_endorsement_form.php b/app/Views/policy_transaction_endorsement_form.php index 830f983e..8d2d529d 100644 --- a/app/Views/policy_transaction_endorsement_form.php +++ b/app/Views/policy_transaction_endorsement_form.php @@ -60,6 +60,12 @@ color: #666; /* Darker text color */ } +.readonly-select { + pointer-events: none; + background-color: #f0f0f0; + color: #666; +} + .select2-hidden-accessible + .select2-container .select2-dropdown { display: none !important; } @@ -68,6 +74,29 @@ color: #000000; } +.right-align-input { + text-align: right; +} + +.input-with-percentage { + position: relative; +} + +.input-with-percentage input { + padding-right: 20px; + text-align: right; +} + +.input-with-percentage::after { + content: '%'; + position: absolute; + right: 5px; + top: 50%; + transform: translateY(-50%); + font-weight: bold; + color: #000; +} +
    - + Back
    @@ -161,7 +190,7 @@
    - + + +
    - - + +
    - - + + +
    + +
    + +
    @@ -222,15 +256,14 @@
    - +
    - +
    - count

    @@ -337,8 +370,6 @@ - - @@ -370,13 +401,13 @@ - + - + - + @@ -418,8 +449,12 @@ - \ No newline at end of file diff --git a/app/Views/policy_transaction_endorsement_list.php b/app/Views/policy_transaction_endorsement_list.php index 5b83f818..6d133613 100644 --- a/app/Views/policy_transaction_endorsement_list.php +++ b/app/Views/policy_transaction_endorsement_list.php @@ -21,12 +21,6 @@ table.dataTable thead th { position: absolute; } -.readonly-select { - pointer-events: none; - background-color: #f0f0f0; - color: #666; -} - .column-header { margin-right: 10px; /* Adjust this value as needed */ } @@ -44,6 +38,131 @@ table.dataTable thead th { } +
    +
    +
    +
    +
    + + + +
    +
    +
    +
    +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    +
    + +
    + +
    + + +
    + +
    + + +
    + + + + + + +
    + +
    +
    +
    +
    + +
    +
    +
    +
    @@ -60,6 +179,7 @@ table.dataTable thead th {
    + + '.$row['first_name'] ?> - + +
    pkInvoice AmountReceived AmountTDS UTR Number Date Action
    Agreed Amount
    Actual TEP %
    Actual BP Brokerage AmountActual BP
    Remuneration Amount
    Actual TP Brokerage AmountActual TP
    Remuneration Amount
    Expected Amount
    + @@ -68,7 +188,7 @@ table.dataTable thead th { - + @@ -76,8 +196,9 @@ table.dataTable thead th { - + $row){ ?> + @@ -85,17 +206,17 @@ table.dataTable thead th { - - - - + + + + @@ -171,7 +292,8 @@ table.dataTable thead th { searchPlaceholder: "Search..." }, paging: true, // Enable pagination - pageLength: 25 // Set default number of rows per page (optional) + pageLength: 25, // Set default number of rows per page (optional) + ordering: false, }); } else { console.error("Table not found."); @@ -184,41 +306,61 @@ table.dataTable thead th { var today = new Date(); var data_received_date = flatpickr("#data_received_date", { - dateFormat: "d-m-Y", - allowInput: false + dateFormat: "d/m/Y", + allowInput: false, + parseDate: (datestr, format) => { + return new Date(datestr.replace(/(\d{2})-(\d{2})-(\d{4})/, "$2/$1/$3")); + }, + onOpen: function(selectedDates, dateStr, instance) { + instance.setDate(instance.input.value, false); + }, + onInput: function(selectedDates, dateStr, instance) { + let inputValue = instance.input.value; + let formattedDate = inputValue.replace(/(\d{2})-(\d{2})-(\d{4})/, "$2/$1/$3"); + instance.input.value = formattedDate; + } }); + var closure_date = flatpickr("#closure_date", { - dateFormat: "d-m-Y", + dateFormat: "d/m/Y", allowInput: false }); - var start_date = flatpickr("#policy_start_date", { - dateFormat: "d-m-Y", - allowInput: false - }); + // var start_date = flatpickr("#policy_start_date", { + // dateFormat: "d/m/Y", + // allowInput: false + // }); - var end_date = flatpickr("#policy_end_date", { - dateFormat: "d-m-Y", - allowInput: false - }); + // var end_date = flatpickr("#policy_end_date", { + // dateFormat: "d/m/Y", + // allowInput: false + // }); var endorse_eff_date = flatpickr("#endorse_eff_date", { - dateFormat: "d-m-Y", + dateFormat: "d/m/Y", allowInput: false }); - }) + var month = flatpickr("#month", { + dateFormat: "M/Y", + allowInput: false, + }); + + }); function hide_list_show_add() { removeAllColumnsExceptFirst('insurerTable'); + $('.hideter').hide() + $('.hidetp').hide() $('#endorsement_form_id')[0].reset(); $('#client_id').val('').change(); $('#client_policy_id').val('').change(); - $('#endorsement_form').show() - $('#endorsement_list').hide() - $('#invoice_no_div').hide() + $('#endorsement_form').show(); + $('#endorsement_list').hide(); + $('#endorsement_filter').hide(); + $('#invoice_no_div').hide(); $('#invoice_no').attr('required', false) } @@ -226,6 +368,7 @@ table.dataTable thead th { { $('#endorsement_form').hide() $('#endorsement_list').show() + $('#endorsement_filter').show() } @@ -330,6 +473,7 @@ table.dataTable thead th { 'data-etp' : item.etp, 'data-iep' : item.iep, 'data-itp' : item.itp, + 'data-bap' : item.bap, 'data-tpa' : item.tpa_branch_id + '-' + item.tpa_id, }); $('#client_policy_id').append(option); @@ -429,4 +573,170 @@ table.dataTable thead th { } }) + + + + \ No newline at end of file diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index a5e74b27..76d12b85 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -60,6 +60,12 @@ color: #666; /* Darker text color */ } +.readonly-select { + pointer-events: none; + background-color: #f0f0f0; + color: #666; +} + .select2-hidden-accessible + .select2-container .select2-dropdown { display: none !important; } @@ -73,7 +79,49 @@ color: #fff; } +.right-align-input { + text-align: right; +} +.input-with-percentage { + position: relative; +} + +.input-with-percentage input { + padding-right: 20px; + text-align: right; +} + +.input-with-percentage::after { + content: '%'; + position: absolute; + right: 5px; + top: 50%; + transform: translateY(-50%); + font-weight: bold; + color: #000; +} + +/* .select2-container .select2-selection__rendered { + min-height: 38px; + display: flex; + align-items: center; +} + +.select2-search__field{ + height: 0px !important; +} */ + +.select2-selection__choice { + background-color: #0a8794 !important; + color: white !important; + font-weight: bold; +} + +.select2-selection__choice__remove { + color: white !important; + margin-right: 5px; +}
    @@ -92,7 +140,7 @@
    Back + >Back
    + + +
    @@ -306,9 +357,14 @@
    + + +
    + +
    -
    - - -
    -
    @@ -390,6 +441,11 @@
    +
    + + +
    +
    @@ -401,7 +457,7 @@
    - +
    - +
    @@ -454,7 +510,7 @@ - + @@ -541,6 +597,9 @@ + + + @@ -583,8 +642,6 @@ - - @@ -651,6 +708,7 @@ +
    @@ -861,79 +919,114 @@
    + + \ No newline at end of file diff --git a/app/Views/policy_transaction_inception_list.php b/app/Views/policy_transaction_inception_list.php index 271af57c..2f8a4885 100644 --- a/app/Views/policy_transaction_inception_list.php +++ b/app/Views/policy_transaction_inception_list.php @@ -105,6 +105,131 @@ table.dataTable tbody td { } +
    +
    +
    +
    +

    + + + +

    +
    +
    +
    +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    +
    + +
    + +
    + + +
    + +
    + + +
    + + + + + +
    + + +
    +
    +
    +
    + +
    +
    +
    +
    @@ -122,6 +247,7 @@ table.dataTable tbody td {
    Sno Issuer Client BranchEndorsement Type Endorsement No Data Recived DateNo of EmployeesNo of Insured No of Dependence Closure Date Status
    CD Acc No
    Agreed Amount
    + @@ -132,7 +258,7 @@ table.dataTable tbody td { - + @@ -140,8 +266,9 @@ table.dataTable tbody td { - + $row){ ?> + @@ -149,17 +276,17 @@ table.dataTable tbody td { - - - - - + + + + + - - - - - - - - - - - + + + + + - - - - - - - + + + + + - + - - - + + + - - + - - + + @@ -85,52 +80,53 @@ table.dataTable tbody td { $row){ ?> - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -143,6 +139,7 @@ table.dataTable tbody td { + \ No newline at end of file diff --git a/writable/tmp/20240924164906 b/writable/tmp/20240924164906 new file mode 100644 index 00000000..826fdc80 Binary files /dev/null and b/writable/tmp/20240924164906 differ diff --git a/writable/tmp/20240924165542 b/writable/tmp/20240924165542 new file mode 100644 index 00000000..1e61950a Binary files /dev/null and b/writable/tmp/20240924165542 differ diff --git a/writable/tmp/20240924171719 b/writable/tmp/20240924171719 new file mode 100644 index 00000000..b9deb977 Binary files /dev/null and b/writable/tmp/20240924171719 differ diff --git a/writable/tmp/20240926123034 b/writable/tmp/20240926123034 new file mode 100644 index 00000000..f5b71fdb Binary files /dev/null and b/writable/tmp/20240926123034 differ diff --git a/writable/tmp/20241001102246 b/writable/tmp/20241001102246 new file mode 100644 index 00000000..18375b41 Binary files /dev/null and b/writable/tmp/20241001102246 differ
    S.No.
    Issuer
    Issuing Type
    Client Type
    Policy Issue Date
    D.O.C
    D.O.E
    No of Employees
    No of Insured
    No of Dependents
    Status
    Action
    ').text(item.doc_name)); row.append($('').text(item.file_name)); + var url = "" + + "?client_id=" + item.client_id + + "&file_type=policy" + + "&file_name=" + item.file_name + + "&client_policy_id=" + item.client_policy_id; + var link = $('') - .attr('href', item.url) + .attr('href', url) .attr('target', '_blank') // Open in a new tab - .text(item.url); // Text for the link + .attr('style', 'font-size:18px;') + .attr('data-id', item.id) + .addClass('fa fa-download') + // Append the tag inside the row.append($('').append(link)); @@ -1051,61 +1157,6 @@ $('#invoice_status_modal').change(function(){ } }) -$("#CDMasterForm").submit(function(event) { - - event.preventDefault(); - - var isValid = $('#CDMasterForm').parsley().validate(); - if (!isValid) { - console.log('Form is Empty', 'Warning'); - return ; - } - - form_action = ''; - - $('.loader').fadeIn(); - $('.loader-mask').fadeIn(); - - var client_id = $('#client_id').val(); - var insurer_id = $('#insurer_id').val(); - - // console.log('client_id', client_id); - // console.log('insurer_id', insurer_id); - - var formData = new FormData($('#CDMasterForm')[0]); - formData.append('client_id', client_id); - formData.append('insurer_id', insurer_id); - - $.ajax({ - data:formData, - url: form_action, - type: "POST", - dataType: 'json', - processData: false, - contentType: false, - success: function(res) { - - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - - if(res.status == true){ - appendCDAccountNumber(res.data) - toastr.success(res.message, 'Success'); - }else{ - toastr.error(res.message, 'Error'); - } - - $('.close').click(); - }, - error: function (xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - } - }); -}); - $("#invoiceForm").submit(function(event) { event.preventDefault(); @@ -1255,6 +1306,8 @@ $('#issue_type').change(function(){ } }); +//-------------------------------------------------------------------------------------------------------- + function formatDateforpolicy(dateStr) { @@ -1277,4 +1330,170 @@ function onlyNumbers(event) return false; } + + + + \ No newline at end of file diff --git a/app/Views/pt_form_file_upload_tab.php b/app/Views/pt_form_file_upload_tab.php index 1e733bcf..e7c35190 100644 --- a/app/Views/pt_form_file_upload_tab.php +++ b/app/Views/pt_form_file_upload_tab.php @@ -8,18 +8,18 @@ Policy - +
    S. NoUser Name Month Business TypeDateSales Generated By (Name)Branch (JIBS)Serviced By (Name)Client NameClient Address Client TypePayment FromReferenceRemarksPolicy/EndorsementInsured NamePolicy/
    Endorsement
    Policy TypeBAP GroupVehicle Number Policy No Endorsement No Insurer Name Insurer Branch TPADays Until ExpiryEndorsement Effective DatePolicy Effective DatePolicy Expiry DatePolicy TypeBAP GroupVehicle NumberEndorsement
    Effective Date
    Policy
    Effective Date
    Policy
    Expiry Date
    ReferenceRemarks Base Premium Terrorism/TPPremium (without GST)Premium
    (without GST)
    GST @ 18% Total PremiumBase Revenue %TP / Terrorism Revenue %Total IRDA Revenue INRBase
    Revenue %
    TP / Terrorism
    Revenue %
    Total IRDA
    Revenue INR
    GST on RevenueTotal Amount ReceivableRewards %Total Amount
    Receivable
    RewardsTotal BrokeragePayment Ref Invoice Number Invoice Date Invoice AmountRealization AmountOutstanding Amount Payment Status UTR Payment Date
     % % + +