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

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

	$persona_obj = new ClienteProveedor(null);
	$persona_inf = $persona_obj->informacionPersona(NULL, NULL, 1);
	$persona_obj->Close();
	?>
	<div class="row">
	<div class="col-sm-12" align="right">
		<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 </button>
	</div>
	</div>
	<table id="tablaClientesProveedores" class="table table-responsive table-hover table-condensed table-striped table-bordered" 
		style="border: 3px solid #DEE0E2;">
		<thead class="thead-default">
			<tr>
				<th width="10%">Rut</th>
				<th width="21%">Razón Social</th>
				<th width="8%">Cliente</th>
				<th width="8%">Proveedor<br/> Sils</th>
				<th width="8%">Proveedor<br/> Cliente</th>
				<th width="15%">Télf.Celular</th>				
				<th width="15%">Email</th>
				<th width="10%">Estado</th>
				<th width="10%">Opciones</th>
			</tr>
		</thead>
		<tbody><?php
			foreach ($persona_inf as $value) {?>		
				<tr>
					<td style="vertical-align: text-top; "><?php echo $value['pers_rut'];?></td>
					<td style="vertical-align: text-top;"><?php echo $value['pers_razon_social'];?></td>
					<td style="vertical-align: text-top;"><?php echo $value['pers_cliente_formato'];?></td>
					<td style="vertical-align: text-top;"><?php echo $value['pers_proveedorSils_formato'];?></td>
					<td style="vertical-align: text-top;"><?php echo $value['pers_proveedorCliente_formato'];?></td>
					<td style="vertical-align: text-top;"><?php echo $value['pers_telefono_celular'];?></td>
					<td style="vertical-align: text-top;"><?php echo $value['pers_email'];?></td>
					<td style="vertical-align: text-top;"><?php echo $value['pers_estado'];?></td>
					<td style="vertical-align: text-top; white-space: nowrap;"  class="row-actions"><?php 
						if($value['para_estado_UID'] == 100001){?>
							<a href="#" title="Aprobar solicitud" onclick="solicitaVerificar(<?php echo $value['pers_UID'];?>, 
								'<?php echo $value['pers_razon_social'];?>')"><i class="picons-thin-icon-thin-0663_like_thumb_up_vote" style="color:green;"></i></a>
							<a href="#" title="Rechazar solicitud" onclick="solicitaVerificar(<?php echo $value['pers_UID'];?>, 
								'<?php echo $value['pers_razon_social'];?>')"><i class="picons-thin-icon-thin-0664_dislike_thumb_down_vote" style="color:red;"></i></a><?php
						} else{?>
						<a href="#" title="Modificar" onclick="solicitaRecuperar(<?php echo $value['pers_UID'];?>, 
								'<?php echo $value['pers_razon_social'];?>')"><i class="os-icon os-icon-pencil-2" style="color:blue;"></i></a><?php
						if ($value['pers_registros'] == 0) {?>
							<a class="danger" href="#" title="Eliminar"
								onclick="solicita_eliminar(<?php echo $value['pers_UID'];?>, 
								'<?php echo $value['pers_razon_social'];?>')"><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 
}?>