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

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);

$maindb = 'product';
$grid = '';
$formname = 'Product Listing';



$cond = "";

if (!empty($_POST["itemname"])) {
    $pname = trim($_POST["itemname"]);
    $cond = "AND `name` LIKE '%$pname%'";
}

$get = mysqli_query($conn, "SELECT * FROM `$maindb` WHERE `name`!='' $cond  ORDER by `name`") or die(mysqli_error($conn));

$getno = mysqli_num_rows($get);

include("includes/linkshead.php");
?>

</head>
<body>
    <div class="container">
        <?php include('includes/head_rep.php') ?>
        <div class="row">
            <div class="col-lg-12 pad">
                <table class="table table-condensed table-bordered ">
                    <tr class="mySearchTr">
                        <th width="5%">Sr.</th>
                        <th width="15%">Barcode</th>
                        <th width="30%">Name</th>
                        <th width="10%">Type</th>
                        <th width="10%">Country Origin</th>
                        <th width="10%">Best Before</th>
                        <th width="10%">Batch</th>
                        <th width="10%">Unit</th>
                    </tr>
                    <tbody>
                        <?php
                        $ctr = 1;
                        while ($pmain = mysqli_fetch_array($get)) {

                            Echo "<tr>";
                            Echo "<td>$ctr</td>";
                            Echo "<td>$pmain[barcode]</td>";
                            Echo "<td>$pmain[name]</td>";
                            Echo "<td>$pmain[type]</td>";
                            Echo "<td>$pmain[origin]</td>";
                            Echo "<td>$pmain[bbf] months</td>";
                            Echo "<td>$pmain[batch]</td>";
                            Echo "<td>$pmain[unit]</td>";
                            echo "</tr>";
                            $ctr++;
                        }
                        ?>
                    </tbody>    
                </table>
            </div>
        </div>
    </div>
</div>

<?php include("includes/linksfoot.php"); ?>
</body>
</html>
