<?php
include("cp_header.php");
if(!isset($_GET['search'])){ die(); };

injection($_GET['search']);


$max_con=10;
$max_rows=20;
$num=0;
$table='pages_desc';



$query="select count(id) from $table where  user_create=1 order by `priority` desc , `sort` desc , id desc ";		


$result=mysqli_query($conn,$query);
$fetch=mysqli_fetch_row($result);
$num_rows=$fetch[0];
?>

<!-- /////////////////////////////////////////////////////////// -->
<div style="visibility:hidden" id="table_name"><?php echo $table?></div>
<div id="load_page" style="display:none">load_<?php echo $table?>_search</div>
<input type="hidden" id="active_page" value="active_<?php  echo $table; ?>" />


<!-- /////////////////////////////////////////////////////////// -->
<div id="cp_cont">
<div id="show_user_details"></div>
<div id="cp_title"> عدد الصفحات (<span id="num_rows"><?php echo $num_rows; ?></span>)
<a style='background:url(../img/add_icon.png);float:left;margin:10px 0px 5px 10px;color:var(--white);width:20px;height:20px;' class='las la-plus-circle' href="add_pages.php" ></a> 
</div>	

<div class="search_div">
<form id="search_form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<input id="search_btn" type="submit" value=""  max="<?php echo $max_rows; ?>" lang="<?php echo  $table ?>" search="<?php echo $_GET['search'] ?>" alt="<?php echo   $num ?>"/>
<input id="search_text" name="search" type="text"/>

<input type="hidden" name="token_sec"  value='<?php echo $_SESSION['token']; ?>'> </form>	



<?php if(!isset($_GET['arrang'])){ ?>
<a style="display:none" id="open_arrang" href="view_<?php echo $table?>.php?search=&arrang="></a>
<?php }else{ ?>

<a style="display:none" id="close_arrang" href="view_<?php echo $table?>.php?search="></a>
<?php }?>







</div>	





<div id="result_limit">

<div id="pages_desc_cont">
<div id="load_wait"></div>
<div id="result_view">
	
<table   cellpadding="0" cellspacing="0" width="988"  dir="rtl"  style="border-left:solid 1px #ccc" >
<tr class='first_table_tr'>
<td align="center" width='20'>الصورة</td>
<td align="center">العنوان</td>


<td width='5' align="center">النشر</td>

<td width="15" align="center">تعديل</td>
<td width="15" align="center">تفاصيل</td>	
<td width="15" align="center">حذف</td>	
</tr>	
	
	
<?php


$query="select active,sort,created,modified,user_created,user_modified,id,page_title,priority from $table where user_create=1 order by  id asc limit $max_rows";		
$result=mysqli_query($conn,$query);

//echo $query;

while($fetch = mysqli_fetch_array($result)) {
   		 $fetch = clean_array($fetch);
	

			
	
	
echo"<tr tr_id='$fetch[id]' priority='$fetch[priority]' arrang='$fetch[sort]' id='tr$fetch[id]' class='table_tr'>";
echo"<td align='center'>
<img class='view_image' width='25' height='25'  src='../img/$table/$fetch[id].webp?time='".time()."/>

</td>";

echo"<td><div>$fetch[page_title]</div></td>";






echo"<td align='center'><a class='active_multi' table='$table' alt='$fetch[id]'>";
if($fetch['active']=='1'){
echo"<img  id='active_image$fetch[id]' class='active_image' src='../img/active.png' status='0'></a></td>";	
}else{
echo"<img table='$table' id='active_image$fetch[id]' class='active_image' src='../img/not_active.png' status='1'></a></td>";		
}







echo"<td align='center'><a class='edit_pages_desc' alt'$fetch[id]' href='edit_pages.php?id=$fetch[id]'><img a src='../img/edit.png'></td>";
echo"<td align='center'><a table='$table' class='show_details' created='$fetch[created]' modified='$fetch[modified]' user_created='$fetch[user_created]' user_modified='$fetch[user_modified]'  alt='$fetch[id]'><img loading='lazy' src='../img/details.png'></td>";

echo"<td align='center'><a table='$table' class='delete_row' alt='$fetch[id]'><img src='../img/delete.png'></td>";
echo"</tr>";
}	
?>
</table>
</div>

<div style='display:none' id='done_load'>done</div>
</div>
</div>	


<?php include "num_container.php" ;?>
</div>

<?php include("cp_footer.php"); ?>