<?php
include("include/config.php");
include("include/protect.class.php");
include("include/jdf.php");
include('include/functions.php');
$prot=new protect();
if ($prot->showPage) {
$db=new DB($globalConfig['dbase'], $globalConfig['dbhost'],$globalConfig['dbuser'], $globalConfig['dbpass']);
mysql_query("SET NAMES utf8");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>درخواست های مدارک</title>
<link rel="stylesheet" type="text/css" href="fancybox/jquery.fancybox-1.3.1.css" media="screen" />
<script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
<script type="text/javascript" src="fancybox/jquery.fancybox-1.3.1.js"></script>
<?php include("maintemplate/mainheader.php");?>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script language="JavaScript" src="maintemplate/js/gen_validatorv4.js" type="text/javascript" xml:space="preserve"></script>
<script type="text/javascript" charset="utf-8">

	function getcat (){
		var part_id = $("#part_id").val();
		
		$(document).ready(function (){
			
			
			$("#loading").fadeIn("slow",function(){
});
			$.ajax({
				type: "POST",
				url: "send_ajax_chitasoft.php?act=getcat",
				dataType: "html",
				data: "part_id="+part_id,
				success: function(data){
					$("#cat_id").html(data);
					 $("#loading").fadeOut("slow");
				}
			
			});
 
        
       	
    
		});
	}
	
</script>
</head>
<body>
<div id="wpwrap">
<div id="wpcontent">
	<?php include("include/menutop.php");?> 
<div id="wpbody">
	<?php include("include/header.php");?>
    <div style="overflow:hidden; padding-bottom:50px;" id="wpbody-content">
        <div id="screen-meta">
            <div class="wrap">
                <div id="icon-index" class="icon32"><b4r></div>
                <h2>نتایج آزمون کاربران</h2>
               
                <div id="dashboard-widgets-wrap">
                    <div id="dashboard-widgets" class="metabox-holder">
              		<div class="postbox-container" style="width:38%;">
                            <div id="normal-sortables" class="meta-box-sortables ui-sortable"><div id="dashboard_recent_comments" class="postbox ">
                   			<div class="handlediv" title="برای جانشینی کلیک کنید"><br></div>
                   			<h3 class="hndle"><span>فیلتر تاریخ</span></h3>
                   <form action="certificate.php?detail" method="post">
                                     <table class="form-table">
<tbody>
<tr class="even" valign="top">
<th scope="row"><label for="from">از تاریخ</label></th>
<td>
<select id="from" name="fromday">
	
    
	<option value="1"><?php echo Convertnumber2farsi(1);?></option>
    <option value="2"><?php echo Convertnumber2farsi(2);?></option>
    <option value="3"><?php echo Convertnumber2farsi(3);?></option>
    <option value="4"><?php echo Convertnumber2farsi(4);?></option>
    <option value="5"><?php echo Convertnumber2farsi(5);?></option>
    <option value="6"><?php echo Convertnumber2farsi(6);?></option>
    <option value="7"><?php echo Convertnumber2farsi(7);?></option>
    <option value="8"><?php echo Convertnumber2farsi(8);?></option>
    <option value="9"><?php echo Convertnumber2farsi(9);?></option>
    <option value="10"><?php echo Convertnumber2farsi(10);?></option>
    <option value="11"><?php echo Convertnumber2farsi(11);?></option>
    <option value="12"><?php echo Convertnumber2farsi(12);?></option>
    <option value="13"><?php echo Convertnumber2farsi(13);?></option>
    <option value="14"><?php echo Convertnumber2farsi(14);?></option>
    <option value="15"><?php echo Convertnumber2farsi(15);?></option>
    <option value="16"><?php echo Convertnumber2farsi(16);?></option>
    <option value="17"><?php echo Convertnumber2farsi(17);?></option>
    <option value="18"><?php echo Convertnumber2farsi(18);?></option>
    <option value="19"><?php echo Convertnumber2farsi(19);?></option>
    <option value="20"><?php echo Convertnumber2farsi(20);?></option>
    <option value="21"><?php echo Convertnumber2farsi(21);?></option>
    <option value="22"><?php echo Convertnumber2farsi(22);?></option>
    <option value="23"><?php echo Convertnumber2farsi(23);?></option>
    <option value="24"><?php echo Convertnumber2farsi(24);?></option>
    <option value="25"><?php echo Convertnumber2farsi(25);?></option>
    <option value="26"><?php echo Convertnumber2farsi(26);?></option>
    <option value="27"><?php echo Convertnumber2farsi(27);?></option>
    <option value="28"><?php echo Convertnumber2farsi(28);?></option>
    <option value="29"><?php echo Convertnumber2farsi(29);?></option>
    <option value="30"><?php echo Convertnumber2farsi(30);?></option>
    <option value="31"><?php echo Convertnumber2farsi(31);?></option>
  
    
</select>
<select id="frommonth" name="frommonth">
	<option value="1" >فروردین</option>
    <option value="2" >اردیبهشت</option>
    <option value="3" >خرداد</option>
    <option value="4" >تیر</option>
    <option value="5" >مرداد</option>
    <option value="6" >شهریور</option>
    <option value="7" >مهر</option>
    <option value="8" >آبان</option>
    <option value="9" >آذر</option>
    <option value="10" >دی</option>
    <option value="11" >بهمن</option>
    <option value="12" >اسفند</option>
</select>
<select id="fromyear" name="fromyear">
<option value="1389"><?php echo Convertnumber2farsi(89); ?></option>
<option value="1390"><?php echo Convertnumber2farsi(90); ?></option>
<option value="1391"><?php echo Convertnumber2farsi(91); ?></option>
<option value="1392"><?php echo Convertnumber2farsi(92); ?></option>
<option value="1393"><?php echo Convertnumber2farsi(93); ?></option>
<option value="1394"><?php echo Convertnumber2farsi(94); ?></option>
<option value="1395"><?php echo Convertnumber2farsi(95); ?></option>
<option value="1396"><?php echo Convertnumber2farsi(96); ?></option>
<option value="1397"><?php echo Convertnumber2farsi(97); ?></option>
<option value="1398"><?php echo Convertnumber2farsi(98); ?></option>
<option value="1399"><?php echo Convertnumber2farsi(99); ?></option>
</select>
</td>
</tr>
<tr class="odd" valign="top">
<th scope="row"><label for="to">تا تاریخ</label></th>
<td>

<select id="to" name="today">
	
    
	<option value="1"><?php echo Convertnumber2farsi(1);?></option>
    <option value="2"><?php echo Convertnumber2farsi(2);?></option>
    <option value="3"><?php echo Convertnumber2farsi(3);?></option>
    <option value="4"><?php echo Convertnumber2farsi(4);?></option>
    <option value="5"><?php echo Convertnumber2farsi(5);?></option>
    <option value="6"><?php echo Convertnumber2farsi(6);?></option>
    <option value="7"><?php echo Convertnumber2farsi(7);?></option>
    <option value="8"><?php echo Convertnumber2farsi(8);?></option>
    <option value="9"><?php echo Convertnumber2farsi(9);?></option>
    <option value="10"><?php echo Convertnumber2farsi(10);?></option>
    <option value="11"><?php echo Convertnumber2farsi(11);?></option>
    <option value="12"><?php echo Convertnumber2farsi(12);?></option>
    <option value="13"><?php echo Convertnumber2farsi(13);?></option>
    <option value="14"><?php echo Convertnumber2farsi(14);?></option>
    <option value="15"><?php echo Convertnumber2farsi(15);?></option>
    <option value="16"><?php echo Convertnumber2farsi(16);?></option>
    <option value="17"><?php echo Convertnumber2farsi(17);?></option>
    <option value="18"><?php echo Convertnumber2farsi(18);?></option>
    <option value="19"><?php echo Convertnumber2farsi(19);?></option>
    <option value="20"><?php echo Convertnumber2farsi(20);?></option>
    <option value="21"><?php echo Convertnumber2farsi(21);?></option>
    <option value="22"><?php echo Convertnumber2farsi(22);?></option>
    <option value="23"><?php echo Convertnumber2farsi(23);?></option>
    <option value="24"><?php echo Convertnumber2farsi(24);?></option>
    <option value="25"><?php echo Convertnumber2farsi(25);?></option>
    <option value="26"><?php echo Convertnumber2farsi(26);?></option>
    <option value="27"><?php echo Convertnumber2farsi(27);?></option>
    <option value="28"><?php echo Convertnumber2farsi(28);?></option>
    <option value="29"><?php echo Convertnumber2farsi(29);?></option>
    <option value="30"><?php echo Convertnumber2farsi(30);?></option>
    <option value="31"><?php echo Convertnumber2farsi(31);?></option>
  
    
</select>
<select id="tomonth" name="tomonth">
	<option value="1" >فروردین</option>
    <option value="2" >اردیبهشت</option>
    <option value="3" >خرداد</option>
    <option value="4" >تیر</option>
    <option value="5" >مرداد</option>
    <option value="6" >شهریور</option>
    <option value="7" >مهر</option>
    <option value="8" >آبان</option>
    <option value="9" >آذر</option>
    <option value="10" >دی</option>
    <option value="11" >بهمن</option>
    <option value="12" >اسفند</option>
</select>
<select id="toyear" name="toyear">
<option value="1389"><?php echo Convertnumber2farsi(89); ?></option>
<option value="1390"><?php echo Convertnumber2farsi(90); ?></option>
<option value="1391"><?php echo Convertnumber2farsi(91); ?></option>
<option value="1392"><?php echo Convertnumber2farsi(92); ?></option>
<option value="1393"><?php echo Convertnumber2farsi(93); ?></option>
<option value="1394"><?php echo Convertnumber2farsi(94); ?></option>
<option value="1395"><?php echo Convertnumber2farsi(95); ?></option>
<option value="1396"><?php echo Convertnumber2farsi(96); ?></option>
<option value="1397"><?php echo Convertnumber2farsi(97); ?></option>
<option value="1398"><?php echo Convertnumber2farsi(98); ?></option>
<option value="1399"><?php echo Convertnumber2farsi(99); ?></option>
</select>
<input type="hidden" name="product" value="<?php echo $_GET['product'];?>" />
</td>
</tr>
</tbody>
</table>
<p class="submit" align="center">
<input name="process" class="button-primary" value="نمایش گزارش" type="submit">
</p>
                                     </form>
                    </div>
                            </div>
                        </div>
					<div class="postbox-container" style="width:98%;">
                                <div id="normal-sortables" class="meta-box-sortables ui-sortable"><div id="dashboard_recent_comments" class="postbox ">
                                   <div class="handlediv" title="برای جانشینی کلیک کنید"><br></div><h3 class="hndle"><span>درخواست های مدارک</span></h3>
                             <div align="center" style="padding:5px;">
                                               
<table id="rounded-corner"dir="rtl">

  <thead>
			<tr>
            	<th scope="col" id="rounded-q5"></th>
                <th scope="col" id="rounded-q5">نام کاربران</th>
                <th scope="col" id="rounded-q5">دوره</th>
                <th scope="col" id="rounded-q5">تاریخ</th>
                <th scope="col" id="rounded-q5">نوع تحویل</th>
			</tr>
		</thead>
		<tbody>
<?php
	/*
		Place code to connect to your DB here.
	*/
	// include your code to connect to DB.

	$tbl_name="certificate";		//your table name
	// How many adjacent pages should be shown on each side?
	$adjacents = 3;
	
	/* 
	   First get total number of rows in data table. 
	   If you have a WHERE clause in your query, make sure you mirror it here.
	*/
	if(isset($_GET['detail'])){
	$fromdatearr=jalali_to_gregorian($_POST['fromyear'],$_POST['frommonth'],$_POST['fromday'],'/');
	$fromdate=$fromdatearr[0].'-'.$fromdatearr[1].'-'.$fromdatearr[2];
	
	$todatearr=jalali_to_gregorian($_POST['toyear'],$_POST['tomonth'],$_POST['today'],'/');
	$todate=$todatearr[0].'-'.$todatearr[1].'-'.$todatearr[2];
	$query = "SELECT COUNT(*) as num FROM $tbl_name where date between '".$fromdate."' and '".$todate."'";
	}else{
	$query = "SELECT COUNT(*) as num FROM $tbl_name";
	}
	$total_pages = mysql_fetch_array(mysql_query($query));
	$total_pages = $total_pages[num];
	
	/* Setup vars for query. */
	$targetpage = "certificate.php"; 	//your file name  (the name of this file)
	$limit = 20; 								//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
	
	/* Get data. */
if(isset($_GET['detail'])){
	$fromdatearr=jalali_to_gregorian($_POST['fromyear'],$_POST['frommonth'],$_POST['fromday'],'/');
	$fromdate=$fromdatearr[0].'-'.$fromdatearr[1].'-'.$fromdatearr[2];
	
	$todatearr=jalali_to_gregorian($_POST['toyear'],$_POST['tomonth'],$_POST['today'],'/');
	$todate=$todatearr[0].'-'.$todatearr[1].'-'.$todatearr[2];
	$sql = "SELECT * FROM $tbl_name where date between '".$fromdate."' and '".$todate."' ORDER BY id DESC LIMIT $start, $limit";
	}else{
	$sql = "SELECT * FROM $tbl_name ORDER BY id DESC LIMIT $start, $limit";	
	}
	$result = mysql_query($sql);
	
	/* Setup page vars for display. */
	if ($page == 0) $page = 1;					//if no page var is given, default to 1.
	$prev = $page - 1;							//قبلی page is page - 1
	$next = $page + 1;							//بعدی 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
	
	/* 
		Now we apply our rules and draw the pagination object. 
		We're actually saving the code to a variable in case we want to draw it more than once.
	*/
	$pagination = "";
	if($lastpage > 1)
	{	
		$pagination .= "<div class=\"pagination\">";
		//قبلی button
		if ($page > 1) 
			$pagination.= "<a href=\"$targetpage?page=$prev\">« قبلی</a>";
		else
			$pagination.= "<span class=\"disabled\">« قبلی</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</span>";
				else
					$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</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</span>";
					else
						$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";					
				}
				$pagination.= "...";
				$pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
				$pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";		
			}
			//in middle; hide some front and some back
			elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
			{
				$pagination.= "<a href=\"$targetpage?page=1\">1</a>";
				$pagination.= "<a href=\"$targetpage?page=2\">2</a>";
				$pagination.= "...";
				for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
				{
					if ($counter == $page)
						$pagination.= "<span class=\"current\">$counter</span>";
					else
						$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";					
				}
				$pagination.= "...";
				$pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
				$pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";		
			}
			//close to end; only hide early pages
			else
			{
				$pagination.= "<a href=\"$targetpage?page=1\">1</a>";
				$pagination.= "<a href=\"$targetpage?page=2\">2</a>";
				$pagination.= "...";
				for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
				{
					if ($counter == $page)
						$pagination.= "<span class=\"current\">$counter</span>";
					else
						$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";					
				}
			}
		}
		
		//بعدی button
		if ($page < $counter - 1) 
			$pagination.= "<a href=\"$targetpage?page=$next\">بعدی »</a>";
		else
			$pagination.= "<span class=\"disabled\">بعدی »</span>";
		$pagination.= "</div>\n";		
	}
?>

	<?php
		while($row = mysql_fetch_array($result))
		{
				if($data['visited'] == 0){
			$sytle = 'style="color:#390"';
		}else{
			$style = '';
		}
		if(($i % 2) == 0) {
			$class = 'tableRow2';
		}else{
			$class = 'tableRow1';
		}
			echo '<tr class="'.$class.'" onmouseover="this.className=\'tableRowOver\'" onmouseout="this.className=\''.$class.'\'">';
			
?>
					
<form action="convert"> 
		<td ><?php echo $row['id'];?></td>
        <td ><?php $sql = $db->query("select * from u_users where ID='".(int)$row['userid']."'");
				   $res = $db->fetchNextArray($sql);
				   echo '<a href="user_list.php?act=show&uid='.$row['userid'].'">'.$res['lastName'].'</a>';?></td>
        
        <td ><?php $sql = $db->query("select * from priod where id='".(int)$row['priodid']."'");
				   $res = $db->fetchNextArray($sql);
				   echo $res['name'];?></td>  
          <td ><?php echo tep_hejri11($row['date']);?></td> 
          <td><?php if($row['kind']=='1'){ echo 'حضوری';}
		  			if($row['kind']=='2'){ echo 'پست رایگان';}
					if($row['kind']=='3'){ echo 'پست سفارشی';}?></td>
			<?php }
	?>
</form>
    		
		</tbody>
  </table>
  <div style="direction:ltr">
<?=$pagination?>
                             </div>                 
                                                </div>

                              </div>
                            </div>
                        </div>
               
                    </div>
                    <div class="clear"></div>
                </div><!-- dashboard-widgets-wrap -->
            </div><!-- wrap -->
			<div class="clear"></div></div><!-- wpbody-content -->
			<div class="clear"></div></div><!-- wpbody -->
			<div class="clear"></div></div><!-- wpcontent -->
        </div>
    </div><!-- wpcontent -->
</div><!-- wpwrap -->
<?php include("include/footer.php");?>
</div>
</div>
</body>
</html><?php } ?>