
<!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 ("connection_sql.php");

$sql = "update s_salma set pirnt_serial='1' where REF_NO='" . $_GET["invno"] . "'";
$res_inv = $conn->query($sql);


$sql = "Select * from s_salma where REF_NO='" . $_GET["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_la = "Select * from s_labour where CODE='" . $row["labour"] . "'";
$result_la = $conn->query($sql_la);
$row_la = $result_la->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 No  " . $row["vat_no"];
                $txtcomvat = "VAT Reg. " . $row_para["VAT"];
                $RTXTVAT = "VAT " . $row["GST"] . "%  ";
                $RTXVATAMU = $row["BTT"];
                $txttaxinv = "<b>TAX INVOICE</b>";
                $txtsubtot = $row["AMOUNT"];
                $txtsubtotdes = "Sub Total";
            }

            if ($row["SVAT"] != "0") {
                $txtcusvat = "Customer VAT No " . $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: 240px;margin-top:-20px;height:109px" src="img/logo.png"/> 
            </td>
            <td>
                <center><p style="margin: 0px;margin-left:-176px !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:-227px !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"){
                                            echo "CANCELED TAX INVOICE  ";
                                        }else{
                                             echo "TAX INVOICE  ";
                                        }
                                        // if ($row["TYPE"] == "CR") {
                                        //     echo "CREDIT";
                                        // }else{
                                        //     echo "CASH";
                                        // } 
                                        
                                        
                                       
                                    }else{
                                         if($row['CANCELL'] =="1"){
                                            echo "CANCELED INVOICE  ";
                                        }else{
                                              echo "INVOICE  ";
                                        }
                                      
                                        // if ($row["TYPE"] == "CR") {
                                        //     echo "CREDIT";
                                        // }else{
                                        //     echo "CASH";
                                        // }  
                                        
                                        
                                    }
                                    
                                    if($row['pirnt_serial'] =="0"){
                                            echo " - COPY";
                                    }
                        ?> 
                </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>  
         
    </table>
     
    <table width="1050px;" cellspacing="0" border="0"> 
        <tr>
            <td colspan="1" class="style2"><b>CUSTOMER NAME:</b> <?php echo $row['CUS_NAME']; ?></td>
            <td colspan="4"></td> 
            <td width="180"><span class="style2"><b>INVOICE 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>INVOICE NO:</b></span></td> 
            <td width="200" align="right" ><span class="style2"><?php echo $row['REF_NO'] ?></span></td> 
        </tr>
        <tr>
            <td width="500" height="21" align="left"><span class="style2">
                <?php  
                 echo $txtcusvat; ?> </span></td>
            <td colspan="4"></td> 
            <td width="180"><span class="style2"><b>JOB NO:</b></span></td> 
            <td width="30"align="right" class="style2"><span><?php echo $row["jobno"]; ?></span></td> 
           
        </tr>
        <tr>
            <td width="500" height="21" align="left"><span class="style2"><b>TEL </b>- <?php echo $row['TEL'] ?> </span></td>
            <td colspan="4"></td> 
            <td width="180"><span class="style2"><b>PO NO:</b></span></td> 
            <td width="30" align="right"><span class="style2"><?php echo $row["ORD_NO"]; ?></span></td> 
        </tr>
        
        <tr>
            <td colspan="4" class="style2"><b>VEHICLE NO:</b><?php echo $row["veheno"]; ?></td> 
            <td width="10" height="21" align="left"><span class="style2"> </span></td>
           <?php if($row["millage"] !=""){?>
            <td width="180"><span class="style2"><b>MILEAGE:</b></span></td> 
            <td width="30" align="right"><span class="style2"><?php echo $row["millage"] ?></span></td> 
            <?php }?>
            
        </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" style='visibility:hidden'><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="70" 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 s_invo where REF_NO='" . $_GET["invno"] . "' order by PRICE DESC"; 
        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"] / $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-$distot, 2, ".", ","); ?></td> 
                <td class="right" style='visibility:hidden'><?php echo number_format($row1["DIS_per"], 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=6;
}else{
     $t=7;
}
       
        while ($i <$t) {

         echo "<tr>

         <td>&nbsp;</td>
         <td></td>
         <td></td>
         <td></td> 
         <td></td> 
         </tr>";
         $i=$i+1;
     }
 
     ?>
      
    <!--<tr> -->
         
        <!--<td  class="right" colspan='4' style="font-size:19px;"><b>SUB TOTAL: </b></td> -->
        <!--<td class="right" style="font-size:19px;"><b>-->
        <?php 
        //  if ($rrtot > 0) {
            // echo number_format($rrtot, 2, ".", ",");
        // }
        // if ($sinvtot > 0) {
        //     echo number_format($sinvtot, 2, ".", ",");
        // }
        ?>
    <!--    </b></td>-->
    <!--</tr>-->
    <!--<tr> -->
          
        <!--<td  class="right" colspan='4' style="font-size:19px;"><b>TOTAL DISCOUNT: </b></td>  -->
        <!--<td class="right" style="font-size:19px;"><b>-->
        <?php 
        //  if ($disgtot > 0) {
            // echo number_format($disgtot, 2, ".", ",");
        // }
        
        ?>
    <!--    </b></td>-->
    <!--</tr>-->
    <?php
        if ($row["VAT"] =="1"){?>
            <tr> 
                  
                <td  class="right" colspan='5' 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='5' 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['note']; ?></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 received 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># Maximum credit period of<b> <?php echo $row["cre_pe"] ; ?> days</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><b>RECEIVED THE ABOVE ITEMS IN GOOD CONDITION</b></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="5" width="480" valign="top" align="center"><span style="font-size:16px;"><b></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> 
                                <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>ISSUED BY</b></span></td> 
                                <td><span><b>&nbsp;</b></span></td> 
                                <td align="center"><span style="font-size:16px;"><b>DELIVERED 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="5" width="480" valign="top" align="center"><span style="font-size:16px;"><b></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</b></span></td>   
                                
                            </tr>
                        </table>
                    </td>
                </tr>
             </table>
        </td> 
         
    </tr>  
</table>
<!-- ************************************************************************** -->
</body>

</html>
