<? include ("sess.php");
 if($id_sent){
$sql="select * from tbl_member where id ='$id_sent' ";
$re=mysql_query($sql);
$data=mysql_fetch_array($re);
	$sql_type=mysql_query("select * from type_program where id='$data[depart]' ");
	$data_type=mysql_fetch_array($sql_type);
}
 if($id_sent2){
$sql2="select * from tbl_book where id ='$id_sent2' ";

$re2=mysql_query($sql2);
$data2=mysql_fetch_array($re2);
	$sql2_type=mysql_query("select * from type_book where id='$data2[book_type]' ");
	//echo  $sql2_type; exit();
	$data2_type=mysql_fetch_array($sql2_type);
	$sql="select * from tbl_member where id ='$id_sent2_' ";
$re=mysql_query($sql);
$data=mysql_fetch_array($re);
	$sql_type=mysql_query("select * from type_program where id='$data[depart]' ");
	$data_type=mysql_fetch_array($sql_type);
}
 ?><meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<link rel="stylesheet" type="text/css" href="../style.css"><style type="text/css">
.browse_page{
	clear:both;
	margin-left:12px;
	height:35px;
	margin-top:5px;
	display:block;
}
.browse_page a,.browse_page a:hover{
	display:block;
	height:18px;
	width:18px;
	font-size:10px;
	float:left;
	margin-right:2px;
	border:1px solid #CCCCCC;
	background-color: #FFFFCC;
	color:#333333;
	text-align:center;
	line-height:18px;
	font-weight:bold;
	text-decoration:none;
}
.browse_page a:hover{
	border:1px solid #0A85CB;
	background-color: #00CC33;
	color:#FFFFFF;
}
.browse_page a.selectPage{
	display:block;
	height:18px;
	width:18px;
	font-size:10px;
	float:left;
	margin-right:2px;
	border:1px solid #0A85CB;
	background-color:#0A85CB;
	color:#FFFFFF;
	text-align:center;
	line-height:18px;
	font-weight:bold;
}
.browse_page a.SpaceC{
	display:block;
	height:18px;
	width:18px;
	font-size:10px;
	float:left;
	margin-right:2px;
	border:0px dotted #0A85CB;
	font-size:11px;
	background-color:#FFFFFF;
	color:#333333;
	text-align:center;
	line-height:18px;
	font-weight:bold;
}
.browse_page a.naviPN{
	width:50px;
	font-size:12px;
	display:block;
	height:18px;
	float:left;
	border:1px solid #0A85CB;
	background-color:#00CC33;
	color:#FFFFFF;
	text-align:center;
	line-height:18px;
	font-weight:bold;	
}
</style>
<style type="text/css">
<!--
#Layer1 {
	position:absolute;
	left:13px;
	top:48px;
	width:87px;
	height:28px;
	z-index:1;
}
.style1 {color: #FFFFFF}
#Layer2 {
	position:absolute;
	left:11px;
	top:67px;
	width:715px;
	height:159px;
	z-index:1;
}
.style2 {
	color: #CC6600;
	font-style: italic;
}
.style4 {color: #006600}
.style5 {color: #006600; font-style: italic; }
-->
</style>
<?
// สร้างฟังก์ชั่น สำหรับแสดงการแบ่งหน้า   
function page_navigator($before_p,$plus_p,$total,$total_p,$chk_page){   
	global $urlquery_str;
	$pPrev=$chk_page-1;
	$pPrev=($pPrev>=0)?$pPrev:0;
	$pNext=$chk_page+1;
	$pNext=($pNext>=$total_p)?$total_p-1:$pNext;		
	$lt_page=$total_p-4;
	if($chk_page>0){  
		echo "<a  href='?module=Report&s_page=$pPrev&urlquery_str=".$urlquery_str."' class='naviPN'>Prev</a>";
	}
	if($total_p>=11){
		if($chk_page>=4){

			echo "<a $nClass href='?module=Report& s_page=0&urlquery_str=".$urlquery_str."'>1</a><a class='SpaceC'>. . .</a>";   
		}
		if($chk_page<4){
			for($i=0;$i<$total_p;$i++){  
				$nClass=($chk_page==$i)?"class='selectPage'":"";
				if($i<=4){
				echo "<a $nClass href='?module=Report&&s_page=$i&urlquery_str=".$urlquery_str."'>".intval($i+1)."</a> ";   
				}
				if($i==$total_p-1 ){ 
				echo "<a class='SpaceC'>. . .</a><a $nClass href='?module=Report&&s_page=$i&urlquery_str=".$urlquery_str."'>".intval($i+1)."</a> ";   
				}		
			}
		}
		if($chk_page>=4 && $chk_page<$lt_page){
			$st_page=$chk_page-3;
			for($i=1;$i<=5;$i++){
				$nClass=($chk_page==($st_page+$i))?"class='selectPage'":"";
				echo "<a $nClass href='?module=Report&s_page=".intval($st_page+$i).$_SESSION['ses_qCurProvince']."'>".intval($st_page+$i+1)."</a> ";   	
			}
			for($i=0;$i<$total_p;$i++){  
				if($i==$total_p-1 ){ 
				$nClass=($chk_page==$i)?"class='selectPage'":"";
				echo "<a class='SpaceC'>. . .</a><a $nClass href='?module=Report&s_page=$i&urlquery_str=".$urlquery_str."'>".intval($i+1)."</a> ";   
				}		
			}									
		}	
		if($chk_page>=$lt_page){
			for($i=0;$i<=4;$i++){
				$nClass=($chk_page==($lt_page+$i-1))?"class='selectPage'":"";
				echo "<a $nClass href='?module=Report&?s_page=".intval($lt_page+$i-1).$_SESSION['ses_qCurProvince']."'>".intval($lt_page+$i)."</a> ";   
			}
		}		 
	}else{
		for($i=0;$i<$total_p;$i++){  
			$nClass=($chk_page==$i)?"class='selectPage'":"";
			echo "<a href='?module=Report&s_page=$i&urlquery_str=".$urlquery_str."' $nClass  >".intval($i+1)."</a> ";   
		}		
	} 	
	if($chk_page<$total_p-1){
		echo "<a href='?module=Report&s_page=$pNext&urlquery_str=".$urlquery_str."'  class='naviPN'>Next</a>";
	}
}   
?>
<table width="800" border="0" align="center">
  <tr>
    <td><br />
    <p>
    <a href="<? echo" index.php?module=Report";?>">
    <span class="menuclick">&nbsp;รายงานข้อมูลการยืม&nbsp;</span></a>
    &nbsp; &nbsp;
        <a href="<? echo" index.php?module=ReportBorow";?>">
    <span class="menuclick">&nbsp;รายงานข้อมูลการคืน&nbsp;</span></a> &nbsp;&nbsp;&nbsp;
        <a href="<? echo" index.php?module=ReportPay";?>">
    <span class="menuclick">รายงานข้อมูลการค้างชำระ&nbsp;</span></a> &nbsp;</p></td>
  </tr>
</table><br />
<table width="800" border="0" align="center" height="250">
  <tr>
    <td><fieldset>
    <legend class="menuclick">รายงานข้อมูลการยืม</legend>
    <br />
    <table width="800" border="0">
      <tr>
        <td width="151" height="28" bordercolor="#00CC33" bgcolor="#FFFFCC" class="menuclick"><div align="center">ชื่อผู้ยืม</div></td>
        <td width="166" bgcolor="#FFFFCC" class="menuclick"><div align="center">โปรแกรมวิชา</div></td>
        <td width="127" bgcolor="#FFFFCC" class="menuclick"><div align="center">ชื่อหนังสือ</div></td>
        <td width="149" bgcolor="#FFFFCC" class="menuclick"><div align="center">ประเภทหนังสือ</div></td>
        <td width="87" bgcolor="#FFFFCC" class="menuclick"><div align="center">วันที่ยืม</div></td>
        <td width="94" bgcolor="#FFFFCC" class="menuclick"><div align="center">กำหนดคืน</div></td>
        </tr>
      <? // echo  $real ;exit();
   $sql_="select * from bookborow where status_borrow=1 ";
		//  echo $sql_  ; exit();
		  $re_=mysql_query($sql_);
		  $ii=1;
				 $num=mysql_num_rows($re_);
				$total=mysql_num_rows($re_);
$e_page=3; // กำหนด จำนวนรายการที่แสดงในแต่ละหน้า   
if(!isset($_GET['s_page'])){   
	$_GET['s_page']=0;   
}else{   
	$chk_page=$_GET['s_page'];     
	$_GET['s_page']=$_GET['s_page']*$e_page;   
}   
$sql_.=" LIMIT ".$_GET['s_page'].",$e_page";
if(mysql_num_rows($re_)>=1){   
	$plus_p=($chk_page*$e_page)+mysql_num_rows($re_);   
}else{   
	$plus_p=($chk_page*$e_page);       
}   
$total_p=ceil($total/$e_page);   
$before_p=($chk_page*$e_page)+1;  
 $re11=mysql_query($sql_);
		while ($data_=mysql_fetch_array($re11)){
				$sql_book=mysql_query("select * from tbl_book where id='$data_[book_id]' ");
				$data_book=mysql_fetch_array($sql_book);
								$sql_type=mysql_query("select * from type_book where id='$data_book[book_type]' ");
								$data_type=mysql_fetch_array($sql_type);
								$sql_mem=mysql_query("select * from tbl_member where id='$data_[member_id]'");
								$mem=mysql_fetch_array($sql_mem);
								$sql_program=mysql_query("select * from type_program where id='$mem[depart]'");
								$program=mysql_fetch_array($sql_program);
		  ?>
      <tr>
        <td height="28" bgcolor="#FFFFCC" class="inputtext"><? echo"$mem[intro]$mem[name]";?></td>
        <td height="28" bgcolor="#FFFFCC" class="inputtext"><?=$program[name]?></td>
        <td bgcolor="#FFFFCC" class="inputtext"><div align="left">
          <?=$data_book[book_name];?>
        </div></td>
        <td bgcolor="#FFFFCC" class="inputtext"><div align="left">
          <?=$data_type[name];?>
        </div></td>
        <td bgcolor="#FFFFCC" class="inputtext"><div align="center">
          <?=$data_[date_borrow];?>
        </div></td>
        <td bgcolor="#FFFFCC" class="inputtext"><div align="center">
          <?=$data_[date_sent];?>
        </div></td>
        </tr> <? $ii++;  }?>
      <tr>
        <td height="28" colspan="6" bgcolor="#FFFFCC" class="menuclick"><div align="right" class="textstyle3">มีข้อมูลการยืมทั้งหมด :
          <?=$num;?>
          เล่ม </div>          
          <div align="left"></div></td>
        </tr>
    </table><? if($total>0){ ?>
<div class="browse_page">
  <?   
 // เรียกใช้งานฟังก์ชั่น สำหรับแสดงการแบ่งหน้า   
  page_navigator($before_p,$plus_p,$total,$total_p,$chk_page);    
  ?>
</div>
<? } ?> 
    </fieldset>    </td>
  </tr>
</table>

<p>
  <input name="btnButton" type="button" class="menuclick" onclick="JavaScript:window.print();" value="พิมพ์รายละเอียด" />
</p>
