Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16604 | Rev 16606 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
15760 anderson 1
<?php
15759 anderson 2
 
16040 anderson 3
$routeOverview = $this->url('discovery-contacts/progress-by-day');
15760 anderson 4
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
5
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
15857 anderson 6
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.js'));
15760 anderson 7
 
15857 anderson 8
$this->headLink()->appendStylesheet($this->basePath('plugins/fontawesome-free/css/all.min.css'));
9
$this->headLink()->appendStylesheet($this->basePath('plugins/daterangepicker/daterangepicker.css'));
10
$this->inlineScript()->appendFile($this->basePath('plugins/moment/moment.min.js'));
11
$this->inlineScript()->appendFile($this->basePath('plugins/daterangepicker/daterangepicker.js'));
15760 anderson 12
 
16370 anderson 13
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
15760 anderson 14
 
16370 anderson 15
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
16
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
17
 
18
 
15857 anderson 19
$this->inlineScript()->appendFile($this->basePath('plugins/chart.js/chart.js'));
20
$this->inlineScript()->appendFile($this->basePath('plugins/chartjs-plugin-datalabels/chartjs-plugin-datalabels.js'));
15760 anderson 21
 
22
echo <<<CSS
23
CSS;
24
$this->headStyle()->captureEnd();
25
 
26
$this->inlineScript()->captureStart();
27
echo <<<JS
15857 anderson 28
jQuery( document ).ready(function( $ ) {
15760 anderson 29
 
15857 anderson 30
    var startDate   = moment().format('YYYY-MM-DD');
31
    var endDate     = moment().format('YYYY-MM-DD');
16561 anderson 32
    var competencies_selected = new Array();
15760 anderson 33
 
16047 anderson 34
    var ctxchartProgressByDay = document.getElementById("chartProgressByDay").getContext("2d");
15857 anderson 35
 
16560 anderson 36
 
37
 
38
 
39
    //Dbujando la tabla con jrender
16563 anderson 40
    // $.fn.renderCompetencies = function() {
16560 anderson 41
 
16563 anderson 42
    //     if(competencies_selected.length > 0) {
16560 anderson 43
 
16563 anderson 44
    //          $('#div-competencies').html($('#competencyTemplate').render(competencies_selected, {
45
    //             getCompetencyType: (uuid) => competency_types.filter((item) => item.uuid == uuid ? item : false)[0],
46
    //             getCompetency: (uuid) => competencies.filter((item) => item.uuid == uuid ? item : false)[0],
47
    //             getBehavior: (uuid) => behaviors.filter((item) => item.uuid == uuid ? item : false)[0]
48
    //         }));
49
    //     } else {
16560 anderson 50
 
51
 
16563 anderson 52
    //          $('#div-competencies').empty();
53
    //     }
54
    // }
55
 
16569 anderson 56
 
16565 anderson 57
 
16560 anderson 58
 
59
 
60
 
61
 
62
 
63
 
16564 anderson 64
 
15857 anderson 65
    // draw empty chart
16047 anderson 66
    var chartProgressByDay = new Chart(ctxchartProgressByDay, {
16236 anderson 67
        type: 'line',
15857 anderson 68
        data: {
16218 anderson 69
            labels: [],
15857 anderson 70
            datasets: [
71
                {
16232 anderson 72
                	label : 'LABEL_CONTACT_PROGRESS_BY_DAY',
16090 anderson 73
         			backgroundColor: '#E69090',
74
                    borderColor: '#E69090',
75
                    borderWidth: 1,
76
                    fill: false,
16221 anderson 77
                    data : []
16090 anderson 78
              	},
15857 anderson 79
            ]
80
        },
81
        options: {
82
            tooltips: {
83
                mode: 'index',
84
                intersect: false
15760 anderson 85
            },
15857 anderson 86
            scales: {
87
                yAxes: [{
88
                    ticks: {
89
                        beginAtZero:true
15760 anderson 90
                    }
15857 anderson 91
                }]
92
            }
93
        }
94
    });
16047 anderson 95
 
96
    $.fn.reload = function() {
97
        NProgress.start();
98
        $.ajax({
99
            'dataType'  : 'json',
100
            'accept'    : 'application/json',
101
            'method'    : 'get',
102
            'url'       : '$routeOverview',
103
            'data'      :  {
104
                'startDate' : startDate,
105
                'endDate' : endDate
106
            },
107
        }).done(function(response) {
16221 anderson 108
            if(response['success']) {
16598 anderson 109
                //console.log(response.items[0].demo);
16572 anderson 110
                var items = response.items;
16219 anderson 111
                chartProgressByDay.data.labels = response.data.added_on;
16220 anderson 112
                chartProgressByDay.data.datasets[0].data = response.data.total_by_day;
16221 anderson 113
                chartProgressByDay.update();
16569 anderson 114
 
115
 
16582 anderson 116
 
16569 anderson 117
 
118
 
119
                //Dibujamos la tabla
120
                var myTemplate = $.templates("#personTmpl");
121
 
16602 anderson 122
 
16605 anderson 123
                    var people =  items ;
16595 anderson 124
                    var html = myTemplate.render(people);
16585 anderson 125
                    $("#peopleList").html(html);
16577 anderson 126
 
127
 
16583 anderson 128
 
16569 anderson 129
 
130
 
131
 
132
 
133
 
134
 
135
 
136
 
137
 
138
 
16031 anderson 139
            }else{
16183 anderson 140
                $.fn.showError(response);
16031 anderson 141
            }
15987 anderson 142
        }).fail(function( jqXHR, textStatus, errorThrown) {
143
            $.fn.showError(textStatus);
144
        }).always(function() {
145
            NProgress.done();
15872 anderson 146
        });
15987 anderson 147
        return false;
15872 anderson 148
    }
149
 
16028 anderson 150
    $('#filterdate').daterangepicker({
151
        maxDate: new Date(),
152
        locale: {
153
            format: 'DD/MM/YYYY',
154
            applyLabel: 'Aplicar',
155
            cancelLabel: 'Cancelar',
156
            daysOfWeek: ['Do', 'Lu','Ma', 'Mi', 'Ju', 'Vi', 'Sa'],
157
            monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo',
158
                'Junio',
159
                'Agosto',
160
                'Septiembre',
161
                'Octubre',
162
                'Noviembre',
163
                'Diciembre'
164
            ],
165
        }
166
    });
167
 
16381 anderson 168
    //Datatable
169
 
16435 anderson 170
    $('#gridTable').dataTable({
16420 anderson 171
        'processing': true,
172
        'serverSide': true,
16436 anderson 173
        'searching': true,
174
        'order': [[ 0, 'asc' ]],
175
        'ordering':  true,
176
        'ordenable' : true,
177
        'responsive': true,
178
        'select' : false,
179
        'paging': true,
180
        'pagingType': 'simple_numbers',
16439 anderson 181
        'ajax': {
16441 anderson 182
            'url' : '$routeOverview',
183
            'type' : 'get',
184
            'beforeSend': function (request) {
185
                NProgress.start();
186
            },
16460 anderson 187
            'dataFilter': function(response) {
188
                var response = jQuery.parseJSON( response );
16458 anderson 189
 
16460 anderson 190
                var json                = {};
191
                json.recordsTotal       = 0;
192
                json.recordsFiltered    = 0;
193
                json.data               = [];
16441 anderson 194
 
16460 anderson 195
                if(response.success) {
16482 anderson 196
                    json.recordsTotal       = response.data.total;
197
                    json.recordsFiltered    = response.data.total;
16540 anderson 198
                    json.data               = response.items;
16460 anderson 199
                } else {
200
                    $.fn.showError(response.data)
201
                }
202
                return JSON.stringify( json );
203
            }
16441 anderson 204
        },
16461 anderson 205
        // 'drawCallback': function( settings ) {
206
        //         NProgress.done();
207
        // },
16441 anderson 208
        'aoColumns': [
16532 anderson 209
            { 'mDataProp': "first_name"},
16502 anderson 210
            { 'mDataProp': "last_name" },
16441 anderson 211
            { 'mDataProp': "email" },
212
            { 'mDataProp': "total_by_day" },
213
            { 'mDataProp': "added_on" },
16413 anderson 214
         ]
16421 anderson 215
 
16412 anderson 216
    });
16411 anderson 217
 
16029 anderson 218
    $('#filterdate').on('apply.daterangepicker', function(ev, picker) {
219
        startDate = picker.startDate.format('YYYY-MM-DD');
220
        endDate =picker.endDate.format('YYYY-MM-DD');
16237 anderson 221
 
222
        $.ajax({
223
            'dataType'  : 'json',
224
            'accept'    : 'application/json',
225
            'method'    : 'post',
226
            'url'       :  '$routeOverview',
227
            'data'      :  {
228
                'startDate' : startDate,
229
                'endDate' : endDate
230
            },
231
            'processData': false,
232
            'contentType': false,
233
            success: function (response) {
234
                console.log('enviado');
235
            }
236
        });
16029 anderson 237
        $.fn.reload();
238
    });
239
 
15875 anderson 240
    $.fn.reload();
15873 anderson 241
 
15857 anderson 242
});
15760 anderson 243
JS;
244
$this->inlineScript()->captureEnd();
245
?>
246
 
247
 
248
 
15857 anderson 249
<section class="content">
15759 anderson 250
    <div class="container-fluid">
251
        <div class="row">
15857 anderson 252
            <div class="col-12" id="row-list">
15759 anderson 253
                <div class="card">
254
                    <div class="card-header">
16543 anderson 255
                        <h2>LABEL_DAILY_PROGRESS_CHART</h2>
15857 anderson 256
                        <div class="form-group">
15859 anderson 257
                            <label>LABEL_DATE_RANGE</label>
15857 anderson 258
 
259
                            <div class="input-group">
260
                                <div class="input-group-prepend">
261
                                    <span class="input-group-text"><i class="far fa-calendar"></i></span>
262
                                </div>
263
                                <input type="text" class="form-control float-right" name="filterdate" id="filterdate">
264
                            </div>
265
                            <!-- /.input group -->
266
                        </div>
15759 anderson 267
                    </div>
268
                    <div class="card-body">
15857 anderson 269
                        <div class="row">
16450 anderson 270
                            <div class="col-lg-12 col-12 chart">
15988 anderson 271
                                <canvas id="chartProgressByDay" style="min-height: 250px; height: 250px; max-height: 250px; max-width: 100%;"></canvas>
15857 anderson 272
                            </div>
16448 anderson 273
                        </div>
15759 anderson 274
                    </div>
275
                </div>
276
            </div>
16424 anderson 277
        </div>
16450 anderson 278
</section>
16376 anderson 279
 
16567 anderson 280
<div id="peopleList"></div>
281
 
282
<script id="personTmpl" type="text/x-jsrender">
16592 anderson 283
    <table class="table table-bordered ">
16595 anderson 284
        <thead>
285
            <tr>
286
                <th>Usuarios</th>
16602 anderson 287
                <th>{{:name}}</th>
16595 anderson 288
            </tr>
289
        </thead>
290
        <tbody>
291
            <tr>
292
                <td></td>
293
            </tr>
294
        </tbody>
295
    </table>
16591 anderson 296
 
16563 anderson 297
</script>
16560 anderson 298
 
299
<!-- <section class="content">
16450 anderson 300
    <div class="container-fluid">
16399 anderson 301
        <div class="row">
302
            <div class="col-12" id="row-list">
303
                <div class="card">
304
                    <div class="card-header">
16546 anderson 305
                        <h2>LABEL_CONTACT_JOURNAL_PROGRESS</h2>
16399 anderson 306
                        <div class="form-group">
307
                        </div>
308
                    </div>
309
                    <div class="card-body">
310
                        <div class="row">
311
                            <div class="col-lg-12 col-12 chart">
16451 anderson 312
                                <table id="gridTable" class="table table-striped table-hover">
16399 anderson 313
                                    <thead>
314
                                        <tr>
16547 anderson 315
                                            <th>LABEL_FIRST_NAME</th>
316
                                            <th>LABEL_LAST_NAME</th>
317
                                            <th>LABEL_EMAIL</th>
318
                                            <th>LABEL_ADDED</th>
319
                                            <th>LABEL_ADDED_DATE</th>
16399 anderson 320
                                        </tr>
321
                                    </thead>
16451 anderson 322
                                </table>
16399 anderson 323
                            </div>
324
                        </div>
325
                    </div>
326
                </div>
327
            </div>
328
        </div>
16560 anderson 329
</section> -->