<?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">
        <?php if (isset($empresa)): ?>
             <div class="col-lg-12 col-md-12">
                 <div id="foto-candidato">
                     <div class="profile-header-container">   
                         <div class="profile-header-img">
                             <?= img($empresa->TEX_LOGO, '', ['class' => 'img-responsive img-circle', 'style' => 'width:200px'])
                             ?>
                             <!-- badge -->
                             <div class="rank-label-container">
                                 <span class="label label-default rank-label"><?= $empresa->TEX_NOMEMP ?></span>
                             </div>
                         </div>
                     </div> 
                 </div>
             </div>
         <?php endif; ?>
    </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_multipart(base_url('empresas'), $form_data); ?>
        <?php if (isset($empresa)): ?>
             <?= form_hidden('edit', 1) ?>
             <?= form_hidden('ID_EMPRESA', $empresa->ID_EMPRESA) ?>
         <?php endif; ?>
        <div class="col-lg-4 col-md-4">
            <div class="form-group input-type"> 
                <?php echo form_label('Nombre Empresa', 'TEX_NOMEMP', $attributes_labels); ?>
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-building"></i>
                    </div>
                    <?=
                     form_input(['name'     => 'TEX_NOMEMP',
                       'id'       => 'TEX_NOMEMP', 'class'    => 'form-control uppercase', 'onkeyup'  => 'uppercase(this.id);',
                       'required' => '', 'value'    => (isset($empresa->TEX_NOMEMP)) ? $empresa->TEX_NOMEMP : ''])
                    ?>   
                </div>
            </div> 
            <div class="form-group input-type"> 
                <?php echo form_label('NIT', 'COD_NIT', $attributes_labels); ?>
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-key"></i>
                    </div>
                    <?=
                     form_input(['name'     => 'COD_NIT',
                       'id'       => 'COD_NIT', 'class'    => 'form-control',
                       'required' => '', 'value'    => (isset($empresa->COD_NIT)) ? $empresa->COD_NIT : ''])
                    ?>   
                </div>
            </div>
            <div class="form-group input-type"> 
                <?php echo form_label('Logo', 'TEX_LOGO', $attributes_labels); ?>
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-image"></i>
                    </div>
                    <input type="hidden" name="TEX_LOGO"id="TEX_LOGO">
                    <?php $foto_required = (isset($empresa)) ? '' : 'required' ?>
                    <?=
                     form_upload(['name'           => 'upload_logo',
                       'id'             => 'upload_logo', 'class'          => 'form-control',
                       "$foto_required" => '', 'value'          => (isset($empresa->TEX_LOGO)) ? $empresa->TEX_LOGO : ''])
                    ?>   
                </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">
                        <option value=" ">Seleccione</option>
                        <?php foreach ($ciudades as $ciudad): ?>
                             <option style="font-weight: bold;"
                                     value="<?= $ciudad->COD_CIUDAD ?>"
                                     <?= ($ciudad->COD_CIUDAD === @$empresa->COD_CIUDAD) ? 'selected' : '' ?>>
                                 <?= $ciudad->TEX_NOMCIU ?></option>
                         <?php endforeach; ?>
                    </select> 
                </div>
            </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($empresa->COD_CIUDAD)) ? $empresa->COD_CIUDAD : ''     ?>">
            <?php
             //form_input(['name' => 'TEX_CIUDAD',
             //  'id' => 'TEX_CIUDAD', 'class' => 'form-control',
             //'required' => '', 'value' => (isset($empresa->TEX_NOMCIU)) ? $empresa->TEX_NOMCIU : ''])
            ?>  
                            </div>
                        </div> -->


        </div>
        <div class="col-lg-4 col-md-4">
            <div class="form-group input-type"> 
                <?php echo form_label('Dirección', 'TEX_DIREMP', $attributes_labels); ?>
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-home"></i>
                    </div>
                    <?=
                     form_input(['name'  => 'TEX_DIREMP',
                       'id'    => 'TEX_DIREMP', 'class' => 'form-control',
                       'value' => (isset($empresa->TEX_DIREMP)) ? $empresa->TEX_DIREMP : ''])
                    ?>   
                </div>
            </div> 
            <div class="form-group input-type"> 
                <?= form_label('Teléfono o Celular de Contacto', 'TEX_TELEMP', $attributes_labels); ?>
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-phone"></i>
                    </div>
                    <?=
                     form_input(['name'    => 'TEX_TELEMP', 'onkeyup' => 'uppercase(this.id);',
                       'id'      => 'TEX_TELEMP', 'class'   => 'form-control uppercase',
                       'value'   => (isset($empresa->TEX_TELEMP)) ? $empresa->TEX_TELEMP : ''])
                    ?>   
                </div>
            </div> 
            <div class="form-group input-type"> 
                <?php echo form_label('Celular Mesa de Ayuda', 'TEX_CELEMP', $attributes_labels); ?>
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-mobile"></i>
                    </div>
                    <?=
                     form_input(['name'  => 'TEX_CELEMP',
                       'id'    => 'TEX_CELEMP', 'class' => 'form-control',
                       'value' => (isset($empresa->TEX_CELEMP)) ? $empresa->TEX_CELEMP : ''
                     ])
                    ?>  
                </div>
            </div>
            <div class="form-group input-type"> 
                <?php echo form_label('Email', 'TEX_MAIEMP', $attributes_labels); ?>
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa">@</i>
                    </div>
                    <?=
                     form_input(['name'  => 'TEX_MAIEMP',
                       'id'    => 'TEX_MAIEMP', 'class' => 'form-control',
                       'value' => (isset($empresa->TEX_MAIEMP)) ? $empresa->TEX_MAIEMP : ''])
                    ?>   
                </div>
            </div> 
        </div>
    </div>
    <div class="row">
        <div class="col-lg-6 col-md-6">
            <div class="form-group input-type"> 
                <?= form_label('Observaciones', 'TEX_OBSERVACION', $attributes_labels); ?>
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="fa fa-calendar"></i>
                    </div>
                    <?=
                     form_textarea(['name'  => 'TEX_OBSERVACION',
                       'id'    => 'TEX_OBSERVACION', 'class' => 'form-control', 'rows'  => 3,
                       'value' => (isset($empresa->TEX_OBSERVACION)) ? $empresa->TEX_OBSERVACION : ''])
                    ?>   
                </div>
            </div> 
        </div>

    </div>
    <div class="row">
        <div class="boton-submit">
            <div class="input-group">
                <a href="<?php echo base_url('administrador') ?>" class="btn btn-danger" style="margin-right: 10px;">Regresar</a>
                <input type="submit" value="Guardar" class="btn btn-default">
            </div>
        </div>

    </div>
    <div class="row">
        <div class="col-lg-6 col-md-6 cajas contenedor-enlace-return">
            <a href="<?php echo base_url('empresas') ?>" class="back-link">Regresar a la lista de empresas</a>
        </div>
    </div>

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