<?php include('casa/setup.casa.php');
$titulo = 'Registro de Usuarios';
include('inc_head.php');
?>
<style>
th{
	color:white;
	text-align:center;
	text-transform:uppercase;}	
</style>
</head>
<body>
	<div class="wrapper">
	
	<?php include('inc_menu.php');?>
		<div class="main-panel">
			<div class="content">
				
			<div class="page-inner">
					
					<div class="row">						
						<div class="col-md-12">
							<div class="card">
								<div class="card-header">
									<div class="d-flex align-items-center">
										<h3 class="card-title"><?php echo $titulo;?></h3>																																									
									</div>
								</div>
								
								<div class="card-body">		
									<div class="row" style='width:97%' align='left'>
											<div class="col-sm-3">
												<a href="<?php echo PATH_HOME.'usuarios-ins1/nuevo';?>" class="btn bg-dark" style='color:white'>
												<i class="fas fa-user"></i> &nbsp; Crear Nuevo Usuario</a>
													<hr>
											</div> 																											
										</div>											
										<div class="table-responsive">
                                    <table id="registros" class="table table-striped table-bordered">
                                        <thead>
                                            <tr class="bg-dark">
												<th>N°</th>
												<th>ROL</th>
												<th>Nombres</th>																																										
												<th>Apellidos</th>
												<th>ci</th>
                                                <th>acciones</th>
                                            </tr>
                                        </thead>
                                        <tbody>    
                                        <?php 
                                        $db=new DB();
										$sql = "SELECT * FROM rol_usuarios
										WHERE us_visible = '1'	
										AND us_codigo <> '6rydh3hqx'
										AND us_id<>'1'	
										ORDER BY us_id ASC;";
                                        $db->dbSQL($sql);
                                        $html='';
										$i=0;
                                        while($db->next()){
										$i++;													 
					
											$rol_id= $db->dbField('rol_id');
												switch($rol_id){
													case 1: $tipo='Administrador';break;
													case 2: $tipo='Técnico';break;													
												}
											$us_id= $db->dbField('us_id');
											$us_ci= $db->dbField('us_ci');
											$us_nombres= $db->dbField('us_nombres');
											$us_apellidos= $db->dbField('us_apellidos');																																		 
														
                                            $html.='<tr>'; 
							    			$html.='<td align=center>'.$i.'</td>';
											$html.='<td>'.$tipo.'</td>';
											$html.='<td>'.$us_nombres.'</td>';
											$html.='<td>'.$us_apellidos.'</td>';
											$html.='<td>'.$us_ci.'</td>';
											$html.='<td align=center>
												  <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
													  <span class="btn-label"><i class="fa fa-cog"></i></span>
												  </button><div class="dropdown-menu">
												  <a class="dropdown-item" href="'.PATH_HOME.'usuarios-upd1/'.$us_id.'"><i class="fas fa-edit"></i> Modificar</a>
												  <div role="separator" class="dropdown-divider"></div>
												  <a class="dropdown-item" href="'.PATH_HOME.'usuarios-del1/'.$us_id.'"><i class="fas fa-window-close"></i> Dar Baja</a>
												  </div></td>';                                         
                                            
                                            $html.='</tr>';
                                            
                                        }
                                        echo $html;                                        
                                        ?>                                                                                    
                                        </tbody>                                        
                                    </table>
                                </div>
								</div>
							</div>
						</div>
					</div>
				</div>
				
			</div>
			<?php include('inc_pie.php');?>
		</div>
		
		
	</div>
</body>
</html>
<script>
$(document).ready(function() {			
	$('#registros').DataTable({
		"pageLength": 25,
	});
});	
</script>