MERGE_code:ss

This commit is contained in:
sriramv 2024-05-08 08:26:14 +05:30
parent 6b25c16edf
commit a27fdcf49b
3 changed files with 14 additions and 11 deletions

View File

@ -140,7 +140,7 @@ $routes->get('dashboard', 'Users::dashboard');
// Model //
$routes->get('bike_model_index/(:any)', 'Model::index/$1');
$routes->post('create_model/(:any)', 'Model::create_model/(:any)');
$routes->post('create_model/(:any)', 'Model::create_model/$1');
$routes->get('delete_model/(:any)', 'Model::delete_model/$1');
$routes->post('status_model', 'Model::status_model');
// Model End's//

View File

@ -207,7 +207,7 @@ echo $html;die;
// Using '&' to reference the original array element
foreach ($servicedata as &$value) {
$product_ids = !empty(json_decode($value['product_id'], true)) ? json_decode($value['product_id'], true) : [0];
$product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname')
$product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname, products.qty_stock')
->join('products', 'products.product_id = job_card_product.product_id')
->whereIn('job_card_product.job_card_product_id', $product_ids)->findAll();
$value['product'] = $product;
@ -218,7 +218,7 @@ echo $html;die;
// Using '&' to reference the original array element
foreach ($complaintdata as &$value) {
$product_ids = !empty(json_decode($value['product_id'], true)) ? json_decode($value['product_id'], true) : [0];
$product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname')
$product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname, products.qty_stock')
->join('products', 'products.product_id = job_card_product.product_id')
->whereIn('job_card_product_id', $product_ids)->findAll();
$value['product'] = $product;
@ -230,7 +230,7 @@ echo $html;die;
// Using '&' to reference the original array element
foreach ($ccomplaintdata as &$value) {
$product_ids = !empty(json_decode($value['product_id'], true)) ? json_decode($value['product_id'], true) : [0];
$product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname')
$product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname, products.qty_stock')
->join('products', 'products.product_id = job_card_product.product_id')
->whereIn('job_card_product_id', $product_ids)->findAll();
$value['product'] = $product;
@ -266,7 +266,7 @@ echo $html;die;
$encodedModelId = json_encode([$makeId]);
// array_push($makeId, 0);
// array_push($modelId, 0);
$product = $productModel->where('JSON_CONTAINS(make_id, \'' . $encodedModelId . '\')', null, false)->findAll();
$product = $productModel->where('JSON_CONTAINS(make_id, \'' . $encodedModelId . '\')', null, false)->where('qty_stock >',0)->findAll();
$data['product']=$product;
// echo json_encode($product);die;
@ -527,7 +527,7 @@ echo $html;die;
foreach ($id_array as $key => $product_id) {
$product = $JobcardProductModel->find($product_id);
$qty = isset($product['qty']) ? $product['qty'] : 0;
if ($status == 'Paid') {
if ($status == 'Created') {
$this->updateProductQuantity($ProductModel, $product['product_id'], $qty);
}elseif ($status == 'Cancelled'){
$this->addBackProductQuantity($ProductModel, $product['product_id'], $qty);
@ -690,6 +690,7 @@ echo $html;die;
// Query the database to find the service based on make_id and model_id
$service = $ServiceModel->where('makes_id LIKE \'%"' . $makeId . '"%\'', null, false)
->where('models_id LIKE \'%"' . $modelId . '"%\'', null, false)
->where('category',0)
->findAll();
$modelName = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->model_name;

View File

@ -85,12 +85,14 @@
<option value="Created" <?= $jobs['status'] === 'Created' ? 'selected' : '' ?>>Created</option>
<option value="Paid" <?= $jobs['status'] === 'Paid' ? 'selected' : '' ?>>Paid</option>
<?php else: ?>
<option value="" <?= $jobs['status'] === '' ? 'selected' : '' ?>>SELECT</option>
<option value="Created" <?= $jobs['status'] === 'Created' ? 'selected' : '' ?>>Created</option>
<option value="Paid" <?= $jobs['status'] === 'Paid' ? 'selected' : '' ?>>Paid</option>
<option value="Cancelled" <?= $jobs['status'] === 'Cancelled' ? 'selected' : '' ?>>Cancelled</option>
<?php endif; ?>
<?php else: ?>
<option value="Created" selected>Created</option>
<option value="" selected>SELECT</option>
<option value="Created">Created</option>
<option value="Paid">Paid</option>
<?php endif; ?>
</select>
@ -440,7 +442,7 @@ $(document).ready(async function() {
for (const product of products) {
total_wih_tax =( parseInt(product.amount) + (parseInt(product.amount) * (product.tax / 100)) )* product.qty;
console.log(total_wih_tax);
console.log(product.pname,product.qty_stock,'qty_stock');
total_tax_amt = total_wih_tax - ( parseInt(product.amount) * product.qty);
var newRow = `<tr class="product"><td hidden style="width:10%;"><input type="number" class="form-control labour_cost" name="labour_cost"></td>
<td style="padding-left: 40px !important;"><i class="fa fa-wrench" style="font-size: 13px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i>
@ -450,7 +452,7 @@ $(document).ready(async function() {
newRow += '</select></td>' +
'<td style="width:10%;"><input type="text" class="form-control rate-d-only" value="'+product.amount+'" readonly /></td>' +
'<td style="width:10%;" hidden><input hidden type="text" class="form-control item-rate" name="unit-price[]" value="' + product.amount * product.qty + '" readonly /></td>' +
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" value="' + product.qty + '" name="quantity[]"/></td>' +
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" max="'+Number(product.qty_stock)+'" value="' + product.qty + '" name="quantity[]"/></td>' +
'<td style="width:8%;"> <input type="text" class="form-control taxable-value item-tax" name="item-tax[]" value="' + product.tax + '" readonly /></td>' +
'<td style="width:8%;"><input type="text" class="form-control total-tax-amount" value="'+total_tax_amt+'" readonly /></td>' +
'<td style="width:12%;"><input type="text" class="form-control item-amount" name="amount[]" value="' + total_wih_tax + '" readonly/></center></td>' +
@ -941,7 +943,7 @@ $(window).on('load', function() {
JSON.parse(data.product_id).forEach(async(element,index) => {
if(element == 0) return;
var product = products.find(function(item) {
return item.product_id == element;
return item.product_id == element && item.qty_stock > 0;
});
var cgst = parseFloat(product.cgst);
@ -955,7 +957,7 @@ $(window).on('load', function() {
newRow += '</select></td>' +
'<td style="width:10%;"><input type="text" class="form-control rate-d-only" value="'+ product.unit_price +'" readonly /></td>' +
'<td style="width:10%;" hidden><input type="text" class="form-control item-rate" name="unit-price[]" value="' + product.unit_price + '" readonly /></td>' +
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" value="1" name="quantity[]"/></td>' +
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" max="'+Number(product.qty_stock)+'" value="1" name="quantity[]"/></td>' +
'<td style="width:8%;"> <input type="text" class="form-control taxable-value item-tax" name="item-tax[]" value="' + tax + '" readonly /></td>' +
'<td style="width:8%;"><input type="text" class="form-control total-tax-amount" value="'+total_tax_amt+'" readonly /></td>' +
'<td style="width:12%;"><input type="text" class="form-control item-amount" name="amount1[]" value="' + total_wih_tax + '" readonly/></td>' +