<?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 Material Requession</title>
        <style type="text/css">
            <!--


            .style5 {
                font-size: 12px
            }
            .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_matrequesionmas 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_materialreqtrn where REFNO='" . $_GET["invno"] . "'";
                $result2 = $db->RunQuery($sql2);

                $sql3 = "Select * from s_mas";
                $result3 = $db->RunQuery($sql3);
                $row3 = mysqli_fetch_array($result3);
                ?>

                <tr>
                    <td style="width: 500px">
                        <p style="margin: 0px;color: #189ce7;font-size: 35px" ><i><b><?php echo $row_head["COMPANY"]; ?></b></i></p>
                                 <p style="margin: 0px;" ><i><b><?php echo $row_head["ADD1"]; ?></b></i></p>
                                   <!--  <p style="margin: 0px;" ><i><b><?php echo "#30, Nagashandiya, GalleRoad, Kaluthara. Sri Lanka" ?></b></i></p>-->
                                 <p style="margin: 0px;" ><i><b>TEL : <?php echo $row_head["TELE"]; ?> E-mail : <?php echo $row_head["EMAIL"]; ?> Web : www.tyreworld.lk</b></i></p>
                                    <p style="margin: 0px;" ><i><b>Hot Line : <?php echo $row_head["FAX"]; ?> <br><b>PV-118764</b></i></p>
                                    <br>
                                    <p style="margin: 0px;" ><i><b>PURCHASE REQUESION</i></p>
                                    <p style="margin: 0px;" ><i><b><?php echo $row[20]; ?></i></p>

                                    <img style="margin-left: 700px;width: 300px;margin-top:  -155px;" src="images/tyreworld.PNG"/>
                                </td>


                </tr>
                <tr>
                    <th colspan="4" scope="col">
                        <table cellpadding="0" cellspacing="0" >
                            <tr  style="text-align: left;">
                                <td style="width: 500px">


                                 <td>

<!--                                    <p style="margin-left: 300px;margin-top: 0px;margin-bottom: 0px;padding-top: 0px;padding-bottom: 4px;">MATERIAL REQUESION</p>
                                    <p style="margin-left: 370px;margin-top: 0px;margin-bottom: 0px;padding-top: 0px;padding-bottom: 4px;">(<?php echo $row[20]; ?>)</p>-->
                                </td>


                                </td>

                            </tr>


                        </table>

                        <table width="1000" cellpadding="0" cellspacing="1" border="0" style="margin-top: 14px;"><tr><td>
                                    <table border="0">
                                        <tr>
                                            <td style="padding: 0px;">
                                                <div style="width: 525px;background-color: white;height: 100px;border-style: solid;text-align: left;">
                                                    <div style="width: 525px;background-color: #d4d7db;height: 25px;"><b>&nbsp;Request By</b> </div>
                                                     <p style="margin-left: 20px;margin-top: 10px;margin-bottom: 0px;padding-top: 0px;padding-bottom: 4px;">Name  : <?php echo $row['SUP_NAME']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp; <?php echo ''; ?></p>
                                                     <p style="margin-left: 20px;margin-top: 0px;margin-bottom: 0px;padding-top: 0px;padding-bottom: 4px;">Department  : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp; <?php echo ''; ?></p>



                                                </div>
                                                <div style="width: 525px;background-color: white;height: 101px;border-style: solid;margin-top: -5px;text-align: left;">
                                                    <div style="width: 525px;background-color: #d4d7db;height: 25px;"><b>&nbsp;Reason for Request</b>
                                                    </div>
                                                     <p style="margin-left: 20px;margin-top: 10px;margin-bottom: 0px;padding-top: 0px;padding-bottom: 4px;">Reason  : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp; <?php echo $row['reason']; ?></p>
                                                     <p style="margin-left: 20px;margin-top: 0px;margin-bottom: 0px;padding-top: 0px;padding-bottom: 4px;">Category  : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp; <?php $row['cat']; ?></p>



                                                </div>
                                            </td>
                                            <td >
                                                <div  style="width: 467px;background-color: white;height: 200px;border-style: solid;text-align: left;margin-left: -6px;">


                                                    <p style="margin-left: 20px;margin-top: 20px;margin-bottom: 0px;padding-top: 0px;padding-bottom: 4px;">PR No : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp; <?php echo $row['REQ_NO']; ?></p>
                                                    <p style="margin-left: 20px;margin-top: 0px;margin-bottom: 0px;padding-top: 0px;padding-bottom: 4px;">PR Date: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp; <?php echo  $row[1]; ?></p>

                                                    <p style="margin-left: 20px;margin-top: 0px;margin-bottom: 0px;padding-top: 0px;padding-bottom: 4px;">Purchasing Group :  &nbsp; <?php echo $row[22]; ?></p>


                                                </div>
                                            </td>

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

                    </th>
                </tr>






            </table>

            <table style="margin-top: -7px;" width="1000" cellpadding="0" border="1" cellspacing="0">
                <tr>
                    <th width="50" height="22" scope="col">S.R</th>
                    <th width="150" height="22" scope="col">PART NO</th>
                    <th width="600" scope="col">Description</th>
                    <th width="70" scope="col">Qty</th>
                    <th width="70" scope="col">UOM</th>
                    <th width="110" scope="col">Unit Price</th>
                    <th width="130" scope="col">Net Amount</th>
                </tr>
                <?php
                $count = 0;
                $ORD_QTY = 0;
 $tot_val = 0;
 $sr = 1;
 $showSR = "";
                            while ($row2 = mysqli_fetch_array($result2)) {

                                 if (strlen($sr) == 1) {


                        $showSR = "0".$sr;
                    }else{
                        $showSR = $sr;
                    }

   $sql3 = "Select * from s_mas where STK_NO ='"  .$row2["STK_NO"] ."'";
                $result3 = $db->RunQuery($sql3);
                $row3 = mysqli_fetch_array($result3);

                    $net = $row3["COST"]*$row2["ORD_QTY"];

//                    . number_format($sr) .
//                     if ($sr < 10) {
//                         echo     "0".$sr;
//
//                        } else {
//                            $sr;
//                            }
                    echo "<tr style='height: 30px;'>
                          <td align=center>" . $showSR . "</td>
                          <td align=center>" . $row3["PART_NO"] . "</td>
                            <td align=left>" . $row2["DESCRIPT"] . "</td>
                            <td align=center>" . $row2["ORD_QTY"] . "</td>
                             <td align=center>" . $row2["uom"] . "</td>

                             <td align=right>" . number_format($row3["COST"],2) . "</td>
                            <td align=right style='height: 30px;'>" . number_format($net,2) . "</td>
                            </tr>";

                             $tot_val = $tot_val + $net;
                    $ORD_QTY = $ORD_QTY + $row2["ORD_QTY"];
                    $count = $count + 1;


                ++$sr;

                            }



                $count = 15 - $count;

                $count = $count * 30;
                ?>





            </table>

            <table style="border-style: solid;height: <?php echo $count; ?>px;" width="1000" border="1" cellpadding="0" cellspacing="0">
                <tr >
                    <td >
                        <div style="margin-top:350px;">
                            <p style="margin-left:800px "><b>Total Value &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo number_format($tot_val,2); ?></b></p></div>
                    </td>
                </tr>




            </table>
             <br>
            <br>
            <br>
            <br>
            <br>
            <div style="width: 1000px;">
                <div style="width: 200px;float: left;">
                     <p>................................</p>
                     <p>Ordered by</p>
                </div>
                <div style="width: 593px;float: left;">
                    <p>................................</p>
                    <p>Prepared by</p>
                </div>
                <div style="width: 200px;float: left;">
                    <p>................................</p>
                    <p>Authorized by</p>
                </div>

            </div>

                                        </body>
                                        </html>
