<?
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');
?>
<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_date" ).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_date").datepicker({ dateFormat: 'dd-mm-yy', minDate: stfnyr, maxDate: efnyr});

$( "#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', minDate: stfnyr, maxDate: efnyr});
});
</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>
<script type="text/javascript">

$(function(){
  $(".panno").live("keydown.autocomplete",function(){
  $supnm = $(this);
  $row = $supnm.parent().parent();
  $(this).autocomplete({
    source: function( request, response ) {
    $.ajax({
      url: "search1_sales.php",
      dataType: "json",
      data: "key="+$supnm.val(),
      success: function( data ) {
        response( $.map( data, function( item ) {
          return {
            label:  item.supnm+' | '+ item.partcode+' | '+  item.partname+' | '+  item.stock+' | '+  item.gstno +' | '+  item.rate ,
            value: item.supnm,
            name:item.partname,
            partcode:item.partcode,
            stock:item.stock,
            rate:item.rate,
            gstno:item.gstno,
            }
        }));
      }
    });
  }
  ,
  minLength: 2,
  select: function( event, ui ) {
        document.getElementById("custname").value=ui.item.partcode;
        document.getElementById("custaddr").value=ui.item.name;
  //$row.find('.partname').val(ui.item.name);
        document.getElementById("custgst").value=ui.item.gstno;
        document.getElementById("custphone").value=ui.item.stock;
        document.getElementById("custemail").value=ui.item.rate;
  $row.find('.qty').focus();
  /*log( ui.item ?
  "Selected: " + ui.item.label :
  "Nothing selected, input was " + this.value);
  */
   }

  }).data("ui-autocomplete")._renderItem = function (ul, item) {
         return $("<li></li>")
             .data("item.autocomplete", item)
             .append( item.label )
             .appendTo(ul);
     };
  });
});
</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];
?>

<table class="form" style="width:auto;" >
<tr><th style="background:grey;" colspan=6>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" ></td><td>Customer Order Form No </td><td><input type="text" id="custordno"  name="custordno" ></td><td>PSN Order Form No </td><td><input type="text" id="psnordno"  name="psnordno" size="50px"></td></tr>
<tr>
    <td>PAN</td><td><input type="text" id="custpan"  name="custpan" class='panno' size="50px"></td>
<td>Customer Name </td><td><input type="text" id="custname"  name="custname"  size="50px" ></td><td>Address</td><td><input type="text" id="custaddr"  name="custaddr" class='partname' size="50px"></td></tr>
<tr><td>Phone</td><td><input type="text" id="custphone"  name="custphone" size="50px"></td><td>Email</td><td><input type="text" id="custemail"  name="custemail" size="50px"></td><td>GST No</td><td><input type="text" id="custgst"  name="custgst" size="50px"></td></tr>
<tr><td>Configuration</td><td><input type="text" id="vehconf"  name="vehconf"  size="50px"></td><td>Financer</td><td><input type="text" id="custfin"  name="custfin" size="50px"></td><td>Executive</td><td><input type="text" id="custexec"  name="custexec" size="50px"></td></tr>
<tr><td>Invoice Amt</td><td><input type="text" id="invamt"  name="invamt" size="50px"></td><td>Insurance Amt</td><td><input type="text" id="insamt"  name="insamt" size="50px"></td>
<td>Insurance Narration</td><td><input type="text" id="insnarr"  name="insnarr"  size="50px"></td>
</tr>
<tr><td>Refund Amt</td><td><input type="text" id="refndamt"  name="refndamt" onKeyup='calcamt()' size="50px"></td><td>Total Amt</td><td><input type="text" id="totamt"  name="totamt" onKeyup='calcamt()' size="50px"></td><td>Final Disbursement</td><td><input type="text" id="findisb"  name="findisb" size="50px"></td></tr>
<tr><td>Exchange Amt</td><td><input type="text" id="exchamt"  name="exchamt" size="50px"></td><td>Discount Amt</td><td><input type="text" id="discamt"  name="discamt" onKeyup='calcamt()' size="50px"></td><td>Subvention Amt</td><td><input type="text" id="subamt"  name="subamt" onKeyup='calcamt()' size="50px"></td></tr>

<tr><td>Other Amt</td><td><input type="text" id="othamt"  name="othamt" onKeyup='calcamt()' size="50px"></td>
<td>Other Amt Narration</td><td><input type="text" id="othamtnarr"  name="othamtnarr" size="50px"></td>
<td>Balance Due Amt</td><td><input type="text" id="dueamt"  name="dueamt" onKeyup='calcamt()' size="50px"></td>
</tr>
<tr>

<td>Segment</td><td><input type="text" id="vehsegment"  name="vehsegment" size="50px"></td><td>Branch</td><td><select id="vehbranch"  name="vehbranch"><option value='select'>-select-</option>

<option value='LCV-COCHIN'>LCV-COCHIN</option>
<option value='LCV-THRISSUR'>LCV-THRISSUR</option>
<option value='LCV-ALLEPPEY'>LCV-ALLEPPEY</option>
<option value='LCV-PALAKKAD'>LCV-PALAKKAD</option>
<option value='LCV-THRISSUR'>LCV-THRISSUR</option>
<option value='HCV-COCHIN'>HCV-COCHIN</option>
<option value='HCV-THRISSUR'>HCV-THRISSUR</option>
<option value='HCV-ALLEPPEY'>HCV-ALLEPPEY</option>
<option value='HCV-PALAKKAD'>HCV-PALAKKAD</option>
<option value='TERRA-COCHIN'>TERRA-COCHIN</option>
<option value='TERRA-THRISSUR'>TERRA-THRISSUR</option>
<option value='TERRA-ALLEPPEY'>TERRA-ALLEPPEY</option>
<option value='TERRA-PALAKKAD'>TERRA-PALAKKAD</option>
</select></td>
<td> Date </td>
<td><input type="text" id="ref_date1" value="<?echo date('d-m-Y');?>" name="todt" readonly></td>
</tr>
<tr>
<td>AMC</td><td><input type="text" id="amcamt"  name="amcamt"  size="50px"></td>
<td>AMC Narration</td><td><input type="text" id="amcnarr"  name="amcnarr"  size="50px"></td>
<td>AMC Type</td><td><select name='amctype' id='amctype'><option value='PAID'>PAID</option><option value='OFFER'>OFFER</option></select></td>
</tr>
<tr>
<td>EW</td><td><input type="text" id="ewamt"  name="ewamt"  size="50px"></td>
<td>EW Narration</td><td><input type="text" id="ewnarr"  name="ewnarr"  size="50px"></td>
<td>EW Type</td><td><select name='ewtype' id='ewtype'><option value='PAID'>PAID</option><option value='OFFER'>OFFER</option></select></td>
</tr>

<tr>
<td>Other</td><td><input type="text" id="acamt"  name="acamt" size="50px"></td>
<td>Other Narration</td><td><input type="text" id="othnarr"  name="othnarr"  size="50px"></td>
<td>Other Type</td><td><select name='othtype' id='othtype'><option value='PAID'>PAID</option><option value='OFFER'>OFFER</option></select></td>
</tr>

<tr>
<td>GPS</td><td><input type="text" id="gpsamt"  name="gpsamt" size="50px"></td>
<td>GPS Narration</td><td><input type="text" id="gpsnarr"  name="gpsnarr"  size="50px"></td>
<td>GPS Type</td><td><select name='gpstype' id='gpstype'><option value='PAID'>PAID</option><option value='OFFER'>OFFER</option></select></td>
</tr>

<tr>
<td>JACK</td><td><input type="text" id="jacamt"  name="jacamt"  size="50px"></td>
<td>JACK Narration</td><td><input type="text" id="jacknarr"  name="jacknarr"  size="50px"></td>
<td>JACK Type</td><td><select name='jacktype' id='jacktype'><option value='PAID'>PAID</option><option value='OFFER'>OFFER</option></select></td>
</tr>

<tr>
<td>REG EXP</td><td><input type="text" id="regamt"  name="regamt" size="50px"></td>
<td>REG EXP Narration</td><td><input type="text" id="regnarr"  name="regnarr"  size="50px"></td>
<td>REG EXP Type</td><td><select name='regtype' id='regtype'><option value='PAID'>PAID</option><option value='OFFER'>OFFER</option></select></td>
</tr>

<tr>
<td>AIR DOOR</td><td><input type="text" id="airamt"  name="airamt" size="50px"></td>
<td>AIR DOOR Narration</td><td><input type="text" id="airnarr"  name="airnarr"  size="50px"></td>
<td>AIR DOOR Type</td><td><select name='airtype' id='airtype'><option value='PAID'>PAID</option><option value='OFFER'>OFFER</option></select></td>
</tr>


<tr>
<td>STERIO /REVERSE CAMERA</td><td><input type="text" id="camamt"  name="camamt" size="50px"></td>
<td>STERIO /REVERSE CAMERA Narration</td><td><input type="text" id="camnarr"  name="camnarr"  size="50px"></td>
<td>STERIO /REVERSE CAMERA Type</td><td><select name='camtype' id='camtype'><option value='PAID'>PAID</option><option value='OFFER'>OFFER</option></select></td>
</tr>

<tr>
<td>FOG LAMP</td><td><input type="text" id="fogamt"  name="fogamt" size="50px"></td>
<td>FOG LAMP Narration</td><td><input type="text" id="fognarr"  name="fognarr"  size="50px"></td>
<td>FOG LAMP Type</td><td><select name='fogtype' id='fogtype'><option value='PAID'>PAID</option><option value='OFFER'>OFFER</option></select></td>
</tr>

<tr>
<td>PAINTING OTHERS</td><td><input type="text" id="paintamt"  name="paintamt"  size="50px"></td>
<td>PAINTING Narration</td><td><input type="text" id="paintnarr"  name="paintnarr"  size="50px"></td>
<td>PAINTING Type</td><td><select name='painttype' id='painttype'><option value='PAID'>PAID</option><option value='OFFER'>OFFER</option></select></td>
</tr>

<tr>
   <td>Body Rate</td><td><input type="text" id="bodyamt"  name="bodyamt"  size="50px"></td>
<td>Body Rate Narration</td><td><input type="text" id="bodynarr"  name="bodynarr"  size="50px"></td> 
    
    <td>CHASIS NO</td><td><input type="text" id="chasisno"  name="chasisno"  size="50px"></td></tr>
<tr><td><br></td></tr>


<tr><th style="background:grey;" colspan=6><input type='submit' name='show' value='Submit'></th></tr>

</form>
</table>
<br><br>
<?
if(isset($_POST['show']))
{
    $slno=$_REQUEST['slno'];
    $custname=$_REQUEST['custname'];
    $custaddr=$_REQUEST['custaddr'];
    $custphone=$_REQUEST['custphone'];
    $custemail=$_REQUEST['custemail'];
    $custgst=$_REQUEST['custgst'];
    $custgst = preg_replace("/[^a-zA-Z0-9]/", "", $custgst);
    $custpan=$_REQUEST['custpan'];
    $custpan = preg_replace("/[^a-zA-Z0-9]/", "", $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'];
    $vehsegment=$_REQUEST['vehsegment'];
    $vehbranch=$_REQUEST['vehbranch'];
    $custordno=$_REQUEST['custordno'];
    $psnordno=$_REQUEST['psnordno'];
    $todt=$_REQUEST['todt'];
    if($findisb<='')    {   $findisb=0;     }
    if($exchamt<='')    {   $exchamt=0;     }
    if($subamt<='')     {   $subamt=0;      }
    if($othamt<='')     {   $othamt=0;      }
    $amcamt=$_REQUEST['amcamt'];
    $ewamt=$_REQUEST['ewamt'];
    $acamt=$_REQUEST['acamt'];
    $gpsamt=$_REQUEST['gpsamt'];
    $jacamt=$_REQUEST['jacamt'];
    $regamt=$_REQUEST['regamt'];
    $airamt=$_REQUEST['airamt'];
    $camamt=$_REQUEST['camamt'];
    $fogamt=$_REQUEST['fogamt'];
    $paintamt=$_REQUEST['paintamt'];
    $chasisno=$_REQUEST['chasisno'];
    if($amcamt<='')     {    $amcamt=0;     }
    if($ewamt<='')      {    $ewamt=0;      }
    if($acamt<='')      {    $acamt=0;      }
    if($gpsamt<='')     {    $gpsamt=0;     }
    if($jacamt<='')     {    $jacamt=0;     }
    if($regamt<='')     {    $regamt=0;     }
    if($airamt<='')     {    $airamt=0;     }
    if($camamt<='')     {    $camamt=0;     }
    if($fogamt<='')     {    $fogamt=0;     }
    if($paintamt<='')   {    $paintamt=0;   }
    
    $insnarr=$_REQUEST['insnarr'];
    $othamtnarr=$_REQUEST['othamtnarr'];
    $amcnarr=$_REQUEST['amcnarr'];
    $amctype=$_REQUEST['amctype'];
    $ewnarr=$_REQUEST['ewnarr'];
    $ewtype=$_REQUEST['ewtype'];
    $othnarr=$_REQUEST['othnarr'];
    $othtype=$_REQUEST['othtype'];
    
    
    $gpsnarr=$_REQUEST['gpsnarr'];
    $gpstype=$_REQUEST['gpstype'];
    $jacknarr=$_REQUEST['jacknarr'];
    $jacktype=$_REQUEST['jacktype'];
    $regnarr=$_REQUEST['regnarr'];
    $regtype=$_REQUEST['regtype'];
    $airnarr=$_REQUEST['airnarr'];
    $airtype=$_REQUEST['airtype'];
    $camnarr=$_REQUEST['camnarr'];
    $camtype=$_REQUEST['camtype'];
    $fognarr=$_REQUEST['fognarr'];
    $fogtype=$_REQUEST['fogtype'];
    $paintnarr=$_REQUEST['paintnarr'];
    $painttype=$_REQUEST['painttype'];
    
    $bodyamt=$_REQUEST['bodyamt'];
    $bodynarr=$_REQUEST['bodynarr'];
    
    
   
   
   
   
   
   
    
    
    
    
    $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')";
  //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,custordno,psnordno) 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','$vehsegment','$vehbranch','$custordno','$psnordno')";
    $qry=mysqli_query($db,"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,custordno,psnordno,amcamt,ewamt,acamt,gpsamt,jacamt,regamt,airamt,camamt,fogamt,paintamt,chasisno,insnarr,othamtnarr,amcnarr,amctyp,ewnarr,ewtyp,othnarr,othtyp,gpsnarr,gpstyp,jacknarr,jacktyp,regnarr,regtyp,airnarr,airtyp,camnarr,camtyp,fognarr,fogtyp,paintnarr,painttyp,bodyrate,bodynarr) 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','$vehsegment','$vehbranch','$custordno','$psnordno','$amcamt','$ewamt','$acamt','$gpsamt','$jacamt','$regamt','$airamt','$camamt','$fogamt','$paintamt','$chasisno',     '$insnarr','$othamtnarr','$amcnarr','$amctype','$ewnarr','$ewtype','$othnarr','$othtype','$gpsnarr','$gpstype','$jacknarr','$jacktype',    '$regnarr','$regtype','$airnarr','$airtype','$camnarr','$camtype','$fognarr','$fogtype','$paintnarr','$painttype','$bodyamt','$bodynarr')");
   
print "<script>alert('Data has been saved'); </script>";
print "<script>document.location='saleqot.php'</script>";
}

    
    $qry=mysqli_query($db,"select* from sales_details where brcode='$brcode' group by sl_no order by sl_no desc");
    //echo "select* from sales_details where brcode='$brcode' group by sl_no order by sl_no desc";
	
    print "<table class='report' border='1' style='width: 100%;'>";
    
    print "<tr><th>SlNo</th><th>Customer</th><th>Address</th><th>Phone<th>Email</th><th>GST No</th>";
   
    print "<th>PAN</th><th>Configuration</th><th>Invoice Amt</th><th>Edit</th><th>Payment Details</th>";
    while($row=mysqli_fetch_array($qry))
    {
        print "<tr><td>".$row[2]."</td><td>".$row[3]."</td><td>".$row[4]."</td><td>$row[5]</td><td>$row[6]</td><td>$row[7]</td><td>$row[8]</td><td>$row[9]</td><td align='right'>$row[12]</td>";
       
        print "<td><a href='editsalequot.php?code=$row[0]'> <img src='img/signit.gif' border=0></a></td><td><input type='button' name='updbtn' id='updbtn' value='View' onclick='upddetails($row[0])'></td></tr>";
  
    }
    $mgr_cot +=  $mtot_cot;
    $mgr_pol +=  $mtot_pol;
    $mgr_rel +=  $mtot_rel;
    $mgr_spu +=  $mtot_spu;
    $mgr_vip +=  $mtot_vip;
    $mgr_woo +=  $mtot_woo;
    $mgr_oth +=  $mtot_oth;
    $mgr_mba+=  $mtot_mba;
    $mgr_strbtnml +=  $mtot_strbtnml;
    $mgr_strbtspl +=  $mtot_strbtspl;
    $mgr_redct +=  $mtot_redct;
    $mgr_befrtx +=  $mtot_befrtx;
    $mgr_taxamt +=  $mtot_taxamt;
    $mgr_nettot +=  $mtot_nettot;
    $mgr_dbtrs +=  $mtot_dbtrs;

    //print "<tr><td>$minvno</td><td align='right'>".number_format($mtot_cot,2,'.','')."</td><td align='right'>".number_format($mtot_pol,2,'.','')."</td><td align='right'>".number_format($mtot_rel,2,'.','')."</td><td align='right'>".number_format($mtot_spu,2,'.','')."</td><td align='right'>".number_format($mtot_vip,2,'.','')."</td><td align='right'>".number_format($mtot_woo,2,'.','')."</td><td align='right'>".number_format($mtot_oth,2,'.','')."</td><td align='right'>".number_format($mtot_mba,2,'.','')."</td><td align='right'>".number_format($mtot_strbtnml,2,'.','')."</td><td align='right'>".number_format($mtot_strbtspl,2,'.','')."</td></tr>";
    //print "<tr><td><b>Grand Total</b></td><td align='right'><b>".number_format($mgr_cot,2)."</b></td><td align='right'><b>".number_format($mgr_pol,2)."</b></td><td align='right'><b>".number_format($mgr_rel,2)."</b></td><td align='right'><b>".number_format($mgr_spu,2)."</b></td><td align='right'><b>".number_format($mgr_vip,2)."</b></td><td align='right'><b>".number_format($mgr_woo,2)."</b></td><td align='right'><b>".number_format($mgr_oth,2)."</b></td><td align='right'><b>".number_format($mgr_mba,2)."</b></td><td align='right'><b>".number_format($mgr_strbtnml,2)."</b></td><td align='right'><b>".number_format($mgr_strbtspl,2)."</b></td></tr>";
    print "</table>";
?>
<script>
function calcamt()
{
    if(document.getElementById("totamt").value>0)
    {
        var total=parseFloat(document.getElementById("totamt").value);
    }
    else
    {
        var total=0;
    }
    if(document.getElementById("discamt").value>0)
    {
    var discamt=parseFloat(document.getElementById("discamt").value);
    }
    else
    {
        var discamt=0;
    }
    if(document.getElementById("subamt").value>0)
    {
    var subventamt=parseFloat(document.getElementById("subamt").value);
    }
    else
    {
        var subventamt=0;
    }
    if(document.getElementById("othamt").value>0)
    {
    var otheramt=parseFloat(document.getElementById("othamt").value);
    }
    else
    {
        var otheramt=0;
    }
    if(document.getElementById("refndamt").value>0)
    {
    var refundamt=parseFloat(document.getElementById("refndamt").value);
    }
    else
    {
        var refundamt=0;
    }
    var dueamtvl=total-discamt-subventamt-otheramt+refundamt;
    document.getElementById("dueamt").value=dueamtvl;
}
function upddetails(rcid)
{
    window.open("updsalepdetails.php?recordid="+rcid,true);
}
</script>