<?php
include("cp_header.php");/**************************************************صفحة عرض الفيديوهات*********************************************************************/

//الحماية من الحقن
if(!isset($_GET['search'])){ die(); };

injection($_GET['search']);
/*  اسم الجدول وبداية الكويرى */  
$table='videos';

//استعلام لتحديد العدد الكلى للسجلات

//بداية الاستعلام
$query="select count(id) from $table where title like '%".$_GET['search']."%'  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_<?php echo $table; ?>.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_cp; ?>" 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 id="save_tr" ></div>
</div>	


<div id="result_limit">

<div id="news_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">العنوان</td>
<td width='100' align="center" >لينك الفيديو</td>
<td width='5' align="center">معاينة</td>
<td width='5' align="center">نسخ</td>
<td width='5' 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>	
<td width="15" align="center">حذف</td>	
</tr>	
	
	
<?php


//بداية الاستعلام
$query="select active,sort,created,modified,user_created,user_modified,
id,title,link,priority from $table where title like '%".$_GET['search']."%'  order by `priority` desc , `sort` desc , id desc limit $max_rows_cp";		
//تنفيذ الاستعلام
$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><div>$fetch[title]</div></td>";
echo"<td align='center'><div>$fetch[link]</div></td>";
echo"<td align='center'>
<a target='_blank' href='$_SESSION[website_url]/video/$fetch[id]/$fetch[title]' >
<img loading='lazy' width='25' height='25'  src='../img/url.png' />
</a>
</td>";

echo"<td align='center'>
<a class='copy_link' data='$_SESSION[website_url]/video/$fetch[id]/$fetch[title]' >
<img loading='lazy' width='25' height='25'  src='../img/copy.png' />
</a>
</td>";
echo"<td align='center'><a class='priority_multi' table='$table' alt='$fetch[id]'>";
if($fetch['priority']=='1'){
echo"<img loading='lazy' table='$table' id='priority_image$fetch[id]' class='priority_image' src='../img/priority.png'></td>";	
}else{
echo"<img loading='lazy' table='$table' id='priority_image$fetch[id]' class='priority_image' src='../img/not_priority.png'></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"<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='edit_news' alt'$fetch[id]' href='edit_$table.php?id=$fetch[id]'><img loading='lazy' 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 loading='lazy' 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"); ?>