<?php 
 include('nf_config.php');
 // include('menu_side.php');
?>
<!doctype html>
<html lang="en-US" class="no-js">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<title><?php echo $nmanagers ?></title>
	
    <link rel="stylesheet" href="./bootstrap/css/bootstrap.css" >
    <link rel="stylesheet" href="./fontawesome/css/all.css" >

<?php include('menu_side_css.php'); ?>
<?php include('nf_chosen01.php'); ?>
	
</head>

<body>
	
<?php include('menu_side_body.php'); ?>	

	
	<?php
	$condition	=	'';
	if(isset($_REQUEST['mid']) and $_REQUEST['mid']!=""){
		$condition	.=	' AND mid LIKE "%'.$_REQUEST['mid'].'%" ';
	}
	if(isset($_REQUEST['desc_manager']) and $_REQUEST['desc_manager']!=""){
		$condition	.=	' AND desc_manager LIKE "%'.$_REQUEST['desc_manager'].'%" ';
	}
	if(isset($_REQUEST['budget']) and $_REQUEST['budget']!=""){
		$condition	.=	' AND budget LIKE "%'.$_REQUEST['budget'].'%" ';
	}
	if(isset($_REQUEST['expenses']) and $_REQUEST['expenses']!=""){
		$condition	.=	' AND expenses LIKE "%'.$_REQUEST['expenses'].'%" ';
	}
	if(isset($_REQUEST['rep_column']) and $_REQUEST['rep_column']!=""){
		$condition	.=	' AND rep_column LIKE "%'.$_REQUEST['rep_column'].'%" ';
	}	
	if(isset($_REQUEST['desc_rep']) and $_REQUEST['desc_rep']!=""){
		$condition	.=	' AND desc_rep LIKE "%'.$_REQUEST['desc_rep'].'%" ';
	}	
	if(isset($_REQUEST['desc_rep_stock']) and $_REQUEST['desc_rep_stock']!=""){
		$condition	.=	' AND desc_rep_stock LIKE "%'.$_REQUEST['desc_rep_stock'].'%" ';
	}		
	if(isset($_REQUEST['delta_col']) and $_REQUEST['delta_col']!=""){
		$condition	.=	' AND delta_col LIKE "%'.$_REQUEST['delta_col'].'%" ';
	}			
	if(isset($_REQUEST['delta_calc']) and $_REQUEST['delta_calc']!=""){
		$condition	.=	' AND delta_calc LIKE "%'.$_REQUEST['delta_calc'].'%" ';
	}				
	if(isset($_REQUEST['menu_order']) and $_REQUEST['menu_order']!=""){
		$condition	.=	' AND menu_order LIKE "%'.$_REQUEST['menu_order'].'%" ';
	}					
	$condition = $condition." AND pid = '".$pid."'";
	
	//Main queries
    $pages->default_ipp  =   20; //total records show on per page
    $sql    = $db->getRecFrmQry("SELECT * FROM ccmanager_id WHERE 1 ".$condition."");
    $pages->items_total  =   count($sql);
    $pages->mid_range    =   9;
    $pages->paginate(); 
      
    $userData   =   $db->getRecFrmQry("SELECT * FROM ccmanager_id WHERE 1 ".$condition." ORDER BY mid ".$pages->limit."");	
	
	
		
	?>
   	<div class="container-fluid">
		<h1><?php echo $nmanagers ?></h1>
		<div class="card">
			<div class="card-header"><i class="fa fa-fw fa-globe"></i> <strong><?php echo $nmanagers ?></strong> <a href="nf_manid_add.php?pid=<?php echo $pid ?>&xuid=<?php echo $xuid ?>&lang=<?php echo $lang ?>&xfdc=<?php echo $xfdc ?>" class="float-end btn btn-dark btn-sm"><i class="fa fa-fw fa-plus-circle"></i><?php echo $nadd." ".$nmanager;  ?></a></div>
		</div>


		<div class="clearfix"></div>
     
		<div class="row marginTop">
			<div class="col-sm-12 paddingLeft pagerfwt">
				<?php if($pages->items_total > 0) { ?>
					<?php echo $pages->display_pages();?>
					<?php echo $pages->display_items_per_page();?>
					<?php echo $pages->display_jump_menu(); ?>
				<?php }?>
			</div>
			<div class="clearfix"></div>
		</div>
	 
		<div class="clearfix"></div>




		
		<div>
			<table class="table table-striped table-bordered">
				<thead>
					<tr class="bg-primary text-white">
						<th><?php echo $nmanager_id ?></th>
						<th><?php echo $ndesc ?></th>
						<th><?php echo $n_budget ?></th>												
						<th><?php echo $n_expenses ?></th>						
						<th><?php echo $n_rep_column ?></th>						
						<th><?php echo $n_desc_rep ?></th>
						<th><?php echo $n_desc_rep_stock ?></th>							
						<th><?php echo $n_delta_col ?></th>																		
						<th><?php echo $n_delta_pm ?></th>																								
						<th><?php echo $n_delta_calc ?></th>																								
						<th><?php echo $n_delta_perc ?></th>																														
						<th><?php echo $n_menu_order ?></th>																								
						<th class="text-center" colspan=2 ><?php echo $naction ?></th>
					</tr>
				</thead>
				<tbody>
					<?php 
					$s	=	'';
					foreach($userData as $val){
						$s++;
					?>

					<tr>
						<td class="text-center"><?php echo $val['mid'] ?></td>
						<td><?php echo $val['desc_manager'];?></td>					
						<td class="text-center"><?php echo $val['budget'];?></td>						
						<td class="text-center"><?php echo $val['expenses'];?></td>
						<td class="text-center"><?php echo $val['rep_column'];?></td>						
						<td><?php echo $val['desc_rep'];?></td>
						<td><?php echo $val['desc_rep_stock'];?></td>							
						<td class="text-center"><?php echo $val['delta_col'];?></td>																		
						<td class="text-center"><?php echo $val['delta_pm'];?></td>																								
						<td class="text-center"><?php echo $val['delta_calc'];?></td>																								
						<td class="text-center"><?php echo $val['delta_perc'];?></td>																														
						<td class="text-center"><?php echo $val['menu_order'];?></td>																								
						<td class="text-center">
						<?php if ($gcrud == "CRUD" || $gcrud == "CRU") { ?>						
							<a href="nf_manid_edit.php?editId=<?php echo $val['cid']; ?>&pid=<?php echo $pid ?>&xuid=<?php echo $xuid ?>&lang=<?php echo $lang ?>" class="text-primary"><i class="fa fa-fw fa-edit"></i><?php echo $nedit ?></a>
						<?php } ?>
						</td>
						<td class="text-center">						
						<?php if ($gcrud == "CRUD") { ?>												
							<a href="nf_manid_delete.php?delId=<?php echo $val['cid']; ?>&pid=<?php echo $pid ?>&xuid=<?php echo $xuid ?>&lang=<?php echo $lang ?>" class="text-danger" onClick="return confirm('<?php echo $areyousure ?>');"><i class="fa fa-fw fa-trash"></i> <?php echo $ndelete ?></a>
						<?php } ?>
						</td>
					</tr>
					<?php } ?>
				</tbody>
			</table>
		</div> <!--/.col-sm-12-->
		
		
		<div class="clearfix"></div>
     
		<div class="row marginTop">
			<div class="col-sm-12 paddingLeft pagerfwt">
				<?php if($pages->items_total > 0) { ?>
					<?php echo $pages->display_pages();?>
					<?php echo $pages->display_items_per_page();?>
					<?php echo $pages->display_jump_menu(); ?>
				<?php }?>
			</div>
			<div class="clearfix"></div>
		</div>
	 
		<div class="clearfix"></div>		
		
	</div>
	
    <script src="./jquery-3.4.1.js"></script>
    <script src="popper.min.js" ></script>
    <script src="./bootstrap/js/bootstrap.min.js" ></script>
    
</body>
</html>
