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

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$zroot = $_SESSION["zdir"];
$zcomp = $_SESSION["comp_" . $dbname];


$myyear = $_SESSION[$myyear];
mysqli_select_db($conn, $zdb);

$vouch = $_GET['vouchno'];

$cond = '';
$lcond = '';
$formname = "Inward Print";

$maindb = 'inwmfmain';
$trandb = 'inwmftran';

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

$getgd = mysqli_query($conn, "SELECT code, name  FROM `godown` WHERE code ='$getdata[godown]'")or die(mysqli_error($conn));
$fetgd = mysqli_fetch_array($getgd);
$gdwname = $fetgd['name'];

$cmpname = mysqli_query($conn, "SELECT * From $zroot.`company` where `code`='$zcomp'")or die(mysqli_error($conn));
$getcmpname = mysqli_fetch_array($cmpname);
?>

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


    <?php
//==        include("includes/files.php");
//        include("includes/tabsuf.php");
    ?>
    <style>
        body {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            /*background-color: #FAFAFA;*/
            font: 12pt "Tahoma";
        }
        @media print {
            .noprint {
                display: none;
            }
        }
        * {
            box-sizing: border-box;
            -moz-box-sizing: border-box;
        }
        .page {
            width: 210mm;
            min-height: 297mm;
            padding: 4mm;
            margin: 10mm auto;
            border: 1px #D3D3D3 solid;
            border-radius: 5px;
            /*background: white;*/

        }
        .subpage {
            padding: 0cm;
            /*        border: 1px solid;*/
            height: 288mm;
            outline: 2cm #ffffff solid;
        }

        @page {
            size: A4;
            margin: 0;
        }
        @media print {
            html, body {
                width: 210mm;
                height: 297mm;        
            }
            .page {
                margin: 0;
                border: initial;
                border-radius: initial;
                width: 210mm;
                min-height: 120mm;
                box-shadow: initial;
                background: initial;
                page-break-after: always;
                padding: 2mm;
            }
        }
        .numeric{
            text-align: right;
        }
        .rnone{
            border-right:none; 
        }
        .lnone{
            border-left:none; 
        }
    </style>
</head>


<body id="main_container">
    <div class="book">
        <!--        <button class="btn btn-primary goBack noprint" onclick="window.close()"  style="float: right;width: 150px;height:35px;background-color: white;color:#A0B1BA;">Go Back</button>-->
        <div class="page">
            <!--<div class="subpage">-->
            <!--   ************Header************  -->
            <!--            <div style="border:solid 1px;" class="col-md-12" >
                            <h3><center><? Echo $getcmpname['compname']; ?></center></h3>
                            <center><?php echo $getcmpname['add1'] . " " . $getcmpname['add2'] . " " . $getcmpname['add3']; ?></center>
                            <center><?php echo "Email :" . $getcmpname['email'] . " &nbsp " . "Contact No :" . $getcmpname['tel'] . "/" . $getcmpname['mobile']; ?></center>
                            <h5><center><b><?php echo $formname; ?></b></center></h5>
            
                        </div>-->
            <div style="border:solid 1px;" class="col-md-12" style="padding-left: 1px ; padding-right: 1px">

                <table class="table table-border table-hover" style="width:100% ;" >
                    <tr style="height:20px;">
                        <td style="text-align: center; width:100% ; font-size: 25px;"><b>Kuche 7</b></td>
                    </tr>
                </table>
            </div>
            <div style="border:solid 1px;" class="col-md-12" style="padding-left: 1px ; padding-right: 1px">

                <table class="table table-border table-hover" style="width:100% ;" >
                    <tr style="height:20px;">
                        <td style="text-align: center; width: 90%;  font-size: 15px;"><b>INWARD PRINT</b></td>

                    </tr>
                    <tr style="height:20px;">
                        <td style="text-align: right;font-size: 13px; width:20%;font-weight: bold;">Godown : <?= $gdwname; ?></td>


                    </tr>

                </table>
            </div>
            <div style="border:solid 1px;" class="col-md-12" style="padding-left: 1px ; padding-right: 1px">

                <table class="table table-border " style="width:100% ;" >
                    <!--<tr style="height:50px;">-->
                    <tr style="height:50px;">
                        <td style="width:50%;"><b>Voucher No: <?= $getdata['vouchno']; ?></b></td>
                        <td style="width:50%;   "><b>Date: <?= $getdata['vouchdt']; ?></b></td>
                
                    </tr>


                </table>
            </div>
            <div>
                <table  border="solid 1px" style="border-collapse: collapse; width:100% ">
                    <tr >
                        <th ><label>Sr No</label></th>
                        <th ><label>Item Name.</label></th>
                        <th ><label>Qty.</label></th>
                        <th ><label>Unit</label></th>
                        <th ><label>Location</label></th>

                    </tr>

                    <?php
                    $ctr = 0;
                    $ctab = 0;
                    $totqty = 0;
                    $gettran = mysqli_query($conn, "SELECT * FROM `$trandb` WHERE `vouchno`='$vouch' $keycond order by srno")or die(mysqli_error($conn));
                    while ($showtran = mysqli_fetch_array($gettran)) {
                        $getitem = mysqli_query($conn, "SELECT `name`,`code`  From `item` WHERE `code` = '$showtran[itemcode]' ")or die(mysqli_error($conn));
                        $showitem = mysqli_fetch_array($getitem);

                        $getuint = mysqli_query($conn, "SELECT `name`,`code`  From `project` WHERE `code` = '$showtran[unit]' ")or die(mysqli_error($conn));
                        $showunit = mysqli_fetch_array($getuint);

                        $getm2 = mysqli_query($conn, "SELECT `name` FROM `accmast` WHERE `accode`='$get[customer]'")or die(mysqli_error($conn));
                        $fetcust = mysqli_fetch_array($getm2);

                        $getloc = mysqli_query($conn, "SELECT `code`,`name` FROM `location` WHERE `code` = '$showtran[location]'") or die(mysqli_error($conn));
                        $fetloc = mysqli_fetch_array($getloc);

                        $getstaff = mysqli_query($conn, "SELECT `accode`, `name` FROM `accmast` WHERE `accode`='$get[staff]' AND grpcode = '040'")or die(mysqli_error($conn));
                        $fetstaf = mysqli_fetch_array($getstaff);


                        Echo"<tr>";
                        Echo"<td style='text-align:center;'>$showtran[srno]</td>";
                        Echo"<td style='text-align:center;'>$showitem[name]</td>";
                        Echo"<td style=' text-align:center;'>$showtran[qty]</td>";
                        Echo"<td style='text-align: center;'>$showtran[unit]</td>";
                        Echo"<td style=' text-align:center;'>$fetloc[name]</td>";


                        Echo"</tr>";

                        $ctr++;
                        $ctab = $ctab + 1;
                        $totqty = $showtran[qty] + $totqty;
                    }
                    if ($ctab < 10) {
                        for ($i = $ctab; $i <= 10; $i++) {
                            $ctab = $ctab + 1;
                            ?>
                            <tr style="height:26px;">
                                <td class="border"></td>
                                <td class="border"></td>
                                <td class="border"></td>
                                <td class="border"></td>
                                <td class="border"></td>


                            </tr>      
                            <?php
                        }
                    }
                    ?>  


                    <tr style="">
                        <td colspan="1" style="border:none" ><? echo "$getdata[remark1]" . "$getdata[remark2]"; ?></td>
                        <td style = "border:none ; text-align:right"> Total Qty </td>
                        <td style = "border:none ; text-align:right"> <b><? echo $totqty; ?>  </b></td>
                        <td style = "border:none"></td>
                        <td style = "border:none"></td>
                    </tr>
                </table>
                <div style="border:solid 1px;" class="col-md-12" style="padding-left: 1px ; padding-right: 1px">

                    <table border="solid 1px" style="border-collapse: collapse; width:100%" >
                        <!--<tr style="height:50px;">-->
                        <tr style="height:30px;">
                            <td style="text-align: center; width:20% ; font-size: 15px;"><b>Prepared By:</b></td>
                            <!--<th style="width:1%">:</th>-->
                            <td  class="border" style="text-align: center; width:30%;font-size: 15px; "><b><?php echo ""; ?></b></td>
                            <!--<td style="border:none"></td>-->

                            <td style="text-align: center ; width:20%;font-size: 15px;"><b>Approved By</b></td>
                            <!--<th style="width:1%">:</th>-->
                            <td style="text-align: center; width:30%;font-size: 15px;"><b><?php echo" "; ?></b></td>
                            <!--<td style="width:1%">:</td>-->

                        </tr>


                    </table>
                </div>
                <div style="border:solid 1px;" class="col-md-12" style="padding-left: 1px ; padding-right: 1px">

                    <table class="table table-border table-hover" style="width:100% ; border:solid 1px;" >
                        <tr style="height:50px;">
                            <td style="text-align: center; width:100% ; font-size: 25px;"><b></b></td>
                            <!--<td style="width:1%">:</td>-->

                        </tr>
                        <!--<hr>-->

<!--                    <tr style="height:50px;">
    <td style="text-align: left; width:5% ; font-size: 30px;"><b>Dept-</b></td>
    <td style="width:1%">:</td>
    <td style="text-align: left; width:40%;font-size: 30px;"><?php echo "$getdata[vouchno]"; ?></td>
    <td style="text-align: right ; width:30%;font-size: 30px;"><b>Date</b></td>
    <td style="width:1%">:</td>
    <td style="text-align: left; width:20%;font-size: 30px;"><?php echo" $getdata[vouchdt]"; ?></td>
</tr>-->

                    </table>
                </div>
            </div>

            <div>
                <table class="border">
                    <tr>
                        <td class="border" style="width: 541px; font-size: 14px;">
                        </td>
                        <td class="border" style="width: 216px">
                            <?php
                            require("includes/dbconnect.php");
                            ?>
                            <!--<div style=" text-align:right; font-size: 14px; font-weight: 900"><? echo "For $getcmpname[pname]"; ?></div>-->
                            <br>
                            <br>
                            <br>
                            <!--<div style=" margin-left: 51px; font-size: 11px">AUTHORISED SIGNATORY</div>-->
                        </td>
                    </tr>
                </table>
            </div>   
        </div>
    </div>
    <?php
    include("includes/linksfoot.php");
    ?>
    <script>
        $(function () {
            formGeneral();
        });
    </script>
</body>
</html>
