<?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_purtax_date.php?sdate=<? echo $start_date ?>&&edate=<? echo $end_date ?>';		
				</script>
            
            <?
			
	
	 //header("Location:view_purtax_date.php?sdate=$start_date&&edate=$end_date");
 }
?>

<!----------------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">
       <!-- <a href="http://amarasudhan.com/admin/index.php?route=common/home&amp;token=b735cc089ec2d51abb9a8e1901f501fb">Home</a>-->
      </div>
              <div class="box">
    <div class="heading">
      <h1><img src="view/image/home.png" alt="" />Purchase Return Details</h1>
    </div>
    <div class="content">
      <div class="overview" style="width:80%; margin-left:200px;">
        <div class="dashboard-heading"> Purchase Return Details</div>
        <div class="dashboard-content">
        
<!--Message Display-->	
<?php
if($_REQUEST['add'] == 'success') {echo $result= '<h4 class="alert_success">Purchase Details Are Added Successfully </h4>';}

elseif($_REQUEST['add'] == 'fail'){echo $result= '<h4 class="alert_error">Purchase Already Exit</h4>';}

if($_REQUEST['edit'] == 'success') {echo $result= '<h4 class="alert_success">Purchase Details Are Edited Successfully </h4>';}

elseif($_REQUEST['edit'] == 'fail'){echo $result= '<h4 class="alert_error">Purchase Already Exit</h4>';}

if($_REQUEST['delete'] == 'success') {echo $result= '<h4 class="alert_success">Purchase Details Are Deleted Successfully </h4>';}

?>	

  

 

  <table class="list" cellspacing="0" > 
			<thead> 
                 <tr>
                    
                    <td class="left">PID</td>
                    <td class="left">Supplier Name</td>
                    <td class="left">TIN No</td>
                    <td class="left">Bill No</td>
                    <td class="left">Purchace Date</td>
                    <td class="left">Total Tax</td>
                    
                         
              </tr>
              </thead>
			
			<tbody> 
           
				 
			<?php 
			$dis1=("select count(*) as num  from purchase_tax");		
		$total_pages = mysql_fetch_array(mysql_query($dis1));


    $total_pages = $total_pages[num];


$targetpage =""; //your file name (the name of this file)
$limit = 10; //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;s</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"$targetpage?page=$lpm1 \">$lpm1 &nbsp;</a>";
$pagination.= "<a href=\"$targetpage?page=$lastpage \">$lastpage &nbsp;s</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 purchase_tax 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'];
                   $id=base64_encode($id);
                   $product_id= $row_section['product_id'];
				  
					$supplier_name= $row_section['supplier_name'];
					$bill_num= $row_section['bill_num'];
					$tin_num= $row_section['tin_num'];
				  	$purchase_date= $row_section['purchase_date'];
					$tot_tax= $row_section['tot_tax'];
			  ?>	    
				 
			    <tr> 
                
                <td class="left"><?php echo $product_id; ?> </td>                
                <td class="left"><?php echo $supplier_name; ?> </td>
                <td class="left"><?php echo $tin_num; ?> </td>
                <td class="left"><?php echo $bill_num; ?> </td>
                <td class="left"><?php echo $purchase_date; ?> </td>
                <td class="left">Rs.<?php echo $tot_tax; ?> </td>
				</tr> 	 
				 
<?php } ?> 
 
			</tbody> 
            
			</table>
            
   
        </div>
        <div align="right"><?php echo $pagination; ?> 	</div>	
      </div>
      
      <form method="post" id="client" enctype="multipart/form-data" action="">
  			<!--<script type="text/javascript" src="../prototype.js"></script> 
  			<script type="text/javascript" src="../validation.js"></script>-->
  
           	    <div style="width:900px; margin-left:100px;">
                <div class="mainrow" style="margin-left:100px;">
                <div class="maintext"></div>
                <div class="maintextbox"><h3>View Purchase Tax by date</h3></div>
                </div>
                 <br />
                <div class="mainrow" style="margin-left:100px;">
                <div class="maintext">Start Date<font color="#FF0000"><b> *</b></font> </div>
                <div class="maintextbox">
                <input type="text" required class="TextBox" name="from_date" id="f_date_b1">
				<img src="images/cal.gif" id="f_trigger_b1" >
				<script type="text/javascript">
				Calendar.setup({inputField :"f_date_b1",ifFormat:"%Y-%m-%d",showsTime:true,button:"f_trigger_b1",singleClick:true});
				</script>
                </div>
                </div>
                 <br />
                <div class="mainrow" style="margin-left:100px;">
                <div class="maintext">End Date<font color="#FF0000"><b> * </b></font> </div>
                <div class="maintextbox">
                <input type="text" required class="TextBox" name="to_date" id="f_date_b2">
				<img src="images/cal.gif" id="f_trigger_b2" >
				<script type="text/javascript">
				Calendar.setup({inputField :"f_date_b2",ifFormat:"%Y-%m-%d",showsTime:true,button:"f_trigger_b2",singleClick:true});
				</script>
                </div>                 
                </div>
                <br />
                <div class="mainrow" style="margin-left:100px;">
    			<div class="maintext"><font color="#FF0000"><b></b></font> </div>
                <div class="maintextbox"><input type="submit" name="submit"value="Submit" ></div>
                </div>
                </div>
 				</form>
      
      
    </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,
					lineWidth: 1
				},
				grid: {
					backgroundColor: '#FFFFFF'
				},	
				xaxis: {
            		ticks: json.xaxis
				}
			}

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

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