diff --git a/app/Config/Routes.php b/app/Config/Routes.php index e2c4773c..dd81efc5 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -241,6 +241,12 @@ $routes->group("/master", ["filter" => "authMVC"], function ($routes) { $routes->get("list/(:any)", "MasterController::getCDMasterDataByID/$1"); $routes->get("remove/(:any)", "MasterController::removeCDMaster/$1"); }); + + $routes->group("vehicle", ["filter" => "authMVC"], function ($routes) { + $routes->get("list", "MasterController::VehicleMasterList"); + $routes->get("list/(:any)", "MasterController::getVehicleMasterDataByID/$1"); + $routes->get("remove/(:any)", "MasterController::deactiveVehicleData/$1"); + }); }); @@ -305,6 +311,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("get_client_policy_data_using_policy_no/(:any)", "ClientController::get_client_policy_data_using_policy_no/$1"); $routes->get("get_client_policy_data_using_policy_no_and_endo_no/(:any)", "ClientController::get_client_policy_data_using_policy_no_and_endo_no/$1"); $routes->get("checkInvoiceStatus/(:any)", "PolicyTransactionController::checkInvoiceStatus/$1"); + $routes->get("base_policy_for_policy_inception/(:any)", "PolicyTransactionController::getBasePolicy/$1"); }); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 07512fc2..586665eb 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -866,18 +866,19 @@ class ClientController extends AdminController $data['cd_ac_no'] = $this->request->getPost('cd_ac_no'); $data['gst'] = $this->request->getPost('gst'); + if($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 6 || $policy_type_id == 7){ - $data['is_addon'] = 1; + $data['is_addon'] = 1; // Base Policy }else if($policy_type_id == 4 || $policy_type_id == 5){ - $data['is_addon'] = 2; + $data['is_addon'] = 2; // SI TOPUP }else if($policy_type_id == 3){ if($base_policy){ - $data['is_addon'] = 3; + $data['is_addon'] = 3; // Dependent Addon }else{ $data['is_addon'] = 1; } @@ -952,6 +953,8 @@ class ClientController extends AdminController $id = $this->request->getPost('PrimaryKey'); $client_id = $this->request->getPost('client_id'); $policy_type_id = $this->request->getPost('policy_type_id'); + $base_policy = $this->request->getPost('base_policy'); + $insurerValue = (string) $this->request->getPost('insurer'); list($insurerBranchId, $insurerId) = explode('-', $insurerValue); @@ -1002,17 +1005,34 @@ class ClientController extends AdminController $data['reminder_date'] = null; } - if($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 3 || $policy_type_id == 6 || $policy_type_id == 7){ + // if($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 3 || $policy_type_id == 6 || $policy_type_id == 7){ - $data['is_addon'] = 1; + // $data['is_addon'] = 1; - }else if($policy_type_id == 4){ + // }else if($policy_type_id == 4){ - $data['is_addon'] = 2; + // $data['is_addon'] = 2; - }else if($policy_type_id == 5){ + // }else if($policy_type_id == 5){ - $data['is_addon'] = 3; + // $data['is_addon'] = 3; + // } + + if($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 6 || $policy_type_id == 7){ + + $data['is_addon'] = 1; // Base Policy + + }else if($policy_type_id == 4 || $policy_type_id == 5){ + + $data['is_addon'] = 2; // SI TOPUP + + }else if($policy_type_id == 3){ + + if($base_policy){ + $data['is_addon'] = 3; // Dependent Addon + }else{ + $data['is_addon'] = 1; + } } @@ -3261,6 +3281,7 @@ class ClientController extends AdminController return $this->respond([ 'status' => true, + 'data' => $postData, 'client_id' => $client_insert, 'branch_id' => $branch_insert ?? null, 'message' => 'Client created successfully' @@ -3270,22 +3291,36 @@ class ClientController extends AdminController public function createVehicleWithMinimalData() { $data = $this->request->getPost(); + $id = $this->request->getPost('vehicle_primary_key'); - $vehicle_insert = $this->vehicleModel->insert($data); + if($id){ + + $vehicle_update = $this->vehicleModel->where('id', $id)->set($data)->update(); + + if($vehicle_update){ + return $this->respond(['status' => true, 'message' => 'Vehicle details updated successfully'], 200); + }else{ + return $this->respond(['status' => false, 'message' => 'Failed to update vehicle details'], 200); + } - if($vehicle_insert){ - $vehicles = $this->vehicleModel->where('is_active', 1)->findAll(); - return $this->respond([ - 'status' => true, - 'vehicle_id' => $vehicle_insert, - 'owner_id' => $data['owner'], - 'owner_branch_id' => $data['branch_id'], - 'owner_type' => $data['Owner_type'], - 'vehicles' => $vehicles, - 'message' => 'Vehicle created successfully - '], 200); }else{ - return $this->respond(['status' => false, 'message' => 'Failed to created vehicle'], 200); + + $vehicle_insert = $this->vehicleModel->insert($data); + + if($vehicle_insert){ + $vehicles = $this->vehicleModel->where('is_active', 1)->findAll(); + return $this->respond([ + 'status' => true, + 'vehicle_id' => $vehicle_insert, + 'owner_id' => $data['owner'], + 'owner_branch_id' => $data['branch_id'] ?? null, + 'owner_type' => $data['Owner_type'], + 'vehicles' => $vehicles, + 'message' => 'Vehicle created successfully + '], 200); + }else{ + return $this->respond(['status' => false, 'message' => 'Failed to created vehicle'], 200); + } } } diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 3fef51e0..4ea1ce46 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -1811,6 +1811,11 @@ class EmpDataServiceController extends BaseController $file_data = $this->getDataByFileId($file_id, 'success'); $this->setPullNotification($file_data); + // if(excelFileGDriveUpload($file_id, 'batch_file')){ + // $this->myLogger->logme('error', 'Inception Update Google Drive File Upload -- File Uploaded Successfully'); + // }else{ + // $this->myLogger->logme('error', 'Inception Update Google Drive File Upload -- File Uploaded Field'); + // } return 'Import Inception Updated ' . $status_val . '- Updated Count : ' . $emp_count; } diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 38ead2cf..1df4dc16 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -148,6 +148,10 @@ class EmployeeController extends AdminController public function employeesUplodWithEvents() { + // $empDataServiceController = new EmpDataServiceController(); + // !dd($empDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 79])); + + // $job_details = new Jobs(); // $r = Jobs::addJob(['job_name' => 'add','payload' => ['a' => 10, 'b' => 35]]); // print_r($r);//die(); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index e6aca562..aba83570 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -1453,7 +1453,7 @@ class EmployeeRestController extends AdminController if ($value > 0) { if($value == 1 && $key ==='either-parents-pil') { $result .= ' + Either 2 Parents or 2 Parents in law'; - }if($value == 2 && $key ==='either-parents-pil') { + }else if($value == 2 && $key ==='either-parents-pil') { $result .= ' + Any 2 of Parents and Parents in law'; }else if($value != 0 && $key ==='spouse') { $string = str_replace('-', ' ', $key); diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index aa1fcd06..2779a509 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -32,6 +32,7 @@ use App\Models\CDMasterModel; use App\Models\ClientDepositModel; use App\Models\InsurerExcelExportTemplateModel; use App\Models\SettingsModel; +use App\Models\VehicleModel; class MasterController extends AdminController { @@ -57,6 +58,7 @@ class MasterController extends AdminController protected $clientDepositModel; protected $insurerTemplateModel; protected $cli_colors; + protected $vehicleModel; @@ -85,6 +87,7 @@ class MasterController extends AdminController $this->clientModel = new ClientModel(); $this->clientDepositModel = new ClientDepositModel(); $this->insurerTemplateModel = new InsurerExcelExportTemplateModel(); + $this->vehicleModel = new VehicleModel(); $this->cli_colors = [ 'red' => "\033[31m", 'green' => "\033[32m", @@ -1395,6 +1398,65 @@ class MasterController extends AdminController } + //Vehicle Master data Function + + public function VehicleMasterList() + { + $data['page_name'] = 'Vehicle Master List'; + $data['vehicle_type'] = [ + 'two_wheeler' => 'Two Wheeler', + 'four_wheeler' => 'Four Wheeler', + 'truck' => 'Truck', + 'bus' => 'Bus', + 'van' => 'Van', + 'suv' => 'SUV', + 'motorcycle' => 'Motorcycle', + 'bicycle' => 'Bicycle' + ]; + $data['vehicle_des'] = [ + 'commercial' => 'Commercial', + 'private' => 'Private', + ]; + $data['entity'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll(); + $data['clients'] = $this->clientModel->where('is_active', 1)->findAll(); + $data['vehicle_Master_Data'] = $this->vehicleModel->getVehicleMasterList(); + $this->loadLayout('vehicle_master_list', $data); + } + + public function getVehicleMasterDataByID($id = null) + { + $vehicle_data = $this->vehicleModel + ->select('vehicle.*, clients.client_type') + ->join('clients', 'vehicle.owner = clients.id') + ->where('vehicle.id', $id) + ->where('vehicle.is_active', 1) + ->first(); + + if ($vehicle_data) { + return $this->respond(['status' => true, 'code' => 200, 'data' => $vehicle_data], 200); + } else { + return $this->respond(['status' => false, 'code' => 404], 200); + } + } + + public function deactiveVehicleData($id) + { + + $this->myLogger->logme('error','deactiveVehicleData function called'); + + $data['updated_by'] = get_session_userid(); + $data['is_active'] = 0; + + $update = $this->vehicleModel->where('id', $id)->set($data)->update(); + + if($update){ + return $this->respond(['status' => true,'code' => 200], 200); + }else{ + return $this->respond(['status' => false,'code' => 404], 200); + } + } + + //excel export template public function createExcelTemplate() { diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 62e7e626..c927ac44 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -216,25 +216,46 @@ class PolicyTransactionController extends BaseController // $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_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_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['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['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['rollover_date'] = (isset($data['rollover_date']) && $data['rollover_date'] !== null && $data['rollover_date'] !== '') + // ? date('d/m/Y', strtotime($data['rollover_date'])) + // : null; + + + if(empty($data['policy_issue_date'])){ + $data['policy_issue_date'] = null; + } + + if(empty($data['policy_start_date'])){ + $data['policy_start_date'] = null; + } + + if(empty($data['policy_end_date'])){ + $data['policy_end_date'] = null; + } + + if(empty($data['renewal_date'])){ + $data['renewal_date'] = null; + } + + if(empty($data['rollover_date'])){ + $data['rollover_date'] = null; + } // Separate Insurer and TPA Branch IDs and IDs @@ -275,7 +296,7 @@ class PolicyTransactionController extends BaseController // 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)); + (in_array($data['policy_type_id'], [4, 5]) ? 2 : ($data['policy_type_id'] == 3 && isset($data['base_policy']) ? 3 : 1)); // print_r($data); die; @@ -717,16 +738,14 @@ class PolicyTransactionController extends BaseController ->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->getPolicyDetailsForRemainder($data['client_id']); + $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']) + ->whereIn('client_policy.policy_type_id', [2, 3]) + ->where('client_policy.is_active', 1) + ->findAll(); $data['pt_files'] = $this->PTFileModel ->join('policy_transaction', 'pt_files.pt_id = policy_transaction.id') @@ -1234,6 +1253,24 @@ class PolicyTransactionController extends BaseController } } + public function getBasePolicy($client_id, $client_branch_id) + { + $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', $client_id) + ->where('client_policy.client_branch_id', $client_branch_id) + ->whereIn('client_policy.policy_type_id', [2, 3]) + ->where('client_policy.is_active', 1) + ->findAll(); + + if($data){ + return $this->respond(['status' => true, 'data'=> $data, 'code' => 200], 200); + }else{ + return $this->respond(['status' => false, 'count'=> 0, 'message' => 'No Data Found', 'code' => 404], 200); + } + } + //--------------------------------------------------------------------------------------------------- //get BDS Reports data @@ -1938,7 +1975,7 @@ class PolicyTransactionController extends BaseController //get policy docs from policy transation related tables $pt_files = $this->PTFileModel->getPolicyDriveFilesIndex($policy_id,$policy_doc_name); // ~dd($this->PTFileModel->getLastQuery()); - // ~dd($d); + // ~dd($pt_files); } if($customer_id != "") { diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index b313789e..d4256270 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -71,7 +71,9 @@ class RestAuthenticationController extends AdminController $mobile_number = $this->request->getJSON()->mobile_number; - $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first(); + $employeeData = $this->employeeModel->where('mobile', $mobile_number) + ->where('relationship', 'self') + ->where('is_active', 1)->first(); if ($employeeData) { @@ -126,7 +128,9 @@ class RestAuthenticationController extends AdminController try { $mobile_number = $this->request->getJSON()->mobile_number; - $HrData = $this->hrModel->where('mobile', $mobile_number)->where('contact_type', 'client')->first(); + $HrData = $this->hrModel->where('mobile', $mobile_number) + ->where('contact_type', 'client') + ->where('is_active', 1)->first(); if ($HrData) { diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index 7b8fc5c8..311ccd47 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -105,9 +105,9 @@ class sendMailNotification $wholeData = []; } return $wholeData; - // }else{ - // return "false"; - // } + // }else{ + // return "false"; + // } } else if($action == 'member_ecard_mail'){ $notification = $params['notification']; @@ -160,7 +160,7 @@ class sendMailNotification $client_data =$clientModel->where('id', $client_id)->first(); $notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first(); - if ($notification_data['enabled'] == 1) { + if (isset($notification_data) && $notification_data['enabled'] == 1) { $mail_content = $notification_data['mail_content']; $subject = $notification_data['subject']; $app_link = $_ENV['App_Url']; @@ -259,7 +259,7 @@ class sendMailNotification $client_data =$clientModel->where('id', $client_id)->first(); $notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first(); - if ($notification_data['enabled'] == 1) { + if (isset($notification_data) && $notification_data['enabled'] == 1) { $client_rm_data= $clientRMModel->where('client_id', $client_id)->where('is_active',1)->findAll(); $user_list= []; foreach ($client_rm_data as $key => $value) { @@ -376,7 +376,7 @@ class sendMailNotification $notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first(); $clientRMModel =new ClientRMModel(); - if ($notification_data['enabled'] == 1) { + if (isset($notification_data['enabled']) && $notification_data['enabled'] == 1) { $client_rm_data= $clientRMModel->where('client_id', $client_id)->where('is_active',1)->findAll(); $user_list= []; foreach ($client_rm_data as $key => $value) { diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index ab40178e..e0e8ef06 100755 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -1,7 +1,10 @@ [ + 'model' => new BatchFileModel(), + 'select' => "client_id, client_policy_id, file_name" + ], + 'files' => [ + 'model' => new FileModel(), + 'select' => "client_id, policy_id as client_policy_id, file_name" + ], + ]; + + if (!array_key_exists($table_name, $models)) { + return; + } + + // Retrieve data + $data = $models[$table_name]['model'] + ->select($models[$table_name]['select']) + ->where('id', $file_id) + ->where('is_active', 1) + ->first(); + + + + if ($data) { + $uploadFilePath .= '/' . $data['file_name']; + // dd($data, $uploadFilePath); + + $GoogleDriveController = new GoogleDriveController(); + $result = $GoogleDriveController->uploadFiletoGdrive( + // client_id : $data['client_id'], + client_policy_id: $data['client_policy_id'], + doc_type : $doc_type, + file_path : $uploadFilePath, + file_name : $data['file_name'] + ); + + // dd($result); + + return true; + + }else{ + + return false; + } + } +} + + function numberToWords($number) diff --git a/app/Models/VehicleModel.php b/app/Models/VehicleModel.php index d1f9cb4c..dda3af1c 100644 --- a/app/Models/VehicleModel.php +++ b/app/Models/VehicleModel.php @@ -61,4 +61,26 @@ class VehicleModel extends Model return $data; } + public function getVehicleMasterList(){ + + return $this->db->table('vehicle') + ->select(" + vehicle.*, + CASE + WHEN clients.client_type = 1 THEN 'Group' + WHEN clients.client_type = 2 THEN 'Individual' + ELSE '-' + END AS owner_type, + clients.client_name as owner_name, + client_branch.branch_name as owner_branch + ") + ->join('clients', 'vehicle.owner = clients.id') + ->join('client_branch', 'vehicle.branch_id = client_branch.id', 'left') + ->where('vehicle.is_active', 1) + ->orderBy('vehicle.id', 'desc') + ->get() + ->getResultArray(); + + } + } diff --git a/app/Views/client_kyc.php b/app/Views/client_kyc.php index 44c2badd..995dd16f 100755 --- a/app/Views/client_kyc.php +++ b/app/Views/client_kyc.php @@ -180,6 +180,8 @@ "&file_name=" + item.file_name + "&client_policy_id=client_policy_id"; + // var url = '= base_url('download-kyc-docs/') ?>' + item.file_name; + // console.log('step 1') if(item.file_name != null && item.file_name != ""){ @@ -298,6 +300,7 @@ "&client_policy_id=client_policy_id"; + // var url = '= base_url('download-kyc-docs/') ?>' + item.file_name; // console.log("Current item:", item); if (item.kyc_doc_type_id == '0') { @@ -468,6 +471,9 @@ "&file_name=" + item.file_name + "&client_policy_id=client_policy_id"; + // var url = '= base_url('download-kyc-docs/') ?>' + item.file_name; + + if(item.kyc_doc_type_id == '0'){ table += `