<?php
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');

$formname = 'Outward';
$maindb = 'outmain';
$trandb = 'outtran';
/*$accdb = 'actran';*/
$stkdb = 'transacn';
$file = 'outward.php';
$source = "OU";
/*$grid = 'salemain.php';*/

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);

$mht = 'height:20px;';
                                            
$admin = $_SESSION["admin_" . $dbname];
$vouchno = $_REQUEST["vouchno"];
$mainqry = mysqli_query($conn, "SELECT *, DATE_FORMAT(`vouchdt`, '%d-%m-%Y') AS vouchdt FROM `$maindb` WHERE vouchno='$vouchno'") or die(mysqli_error($conn));
$getmdata = mysqli_fetch_array($mainqry) or die(mysqli_error($conn));

$getengine = mysqli_query($conn, "SELECT `name` FROM `engine` WHERE code =$getmdata[engine]") or die(mysqli_error($conn));
$mengine = mysqli_fetch_array($getengine);

$getsite = mysqli_query($conn, "SELECT `name` FROM `site` WHERE code =$getmdata[site]") or die(mysqli_error($conn));
$msite = mysqli_fetch_array($getsite);

$getstaff = mysqli_query($conn, "SELECT `name` FROM `staff` WHERE code =$getmdata[staff]") or die(mysqli_error($conn));
$mstaff = mysqli_fetch_array($getstaff);
?>

<!DOCTYPE HTML>
<html lang="en-US">

    <head>
        <?php
        include("includes/files.php");
        ?>
    </head>

    <body id="main_container">
        <div class="row">
            <b style="font-size:18px;"><center>Outward Challan</center></b>
        </div>
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <table class="table table-bordered">
                        <tr>
<!--                            <td style="text-align: center;vertical-align: inherit;">
                                <img src="images/trdlogo3.png"/>
                            </td>-->
                            <td style="width:58%">
                                <table class="">
                                    <tr>
                                        <td><h5><b>MODERN HIRING SERVICE</b></h5></td>
                                    </tr>
                                    <tr>
                                    <td>BEST Quarters No.1, Reay Road, Mumbai-400010</td>
                                    </tr>
                                    <tr>
                                    <td>Tel: 022-23719929 / 23705678 Fax : 022-23711453</td>
                                    </tr>
                                    <tr>
                                    <td>E-mail: modern@born8.vsnl.net.in, modern.hiring@yahoo.com</td>
                                    </tr>
                                </table>                                
                            </td>
                            <td style="padding: 0px;">
                                <table class="table table-bordered" style="margin-bottom: 0px;">
                                    <tr>
                                        <td style="width:30%">Engine:</td>
                                        <td> <?php echo $mengine["name"] ?></td>
                                    </tr>
                                    <tr>
                                        <td style="width:30%">Site:</td>
                                        <td> <?php echo $msite["name"] ?></td>
                                    </tr>
                                    <tr>
                                        <td style="width:30%">Staff:</td>
                                        <td> <?php echo $mstaff["name"] ?></td>
                                    </tr>
                                </table>                                
                            </td>
                            <td style="padding: 0px;">
                                <table class="table table-bordered" style="margin-bottom: 0px;">
                                    <tr>
                                        <td>No. :</td>
                                        <td><?php echo $getmdata["vouchno"] ?></td>
                                    </tr>
                                    <tr>
                                        <td>Date :</td>
                                        <td><?php echo $getmdata["vouchdt"] ?></td>
                                    </tr>
                                </table>                                
                            </td>
                        </tr>
                        <tr>
                             <!--style="padding: 0px;"  style="margin-bottom: 0px;"-->
                            <td colspan="3">
                                <div class="table-responsive">
                                    <table class="table table-bordered">
                                        <thead>
                                            <tr>
                                                <td style="width:8%;"><strong>Sr. No.</strong></td>
                                                <td style="width:43%;"><strong>Item</strong></td>
                                                <td style="width:26%;"><strong>Location</strong></td>
                                                <td style="width:19%;" class="text-right"><strong>Qty.</strong></td>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php
                                            $ctr = 0;
                                            $gettranqry = mysqli_query($conn, "SELECT * FROM `$trandb` WHERE vouchno='$vouchno' ORDER BY srno") or die(mysqli_error($conn));
                                            while ($row = mysqli_fetch_array($gettranqry)) {
                                                $getitemname = mysqli_query($conn, "SELECT `name` FROM `item` WHERE code='$row[itemcode]'") or die(mysqli_error($conn));
                                                $item = mysqli_fetch_array($getitemname);
                                                
                                                $getlocation = mysqli_query($conn, "SELECT `name` FROM `location` WHERE code='$row[location]'") or die(mysqli_error($conn));
                                                $location = mysqli_fetch_array($getlocation);
                                                
                                                echo "<tr>";
                                                echo "<td style=$mht>";
                                                echo $row["srno"];
                                                echo "</td>";
                                                echo "<td style=$mht>";
                                                echo $item["name"];
                                                echo "</td>";
                                                echo "<td style=$mht>";
                                                echo $location["name"];
                                                echo "</td>";
                                                echo "</td style=$mht>";
                                                echo "<td class='text-right'>";
                                                echo $row["qty"];
                                                echo "</td>";
                                                echo "</tr>";
                                                $ctr++;
                                            }
                                            if ($ctr < 10) {
                                                $mctr = 10 - $ctr;
                                                for ($i = 1; $i <= $mctr; $i++) {
                                                    echo '<tr>';
                                                    echo "<td style=$mht></td>";
                                                    echo "<td style=$mht></td>";
                                                    echo "<td style=$mht></td>";
                                                    echo "<td style=$mht></td>";
                                                    echo '</tr>';
                                                }
                                            }
                                            ?>

                                            <tr>
                                                <td colspan="6">
                                                    <table>
                                                        <tr>
                                                            <td colspan="3">
                                                                <?php
                                                                echo $getmdata["rem1"] . "<br/>";?>
                                                            </td>
                                                            <td style="width:115px;"></td>
                                                            <td style="width:150px;"></td>
                                                            <td style="width:175px;"></td>
                                                            <td valign="bottom" class="text-right">For <strong><b>MODERN HIRING SERVICES</b></strong></td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                <?php
                                                                echo $getmdata["rem2"];
                                                             ?>
                                                            </td>
                                                            </tr>
                                                            <td style="width:115px;"></td>
                                                            <td style="width:150px;"></td>
                                                                
                                                        </tr>
                                                        <tr></tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
        <b style="font-size:18px;"><center>Outward Challan</center></b>
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <table class="table table-bordered">
                        <tr>
<!--                            <td style="text-align: center;vertical-align: inherit;">
                                <img src="images/trdlogo3.png"/>
                            </td>-->
                            <td style="width:55%">
                                <table class="">
                                    <tr>
                                        <td><h5><b>MODERN HIRING SERVICE</b></h5></td>
                                    </tr>
                                    <tr>
                                    <td>BEST Quarters No.1, Reay Road, Mumbai-400010</td>
                                    </tr>
                                    <tr>
                                    <td>Tel: 022-23719929 / 23705678 Fax : 022-23711453</td>
                                    </tr>
                                    <tr>
                                    <td>E-mail: modern@born8.vsnl.net.in, modern.hiring@yahoo.com</td>
                                    </tr>
                                </table>                                
                            </td>
                            <td style="padding: 0px;">
                                <table class="table table-bordered" style="margin-bottom: 0px;">
                                    <tr>
                                        <td style="width:30%">Engine:</td>
                                        <td> <?php echo $mengine["name"] ?></td>
                                    </tr>
                                    <tr>
                                        <td style="width:30%">Site:</td>
                                        <td> <?php echo $msite["name"] ?></td>
                                    </tr>
                                    <tr>
                                        <td style="width:30%">Staff:</td>
                                        <td> <?php echo $mstaff["name"] ?></td>
                                    </tr>
                                </table>                                
                            </td>
                            <td style="padding: 0px;">
                                <table class="table table-bordered" style="margin-bottom: 0px;">
                                    <tr>
                                        <td>No. :</td>
                                        <td><?php echo $getmdata["vouchno"] ?></td>
                                    </tr>
                                    <tr>
                                        <td>Date :</td>
                                        <td><?php echo $getmdata["vouchdt"] ?></td>
                                    </tr>
                                </table>                                
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3" style="padding: 0px;">
                                <div class="table-responsive">
                                    <table class="table table-bordered" style="margin-bottom: 0px;">
                                        <thead>
                                            <tr>
                                                <td style="width:8%;"><strong>Sr. No.</strong></td>
                                                <td style="width:43%;"><strong>Item</strong></td>
                                                <td style="width:26%;"><strong>Location</strong></td>
                                                <td style="width:19%;" class="text-right"><strong>Qty.</strong></td>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php
                                            $ctr = 0;
                                            $gettranqry = mysqli_query($conn, "SELECT * FROM `$trandb` WHERE vouchno='$vouchno' ORDER BY srno") or die(mysqli_error($conn));
                                            while ($row = mysqli_fetch_array($gettranqry)) {
                                                $getitemname = mysqli_query($conn, "SELECT `name` FROM `item` WHERE code='$row[itemcode]'") or die(mysqli_error($conn));
                                                $item = mysqli_fetch_array($getitemname);
                                                
                                                $getlocation = mysqli_query($conn, "SELECT `name` FROM `location` WHERE code='$row[location]'") or die(mysqli_error($conn));
                                                $location = mysqli_fetch_array($getlocation);
                                                
                                                echo "<tr>";
                                                echo "<td style=$mht>";
                                                echo $row["srno"];
                                                echo "</td>";
                                                echo "<td style=$mht>";
                                                echo $item["name"];
                                                echo "</td>";
                                                echo "<td style=$mht>";
                                                echo $location["name"];
                                                echo "</td>";
                                                echo "</td style=$mht>";
                                                echo "<td class='text-right'>";
                                                echo $row["qty"];
                                                echo "</td>";
                                                echo "</tr>";
                                                $ctr++;
                                            }
                                            if ($ctr < 10) {
                                                $mctr = 10 - $ctr;
                                                
                                                for ($i = 1; $i <= $mctr; $i++) {
                                                    echo '<tr>';
                                                    echo "<td style=$mht></td>";
                                                    echo "<td style=$mht></td>";
                                                    echo "<td style=$mht></td>";
                                                    echo "<td style=$mht></td>";
                                                    echo '</tr>';
                                                }
                                            }
                                            ?>

                                            <tr>
                                                <td colspan="6">
                                                    <table>
                                                        <tr>
                                                            <td colspan="3">
                                                                <?php
                                                                echo $getmdata["rem1"] . "<br/>";?>
                                                            </td>
                                                            <td style="width:115px;"></td>
                                                            <td style="width:150px;"></td>
                                                            <td style="width:175px;"></td>
                                                            <td valign="bottom" class="text-right">For <strong><b>MODERN HIRING SERVICES</b></strong></td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                <?php
                                                                echo $getmdata["rem2"];
                                                             ?>
                                                            </td>
                                                            </tr>
                                                            <td style="width:115px;"></td>
                                                            <td style="width:150px;"></td>
                                                                
                                                        </tr>
                                                        <tr></tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </td>
                        </tr>
                    </table>

                </div>
            </div>
        </div>
        <style>
            .height {
                min-height: 100px;
            }

            .icon {
                font-size: 45px;
                color: #5CB85C;
            }

            .iconbig {
                font-size: 70px;
                color: #5CB85C;
            }

            .table > tbody > tr > .emptyrow {
                border-top: none;
            }

            .table > thead > tr > .emptyrow {
                border-bottom: none;
            }

            .table > tbody > tr > .highrow {
                border-top: 2px solid;
            }
        </style>
<?php
include("includes/files_footer.php");
?>
        <script>
            $(function() {
                formGeneral();
            });
        </script>
    </body>
</html>
