921 lines
29 KiB
PHP
921 lines
29 KiB
PHP
<!-- <?php echo $creditstatus;?> -->
|
|
<?php
|
|
|
|
$Secondary='';
|
|
$State='';
|
|
|
|
//echo "inv".$parentinvoiceqty;
|
|
|
|
//print_r($invoice);
|
|
$readonlycheck='';
|
|
$readonlycheck = $invoice->is_read_only;
|
|
|
|
//echo $readonlycheck;
|
|
|
|
$invqty=0;
|
|
|
|
foreach($clientid as $c)
|
|
{
|
|
$client = $c->client_id;
|
|
}
|
|
|
|
if(!empty($items))
|
|
{
|
|
foreach($items as $item)
|
|
{
|
|
|
|
$invqty=$item->item_quantity;
|
|
}
|
|
}
|
|
|
|
|
|
//print_r($items);
|
|
|
|
|
|
$inv_st='';
|
|
|
|
if(!empty($GetSecondary))
|
|
{
|
|
foreach ($GetSecondary as $GetSec)
|
|
{
|
|
$Secondary = $GetSec->Secondary;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
//echo $Secondary;
|
|
|
|
if(!empty($GetState))
|
|
{
|
|
foreach ($GetState as $GetState)
|
|
{
|
|
$State = $GetState->client_state;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
// print_r($statecode);
|
|
|
|
$primarystatecode='';
|
|
foreach ($GetClientPrimaryStateCode as $primary)
|
|
{
|
|
$primarystatecode=$primary->client_custom_fieldvalue;
|
|
}
|
|
|
|
$secondarystatecode='';
|
|
|
|
foreach ($GetClientSecondaryStateCode as $secondary)
|
|
{
|
|
$secondarystatecode=$secondary->client_custom_fieldvalue;
|
|
}
|
|
|
|
?>
|
|
|
|
<style type="text/css">
|
|
.select2
|
|
{
|
|
width: 100% ! important;
|
|
}
|
|
.num{
|
|
text-align:right;
|
|
}
|
|
|
|
.deleteClick {
|
|
border: none;
|
|
text-align: left;
|
|
|
|
}
|
|
|
|
|
|
|
|
.deleteClick {background-color: #FFF;}
|
|
</style>
|
|
|
|
|
|
<script>
|
|
$(function () {
|
|
// Select2 for all select inputs
|
|
$(".simple-select").select2();
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
<!-- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> -->
|
|
<?php $row=1;?>
|
|
|
|
<!-- <?php print_r($items);?> -->
|
|
<?php if(!empty($items)){?>
|
|
<?php foreach($items as $item){?>
|
|
|
|
<div class="table-responsive">
|
|
<p>
|
|
<table id="item_table" class="items table table-condensed table-bordered no-margin">
|
|
<thead>
|
|
<tr>
|
|
<th></th>
|
|
<th><?php _trans('item'); ?></th>
|
|
<th><?php _trans('description'); ?></th>
|
|
<th><?php _trans('UOM'); ?></th>
|
|
<th><?php _trans('quantity'); ?></th>
|
|
<th><?php _trans('price'); ?></th>
|
|
<th><?php _trans('Item Discount'); ?></th>
|
|
<th><?php _trans('CGST'); ?></th>
|
|
<th><?php _trans('SGST'); ?></th>
|
|
<th><?php _trans('IGST'); ?></th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="new_row" class="item">
|
|
<div>
|
|
<tr id="'+addrowcount+'">
|
|
<td class="td-icon"><i class="fa fa-arrows cursor-move"></i></td>
|
|
|
|
<td class="td-text">
|
|
<input type="hidden" id="invoice_id<?php echo $row?>" name="invoice_id<?php echo $row?>" value="<?php echo $invoice_id;?>">
|
|
<input type="hidden" name="item_id<?php echo $row?>" id="item_id<?php echo $row?>" value="<?php echo $item->item_id; ?>">
|
|
<input type="hidden" name="item_product_id<?php echo $row?>"" id="item_product_id<?php echo $row?>" value="<?php echo $item->item_product_id;?>">
|
|
<input type="hidden" name="item_task_id<?php echo $row?>" id="item_task_id<?php echo $row?>" class="item-task-id" value="">
|
|
|
|
<input type="text" name="item_name<?php echo $row?>" id="item_name<?php echo $row?>" class="input-sm form-control" value="<?php echo $item->item_name?>" > </td>
|
|
|
|
<td class="td-text" style="width:220px;"><select class="form-control required" id="item_description<?php echo $row?>" name="item_description<?php echo $row?>" onchange="changeItemDesc(this,addrowcount);"
|
|
<?php foreach($products as $product):
|
|
|
|
|
|
for($i = $product->product_id; $i <= $product->product_id; $i++): ?>
|
|
<option value="<?php echo $product->product_description; ?>" name="<?php echo $product->product_description ?>" id="<?php echo $product->product_description ?>"
|
|
<?php check_select($item->product_description, $product->product_description); ?>>
|
|
<?php echo htmlsc($product->product_description); ?>
|
|
</option>
|
|
<?php endfor;
|
|
endforeach;
|
|
?>
|
|
</select></td>
|
|
|
|
<td class="td-text"> <select class="form-control required" id="item_product_unit_id<?php echo $row?>" name="item_product_unit_id<?php echo $row?>">
|
|
<option value="0"><?php _trans('none'); ?></option>
|
|
<?php foreach ($units as $unit) { ?>
|
|
<option value="<?php echo $unit->unit_id; ?>"
|
|
<?php check_select($item->item_product_unit_id, $unit->unit_id); ?>>
|
|
<?php echo htmlsc($unit->unit_name) . "/" . htmlsc($unit->unit_name_plrl); ?>
|
|
</option>
|
|
<?php } ?>
|
|
</select></td>
|
|
|
|
<td class="td-amount td-quantity"> <div class="input-group">
|
|
<input type="text" name="item_quantity<?php echo $row?>" id="item_quantity<?php echo $row;?>" class="input-sm form-control amount" value="<?php echo $item->item_quantity?>" onkeypress="return isNumberKey(event)";>
|
|
</div> </td>
|
|
|
|
<td class="td-amount"> <div class="input-group">
|
|
<input type="text" name="item_price<?php echo $row?>" id="item_price<?php echo $row?>" class="input-sm form-control amount" value="<?php echo $item->item_price?>" >
|
|
</div></td>
|
|
|
|
<td class="td-amount"> <div class="input-group">
|
|
<input type="text" name="item_discount_amount<?php echo $row?>" id="item_discount_amount<?php echo $row?>" class="input-sm form-control amount" value="<?php echo format_amount($item->item_discount_amount);?>" data-toggle="tooltip" data-placement="bottom" title="<?php echo get_setting('currency_symbol') . ' ' . trans('per_item'); ?>">
|
|
</div></td>
|
|
|
|
<td><div class="input-group">
|
|
<select class="form-control required Pay" required id="Cgst_item_tax_rate_id<?php echo $row?>" required name="Cgst_item_tax_rate_id<?php echo $row?>">
|
|
<option value="-1">Select</option>
|
|
|
|
<?php if ($invoice->is_read_only == 1) {
|
|
echo 'disabled="disabled"';
|
|
} ?>>
|
|
<option value="0"><?php _trans('none'); ?></option>
|
|
<?php foreach ($tax_rates as $tax_rate) { ?>
|
|
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
|
<?php check_select($item->Cgst_item_tax_rate_id, $tax_rate->tax_rate_id); ?>>
|
|
<?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . $tax_rate->tax_rate_name; ?>
|
|
</option>
|
|
<?php } ?>
|
|
|
|
</select>
|
|
|
|
</div></td>
|
|
|
|
<td><div class="input-group">
|
|
<select class="form-control required Pay" required id="Sgst_item_tax_rate_id<?php echo $row?>" required name="Sgst_item_tax_rate_id<?php echo $row?>">
|
|
<?php if ($invoice->is_read_only == 1) {
|
|
echo 'disabled="disabled"';
|
|
} ?>>
|
|
<option value="0"><?php _trans('none'); ?></option>
|
|
<?php foreach ($tax_rates as $tax_rate) { ?>
|
|
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
|
<?php check_select($item->Sgst_item_tax_rate_id, $tax_rate->tax_rate_id); ?>>
|
|
<?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . $tax_rate->tax_rate_name; ?>
|
|
</option>
|
|
<?php } ?>
|
|
</select>
|
|
|
|
</div></td>
|
|
<td><div class="input-group" id="input-group">
|
|
<select class="form-control required Pay" required id="Igst_item_tax_rate_id<?php echo $row?>" required name="Igst_item_tax_rate_id<?php echo $row?>">
|
|
<?php if ($invoice->is_read_only == 1) {
|
|
echo 'disabled="disabled"';
|
|
} ?>>
|
|
<option value="0"><?php _trans('none'); ?></option>
|
|
<?php foreach ($tax_rates as $tax_rate) { ?>
|
|
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
|
<?php check_select($item->Igst_item_tax_rate_id, $tax_rate->tax_rate_id); ?>>
|
|
<?php echo format_amount($tax_rate->tax_rate_percent) ?>
|
|
</option>
|
|
<?php } ?>
|
|
</select>
|
|
|
|
</div>
|
|
</td>
|
|
|
|
|
|
|
|
<td class="td-icon text-right td-vert-middle">
|
|
<?php if ($invoice->is_read_only != 1): ?>
|
|
<a href="<?php echo site_url('invoices/delete_item/' . $invoice->invoice_id . '/' . $item->item_id); ?>"
|
|
title="<?php _trans('delete'); ?>">
|
|
<i class="fa fa-trash-o text-danger"></i>
|
|
</a>
|
|
<?php endif; ?>
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
</div>
|
|
</tbody>
|
|
|
|
|
|
</div>
|
|
</table>
|
|
|
|
<?php $row=$row+1;?>
|
|
|
|
<?php } ?>
|
|
<?php }?>
|
|
|
|
<div id="newdiv"> <?php if ($invoice->is_read_only != 1) { ?>
|
|
<button type="button" class="btn btn-default" onclick="add_row()">Add new row</button>
|
|
|
|
<button type="button" class="btn btn-default" onclick="remove_row()">Remove row</button>
|
|
<?php } ?> </div>
|
|
|
|
<div class="row">
|
|
<div class="col-xs-12 visible-xs visible-sm"><br></div>
|
|
|
|
<div class="col-xs-6 col-lg-6 col-md-6">
|
|
<?php $this->layout->load_view('upload/dropzone-invoice-html'); ?>
|
|
<?php $this->layout->load_view('upload/dropzone-invoice-scripts'); ?>
|
|
</div>
|
|
|
|
<div class="col-xs-6 col-lg-6 col-md-6 ">
|
|
<table class="table table-bordered text-right">
|
|
<tr>
|
|
<td style="width: 40%;"><?php _trans('subtotal'); ?></td>
|
|
<td style="width: 60%;"
|
|
class="amount" id="subtotal"><?php echo format_currency($invoice->invoice_item_subtotal); ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td><?php _trans('item_tax'); ?></td>
|
|
<td class="amount" id="item_tax"><?php echo format_currency($invoice->invoice_item_tax_total); ?></td>
|
|
</tr>
|
|
|
|
<tr id="inv_hs">
|
|
<td ><?php _trans('invoice_tax'); ?></td>
|
|
<td>
|
|
<?php if ($invoice_tax_rates) {
|
|
foreach ($invoice_tax_rates as $invoice_tax_rate) {
|
|
?>
|
|
<form>
|
|
<button type="button" class="btn btn-xs btn-link"
|
|
onclick="deletetcs();">
|
|
<i class="fa fa-trash-o"></i>
|
|
</button>
|
|
<span class="text-muted" id="tcspercentage">
|
|
<?php echo htmlsc($invoice_tax_rate->invoice_tax_rate_name) . ' ' .($invoice_tax_rate->invoice_tax_rate_percent) . '%' ?>
|
|
</span>
|
|
<span class="amount" id="tcs">
|
|
<?php echo format_currency($invoice_tax_rate->invoice_tax_rate_amount); ?>
|
|
</span>
|
|
</form>
|
|
<?php
|
|
}
|
|
} else {
|
|
echo format_currency('0');
|
|
} ?>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
|
|
?>
|
|
|
|
<tr>
|
|
<td><?php _trans('total');?></td>
|
|
<td class="amount" id="total"><strong><?php echo format_currency($invoice->invoice_total); ?></strong></td>
|
|
</tr>
|
|
|
|
</table>
|
|
</div>
|
|
|
|
|
|
<input type="hidden" name="addclone" id="addclone">
|
|
|
|
</div>
|
|
|
|
|
|
<script>
|
|
|
|
var deletemode='';
|
|
function deletetcs()
|
|
{
|
|
|
|
//$('#deletestatus').text('1');
|
|
//$("#inv_hs").show();
|
|
totalinvoice=$('#total').text();
|
|
subtotalinvoice=$('#subtotal').text();
|
|
itemtax=$('#item_tax').text();
|
|
tcsamount=$('#tcs').text();
|
|
totalinvoice= Number(totalinvoice.replace(/[^0-9\.]+/g,""));
|
|
subtotalinvoice= Number(subtotalinvoice.replace(/[^0-9\.]+/g,""));
|
|
itemtax= Number(itemtax.replace(/[^0-9\.]+/g,""));
|
|
tcsamount= Number(tcsamount.replace(/[^0-9\.]+/g,""));
|
|
result = (totalinvoice - tcsamount).toFixed(2);
|
|
invoice_balance=(subtotalinvoice + itemtax).toFixed(2);
|
|
console.log(result);
|
|
|
|
console.log(invoice_balance);
|
|
//return false;
|
|
$('#tcs').text('0.00');
|
|
$('#tcspercentage').text('0.00');
|
|
var invoice_id = <?php echo json_encode($invoice_id)?>;
|
|
//alert(invoice_id);
|
|
//return false;
|
|
$('#total').text(result);
|
|
//return false;
|
|
$.ajax(
|
|
{
|
|
data:{inv_id:invoice_id,tcs:tcsamount,invoiceamount:result,inv_balance:invoice_balance},
|
|
//alert(data);
|
|
type:"POST",
|
|
url:"<?php echo base_url() ?>index.php/invoices/delete_invoice_tax",
|
|
success:function(res)
|
|
{
|
|
alert('invoice tax deleted successfully');
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
//$("#po_select option[text='it\'s me']").attr("selected","selected");
|
|
|
|
var dropdownpo = document.getElementById('po_select');
|
|
var selectedquotedetails='';
|
|
//console.log(dropdownpo)
|
|
|
|
var inv_status = <?php echo json_encode($inv_st, JSON_PRETTY_PRINT) ?>;
|
|
var inv_id = <?php echo json_encode($invoice_id,JSON_PRETTY_PRINT) ?>;
|
|
//alert(inv_id)
|
|
|
|
if(inv_status == '4')
|
|
{
|
|
|
|
$("#Igst_item_tax_rate_id option").attr("disabled", "disabled");
|
|
$("#Cgst_item_tax_rate_id option").attr("disabled", "disabled");
|
|
$("#Sgst_item_tax_rate_id option").attr("disabled", "disabled");
|
|
$("#item_product_unit_id option").attr("disabled", "disabled");
|
|
$("#description option").attr("disabled","disabled");
|
|
$('input[type="text"], textarea').attr('readonly','readonly');
|
|
|
|
|
|
}
|
|
|
|
|
|
function changeItemDesc(s,addrowcount){
|
|
var jsarray = <?php echo json_encode($products);?>;
|
|
var taxrate = <?php echo json_encode($producttax);?>;
|
|
var primarystate= <?php echo json_encode($primarystatecode);?>
|
|
|
|
//console.log(s);
|
|
var bid = s.id; // button ID
|
|
//alert(bid)
|
|
|
|
var rowcount = bid.replace( /^\D+/g, '');
|
|
//alert(rowcount);
|
|
|
|
var pname ='';
|
|
var pprice ='';
|
|
var pid='';
|
|
var adID = s[s.selectedIndex].value; // get ID
|
|
var adVALUE = s[s.selectedIndex].id; // get value
|
|
|
|
|
|
$.each(jsarray,function(key,value)
|
|
{
|
|
// console.log('adval'+adVALUE);
|
|
// console.log('pro'+value.product_id)
|
|
|
|
if(adVALUE == value.product_id)
|
|
{
|
|
|
|
//alert('if')
|
|
pname = value.product_name;
|
|
pprice = value.product_price;
|
|
pid=value.product_id;
|
|
puom=value.unit_name;
|
|
pcgst=value.cgst;
|
|
psgst=value.sgst;
|
|
pigst=value.igst;
|
|
gst = "% - GST";
|
|
|
|
//alert(pname)
|
|
//console.log(pigst);
|
|
|
|
// console.log(pcgst);
|
|
// console.log(psgst);
|
|
|
|
var CGST=pcgst+gst;
|
|
|
|
$('#item_name'+rowcount).val(pname);
|
|
$('#item_price'+rowcount).val(pprice);
|
|
$('#item_product_id'+rowcount).val(adVALUE);
|
|
|
|
var dropdown = document.getElementById('item_product_unit_id'+rowcount);
|
|
var length=dropdown.length;
|
|
for(var i=0;i<=length;i++)
|
|
{
|
|
var opt=document.getElementById("item_product_unit_id"+rowcount).options[i].text;
|
|
//alert('all'+opt)
|
|
//alert('sel'+puom)
|
|
var opta = opt.substr(0,opt.indexOf('/'));
|
|
var optval=document.getElementById("item_product_unit_id"+rowcount).options[i].value;
|
|
if(puom==opt)
|
|
{
|
|
|
|
$('#item_product_unit_id'+rowcount).val(optval);
|
|
//$('[name=product_unit_id]').val(optval);
|
|
break;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(primarystate=='33')
|
|
{
|
|
|
|
//alert("state if");
|
|
var dropdowncgst = document.getElementById('Cgst_item_tax_rate_id'+rowcount);
|
|
|
|
var cgstlength=dropdowncgst.length;
|
|
for(var i=0;i<cgstlength;i++)
|
|
{
|
|
|
|
var cgst=document.getElementById("Cgst_item_tax_rate_id"+rowcount).options[i].text;
|
|
var optcgst=document.getElementById("Cgst_item_tax_rate_id"+rowcount).options[i].text;
|
|
var optacgst = optcgst.substr(0,optcgst.indexOf('%'));
|
|
var optcgstval=document.getElementById("Cgst_item_tax_rate_id"+rowcount).options[i].value;
|
|
|
|
if(pcgst==optcgst)
|
|
{
|
|
//$('[name=Cgst_item_tax_rate_id]').val(optcgstval);
|
|
$('#Cgst_item_tax_rate_id'+rowcount).val(optcgstval);
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
var dropdownsgst=document.getElementById('Sgst_item_tax_rate_id'+rowcount);
|
|
|
|
var sgstlength=dropdownsgst.length;
|
|
|
|
for(var i=0;i<sgstlength;i++)
|
|
{
|
|
var sgst=document.getElementById("Sgst_item_tax_rate_id"+rowcount).options[i].text;
|
|
var optsgst=document.getElementById("Sgst_item_tax_rate_id"+rowcount).options[i].text;
|
|
var optasgst = optsgst.substr(0,optsgst.indexOf('%'));
|
|
var optsgstval=document.getElementById("Sgst_item_tax_rate_id"+rowcount).options[i].value;
|
|
|
|
if(psgst==optsgst)
|
|
{
|
|
//alert('sgstif')
|
|
//$('[name=Sgst_item_tax_rate_id]').val(optsgstval);
|
|
$('#Sgst_item_tax_rate_id'+rowcount).val(optsgstval);
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
//alert("state else");
|
|
//alert();
|
|
var dropdownigst=document.getElementById('Igst_item_tax_rate_id'+rowcount);
|
|
//console.log(dropdownigst);
|
|
var igstlength=dropdownigst.length;
|
|
// console.log(igstlength)
|
|
for(var i=0;i<igstlength;i++)
|
|
{
|
|
|
|
var igst=document.getElementById("Igst_item_tax_rate_id"+rowcount).options[i].text;
|
|
var optigst=document.getElementById("Igst_item_tax_rate_id"+rowcount).options[i].text;
|
|
var optaigst = optigst.substr(0,optigst.indexOf('%'));
|
|
var optigstval=document.getElementById("Igst_item_tax_rate_id"+rowcount).options[i].value;
|
|
|
|
//console.log(igst);
|
|
|
|
if(pigst==optigst)
|
|
{ //console.log(optaigst);
|
|
//alert('if')
|
|
$('#Igst_item_tax_rate_id'+rowcount).val(optigstval);
|
|
// $('[name=Igst_item_tax_rate_id]').val(optigstval);
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
//alert(pname+':'+pprice+':'+pid);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var parentqty = <?php echo json_encode($parentinvoiceqty, JSON_PRETTY_PRINT) ?>;
|
|
|
|
var qtychange=0;
|
|
function valuecheck1(addrowcount)
|
|
{
|
|
// alert(addrowcount)
|
|
// alert(parentqty)
|
|
//alert(qty)
|
|
|
|
var qty= $('#item_quantity'+addrowcount).val();
|
|
//alert(qty)
|
|
|
|
if(parentqty !='')
|
|
{
|
|
if(Math.abs(qty)>parentqty)
|
|
{
|
|
alert("You are Exceeding the allowed Quantity, Max Allowed Qty is"+parentqty);
|
|
var alloqty = '-'+parentqty;
|
|
//alert(alloqty);
|
|
$('#item_quantity'+addrowcount).val(alloqty);
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
qtychange=1;
|
|
valuecheck()
|
|
}
|
|
|
|
function valuecheck()
|
|
{
|
|
|
|
|
|
var balqty = <?php echo json_encode($balancequoteqty);?>;
|
|
var orderedqty = <?php echo json_encode($orderedquoteqty);?>;
|
|
var suppliedqty = <?php echo json_encode($suppliedquoteqty);?>;
|
|
var invoiceqty = <?php echo json_encode($invqty);?>;
|
|
var suppliedqty='';
|
|
var balanceqty= '';
|
|
var actualbalanceqty='';
|
|
var actsuppliedqty='';
|
|
// alert(invoiceqty)
|
|
|
|
//alert(balqty)
|
|
// if(qtychange == 1)
|
|
// {
|
|
|
|
if(selectedquotedetails != '' || balqty != '')
|
|
{
|
|
|
|
//alert(balqty)
|
|
//console.log(selectedquotedetails)
|
|
if(selectedquotedetails != '')
|
|
{
|
|
var balcqty= selectedquotedetails[0]['item_balancequantity'];
|
|
var ordqty= selectedquotedetails[0]['item_quantity'];
|
|
var supqty= selectedquotedetails[0]['item_suppliedquantity'];
|
|
}
|
|
|
|
else
|
|
{
|
|
var balcqty= balqty;
|
|
var ordqty= orderedqty;
|
|
var supqty= suppliedqty;
|
|
|
|
}
|
|
|
|
if(invoiceqty !=0)
|
|
{
|
|
|
|
actualbalanceqty = parseFloat(balcqty)+parseFloat(invoiceqty);
|
|
actsuppliedqty = parseFloat(supqty) - parseFloat(invoiceqty);
|
|
}
|
|
else
|
|
{
|
|
//alert("else")
|
|
actualbalanceqty = balcqty;
|
|
actsuppliedqty = supqty;
|
|
|
|
}
|
|
|
|
var last_item_row = $('#item_table tbody:last');
|
|
var qty = last_item_row.find('input[name=item_quantity]').val();
|
|
|
|
if(parseFloat(suppliedqty)==0)
|
|
{
|
|
|
|
if(parseFloat(qty)>parseFloat(ordqty))
|
|
{
|
|
// alert("sup0")
|
|
alert("You Are Exceeding the allowed Quantity")
|
|
return false;
|
|
}
|
|
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
//alert("sup not 0")
|
|
if(parseFloat(qty)>parseFloat(actualbalanceqty))
|
|
{
|
|
|
|
alert("You Are Exceeding the allowed Quantity");
|
|
return false;
|
|
}
|
|
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
return true
|
|
}
|
|
// }
|
|
|
|
// else
|
|
// {
|
|
// return true
|
|
// }
|
|
}
|
|
|
|
|
|
function isNumberKey(evt)
|
|
{
|
|
var charCode = (evt.which) ? evt.which : evt.keyCode;
|
|
// Added to allow decimal, period, or delete
|
|
if (charCode == 110 || charCode == 190 || charCode == 46)
|
|
return true;
|
|
|
|
if (charCode > 31 && (charCode < 48 || charCode > 57))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
//var addrowcount=0;
|
|
addrowcount= <?php echo json_encode($row,JSON_PRETTY_PRINT) ?>;
|
|
function add_row()
|
|
{
|
|
|
|
// addrowcount=addrowcount+1;
|
|
|
|
|
|
$('#addclone').val(addrowcount);
|
|
//alert(addrowcount);
|
|
// $('#new_row').clone().appendTo('#item_table').removeAttr('id',addrowcount).addClass('item1').show();
|
|
|
|
|
|
// var num = $('.clonedInput').length;
|
|
//alert(addrowcount)
|
|
|
|
var div_id;
|
|
var div = document.createElement('div');
|
|
div.id = "divid"+addrowcount;
|
|
div.className="row";
|
|
|
|
|
|
//div.style.cssText = "border:1px dashed; margin-left:0px;margin-right:0px; height:50px;width:1200px";
|
|
div.innerHTML='<div class="table-responsive">'+
|
|
'<p>'+
|
|
'<table id="item_table" class="items table table-condensed table-bordered no-margin">'+
|
|
'<thead>'+
|
|
'<tr>'+
|
|
'<th></th>'+
|
|
'<th><?php _trans('item'); ?></th>'+
|
|
'<th><?php _trans('description'); ?></th>'+
|
|
'<th><?php _trans('UOM'); ?></th>'+
|
|
'<th><?php _trans('quantity'); ?></th>'+
|
|
'<th><?php _trans('price'); ?></th>'+
|
|
'<th><?php _trans('Item Discount'); ?></th>'+
|
|
'<th><?php _trans('CGST'); ?></th>'+
|
|
'<th><?php _trans('SGST'); ?></th>'+
|
|
'<th><?php _trans('IGST'); ?></th>'+
|
|
'<th></th>'+
|
|
'</tr>'+
|
|
'</thead>'+
|
|
'<tbody id="new_row" class="item">'+
|
|
'<div>'+
|
|
'<tr id="'+addrowcount+'">'+
|
|
'<td class="td-icon"><i class="fa fa-arrows cursor-move"></i></td>'+
|
|
|
|
'<td class="td-text"><input type="hidden" name="invoice_id'+addrowcount+'" value="<?php echo $invoice_id; ?>">'+
|
|
'<input type="hidden" name="item_id'+addrowcount+'" value="">'+
|
|
'<input type="hidden" name="item_product_id'+addrowcount+'" id="item_product_id'+addrowcount+'" value="">'+
|
|
'<input type="hidden" name="item_task_id'+addrowcount+'" class="item-task-id" value="">'+
|
|
|
|
'<input type="text" name="item_name'+addrowcount+'" class="input-sm form-control" id="item_name'+addrowcount+'" value=""> </td>'+
|
|
|
|
'<td class="td-text" style="width:220px;"><select class="form-control required" id="item_description'+addrowcount+'" name="item_description'+addrowcount+'" onchange="changeItemDesc(this,addrowcount);" '+
|
|
'<option value="-1">Select</option>'+
|
|
'</select></td>'+
|
|
|
|
'<td class="td-text"> <select class="form-control required" id="item_product_unit_id'+addrowcount+'" name="item_product_unit_id'+addrowcount+'">'+
|
|
'<option value="-1">Select</option>'+
|
|
'</select></td>'+
|
|
|
|
'<td class="td-amount td-quantity"> <div class="input-group">'+
|
|
'<input type="text" name="item_quantity'+addrowcount+'" id="item_quantity'+addrowcount+'" class="input-sm form-control amount" value="" onkeypress="return isNumberKey(event)";>'+
|
|
'</div> </td>'+
|
|
|
|
'<td class="td-amount"> <div class="input-group">'+
|
|
'<input type="text" name="item_price'+addrowcount+'" id="item_price'+addrowcount+'" class="input-sm form-control amount" >'+
|
|
'</div></td>'+
|
|
|
|
'<td class="td-amount"> <div class="input-group">'+
|
|
'<input type="text" name="item_discount_amount'+addrowcount+'" id="item_discount_amount'+addrowcount+'" class="input-sm form-control amount" value="" data-toggle="tooltip" data-placement="bottom" title="<?php echo get_setting('currency_symbol') . ' ' . trans('per_item'); ?>">'+
|
|
'</div></td>'+
|
|
|
|
'<td><div class="input-group">'+
|
|
'<select class="form-control required Pay" required id="Cgst_item_tax_rate_id'+addrowcount+'" required onchange="changevalue();" name="Cgst_item_tax_rate_id'+addrowcount+'">'+
|
|
'<option value="-1">Select</option>'+
|
|
'</select>'+
|
|
|
|
'</div></td>'+
|
|
|
|
'<td><div class="input-group">'+
|
|
'<select class="form-control required Pay" required id="Sgst_item_tax_rate_id'+addrowcount+'" required onchange="changevalue();" name="Sgst_item_tax_rate_id'+addrowcount+'">'+
|
|
'<option value="-1">Select</option>'+
|
|
'</select>'+
|
|
|
|
'</div></td>'+
|
|
'<td><div class="input-group" id="input-group">'+
|
|
'<select class="form-control required Pay" required id="Igst_item_tax_rate_id'+addrowcount+'" required onchange="changevalue();" name="Igst_item_tax_rate_id'+addrowcount+'">'+
|
|
'<option value="-1">Select</option>'+
|
|
'</select>'+
|
|
|
|
'</div></td>'+
|
|
|
|
'</tr>'+
|
|
'</div>'+
|
|
'</tbody>'+
|
|
''+
|
|
|
|
'</div>';
|
|
$('#newdiv').append(div);
|
|
|
|
|
|
var product_option= <?php echo json_encode($products) ?>;
|
|
|
|
var option = '';
|
|
$.each(product_option,function(i,obj){
|
|
|
|
option += "<option value='"+obj.product_description+"' id="+obj.product_id+">"+obj.product_description+"</option>";
|
|
});
|
|
|
|
$('#item_description'+addrowcount).append(option);
|
|
|
|
// <option value='" + item.Brand + "'>
|
|
|
|
var uom = <?php echo json_encode($units)?>;
|
|
var uomoption='';
|
|
$.each(uom,function(iuom,obj){
|
|
|
|
uomoption += "<option value="+obj.unit_id+">"+obj.unit_name+"</option>";
|
|
|
|
});
|
|
|
|
//console.log(uomoption)
|
|
$('#item_product_unit_id'+addrowcount).append(uomoption);
|
|
|
|
|
|
var tax = <?php echo json_encode($tax_rates)?>;
|
|
var taxoption='';
|
|
$.each(tax,function(itax,obj){
|
|
|
|
taxoption += "<option value="+obj.tax_rate_id+">"+obj.tax_rate_percent+"</option>";
|
|
|
|
});
|
|
|
|
$('#Cgst_item_tax_rate_id'+addrowcount).append(taxoption);
|
|
$('#Sgst_item_tax_rate_id'+addrowcount).append(taxoption);
|
|
$('#Igst_item_tax_rate_id'+addrowcount).append(taxoption);
|
|
|
|
|
|
addrowcount=addrowcount+1;
|
|
|
|
}
|
|
|
|
//var x = document.getElementById("item_table").rows.length;
|
|
var x= <?php echo json_encode($row, JSON_PRETTY_PRINT) ?>;
|
|
//alert(x)
|
|
|
|
var readonly = <?php echo json_encode($readonlycheck, JSON_PRETTY_PRINT) ?>;
|
|
|
|
//alert(readonly)
|
|
|
|
var qty= '';
|
|
var price = '';
|
|
var discount = '';
|
|
|
|
for(var i=1;i<x;i++)
|
|
{
|
|
if(readonly == '1')
|
|
{
|
|
//alert('loop');
|
|
//alert(i)
|
|
|
|
document.getElementById("item_quantity"+i).readOnly = true
|
|
document.getElementById("item_price"+i).readOnly = true
|
|
document.getElementById("item_discount_amount"+i).readOnly = true
|
|
document.getElementById("item_name"+i).readOnly = true
|
|
|
|
$("#item_description"+i).attr("style", "pointer-events: none;");
|
|
$("#Cgst_item_tax_rate_id"+i).attr("style", "pointer-events: none;");
|
|
$("#Sgst_item_tax_rate_id"+i).attr("style", "pointer-events: none;");
|
|
$("#Igst_item_tax_rate_id"+i).attr("style", "pointer-events: none;");
|
|
$("#item_product_unit_id"+i).attr("style", "pointer-events: none;");
|
|
}
|
|
}
|
|
|
|
|
|
function deleterow(o)
|
|
{
|
|
// alert(addrowcount);
|
|
alert(o)
|
|
|
|
// $(this).closest('tr').remove();
|
|
|
|
var p=o.parentNode.parentNode;
|
|
//p.parentNode.removeChild(p);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function remove_row()
|
|
{
|
|
|
|
var act_row = parseFloat(addrowcount)-1;
|
|
addrowcount=act_row;
|
|
//alert(act_row);
|
|
if(addrowcount<=1)
|
|
{
|
|
alert('Please Add A Row');
|
|
}
|
|
|
|
else
|
|
{
|
|
document.getElementById("divid"+act_row).remove();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|