<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='index.php' </script>";
  return;
}
if (date('m') <= 4) {//Upto June 2014-2015
    $fin_year = (date('Y')-1) . '-' . date('y');
} else {//After June 2015-2016
    $fin_year = date('Y') . '-' . (date('y') + 1);
  
}
include('includes/top.php');
include('opendb.php');
$recordid=$_REQUEST['recordid'];
?>
<link href="css/form.css" type="text/css" rel="stylesheet" media="screen" />
<html>
<body >
<center>
<title>GST Report</title>

<link type="text/css" href="jquery/jquery-ui.min.css" rel="stylesheet" />	
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="cal/jquery-ui1.js"></script>
<script type="text/javascript" src="jquery/jquery-1.7.min.js"></script>
<script type="text/javascript" src="jquery/jquery-ui.min.js"></script>




<script type="text/javascript">
$(function() {


$( "#ref_date1" ).datepicker("destroy");
     var fyr=document.getElementById('f_yr').value;
     var splv=fyr.split("-");
     var syr=splv[0];
     var eyr='20'.concat(splv[1]);
     var syr1='01-04-';
     var eyr1='31-03-';
     var stfnyr=syr1.concat(syr);
     var efnyr=eyr1.concat(eyr);
     $("#ref_date1").datepicker({ dateFormat: 'dd-mm-yy'});
});
</script>
<script>
function valid()
{
}
</script>
<style>
#txt{
font-family: Arial, Helvetica;
background-color: #F2F2F2;
}
</style>
<link rel="stylesheet" type="text/css" media="all" href="jsDatePick_ltr.min.css" />
<script type="text/javascript" src="jsDatePick.min.1.3.js"></script>
<script type="text/javascript">
window.onload = function(){
new JsDatePick({
  useMode:2,
  target:"inputField",
  dateFormat:"%Y-%m-%d"
});
new JsDatePick({
  useMode:2,
  target:"inputField1",
  dateFormat:"%Y-%m-%d"
});

};
</script>

<SCRIPT LANGUAGE="JavaScript" SRC="util/PopupWindow.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="util/AnchorPosition.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="util/CalendarPopup.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="util/date.js"></SCRIPT>
<script>
var cal1 = new CalendarPopup();
cal1.showYearNavigation();

var cal2 = new CalendarPopup();
cal2.showYearNavigation();

</script>
<style>
th{
    // background-color: grey;
    font-weight: bold;
    color: white;
    border:1px solid #D7D7D1;
    border-collapse:collapse;
background: rgb(181,189,200); /* Old browsers */
background: -moz-linear-gradient(top, rgba(181,189,200,1) 0%, rgba(130,140,149,1) 36%, rgba(40,52,59,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(181,189,200,1)), color-stop(36%,rgba(130,140,149,1)), color-stop(100%,rgba(40,52,59,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b5bdc8', endColorstr='#28343b',GradientType=0 ); /* IE6-9 */
}
.ro_settled td
{
background: #6bba70; /* Old browsers */
background: -moz-linear-gradient(top, #6bba70 0%, #6bba70 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6bba70), color-stop(100%,#6bba70)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #6bba70 0%,#6bba70 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #6bba70 0%,#6bba70 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #6bba70 0%,#6bba70 100%); /* IE10+ */
background: linear-gradient(to bottom, #6bba70 0%,#6bba70 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6bba70', endColorstr='#6bba70',GradientType=0 ); /* IE6-9 */
color:white;
}
.ro_settl td
{
background: #6bba70; /* Old browsers */
background: -moz-linear-gradient(top, #6bba70 0%, #6bba70 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6bba70), color-stop(100%,#6bba70)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #6bba70 0%,#6bba70 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #6bba70 0%,#6bba70 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #6bba70 0%,#6bba70 100%); /* IE10+ */
background: linear-gradient(to bottom, #6bba70 0%,#6bba70 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6bba70', endColorstr='#6bba70',GradientType=0 ); /* IE6-9 */
color:red;
}
</style>
<body background="back_ground.jpg">
<?php //include('logo2.php'); ?>
<?php //include('includes/top.php'); ?>
<form action='<?print $PHP_SELF?>' name="f1" method='post' >
<br>
<table class="container"><tr><td>
<br>
<center>
<?
$brqry="select brname from branch where brcode='$brcode'";
$brrs=mysqli_query($db,$brqry);
$brrw=mysqli_fetch_array($brrs);
$brnchnm=$brrw[0];
$qry=mysqli_query($db,"select* from sales_details where brcode='$brcode' and id='$recordid'");
$row=mysqli_fetch_array($qry);
$todt = implode('-', array_reverse(explode('-', $row['date'])));
?>

<table class="form" style="width:auto;" >
<tr><th style="background:grey;" colspan=2>GST REPORT</th><input type=hidden name='f_yr' id='f_yr' value='<? echo $fin_year ?>'></tr>
<?
$yeardat=explode('-',$fin_year);
$startingyr=$yeardat[0];
$mgrp="";
?>
<tr><td>Sl No </td><td><? echo $row['sl_no'] ?><input type='hidden' name='recdid' id='recdid' value='<? echo $row['id'] ?>'></td></tr>
<tr><td>Customer Name </td><td><? echo $row['customer_name'] ?></td></tr>

<tr><td>Invoice Amt</td><td><? echo $row['inv_value'] ?></td></tr>
<tr><td>Insurance Amt</td><td><? echo $row['ins_amt'] ?></td></tr>
<tr><td>Refund Amt</td><td><? echo $row['refund_amt'] ?></td></tr>
<tr><td>Total Amt</td><td><? echo $row['total_amt'] ?></td></tr>
<tr><td>Final Disbursement</td><td><? echo $row['fin_disbursment'] ?></td></tr>
<tr><td>Exchange Amt</td><td><? echo $row['exchange_amt'] ?></td></tr>
<tr><td>Discount Amt</td><td><? echo $row['discount_amt'] ?></td></tr>
<tr><td>Subvention Amt</td><td><? echo $row['subvention'] ?></td></tr>

<tr><td>Other Amt</td><td><? echo $row['others'] ?></td></tr>
<tr><td>Balance Due Amt</td><td><? echo $row['bal_due_amt'] ?></td></tr>

<tr><td> Date </td>
<td><input type="text" id="ref_date1" value="<? echo $todt ?>" name="todt" readonly></td>
</tr>
<tr><td>Amt Received</td><td><input type="text" id="recvamt"  name="recvamt" size="50px"></td></tr>
<tr><td>Remarks</td><td><input type="text" id="recvrmrk"  name="recvrmrk" size="50px"></td></tr>



<tr><td align='center'>
<input type='submit' name='show' value='Submit' >
</td>
</tr></form>
</table>
<br><br>
<?
if(isset($_POST['show']))
{
    $recdid=$_REQUEST['recdid'];
    
    $qry=mysqli_query($db,"select* from sales_details where brcode='$brcode' and id='$recdid'");
    $row=mysqli_fetch_array($qry);
    $slno=$row['sl_no'];
    $customername=$row['customer_name'];
    $todt=$_REQUEST['todt'];
    $recvamt=$_REQUEST['recvamt'];
    $recvrmrk=$_REQUEST['recvrmrk'];
    
    
    $todt = implode('-', array_reverse(explode('-', $todt)));
  //echo "insert into downpayment(brcode,sl_no,customer_name,received_amt,deposit_at,date,refid) values('$brcode','$slno','$customername','$recvamt','$recvrmrk','$todt','$recdid')";
    $qry=mysqli_query($db,"insert into downpayment(brcode,sl_no,customer_name,received_amt,deposit_at,date,refid) values('$brcode','$slno','$customername','$recvamt','$recvrmrk','$todt','$recdid')");
    
    
print "<script>alert('Data has been updated'); </script>";
print "<script>window.close()</script>";
}

    
    
   


?>
<br><br>
<?
$saledetqry=mysqli_query($db,"select* from sales_details where brcode='$brcode' and id='$recordid'") or die('Insert Err:'.mysqli_error($db));
$salesrow=mysqli_fetch_array($saledetqry);
$insrexcel=mysqli_query($db,"select* from downpayment where brcode='$brcode' and refid='$salesrow[id]'") or die('Insert Err:'.mysqli_error($db));
$invamt=$salesrow['inv_value'];
?>
<table border=1 class='tble1' width=100%>
            
<tr><th>Customer Name</th><th>Invoice Amt</th><th>Received Date</th><th>Received Amt</th><th>Remarks</th></tr>
<?
while($insrow=mysqli_fetch_array($insrexcel))
{
    ?>
    <tr>
    <td><? echo $insrow['customer_name'] ?></td>
    <td><? echo $invamt ?></td>
    <td><? echo $insrow['date'] ?></td>
    <td><? echo $insrow['received_amt'] ?></td>
    <td><? echo $insrow['deposit_at'] ?></td>

    
    </tr>
    <?
}
       ?>
       
        
            </table>


