FIX_Invoice Bug Fixes
This commit is contained in:
parent
2c0ba2e438
commit
aaa91e1493
@ -657,7 +657,7 @@ class Products extends BaseController
|
||||
public function quick_add()
|
||||
{
|
||||
|
||||
$tax = floatval($this->request->getPost('tax')) / 2;
|
||||
$tax = floatval($this->request->getPost('product_tax')) / 2;
|
||||
$bid = $this->session->get('logged_user_branch_id');
|
||||
|
||||
$ml = 0;
|
||||
@ -666,29 +666,29 @@ class Products extends BaseController
|
||||
$barrel = 0;
|
||||
$ltr_per_barrel = 0;
|
||||
|
||||
$per = $this->request->getPost('per');
|
||||
$per = $this->request->getPost('product_per');
|
||||
if ($per === 'ml') {
|
||||
$ml = floatval($this->request->getPost('ml') ?? 0);
|
||||
$ml = floatval($this->request->getPost('product_ml') ?? 0);
|
||||
} elseif ($per === 'box') {
|
||||
$box = floatval($this->request->getPost('box') ?? 0);
|
||||
$qty_per_box = floatval($this->request->getPost('qty_per_box') ?? 0);
|
||||
$box = floatval($this->request->getPost('product_box') ?? 0);
|
||||
$qty_per_box = floatval($this->request->getPost('product_qty_per_box') ?? 0);
|
||||
} elseif ($per === 'barrel') {
|
||||
$barrel = floatval($this->request->getPost('barrel') ?? 0);
|
||||
$ltr_per_barrel = floatval($this->request->getPost('ltr_per_barrel') ?? 0);
|
||||
$barrel = floatval($this->request->getPost('product_barrel') ?? 0);
|
||||
$ltr_per_barrel = floatval($this->request->getPost('product_ltr_per_barrel') ?? 0);
|
||||
}
|
||||
|
||||
|
||||
$qty_in_stock = floatval($this->request->getPost('qty_stock') ?: 0); // Get qty_stock from POST
|
||||
$qty_in_stock = floatval($this->request->getPost('product_qty_stock') ?: 0); // Get qty_stock from POST
|
||||
$purchase_order_level = floor($qty_in_stock / 2); // Calculate purchase reorder level (half of qty in stock)
|
||||
$purchase_order_level = is_nan($purchase_order_level) ? '' : $purchase_order_level; // Safely assign values (handle invalid numbers)
|
||||
$reorder_level = is_nan($qty_in_stock) ? '' : $qty_in_stock;
|
||||
|
||||
$data = [
|
||||
'cubic_centimeter_id' => json_encode($this->request->getPost('cubic_centimeter_id')),
|
||||
'product_name' => $this->request->getPost('productname'),
|
||||
'product_category' => $this->request->getPost('productcategory'),
|
||||
'total_amount' => $this->request->getPost('total_amount'),
|
||||
'unit_price' => $this->request->getPost('unit_price'),
|
||||
'product_name' => $this->request->getPost('product_name'),
|
||||
'product_category' => $this->request->getPost('product_category'),
|
||||
'total_amount' => $this->request->getPost('product_total_amount'),
|
||||
'unit_price' => $this->request->getPost('product_unit_price'),
|
||||
'qty_stock' => $qty_in_stock,
|
||||
'sgst' => $tax,
|
||||
'cgst' => $tax,
|
||||
@ -702,7 +702,7 @@ class Products extends BaseController
|
||||
'branch_id' => $bid,
|
||||
'purchase_order_level'=> $purchase_order_level,
|
||||
'reorder_level' => $reorder_level,
|
||||
'manufacturer_id' => $this->request->getPost('manufacturer'),
|
||||
'manufacturer_id' => $this->request->getPost('product_manufacturer'),
|
||||
];
|
||||
|
||||
$insertID = $this->ProductModel->insert($data);
|
||||
|
||||
@ -11,6 +11,39 @@
|
||||
padding: 5px !important;
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
.select2-container--default .select2-results__option--highlighted[aria-selected]{
|
||||
color:#ffffff;
|
||||
background: #526dee!important;
|
||||
}
|
||||
.select2-container .select2-selection--single{
|
||||
height: 36px;
|
||||
border:1px solid #ced4da;
|
||||
}
|
||||
.select2-container--default .select2-selection--single .select2-selection__rendered{
|
||||
line-height: 36px;
|
||||
}
|
||||
.select2-container--default .select2-selection--single .select2-selection__arrow{
|
||||
top:4px;
|
||||
}
|
||||
|
||||
.select2-container .select2-selection--multiple .select2-selection__choice{
|
||||
padding: 5px 7px 5px 0 !important;
|
||||
color: #000000;
|
||||
|
||||
}
|
||||
.select2-container--default .select2-results__option{
|
||||
border-bottom: 1px solid #dddddd;
|
||||
}
|
||||
.select2-container--default .select2-results__option[aria-selected=true]{
|
||||
color: #000000;
|
||||
background-color: #3efba4;
|
||||
font-weight: 500;
|
||||
border-bottom: 1px solid #747474;
|
||||
}
|
||||
</style>
|
||||
|
||||
<?php $status = $invoice['status'] ?? 'Draft'; ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@ -207,7 +240,7 @@
|
||||
<tr>
|
||||
<td style="width:30%;" class="fixed-dropdown-container">
|
||||
<select class="form-control book-select SelExample" name="item_details[]"
|
||||
required data-toggle="select2" id="" style="width: 249px !important;" onchange="addProductNamesId(this)">
|
||||
required data-toggle="select2" id="" style="width: 249px !important;" onchange="addProductNamesId(this)" <?= $status !== 'Draft'? 'disabled' : '' ?>>
|
||||
<option value="">Select a Product</option>
|
||||
<option value="add_new_product">+ Add New Product</option>
|
||||
<?php foreach ($product as $value) : ?>
|
||||
@ -228,13 +261,12 @@
|
||||
</td>
|
||||
<td style="width:12%;">
|
||||
<input type="text" class="form-control item-rate" name="unit-price[]"
|
||||
readonly
|
||||
value="<?= isset($ic['net_price']) ? $ic['net_price'] : '' ?>">
|
||||
value="<?= isset($ic['net_price']) ? $ic['net_price'] : '' ?>" <?= $status !== 'Draft' ? 'readonly' : '' ?>>
|
||||
</td>
|
||||
<td style="width:10%;">
|
||||
<input type="number" class="form-control item-quantity" name="quantity[]"
|
||||
min="0"
|
||||
value="<?= isset($ic['qty']) ? $ic['qty'] : '1' ?>" onchange="updateThirdColumnValue(this); updateTaxAmount(this)" onkeydown="return false;">
|
||||
min="1"
|
||||
value="<?= isset($ic['qty']) ? $ic['qty'] : '1' ?>" onchange="updateThirdColumnValue(this); updateTaxAmount(this)" onkeydown="return false;" <?= $status !== 'Draft' ? 'readonly' : '' ?>>
|
||||
</td>
|
||||
<td style="width:14%;">
|
||||
<?php if (isset($ic['net_price']) && isset($ic['qty'])) {
|
||||
@ -266,13 +298,15 @@
|
||||
</td> -->
|
||||
<td style="width:13%;">
|
||||
<input type="text" class="form-control item-amount" name="amount[]"
|
||||
value="<?= isset($ic['amount']) ? $ic['amount'] : '' ?>" >
|
||||
value="<?= isset($ic['amount']) ? $ic['amount'] : '' ?>" <?= $status !== 'Draft' ? 'readonly' : '' ?>>
|
||||
</td>
|
||||
<td hidden><input type="hidden"
|
||||
value="<?= isset($ic['invoice_child_id']) ? $ic['invoice_child_id'] : '' ?>"
|
||||
name="invoice_child_id[]"></td>
|
||||
<td style="width:7%;">
|
||||
<center><i class="fa fa-trash remove-item"></i></center>
|
||||
<?php if ($status === 'Draft'): ?>
|
||||
<center><i class="fa fa-trash remove-item"></i></center>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
@ -283,9 +317,11 @@
|
||||
</table>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<!-- Show the "Add More Item" button only if invoice_type is not 1 -->
|
||||
<?php if ($status === 'Draft') : ?>
|
||||
<a class="btn" id="addItem">
|
||||
<h4><i class="fa fa-plus" aria-hidden="true"></i> Add Product</h4>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
|
||||
@ -540,21 +576,21 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="productname" class="col-form-label">Product Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="productname" placeholder="Product Name" required>
|
||||
<label for="product_name" class="col-form-label">Product Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="product_name" placeholder="Product Name" required>
|
||||
</div>
|
||||
</div>
|
||||
<!-- PRICING -->
|
||||
<h5 class="header-title mt-3">Pricing Information :</h5>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label class="col-form-label">Unit Price (Including Tax)<span class="text-danger">*</span></label>
|
||||
<input type="number" step="0.01" class="form-control" name="total_amount" required>
|
||||
<label class="product_total_amount">Unit Price (Including Tax)<span class="text-danger">*</span></label>
|
||||
<input type="number" step="0.01" class="form-control" name="product_total_amount" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label class="col-form-label">Tax<span class="text-danger">*</span></label>
|
||||
<select class="form-control" name="tax" required>
|
||||
<label class="product_tax">Tax<span class="text-danger">*</span></label>
|
||||
<select class="form-control" name="product_tax" required>
|
||||
<!-- <option value="">Select Tax</option> -->
|
||||
<option value="18">18%</option>
|
||||
<option value="28">28%</option>
|
||||
@ -562,28 +598,28 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label class="col-form-label">Unit Price<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="unit_price" required readonly>
|
||||
<label class="product_unit_price">Unit Price<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="product_unit_price" required readonly>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- STOCK INFO -->
|
||||
<h5 class="header-title mt-3">Stock Information :</h5>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label class="col-form-label">Unit of Measurement<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="per" name="per" required>
|
||||
<!-- <option value="">Select</option> -->
|
||||
<option value="Nos" selected>No's</option>
|
||||
<option value="ml">ML</option>
|
||||
<option value="litre">Litre</option>
|
||||
<option value="barrel">Barrel</option>
|
||||
<option value="box">Box</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label class="col-form-label">Unit of Measurement<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="product_per" name="product_per" required>
|
||||
<!-- <option value="">Select</option> -->
|
||||
<option value="Nos" selected>No's</option>
|
||||
<option value="ml">ML</option>
|
||||
<option value="litre">Litre</option>
|
||||
<option value="barrel">Barrel</option>
|
||||
<option value="box">Box</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-3" id="ml_div" hidden >
|
||||
<label class="col-form-label">ML<span class="text-danger">*</span></label>
|
||||
<select name="ml" id="ml" class="form-control SelExample select2-hidden-accessible" <?= (isset($products['per']) && $products['per'] == 'ml') ? 'required' : '' ?>>
|
||||
<label class="product_ml">ML<span class="text-danger">*</span></label>
|
||||
<select name="product_ml" id="product_ml" class="form-control SelExample select2-hidden-accessible" <?= (isset($products['per']) && $products['per'] == 'ml') ? 'required' : '' ?>>
|
||||
<option value>Select ML</option>
|
||||
<?php
|
||||
$selectedValue = isset($products['ml']) ? $products['ml'] : 0;
|
||||
@ -594,35 +630,34 @@
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-3" id="box_div" hidden >
|
||||
<div class="form-group col-md-3" id="product_box_div" hidden >
|
||||
<label class="col-form-label">No Of Box<span class="text-danger">*</span></label>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" name="box" id="box" class="form-control" value="<?= isset($products['box']) ? $products['box'] : '' ?>" <?= (isset($products['per']) && $products['per'] == 'box') ? 'required' : '' ?>>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" name="product_box" id="product_box" class="form-control" value="<?= isset($products['box']) ? $products['box'] : '' ?>" <?= (isset($products['per']) && $products['per'] == 'box') ? 'required' : '' ?>>
|
||||
</div>
|
||||
<div class="form-group col-md-3" id="qty_per_box_div" hidden >
|
||||
<div class="form-group col-md-3" id="product_qty_per_box_div" hidden >
|
||||
<label class="col-form-label">Qty In Box<span class="text-danger">*</span></label>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" name="qty_per_box" id="qty_per_box" class="form-control" value="<?= isset($products['qty_per_box']) ? $products['qty_per_box'] : '' ?>" <?= (isset($products['per']) && $products['per'] == 'box') ? 'required' : '' ?>>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" name="product_qty_per_box" id="product_qty_per_box" class="form-control" value="<?= isset($products['qty_per_box']) ? $products['qty_per_box'] : '' ?>" <?= (isset($products['per']) && $products['per'] == 'box') ? 'required' : '' ?>>
|
||||
</div>
|
||||
<div class="form-group col-md-3" id="barrel_div" hidden >
|
||||
<div class="form-group col-md-3" id="product_barrel_div" hidden >
|
||||
<label class="col-form-label">No Of Barrel<span class="text-danger">*</span></label>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" name="barrel" id="barrel" class="form-control" value="<?= isset($products['barrel']) ? $products['barrel'] : '' ?>" <?= (isset($products['per']) && $products['per'] == 'barrel') ? 'required' : '' ?>>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" name="product_barrel" id="product_barrel" class="form-control" value="<?= isset($products['barrel']) ? $products['barrel'] : '' ?>" <?= (isset($products['per']) && $products['per'] == 'barrel') ? 'required' : '' ?>>
|
||||
</div>
|
||||
<div class="form-group col-md-3" id="ltr_per_barrel_div" hidden >
|
||||
<div class="form-group col-md-3" id="product_ltr_per_barrel_div" hidden >
|
||||
<label class="col-form-label">Liters In Barrel<span class="text-danger">*</span></label>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" name="ltr_per_barrel" id="ltr_per_barrel" class="form-control" value="<?= isset($products['ltr_per_barrel']) ? $products['ltr_per_barrel'] : '' ?>" <?= (isset($products['per']) && $products['per'] == 'barrel') ? 'required' : '' ?>>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" name="product_ltr_per_barrel" id="product_ltr_per_barrel" class="form-control" value="<?= isset($products['ltr_per_barrel']) ? $products['ltr_per_barrel'] : '' ?>" <?= (isset($products['per']) && $products['per'] == 'barrel') ? 'required' : '' ?>>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label class="col-form-label">Qty in Stock<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="product_qty_stock" id="product_qty_stock" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label class="col-form-label">Qty in Stock<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="qty_stock" id="qty_stock" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Additional -->
|
||||
<h5 class="header-title mt-3">Additional Information :</h5>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="PCselect" class="col-form-label">Product Category</label>
|
||||
<select class="form-control SelExample" id="PCselect" name="productcategory">
|
||||
<select class="form-control SelExample" id="PCselect" name="product_category">
|
||||
<option value="">Select Category</option>
|
||||
<?php foreach ($productcategory as $category): ?>
|
||||
<?php if ((int)$category['isactive'] == 1): ?>
|
||||
@ -634,8 +669,8 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="manufacturer" class="col-form-label">Manufacturer</label>
|
||||
<select class="form-control SelExample" id="manufacturer" name="manufacturer">
|
||||
<label for="product_manufacturer" class="col-form-label">Manufacturer</label>
|
||||
<select class="form-control SelExample" id="product_manufacturer" name="product_manufacturer">
|
||||
<option value="">Select a Manufacturer</option>
|
||||
<?php foreach ($manufacturers as $value): ?>
|
||||
<option value="<?= $value['manufacturer_id'] ?>">
|
||||
@ -927,8 +962,9 @@ $(document).ready(function() {
|
||||
var total_tax_amount = product.unit_price * totalTax / 100;
|
||||
var total_tax_amount = parseFloat(total_tax_amount).toFixed(2);
|
||||
|
||||
console.log("product.qty_stock : ",product.qty_stock);
|
||||
$(this).closest('tr').find('.item-quantity').attr('max', product.qty_stock);
|
||||
// console.log("product.qty_stock : ",product.qty_stock);
|
||||
// $(this).closest('tr').find('.item-quantity').attr('max', product.qty_stock);
|
||||
// Gowtham TL told to me => Don’t restrict the max quantity based on the product’s available quantity.
|
||||
|
||||
|
||||
// Access unit price from product and set it as rate
|
||||
@ -1091,8 +1127,8 @@ $(document).ready(function() {
|
||||
}
|
||||
}
|
||||
newRow += '</select></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)" onkeydown="return false;" /></td>' +
|
||||
'<td style="width:12%;"><input type="text" class="form-control item-rate" name="unit-price[]" /></td>' +
|
||||
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="1" max="" name="quantity[]" onchange="updateThirdColumnValue(this); updateTaxAmount(this)" onkeydown="return false;" /></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:13%;"><input type="text" class="form-control tax-amount" name="tax-amount[]" readonly /></td>' +
|
||||
@ -1568,30 +1604,69 @@ function addProductNamesId(selectElement) {
|
||||
$(document).ready(function() {
|
||||
|
||||
function unitPriceReverseCalculation() {
|
||||
var taxVal = $("select[name='tax']").val();
|
||||
var total_amount = parseFloat($("input[name='total_amount']").val());
|
||||
var taxVal = $("select[name='product_tax']").val();
|
||||
var total_amount = parseFloat($("input[name='product_total_amount']").val());
|
||||
|
||||
if (isNaN(total_amount) || total_amount <= 0) {
|
||||
$("input[name='unit_price']").val('');
|
||||
$("input[name='product_unit_price']").val('');
|
||||
return;
|
||||
}
|
||||
|
||||
if (taxVal === '' || isNaN(parseFloat(taxVal))) {
|
||||
$("input[name='unit_price']").val(total_amount.toFixed(2));
|
||||
$("input[name='product_unit_price']").val(total_amount.toFixed(2));
|
||||
toastr.warning('Please select Tax', 'Warning');
|
||||
return;
|
||||
}
|
||||
|
||||
var tax = parseFloat(taxVal);
|
||||
var unitPrice = total_amount / ((tax / 100) + 1);
|
||||
$("input[name='unit_price']").val(unitPrice.toFixed(2));
|
||||
$("input[name='product_unit_price']").val(unitPrice.toFixed(2));
|
||||
}
|
||||
|
||||
$("input[name='total_amount'], select[name='tax']").on('change keyup', function() {
|
||||
$("input[name='product_total_amount'], select[name='product_tax']").on('change keyup', function() {
|
||||
unitPriceReverseCalculation();
|
||||
});
|
||||
|
||||
$('#per').change(function () {
|
||||
// When Rate is edited, recalculate Amount and Tax Amount in the same row
|
||||
$(document).on('keyup', '.item-rate', function () {
|
||||
updateAmountAndTax(this);
|
||||
});
|
||||
|
||||
function updateAmountAndTax(input) {
|
||||
const row = $(input).closest('tr');
|
||||
const rate = parseFloat($(input).val()) || 0;
|
||||
const qty = parseFloat(row.find('.item-quantity').val()) || 0;
|
||||
const tax = parseFloat(row.find('.item-tax').val()) || 0;
|
||||
|
||||
// Calculate Amount (Rate x Qty)
|
||||
const amount = rate * qty;
|
||||
row.find('.item-result').val(amount.toFixed(2));
|
||||
|
||||
// Calculate Tax Amount
|
||||
const taxAmount = amount * (tax / 100);
|
||||
row.find('.tax-amount').val(taxAmount.toFixed(2));
|
||||
|
||||
// Calculate Total Amount
|
||||
const totalAmount = amount + taxAmount;
|
||||
row.find('.item-amount').val(totalAmount.toFixed(2));
|
||||
|
||||
// Optionally trigger a summary update (like subtotal, grand total, etc.)
|
||||
updateGrandTotal();
|
||||
}
|
||||
|
||||
function updateGrandTotal() {
|
||||
let grandTotal = 0;
|
||||
$('.item-amount').each(function () {
|
||||
const val = parseFloat($(this).val()) || 0;
|
||||
grandTotal += val;
|
||||
});
|
||||
$('input[name="total_amount"]').val(grandTotal.toFixed(2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$('#product_per').change(function () {
|
||||
if ($(this).val() == 'ml')
|
||||
{
|
||||
hide_box();
|
||||
@ -1624,81 +1699,81 @@ $(document).ready(function() {
|
||||
|
||||
function hide_box()
|
||||
{
|
||||
$('#box_div').attr('hidden', 'hidden');
|
||||
$('#box').removeAttr('required');
|
||||
$('#qty_per_box_div').attr('hidden', 'hidden');
|
||||
$('#qty_per_box').removeAttr('required');
|
||||
$('#product_box_div').attr('hidden', 'hidden');
|
||||
$('#product_box').removeAttr('required');
|
||||
$('#product_qty_per_box_div').attr('hidden', 'hidden');
|
||||
$('#product_qty_per_box').removeAttr('required');
|
||||
}
|
||||
function hide_barrel()
|
||||
{
|
||||
$('#barrel_div').attr('hidden', 'hidden');
|
||||
$('#barrel').removeAttr('required');
|
||||
$('#ltr_per_barrel_div').attr('hidden', 'hidden');
|
||||
$('#ltr_per_barrel').removeAttr('required');
|
||||
$('#product_barrel_div').attr('hidden', 'hidden');
|
||||
$('#product_barrel').removeAttr('required');
|
||||
$('#product_ltr_per_barrel_div').attr('hidden', 'hidden');
|
||||
$('#product_ltr_per_barrel').removeAttr('required');
|
||||
}
|
||||
function hide_ml()
|
||||
{
|
||||
$('#ml_div').attr('hidden', 'hidden');
|
||||
$('#ml').removeAttr('required');
|
||||
$('#product_ml_div').attr('hidden', 'hidden');
|
||||
$('#product_ml').removeAttr('required');
|
||||
}
|
||||
function show_box()
|
||||
{
|
||||
$('#box_div').removeAttr('hidden');
|
||||
$('#box').attr('required','required');
|
||||
$('#qty_per_box_div').removeAttr('hidden');
|
||||
$('#qty_per_box').attr('required','required');
|
||||
$('#product_box_div').removeAttr('hidden');
|
||||
$('#product_box').attr('required','required');
|
||||
$('#product_qty_per_box_div').removeAttr('hidden');
|
||||
$('#product_qty_per_box').attr('required','required');
|
||||
}
|
||||
function show_barrel()
|
||||
{
|
||||
$('#barrel_div').removeAttr('hidden');
|
||||
$('#barrel').attr('required','required');
|
||||
$('#ltr_per_barrel_div').removeAttr('hidden');
|
||||
$('#ltr_per_barrel').attr('required','required');
|
||||
$('#product_barrel_div').removeAttr('hidden');
|
||||
$('#product_barrel').attr('required','required');
|
||||
$('#product_ltr_per_barrel_div').removeAttr('hidden');
|
||||
$('#product_ltr_per_barrel').attr('required','required');
|
||||
}
|
||||
function show_ml()
|
||||
{
|
||||
$('#ml_div').removeAttr('hidden');
|
||||
$('#ml').attr('required','required');
|
||||
$('#product_ml_div').removeAttr('hidden');
|
||||
$('#product_ml').attr('required','required');
|
||||
}
|
||||
|
||||
function resetStockDetails()
|
||||
{
|
||||
$('#ml').val(null).trigger('change');
|
||||
$('#barrel').val('');
|
||||
$('#ltr_per_barrel').val('');
|
||||
$('#box').val('');
|
||||
$('#qty_per_box').val('');
|
||||
$('#qty_stock').val('');
|
||||
$('#product_ml').val(null).trigger('change');
|
||||
$('#product_barrel').val('');
|
||||
$('#product_ltr_per_barrel').val('');
|
||||
$('#product_box').val('');
|
||||
$('#product_qty_per_box').val('');
|
||||
$('#product_qty_stock').val('');
|
||||
}
|
||||
|
||||
|
||||
$('#box, #qty_per_box').on('keyup', function() {
|
||||
var box = parseFloat($('#box').val()) || 0;
|
||||
var qtyPerBox = parseFloat($('#qty_per_box').val()) || 0;
|
||||
$('#product_box, #product_qty_per_box').on('keyup', function() {
|
||||
var box = parseFloat($('#product_box').val()) || 0;
|
||||
var qtyPerBox = parseFloat($('#product_qty_per_box').val()) || 0;
|
||||
console.log(`b : ${box} qpb : ${qtyPerBox} `);
|
||||
// if (!isNaN(box) && !isNaN(qtyPerBox) && box !== '' && qtyPerBox !== '') {
|
||||
if (box > 0 && qtyPerBox > 0) {
|
||||
var qtyInStock = box * qtyPerBox;
|
||||
console.log(`calc : ${qtyInStock}`);
|
||||
$('#qty_stock').val(qtyInStock);
|
||||
$('#product_qty_stock').val(qtyInStock);
|
||||
} else {
|
||||
console.log(`mt : ${qtyInStock}`);
|
||||
$('#qty_stock').val('');
|
||||
$('#product_qty_stock').val('');
|
||||
}
|
||||
});
|
||||
|
||||
$('#barrel, #ltr_per_barrel').on('keyup', function() {
|
||||
var barrel = parseFloat($('#barrel').val()) || 0;
|
||||
var ltrPerBarrel = parseFloat($('#ltr_per_barrel').val()) || 0;
|
||||
$('#product_barrel, #product_ltr_per_barrel').on('keyup', function() {
|
||||
var barrel = parseFloat($('#product_barrel').val()) || 0;
|
||||
var ltrPerBarrel = parseFloat($('#product_ltr_per_barrel').val()) || 0;
|
||||
console.log(`b : ${barrel},lpb : ${ltrPerBarrel}`);
|
||||
// if (!isNaN(barrel) && !isNaN(ltrPerBarrel) && barrel !== '' && ltrPerBarrel !== '') {
|
||||
if (barrel > 0 && ltrPerBarrel > 0) {
|
||||
var qtyInStock = barrel * ltrPerBarrel;
|
||||
console.log(`calc : ${qtyInStock}`);
|
||||
$('#qty_stock').val(qtyInStock);
|
||||
$('#product_qty_stock').val(qtyInStock);
|
||||
} else {
|
||||
console.log(`mt : ${qtyInStock}`);
|
||||
$('#qty_stock').val('');
|
||||
$('#product_qty_stock').val('');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -120,15 +120,17 @@
|
||||
var datatable_invoice ='';
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
const totalColumns = $('#datatable_invoices thead th').length;
|
||||
const exportColumns = [...Array(totalColumns).keys()].slice(0, -1); // Exclude last column
|
||||
|
||||
datatable_invoice = $('#datatable_invoices').DataTable({
|
||||
"order": [[0, 'desc']], // Sort by Id (hidden column)
|
||||
"dom": 'Bfrtip', // Show export buttons
|
||||
"buttons": [
|
||||
{extend: 'pdfHtml5', title: 'Products', text: 'PDF'},
|
||||
{extend: 'print', title: 'Products', text: 'Print'},
|
||||
{extend: 'copy', text: 'Copy', titleAttr: 'Copy'},
|
||||
{extend: 'csv', text: 'CSV', title: 'Products'}
|
||||
{extend: 'pdfHtml5', title: 'Products', text: 'PDF',exportOptions: {columns: exportColumns}},
|
||||
{extend: 'print', title: 'Products', text: 'Print',exportOptions: {columns: exportColumns}},
|
||||
{extend: 'copy', text: 'Copy', titleAttr: 'Copy',exportOptions: {columns: exportColumns}},
|
||||
{extend: 'csv', text: 'CSV', title: 'Products',exportOptions: {columns: exportColumns}}
|
||||
],
|
||||
"language": {
|
||||
"search": "Search: " // Customize search label
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -410,8 +410,8 @@
|
||||
<div class="collapse" id="sidebarLayouts">
|
||||
<ul class="nav-second-level">
|
||||
<li>
|
||||
<!-- <a href="<?php echo base_url('product_index') ?>">Products</a> -->
|
||||
<a href="<?php echo base_url('product_categories') ?>">Products</a>
|
||||
<a href="<?php echo base_url('product_index') ?>">Products</a>
|
||||
<!-- <a href="<?php echo base_url('product_categories') ?>">Products</a> -->
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo base_url('product_category_index') ?>">Product Category</a>
|
||||
|
||||
@ -1,4 +1,9 @@
|
||||
<?php include('layout/header.php'); ?>
|
||||
<style>
|
||||
#datatable-productcategory td.productcategory {
|
||||
text-align: left !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
@ -21,28 +26,28 @@
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<table id="datatable-productcategory" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;text-align: center;width: 100%;">
|
||||
<table id="datatable-productcategory" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Product Category</th>
|
||||
<th>Total Product</th>
|
||||
<th>Status</th>
|
||||
<th>Products</th>
|
||||
<th style="text-align: center;">Total Product</th>
|
||||
<th style="text-align: center;">Status</th>
|
||||
<th style="text-align: center;">Products</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($productcategory as $index => $item): ?>
|
||||
<tr class="productcategory_tr_<?php echo $index+1; ?>">
|
||||
<td class="productcategory"><?php echo $item['product_category_name']; ?></td>
|
||||
<td><?php echo $item['total_product']; ?></td>
|
||||
<td>
|
||||
<td style="text-align: center;"><?php echo $item['total_product']; ?></td>
|
||||
<td style="text-align: center;">
|
||||
<?php if($item['isactive'] == 1): ?>
|
||||
<span style="color:green">Active</span>
|
||||
<?php else: ?>
|
||||
<span style="color:red">Inactive</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<td style="text-align: center;">
|
||||
|
||||
<a href="<?php echo base_url('product_index?category=').$item['product_category_name']; ?>" ><i class="ri-eye-line" style="font-size: 15px;"></i></a>
|
||||
|
||||
@ -75,10 +80,10 @@
|
||||
datatable_make = $('#datatable-productcategory').DataTable({
|
||||
"order": [[0, 'asc']], // Set initial sorting to descending on the first column
|
||||
"dom": 'Bfrtip', // Show export buttons
|
||||
"buttons": [{extend: 'pdfHtml5',title: 'Products', text: 'PDF',},
|
||||
{extend: 'print',title: 'Products',text: 'Print',},
|
||||
{extend: 'copy',text: 'Copy', titleAttr: 'Copy',},
|
||||
{extend: 'csv',text: 'CSV', title: 'Products', }],
|
||||
"buttons": [{extend: 'pdfHtml5',title: 'Products', text: 'PDF',exportOptions: { columns: [0, 1, 2] }},
|
||||
{extend: 'print',title: 'Products',text: 'Print',exportOptions: { columns: [0, 1, 2] }},
|
||||
{extend: 'copy',text: 'Copy', titleAttr: 'Copy',exportOptions: { columns: [0, 1, 2] }},
|
||||
{extend: 'csv',text: 'CSV', title: 'Products',exportOptions: { columns: [0, 1, 2] }}],
|
||||
"language": {
|
||||
"search": "Search: " // Customize search label
|
||||
},
|
||||
|
||||
@ -22,26 +22,26 @@
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<table id="datatable-productcategory" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;text-align: center;width: 100%;">
|
||||
<table id="datatable-productcategory" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Product Category</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
<th style="text-align: center;">Status</th>
|
||||
<th style="text-align: center;">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($productcategory as $index => $item): ?>
|
||||
<tr class="productcategory_tr_<?php echo $index+1; ?>">
|
||||
<td class="productcategory"><?php echo $item['product_category_name']; ?></td>
|
||||
<td>
|
||||
<td style="text-align: center;">
|
||||
<?php if($item['isactive'] == 1): ?>
|
||||
<span style="color:green">Active</span>
|
||||
<?php else: ?>
|
||||
<span style="color:red">Inactive</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<td style="text-align: center;">
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
@ -216,10 +216,10 @@
|
||||
datatable_make = $('#datatable-productcategory').DataTable({
|
||||
"order": [[0, 'asc']], // Set initial sorting to descending on the first column
|
||||
"dom": 'Bfrtip', // Show export buttons
|
||||
"buttons": [{extend: 'pdfHtml5',title: 'Products', text: 'PDF',},
|
||||
{extend: 'print',title: 'Products',text: 'Print',},
|
||||
{extend: 'copy',text: 'Copy', titleAttr: 'Copy',},
|
||||
{extend: 'csv',text: 'CSV', title: 'Products', }],
|
||||
"buttons": [{extend: 'pdfHtml5',title: 'Products', text: 'PDF',exportOptions: { columns: [0, 1] }},
|
||||
{extend: 'print',title: 'Products',text: 'Print',exportOptions: { columns: [0, 1] }},
|
||||
{extend: 'copy',text: 'Copy', titleAttr: 'Copy',exportOptions: { columns: [0, 1] }},
|
||||
{extend: 'csv',text: 'CSV', title: 'Products',exportOptions: { columns: [0, 1] } }],
|
||||
"language": {
|
||||
"search": "Search: " // Customize search label
|
||||
},
|
||||
|
||||
@ -97,8 +97,7 @@
|
||||
<tr class="product_tr_<?php echo $index+1; ?>" style="color:<?php echo $color; ?>" >
|
||||
<td><?= $value['sku_id']; ?></td>
|
||||
<td>
|
||||
<i class="ri-information-fill product_addtional_details" id="<?= $value['product_id']; ?>" ></i>
|
||||
|
||||
<!-- <i class="ri-information-fill product_addtional_details" id="<?= $value['product_id']; ?>" ></i> -->
|
||||
<?= $value['product_name']; ?>
|
||||
|
||||
</td>
|
||||
@ -183,10 +182,10 @@
|
||||
data_table_set = $('#datatable-buttons2').DataTable({
|
||||
"order": [[1, 'asc']], // Set initial sorting to descending on the first column
|
||||
"dom": 'Bfrtip', // Show export buttons
|
||||
"buttons": [{extend: 'pdfHtml5',title: 'Products', text: 'PDF',},
|
||||
{extend: 'print',title: 'Products',text: 'Print',},
|
||||
{extend: 'copy',text: 'Copy', titleAttr: 'Copy',},
|
||||
{extend: 'csv',text: 'CSV', title: 'Products', }],
|
||||
"buttons": [{extend: 'pdfHtml5',title: 'Products', text: 'PDF', exportOptions: { columns: [0, 1, 2, 3, 4, 5, 6] }},
|
||||
{extend: 'print',title: 'Products',text: 'Print', exportOptions: { columns: [0, 1, 2, 3, 4, 5, 6] }},
|
||||
{extend: 'copy',text: 'Copy', titleAttr: 'Copy', exportOptions: { columns: [0, 1, 2, 3, 4, 5, 6] }},
|
||||
{extend: 'csv',text: 'CSV', title: 'Products', exportOptions: { columns: [0, 1, 2, 3, 4, 5, 6] }}],
|
||||
"language": {
|
||||
"search": "Search: " // Customize search label
|
||||
},
|
||||
|
||||
@ -121,16 +121,17 @@
|
||||
<script>
|
||||
var datatable_sales_order ='';
|
||||
$(document).ready(function() {
|
||||
|
||||
const totalColumns = $('#datatable-sales-order thead th').length;
|
||||
const exportColumns = [...Array(totalColumns).keys()].slice(0, -1); // Exclude last column
|
||||
|
||||
datatable_sales_order = $('#datatable-sales-order').DataTable({
|
||||
"order": [[0, 'desc']], // Sort by Sales Order Id (hidden column)
|
||||
"dom": 'Bfrtip', // Show export buttons
|
||||
"buttons": [
|
||||
{extend: 'pdfHtml5', title: 'Products', text: 'PDF'},
|
||||
{extend: 'print', title: 'Products', text: 'Print'},
|
||||
{extend: 'copy', text: 'Copy', titleAttr: 'Copy'},
|
||||
{extend: 'csv', text: 'CSV', title: 'Products'}
|
||||
{extend: 'pdfHtml5', title: 'Products', text: 'PDF',exportOptions: {columns: exportColumns}},
|
||||
{extend: 'print', title: 'Products', text: 'Print',exportOptions: {columns: exportColumns}},
|
||||
{extend: 'copy', text: 'Copy', titleAttr: 'Copy',exportOptions: {columns: exportColumns}},
|
||||
{extend: 'csv', text: 'CSV', title: 'Products',exportOptions: {columns: exportColumns}}
|
||||
],
|
||||
"language": {
|
||||
"search": "Search: " // Customize search label
|
||||
|
||||
@ -762,7 +762,7 @@ $(document).ready(function() {
|
||||
}
|
||||
newRow += '</select></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)" onkeydown="return false;" /></td>' +
|
||||
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="1" max="" name="quantity[]" onchange="updateThirdColumnValue(this); updateTaxAmount(this)" onkeydown="return false;" /></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:13%;"><input type="text" class="form-control tax-amount" name="tax-amount[]" readonly /></td>' +
|
||||
|
||||
Loading…
Reference in New Issue
Block a user