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

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

$cond = '';
$lcond = '';
$formname = "TAX INVOICE";
$maindb = 'salemain';
$trandb = 'saletran';
$root = $_SESSION["zdbroot"];

if ($type == "M") {
    $party = $_POST["party"];
    $frmdt = $_POST["frmdt"];
    $todt = $_POST["todt"];
    $frminvno = $_POST["frminvno"];
    $toinvno = $_POST["toinvno"];

    if (!empty($party)) {
        $partycond = " AND `party` = '$party' ";
    }

    if (!empty($frminvno)) {
        $rangecond = "and invno between $frminvno and $toinvno ";
    }

    $getqry = mysqli_query($conn, "SELECT *, DATE_FORMAT(`vouchdt`, '%d/%m/%Y')as mydt FROM `$maindb`
                       WHERE vouchno != '' $rangecond $partycond and vouchdt >= '$frmdt' and vouchdt <= '$todt' ORDER BY vouchno+0")or die(mysqli_error($conn));
} else {
    $getqry = mysqli_query($conn, "SELECT *, DATE_FORMAT(`vouchdt`, '%d/%m/%Y')as mydt FROM `$maindb`
                       WHERE vouchno='$vouch' ORDER BY vouchno+0")or die(mysqli_error($conn));
}


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




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

    .bor{
        border-left: 1px solid black;
        border-right:  1px solid black;
    }

    .numeric{
        text-align: right
    }

    .fontnew{
        font-family: 'Verdana';
        font-size : 13px;
        font : 'bold';
    }
    .border{
        border-top-style:solid; 
        border-right-style:solid; 
        border-bottom-style:none; 
        border-left-style:solid;
        border-width:1px black;
    }
    .border2{
        border-top-style:solid; 
        border-right-style:solid; 
        border-bottom-style:none; 
        border-left-style:none;
        border-width:1px ;
    }
    .uppercase{
        text-transform:uppercase;
    }
    th{
        font-size:10px
    }
    .table-condensed > tbody > tr > td {
        padding:3px;
        font-size:10px
    }
    .padd{
        padding-left: 2px;
    }
</style>
</head>
<body onload="">

    <?php
    $tdhg = "24px";

    while ($qry = mysqli_fetch_array($getqry)) {

        if (!empty($qry['deemexp'])) {
            $deemexp = 'E';
        } else {
            $deemexp = 'L';
        }
        $saltype = $qry['paidby'];
        $vouchno = $qry['vouchno'];
        $oms = $qry['oms'];
        $gstslform = $qry['gstno'];
        $mobile = $qry[mobile];
        if ($saltype == "C") {
            $nametype = "Cash";
            $codetype = "C";
        } else {
            $nametype = "Credit";
            $codetype = "R";
        }

        $stafcode = $qry['staff'];
        $getstaf = mysqli_query($conn, "SELECT accode,name FROM `accmast` where accode = '$stafcode' ")or die(mysqli_error($conn));
        $staff = mysqli_fetch_array($getstaf);
        ?>
        <div class="page">
            <div class="subpage" style="padding-top: 16px">
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 text-right">
                        <button onclick="window.print();
                                return false;" class="btn btn-primary noPrint" style="text-align: right">Print</button>
                    </div>
                </div><br>
                <div class="border" style="border-bottom: none">
                    <table style="width:100%;height: 7%">
                        <tr>
                            <td style="width:25%">
                                <table style="width:100%">
                                    <tr>
                                        <td><img src="images/logo/khlogo.jpg" style="width: 120px;height: 80px"></td> 
                                    </tr>
                                </table>
                            </td>
                            <td style="width:50%">
                                <table style="width:100%">
                                    <tr>
                                        <td class="uppercase" style="text-align: center;width: 100%;font-size: 35px;font-family: 'Times New Roman';">
                                            <b><? Echo $comp2['compname'] ?></b></td> 
                                    </tr>
                                </table> 
                            </td>
                            <td style="width:25%">
                                <table style="width:100%">
                                    <tr>
                                        <td style="text-align: right"><img src="images/logo/KH150.jpg" style="width: 120px;height: 80px"></td> 
                                    </tr>
                                </table> 
                            </td>
                        </tr>
                    </table>
                    <table style="width:100%">
                        <tr><td class="text-center"><b>Head Office :</b>
                                <?php echo $comp2['hoadd1'] . ' ' . $comp2['hoadd2'] . ' ' . $comp2['hoadd3'] . ' ' . $comp2['hocity'] . '-' . $comp2['hopin'] . " " . "Tel :" . " " . $comp2["htel"] ?>                      
                            </td>
                        </tr>
                        <tr>
                            <td class="text-center"><b>Sales :</b>
                                <?php echo $comp2['sadd1'] . ' ' . $comp2['sadd2'] . ' ' . $comp2['sadd3']; ?>   
                            </td>
                        </tr>
                        <tr>
                            <td class="text-center"><b>Factory :</b>
                                <?php echo $comp2['fadd1'] . ' ' . $comp2['fadd2'] . ' ' . $comp2['fadd3']; ?>   
                            </td>
                        </tr>
                        <tr>
                            <td style="font-size: 12px;" class="text-center"><span style="padding-left:50px"></span><b>
                                    GST NO :&nbsp;
                                    <?php echo $comp2['gstno'] ?>   
                                </b>
                            </td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                        </tr>

                        <tr>
                            <td style="font-size: 15px;" class="text-center">
                                <b>
                                    TAX INVOICE
                                </b>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="border">
                    <div class="row">
                        <?
                        $getpartyname = mysqli_query($conn, "SELECT * FROM `accmast` WHERE `accode`='$qry[party]' AND `grpcode`='010'")or die(mysqli_error($conn));
                        $mpartyname = mysqli_fetch_array($getpartyname);
                        $partyname = $mpartyname['name'];
                        $add1 = $mpartyname['add1'];
                        $add2 = $mpartyname['add2'];
                        $add3 = $mpartyname['add3'];
                        $city = $mpartyname['city'];
                        $pin = $mpartyname['pin'];
                        $panno = $mpartyname['vattin'];
                        $pan = $mpartyname['pan'];
                        $gstno = $mpartyname['gstno'];
                        $stcode = $mpartyname['statecode'];
                        $state = $mpartyname['state'];
                        $gettrans = mysqli_query($conn, "SELECT code,name FROM `transport` WHERE `code`='$qry[transporter]'")or die(mysqli_error($conn));
                        $mtrans = mysqli_fetch_array($gettrans);
                        ?>
                        <table width="100%">
                            <tr>
                                <td style="width:55%; border-right: 1px solid black;" class="text-left padd">
                                    <label class="fontnew" style="text-align: left;"><b>M/s.&nbsp;:&nbsp;&nbsp;<? Echo $partyname; ?></b></label>
                                </td>
                                <td style="width:10%" class="text-left padd">
                                    <label class="fontnew" style="text-align: left;"><b>Invoice No. &nbsp; </b></label>
                                </td>
                                <td  class="padd" style="width:20%">
                                    <label style="font-size: 12px;font-family: 'verdana'">:&nbsp;
                                        <? // Echo $comp2['init'] . "/GST/" . $myyear . "/" . $deemexp . $qry['invno']; ?>
                                        <? Echo $comp2['init'] . "/" . $myyear . "/" . $deemexp . $qry['invno']; ?></label>
                                </td>
                            </tr>
                            <tr>
                                <td  class="padd" style="width:55%;border-right: 1px solid black">
                                    <?php
                                    if ($add1 != '') {
                                        ?>
                                        <label class="fontnew"><? Echo $add1 . '' . $add2; ?></label>
                                    <?php }
                                    ?>
                                </td>
                                <td style="width:15%" class="text-left padd">
                                    <label class="fontnew" style="text-align: left;" >Date &nbsp;&nbsp;</label>
                                </td>
                                <td  class="text-left" style="width:15%">
                                    <label class="fontnew">:&nbsp;<? Echo $qry['mydt']; ?></label>
                                </td>
                            </tr>
                            <tr>
                                <td  class="padd" style="width:55%;border-right: 1px solid black">
                                    <?php
                                    if ($add3 != '') {
                                        ?>
                                        <label class="fontnew"><? Echo $add3 ?></label>
                                    <?php }
                                    ?>
                                </td>
                                <td style="width:15%" class="text-left padd">
                                    <label class="fontnew" style="text-align: right;" >Transport </label>
                                </td>
                                <td  class="padd" style="width:15%; font-family: 'Verdana';font-size : 12px;font : 'bold';">
                                    <label>:&nbsp;<? Echo $mtrans[name]; ?></label>
                                </td>
                            </tr>
                            <tr>
                                <td style="width:55%;border-right: 1px solid black" class="text-left padd">
                                    <?php
                                    if ($mobile != '') {
                                        ?>
                                        <label class="fontnew padd" style="text-align: right; " >
                                            Mobile &nbsp;&nbsp;:&nbsp;&nbsp;<? Echo $mobile; ?> </label>
                                    <?php } ?>
                                </td>
                                <?php if ($qry['lrno'] != '') { ?>

                                    <td style="width:15%" class="text-left padd">
                                        <label class="fontnew" style="text-align: right;" >L.R. No. &nbsp;&nbsp; </label>
                                    </td>

                                    <td class = "padd" style = "width:15%">
                                        <label class = "fontnew">:&nbsp;<?php Echo $qry['lrno']; ?></label>
                                    </td>
                                </tr>
                            <?php }
                            ?>
                            <tr>
                                <td style = "width:10%;border-right: 1px solid black;" class = "text-left padd">
                                    <label style = "font-size: 13px;font-family: 'verdana';text-align: left;" >GST NO&nbsp;
                                        :
                                        <?php
                                        if ($gstno != '') {
                                            Echo $gstno;
                                            ?>
                                        </label>
                                        <?php
                                    }
                                    if ($pan != '') {
                                        ?>

                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label style="font-size: 13px;font-family: 'verdana';text-align: left;" >Pan No &nbsp;:

                                            <? Echo $pan; ?>
                                        </label>
                                    <?php } ?>
                                </td>
                                <?php if ($qry['lrdate'] != '0000-00-00') { ?>

                                    <td style="width:15%" class="text-left padd">
                                        <label class="fontnew" style="text-align: left;" >L.R. Date &nbsp; </label>
                                    </td>
                                    <td  class="" style="width:15%">
                                        <label style="font-size: 12px;font-family: 'verdana'">:&nbsp;<? Echo $qry['lrdate']; ?></label>
                                    </td>
                                <?php } ?>
                            </tr>
                            <tr>
                                <td style="width:10%;border-right: 1px solid black;" class="text-left padd">
                                    <label style="font-size: 13px;font-family: 'verdana';text-align: left;" >State Code&nbsp;:
                                        <?php
                                        if ($stcode != '') {
                                            Echo $stcode;
                                            ?>
                                        </label>
                                        <?php
                                    }
                                    if ($state != '') {
                                        ?>

                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label style="font-size: 13px;font-family: 'verdana';text-align: left;" >State &nbsp;:

                                            <? Echo $state; ?>
                                        </label>
                                        <?php
                                    }
                                    ?>
                                </td>
                                <td colspan="2" style="width:15%" class="text-left padd">
                                </td>

                            </tr>
                        </table>

                    </div>
                </div>
                <!--                <div style="border-right: 1px solid black;border-left: 1px solid black;padding:0px">
                                    <div class="row">
                                        <div class="col-lg-12">-->
                <table class="table-condensed table-hover" style="width: 100%">
                    <tr style="background: #0098DA;color: white;border: 1px solid black; height: <?= $tdhg; ?>">
                        <th class="uppercase numeric bor" style="width:2%">Sr</th>
                        <th class="uppercase bor" style="width:43%">Description</th>
                        <th class="uppercase bor" style="width:6%">Net WT.</th>
                        <th class="uppercase bor" style="width:6%">Hsncode</th>
                        <th class="uppercase bor numeric " style="width:3%">B.NO.</th>
                        <th class="uppercase bor numeric " style="width:6%">M.R.P.</th>
                        <th class="uppercase bor numeric " style="width:6%">Qty.</th>
                        <th class="uppercase bor numeric " style="width:6%">Rate</th>
                        <th class="uppercase bor numeric " style="width:7%">Amount</th>
                        <th class="uppercase bor numeric " style="width:7%">Taxable Value</th>
                        <th class="uppercase bor numeric " style="width:6%">Gst %</th>
                        <th class="uppercase bor numeric" style="width:7%">Total</th>
                    </tr>
                    <?
                    $ctr = 0;
                    $checkgstzero = 0;
                    $gettran = mysqli_query($conn, "SELECT * FROM `saletran` WHERE `vouchno`='$vouchno' ORDER BY `srno`")or die(mysqli_error($conn));
                    while ($tran = mysqli_fetch_array($gettran)) {
                        $amount = round($tran['amount'], 2);
                        $subtot = round($tran['subtot'], 2);

                        $getitem = mysqli_query($conn, "SELECT `nametoprint` FROM `product` WHERE `prodcode`='$tran[itemcode]'")or die(mysqli_error($conn));
                        $item = mysqli_fetch_array($getitem);
                        $descrip = $item['nametoprint'];


                        if ($tran["igstrate"] > 0) {
                            $gstperc = $tran["igstrate"];
                        } else {
                            $gstperc = $tran["cgstrate"] * 2;
                        }


                        $ctr++;
                        if ($qry['canc_flag'] != '') {
                            ?>
                            <tr style="height: <?= $tdhg; ?>;">
                                <td class="bor" colspan="12">              
                                    <img src="images/cancel.jpg" alt="Cancelled Bill" style="width:100%;height:100%">
                                </td>

                            </tr> 
                        <?php } else {
                            ?>

                            <tr style="height: <?= $tdhg; ?>;">
                                <td class="bor"><? Echo $ctr; ?></td>
                                <td class="bor"><? Echo $descrip; ?></td>
                                <td class="bor"><? Echo $tran['gram']; ?></td>
                                <td class="bor"><? Echo $tran['hsncode']; ?></td>
                                <td class="bor numeric "><? Echo $tran['batch']; ?></td>
                                <td class="bor numeric "><? Echo $tran['mrp']; ?></td>
                                <td class="bor text-right"><? Echo round($tran['qty'], 0); ?></td>
                                <td class="bor text-right"><? Echo $tran['rate']; ?></td>
                                <td class="bor text-right"><? Echo number_format($amount, 2) ?></td>
                                <td class="bor text-right"><? Echo number_format($subtot, 2) ?></td>                            
                                <td class="text-right bor"><? Echo $gstperc ?></td>                                                                                  
                                <td class="text-right bor "><? Echo round($tran['total']); ?></td>
                            </tr>
                            <?
                        }
                        if ($checkgstzero == 0) {
                            if ($gstperc == 0) {
                                $checkgstzero = 1;
                            }
                        }
                    }
                    if ($qry[tcsamt] > 0) {
                        $ln = 7;
                    } else {
                        $ln = 9;
                    }

                    if ($ctr < $ln) {
                        for ($i = 0; $i < $ln; $i++) {
                            ?>
                            <tr style="height: <?= $tdhg; ?>">
                                <td class="bor"></td>
                                <td class="bor"></td>
                                <td class="bor"></td>
                                <td class="bor"></td>
                                <td class="bor"></td>
                                <td class="bor"></td>
                                <td class="bor"></td>
                                <td class="bor"></td>
                                <td class="bor"></td>
                                <td class="bor"></td>
                                <td class="bor"></td>
                                <td class="bor"></td>
                            </tr>
                            <?php
                        }
                    }
                    ?> 
                </table>
                <!--                        </div>
                                    </div>
                                </div>-->
                <div class="border">
                    <div class="row">
                        <div class="col-sm-12" style="padding: 0px">
                            <table class="table-hover pad" style="float: left;width:50%">
                                <tr>
                                    <td><label class="pad"><? Echo $qry['rem1'] ?></label></td>
                                </tr>
                                <tr>
                                    <td><label class="pad"><? Echo $qry['rem2']; ?></label></td>
                                </tr>
                                <?php if ($qry['deemexp'] == "1") { ?>
                                    <tr>
                                        <td><label class="pad">Export Sales: Rate Of Tax 0.1% Notification No.41/2017</label></td>
                                    </tr>
                                    <tr>
                                        <td><label class="pad">              Integrated Tax(Rate) Dated 23/10/2017</label></td>
                                    </tr>
                                    <?php
                                }
                                ?>
                            </table>
                            <table class="table-hover pad" style="float:left;width:50%">
                                <tr>
                                    <td style="text-align: right;font-size:13px"><label class="">Sub Total</label></td>
                                    <td class="numeric" style="text-align:left "><label class=""></label></td>
                                    <td class="numeric"><label class="" style="text-align:right;font-size:13px"><? echo $qry['grossamt']; ?></label></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right;font-size:13px;"><label class="">Discount</label></td>
                                    <td><label class="" style="text-align:left "><? $qry['discperc']; ?></label></td>
                                    <td class="numeric" style="font-size:13px"><label class=""><? Echo $qry['discamt']; ?></label></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right;font-size:13px;"><label class="">Postage</label></td>
                                    <td class="numeric" style="font-size:13px" colspan="2"><label class=""><? Echo $qry['postamt']; ?></label></td>
                                </tr>
                                <tr>
                                    <td style="text-align: right; font-size:13px"><label class="">Taxable Value</label></td>
                                    <td class="numeric" style="text-align:left "><label class=""></label></td>
                                    <td class="numeric" style="font-size:13px"><label class=""><? Echo $qry['taxableamt']; ?></label></td>
                                </tr>
                            </table>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-12" style="padding: 0px">
                            <table class="table-hover table-bordered" style="float: left;width:50%">
                                <tr style="height: 21px">
                                    <td width="50%" class='text-center' colspan="2">Payment Details</td>
                                </tr>
                                <tr style="height: 21px">
                                    <td width="10%" class=''>Prepared By</td>
                                    <td width="40%" class=''><?php echo $comp2['compname']; ?></td>
                                </tr>
                                <tr style="height: 21px">
                                    <td width="10%" class=''>Bank Name</td>
                                    <td width="40%" class=''><?php echo $comp2['bankname']; ?></td>
                                </tr>
                                <tr style="height: 21px">
                                    <td width="10%" class=''>Branch Name</td>
                                    <td width="40%" class=''><?php echo $comp2['branchname']; ?></td>
                                </tr>
                                <tr style="height: 21px">
                                    <td width="10%" class=''>Account No.</td>
                                    <td width="40%" class=''><?php echo $comp2['acno']; ?></td>
                                </tr>
                                <tr>
                                    <td width="10%"><label class="" >IFSC Code </label></td>
                                    <td width="40%"><label class="" ><? echo $comp2['ifccode']; ?></label></td>
                                </tr>
                            </table>
                            <table class="table-hover table-bordered" style="float: right;width:50%">
                                <tr style="height: 21px">
                                    <td width="10%" class='text-right'>Taxable Amt.</td>
                                    <td width="8%" class='text-right'>%</td>
                                    <td width="8%" class='text-right'>CGST</td>
                                    <td width="8%" class='text-right'>SGST</td>
                                    <td width="8%" class='text-right'>IGST</td>
                                    <td width="8%"></td>
                                </tr>
                                <?php
                                Echo "<tr style='height: 21px'>";
                                if ($qry[tottaxable0] > 0) {
                                    Echo "<td class='text-right'>$qry[tottaxable0]</td>";
                                    Echo "<td class='text-right'><b>0%</b></td>";
                                    Echo "<td class='text-right'>$qry[cgst0]</td>";
                                    Echo "<td class='text-right'>$qry[sgst0]</td>";
                                    Echo "<td class='text-right'>$qry[igst0]</td>";
                                    Echo "<td class='text-right'>$qry[totgst0]</td>";
                                } else {
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'><b></b></td>";
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'></td>";
                                }
                                Echo "</tr>";
                                if ($qry[tottaxble5] > 0) {
                                    Echo "<tr style='height: 21px'>";
                                    Echo "<td class='text-right'>$qry[tottaxble5]</td>";
                                    Echo "<td class='text-right'><b>5%</b></td>";
                                    Echo "<td class='text-right'>$qry[cgst5]</td>";
                                    Echo "<td class='text-right'>$qry[sgst5]</td>";
                                    Echo "<td class='text-right'>$qry[igst5]</td>";
                                    Echo "<td class='text-right'>$qry[totgst5]</td>";
                                } else {
                                    Echo "<tr style='height: 21px'>";
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'><b></b></td>";
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'></td>";
                                }
                                Echo "</tr>";
                                Echo "<tr style='height: 21px'>";
                                if ($qry[tottaxble12] > 0) {
                                    Echo "<td class='text-right'>$qry[tottaxble12]</td>";
                                    Echo "<td class='text-right'><b>12%</b></td>";
                                    Echo "<td class='text-right'>$qry[cgst12]</td>";
                                    Echo "<td class='text-right'>$qry[sgst12]</td>";
                                    Echo "<td class='text-right'>$qry[igst12]</td>";
                                    Echo "<td class='text-right'>$qry[totgst12]</td>";
                                } else {
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'><b></b></td>";
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'></td>";
                                }
                                Echo "</tr>";
                                Echo "<tr style='height: 21px'>";
                                if ($qry[tottaxble18] > 0) {

                                    Echo "<td class='text-right'>$qry[tottaxble18]</td>";
                                    Echo "<td class='text-right'><b>18%</b></td>";
                                    Echo "<td class='text-right'>$qry[cgst18]</td>";
                                    Echo "<td class='text-right'>$qry[sgst18]</td>";
                                    Echo "<td class='text-right'>$qry[igst18]</td>";
                                    Echo "<td class='text-right'>$qry[totgst18]</td>";
                                } else {
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'><b></b></td>";
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'></td>";
                                }

                                Echo "</tr>";
                                Echo "<tr style='height: 21px'>";
                                if ($qry[tottaxble28] > 0) {
                                    Echo "<td class='text-right'>$qry[tottaxble28]</td>";
                                    Echo "<td class='text-right'><b>28%</b></td>";
                                    Echo "<td class='text-right'>$qry[cgst28]</td>";
                                    Echo "<td class='text-right'>$qry[sgst28]</td>";
                                    Echo "<td class='text-right'>$qry[igst28]</td>";
                                    Echo "<td class='text-right'>$qry[totgst28]</td>";
                                } else {
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'><b></b></td>";
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'></td>";
                                    Echo "<td class='text-right'></td>";
                                }
                                Echo "</tr>";
                                if ($qry['tcsamt'] > 0) {
                                    ?>

                                    <tr>
                                        <td colspan="3" class="text-right"><label class="text-right" style="font-family: 'verdana';font-size: 10px">Pre Tcs</label></td>
        <!--                                <td class="numeric"><label class=""><i style="font-size:12px" class="fa fa-rupee"></i></label></td>-->
                                        <td class="numeric padd" colspan="3"><label class="" style="font-family: 'verdana';font-size: 10px"><b><i style="font-size:12px" class="fa fa-rupee"></i>&nbsp;<? Echo number_format(round($qry['pretcs']), 2); ?></b></label></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" class="text-right"><label class="text-right" style="font-family: 'verdana';font-size: 10px">TCS</label></td>
                                        <td class="numeric"><? Echo $qry['tcsperc']; ?>%</td>
                                        <td class="numeric padd" colspan="3"><label class="" style="font-family: 'verdana';font-size: 10px"><b><i style="font-size:12px" class="fa fa-rupee"></i>&nbsp;<? Echo number_format(round($qry['tcsamt']), 2); ?></b></label></td>
                                    </tr>
                                <?php } ?>
                                <tr>
                                    <td colspan="3" class="text-right"><label class="text-right" style="font-family: 'verdana';font-size: 12px">Bill Amount</label></td>
    <!--                                <td class="numeric"><label class=""><i style="font-size:12px" class="fa fa-rupee"></i></label></td>-->
                                    <td class="numeric padd" colspan="3"><label class="" style="font-family: 'verdana';font-size: 12px"><b><i style="font-size:12px" class="fa fa-rupee"></i>&nbsp;<? Echo number_format(round($qry['billamt']), 2); ?></b></label></td>
                                </tr>
                            </table>
                        </div>
                    </div>

                </div>
                <?php
                $mwords = round($qry['billamt']);
                $words = rsword($mwords);
                ?>
                <div style="border:1px solid black" style="">
                    <div class="row">
                        <div class="col-lg-12" style="padding: 0px">
                            <label class="pad fa fa-inr">&nbsp;<?php Echo $words . " Only"; ?></label>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-12" style="padding: 0px">
                        <?php if ($checkgstzero == 1) { ?>
                            <label style="font-size:10px">KAJAL / SURMA (Other than pencil stick). HSN Code 33040000.Rate of Tax : NIL. Notification No. 2/2017. dt 20/06/2017. Sr No. 109</label>
                        <? } ?>
                    </div>
                </div>
                <?php $content = "Certified that the particulars given above are true and correct." ?>
                <div class="" style="padding-top: 5px;">
                    <div class="row">
                        <div class="col-sm-12" style="padding:0px">

                            <table width='100%'>
                                <tr>
                                    <td style="width: 50%">
                                        <label style="font-family: 'verdana';font-size: 16px">E.O.& E.</label>
                                    </td>
                                    <td style="width: 50%" class="text-right">
                                        <label><b style="font-family: 'verdana';font-size: 16px"><?php Echo "For " . $comp2['compname'] ?></b></label>
                                    </td>
                                </tr>
                            </table>
                            <table width='50%'>
                                <tr>
                                    <td>
                                        <label style="font-size:10px">
                                            " I / We hereby certify that  my / our registration  certificate  under    
                                            Rule 1 of GST invoice rules 2017  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='100%'>
                                <tr>
                                    <td class="text-right" style="font-size: 12px;">
                                        <label>Authorized Signatory</label><br>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>

                </div>
            </div>
        </div>
        <?php
    }

    include('includes/linksfoot.php');
    ?>
