<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
<?php $this->load->view('template/head.php'); ?>
<?php
 $this->load->view('template/header_admin.php');
?>
<section>
    <div id="container">
        <h3 class="text-center titulo"><?= $titulo ?></h3>
    </div>

       <div class="row contenedor-form caja-forms">
        <?php if (isset($lista)): ?>
             <div class="col-lg-12 col-md-12">
                 <div id="foto-lista">
                     <div class="profile-header-container">   
                         <div class="profile-header-img">
                             <?= img($lista->TEX_FOTO, '', ['class' => 'img-responsive img-circle', 'style'=>'    margin: 0 auto;']) ?>
                             <!-- badge -->
                             <div class="rank-label-container">
                                 <span class="label label-default rank-label"><?= $lista->TEX_NOMLIS ?></span>
                             </div>
                         </div>
                     </div> 
                 </div>
             </div>
         <?php endif; ?>
         </div>


    <div class="row contenedor-form caja-forms">
        <?php
         $form_data         = ['name'       => 'crear_form',
           'id'         => 'crear-form',
           'class'      => 'create-form',
           'novalidate' => '',
         ];
         $attributes_labels = ['class' => 'control-label'];
        ?>
        <?php echo form_open_multipart(base_url('listas/create'), $form_data); ?>
        <?php if (isset($lista)): ?>
             <?= form_hidden('edit', 1) ?>
             <?= form_hidden('ID_LISTA', $lista->ID_LISTA) ?>
         <?php endif; ?>

        <div class="col-lg-4 col-md-4">
            <div class="form-group input-type"> 
                <?php echo form_label('Nombre Lista', 'TEX_NOMLIS', $attributes_labels); ?>
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-list"></i>
                    </div>
                    <?=
                     form_input([
                       'name'     => 'TEX_NOMLIS',
                       'id'       => 'TEX_NOMLIS', 'class'    => 'form-control uppercase', 'onkeyup'  => 'uppercase(this.id);',
                       'required' => '', 'value'    => (isset($lista->TEX_NOMLIS)) ? $lista->TEX_NOMLIS : ''])
                    ?>   
                </div>
            </div>
            <div class="form-group input-type" style="width: 100%;"> 
                <?php echo form_label('Seleccione la Instancia', 'ID_INSTAN', $attributes_labels); ?>
                <div class="input-group" style="width: 100%;">
                    <div class="input-group-addon">
                        <i class="fa fa-building"></i>
                    </div>
                    <select name="ID_INSTAN"  id="ID_INSTAN" class="form-control">
                        <option value=" ">Seleccione</option>
                        <?php foreach ($instancias as $instan): ?>
                             <option style="font-weight: bold;" value="<?= $instan->ID_INSTAN ?>"
                                     <?= ($instan->ID_INSTAN === @$lista->ID_INSTAN) ? 'selected' : '' ?>>
                                 <?= $instan->TEX_NOMINS ?></option>
                         <?php endforeach; ?>
                    </select> 
                </div>
            </div>
            <div class="form-group input-type"> 
                <?php echo form_label('Orden de la Lista', 'NUM_ORDEN', $attributes_labels); ?>
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-navicon"></i>
                    </div>
                    <?=
                     form_input([
                       'name'     => 'NUM_ORDEN',
                       'id'       => 'NUM_ORDEN', 'class'    => 'form-control', 'type'     => 'number','min'     => 0,
                       'required' => '', 'value'    => (isset($lista->NUM_ORDEN)) ? $lista->NUM_ORDEN : ''])
                    ?>   
                </div>
            </div> 
            <div class="form-group input-type grupo-seleccion" style="<?= (@$lista->TEX_TIPLIS === 'LVP')?'':'display: none;' ?>"> 
                <?php echo form_label('Multiselección de listas (definir número)', 'NUM_MUSEIN', $attributes_labels); ?>
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-users"></i>
                    </div>
                    <?=
                     form_input([
                       'name'     => 'NUM_MUSEIN',
                       'id'       => 'NUM_MUSEIN',
                       'class'    => 'form-control',
                       'type'     => 'number',
                       'required' => '',
                       'value'    => (isset($lista->NUM_MUSEIN)) ? $lista->NUM_MUSEIN : ''])
                    ?>   
                </div>
            </div>
            <div class="boton-submit">
                <div class="input-group">
                    <a href="<?php echo base_url($route) ?>" class="btn btn-danger" style="margin-right: 10px;">Regresar</a>
                    <input type="submit" value="Guardar" class="btn btn-default"> 
                </div>  
            </div>
        </div>

        <div class="col-lg-4 col-md-4">
            <div class="form-group input-type" style="width: 100%;">
                <?php echo form_label('Tipo de Lista', 'TEX_TIPLIS', $attributes_labels); ?>
                <div class="input-group" style="width: 100%;">
                    <div class="input-group-addon">
                        <i class="fa fa-list"></i>
                    </div>
                    <select name="TEX_TIPLIS"  id="TEX_TIPLIS" onchange="validaMultiseleccion(this.id, this.value)" class="form-control <?= (@$lista->TEX_TIPLIS) ? 'disabled-select' : '' ?>" <?= (!@$lista->TEX_TIPLIS) ? 'required' : '' ?>>
                        <option value=" ">Seleccione Lista</option>
                        <option value="LCC" <?= (@$lista->TEX_TIPLIS === 'LCC') ? 'selected' : '' ?>>Lista Cerrada</option>
                        <option value="LVP" <?= (@$lista->TEX_TIPLIS === 'LVP') ? 'selected' : '' ?>>Lista Voto Preferente</option>
                    </select>
                </div>
            </div>

            <div class="form-group input-type" style="width: 100%;"> 
                <?php echo form_label('Seleccione la Ciudad', 'COD_CIUDAD', $attributes_labels); ?>
                <div class="input-group" style="width: 100%;">
                    <select name="COD_CIUDAD"  id="COD_CIUDAD" class="form-control" required="">
                        <option value=" ">Seleccione</option>
                        <?php foreach ($ciudades as $ciudad): ?>
                             <option style="font-weight: bold;"
                                     value="<?= $ciudad->COD_CIUDAD ?>"
                                     <?= ($ciudad->COD_CIUDAD === @$lista->COD_CIUDAD) ? 'selected' : '' ?>>
                                 <?= $ciudad->TEX_NOMCIU ?></option>
                         <?php endforeach; ?>
                    </select> 
                </div>
            </div>
            <div class="form-group input-type" style="width: 100%;"> 
                <?php echo form_label('Seleccione la '.$this->session->userdata('NOMBRE_SEGMENTO'), 'COD_AGENCIA', $attributes_labels); ?>
                <div class="input-group" style="width: 100%;">
                    <div class="input-group-addon">
                        <i class="fa fa-map-marker"></i>
                    </div>
                    <select name="COD_AGENCIA"  id="COD_AGENCIA" class="form-control" required="">
                        <option value=" ">Seleccione</option>
                        <?php foreach ($agencias as $agen): ?>
                             <option style="font-weight: bold;" value="<?= $agen->COD_AGENCIA ?>"
                                     <?= ($agen->COD_AGENCIA === @$lista->COD_AGENCIA) ? 'selected' : '' ?>>
                                 <?= $agen->TEX_NOMAGE ?></option>
                         <?php endforeach; ?>
                    </select> 
                </div>
            </div>

            <div class="form-group input-type"> 
                <?php echo form_label('Fotografía', 'TEX_FOTO', $attributes_labels); ?>
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-image"></i>
                    </div>
                    <input type="hidden" name="TEX_FOTO"id="TEX_FOTO">
                    <?=
                     form_upload([
                       'name'                                          => 'upload_foto',
                       'id'                                            => 'upload_foto', 'class'                                         => 'form-control',
                       (isset($lista->TEX_FOTO)) ? '' : 'required' => '', 'value'                                         => (isset($lista->TEX_FOTO)) ? $lista->TEX_FOTO : ''])
                    ?>   
                </div>
            </div>
        </div>

        <div class="col-lg-4 col-md-4">
            <div class="form-group input-type grupo-check-seleccion" style="<?= (@$lista->TEX_TIPLIS === 'LVP')?'':'display: none;' ?>> 
                <label for="BOL_OBLMUL" class="control-label input-group">Obliga selección total multiselección</label>
                <div class="btn-group" data-toggle="buttons">
                    <label class="switch btn btn-primary <?= (@$lista->BOL_OBLMUL) ? 'active' : '' ?>" data-toggle="button">
                        <?= form_radio('BOL_OBLMUL', '1', (@$lista->BOL_OBLMUL) ? true : '', 'class="bol-oblmul"') ?>Si
                    </label>
                    <label class="switch btn btn-primary <?= (@$lista->BOL_OBLMUL) ? '' : 'active' ?>" data-toggle="button">
                        <?= form_radio('BOL_OBLMUL', '0', (@$lista->BOL_OBLMUL) ? '' : true, 'class="bol-oblmul"') ?>No
                    </label>
                </div>
            </div>

                <div class="form-group input-type"> 
                <?php echo form_label('Texto perfil Lista', 'TEX_PERLIS', $attributes_labels); ?>
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-book"></i>
                    </div>
                    <?=
                     form_input(['name'     => 'TEX_PERLIS',
                       'id'       => 'TEX_PERLIS', 'class'    => 'form-control',
                        'value'    => (isset($lista->TEX_PERLIS)) ? $lista->TEX_PERLIS : ''])
                    ?>   
                </div>

            <!--            <div class="form-group input-type"> 
            <?php //echo form_label('Ciudad', 'TEX_CIUDAD', $attributes_labels); ?>
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <i class="fa fa-map-marker"></i>
                                </div>
                                <input type="hidden" name="COD_CIUDAD"id="COD_CIUDAD" 
                                       value="<?php // (isset($lista->COD_CIUDAD)) ? $lista->COD_CIUDAD : ''                                                              ?>">
            <?php
             //form_input(['name'     => 'TEX_CIUDAD',
             //'id'       => 'TEX_CIUDAD', 'class'    => 'form-control',
             //'required' => '', 'value'    => (isset($lista->TEX_NOMCIU)) ? $lista->TEX_NOMCIU : '', 'style'    => 'width:200px;'])
            ?>  
                            </div>
                        </div> -->
        </div>
    </div>
    <?php echo form_close(); ?>
</section>
<?php
 $data_view['loajs'] = $load_js;
 $this->load->view('template/footer.php', $data_view);
?>