<?php
  defined('BASEPATH') or exit('No direct script access allowed');
  
  ?>
<div class="content-wrapper" style="overflow-y: scroll;">
  <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-body">
              <?php     if (!empty($message)) {
                echo '<pre>';
                echo '<b>'.$message.'</b>';
                echo '</pre>';
                }
                ?>
              <?php if (grupo_usuario(3)) : ?>
              <div class="panel panel-default">
                <div class="panel-body">
                  <?php echo anchor('tramos/tramos/create', 'Crear', array('class' => 'btn btn-alert ')); ?>
                </div>
              </div>
              <?php endif; ?>
              <div class="panel panel-default">
                <div class="panel-body">
                  <div style="overflow-y: visible;">
                    <table id="tabla_tramo" class="table table-striped table-hover" style="width: 100%;">
                      <thead>
                        <tr class="colorMOPC">
                          <?php
                            /*
                            
                                id_tramo
                                cod_geografico
                                nombre
                                fecha
                                hora
                                usuario
                            */
                                ;?>
                          <th><?php echo lang('tramos_id_tramo');                           ?></th>
                          <th><?php echo lang('tramos_cod_geografico');                 ?></th>
                          <th><?php echo lang('tramos_nombre');                         ?></th>
                          <th><?php echo lang('tramos_fecha');                          ?></th>
                          <th><?php echo lang('tramos_hora');                               ?></th>
                          <th><?php echo lang('tramos_usuario');                            ?></th>
                          <th><?php echo anchor('tramo/tramo/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_tramo')); ?>
                          <th><input id="id_tramo" name="id" type="number" max="9999" min="0" class="form-control" placeholder="<?php echo lang('tramos_id_tramo');?>" 
                            value="<?php if (isset($_SESSION['arraywhere_tramo']['id_tramo'])) {
                              echo $_SESSION['arraywhere_tramo']['id_tramo'];
                                 } else {
                                     echo '';
                                 } ?>"
                            enable></th>
                          <th><input id="cod_geografico" name="cod_geografico" type="text" class="form-control" placeholder="<?php echo lang('tramos_cod_geografico');?>"
                            value="<?php if (isset($_SESSION['arraywhere_tramo']['cod_geografico'])) {
                              echo $_SESSION['arraywhere_tramo']['cod_geografico'];
                                 } else {
                                     echo '';
                                 } ?>"
                            enable></th>
                          <th><input id="nombre" name="nombre" type="text" class="form-control" placeholder="<?php echo lang('tramos_nombre');?>" 
                            value="<?php if (isset($_SESSION['arraywhere_tramo']['nombre'])) {
                              echo $_SESSION['arraywhere_tramo']['nombre'];
                                 } else {
                                     echo '';
                                 } ?>"
                            enable></th>
                          <th><input id="fecha" name="fecha" type="text" class="form-control" placeholder="<?php echo 'Fecha';?>" 
                            value="<?php if (isset($_SESSION['arraywhere_tramo']['fecha'])) {
                              echo $_SESSION['arraywhere_tramo']['fecha'];
                                 } else {
                                     echo '';
                                 } ?>"
                            enable></th>
                          <th><input id="hora" name="hora" type="text" class="form-control" 
                            placeholder="<?php echo lang('tramos_hora');?>" 
                            value="<?php if (isset($_SESSION['arraywhere_tramo']['hora'])) {
                              echo $_SESSION['arraywhere_tramo']['hora'];
                                 } else {
                                     echo '';
                                 } ?>"
                            enable></th>
                          <th><input id="usuario" name="usuario" type="text" class="form-control" 
                            placeholder="<?php echo lang('tramos_usuario');?>" 
                            value="<?php if (isset($_SESSION['arraywhere_tramo']['usuario'])) {
                              echo $_SESSION['arraywhere_tramo']['usuario'];
                                 } else {
                                     echo '';
                                 } ?>"
                            enable></th>
                          <th><?php echo form_button(array('type' => 'submit', 'class' => 'btn btn-primary ', 'content' => ' Buscar Exp. ', 'id' => 'boton'));?>
                          </th>
                          <?php echo form_close();?>
                        </tr>
                      </thead>
                      <tbody class="muestra_tramo">
                        <?php
                          $i = 0;
                          if (isset($tramos)) : ?>
                        <?php foreach ($tramos 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->expe_id_expediente."'".','.$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('tramo/tramo/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 //echo '&nbsp;';?>
                            
                            </td>
                            -->
                          <td><?php echo htmlspecialchars($values->id_tramo, ENT_QUOTES, 'UTF-8'); ?></td>
                          <td><?php echo htmlspecialchars($values->cod_geografico, ENT_QUOTES, 'UTF-8'); ?></td>
                          <td><?php echo htmlspecialchars($values->nombre, ENT_QUOTES, 'UTF-8'); ?></td>
                          <td><?php echo htmlspecialchars($values->fecha, ENT_QUOTES, 'UTF-8'); ?></td>
                          <td><?php echo htmlspecialchars($values->hora, ENT_QUOTES, 'UTF-8'); ?></td>
                          <td><?php echo htmlspecialchars($values->usuario, ENT_QUOTES, 'UTF-8'); ?></td>
                          <!--<input type="hidden" id="<?php //echo 'expe_secuencia_'.$i; ?>" class="form-control">-->
                          </td> 
                          <td>
                            <div class="btn-group">
                              <button type="button" class="btn btn-flat dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Acciones<span class="caret"></span>
                              </button>
                              <div class="dropdown-menu pull-right">
                                <table class="tablaCentrada"  style="width: 100%;">
                                  <tbody>
                                    <td><?php echo anchor('tramos/mantenimiento/vergrafico/'.$values->id_tramo, '<button class="btn btn-primary btn-xs">VER</button>', array('disabled' => true)); ?></td>
                                    <?php if (grupo_usuario(3)) : ?>
                                    <td><?php echo anchor('tramos/tramos/edit_tramo/'.$values->id_tramo, '<button class="btn btn-primary btn-xs">EDITAR</button>'); ?></td>
                                    <td><?php echo anchor('tramos/mantenimiento/tramo_mantenimiento/'.$values->id_tramo, '<button class="btn btn-primary btn-xs">MANTENIMIENTO</button>'); ?></td>
                                    <td><a href="#" onclick="eliminar_expe(<?php echo $values->id_tramo?>)"><button class="btn btn-alert btn-xs">ELIMINAR</button></a></td>
                                    <?php endif; ?>
                                  </tbody>
                                </table>
                              </div>
                            </div>
                            <?php //if ($values->existe_poligono == 0): ?>
                            <!--a href="#" id='vertramos' 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_id_tramo(<?php echo $values->id_tramo ?>)">
                              <i title="Ver Tramo" class="fa fa-map btn btn-xs bg-green color-palette"></i>
                              </a-->
                            <?php //endif ?>                                            
                            <?php //echo '&nbsp;';?>    
                            <?php //echo anchor('', lang('actions_delete'), array('onclick' => 'eliminar_expe($values->expe_id)')); ?>
                          </td>
                        </tr>
                        <?php endforeach;?>
                        <?php else : ?>
                        <tr>
                          <td align="center" colspan="12"><b>No hay resultados</b></td>
                        </tr>
                        <?php endif ?>
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
              <?php echo $pagination; ?>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
</div>