diff --git a/app/Config/Routes.php b/app/Config/Routes.php index e2c4773c..eb09ded0 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"); + }); }); 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/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/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/layout/header.php b/app/Views/layout/header.php index 6f7dcf21..88f3ad4b 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -610,6 +610,9 @@
  • CD Master
  • +
  • + Vehicle Master +
  • Users
  • @@ -697,6 +700,9 @@
  • CD Master
  • +
  • + Vehicle Master +
  • Documents
  • diff --git a/app/Views/policy_transaction_endorsement_list.php b/app/Views/policy_transaction_endorsement_list.php index 6d133613..4c5ddef6 100644 --- a/app/Views/policy_transaction_endorsement_list.php +++ b/app/Views/policy_transaction_endorsement_list.php @@ -175,7 +175,7 @@ table.dataTable thead th { -
    +
    @@ -276,6 +276,7 @@ table.dataTable thead th { if (ticketsTable.length) { ticketsTable.DataTable({ + scrollX: true, dom: "<'row'<'col-sm-6'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector diff --git a/app/Views/policy_transaction_inception_list.php b/app/Views/policy_transaction_inception_list.php index 2f8a4885..37cd6cec 100644 --- a/app/Views/policy_transaction_inception_list.php +++ b/app/Views/policy_transaction_inception_list.php @@ -243,7 +243,7 @@ table.dataTable tbody td { -
    +
    @@ -415,6 +415,7 @@ $(document).ready(function() { if (ticketsTable.length) { ticketsTable.DataTable({ + scrollX: true, dom: "<'row'<'col-sm-6'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector diff --git a/app/Views/report_bds.php b/app/Views/report_bds.php index a0f075c9..0caa9383 100644 --- a/app/Views/report_bds.php +++ b/app/Views/report_bds.php @@ -31,7 +31,7 @@ table.dataTable tbody td { -
    +
    @@ -148,6 +148,7 @@ $(document).ready(function() { if (ticketsTable.length) { ticketsTable.DataTable({ + scrollX: true, dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector diff --git a/app/Views/vehicle_master_list.php b/app/Views/vehicle_master_list.php new file mode 100644 index 00000000..84f27a83 --- /dev/null +++ b/app/Views/vehicle_master_list.php @@ -0,0 +1,812 @@ + + +
    +
    +
    +
    +
    +
    +

    Vehicle Master List

    +
    +
    + +
    +
    +
    + + + + + + + + + + + + + + + $row){ ?> + + + + + + + + + + + + +
    S.No.Owner TypeOwner NameRC Book NoVehicle NoVehicle typeDescriptionAction
    + +
    +
    +
    + + + + + + + + + + + + + + + + + + + \ No newline at end of file