diff --git a/app/Controllers/Jobcard.php b/app/Controllers/Jobcard.php index 8651939..4c9527d 100644 --- a/app/Controllers/Jobcard.php +++ b/app/Controllers/Jobcard.php @@ -400,7 +400,11 @@ class Jobcard extends BaseController $VehicleModel = new VehicleModel(); $vehicle = $VehicleModel->getCustomerandVehicle($this->session->get('logged_user_branch_id')); $ProductModel = new ProductModel(); - $product=$ProductModel->where('isactive',1)->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll(); + $product=$ProductModel->select('products.*, manufacturer.manufacturer_name') + ->join('manufacturer', 'products.manufacturer_id = manufacturer.manufacturer_id') + ->where('products.isactive',1) + ->where('products.branch_id',$this->session->get('logged_user_branch_id')) + ->findAll(); $ServiceModel = new ServiceModel(); // echo $this->session->get('logged_user_branch_id');die; $service=$ServiceModel->where('isactive',1)->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll(); @@ -444,9 +448,11 @@ class Jobcard extends BaseController foreach ($servicedata as &$value) { // sub product datas $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, products.qty_stock') - ->join('products', 'products.product_id = job_card_product.product_id') - ->whereIn('job_card_product.job_card_product_id', $product_ids)->findAll(); + + $product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname, products.qty_stock, manufacturer.manufacturer_name') + ->join('products', 'products.product_id = job_card_product.product_id') + ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id') + ->whereIn('job_card_product.job_card_product_id', $product_ids)->findAll(); $value['product'] = $product; // sub service data @@ -464,9 +470,11 @@ class Jobcard extends BaseController // 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, products.qty_stock') - ->join('products', 'products.product_id = job_card_product.product_id') - ->whereIn('job_card_product_id', $product_ids)->findAll(); + $product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname, products.qty_stock,manufacturer.manufacturer_name') + ->join('products', 'products.product_id = job_card_product.product_id') + ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id') + ->whereIn('job_card_product_id', $product_ids) + ->findAll(); $value['product'] = $product; } $data['editcomplaintdata'] = $complaintdata; @@ -476,9 +484,11 @@ class Jobcard extends BaseController // 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, products.qty_stock') - ->join('products', 'products.product_id = job_card_product.product_id') - ->whereIn('job_card_product_id', $product_ids)->findAll(); + $product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname, products.qty_stock, manufacturer.manufacturer_name') + ->join('products', 'products.product_id = job_card_product.product_id') + ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id') + ->whereIn('job_card_product_id', $product_ids) + ->findAll(); $value['product'] = $product; } $data['editccomplaintdata'] = $ccomplaintdata; @@ -488,9 +498,11 @@ class Jobcard extends BaseController // Using '&' to reference the original array element foreach ($os_data 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, products.qty_stock') - ->join('products', 'products.product_id = job_card_product.product_id') - ->whereIn('job_card_product_id', $product_ids)->findAll(); + $product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname, products.qty_stock, manufacturer.manufacturer_name') + ->join('products', 'products.product_id = job_card_product.product_id') + ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id') + ->whereIn('job_card_product_id', $product_ids) + ->findAll(); $value['product'] = $product; } $data['editosdata'] = $os_data; @@ -524,12 +536,14 @@ class Jobcard extends BaseController // Encode the modelId before searching $encodedModelId = json_encode([$makeId]); $encoded_make_id = json_encode(['0']); - $product1 = $productModel + $product1 = $productModel->select('products.* , manufacturer.manufacturer_name') ->where('JSON_CONTAINS(make_id, \'' . $encodedModelId . '\')', null, false) + ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id') ->where('qty_stock >',0) ->findAll(); - $product2 = $productModel + $product2 = $productModel->select('products.* , manufacturer.manufacturer_name') ->orWhere('JSON_CONTAINS(make_id, \'' . $encoded_make_id . '\')', null, false) + ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id') ->where('qty_stock >',0) ->findAll(); $product = array_merge($product1, $product2); diff --git a/app/Controllers/Purchase.php b/app/Controllers/Purchase.php index bc63b5a..671508d 100644 --- a/app/Controllers/Purchase.php +++ b/app/Controllers/Purchase.php @@ -219,7 +219,6 @@ class Purchase extends BaseController 'shipping_postal_code' => $this->request->getPost('shipping_postal_code'), 'bill_number' => $this->request->getPost('bill_number')? $this->request->getPost('bill_number') : '', 'return_date' => $this->request->getPost('return_date') ? $this->request->getPost('return_date') : '', - 'terms_condition' => $this->request->getPost('terms_condition'), 'branch_id'=> $this->session->get('logged_user_branch_id'), ]; @@ -249,9 +248,7 @@ class Purchase extends BaseController $unitprice=$this->request->getPost('unit-price'); $selected_items=$this->request->getPost('selected_items'); $purchase_order_child_id = $this->request->getPost('purchase_order_child_id'); - // print_r($selected_items);die; - - // print_r($status);die; + $status = $this->request->getPost('purchase_status'); foreach ($product_ids as $key => $product_id) { $qty = isset($quantities[$key]) ? $quantities[$key] : 0; diff --git a/app/Controllers/Service.php b/app/Controllers/Service.php index 1b523b5..b60b71f 100644 --- a/app/Controllers/Service.php +++ b/app/Controllers/Service.php @@ -81,8 +81,11 @@ class Service extends BaseController $service=$ServiceModel->where('isactive',1)->where('category','0')->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll(); // echo $this->session->get('logged_user_branch_id');die; $data['service']=$service; - $product=$ProductModel->where('isactive',1)->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll(); - // echo json_encode($service);die; + $product=$ProductModel->select('products.*, manufacturer.manufacturer_name') + ->join('manufacturer', 'products.manufacturer_id = manufacturer.manufacturer_id') + ->where('products.isactive',1) + ->where('products.branch_id',$this->session->get('logged_user_branch_id')) + ->findAll(); // echo json_encode($service);die; $data['product']=$product; $data['page_name']="Add Service"; } else if ($service_id !== '0') { @@ -95,7 +98,11 @@ class Service extends BaseController $data['page_name']="Edit Service"; - $product=$ProductModel->where('isactive',1)->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll(); + $product=$ProductModel->select('products.*, manufacturer.manufacturer_name') + ->join('manufacturer', 'products.manufacturer_id = manufacturer.manufacturer_id') + ->where('products.isactive',1) + ->where('products.branch_id',$this->session->get('logged_user_branch_id')) + ->findAll(); $data['product']=$product; $models = []; diff --git a/app/Views/job_card_form.php b/app/Views/job_card_form.php index 651acf9..b118bc8 100644 --- a/app/Views/job_card_form.php +++ b/app/Views/job_card_form.php @@ -533,6 +533,7 @@ $(document).ready(async function() { data.labour_cost = 0; total_wih_tax = Number(data.labour_cost) + (Number(data.labour_cost) * (data.tax / 100)); total_tax_amt = Number(data.labour_cost) * (data.tax / 100); + var newRow = '' + '' + @@ -543,7 +544,7 @@ $(document).ready(async function() { newRow += '' + '' + - '' + + '' + '' + '' + ''; @@ -554,7 +555,6 @@ $(document).ready(async function() { } function edit_product_data(products) { - for (const product of products) { product.amount = 0; total_wih_tax =( Number(product.amount) + (Number(product.amount) * (product.tax / 100)) )* product.qty; @@ -573,7 +573,7 @@ $(document).ready(async function() { ' + '' + '' + @@ -583,7 +583,7 @@ $(document).ready(async function() { newRow += ' ' + '' + - '' + + '' + ''+ action+ ''+ @@ -633,7 +633,7 @@ $(document).ready(async function() { newRow += ' ' + '' + - '' + + '' + ''+ action+ ''+ @@ -1347,7 +1347,7 @@ $(document).ready(function() { '' + '' + '' + - '' + + '' + '' + '' + ''; @@ -1373,14 +1373,14 @@ $(document).ready(function() { total_wih_tax = ( Number(product.unit_price) ) + ( Number(product.unit_price) * (tax / 100) ); total_tax_amt = Number(product.unit_price) * (tax / 100); var newRow = '' + '' + '' + '' + '' + '' + - '' + + '' + '
' + '' + '' + @@ -1419,7 +1419,7 @@ $(document).ready(function() { '' + '' + '' + - '' + + '' + '
' + '' + '' + @@ -1565,7 +1565,7 @@ $(document).ready(function() { var product = productarray[i]; if(!selected_pr.includes(product.product_id)) { - newRow += ''; + newRow += ''; } } @@ -1575,7 +1575,7 @@ $(document).ready(function() { '' + '' + '' + - '' + + '' + '
' + '' + '' + @@ -1645,45 +1645,50 @@ $(document).ready(function() { }); $('#addcomplaint').click(function() { - selected_pr = []; - $('tr.complaint_class').each(function() { - var rowProductid = $(this).find('.complaint').val(); - selected_pr.push(rowProductid); - }); + if ($('#vehicle_name').val()) { + selected_pr = []; + $('tr.complaint_class').each(function() { + var rowProductid = $(this).find('.complaint').val(); + selected_pr.push(rowProductid); + }); - complaint = ; - var newRow = ' ' + - '' + - '' + - '' + - '' + - '' + - '' + - '
'+ - '
'+ - '
'+ - '
'+ - ''+ - ''+ - ''+ - ''+ - '
'+ - '' + - '' + - ''; - $('#productItemTable tbody').append(newRow); - // initializeSelect2(); + newRow += '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
'+ + '
'+ + '
'+ + '
'+ + ''+ + ''+ + ''+ + ''+ + '
'+ + '' + + '' + + ''; + $('#productItemTable tbody').append(newRow); + // initializeSelect2(); + }else{ + toastr.warning("First Select Vehicle!"); + } + }); /** To achieve this functionality where entering a value in one input field automatically populates another input field * ONLY APPLICABLE IN COMPLAINT ONLY @@ -1699,41 +1704,45 @@ $(document).ready(function() { }); $('#addCustomComplaint').click(function() { - complaint = ; - var newRow = ' ' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '
'+ - '
'+ - '
'+ - '
'+ - ''+ - ''+ - ''+ - ''+ - '
'+ - '' + - '' + + if ($('#vehicle_name').val()) { + complaint = ; + var newRow = ' ' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
'+ + '
'+ + '
'+ + '
'+ + ''+ + ''+ + ''+ + ''+ + '
'+ + '' + + '' + + ''; + + newRow += '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + ''; - newRow += '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - ''; - - $('#productItemTable tbody').append(newRow); - // initializeSelect2(); + $('#productItemTable tbody').append(newRow); + // initializeSelect2(); + }else{ + toastr.warning("First Select Vehicle!"); + } }); /** To achieve this functionality where entering a value in one input field automatically populates another input field @@ -1777,45 +1786,49 @@ $(document).ready(function() { }); $('#addOutsource').click(function() { - selected_os = []; - $('tr.os_class').each(function() { - var rowProductid = $(this).find('.complaint').val(); - selected_os.push(rowProductid); - }); + if ($('#vehicle_name').val()) { + selected_os = []; + $('tr.os_class').each(function() { + var rowProductid = $(this).find('.complaint').val(); + selected_os.push(rowProductid); + }); - os = ; - var newRow = ' ' + - '' + - '' + - '' + - '' + - '' + - '' + - '
'+ - '
'+ - '
'+ - '
'+ - ''+ - ''+ - ''+ - ''+ - '
'+ - '' + - '' + - ''; - $('#productItemTable tbody').append(newRow); - // initializeSelect2(); + newRow += '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
'+ + '
'+ + '
'+ + '
'+ + ''+ + ''+ + ''+ + ''+ + '
'+ + '' + + '' + + ''; + $('#productItemTable tbody').append(newRow); + // initializeSelect2(); + }else{ + toastr.warning("First Select Vehicle!"); + } }); /** To achieve this functionality where entering a value in one input field automatically populates another input field * ONLY APPLICABLE IN COMPLAINT ONLY diff --git a/app/Views/layout/footer.php b/app/Views/layout/footer.php index c00da37..26d16bb 100644 --- a/app/Views/layout/footer.php +++ b/app/Views/layout/footer.php @@ -36,6 +36,16 @@ + + diff --git a/app/Views/purchase_form.php b/app/Views/purchase_form.php index 98b2503..21cc37e 100644 --- a/app/Views/purchase_form.php +++ b/app/Views/purchase_form.php @@ -1,5 +1,16 @@ + +
@@ -179,12 +190,12 @@ - > + > - +
@@ -412,31 +423,34 @@ $(document).ready(function() { // Event listener for "Add More Item" button $('#addItem').click(function() { - // console.log(productarray); - var newRow = '' + ''; - for (var i = 0; i < productarray.length; i++) - { - var product = productarray[i]; - var value_ml =''; - if (product.per == 'ml') { - value_ml = "("+product.ml+product.per+")"; + for (var i = 0; i < productarray.length; i++) + { + var product = productarray[i]; + var value_ml =''; + if (product.per == 'ml') { + value_ml = "("+product.ml+product.per+")"; + } + newRow += ''; } - newRow += ''; - } - newRow += '' + - '' + - - - '
' + - ''; + newRow += '' + + '' + + + + '
' + + ''; - $('#itemTable tbody').append(newRow); - initializeSelect2(); - + $('#itemTable tbody').append(newRow); + initializeSelect2(); + }else{ + + } }); // Event listener for removing item @@ -557,13 +571,31 @@ function initializeSelect2() { @@ -579,4 +611,5 @@ $('#editaddbutton').click(function() { } }); }); + diff --git a/app/Views/sales_order_form.php b/app/Views/sales_order_form.php index 28f794b..156c7ac 100644 --- a/app/Views/sales_order_form.php +++ b/app/Views/sales_order_form.php @@ -668,7 +668,7 @@ $(document).ready(function() { console.log(productarray.length); if (productarray.length > 0) { var newRow = '' + - ''; for (var i = 0; i < productarray.length; i++) { var product = productarray[i]; @@ -682,11 +682,11 @@ $(document).ready(function() { } newRow += '' + - '' + + '' + '' + - '' + + '' + '' + - '' + + '' + '' + '' + '
' + diff --git a/app/Views/service_form.php b/app/Views/service_form.php index ab4721f..51fcde0 100644 --- a/app/Views/service_form.php +++ b/app/Views/service_form.php @@ -65,7 +65,7 @@ @@ -261,7 +261,7 @@ $(document).ready(function() { // Append new options $('#productSelect').append(''); $.each(response, function(index, product) { - $('#productSelect').append(''); + $('#productSelect').append(''); }); } else { // Handle case when no vendors are found for the selected model