<?php
defined('BASEPATH') OR exit('No direct script access allowed');

?>

<div class="content-wrapper">
	<section class="content-header">
		<?php echo $pagetitle; ?>
		<?php echo $breadcrumb; ?>
	</section>
	<section class="content">
		<div class="row">
			<div class="filterable">
				<div class="col-md-12">
					<div class="box">
						<div class="box-header with-border">
							<h3 class="box-title">
								<?php 
								//if (grupo_usuario(18) or grupo_usuario(16)) {
									echo anchor('users/users/create_users', '<i class="fa fa-plus"></i> '. 'Crear', array('class' => 'btn btn-block btn-primary btn-flat')); 
								//}
								?>

							</h3>
								
						</div>
						<div class="box-body">
							
							<?php 	if (!empty($message)){
										echo '<pre>';
										echo '<b>'.$message.'</b>';
										echo '</pre>';
									}
							?>
							<div style="overflow-x: scroll;">
							<table id="tabla_users" class="table table-striped table-hover">
								<thead>
									<tr>


<?php<--

/*
	id
	ip_address 
	username
	email
	active
	first_name
	last_name
	company
    phone 
    nick 
    dependencia 
    user_jefe_id 
    genero 

*/
?>		



										<th><?php echo lang('users_id');										?></th>
										<th><?php echo lang('users_ip_address');								?></th>
										<th><?php echo lang('users_username');									?></th>
										<th><?php echo lang('users_email');										?></th>
										<th><?php echo lang('users_active');									?></th>
										<th><?php echo lang('users_first_name');								?></th>
										<th><?php echo lang('users_last_name');									?></th>
										<th><?php echo lang('users_company');									?></th>
										<th><?php echo lang('users_phone');										?></th>
										<th><?php echo lang('users_nick');										?></th>
										<th><?php echo lang('users_dependencia');								?></th>
										<th><?php echo lang('users_user_jefe_id');								?></th>
										<th><?php echo lang('users_genero');									?></th>

																							

										<th><?php echo anchor('users/users/reset_busqueda/', '<i title="Limpiar busqueda" class="glyphicon glyphicon-refresh btn btn-primary"></i>'); ?>
										</th>
									</tr>
									<tr>
									<?php echo form_open(current_url(), array('class' => 'form-horizontal', 'id' => 'form-create_users')); ?>



		

										<th><input id="id" name="id" type="number" max="9999" min="0" class="form-control" placeholder="<?php echo lang('users_id');?>" 
										value="<?php if (isset($_SESSION['arraywhere_users']['id'])) 
													 {	
														echo $_SESSION['arraywhere_users']['id'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="ip_address" name="ip_address" type="text" class="form-control" placeholder="<?php echo lang('users_ip_address');?>"
										value="<?php if (isset($_SESSION['arraywhere_users']['ip_address'])) 
													 {	
														echo $_SESSION['arraywhere_users']['ip_address'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="username" name="username" type="number" max="9999" min="0" class="form-control" placeholder="<?php echo lang('users_username');?>" 
										value="<?php if (isset($_SESSION['arraywhere_users']['username'])) 
													 {	
														echo $_SESSION['arraywhere_users']['username'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										
										<th><input id="email" name="email" type="text" class="form-control" placeholder="<?php echo 'Tipo Ref.';?>" 
										value="<?php if (isset($_SESSION['arraywhere_email']['email'])) 
													 {	
														echo $_SESSION['arraywhere_users']['email'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="active" name="active" type="text" class="form-control" 
										placeholder="<?php echo lang('users_active');?>" 
										value="<?php if (isset($_SESSION['arraywhere_users']['active'])) 
													 {	
														echo $_SESSION['arraywhere_users']['active'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="first_name" name="first_name" type="text" class="form-control" 
										placeholder="<?php echo lang('users_first_name');?>" 
										value="<?php if (isset($_SESSION['arraywhere_users']['first_name'])) 
													 {	
														echo $_SESSION['arraywhere_users']['first_name'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="last_name" name="last_name" type="text" class="form-control" 
										placeholder="<?php echo lang('users_last_name');?>" 
										value="<?php if (isset($_SESSION['arraywhere_users']['last_name'])) 
													 {	
														echo $_SESSION['arraywhere_users']['last_name'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="company" name="company" type="text" class="form-control" 
										placeholder="<?php echo lang('users_company');?>" 
										value="<?php if (isset($_SESSION['arraywhere_users']['company'])) 
													 {	
														echo $_SESSION['arraywhere_users']['company'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="phone" name="phone" type="text" class="form-control" 
										placeholder="<?php echo lang('users_phone');?>" 
										value="<?php if (isset($_SESSION['arraywhere_users']['phone'])) 
													 {	
														echo $_SESSION['arraywhere_users']['phone'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="nick" name="nick" type="text" class="form-control" 
										placeholder="<?php echo lang('users_nick');?>" 
										value="<?php if (isset($_SESSION['arraywhere_users']['nick'])) 
													 {	
														echo $_SESSION['arraywhere_users']['nick'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="dependencia" name="dependencia" type="text" class="form-control" 
										placeholder="<?php echo lang('users_dependencia');?>" 
										value="<?php if (isset($_SESSION['arraywhere_users']['dependencia'])) 
													 {	
														echo $_SESSION['arraywhere_users']['dependencia'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="user_jefe_id" name="user_jefe_id" type="text" class="form-control" 
										placeholder="<?php echo lang('users_user_jefe_id');?>" 
										value="<?php if (isset($_SESSION['arraywhere_users']['user_jefe_id'])) 
													 {	
														echo $_SESSION['arraywhere_users']['user_jefe_id'];
													 }else{
														echo '';
													 } ?>"
										enable></th>

										<th><input id="genero" name="genero" type="text" class="form-control" 
										placeholder="<?php echo lang('users_genero');?>" 
										value="<?php if (isset($_SESSION['arraywhere_users']['genero'])) 
													 {	
														echo $_SESSION['arraywhere_users']['genero'];
													 }else{
														echo '';
													 } ?>"
										enable></th>



										<th><?php echo form_button(array('type' => 'submit', 'class' => 'btn btn-primary btn-flat', 'content' => ' Buscar Exp. ', 'id' => 'boton'));?>
										</th>


									<?php echo form_close();?>
									</tr>
								</thead>
								<tbody class="muestra_users">
								<?php 
									$i = 0;
									if (isset($users)): ?>
								
			<?php foreach ($users as $values):
										  $i = $i + 1;
			?>                          

										<!-- 
										<?php 
											/*
											if ($values->existe_grafico == 'N') {
												$bg = '#838383';
											} 
											*/
										?>
										-->
										<tr>

<!-- 
											<td>

												<?php //if ($values->existe_grafico == 0): ?>
													<a href="#" id='verparcela' onclick="return false">
														<i title="Sin gráfico" class="fa fa-map btn btn-xs bg-gray color-palette"></i>
													</a>
												<?php //endif ?>
												<?php //if ($values->existe_grafico > 0): ?>
													<a href="#" id='verparcela' onclick="existe_grafico(<?php //echo "'".$values->user_id_user."'".','.$values->expe_gestion ?>)">
														<i title="Ver Parcela" class="fa fa-map btn btn-xs bg-green color-palette"></i>
													</a>
												<?php //endif ?>
												<?php //echo '&nbsp;';?>

												<?php //echo anchor('users/users/ver_exp/'.$values->user_id, '<i title="Ver Expediente" class="fa fa-info-circle btn btn-xs bg-blue color-palette"></i>',array('disabled' => TRUE)); ?>

                                                <?php //echo '&nbsp;';?>

											</td>
-->

<?php<--
/*
	id
	ip_address 
	username
	email
	active
	first_name
	last_name
	company
    phone 
    nick 
    dependencia 
    user_jefe_id 
    genero 

*/
?>

											<td><?php echo htmlspecialchars($values->id, 				ENT_QUOTES, 'UTF-8'); ?></td>

											<td><?php echo htmlspecialchars($values->ip_address, 		ENT_QUOTES, 'UTF-8'); ?></td>

											<td><?php echo htmlspecialchars($values->username, 		    ENT_QUOTES, 'UTF-8'); ?></td>

											<td><?php echo htmlspecialchars($values->email, 			ENT_QUOTES, 'UTF-8'); ?></td>

											<td><?php echo htmlspecialchars($values->active, 			ENT_QUOTES, 'UTF-8'); ?></td>

											<td><?php echo htmlspecialchars($values->first_name, 		ENT_QUOTES, 'UTF-8'); ?></td>

											<td><?php echo htmlspecialchars($values->last_name, 		ENT_QUOTES, 'UTF-8'); ?></td>

											<td><?php echo htmlspecialchars($values->company, 			ENT_QUOTES, 'UTF-8'); ?></td>

											<td><?php echo htmlspecialchars($values->phone, 			ENT_QUOTES, 'UTF-8'); ?></td>

											<td><?php echo htmlspecialchars($values->nick, 		    	ENT_QUOTES, 'UTF-8'); ?></td>

											<td><?php echo htmlspecialchars($values->dependencia, 		ENT_QUOTES, 'UTF-8'); ?></td>

											<td><?php echo htmlspecialchars($values->user_jefe_id, 		ENT_QUOTES, 'UTF-8'); ?></td>
									
											<td><?php echo htmlspecialchars($values->genero, 			ENT_QUOTES, 'UTF-8'); ?></td>
												
											

										
												
												<!--<input type="hidden" id="<?php //echo 'expe_secuencia_'.$i; ?>" class="form-control">-->

											</td> 

											<td>
												<?php if ($values->existe_poligono == 0): ?>
													<a href="#" id='verparcela' onclick="return false">
														<i title="Sin gráfico" class="fa fa-map btn btn-xs bg-gray color-palette"></i>
													</a>
												<?php endif ?>
												<?php if ($values->existe_poligono > 0): ?>
													<a href="#" id='verparcela' onclick="existe_grafico_user_id(<?php echo $values->id ?>)">
														<i title="Ver Parcela" class="fa fa-map btn btn-xs bg-green color-palette"></i>
													</a>
												<?php endif ?>												
												<?php echo '&nbsp;';?>

												<?php echo anchor('users/users/ver_exp/'.$values->id, '<i title="Ver Expediente" class="fa fa-info-circle btn btn-xs bg-blue color-palette"></i>',array('disabled' => TRUE)); ?>

                                                <?php echo '&nbsp;';?>
 												
                                             
												<?php //if (grupo_usuario(18)) {
														echo anchor('users/users/edit_user/'.$values->id, '<i class="btn btn-xs bg-blue color-palette">EDIT.</i>'); 
													  //}
												?>

												<?php echo '&nbsp;';?>


												<?php //if ($values->grupo_usuario == 'N') {
														echo anchor('users/mantenimiento/user_mantenimiento/'.$values->id, '<i class="btn btn-xs bg-orange color-palette">MANT.</i>'); 
													  //}
												?>

												<?php echo '&nbsp;';?>

												
                                                <?php //if (grupo_usuario(16) or grupo_usuario(18)): ?>						
													<a href="#" onclick="eliminar_user(<?php echo $values->id?>)">
														<i class="fa fa-trash btn btn-xs bg-red color-palette"></i>
													</a>
												<?php //endif ?>
                                                <?php //echo anchor('', lang('actions_delete'), array('onclick' => 'eliminar_expe($values->user_id)')); ?>
											</td>

											<td></td>
										</tr>

			<?php endforeach;?>

								<?php else: ?>
									<tr>
										<td align="center" colspan="12"><b>No hay resultados</b></td>
									</tr>
								<?php endif ?>
								</tbody>
							</table>
							</div>
							<?php echo $pagination; ?>
						</div>
					</div>
				</div>
			</div>
		</div>
	</section>
</div>



