<?php session_start();
?>
<!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>Print Purchase Order</title>
        <style type="text/css">
            <!--
            .companyname {
                color: #0000FF;
                font-weight: bold;
                font-size: 24px; 

            }

            .com_address {
                color: #000000;
                font-weight: bold;
                font-size: 18px;
                text-align: left;
            }

            .heading {
                color: #000000;
                font-weight: bold;
                font-size: 20px;
                text-align: left;
            }
            -->
        </style>
    </head>

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

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


            <table width="922" height="428" border="0">
                <?php
                //echo $_GET["invno"];

                $sql = "Select * from s_ordmas where REFNO='" . $_GET["invno"] . "'";
                $result = $db->RunQuery($sql);
                $row = mysqli_fetch_array($result);

                $sql1 = "Select * from vendor where CODE='" . $row["SUP_CODE"] . "'";
                $result1 = $db->RunQuery($sql1);
                $row1 = mysqli_fetch_array($result1);

                $sql2 = "Select * from s_ordtrn where REFNO='" . $_GET["invno"] . "'";
                $result2 = $db->RunQuery($sql2);
                ?>

                <tr>
                    <th colspan="4" scope="col" class="heading" style="color: blue"><?php echo $row_head["COMPANY"]; ?></th>
                </tr>

                <tr>
                    <th colspan="4" scope="col" class="heading" style="text-align: left ">Purchase Order</th>
                </tr>




                <tr>
                    <th colspan="4" scope="col">
                        <table cellpadding="0" cellspacing="0" >                                   
                            <tr  style="text-align: left;">
                                <td style="width: 500px">
                                    <p style="margin: 0px;" ><?php echo $row_head["ADD1"]; ?></p> 
                                    <p style="margin: 0px;" ><?php echo $row_head["ADD3"]; ?></p> 
                                    <p style="margin: 0px;" ><?php echo $row_head["TELE"]; ?></p> 
                                    <p style="margin: 0px;" ><?php echo $row_head["FAX"]; ?></p> 
                                </td>

                                <td>
                                    <img style="margin-left: 350px;width: 300px;" src="images/tyres.png"/>
                                </td>
                            </tr>


                        </table>

                        <table width="1000" cellpadding="0" cellspacing="0" border="0"><tr><td>
                                    <table border="0">
                                        <tr>
                                            <td style="padding: 0px;">
                                                <div style="width: 492px;background-color: white;height: 100px;border-style: solid;text-align: left;">
                                                    <div style="width: 492px;background-color: #d4d7db;height: 25px;">


                                                    </div>
                                                    <p style="margin-left: 20px;">fihsduogh : <?php echo $row[0]; ?></p>
                                                    <p style="margin-left: 20px;">fihsduogh : <?php echo $row[1]; ?></p>



                                                </div>
                                                <div style="width: 492px;background-color: white;height: 100px;border-style: solid;margin-top: 4px;text-align: left;">
                                                    <div style="width: 492px;background-color: #d4d7db;height: 25px;">

                                                    </div>
                                                    <p style="margin-left: 20px;">fihsduogh : <?php echo $row[3]; ?></p>
                                                    <p style="margin-left: 20px;">fihsduogh : <?php echo $row[8]; ?></p>


                                                </div>
                                            </td>
                                            <td>
                                                <div style="width: 492px;background-color: white;height: 210px;border-style: solid;text-align: left;">
                                                    <div style="width: 492px;background-color: #d4d7db;height: 25px;">

                                                    </div>

                                                    <p style="margin-left: 20px;">fihsduogh : <?php echo $row[4]; ?></p>
                                                    <p style="margin-left: 20px;">fihsduogh : <?php echo $row[5]; ?></p>
                                                    <p style="margin-left: 20px;">fihsduogh : <?php echo $row[7]; ?></p>
                                                

                                                </div>
                                            </td>

                                        </tr>

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

                    </th>
                </tr>






            </table>

            <table style="" width="1000" border="1" cellpadding="0" cellspacing="0">
                <tr>
                    <th width="100" height="22" scope="col">Item Code</th>
                    <th width="600" scope="col">Item Description</th>
                    <th width="150" scope="col">Part No</th>
                    <th width="150" scope="col">Qty</th>
                </tr>
                <?php
                $count = 0;
                $ORD_QTY = 0;

                while ($row2 = mysqli_fetch_array($result2)) {

                    echo "<tr style='height: 30px;'>
        <td align=center>" . $row2["STK_NO"] . "</td>
        <td>" . $row2["DESCRIPT"] . "</td>
        <td>" . $row2["partno"] . "</td>
        <td align=right style='height: 30px;'>" . $row2["ORD_QTY"] . "</td>
      </tr>";
                    $ORD_QTY = $ORD_QTY + $row2["ORD_QTY"];
                    $count = $count + 1;
                }


                $count = 14 - $count;

                $count = $count * 30;
                ?>





            </table>
            <table style="height: <?php echo $count; ?>px" width="1000" border="1" cellpadding="0" cellspacing="0"></table>


            <table style="margin-top: -1px;"  width="1000" border="1" cellpadding="0" cellspacing="0">
                <tr>
                    <th width="100"  height="22" scope="col"></th>
                    <th width="600" scope="col"></th>
                    <th width="150" scope="col">Total Qty</th>
                    <th width="150" align="right" scope="col"><?php echo $ORD_QTY; ?>.00</th>
                </tr>
                <tr style="height: 100px;">
                    
                </tr>




            </table>
            <p>Tharanga</p>
            <p>Tharanga De Silva</p>
            <p>Tharanga De Silva</p>


    </body>
</html>
