Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15996 | Rev 16013 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

<?php

$routeOverview = $this->url('discovery-contacts/progress-by-day');
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.js'));

$this->headLink()->appendStylesheet($this->basePath('plugins/fontawesome-free/css/all.min.css'));
$this->headLink()->appendStylesheet($this->basePath('plugins/daterangepicker/daterangepicker.css'));
$this->inlineScript()->appendFile($this->basePath('plugins/moment/moment.min.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/daterangepicker/daterangepicker.js'));


$this->inlineScript()->appendFile($this->basePath('plugins/chart.js/chart.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/chartjs-plugin-datalabels/chartjs-plugin-datalabels.js'));

echo <<<CSS
CSS;
$this->headStyle()->captureEnd();

$this->inlineScript()->captureStart();
echo <<<JS
jQuery( document ).ready(function( $ ) {

    var startDate   = moment().format('YYYY-MM-DD'); 
    var endDate     = moment().format('YYYY-MM-DD'); 

    var ctxchartProgressByDay = document.getElementById("chartProgressByDay").getContext("2d");

    // draw empty chart
    var chartProgressByDay = new Chart(ctxchartProgressByDay, {
        type: 'bar',
        data: {
            labels: [],
            datasets: [
                {
                        label : 'LABEL_CHART_HOW_ARE_YOU_FEEL',
                                backgroundColor: '#E69090',
                    borderColor: '#E69090',
                    borderWidth: 1,
                    fill: false,
                    data : []
                },
                {
                        label : 'LABEL_CHART_CLIMATE_ON_YOUR_ORGANIZATION',
                    backgroundColor: '#66BBBB',
                                borderColor: '#66BBBB',
                                borderWidth: 1,
                    fill: false,
                    data : []
                },
            ]
        },
        options: {
            tooltips: {
                mode: 'index',
                intersect: false
            },
            scales: {
                yAxes: [{
                    ticks: {
                        beginAtZero:true
                    }
                }]
            }
        }
    });

    $.fn.reload = function() {
        NProgress.start();
        $.ajax({
            'dataType'  : 'json',
            'accept'    : 'application/json',
            'method'    : 'get',
            'url'       : '$routeOverview',
            'data'      :  {
                'startDate' : startDate,
                'endDate' : endDate
            },
            success: function (response) {
                console.log(chartProgressByDay.data.datasets[3].data = response['data']['added_on']);
                if(response['success']) {
                    chartProgressByDay.data.datasets[0].data = response['data']['added_on'];
                    chartProgressByDay.data.datasets[1].data = response['data']['total_by_day'];
                    chartProgressByDay.update();
                }else{
                    $.fn.showError(response['data']);
                }
            }
        }).fail(function( jqXHR, textStatus, errorThrown) {
            $.fn.showError(textStatus);
        }).always(function() {
            NProgress.done();
        });
        return false;
    }

    $.fn.reload();

});
JS;
$this->inlineScript()->captureEnd();
?>



<section class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-12" id="row-list">
                <div class="card">
                    <div class="card-header">
                        <h2>Progreso Diario de contactos</h2>
                        <div class="form-group">
                            <label>LABEL_DATE_RANGE</label>

                            <div class="input-group">
                                <div class="input-group-prepend">
                                    <span class="input-group-text"><i class="far fa-calendar"></i></span>
                                </div>
                                <input type="text" class="form-control float-right" name="filterdate" id="filterdate">
                            </div>
                            <!-- /.input group -->
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-lg-12 col-12 chart">
                                <canvas id="chartProgressByDay" style="min-height: 250px; height: 250px; max-height: 250px; max-width: 100%;"></canvas>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>