<?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('expedientes/expedientes/create', '<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_expedientes" class="table table-striped table-hover">
								<thead>
									<tr>
										<th></th>
										<th></th>
										<th><?php echo lang('expedientes_expe_id_expediente');		?></th>
										<th><?php echo lang('expedientes_expe_gestion');			?></th>
										<th><?php echo 'Dependencia';								?></th>
										<th><?php echo 'Tipo Ref.';									?></th>
										<th><?php echo lang('expedientes_expe_proyecto');			?></th>
										<th><?php echo lang('expedientes_expe_proponente');			?></th>
										<th><?php echo lang('expedientes_expe_dpto_desc');			?></th>
										<th><?php echo lang('expedientes_expe_dist_desc');			?></th>
										<th><?php echo lang('expedientes_expe_consultor_nom');		?></th>
										<th><?php echo lang('expedientes_expe_entrada');			?></th>
										<th><?php echo lang('expedientes_expe_salida');				?></th>
										<th><?php echo 'Sec.';										?></th>

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

										<th><input id="expe_id_expediente" name="expe_id_expediente" type="text" class="form-control" 
										placeholder="<?php echo lang('expedientes_expe_id_expediente');?>" 
										value="<?php if (isset($_SESSION['arraywhere_expedientes']['expe_id_expediente'])) 
													 {	
														echo $_SESSION['arraywhere_expedientes']['expe_id_expediente'];
													 }else{
														echo '';
													 } ?>"
										enable autofocus maxlength="10"></th>

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

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

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

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

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

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

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

										<th><input id="expe_entrada" name="expe_entrada" type="text" class="form-control" 
										placeholder="<?php echo lang('expedientes_expe_entrada');?>" 
										value="<?php if (isset($_SESSION['arraywhere_expedientes']['expe_entrada'])) 
													 {	
														echo $_SESSION['arraywhere_expedientes']['expe_entrada'];
													 }else{
														echo '';
													 } ?>"
										enable data-provide="datepicker" data-date-format="yyyy-mm-dd"></th>

										<th><input id="expe_salida" name="expe_salida" type="text" class="form-control" 
										placeholder="<?php echo lang('expedientes_expe_salida');?>" 
										value="<?php if (isset($_SESSION['arraywhere_expedientes']['expe_salida'])) 
													 {	
														echo $_SESSION['arraywhere_expedientes']['expe_salida'];
													 }else{
														echo '';
													 } ?>"
										enable data-provide="datepicker"></th>

										<th><input id="expe_secuencia" name="expe_secuencia" type="text" class="form-control" 
										placeholder="<?php echo lang('expedientes_expe_secuencia');?>" 
										value="<?php if (isset($_SESSION['arraywhere_expedientes']['expe_secuencia'])) 
													 {	
														echo $_SESSION['arraywhere_expedientes']['expe_secuencia'];
													 }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_expedientes">
								<?php 
									$i = 0;
									if (isset($expedientes)): ?>
								
										<?php foreach ($expedientes as $values):
											$i = $i + 1;
										?>                          

										<tr>
											<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_expe_id(<?php echo $values->expe_id ?>)">
														<i title="Ver Parcela" class="fa fa-map btn btn-xs bg-green color-palette"></i>
													</a>
												<?php endif ?>												
												
												<?php echo anchor('expedientes/expedientes/ver_exp/'.$values->expe_id, '<i title="Ver Expediente" class="fa fa-info-circle btn btn-xs bg-blue color-palette"></i>',array('disabled' => TRUE)); ?>

                                                
												<?php if ($values->grupo_usuario == 'N' AND !grupo_usuario(32)): ?>
														<a href="#" id=<?php echo $values->expe_id;?> onclick="anular_salida(<?php echo $values->expe_id?>,<?php echo $values->expe_id_expediente?>,<?php echo $values->expe_gestion ?>)">
															<i title="Anular Salida" class="fa fa-info-circle btn btn-xs bg-red color-palette"></i>
														</a>
												<?php endif;?>

                                                <?php if (grupo_usuario(16) or grupo_usuario(18) ): ?>
                                                	<a href="#" id=<?php echo $values->expe_id;?> gestion=<?php echo $values->expe_gestion;?> expediente=<?php echo $values->expe_id_expediente;?> onclick="tiene_salida(this.id)">
														<i class="fa fa-pencil btn btn-xs bg-orange color-palette"></i>
													</a>
												<?php endif ?>
											</td>
											<td>
												<?php if (grupo_usuario(18)) {
														echo anchor('expedientes/expedientes/edit_expe/'.$values->expe_id, '<i class="btn btn-xs bg-blue color-palette">Edit.</i>'); 
													  }
												?>

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


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

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

												<?php if ($values->grupo_usuario == 'N' and ($values->expe_tipo_ref == 1 or $values->expe_tipo_ref == 2 or $values->expe_tipo_ref == 3)) {
														echo anchor('expedientes/licencia/expe_licencia/'.$values->expe_id, '<i class="btn btn-xs bg-green color-palette">Lic.</i>'); 
													  }
												?>

												<?php if ($values->grupo_usuario == 'N' and ($values->expe_tipo_ref == 4)) {
														echo anchor('expedientes/licencia/expe_resolucion/'.$values->expe_id, '<i class="btn btn-xs bg-blue color-palette">Res.</i>'); 
													  }
												?>

												<?php if ($values->grupo_usuario == 'N' and ($values->expe_tipo_ref == 7)) {
														echo anchor('expedientes/licencia/expe_resolucion/'.$values->expe_id, '<i class="btn btn-xs bg-red color-palette">AA.</i>'); 
													  }
												?>

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

                                                <?php if (grupo_usuario(16) or grupo_usuario(18)): ?>						
													<a href="#" onclick="eliminar_expe(<?php echo $values->expe_id?>,<?php echo $values->expe_id_expediente?>,<?php echo $values->expe_gestion ?>,<?php echo $values->expe_secuencia ?>,<?php echo $values->expe_secuencia ?>)">
														<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->expe_id)')); ?>
											</td>

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

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

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

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

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

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

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

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

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

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

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

											<td class="edit" id="<?php echo 'expe_secuencia_'.$i; ?>"><?php echo htmlspecialchars($values->expe_secuencia,		ENT_QUOTES, 'UTF-8'); ?>
												
												<!--<input type="hidden" id="<?php //echo 'expe_secuencia_'.$i; ?>" class="form-control">-->

											</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>



