<?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);

$zyear = $myyear;



$vouch = $_GET['vouchno'];



$cond = '';

$lcond = '';

$formname = "E-Way Bill Print";



$maindb = 'gstmain';

$trandb = 'gsttran';



$getqry = mysqli_query($conn, "SELECT *, DATE_FORMAT(`entrydate`, '%d-%m-%Y')as entrydate,DATE_FORMAT(`docdate`, '%d-%m-%Y')as docdate   FROM `$maindb` WHERE vouchno='$vouch'")or die(mysqli_error($conn));

$get = mysqli_fetch_array($getqry);



$uniqueno = $get['uniqueno'];

$entrydate = $get['entrydate'];
?>



<!DOCTYPE html>

<title><?= $formname; ?></title>



<style>

    table, td{

        border: 1px solid black;

    }



    table {

        border-collapse: collapse;

        width: 100%;

        text-align: left;

    }



    table.table1, td {

        padding: 35px;



    }



    .th1{

        padding: 10px;

        padding-left: 70px;

    }

</style>

</head>



<center>

    <h2><?= $formname; ?></h2>

    <br>

    <h3>Part - A Slip</h3>





    <table class="table1" style="width:55%">



        <tr>

            <th class="th1" >Unique No.</th>

            <th class="th1"><?= $uniqueno; ?>.</th>

        </tr>



        <tr>

            <th class="th1">Entered Date:</th>

            <th class="th1"><?= $entrydate; ?>.</th>

        </tr>



        <tr>

            <th class="th1">Entered By:</th>

            <th class="th1"></th>

        </tr>



        <tr style="border-bottom: 1px solid black;">

            <th class="th1">Valid Form:</th>

            <th class="th1"><?= $entrydate; ?>.</th>

        </tr>



        <tr>

            <th>Part-A</th>
            <th class="th1"></th>

        </tr>



        <tr>

            <th class="th1">GSTIN of Supplier</th>
            <?php
            $getcomp2 = mysqli_query($conn, "SELECT * FROM $zroot.`company`") or die(mysqli_error($conn));
            $fetcomp2 = mysqli_fetch_array($getcomp2);

            $getparty = mysqli_query($conn, "SELECT * FROM `accmast` where accode='$get[party]'") or die(mysqli_error($conn));
            $fetparty = mysqli_fetch_array($getparty);
            ?>
            <th class="th1"><?= $fetcomp2[gstno] . " " . $fetcomp2[name] ?></th>

        </tr>



        <tr>

            <th class="th1">Place Of Dispatch:</th>

            <th class="th1"><?= $fetcomp2[add1] . $fetcomp2[add2] . $fetcomp2[add3] ?></th>

        </tr>



        <tr>

            <th class="th1">GSTIN of Receipient:</th>

            <th class="th1"><?= $fetparty[name] . " - " . $fetparty[gstno] ?></th>

        </tr>





        <tr>

            <th class="th1">Place of Delivery</th>

            <th class="th1"><?= $fetparty[add1] . $fetparty[add2] . $fetparty[add3] . $fetparty[city] . $fetparty[pincode] ?></th>

        </tr>





        <tr>

            <th class="th1">Document No.</th>

            <th class="th1"><?= $get[docno] ?></th>

        </tr>





        <tr>

            <th class="th1">Document Date</th>

            <th class="th1"><?= $get[docdate] ?></th>

        </tr>





        <tr>

            <th class="th1">Transaction Type:</th>

            <th class="th1"><?= $get[trantype] ?></th>

        </tr>





        <tr>

            <th class="th1">Value of Goods</th>

            <th class="th1"><?= $get[valgoods] ?></th>

        </tr>





        <tr>

            <th class="th1">HSN Code</th>

            <th class="th1"></th>

        </tr>





        <tr>

            <th class="th1">Reason form Transportation</th>

            <th class="th1">Outward - Supply</th>

        </tr>





        <tr>

            <?php
            $gettran = mysqli_query($conn, "SELECT `code`, `name` FROM `transport` WHERE code = '$get[transporter]'")or die(mysqli_error($conn));
            $fettran = mysqli_fetch_array($gettran);
            $transporter = $fettran['name'];
            ?>
            <th class="th1">Transporter</th>

            <th class="th1"><?= $transporter; ?></th>

        </tr>



    </table>

</center>

</html>