<?php session_start();
?>
<?php 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>AUDIT LIST REPORT</title>
        
    <style>
        .center {
            text-align: center;
        }

        .right {
            text-align: right;
        }

        .tb  { 
           border: 1px solid black;


           border-collapse: collapse;
       }
       .tb td  {

           border-top: 1px solid black;
           border-left: 1px solid black;
        font-size:18px;

           border-collapse: collapse;
       }
       .tb th  {

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


           border-collapse: collapse;
       }

       .tb1 {

           border: 1px solid #000000;
       }

   </style>
        <style type="text/css">
            <!--
            .style1 {
                color: #0000FF;
                font-weight: bold;
                font-size: 24px;
            }
            -->
        </style>
    </head>

    <body>
        <!-- Progress bar holder -->
        <?php
          require_once("connection_sql.php");
        $sql_invpara = "SELECT * from invpara";
            $result_invpara = $conn->query($sql_invpara);
            $row_invpara = $result_invpara->fetch(); 
        ?>
<center>
 <table width="1000px;" cellspacing="0" border="0">

        <tr>
            <th class="center"  colspan=5 ><?php echo $row_invpara['COMPANY']?></th>
        </tr> 
        
         
        <tr> 
         
            <th class='center' colspan='5'>DATE  <?php echo $_GET['dtfrom']?> To  <?php echo $_GET['dtto']?> </th> 
           
        </tr>
         
         <tr>  
            <th class='center' colspan='5'>Company - <?php echo $_GET['company']?>  </th>  
        </tr>
         
         
        <tr>

            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td align="right">&nbsp;</td>
        </tr>
        
        <tr>

            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>

            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>

            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        
        <tr>

            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
       
    </table>
    </center>
        <?php
        
         

        $dt1 = $_GET['dtfrom'];
        $dt2 = $_GET['dtto'];
 
        echo "<center>
        <table class=\"table table-bordered\" border=\"1\" >";
        echo "<tr>";
        echo "<td><b>COMPANY</b></td>"; 
        echo "<td><b>REFNO</b></td>"; 
        echo "<td><b>CUSTOMER CODE</b></td>"; 
        echo "<td><b>CUSTOMER NAME</b></td>"; 
        echo "<td><b>AMOUNT</b></td>"; 


        echo "</tr>";

       
      
        
         echo "<tr>"; 
        $tot=0; 
        
        

        $sql = "Select  * from s_salma where  SDATE >='" . $dt1 . "' and SDATE <='" .$dt2 . "'   and OK='Y' AND TRN_TYPE='INV' "; 
        if($_GET['company'] !="ALL"){
             $sql.=" and company='".$_GET['company']."'"; 
        }
         
        $sql.=" order by SDATE";   
        $date="";
        foreach ($conn->query($sql) as $row) {
            
            if($date !=$row['SDATE']){
                   echo "<tr > ";   
                    echo "<td colspan='6'><b>" .  $row['SDATE'] . "</b></td>";  
                    echo "</tr>";
            }
          
            echo "<tr > ";
            echo "<td align='center'>" .  $row['company'] . "</td>";  
            echo "<td>" .  $row['REF_NO'] . "</td>"; 
            echo "<td>" .  $row['C_CODE'] . "</td>";  
            echo "<td>" .  $row['CUS_NAME'] . "</td>";    
            echo "<td align='right'>" .  number_format($row['GRAND_TOT'],2) . "</td>";  
            echo "</tr>";
            
            
                
                 
                 $tot+=$row['GRAND_TOT'];
              
            
       
               
           
             $date=$row['SDATE'] ;
            
        }

         echo "<tr style='font-size:18px;'>";
        echo "<td colspan='4'></td>";   
        echo "<td align='right'><b>" . number_format($tot,2). "</b></td>"; 
        echo "</tr>"; 
        // ============
        

        echo "</table>";
        ?>
    </body>
</html>
 