<?php 
 /****************************************** صفحة الترقيم ***************************************/ 
$depart_id='';
$num_count_query='';
if(isset($_GET['depart_id'])){
	
	if($_GET['depart_id']===0){
		goto end_cont ;
	}elseif($_GET['depart_id']=='new'){
		goto no_depart;
	}
	$depart_id=$_GET['depart_id'];
	$num_count_query="select count(id) from $table where depart=$depart_id";
}else{
	no_depart:
	$num_count_query="select count(id) from $table";
}

		

//تحديد عدد الصفحات
$num_count_result=mysqli_query($conn,$num_count_query);
$num_count_fetch=mysqli_fetch_row($num_count_result);
$num_rows=$num_count_fetch[0];



if($num_rows==0){
	goto end_cont ;
}


?>


<div id="num_container">
<div max='<?php echo $max_rows ?>' lang='<?php echo $table?>' search=""  depart="<?php echo $depart_id; ?>"  alt='0' id='prev_num_search' class='num_con '><span class='fa las la-angle-right'> <span class='prenext'>السابق</span></span></div>
	
<?php
 
//بداية التكرار
for ($i=1;$i<=$num_rows;$i+=$max_rows){
	$num++;	
	if($i!=1){
	echo"<div max='$max_rows' lang='$table' search='' depart='$depart_id'  alt='$num' id='num_con_search$num' class='num_con_search'>$num</div>";
	}else{
	echo"<div max='$max_rows' lang='$table' search='' depart='$depart_id'  alt='$num' id='num_con_search$num' class='num_con_search num_active'>$num</div>";
	}
	
	if($num==$max_con){
	goto endloop ;
	}
}
endloop:
$num=$num+1;




?>	



<div max='<?php echo $max_rows?>' lang='<?php echo $table?>' search="" depart="<?php echo $depart_id; ?>" alt='2' id='next_num_search' class='num_con '><span class='prenext'> التالى </span><span class='fa las la-angle-left'> </span></div>

<?php if($num_rows>$max_rows){ ?>
	<div max='<?php echo $max_rows?>' current_con='1' lang='<?php echo $table?>' search="" depart="<?php echo $depart_id; ?>" alt='2' id='next_num_search_same' class='num_con '> عرض المزيد <span class='fa las la-angle-left'></span>  </div>
<?php } ?>

<div style="display: none">
<div id="rows_range" style="float:right"><?php echo $max_rows; ?>-1</div>
<div style="float:right">/</div>
<div id ="total_rows" style="float:right"><?php echo $num_rows; ?></div>
</div>
<div id="total_con" style="display:none"><?php echo ceil($num_rows/$max_rows) ; ?></div>
<div id="max_con" style="display:none"><?php echo $max_con ; ?></div>
<div id="load_page" style="display:none"><?php echo 'load_'.$table ; ?></div>
<div id="load_type" style="display:none">article</div>
</div>

<?php end_cont : ?>