<?php
if(!isset($_SESSION)) {
    session_start();
}

require_once($_SERVER['DOCUMENT_ROOT'].'/varios/varios.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/clases/Varios.Class.php');

if( Varios::isActiveSession() 
    && Varios::hasModuleAccess(8)
) {

	require_once($_SERVER['DOCUMENT_ROOT'].'/clases/Handheld.Class.php');

	$handheld_obj = new Handheld(null);
	$handheld_inf = $handheld_obj->informacionHandheld(NULL, NULL, 1);
	$handheld_obj->Close();
	?>
	<div class="row">
	<div class="col-sm-12" align="right"><?php
		if ( Varios::hasModuleActionAccess(8, 6) ) {?>
			<button class="btn btn-sm btn-primary" onclick="solicitaRecuperar(0)"><i class="picons-thin-icon-thin-0151_plus_add_new" 
				style="font-size:15px;color:white;"></i> Nuevo Handheld</button><?php
		}?>
	</div>
	</div>
	<table id="tablaHandheld" class="table table-responsive table-hover table-condensed table-striped table-bordered" 
		style="border: 3px solid #DEE0E2;">
		<thead class="thead-default">
			<tr>
				<th width="80%">Identifcador</th>
				<th width="20%">Estado</th>
				<th width="50%">Opciones</th>
			</tr>
		</thead>
		<tbody><?php
			foreach ($handheld_inf as $value) {?>		
				<tr>
					<td style="vertical-align: text-top;"><?php echo $value['hand_identificador'];?></td>
					<td style="vertical-align: text-top;"><?php echo $value['hand_estado'];?></td>
					<td style="vertical-align: text-top; white-space: nowrap;"  class="row-actions">	
						<a href="#" title="Modificar el handheld" onclick="solicitaRecuperar(<?php echo $value['hand_UID'];?>, 
								'<?php echo $value['hand_identificador'];?>')"><i class="os-icon os-icon-pencil-2" style="color:blue;"></i></a><?php
						if ($value['hand_registros'] == 0) {?>
							<a class="danger" href="#" title="Eliminar el handheld"
								onclick="funcionarioEliminarConfirmar('<?php echo Varios::codifica($value['hand_UID']);?>', 
								'<?php echo $value['hand_identificador'];?>')"><i class="picons-thin-icon-thin-0018_office_trash_bin" style="color:blue;"></i></a><?php											
						} else {?>
							<a class="disabled" href="#" title="No se puede eliminar porque está siendo ocupado"><i class="picons-thin-icon-thin-0018_office_trash_bin" 
										style="color:#aeb6bf;"></i></a><?php						
						}?>
					</td>
				</tr><?php
				
			}?>		
		</tbody>
	</table><?php 
}?>