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

$formname = 'Previous Bill';
$maindb = 'prevbill';
$bseries = $_SESSION["series_" . $dbname];

$file = 'prevbill_fr.php';

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$myyear = $_SESSION[$myyear];

//$zroot = $_SESSION["zdbroot"];

$username = $_SESSION["username_" . $dbname];

mysqli_select_db($conn, $zdb) or die(mysqli_error($conn));

include("includes/linkshead.php");
?>
<script src="MyScript/prevbill.js" type="text/javascript"></script>
</head>
<body>
    <form action="<?= $file ?>" method="POST">
    <!-- Default box -->
    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 pad">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title" style="color:#6082BF"><?php Echo $formname; ?></h3>
                <div class="actions pull-right">
                    <i class="fa fa-chevron-down"></i>
                </div>
            </div>
            <div class="panel-body">
                <div class="row">
                    &nbsp;
                </div>
                <div class="row">
                    <label class="col-lg-3 col-md-3 col-sm-3 col-xs-3 label-control text-right">CODE</label>
                    <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 pad">
                        <input type='text' class='form-control custcode code' name='code'>
                    </div>
                </div>
                <div class="row">
                    <label class="col-lg-3 col-md-3 col-sm-3 col-xs-3 label-control text-right">PARTY</label>
                    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 pad">
                        <select class="form-control select2 school" name="supplier" required>
                            <option value=""></option>
                            <?php
                            $gsupp = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` WHERE `grpcode` = '010' ORDER BY `name`") or die(mysqli_error($conn));
                            while ($fsupp = mysqli_fetch_array($gsupp)) {
                                echo "<option value='$fsupp[accode]'>$fsupp[name]</option>";
                            }
                            ?>
                        </select>
                    </div>
                </div>
                <div class="row">
                    &nbsp;
                </div>
            </div>
        </div>
        <div class="panel-footer" style="text-align: center">
            <!--            <button id='view' type='submit' name='submit' class="btn btn-pad btn-square " style="background-color:#008D4C; ">
                            <i class="fa fa-check" style="color:#ffffff"></i>
                        </button>-->
            <a id="prevref"><button class="btn btn-pad btn-square" style="background-color:#6082BF;color: white">
                    Proceed</button></a>
            <!--<input type="submit" name="exit" value="Exit" id="exit" class="btn btn-danger" onclick="window.location.href='followup.php'">-->
            <button id='cancel' type="reset" class="btn btn-pad btn-square" style="background-color:red;color: white;" onclick="window.location.href = 'default.php'">
                Exit</button>
        </div>
    </div>
<div class="modal fade" id="schlmodal"  role="dialog" aria-labelledby="myLargeModalLabel" >
        <div class="modal-dialog modal-lg" style="margin-top: 5%;">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span>&times;</span></button>
                    <div class="row">
                        <div class="col-lg-2 text-right padi">
                            <label class="label-control">Search By Code</label>
                        </div>
                        <div class="col-lg-2 padi" >
                            <input type='text' style="" name='search' class="form-control tsearch">    
                        </div>

                    </div>
                </div>
                <div class="modal-body">
                    <div class="table-responsive" style="height: 300px;">
                        <?php
                        $srchresult = mysqli_query($conn, "SELECT * FROM `accmast` WHERE `accode` != '' and `grpcode` = '010' ")or die(mysqli_error($conn));


                        if (mysqli_num_rows($srchresult) > 0) {
                            echo "<table class='table table-bordered table-hover myTable'>";
                            echo "<tr class='clickable-row' style='background-color: #6082BF;color: white;'>";
                            echo "<td><b>Code</b></td>";
                            echo "<td><b>Name</b></td>";
                            echo "<td><b>Address</b></td>";
                            echo "</tr>";
                            $sctr = 0;
                            $ctr = 0;
                            while ($row2 = mysqli_fetch_array($srchresult)) {
                                $modcode = $row2['custcode'];
                                $modname = $row2['name'];
                                $add1 = $row2[add1];
                                $add2 = $row2[add2];
                                $add3 = $row2[add3];

                                echo "<tr class='schltab'>";
                                echo "<td><b>$modcode</b>
                                    <input type='hidden' style='border: none' class='scust' value='$modcode' readonly>
                                            <input type='hidden' value='$row2[medmcode]' class='medium'>
                                            <input type='hidden' value='$row2[accode]' class='accode'>
                                    </td>";
                                echo "<td><b>$modname<input type='hidden' style='border: none' class='sname' value='$modname' readonly></b></td>";
                                echo "<td><b>$add1 $add2 $add3
                                     <input type='hidden' style='border: none' class='sadd1' value='$row2[add1]' readonly>
                                     <input type='hidden' style='border: none' class='sadd2' vadayalue='$row2[add2]' readonly>          
                                     <input type='hidden' style='border: none' class='sadd3' value='$row2[add3]' readonly>          
                                   </b></td>";
                                echo "</tr>";
                                $sctr++;
                                $ctr++;
                            }
                            echo "</table>";
                        }
                        ?>
                    </div>
                </div>
                <div class="modal-footer"></div>
            </div>
        </div>
    </div>
<?php include("includes/linksfoot.php"); ?>
    </form>
</body>
</html>
