<?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 ?></h3>
    </div>
    <div class="row contenedor-form">
        <?php
         $form_data         = ['name'       => 'crear_form',
           'id'         => 'crear-form',
           'class'      => 'create-form',
           'novalidate' => '',
         ];
         $attributes_labels = ['class' => 'control-label'];
        ?>
        <?php echo form_open(base_url('departamentos/create'), $form_data); ?>
        <?php if (isset($departamento)): ?>
             <?= form_hidden('edit', 1) ?>
             <?= form_hidden('COD_DEPTO', $departamento->COD_DEPTO) ?>
         <?php endif; ?>
        <div class="col-lg-4 col-md-4" style="margin:0 auto;float:none;">
            <div class="form-group input-type"> 
                <?php echo form_label('Código del Departamento', 'COD_DEPTO', $attributes_labels); ?>
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-key"></i>
                    </div>
                    <?=
                     form_input(['name'     => 'COD_DEPTO', 'type'     => 'number',
                       'id'       => 'COD_DEPTO', 'class'    => 'form-control',
                       'required' => '', 'value'    => (isset($departamento->TEX_NOMDEPTO)) ? $departamento->COD_DEPTO : ''])
                    ?>   
                </div>
            </div> 
            <div class="form-group input-type"> 
                <?php echo form_label('Nombre del Departamento', 'TEX_NOMDEPTO', $attributes_labels); ?>
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-map-marker"></i>
                    </div>
                    <?=
                     form_input(['name'     => 'TEX_NOMDEPTO',
                       'id'       => 'TEX_NOMDEPTO', 'class'    => 'form-control uppercase',
                       'required' => '', 'onkeyup'  => 'uppercase(this.id);',
                       'value'    => (isset($departamento->TEX_NOMDEPTO)) ? $departamento->TEX_NOMDEPTO : ''])
                    ?>   
                </div>
            </div>
            <div class="form-group input-type" style="width: 100%;"> 
                <?php echo form_label('Seleccione el País', 'COD_PAIS', $attributes_labels); ?>
                <div class="input-group" style="width: 100%;">
                    <select name="COD_PAIS"  id="COD_PAIS" class="form-control">
                        <option value=" ">Seleccione</option>
                        <?php foreach ($paises as $pais): ?>
                             <option style="font-weight: bold;" value="<?= $pais->COD_PAIS ?>"
                                     <?= ($pais->COD_PAIS === @$departamento->COD_PAIS) ? 'selected' : '' ?>>
                                 <?= $pais->TEX_NOMPAIS ?></option>
                         <?php endforeach; ?>
                    </select> 
                </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>

    <?php echo form_close(); ?>
</section>
<?php
 $data_view['loajs'] = $load_js;
 $this->load->view('template/footer.php', $data_view);
?>

