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

session_start();
date_default_timezone_set('Asia/Colombo');
?>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">


    <title><?php echo $_GET['type']?> REPORT</title>

    <style>
        .center {
            text-align: center;
        }

        .right {
            text-align: right;
        }

        .tb  {
           width: 1200px;
           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;
       }
       .tb2  {
           
           border: 1px solid black;


           border-collapse: collapse;
       }
       .tb2 td  {

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

           border-collapse: collapse;
       }
       .tb2 th  {

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


           border-collapse: collapse;
       }

       .tb1 {

           border: 1px solid #000000;
       }
 

   </style>

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

 

$sql_invpara = "SELECT * from invpara";
$result_invpara = $conn->query($sql_invpara);
$row_invpara = $result_invpara->fetch(); 



?>
<body>
    <center>
    <table width="1200px;" cellspacing="0" border="0">

        <tr>
            <th class="center"  colspan=5 ><?php echo $row_invpara['COMPANY']; ?></th>
        </tr> 
        
        <tr> 
            <th class='center' colspan='5'> <?php echo $_GET['type']?> REPORT - (<?php echo date('Y-m-d H:i:s');?>)</th> 
        </tr>
         
        <tr> 
        <?php 
         if($_GET['brandname'] !=""){?>
            <th class='center' colspan='5'>Brand Wise - <?php echo $_GET['brandname']?>  </th> 
           <?php } ?>
        </tr> 
        <tr> 
        <?php 
         if($_GET['dep'] !=""){?>
            <th class='center' colspan='5'>Department Wise - (<?php echo $_GET['dep']?> ) </th> 
           <?php } ?>
        </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>
<!--==================================================================================-->
   
                <table class="tb" width="1200px;" >
                <tr >
        
                    <th width="30px;">NO</th> 
                    <th width="100px;">STK NO</th>
                    <th width="200px;">DESCRIPTION</th>
                    <th width="200px;">PART NO</th>
                    <th width="200px;">CATEGORY</th>
                    <th width="120px;">DEPARTMENT</th> 
                    <th width="100px;">QTY</th> 
                    <th width="100px;">COST</th>
                    <th width="100px;">SELLING</th>
                     <th width="200px;">STOCK VALUE</th>
                </tr>
                <?php
                $i=1;  
                $part="";
                $BAL=0;
                $sql1 = "Select * from viewsubmas where STK_NO <> ''";
                
                // if (isset($_GET['itemname'])) {
                //     if ($_GET['itemname'] != "") {
                //         $sql1 .= " and DESCRIPT like  '%$letters%'";
                //     }
                // }
                 
                
                
                if($_GET['dep'] !=""){
                     $sql1.=" and STO_CODE='".$_GET['dep']."'"; 
                }
                if($_GET['brandname'] !=""){
                     $sql1.=" and BRAND_NAME='".$_GET['brandname']."'"; 
                }
                if($_GET['cat'] !=""){
                     $sql1.=" and Cat1='".$_GET['cat']."'"; 
                }
                if($_GET['stk_no'] !=""){
                     $sql1.=" and STK_NO='".$_GET['stk_no']."'"; 
                } 
                if($_GET['check'] =="on"){
                     $sql1.=" and QTYINHAND >0"; 
                }
                
                
                
                
                $sql1.=" order by  BRAND_NAME ";
                
                foreach ($conn->query($sql1) as $row1) {
                     
                    ?>
                    <tr style="font-size:13px;">
         
        
                        
                        
                        <?php  
                        
                        if($part!=$row1['BRAND_NAME']){
                           
                            echo "<tr><td colspan='10'><b>  ". $row1['BRAND_NAME'] ."   </b></td></tr>";
                        } 
                        ?>
                        <td class="center"><?php echo $i ?></td>
                        <td class="left" ><?php echo $row1['STK_NO']; ?> </td>
                        <td class="left" ><?php echo $row1['DESCRIPT1']; ?> </td> 
                        <td class="left" ><?php echo $row1['PART_NO']; ?> </td> 
                        <td class="left" ><?php echo $row1['Cat1']; ?> </td> 
                         <td class="left" ><?php echo $row1['DESCRIPTION']; ?> </td> 
                        <td align="center"><?php echo number_format($row1['QTYINHAND'], 2, ".", ","); ?></td> 
                        <td align="right"><?php echo number_format($row1['COST'], 2, ".", ","); ?></td> 
                        <td align="right"><?php echo number_format($row1['SELLING'], 2, ".", ","); ?></td> 
                        <td align="right"><?php echo number_format($row1['COST']*$row1['QTYINHAND'], 2, ".", ","); ?></td> 
                    </tr>
                    <?php
                    $i=$i+1;
                     $part=$row1['BRAND_NAME']; 
                     $BAL=$BAL+$row1['QTYINHAND'];
                     $SELLING=$SELLING+$row1['SELLING'];
                     $TOTCOST=$TOTCOST+($row1['COST']*$row1['QTYINHAND']);
                }
                ?>
           
           
            <tr>
          <td  align="right" style='font-size:20px;' colspan='6'><b></b></td>
                 
                <td align="center" style='font-size:20px;'><b><?php 
                echo number_format($BAL, 2, ".", ",");
        
                ?><b/></td>
               <td align="right" style='font-size:20px;'><b> 
                <b/></td>
               <td align="right" style='font-size:20px;'><b> 
                <b/></td>
                <td align="right" style='font-size:20px;'><b><?php 
                echo number_format($TOTCOST, 2, ".", ",");
        
                ?><b/></td>
            </tr>
        </table>
    
 
    
    
    <!--===================================================================================-->
    
    
    
 
<!-- ************************************************************************** -->
</center>
</body>

</html>
