<?PHP 
include("header.php");
//session_start();
//error_reporting(0);

include "checksession.php";

include ("include/db-connect.php");

if(isset($_REQUEST['submit']))
 {
	  $bname=$_REQUEST['bname'];
	  $account=$_REQUEST['account'];
	  $aname=$_REQUEST['aname'];
	  $branch=$_REQUEST['branch'];
	  $ifsc=$_REQUEST['ifsc'];
	   //upload file1
	   $small_jpg=$_FILES['small_jpg']['name'];
	   $viewid="select * from ".$PRODUCT." order by `serial` desc";
       $resultid=mysql_query($viewid);
	   $rowid= mysql_fetch_row($resultid);
	  
	     $id=$rowid[0];
		if(!$id)
		{
		$id=$id;
		}
		else
		{
		$id=$id+1;
		}
	 
	$filename=$id.$small_jpg;
    $uploaddir = 'sample/';
    $uploadfile = $uploaddir . $filename;
	move_uploaded_file($_FILES['small_jpg']['tmp_name'], $uploadfile);
	 //end  

    $insert=("insert into bank_det(bname,account,aname,branch,ifsc,image)
			values ('$bname','$account','$aname','$branch','$ifsc','$uploadfile')");
 
    $exce=mysql_query($insert);
		                   
						   ?>
                           <script>
						   window.location='add_product.php?add=success';
						   </script>
                           <?
   // header("location:add_product.php?add=success"); 
}
 ?>
  <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="" />Offer Details</h1>
    </div>
    <div class="content">
      <div class="overview" style="width:80%; margin-left:200px;">
        <div class="dashboard-heading"> Offer Details</div>
        <div class="dashboard-content">
        
 
  <?php
if($_REQUEST['add'] == 'success') {echo $result= '<h4 class="alert_success"> Added Successfully </h4>';}

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

?>	
 

  <table class="list" cellspacing="0" > 
			<thead> 
                 <tr>
                 
                 
                    <td class="left">S.No</td>
                    <td class="left">Product ID</td>
                    <td class="left">Name</td> 
                    <td class="left">Original Price</td> 
                    <td class="left">Price</td>
                    <td class="left">Offer</td>
                    <td class="left">Small Picture</td>
                    <td class="left">Actions</td>
              </tr>
              </thead>
			
			<tbody> 
           
				 
			   <?php 
			
		
			 $dis1=("select count(*) as num  from ".$PRODUCT." where offer='offer' and offper>'0'");		
		$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 = 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 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;</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." where offer='offer' and offper>'0' order by serial 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)) 
			{
			   
	   $serial=$row_section['serial'];
	   
	   $category=$row_section['category'];
	
	   $sub_category=$row_section['sub_category'];
	   $name=$row_section['name'];
	   $description=$row_section['description'];
	   $price=$row_section['price'];
	   $product_id=$row_section['product_id'];
	   
	   $details=$row_section['details'];
	   $offper=$row_section['offper'];
	   $org_price=$row_section['org_price'];
	   $small_jpg=$row_section['small_jpg'];
	   
	   
							
			  ?>	    
				 
			    <tr> 
   					
    				<td class="left"><?php echo $serial; ?></td>
                    <td class="left"><?php echo $product_id; ?></td> 
                    <td class="left"><?php echo $name; ?></td> 
                    <td>&#x20B9;<?php echo $org_price; ?></td> 
                    <td class="left">&#x20B9;<?php echo $price; ?></td>  
                    <td class="left"><?php echo $offper; ?>%</td>   
                    <td class="left"><img src="<?php echo $small_jpg; ?>" border="0" height="30" width="50"/></td>
                                       
                                        
                                      
   				  <td class="left"><a href="eit_offer.php?id=<?php echo $row_section['serial'];?>">
                    <input type="image" src="images/edit.jpg" title="Edit" width="20" height="20"></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,
					lineWidth: 1
				},
				grid: {
					backgroundColor: '#FFFFFF'
				},	
				xaxis: {
            		ticks: json.xaxis
				}
			}

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

getSalesChart($('#range').val());
//--></script> 
</div>
<div id="footer">Copyright &copy; 2014 | Powered by <a href="http://linikantech.com/" target="_blank">Linikantech</a><!--<a href="http://www.opencart.com">OpenCart</a> &copy; 2009-2016 All Rights Reserved.<br />Version 1.5.6.4--></div>
</body></html>