CHANGE_JOB_CARD_PDF_OS_ : AADHAVAN

This commit is contained in:
aadhavan valli 2024-05-27 08:50:21 +05:30
parent bc36cceaa3
commit a75f6fb3c0
9 changed files with 166 additions and 174 deletions

View File

@ -545,12 +545,24 @@ class Jobcard extends BaseController
// $service = $ServiceModel->where('JSON_CONTAINS(makes_id, \'' . $encodedMakeId . '\')', null, false) // $service = $ServiceModel->where('JSON_CONTAINS(makes_id, \'' . $encodedMakeId . '\')', null, false)
// ->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false) // ->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
// ->findAll(); // ->findAll();
$service = $ServiceModel->where('makes_id LIKE \'%"' . $makeId . '"%\'', null, false) $service1 = $ServiceModel->where('makes_id LIKE \'%"' . $makeId . '"%\'', null, false)
->where('models_id LIKE \'%"' . $modelId . '"%\'', null, false) ->where('models_id LIKE \'%"' . $modelId . '"%\'', null, false)
->orWhere('category', 0) ->orWhere('category', 0)
->findAll(); ->findAll();
$encodedMakeId1 = 0;
$encodedModelId1 = 0;
$common_services = $ServiceModel->where('makes_id LIKE \'%"' . $encodedMakeId1 . '"%\'', null, false)
->where('models_id LIKE \'%"' . $encodedModelId1 . '"%\'', null, false)
->findAll();
$service = array_merge($common_services, $service1);
$data['product']=$product; $data['product']=$product;
$data['service']=$service; $data['service']=$service;
// echo "<pre>";
// print_r($service);die;
$jobs_product= $JobcardCustomComplaintModel->where('job_card_id', $job_card_id)->findAll(); $jobs_product= $JobcardCustomComplaintModel->where('job_card_id', $job_card_id)->findAll();
$data['jobs_product']=$jobs_product; $data['jobs_product']=$jobs_product;
$jobs_service= $JobcardServiceModel->where('job_card_id', $job_card_id)->findAll(); $jobs_service= $JobcardServiceModel->where('job_card_id', $job_card_id)->findAll();
@ -1155,11 +1167,23 @@ class Jobcard extends BaseController
$ServiceModel = new ServiceModel(); $ServiceModel = new ServiceModel();
// Query the database to find the service based on make_id and model_id // Query the database to find the service based on make_id and model_id
$service = $ServiceModel->where('makes_id LIKE \'%"' . $makeId . '"%\'', null, false) $service1 = $ServiceModel->where('makes_id LIKE \'%"' . $makeId . '"%\'', null, false)
->where('models_id LIKE \'%"' . $modelId . '"%\'', null, false) ->where('models_id LIKE \'%"' . $modelId . '"%\'', null, false)
->where('category',0) ->where('category',1)
->findAll(); ->findAll();
$encodedMakeId1 = 0;
$encodedModelId1 =0;
$common_services = $ServiceModel->where('makes_id LIKE \'%"' . $encodedMakeId1 . '"%\'', null, false)
->where('models_id LIKE \'%"' . $encodedModelId1 . '"%\'', null, false)
->where('category',1)
->findAll();
$service2 = $ServiceModel->where('category',0)
->findAll();
$service = array_merge($common_services, $service1, $service2);
$modelName = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->model_name; $modelName = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->model_name;
$makeName = $this->BikemakeModel->where('make_id',$makeId)->get()->getRow()->make; $makeName = $this->BikemakeModel->where('make_id',$makeId)->get()->getRow()->make;

View File

@ -97,11 +97,24 @@ class Sales extends BaseController
$productModel = new ProductModel(); $productModel = new ProductModel();
// Query the database to find the product based on make_id and model_id // Query the database to find the product based on make_id and model_id
$product = $productModel->select('products.*, manufacturer.manufacturer_name') $makemodelproduct = $productModel->select('products.*, manufacturer.manufacturer_name')
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id') ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false) ->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false) ->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
->findAll(); ->findAll();
$encodedMakeId1 = json_encode(['0']);
$encodedModelId1 = json_encode(['0']);
$common_product = $productModel->select('products.*, manufacturer.manufacturer_name')
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId1 . '\')', null, false)
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId1 . '\')', null, false)
->where('qty_stock >',0)
->findAll();
$product = array_merge($common_product, $makemodelproduct);
$data['product']=$product; $data['product']=$product;
$SalesProductOrderModel = new SalesOrderProductModel(); $SalesProductOrderModel = new SalesOrderProductModel();
$sales_product=$SalesProductOrderModel->where('sales_order_id', $sales_order_id)->findAll(); $sales_product=$SalesProductOrderModel->where('sales_order_id', $sales_order_id)->findAll();
@ -451,6 +464,12 @@ public function getProducts()
// Load the ProductModel // Load the ProductModel
$productModel = new ProductModel(); $productModel = new ProductModel();
$bikemodelsModel = new BikemodelsModel();
$BikemakeModel = new BikemakeModel();
$makeGeneral = $BikemakeModel->where('make' , 'General')->first();
$modelGeneral = $bikemodelsModel->where('model_name' , 'General')->first();
// Query the database to find the product based on make_id and model_id // Query the database to find the product based on make_id and model_id
$makeproduct = $productModel->select('products.*, manufacturer.manufacturer_name') $makeproduct = $productModel->select('products.*, manufacturer.manufacturer_name')

View File

@ -234,7 +234,7 @@
$('#form_add_edit').text('Edit Models'); $('#form_add_edit').text('Edit Models');
var full_div = $(params).parent().parent()[0]; var full_div = $(params).closest('tr')[0];
$('#modelname').val($(full_div).find('.model_name').text()); $('#modelname').val($(full_div).find('.model_name').text());
} }

View File

@ -25,7 +25,6 @@
<th>Labour Charge</th> <th>Labour Charge</th>
<th hidden>Status</th> <th hidden>Status</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -105,22 +104,20 @@
<?php include('layout/footer.php'); ?> <?php include('layout/footer.php'); ?>
<script> <script>
function ReverseCalculation() {
function ReverseCalculation() { var tax = parseFloat($("#tax").val());
var tax = parseFloat($("#tax").val()); if(tax == ''){
if(tax == ''){ toastr.warning('Please select Tax', 'Warning');
toastr.warning('Please select Tax', 'Warning'); }else{
}else{ var labour_cost_with_tax = parseFloat($("#labour_cost_with_tax").val());
var labour_cost_with_tax = parseFloat($("#labour_cost_with_tax").val()); var labour_cost = labour_cost_with_tax / parseFloat((tax / 100) + 1);
var labour_cost = labour_cost_with_tax / parseFloat((tax / 100) + 1);
$("#labour_charge").val(labour_cost.toFixed(2));
}
} $("#labour_charge").val(labour_cost.toFixed(2));
}
}
function submitComplaint(params) { function submitComplaint(params) {
if (!$('#name').val() || !$('#labour_charge').val()) { if (!$('#name').val() || !$('#labour_charge').val()) {
return false; return false;
@ -152,9 +149,6 @@
}); });
} }
function editComplaint(params) { function editComplaint(params) {
var complaint_id = $(params).data('value'); var complaint_id = $(params).data('value');
$.ajax({ $.ajax({
@ -162,7 +156,6 @@
url: '<?php echo base_url()."edit_complaint/"?>' + complaint_id, url: '<?php echo base_url()."edit_complaint/"?>' + complaint_id,
dataType: 'json', dataType: 'json',
success: function(response) { success: function(response) {
console.log(response);
$('#form_add_edit').html(response.page_name) $('#form_add_edit').html(response.page_name)
$('#complaint_id').val(response.complaint[0].complaint_id); $('#complaint_id').val(response.complaint[0].complaint_id);
$('#name').val(response.complaint[0].name); $('#name').val(response.complaint[0].name);
@ -178,7 +171,6 @@
break; break;
} }
} }
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
// Handle error response here // Handle error response here
@ -189,55 +181,53 @@
function clearDetials(params) { function clearDetials(params) {
$('#form_add_edit').text('Add Complaint'); $('#form_add_edit').text('Add Complaint');
$('#model_form_data')[0].reset();
} }
</script>
$(document).ready(function() {
<script> $('#datatable-buttons-2').DataTable({
$(document).ready(function() { "order": [[2, 'desc']], // Set initial sorting to descending on the first column
$('#datatable-buttons-2').DataTable({ "dom": 'Bfrtip', // Show export buttons
"order": [[2, 'desc']], // Set initial sorting to descending on the first column "buttons": [ {
"dom": 'Bfrtip', // Show export buttons extend: 'pdfHtml5',
"buttons": [ { title: 'Complaint', // Set your custom PDF title here
extend: 'pdfHtml5', text: 'PDF',
title: 'Complaint', // Set your custom PDF title here customize: function(doc) {
text: 'PDF', // You can further customize the PDF here if needed
customize: function(doc) { // doc.content[1].table.body.forEach(function(row) {
// You can further customize the PDF here if needed // row.splice(0, 1); // Remove the first column (ID column)
// doc.content[1].table.body.forEach(function(row) { // });
// row.splice(0, 1); // Remove the first column (ID column) }
// }); },
} {
}, extend: 'print',
{ title: 'Complaint', // Set your custom print title here
extend: 'print', text: 'Print',
title: 'Complaint', // Set your custom print title here customize: function(win) {
text: 'Print', // You can further customize the print output here if needed
customize: function(win) { // $(win.document.body).find('table').find('th:first-child, td:first-child').remove();
// You can further customize the print output here if needed }
// $(win.document.body).find('table').find('th:first-child, td:first-child').remove(); },
} {
}, extend: 'copy',
{ text: 'Copy', // Set the title for the Copy button
extend: 'copy', titleAttr: 'Copy', // Set the tooltip for the Copy button
text: 'Copy', // Set the title for the Copy button exportOptions: {
titleAttr: 'Copy', // Set the tooltip for the Copy button // columns: ':not(:first-child)' // Exclude the first column (ID column)
exportOptions: { }
// columns: ':not(:first-child)' // Exclude the first column (ID column) },
} {
}, extend: 'csv',
{ text: 'CSV', // Set the title for the CSV button
extend: 'csv', title: 'Complaint', // Set your custom print title here
text: 'CSV', // Set the title for the CSV button exportOptions: {
title: 'Complaint', // Set your custom print title here // columns: ':not(:first-child)' // Exclude the first column (ID column)
exportOptions: { }
// columns: ':not(:first-child)' // Exclude the first column (ID column) }], // Enable export options
} "language": {
}], // Enable export options "search": "Search: " // Customize search label
"language": { },
"search": "Search: " // Customize search label "ordering": false
}, });
"ordering": false
}); });
});
</script> </script>

View File

@ -494,7 +494,7 @@ $(document).ready(async function() {
var edit_ccomplaint_data = <?php echo isset($editccomplaintdata) ? json_encode($editccomplaintdata) : 0 ?>; var edit_ccomplaint_data = <?php echo isset($editccomplaintdata) ? json_encode($editccomplaintdata) : 0 ?>;
if(edit_ccomplaint_data.length > 0) { if(edit_ccomplaint_data.length > 0) {
for (const value of edit_ccomplaint_data) { for (const value of edit_ccomplaint_data) {
var newRow = '<tr class="custom_complaint_class"><td hidden> <input type="number" class="form-control labour_cost" name="labour_cost" value="'+value.labour_cost+'"></td><td><textarea class="form-control custom-comp" id="custom_complaint_detail" rows="5">'+value.name+'</textarea></td>' + var newRow = '<tr class="custom_complaint_class"><td hidden> <input type="number" class="form-control labour_cost" name="labour_cost" step="0.01" value="'+value.labour_cost+'"></td><td><textarea class="form-control custom-comp" id="custom_complaint_detail" rows="5">'+value.name+'</textarea></td>' +
'<td><input hidden type="text" class="form-control rate-d-only" value="'+value.amount+'" readonly /></td>' + '<td><input hidden type="text" class="form-control rate-d-only" value="'+value.amount+'" readonly /></td>' +
'<td hidden><input hidden type="text" class="form-control item-rate1" value="'+value.amount+'" name="unit-price[]" /></td>' + '<td hidden><input hidden type="text" class="form-control item-rate1" value="'+value.amount+'" name="unit-price[]" /></td>' +
'<td><input hidden type="number" class="form-control item-quantity" min="0" value="'+value.qty+'" name="quantity[]" readonly/></td>'; '<td><input hidden type="number" class="form-control item-quantity" min="0" value="'+value.qty+'" name="quantity[]" readonly/></td>';
@ -753,6 +753,7 @@ $(window).on('load', function() {
vehicle_id: vehicleId vehicle_id: vehicleId
}, },
success: function(response) { success: function(response) {
console.log("111111111111111111");
console.log(response); console.log(response);
servicearray = response.service; servicearray = response.service;
makeAndModel = response.makeName+' '+response.modelName; makeAndModel = response.makeName+' '+response.modelName;
@ -833,8 +834,7 @@ $(window).on('load', function() {
else if(className == 'custom_complaint_lb') { else if(className == 'custom_complaint_lb') {
previousRow = $(this).closest('tr').prevAll(".custom_complaint_class").first(); previousRow = $(this).closest('tr').prevAll(".custom_complaint_class").first();
labour_rate = previousRow.find('.labour_cost'); labour_rate = previousRow.find('.labour_cost');
// labour_rate.val(actual_amount.toFixed(2)); labour_rate.val(actual_amount.toFixed(2));
labour_rate.val(parseInt(actual_amount, 10));
item_rate = previousRow.find('.item-rate1'); item_rate = previousRow.find('.item-rate1');
item_rate.val(actual_amount.toFixed(2)); item_rate.val(actual_amount.toFixed(2));
@ -1595,10 +1595,10 @@ $(window).on('load', function() {
selected_pr.push(rowProductid); selected_pr.push(rowProductid);
}); });
if(servicearray.length == 0) // if(servicearray.length == 0)
{ // {
servicearray = <?php echo isset($service_1) ? json_encode($service_1) : json_encode($service) ?>; // servicearray = <?php echo isset($service_1) ? json_encode($service_1) : json_encode($service) ?>;
} // }
console.log(servicearray); console.log(servicearray);
var newRow = '<tr class="service_class"><td hidden> <input type="text" class="form-control labour_cost" name="labour_cost"></td><td><select class="form-control book-select SelExample service" name="service_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Service</option>'; var newRow = '<tr class="service_class"><td hidden> <input type="text" class="form-control labour_cost" name="labour_cost"></td><td><select class="form-control book-select SelExample service" name="service_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Service</option>';
@ -1699,7 +1699,7 @@ $(window).on('load', function() {
$('#addCustomComplaint').click(function() { $('#addCustomComplaint').click(function() {
complaint = <?php echo json_encode($complaint) ?>; complaint = <?php echo json_encode($complaint) ?>;
var newRow = '<tr class="custom_complaint_class"><td hidden> <input type="number" class="form-control labour_cost" name="labour_cost"></td><td><textarea class="form-control custom-comp" id="custom_complaint_detail" required rows="5"></textarea></td>' + var newRow = '<tr class="custom_complaint_class"><td hidden> <input type="number" class="form-control labour_cost" step="0.01" name="labour_cost"></td><td><textarea class="form-control custom-comp" id="custom_complaint_detail" required rows="5"></textarea></td>' +
'<td><input hidden type="text" class="form-control rate-d-only" readonly /></td>' + '<td><input hidden type="text" class="form-control rate-d-only" readonly /></td>' +
'<td hidden><input type="text" class="form-control item-rate1" name="unit-price[]" readonly /></td>' + '<td hidden><input type="text" class="form-control item-rate1" name="unit-price[]" readonly /></td>' +
'<td><input hidden type="number" class="form-control item-quantity" min="0" value="1" name="quantity[]" readonly/></td>' + '<td><input hidden type="number" class="form-control item-quantity" min="0" value="1" name="quantity[]" readonly/></td>' +
@ -1746,7 +1746,7 @@ $(window).on('load', function() {
var $targetField = $previousRow.find('.item-rate1'); var $targetField = $previousRow.find('.item-rate1');
$targetField.val(enteredValue); $targetField.val(enteredValue);
var $targetField2 = $previousRow.find('.labour_cost'); var $targetField2 = $previousRow.find('.labour_cost');
$targetField2.val(int(enteredValue)); $targetField2.val(enteredValue);
updateCalculations(); updateCalculations();
}); });
/** TAX FIELD */ /** TAX FIELD */
@ -1874,16 +1874,17 @@ $(window).on('load', function() {
} }
if ($closestTR.attr('class') !== "product" && $closestTR.attr('class') !== "sub_service") { if ($closestTR.attr('class') !== "product" && $closestTR.attr('class') !== "sub_service") {
while ($closestTR.next().length > 0 ) { while ($closestTR.next().length > 0 ) {
if ($closestTR.next().hasClass('service_class') || $closestTR.next().hasClass('complaint_class') || $closestTR.next().hasClass('custom_complaint_class') || $closestTR.next().hasClass('os_class')) { if ($closestTR.next().hasClass('service_class') || $closestTR.next().hasClass('complaint_class') || $closestTR.next().hasClass('custom_complaint_class') || $closestTR.next().hasClass('os_class')) {
break; break;
} }
// Remove the next row // Remove the next row
$closestTR.next().remove(); $closestTR.next().remove();
} }
// Remove the clicked row // Remove the clicked row
} }
$closestTR.remove(); $closestTR.remove();
updateCalculations(); updateCalculations();
}); });
@ -2081,7 +2082,7 @@ $(window).on('load', function() {
$('#addVehicleModal').modal('hide'); $('#addVehicleModal').modal('hide');
toastr.success("Vehicle saved successfully!"); toastr.success("Vehicle saved successfully!");
localStorage.setItem('vehicle_id',response.vehicle_id) localStorage.setItem('vehicle_id',response.vehicle_id)
window.location.reload(); // window.location.reload();
} else { } else {
toastr.warning("Failed to save vehicle. Please try again"); toastr.warning("Failed to save vehicle. Please try again");

View File

@ -183,66 +183,26 @@
toastr.error('Please enter a Make Name.', 'Error'); toastr.error('Please enter a Make Name.', 'Error');
return; // Stop further execution of the function return; // Stop further execution of the function
} }
var formData = { var formData = {
makename: $('#bike_make_name').val() makename: $('#bike_make_name').val()
}; };
var edit_make_id = $('#edit_make_id').val(); var edit_make_id = $('#edit_make_id').val();
if (!edit_make_id) { if (!edit_make_id) {
edit_make_id =0; edit_make_id =0;
} }
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: 'create_make/'+edit_make_id, url: 'create_make/'+edit_make_id,
data: formData, data: formData,
dataType: 'json', dataType: 'json',
success: function(response) { success: function(response) {
console.log(response);
if (response.status == "failed") { if (response.status == "failed") {
toastr.warning(response.data, 'Warning'); toastr.warning(response.data, 'Warning');
}else{ }else{
$('#bike_make_login-modal').modal('hide'); $('#bike_make_login-modal').modal('hide');
$('#bike_make_name').val(''); $('#bike_make_name').val('');
toastr.success(response.data, 'Success'); toastr.success(response.data, 'Success');
// $('tbody').html('');
window.location.reload(); window.location.reload();
// $.each(response.make_list, function(index, item) {
// var row = '<tr>' +
// '<td class="make">' + item.make + '</td>' +
// '<td>';
// if (item.isactive == 1) {
// row += '<span style="color:green">Active</span>';
// } else if (item.isactive == 0) {
// row += '<span style="color:red">Inactive</span>';
// }
// row += '</td><td>';
// // Check the isactive status and set the icon color accordingly
// row += '<a data-toggle="modal" data-target="#bike_make_login-modal" data-value="'+ item.make_id +'" class="edit-button" onclick="editMake(this)"><i class="ri-pencil-line" style="font-size:20px;"></i></a>';
// row +='<a href="#" data-toggle="modal" data-target="#bike_model_login-modal" style="margin-left: 12px;" class="add-button" title="Add" data-id="'+ item.make_id+'" data-value="' +item.make+'" onclick="setMakeName(this)"><i class="ri-add-line icon-large" style="font-size:20px;"></i></a>';
// row +='<a href="bike_model_index/' +item.make_id+'" class="view-list-button" title="Model List" style="margin-left: 12px;"><i class="ri-list-check-2 icon-large" style="font-size:20px;"></i></a>';
// if (item.isactive == 1) {
// row += '<a style="color:red; margin-left:12px;" data-id="' + item.make_id + '" data-isactive="' + item.isactive + '" title="Deactivate" onclick="statusChange(this)"><i class="fa fa-bicycle" style="font-size:20px;"></i><i class="fa fa-times" style="font-size: x-small;" style="font-size:20px;"></i></a>';
// } else if (item.isactive == 0) {
// row += '<a style="color:green; margin-left:12px;" data-id="' + item.make_id + '" data-isactive="' + item.isactive + '" title="Activate" onclick="statusChange(this)"><i class="fa fa-bicycle" style="font-size:20px;"></i></a>';
// }
// row += '</td><td></td></tr>';
// // Append the row to the tbody
// $('tbody').append(row);
// });
} }
}, },
@ -253,24 +213,18 @@
}); });
} }
function editMake(params) { function editMake(params) {
$('#edit_make_id').val($(params).data('value')); $('#edit_make_id').val($(params).data('value'));
$('#form_add_edit').text('Edit Bike Make'); $('#form_add_edit').text('Edit Bike Make');
var full_div = $(params).closest('tr')[0];
var full_div = $(params).parent().parent()[0];
console.log($(full_div));
$('#bike_make_name').val($(full_div).find('.make').text()); $('#bike_make_name').val($(full_div).find('.make').text());
} }
function clearDetials(params) { function clearDetials(params) {
$('#form_add_edit').text('Add Bike Make'); $('#form_add_edit').text('Add Bike Make');
$('#bike_make_name').val(''); $('#bike_make_name').val('');
} }
function statusChange(params) { function statusChange(params) {
var status = params.getAttribute('data-isactive'); var status = params.getAttribute('data-isactive');
var make_id = params.getAttribute('data-id'); var make_id = params.getAttribute('data-id');

View File

@ -136,11 +136,9 @@
} }
function editManufacturer(params) { function editManufacturer(params) {
$('#manufacturer_id').val($(params).data('value')); $('#manufacturer_id').val($(params).data('value'));
$('#form_add_edit').text('Edit Manufacturer'); $('#form_add_edit').text('Edit Manufacturer');
var full_div = $(params).parent().parent()[0]; var full_div = $(params).closest('tr')[0];
$('#manufacturer_name').val($(full_div).find('.manufacturer_name').text()); $('#manufacturer_name').val($(full_div).find('.manufacturer_name').text());
$('#quality').val($(full_div).find('.quality').text()); $('#quality').val($(full_div).find('.quality').text());
} }

View File

@ -196,7 +196,7 @@ p {
<?= $item['reg_no'] ?><br> <?= $item['reg_no'] ?><br>
<?= $item['bike_name'] ?> - <?= $item['bike_modal_name'] ?><br> <?= $item['bike_name'] ?> - <?= $item['bike_modal_name'] ?><br>
<?= $item['colour'] ?> color<br> <?= $item['colour'] ?> color<br>
<?= $item['delivery_date'] ?><br> <?= $item['delivery_date'] ?> delivery date<br>
</td> </td>
<td style="padding: 0;width: 33%;border: 0.5px solid black;"> <td style="padding: 0;width: 33%;border: 0.5px solid black;">
<table style="margin-left: -2px;width: 101%;padding: 0;"> <table style="margin-left: -2px;width: 101%;padding: 0;">

View File

@ -436,7 +436,8 @@ $(document).ready(function() {
dataType: 'json', dataType: 'json',
data: { data: {
make_id: makeId, make_id: makeId,
model_id: modelId model_id: modelId,
general: 1
}, },
success: function(response) { success: function(response) {
console.log(response); console.log(response);
@ -444,7 +445,6 @@ $(document).ready(function() {
var makeAndModel = response.makeName + ' ' + response.modelName; var makeAndModel = response.makeName + ' ' + response.modelName;
$('#makeAndModel').val(makeAndModel); $('#makeAndModel').val(makeAndModel);
console.log(response);
productarray = response.product; productarray = response.product;
@ -455,6 +455,7 @@ $(document).ready(function() {
} }
}); });
} else { } else {
productarray = [];
console.error('Make ID or Model ID not found for the selected vehicle'); console.error('Make ID or Model ID not found for the selected vehicle');
} }
} }
@ -664,38 +665,43 @@ $(document).ready(function() {
// Event listener for "Add More Item" button // Event listener for "Add More Item" button
$('#addItem').click(function() { $('#addItem').click(function() {
// console.log(productarray); console.log(productarray.length);
var newRow = '<tr>' + if (productarray.length > 0) {
var newRow = '<tr>' +
'<td><select class="form-control book-select SelExample" name="item_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Product</option>'; '<td><select class="form-control book-select SelExample" name="item_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Product</option>';
for (var i = 0; i < productarray.length; i++) { for (var i = 0; i < productarray.length; i++) {
var product = productarray[i]; var product = productarray[i];
// console.log("product",product); // console.log("product",product);
var value_ml =''; var value_ml ='';
if (product.per == 'ml') { if (product.per == 'ml') {
value_ml = " ("+product.ml+product.per+")"; value_ml = " ("+product.ml+product.per+")";
}
newRow += '<option value="' + product.product_id + '" >' + product.product_name + value_ml + " - " + product.manufacturer_name+
'</option>';
} }
newRow += '<option value="' + product.product_id + '" >' + product.product_name + value_ml + " - " + product.manufacturer_name+
'</option>'; newRow += '</select></td>' +
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" readonly /></td>' +
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" max="" name="quantity[]" onchange="updateThirdColumnValue(this); updateTaxAmount(this)" /></td>' +
'<td style="width:10%;"><input type="text" class="form-control item-result" readonly /></td>' +
'<td style="width:8%;"><input type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
'<td style="width:8%;"><input type="text" class="form-control tax-amount" name="tax-amount[]" readonly /></td>' +
'<td style="width:12%;"><input type="text" class="form-control item-amount" name="amount[]"/></td>' +
'<td hidden><input type="hidden"></td>' +
'<td><center><i class="fa fa-trash remove-item"></i></center></td>' +
'</tr>';
$('#itemTable tbody').append(newRow);
initializeSelect2();
updateCalculations();
initializeRowCalculations(row);
}else{
toastr.warning("First Choose the Vehicle!");
} }
newRow += '</select></td>' +
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" readonly /></td>' +
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" max="" name="quantity[]" onchange="updateThirdColumnValue(this); updateTaxAmount(this)" /></td>' +
'<td style="width:10%;"><input type="text" class="form-control item-result" readonly /></td>' +
'<td style="width:8%;"><input type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
'<td style="width:8%;"><input type="text" class="form-control tax-amount" name="tax-amount[]" readonly /></td>' +
'<td style="width:12%;"><input type="text" class="form-control item-amount" name="amount[]"/></td>' +
'<td hidden><input type="hidden"></td>' +
'<td><center><i class="fa fa-trash remove-item"></i></center></td>' +
'</tr>';
$('#itemTable tbody').append(newRow);
initializeSelect2();
updateCalculations();
initializeRowCalculations(row);
}); });
// Event listener for removing item // Event listener for removing item