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

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$myyear = $_SESSION[$myyear];
mysqli_select_db($conn, $zdb);
$root = $_SESSION["zdbroot"];

$vouch = $_GET['vouchno'];
$para = $_GET['para'];

$cond = '';
$lcond = '';
$formname = "Outward Voucher";

$maindb = 'outmain_mi';
$trandb = 'outtran_mi';

$fseries = $_SESSION["series_" . $dbname];

$getqry = mysqli_query($conn, "SELECT *, DATE_FORMAT(`vouchdt`, '%d-%m-%Y')as mydt FROM `$maindb` WHERE vouchno='$vouch' ORDER BY `vouchno`")or die(mysqli_error($conn));
$get = mysqli_fetch_array($getqry);

$getcomp = mysqli_query($conn, "SELECT * FROM $root.`series` WHERE `code`='$fseries'")or die(mysqli_error($conn));
$comp = mysqli_fetch_array($getcomp);

$getcomp2 = mysqli_query($conn, "SELECT * FROM $root.`company`")or die(mysqli_error($conn));
$comp2 = mysqli_fetch_array($getcomp2);

$getgo = mysqli_query($conn, "SELECT * FROM `$root`.`series` WHERE `code`= '$get[fromcode]'") or die(mysqli_error($conn));
$getgodown = mysqli_fetch_array($getgo);

$getgo1 = mysqli_query($conn, "SELECT * FROM `$root`.`series` WHERE `code`= '$get[tocode]'") or die(mysqli_error($conn));
$getgodown1 = mysqli_fetch_array($getgo1);


if (mysqli_num_rows($getqry) <= 0) {
    browse("Record Not Found");
}
include("includes/linkshead.php");
?>
<link href="MyStyle/inv_format.css" rel="stylesheet">
<style>
    body{
        font-size: 13px;
    }
    .table > tbody > tr > td{
        padding: 0px;
    }

</style>
</head>
<body>
    <?php
    $tdhg = "24px";
    ?>
    <div class="page">
        <div class="subpage">
            <table width="100%">
                <tr>
                    <td style="width:25%">
                        <table style="width:100%">
                            <tr>
                                <td style="width:33.33%"><img src="images/cycle_logo.png" style="width: 130px;height: 60px"></td> 


                            </tr>
                        </table>
                    </td>
                    <td style="width:50%">
                        <table style="width:100%">
                            <tr>
                                <td style="text-align: center;width: 100%;font-size: 24px"><? Echo $comp2[compname] ?></td> 
                            </tr>
                            <tr>
                                <td style=""><label class="label-control" style=""><? Echo "$comp[address]"; ?></label></td> 
                            </tr>
                            <tr>
                                <td style="width:33.33%;text-align: center"><label class="label-control"><? Echo $formname; ?></label></td> 
                            </tr>
                        </table> 
                    </td>
                    <td style="width:25%">

                        <table style="width:100%">
                            <tr>
                                <td style="width:33.33%;text-align: right"><img src="images/since_logo.png" style="width: 130px;height: 60px"></td> 
                            </tr>
                        </table> 
                    </td>
                </tr>
            </table>
            <div class="border">
                <div class="row">
                    <table style="width: 100%">
                        <tr>
                            <td width="5%" class="text-right"><label class="label-control">No  :</label></td>
                            <td width="20%"><label class="label-control"><? Echo $get[chalno]; ?></label></td>

                            <td width="5%" class="text-right"><label class="label-control">From  :</label></td>
                            <td width="20%"><label class="label-control"><? Echo $getgodown[name]; ?></label></td>

                            <td width="5%" class="text-right"><label class="label-control">To  :</label></td>
                            <td width="20%"><label class="label-control"><? Echo $getgodown1[name]; ?></label></td>

                            <td width="5%" class="text-right"><label class="label-control">Date  :</label></td>
                            <td width="20%"><label class="label-control"><? Echo $get[mydt]; ?></label></td>

                        </tr>
                    </table>
                </div>
            </div>
            <div style="border-right: 1px solid black;border-left: 1px solid black;">
                <div class="row">
                    <div class="col-sm-12 pad">
                        <table class="table-condensed table-hover" style="width: 100%">
                            <tr style="background-color:#cccccc;border: 1px solid black; height: <?= $tdhg; ?>">
                                <th width="5%" class="numeric">Sr</th>
                                <th width="10%">Barcode</th>
                                <th width="15%">Item Name</th>
                                <th width="10%">Brand</th>
                                <th width="10%">Size</th>
                                <th width="7%">Colour</th>
                                <th width="7%">Unit</th>
                                <th class="numeric" width="7%">Qty.</th>
                            </tr>
                            <?
                            $ctab = 0;
                            $gettran = mysqli_query($conn, "SELECT * FROM $trandb WHERE `vouchno`='$get[vouchno]' ORDER BY `srno`")or die(mysqli_error($conn));
                            while ($tran = mysqli_fetch_array($gettran)) {
                                $getitem = mysqli_query($conn, "SELECT `name` FROM `item` WHERE `code`='$tran[itemcode]'")or die(mysqli_error($conn));
                                $item = mysqli_fetch_array($getitem);
                                ?>
                                <tr style="height: <?= $tdhg; ?>">
                                    <td class="numeric"><? Echo $tran[srno]; ?></td>
                                    <td ><? Echo $tran[barcode]; ?></td>
                                    <td ><? Echo $item[name]; ?></td>
                                    <td ><? Echo $tran[brand]; ?></td>
                                    <td ><? Echo $tran[size]; ?></td>
                                    <td ><? Echo $tran[colour]; ?></td>
                                    <td ><? Echo $tran[unit]; ?></td>
                                    <td class="numeric"><? Echo $tran[qty]; ?></td>

                                </tr>
                                <?
                                $ctab = $ctab + 1;
                            }
                            if ($ctab < 31) {
                                for ($i = $ctab; $i < 32; $i++) {
                                    ?>
                                    <tr style="height: <?= $tdhg; ?>">
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                    </tr>
                                    <?php
                                }
                            }
                            ?> 
                        </table>
                    </div>
                </div>
            </div>
            <div class="border">
                <div class="row">
                    <div class="col-lg-12" style="padding: 0px">
                        <table class="table-hover rborder pad" style="float: left;width:70%">
                            <tr>
                                <td><label class="smfont pad">Remark : </label> <? Echo $get[rem1]; ?></td>
                            </tr>
                        </table>
                        <table>
                            <tr>
                                <td><label class="smfont pad" style="margin-right: 127px;">Total Qty.</label></td>
                                <td class="numeric"><label class="smfont text-right pad"><? Echo $get[totqty]; ?></label></td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
            <?php ?>
            <div class="">
                <div class="row">
                    <div class="col-sm-12" style="padding:0px">
                        <table class="" width='50%' style="float:left">
                            <tr>
                                <!--<td><label class="smfont">E.O.& E.</label></td>-->
                                <!--<td><label style="font-size:10px">Subject to Navi Mumbai Jurisdiction</label></td>-->
                            </tr>
                        </table>
                        <table width='50%'>
                            <tr>
                                <td class="numeric">
                                    <!--<label class="smfont"><?php // Echo "For " . $comp[compname] ?></label><br>-->
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-12" style="padding:0px">
                        <table class="" width='50%' style="float:left">
                            <tr>
                                <td>
                                    <label style="font-size:10px">
<!--                                        " I / We hereby certify that  my / our registration  certificate  under  the  
                                        Maharashtra Value Added Tax Act  2002  is in force  on  the  date on which 
                                        the sale of the goods specified in this tax invoice is made by me/us  and 
                                        that the transaction of sale covered  by  this  tax invoice has been 
                                        affected by me/us and its shall be accounted for in the turnover of sales 
                                        while filling of return and the due tax, if any, payable on the sale has 
                                        been paid or shall be paid. "-->
                                    </label>
                                </td>
                            </tr>
                        </table>
                        <table width='50%'>
                            <tr>
                                <td class="numeric">
                                    <label class="smfont" style="margin-top: 15%;">Authorized Signatory</label><br>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php include('includes/linksfoot.php'); ?>
