CHANGE_FULL_FLOW_ADD_PRODUCT_WITH_MANUFACTURER_NAME : AADHAVAN

This commit is contained in:
aadhavan valli 2024-06-05 09:50:29 +05:30
parent d00767002a
commit fbf43cc737
8 changed files with 239 additions and 165 deletions

View File

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

View File

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

View File

@ -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 = [];

View File

@ -533,6 +533,7 @@ $(document).ready(async function() {
<?php if(isset($rework)) { ?> data.labour_cost = 0; <?php } ?>
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 = '<tr class="'+cls+'"><td hidden><input type="number" class="form-control labour_cost" name="labour_cost"></td><td style="padding-left: 40px !important;"><i class="fas fa-user-alt" style="font-size: 13px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i><input type="text" class="form-control labour_cost" readonly value="Labour Cost"></td>' +
'<td><input type="text" class="form-control rate-d-only" value="'+data.labour_cost+'" readonly /></td>' +
@ -543,7 +544,7 @@ $(document).ready(async function() {
<?php } ?>
newRow += '<td><input type="text" class="form-control taxable-value item-tax" name="item-tax[]" value="'+data.tax+'" readonly /></td>' +
'<td><input type="text" class="form-control total-tax-amount" value="'+total_tax_amt.toFixed(2)+'" readonly /></td>' +
'<td><input type="text" class="form-control item-amount lab_amt" name="amount[]" value="' + Math.round(total_wih_tax) + '" /></td>' +
'<td><input type="text" class="form-control item-amount lab_amt" name="amount[]" value="' + Math.round(total_wih_tax).toFixed(2) + '" onblur="floatInput(event)" /></td>' +
'<td hidden></td>' +
'<td hidden></td>' +
'</tr>';
@ -554,7 +555,6 @@ $(document).ready(async function() {
}
function edit_product_data(products) {
for (const product of products) {
<?php if(isset($rework)) { ?> product.amount = 0; <?php } ?>
total_wih_tax =( Number(product.amount) + (Number(product.amount) * (product.tax / 100)) )* product.qty;
@ -573,7 +573,7 @@ $(document).ready(async function() {
<td style="padding-left: 40px !important;"><i class="fa fa-archive" style="font-size: 13px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i>
<select class="form-control book-select SelExample product" name="item_details[]" required data-toggle="select2" style="width: 249px !important;">`;
newRow += '<option value="' + product.product_id + '" selected>' + product.pname + '</option>';
newRow += '<option value="' + product.product_id + '" selected>' + product.pname +'-'+ product.manufacturer_name + '</option>';
newRow += '</select></td>' +
'<td><input type="text" class="form-control rate-d-only" value="'+product.amount+'" readonly /></td>' +
'<td hidden><input hidden type="text" class="form-control item-rate" name="unit-price[]" value="' + product.amount * product.qty + '" readonly /></td>' +
@ -583,7 +583,7 @@ $(document).ready(async function() {
<?php } ?>
newRow += '<td> <input type="text" class="form-control taxable-value item-tax" name="item-tax[]" value="' + product.tax + '" readonly /></td>' +
'<td><input type="text" class="form-control total-tax-amount" value="'+total_tax_amt.toFixed(2)+'" readonly /></td>' +
'<td><input type="text" class="form-control item-amount" name="amount[]" value="' + Math.round(total_wih_tax) + '" readonly/></center></td>' +
'<td><input type="text" class="form-control item-amount" name="amount[]" value="' + Math.round(total_wih_tax).toFixed(2) + '" onblur="floatInput(event)" readonly/></center></td>' +
'<td>'+
action+
'<input value="product" name="item_type" hidden>'+
@ -633,7 +633,7 @@ $(document).ready(async function() {
<?php } ?>
newRow += '<td> <input type="text" class="form-control taxable-value item-tax" name="item-tax[]" value="' + sub_service.tax + '" readonly /></td>' +
'<td><input type="text" class="form-control total-tax-amount" value="'+total_tax_amt.toFixed(2)+'" readonly /></td>' +
'<td><input type="text" class="form-control item-amount" name="amount[]" value="' + Math.round(total_wih_tax) + '" readonly/></center></td>' +
'<td><input type="text" class="form-control item-amount" name="amount[]" value="' + Math.round(total_wih_tax).toFixed(2) + '" onblur="floatInput(event)" readonly/></center></td>' +
'<td>'+
action+
'<input value="sub_service" name="item_type" hidden>'+
@ -1347,7 +1347,7 @@ $(document).ready(function() {
'<td><input type="number" class="form-control item-quantity-'+cls+' item-quantity" min="0" name="quantity[]" value="'+1+'" /></td>' +
'<td><input type="text" class="form-control taxable-value item-tax" name="item-tax[]" value="'+tax+'" /></td>' +
'<td><input type="text" class="form-control total-tax-amount" value="'+Number(total_tax_amt).toFixed(2)+'" readonly /></td>' +
'<td><input type="text" class="form-control item-amount lab_amt" name="amount[]" value="' + Math.round(total_wih_tax) + '"/></td>' +
'<td><input type="text" class="form-control item-amount lab_amt" name="amount[]" value="' + Math.round(total_wih_tax).toFixed(2) + '" onblur="floatInput(event)" /></td>' +
'<td hidden></td>' +
'<td hidden></td>' +
'</tr>';
@ -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 = '<tr class="product"><td hidden><input type="number" class="form-control labour_cost" name="labour_cost"></td><td style="padding-left: 40px !important;"><i class="fa fa-archive" style="font-size: 13px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i><select class="form-control book-select SelExample product" name="item_details[]" required data-toggle="select2" style="width: 249px !important;">';
newRow += '<option value="' + product.product_id + '">' + product.product_name + '</option>';
newRow += '<option value="' + product.product_id + '">' + product.product_name +'-'+ product.manufacturer_name + '</option>';
newRow += '</select></td>' +
'<td><input type="text" class="form-control rate-d-only" value="'+ Number(product.unit_price).toFixed(2) +'" readonly /></td>' +
'<td hidden><input type="text" class="form-control item-rate" name="unit-price[]" value="' + product.unit_price + '" readonly /></td>' +
'<td><input type="number" class="form-control item-quantity" min="0" max="'+Number(product.qty_stock)+'" value="1" name="quantity[]"/></td>' +
'<td><input type="text" class="form-control taxable-value item-tax" name="item-tax[]" value="' + tax + '" readonly /></td>' +
'<td><input type="text" class="form-control total-tax-amount" value="'+ total_tax_amt.toFixed(2) +'" readonly /></td>' +
'<td><input type="text" class="form-control item-amount" name="amount1[]" value="' + Math.round(total_wih_tax) + '" readonly/></td>' +
'<td><input type="text" class="form-control item-amount" name="amount1[]" value="' + Math.round(total_wih_tax).toFixed(2) + '" onblur="floatInput(event)" readonly/></td>' +
'<td><center><i class="fa fa-trash remove-item"></i></center><input value="product" name="item_type" hidden></td>' +
'<td hidden><input type="hidden" name="id" value=""></td>' +
'<td hidden><input value="'+product.product_name+'" name="name"></td>' +
@ -1419,7 +1419,7 @@ $(document).ready(function() {
'<td><input type="number" class="form-control item-quantity" min="0" value="1" name="quantity[]"/></td>' +
'<td><input type="text" class="form-control taxable-value item-tax" name="item-tax[]" value="' + tax + '" readonly /></td>' +
'<td><input type="text" class="form-control total-tax-amount" value="'+ total_tax_amt.toFixed(2) +'" readonly /></td>' +
'<td><input type="text" class="form-control item-amount" name="amount1[]" value="' + Math.round(total_wih_tax) + '" readonly/></td>' +
'<td><input type="text" class="form-control item-amount" name="amount1[]" value="' + Math.round(total_wih_tax).toFixed(2) + '" onblur="floatInput(event)" readonly/></td>' +
'<td><center><i class="fa fa-trash remove-item"></i></center><input value="sub_service" name="item_type" hidden></td>' +
'<td hidden><input type="hidden" name="id" value=""></td>' +
'<td hidden><input value="'+service.service_name+'" name="name"></td>' +
@ -1565,7 +1565,7 @@ $(document).ready(function() {
var product = productarray[i];
if(!selected_pr.includes(product.product_id))
{
newRow += '<option value="' + product.product_id + '">' + product.product_name + '</option>';
newRow += '<option value="' + product.product_id + '">' + product.product_name + '-' + product.manufacturer_name + '</option>';
}
}
@ -1575,7 +1575,7 @@ $(document).ready(function() {
'<td><input type="number" class="form-control item-quantity" min="0" name="quantity[]"/></td>' +
'<td><input type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
'<td><input type="text" class="form-control total-tax-amount" value="" readonly /></td>' +
'<td><input type="text" class="form-control item-amount" name="amount[]"/></td>' +
'<td><input type="text" class="form-control item-amount" name="amount[]" onblur="floatInput(event)" /></td>' +
'<td><center><i class="fa fa-trash remove-item"></i></center><input value="product" name="item_type" hidden></td>' +
'<td hidden><input type="hidden" name="id"></td>' +
'<td hidden><input value="'+product.product_name+'" name="name"></td>' +
@ -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 = <?php echo json_encode($complaint) ?>;
var newRow = '<tr class="complaint_class"><td hidden> <input type="number" class="form-control labour_cost" name="labour_cost"></td><td><select class="form-control book-select SelExample complaint" id="complaint_detail" name="complaint_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Complaint</option>';
complaint = <?php echo json_encode($complaint) ?>;
var newRow = '<tr class="complaint_class"><td hidden> <input type="number" class="form-control labour_cost" name="labour_cost"></td><td><select class="form-control book-select SelExample complaint" id="complaint_detail" name="complaint_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Complaint</option>';
for (var i = 0; i < complaint.length; i++)
{
var complaints = complaint[i];
if(!selected_pr.includes(complaints.complaint_id))
for (var i = 0; i < complaint.length; i++)
{
newRow += '<option value="' + complaints.complaint_id + '">' + complaints.name + '</option>';
var complaints = complaint[i];
if(!selected_pr.includes(complaints.complaint_id))
{
newRow += '<option value="' + complaints.complaint_id + '">' + complaints.name + '</option>';
}
}
}
newRow += '</select></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><input hidden type="number" class="form-control item-quantity" min="0" name="quantity[]" readonly/></td>' +
'<td><input hidden type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
'<td><input hidden type="text" class="form-control total-tax-amount" readonly /></td>' +
'<td><input hidden type="text" class="form-control item-amount1" name="amount[]"/></td>' +
'<td><div style="display: inline-block;">'+
'<center><i class="fa fa-trash remove-item"></i></center>'+
'</div>'+
'<div style="display: inline-block; margin-left: 10px;">'+
'<input value="product" name="item_type" hidden>'+
'<a class="complaint_detail" id="addProduct" title="Add Product">'+
'<i class="fa fa-plus" aria-hidden="true"></i>'+
'</a>'+
'</div>'+
'</td>' +
'<td hidden><input type="hidden" name="id"></td>' +
'</tr>';
$('#productItemTable tbody').append(newRow);
// initializeSelect2();
newRow += '</select></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><input hidden type="number" class="form-control item-quantity" min="0" name="quantity[]" readonly/></td>' +
'<td><input hidden type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
'<td><input hidden type="text" class="form-control total-tax-amount" readonly /></td>' +
'<td><input hidden type="text" class="form-control item-amount1" name="amount[]"/></td>' +
'<td><div style="display: inline-block;">'+
'<center><i class="fa fa-trash remove-item"></i></center>'+
'</div>'+
'<div style="display: inline-block; margin-left: 10px;">'+
'<input value="product" name="item_type" hidden>'+
'<a class="complaint_detail" id="addProduct" title="Add Product">'+
'<i class="fa fa-plus" aria-hidden="true"></i>'+
'</a>'+
'</div>'+
'</td>' +
'<td hidden><input type="hidden" name="id"></td>' +
'</tr>';
$('#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 = <?php echo json_encode($complaint) ?>;
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 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="text" class="form-control item-tax" name="item-tax[]" value="18" readonly /></td>' +
'<td><input hidden type="text" class="form-control item-amount1" name="amount[]" required/></td>' +
'<td><input hidden type="text" class="form-control total-tax-amount" readonly /></td>' +
'<td hidden><input type="hidden"></td>' +
'<td><div style="display: inline-block;">'+
'<center><i class="fa fa-trash remove-item"></i></center>'+
'</div>'+
'<div style="display: inline-block; margin-left: 10px;">'+
'<input value="product" name="item_type" hidden>'+
'<a class="custom_complaint_detail" id="addProduct" title="Add Product">'+
'<i class="fa fa-plus" aria-hidden="true"></i>'+
'</a>'+
'</div>'+
'</td>' +
'<td hidden><input type="hidden" name="id" value=""></td>' +
if ($('#vehicle_name').val()) {
complaint = <?php echo json_encode($complaint) ?>;
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 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="text" class="form-control item-tax" name="item-tax[]" value="18" readonly /></td>' +
'<td><input hidden type="text" class="form-control item-amount1" name="amount[]" required/></td>' +
'<td><input hidden type="text" class="form-control total-tax-amount" readonly /></td>' +
'<td hidden><input type="hidden"></td>' +
'<td><div style="display: inline-block;">'+
'<center><i class="fa fa-trash remove-item"></i></center>'+
'</div>'+
'<div style="display: inline-block; margin-left: 10px;">'+
'<input value="product" name="item_type" hidden>'+
'<a class="custom_complaint_detail" id="addProduct" title="Add Product">'+
'<i class="fa fa-plus" aria-hidden="true"></i>'+
'</a>'+
'</div>'+
'</td>' +
'<td hidden><input type="hidden" name="id" value=""></td>' +
'</tr>';
newRow += '<tr class="custom_complaint_lb"><td hidden><input type="number" class="form-control labour_cost" name="labour_cost"></td><td style="padding-left: 40px !important;"><i class="fas fa-user-alt" style="font-size: 13px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i><input type="text" class="form-control labour_cost" value="Labour Cost"></td>' +
'<td hidden><input type="text" class="form-control rate-d-only" readonly /></td>' +
'<td><input type="text" class="form-control item-rate item-rate_cc" name="unit-price[]" value="" readonly/></td>' +
'<td><input type="number" class="form-control item-quantity" min="0" name="quantity[]" value="'+1+'" readonly /></td>' +
'<td><input type="text" class="form-control taxable-value item-tax item-tax_cc" name="item-tax[]" value="'+18+'" readonly /></td>' +
'<td><input type="text" class="form-control total-tax-amount" value="" readonly /></td>' +
'<td><input type="text" class="form-control item-amount lab_amt item-amount_cc" name="amount1[]" onblur="floatInput(event)" value="" required /></td>' +
'<td hidden></td>' +
'<td hidden></td>' +
'</tr>';
newRow += '<tr class="custom_complaint_lb"><td hidden><input type="number" class="form-control labour_cost" name="labour_cost"></td><td style="padding-left: 40px !important;"><i class="fas fa-user-alt" style="font-size: 13px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i><input type="text" class="form-control labour_cost" value="Labour Cost"></td>' +
'<td hidden><input type="text" class="form-control rate-d-only" readonly /></td>' +
'<td><input type="text" class="form-control item-rate item-rate_cc" name="unit-price[]" value="" readonly/></td>' +
'<td><input type="number" class="form-control item-quantity" min="0" name="quantity[]" value="'+1+'" readonly /></td>' +
'<td><input type="text" class="form-control taxable-value item-tax item-tax_cc" name="item-tax[]" value="'+18+'" readonly /></td>' +
'<td><input type="text" class="form-control total-tax-amount" value="" readonly /></td>' +
'<td><input type="text" class="form-control item-amount lab_amt item-amount_cc" name="amount1[]" value="" required /></td>' +
'<td hidden></td>' +
'<td hidden></td>' +
'</tr>';
$('#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 = <?php echo json_encode($os_data) ?>;
var newRow = '<tr class="os_class"><td hidden> <input type="text" class="form-control labour_cost" name="labour_cost"></td><td><select class="form-control book-select SelExample os" id="os_detail" name="os_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Outsource</option>';
os = <?php echo json_encode($os_data) ?>;
var newRow = '<tr class="os_class"><td hidden> <input type="text" class="form-control labour_cost" name="labour_cost"></td><td><select class="form-control book-select SelExample os" id="os_detail" name="os_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Outsource</option>';
for (var i = 0; i < os.length; i++)
{
var os_data = os[i];
if(!selected_os.includes(os_data.id))
for (var i = 0; i < os.length; i++)
{
newRow += '<option value="' + os_data.id + '">' + os_data.name + '</option>';
var os_data = os[i];
if(!selected_os.includes(os_data.id))
{
newRow += '<option value="' + os_data.id + '">' + os_data.name + '</option>';
}
}
}
newRow += '</select></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><input hidden type="number" class="form-control item-quantity" min="0" name="quantity[]" readonly/></td>' +
'<td><input hidden type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
'<td><input hidden type="text" class="form-control total-tax-amount" readonly /></td>' +
'<td><input hidden type="text" class="form-control item-amount1" name="amount[]"/></td>' +
'<td><div style="display: inline-block;">'+
'<center><i class="fa fa-trash remove-item"></i></center>'+
'</div>'+
'<div style="display: inline-block; margin-left: 10px;">'+
'<input value="product" name="item_type" hidden>'+
'<a class="complaint_detail" id="addProduct" title="Add Product">'+
'<i class="fa fa-plus" aria-hidden="true"></i>'+
'</a>'+
'</div>'+
'</td>' +
'<td hidden><input type="hidden" name="id"></td>' +
'</tr>';
$('#productItemTable tbody').append(newRow);
// initializeSelect2();
newRow += '</select></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><input hidden type="number" class="form-control item-quantity" min="0" name="quantity[]" readonly/></td>' +
'<td><input hidden type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
'<td><input hidden type="text" class="form-control total-tax-amount" readonly /></td>' +
'<td><input hidden type="text" class="form-control item-amount1" name="amount[]"/></td>' +
'<td><div style="display: inline-block;">'+
'<center><i class="fa fa-trash remove-item"></i></center>'+
'</div>'+
'<div style="display: inline-block; margin-left: 10px;">'+
'<input value="product" name="item_type" hidden>'+
'<a class="complaint_detail" id="addProduct" title="Add Product">'+
'<i class="fa fa-plus" aria-hidden="true"></i>'+
'</a>'+
'</div>'+
'</td>' +
'<td hidden><input type="hidden" name="id"></td>' +
'</tr>';
$('#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

View File

@ -36,6 +36,16 @@
<!-- Right bar overlay-->
<script>
function floatInput(event) {
let inputField = event.target;
let value = parseFloat(inputField.value);
if (!isNaN(value)) {
inputField.value = value.toFixed(2);
}
}
</script>
<!-- Vendor js -->
<script src="<?php echo base_url(); ?>public/assets/js/vendor.min.js"></script>

View File

@ -1,5 +1,16 @@
<?php include('layout/header.php'); ?>
<style>
.large-checkbox {
transform: scale(1.5); /* Adjust the scale value as needed */
-webkit-transform: scale(1.5); /* Safari and Chrome */
-moz-transform: scale(1.5); /* Firefox */
-ms-transform: scale(1.5); /* Internet Explorer */
-o-transform: scale(1.5); /* Opera */
margin: 10px; /* Adjust the margin as needed to avoid layout issues */
}
</style>
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
@ -179,12 +190,12 @@
<?php if(!isset($reorder)) { ?>
<td style="width:2%;">
<input type="hidden" name="selected_items[]" value="<?= (isset($purchasechild['is_selected']) && $purchasechild['is_selected'] == 1) ? 'checked' : 'unchecked' ?>"> <!-- Hidden input for unchecked checkboxes -->
<input type="checkbox" class="form-control-check-input" <?php echo (isset($purchasechild['is_selected']) && $purchasechild['is_selected'] == 1) ? 'checked' : ''; ?> >
<input type="checkbox" class="form-control-check-input received-product large-checkbox" <?php echo (isset($purchasechild['is_selected']) && $purchasechild['is_selected'] == 1) ? 'checked' : ''; ?> >
</td>
<td style="width:5%;">
<input type="number" class="form-control item-quantity" name="amount[]" value="<?= isset($purchasechild['amount']) ? $purchasechild['amount'] : '' ?>">
</td>
<?php } ?>
<?php }?>
<td hidden><input type="hidden" value="<?= isset($purchasechild['purchase_order_child_id']) ? $purchasechild['purchase_order_child_id'] : '' ?>"name="purchase_order_child_id[]"></td>
<td style="width:5%;">
<center><i class="fa fa-trash remove-item"></i></center>
@ -412,31 +423,34 @@ $(document).ready(function() {
// Event listener for "Add More Item" button
$('#addItem').click(function() {
// console.log(productarray);
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>';
if ($('#vendor_id').val() != 0) {
// console.log(productarray);
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>';
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 += '<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="number" class="form-control item-quantity" min="0" name="quantity[]"/></td>' +
'<td><center><i class="fa fa-trash remove-item"></i></center></td>' +
'</tr>';
newRow += '</select></td>' +
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" name="quantity[]"/></td>' +
'<td><center><i class="fa fa-trash remove-item"></i></center></td>' +
'</tr>';
$('#itemTable tbody').append(newRow);
initializeSelect2();
$('#itemTable tbody').append(newRow);
initializeSelect2();
}else{
}
});
// Event listener for removing item
@ -557,13 +571,31 @@ function initializeSelect2() {
</style>
<script>
// Assuming you have an edit button with an ID 'editButton'
$('#editaddbutton').click(function() {
// Enable the vendor dropdown
$('#vendor_id').prop('disabled', false);
$('#editaddbutton').click(function(event) {
if ($('#purchase_order_id').val()) {
$('#vendor_id').prop('disabled', false);
var isAnyChecked = false;
$('.received-product').each(function() {
if ($(this).is(':checked')) {
isAnyChecked = true;
return false;
}
});
var someCondition = !isAnyChecked;
if (someCondition) {
event.preventDefault();
toastr.warning("Please Check Received Product.");
}
}
});
</script>
@ -579,4 +611,5 @@ $('#editaddbutton').click(function() {
}
});
});
</script>

View File

@ -668,7 +668,7 @@ $(document).ready(function() {
console.log(productarray.length);
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 style="width:30%"><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++) {
var product = productarray[i];
@ -682,11 +682,11 @@ $(document).ready(function() {
}
newRow += '</select></td>' +
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" readonly /></td>' +
'<td style="width:12%;"><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: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 tax-amount" name="tax-amount[]" readonly /></td>' +
'<td style="width:12%;"><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>' +

View File

@ -65,7 +65,7 @@
<?php 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["product_name"]; ?>
<?= $value["product_name"] .'-'. $value['manufacturer_name']; ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
@ -261,7 +261,7 @@ $(document).ready(function() {
// Append new options
$('#productSelect').append('<option value>Select Product</option>');
$.each(response, function(index, product) {
$('#productSelect').append('<option value="' + product.product_id + '">' + product.product_name + '</option>');
$('#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