<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


        <link href="admin_min.css" rel="stylesheet" type="text/css" media="screen" />



        <title>Search Customer</title>

        <script language="JavaScript" src="js/sales_inv.js"></script>
        <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css"/>


    </head>

    <body>

        <table width="899" border="0">

            <tr>					
                <?php
                if (isset($_GET["stname"])) {
                $stname = $_GET["stname"];
                } else {
                $stname = "";    
                }
                ?>
                <td width="243"  background="images/headingbg.gif" ><input type="text" size="20" name="invno" id="invno" value="" class="txtbox"  onkeyup="<?php echo "update_list_inv('$stname')"; ?>"/></td>
                <td width="446"  background="images/headingbg.gif" ><input type="text" size="70" name="customername" id="customername" value="" class="txtbox" onkeyup="<?php echo "update_list_inv('$stname')"; ?>"/></td>
                <td width="196"  background="images/headingbg.gif" ><input type="text" size="29" name="invdate" id="invdate" value="" class="txtbox"/></td>

            </tr>  </table>   
        <div class="CSSTableGenerator" > 
            <div id="filt_table">  <table width="735"  class="table-bordered">
                    <tr>
                        <td width="220" >Invoice No</font></td>
                        <td width="424"  >Customer</font></td>
                        <td width="424"  >Invoice Date</font></td>
                        <td width="424"  >Invoice Value</font></td>
                    </tr>
                    <?php
                    require_once("connectioni.php");



                    if ($stname == "crn") {
                        if ($_SESSION["custno"] != "") {
                            $sql = "SELECT * FROM s_salma where C_CODE='" . $_SESSION["custno"] . "' and DEV='" . $_SESSION["dev"] . "' and CANCELL='0' order by id desc limit 50";
                        } else {
                            $sql = "SELECT * FROM s_salma where CANCELL='0' order by id desc limit 50";
                        }
                    } else if ($stname == "grn") {
                        if ($_SESSION["custno"] != "") {
                            $sql = "SELECT * FROM s_salma where C_CODE='" . $_SESSION["custno"] . "' and DEV='" . $_SESSION["dev"] . "' and CANCELL='0' order by id desc limit 50";
                        } else {
                            $sql = "SELECT * FROM s_salma where CANCELL='0' and DEV='" . $_SESSION["dev"] . "' order by id desc limit 50";
                        }
                    } else if ($stname == "search_grn") {
                        $sql = "SELECT * FROM s_crnma where CANCELL='0' order by id desc limit 50";
                    } else {
                        $sql = "SELECT * FROM s_salma where  CANCELL='0' and DEV='" . $_SESSION["dev"] . "' order by id desc limit 50";
                    }
                    //echo $sql;
                    $result = mysqli_query($GLOBALS['dbinv'], $sql);
                    while ($row = mysqli_fetch_array($result)) {

                        echo "<tr>               
                              <td onclick=\"invno_inv('" . $row['REF_NO'] . "', '" . $stname . "');\">" . $row['REF_NO'] . "</a></td>
                              <td onclick=\"invno_inv('" . $row['REF_NO'] . "', '" . $stname . "');\">" . $row["CUS_NAME"] . "</a></td>
                              <td onclick=\"invno_inv('" . $row['REF_NO'] . "', '" . $stname . "');\">" . $row['SDATE'] . "</a></td>
							  <td onclick=\"invno_inv('" . $row['REF_NO'] . "', '" . $stname . "');\">" . $row['GRAND_TOT'] . "</a></td>
                              
                            </tr>";
                    }
                    ?>
                </table>
            </div>
        </div>              

    </body>
</html>
