<?php 
include "config.php";
?>
<html>
<head>
  <title>Feenix</title>
  <style>
    th
    {
      font-size:24px;
    }
    td
    {
      font-size:20px;
      font-weight:bold;
    }
    .contentTable td {
      padding:15px;
    }
    .contentTable .paddingLeft{
      padding-left:40px;
    }
    .contentTable td:nth-child(1) {
      padding-top:35px;
    }
    .contentTable td:nth-child(2) {
      padding-top:35px;
    }
    .borderTop{
      border-top:2px solid black;
    }
    .borderLeft{
      border-left:2px solid black;
    }
    .borderBottom{
      border-bottom:2px solid black;
    }
    .borderRight{
      border-right:2px solid black;
    }
  </style>
</head>
<script>
  function escapekeypressed()
{
	//alert(event.keyCode);
	if(event.keyCode=='13'){ window.print(); }
}
</script>
<body onkeydown="escapekeypressed()" ontouchstart="window.print()">
<table>
<?php 
$code = $_GET['print'];
$table = $_GET['table'];
//echo $code;
//echo "select * from $table where status !='deleted' and salescode ='$code'";
if($table !='purchasedetails'){
$single=mysqli_query($connect,"select * from $table where status !='deleted' and salescode ='$code'");
while($singleshow = mysqli_fetch_array($single))
{
    $tkt = $singleshow['ticket'];
    $fst=mysqli_query($connect,"select * from ticket where status !='deleted' and ticket = '$tkt'");
    while($fstshow = mysqli_fetch_array($fst))
    {
	//echo "select * from ticket where status !='deleted' and ticket = '$tkt'";
	
   $customer = $singleshow['customer'];
  // echo"select * from customerdetails  where  code = '$customer' && status!='deleted'";
$cus=mysqli_query($connect,"select * from customerdetails  where  code = '$customer' && status!='deleted'");
while($cusshow = mysqli_fetch_array($cus))
{
    $product = $singleshow['product'];
$pro=mysqli_query($connect,"select * from productdetail where productcode = '$product'");
while($proshow = mysqli_fetch_array($pro))
{
    $date = $singleshow['editdate'];
  $datefr = date_create($date);
  $datefrom = date_format($datefr,"d-m-Y");

?><?php 
$proedit=mysqli_query($connect,"select * from partydetail order by id desc");
while($proshowedi = mysqli_fetch_array($proedit))
{
  $party=  $proshowedi['party'];
}

?>
<tr align="center"><th colspan="4"><?php echo $party ?></th></tr>
  <tr>
    <td colspan="4"><b>To:<?php echo $cusshow['name'] ?></b></td>
  </tr>
  <!-- <tr>
    <td colspan=4><b>Trip No:</b>
    <span><b><?php echo $fstshow['tripno'] ?></b></span></td>
  </tr> -->
  <tr>
    <td colspan=4><b>Vehicle No:</b>
    <span><b><?php echo $singleshow['vehicleno'] ?></b></span></td>
  </tr>
  <tr>
    <td colspan=4><b>Ticket No:</b>
    <span><b><?php echo $singleshow['ticket'] ?></b></span></td>
  </tr>
    <tr>
    <td colspan=4><b>Invoice No:</b>
    <span><b><?php echo $singleshow['salescode'] ?></b></span></td>
  </tr>
  <tr>
    <td colspan=4><b><span><?php echo $datefrom?></span>,</b>
    <span><b><?php echo $singleshow['edittime'] ?></b></span></td>
  </tr>
  <tr>
    <td colspan=4>--------------------------------------------------</td>
  </tr>
  <tr>
    <td colspan=4><b>Material:</b>
    <span><b><?php echo $proshow['productname'] ?></b></span></td>
  </tr>
  <tr>
    <td colspan=4><span><b>Unit:<?php echo $singleshow['netqty'] ?></b></span></b>
    </td>  </tr>
  <tr>
    <td colspan=4>--------------------------------------------------</td>
  </tr>
  <tr>
    <td colspan=2><b>Details</b>
    </td><td colspan=2><span><b>Weight</b></span></td>
  </tr>
  <tr>
    <td colspan=4>--------------------------------------------------</td>
  </tr>
  <tr>
    <td colspan=2><b>Empty-weight</b>
    </td><td colspan=2><span><b><?php echo $singleshow['emptyweight'] ?></b></span></td>
  </tr>
  <tr>
    <td colspan=2><b>Load-weight</b>
    </td><td colspan=2><span><b><?php echo $singleshow['loadweight'] ?></b></span></td>
  </tr>
    <tr>
    <td colspan=4>--------------------------------------------------</td>
  </tr>
  <tr>
    <td colspan=2><b>Nett-weight</b>
    </td><td colspan=2><span><b><?php echo $singleshow['netweight'] ?></b></span></td>
  </tr>
  <tr>
    <td colspan=4>--------------------------------------------------</td>
  </tr>
  <tr>
  
    <td colspan=2 style="text-align:center;float:left;margin-top:50px;font-weight:normal;">Customer Signature<td>
	<td colspan=2 style="text-align:center;float:right;font-weight:normal;">Authorized Signature<td>
  </tr>
  <tr>
    <td colspan=4>--------------------------------------------------</td>
  </tr>
  <tr>
    <td colspan=4 style="text-align:center">Thank You<td>
  </tr>
  <?php 
}}}}}
  ?>
  <?php 
  if($table =='purchasedetails'){
    $single=mysqli_query($connect,"select * from $table where status !='deleted' and salescode ='$code'");
while($singleshow = mysqli_fetch_array($single))
{
    $tkt = $singleshow['ticket'];
    $fst=mysqli_query($connect,"select * from ticket where status !='deleted' and ticket = '$tkt'");
    while($fstshow = mysqli_fetch_array($fst))
    {
	$tripno=$fstshow['tripno'];
   $customer = $singleshow['customer'];
  // echo"select * from customerdetails  where  code = '$customer' && status!='deleted'";
$cus=mysqli_query($connect,"select * from customerdetails  where  code = '$customer' && status!='deleted'");
while($cusshow = mysqli_fetch_array($cus))
{
    $product = $singleshow['product'];
$pro=mysqli_query($connect,"select * from productdetail where productcode = '$product'");
while($proshow = mysqli_fetch_array($pro))
{
    $date = $singleshow['date'];
  $datefr = date_create($date);
  $datefrom = date_format($datefr,"d-m-Y");
  ?>
  <table width="100%" style="border:2px solid black">
  <tr style="border:2px solid red">
     <td width="100%" align="center" style="padding-left:10px;padding-bottom:10px"> <img src="image/logo.png" style="float:left;margin-top:2px;" width="130px">
     <font style="padding-top:200px;font-size:24px;"><br>YOGA SAND AND STONES COMPANY</font><br>
     <font style="margin-left:20px;font-size:16px;">No 4/5.1 Vadipatti,Kachakatti Main Road<br> <span style="margin-left:20px;">Thathampatti Village (P.o)
Vadipatti (T.k),Madurai-625 218</span> <br>
     
     <span style="margin-left:20px;margin-bottom:20px;"><b>Email: &nbsp;&nbsp;:sandsandstones@yogainfra.com</b></span>
   </font>
</td>
</tr>
  </table>
<table width="100%"  class="borderBottom borderLeft borderRight">
<tr>
<td width="30%" align="Center"> No : <?php echo $singleshow['salescode'] ?></td>
<td width="40%" align="Center">Delivery Sheet</td>
<td width="30%" align="Center">Date : <?php echo $datefrom ?></td>
</tr>
</table>
<table width="100%" class="contentTable borderLeft borderRight" >
<tr>
<td width="50%" class="paddingLeft"align="left"> Vehicle No </td><td width="50%" align="left">:&nbsp;<?php echo $singleshow['vehicleno'] ?> </td></tr>
<tr><td width="50%" class="paddingLeft"align="left">Time</td><td width="50%" align="left">:&nbsp;<?php echo $singleshow['time'] ?></td></tr>
<tr><td width="50%" class="paddingLeft"align="left">Party Name </td><td width="50%" align="left">:&nbsp;<?php echo $cusshow['name'] ?></td></tr>
<tr><td width="50%" class="paddingLeft"align="left"> Material From</td><td width="50%" align="left">:&nbsp;<?php echo $singleshow['delivery'] ?></td></tr>
<tr><td width="50%" class="paddingLeft"align="left"> Trip Sheet.No</td><td width="50%" align="left">:&nbsp;<?php echo $tripno; ?></td></tr>
<tr><td width="50%" class="paddingLeft"align="left">Delivery Place</td><td width="50%" align="left">:&nbsp;YOGA S&S</td></tr>
<tr><td width="50%" class="paddingLeft"align="left">Material</td><td width="50%" align="left">:&nbsp;<?php echo $proshow['productname'] ?></td></tr>
<tr><td width="50%" class="paddingLeft"align="left">Quantity</td><td width="50%" align="left">:&nbsp;<?php echo $singleshow['netqty'] ?></td></tr>
</tr>

</table>
<table width="100%" class="borderLeft borderRight borderTop borderBottom">
<tr>
  <td width="50%" align='left' style="padding-top:100px">------------------------------------------<td>
<td width="50%" align='right' style="padding-top:100px" >-----------------------------------------<td>
</tr>
<tr>
  <td width="50%" align='left'>Customer Signature<td>
<td width="50%" align='right' >Authorized&nbsp;Signature<td>
</tr>
  </table>

  <?php
}}}}}
  ?>
</table>

</body>
</html>