<div class="content-wrapper">
    <section class="content-header">
        <h1>Nuevo Transportista</h1>
    </section>

    <section class="content">
        <div class="row">
            <div class="col-md-8">
                <div class="panel panel-primary">
                    <div class="panel-heading">
                        <strong>Formulario de registro</strong>
                    </div>
                    <div class="panel-body">

                        <?php if($this->session->flashdata('error')): ?>
                            <div class="alert alert-danger">
                                <?php echo $this->session->flashdata('error'); ?>
                            </div>
                        <?php endif; ?>

                        <?php echo validation_errors('<div class="alert alert-danger">', '</div>'); ?>

                        <form method="post" action="<?php echo base_url('index.php/mantenimiento/transportistas/store'); ?>" id="formTransportista">

                            <div class="form-group">
                                <label>RUC</label>
                                <input type="text"
                                       name="ruc"
                                       id="ruc"
                                       class="form-control"
                                       maxlength="11"
                                       value="<?php echo set_value('ruc'); ?>"
                                       required>
                            </div>

                            <div class="form-group">
                                <label>Razón Social</label>
                                <input type="text"
                                       name="razon_social"
                                       id="razon_social"
                                       class="form-control"
                                       maxlength="200"
                                       value="<?php echo set_value('razon_social'); ?>"
                                       required>
                            </div>

                            <div class="form-group">
                                <label>Nro. Registro MTC</label>
                                <input type="text"
                                       name="nro_registro_mtc"
                                       id="nro_registro_mtc"
                                       class="form-control"
                                       maxlength="50"
                                       value="<?php echo set_value('nro_registro_mtc'); ?>">
                            </div>

                            <div class="form-group">
                                <label>Entidad Emisora</label>
                                <select name="entidad_emisora_id" id="entidad_emisora_id" class="form-control" required>
                                    <option value="">Seleccione...</option>
                                    <?php foreach($entidades_emisoras as $item): ?>
                                        <option value="<?php echo $item->id; ?>" <?php echo set_select('entidad_emisora_id', $item->id); ?>>
                                            <?php echo $item->nombre; ?>
                                        </option>
                                    <?php endforeach; ?>
                                </select>
                            </div>

                            <div class="form-group">
                                <label>Nro. Autorización</label>
                                <input type="text"
                                       name="nro_autorizacion"
                                       id="nro_autorizacion"
                                       class="form-control"
                                       maxlength="50"
                                       value="<?php echo set_value('nro_autorizacion'); ?>">
                            </div>

                            <button type="submit" class="btn btn-primary">
                                <i class="fa fa-save"></i> Guardar
                            </button>

                            <a href="<?php echo base_url('index.php/mantenimiento/transportistas'); ?>" class="btn btn-default">
                                Cancelar
                            </a>

                        </form>

                    </div>
                </div>
            </div>
        </div>
    </section>
</div>

<script>
window.addEventListener('load', function () {

    document.getElementById('ruc').addEventListener('input', function() {
        this.value = this.value.replace(/[^0-9]/g, '');
    });

});
</script>