<!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>Shipment Details</title>

        <style>
            table
            {
                border-collapse:collapse;
            }
            table, td, th
            {
                
                font-family:Arial, Helvetica, sans-serif;
                padding:5px;
            }
            th
            {
                font-weight:bold;
                font-size:13px;

            }
            td
            {
                font-size:12px;

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

    <body> 

        <?php
        require_once("config.inc.php");
        require_once("DBConnector.php");
        $db = new DBConnector();









        $sql_head = "select * from invpara";
        $result_head = $db->RunQuery($sql_head);
        $row_head = mysql_fetch_array($result_head);

        echo "<center><span class=\"style1\">" . $row_head["COMPANY"] . "</span></center><br>";

        $heading = "<center>Shipment Details From  " . $_GET["DT1"] . " To ".  $_GET["DT2"]  . " <br><br>";
        echo $heading;


        $sql = "SELECT LCNO,SDATE,BRAND,BRAND_NAME,REFNO from view_sh_de1 where SDATE>='" . $_GET["DT1"] . "' AND SDATE<='" . $_GET["DT2"] . "'   AND cancel=0  ";
        if ($_GET["cmbcat"] != "All") {
            $sql .=" and cat1 ='" . $_GET["cmbcat"] . "'";
        }
        if ($_GET["cmbbrand"] != "All") {
            $sql .=" and BRAND_NAME ='" . $_GET["cmbbrand"] . "'";
        }
        $sql .= " and type='Import'";

        $sql .="  group by LCNO,SDATE,BRAND,BRAND_NAME,REFNO order by refno ";
        $result = $db->RunQuery($sql);

       
        echo "<table border='1' ><tr> <td><b>LC NO</td> <td><b>DATE</td> <td><b>BRAND</td><td><b>STK NO</td><td><b>DESCRIPTION</td><td><b>QTY</td><td><b>COST</td><td><b>SELLING</td></</</tr>";

        while ($row = mysql_fetch_array($result)) {
            $sql_02 = "SELECT * from view_sh_de1 where REFNO = '" . $row['REFNO'] . "'";

            echo "<tr> <td>" . $row['LCNO'] . "</td> <td>" . $row['SDATE'] . "</td> <td>" . $row['BRAND_NAME'] . "</td>  <td colspan='5'>" . $row['REFNO'] . "</td>    </tr>";

            $result1 = $db->RunQuery($sql_02);


$mtot=0;
$mcost=0;
$mselig=0;

            while ($row1 = mysql_fetch_array($result1)) {
                $sql_head = "select * from s_purtrn where REFNO= '" . $row1['REFNO'] . "' and STK_NO= '" . $row1['STK_NO'] . "'";  
        $result_head = $db->RunQuery($sql_head);
        $row_head = mysql_fetch_array($result_head);
        
                echo "<tr> <td colspan='3'></td>            "
                
                . "<td>" . $row1['STK_NO'] . "</td>"
                . "<td>" . $row1['DESCRIPT'] . "</td>"
                . "<td align = 'right'>" . $row1['REC_QTY'] . "</td>"
                . "<td align = 'right'>" . $row_head['COST'] . "</td>"
                . "<td align = 'right'>" . $row_head['SELLING'] . "</td>"
                . " </tr>";
                $mtot = $mtot +$row1['REC_QTY'] ;
                 $mcost = $mcost+$row_head['COST'] ;
                  $mselig = $mselig +$row_head['SELLING'] ;
            }
            echo "<tr> <td colspan='5'></td>            "
                
                 
                . "<td align = 'right'><b>" . $mtot . "</b></td>"
                 . "<td align = 'right'><b>" . $mcost . "</b></td>"
                  . "<td align = 'right'><b>" . $mselig . "</b></td>"
                . " </tr>";
        }

        
                
        
        echo "</table><br>";


        $sql = "select sum(rec_qty) as qty from view_sh_de1 where SDATE>='" . $_GET["DT1"] . "' AND SDATE<='" . $_GET["DT2"] . "' and type='Import' and ttype='PCR' and cancel='0'";
        if ($_GET["cmbbrand"] != "All") {
            $sql .=" and BRAND_NAME ='" . $_GET["cmbbrand"] . "'";
        }
        $result1 = $db->RunQuery($sql);
        $row1 = mysql_fetch_array($result1);
        $pcr = $row1['qty'];

        $sql = "select sum(rec_qty) as qty from view_sh_de1 where SDATE>='" . $_GET["DT1"] . "' AND SDATE<='" . $_GET["DT2"] . "' and type='Import' and ttype='LTR' and cancel='0'";
        if ($_GET["cmbbrand"] != "All") {
            $sql .=" and BRAND_NAME ='" . $_GET["cmbbrand"] . "'";
        }
        $result1 = $db->RunQuery($sql);
        $row1 = mysql_fetch_array($result1);
        $LTR = $row1['qty'];

        $sql = "select sum(rec_qty) as qty from view_sh_de1 where SDATE>='" . $_GET["DT1"] . "' AND SDATE<='" . $_GET["DT2"] . "' and type='Import' and ttype='OTR' and cancel='0'";
        if ($_GET["cmbbrand"] != "All") {
            $sql .=" and BRAND_NAME ='" . $_GET["cmbbrand"] . "'";
        }
        $result1 = $db->RunQuery($sql);
        $row1 = mysql_fetch_array($result1);
        $OTR = $row1['qty'];

        $sql = "select sum(rec_qty) as qty from view_sh_de1 where SDATE>='" . $_GET["DT1"] . "' AND SDATE<='" . $_GET["DT2"] . "' and type='Import' and ttype='TBR' and cancel='0'";
        if ($_GET["cmbbrand"] != "All") {
            $sql .=" and BRAND_NAME ='" . $_GET["cmbbrand"] . "'";
        }
        $result1 = $db->RunQuery($sql);
        $row1 = mysql_fetch_array($result1);
        $TBR = $row1['qty'];

        $sql = "select sum(rec_qty) as qty from view_sh_de1 where SDATE>='" . $_GET["DT1"] . "' AND SDATE<='" . $_GET["DT2"] . "' and type='Import' and ttype='BIAS TYRES' and cancel='0'";
        if ($_GET["cmbbrand"] != "All") {
            $sql .=" and BRAND_NAME ='" . $_GET["cmbbrand"] . "'";
        }
        $result1 = $db->RunQuery($sql);
        $row1 = mysql_fetch_array($result1);
        $bst = $row1['qty'];

        $sql = "select sum(rec_qty) as qty from view_sh_de1 where SDATE>='" . $_GET["DT1"] . "' AND SDATE<='" . $_GET["DT2"] . "' and type='Import' and ttype='T/W TYRES' and cancel='0'";
        if ($_GET["cmbbrand"] != "All") {
            $sql .=" and BRAND_NAME ='" . $_GET["cmbbrand"] . "'";
        }
        $result1 = $db->RunQuery($sql);
        $row1 = mysql_fetch_array($result1);
        $twt = $row1['qty'];

        $sql = "select sum(rec_qty) as qty from view_sh_de1 where SDATE>='" . $_GET["DT1"] . "' AND SDATE<='" . $_GET["DT2"] . "' and type='Import' and cat1='TYRE' and cancel='0'";
        if ($_GET["cmbbrand"] != "All") {
            $sql .=" and BRAND_NAME ='" . $_GET["cmbbrand"] . "'";
        }
        $result1 = $db->RunQuery($sql);
        $row1 = mysql_fetch_array($result1);
        $tyres = $row1['qty'];

        $sql = "select sum(rec_qty) as qty from view_sh_de1 where SDATE>='" . $_GET["DT1"] . "' AND SDATE<='" . $_GET["DT2"] . "' and type='Import' and cat1='BATTERY' and cancel='0'";
        if ($_GET["cmbbrand"] != "All") {
            $sql .=" and BRAND_NAME ='" . $_GET["cmbbrand"] . "'";
        }
        $result1 = $db->RunQuery($sql);
        $row1 = mysql_fetch_array($result1);
        $batt = $row1['qty'];


        $sql = "select sum(rec_qty) as qty from view_sh_de where SDATE>='" . $_GET["DT1"] . "' AND SDATE<='" . $_GET["DT2"] . "' and type='Import' and cat1='ALLOY WHEEL' and cancel='0'";
        if ($_GET["cmbbrand"] != "All") {
            $sql .=" and brand ='" . $_GET["cmbbrand"] . "'";
        }
        $result1 = $db->RunQuery($sql);
        $row1 = mysql_fetch_array($result1);
        $alwh = $row1['qty'];

        $sql = "select sum(rec_qty) as qty from view_sh_de1 where SDATE>='" . $_GET["DT1"] . "' AND SDATE<='" . $_GET["DT2"] . "' and type='Import' and cat1='TUBE' and cancel='0'";
        if ($_GET["cmbbrand"] != "All") {
            $sql .=" and BRAND_NAME ='" . $_GET["cmbbrand"] . "'";
        }
        $result1 = $db->RunQuery($sql);
        $row1 = mysql_fetch_array($result1);
        $tube = $row1['qty'];


        echo "<table border='1' width = '300'><tr><td>PCR</td><td  align = 'right'>" . $pcr . "</td></tr>";
        echo "<tr><td>LTR</td><td  align = 'right'>" . $LTR . "</td></tr>";
        echo "<tr><td>OTR</td><td align = 'right'>" . $OTR . "</td></tr>";
        echo "<tr><td>TBR</td><td  align = 'right'>" . $TBR . "</td></tr>";
        echo "<tr><td>BIAS TYRES</td><td  align = 'right'>" . $bst . "</td></tr>";
        echo "<tr><td>T/W TYRES</td><td  align = 'right'>" . $twt . "</td></tr>";
        echo "<tr><td>TOTAL TYRES</td><td  align = 'right'>" . $tyres . "</td></tr>";
        echo "<tr><td>TOTAL BATTERIES</td><td  align = 'right'>" . $batt . "</td></tr>";
        echo "<tr><td>TOTAL ALLOY WHEELS</td><td  align = 'right'>" . $alwh . "</td></tr>";
        echo "<tr><td>TOTAL TUBES</td><td  align = 'right'>" . $tube . "</td></tr></table>";


        echo"<br><br><br><table width = '500' > <tr><td>Signature </td> <td>..............................................</td>          <td colspan = '4'>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp </td>         </tr>      "
        . "<tr><td>Working Director </td> <td>..............................................</td>       <td colspan = '4'>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp </td>              </tr> "
        . "<tr><td>Managing Director </td> <td>..............................................</td>     <td colspan = '4'>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp </td>                </tr>  </table>"
        ?>



    </body>
</html>
