<?
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'];
?>
<html>
<body >
<center>
<title>GST Report</title>

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">


<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="report" style="width:auto;" >
<h2>Sale Details</h2>
<?
$yeardat=explode('-',$fin_year);
$startingyr=$yeardat[0];
$mgrp="";
$qry=mysqli_query($db,"select * from sales_details where brcode='$brcode' and id='$recordid'");
$row=mysqli_fetch_array($qry);
//echo "select * from sales_details where brcode='$brcode' and id='$recordid'";
?>




</form>
</table>
<br><br>
<table class="table table-bordered table-striped">
<tr>
<th>Sl No</th>
<th>Customer Order Form No</th>
<th>PSN Order Form No</th>
<th>Customer Name </th>
<th>Address </th>
<th>PAN </th>

</tr>
<tr>
<td><? echo $row['sl_no'] ?></td>
<td><? echo $row['custordno'] ?></td>
<td><? echo $row['psnordno'] ?></td>
<td><? echo $row['customer_name'] ?></td>
<td><? echo $row['address'] ?></td>
<td><? echo $row['pan_no'] ?></td>
</tr>
<tr>
<th>Phone</th>
<th>Email</th>
<th>GST No</th>
<th>Configuration </th>
<th>Financer </th>
<th>Executive </th>
</tr>
<tr>
<td><? echo $row['phone'] ?></td>
<td><? echo $row['email'] ?></td>
<td><? echo $row['gst_no'] ?></td>
<td><? echo $row['cofiguration'] ?></td>
<td><? echo $row['financier'] ?></td>
<td><? echo $row['exc_name'] ?></td>
</tr>
<tr>
<th>Invoice Amt</th>
<th>Insurance Amt</th>
<th>Insurance Narration</th>
<th>Refund Amt </th>
<th>Total Amt </th>
<th>Final Disbursement </th>
</tr>
<tr>
<td><? echo $row['inv_value'] ?></td>
<td><? echo $row['ins_amt'] ?></td>
<td><? echo $row['insnarr'] ?></td>
<td><? echo $row['refund_amt'] ?></td>
<td><? echo $row['total_amt'] ?></td>
<td><? echo $row['fin_disbursment'] ?></td>
</tr>



<tr>
<th>Exchange Amt</th>
<th>Discount Amt</th>
<th>Subvention Amt </th>
<th>Other Amt </th>
<th>Other Amt Narration</th>
<th>Balance Due Amt </th>
</tr>
<tr>
<td><? echo $row['exchange_amt'] ?></td>
<td><? echo $row['discount_amt'] ?></td>
<td><? echo $row['subvention'] ?></td>
<td><? echo $row['others'] ?></td>
<td><? echo $row['othamtnarr'] ?></td>
<td><? echo $row['bal_due_amt'] ?></td>
</tr>

<tr>
<th>Segment</th>
<th>Branch</th>
<th>Date </th>
<th>AMC </th>
<th>AMC Narration</th>
<th>AMC Type </th>
</tr>
<tr>
<td><? echo $row['segment'] ?></td>
<td><? echo $row['branch'] ?></td>
<td><? echo $row['date'] ?></td>
<td><? echo $row['amcamt'] ?></td>
<td><? echo $row['amcnarr'] ?></td>
<td><? echo $row['amctyp'] ?></td>
</tr>



<tr>
<th>EW</th>
<th>EW Narration</th>
<th>EW Type </th>
<th>Other </th>
<th>Other Narration</th>
<th>Other Type</th>
</tr>
<tr>
<td><? echo $row['ewamt'] ?></td>
<td><? echo $row['ewnarr'] ?></td>
<td><? echo $row['ewtyp'] ?></td>
<td><? echo $row['acamt'] ?></td>
<td><? echo $row['othnarr'] ?></td>
<td><? echo $row['othtyp'] ?></td>
</tr>

<tr>
<th>GPS</th>
<th>GPS Narration</th>
<th>GPS Type </th>
<th>JACK </th>
<th>JACK Narration</th>
<th>JACK Type</th>
</tr>
<tr>
<td><? echo $row['gpsamt'] ?></td>
<td><? echo $row['gpsnarr'] ?></td>
<td><? echo $row['gpstyp'] ?></td>
<td><? echo $row['jacamt'] ?></td>
<td><? echo $row['jacknarr'] ?></td>
<td><? echo $row['jacktyp'] ?></td>
</tr>

<tr>
<th>REG EXP</th>
<th>REG EXP Narration</th>
<th>REG EXP Type </th>
<th>AIR DOOR </th>
<th>AIR DOOR Narration</th>
<th>AIR DOOR Type</th>
</tr>
<tr>
<td><? echo $row['regamt'] ?></td>
<td><? echo $row['regnarr'] ?></td>
<td><? echo $row['regtyp'] ?></td>
<td><? echo $row['airamt'] ?></td>
<td><? echo $row['airnarr'] ?></td>
<td><? echo $row['airtyp'] ?></td>
</tr>
<tr>
<th>STERIO /REVERSE CAMERA</th>
<th>STERIO /REVERSE CAMERA Narration</th>
<th>STERIO /REVERSE CAMERA Type </th>
<th>FOG LAMP </th>
<th>FOG LAMP Narration</th>
<th>FOG LAMP Type</th>
</tr>
<tr>
<td><? echo $row['camamt'] ?></td>
<td><? echo $row['camnarr'] ?></td>
<td><? echo $row['camtyp'] ?></td>
<td><? echo $row['fogamt'] ?></td>
<td><? echo $row['fognarr'] ?></td>
<td><? echo $row['fogtyp'] ?></td>
</tr>
<tr>
<th>PAINTING OTHERS</th>
<th>PAINTING Narration</th>
<th>PAINTING Type </th>
<th>Body Rate </th>
<th>Body Rate Narration</th>
<th>CHASIS NO</th>
</tr>
<tr>
<td><? echo $row['paintamt'] ?></td>
<td><? echo $row['paintnarr'] ?></td>
<td><? echo $row['painttyp'] ?></td>
<td><? echo $row['fogamt'] ?></td>
<td><? echo $row['bodyrate'] ?></td>
<td><? echo $row['chasisno'] ?></td>
</tr>
</table>
<h2>Payment Details</h2>
<?
$slnoval=$row['sl_no'];

$qrydown=mysqli_query($db,"select * from downpayment where brcode='$brcode' and sl_no='$slnoval'");

?>
<table class="table table-bordered table-striped">
<tr>
<th>Sl No</th>
<th>Customer</th>
<th>Received Amt</th>
<th>Deposit </th>
<th>Date </th>

</tr>
<?
while($rowdown=mysqli_fetch_array($qrydown))
{
?>
<tr>
<td><? echo $rowdown['sl_no'] ?></td>
<td><? echo $rowdown['customer_name'] ?></td>
<td><? echo $rowdown['received_amt'] ?></td>
<td><? echo $rowdown['deposit_at'] ?></td>
<td><? echo $rowdown['date'] ?></td>

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