From 3c26494a55787db8e086c8f736f714e3e22298d7 Mon Sep 17 00:00:00 2001 From: aadhavan valli Date: Mon, 8 Apr 2024 17:50:50 +0530 Subject: [PATCH 1/2] FEATURE_MAKE_AND_MODEL_MODEL:AADHAVAN --- app/Config/Routes.php | 23 +++- app/Controllers/Make.php | 55 ++++++++++ app/Controllers/Model.php | 99 +++++++++++++++++ app/Views/bike_model_list.php | 194 ++++++++++++++++++++++++++++++++++ app/Views/layout/header.php | 13 ++- app/Views/make_list.php | 177 +++++++++++++++++++++++++++++++ 6 files changed, 559 insertions(+), 2 deletions(-) create mode 100644 app/Controllers/Make.php create mode 100644 app/Controllers/Model.php create mode 100644 app/Views/bike_model_list.php create mode 100644 app/Views/make_list.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 0ddab8a..94a9c4a 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -74,4 +74,25 @@ $routes->get("delete_vehicle/(:any)", "Vehicle::delete_vehicle/$1"); //dashboard -$routes->get('dashboard', 'Users::dashboard'); \ No newline at end of file +$routes->get('dashboard', 'Users::dashboard'); + + + + + +//---------------------- Make And Model +// Make +$routes->get('make_index', 'Make::index'); +$routes->post('create_make', 'Make::create_make'); + + + +// Model +$routes->get('bike_model_index/(:any)', 'Model::index/$1'); + +$routes->post('create_model', 'Model::create_model'); + +$routes->post('status_model', 'Model::status_model'); + + + diff --git a/app/Controllers/Make.php b/app/Controllers/Make.php new file mode 100644 index 0000000..d6d2763 --- /dev/null +++ b/app/Controllers/Make.php @@ -0,0 +1,55 @@ +session = session(); + $this->BikemakeModel = new BikemakeModel(); + } + + public function index() + { + + $BikemakeModel = new BikemakeModel(); + $make = $BikemakeModel->findAll(); + $data['make']=$make; + + return view('make_list',$data); + } + + + + public function create_make() + { + try { + $make_name = $this->request->getPost('makename'); + $BikemakeModel = new BikemakeModel(); + $data = [ + 'make' => $make_name + ]; + $inserted = $BikemakeModel->insert($data); + if ($inserted) { + $result = $data; + return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); + } else { + $result = "No Match's"; + return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404); + } + } catch (\Exception $e) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $e],500); + } + } + +} \ No newline at end of file diff --git a/app/Controllers/Model.php b/app/Controllers/Model.php new file mode 100644 index 0000000..e5e6d5a --- /dev/null +++ b/app/Controllers/Model.php @@ -0,0 +1,99 @@ +session = session(); + $this->BikemodelsModel = new BikemodelsModel(); + $this->BikemakeModel = new BikemakeModel(); + + } + + 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_name= $make_value[0]['make']; + $make_id= $make_value[0]['make_id']; + + $model = $BikemodelsModel->where('make_id',$make_id)->findAll(); + $data['model']=$model; + $data['make_name'] =$make_name; + $data['make_id'] =$make_id; + + return view('bike_model_list',$data); + } + + + public function create_model() + { + try { + $make_id = $this->request->getPost('make_id'); + $model_name = $this->request->getPost('modelname'); + + $BikemodelsModel = new BikemodelsModel(); + $data = [ + 'make_id' => $make_id, + 'model_name' => $model_name + ]; + + $inserted = $BikemodelsModel->insert($data); + if ($inserted) { + $result = $data; + return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); + } else { + $result = "No Match's"; + return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404); + } + } catch (\Exception $exception) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $exception],500); + } + } + + + + public function status_model() + { + + try { + $model_id = $this->request->getPost('model_id'); + $isactive = $this->request->getPost('isactive'); + + $BikemodelsModel = new BikemodelsModel(); + $data = [ + 'isactive' => $isactive + ]; + + $updated = $BikemodelsModel->update($model_id, $data); + $model_list = $BikemodelsModel->findAll(); + if ($updated) { + $result = $data; + return $this->respond(['status' => 'success','code' => 200,'data' => $model_list],200); + } else { + $result = "No Match's"; + return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404); + } + } catch (\Exception $exception) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $exception],500); + } + } + + + +} \ No newline at end of file diff --git a/app/Views/bike_model_list.php b/app/Views/bike_model_list.php new file mode 100644 index 0000000..8b981d9 --- /dev/null +++ b/app/Views/bike_model_list.php @@ -0,0 +1,194 @@ + +
+
+
+
+

Bike Model List -

+
+ +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Model NameStatusAction
+ + Active + + Inactive + + + + + + + + +
+
+ +
+
+
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index ece5dfa..36c6a83 100644 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -38,6 +38,11 @@ background-color: #2aa762 !important; /* Set background color to a solid color */ opacity: 1 !important; /* Set opacity to 1 to remove transparency */ } + + .icon-large { + font-size: 1.5em; /* Adjust the font size as needed */ + } + @@ -127,7 +132,13 @@ - + +
  • + + + Make + +
  • get('logged_user_role') == 'Floor Manager' || session()->get('logged_user_role') == 'Job Card Manager') { ?> diff --git a/app/Views/make_list.php b/app/Views/make_list.php new file mode 100644 index 0000000..f6a55ea --- /dev/null +++ b/app/Views/make_list.php @@ -0,0 +1,177 @@ + + +
    +
    +
    +
    +

    Make List

    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + +
    Bike MakeAction
    + + + + " class="view-list-button" title="Model List"> + + +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + From 6e4a86c7f4a15bc6bdbe9d0631b93d84990e9dd7 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Tue, 9 Apr 2024 10:39:12 +0530 Subject: [PATCH 2/2] GWM:CHANGES-in-product-module --- app/Controllers/Products.php | 23 +++++++------------- app/Models/ProductModel.php | 2 +- app/Views/client_form.php | 28 +++++++++++------------- app/Views/product_form.php | 42 +++++++++++++++++++----------------- app/Views/vehicle_form.php | 22 ++++++++++--------- 5 files changed, 56 insertions(+), 61 deletions(-) diff --git a/app/Controllers/Products.php b/app/Controllers/Products.php index 9ade4f0..4918b0d 100644 --- a/app/Controllers/Products.php +++ b/app/Controllers/Products.php @@ -65,7 +65,7 @@ class Products extends BaseController $ProductModel = new ProductModel(); $tax= $this->request->getPost('tax')/2; - + // print_r($this->request->getPost());die; $data = [ 'product_name' => $this->request->getPost('productname'), 'product_category' => $this->request->getPost('productcategory'), @@ -82,6 +82,8 @@ class Products extends BaseController 'vendor' => $this->request->getPost('vendor'), 'purchase_order_level' => $this->request->getPost('purchase_order_level'), 'quality' => $this->request->getPost('quality'), + 'make_id' => $this->request->getPost('make'), + 'models_id' => json_encode($this->request->getPost('model')), 'isactive' => 1 , 'branch_id' => $this->session->get('logged_user_branch_id') ]; @@ -124,26 +126,17 @@ class Products extends BaseController // Retrieve the make_id from the AJAX request public function get_vendors_by_model() { - $make_id = $this->request->getPost('make_id'); + $model_ids = $this->request->getPost('model_ids'); - // print_r( $model_ids);die; - - // If make_id or model_ids is not provided, return an empty response - - // Create an instance of VendorModel $vendorModel = new VendorModel(); - - // Call the get_vendors_by_model method from the model - $vendors = $vendorModel->get_vendors_by_model($make_id, $model_ids); - // print_r($vendors); - // Return the response as JSON - // return $this->response->setJSON(['success' => true, 'message' => 'Client saved successfully.']); + $vendors = $vendorModel->get_vendors_by_model( $model_ids); + if ($vendors) { - // Return the retrieved vendors as JSON response + return $this->response->setJSON($vendors); } else { - // If no vendors were found, return an empty response or handle the error accordingly + return $this->response->setJSON([]); } } diff --git a/app/Models/ProductModel.php b/app/Models/ProductModel.php index a0f7a1f..63c54ff 100644 --- a/app/Models/ProductModel.php +++ b/app/Models/ProductModel.php @@ -5,7 +5,7 @@ class ProductModel extends Model { protected $table = 'products'; protected $primaryKey = 'product_id'; - protected $allowedFields = ['product_id','quality','product_name','branch_id','search_tag','product_category','mfr_part_no','purchase_order_level','serial_no','unit_price','commision_rate','sgst','cgst','purchase_cost','usage_unit','vendor','qty_stock','reorder_level','handler','qty_in_demand','product_image','description','isactive']; + protected $allowedFields = ['product_id','make_id','models_id','quality','product_name','branch_id','search_tag','product_category','mfr_part_no','purchase_order_level','serial_no','unit_price','commision_rate','sgst','cgst','purchase_cost','usage_unit','vendor','qty_stock','reorder_level','handler','qty_in_demand','product_image','description','isactive']; public function getTax() diff --git a/app/Views/client_form.php b/app/Views/client_form.php index a8c072a..e962a9a 100644 --- a/app/Views/client_form.php +++ b/app/Views/client_form.php @@ -21,6 +21,7 @@
    " method="post"> +

    Client Details :

    @@ -30,6 +31,16 @@
    +
    + + +
    @@ -38,23 +49,10 @@
    -
    - - -
    - - - - +
    -

    Address Information :

    +

    Address Information :

    diff --git a/app/Views/product_form.php b/app/Views/product_form.php index e79bb74..237b6aa 100644 --- a/app/Views/product_form.php +++ b/app/Views/product_form.php @@ -26,6 +26,7 @@
    - - -
    -
    - - -
    - + + +
    +
    + + +
    +
    @@ -200,6 +201,7 @@ $(document).ready(function() { // Clear existing options $('#model').empty(); // Append new options + $("#model").append(''); $.each(response, function(index, model) { $('#model').append(''); }); @@ -218,7 +220,7 @@ $(document).ready(function() { $(document).ready(function() { $('#model').change(function() { - var make_id = $(this).val(); // Get the selected make ID + var model_ids = $('#model').val(); // Get the selected model IDs console.log(model_ids); @@ -227,14 +229,14 @@ console.log(model_ids); url: '', // URL to your CodeIgniter controller method type: 'POST', dataType: 'json', - data: { make_id: make_id, model_ids: model_ids }, // Send the selected make ID and model IDs to the controller + data: { model_ids: model_ids }, // Send the selected make ID and model IDs to the controller success: function(response) { // Update vendor dropdown based on the response if (response) { // Clear existing options $('#vendor').empty(); // Append new options - $('#vendor').append(''); + $('#vendor').append(''); $.each(response, function(index, vendor) { $('#vendor').append(''); }); diff --git a/app/Views/vehicle_form.php b/app/Views/vehicle_form.php index 41b984d..588e1a2 100644 --- a/app/Views/vehicle_form.php +++ b/app/Views/vehicle_form.php @@ -20,10 +20,10 @@ " method="post"> -

    Vehicle Details :


    +

    Vehicle Details :

    - +
    - +
    - +
    @@ -58,10 +58,11 @@
    -

    Client Details :


    +
    +

    Client Details :

    - + ' ?>
    +
    + + +
    -
    - - -
    +