<?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(6)
) {

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

	$purta_obj = new Puerta(null);
	$purta_inf = $purta_obj->informacionPuerta(NULL, NULL,1);
	$purta_obj->Close();
	?>
	<div class="row">
	<div class="col-sm-12" align="right"><?php
		if ( Varios::hasModuleActionAccess(6, 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> Nueva puerta</button><?php
		}?>
	</div>
	</div>
	<table id="tablaPuertas" class="table table-responsive table-hover table-condensed table-striped table-bordered" 
		style="border: 3px solid #DEE0E2;">
		<thead class="thead-default">
			<tr>
				<th width="15%">Bodega</th>
				<th width="15%">Código de Puerta</th>
				<th width="30%">Denominación</th>
				<th width="15%">Capacidad</th>
				<th width="15%">Prioridad</th>
				<th width="10%">Estado</th>
				<th width="10%">Opciones</th>
			</tr>
		</thead>
		<tbody><?php
			foreach ($purta_inf as $value) {?>		
				<tr>
					<td style="vertical-align: text-top;"><?php echo $value['puer_bodega_nombre'];?></td>
					<td style="vertical-align: text-top; "><?php echo $value['puer_codigo'];?></td>
					<td style="vertical-align: text-top;"><?php echo $value['puer_descripcion'];?></td>
					
					<td style="vertical-align: text-top; text-align:right"><?php echo $value['puer_capacidad'];?></td>
					<td style="vertical-align: text-top;"><?php echo $value['puer_prioridad'];?></td>
					<td style="vertical-align: text-top;"><?php echo $value['puer_estado_formato'];?></td>
					<td style="vertical-align: text-top; white-space: nowrap;"  class="row-actions"><?php
						if ( Varios::hasModuleActionAccess(6, 6) ) {?>
							<a href="#" title="Modificar la puerta" onclick="solicitaRecuperar(<?php echo $value['puer_UID'];?>, 
									'<?php echo $value['puer_descripcion'];?>')">
								<i class="os-icon os-icon-pencil-2" style="color:blue;"></i>
							</a><?php
						}

						if ( Varios::hasModuleActionAccess(6, 4) ) {
							if( $value['puer_registros'] == 0) {?>
								<a class="danger" href="#" title="Eliminar la puerta"
									onclick="puertaEliminarConfirmar('<?php echo varios::codifica($value['puer_UID']);?>', 
									'<?php echo $value['puer_descripcion'];?>')"><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 
}?>