bug fixes : ps

This commit is contained in:
VE10-Sanjeev 2025-02-20 11:33:07 +00:00
parent a221412a5f
commit 5673d4bed6
7 changed files with 152 additions and 27 deletions

View File

@ -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');

View File

@ -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 "<pre>";
// 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]);

View File

@ -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();

View File

@ -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');

View File

@ -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');

View File

@ -883,6 +883,25 @@ $(document).ready(function() {
console.error('Error fetching product information:', error);
}
});
$.ajax({
url: '<?php echo base_url().'getComplaints'?>', // 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 = <?php echo $product_json; ?>;
var services = <?php echo $service_json; ?>;
var complaint = <?php echo json_encode($complaint) ?>;
var mapTable;
function data_contruction_for_save() {

View File

@ -30,7 +30,7 @@
</select>
</div>
<div class="form-group col-md-3" id="cc_hide" <?= (!isset($services['category']) || $services['category'] == 0) ? 'style="display: none;"' : '' ?>>
<label for="cubiccapacity" class="col-form-label">Cubic capacity<span class="text-danger">*</span></label>
<label for="cubiccapacity" class="col-form-label">Cubic Capacity<span class="text-danger">*</span></label>
<select class="form-control" id="cubiccapacity" name="cubiccapacity" style="height:32px" required>
<option value="">Select</option>
<?php foreach ($cubiccapacity as $item): ?>
@ -74,7 +74,7 @@
<?php if(isset($product)){ foreach ($product as $value) { ?>
<?php if ((int)$value["isactive"] === 1) : ?>
<option value="<?= $value["product_id"] ?>" <?= isset($services['product_id']) && is_array(json_decode($services['product_id'])) && in_array($value['product_id'], json_decode($services['product_id'])) ? 'selected' : '' ?>>
<?= $value["additional_product_name"] .'-'. $value['manufacturer_name']; ?>
<?= $value["product_name"] .' - '. $value['manufacturer_name']; ?>
</option>
<?php endif; ?>
<?php } }?>
@ -286,6 +286,40 @@ $(document).ready(function() {
// }
// });
$('#cubiccapacity').change(function() {
var cc_id = $(this).val();
$('#productSelect').empty();
$('#productSelect').append('<option value="0"> Select Product</option>');
if (cubiccapacity) {
$.ajax({
url: '<?php echo base_url('get_product_by_cc') ?>',
type: 'POST',
dataType: 'json',
data: { cc_id: cc_id }, // Send the selected make ID and model IDs to the controller
success: function(response) {
console.log(response);
// Update vendor dropdown based on the response
if (response) {
$.each(response, function(index, product) {
$('#productSelect').append('<option value="' + product.product_id + '">' + product.product_name +' - '+ product.manufacturer_name + '</option>');
});
} else {
// Handle case when no vendors are found for the selected model
console.log('No vendors found for the selected cc');
}
},
error: function(xhr, status, error) {
// Handle error
console.error(xhr.responseText);
}
});
}else{
console.log('No vendors found for the selected cc');
}
});
data = <?php echo json_encode($product) ?>;
servicedata = <?php echo json_encode($service) ?>;
var service_id = "<?php echo $service_id; ?>";
@ -305,27 +339,32 @@ document.getElementById('category').addEventListener('change', function() {
// var modelSelect = document.getElementById('model');
var ccSelect = document.getElementById('cubiccapacity');
var serviceSelected = document.getElementById('serviceSelected');
if (this.value == '1') {
var productSelect = document.getElementById('productSelect');
if (this.value == '1') { // 1 ==> Standalone
// customFields.style.display = 'block';
// $('#make_hide').css('display' , 'block');
// $('#model_hide').css('display' ,'block');
$('#cc_hide').css('display' , 'block');
$('#service_hide').css('display' ,'block');
$('#cubiccapacity').val('');
$('#productSelect').empty();
ccSelect.setAttribute('required', 'required');
// makeSelect.setAttribute('required', 'required');
// modelSelect.setAttribute('required', 'required');
// serviceSelected.setAttribute('required', 'required');
} else {
} else { // 0 ==> Common
// customFields.style.display = 'none';
// $('#make_hide').css('display' , 'none');
// $('#model_hide').css('display' ,'none');
$('#cc_hide').css('display' , 'none');
$('#service_hide').css('display' ,'none');
$('#cubiccapacity').val('');
$('#productSelect').empty();
ccSelect.removeAttribute('required');
// makeSelect.removeAttribute('required');
// modelSelect.removeAttribute('required');
serviceSelected.removeAttribute('required');
$.ajax({
url: '<?php echo base_url('product_list_for_service') ?>', // URL to your CodeIgniter controller method
type: 'GET',