<?php
$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>
                                Dashboard
                            </h3>
                        </div>
                        <div class="box-content">
                            <div class="row">
                                <?php
                                    if($_SESSION[SESSION]->user_nivel == '0'):
                                ?>
                                <div class="col-sm-3">
                                    <div class="box box-color box-bordered green">
                                        <div class="box-title" align="center" style="color: #FFFFFF">
                                            Saldo Guru
                                        </div>
                                        <div class="box-content">
                                            <h4 align="center">R$ <?php echo format_money(file_get_contents('http://api.captcha.guru/res.php?action=getbalance&key='.GURU));?></h4>
                                        </div>
                                    </div>
                                </div>
                                <?php
                                    endif;
                                ?>
                                <div class="col-sm-3">
                                    <div class="box box-color box-bordered orange">
                                        <div class="box-title" align="center" style="color: #FFFFFF">
                                            XMLs Pendentes (+)
                                        </div>
                                        <div class="box-content">
                                            <h4 align="center" class="venda_ticket_medio"><?php echo get_dashboard(0);?></h4>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-3">
                                    <div class="box box-color box-bordered grey">
                                        <div class="box-title" align="center" style="color: #FFFFFF">
                                            XMLs Cancelados (+)
                                        </div>
                                        <div class="box-content">
                                            <h4 align="center" class="venda_confirmada_mes_qtd"><?php echo get_dashboard(1);?></h4>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-3" style="display: none;">
                                    <div class="box box-color box-bordered blue">
                                        <div class="box-title" align="center" style="color: #FFFFFF">
                                            XMLs Baixados (+)
                                        </div>
                                        <div class="box-content">
                                            <h4 align="center" class="venda_aberto_qtd"></h4>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-3">
                                    <div class="box box-color box-bordered satblue">
                                        <div class="box-title" align="center" style="color: #FFFFFF">
                                            XMLs Erros (+)
                                        </div>
                                        <div class="box-content">
                                            <h4 align="center" class="venda_aberto_qtd"><?php echo get_dashboard(3);?></h4>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <hr />

                            <div class="row">
                                <?php
                                    if(get_autenticate(ID_LOG, 'user_atendimento') == 0):
                                ?>
                                        <div class="col-lg-12" align="center">
                                            <img src="<?php echo asset('robo_off.png');?>" width="256" />
                                            <br />
                                            <h3>Seu robô não está trabalhando - <strong><?php echo get_autenticate(ID_LOG, 'user_nome');?></strong></h3>
                                            <br />
                                            <button class="btn btn-success" onclick="manager_robot();">ATIVAR</button>
                                        </div>
                                <?php
                                    endif;
                                ?>

                                <?php
                                if(get_autenticate(ID_LOG, 'user_atendimento') == 1):
                                    ?>
                                    <div class="col-lg-12" align="center">
                                        <img src="<?php echo asset('robo_on.png');?>" width="256" />
                                        <br />
                                        <h3>Seu robô está trabalhando - <strong><?php echo get_autenticate(ID_LOG, 'user_nome');?></strong></h3>
                                        <br />
                                        <button class="btn btn-danger" onclick="manager_robot();">DESATIVAR</button>
                                    </div>
                                <?php
                                endif;
                                ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $v->start("scripts"); ?>
    <script type="text/javascript">
        function manager_robot(){
            var Data = "&id=0";
            $.ajax({
                url: "<?= url('config/manageRobot'); ?>",
                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();?>');
                    }
                    load_out();
                },
                error: function (request, status, error) {
                    notify('Opss', 'Operação não pode ser finalizada!');
                }
            });
            return false;
        }
    </script>
<?php $v->end(); ?>
