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

$formname = 'Contra Voucher';
$maindb = 'contra';
//$trandb = 'purtran';
/* $accdb = 'actran'; */
$file = 'contra.php';
$source = "TR";
/* $grid = 'salemain.php'; */

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);
$zyear = right($zdb, 4);
$mht = 'height:20px;';

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

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


    <?php
    include("includes/linkshead.php");
    ?>
</head>
<style>
    body {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        /*background-color: #FAFAFA;*/
        font: 12pt "Tahoma";
    }
    * {
        box-sizing: border-box;
        -moz-box-sizing: border-box;
    }
    .page {
        width: 180mm;
        /*min-height: 297mm;*/
        padding: 4mm;
        margin: 5mm auto;
        /*border: 1px #D3D3D3 solid;*/
        border-radius: 3px;
        /*background: white;*/

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

    @page {
        size: A4;
        margin: none;
    }
    @media print {
        html, body {
            width: 210mm;
            height: 297mm;        
        }
        .page {
            margin: 0;
            border: initial;
            border-radius: initial;
            width: initial;
            min-height: initial;
            box-shadow: initial;
            background: initial;
            page-break-after: always;
        }
    }
    .border{
        border: 1px solid;
    }
</style>

<body id="main_container">
    <div class="book">
        <div class="page" style="">
            <!--<div class="subpage">-->
            <!--   ************Header************  -->
            <div style="" class="col-md-12" >
                <?php
                require("includes/dbconnect.php");
                $comp = mysqli_query($conn, "SELECT * FROM `company`") or die(mysqli_error($conn));
                $zcomp = mysqli_fetch_assoc($comp);
                mysqli_select_db($conn, $zdb);

                ?>
                <!--/<b><center><?php // echo $zcomp[compname]; ?></center></b>-->
                <h4><center><B><?php echo $formname; ?></B></center></h4>

            </div>
            <div style="" class="col-md-12" style="padding-left: 1px ; padding-right: 1px">
                <?php
                $gcust = mysqli_query($conn, "SELECT * FROM `accmast` WHERE `accode`=$getmdata[frombc]") or die(mysqli_error($conn));
                $cust = mysqli_fetch_array($gcust);
                
                $gcust1 = mysqli_query($conn, "SELECT * FROM `accmast` WHERE `accode`=$getmdata[tobc]") or die(mysqli_error($conn));
                $cust1 = mysqli_fetch_array($gcust1);
                ?>
                <table width="100%">
                    <tr>
                        <td style="text-align: left;width:75%">
                        <!--<td style="text-align: left;padding-left: 12px;">-->
                            Voucher No:
                            <b><?php echo $zyear; ?>/<?php echo "$getmdata[vouchno]"; ?></b> 
                        </td>
                        <td style="text-align: left;width:25%">
                            Date:
                            <b><?php echo "$getmdata[vouchdt]"; ?></b>
                        </td>
                    </tr>
                    <tr style="height:10px;"></tr>
                    <tr>
                        <td style="text-align: left;">From :&nbsp&nbsp
                        <!--<td style="text-align: left;padding-left: 53px;">From :&nbsp&nbsp-->
                            <b><?php echo "$cust[name]"; ?> </b>
                        </td>
                    </tr>
                    <tr style="height:10px;"></tr>
                    <tr>
                        <td style="text-align: left;">To :&nbsp&nbsp
                        <!--<td style="text-align: left;padding-left: 71px;">To :&nbsp&nbsp-->
                            <b><?php echo "$cust1[name]"; ?> </b>
                        </td>
                    </tr>
                    <tr style="height:10px;"></tr>
                    <tr>
                        <td style="text-align: left;">Amount(Rs.) :&nbsp&nbsp
                            <b><? echo "$getmdata[amount]"; ?>
                            (<?php echo rsword(round($getmdata["amount"])); ?>) </b>
                        </td>
                    </tr>
                    <?php 
                    if($getmdata['chqno'] != ''){
                    ?>
                    <tr style="height:10px;"></tr>
                    <tr>
                        <td>
                            vide cheque no.:&nbsp&nbsp
                            <b><? echo "$getmdata[chqno]"; ?></b> dated <b><?= $getmdata['chqdate']; ?></b>
                        </td>
                    </tr>
                    <?php }
                    else {
                        
                    }?>
                    <tr style="height:10px;"></tr>
                    <tr>
                        <td>
                            <? echo "$getmdata[narr1]  $getmdata[narr2]"; ?>    
                        </td>
                    </tr>

                </table>
            </div>


            
        </div>    
        <!--</div>-->
    </div>
    <?php
    include("includes/linksfoot.php");
    ?>
    <script>
        $(function () {
            formGeneral();
        });
    </script>
</body>
</html>
