<?
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');
$code=$_REQUEST['code'];
?>
<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='$code'");
$row=mysqli_fetch_array($qry);
$todt = implode('-', array_reverse(explode('-', $row['date'])));
?>

<table class="form" style="width:auto;" >
<tr><th style="background:grey;" colspan=4>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><input type="text" id="slno"  name="slno" value='<? echo $row['sl_no'] ?>' ><input type='hidden' name='recdid' id='recdid' value='<? echo $row['id'] ?>'></td></tr>
<tr><td>Customer Name </td><td><input type="text" id="custname"  name="custname" value='<? echo $row['customer_name'] ?>' size="50px"></td></tr>
<tr><td>Address</td><td><input type="text" id="custaddr"  name="custaddr" value='<? echo $row['address'] ?>' size="50px"></td></tr>
<tr><td>Phone</td><td><input type="text" id="custphone"  name="custphone" value='<? echo $row['phone'] ?>' size="50px"></td><td>Email</td><td><input type="text" id="custemail"  name="custemail" value='<? echo $row['email'] ?>' size="50px"></td></tr>

<tr><td>GST No</td><td><input type="text" id="custgst"  name="custgst" value='<? echo $row['gst_no'] ?>' size="50px"></td><td>PAN</td><td><input type="text" id="custpan"  name="custpan" value='<? echo $row['pan_no'] ?>' size="50px"></td></tr>

<tr><td>Configuration</td><td><input type="text" id="vehconf"  name="vehconf" value='<? echo $row['cofiguration'] ?>' size="50px"></td><td>Financer</td><td><input type="text" id="custfin"  name="custfin" value='<? echo $row['financier'] ?>' size="50px"></td></tr>
<tr><td>Executive</td><td><input type="text" id="custexec"  name="custexec" value='<? echo $row['exc_name'] ?>' size="50px"></td><td>Invoice Amt</td><td><input type="text" id="invamt"  name="invamt" value='<? echo $row['inv_value'] ?>' size="50px"></td></tr>
<tr><td>Insurance Amt</td><td><input type="text" id="insamt"  name="insamt" value='<? echo $row['ins_amt'] ?>' size="50px"></td><td>Refund Amt</td><td><input type="text" id="refndamt"  name="refndamt" value='<? echo $row['refund_amt'] ?>' size="50px"></td></tr>
<tr><td>Total Amt</td><td><input type="text" id="totamt"  name="totamt" value='<? echo $row['total_amt'] ?>' size="50px"></td><td>Final Disbursement</td><td><input type="text" id="findisb"  name="findisb" value='<? echo $row['fin_disbursment'] ?>' size="50px"></td></tr>
<tr><td>Exchange Amt</td><td><input type="text" id="exchamt"  name="exchamt" value='<? echo $row['exchange_amt'] ?>' size="50px"></td><td>Discount Amt</td><td><input type="text" id="discamt"  name="discamt" value='<? echo $row['discount_amt'] ?>' size="50px"></td></tr>
<tr><td>Subvention Amt</td><td><input type="text" id="subamt"  name="subamt" value='<? echo $row['subvention'] ?>' size="50px"></td><td>Other Amt</td><td><input type="text" id="othamt"  name="othamt" value='<? echo $row['others'] ?>' size="50px"></td></tr>
<tr><td>Balance Due Amt</td><td><input type="text" id="dueamt"  name="dueamt" value='<? echo $row['bal_due_amt'] ?>' size="50px"></td><td> Date </td>
<td><input type="text" id="ref_date1" value="<? echo $todt ?>" name="todt" readonly></td>
</tr>

<tr><td>AMC</td><td><input type="text" id="amcamt"  name="amcamt" value='<? echo $row['amcamt'] ?>' size="50px"></td><td>EW</td><td><input type="text" id="ewamt"  name="ewamt" value='<? echo $row['ewamt'] ?>' size="50px"></td></tr>

<tr><td>AC</td><td><input type="text" id="acamt"  name="acamt" value='<? echo $row['acamt'] ?>' size="50px"></td><td>GPS</td><td><input type="text" id="gpsamt"  name="gpsamt" value='<? echo $row['gpsamt'] ?>' size="50px"></td></tr>
<tr><td>JACK</td><td><input type="text" id="jacamt"  name="jacamt" value='<? echo $row['jacamt'] ?>' size="50px"></td><td>REG EXP</td><td><input type="text" id="regamt"  name="regamt" value='<? echo $row['regamt'] ?>' size="50px"></td></tr>
<tr><td>AIR DOOR</td><td><input type="text" id="airamt"  name="airamt" value='<? echo $row['airamt'] ?>' size="50px"></td><td>STERIO /REVERSE CAMERA</td><td><input type="text" id="camamt"  name="camamt" value='<? echo $row['camamt'] ?>' size="50px"></td></tr>

<tr><td>FOG LAMP</td><td><input type="text" id="fogamt"  name="fogamt" value='<? echo $row['fogamt'] ?>' size="50px"></td><td>PAINTING OTHERS</td><td><input type="text" id="paintamt"  name="paintamt" value='<? echo $row['paintamt'] ?>' size="50px"></td></tr>

<tr><td>CHASIS NO</td><td><input type="text" id="chasisno"  name="chasisno" value='<? echo $row['chasisno'] ?>' 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'];
    $slno=$_REQUEST['slno'];
    $custname=$_REQUEST['custname'];
    $custaddr=$_REQUEST['custaddr'];
    $custphone=$_REQUEST['custphone'];
    $custemail=$_REQUEST['custemail'];
    $custgst=$_REQUEST['custgst'];
    $custpan=$_REQUEST['custpan'];
    $vehconf=$_REQUEST['vehconf'];
    $custfin=$_REQUEST['custfin'];
    $custexec=$_REQUEST['custexec'];
    $invamt=$_REQUEST['invamt'];
    $insamt=$_REQUEST['insamt'];
    $refndamt=$_REQUEST['refndamt'];
    $totamt=$_REQUEST['totamt'];
    
    $findisb=$_REQUEST['findisb'];
    $exchamt=$_REQUEST['exchamt'];
    $discamt=$_REQUEST['discamt'];
    $subamt=$_REQUEST['subamt'];
    $othamt=$_REQUEST['othamt'];
    $dueamt=$_REQUEST['dueamt'];
    
    
    
    $amcamt=$_REQUEST['amcamt'];
    $acamt=$_REQUEST['acamt'];
    $ewamt=$_REQUEST['ewamt'];
    $gpsamt=$_REQUEST['gpsamt'];
    $jacamt=$_REQUEST['jacamt'];
    $regamt=$_REQUEST['regamt'];
    $airamt=$_REQUEST['airamt'];
    $camamt=$_REQUEST['camamt'];
    $fogamt=$_REQUEST['fogamt'];
    $paintamt=$_REQUEST['paintamt'];
    
    $chasisno=$_REQUEST['chasisno'];
    $todt=$_REQUEST['todt'];
    
    $todt = implode('-', array_reverse(explode('-', $todt)));
  //echo "insert into sales_details(brcode,sl_no,customer_name,address,phone,email,gst_no,pan_no,cofiguration,financier,exc_name,inv_value,ins_amt,refund_amt,total_amt,fin_disbursment,exchange_amt,discount_amt,subvention,others,bal_due_amt,date,received_amt,deposit_at,segment,branch) values('$brcode','$slno','$custname','$custaddr','$custphone','$custemail','$custgst','$custpan','$vehconf','$custfin','$custexec','$invamt','$insamt','$refndamt','$totamt','$findisb','$exchamt','$discamt','$subamt','$othamt','$dueamt','$todt',0,'$deposit','$segment','$branchname')";
    $qry=mysqli_query($db,"update sales_details set sl_no='$slno',customer_name='$custname',address='$custaddr',phone='$custphone',email='$custemail',gst_no='$custgst',pan_no='$custpan',cofiguration='$vehconf',financier='$custfin',exc_name='$custexec',inv_value='$invamt',ins_amt='$insamt',refund_amt='$refndamt',total_amt='$totamt',fin_disbursment='$findisb',exchange_amt='$exchamt',discount_amt='$discamt',subvention='$subamt',others='$othamt',bal_due_amt='$dueamt',date='$todt',amcamt='$amcamt',ewamt='$ewamt',acamt='$acamt',gpsamt='$gpsamt',jacamt='$jacamt',regamt='$regamt',airamt='$airamt',camamt='$camamt',fogamt='$fogamt',paintamt='$paintamt',chasisno='$chasisno' where brcode='$brcode' and id='$recdid'");
   
print "<script>alert('Data has been updated'); </script>";
print "<script>document.location='saleqot.php'</script>";
}

    
    
   


?>