From a221412a5f13776f6de69a740a8044304d4dffe0 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 19 Feb 2025 12:17:28 +0000 Subject: [PATCH] GWM assigned in model , service : ps --- app/Config/Routes.php | 4 +- app/Controllers/Model.php | 24 ++-- app/Controllers/Service.php | 107 +++++++++--------- app/Models/BikemodelsModel.php | 2 +- app/Models/ServiceModel.php | 2 +- app/Models/ServicesModel.php | 2 +- app/Views/bike_model_list.php | 44 +++++++- app/Views/service_form.php | 198 ++++++++++++++++++--------------- 8 files changed, 224 insertions(+), 159 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 9b39123..e42b521 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -173,9 +173,9 @@ $routes->get('dashboard', 'Users::dashboard'); $routes->get('service_index', 'Service::service_index'); $routes->get("new_service/(:any)", "Service::new_service/$1"); $routes->post("add_service", "Service::add_service"); - $routes->post("get_models_service", "Service::get_models"); + // $routes->post("get_models_service", "Service::get_models"); $routes->get("delete_service/(:any)", "Service::delete_service/$1"); - $routes->post("get_product_by_models", "Service::get_product_by_models"); + // $routes->post("get_product_by_models", "Service::get_product_by_models"); $routes->post('status_service', 'Service::status_service'); diff --git a/app/Controllers/Model.php b/app/Controllers/Model.php index aa82da4..df4189a 100755 --- a/app/Controllers/Model.php +++ b/app/Controllers/Model.php @@ -4,6 +4,7 @@ namespace App\Controllers; use App\Models\BikemodelsModel; use App\Models\BikemakeModel; +use App\Models\ComplaintModel; use CodeIgniter\API\ResponseTrait; @@ -15,29 +16,36 @@ class Model extends BaseController use ResponseTrait; public $BikemodelsModel; public $BikemakeModel; + public $ComplaintModel; + public function __construct() { $this->session = session(); $this->BikemodelsModel = new BikemodelsModel(); $this->BikemakeModel = new BikemakeModel(); + $this->ComplaintModel = new ComplaintModel(); } public function index($make_id) { - $BikemodelsModel = new BikemodelsModel(); - $BikemakeModel = new BikemakeModel(); - - $make_value = $BikemakeModel->where('make_id',$make_id)->select('make_id,make')->find(); + $make_value = $this->BikemakeModel->where('make_id',$make_id)->select('make_id,make')->find(); $make_name= $make_value[0]['make']; $make_id= $make_value[0]['make_id']; - $model = $BikemodelsModel->orderBy('model_name')->where('make_id',$make_id)->findAll(); + $model = $this->BikemodelsModel->select('model.*, cubic_capacity.value') + ->join('cubic_capacity', 'cubic_capacity.id = model.cubic_capacity_id', 'left') + ->where('make_id',$make_id)->orderBy('model_name') + ->findAll(); + $data['model']=$model; $data['make_name'] =$make_name; $data['make_id'] =$make_id; - + + $cubiccapacity = $this->ComplaintModel->getCubicCapacityName(); + $data['cubiccapacity']=$cubiccapacity; + // dd($model); return view('bike_model_list',$data); } @@ -64,6 +72,7 @@ class Model extends BaseController try { $make_id = $this->request->getPost('make_id'); $model_name = $this->request->getPost('modelname'); + $cubic_capacity = $this->request->getPost('cubiccapacity'); $BikemodelsModel = new BikemodelsModel(); //they check model name already exist or not here. @@ -83,7 +92,8 @@ class Model extends BaseController $data = [ 'make_id' => $make_id, - 'model_name' => $model_name + 'model_name' => $model_name, + 'cubic_capacity_id'=>$cubic_capacity ]; // print_r($model_id);die; diff --git a/app/Controllers/Service.php b/app/Controllers/Service.php index f49bd38..d197aeb 100755 --- a/app/Controllers/Service.php +++ b/app/Controllers/Service.php @@ -8,6 +8,7 @@ use App\Models\VendorModel; use App\Models\BikemodelsModel; use App\Models\ProductModel; use App\Models\AdditionalProductNameModal; +use App\Models\ComplaintModel; use CodeIgniter\API\ResponseTrait; class Service extends BaseController @@ -20,6 +21,7 @@ class Service extends BaseController protected $vendorModel; protected $BikemodelsModel; protected $ProductModel; + protected $ComplaintModel; use ResponseTrait; public function __construct() @@ -32,6 +34,7 @@ class Service extends BaseController $this->vendorModel = new VendorModel(); $this->BikemodelsModel = new BikemodelsModel(); $this->ProductModel = new ProductModel(); + $this->ComplaintModel = new ComplaintModel(); } public function service_index() @@ -89,6 +92,7 @@ class Service extends BaseController ->findAll(); $data['tax'] = $this->ServiceModel->getTax(); + $data['cubiccapacity']= $this->ComplaintModel->getCubicCapacityName(); if ($service_id === '0') { @@ -135,11 +139,11 @@ class Service extends BaseController // print $final_price; // print_r($this->request->getPost()); - $make_ids = $this->request->getPost('make'); - $model_ids = $this->request->getPost('model'); + // $make_ids = $this->request->getPost('make'); + // $model_ids = $this->request->getPost('model'); - $model_json = json_encode($model_ids); - $make_json = json_encode($make_ids); + // $model_json = json_encode($model_ids); + // $make_json = json_encode($make_ids); $data = [ 'service_name' => $this->request->getPost('servicename'), 'category' => $this->request->getPost('category'), @@ -151,10 +155,11 @@ class Service extends BaseController 'labour_cost' => $this->request->getPost('labour_cost'), 'labour_cost_with_cost' => $this->request->getPost('labour_cost_with_cost'), 'price' => $final_price, - 'makes_id' => $make_json, - 'models_id' => $model_json, + // 'makes_id' => $make_json, + // 'models_id' => $model_json, 'description' => $this->request->getPost('description'), 'isactive' => 1 , + 'cubic_capacity_id' => $this->request->getPost('cubiccapacity'), ]; $service_id = $this->request->getPost('service_id'); @@ -208,64 +213,64 @@ class Service extends BaseController } - public function get_product_by_models(){ - $make_id = $this->request->getPost('make_id'); - $model_ids = $this->request->getPost('model_ids'); + // public function get_product_by_models(){ + // $make_id = $this->request->getPost('make_id'); + // $model_ids = $this->request->getPost('model_ids'); - $products = []; - array_push($model_ids,'0'); + // $products = []; + // array_push($model_ids,'0'); - foreach ($model_ids as $modelId) { - $product = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.product_names_id, product_names.additional_product_name') - ->join('products', 'products.product_id = product_names.product_id') - ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id') - ->where('JSON_CONTAINS(products.models_id, \'["' . $modelId . '"]\')', null, false) - ->where('products.isactive', 1) - ->findAll(); + // foreach ($model_ids as $modelId) { + // $product = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.product_names_id, product_names.additional_product_name') + // ->join('products', 'products.product_id = product_names.product_id') + // ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id') + // ->where('JSON_CONTAINS(products.models_id, \'["' . $modelId . '"]\')', null, false) + // ->where('products.isactive', 1) + // ->findAll(); - $products = array_merge($products, $product); - } + // $products = array_merge($products, $product); + // } - $products = array_unique($products, SORT_REGULAR); + // $products = array_unique($products, SORT_REGULAR); - return $this->response->setJSON($products); - } + // return $this->response->setJSON($products); + // } - public function get_models() - { - $selected_makes = $this->request->getPost('selected_makes'); + // public function get_models() + // { + // $selected_makes = $this->request->getPost('selected_makes'); - // Initialize an empty array to store formatted model data - $formatted_models = []; + // // Initialize an empty array to store formatted model data + // $formatted_models = []; - // Iterate over each selected make ID - if ($selected_makes) { - foreach ($selected_makes as $make_id) { - // Fetch models based on the selected make ID - $models = $this->BikemodelsModel->where('make_id', $make_id)->where('business_id', $this->session->get('logged_user_business_id'))->findAll(); + // // Iterate over each selected make ID + // if ($selected_makes) { + // foreach ($selected_makes as $make_id) { + // // Fetch models based on the selected make ID + // $models = $this->BikemodelsModel->where('make_id', $make_id)->where('business_id', $this->session->get('logged_user_business_id'))->findAll(); - // Iterate over each fetched model and format it as needed - foreach ($models as $model) { - // Create an associative array with 'model_id' and 'model_name' properties - $formatted_model = [ - 'make_id' => $model['make_id'], - 'model_id' => $model['model_id'], - 'model_name' => $model['model_name'] - // Add other properties if needed - ]; + // // Iterate over each fetched model and format it as needed + // foreach ($models as $model) { + // // Create an associative array with 'model_id' and 'model_name' properties + // $formatted_model = [ + // 'make_id' => $model['make_id'], + // 'model_id' => $model['model_id'], + // 'model_name' => $model['model_name'] + // // Add other properties if needed + // ]; - // Push the formatted model into the array - $formatted_models[] = $formatted_model; - } - } - } - // print_r($formatted_models);die; - // Send the formatted models as JSON response back to the client - return $this->response->setJSON($formatted_models); - } + // // Push the formatted model into the array + // $formatted_models[] = $formatted_model; + // } + // } + // } + // // print_r($formatted_models);die; + // // Send the formatted models as JSON response back to the client + // return $this->response->setJSON($formatted_models); + // } public function status_service() diff --git a/app/Models/BikemodelsModel.php b/app/Models/BikemodelsModel.php index cbe7014..d841b53 100755 --- a/app/Models/BikemodelsModel.php +++ b/app/Models/BikemodelsModel.php @@ -5,5 +5,5 @@ class BikemodelsModel extends Model { protected $table = 'model'; protected $primaryKey = 'model_id'; - protected $allowedFields = ['model_id','business_id','make_id','model_name','isactive']; + protected $allowedFields = ['model_id','business_id','make_id','model_name','isactive','cubic_capacity_id']; } \ No newline at end of file diff --git a/app/Models/ServiceModel.php b/app/Models/ServiceModel.php index 3864ae4..fcdc13a 100755 --- a/app/Models/ServiceModel.php +++ b/app/Models/ServiceModel.php @@ -5,7 +5,7 @@ class ServiceModel extends Model { protected $table = 'services'; protected $primaryKey = 'service_id'; - protected $allowedFields = ['service_id','branch_id','category','service_name','labour_cost','cgst','sgst','price','tax','labour_cost_with_cost','description','makes_id','models_id','product_id','sub_service_id','isactive']; + protected $allowedFields = ['service_id','branch_id','category','service_name','labour_cost','cgst','sgst','price','tax','labour_cost_with_cost','description','makes_id','models_id','product_id','sub_service_id','isactive','cubic_capacity_id']; public function getTax() diff --git a/app/Models/ServicesModel.php b/app/Models/ServicesModel.php index e628efc..0c8febd 100755 --- a/app/Models/ServicesModel.php +++ b/app/Models/ServicesModel.php @@ -5,7 +5,7 @@ class ServicesModel extends Model { protected $table = 'services'; protected $primaryKey = 'service_id'; - protected $allowedFields = ['service_id','service_name','price','commission_rate','cgst','sgst','purchase_cost','description','isactive']; + protected $allowedFields = ['service_id','service_name','price','commission_rate','cgst','sgst','purchase_cost','description','isactive','cubic_capacity_id']; } \ No newline at end of file diff --git a/app/Views/bike_model_list.php b/app/Views/bike_model_list.php index 3efb383..642a8e2 100755 --- a/app/Views/bike_model_list.php +++ b/app/Views/bike_model_list.php @@ -25,6 +25,7 @@ Model Name + Cubic Capacity Status Action @@ -33,6 +34,7 @@ $item): ?> + Active @@ -77,11 +79,27 @@
+ + +
+ +
+
+ + +
+
+
@@ -98,8 +116,6 @@