<?php 
error_reporting(0);
session_start();
if(!isset($_SESSION['admin']) || ($_SESSION['admin'] == "") )
{
	?>
<script language="javascript">window.location.href="index.php";</script>
<?php 
}
include "config.php";
?>
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Product List</title>
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="shortcut icon" href="img/favicon.ico">
<link rel="apple-touch-icon" href="img/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="57x57" href="img/apple-touch-icon-57x57-precomposed.png">
<link rel="apple-touch-icon" sizes="72x72" href="img/apple-touch-icon-72x72-precomposed.png">
<link rel="apple-touch-icon" sizes="114x114" href="img/apple-touch-icon-114x114-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="img/apple-touch-icon-precomposed.png">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,400italic,700,700italic">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/plugins.css">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/themes.css">
<script src="js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
</head>
<body>
<div id="page-container">
  <?php include 'header.php' ?>
  <div id="inner-container">
    <?php include 'left_menu.php' ?>
    <?php 						
		$id = $_GET['reg'];				
		 if((isset($_GET['action'])== 'up_sts')) 
		{
  		  $id = $_GET['ids'];
		  $sts = $_GET['sts'];
	
			$qry = "update tbl_product_master set status='$sts' where prd_id=$id";
			mysql_query($qry) or die(mysql_error());
		?>
    <script language="javascript">window.location.href="product_list.php";</script>
    <?php
}
  ?>
    <div id="page-content">
      <ul id="nav-info" class="clearfix">
        <li><a href="#"><i class="icon-home"></i></a></li>
        <li class="active"><a href="#">Product List</a></li>
      </ul>
      <button id="addRow" class="btn btn-success" onClick="location.href = 'product_add.php';"><i class="icon-plus"></i> Add New Product</button>
      <table id="example-datatables" class="table table-striped table-bordered table-hover">
        <thead>
          <tr>
            <th class="span1">Action</th>
            <th> Product Name</th>
            <!--<th> Description</th>-->
            <!-- <th> Unit Price</th>
    <th> Per</th>-->
            <th class="hidden-phone hidden-tablet">Status</th>
          </tr>
        </thead>
        <tbody>
          <?php
		$ure=mysql_query("SELECT * FROM tbl_product_master order by prd_id ASC");		
		while($urow=mysql_fetch_array($ure)) {
		?>
          <tr>
            <td class="span1"><div class="btn-group"> <a href="product_add.php?reg=<?php echo $urow[0]; ?>" data-toggle="tooltip" title="Edit" class="btn btn-mini btn-success" style="margin-right:10px;"><i class="icon-pencil"></i></a> <?php echo "<a href='#' data-toggle='tooltip' title='Delete' class='btn btn-mini btn-danger' onclick='del(this,$urow[0])'>" ?><i class="icon-remove"></i></a> </div></td>
            <td><?php echo $urow['productname']; ?></td>
            <!--<td>
								 <?php //echo $urow['description']; ?>
							</td>-->
            <!-- <td>
								 <?php //echo $urow['unitprice']; ?>
							</td>
                            <td>
								 <?php //echo $urow['perunit']; ?>
							</td>-->
            <td><?php $img = ($urow['status']==0)?"2.png":"1.png";
			$trgt = ($urow['status']==1)?0:1;
			$sts = ($urow['status']==0)?"Deactive":"Active";
			$st=$urow['status']; ?>
              <?php 
					if($urow['status']=='1')
					{
						?>
              <a href="product_list.php?action=up_sts&ids=<?php echo $urow[0];?>&sts=<?php echo $trgt; ?>"><img src="images/1.png" title="Click To Disable" /></a>
              <?php				}
					else if($urow['status']=='0')
					{?>
              <a href="product_list.php?action=up_sts&ids=<?php echo $urow[0];?>&sts=<?php echo $trgt; ?>"><img src="images/2.png" title="Click To Enable" /></a>
              <?php }
						?>
            </td>
          </tr>
          <?php } ?>
        </tbody>
      </table>
      <script language="javascript">
			function del(obj,id)
			{
					if(confirm("Are You Sure To Delete ?"))
					{
						obj.href="product_list.php?id="+id;
					}
				
			}
			</script>
      <?php
		if(isset($_GET['id']))
			{
		$delquery="select * from  tbl_product_master where prd_id=".$_GET['id'];
		$dusr="delete from  tbl_product_master where prd_id=$_GET[id]";
		$dre=mysql_query($dusr);
		?>
      <script language="javascript">window.location.href="product_list.php";</script>
      <?php		
	}
	?>
    </div>
    <?php include 'footer.php' ?>
  </div>
</div>
<?php include 'profile_popup.php' ?>
<!--[if lte IE 8]><script src="js/helpers/excanvas.min.js"></script><![endif]-->
<script src="js/jquery.min.js"></script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/vendor/jquery-1.9.1.min.js"%3E%3C/script%3E'));</script>
<script src="js/vendor/bootstrap.min.js"></script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script>
<script>$(function(){$("#example-datatables").dataTable({aoColumnDefs:[{bSortable:!1,aTargets:[0]}]}),$("#example-datatables2").dataTable(),$("#example-datatables3").dataTable()});</script>
</body>
</html>