ria/application/views/editincomeexpenses.php
2018-04-24 12:57:39 +05:30

1168 lines
37 KiB
PHP
Executable File

<?php //
$accountcode1='';
$type1='';
$viewdep='';
$dropdown='';
$date1='';
$gst1='';
$invoiceno1='';
$Merchant1='';
$MerchantGST1='';
$HSNSAC1='';
$valuebeforegst1='';
$SGST1='';
$CGST1='';
$IGST1='';
$Description1='';
$towhom1='';
$id='';
$file1='';
$document = '';
$subdesc ='';
$checked = '';
if(!empty($RecepitPayment))
{
foreach ($RecepitPayment as $rd)
{
$document =$rd->document;
$final = base_url().$document;
$accountcode1=$rd->account_code;
$id=$rd->id;
$type1=$rd->type;
$viewdep=$rd->total;
$dropdown=$rd->name;
$date1=$rd->date;
$invoiceno1=$rd->invoice_no;
$Merchant1=$rd->merchant;
$MerchantGST1=$rd->merchant_gst;
$HSNSAC1=$rd->HSN;
$valuebeforegst1=$rd->value_before_gst;
if($valuebeforegst1 != '')
{
$checked = 'checked';
}
else
{
$checked = '';
}
$SGST1=$rd->sgst;
$CGST1=$rd->cgst;
$IGST1=$rd->igst;
$Description1=$rd->description;
$towhom1=$rd->towhom;
$subdesc = $rd->paymentsubdesc;
}}
if(!empty($PaymentMultiple))
{
foreach ($PaymentMultiple as $pm)
{
$document =$pm->document;
$final = base_url().$document;
$accountcode1=$pm->account_code;
$id=$pm->id;
$type1=$pm->type;
$viewdep=$pm->total;
$dropdown=$pm->name;
$date1=$pm->date;
$invoiceno1=$pm->invoice_no;
$Merchant1=$pm->merchant;
$MerchantGST1=$pm->merchant_gst;
$HSNSAC1=$pm->HSN;
$valuebeforegst1=$pm->value_before_gst;
$SGST1=$pm->sgst;
$CGST1=$pm->cgst;
$IGST1=$pm->igst;
$Description1=$pm->description;
$towhom1=$pm->towhom;
$subdesc = $pm->paymentsubdesc;
}}
?>
<div class="content-wrapper" style="min-height: 537px;">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<!-- <center> Resico Industries - Edit <?php echo ucwords(strtolower($type1)); ?> Details </center> -->
<center><?php echo $pageTitle . ucwords(strtolower($type1)); ?> Details </center>
</h1>
</section>
<section class="content">
<div style="text-align:right;">
<a href="<?php echo base_url() ?>cashbook/incomeExpenseList" class="btn btn-primary" value="Back"/>Back</a>
</div>
<br>
<?php if($type1 == 'RECEIPT'){?>
<div id="Receipt">
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<!-- <div class="box-header">
<h3 class="box-title">Edit Receipt</h3>
</div>
-->
<!-- <form role="form" id="addIncomeExpense" action="<?php echo base_url() ?>updateExpense" enctype="multipart/form-data" method="post"> -->
<form role="form" id="updateReceipt" action="<?php echo base_url() ?>cashbook/updateReceipt" enctype="multipart/form-data" method="post">
<div class="box-body">
<div class="row">
<div class="col-md-12">
<!-- <div class="col-md-3">
<div class="form-group">
<b><span for="Accountcode">Select Account type:</span> </b> </br></br>
<input type="radio" onclick = loadAccountType(this.id); id="myradio1" name="myradio" value="1" checked>RECEIPT &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" onclick = loadAccountType(this.id); id="myradio2" name="myradio" value="2" >PAYMENT
</div>
</div> -->
<div class="col-md-3"><div class="form-group"><b>
<span for="Accountname">Account Name Select:</span> </b><span style="color:red">*</span> </br></br>
<select class="form-control required " required id="accode" required name="accode" >
<option value="-1">Account Name Select</option>
</select>
</div></div>
<div class="col-md-3"><div class="form-group">
<b><span for="Date">Date:</span></b><span style="color:red">*</span></br></br>
<input type="text" class="form-control required" id="Date" name="Date" value="<?php echo $date1; ?>">
</div></div>
<div class="col-md-3"><div class="form-group"><b>
<span for="towhome" id="towhom">Recevied From</span></b><span style="color:red">*</span></br></br>
<input type="text" class="form-control required" id="towhome" name="towhome" value="<?php echo $towhom1; ?>">
</div></div>
</div><!-- row -->
</div><!-- 12-md-->
<div class="row">
<div class="col-md-12"><div class="col-md-3">
<input type="checkbox" id="gst" name="gsttoggle" <?php echo $checked;?> > GST
</div></div>
</div>
<div class="row" id="gstarea" style="border:1px dashed; margin-left:0px;margin-right:0px;display:none;">
<div class="col-md-12">
<div class="col-md-3"><div class="form-group">
<b><span for="Invoiceno">Invoice No:</span></b>
<input type="text" class="form-control required" id="Invoiceno" name="Invoiceno" value="<?php echo $invoiceno1; ?>">
</div></div>
<div class="col-md-3"><div class="form-group">
<b><span for="Merchant">Merchant Name:</span></b>
<input type="text" class="form-control required" id="merchant" name="merchant" value="<?php echo $Merchant1; ?>">
</div></div>
<div class="col-md-3"><div class="form-group">
<b><span for="Merchantgst">Merchant GST No:</span></b>
<input id="merchantgst" name="Merchantgst" class="form-control" value="<?php echo $MerchantGST1 ; ?>">
</div></div>
<div class="col-md-3"><div class="form-group">
<b><span for="HSN/SAC Code">HSN/SAC Code:</span></b>
<input id="hsn" name="hsn" class="form-control" value="<?php echo $HSNSAC1; ?>">
</div></div>
</div>
<div class="col-md-12">
<div class="col-md-3"><div class="form-group">
<b><span for="ValuebeforeGST">Value before GST(&#8377;):</span></b>
<input id="valuebeforegST" name="valuebeforegST" style="text-align:right;" class="form-control" onkeypress="return isNumberKey(event)" value="<?php echo $valuebeforegst1; ?>" onchange="calculateTotal()">
</div></div>
<div class="col-md-3"><div class="form-group">
<b><span for="SGST">SGST(&#8377;):</span></b>
<input type="text" class="form-control" style="text-align:right;" onchange="GSTvalue(this.id)" id="SGST" name="SGST" onkeypress="return isNumberKey(event)" value="<?php echo $SGST1; ?>">
</div></div>
<div class="col-md-3"><div class="form-group">
<b><span for="CGST">CGST(&#8377;):</span></b>
<input type="text" class="form-control" id="CGST" style="text-align:right;" name="CGST" onkeypress="return isNumberKey(event)" value="<?php echo $CGST1; ?>" onchange="GSTvalue(this.id)">
</div></div>
<div class="col-md-3"><div class="form-group">
<b><span for="IGST">IGST(&#8377;):</span></b>
<input type="text" class="form-control" style="text-align:right;" onkeypress="return isNumberKey(event)" onchange = GSTvalue(this.id) id="IGST" name="IGST" value="<?php echo $IGST1; ?>">
</div></div>
</div>
</div> <!-- /End of GST Area -->
<div class="row">
<div class="col-md-12">
<div class="col-md-4">
<b><span for="Total">Total Amount(&#8377;):</span></b><span style="color:red">*</span>
<input type="text" class="form-control" id="totalamount" name="totalamount" onkeypress="return isNumberKey(event)" style="text-align:right;" value="<?php echo $viewdep; ?>">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-4">
<b><span for="Description">Description:</span></b>
<textarea class="form-control" id="description" name="description">
<?php echo $Description1;?>
</textarea>
</div>
<div class="col-md-4" style="border:0px solid;">
<b><span for="Description">File Upload: <span id="strname"><?php $strname = explode("/",$document); echo $strname[2]; ?></span></span></b>
<img id="receiptslip" src="<?php echo $final ?>" alt="No Receipt Available" style="width: 139px;height:139px;"/><br/>
<input type="button" onclick="DeleteRow();"class="btn btn-primary" value="Delete" />
<!-- <b><span for="Description">File Upload:</span></b> -->
<input type='file' input accept=".JPG,.PNG,.PDF" onchange="readURL(this);" id="recepitfile" name="myfile" value="<?php echo $document; ?>">
</div>
<div>
<input type="hidden" id="oldfile" style="text-align:right;" name="oldfile" value="<?php echo $document; ?>">
<input type="hidden" id="deleteflag" style="text-align:right;" name="deleteflag" value="0">
</div>
</div>
</div>
<div><!-- This div for hidden datas-->
<input type="hidden" class="form-control read_only" id="id1" name="id1" value="<?php echo $id; ?>">
<input type="hidden" class="form-control read_only" id="accode1" name="accode1" value="<?php echo $accountcode1; ?>">
</div>
</div><!-- /.box-body -->
<div class="box-footer" style="text-align:right">
<input type="button" onclick="validate();"class="btn btn-primary" value="Update Recepit" />
<input type="reset" id="resetReceipt" class="btn btn-primary" value="Reset" />
</div>
</form>
</div><!-- box-primary div-->
</div><!-- col-md-12 div-->
</div><!-- row div-->
</div><!-- tabcontent-->
<?php } else { ?>
<!--- Payment tab content start -->
<div id="Payment">
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<!-- <div class="box-header">
<h3 class="box-title">Edit Payment</h3>
</div>-->
<form role="form" id="updatePayment" action="<?php echo base_url() ?>cashbook/updatePayment" enctype="multipart/form-data" method="post">
<div class="box-body">
<div class="row">
<div class="col-md-12">
<div class="col-md-3"><div class="form-group">
<b><span for="PaymentDate">Date:</span></b><span style="color:red">*</span></br></br>
<input type="text" class="form-control required" id="PaymentDate" name="PaymentDate" value="<?php echo $date1;?>" >
</div></div>
<div class="col-md-3"><div class="form-group">
<b><span for="PaymentPaidto">Paid To:</span></b><span style="color:red">*</span></br></br>
<input type="text" class="form-control required" id="PaymentPaidto" name="PaymentPaidto" value="<?php echo $towhom1; ?>">
</div></div>
<div class="col-md-3"><div class="form-group">
<b><span for="PaymentMerchant">Merchant Name:</span></b></br></br>
<input type="text" class="form-control required" id="Paymentmerchant" name="Paymentmerchant" value="<?php echo $Merchant1; ?>">
</div></div>
<div class="col-md-3"><div class="form-group">
<b><span for="PaymentMerchantgst">Merchant GST No:</span></b></br></br>
<input id="Paymentmerchantgst" name="PaymentMerchantgst" class="form-control" value="<?php echo $MerchantGST1 ; ?>">
</div></div>
</div>
<div class="col-md-12">
<div class="col-md-3"><div class="form-group">
<b><span for="Paymentvoucher">Voucher Code:</span></b><span style="color:red">*</span></br></br>
<input id="Paymentvouchercode" name="Paymentvouchercode" value="<?php echo $invoiceno1; ?>" class="form-control" required onkeypress="return isNumberKey(event)" >
</div></div>
<div class="col-md-3"><div class="form-group">
<b><span for="HSN/SAC Code">HSN/SAC Code:</span></b></br></br>
<input id="Paymenthsn" name="Paymenthsn" class="form-control" value="<?php echo $HSNSAC1; ?>">
</div></div>
<div class="col-md-3"><div class="form-group">
<b><span for="ValuebeforeGST">Value before GST(&#8377;):</span></b><!--<span style="color:red">*</span>--></br></br>
<input id="PaymentvaluebeforegST" name="PaymentvaluebeforegST" style="text-align:right;" class="form-control" onkeypress="return isNumberKey(event)" value="<?php echo $valuebeforegst1; ?>" readonly>
</div></div>
<div class="col-md-3"><div class="form-group">
<b><span for="SGST">SGST(&#8377;):</span><span style="color:red">*</span></b></br></br>
<input type="text" class="form-control" style="text-align:right;" onchange="PaymentGSTvalue(this.id)" id="PaymentSGST" name="PaymentSGST" onkeypress="return isNumberKey(event)" value="<?php echo $SGST1; ?>">
</div> </div>
</div>
<div class="col-md-12">
<div class="col-md-3"><div class="form-group">
<b><span for="CGST">CGST(&#8377;):</span><span style="color:red">*</span></b></br></br>
<input type="text" class="form-control" id="PaymentCGST" style="text-align:right;" name="PaymentCGST" onkeypress="return isNumberKey(event)" onchange="PaymentGSTvalue(this.id)" value="<?php echo $CGST1; ?>">
</div></div>
<div class="col-md-3"><div class="form-group">
<b><span for="IGST">IGST(&#8377;):</span></b></br></br>
<input type="text" class="form-control" style="text-align:right;" onkeypress="return isNumberKey(event)" onchange = PaymentGSTvalue(this.id) id="PaymentIGST" name="PaymentIGST" value="<?php echo $IGST1; ?>">
</div></div>
</div>
</div>
<div class="row" style="border:1px dashed; margin-left:0px;margin-right:0px;">
<div class="col-md-12">
<div class="col-md-3"><div class="form-group">
<b><span for="PaymentAccname">Account Name Select:</span><span style="color:red">*</span>
<select class="form-control required " required id="Paymentaccode1" required name="mydata1[Paymentaccode1]">
<option value="-1">Account Name Select</option>
</select>
</div></div>
<div class="col-md-3"><div class="form-group">
<b><span for="Decription"><b>Account Description:</b></span><span style="color:red">*</span>
<input type="text" class="form-control" style="text-align:right;" id="subdescription1" name="mydata1[subdescription1]" requried>
</div></div>
<div class="col-md-3"><div class="form-group">
<span for="amount"><b>Amount(&#8377;):</b></span><span style="color:red">*</span>
<input type="text" class="form-control" style="text-align:right;" id="Paymentamount1" name="mydata1[Paymentamount1]" onchange="paymenttotalamount();" requried onkeypress="return isNumberKey(event)">
</div></div>
<!-- <div class="col-md-offset-10 col-md-2"> -->
<div class="col-md-offset-2 col-md-1" style="padding-top:15px;padding-left:0px"><div class="form-group">
<input type="button" id ="addmorebutton" onclick="add_more();" value=" + ADD MORE">
</div></div>
</div>
</div>
<?php
if(!empty($PaymentDetails))
{
$paydtlcount = 2;
foreach($PaymentDetails as $paydtl)
{
?>
<div id="divid<?php echo $paydtlcount?>" class="row" style="border:1px dashed; margin-left:0px;margin-right:0px;">
<div class="col-md-12">
<div class="col-md-3"><div class="form-group">
<b><span for="PaymentAccname">Account Name Select:</span>
<select class="form-control required select2" id= "Paymentaccode<?php echo $paydtlcount?>" height required name="mydata<?php echo $paydtlcount?>[Paymentaccode<?php echo $paydtlcount?>]">
<option value="<?php echo $paydtl->Account_code;?>"><?php echo $paydtl->name;?></option>
<?php
if(!empty($dropdownvalues))
{
foreach ($dropdownvalues as $dd)
{
if($dd->type == 'PAYMENT'){
$dropdowncode = $dd->code;
$dropdownname = $dd->name;
if(trim($dropdowncode) != trim($paydtl->Account_code))
{
if ($_POST['$paydtl->Account_code'] == $dropdowncode)
{
echo "<option value=\"".$dropdowncode."\" selected=\"selected\">". $dd->name."</option>";
}
else
{
echo "<option value=\"".$dropdowncode."\">". $dd->name ."</option>";
}
}
}
}
}
?>
</select>
</div></div>
<div class="col-md-3"><div class="form-group">
<b><span for="Decription"><b>Account Description:</b></span>
<input type="text" class="form-control" style="text-align:right;" id="subdescription<?php echo $paydtlcount?>" name="mydata<?php echo $paydtlcount?>[subdescription<?php echo $paydtlcount?>]" requried value="<?php echo $paydtl->Account_description ?>">
</div></div>
<div class="col-md-3"><div class="form-group">
<span for="amount"><b>Amount(&#8377;):</b></span>
<input type="text" class="form-control" style="text-align:right;" id="Paymentamount<?php echo $paydtlcount?>" name="mydata<?php echo $paydtlcount?>[Paymentamount<?php echo $paydtlcount?>]" onchange="paymenttotalamount();" requried value="<?php echo $paydtl->Amount ?>" onkeypress="return isNumberKey(event)">
</div></div>
<input type="hidden" id="hideid<?php echo $paydtlcount?>" name="mydata<?php echo $paydtlcount?>[hideid<?php echo $paydtlcount?>]" value="<?php echo $paydtl->ID?>" >
<input type="hidden" id="hideaccount<?php echo $paydtlcount?>" name="hideaccount<?php echo $paydtlcount?>" value="<?php echo $paydtl->Account_code?>" >
<!-- <div class="col-md-offset-10 col-md-2"> -->
<div class="col-md-offset-2 col-md-1" style="padding-top:15px;padding-left:0px"><div class="form-group">
<input class="remove_this" type="button" id="removebtn<?php echo $paydtlcount?>" value="REMOVE" onclick="removeRow(this.id)">
</div></div>
</div>
</div>
<?php
$paydtlcount++;
}} ?>
<div id="newdiv"></div><!-- this div for add more section-->
<div class="row">
<div class="col-md-12"><div class="col-md-4">
<b><span for="Total">Total Amount(&#8377;):</span></b><!--<span style="color:red">*</span>-->
<input type="text" class="form-control" id="Paymenttotalamount" name="Paymenttotalamount" onkeypress="return isNumberKey(event)" style="text-align:right;" value="<?php echo $viewdep; ?>" readonly>
</div></div>
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-4">
<b><span for="Description">Description:</span></b>
<textarea class="form-control" id="Paymentdescription" name="Paymentdescription" >
<?php echo $Description1;?>
</textarea>
</div>
<div class="col-md-4" style="border:0px solid;">
<b><span for="Description">File Upload: <span id="strname"><?php $strname = explode("/",$document); echo $strname[2]; ?></span></span></b>
<img id="paymentslip" src="<?php echo $final ?>" alt="No Receipt Available" style="width: 139px;height:139px;"/><br/>
<input type="button" onclick="DeleteRow();"class="btn btn-primary" value="Delete" />
<input type='file' input accept=".JPG,.PNG,.PDF" onchange="paymentreadURL(this);" id="paymentfile" name="myfile" value="<?php echo $document; ?>">
</div>
<div>
<input type="hidden" id="oldfile" style="text-align:right;" name="oldfile" value="<?php echo $document; ?>">
<input type="hidden" id="deleteflag" style="text-align:right;" name="deleteflag" value="0">
</div>
</div>
</div>
<div><!-- this div for hidden datas -->
<input type="hidden" class="form-control read_only" id="id1" name="id1" value="<?php echo $id; ?>">
<!-- <input type="hidden" class="form-control read_only" id="hideaccode" name="hideaccode" value="<?php echo $accountcode1; ?>"> -->
<input type="hidden" name="hidepaydtl" id="hidepaydtl" value="<?php echo $paydtlcount;?>" />
<input type="hidden" name="hidecounter" id="hidecounter" value="<?php if($paydtlcount == ''){ echo '1'; }else{ echo $paydtlcount; }?>" />
<input type="hidden" name="hideconstant" id="hideconstant" value="<?php if($paydtlcount == ''){ echo '1'; }else{ echo $paydtlcount; }?>" />
</div>
</div><!-- /.box-body -->
<div class="box-footer" style="text-align:right">
<input type="button" onclick="valid()" class="btn btn-primary" value="Update Payment" />
<input type="reset" id="paymentreset" class="btn btn-primary" value="Reset" />
</div>
</form>
</div><!-- box-primary div-->
</div><!-- col-md-12 div-->
</div><!-- row div-->
</div><!-- tabcontent-->
<?php } ?>
</section><!-- content section -->
</div><!-- content-wrapper div-->
<script>
//var drop=$("input[type=radio][name='range']:checked").val()
$(document).ready(function(){
var type = "<?php echo $type1;?>";
//alert(type);
if(type == "RECEIPT")
{
$('#myradio1').attr('checked','true');
$('#towhom').text('Received From:');
}
else
{
$('#myradio2').attr('checked','true');
$('#towhom').text('Paid To:');
}
});
$(function() {
var t = [];
var index = 0
t= <?php echo json_encode($dropdownvalues)?>;
$.each(t,function(i,item){
if(item.type == '<?php echo $type1?>')
{
$("#accode").append( $('<option></option>').val(item.code).html(item.name));
}
});
$('#accode option[value="<?php echo $accountcode1?>"]').attr("selected", "selected");
if('<?php echo $accountcode1 ?>' != '999'){
$.each(t,function(i,item){
if(item.type == 'PAYMENT')
{
$("#Paymentaccode1").append( $('<option></option>').val(item.code).html(item.name));
}
});
$('#Paymentaccode1 option[value="<?php echo $accountcode1 ?>"]').attr("selected", "selected");
$('#subdescription1').val("<?php echo $subdesc ?>");
$('#Paymentamount1').val(<?php echo $valuebeforegst1 ?>);
}
else{
$.each(t,function(i,item){
if(item.type == 'PAYMENT')
{
$("#Paymentaccode1").append( $('<option></option>').val(item.code).html(item.name));
}
});
}
$('#gst').click(function(){
$('#gstarea').toggle();
});
$("#Date").datepicker({
maxDate :'now',
dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true,
});
$("#PaymentDate").datepicker({
maxDate :'now',
dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true,
});
var value = "<?php echo $valuebeforegst1;?>";
var type = "<?php echo $type1;?>";
if(type == "RECEIPT")
{
if(value != ''){
// $('#gstarea').attr('checked', true);
$('#gstarea').toggle();
}
}
});
function readURL(input,id) {
//alert(id);
$("#strname").remove();
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
if(id == "receiptfile"){
$('#receiptslip')
.attr('src', e.target.result)
.width(100)
.height(100);
}
else{
$('#paymentslip')
.attr('src', e.target.result)
.width(100)
.height(100);
}
// alert(e.target.result);
};
reader.readAsDataURL(input.files[0]);
if(id == "receiptfile"){
$('#receiptslip').val(input.files[0]['name']);}
else{
$('#paymentslip').val(input.files[0]['name']);}
}
}
function paymentreadURL(input) {
$("#strname").remove();
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#payment')
.attr('src', e.target.result)
.width(100)
.height(100);
//alert(e.target.result);
};
reader.readAsDataURL(input.files[0]);
$('#payment').val(input.files[0]['name']);
}
}
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode != 46 && charCode > 31
&& (charCode < 48 || charCode > 57))
return false;
return true;
}
function loadAccountType(id)
{
var id=id;
var t = [];
var ex = [];
var inc = [];
t= <?php echo json_encode($dropdownvalues)?>;
if(id == 'myradio1')
{
$('#accode').find('option').remove().end().append('<option value="-1">Select Account Name</option>').val('Select Account Code');
$.each(t,function(i,item){
if(item.type == 'RECEIPT')
{
$("#accode").append( $('<option></option>').val(item.code).html(item.name));
}
});
}
if(id == 'myradio2')
{
//alert('expense clicked');
$('#accode').find('option').remove().end().append('<option value="-1">Select Account Name</option>').val('Select Account Code');
$.each(t,function(i,item){
if(item.type == 'PAYMENT')
{
$("#accode").append( $('<option></option>').val(item.code).html(item.name));
}
});
}
//alert('final alert');
}
</script>
<!-- old sript above -->
<script>
function validate()
{
var accode = $('#accode').val();
var date = $('#Date').val();
var towhome = $('#towhome').val();
var gstcheck = document.getElementById("gst").checked;
var Invoiceno = $('#Invoiceno').val();
var merchant = $('#merchant').val();
var mergst = $('#merchantgst').val();
var beforegst = $('#valuebeforegST').val();
// var sgst = $('#SGST').val();
// var cgst = $('#CGST').val();
// var igst = $('#IGST').val();
var total = $('#totalamount').val();
var errorflag = 0;
if(accode < 0)
{
errorflag++;
}
if(date == '')
{
errorflag++;
}
if(total == '')
{
errorflag++;
}
if(towhome == '')
{
errorflag++;
}
if(gstcheck == true)
{
if((merchant == '') || (mergst == '') || (Invoiceno == '') || (beforegst == '')) /* || (sgst == '') || (cgst == '') || (igst == ''))*/
{
errorflag++;
}
else
{
// calculation part
}
}
if(errorflag != 0)
{
alert("Please Provide All Details..!");
return false;
}
$('#updateReceipt').submit();
}
function GSTvalue(id)
{
var sgst = $('#SGST').val();
if(sgst == ''){
sgst = "0.00" ;
}else{
sgst = sgst;
}
var cgst = $('#CGST').val();
if(cgst == ''){
cgst = "0.00" ;
}else{
cgst = cgst;
}
var igst = $('#IGST').val();
if(igst == ''){
igst = "0.00" ;
}else{
igst = igst;
}
var beforegst = $('#valuebeforegST').val();
$('#valuebeforegST').val((parseFloat(beforegst).toFixed(2)));
if(id == 'SGST')
{
$('#CGST').val(parseFloat(sgst).toFixed(2));
$('#SGST').val(parseFloat(sgst).toFixed(2));
$('#IGST').val('0.00');
calculateTotal();
}
if(id == 'CGST')
{
$('#CGST').val(parseFloat(cgst).toFixed(2));
$('#SGST').val(parseFloat(cgst).toFixed(2));
$('#IGST').val('0.00');
calculateTotal();
}
if(id == 'IGST')
{
$('#CGST').val('0.00');
$('#SGST').val('0.00');
$('#IGST').val(parseFloat(igst).toFixed(2));
calculateTotal();
}
}
// function SetVatorCST()
// {
// $('#RECEIPT').click(function(){
// $('#towhom').text('Received From:');
// }
// $('#PAYMENT').click(function(){
// $('#towhom').text('Paid To:');
// });
function DeleteRow()
{
$('#deleteflag').val(1);
var file = "<?php echo $strname[2];?>";
//var id2='';
var id2= $('#id1').val();
//alert(file);
//alert(id2);
$.ajax({
data:{id:file,ide:id2},
type:"POST",
url:"<?php echo base_url() ?>cashbook/deletefile",
success:function(data) {
if(data==1)
{
$('#content').loader('hide');
$("#strname").remove();
$('#receiptslip').attr('src', '');
alert('Delete Successfully');
//window.location ="cashbook/incomeExpenseList";
}
else
{
alert('No file');
//window.location ="incomeExpenseList";
}
}});
}
function calculateTotal()
{
var sgst = $('#SGST').val();
var cgst = $('#CGST').val();
var igst = $('#IGST').val();
var beforegst = $('#valuebeforegST').val();
var total = parseFloat(sgst)+parseFloat(cgst)+parseFloat(igst)+parseFloat(beforegst);
$('#totalamount').val((total.toFixed(2)));
}
$('#myradio1').click(function(){
$('#towhom').text('Received From:');
});
$('#myradio2').click(function(){
$('#towhom').text('Paid To:');
});
</script>
<!--old script above-->
<!-- this script is new from add -->
<script>
function PaymentGSTvalue(id)
{
var sgst = $('#PaymentSGST').val();
if(sgst == ''){
sgst = '0.00' ;
//alert('qwe'+sgst);
}else{
sgst = sgst;
}
var cgst = $('#PaymentCGST').val();
if(cgst == ''){
cgst = '0.00' ;
//alert('qwe'+sgst);
}else{
cgst = cgst;
}
var igst = $('#PaymentIGST').val();
if(igst == ''){
igst = '0.00' ;
//alert('qwe'+sgst);
}else{
igst = igst;
}
if(id == 'PaymentSGST')
{
$('#PaymentCGST').val(parseFloat(sgst).toFixed(2));
$('#PaymentSGST').val(parseFloat(sgst).toFixed(2));
$('#PaymentIGST').val('0.00');
paymenttotalamount();
}
if(id == 'PaymentCGST')
{
$('#PaymentCGST').val(parseFloat(cgst).toFixed(2));
$('#PaymentSGST').val(parseFloat(cgst).toFixed(2));
$('#PaymentIGST').val('0.00');
paymenttotalamount();
}
if(id == 'PaymentIGST')
{
$('#PaymentCGST').val('0.00');
$('#PaymentSGST').val('0.00');
$('#PaymentIGST').val(parseFloat(igst).toFixed(2));
paymenttotalamount();
}
}
//var temparray = [];
var paydtl = $('#hidepaydtl').val();
if(paydtl == ''){ var counter = 1; }
else{ var counter = paydtl-1; }
if(paydtl == ''){ var counterConstant = 1; }
else{ var counterConstant = paydtl-1; }
function add_more()
{
if($("option:selected", $("#Paymentaccode1")).val() == '-1')
{
alert('Select/Choose account name');
$('#Paymentaccode1').focus();
return false;
}
// else if($('#subdescription1').val() == '')
// {
// alert("Provide Account description..!");
// $('#subdescription1').focus();
// return false;
// }
else if($('#Paymentamount1').val() == '')
{
alert("Provide Amount data..!");
$('#Paymentamount1').focus();
return false;
}
else
{// var paydtl = $('#hidepaydtl').val();
// alert(paydtl);
counter++;
counterConstant++;
var div = document.createElement('div');
div.id = "divid"+counterConstant;
div.className="row";
div.style.cssText = "border:1px dashed; margin-left:0px;margin-right:0px;";
div.innerHTML='<div class="col-md-12"><div class="col-md-3"><div class="form-group"><b>'+
'<span for="name">Account Name Select:</span>'+
'<select class="form-control required " required id="Paymentaccode'+counterConstant+'" required name="mydata'+counterConstant+'[Paymentaccode'+counterConstant+']">'+
'<option value="-1">Account Name Select</option>'+
'</select>'+
'</div></div>'+
'<div class="col-md-3"><div class="form-group">'+
'<span for="Decription"><b>Account Description:</b></span> '+
'<input type="text" class="form-control" style="text-align:right;" id="subdescription'+counterConstant+'" name="mydata'+counterConstant+'[subdescription'+counterConstant+']">'+
'</div></div>'+
'<div class="col-md-3"><div class="form-group">'+
'<span for="amount"><b>Amount(&#8377;):</b></span> '+
'<input type="text" class="form-control required" style="text-align:right;" id="Paymentamount'+counterConstant+'" name="mydata'+counterConstant+'[Paymentamount'+counterConstant+']" onkeypress="return isNumberKey(event)" onchange="paymenttotalamount();" onkeypress="return isNumberKey(event)">'+
'</div></div>'+
'<div class="col-md-offset-2 col-md-1" style="padding-top:15px;padding-left:0px"><div class="form-group">'+
'<input class="remove_this" type="button" id="removebtn'+counterConstant+'" value="REMOVE" onclick="removeRow(this.id)"></div>'+
'</div></div></div>';
$('#newdiv').append(div);
$('#hidecounter').val(counter);
$('#hideconstant').val(counterConstant);
}
t= <?php echo json_encode($dropdownvalues) ?>;
var option = '';
$.each(t,function(i,obj){
if(obj.type == 'PAYMENT')
{
option += "<option value="+obj.code+">"+obj.name+"</option>";
}
});
$('#Paymentaccode'+counterConstant).append(option);
//this validation for payment account code dropdown
// var ddfirstvalue = $('#Paymentaccode1 option:selected').val();//this part for default dropdown value
// if(ddvalue != -1){ temparray.push(ddfirstvalue); }
// var cc = counterConstant-1;//this for dynamical dropdown value after click add more button
// var ddvalue = $('#Paymentaccode'+cc+' option:selected').val();
// if(ddvalue != -1){ temparray.push(ddvalue); }
// if(paydtl == ''){
// dbarray = <?php echo json_encode($PaymentDetails) ?>;//this part is db dropdown value
// $.each(dbarray,function(db,obj){
// dbacccode = obj.Account_code;
// });
// if(dbacccode != -1){ temparray.push(dbacccode); }
// }
//dynamic dropdown value is disabled
// $.each(temparray,function(t,temp){
// $('#Paymentaccode'+counterConstant+' option[value='+temp+']').prop('disabled',true);
// });
// } /* else part closed */
}
function removeRow(input) {
var number = input.replace(/[^0-9]+/ig,"");
var lineitemamount = $("#Paymentamount"+number).val();
var total = $('#Paymenttotalamount').val();
var subtracttotal = total - lineitemamount;
var valueb4gst = $('#PaymentvaluebeforegST').val();
var valueb4 = valueb4gst - lineitemamount;
//alert(subtracttotal);
var accode = $('#Paymentaccode'+number).val();
//alert('remove');
//temparray = jQuery.grep(temparray, function(value) {
// return value != accode;});
//alert(temparray);
if(counter >= 1){
counter--;
//var hideaccountname = $('#hideaccount'+number).val();
var hideid = $('#hideid'+number).val();
//alert($('#hideid'+number).val());
$.ajax({
data:{id:hideid},
type:"POST",
url:"<?php echo base_url() ?>cashbook/Removepaymentdetails",
success:function(data) {
// alert(data);
// alert("deleted");
}
});
$("#divid"+number).remove();
$('#hidecounter').val(counter);
}
$('#Paymenttotalamount').val(parseFloat(subtracttotal).toFixed(2));
$('#PaymentvaluebeforegST').val(parseFloat(valueb4).toFixed(2));
//parseFloat(subtracttotal).toFixed(2)
}
function paymenttotalamount(){
var total = 0;
var withtax = 0;
//alert(counterConstant);
for(i=1;i<=counterConstant;i++){
var value = $('#Paymentamount'+i).val();
value = parseFloat(value);
if(isNaN(value)){
value = 0.00;
}
total = total + parseFloat(value);
}
var sgst = $('#PaymentSGST').val();
if(sgst == ''){
sgst = 0 ;
//alert('qwe'+sgst);
}else{
sgst = sgst;
}
var cgst = $('#PaymentCGST').val();
if(cgst == ''){
cgst = 0 ;
}else{
cgst = cgst;
//alert('sda'+cgst)
}
var igst = $('#PaymentIGST').val();
if(igst == ''){
igst = 0 ;
}else{
igst = igst;
}
withtax = parseFloat(total)+parseFloat(sgst)+parseFloat(cgst)+parseFloat(igst);
$('#PaymentvaluebeforegST').val(parseFloat(total).toFixed(2));
$('#Paymenttotalamount').val(parseFloat(withtax).toFixed(2));
}
function valid(){
//alert("now entered");
if($('#PaymentDate').val() == '')
{
alert("Please Provide Date..!");
$('#PaymentDate').focus();
return false;
}
else if($('#PaymentPaidto').val() == '')
{
alert("Please Provide paid to Data..!");
$('#PaymentPaidto').focus();
return false;
}
else if($('#Paymentvouchercode').val() == '')
{
alert("Please Provide voucher code data..!");
$('#Paymentvouchercode').focus();
return false;
}
else if($('#hidecounter').val() == 1){
// alert('true');
if($("option:selected", $("#Paymentaccode1")).val() == '-1')
{
alert('Select/Choose account name');
$('#Paymentaccode1').focus();
return false;
}
else if($('#subdescription1').val() == '')
{
alert("Provide Account description..!");
$('#subdescription1').focus();
return false;
}
else if($('#Paymentamount1').val() == '')
{
alert("Provide Amount data..!");
$('#Paymentamount1').focus();
return false;
}
else{
$('#updatePayment').submit();
}
}
else{
$('#updatePayment').submit();
}
}
</script>