CHANGE_service_module:ss
This commit is contained in:
parent
e6f67575e1
commit
96ddbcad49
@ -87,7 +87,9 @@ class Jobcard extends BaseController
|
||||
// Using '&' to reference the original array element
|
||||
foreach ($servicedata as &$value) {
|
||||
$product_ids = json_decode($value['product_id'], true);
|
||||
$product = $JobcardProductModel->whereIn('job_card_product_id', $product_ids)->findAll();
|
||||
$product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname')
|
||||
->join('products', 'products.product_id = job_card_product.product_id')
|
||||
->whereIn('job_card_product.job_card_product_id', $product_ids)->findAll();
|
||||
$value['product'] = $product;
|
||||
}
|
||||
$data['editservicedata'] = $servicedata;
|
||||
@ -96,7 +98,9 @@ class Jobcard extends BaseController
|
||||
// Using '&' to reference the original array element
|
||||
foreach ($complaintdata as &$value) {
|
||||
$product_ids = json_decode($value['product_id'], true);
|
||||
$product = $JobcardProductModel->whereIn('job_card_product_id', $product_ids)->findAll();
|
||||
$product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname')
|
||||
->join('products', 'products.product_id = job_card_product.product_id')
|
||||
->whereIn('job_card_product_id', $product_ids)->findAll();
|
||||
$value['product'] = $product;
|
||||
}
|
||||
$data['editcomplaintdata'] = $complaintdata;
|
||||
@ -106,7 +110,9 @@ class Jobcard extends BaseController
|
||||
// Using '&' to reference the original array element
|
||||
foreach ($ccomplaintdata as &$value) {
|
||||
$product_ids = json_decode($value['product_id'], true);
|
||||
$product = $JobcardProductModel->whereIn('job_card_product_id', $product_ids)->findAll();
|
||||
$product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname')
|
||||
->join('products', 'products.product_id = job_card_product.product_id')
|
||||
->whereIn('job_card_product_id', $product_ids)->findAll();
|
||||
$value['product'] = $product;
|
||||
}
|
||||
$data['editccomplaintdata'] = $ccomplaintdata;
|
||||
@ -137,7 +143,7 @@ class Jobcard extends BaseController
|
||||
$data['make_model'] = $make_name['make'].' ' . $model_name['model_name'];
|
||||
// Encode the modelId before searching
|
||||
$encodedModelId = json_encode([$modelId]);
|
||||
|
||||
// echo $encodedModelId;die;
|
||||
// Load the ProductModel
|
||||
|
||||
|
||||
@ -147,6 +153,8 @@ class Jobcard extends BaseController
|
||||
->findAll();
|
||||
$data['product']=$product;
|
||||
|
||||
// echo json_encode($product);die;
|
||||
|
||||
// Load the ServiceModel
|
||||
$ServiceModel = new ServiceModel();
|
||||
$encodedMakeId = json_encode([$makeId]);
|
||||
@ -231,7 +239,8 @@ class Jobcard extends BaseController
|
||||
$service['qty'] = $item->quality;
|
||||
$service['tax'] = $item->tax;
|
||||
$service['amount'] = $item->amount;
|
||||
if($item->id == '') {
|
||||
// echo empty($item->id);die;
|
||||
if(empty($item->id)) {
|
||||
$JobcardServiceModel->insert($service);
|
||||
$service_id = $JobcardServiceModel->getInsertID();
|
||||
}
|
||||
@ -248,13 +257,13 @@ class Jobcard extends BaseController
|
||||
$product['qty'] = $pt->qty;
|
||||
$product['tax'] = $pt->tax;
|
||||
$product['amount'] = $pt->amount;
|
||||
if($pt->id == '') {
|
||||
if(empty($pt->id)) {
|
||||
$JobcardProductModel->insert($product);
|
||||
$job_card_product_id = $JobcardProductModel->getInsertID();
|
||||
}
|
||||
else {
|
||||
$JobcardProductModel->update($pt->id, $service);
|
||||
$job_card_product_id = $item->id;
|
||||
$JobcardProductModel->update($pt->id, $product);
|
||||
$job_card_product_id = $pt->id;
|
||||
}
|
||||
array_push($id, $job_card_product_id);
|
||||
}
|
||||
@ -274,7 +283,7 @@ class Jobcard extends BaseController
|
||||
$service['qty'] = $item->quality;
|
||||
$service['tax'] = $item->tax;
|
||||
$service['amount'] = $item->amount;
|
||||
if($item->id == '') {
|
||||
if(empty($item->id)) {
|
||||
$JobcardComplaintModel->insert($service);
|
||||
$complaint_id = $JobcardComplaintModel->getInsertID();
|
||||
}
|
||||
@ -291,13 +300,13 @@ class Jobcard extends BaseController
|
||||
$product['qty'] = $pt->qty;
|
||||
$product['tax'] = $pt->tax;
|
||||
$product['amount'] = $pt->amount;
|
||||
if($pt->id == '') {
|
||||
if(empty($pt->id)) {
|
||||
$JobcardProductModel->insert($product);
|
||||
$job_card_product_id = $JobcardProductModel->getInsertID();
|
||||
}
|
||||
else {
|
||||
$JobcardProductModel->update($pt->id, $service);
|
||||
$job_card_product_id = $item->id;
|
||||
$JobcardProductModel->update($pt->id, $product);
|
||||
$job_card_product_id = $pt->id;
|
||||
}
|
||||
array_push($id, $job_card_product_id);
|
||||
}
|
||||
@ -317,7 +326,7 @@ class Jobcard extends BaseController
|
||||
$service['qty'] = $item->quality;
|
||||
$service['tax'] = $item->tax;
|
||||
$service['amount'] = $item->amount;
|
||||
if($item->id == '') {
|
||||
if(empty($item->id)) {
|
||||
$JobcardCustomComplaintModel->insert($service);
|
||||
$cc_complaint_id = $JobcardCustomComplaintModel->getInsertID();
|
||||
}
|
||||
@ -334,13 +343,13 @@ class Jobcard extends BaseController
|
||||
$product['qty'] = $pt->qty;
|
||||
$product['tax'] = $pt->tax;
|
||||
$product['amount'] = $pt->amount;
|
||||
if($pt->id == '') {
|
||||
if(empty($pt->id)) {
|
||||
$JobcardProductModel->insert($product);
|
||||
$job_card_product_id = $JobcardProductModel->getInsertID();
|
||||
}
|
||||
else {
|
||||
$JobcardProductModel->update($pt->id, $service);
|
||||
$job_card_product_id = $item->id;
|
||||
$JobcardProductModel->update($pt->id, $product);
|
||||
$job_card_product_id = $pt->id;
|
||||
}
|
||||
array_push($id, $job_card_product_id);
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ class Service extends BaseController
|
||||
{
|
||||
|
||||
$ServiceModel = new ServiceModel();
|
||||
$services = $ServiceModel->where('branch_id',$this->session->get('logged_user_business_id'))->findAll();
|
||||
$services = $ServiceModel->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
||||
|
||||
foreach ($services as &$service) {
|
||||
// Convert JSON strings to arrays
|
||||
@ -169,7 +169,7 @@ class Service extends BaseController
|
||||
|
||||
$ServiceModel->update($service_id, $data);
|
||||
} else {
|
||||
$data['branch_id'] = $this->session->get('logged_user_business_id');
|
||||
$data['branch_id'] = $this->session->get('logged_user_branch_id');
|
||||
$ServiceModel->insert($data);
|
||||
}
|
||||
|
||||
|
||||
@ -328,7 +328,7 @@
|
||||
/***** APPEND DATA ONLY EDIT ******/
|
||||
$(document).ready(async function() {
|
||||
/** SERVICE */
|
||||
var edit_service_data = <?php echo isset($editservicedata) ? json_encode($editservicedata) : '' ?>;
|
||||
var edit_service_data = <?php echo isset($editservicedata) ? json_encode($editservicedata) : 0 ?>;
|
||||
// console.log(edit_service_data);
|
||||
if(edit_service_data.length > 0) {
|
||||
for (const value of edit_service_data) {
|
||||
@ -365,7 +365,7 @@ $(document).ready(async function() {
|
||||
}
|
||||
|
||||
/** COMPLAINT */
|
||||
var edit_complaint_data = <?php echo isset($editcomplaintdata) ? json_encode($editcomplaintdata) : '' ?>;
|
||||
var edit_complaint_data = <?php echo isset($editcomplaintdata) ? json_encode($editcomplaintdata) : 0 ?>;
|
||||
if(edit_complaint_data.length > 0) {
|
||||
for (const value of edit_complaint_data) {
|
||||
complaint = <?php echo json_encode($complaint) ?>;
|
||||
@ -405,7 +405,7 @@ $(document).ready(async function() {
|
||||
}
|
||||
|
||||
/** CUSTOM COMPLAINT */
|
||||
var edit_ccomplaint_data = <?php echo isset($editcomplaintdata) ? json_encode($editccomplaintdata) : '' ?>;
|
||||
var edit_ccomplaint_data = <?php echo isset($editcomplaintdata) ? json_encode($editccomplaintdata) : 0 ?>;
|
||||
console.log(edit_ccomplaint_data);
|
||||
if(edit_ccomplaint_data.length > 0) {
|
||||
for (const value of edit_ccomplaint_data) {
|
||||
@ -443,7 +443,7 @@ $(document).ready(async function() {
|
||||
<td style="padding-left: 40px !important;"><i class="fa fa-caret-right" style="font-size: 20px;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.name + '</option>';
|
||||
newRow += '<option value="' + product.product_id + '" selected>' + product.pname + '</option>';
|
||||
newRow += '</select></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="text" class="form-control item-rate" name="unit-price[]" value="' + product.amount + '" readonly /></td>' +
|
||||
@ -493,7 +493,7 @@ $(document).ready(async function() {
|
||||
vehicle_id: vehicleId
|
||||
},
|
||||
success: function(response) {
|
||||
// console.log(response);
|
||||
console.log(response);
|
||||
productarray = response.product;
|
||||
makeAndModel = response.makeName+' '+response.modelName;
|
||||
$('#makeAndModel').val(makeAndModel);
|
||||
@ -911,6 +911,11 @@ $(document).ready(async function() {
|
||||
|
||||
// Event listener for "Add More Item" button
|
||||
$(document).on('click', '#addProduct', function() {
|
||||
console.log(productarray.length);
|
||||
if(productarray.length == 0) {
|
||||
productarray = <?php echo json_encode($product) ?>;
|
||||
console.log(productarray);
|
||||
}
|
||||
|
||||
var newRow = '<tr class="complaint_product_'+$(this).closest('tr').data('select2Id')+'"><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-caret-right" style="font-size: 20px;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;"><option value="">Select a Product</option>';
|
||||
|
||||
@ -938,7 +943,6 @@ $(document).ready(async function() {
|
||||
});
|
||||
|
||||
$('#addService').click(function() {
|
||||
alert('dzfaf')
|
||||
servicearray = <?php echo isset($service_1) ? json_encode($service_1) : json_encode($service) ?>;
|
||||
// console.log(servicearray);
|
||||
var newRow = '<tr class="service_class"><td hidden style="width:10%;"> <input type="number" 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>';
|
||||
|
||||
@ -320,16 +320,16 @@ document.getElementById('category').addEventListener('change', function() {
|
||||
$('#productCost').val(parseInt(sum));
|
||||
// console.log(sum);
|
||||
|
||||
// labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val());
|
||||
add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val()) //+ labour_cost;
|
||||
labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val());
|
||||
add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val()) + labour_cost;
|
||||
console.log("New value of #serviceCost:", add);
|
||||
|
||||
$('#price').val(add);
|
||||
}
|
||||
else if(this.value == '' ) {
|
||||
$('#productCost').val(0);
|
||||
// labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val());
|
||||
add = parseInt($('#productCost').val()) + parseInt($('#serviceCost').val()) //+ labour_cost;
|
||||
labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val());
|
||||
add = parseInt($('#productCost').val()) + parseInt($('#serviceCost').val()) + labour_cost;
|
||||
console.log("New value of #serviceCost:", add);
|
||||
|
||||
$('#price').val(add);
|
||||
@ -341,7 +341,7 @@ document.getElementById('category').addEventListener('change', function() {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
if (data[i].product_id === productId) {
|
||||
// Return the purchase_cost if the product_id matches
|
||||
return data[i].purchase_cost;
|
||||
return data[i].unit_price;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -392,13 +392,13 @@ document.getElementById('category').addEventListener('change', function() {
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- <script>
|
||||
<script>
|
||||
$('#labour_cost').on('keyup change', function() {
|
||||
var newValue = ($(this).val() == '') ? 0 : $(this).val();
|
||||
add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val()) + parseInt(newValue);
|
||||
$('#price').val(add);
|
||||
});
|
||||
</script> -->
|
||||
</script>
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user