<?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>
                                Saldo
                            </h3>
                        </div>
                        <div class="box-content">
                            <div class="row">
                                <div class="col-sm-4">
                                    <div class="box box-color green box-condensed box-bordered">
                                        <div class="box-title" align="center">
                                            <h3>
                                                CHAVES DISPONÍVEIS
                                            </h3>
                                        </div>
                                        <div class="box-content">
                                            <div id="key_disponivel" align="center"><h4></h4></div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <div class="box box-color orange box-condensed box-bordered">
                                        <div class="box-title" align="center">
                                            <h3>
                                                CHAVES SOLICITADAS
                                            </h3>
                                        </div>
                                        <div class="box-content">
                                            <div id="key_solicitada" align="center"><h4></h4></div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <div class="box box-color blue box-condensed box-bordered">
                                        <div class="box-title" align="center">
                                            <h3>
                                                CHAVES COMPRADAS
                                            </h3>
                                        </div>
                                        <div class="box-content">
                                            <div id="key_comprada" align="center"><h4></h4></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function load_balance(){
        var Data = "&id=1";
        $.ajax({
            url: "<?= $router->route("finance.balanceKey"); ?>",
            data: Data,
            type: 'POST',
            dataType: 'json',
            beforeSend: load_in(),
            success: function (data) {
                $("#key_disponivel").html('<h4>'+data.countAvailable+'</h4>');
                $("#key_solicitada").html('<h4>'+data.countXml+'</h4>');
                $("#key_comprada").html('<h4>'+data.countKey+'</h4>');
                load_out();
            },
            error: function (request, status, error) {
                notify('Opss', 'Operação não pode ser finalizada!');
            }
        });
        return false;
    }
    $(function(){
        load_balance();
    });
</script>