<?php session_start();
if(!isset($_SESSION["UserName"])){
    echo "Invalid Login";
    exit();
}
date_default_timezone_set('Asia/Colombo');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <title>Print Invoice</title>
    <style type="text/css">
        <!--
        .style2 {
            font-family: Arial, Helvetica, sans-serif;
            font-size: 14px;
            font-weight: bold;
        }
        .style4 {
            font-size: 14px;
            font-weight: bold;
        }
        .style5 {
            font-size: 18px;
            font-weight: bold;
        }
        .style6 {
            font-size: 24px;
            font-weight: bold;
        }
        .style7 {font-size: 24px}

        .style8 {
            font-size: 18px;
            font-weight: bold;
        }
        .style9 {
            font-size: 20px;
            font-weight: bold;
        }

        .style10 {
            font-size: 18px;
            font-weight: bold;
        }
        -->

    </style>
</head>

<body><center>
    <?php 
    require_once ("connection_sql.php");
     
     
    $sql_invpara="SELECT * from invpara where COMCODE='".$_SESSION['company']."'";
    $result_invpara = $conn->query($sql_invpara);
    $row_invpara = $result_invpara->fetch();  
    
    $sql="Select * from s_salma_dcl where REF_NO='".$_GET["invno"]."'";
    $result = $conn->query($sql);
    $row = $result->fetch();  
         
     
  
    
    $rtxtinvno= $row["invno"];
    $rtxtordno= $row["ORD_NO"]; 
     
    
    
    
    $rtxtrep = $row2["Name"];
    $rtxtSupCode= $row1["CODE"];
    $rtxtSupName=  $row["C_CODE"]." ".$row["CUS_NAME"];
    $txtadd1 = $row1["ADD1"];
        //$txtadd2 = $row1["ADD2"];
    $txtadd2 = $_GET["cus_address2"];
    $txtadd = $row1["ADD1"]."</br>".$row1["ADD2"];
    $rtxtdate=date("Y-m-d", strtotime($row["SDATE"]));
    $rtxttot = $row["GRAND_TOT"];
     
    
    
    $sql_para="Select * from invpara  where COMCODE='".$_SESSION['company']."'";
    $result_para = $conn->query($sql_para);
    $row_para = $result_para->fetch();   
    ?>
    
    <table width="1000"   border="0">
        <tr>
            <td  style="width: 500px">
                <p style="margin: 0px;color: #189ce7;font-size: 35px" ><i><b><?php echo $row_para["COMPANY"]; ?></b></i></p>
                <p style="margin: 0px;" ><i><b><?php echo $row_para["ADD1"].", ".$row_para["ADD2"].", " .$row_para["ADD3"] ?></b></i></p>
                <!--  <p style="margin: 0px;" ><i><b><?php echo $row_para["ADD1"].", ".$row_para["ADD2"].", " .$row_para["ADD3"]  ?></b></i></p>-->
                <p style="margin: 0px;" ><i><b>TEL : <?php echo $row_para["TELE"]; ?> </b></i></p>
                <p style="margin: 0px;" ><i><b>  E-mail : <?php echo $row_para["EMAIL"]; ?> </b></i></p>
                <p style="margin: 0px;" ><i><b>  Web : www.tyreworld.lk</b></i></p>
                <p style="margin: 0px;" ><i> <b>PV-118764</b></i></p>
                <br>
                <p style="margin: 0px;font-size:25px" ><i><b>Dag Tyre Acceptance Form</i></p> 

                    <img style="margin-left: 700px; width: 300px; margin-top:  -198px;" src="../images/tyreworld.PNG"/>
                </td> 
            </tr> 
        </table>
<table width="1000"  border="0" >
           
        <tr>
            <td height="44" colspan="3" align="right"><span class="style6"><u> </u></span></td>
            <td width="55" height="44" align="center">&nbsp;</td>
            <td width="171" align="left">Sales Ex : <?php echo $row_salrep["Name"]; ?></td>
            <td width="80" align="right">Entered By: </td>
            <td width="186"><?php echo $row["use_name"]; ?></td>
        </tr>
        <tr>
            <td height="50" colspan="3" valign="top"><table border="1" bordercolor="#000000" cellpadding="0" cellspacing="0"><tr><td width="428"><table width="500" border="0" >
                <tr>
                  <td width="91"><span class="style4">CUSTOMER</span></td>
                  <td width="8"><strong>:</strong></td>
                  <td width="443"><span class="style5"><?php  echo $rtxtSupName;  ?></span></td>
              </tr>
               
               
        </table></td></tr></table></td>
        <td colspan="4" valign="top"><table border="1" bordercolor="#000000" cellpadding="0" cellspacing="0"><tr><td><table width="480" border="0">
          <tr>
            <td width="108"><span class="style4">Dag. NO</span></td>
            <td width="9">:</td>
            <td width="146"><span class="style9"><?php echo $row["REF_NO"]; ?></span></td>
            <td width="82"><span class="style4">Date</span></td>
            <td width="12">:</td>
            <td width="201"><?php echo $row["SDATE"]; ?></td>
        </tr>
        
        
        
    </table></td></tr></table>
    <span class="style2">    </span></td>
</tr>
</table>
<table width="1000" height="21" border="0" cellspacing="0">
   
    <tr>
        <td width="115" align="left"><table border="1" width="185" cellspacing="0"><tr><td><span class="style4"><u>ITEM NO.</u></span></td></tr></table></td>
        <td width="440" align="left"><table border="1"  width="440" cellspacing="0"><tr><td><span class="style4"><u>DESCRIPTION</u></span></td></tr></table></td>
        <td width="90" align="left"><table border="1"  width="110" cellspacing="0"><tr><td><span class="style4"><u>BRAND</u></span></td></tr></table></td>
        <td width="90" align="left"><table border="1"  width="250" cellspacing="0"><tr><td><span class="style4"><u>SERIAL NO</u></span></td></tr></table></td>  
    </tr>
    <?php 
    $i=1;
    $totsuntot=0;
    
    $sql1="Select * from s_invo_dcl where REF_NO='".$_GET["invno"]."'";
    foreach ($conn->query($sql1) as $row1) { 
      
            $PRICE=$row1["dcharge"]+$row1["ccharge"];
        
         
        echo "<tr><td><span width=100  class=\"style10\">".$row1["STK_NO"]."</span></td>
        <td><span width=500  class=\"style10\">".$row1["DESCRIPT"]."</span></td>
        <td><span width=500  class=\"style10\">".$row1["BRAND"]."</span></td>
        <td><span width=500  class=\"style10\">".$row1["srlNo"]."</span></td>
         ";
         
            //}
        echo "</tr>"; 
        $i=$i+1;
    }   
    
    
 
    while ($i<12){
        echo "<tr><td>&nbsp;</td>
        <td>&nbsp;</td> 
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td></tr>";
        $i=$i+1;
    }
    ?>
    
    
</table>
<table width="1000" border="0">
     
     
    <tr>
        <td>__________</td>
        <td width="98">&nbsp;</td>
        <td width="96">____________</td>
        <td width="104">&nbsp;</td>
        <td>____________</td>
        <td></td>
        <td align="right">&nbsp;</td>
        <td align="right"><b>
          <span class="style7">      </span></b>
          <table width="250" border="0">
            <tr>
              <td width="175" align="right"><b><span class="style7">
                <?php 
                if ($rtxttot>0){  
                      echo "Total : ";  echo number_format($rtxttot, 2, ".", ","); 
                   
                } 
                ?>
            </span></b></td>
            <td width="62">&nbsp;</td>
        </tr>
        
    </table>
    </td>
    </tr>
<tr>
    <td>Prepared By</td>
    <td>&nbsp;</td>
    <td>Customer</td>
    <td>&nbsp;</td>
    <td>Deliverd By</td>
    <td></td>
    <td align="right">Printed By:<?php echo $_SESSION["CURRENT_USER"]; ?> </td>
    <td align="right"></td>
</tr>
 
 
 
 
</table>

</body>
</html>
