
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<meta charset="utf-8">
  <!--<meta name="viewport" content="width=device-width, initial-scale=1">-->
  <!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">-->
  <!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>-->
  <!--<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>-->
    <title>Invoice Print</title>

    <style>
        .center {
            text-align: center;
        }
        .style2{
            font-size:18px;
        }
        .right {
            text-align: right;
        }

        .tb  {
           width: 1050px;
           border: 1px solid black;


           border-collapse: collapse;
       }
       .tb td  {

           border-top: 1px solid black;
           border-left: 1px solid black;


           border-collapse: collapse;
       }
       .tb th  {

           border-top: 1px solid black;
           border-left: 1px solid black;


           border-collapse: collapse;
       }

       .tb1 {

           border: 1px solid #000000;
       }

   </style>

</head>
<?php
session_start();
require_once ("new/connection_sql.php");

$sql = "Select * from s_cusordmas where REF_NO='" . $_GET["txt_invno"] . "'";
$result = $conn->query($sql);
$row = $result->fetch();

$sql1 = "Select * from vendor where CODE='" . $row["C_CODE"] . "'";
$result1 = $conn->query($sql1);
$row1 = $result1->fetch();

$sql2 = "Select * from s_salrep where REPCODE='" . $row["SAL_EX"] . "'";
$result2 = $conn->query($sql2);
$row2 = $result2->fetch();

	$sql_dep="select * from s_stomas where CODE='" .$row["DEPARTMENT"] . "'";
$result_dep =$conn->query($sql_dep);
$row_dep = $result_dep->fetch();
		

$sql3 = "Select sum(PRICE*QTY)  as pricetot from s_invo where REF_NO='" . $_GET["invno"] . "'";
$result3 = $conn->query($sql3);
$row3 = $result3->fetch();
 
$sinvtot=$row3["pricetot"];

$sql_invpara = "SELECT * from invpara where flag='".$_SESSION['company']."'";  
$result_invpara = $conn->query($sql_invpara);
$row_invpara = $result_invpara->fetch(); 
            
            $rtxtrep = $row2["Name"];
            $rtxtSupCode = $row1["CODE"];
            $rtxtSupName = $row1["NAME"];
            $txtadd = $row1["ADD1"] . " " . $row1["ADD2"];
            $rtxtdate = date("Y-m-d", strtotime($row["SDATE"]));
            $grandtot = $row["GRAND_TOT"];

            $VAT_per = $row["VAT"];
            $disamou=$row["DISCOU"];
            $txtsubtot = $row["AMOUNT"];

            if ($row["VAT"] == "1") { 
                $txtcusvat = "Customer VAT  " . $row["vat_no"];
                $txtcomvat = "VAT Reg. " . $row_para["VAT"];
                $RTXTVAT = "VAT " . $row["GST"] . "%  ";
                $RTXVATAMU = $row["VAT_VAL"];
                $txttaxinv = "<b>TAX INVOICE</b>";
                $txtsubtot = $row["AMOUNT"];
                $txtsubtotdes = "Sub Total";
            }else if ($row["SVAT"] != "0") { 
                $txtcusvat = "Customer VAT  " . $row["vat_no"];
                $txtcomvat = "VAT Reg. " . $row_invpara["VAT"];
                $RTXTVAT = "Suspended VAT " . $row["GST"] . "%  ";
                $RTXVATAMU = $row["BTT"];
                $txttaxinv = "<b>SUSPENDED TAX INVOICE</b>";
                $txtsubtot = $row["AMOUNT"];
                $txtsubtotdes = "Nett Total";

                $txtoursvat = "SVAT Reg. " . $row_invpara["svatno"];
                $txtcussavat = "Customer SVAT " . $row["s_vat_no"];
            }



?>
<body style="font-family:  "Times New Roman", Times, serif;">
 
    <table width="1050px;" cellspacing="0" border="0">
        <tr>
            <td style='width: 100px;'>
                 <img style="width: 225px;margin-top:-20px;" src="new/img/logo.jpg1"/> 
            </td>
            <td>
                <center><p style="margin: 0px;margin-left:-203px !important;font-size: 30px;" ><b><?php echo $row_invpara["COMPANY"] ; ?></b></p> </center>
                <center><p style="margin: 0px;margin-left:-242px !important;font-size: 18px;" ><b><?php echo $row_invpara["ADD1"].','.$row_invpara["ADD2"] ; ?></b></p></center>
                <center><p style="margin: 0px;margin-left:-238px !important;font-size: 18px;" ><b><?php echo "Telephone -".$row_invpara["TELE"] ; ?></b></p></center>
                <center><p style="margin: 0px;margin-left:-232px !important;font-size: 18px;" ><b><?php echo "E-mail -  ".$row_invpara["EMAIL"] ; ?></b></p></center>
                <center><p style="margin: 0px;margin-left:-150px !important;font-size: 18px;" ><b><?php if($row["VAT"]=="1"){ 
               echo "VAT Registration No. - " . $row_invpara["VAT"];
                  }?></b></i></p></center>
                <br>
            </td> 
        </tr>
    </table> 
      
    <table width="1050px;" cellspacing="0" border="0">
        <tr>
            <td> 
                 <!--<img style="  width: 245px;margin-top:-20px;" src="img/lassa.jpg"/> -->
            </td>
            <td align="right" style=" margin-top:-20px;">
               
                <?php
                 
                 if($row['CANCELL'] =="1"){?>
                 <center><p style="margin: 0px;font-size:24px;color:red" ></p></center>
              <?php  }else{?>
                    <center><p style="margin: 0px;font-size:24px;" >
                <?php   }?>
                
                    <b><u>
                        <?php 
                                    if($row["VAT"]=="1"){
                                        if($row['CANCELL'] =="1"){
                                             if($row['TYPE1'] =="Proforma Invoice"){
                                                  echo "CANCELED TAX INVOICE";
                                             }else{
                                                   echo "CANCELED TAX INVOICE";
                                             }
                                             
                                           
                                        }else{
                                            if($row['TYPE1'] =="Proforma Invoice"){
                                                   echo "PROFORMA TAX INVOICE";
                                             }else{
                                                    echo "INVOICE";
                                             }
                                           
                                        }
                                       
                                    }else{
                                         if($row['CANCELL'] =="1"){
                                             if($row['TYPE1'] =="Proforma Invoice"){
                                                  echo "CANCELED PROFORMA  INVOICE - ";
                                             }else{
                                                  echo "CANCELED INVOICE - ";
                                             }
                                             
                                           
                                        }else{
                                             if($row['TYPE1'] =="Proforma Invoice"){
                                                 echo "PROFORMA  INVOICE - ";
                                             }else{
                                                 echo "INVOICE - ";
                                             }
                                              
                                        }
                                      
                                        if ($row["TYPE"] == "CR") {
                                            echo "CREDIT";
                                        }else{
                                            echo "CASH";
                                        }  
                                    }
                        ?> 
                </u></b></p></center>
            </td>
            <td align="right">
                 <!--<img style="  width: 245px;margin-top:-20px;" src="img/radar.png"/> -->
            </td>
            
        </tr>
        <tr>
           <td>&nbsp;</td>
        </tr>  
        <tr>
           <td>&nbsp;</td>
        </tr>  
    </table>
     
    <table width="1050px;" cellspacing="0" border="0"> 
        <tr>
            <td colspan="1" class="style2"><b>CUSTOMER:</b> <?php echo $row['CUS_NAME']; ?></td>
            <td colspan="4"></td> 
            <td width="180"><span class="style2"><b>DATE:</b></span></td>  
            <td width="30" align="right" class="style2"><?php echo $row['SDATE']; ?></td>
        </tr>
        <tr> 
            <td colspan="4" ><span class="style2" ><?php echo  strtoupper($row['C_ADD1'])?></span></td>
            <td width="10" height="21" align="left"><span class="style2"> </span></td>
            <td width="20"><span class="style2"><b>REFNO:</b></span></td> 
            <td width="200" align="right" ><span class="style2"><?php 
             if($row['TYPE1'] =="Proforma Invoice"){
                echo  $row['REF_NO'];
             }else{
                 echo  $row['DUPLI_NO'];
             }
             ?></span></td> 
        </tr>
         
        <tr>
            <td width="500" height="21" align="left"><span class="style2"><b>TEL </b>- <?php echo $row1['TELE1'] ?> </span></td>
            <td colspan="4"></td> 
            <td width="180"><span class="style2"><b>DEPARTMENT:</b></span></td> 
            <td width="30" align="right"><span class="style2"><?php echo $row_dep["DESCRIPTION"]; ?></span></td> 
        </tr>
        
        <tr>
            <td colspan="4" class="style2"><?php if($row["VAT"]=="1"){?>VAT REG NO. -
                           <?php echo $row1["vatno"];
                            }?></td> 
            <td width="10" height="21" align="left"><span class="style2"> </span></td>
            <td width="180"><span class="style2"><b>SALES.EX :</b></span></td> 
            <td width="30"align="right" class="style2"><span><?php echo $rtxtrep; ?></span></td> 
        </tr>
       
       
         <tr>
            <td width="10" height="21" align="left"><span class="style2"> </span></td>
            <td colspan="4"></td> 
            <td><span>&nbsp;</span></td> 
        </tr> 
    </table>
     
    <table   width="1050px;" >
        <tr style="font-size:18px;">
             <th width="30px;"></th>
             <td width="850"><b><u>ITEM DESCRIPTION</u></b></td>
             <td width="80" align="right"><b><u>QTY<u></b></td>
             <td width="135" align="right"><b><u>UNIT PRICE<u></b></td>
             <!--<td width="70" align="right"><b><u>DIS(%)<u></b></td>-->
             <!--<td width="80" align="right"><b><u>Q DIS(%)<u></b></td>-->
             <td width="145" align="right"><b><u>UNIT TOTAL<u></b></td>
        </tr>
        <tr style="font-size:18px;">
             <th width="30px;"></th>
             <td width="850"><b>&nbsp;</b></td>
             <td width="80" align="right"><b>&nbsp;</b></td>
             <td width="135" align="right"><b>&nbsp;</b></td>
             <td width="145" align="right"><b>&nbsp;</b></td>
        </tr>
        <?php
        $i=1;  
        $part="";
        $qty=0;
        $TOTPRICE=0;
        $unittot=0;
        $distot=0;
        $disgtot=0;
        $unitgtot=0;
        $rr=0;
        $rrtot=0; 
        $sql1="SELECT * from print_repord where REF_NO= '" . trim($_GET["txt_invno"]) . "'  order by id";
        foreach ($conn->query($sql1) as $row1) {
            $sql_smas = "SELECT * from s_mas where STK_NO='".$row1['STK_NO']."'";
            $result_smas = $conn->query($sql_smas);
            $row_smas= $result_smas->fetch(); 
            
            if (($row["VAT"] == "1") or ($row["VAT"] == "2")) {
                $vatr = 100 + $row["GST"];
                // $PRICE = $row1["PRICE"] / $vatr * 100;
                $PRICE = $row1["PRICE"] ;
            } else {
                $PRICE = $row1["PRICE"];
            }
            
            $unittot=$PRICE*$row1['QTY']-($PRICE*$row1['QTY']*$row1["DIS_per"]/100);
            $distot=$PRICE*$row1['QTY']*$row1["DIS_per"]/100;
            $rr=$PRICE*$row1['QTY'];
            ?>
            <tr style="font-size:19px;">  
                <td class="center"><?php echo $i.'.' ?></td>  
                <td class="left" ><?php echo $row1['DESCRIPT']; ?> </td>
                <td class="right"><?php echo number_format($row1['QTY'], 2, ".", ","); ?></td>
                <td class="right"><?php echo number_format($PRICE, 2, ".", ","); ?></td> 
                <!--<td class="right"><?php echo number_format($row1["Print_dis1"], 2, ".", ","); ?></td> -->
                <!--<td class="right"><?php echo number_format($row1["Print_dis2"], 2, ".", ","); ?></td> -->
                <td class="right"><?php echo number_format($unittot, 2, ".", ","); ?></td> 
            </tr>
            <?php
             $i=$i+1;  
             $TOTPRICE=$TOTPRICE+($PRICE*$row1['QTY']);
             $unitgtot=$unitgtot+$unittot;
             $disgtot=$disgtot+$distot;
             $rrtot=+$rrtot+$rr;
        }
        ?>

        <?php
if ($row["VAT"] == "1"){
     $t=15;
}else{
     $t=23;
}
       
        while ($i <$t) {

         echo "<tr>

         <td>&nbsp;</td>
         <td></td>
         <td></td>
         <td></td> 
         </tr>";
         $i=$i+1;
     }
 
     ?>
      
   
    <?php
        if ($row["VAT"] =="1"){?>
            <tr> 
                  
                <td  class="right" colspan='4' style="font-size:19px;"><b><?php echo  $RTXTVAT ?> :</b></td>  
                <td class="right" style="font-size:19px;"><b><?php
                                    if ($RTXVATAMU > 0) {
                                        echo number_format($RTXVATAMU, 2, ".", ",");
                                    }
                                    ?></b>
                 </td>
            </tr>
       <?php }?>
 
    <tr>

       
         
        <td  class="right" colspan='4' style="font-size:24px;"><b>GRAND TOTAL: </b></td>  
        <td class="right" style="font-size:28px;"><b><?php
                                        if ($grandtot > 0) {
                                            echo number_format($grandtot, 2, ".", ",");
                                        }
                                        ?></b></td>
    </tr>
    
</table>


</table> 
<table width="1050px;">
        <tr>
            <td colspan="12"  class="style2"><b>REMARK:</b> <?php echo $row['REMARK']; ?></td>   
        </tr> 
        <tr>
            <td colspan="12"  class="style2">&nbsp;</td>   
        </tr> 
        <tr>
            <td colspan="12"  class="style2">&nbsp;</td>   
        </tr> 
</table>         
<!--<div style='height:34px;'></div>-->
<table width="1050px;">
    <tr> 
        <td colspan="8"  style="font-size:17px;"><b><u>CUSTOMER AGREED TO THE FOLLOWING TERMS & CONDITIONS</u></b></td> 
    </tr> 
    
    <tr> 
        <td colspan="8" style="font-size:17px;"><p># If no written complaint recieved within three days from the date hereon, invoiced goods shall be presumed to have delivered correctly.</p></b></td> 
    </tr>
    <tr> 
        <td colspan="8" style="font-size:17px;"><p># All cheques made payable to <b><?php echo $row_invpara["COMPANY"] ; ?></b> and crossed <b>AC PAYEE Only</b>.</p></td>
    </tr> 
    <tr> 
        <td colspan="8" style="font-size:17px;"><p>#  <b><?php echo $row_invpara["COMPANY"] ; ?>&nbsp;</b>  reserves the right to take appropriate legal action to recover in full, if the invoice amount contained here in is not settled within the stipulated credit period.</p> </td>
    </tr>
</table>
<table width="1050px;">
    <tr>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td>&nbsp;&nbsp;&nbsp;</td>
    </tr>
    <tr>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td>&nbsp;&nbsp;&nbsp;</td>
    </tr>
    
</table>
<table cellpadding="0" cellspacing="0" border="0" width="1050px;">
    <tr> 
        <td>
            <table border="0" bordercolor="#000000" cellpadding="0" cellspacing="0">
                <tr>
                    <td>
                        <table border="0" >
                            <tr>
                                 
                                <td height="135" colspan='3' valign="top" align='right'><span style="font-size:16px;text-align:center"><b>OFFICE USE ONLY</b></span></td> 
                                 
                               
                                 
                            </tr> 
                            <tr>
                                <td><span><b>&nbsp;</b></span></td> 
                                <td align="center"><span><b>....................................................................</b></span></td> 
                                <td><span><b>&nbsp;</b></span></td> 
                                <td align="center"><span><b>...........................................................................</b></span></td>
                                <td><span><b>&nbsp;</b></span></td> 
                            </tr>
                            <tr>
                                <td><span><b>&nbsp;</b></span></td> 
                                <td align="center"><span style="font-size:16px;"><b>INVOICED BY</b></span></td> 
                                <td><span><b>&nbsp;</b></span></td> 
                                <td align="center"><span style="font-size:16px;"><b>AUTHORIZED BY</b></span></td> 
                                <td><span><b>&nbsp;</b></span></td> 
                                
                            </tr>
                        </table>
                    </td>
                </tr>
             </table>
        </td>
        <td>
            <table border="0" bordercolor="#000000" cellpadding="0" cellspacing="0">
                <tr>
                    <td>
                        <table border="0" >
                            <tr>
                                 <td><span><b>&nbsp;</b></span></td> 
                            </tr> 
                            
                        </table>
                    </td>
                </tr>
             </table>
        </td> 
         
        
        <td>
            <table border="0" bordercolor="#000000" cellpadding="0" cellspacing="0">
                <tr>
                    <td>
                        <table border="0" >
                            <tr > 
                                <td height="135" width="480" valign="top" align="center"><span style="font-size:16px;"><b>RECEIVED THE ABOVE ITEMS IN GOOD CONDITION</b></span></td> 
                                  
                            </tr> 
                            <tr>
                                <td align="center"><span><b>...................................................................................................</b></span></td>   
                            </tr>
                            <tr>
                                <td align="center"><span style="font-size:16px;"><b>CUSTOMER SIGNATURE & RUBBER STAMP</b></span></td>   
                                
                            </tr>
                        </table>
                    </td>
                </tr>
             </table>
        </td> 
         
    </tr>  
</table>
<!-- ************************************************************************** -->
</body>

</html>







 