<?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('memos/memos/create', 'CREAR NUEVO', array('class' => 'btn btn-alert')); ?>
                </div>
              </div>
              <?php endif; ?>
              <div class="panel panel-default">
                <div class="panel-body">
                  <div style="overflow-y: scroll;">
                    <table id="tabla_memos" class="table table-striped table-hover" style="width: 100%;">
                      <thead>
                        <tr class="colorMOPC">
                          <th><?php echo lang('memos_id_memo');                                  ?></th>
                          <th><?php echo lang('memos_nro_memo');                                 ?></th>
                          <th><?php echo lang('memos_anho_memo');                                ?></th>
                          <th><?php echo lang('memos_id_emisor');                                ?></th>
                          <th><?php echo lang('memos_id_receptor');                              ?></th>
                          <th><?php echo lang('memos_referencia');                               ?></th>
                          <th><?php echo lang('memos_descripcion');                              ?></th>
                          <th><?php echo lang('memos_fecha');                                    ?></th>
                          <th><?php echo lang('memos_id_usuario');                               ?></th>
                          <th><?php echo anchor('memos/memos/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_memo' => 'form-create_memo')); ?>
                          <th><input id="id_memo" name="id_memo" type="number" max="9999" min="0" class="form-control" placeholder="<?php echo ('ID');?>" 
                            value="<?php if (isset($_SESSION['arraywhere_memos']['id_memo'])) {
                              echo $_SESSION['arraywhere_memos']['id_memo'];
                                 } else {
                                     echo '';
                                 } ?>"
                            enable></th>
                          <th><input id="nro_memo" name="nro_memo" type="text" class="form-control" 
                          placeholder="<?php echo lang('memos_nro_memo');?>" 
                          value="<?php if (isset($_SESSION['arraywhere_memos']['nro_memo'])) {
                            echo $_SESSION['arraywhere_memos']['nro_memo'];
                               } else {
                                   echo '';
                               } ?>"
                          enable></th>
                          <th><input id="anho_memo" name="anho_memo" type="number" max="9999" min="0" class="form-control" placeholder="<?php echo lang('memos_anho_memo');?>" 
                            value="<?php if (isset($_SESSION['arraywhere_memos']['anho_memo'])) {
                              echo $_SESSION['arraywhere_memos']['anho_memo'];
                                 } else {
                                     echo '';
                                 } ?>"
                            enable></th>
                          <th><input id="id_emisor" name="id_emisor" type="text" class="form-control" placeholder="<?php echo lang('memos_id_emisor');?>"
                            value="<?php if (isset($_SESSION['arraywhere_memos']['id_emisor'])) {
                              echo $_SESSION['arraywhere_memos']['id_emisor'];
                                 } else {
                                     echo '';
                                 } ?>"
                            enable></th>
                            <th><input id="id_receptor" name="id_receptor" type="text" class="form-control" placeholder="<?php echo lang('memos_id_receptor');?>"
                            value="<?php if (isset($_SESSION['arraywhere_memos']['id_receptor'])) {
                              echo $_SESSION['arraywhere_memos']['id_receptor'];
                                 } else {
                                     echo '';
                                 } ?>"
                            enable></th>
                            <th><input id="referencia" name="referencia" type="text" class="form-control" 
                            placeholder="<?php echo lang('memos_referencia');?>" 
                            value="<?php if (isset($_SESSION['arraywhere_memos']['referencia'])) {
                              echo $_SESSION['arraywhere_memos']['referencia'];
                                 } else {
                                     echo '';
                                 } ?>"
                            enable></th>
                            <th><input id="descripcion" name="descripcion" type="text" class="form-control" 
                            placeholder="<?php echo lang('memos_descripcion');?>" 
                            value="<?php if (isset($_SESSION['arraywhere_memos']['descripcion'])) {
                              echo $_SESSION['arraywhere_memos']['descripcion'];
                                 } else {
                                     echo '';
                                 } ?>"
                            enable></th>
                            <th><input id="fecha" name="fecha" type="text" class="form-control" 
                            placeholder="<?php echo lang('memos_fecha');?>" 
                            value="<?php if (isset($_SESSION['arraywhere_memos']['fecha'])) {
                              echo $_SESSION['arraywhere_memos']['fecha'];
                                 } else {
                                     echo '';
                                 } ?>"
                            enable></th>
                            <th><input id="id_usuario" name="id_usuario" type="text" class="form-control" 
                            placeholder="<?php echo lang('memos_id_usuario');?>" 
                            value="<?php if (isset($_SESSION['arraywhere_memos']['id_usuario'])) {
                              echo $_SESSION['arraywhere_memos']['id_usuario'];
                                 } else {
                                     echo '';
                                 } ?>"
                            enable></th>
                            
                          
                          
                          <th><?php echo form_button(array('type' => 'submit', 'class' => 'btn btn-primary', 'content' => 'BUSCAR', 'id_memo' => 'boton'));?>
                          </th>
                          <?php echo form_close();?>
                        </tr>
                      </thead>
                      <tbody class="muestra_memos">
                        <?php
                          $i = 0;
                          if (isset($memos)) : ?>
                        <?php foreach ($memos as $values) :
                          $i = $i + 1;
                          ?>                          
                        <tr>
                          <td><?php echo htmlspecialchars($values->id_memo, ENT_QUOTES, 'UTF-8'); ?></td>
                          <td><?php echo htmlspecialchars($values->nro_memo, ENT_QUOTES, 'UTF-8'); ?></td>
                          <td><?php echo htmlspecialchars($values->anho_memo, ENT_QUOTES, 'UTF-8'); ?></td>
                          <td><?php echo htmlspecialchars($values->id_emisor, ENT_QUOTES, 'UTF-8'); ?></td>
                          <td><?php echo htmlspecialchars($values->id_receptor, ENT_QUOTES, 'UTF-8'); ?></td>
                          <td><?php echo htmlspecialchars($values->referencia, ENT_QUOTES, 'UTF-8'); ?></td>
                          <td><?php echo htmlspecialchars($values->descripcion, ENT_QUOTES, 'UTF-8'); ?></td>
                          <td><?php echo htmlspecialchars($values->fecha, ENT_QUOTES, 'UTF-8'); ?></td>
                          <td><?php echo htmlspecialchars($values->id_usuario, ENT_QUOTES, 'UTF-8'); ?></td>
                          </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>
                                    <tr><?php //echo anchor('proyectos/mantenimiento/vergrafico/'.$values->id_proyecto, '<button class="btn btn-primary btn-xs">VER</button>', array('disabled' => true)); ?></tr>
                                    <tr><?php if (grupo_usuario(3)) {
                                      echo anchor('memos/memos/edit_memo/'.$values->id_memo, '<button class="btn btn-xs btn-orange"> <i class="fa fa-edit btn btn-xs bg-orange color-palette"></i>  </button>');
                                      }
                                      ?></tr>
                                      
                                      <tr>
                                        <?php echo '&nbsp;';?>
                                        <?php echo anchor('memos/memos/imprimir_pdf/'.$values->id_memo, '<button class="btn btn-danger btn-xs"> <i class="fa fa-file-pdf-o" aria-hidden="true"></i> </button>', array('disabled' => true)); ?>
                                      </tr>                                    
                                      <tr>
                                        <?php //if (grupo_usuario(3)) {
                                          //echo anchor('proyectos/mantenimiento/proyecto_mantenimiento/'.$values->id_proyecto, '<button class="btn btn-xs btn-primary">MANTENIMIENTO</button>');
                                         // }
                                          ?>
                                      </tr>
                                  </tbody>
                                </table>
                              </div>
                            </div>
                          </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>