Merge branch 'main' of bitbucket.org:venbainformationtechnology/the_mechanic

This commit is contained in:
Gowtham M 2025-04-10 16:27:35 +05:30
commit 78e01c1256
5 changed files with 90 additions and 46 deletions

View File

@ -219,24 +219,27 @@ class Service extends BaseController
return $this->response->setJSON([]); return $this->response->setJSON([]);
} }
} }
public function get_product_by_cc(){ public function get_product_by_cc(){
$cc_id = $this->request->getPost('cc_id'); $cc_id = $this->request->getPost('cc_id');
$products = []; $products = [];
$model_ids = $this->BikemodelsModel->select('model_id')->where('cubic_capacity_id', $cc_id)->asArray()->findAll(); $model_ids = $this->BikemodelsModel->select('model_id')->where('cubic_capacity_id', $cc_id)->asArray()->findAll();
foreach ($model_ids as $model) { $mid[] = 0; // default zero. because general..
$modelId = $model['model_id']; foreach($model_ids as $model){
// echo $modelId; $mid[] = $model['model_id'];
$product = $this->ProductModel->select('products.*, manufacturer.manufacturer_name') }
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id') $products = [];
->where('JSON_CONTAINS(products.models_id, \'["' . $modelId . '"]\')', null, false) foreach ($mid as $id) {
->where('products.isactive', 1) $sql = "SELECT products.*, manufacturer.manufacturer_name
->findAll(); FROM products
// echo( $this->ProductModel->getLastQuery()->getQuery()); JOIN manufacturer ON manufacturer.manufacturer_id = products.manufacturer_id
$products = array_merge($products, $product); WHERE JSON_CONTAINS(products.models_id, ?)
} AND products.isactive = 1";
$products = array_unique($products, SORT_REGULAR);
$result = $this->ProductModel->query($sql, ['"' . $id . '"'])->getResult();
$products = array_merge($products, $result);
}
return $this->response->setJSON($products); return $this->response->setJSON($products);
} }

View File

@ -90,8 +90,8 @@
<label for="inputEmail4" class="col-form-label">Type<span class="text-danger">*</span></label> <label for="inputEmail4" class="col-form-label">Type<span class="text-danger">*</span></label>
<select class="form-control type-select SelExample" name="type" id="type" data-toggle="select2" required> <select class="form-control type-select SelExample" name="type" id="type" data-toggle="select2" required>
<option value="" <?= (isset($jobs['type']) && $jobs['type'] == '') ? 'selected' : '' ?>>Select Type</option> <option value="" <?= (isset($jobs['type']) && $jobs['type'] == '') ? 'selected' : '' ?>>Select Type</option>
<option value="With General" <?= (isset($jobs['type']) && $jobs['type'] == "With General") ?'selected' : '' ?>>With General</option> <option value="General" <?= (isset($jobs['type']) && $jobs['type'] == "General") ?'selected' : '' ?>>General</option>
<option value="Without General" <?= (isset($jobs['type']) && $jobs['type'] == "Without General") ? 'selected' : '' ?>>Without General</option> <option value="Complaints" <?= (isset($jobs['type']) && $jobs['type'] == "Complaints") ? 'selected' : '' ?>>Complaints</option>
</select> </select>
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
@ -312,7 +312,7 @@
<h4><i class="fa fa-plus" aria-hidden="true" style="margin-right: 5px;"></i>Complaint</h4> <h4><i class="fa fa-plus" aria-hidden="true" style="margin-right: 5px;"></i>Complaint</h4>
</a> </a>
<a class="btn" id="addCustomComplaint"> <a class="btn" id="addCustomComplaint">
<h4><i class="fa fa-plus" aria-hidden="true" style="margin-right: 5px;"></i>Customer Complaint</h4> <h4><i class="fa fa-plus" aria-hidden="true" style="margin-right: 5px;"></i>Additional Complaint</h4>
</a> </a>
<a class="btn" id="addOutsource"> <a class="btn" id="addOutsource">
<h4><i class="fa fa-plus" aria-hidden="true" style="margin-right: 5px;"></i>Outsource</h4> <h4><i class="fa fa-plus" aria-hidden="true" style="margin-right: 5px;"></i>Outsource</h4>

View File

@ -232,7 +232,7 @@
</td> </td>
<td style="width:8%;"> <td style="width:8%;">
<input type="text" class="form-control item-tax" name="item-tax[]" <input type="text" class="form-control item-tax" name="item-tax[]"
value="<?= isset($salechild['tax']) ? $salechild['tax'] : '' ?>" onchange="updateTaxAmount(this)"> value="<?= isset($salechild['tax']) ? $salechild['tax'] : '' ?>" onchange="updateTaxAmount(this)" readonly>
</td> </td>
<td style="width:13%;"> <td style="width:13%;">
<?php if (isset($salechild['tax']) && isset($result) ) { <?php if (isset($salechild['tax']) && isset($result) ) {
@ -241,7 +241,7 @@
$tax_amount=0 ; $tax_amount=0 ;
} }
?> ?>
<input type="text" class="form-control" name="tax-amount[]" value="<?= number_format($tax_amount,2); ?>" readonly> <input type="text" class="form-control tax-amount" name="tax-amount[]" value="<?= number_format($tax_amount,2); ?>" readonly>
</td> </td>
<!-- <td style="width:12%;"> <!-- <td style="width:12%;">
<input type="number" class="form-control item-discount-amount" min="0" name="discount_amount[]" value="<?= isset($salechild['discount']) ? $salechild['discount'] : '' ?>"> <input type="number" class="form-control item-discount-amount" min="0" name="discount_amount[]" value="<?= isset($salechild['discount']) ? $salechild['discount'] : '' ?>">
@ -254,7 +254,7 @@
</td> --> </td> -->
<td style="width:13%;"> <td style="width:13%;">
<input type="text" class="form-control item-amount" name="amount[]" <input type="text" class="form-control item-amount" name="amount[]"
value="<?= isset($salechild['amount']) ? $salechild['amount'] : '' ?>" readonly> value="<?= isset($salechild['amount']) ? $salechild['amount'] : '' ?>" >
</td> </td>
<td hidden><input type="hidden" <td hidden><input type="hidden"
value="<?= isset($salechild['sales_order_product_id']) ? $salechild['sales_order_product_id'] : '' ?>" value="<?= isset($salechild['sales_order_product_id']) ? $salechild['sales_order_product_id'] : '' ?>"
@ -532,11 +532,46 @@ $(document).ready(function() {
var amount = rate * quantity; var amount = rate * quantity;
var taxamount = amount * tax / 100; var taxamount = amount * tax / 100;
$(row).find('.tax-amount').val(parseFloat(taxamount).toFixed(2));
var finalamt = amount + taxamount; var finalamt = amount + taxamount;
$(row).find('.item-amount').val(parseFloat(finalamt).toFixed(2)); $(row).find('.item-amount').val(parseFloat(finalamt).toFixed(2));
} }
function calculateTotalAmount(row) {
// Retrieve CGST and SGST values from the database for the selected product
var productId = $(row).find('select[name="item_details[]"]').val();
var product = products.find(function(item) {
return item.product_id == productId;
});
var cgst = parseFloat(product.cgst);
var sgst = parseFloat(product.sgst);
var tax = cgst + sgst;
var quantity = $(row).find('.item-quantity').val();
var final_amount = $(row).find('.item-amount').val();
var taxRate = tax/100;
// console.log(taxRate);
var amt = final_amount/((1+taxRate));
// console.log(amt);
$(row).find('.item-result').val(parseFloat(amt).toFixed(2));
var taxAmount = final_amount-amt;
// console.log(taxAmount);
$(row).find('.tax-amount').val(parseFloat(taxAmount).toFixed(2));
var rate = amt / quantity;
// console.log(rate);
$(row).find('.item-rate').val(parseFloat(rate).toFixed(2));
}
// Event listener for product selection // Event listener for product selection
$(document).on('change', 'select[name="item_details[]"]', function() { $(document).on('change', 'select[name="item_details[]"]', function() {
var productId = $(this).val(); var productId = $(this).val();
@ -545,7 +580,7 @@ $(document).ready(function() {
if(productId == 0){ if(productId == 0){
$(this).closest('tr').find('.item-quantity').prop('readonly', true); $(this).closest('tr').find('.item-quantity').prop('readonly', true);
$(this).closest('tr').find('.item-amount').prop('readonly', false); // $(this).closest('tr').find('.item-amount').prop('readonly', false);
} }
// Find product details from JSON // Find product details from JSON
@ -577,21 +612,21 @@ $(document).ready(function() {
$(document).on('keyup', '.item-amount', function() $(document).on('keyup', '.item-amount', function()
{ {
var total_amount = $(this).val(); // var total_amount = $(this).val();
var totalTax = $(this).closest('tr').find('.item-tax').val(); // var totalTax = $(this).closest('tr').find('.item-tax').val();
var unitPrice = total_amount / parseFloat((totalTax / 100) + 1); // var unitPrice = total_amount / parseFloat((totalTax / 100) + 1);
var unitPrice = parseFloat(unitPrice).toFixed(2); // var unitPrice = parseFloat(unitPrice).toFixed(2);
var taxAmt = total_amount - unitPrice; // var taxAmt = total_amount - unitPrice;
var taxAmt = parseFloat(taxAmt).toFixed(2) // var taxAmt = parseFloat(taxAmt).toFixed(2)
$(this).closest('tr').find('.tax-amount').val(taxAmt);
$(this).closest('tr').find('.item-rate').val(unitPrice);
$(this).closest('tr').find('.item-result').val(unitPrice);
// $(this).closest('tr').find('.tax-amount').val(taxAmt);
// $(this).closest('tr').find('.item-rate').val(unitPrice);
// $(this).closest('tr').find('.item-result').val(unitPrice);
calculateTotalAmount($(this).closest('tr'));
updateCalculations(); updateCalculations();
}); });
@ -727,7 +762,7 @@ $(document).ready(function() {
'<td style="width:14%;"><input type="text" class="form-control item-result" readonly /></td>' + '<td style="width:14%;"><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 item-tax" name="item-tax[]" readonly /></td>' +
'<td style="width:13%;"><input type="text" class="form-control tax-amount" name="tax-amount[]" readonly /></td>' + '<td style="width:13%;"><input type="text" class="form-control tax-amount" name="tax-amount[]" readonly /></td>' +
'<td style="width:13%;"><input type="text" class="form-control item-amount" name="amount[]" readonly/></td>' + '<td style="width:13%;"><input type="text" class="form-control item-amount" name="amount[]" /></td>' +
'<td hidden><input type="hidden"></td>' + '<td hidden><input type="hidden"></td>' +
'<td><center><i class="fa fa-trash remove-item"></i></center></td>' + '<td><center><i class="fa fa-trash remove-item"></i></center></td>' +
'</tr>'; '</tr>';

View File

@ -35,7 +35,7 @@
</div> </div>
<div class="form-group col-md-3" id="cc_hide" <?= (!isset($services['category']) || $services['category'] == 0) ? 'style="display: none;"' : '' ?>> <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> <select class="form-control" id="cubiccapacity" name="cubiccapacity" style="height:32px">
<option value="">Select</option> <option value="">Select</option>
<?php foreach ($cubiccapacity as $item): ?> <?php foreach ($cubiccapacity as $item): ?>
<option value="<?= $item['id'] ?>" <?php if (isset($services['cubic_capacity_id']) && (($services['cubic_capacity_id'] === $item['id']))) echo "selected"; ?>><?= $item['value'] ?></option> <option value="<?= $item['id'] ?>" <?php if (isset($services['cubic_capacity_id']) && (($services['cubic_capacity_id'] === $item['id']))) echo "selected"; ?>><?= $item['value'] ?></option>
@ -93,24 +93,28 @@
<div class="form-group col-md-4"></div> <div class="form-group col-md-4"></div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Unit Price (Including Tax) with General<span class="text-danger">*</span></label> <!-- <label for="inputPassword4" class="col-form-label">Unit Price (Including Tax) with General<span class="text-danger">*</span></label> -->
<label for="inputPassword4" class="col-form-label">Unit Price (Including Tax) General<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="wg_price_withtax" id="PriceWithTaxAndGeneral" placeholder="Total Price" step="0.01" min="0" value="<?= isset($services['wg_price']) ? $services['wg_price'] : '' ; ?>" required> <input type="number" class="form-control" name="wg_price_withtax" id="PriceWithTaxAndGeneral" placeholder="Total Price" step="0.01" min="0" value="<?= isset($services['wg_price']) ? $services['wg_price'] : '' ; ?>" required>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="inputEmail4" class="col-form-label">Labour Cost with General <span class="text-danger">*</span></label> <!-- <label for="inputEmail4" class="col-form-label">Labour Cost with General <span class="text-danger">*</span></label> -->
<label for="inputEmail4" class="col-form-label">Labour Cost General <span class="text-danger">*</span></label>
<input type="text" class="form-control" name="wg_labour_cost" id="labour_cost" placeholder="Labour Cost" value="<?= isset($services['wg_labour_cost']) ? $services['wg_labour_cost'] : '' ?>" required readonly> <input type="text" class="form-control" name="wg_labour_cost" id="labour_cost" placeholder="Labour Cost" value="<?= isset($services['wg_labour_cost']) ? $services['wg_labour_cost'] : '' ?>" required readonly>
</div> </div>
<div class="form-group col-md-4"></div> <div class="form-group col-md-4"></div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Unit Price (Including Tax) without General<span class="text-danger">*</span></label> <!-- <label for="inputPassword4" class="col-form-label">Unit Price (Including Tax) without General<span class="text-danger">*</span></label> -->
<label for="inputPassword4" class="col-form-label">Unit Price (Including Tax) Complaints<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="wog_price_withtax" id="PriceWithOutTaxWithGeneral" placeholder="Total Price" step="0.01" min="0" value="<?= isset($services['wog_price']) ? $services['wog_price'] : ''; ?>" required> <input type="number" class="form-control" name="wog_price_withtax" id="PriceWithOutTaxWithGeneral" placeholder="Total Price" step="0.01" min="0" value="<?= isset($services['wog_price']) ? $services['wog_price'] : ''; ?>" required>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="inputEmail4" class="col-form-label">Labour Cost without General <span class="text-danger">*</span></label> <!-- <label for="inputEmail4" class="col-form-label">Labour Cost without General <span class="text-danger">*</span></label> -->
<label for="inputEmail4" class="col-form-label">Labour Cost Complaints <span class="text-danger">*</span></label>
<input type="text" class="form-control" name="wog_labour_cost" id="labour_cost" placeholder="Labour Cost" value="<?= isset($services['wog_labour_cost']) ? $services['wog_labour_cost'] : '' ?>" required readonly> <input type="text" class="form-control" name="wog_labour_cost" id="labour_cost" placeholder="Labour Cost" value="<?= isset($services['wog_labour_cost']) ? $services['wog_labour_cost'] : '' ?>" required readonly>
</div> </div>
@ -311,14 +315,16 @@ $(document).ready(function() {
if (service_id != 0) { if (service_id != 0) {
var category = <?php echo isset($services['category']) ? json_encode($services['category']) : 'null'; ?>; var category = <?php echo isset($services['category']) ? json_encode($services['category']) : 'null'; ?>;
if (category == 1) { if (parseInt(category) == 1) {
$('#cc_hide').css('display', 'block'); $('#cc_hide').css('display', 'block');
$('#service_hide').css('display' ,'block'); $('#service_hide').css('display' ,'block');
$('#cubiccapacity').attr('required', false).attr('readonly', true); $('#cubiccapacity').attr('required', true).attr('readonly', false);
// $('#serviceSelected').attr('required', true).attr('readonly', false);
} else { } else {
$('#cc_hide').css('display', 'none'); $('#cc_hide').css('display', 'none');
$('#service_hide').css('display' ,'none'); $('#service_hide').css('display' ,'none');
$('#cubiccapacity').attr('required', true).attr('readonly', false); $('#cubiccapacity').attr('required', false).attr('readonly', true);
$('#serviceSelected').attr('required', false);
} }
} }
}); });
@ -334,8 +340,8 @@ document.getElementById('category').addEventListener('change', function() {
var ccSelect = document.getElementById('cubiccapacity'); var ccSelect = document.getElementById('cubiccapacity');
var serviceSelected = document.getElementById('serviceSelected'); var serviceSelected = document.getElementById('serviceSelected');
var productSelect = document.getElementById('productSelect'); var productSelect = document.getElementById('productSelect');
if (parseInt(this.value) == 1) {
if (this.value == '1') { // 1 ==> Standalone // 1 ==> Standalone
// customFields.style.display = 'block'; // customFields.style.display = 'block';
// $('#make_hide').css('display' , 'block'); // $('#make_hide').css('display' , 'block');
// $('#model_hide').css('display' ,'block'); // $('#model_hide').css('display' ,'block');
@ -343,7 +349,7 @@ document.getElementById('category').addEventListener('change', function() {
$('#service_hide').css('display' ,'block'); $('#service_hide').css('display' ,'block');
$('#cubiccapacity').val(''); $('#cubiccapacity').val('');
$('#productSelect').empty(); $('#productSelect').empty();
ccSelect.setAttribute('required', 'required'); $('#cubiccapacity').attr('required', true).attr('readonly', false);
// makeSelect.setAttribute('required', 'required'); // makeSelect.setAttribute('required', 'required');
// modelSelect.setAttribute('required', 'required'); // modelSelect.setAttribute('required', 'required');
// serviceSelected.setAttribute('required', 'required'); // serviceSelected.setAttribute('required', 'required');
@ -355,10 +361,10 @@ document.getElementById('category').addEventListener('change', function() {
$('#service_hide').css('display' ,'none'); $('#service_hide').css('display' ,'none');
$('#cubiccapacity').val(''); $('#cubiccapacity').val('');
$('#productSelect').empty(); $('#productSelect').empty();
ccSelect.removeAttribute('required'); $('#cubiccapacity').attr('required', false).attr('readonly', true);
$('#serviceSelected').attr('required', false);
// makeSelect.removeAttribute('required'); // makeSelect.removeAttribute('required');
// modelSelect.removeAttribute('required'); // modelSelect.removeAttribute('required');
serviceSelected.removeAttribute('required');
$.ajax({ $.ajax({
url: '<?php echo base_url('product_list_for_service') ?>', // URL to your CodeIgniter controller method url: '<?php echo base_url('product_list_for_service') ?>', // URL to your CodeIgniter controller method
type: 'GET', type: 'GET',

View File

@ -23,8 +23,8 @@
<thead> <thead>
<tr> <tr>
<th>Service Name</th> <th>Service Name</th>
<th>Price With General</th> <th>General Service Price</th>
<th>Price WithOut General</th> <th>Complaint Price</th>
<th>Tax</th> <th>Tax</th>
<th>Description</th> <th>Description</th>
<th>Action</th> <th>Action</th>