Current File : //home/obabain/autoclutchess_obaba_in/editRecVoucher.jsp |
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ include file="Connection.jsp" %>
<%
Statement st=con.createStatement();
ResultSet rs = null;
String id=request.getParameter("Id");
rs=st.executeQuery("select tb.*,((select credit_amt from account_voucher_main where voucher_id=tb.voucher_id)-IFNULL((select sum(debit_amt) from account_voucher_sub where voucher_id=tb.voucher_id and type='O'),0))amt,IFNULL((select sum(debit_amt) from account_voucher_sub where voucher_id=tb.voucher_id and type='B'),0)amtbill from account_voucher_main tb where voucher_id="+id+"");
while(rs.next())
{
vchno=rs.getString("voucher_no");
vdate=rs.getString("voucher_date");
part=rs.getString("particular");
acc=rs.getString("account");
totamt=rs.getString("credit_amt");
narration=rs.getString("narration");
amt=rs.getString("amt");
paytype=rs.getString("cash_cheque");
amtbil=rs.getString("amtbill");
System.out.print(amtbil);
}
rs=st.executeQuery("select * from account_ledger where l_id="+part+"");
while(rs.next())
{
supplid=rs.getString("ref_id");
}
if(paytype.equals("chq"))
{
rs=st.executeQuery("select * from cheque_voucher where voucher_no="+id+"");
while(rs.next())
{
chqid=rs.getString("id");
chqno=rs.getString("chq_no");
chqdate=rs.getString("created_date");
}
}
else
{
rs=st.executeQuery("select Now() as tdate");
while(rs.next())
{
chqid="0";
chqno="";
chqdate="";
}
}
%>
<%!
String vchno=null;
String vdate=null;
String part=null;
String acc=null;
String totamt=null;
String narration=null;
String amt=null;
String supplid=null;
String paytype=null;
String chqid=null;
String chqno=null;
String chqdate=null;
String amtbil=null;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.2/bootstrap3-typeahead.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="css/select2.min.css" rel="stylesheet">
<link href="css/jquery.datetimepicker.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.2/bootstrap3-typeahead.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<link href="css/select2.min.css" rel="stylesheet">
<link href="css/jquery.datetimepicker.css" rel="stylesheet">
<style>
.otherch{display:none;}
</style>
<style>
.template{display:none;}
</style>
<script language="javascript" type="text/javascript">
var xmlHttp
var xmlHttp
function showState(str){
if (typeof XMLHttpRequest != "undefined"){
xmlHttp= new XMLHttpRequest();
}
else if (window.ActiveXObject){
xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlHttp==null){
alert("Browser does not support XMLHTTP Request")
return;
}
var url="city.jsp";
url +="?count=" +str;
xmlHttp.onreadystatechange = stateChange1;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function stateChange1(){
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
document.getElementById("city").innerHTML=xmlHttp.responseText
}
}
</script>
</head>
<body onload="loaddropdown(<%=acc%>,<%=part%>)">
<%@include file="master.jsp" %>
<script>
function checkExist(){
var xmlhttp = new XMLHttpRequest();
var username = document.forms["rv"]["payno"].value;
var url = "ReceiptExist.jsp?username=" + username;
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
if(xmlhttp.responseText == "Duplicate Voucher No.")
document.getElementById("isE").style.color = "red";
else
document.getElementById("isE").style.color = "green";
document.getElementById("isE").innerHTML = xmlhttp.responseText;
}
};
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
</script>
<form action="editRecVoucherDA.jsp">
<div class="content">
<div class="row" style="width:90%">
<div class="col-md-9" >
<div class="panel panel-default" >
<div class="panel-heading main-color-bg">
<h3 class="panel-title">Receipt Voucher</h3>
</div>
<div style="padding:5px 10px 0px 10px;"><a class="cash btn btn-danger">Cash</a>
<a class="cheq btn btn-danger">Cheque</a>
<a class="pull-right btn btn-primary" href="ViewReceiptVoucher.jsp">View</a>
</div>
<div class="panel-body" >
<input type="hidden" name="paytype" class="paytype" value="<%=paytype %>">
<input type="hidden" name="vid" class="paytype" value="<%=id %>">
<div class="row" >
<div class="col-xs-3">
<label for="lastname" style="margin-left:5px; color:red;">Receipt No.</label>
<input type="text" name="payno" class="form-control" onblur="checkExist()" id="payno" value="<%=vchno%>" readonly="readonly">
<span id="isE"></span>
</div>
<div class="col-xs-2 pull-right">
<label for="lastname" style="margin-left:5px;">Date</label>
<input type="text" name="paydate" class="form-control" id="datetimepicker" value="<%=vdate%>">
</div>
<div class="col-xs-3">
<label for="lastname" style="margin-left:5px;">Account</label>
<select class="select1 form-control" name='account' id="campInput" style="width:100%;" >
<option value="0">select</option>
<%
rs=st.executeQuery("select * from account_ledger where (under = 17 or under=16 or under= 15) and branch_id="+loginid+" order by ledger_name asc");
while(rs.next())
{
%>
<option value="<%=rs.getString("l_id") %>"><%=rs.getString("ledger_name") %></option>
<%} %>
</select>
</div>
</div>
<br>
<div class="chq row">
<div class="col-xs-3">
<label for="lastname" style="margin-left:5px;">Cheque No.</label>
<input type="text" name="chqno" class="chqno form-control" value="<%=chqno %>">
</div>
<div class="col-xs-3">
<label for="lastname" style="margin-left:5px;"> Cheque Date</label>
<input type="text" name="chqdate" class="form-control" id="datetimepicker2" value="<%=chqdate %>">
</div>
<!-- <div class="col-xs-3">
Cross Using
<input type="text" name="chqcross" class="form-control">
</div> -->
</div><br>
<div class="row" >
<div class="col-xs-3">
<label for="lastname" style="margin-left:5px;">Particular</label>
<select name='country' onchange="showState(this.value)" class="select1 form-control" id="ddlparti">
<option value="none">Select</option>
<%
rs = st.executeQuery("select * from account_ledger where branch_id="+loginid+" order by ledger_name asc");
while(rs.next()){
%>
<option value="<%=rs.getString("l_id")%>"><%=rs.getString("ledger_name")%></option>
<%
}
%>
</select>
</div>
<div class="col-xs-3">
<label for="lastname" style="margin-left:5px;">Amount</label>
<input type="text" class="gtot form-control" name="gtotal" value="<%=amt%>">
<input type="hidden" name="total" class="total form-control" value="<%=amtbil%>">
</div>
</div>
<br>
<table class="table table-hover additionalMargin alignment" id="table1">
<thead>
<tr class="info">
<th>Bills ( Date | No. | Due Amt.)</th><th style=text-align:right;">Amount</th><th></th>
</tr>
</thead>
<tbody>
<tr class="otherch">
<td style="width:60%;">
<div class="row">
<div class="col-md-4" style="width:70%;">
<input type="hidden" name="comm[]" value="0" class="comm">
<input type="hidden" value="O" name="typ[]" class="otherval">
<select class="selectother form-control" name="state[]" style="width:60%;">
<option value="0">select</option>
<%
rs=st.executeQuery("select * from account_ledger where branch_id="+loginid+" order by ledger_name asc");
while(rs.next())
{
%>
<option value="<%=rs.getString("l_id") %>"><%=rs.getString("ledger_name") %></option>
<%} %>
</select>
</div>
<div class="col-xs-3" >
<input type="hidden" name="invid[]" class="billno">
</div>
</div>
</td>
<td align="right">
<div class="row">
<!-- <div class="col-md-1">(-)</div> -->
<div class="col-md-4" style="width:100%;">
<input type="text" class="otherchrg form-control" value="0" name="billamt[]" style="width:51%;">
</div>
</div>
</td>
<td><a href='#' onclick='deleteRow(this)'><i class='glyphicon glyphicon-trash'></a></td>
</tr>
<tr class='template'>
<td style="width:60%;">
<div class="row">
<div id='city' class="col-md-4" style="width:70%;">
<input type="hidden" name="comm[]" value="0">
<input type="hidden" value="B" name="typ[]" class="bill">
<select name='state[]' class="selectType form-control" style="width:60%;">
<option value='-1'>select</option>
</select>
</div>
<div class="col-xs-3">
<input type="hidden" name="invid[]" class="billno">
</div>
</div>
</td>
<td style="width:45%;" align="right">
<input type="text" class="amt form-control" name="billamt[]" value="0" style="width:51%;">
</td>
<td><a href='#' onclick='deleteRow(this)'><i class='glyphicon glyphicon-trash'></a></td>
</tr>
<%
Statement stbill=con.createStatement();
ResultSet rbill=null;
if(supplid.equals("0"))
{
rbill=stbill.executeQuery("select tb.*,(select journal_no from journalentry where journal_id=tb.bill_no)bill from account_voucher_sub tb where voucher_id="+id+" and type='B'");
}
else
{
rbill=stbill.executeQuery("select tb.*,(select sales_invoice_no from ip_sales_invoice where sinvoice_id=tb.bill_no)bill from account_voucher_sub tb where voucher_id="+id+" and type='B'");
}
while(rbill.next())
{
%>
<tr>
<td style="width:60%;">
<div class="row">
<div id='city' class="col-md-4" style="width:70%;">
<input type="hidden" name="comm[]" value="0">
<input type="hidden" value="B" name="typ[]" class="bill">
<select name='state[]' class="selectType form-control" style="width:60%;">
<option value='-1'>select</option>
<%
if(supplid.equals("0"))
{
rs = st.executeQuery("select tb.journal_id as sinvoice_id,tb.created_date as invoice_date_created,tb.journal_no as sales_invoice_no, (tr.debit-tr.paid_amt)as tot From journalentry tb where particulars="+part+" and (debit-paid_amt)>0 and branch_id="+loginid+" ");
}
else
{
rs = st.executeQuery("select tb.*,(tb.total-tb.received_amt)as tot From ip_sales_invoice tb where supplier_id="+supplid+" and (total-received_amt)>0 and branch_id="+loginid+" ");
}
while(rs.next()){
%>
<option value="<%=rs.getString("sinvoice_id") %>"><%=rs.getString("invoice_date_created")%> | <%=rs.getString("sales_invoice_no") %> | <%=rs.getString("tot") %></option>
<%} %>
</select>
</div>
<div class="col-md-3">Agst Ref- <b><%=rbill.getString("bill") %></b>
<input type="hidden" name="invid[]" value="<%=rbill.getString("bill_no") %>" class="billno">
</div>
</div>
</td>
<td style="width:45%;" align="right">
<input type="text" class="amt form-control" name="billamt[]" value="<%=rbill.getString("debit_amt") %>" style="width:51%;">
</td>
<td><a href='#' onclick='deleteRow(this)'><i class='glyphicon glyphicon-trash'></a></td>
</tr>
<%} %>
<%
Statement stother=con.createStatement();
ResultSet rother=stother.executeQuery("select tb.*,(select sales_invoice_no from ip_sales_invoice where sinvoice_id=tb.bill_no)bill,(select ledger_name from account_ledger where l_id=tb.bill_no)parti from account_voucher_sub tb where voucher_id="+id+" and type='O'");
while(rother.next())
{
%>
<tr>
<td style="width:60%;">
<div class="row">
<div class="col-md-4" style="width:70%;">
<input type="hidden" name="comm[]" value="0" class="comm">
<input type="hidden" value="O" name="typ[]" class="otherval">
<select class="selectother firstselect form-control" name="state[]" style="width:60%;">
<option value="0">select</option>
<%
rs=st.executeQuery("select * from account_ledger where branch_id="+loginid+" order by ledger_name asc");
while(rs.next())
{
%>
<option value="<%=rs.getString("l_id") %>"><%=rs.getString("ledger_name") %></option>
<%} %>
</select>
</div>
<div class="col-md-3"><b><%=rother.getString("parti") %></b>
<input type="hidden" name="invid[]" value="<%=rother.getString("bill_no") %>" class="billno">
</div>
</div>
</td>
<td style="width:45%;" align="right">
<input type="text" class="otherchrg form-control" name="billamt[]" value="<%=rother.getString("debit_amt") %>" style="width:51%;">
</td>
<td><a href='#' onclick='deleteRow(this)'><i class='glyphicon glyphicon-trash'></a></td>
</tr>
<%} %>
</table>
<div class="pull-right col-xs-3" style="margin-right: 14px;">
<label for="lastname">Amount balance</label>
<input type="text" name="balance" class="bal form-control" value="0"></div>
<%-- <div class="bankdiv row" >
<div class="col-xs-3">
<!-- <label for="lastname" style="margin-left:5px;">Bank</label> -->
<select class="select1 form-control" name='bank' id="bank" style="width:100%;" >
<option value="0">select Bank</option>
<%
rs=st.executeQuery("select * from account_ledger order by ledger_name asc");
while(rs.next())
{
%>
<option value="<%=rs.getString("l_id") %>"><%=rs.getString("ledger_name") %></option>
<%} %>
</select>
</div>
<div class="col-xs-3">
<input type="text" name="chrg" class="bnkch form-control" placeholder="Charges" value="0">
</div>
</div> --%><br>
<div class="col-xs-1" style="padding-right:80px;">
<a id='add' class="pull-left btn btn-default">ADD BILL</a></div>
<div class="col-xs-4">
<!-- <input type="button" id="addc" class="addc pull-left btn btn-default" value="Other Charges"></div> -->
<a id='addother' class="pull-left btn btn-default">Add othercharges</a></div>
<br>
<hr>
<div class="row" >
<div class="col-xs-4">
<label for="lastname" style="margin-left:5px;">Narration</label>
<textarea name="narr" class="form-control"><%=narration %></textarea>
</div>
<div class="pull-right col-xs-3" style="margin-right:25px;">
<label for="lastname" style="margin-left:5px;">Total Amount</label>
<input type="text" name="total2" class="total2 form-control" value="<%=totamt%>" placeholder="Total Amount">
</div>
</div> </div> <br>
<div class="modal-footer" id="contact_submit">
<input type="button" value="Back" style="background:#204b58;" class="pull-left btn btn-info" onclick="goBack()"/>
<a class="btn btn-default" href="">Reset</a>
<input type="submit" value="Save Change" style="background:#204b58;" class="btn btn-info" >
</div>
</div>
</div>
</div>
</div>
</form>
<%@include file="footer.jsp" %>
</body>
<script type="text/javascript">
function goBack() {
window.history.back();
};
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.1/js/select2.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="js/jquery.datetimepicker.full.js"></script>
<script>
jQuery('#datetimepicker').datetimepicker({
timepicker:false,
todayBtn: "linked"
//mask:true, // '9999/19/39 29:59' - digit is the maximum possible for a cell
});
jQuery('#datetimepicker2').datetimepicker({
timepicker:false,
todayBtn: "linked"
//mask:true, // '9999/19/39 29:59' - digit is the maximum possible for a cell
});
</script>
<script>
function loaddropdown(acc,parti)
{
$("#campInput").val(acc).trigger("change");
$("#ddlparti").val(parti).trigger("change");
}
</script>
<script>
$('.select1').select2();
$(".firstselect").select2();
</script>
<script langauge="JavaScript">
function deleteRow(btn) {
var row = btn.parentNode.parentNode;
if ( $('#table1 tbody tr').length == 2 ) return;
row.parentNode.removeChild(row);
var gt=$(".gtot").val();
var sum = 0;
$(".amt").each(function(){
sum += +$(this).val();
});
var sum2 = 0;
$(".otherchrg").each(function(){
sum2 += +$(this).val();
});
var c=parseFloat()
$(".total").val(sum.toFixed(2));
var tot=parseFloat(gt)+sum2
$(".total2").val(tot);
$(".bal").val(($(".gtot").val()-$(".total").val()).toFixed(2));
}
</script>
<script>
$(function() {
// initThings();
$('#add').on('click', function() { add_row($('#table1')); });
});
function add_row($table) {
var tr_id = $table.find('tr').length -1;
var $template = $table.find('tr.template');
var $tr = $template.clone().removeClass('template').prop('id', tr_id);
$tr.find(':input').each(function() {
if($(this).hasClass('hasDatepicker')) {
$(this).removeClass('hasDatepicker').removeData('datepicker');
}
var input_id = $(this).prop('id');
input_id = input_id + tr_id;
$(this).prop('id', input_id);
var new_name = $(this).prop('name');
new_name = new_name.replace('[0]', '['+ tr_id +']');
$(this).prop('name', new_name);
$(this).prop('value', '');
});
$table.find('tbody').append($tr);
$(".dateControl", $tr).datepicker({
dateFormat: "dd-mm-yy"
});
//$(".selectType", $tr).select2();
$(".amt",$tr).val(0);
$(".bill",$tr).val("B");
}
function initThings() {
add_row($('#table1'));
}
</script>
<script>
$(function() {
// initThings();
$('#addother').on('click', function() { add_row1($('#table1')); });
});
function add_row1($table) {
var tr_id = $table.find('tr').length -1;
var $template = $table.find('tr.otherch');
var $tr = $template.clone().removeClass('otherch').prop('id', tr_id);
$tr.find(':input').each(function() {
if($(this).hasClass('hasDatepicker')) {
$(this).removeClass('hasDatepicker').removeData('datepicker');
}
var input_id = $(this).prop('id');
input_id = input_id + tr_id;
$(this).prop('id', input_id);
var new_name = $(this).prop('name');
new_name = new_name.replace('[0]', '['+ tr_id +']');
$(this).prop('name', new_name);
$(this).prop('value', '');
});
$table.find('tbody').append($tr);
$(".dateControl", $tr).datepicker({
dateFormat: "dd-mm-yy"
});
$(".selectother", $tr).select2();
$(".otherchrg",$tr).val(0);
$(".otherval",$tr).val("O");
$(".comm",$tr).val("0");
}
</script>
<script>
$(document).on("blur", ".gtot", function() {
var g=$(".gtot").val();
var t=$(".total").val();
var sum=0;
var sum2=0;
$("#table1").find(".amt").each(function(){
sum+=+$(this).val();
});
$("#table1").find(".otherchrg").each(function(){
sum2+=+$(this).val();
});
$(".bal").val(g-t);
var f=(parseFloat(g)+parseFloat(sum2));
$(".total2").val(f);
$(".bal").val(g-t);
});
</script>
<script>
$(document).on("change", ".selectother", function() {
var id=$(".selectother:last").find('option:selected').val();
$(".billno:last").val(id);
});
$(document).on("change", ".selectType", function() {
var a=$(".gtot").val();
var b=$(".total").val();
var i=$(this).find('option:selected').val();
//alert(i);
if(i==-1)
{
$(".amt:last").val(0);
}
else
{
if(a=="")
{
alert('please enter amount');
$(".selectType:last").val("-1");
}
else{
$(".selectType").each(function(){
//var s=$(".selectType:last").val();
//alert($(".selectType:last").find('option:selected').text())
var pa=[];
var str=$(".selectType:last").find('option:selected').text();
pa=str.split("|");
var id=$(".selectType:last").find('option:selected').val();
var s=pa[2];
if($(".amt:last").val()==0)
{
if(s > a-b)
{
$(".amt:last").val((a-b).toFixed(2));
}
else
{
$(".amt:last").val(s);
}
$(".billno:last").val(id);
var bb=parseFloat(b)+parseFloat($(".amt:last").val())
$(".total").val(bb);
var sum = 0;
}
});
var sum2 = 0;
$("#table1").find(".amt").each(function(){
sum2+=+$(this).val();
});
var sum3 = 0;
$("#table1").find(".otherchrg").each(function(){
sum3+=+$(this).val();
});
var t=$(".total").val()
$(".bal").val(a-t);
var ss=parseFloat(sum2)+parseFloat(sum3);
$(".total2").val(ss);
}}
});
$( document ).ready(function() {
var sum2 = 0;
$("#table1").find(".amt").each(function(){
sum2+=+$(this).val();
});
var a=$(".gtot").val();
//$(".total").val(a);
});
$( document ).ready(function() {
var ty=$(".paytype").val();
if(ty=="cash")
{
$(".chq").hide();
}
else
{
$(".chq").show();
}
$(".cash").click(function(){
$(".chq").hide();
$(".chqno").val('');
});
$(".cheq").click(function(){
$(".chq").show();
});
});
$(document).on("change", ".otherchrg", function() {
var sum =parseFloat($(".gtot").val());
var sum2=0;
$(".otherchrg").each(function(){
sum2 +=+$(this).val();
});
/* var sum2=0;
$(".amt").each(function(){
sum2 +=+$(this).val();
}); */
var ss=sum+sum2;
$(".total2").val(ss);
});
</script>
</html>