<?PHP 
include("header.php");
session_start();
error_reporting(0);
include("include/db-connect.php");
//mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
if(isset($_REQUEST['submit']))
{
	$search=$_REQUEST['search'];
	?>
    <script>
	window.location='view_search.php?search=<? echo $search; ?>';
	</script>
<? } ?>
  <div id="content">
  <div class="breadcrumb">
      </div>
              <div class="box">
    <div class="heading">
     <?php 
			 $dis1=("select count(*) as num  from ".$PRODUCT." ");		
		     $total_pages = mysql_fetch_array(mysql_query($dis1));
             $total_pages = $total_pages[num];
		 ?>
      <h1><img src="view/image/home.png" alt="" />Product Details  &nbsp;&nbsp;&nbsp;Total Products - <?php echo  $total_pages; ?>  </h1>
    </div>
    <div class="content">
      <div class="overview" style="width:96%; margin-left:50px;">
        <div class="dashboard-heading" style="  margin-top:20px; ">
        <h3 class="tabs_involved" style="margin-left:25px;  color:#033;">
        
<form enctype="multipart/form-data" metdod="post">
<input list="browsers" name="search" style="width:300px;height:20px;padding:4px;
  border-radius:4px;border:1px groove;border-color:#333;font-size:20px;">
  <datalist id="browsers">
  <? $selecf_pr_details=mysql_query("select * from `products` ");
  while($fetch_pr_details=mysql_fetch_array($selecf_pr_details)){ ?>
    <option value="<? echo $fetch_pr_details['name']; ?>">
   <? } ?>
  </datalist>
<input type="submit" value="SUBMIT" name="submit">
</form>
        </h3></div>
        <div class="dashboard-content">
<!--Message Display-->	

<? if($_REQUEST['output'] == 'delete') { ?>
<div style="font-size:18px;color:#090;margin-top:10px;margin-bottom:10px;" align="center">One Product Details Deleted Successfully.</div><? } ?>

<?php 
$dis1=("select count(*) as num  from ".$PRODUCT." ");		
$total_pages = mysql_fetch_array(mysql_query($dis1));
$total_pages = $total_pages[num];
?>
		 
  <table class="list" cellspacing="0" > 
			<thead> 
                 <tr>
                    <td class="left">S.No</td>
                    <td class="left">Category</td>
                    <!--<td class="left">Sub Category</td>
                    <td class="left">Sub Sub Category</td>-->
                    <td class="left">Product ID</td> 
                    <td class="left">Product Name</td>
                    <!--<td class="left">Back Name</td>-->
                    <td class="left">Tax (%)</td>
                    <td class="left">Quantity</td>
                    <td class="left">Purchase Price</td>
                    <td class="left">Sales Price</td> 
                   <!-- <td class="left">Tax</td> 
                    <td class="left">Total</td>--> 
                    <td class="left">Picture</td>
                    <td class="left">Actions</td>
              </tr>
              </thead>
			
			<tbody> 
           
				 
			 
			<?php 
		$dis1=("select count(*) as num  from ".$PRODUCT."  ");		
		$total_pages = mysql_fetch_array(mysql_query($dis1));
		$adjacents = 3;
     $total_pages = $total_pages[num];
$targetpage =""; //your file name (tde name of tdis file)
$limit = 30; //how many items to show per page
$page = $_GET['page'];
if($page)
$start = ($page - 1) * $limit; //first item to display on tdis page
else
$start = 0; //if no page var is given, set start to 0
if ($page == 0) $page = 1; //if no page var is given, default to 1.
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
$lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
$pagination = "";
if($lastpage > 1)
{
$pagination .= "<div class=\"pagination\">";
//previous button
if ($page > 1)
$pagination.= "<a href=\"$targetpage?page=$prev \">Previous &nbsp;</a>";
else
$pagination.= "<span class=\"disabled\">Previous &nbsp;</span>";
//pages
if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to botder breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter &nbsp;</span>";
else
$pagination.= "<a href=\"$targetpage?page=$counter \">$counter &nbsp;</a>";
}
}
elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some
{
//close to beginning; only hide later pages
if($page < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter &nbsp;</span>";
else
$pagination.= "<a href=\"$targetpage?page=$counter \">$counter &nbsp;</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"$targetpage?page=$lpm1 \">$lpm1 &nbsp;</a>";
$pagination.= "<a href=\"$targetpage?page=$lastpage \">$lastpage &nbsp;</a>";
}
//in middle; hide some front and some back
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination.= "<a href=\"$targetpage?page=1 \">1 &nbsp;</a>";
$pagination.= "<a href=\"$targetpage?page=2 \">2 &nbsp;</a>";
$pagination.= "...";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter &nbsp;</span>";
else
$pagination.= "<a href=\"$targetpage?page=$counter \">$counter &nbsp;</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"$targetpage?page=$lpm1 \">$lpm1 &nbsp;</a>";
$pagination.= "<a href=\"$targetpage?page=$lastpage \">$lastpage &nbsp;</a>";
}
//close to end; only hide early pages
else
{
$pagination.= "<a href=\"$targetpage?page=1 \">1 &nbsp;</a>";
$pagination.= "<a href=\"$targetpage?page=2 \">2 &nbsp;</a>";
$pagination.= "...";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter &nbsp;</span>";
else
$pagination.= "<a href=\"$targetpage?page=$counter \">$counter &nbsp;</a>";
}
}
}
//next button
if ($page < $counter - 1)
$pagination.= "<a href=\"$targetpage?page=$next \">Next  &nbsp;</a>";
else
$pagination.= "<span class=\"disabled\">Next &nbsp;</span>";
$pagination.= "</div>\n";
}

	  $qur="SELECT * FROM ".$PRODUCT." order by `serial` asc  LIMIT $start, $limit"; 
		$result = mysql_query($qur)or die('Have an error in viewing data'.mysql_error());
		while ($row_section = mysql_fetch_array($result)) 
			{
	   $serial=$row_section['serial'];
	   $category=$row_section['category'];
	   $sub_category=$row_section['sub_category'];
	   $sub_sub_cat=$row_section['sub_sub_cat'];
	   $name=$row_section['name'];
	   $description=$row_section['description'];
	   $price=$row_section['price'];
	   $quantity=$row_section['quantity'];
	    $product_id=$row_section['product_id'];
	   $offper=$row_section['offper'];
	   $small_jpg=$row_section['small_jpg'];
	   $in_price=$row_section['in_price'];
	   $sale_tax=$row_section['sale_tax'];
	   $tax_percen=$row_section['tax_percen'];
	   $pur_price=$row_section['pur_price'];
	   $tname=$row_section['tname'];
			  ?>	    
				 
			    <tr> 
    				<td><?php echo $i=$i+1; ?></td>
                    <td><?php echo $category; ?></td>
                    <!--<td><?php echo $sub_category; ?></td>
                    <td><?php echo $sub_sub_cat; ?></td>-->
                     <td><?php echo $product_id; ?></td>
                    <td><?php echo $name; ?></td>
                    <td><?php echo $tax_percen; ?></td>
                    <td><?php echo $quantity; ?></td>                   
                    <td><?php //echo $corrrency;?> <?php echo $pur_price; ?></td>
                    <td><?php //echo $corrrency;?> <?php echo $in_price; ?></td>
                   <!-- <td><?php //echo $corrrency;?> <?php echo $sale_tax; ?></td>
                    <td><?php //echo $corrrency;?> <?php echo $price; ?></td>-->
                    <td><img src="<?php echo $small_jpg; ?>" border="0" height="30" widtd="60"/></td>
                                       
   				  <td><a href="editproduct2.php?id=<?php echo $row_section['serial'];?>">
                    <input type="image" src="images/edit.jpg" title="Edit" widtd="20" height="15"></a>
                    
                     <a href="deleteproduct.php?id=<?php echo $row_section['serial'];?>&&imgname=<? echo $small_jpg; ?>" 
                     onClick="return confirm('Are you sure you want to delete?')">
                     <input type="image" src="images/delete.jpg" title="Delete" widtd="20" height="15"></a></td> 
				</tr> 	 
				 
<?php } ?> 
 
			</tbody> 
			</table>
            
   
        </div>
        <div align="right"><?php echo $pagination; ?> 	</div>	
      </div>
      
      
    </div>
  </div>
</div>
<!--[if IE]>
<script type="text/javascript" src="view/javascript/jquery/flot/excanvas.js"></script>
<![endif]--> 
<script type="text/javascript" src="view/javascript/jquery/flot/jquery.flot.js"></script> 
<script type="text/javascript"><!--
function getSalesChart(range) {
	$.ajax({
		type: 'get',
		url: 'index.php?route=common/home/chart&token=b735cc089ec2d51abb9a8e1901f501fb&range=' + range,
		dataType: 'json',
		async: false,
		success: function(json) {
			var option = {	
				shadowSize: 0,
				lines: { 
					show: true,
					fill: true,
					lineWidtd: 1
				},
				grid: {
					backgroundColor: '#FFFFFF'
				},	
				xaxis: {
            		ticks: json.xaxis
				}
			}

			$.plot($('#report'), [json.order, json.customer], option);
		}
	});
}

getSalesChart($('#range').val());
//--></script> 
</div>
<?  include("footer.php"); ?>