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

$zdb = $_SESSION["zdbyear_bmexp"];
mysqli_select_db($conn, $zdb);

$result = mysqli_query($conn, "SELECT * FROM itemgrp WHERE name !='' ORDER BY `name`") or die(mysqli_error($conn));
 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script src="tables/media/js/jquery.js" type="text/javascript"></script>
        <script src="tables/media/js/jquery.dataTables.js" type="text/javascript"></script>
        
        <style type="text/css">
            @import "tables/media/css/demo_table_jui.css";
            @import "tables/media/themes/smoothness/jquery-ui-1.8.4.custom.css";
        </style>
        
        <style>
            *{
                font-family: arial;
            }
        </style>
        <script type="text/javascript" charset="utf-8">
            $(document).ready(function(){
                $('#datatables').dataTable({
                    "sPaginationType":"full_numbers",
                    "aaSorting":[[2, "desc"]],
                    "bJQueryUI":true
                });
            })
            
        </script>
           <script >
function PopupWindowCenter(URL, title,w,h)
{var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var newWin = window.open (URL, title, 'toolbar=no, location=no,directories=no, status=no, menubar=no, scrollbars=no, resizable=no,copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}
</script>
    <!End poopup Window-->
    <style>
        .print{
            background-image:url(images/print.png);
            background-repeat: no-repeat;
            width:4px;
            
        }
    </style>
</head>
    
                  
                &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" onClick ="PopupWindowCenter('itemgrplst.php', 'PopupWindowCenter',800,800)"><font color="blue"><strong>Print</strong></font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="itemgrp.php?mode=true"><font color="green"><strong>+ Add New Record</strong></font></a>
                <table id="datatables" class="display">
                <thead>
                    <tr>
                        <th align='left'>Name</th>
                        <th align='left'>Action</th>
                        
                    </tr>
                </thead>
                <tbody>
                    <?php
                     if (isset($_GET["vouchno"])) {
                         delete($zdb, "itemgrp", "code", $_GET["vouchno"], "itemgrpmain.php");
                    }
                    while ($row = mysqli_fetch_array($result)) {
                    echo "<tr>";
                    echo "<td align='left'>$row[name]</td>";
                    echo "<td align='left'><a href=\"itemgrp.php?vouchno=$row[code]\"><img src='images/edit.png'></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"?vouchno=$row[code]\" onClick=\"return confirm('Confrim Delete?');\"><img src='images/delete.png'></a></td>";
                    echo "</tr>";
                      
                    }
                    ?>
                </tbody>
            </table>