<?php 
 include('nf_config.php');
 // include('menu_side.php');
 include('nf_order.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 $n_categs_groups ?></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['code_categ_group']) and $_REQUEST['code_categ_group']!=""){
		$condition	.=	' AND code_categ_group LIKE "%'.$_REQUEST['code_categ_group'].'%" ';
	}
	if(isset($_REQUEST['desc_categ_group']) and $_REQUEST['desc_categ_group']!=""){
		$condition	.=	' AND desc_categ_group LIKE "%'.$_REQUEST['desc_categ_group'].'%" ';
	}
	$condition = $condition." AND pid = '".$pid."'";
	
	//Main queries
    $pages->default_ipp  =   $f_pagesize; //total records show on per page
    $sql    = $db->getRecFrmQry("SELECT * FROM categs_groups WHERE 1 ".$condition."");
    $pages->items_total  =   count($sql);
    $pages->mid_range    =   9;
    $pages->paginate(); 
      
    $userData   =   $db->getRecFrmQry("SELECT * FROM categs_groups WHERE 1 ".$condition." ORDER BY ".$ordr_qry." ".$pages->limit."");	
	
	
		
	?>
   	<div class="container">
		<h1><?php echo $n_categs_groups ?></h1>
		<div class="card">
			<div class="card-header"><i class="fa fa-fw fa-globe"></i> <strong><?php echo $n_categs_groups ?></strong> 
					<?php if ($gcrud == "CRUD" || $gcrud == "CRU") { ?>			
				<a href="nf_categsg_add.php?pid=<?php echo $pid ?>&xuid=<?php echo $xuid ?>&lang=<?php echo $lang ?>" class="float-end btn btn-dark btn-sm"><i class="fa fa-fw fa-plus-circle"></i><?php echo $nadd." ".$n_categ_group;  ?></a>
					<?php } ?>		
			</div>
			<div class="card-body">
				<?php
				if(isset($_REQUEST['msg']) and $_REQUEST['msg']=="rds"){
					echo	'<div class="alert alert-success"><i class="fa fa-thumbs-up"></i>'.$recdel.'</div>';
				}elseif(isset($_REQUEST['msg']) and $_REQUEST['msg']=="rus"){
					echo	'<div class="alert alert-success"><i class="fa fa-thumbs-up"></i>'.$recupd.'</div>';
				}elseif(isset($_REQUEST['msg']) and $_REQUEST['msg']=="rnu"){
					echo	'<div class="alert alert-warning"><i class="fa fa-exclamation-triangle"></i>'.$recnochange.'</div>';
				}elseif(isset($_REQUEST['msg']) and $_REQUEST['msg']=="rna"){
					echo	'<div class="alert alert-danger"><i class="fa fa-exclamation-triangle"></i>'.$recwrong.' <strong>'.$rectry.'</strong></div>';
				}
				?>
				<div class="col-sm-12">
					<h5 class="card-title"><i class="fa fa-fw fa-search"></i><?php echo $nfind." ".$n_categ_group ?></h5>
					<form method="get"  >
						<div class="row">
							<div class="col-sm-4">
								<div class="mb-3">
									<label><?php echo $n_categ_group ?></label>
									<input type="text" name="code_categ_group" id="code_categ_group" class="form-control" value="<?php echo isset($_REQUEST['code_categ_group'])?$_REQUEST['code_categ_group']:''?>" placeholder="<?php echo $nenter." ".$n_categ_group; ?>">
								</div>
							</div>
							<div class="col-sm-4">
								<div class="mb-3">
									<label><?php echo $ndesc ?></label>
									<input type="text" name="desc_categ_group" id="desc_categ_group" class="form-control" value="<?php echo isset($_REQUEST['desc_categ_group'])?$_REQUEST['desc_categ_group']:''?>" placeholder="<?php echo $nenter." ".$ndesc; ?>">
								</div>
							</div>
							
							<input type="hidden" id="pid"  name="pid"  value="<?php echo $pid ?>"  >
							<input type="hidden" id="xuid" name="xuid" value="<?php echo $xuid ?>" >
							<input type="hidden" id="lang" name="lang" value="<?php echo $lang ?>" >

							<div class="col-sm-4">
								<div class="mb-3">
									<label>&nbsp;</label>
									<div>
										<button type="submit" name="submit" value="search" id="submit" class="btn btn-primary"><i class="fa fa-fw fa-search"></i><?php echo $nsearch ?></button>
										<a href="<?php echo $_SERVER['PHP_SELF']; ?>?pid=<?php echo $pid ?>&xuid=<?php echo $xuid ?>&lang=<?php echo $lang ?>" class="btn btn-danger"><i class="fa fa-fw fa-sync"></i> <?php echo $nclear ?></a>
									</div>
								</div>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
		<hr>



		<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 $n_categ_group ?>
						<a href="nf_categsg.php?pid=<?php echo $pid ?>&xuid=<?php echo $xuid ?>&lang=<?php echo $lang ?>&ordr=acode_categ_group" />
						<i class="fas fa-sort-up" style="color:#ffffff;"></i>
						</a>
						<a href="nf_categsg.php?pid=<?php echo $pid ?>&xuid=<?php echo $xuid ?>&lang=<?php echo $lang ?>&ordr=dcode_categ_group" />
						<i class="fas fa-sort-down" style="color:#ffffff;"></i>
						</a>						
						</th>
						<th><?php echo $ndesc ?></th>
						<th class="text-center"><?php echo $naction ?></th>
					</tr>
				</thead>
				<tbody>
					<?php 
					$s	=	'';
					foreach($userData as $val){
						$s++;
					?>
					<tr>
						<td><?php echo $val['code_categ_group'];?></td>
						<td><?php echo $val['desc_categ_group'];?></td>
						<td class="text-center">
						<?php if ($gcrud == "CRUD" || $gcrud == "CRU") { ?>												
							<a href="nf_categsg_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 } 
						if ($gcrud == "CRUD") { ?>						
						|							
							<a href="nf_categsg_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>
