<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <!-- Apple devices fullscreen -->
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <!-- Apple devices fullscreen -->
    <meta names="apple-mobile-web-app-status-bar-style" content="black-translucent" />

    <title>DOWNLOAD XML</title>

    <link rel="stylesheet" href="<?= asset("/_boot/css/bootstrap.min.css"); ?>">
    <link rel="stylesheet" href="<?= asset("/_boot/css/plugins/jquery-ui/jquery-ui.min.css"); ?>">

    <link rel="stylesheet" href="<?= asset("/_boot/css/plugins/colorbox/colorbox.css"); ?>">


    <link rel="stylesheet" href="<?= asset("/_boot/css/plugins/gritter/jquery.gritter.css"); ?>">
    <link rel="stylesheet" href="<?= asset("/_boot/css/plugins/timepicker/bootstrap-timepicker.min.css"); ?>">
    <link rel="stylesheet" href="<?= asset("/_boot/css/plugins/colorpicker/colorpicker.css"); ?>">
    <link rel="stylesheet" href="<?= asset("/_boot/css/plugins/datepicker/datepicker.css"); ?>">
    <link rel="stylesheet" href="<?= asset("/_boot/css/plugins/daterangepicker/daterangepicker.css"); ?>">
    <link rel="stylesheet" href="<?= asset("/_boot/css/plugins/icheck/all.css"); ?>">
    <link rel="stylesheet" href="<?= asset("/_boot/css/plugins/multiselect/multi-select.css"); ?>">
    <link rel="stylesheet" href="<?= asset("/_boot/css/plugins/chosen/chosen.css"); ?>">
    <link rel="stylesheet" href="<?= asset("/_boot/css/plugins/select2/select2.css"); ?>">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/css/bootstrap-multiselect.css" />

    <link rel="stylesheet" href="<?= asset("/_boot/css/style.css"); ?>">
    <link rel="stylesheet" href="<?= asset("/_boot/css/themes.css"); ?>">

    <link href="<?= asset("/uploader-master/dist/css/jquery.dm-uploader.min.css"); ?>" rel="stylesheet" />
    <link href="<?= asset("/uploader-master/demo/styles.css"); ?>" rel="stylesheet" />

    <link href="<?= asset("/shadowbox/shadowbox.css"); ?>" rel="stylesheet" />





    <script src="<?= asset("/_boot/js/jquery.min.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/jquery.form.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/plugins/nicescroll/jquery.nicescroll.min.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/plugins/jquery-ui/jquery-ui.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/plugins/imagesLoaded/jquery.imagesloaded.min.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/plugins/slimscroll/jquery.slimscroll.min.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/bootstrap.min.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/plugins/form/jquery.form.min.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/jquery.maskMoney.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/plugins/datepicker/bootstrap-datepicker.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/plugins/daterangepicker/moment.min.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/plugins/daterangepicker/daterangepicker.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/plugins/timepicker/bootstrap-timepicker.min.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/plugins/colorpicker/bootstrap-colorpicker.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/plugins/bootbox/jquery.bootbox.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/plugins/gritter/jquery.gritter.min.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/plugins/multiselect/jquery.multi-select.js"); ?>"></script>
    <script src="<?= asset("/_boot/jquery.blockUI.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/plugins/ckeditor/ckeditor.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/plugins/select2/select2.min.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/plugins/chosen/chosen.jquery.min.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/application.min.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/demonstration.min.js"); ?>"></script>



    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.2/bootstrap3-typeahead.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/js/bootstrap-multiselect.js"></script>

    <script src="<?= asset("/uploader-master/dist/js/jquery.dm-uploader.min.js"); ?>"></script>
    <script src="<?= asset("/uploader-master/demo/demo-ui.js"); ?>"></script>
    <script src="<?= asset("/uploader-master/demo/demo-config.js"); ?>"></script>

    <script src="<?= asset("/_boot/js/plugins/colorbox/jquery.colorbox-min.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/plugins/masonry/jquery.masonry.min.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/plugins/imagesLoaded/jquery.imagesloaded.min.js"); ?>"></script>

    <script src="<?= asset("/shadowbox/shadowbox.js"); ?>"></script>
    <script>
        $(function(){
            Shadowbox.init();
        });
    </script>

    <script>
        function trim(str) {
            return str.replace(/^\s+|\s+$/g, "");
        }
        $(document).ajaxStop($.unblockUI);
        function load_in() {
            $.blockUI({message: '<H1><img src="<?= asset("/load.gif"); ?>" /></H1><H1></H1>'});
        }
        function load_out() {
            $.unblockUI();
        }
        function notify(title, text) {
            if(title === 'Ops' || title === 'Opss'){
                var img = '<?= asset("/cancel.png"); ?>';
            }else{
                var img = '<?= asset("/confirm.png"); ?>';
            }
            var unique_id = $.gritter.add({
                title: title,
                image:img,
                text: text,
                sticky: false,
                time: '2000'
            });
            return false;
        }
        $(function(){
            document.body.style.zoom = "90%";
        });
    </script>
    <!-- tabulator -->
    <script type="text/javascript" src="<?= asset("/_boot/tabulator-master/tabulator.js"); ?>"></script>
    <link rel="stylesheet" href="<?= asset("/_boot/tabulator-master/tabulator.css"); ?>">

    <script type="text/javascript" src="<?= asset("/_boot/js/jquery.priceformat.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/jquery.mask.js"); ?>"></script>
    <script src="<?= asset("/_boot/js/jquery.mask.min.js"); ?>"></script>

    <script src="https://code.highcharts.com/highcharts.js"></script>
</head>
<body class="theme-grey" data-theme="theme-balck">
<div id="navigation">
    <div class="container-fluid">
        
    </div>
</div>
<div class="container-fluid nav-hidden carregar_paginas" id="content">
    <?= $v->section("content"); ?>
</div>
<script>
    function carrega_pagina(pasta, arquivo) {
        $.ajax({
            url: '../views/theme/' + pasta + '/' + arquivo + '?ajax=true',
            type: 'GET',
            beforeSend: load_in(),
            success: function (html) {
                $('.carregar_paginas').html(html);
                load_out();
            },
            error: function (jqXHR, textStatus, errorThrown) {
                load_out();
                notify('Erro', 'Houve uma falha de comunicação.');
            }
        });
        return false;
    }
    function carrega_pagina_new(pasta, arquivo) {
        $.post('../views/theme/' + pasta + '/' + arquivo + '', function (html) {
            $('#content_modal').html(html);
            load_out();
        });
    }
    
    function setTimeOutPage(url){
        setTimeout(function(){ 
            window.location = url;
        }, 2000);
    }
    
    function redirect(url){
        window.location = url;
    }

    function select_segmento(){
        var acao = "acao=load_segmento";
        $.ajax({
            type: 'POST',
            url: "<?= url("select/segmento"); ?>",
            data: acao,
            beforeSend: load_in(),
            success: function (data) {
                var data_return = jQuery.parseJSON(data);
                var options = '<option value=""></option>';
                for (var i = 0; i < data_return.data.length; i++) {
                    options += '<option value="' + data_return.data[i].segmento_id + '">' + data_return.data[i].segmento_descricao + '</option>';
                }
                $('.carrega_segmento').html(options).show();
                load_out();
            }
        });
        load_out();
    }

    function select_categoria(){
        var acao = "acao=load_categoria";
        $.ajax({
            type: 'POST',
            url: "<?= url("select/categoria"); ?>",
            data: acao,
            beforeSend: load_in(),
            success: function (data) {
                var data_return = jQuery.parseJSON(data);
                var options = '<option value=""></option>';
                for (var i = 0; i < data_return.data.length; i++) {
                    $('.carrega_categoria').append('<option value="' + data_return.data[i].categoria_id + '">' + data_return.data[i].categoria_descricao + '</option>');
                }
                $('.carrega_categoria').multiselect('rebuild');
                load_out();
            }
        });
        load_out();
    }

    function select_variacao(){
        var acao = "acao=load_variacao";
        $.ajax({
            type: 'POST',
            url: "<?= url("select/variacao"); ?>",
            data: acao,
            beforeSend: load_in(),
            success: function (data) {
                var data_return = jQuery.parseJSON(data);
                var options = '<option value=""></option>';
                for (var i = 0; i < data_return.data.length; i++) {
                    options += '<option value="' + data_return.data[i].variacao_id + '">' + data_return.data[i].variacao_descricao + '</option>';
                }
                $('.carrega_variacao').html(options).show();
                load_out();
            }
        });
        load_out();
    }

    function select_icone_categoria(){
        var acao = "acao=load_icone_categoria";
        $.ajax({
            type: 'POST',
            url: "<?= url("select/iconeCategoria"); ?>",
            data: acao,
            beforeSend: load_in(),
            success: function (data) {
                var data_return = jQuery.parseJSON(data);
                var options = '<option value=""></option>';
                for (var i = 0; i < data_return.data.length; i++) {
                    options += '<option value="' + data_return.data[i].icone_id + '">' + data_return.data[i].icone_descricao + '</option>';
                }
                $('.carrega_icone_categoria').html(options).show();
                load_out();
            }
        });
        load_out();
    }
    
    function select_marca(){
        var acao = "acao=load_marca";
        $.ajax({
            type: 'POST',
            url: "<?= url("select/marca"); ?>",
            data: acao,
            beforeSend: load_in(),
            success: function (data) {
                var data_return = jQuery.parseJSON(data);
                var options = '<option value=""></option>';
                for (var i = 0; i < data_return.data.length; i++) {
                    options += '<option value="' + data_return.data[i].marca_id + '">' + data_return.data[i].marca_descricao + '</option>';
                }
                $('.carrega_marca').html(options).show();
                load_out();
            }
        });
        load_out();
    }
    
    function select_categoria_pai(){
        var acao = "acao=load_categoria_pai";
        $.ajax({
            type: 'POST',
            url: "<?= url("select/categoriaPai"); ?>",
            data: acao,
            dataType: 'json',
            beforeSend: load_in(),
            success: function (data_return) {
                var options = '<option value="0">SEM PAI</option>';
                for (var i = 0; i < data_return.data.length; i++) {
                    options += '<option value="' + data_return.data[i].categoria_id + '">' + data_return.data[i].categoria_descricao + '</option>';
                }
                $('.carrega_categoria_pai').html(options).show();
                load_out();
            },
            error: function (request, status, error) {
                var options = '<option value="0">SEM PAI</option>';
                $('.carrega_categoria_pai').html(options).show();
            }
        });
        load_out();
    }

    function fazer_bkp(){
        var acao = "acao=fazer_bkp";
        $.ajax({
            type: 'POST',
            url: "<?= url("dump/bkp"); ?>",
            data: acao,
            beforeSend: load_in(),
            dataType: 'json',
            success: function (data) {
                if(data[0].type === 'error'){
                    notify(data[0].title, data[0].message);
                }else{
                    notify(data[0].title, data[0].message);
                }
                load_out();
            },
            error: function (request, status, error) {
                notify('Opss', 'Operação não pode ser finalizada!!');
            }
        });
        load_out();
    }

    $( ".autocomplete_produto" ).autocomplete({
        source: function( request, response ) {
            $.ajax({
                url: "<?= url("autocomplete/produto"); ?>",
                type: 'post',
                dataType: "json",
                data: {
                    search: request.term
                },
                success: function( data ) {
                    response( data );
                }
            });
        },
        minLength: 2,
        focus: function(event, ui) {
            event.preventDefault();
        },
        select: function( event, ui ) {
            $(".autocomplete_produto_id").val(ui.item.value);
            $(".autocomplete_produto").val(ui.item.label);

            carrega_variacao(ui.item.value);
            event.preventDefault();
        }
    });

    $( ".autocomplete_contato" ).autocomplete({
        source: function( request, response ) {
            $.ajax({
                url: "<?= url("autocomplete/contato"); ?>",
                type: 'post',
                dataType: "json",
                data: {
                    search: request.term
                },
                success: function( data ) {
                    response( data );
                }
            });
        },
        minLength: 2,
        focus: function(event, ui) {
            event.preventDefault();
        },
        select: function( event, ui ) {
            $(".autocomplete_contato_id").val(ui.item.value);
            $(".autocomplete_contato").val(ui.item.label);
            event.preventDefault();
        }
    });

    $('.telefone').mask('(00)000000000');
    $('.mask_telefone').mask('(00)000000000');
    $('.referencia_faturamento_mask').mask('00/0000');
    $('.mask_cep').mask('00000-000');
    $('.veiculo_placa').mask('AAA0000');
    $('.cpf').mask('000.000.000-00');
    $('.fipe').mask('000000-0');
    $(".mask_moeda").maskMoney({thousands: '', decimal: '.', allowZero:true});
    
    $(".mask_moeda_real").maskMoney({thousands: '.', decimal: ','});
    $(".mask_peso").maskMoney({thousands: '', decimal: '.', precision: 3, allowZero:true});
</script>
<?= $v->section("scripts"); ?>
</div>
</body>
</html>