diff --git a/app/Config/Routes.php b/app/Config/Routes.php index e42b521..273690e 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -107,6 +107,7 @@ $routes->get("download_os", "Jobcard::download_os"); $routes->get("individual_download_os/(:any)", "Jobcard::individual_download_os/$1"); $routes->post("getServices", "Jobcard::getServices"); $routes->post('deleteJobCardFile', 'Jobcard::deleteJobCardFile'); +$routes->post("getComplaints", "Jobcard::getComplaints"); //End Job Card // //Client// @@ -176,6 +177,7 @@ $routes->get('dashboard', 'Users::dashboard'); // $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_cc", "Service::get_product_by_cc"); $routes->post('status_service', 'Service::status_service'); diff --git a/app/Controllers/Jobcard.php b/app/Controllers/Jobcard.php index b2e120f..8d6d34a 100755 --- a/app/Controllers/Jobcard.php +++ b/app/Controllers/Jobcard.php @@ -559,9 +559,9 @@ class Jobcard extends BaseController } $data['editosdata'] = $os_data; - $complaint = $this->ComplaintModel->where('isactive',1)->findAll(); + // $complaint = $this->ComplaintModel->where('isactive',1)->findAll(); - $data['complaint']= $complaint; + // $data['complaint']= $complaint; $data['os_data'] = $this->OutsourceModel->where('is_active',1)->findAll(); $data['page_name']="Edit Job Card"; @@ -582,8 +582,12 @@ class Jobcard extends BaseController $makeId = $vehicles['make']; $modelId = $vehicles['model']; - - + $ccId = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->cubic_capacity_id; + + // $complaint = $this->ComplaintModel->where('cubic_capacity_id',$ccId)->where('isactive',1)->findAll(); + $complaint = $this->ComplaintModel->where('isactive',1)->findAll(); + + $data['complaint']= $complaint; $make_name = $this->BikemakeModel->where('make_id',$makeId)->select('make')->first(); $model_name = $this->BikemodelsModel->where('model_id',$modelId)->select('model_name')->first(); @@ -606,23 +610,20 @@ class Jobcard extends BaseController $data['product']=$product; $encodedMakeId = json_encode([$makeId]); - - $service1 = $this->ServiceModel->where('makes_id LIKE \'%"' . $makeId . '"%\'', null, false) - ->where('models_id LIKE \'%"' . $modelId . '"%\'', null, false) - ->orWhere('category', 0) - ->findAll(); + // $service1 = $this->ServiceModel->where('cubic_capacity_id', $ccId) + // ->orWhere('category', 0) + // ->findAll(); $encodedMakeId1 = 0; $encodedModelId1 = 0; - $common_services = $this->ServiceModel->where('makes_id LIKE \'%"' . $encodedMakeId1 . '"%\'', null, false) - ->where('models_id LIKE \'%"' . $encodedModelId1 . '"%\'', null, false) + $services2 = $this->ServiceModel->where('cubic_capacity_id', $ccId) ->findAll(); - $service = array_merge($common_services, $service1); + // $service = array_merge($common_services, $service1); $data['product']=$product; - $data['service']=$service; + $data['service']=$services2; // echo "
";
// print_r($service);die;
$jobs_product= $this->JobcardCustomComplaintModel->where('job_card_id', $job_card_id)->findAll();
@@ -1226,7 +1227,21 @@ class Jobcard extends BaseController
}
+ public function getComplaints(){
+ $modelId = $this->request->getPost('model_id');
+ $ccId = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->cubic_capacity_id;
+ $modelName = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->model_name;
+ $complaint = $this->ComplaintModel->where('cubic_capacity_id',$ccId)->where('isactive',1)->findAll();
+
+ if($complaint){
+ // Send JSON response
+ return $this->response->setJSON(['complaint'=>$complaint , 'modelName'=>$modelName ] );
+ } else {
+ // If service is not found, return an empty response or appropriate message
+ return $this->response->setJSON(['complaint'=>[] , 'modelName'=>$modelName ]);
+ }
+ }
public function getServices()
{
@@ -1234,6 +1249,40 @@ class Jobcard extends BaseController
$makeId = $this->request->getPost('make_id');
$modelId = $this->request->getPost('model_id');
+ $ccId = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->cubic_capacity_id;
+
+ // Query the database to find the service - cubic_capacity_id
+ $service1 = $this->ServiceModel->where('cubic_capacity_id', $ccId)
+ ->where('category',1)
+ ->where('isactive' ,1)
+ ->findAll();
+
+ // Query the database to find the service - default values
+ $service2 = $this->ServiceModel->where('category',0)
+ ->where('isactive' ,1)
+ ->findAll();
+
+ // final service
+ $service = array_merge($service1, $service2);
+
+ $modelName = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->model_name;
+ $makeName = $this->BikemakeModel->where('make_id',$makeId)->get()->getRow()->make;
+
+ if($service){
+ // Send JSON response
+ return $this->response->setJSON(['service'=>$service , 'modelName'=>$modelName ,'makeName'=>$makeName] );
+ } else {
+ // If service is not found, return an empty response or appropriate message
+ return $this->response->setJSON(['service'=>[] , 'modelName'=>$modelName ,'makeName'=>$makeName]);
+ }
+ }
+
+ public function getServicesOld()
+ {
+ // Retrieve make_id and model_id from the request
+ $makeId = $this->request->getPost('make_id');
+ $modelId = $this->request->getPost('model_id');
+
// Encode the makeId before searching
$encodedMakeId = json_encode([$makeId]);
diff --git a/app/Controllers/Products.php b/app/Controllers/Products.php
index 0821a94..41e9b7b 100755
--- a/app/Controllers/Products.php
+++ b/app/Controllers/Products.php
@@ -487,8 +487,7 @@ class Products extends BaseController
{
// Assuming you have a model for products and one for manufacturers
- $products = $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')
+ $products = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
->where('products.isactive', 1)
->findAll();
diff --git a/app/Controllers/Service.php b/app/Controllers/Service.php
index d197aeb..e4fea91 100755
--- a/app/Controllers/Service.php
+++ b/app/Controllers/Service.php
@@ -5,7 +5,7 @@ namespace App\Controllers;
use App\Models\ServiceModel;
use App\Models\BikemakeModel;
use App\Models\VendorModel;
-use App\Models\BikemodelsModel;
+use App\Models\BikemodelsModel;
use App\Models\ProductModel;
use App\Models\AdditionalProductNameModal;
use App\Models\ComplaintModel;
@@ -85,9 +85,9 @@ class Service extends BaseController
public function new_service($service_id)
{
- $data['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')
+ $data['product'] = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
+ ->where('JSON_CONTAINS(products.models_id, \'["0"]\')', null, false)
->where('products.isactive', 1)
->findAll();
@@ -211,7 +211,27 @@ class Service extends BaseController
return $this->response->setJSON([]);
}
}
+
+ public function get_product_by_cc(){
+ $cc_id = $this->request->getPost('cc_id');
+ $products = [];
+ $model_ids = $this->BikemodelsModel->select('model_id')->where('cubic_capacity_id', $cc_id)->asArray()->findAll();
+
+ foreach ($model_ids as $model) {
+ $modelId = $model['model_id'];
+ // echo $modelId;
+ $product = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
+ ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
+ ->where('JSON_CONTAINS(products.models_id, \'["' . $modelId . '"]\')', null, false)
+ ->where('products.isactive', 1)
+ ->findAll();
+ // echo( $this->ProductModel->getLastQuery()->getQuery());
+ $products = array_merge($products, $product);
+ }
+ $products = array_unique($products, SORT_REGULAR);
+ return $this->response->setJSON($products);
+ }
// public function get_product_by_models(){
// $make_id = $this->request->getPost('make_id');
@@ -237,8 +257,6 @@ class Service extends BaseController
// return $this->response->setJSON($products);
// }
-
-
// public function get_models()
// {
// $selected_makes = $this->request->getPost('selected_makes');
diff --git a/app/Models/VehicleModel.php b/app/Models/VehicleModel.php
index 0f42b8b..cbf15d1 100755
--- a/app/Models/VehicleModel.php
+++ b/app/Models/VehicleModel.php
@@ -12,7 +12,7 @@ class VehicleModel extends Model
public function getCustomerandVehicle($branch_id)
{
// Select required fields from both tables
- $this->select('vehicle.*, client.client_name ,client.address,client.city,client.state,client.postal_code, make.make as make_name , model.model_name as model_name');
+ $this->select('vehicle.*, client.client_name ,client.address,client.city,client.state,client.postal_code, make.make as make_name , model.model_name as model_name,model.cubic_capacity_id');
$this->join('client', 'client.client_id = vehicle.client_id');
$this->join('make', 'make.make_id = vehicle.make');
$this->join('model', 'model.model_id = vehicle.model');
diff --git a/app/Views/job_card_form.php b/app/Views/job_card_form.php
index 6070ff2..3340ec0 100755
--- a/app/Views/job_card_form.php
+++ b/app/Views/job_card_form.php
@@ -883,6 +883,25 @@ $(document).ready(function() {
console.error('Error fetching product information:', error);
}
});
+
+ $.ajax({
+ url: '', // Replace with the actual backend endpoint
+ method: 'POST', // or 'GET' based on your server implementation
+ dataType: 'json',
+ data: {
+ model_id:modelId,
+ },
+ success: function(response) {
+ console.log(response);
+ complaintsarray = response.complaint;
+ },
+ error: function(xhr, status, error) {
+ // Handle error
+ console.error('Error fetching product information:', error);
+ }
+ });
+
+
} else {
console.error('Make ID not found for the selected vehicle');
}
@@ -1087,7 +1106,6 @@ $(document).ready(function() {
var products = ;
var services = ;
- var complaint = ;
var mapTable;
function data_contruction_for_save() {
diff --git a/app/Views/service_form.php b/app/Views/service_form.php
index bd85db9..7d50bf9 100755
--- a/app/Views/service_form.php
+++ b/app/Views/service_form.php
@@ -30,7 +30,7 @@
>
-
+