<?php
if(empty($_GET['ajax'])){
    $v->layout("_themesis");
}
?>
<div class="container-fluid nav-hidden" id="content">
    <div id="">
        <div class="container-fluid">
            <div class="row">
                <div class="col-sm-12">
                    <div class="box">
                        <div class="box-title">
                            <h3>
                                XMLs
                                <a href="<?php echo url('xml_key_nfe/index');?>" class="btn btn-primary">VOLTAR</a>
                            </h3>
                        </div>
                        <div class="box-content">
                            <form class="wc_form" action="" method="POST">
                                <fieldset>
                                    <div class="row">
                                        <div class="form-group col-lg-12">
                                            <label>Tipo</label>
                                            <select name="lote_type" class="form-control">
                                                <option value="55">NFe</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="form-group col-lg-2" style="display: none">
                                            <label>ID CONTATO</label>
                                            <input type="number" class="form-control autocomplete_company_id"  name="xml_id_company" />
                                        </div>
                                        <div class="form-group col-lg-12">
                                            <label>ID CONTATO</label>
                                            <input type="text" class="form-control autocomplete_company" />
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="form-group col-lg-12">
                                            <label>Chaves</label>
                                            <textarea class="form-control" cols="10" rows="10" name="texto"></textarea>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="form-group col-lg-12" align="right">
                                            <button class="btn btn-primary">GRAVAR</button>
                                        </div>
                                    </div>
                                </fieldset>
                            </form>
                            <p>Importar as Chaves</p>
                            <pre>
12345646
12345646
12345646
12345646
12345646
12345646
12345646</pre>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $v->start("scripts"); ?>
<script type="text/javascript">
    $('.wc_form').submit(function () {
        var Form = $(this);
        var Data = Form.serialize();

        $.ajax({
            url: "<?= $router->route("xml_key_nfe.insert"); ?>",
            data: Data,
            type: 'POST',
            dataType: 'json',
            beforeSend: load_in(),
            success: function (data) {
                if(data[0].type === 'error'){
                    notify(data[0].title, data[0].message);
                }else{
                    notify(data[0].title, data[0].message);
                    setTimeOutPage('<?php echo url('xml_key_nfe/index');?>');
                }
                load_out();
            },
            error: function (request, status, error) {
                notify('Opss', 'Operação não pode ser finalizada!!');
            }
        });
        return false;
    });
</script>
<?php $v->end(); ?>
