<?php
session_start();/**************************************************صفحة حفظ ترتيب الصفوف *******************************************************************/

//استدعاء ملف الاعدادات
$conc_type='cp_exec_conc';
include '../conf.php';
include '../conf_sub.php';
//استدعاء ملف الاتصال بقاعدة البيانات
//include $cp_exec_conc;

//استدعاء ملف معالجة الحقن
include("../injection.php");
//ضمان توافق قاعدة البيانات مع اللغة العربية
mysqli_query($conn,"SET NAMES 'utf8'");
mysqli_query($conn,'SET CHARACTER SET utf8');
mysqli_query($conn,"SET character_set_client=utf8");
mysqli_query($conn,"SET character_set_connection=utf8");
mysqli_query($conn,"SET character_set_database=utf8");
mysqli_query($conn,"SET character_set_results=utf8");
mysqli_query($conn,"SET character_set_server=utf8");
mysqli_query($conn," set character_set_server='utf8'");
//ايقاف التنفيذ فى حالة عدم تسجيل الدخول
if(!isset($_SESSION[$domain.'_user']) || $_SESSION[$domain.'_user']==""){die;}
	

/*  اسم الجدول وبداية الكويرى */  
$menu=$_POST['menu'];


	//استدعاء القوائم من قاعدة البيانات
	$query_menus="select id,title from menus ";
	$result_menus=mysqli_query($conn,$query_menus);

	/*بداية التكرار */  
	while($fetch_menus = mysqli_fetch_array($result_menus)) {
   		 $fetch_menus = clean_array($fetch_menus); $menus[]=$fetch_menus['title']; } 
		
		
?>



<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" style='display:none;'>اسم الصفحة</td>
<td align="center" >عنوان الصفحة</td>
<td width='100' align="center" >القائمة التابع لها</td>
<td width='5' align="center">الترتيب</td>
<td width='5' align="center">النشر</td>

</tr>	
	
	
<?php


//بداية الاستعلام
$query="select id,page_title,page_name,menu,active,sort,created,modified,user_created,user_modified,priority from pages_desc where menu like '%$menu%' and not_menued=0  order by  menu asc ,sort asc, id asc ";	

//تنفيذ الاستعلام
$result=mysqli_query($conn,$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 loading='lazy' class='view_image' width='25' height='25'  src='../img/pages_desc/img".$fetch['id']."_tiny.webp?time=".time()."' />
</td>";
echo"<td style='display:none;'><div>$fetch[page_name]</div></td>";
echo"<td><div>$fetch[page_title]</div></td>";
echo"<td><div><select id='$fetch[id]' class='page_menu_change'> ";

echo"<option "; if($fetch['menu']==''){echo 'selected' ;}  echo " value='' >   </option>";
for($i=0;$i<count($menus);$i++){
	echo"<option "; if($fetch['menu']==$menus[$i]){echo 'selected' ;}  echo " value='$menus[$i]'>$menus[$i]</option>";

}

echo "</select></div></td>";


echo"<td align='center'>";
?>
<div tr_id="<?php echo $fetch['id']?>" arrang="<?php echo $fetch['sort']?>" priority="<?php echo $fetch['priority']?>" class="up_arrow"></div>
<div tr_id="<?php echo $fetch['id']?>" arrang="<?php echo $fetch['sort']?>" priority="<?php echo $fetch['priority']?>" class="down_arrow"></div>

<?php
echo"</td>";


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


echo"</tr>";
}	
?>
</table>

	
