Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16641 | Rev 16822 | 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->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));

$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.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 competencies_selected = new Array();

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

    
    
    
    //Dbujando la tabla con jrender
    // $.fn.renderCompetencies = function() {

    //     if(competencies_selected.length > 0) {

    //          $('#div-competencies').html($('#competencyTemplate').render(competencies_selected, {
    //             getCompetencyType: (uuid) => competency_types.filter((item) => item.uuid == uuid ? item : false)[0],
    //             getCompetency: (uuid) => competencies.filter((item) => item.uuid == uuid ? item : false)[0],
    //             getBehavior: (uuid) => behaviors.filter((item) => item.uuid == uuid ? item : false)[0]
    //         }));
    //     } else {


    //          $('#div-competencies').empty();
    //     }
    // }

    

    
    
    
    
    
    
    
    // draw empty chart
    var chartProgressByDay = new Chart(ctxchartProgressByDay, {
        type: 'line',
        data: {
            labels: [],
            datasets: [
                {
                        label : 'LABEL_CONTACT_PROGRESS_BY_DAY',
                                backgroundColor: '#E69090',
                    borderColor: '#E69090',
                    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
            },
        }).done(function(response) {
            if(response['success']) {
                //console.log(response.items[0].demo);
                var items = response.items;
                chartProgressByDay.data.labels = response.data.added_on;
                chartProgressByDay.data.datasets[0].data = response.data.total_by_day;
                chartProgressByDay.update();

                //Dibujamos la tabla
                var myTemplate = $.templates("#peopleTmpl");

                app = {
                    people: items
                };

                var html = myTemplate.render(app);

                $("#peopleList").html(html);
                
                
                










            }else{
                $.fn.showError(response);
            }
        }).fail(function( jqXHR, textStatus, errorThrown) {
            $.fn.showError(textStatus);
        }).always(function() {
            NProgress.done();
        });
        return false;
    }

    $('#filterdate').daterangepicker({
        maxDate: new Date(),
        locale: {
            format: 'DD/MM/YYYY',
            applyLabel: 'Aplicar',
            cancelLabel: 'Cancelar',
            daysOfWeek: ['Do', 'Lu','Ma', 'Mi', 'Ju', 'Vi', 'Sa'],
            monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo',   
                'Junio',     
                'Agosto',   
                'Septiembre',   
                'Octubre',   
                'Noviembre',   
                'Diciembre'
            ],
        }
    });

    //Datatable

    $('#gridTable').dataTable({
        'processing': true,
        'serverSide': true,
        'searching': true,
        'order': [[ 0, 'asc' ]],
        'ordering':  true,
        'ordenable' : true,
        'responsive': true,
        'select' : false,
        'paging': true,
        'pagingType': 'simple_numbers',
        'ajax': {
            'url' : '$routeOverview',
            'type' : 'get',
            'beforeSend': function (request) {
                NProgress.start();
            },
            'dataFilter': function(response) {
                var response = jQuery.parseJSON( response );
                
                var json                = {};
                json.recordsTotal       = 0;
                json.recordsFiltered    = 0;
                json.data               = [];
                
                if(response.success) {
                    json.recordsTotal       = response.data.total;
                    json.recordsFiltered    = response.data.total;
                    json.data               = response.items;
                } else {
                    $.fn.showError(response.data)
                }
                return JSON.stringify( json );
            }
        },
        // 'drawCallback': function( settings ) {
        //         NProgress.done();
        // },
        'aoColumns': [ 
            { 'mDataProp': "first_name"},
            { 'mDataProp': "last_name" },
            { 'mDataProp': "email" },
            { 'mDataProp': "total_by_day" },
            { 'mDataProp': "added_on" },
         ]

    });

    $('#filterdate').on('apply.daterangepicker', function(ev, picker) {
        startDate = picker.startDate.format('YYYY-MM-DD');
        endDate =picker.endDate.format('YYYY-MM-DD');
        
        $.ajax({
            'dataType'  : 'json',
            'accept'    : 'application/json',
            'method'    : 'post',
            'url'       :  '$routeOverview',
            'data'      :  {
                'startDate' : startDate,
                'endDate' : endDate
            },
            'processData': false,
            'contentType': false,
            success: function (response) {
                console.log('enviado');
            }
        });
        $.fn.reload();
    });

    $.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>LABEL_DAILY_PROGRESS_CHART</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>
</section>

<table class="table table-bordered" id="peopleList">

</table>

<script id="peopleTmpl" type="text/x-jsrender">
    <thead>
        <tr>
            <th>Usuario</th>
            {{for people}}
                <th>
                    {{:month}}
                </th>
            {{/for}}
        </tr>
    </thead>
    <tbody>
        {{for people}}
            <tr>
                <td>
                    {{:users}}
                </td>
                <td>
                    {{:total}}
                </td>
            </tr>
        {{/for}}
    </tbody>
    

    
</script>

<!-- <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>LABEL_CONTACT_JOURNAL_PROGRESS</h2>
                        <div class="form-group">
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-lg-12 col-12 chart">
                                <table id="gridTable" class="table table-striped table-hover">
                                    <thead>
                                        <tr>
                                            <th>LABEL_FIRST_NAME</th>
                                            <th>LABEL_LAST_NAME</th>
                                            <th>LABEL_EMAIL</th>
                                            <th>LABEL_ADDED</th>
                                            <th>LABEL_ADDED_DATE</th>
                                        </tr>
                                    </thead>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
</section> -->