CHANGE_jobcard_module_discount_calculation:ss
This commit is contained in:
parent
bc24ba9e45
commit
2fb965e183
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Controllers;
|
||||
use App\Models\BusinessModel;
|
||||
use App\Models\BranchModel;
|
||||
use App\Models\JobcardModel;
|
||||
use App\Models\JobcardComplaintModel;
|
||||
use App\Models\JobcardCustomComplaintModel;
|
||||
@ -27,6 +28,7 @@ class Jobcard extends BaseController
|
||||
public $BikemakeModel;
|
||||
public $BusinessModel;
|
||||
public $JobcardModel;
|
||||
public $BranchModel;
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -35,6 +37,7 @@ class Jobcard extends BaseController
|
||||
$this->BikemakeModel = new BikemakeModel();
|
||||
$this->BusinessModel = new BusinessModel();
|
||||
$this->JobcardModel = new JobcardModel();
|
||||
$this->BranchModel = new BranchModel();
|
||||
|
||||
}
|
||||
|
||||
@ -56,9 +59,20 @@ class Jobcard extends BaseController
|
||||
$data['vehicle'] = $this->JobcardModel->get_jobcard_vehicle_details($job_card_id);
|
||||
$bus_id = $this->session->get('logged_user_business_id');
|
||||
$data['job_card'] = $this->JobcardModel->where('job_card_id',$job_card_id)->findAll();
|
||||
$data['company_address'] = $this->BusinessModel->where('business_id', $bus_id)->where('isactive', 1)->findAll();
|
||||
$data['company_address'] = $this->BranchModel->where('branch_id', $this->session->get('logged_user_branch_id'))->where('business_id', $bus_id)->where('isactive', 1)->findAll();
|
||||
// echo json_encode($data['company_address']);die;
|
||||
$productdata = $this->JobcardModel->get_jobcard_products_details($job_card_id);
|
||||
// echo json_encode($productdata);die;
|
||||
|
||||
if($data['job_card'][0]['inv_no'] == '')
|
||||
{
|
||||
/** GENERATE INV NO */
|
||||
$uniqueId = sprintf('%06d', mt_rand(0, 999999));
|
||||
$date = date('Ymdhms');
|
||||
$invoiceNumber = 'INV' . '-' . $date . $uniqueId;
|
||||
$this->JobcardModel->update($job_card_id,['inv_no' => $invoiceNumber]);
|
||||
$data['job_card'][0]['inv_no'] = $invoiceNumber;
|
||||
}
|
||||
|
||||
$servicedata = $this->JobcardModel->get_jobcard_service($job_card_id);
|
||||
$complaintdata = $this->JobcardModel->get_jobcard_complaint($job_card_id);
|
||||
@ -70,7 +84,7 @@ class Jobcard extends BaseController
|
||||
// Calculate total amount and total tax
|
||||
foreach ($labourcost as $product) {
|
||||
$totalAmount += $product["labour_amount"];
|
||||
$totalTax += $product["labour_amount"] * ($product["tax"] / 100);
|
||||
$totalTax = $product["tax"];
|
||||
}
|
||||
|
||||
// Calculate total
|
||||
@ -115,7 +129,7 @@ class Jobcard extends BaseController
|
||||
|
||||
// Generate the PDF content (HTML) with data
|
||||
$html = view('invoice_pdf_template_jobcard', $data);
|
||||
|
||||
echo $html;die;
|
||||
// Load HTML into the mPDF instance
|
||||
$mpdf->WriteHTML($html);
|
||||
|
||||
@ -305,6 +319,7 @@ class Jobcard extends BaseController
|
||||
'store_item_issued'=> $this->request->getPost('store_item_issued'),
|
||||
'subtotal'=> $this->request->getPost('sub_total'),
|
||||
'tax'=> $this->request->getPost('invoicetax'),
|
||||
'discount'=> ($this->request->getPost('discount')) == '' ? 0 : $this->request->getPost('discount'),
|
||||
'total'=> $this->request->getPost('grand_total'),
|
||||
'isactive' => 1
|
||||
];
|
||||
@ -425,16 +440,28 @@ class Jobcard extends BaseController
|
||||
|
||||
public function delete_items($delArr)
|
||||
{
|
||||
$JobcardProductModel = new JobcardProductModel();
|
||||
$JobcardServiceModel = new JobcardServiceModel();
|
||||
$JobcardComplaintModel = new JobcardComplaintModel();
|
||||
$JobcardCustomComplaintModel = new JobcardCustomComplaintModel();
|
||||
$data = json_decode($delArr);
|
||||
|
||||
$product_data = $data[0]->product;
|
||||
if(!empty($product_data)) {
|
||||
foreach ($product_data as $item) {
|
||||
$conditions = [ 'job_card_product_id' => $item ];
|
||||
// $product_deleted_data = $JobcardProductModel->where($conditions)->findAll();
|
||||
// $this->product_delete($service_deleted_data[0]['product_id']);
|
||||
$JobcardProductModel->where($conditions)->delete();
|
||||
}
|
||||
}
|
||||
|
||||
$service_data = $data[0]->service;
|
||||
if(!empty($service_data)) {
|
||||
foreach ($service_data as $item) {
|
||||
$conditions = [ 'job_card_service_id' => $item ];
|
||||
$service_deleted_data = $JobcardServiceModel->where($conditions)->findAll();
|
||||
if(isset($service_deleted_data[0]['product_id']))
|
||||
$this->product_delete($service_deleted_data[0]['product_id']);
|
||||
$JobcardServiceModel->where($conditions)->delete();
|
||||
}
|
||||
@ -445,6 +472,7 @@ class Jobcard extends BaseController
|
||||
foreach ($complaint_data as $item) {
|
||||
$conditions = [ 'job_card_complaint_id' => $item ];
|
||||
$complaint_deleted_data = $JobcardComplaintModel->where($conditions)->findAll();
|
||||
if(isset($complaint_deleted_data[0]['product_id']))
|
||||
$this->product_delete($complaint_deleted_data[0]['product_id']);
|
||||
$JobcardComplaintModel->where($conditions)->delete();
|
||||
}
|
||||
@ -455,6 +483,7 @@ class Jobcard extends BaseController
|
||||
foreach ($ccomplaint_data as $item) {
|
||||
$conditions = [ 'job_card_cc_id' => $item ];
|
||||
$cc_deleted_data = $JobcardCustomComplaintModel->where($conditions)->findAll();
|
||||
if(isset($cc_deleted_data[0]['product_id']))
|
||||
$this->product_delete($cc_deleted_data[0]['product_id']);
|
||||
$JobcardCustomComplaintModel->where($conditions)->delete();
|
||||
}
|
||||
|
||||
@ -5,10 +5,10 @@ class JobcardModel extends Model
|
||||
{
|
||||
protected $table = 'job_card';
|
||||
protected $primaryKey = 'job_card_id';
|
||||
protected $allowedFields = ['job_card_id','vehicle_id','branch_id',
|
||||
protected $allowedFields = ['job_card_id','inv_no','vehicle_id','branch_id',
|
||||
'order_number','client_mobile_no','client_name',
|
||||
'billing_address','billing_city','billing_state','billing_country',
|
||||
'billing_postal_code','status','assigned_to', 'store_item_issued','subtotal','tax','total','isactive'];
|
||||
'billing_postal_code','status','assigned_to', 'store_item_issued','subtotal','tax', 'discount','total','isactive'];
|
||||
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ class JobcardModel extends Model
|
||||
|
||||
public function get_jobcard_service($job_id)
|
||||
{
|
||||
$this->select('job_card.*, job_card_service.*, services.service_name as product_name, services.labour_cost as labour_amount');
|
||||
$this->select('job_card.*, job_card_service.*, services.service_name as product_name, job_card_service.labour_cost as labour_amount');
|
||||
$this->join('job_card_service', 'job_card_service.job_card_id = job_card.job_card_id');
|
||||
$this->join('services', 'services.service_id = job_card_service.service_id');
|
||||
$this->where('job_card.isactive', 1);
|
||||
@ -90,7 +90,7 @@ class JobcardModel extends Model
|
||||
|
||||
public function get_jobcard_complaint($job_id)
|
||||
{
|
||||
$this->select('job_card.*, job_card_complaint.*, complaints.name as product_name, complaints.labour_charge as labour_amount');
|
||||
$this->select('job_card.*, job_card_complaint.*, complaints.name as product_name, job_card_complaint.labour_cost as labour_amount');
|
||||
$this->join('job_card_complaint', 'job_card_complaint.job_card_id = job_card.job_card_id');
|
||||
$this->join('complaints', 'complaints.complaint_id = job_card_complaint.complaint_id');
|
||||
$this->where('job_card.isactive', 1);
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
table.invoice-related-table {width: 100%;border-collapse: collapse;}
|
||||
table.invoice-related-table th,table.invoice-related-table td {border: none;padding: 8px;text-align: left;}
|
||||
table.invoice-related-table th {background-color: #DAC2AD;font-weight: bold;}
|
||||
table.invoice-related-table thead tr th{border: 0.5px solid black;"}
|
||||
table.invoice-related-table thead tr{border: 0.5px solid black;"}
|
||||
table.invoice-related-table thead tr th{border: 0.5px solid black;}
|
||||
table.invoice-related-table thead tr{border: 0.5px solid black;}
|
||||
.business-stamp, .terms {text-align: center;margin-top: 20px;}
|
||||
.subtotal-table {width: 100%;margin-top: 20px;}
|
||||
.subtotal-table table {width: 100%;border-collapse: collapse;border: 1px solid black;}
|
||||
|
||||
@ -154,7 +154,7 @@ p {
|
||||
<p><b>THE MECHANIC</b><br>
|
||||
<?= $value['address'] ?>,<br>
|
||||
<?= '<b>GSTNO: </b>'.$value['gstno'] ?><br>
|
||||
<?= '<b>State Name: </b>'.$value['state'].', code'.$value['code'] ?><br>
|
||||
<?= '<b>State Name: </b>'.$value['state'].', code'.$value['state_code'] ?><br>
|
||||
<?= '<b>Contact: </b>'.$value['postal_code'] ?><br>
|
||||
<?= '<b>Email: </b>'.$value['email'] ?></p>
|
||||
<br>
|
||||
@ -175,7 +175,7 @@ p {
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Invoice No.</td>
|
||||
<td>1657</td>
|
||||
<td><?= $job_card[0]['inv_no'] ?></td>
|
||||
</tr>
|
||||
<tr style="border: 1px solid black;">
|
||||
<td>Bike Name</td>
|
||||
@ -245,17 +245,17 @@ p {
|
||||
<td style="border: 0.5px solid black;"><?= $item['qty'] ?></td>
|
||||
<td style="border: 0.5px solid black;">nos</td>
|
||||
<td style="border: 0.5px solid black;"><?= $item['tax'] ?>%</td>
|
||||
<td style="border: 0.5px solid black;"><?php echo isset($item['custom_tax']) ? $item['custom_tax'] : ($item['amount'] * ($item['tax'] / 2) / 100) ?></td>
|
||||
<td style="border: 0.5px solid black;"><?php echo isset($item['custom_tax']) ? $item['custom_tax'] : ($item['amount'] * ($item['tax'] / 2) / 100) ?></td>
|
||||
<td style="border: 0.5px solid black;"><?php echo isset($item['custom_tax']) ? $item['custom_tax'] : ($item['amount'] * $item['tax'] / 100) ?></td>
|
||||
<td style="border: 0.5px solid black;"><?php echo isset($item['custom_total']) ? $item['custom_total'] : ($item['amount'] + ($item['amount'] * $item['tax'] / 100) ) ?></td>
|
||||
<td style="border: 0.5px solid black;"><?php echo isset($item['custom_tax']) ? $item['custom_tax'] / 2: ($item['amount'] * ($item['tax'] / 2) / 100) ?></td>
|
||||
<td style="border: 0.5px solid black;"><?php echo isset($item['custom_tax']) ? $item['custom_tax'] / 2: ($item['amount'] * ($item['tax'] / 2) / 100) ?></td>
|
||||
<td style="border: 0.5px solid black;"><?php echo isset($item['custom_tax']) ? round(($item['custom_amount'] * $item['tax'] / 100)) : ($item['amount'] * $item['tax'] / 100) ?></td>
|
||||
<td style="border: 0.5px solid black;"><?php echo isset($item['custom_total']) ? round($item['custom_amount'] + ($item['custom_amount'] * $item['tax'] / 100)) : ($item['amount'] + ($item['amount'] * $item['tax'] / 100) ) ?></td>
|
||||
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td colspan="6" style="border-top: 0.5px solid black;border-left: 0.5px solid black;"></td>
|
||||
<td colspan="3" style="text-align:center;border: 0.5px solid black;">Total Amount with Tax</td>
|
||||
<td style="border: 0.5px solid black;"></td>
|
||||
<td style="border: 0.5px solid black;"><?= $job_card[0]['subtotal'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6" style="border-left: 0.5px solid black;"></td>
|
||||
|
||||
@ -96,14 +96,14 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<?php if(isset($workers) && $jobs['status'] == 'Paid') { ?>
|
||||
<?php if(isset($workers) && $jobs['status'] == 'Created') { ?>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="inputPassword4" class="col-form-label">Assign To</label>
|
||||
<select class="form-control SelExample" name="assigned_to[]" id="assigned_to" required multiple>
|
||||
<?= isset($jobs['assigned_to']) ? '' : '<option value="">Select a Make</option>' ?>
|
||||
<?php foreach ($workers as $value) : ?>
|
||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||
<option value="<?= $value["user_id"] ?>" <?= isset($jobs['assigned_to']) && in_array($value["user_id"], json_decode($jobs['assigned_to'])) ? 'selected' : '' ?>>
|
||||
<option value="<?= $value["user_id"] ?>" <?= isset($jobs['assigned_to']) && is_array(json_decode($jobs['assigned_to'])) && in_array($value["user_id"], json_decode($jobs['assigned_to'])) ? 'selected' : ''; ?>>
|
||||
<?= $value["name"]; ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
@ -132,9 +132,11 @@
|
||||
<th hidden></th>
|
||||
<th>Item Details</th>
|
||||
<th>Rate</th>
|
||||
<th hidden>Rate</th>
|
||||
<th hidden></th>
|
||||
<th>Qty</th>
|
||||
<th>Tax (%)</th>
|
||||
<th>Tax Amount</th>
|
||||
<th>Amount</th>
|
||||
<th style="width: 10px;">Action</th>
|
||||
<th hidden></th>
|
||||
@ -161,13 +163,16 @@
|
||||
<div class="offset-md-7 col-md-5 card">
|
||||
<div class="card-body">
|
||||
<h4>Calculation</h4>
|
||||
<!-- <div class="form-group">
|
||||
<label for="invoicetax">Discount (Amount)<span id=""></span></label>
|
||||
<input type="text" class="form-control" id="discount_amt" name="discount" value="<?= isset($sales['discount']) ? $sales['discount'] : 0 ?>">
|
||||
</div> -->
|
||||
<div class="form-group">
|
||||
<label for="subtotal">Subtotal</label>
|
||||
<input type="text" class="form-control" id="subtotal" name="sub_total" value="<?= isset($sales['subtotal']) ? $sales['subtotal'] : '' ?>"readonly >
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="invoicetax">Tax Amount<span id=""></span></label>
|
||||
|
||||
<input type="text" class="form-control" id="invoicetax" name="invoicetax" readonly value="<?= isset($sales['tax']) ? $sales['tax'] : '' ?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@ -325,9 +330,11 @@ $(document).ready(async function() {
|
||||
|
||||
|
||||
newRow += '</select></td>' +
|
||||
'<td style="width:10%;"><input hidden type="text" class="form-control item-rate1" value="'+value.amount+'" name="unit-price[]" readonly /></td>' +
|
||||
'<td style="width:10%;"><input hidden type="text" class="form-control rate-d-only" value="'+value.amount+'" readonly /></td>' +
|
||||
'<td style="width:10%;" hidden><input hidden type="text" class="form-control item-rate1" value="'+value.amount+'" name="unit-price[]" readonly /></td>' +
|
||||
'<td style="width:10%;"><input hidden type="number" class="form-control item-quantity" min="0" value="'+value.qty+'" name="quantity[]" readonly/></td>' +
|
||||
'<td style="width:8%;"><input hidden type="text" class="form-control item-tax" value="'+value.tax+'" name="item-tax[]" readonly /></td>' +
|
||||
'<td style="width:8%;"><input hidden type="text" class="form-control total-tax-amount" readonly /></td>' +
|
||||
'<td style="width:12%;"><input hidden type="text" class="form-control item-amount1" value="'+value.amount+'" name="amount[]"/></td>' +
|
||||
'<td><center><i class="fa fa-trash remove-item"></i></center><input value="service" name="item_type" hidden></td>' +
|
||||
'<td hidden><input name="id" value="'+value.job_card_service_id+'"></td>' +
|
||||
@ -358,9 +365,11 @@ $(document).ready(async function() {
|
||||
}
|
||||
|
||||
newRow += '</select></td>' +
|
||||
'<td style="width:10%;"><input hidden type="text" class="form-control item-rate1" value="'+value.amount+'" name="unit-price[]" readonly /></td>' +
|
||||
'<td style="width:10%;"><input hidden type="text" class="form-control rate-d-only" value="'+value.amount+'" readonly /></td>' +
|
||||
'<td style="width:10%;" hidden><input hidden type="text" class="form-control item-rate1" value="'+value.amount+'" name="unit-price[]" readonly /></td>' +
|
||||
'<td style="width:10%;"><input hidden type="number" class="form-control item-quantity" min="0" value="'+value.qty+'" name="quantity[]" readonly/></td>' +
|
||||
'<td style="width:8%;"><input hidden type="text" class="form-control item-tax" value="'+value.tax+'" name="item-tax[]" readonly /></td>' +
|
||||
'<td style="width:8%;"><input hidden type="text" class="form-control total-tax-amount" readonly /></td>' +
|
||||
'<td style="width:12%;"><input hidden type="text" class="form-control item-amount1" value="'+value.amount+'" name="amount[]"/></td>' +
|
||||
'<td><div style="display: inline-block;">'+
|
||||
'<center><i class="fa fa-trash remove-item"></i></center>'+
|
||||
@ -389,9 +398,11 @@ $(document).ready(async function() {
|
||||
if(edit_ccomplaint_data.length > 0) {
|
||||
for (const value of edit_ccomplaint_data) {
|
||||
var newRow = '<tr class="custom_complaint_class"><td hidden style="width:10%;"> <input type="number" class="form-control labour_cost" name="labour_cost" value="'+value.labour_cost+'"></td><td><textarea class="form-control custom-comp" id="custom_complaint_detail" rows="5">'+value.name+'</textarea></td>' +
|
||||
'<td style="width:10%;"><input hidden type="text" class="form-control item-rate1" value="'+value.amount+'" name="unit-price[]" /></td>' +
|
||||
'<td style="width:10%;"><input hidden type="text" class="form-control rate-d-only" value="'+value.amount+'" readonly /></td>' +
|
||||
'<td style="width:10%;" hidden><input hidden type="text" class="form-control item-rate1" value="'+value.amount+'" name="unit-price[]" /></td>' +
|
||||
'<td style="width:10%;"><input hidden type="number" class="form-control item-quantity" min="0" value="'+value.qty+'" name="quantity[]" readonly/></td>' +
|
||||
'<td style="width:8%;"><input hidden type="text" class="form-control item-tax" value="'+value.tax+'" name="item-tax[]" /></td>' +
|
||||
'<td style="width:8%;"><input hidden type="text" class="form-control total-tax-amount" readonly /></td>' +
|
||||
'<td style="width:12%;"><input hidden type="text" class="form-control item-amount1" value="'+value.amount+'" name="amount[]"/></td>' +
|
||||
'<td><div style="display: inline-block;">'+
|
||||
'<center><i class="fa fa-trash remove-item"></i></center>'+
|
||||
@ -415,13 +426,16 @@ $(document).ready(async function() {
|
||||
}
|
||||
}
|
||||
|
||||
function editlabourcost(data,cls) {
|
||||
function editlabourcost(data,cls) {
|
||||
total_wih_tax = parseInt(data.labour_cost) + (parseInt(data.labour_cost) * (data.tax / 100));
|
||||
total_tax_amt = total_wih_tax - parseInt(data.labour_cost);
|
||||
var newRow = '<tr class="'+cls+'"><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><input type="text" class="form-control labour_cost" value="Labour Cost"></td>' +
|
||||
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" value="'+data.labour_cost+'" /></td>' +
|
||||
'<td style="width:10%;"><input type="number" class="form-control item-quantity-'+cls+' item-quantity" min="0" name="quantity[]" value="'+1+'" /></td>' +
|
||||
'<td style="width:8%;"><input type="text" class="form-control item-tax" name="item-tax[]" value="'+data.tax+'" /></td>' +
|
||||
'<td style="width:12%;"><input type="text" class="form-control item-amount" name="amount[]" value="' + total_wih_tax + '"/></td>' +
|
||||
'<td style="width:10%;"><input type="text" class="form-control rate-d-only" value="'+data.labour_cost+'" readonly /></td>' +
|
||||
'<td style="width:10%;" hidden><input hidden type="text" class="form-control item-rate" name="unit-price[]" value="'+data.labour_cost +'" /></td>' +
|
||||
'<td style="width:10%;"><input type="number" class="form-control item-quantity-'+cls+' item-quantity" min="0" name="quantity[]" value="1" readonly /></td>' +
|
||||
'<td style="width:8%;"><input type="text" class="form-control taxable-value item-tax" name="item-tax[]" value="'+data.tax+'" readonly /></td>' +
|
||||
'<td style="width:8%;"><input type="text" class="form-control total-tax-amount" value="'+Math.round(total_tax_amt)+'" readonly /></td>' +
|
||||
'<td style="width:12%;"><input type="text" class="form-control item-amount" name="amount[]" value="' + Math.round(total_wih_tax) + '" /></td>' +
|
||||
'<td hidden></td>' +
|
||||
'<td hidden></td>' +
|
||||
'</tr>';
|
||||
@ -434,18 +448,22 @@ $(document).ready(async function() {
|
||||
function edit_product_data(products) {
|
||||
|
||||
for (const product of products) {
|
||||
total_wih_tax = parseInt(product.amount) + (parseInt(product.amount) * (product.tax / 100));
|
||||
total_wih_tax =( parseInt(product.amount) + (parseInt(product.amount) * (product.tax / 100)) )* product.qty;
|
||||
console.log(total_wih_tax);
|
||||
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-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.pname + '</option>';
|
||||
newRow += '</select></td>' +
|
||||
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" value="' + product.amount + '" readonly /></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:8%;"> <input type="text" class="form-control item-tax" name="item-tax[]" value="' + product.tax + '" readonly /></td>' +
|
||||
'<td style="width:12%;"><input type="text" class="form-control item-amount" name="amount[]" value="' + total_wih_tax + '" readonly/></td>' +
|
||||
'<td hidden><input type="hidden"></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>' +
|
||||
'<td><center><i class="fa fa-trash remove-item" id="remove-item"></i></center><input value="product" name="item_type" hidden></td>' +
|
||||
'<td hidden><input type="hidden" name="id" value="'+product.job_card_product_id+'"></td>' +
|
||||
'</tr>';
|
||||
|
||||
@ -553,6 +571,67 @@ $(document).ready(async function() {
|
||||
});
|
||||
|
||||
$(document).on('keyup change', '.item-amount', function() {
|
||||
amount = $(this).val();
|
||||
tax = $(this).closest('tr').find('.item-tax').val();
|
||||
actual_amount = Number(amount) / (1 + (Number(tax)/100));
|
||||
actual_amount = Math.round(actual_amount)
|
||||
className = $(this).closest('tr').attr('class');
|
||||
if(className == 'service_lb') {
|
||||
previousRow = $(this).closest('tr').prevAll(".service_class").first();
|
||||
|
||||
labour_rate = previousRow.find('.labour_cost');
|
||||
labour_rate.val(actual_amount);
|
||||
|
||||
item_rate = previousRow.find('.item-rate1');
|
||||
item_rate.val(actual_amount);
|
||||
|
||||
item_rate = $(this).closest('tr').find('.item-rate');
|
||||
item_rate.val(actual_amount);
|
||||
|
||||
tax_amount = amount - actual_amount;
|
||||
tax_rate = $(this).closest('tr').find('.total-tax-amount');
|
||||
tax_rate.val(Math.round(tax_amount));
|
||||
|
||||
display_rate = $(this).closest('tr').find('.rate-d-only');
|
||||
display_rate.val(actual_amount);
|
||||
}
|
||||
else if(className == 'complaint_lb') {
|
||||
previousRow = $(this).closest('tr').prevAll(".complaint_class").first();
|
||||
|
||||
labour_rate = previousRow.find('.labour_cost');
|
||||
labour_rate.val(actual_amount);
|
||||
|
||||
item_rate = previousRow.find('.item-rate1');
|
||||
item_rate.val(actual_amount);
|
||||
|
||||
item_rate = $(this).closest('tr').find('.item-rate');
|
||||
item_rate.val(actual_amount);
|
||||
|
||||
tax_amount = amount - actual_amount;
|
||||
tax_rate = $(this).closest('tr').find('.total-tax-amount');
|
||||
tax_rate.val(Math.round(tax_amount));
|
||||
|
||||
display_rate = $(this).closest('tr').find('.rate-d-only');
|
||||
display_rate.val(actual_amount);
|
||||
}
|
||||
else if(className == 'custom_complaint_lb') {
|
||||
previousRow = $(this).closest('tr').prevAll(".custom_complaint_class").first();
|
||||
labour_rate = previousRow.find('.labour_cost');
|
||||
labour_rate.val(actual_amount);
|
||||
|
||||
item_rate = previousRow.find('.item-rate1');
|
||||
item_rate.val(actual_amount);
|
||||
|
||||
item_rate = $(this).closest('tr').find('.item-rate');
|
||||
item_rate.val(actual_amount);
|
||||
|
||||
tax_amount = amount - actual_amount;
|
||||
tax_rate = $(this).closest('tr').find('.total-tax-amount');
|
||||
tax_rate.val(Math.round(tax_amount));
|
||||
|
||||
display_rate = $(this).closest('tr').find('.rate-d-only');
|
||||
display_rate.val(actual_amount);
|
||||
}
|
||||
// Calculate amount and update amount input field
|
||||
updateCalculations();
|
||||
});
|
||||
@ -572,10 +651,10 @@ $(document).ready(async function() {
|
||||
tableRows.forEach(function(row) {
|
||||
var firstTd = row.querySelector("td:nth-child(1)");
|
||||
var secondTd = row.querySelector("td:nth-child(2)");
|
||||
var thirdTd = row.querySelector("td:nth-child(4)");
|
||||
var fifthTd = row.querySelector("td:nth-child(5)");
|
||||
var sixthTd = row.querySelector("td:nth-child(3)");
|
||||
var eigthTd = row.querySelector("td:nth-child(8)");
|
||||
var thirdTd = row.querySelector("td:nth-child(5)");
|
||||
var fifthTd = row.querySelector("td:nth-child(6)");
|
||||
var sixthTd = row.querySelector("td:nth-child(4)");
|
||||
var eigthTd = row.querySelector("td:nth-child(10)");
|
||||
|
||||
// Check if the second <td> element contains a <select> element
|
||||
var selectFirstElement = firstTd.querySelector("input");
|
||||
@ -676,8 +755,9 @@ $(document).ready(async function() {
|
||||
var product = products.find(function(item) {
|
||||
return item.product_id == productId;
|
||||
});
|
||||
// Access unit price from product and set it as rate
|
||||
// Access unit price from product and set it as rate
|
||||
var unitPrice = parseFloat(product.unit_price); // Convert to float if necessary
|
||||
$(this).closest('tr').find('.rate-d-only').val(unitPrice);
|
||||
$(this).closest('tr').find('.item-rate').val(unitPrice);
|
||||
|
||||
// Calculate amount and update amount input field
|
||||
@ -715,6 +795,7 @@ $(document).ready(async function() {
|
||||
// Access unit price from product and set it as rate
|
||||
var unitPrice = parseInt(service_data.price); // Convert to float if necessary
|
||||
console.log(service_data);
|
||||
$(this).closest('tr').find('.rate-d-only').val(unitPrice);
|
||||
$(this).closest('tr').find('.item-rate1').val(unitPrice);
|
||||
$(this).closest('tr').find('.item-tax').val(Number(service_data.tax));
|
||||
$(this).closest('tr').find('.labour_cost').val(parseInt(service_data.labour_cost));
|
||||
@ -741,6 +822,7 @@ $(document).ready(async function() {
|
||||
|
||||
// Access unit price from product and set it as rate
|
||||
var unitPrice = parseInt(complaint_data.labour_charge); // Convert to float if necessary
|
||||
$(this).closest('tr').find('.rate-d-only').val(unitPrice);
|
||||
$(this).closest('tr').find('.item-rate1').val(unitPrice);
|
||||
$(this).closest('tr').find('.item-tax').val(Number(complaint_data.tax));
|
||||
$(this).closest('tr').find('.labour_cost').val(parseInt(complaint_data.labour_charge));
|
||||
@ -774,19 +856,11 @@ $(document).ready(async function() {
|
||||
$(row).find('.item-rate').val(finrate);
|
||||
rate = Number(product.unit_price);
|
||||
var amount = (parseInt(rate) + (parseInt(rate) * tax / 100)) * quantity;
|
||||
total_tax_amt = amount - finrate;
|
||||
$(row).find('.total-tax-amount').val(total_tax_amt);
|
||||
$(row).find('.item-amount').val(amount);
|
||||
}
|
||||
else if(type.includes("service")) {
|
||||
// var productId = $(row).find('select[name="service_details[]"]').val();
|
||||
// var product = services.find(function(item) {
|
||||
// return item.service_id == productId;
|
||||
// });
|
||||
// var cgst = parseFloat(product.cgst);
|
||||
// var igst = parseFloat(product.sgst);
|
||||
|
||||
// // Calculate total tax by adding CGST and SGST
|
||||
// var tax = cgst + igst;
|
||||
// console.log(tax);
|
||||
if(action == 'parent') var $previousRow = row;
|
||||
else var $previousRow = row.prevAll(".service_class").first();
|
||||
|
||||
@ -799,19 +873,11 @@ $(document).ready(async function() {
|
||||
$(row).find('.item-rate').val(finrate);
|
||||
|
||||
var amount = (parseInt(rate) + (parseInt(rate) * tax / 100)) *quantity;
|
||||
total_tax_amt = amount - finrate;
|
||||
$(row).find('.total-tax-amount').val(total_tax_amt);
|
||||
$(row).find('.item-amount').val(amount);
|
||||
}
|
||||
else if(type.includes("complaint")) {
|
||||
// var productId = $(row).find('select[name="complaint_details[]"]').val();
|
||||
// var product = complaint.find(function(item) {
|
||||
// return item.complaint_id == productId;
|
||||
// });
|
||||
// console.log(product);
|
||||
// var cgst = parseFloat(product.cgst);
|
||||
// var igst = parseFloat(product.sgst);
|
||||
|
||||
// // Calculate total tax by adding CGST and SGST
|
||||
// var tax = cgst + igst;
|
||||
if(action == 'parent') var $previousRow = row;
|
||||
else var $previousRow = row.prevAll(".complaint_class").first();
|
||||
|
||||
@ -824,6 +890,8 @@ $(document).ready(async function() {
|
||||
|
||||
rate = $targetField.val();
|
||||
var amount = (parseInt(rate) + (parseInt(rate) * tax / 100)) *quantity;
|
||||
total_tax_amt = amount - finrate;
|
||||
$(row).find('.total-tax-amount').val(total_tax_amt);
|
||||
$(row).find('.item-amount').val(amount);
|
||||
}
|
||||
|
||||
@ -831,10 +899,13 @@ $(document).ready(async function() {
|
||||
|
||||
const labourcost = async (cost,tax,tr,cls) => {
|
||||
total_wih_tax = parseInt(cost) + (parseInt(cost) * (tax / 100));
|
||||
total_tax_amt = total_wih_tax - parseInt(cost);
|
||||
var newRow = '<tr class="'+cls+'"><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><input type="text" class="form-control labour_cost" value="Labour Cost"></td>' +
|
||||
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" value="'+cost+'" /></td>' +
|
||||
'<td style="width:10%;"><input type="text" class="form-control rate-d-only" value="'+cost+'" readonly /></td>' +
|
||||
'<td style="width:10%;" hidden><input type="text" class="form-control item-rate" name="unit-price[]" value="'+cost+'" /></td>' +
|
||||
'<td style="width:10%;"><input type="number" class="form-control item-quantity-'+cls+' item-quantity" min="0" name="quantity[]" value="'+1+'" /></td>' +
|
||||
'<td style="width:8%;"><input type="text" class="form-control item-tax" name="item-tax[]" value="'+tax+'" /></td>' +
|
||||
'<td style="width:8%;"><input type="text" class="form-control taxable-value item-tax" name="item-tax[]" value="'+tax+'" /></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 + '"/></td>' +
|
||||
'<td hidden></td>' +
|
||||
'<td hidden></td>' +
|
||||
@ -857,14 +928,17 @@ $(document).ready(async function() {
|
||||
// Calculate total tax by adding CGST and SGST
|
||||
var tax = cgst + sgst;
|
||||
total_wih_tax = parseInt(product.unit_price) + (parseInt(product.unit_price) * (tax / 100));
|
||||
total_tax_amt = total_wih_tax - parseInt(product.unit_price);
|
||||
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-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 + '">' + product.product_name + '</option>';
|
||||
newRow += '</select></td>' +
|
||||
'<td style="width:10%;"><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[]" readonly/></td>' +
|
||||
'<td style="width:8%;"> <input type="text" class="form-control item-tax" name="item-tax[]" value="' + tax + '" readonly /></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: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>' +
|
||||
'<td hidden><input type="hidden"></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>' +
|
||||
'</tr>';
|
||||
|
||||
@ -888,9 +962,20 @@ $(document).ready(async function() {
|
||||
$('.item-rate').each(function() {
|
||||
subtotal += parseFloat($(this).val()) || 0;
|
||||
});
|
||||
|
||||
return subtotal;
|
||||
}
|
||||
|
||||
// Function to calculate subtotal
|
||||
function get_tax_percentage() {
|
||||
var tax = 0;
|
||||
$('.taxable-value').each(function(index) {
|
||||
tax += parseFloat($(this).val()) || 0;
|
||||
});
|
||||
|
||||
return tax;
|
||||
}
|
||||
|
||||
// Function to calculate total tax
|
||||
function calculateTax() {
|
||||
var subtotal = 0;
|
||||
@ -903,24 +988,21 @@ $(document).ready(async function() {
|
||||
total += parseFloat($(this).val()) || 0;
|
||||
});
|
||||
return total - subtotal;
|
||||
}
|
||||
}
|
||||
|
||||
// Function to calculate total discount
|
||||
function calculateDiscount() {
|
||||
var totalDiscount = 0;
|
||||
$('.item-discount-amount').each(function(index, element) {
|
||||
var discountAmount = parseFloat($(element).val()) || 0;
|
||||
var discountType = $(element).closest('tr').find('.item-discount-type').val();
|
||||
if (discountType === '%') {
|
||||
var rate = $(element).closest('tr').find('.item-rate').val();
|
||||
var quantity = $(element).closest('tr').find('.item-quantity').val();
|
||||
var amount = rate * quantity;
|
||||
discountAmount = amount * discountAmount / 100;
|
||||
}
|
||||
totalDiscount += discountAmount;
|
||||
});
|
||||
return totalDiscount;
|
||||
}
|
||||
// Event listener for discount change
|
||||
$(document).on('input', '#discount_amt', function() {
|
||||
console.log(get_tax_percentage());
|
||||
discount_amt = Number($(this).val());
|
||||
sb_tot = calculateSubtotal() - discount_amt;
|
||||
tot = sb_tot + calculateTax();
|
||||
|
||||
// console.log(get_tax_percentage());
|
||||
|
||||
$('#subtotal').val(sb_tot.toFixed(2));
|
||||
$('#invoicetax').val(calculateTax().toFixed(2));
|
||||
$('#grandtotal').val(tot.toFixed(2));
|
||||
});
|
||||
|
||||
// Function to calculate total
|
||||
function calculateTotal() {
|
||||
@ -928,15 +1010,30 @@ $(document).ready(async function() {
|
||||
$('.item-amount').each(function() {
|
||||
total += parseFloat($(this).val()) || 0;
|
||||
});
|
||||
// discount_percentage = Number($('#discount_amt').val());
|
||||
// // Calculate the discount
|
||||
// discount = total * (discount_percentage / 100);
|
||||
// total_with_discount = total - discount;
|
||||
return total;
|
||||
}
|
||||
|
||||
// Update subtotal, tax, and total
|
||||
function updateCalculations() {
|
||||
$('#subtotal').val(calculateSubtotal().toFixed(2));
|
||||
$('#invoicetax').val(calculateTax().toFixed(2));
|
||||
$('#discount').val(calculateDiscount().toFixed(2));
|
||||
$('#grandtotal').val(calculateTotal().toFixed(2));
|
||||
if($('#discount_amt').val())
|
||||
{
|
||||
discount_amt = Number($('#discount_amt').val());
|
||||
sb_tot = calculateSubtotal() - discount_amt;
|
||||
tot = sb_tot + calculateTax();
|
||||
$('#subtotal').val(sb_tot.toFixed(2));
|
||||
$('#invoicetax').val(calculateTax().toFixed(2));
|
||||
$('#grandtotal').val(tot.toFixed(2));
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#subtotal').val(calculateSubtotal().toFixed(2));
|
||||
$('#invoicetax').val(calculateTax().toFixed(2));
|
||||
$('#grandtotal').val(calculateTotal().toFixed(2));
|
||||
}
|
||||
}
|
||||
|
||||
// Event listener for discount change
|
||||
@ -961,9 +1058,11 @@ $(document).ready(async function() {
|
||||
}
|
||||
|
||||
newRow += '</select></td>' +
|
||||
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" readonly /></td>' +
|
||||
'<td style="width:10%;"><input type="text" class="form-control rate-d-only" readonly /></td>' +
|
||||
'<td style="width:10%;" hidden><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" name="quantity[]"/></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 total-tax-amount" value="" readonly /></td>' +
|
||||
'<td style="width:12%;"><input type="text" class="form-control item-amount" name="amount[]"/></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>' +
|
||||
@ -988,9 +1087,11 @@ $(document).ready(async function() {
|
||||
}
|
||||
|
||||
newRow += '</select></td>' +
|
||||
'<td style="width:10%;"><input hidden type="text" class="form-control item-rate1" name="unit-price[]" readonly /></td>' +
|
||||
'<td style="width:10%;"><input hidden type="text" class="form-control rate-d-only" readonly /></td>' +
|
||||
'<td style="width:10%;" hidden><input type="text" class="form-control item-rate1" name="unit-price[]" readonly /></td>' +
|
||||
'<td style="width:10%;"><input hidden type="number" class="form-control item-quantity" min="0" name="quantity[]" readonly/></td>' +
|
||||
'<td style="width:8%;"><input hidden type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
|
||||
'<td style="width:8%;"><input hidden type="text" class="form-control total-tax-amount" readonly /></td>' +
|
||||
'<td style="width:12%;"><input hidden type="text" class="form-control item-amount1" name="amount[]"/></td>' +
|
||||
'<td><center><i class="fa fa-trash remove-item" id="remove-item"></i></center><input value="service" name="item_type" hidden></td>' +
|
||||
'<td hidden><input type="hidden" name="id"></td>' +
|
||||
@ -1028,9 +1129,11 @@ $(document).ready(async function() {
|
||||
}
|
||||
|
||||
newRow += '</select></td>' +
|
||||
'<td style="width:10%;"><input hidden type="text" class="form-control item-rate1" name="unit-price[]" readonly /></td>' +
|
||||
'<td style="width:10%;"><input hidden type="text" class="form-control rate-d-only" readonly /></td>' +
|
||||
'<td style="width:10%;" hidden><input type="text" class="form-control item-rate1" name="unit-price[]" readonly /></td>' +
|
||||
'<td style="width:10%;"><input hidden type="number" class="form-control item-quantity" min="0" name="quantity[]" readonly/></td>' +
|
||||
'<td style="width:8%;"><input hidden type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
|
||||
'<td style="width:8%;"><input hidden type="text" class="form-control total-tax-amount" readonly /></td>' +
|
||||
'<td style="width:12%;"><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>'+
|
||||
@ -1063,10 +1166,12 @@ $(document).ready(async function() {
|
||||
$('#addCustomComplaint').click(function() {
|
||||
complaint = <?php echo json_encode($complaint) ?>;
|
||||
var newRow = '<tr class="custom_complaint_class"><td hidden style="width:10%;"> <input type="number" class="form-control labour_cost" name="labour_cost"></td><td><textarea class="form-control custom-comp" id="custom_complaint_detail" rows="5"></textarea></td>' +
|
||||
'<td style="width:10%;"><input hidden type="text" class="form-control item-rate1" name="unit-price[]" /></td>' +
|
||||
'<td style="width:10%;"><input hidden type="text" class="form-control rate-d-only" readonly /></td>' +
|
||||
'<td style="width:10%;" hidden><input type="text" class="form-control item-rate1" name="unit-price[]" readonly /></td>' +
|
||||
'<td style="width:10%;"><input hidden type="number" class="form-control item-quantity" min="0" value="1" name="quantity[]" readonly/></td>' +
|
||||
'<td style="width:8%;"><input hidden type="text" class="form-control item-tax" name="item-tax[]" /></td>' +
|
||||
'<td style="width:8%;"><input hidden type="text" class="form-control item-tax" name="item-tax[]" value="18" readonly /></td>' +
|
||||
'<td style="width:12%;"><input hidden type="text" class="form-control item-amount1" name="amount[]"/></td>' +
|
||||
'<td style="width:8%;"><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>'+
|
||||
@ -1082,10 +1187,12 @@ $(document).ready(async function() {
|
||||
'</tr>';
|
||||
|
||||
newRow += '<tr class="custom_complaint_lb"><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><input type="text" class="form-control labour_cost" value="Labour Cost"></td>' +
|
||||
'<td style="width:10%;"><input type="text" class="form-control item-rate item-rate_cc" name="unit-price[]" value="" /></td>' +
|
||||
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" name="quantity[]" value="'+1+'" /></td>' +
|
||||
'<td style="width:8%;"><input type="text" class="form-control item-tax item-tax_cc" name="item-tax[]" /></td>' +
|
||||
'<td style="width:12%;"><input type="text" class="form-control item-amount item-amount_cc" name="amount1[]" value=""/></td>' +
|
||||
'<td style="width:10%;" hidden><input type="text" class="form-control rate-d-only" readonly /></td>' +
|
||||
'<td style="width:10%;"><input type="text" class="form-control item-rate item-rate_cc" name="unit-price[]" value="" readonly/></td>' +
|
||||
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" name="quantity[]" value="'+1+'" readonly /></td>' +
|
||||
'<td style="width:8%;"><input type="text" class="form-control taxable-value item-tax item-tax_cc" name="item-tax[]" value="'+18+'" readonly /></td>' +
|
||||
'<td style="width:8%;"><input type="text" class="form-control total-tax-amount" value="" readonly /></td>' +
|
||||
'<td style="width:12%;"><input type="text" class="form-control item-amount item-amount_cc" name="amount1[]" value="" /></td>' +
|
||||
'<td hidden></td>' +
|
||||
'<td hidden></td>' +
|
||||
'</tr>';
|
||||
@ -1137,7 +1244,7 @@ $(document).ready(async function() {
|
||||
/**
|
||||
* REMOVE ITEMS FROM THE TABLE
|
||||
* **/
|
||||
delete_items_id = [{ 'service': [], 'complaint': [], 'custom_complaint': [] }];
|
||||
delete_items_id = [{ 'service': [], 'complaint': [], 'custom_complaint': [], 'product' : [] }];
|
||||
$(document).on('click', '.remove-item', function() {
|
||||
var $closestTR = $(this).closest('tr');
|
||||
|
||||
@ -1159,6 +1266,12 @@ $(document).ready(async function() {
|
||||
delete_items_id[0].custom_complaint.push(id);
|
||||
console.log(delete_items_id);
|
||||
}
|
||||
else if($closestTR.attr('class') == "product")
|
||||
{
|
||||
id = $closestTR.find('input[name="id"]').val();
|
||||
delete_items_id[0].product.push(id);
|
||||
console.log(delete_items_id);
|
||||
}
|
||||
|
||||
while ($closestTR.next().length > 0 && $closestTR.attr('class') != "product") {
|
||||
if ($closestTR.next().hasClass('service_class') || $closestTR.next().hasClass('complaint_class') || $closestTR.next().hasClass('custom_complaint_class')) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user