<?PHP
include("header.php");
//include "checksession.php";
//include "include/db-connect.php";
/*if(isset($_REQUEST['submit']))
 {
	 $start_date=$_REQUEST['from_date'];
	 $end_date=$_REQUEST['to_date']; 
	 header("Location:view_sales_profit.php?sdate=$start_date&&edate=$end_date");
 }*/

 ?>
  <div id="content">
  <div class="breadcrumb">
      </div>
              <div class="box">
    <div class="heading">
      <h1><img src="view/image/home.png" alt="" />Customer Details</h1>
    </div>
    <div class="content">
      <div class="overview" style="width:80%; margin-left:170px;">
        <div class="dashboard-heading">  <h3 class="tabs_involved" style="margin-left:5px; color:#FFF;">
          <?php 
          $dis1="select COUNT(*) as num  from ".$FLOGIN."";		
		$total_pages = mysql_fetch_array(mysql_query($dis1));
		$adjacents = 3;
        $total_pages = $total_pages[num];
		?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Total Customers - <?php echo $total_pages;?>
        </h3></div>
        <div class="dashboard-content">
<?php
if($_REQUEST['add'] == 'success') {echo $result= '<h4 class="alert_success">Category Added Success </h4>';}
if($_REQUEST['edit'] == 'sucess') {echo $result= '<h4 class="alert_success">Category Edited Success </h4>';}
if($_REQUEST['deactive'] == 'success') {echo $result= '<h4 class="alert_success">Deactivated Successfully </h4>';}
if($_REQUEST['delete'] == 'sucess') {echo $result= '<h4 class="alert_success">Category Deleted Success </h4>';}
?>

  <table class="list" cellspacing="0" > 
			<thead> 
                 <tr>
                    <th class="left">S.No</th>
    				<th class="left">Name</th> 
    				<th class="left">Username</th> 
                    <th class="left">Password</th>
                    <th class="left">Phone</th> 
                    <th class="left">Address</th>
                    <th class="left">Timestamp</th> 
                    <th class="left">Status</th>    
                    <th class="left">Delete</th>       
              </tr>
              </thead>
			<tbody> 
			 <?php 
		$dis1="select COUNT(*) as num  from ".$FLOGIN."";		
		$total_pages = mysql_fetch_array(mysql_query($dis1));
		$adjacents = 3;
        $total_pages = $total_pages[num];
$targetpage = ""; //your file name (the name of this file)
$limit = 40; //how many items to show per page
$page = $_GET['page'];
if($page)
$start = ($page - 1) * $limit; //first item to display on this 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 bother 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;s</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 ".$FLOGIN." order by `id` desc LIMIT $start, $limit"; 
		$result = mysql_query($qur)or die('Have an error in viewing data'.mysql_error());
		while ($row_section = mysql_fetch_array($result)) 

			{
			    $id=$row_section['id'];
				$name=$row_section['name'];
				$username=$row_section['username'];
				$password=$row_section['password'];
				$door_no=$row_section['door_no'];
				$locality=$row_section['locality'];
				$street=$row_section['street'];
				$state=$row_section['state'];
				$city=$row_section['city'];
				$district=$row_section['district'];
				$pincode=$row_section['pincode'];
				$phone=$row_section['phone'];
				$code=$row_section['code'];
			  ?>	    
			    <tr> 
   					<td class="left"><?php echo $id;?></td> 
    				<td class="left"><?php  echo $name; ?></td>
   				 	<td class="left"><?php echo $username; ?></td>
                     <td class="left"><?php echo $password; ?></td>
                     <td class="left"><?php echo $phone; ?></td>
                      <td class="left">
					  <?php echo $door_no; ?><?php echo $door_no; ?><?php echo $locality; ?><?php echo $street; ?><?php echo $city; ?><?php echo $district; ?><?php echo $pincode; ?></td>
                      <td><? echo $row_section['date']; ?>, <? echo $row_section['time']; ?></td>
                     <td class="left">
                     <?php if($code==0){?>
                     <img src="images/delete1.jpg" width="20" />
                     <?php } else{ ?>
                     <img src="images/Check-icon.png" width="20" />
                     <?php } ?>
                     </td>
                    <td class="left"><a href="delete_customers.php?id=<?php echo $id; ?>" onClick="return confirm('Do you want to Delete?...')"><img src="images/icn_logout.png" width="20" height="20"></a></td> 
				</tr> 	 
<?php } ?> 
			</tbody> 
			</table>
        </div>
        <div align="right"><?php echo $pagination; ?> 	</div>	
      </div>
    </div>
  </div>
</div>
</div>
<?  include("footer.php"); ?>