<?PHP 
include("header.php");
//session_start();
//error_reporting(0);
include "checksession.php";
include "include/db-connect.php";
if(isset($_REQUEST['submit']))
 {
	$start_date=$_REQUEST['from_date'];
	 $end_date=$_REQUEST['to_date']; 
	  ?>
     <script>
	 window.location='view_sales_tax1.php?sdate=<? echo $start_date ?>&&edate=<? echo $end_date ?>';
	 </script>
     <? } ?>


<!----------------Start Date Picker Code-------->
<script type="text/javascript" src="JavaScript/calendar.js">
</script>
<script type="text/javascript" src="JavaScript/calendar-en.js">
</script>
<script type="text/javascript" src="JavaScript/calendar-setup.js">
</script>
<link rel="stylesheet" type="text/css" media="all" href="JavaScript/calendar-win2k-cold-1.css" title="win2k-cold-1" />
<!----------------End Date Picker Code-------->

  <div id="content">
  <div class="breadcrumb">
      </div>
              <div class="box">
    <div class="heading">
      <h1><img src="view/image/home.png" alt="" /> Payment Management</h1>
    </div>
    <div class="content">
      <div class="overview" style="width:93%; margin-left:70px;">
        <div class="dashboard-heading"> 
		Payment Details
        </div>
        <div class="dashboard-content">
        
<?php
if($_REQUEST['add'] == 'success') {echo $result= '<h4 class="alert_success">Client Details Are Added Successfully </h4>';}
if($_REQUEST['edit'] == 'success') {echo $result= '<h4 class="alert_success">Client Details Are Edited Successfully </h4>';}
if($_REQUEST['deac'] == 'success') {echo $result= '<h4 class="alert_success">Account Deactivated Successfully </h4>';}
?>	
																																				        
 <?php 
		    $start_date=$_REQUEST['sdate'];
            $end_date=$_REQUEST['edate'];
			  $dis1=("select count(*) as num  from purchase_tax where purchase_date Between '$start_date' and '$end_date'");		
		     $total_pages = mysql_fetch_array(mysql_query($dis1));
             $total_pages = $total_pages[num];
	        {
?>
<?php } ?>
 

  <table class="list" cellspacing="0" > 
			<thead> 
                 <tr>
                     <td class="left">Date</td>
                     <td class="left">Supplier Name</td>
                     <td class="left">Amount</td>
                     <td class="left">Pay Option</td>
                     <td class="left">Cheque No</td>
                     <td class="left">Reason</td>
              </tr>
              </thead>
			
			<tbody> 
      <?php 
			$dis1=("select count(*) as num  from ".$pay."");		
		    $total_pages = mysql_fetch_array(mysql_query($dis1));
			$total_pages = $total_pages[num];
$targetpage =""; //your file name (the name of this file)
$limit = 30; //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 ($page == 0) $page = 1; 
$prev = $page - 1; 
$next = $page + 1; 
$lastpage = ceil($total_pages/$limit);
$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;</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</a>";
else
$pagination.= "<span class=\"disabled\">Next</span>";
$pagination.= "</div>\n";
}

if($total_pages!=0)
{
		$qur="select * from ".$pay." 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'];
                    $Supplier_Name= $row_section['Supplier_Name'];             
				  	$Amount= $row_section['Amount'];
					$billno= $row_section['billno'];
					
					$Payment_option= $row_section['Payment_option'];
				  	$Cheque_No= $row_section['Cheque_No'];
					$pay_method= $row_section['pay_method'];
				 	$date= $row_section['date'];
					$pay_reason= $row_section['pay_reason'];
			  ?>	    
			    <tr> 
                <td class="left"><?php echo $date; ?> </td>
                 <td class="left"><?php echo ucwords($row_section['Supplier_Name']); ?> </td>
                <td class="left"><?php echo $Amount; ?> </td>
                <td class="left"><?php echo $Payment_option; ?> </td>
                <td class="left"><?php echo $Cheque_No; ?> </td>
                <td class="left"><?php echo $pay_reason; ?> </td>
               </tr> 	 
<?php } } else { echo "<div style='margin-left:400px; color:red; margin-top:30px; margin-bottom:20px;'>No Data Found</div>";}?> 
			</tbody> 
			</table>
        </div>
        <div align="right"><?php echo $pagination; ?> 	</div>	
      </div>
                </div></div>
 				</form>
                 <script type="text/javascript">
						function formCallback(result, form) 
						{
							window.status = "valiation callback for form '" + form.id + "': result = " + result;
						}
						var valid = new Validation('profit_id', {immediate : true, onFormValidate : formCallback});
					</script>
      </div></div></div>
    </div>
  </div>
</div>
</div>
<?  include("footer.php"); ?>