<?php
session_start();
include("dbf.php");
//echo $_SESSION[id].'dddddddddddddddd<br/>';
$s122=mysql_query("select * from `login` where  id='{$_SESSION[id]}' ");
$ab12=mysql_fetch_assoc($s122);
?>
<body onload="document.getElementById('btnnew').focus()">
<?php
class search {
	var $table;
	var $field1;
	var $field2;

function queryRow($query){
//define database settings
define("host", "localhost");
define("login", "root");
//define("senha", "");

//define database name
//define("data", "sandogh");
//conection routine
    try{
    	$host = host;
    	$data = data;
             $connection = new PDO("mysql:host=$host;dbname=$data", login, senha);
             $result = $connection->prepare($query);
             $result->execute();
             return $result;

             $this->connection = $connection;
    }catch(PDOException $e){
    echo $e->getMessage();
    }
    }

      function close($connection){
	      $connection = null;
	      }
	function query($query){
	    $host = host;
	    $result = $this->queryRow($query);
	    $row = $result->fetch(PDO::FETCH_ASSOC);
	    $this->close($this->connection);
	    $this->query = $query;
	    return $row;
	    }
function fieldSelect1($tbl,$f,$n){
$retorno  = "<select name=\"fieldselect\" id=\"fieldselect\" class=\"drop\" >\n";
		$i=0;
		do{
	    $retorno .= "<option value=\"$f[$i]\">$n[$i]</option>\n";
		$i++;
		}while($i < count($f));

	$retorno .= "</select>\n";
	return $retorno;
}
function Select2($tbl,$lbl,$val,$id,$multiple,$wher,$valu,$func)
{
   $retorno  = "<span id=divdis><select name=\"$id\" id=\"$id\"  class=\"drop\"  $multiple  $func >\n";
 //echo "select * from $tbl $wher ";
   $fg=mysql_query("select * from $tbl $wher ");
	while($v=mysql_fetch_assoc($fg))
    {
      $lb=split('~',$lbl);
      $l1=$lb[0];
      $l2=$lb[1];
     if($lb[1]!='')
      $vlb=$v[$l1].' '.$v[$l2];
     else
        $vlb=$v[$lbl];
//echo $vlb;
	  if($v[$val]==$valu)
	    $retorno .= "<option selected value=\"$v[$val]\"> $vlb</option>\n";
	  else
	    $retorno .= "<option  value=\"$v[$val]\"> $vlb</option>\n";
	}
	$retorno .= "</select></span>\n";
    //$retorno .= "<img src='images/Search1[1].gif'  id='im' width='15' height='15'   onclick='ajxcode(\"$id\",\"id\",\"ozv\",\"lname\",\"divdis\")' >";
	return $retorno;
}
function whereSelect(){
	$wheres = array();
	$wheres[] = 'equal';
	$wheres[] = 'diferent';
	$wheres[] = 'minor';
	$wheres[] = 'more';
	$wheres[] = 'minororequal';
	$wheres[] = 'moreorequal';
	$wheres[] = 'content';
	$wheres[] = 'notcontent';


	$label[] = 'مساوی';
	$label[] = 'متفاوت';
	$label[] = 'کوچکتر';
	$label[] = 'بزرگتر';
	$label[] = 'کوچکتر مساوی';
	$label[] = 'بزرگتر مساوی';
	$label[] = 'شامل باشد';
	$label[] = 'شامل نباشد';


	$retorno  = "<select name=\"select\" id=\"select\" class=\"drop\" >\n";
		$i=0;
		do{
			if ($_POST['select'] == $wheres[$i]){
				$selected = " selected=\"selected\" ";
			}else{
				$selected = "";
		}
	    $retorno .= "<option value=\"$wheres[$i]\"$selected>$label[$i]</option>\n";
		$i++;
		}while($i < count($wheres));

	$retorno .= "</select>\n";
	return $retorno;
}
function fieldText($size, $max){
		$retorno .= "<input type=\"text\" name=\"fieldtext\" id=\"fieldtext\"  size=\"$size\" maxlength=\"$max\" onkeyup='Eve(event)'  >\n";

		return $retorno;

}

function grid($width,$bordercolor,$header,$page,$tbl,$fieldshow,$ke,$tbl2,$backheader,$row,$bgcolor,$bgcolor1,$fieldsu)
{
	include("dbf.php");
	$s=mysql_query("select * from `login` where  id='{$_SESSION[id]}' ");
    $a=mysql_fetch_array($s);
	//echo $_SESSION[ser];
	$_SESSION[sort]='';
	$resultfields = "";
	$search=$_SESSION['se'];
	$fieldtext=$_SESSION['txt'];
	$fieldselect=$_SESSION['fs'];
	$sor = ($_SESSION[sf]) ? $_SESSION[sf] : $tbl.'.'.$ke;
    $order = ($_SESSION[orde]) ? $_SESSION[orde] : 'asc';
    $retorno = "<div style='padding-bottom:20px' class='head' ><b>$header<b/></div>";
	$retorno .= "<table border='1' cellspacing='0.75' cellpadding='3'class='table'  width=\"$width\"' bordercolor=\"$bordercolor\"' $bordercolor align=\"center\"   dir='rtl'  />\n";
	$retorno .= "<tr bgcolor=\"$backheader\" align=\"center\"  valign='top'>";
	$i=0;
	$j=0;
	 if(($_SESSION[tbl]=='matn') || (($_SESSION[onvan]=='مدير') && ($_SESSION[tbl]=='majale') && ($a['majale1']==1) )  || ($_SESSION[tbl]=='darkhast') )
	   $retorno .= "<td>--</td>";
	 if(($_SESSION[tbl]=='ozv') && ($a['ozve3']==1) )
	   $retorno .= "<td>--</td>";
	 if(($_SESSION[tbl]=='ozv') && ($a['ozve3']==1) )
	   $retorno .= "<td>--</td>";
	 if(($_SESSION[tbl]=='amanat')&& ($_SESSION[mainpage]=='requirpage.php') && ($a['req9']==1) )
	   $retorno .= "<td>--</td>";
	 if(($_SESSION[tbl]=='amanat')&& ($_SESSION[mainpage]=='requirpage.php') && ($a['req10']==1)  )
	   $retorno .= "<td>--</td>";
	 if(($_SESSION[tbl]=='amanat')&& ($_SESSION[mainpage]=='requirpage.php'))
	   $retorno .= "<td>--</td>";
	if(($_SESSION[onvan]=='مدير') && ($_SESSION[mainpage]!='expire.php') && ($_SESSION[mainpage]!='requirpage.php') && ($_SESSION[tbl]!='darkhast')&& ($_SESSION[mainpage]!='listamanat.php')&& ($_SESSION[mainpage]!='listmemberpage.php')&& ($_SESSION[mainpage]!='listketab.php')&& ($_SESSION[mainpage]!='mot.php')&& ($_SESSION[tbl]!='takhir_am')&& ($_SESSION[mainpage]!='mov.php') )
	{
	  if($_SESSION[tbl]=='ketab')
      $retorno .= "<td>--</td>";

	  if($_SESSION[tbl]=='matn')
	  $retorno .= "<td>--</td>";

	  $retorno .= "<td>--</td>";
	  $retorno .= "<td>--</td>";
	}

    if(($_SESSION[onvan]=='مدير') && (($_SESSION[tbl]=='amanat')&& ($_SESSION[mainpage]=='mot.php') ))
	{
	$retorno .= "<td>SMS</td>";
	}
	$retorno .= "<td> رديف</td>";
// echo $_SESSION[ser];
foreach($fieldsu as $name => $value)
{
//echo $value;
   $retorno .= "<td>";
   if(($_SESSION[sor]==$name) && ($_SESSION[orde]=='asc'))
     $rg=$name." "."<img  src='images/sort_asc.png' border='0'/>" ;
   elseif(($_SESSION[sor]==$name) && ($_SESSION[orde]=='desc'))
     $rg=$name." "."<img  src='images/sort_desc.png' border='0'/>" ;
    else
	 $rg=$name ;
	 if($value=='name1')
	  $val=$value;
	else
	   $val=$tbl.'.'.$value;

   $retorno .= "<a  onClick='sort(\"getajax.php\",\"$val\",\"$order\",\"$name\",\"$_SESSION[ser]\")' style='text-decoration:none'>";
   $retorno .= $rg;
   $retorno .= "</a></td>";

}

	$page_name=$page;
	$_SESSION[pag]=$page;
	//echo $sort.'uuu';

    include('paging1.php');
//echo $_SESSION[ser];
	 if($_SESSION[ro]=='1')
	   $_SESSION[eu2]=$_SESSION[row];
	 //elseif($_SESSION[ser]=='1')
	   //$_SESSION[eu2]='0';
	 else
	   $_SESSION[eu2]=$eu;
	   $eu1=$_SESSION[eu2];
	   //echo $_SESSION[eu2];
    $p="a";
     if($_SESSION[ser]=="1")
	 {


 //$q2=" order by $sor $order limit  $limit ";
		if($_SESSION[txt]=='')
		{ //echo 'ssssssss';
		  $q2=" order by $sor $order limit $eu1, $limit ";
		  $q3="";
		}
		else
		{ //echo '444444444444';
		 $q2=" order by $sor $order  limit  $eu1, $limit   ";
		 $q3=" and ".$_SESSION[fs].$_SESSION[fildtext];
		}

	 }
	elseif($_SESSION[ro]=='1')
	{ //echo '111111';
	    $q3="";
		$q2=" order by $sor $order limit $_SESSION[row], $limit ";
	}
	 else
	 {  //echo $sor.'-'.$order;
		$q3="";
		if($_SESSION[tbl]=='ozv')
		$q2=" order by id $order limit $eu1, $limit ";
		elseif($_SESSION[tbl]=='ketab')
		$q2=" order by dio_ip $order limit $eu1, $limit ";
		elseif($_SESSION[tbl]=='matn')
		$q2=" order by ip $order limit $eu1, $limit ";
		elseif($_SESSION[tbl]=='amanat')
		$q2=" order by id_ozv $order limit $eu1, $limit ";
		elseif($_SESSION[tbl]=='dio')
		$q2=" order by code $order limit $eu1, $limit ";
		else
		$q2=" order by $sor $order limit $eu1, $limit ";
	 }

	 	function hh($nam){
							$g=strlen($nam);
							if ($g<=15) {
							return $nam;
							}
							if ($g>15) {
							$nam =substr($nam,0,15 ).str_repeat(".",4 );
							return $nam;
							}
							}
	   $s122=mysql_query("select * from `login` where  id='{$_SESSION[id]}' ");
		$ab12=mysql_fetch_assoc($s122);
	   if($_SESSION[tbl]=='matn')
	   {
	   	     $q1="select $tbl.id,$tbl.paje,$tbl.name,$tbl.ip,$tbl.up_book,$tbl.city,ketab.name as name1,ketab.id from $tbl inner join ketab on $tbl.id=ketab.id  where ($tbl.city='{$_SESSION[city]}')  ";
	   }
	   elseif($_SESSION[tbl]=='login')
	   {
	   $q1="select * from $tbl where (city='{$_SESSION[city]}' ) $_SESSION[wher]  ";
	   }
	   else
	   {
	   	if ($ab12['modir']==1)
	   	{
	    $q1="select * from $tbl where (city='{$_SESSION[city]}') $_SESSION[wher]  ";
//echo "select * from $tbl where (city='{$_SESSION[city]}') $_SESSION[wher]  4444444";
	    }
	    else
	    {
//echo "select * from $tbl where (city='{$_SESSION[city]}' and user='{$_SESSION[user]}') $_SESSION[wher]  333333333";
		 $q1="select * from $tbl where (city='{$_SESSION[city]}' and user='{$_SESSION[user]}') $_SESSION[wher]  ";
//echo "select * from $tbl where (city='{$_SESSION[city]}' and user='{$_SESSION[user]}') $_SESSION[wher]  ";
		 }
//echo "select * from $tbl where (city='{$_SESSION[city]}') $_SESSION[wher] $order <br/>";
		}


	  $fg=mysql_query($q1.$q3)or die(mysql_error());
	  $nume=mysql_num_rows($fg);
	  $_SESSION['p']=$nume;
	  $q4=" order by $sor $order ";
	  $_SESSION[qury]=$q1.$q3.$q4;
 //echo $q1.'<br/>'.$q3.'<br/>w'.$q2;
	  $q=@mysql_query($q1.$q3.$q2)or die(mysql_error());

	$_SESSION[pag1]=$back;
	//echo $row;
	$i=1;
	//echo $_SESSION[ser];

	$retorno .= "</tr>\n";
	$c=1;
	$pge=$_SESSION[mainpage];
   while($ff=@mysql_fetch_assoc($q))
	{
		$codeee=$ff['ip'];

        if($c%2)
		  $bg=$bgcolor;
		else
		  $bg=$bgcolor1;
	  $retorno .= "<tr align=\"center\"   bgcolor=\"$bg\"> ";
      if($_SESSION[radif]==1)
		 $r=$sr;
	  elseif($_SESSION[radif]==2)
		 $r=$sro;
	  elseif($_SESSION[radif]==3)
		$r=$c;

		if(($_SESSION[tbl]=='ozv') && ($_SESSION[mainpage]!='expire.php') && ($a['ozve3']==1)  )
		{
		  //$retorno .= "<td><form method='post' action='memberpage.php'><button type='submit' name='smss' title='ارسال SMS'><img src='images/sms.png'  border='0' width='8' height='15' ></button></form>";
		  $retorno .= "<td><a href='smslist.php?ipp=$ff[$ke]' target='_blank' style='cursor:pointer'  ><img src='images/sms.png' title='ارسال SMS'  border='0' width='15' height='20' class=\"link\"></a></td>";
		}
		if(($_SESSION[tbl]=='ozv') && ($_SESSION[mainpage]!='expire.php') && ($a['ozve3']==1)  )
	      $retorno .= "<td><a onClick='ajaxloadp(\"printcart.php\",$ff[$ke],\"$pge\")' ><img src='images/kart.png' height='20' width='20' border='0'></a></td>";
		if(($_SESSION[onvan]=='مدير') &&($_SESSION[tbl]=='majale') && ($a['majale1']==1) )
	      $retorno .= "<td><a onClick='seerec1($ff[$ke],\"majale_et.php\")' ><img src='images/as.png' border='0' width='20' height='20'></a></td>";
		if($_SESSION[mainpage]=='expire.php')
	      $retorno .= "<td><a  onClick='ajaxloadalert(\"a_memberpage.php\",$ff[$ke],\"تمديد با موفقيت انجام شد\"),ajaxload(\"expire.php\")' ><img src='images/tam.png' title='تمدید' border='0' height='20' width='20'></a></td>";
		if($_SESSION[tbl]=='darkhast')
		  $retorno .= "<td  title='ويرايش'><a onClick='deleconf(\"a_bookpage.php\",$ff[$ke],\"listdar.php\"),ajaxload(\"listdar.php\")'><img src='images/b_drop.png' border='0' height='15' width='15'></a></td>";
		if(($_SESSION[onvan]=='مدير') &&($_SESSION[tbl]=='amanat') && ($_SESSION[mainpage]=='mot.php') )
		{
			$retorno .= "<td><a target='_blank' href='smstahvil.php?idmem2=".$ff['id']."&&kind=2&&smsmatn=2&&pageback=search.class.php'><img src='images/sms.png' border='0' height='15' width='15'></a></td>";
		}
		if(($_SESSION[onvan]=='مدير') &&($_SESSION[tbl]=='amanat') && ($_SESSION[mainpage]=='requirpage.php') )
		{
		  $retorno .= "<td><a onClick='deleconf(\"a_requirpage.php\",$ff[$ke],\"requirpage.php\"),ajaxload(\"requirpage.php\")'><img src='images/b_drop.png' border='0' height='15' width='15'></a></td>";
		  if($a['req9']==1)
		    $retorno .= "<td><a onclick='ajaxload3(\"requirpage1.php\",$ff[$ke],\"amanat\")' ><img src='images/ba.png' title='بازگشت کتاب' height='20' width='20' border='0'></a></td>";
		  if($a['req10']==1)
		    $retorno .= "<td><a onclick='ajaxload1(\"rezerv.php\",$ff[$ke])'><img src='images/rez1.png' border='0' height='20' title='رزرو کتاب' width='20'></a></td>";
		}
//	echo $_SESSION[tbl].'dddddddddd';
		if($_SESSION[tbl]=='matn')
		{
		$retorno .= "

		<td>
			<a href='funcs.php?iipe=$codeee' target='_blank'><img src='images/46.png' border='0' width='20' height='20' title='حذف اعراب متن'></a>
		</td>
		";
		}
		if($_SESSION[tbl]=='matn')
		{

		 if($ff['up_book']!="")
		   $retorno .= "<td><a target='_blank' href='books/$ff[up_book]' ><img src='images/15.png' border='0' width='20' height='20' title='مشاهده متن'></a></td>";
		 else
		   $retorno .= "<td><a onClick='seerec($ff[$ke],\"textpage1.php\")' ><img src='images/15.png' border='0' width='20' height='20' title='مشاهده متن'></a></td>";
		}

		if(($_SESSION[onvan]=='مدير') && ($_SESSION[tbl]!='amanat') && ($_SESSION[mainpage]!='expire.php') && ($_SESSION[tbl]!='darkhast')&& ($_SESSION[tbl]!='takhir_am'))
		{

		   if($_SESSION[tbl]=='ketab')
		   {
		   		$retorno .= "<td>
		   		<a  href='book_group1.php?ip=".$ff['ip']."&mode=group' target='_blank' ><img src='images/47.png' title='تعیین گروه' class=\"link\"></a>";
		   		$retorno .= "</td>";
		   }
		   $retorno .= "<td>
		   <a onClick='editrec($ff[$ke],\"$_SESSION[opepage]\")' style='cursor:pointer'  ><img src='images/b_edit.png' title='ویرایش' class=\"link\"></a>";
		   $retorno .= "</td>";

        $retorno .= "<td>
		<a onClick='delrec($ff[$ke],\"$_SESSION[opepage]\")' style='cursor:pointer'  ><img src='images/b_drop.png' title='حذف' class=\"link\"></a>";
		$retorno .= "</td>";
		}
		$retorno .= "<td>$r</td>";
       foreach($fieldsu as $name => $value)
       {
         if(($_SESSION[tbl]=='matn')&& ($ff[$value]=='name') )
           $retorno .= "<td >".substr((hh($ff[$value])),0,500)."</td>";
		 else
		   $retorno .= "<td >&nbsp;".substr($ff[$value],0,500)."</td>";
	   }


	  $retorno .= "</tr>\n";
      $c++;
      $sr++;
      $sro++;
	 }

  if(($_SESSION[onvan]=='مدير') && ($_SESSION[tbl]=='takhir_am') )
	{
	  $q=mysql_query("select sum(haz_takhir) as sum  from `takhir_am` where pardakht='1'")or die(mysql_error());
	  $r=mysql_fetch_array($q);
	  $retorno .= "<tr bgcolor=\"$bg\"><td colspan='9' align='left'  >جمع کل :$r[sum]</td></tr>";
	}
	$retorno .= "</table>\n";
	include('paging2.php');
	if(($_SESSION[onvan]=='مدير') && (($_SESSION[tbl]=='amanat')&& ($_SESSION[mainpage]=='requirpage1.php') ))
	{
	 $nb=mysql_query("select * from `ketab`");
	 $nb1=mysql_query("select * from amanat where (city='{$_SESSION[city]}' and date_in=0 ) order by amanat.id_ozv");
	 $bbn=mysql_num_rows($nb);
	 $bam=mysql_num_rows($nb1);
	 $te=$bbn-$bam;
	 $retorno .= "<div align='center' style='padding-top:20px;' >تعداد کل کتب :$bbn &nbsp;&nbsp;&nbsp; تعداد کتب به امانت رفته :$bam&nbsp;&nbsp;&nbsp; موجودی فعلی کتب : $te</div>";
	}


    $retorno .= "<div style='padding-top:20px;width:600px' dir='rtl' >";
	$retorno .= "<form method='post' action='output.php'>";
	if(($_SESSION[onvan]=='مدير') && ($_SESSION[tbl]=='matn') && ($a['txt1']==1) )
	  $retorno .= "<button tabindex='1' title='آپلود متن کتاب'   type='button'  onClick='ajaxload(\"up_book.php\")'><img src='images/pdf.png'    border='0' width='20' height='20' ></button>";
	if(($_SESSION[onvan]=='مدير') && ($_SESSION[tbl]!='amanat') && ($_SESSION[mainpage]!='expire.php')&& ($_SESSION[tbl]!='darkhast') && ($_SESSION[tbl]!='takhir_am') )
	   $retorno .= "<button tabindex='1' type='button' id='btnnew'  onClick='newrec(\"$_SESSION[opepage]\")'  ><img src='images/sabt2.png' name='Add'  border='0' width='20' height='20' ></button>";
	 if(($_SESSION[tbl]=='ozv') && $_SESSION[mainpage]!='expire.php' )
	 {
	    if($a['ozve1']==1)
	     $retorno .= "<button tabindex='2' title='اعضایی که تاریخ عضویت آن ها منقضی شده' type='button'  onClick='ajaxload1(\"expire.php\",\"1\")'   ><img src='images/user.png'   border='0' width='20' height='20' ></button>";
	    if($a['ozve2']==1)
	     $retorno .= "<button tabindex='3' title='تعیین تاریخ انقضا' type='button'  onClick='ajaxload(\"expire1.php\")'  ><img src='images/datee.png' border='0' width='20' height='20' ></button>";
	 }
	 if(($_SESSION[onvan]=='مدير') &&($_SESSION[tbl]=='amanat') && ($_SESSION[mainpage]=='requirpage.php'))
	 {
	  if($a['req1']==1)
	   $retorno .= "<button tabindex='1' title='متاخرین در امانت'  type='button'  onClick='ajaxload(\"mot.php\")'   ><img src='images/takhir.png'  border='0' width='20' height='20' ></button>";
	  if($a['req2']==1)
	   $retorno .= "<button tabindex='2' title='لیست کارمزدهای دریافتی'  type='button'  onClick='ajaxload(\"kmoz.php\")' ><img src='images/mony.png' border='0' width='20' height='20' ></button>";
	  if($a['req3']==1)
	   $retorno .= "<button tabindex='3' title='تحویل موقت'  type='button'  onClick='ajaxload(\"mov.php\")'  ><img src='images/rez3.png'  border='0'width='20' height='20' ></button>";
	  if($a['req4']==1)
	   $retorno .= "<button tabindex='4' title='مدت امانت وهزینه دیرکرد'  type='button'  onClick='ajaxload(\"h_aman.php\")'  ><img src='images/haz.png'   border='0' width='20' height='20' ></button>";
	   $retorno .= "<button tabindex='2' title='چاپ' name='print' type='button'  onClick='ajaxloadp(\"print.php\",\"$tbl\",\"$pge\")' ><img src='images/1465.png'	 name='print'  border='0' width='20' height='20' ></button>";
	   $retorno .= "<button tabindex='3' title='خروجی' name='out' type='submit'   ><img src='images/excel.png' name='print'  border='0' width='20' height='20' ></button>";
	  if($a['req5']==1)
	   $retorno .= "<br><br><input  tabindex='5' type='button'  onClick='ajaxload1(\"requirpage1.php\",\"out\")'  value='امانت كتاب' style='cursor:hand;font-family:tahoma;font-size:10pt'>";
	  if($a['req6']==1)
	   $retorno .= "<input tabindex='6'  type='button'  onClick='ajaxload1(\"listamanat.php\",\"kol\")' value='مشاهده لیست کلی' style='cursor:hand;font-family:tahoma;font-size:10pt'>";
	  if($a['req7']==1)
	   $retorno .= "<input tabindex='7'  type='button'  onClick='ajaxload1(\"requirpage1.php\",\"list\")' value='مشاهده لیست اشخاص' style='cursor:hand;font-family:tahoma;font-size:10pt'>";
	  if($a['req8']==1)
	   $retorno .= "<br/><input  tabindex='8'  type='button'  onClick='ajaxload1(\"requirpage1.php\",\"ket\")' value='مشاهده وضعیت امانت کتاب خاص' style='cursor:hand;font-family:tahoma;font-size:10pt'>";



	 }
	 if($_SESSION[tbl]=='ketab')
	 {
	   if($_SESSION[onvan]=='مدير')
	   {
	     if($a['book1']==1)
	      $retorno .= "<button tabindex='1' title='موضوع جدید'   type='button'  onClick='ajaxload(\"subject.php\")'><img src='images/notepad_01.png'  border='0' width='20' height='20' ></button>";
	     if($a['book2']==1)
		  $retorno .= "<button tabindex='3' title='لیست درخواست کتاب اعضا'   type='button'  onClick='ajaxload(\"listdar.php\")'  ><img src='images/as.png'   border='0' width='20' height='20' ></button>";
	   }
	   else
	     $retorno .= "<button  name='dar' type='button'  onClick='ajaxload(\"dar.php\")' title='درخواست خرید کتاب'><img src='images/dar.png' height='20' width='20'	></button>";

	 }
	if(($_SESSION[onvan]=='مدير') && ($_SESSION[mainpage]!='requirpage.php')  && ($_SESSION[tbl]!='mozo')&& ($_SESSION[tbl]!='darkhast')  )
	{
	  $retorno .= "<button tabindex='2' title='چاپ' name='print' type='button'  onClick='ajaxloadp(\"print.php\",\"$tbl\",\"$pge\")' ><img src='images/1465.png'	 name='print'  border='0' width='20' height='20' ></button>";
	  $retorno .= "<button tabindex='3' title='خروجی' name='out' type='submit'   ><img src='images/excel.png' name='print'  border='0' width='20' height='20' ></button>";

	  if($_SESSION[tbl]=='ketab')
	  {
	  $retorno .= "<br/><a href='book_group.php' target='_blank' title='گروه بندی کتاب ها'><img src='images/47.png'   border='1' width='25' height='25' ></a>";
	  $retorno .= "<a href='book.php?kin=1' target='_blank' title='آپلود کتب خطی'><img src='images/khatibook.jpg'   border='1' width='35' height='25' ></a>";
	  }
	  if($_SESSION[tbl]=='majale')
	  {
	  $retorno .= "<br/><a href='book.php?kin=2' target='_blank' title='آپلود مقالات'><img src='images/maghale.jpg'   border='1' width='45' height='25' ></a>";
	  }
	}

    $retorno .= "</form>";
	$retorno .= "</div>\n";
	$retorno .= "<div style='padding-top:20px;padding-bottom:20px' dir='rtl'>";
	include_once('search.class.php');
    $search = new search;
    if(($_SESSION[tbl]!='mozo') && ($_SESSION[mainpage]!='listmemberpage.php') && ($_SESSION[mainpage]!='listketab.php') )
    {
      $retorno .= $search->fieldSelect1($_SESSION[tbl],$_SESSION[arv],$_SESSION[arf]);
      $retorno .= $search->whereSelect();
	  $retorno .= $search->fieldText(10,20);
	  $retorno .= "<button tabindex='1'  type='button'    onClick='search1(\"getajax.php\")'  style='cursor:pointer;border-width:0;background-color:#fff'><img src='images/Search1[1].gif'    border='0' width='20' height='20' ></button>";
	}
	$retorno .= "</div>\n";
	return $retorno;
  }
}
 ?>
