Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16596 | Rev 16598 | 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']) {
16579 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
 
16582 anderson 122
                response.items.forEach(item => {
16593 anderson 123
 
16582 anderson 124
                    var people = [
125
                        {
16597 anderson 126
                            name: "Danniel"
16596 anderson 127
                        },
128
                        {
16597 anderson 129
                            name: "Ana"
16582 anderson 130
                        }
131
                    ];
16595 anderson 132
                    console.log(people);
133
                    var html = myTemplate.render(people);
16585 anderson 134
                    $("#peopleList").html(html);
16582 anderson 135
                });
16577 anderson 136
 
137
 
16583 anderson 138
 
16569 anderson 139
 
140
 
141
 
142
 
143
 
144
 
145
 
146
 
147
 
148
 
16031 anderson 149
            }else{
16183 anderson 150
                $.fn.showError(response);
16031 anderson 151
            }
15987 anderson 152
        }).fail(function( jqXHR, textStatus, errorThrown) {
153
            $.fn.showError(textStatus);
154
        }).always(function() {
155
            NProgress.done();
15872 anderson 156
        });
15987 anderson 157
        return false;
15872 anderson 158
    }
159
 
16028 anderson 160
    $('#filterdate').daterangepicker({
161
        maxDate: new Date(),
162
        locale: {
163
            format: 'DD/MM/YYYY',
164
            applyLabel: 'Aplicar',
165
            cancelLabel: 'Cancelar',
166
            daysOfWeek: ['Do', 'Lu','Ma', 'Mi', 'Ju', 'Vi', 'Sa'],
167
            monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo',
168
                'Junio',
169
                'Agosto',
170
                'Septiembre',
171
                'Octubre',
172
                'Noviembre',
173
                'Diciembre'
174
            ],
175
        }
176
    });
177
 
16381 anderson 178
    //Datatable
179
 
16435 anderson 180
    $('#gridTable').dataTable({
16420 anderson 181
        'processing': true,
182
        'serverSide': true,
16436 anderson 183
        'searching': true,
184
        'order': [[ 0, 'asc' ]],
185
        'ordering':  true,
186
        'ordenable' : true,
187
        'responsive': true,
188
        'select' : false,
189
        'paging': true,
190
        'pagingType': 'simple_numbers',
16439 anderson 191
        'ajax': {
16441 anderson 192
            'url' : '$routeOverview',
193
            'type' : 'get',
194
            'beforeSend': function (request) {
195
                NProgress.start();
196
            },
16460 anderson 197
            'dataFilter': function(response) {
198
                var response = jQuery.parseJSON( response );
16458 anderson 199
 
16460 anderson 200
                var json                = {};
201
                json.recordsTotal       = 0;
202
                json.recordsFiltered    = 0;
203
                json.data               = [];
16441 anderson 204
 
16460 anderson 205
                if(response.success) {
16482 anderson 206
                    json.recordsTotal       = response.data.total;
207
                    json.recordsFiltered    = response.data.total;
16540 anderson 208
                    json.data               = response.items;
16460 anderson 209
                } else {
210
                    $.fn.showError(response.data)
211
                }
212
                return JSON.stringify( json );
213
            }
16441 anderson 214
        },
16461 anderson 215
        // 'drawCallback': function( settings ) {
216
        //         NProgress.done();
217
        // },
16441 anderson 218
        'aoColumns': [
16532 anderson 219
            { 'mDataProp': "first_name"},
16502 anderson 220
            { 'mDataProp': "last_name" },
16441 anderson 221
            { 'mDataProp': "email" },
222
            { 'mDataProp': "total_by_day" },
223
            { 'mDataProp': "added_on" },
16413 anderson 224
         ]
16421 anderson 225
 
16412 anderson 226
    });
16411 anderson 227
 
16029 anderson 228
    $('#filterdate').on('apply.daterangepicker', function(ev, picker) {
229
        startDate = picker.startDate.format('YYYY-MM-DD');
230
        endDate =picker.endDate.format('YYYY-MM-DD');
16237 anderson 231
 
232
        $.ajax({
233
            'dataType'  : 'json',
234
            'accept'    : 'application/json',
235
            'method'    : 'post',
236
            'url'       :  '$routeOverview',
237
            'data'      :  {
238
                'startDate' : startDate,
239
                'endDate' : endDate
240
            },
241
            'processData': false,
242
            'contentType': false,
243
            success: function (response) {
244
                console.log('enviado');
245
            }
246
        });
16029 anderson 247
        $.fn.reload();
248
    });
249
 
15875 anderson 250
    $.fn.reload();
15873 anderson 251
 
15857 anderson 252
});
15760 anderson 253
JS;
254
$this->inlineScript()->captureEnd();
255
?>
256
 
257
 
258
 
15857 anderson 259
<section class="content">
15759 anderson 260
    <div class="container-fluid">
261
        <div class="row">
15857 anderson 262
            <div class="col-12" id="row-list">
15759 anderson 263
                <div class="card">
264
                    <div class="card-header">
16543 anderson 265
                        <h2>LABEL_DAILY_PROGRESS_CHART</h2>
15857 anderson 266
                        <div class="form-group">
15859 anderson 267
                            <label>LABEL_DATE_RANGE</label>
15857 anderson 268
 
269
                            <div class="input-group">
270
                                <div class="input-group-prepend">
271
                                    <span class="input-group-text"><i class="far fa-calendar"></i></span>
272
                                </div>
273
                                <input type="text" class="form-control float-right" name="filterdate" id="filterdate">
274
                            </div>
275
                            <!-- /.input group -->
276
                        </div>
15759 anderson 277
                    </div>
278
                    <div class="card-body">
15857 anderson 279
                        <div class="row">
16450 anderson 280
                            <div class="col-lg-12 col-12 chart">
15988 anderson 281
                                <canvas id="chartProgressByDay" style="min-height: 250px; height: 250px; max-height: 250px; max-width: 100%;"></canvas>
15857 anderson 282
                            </div>
16448 anderson 283
                        </div>
15759 anderson 284
                    </div>
285
                </div>
286
            </div>
16424 anderson 287
        </div>
16450 anderson 288
</section>
16376 anderson 289
 
16567 anderson 290
<div id="peopleList"></div>
291
 
292
<script id="personTmpl" type="text/x-jsrender">
16592 anderson 293
    <table class="table table-bordered ">
16595 anderson 294
        <thead>
295
            <tr>
296
                <th>Usuarios</th>
297
                <th>{{:name}}</th>
298
            </tr>
299
        </thead>
300
        <tbody>
301
            <tr>
302
                <td></td>
303
            </tr>
304
        </tbody>
305
    </table>
16591 anderson 306
 
16563 anderson 307
</script>
16560 anderson 308
 
309
<!-- <section class="content">
16450 anderson 310
    <div class="container-fluid">
16399 anderson 311
        <div class="row">
312
            <div class="col-12" id="row-list">
313
                <div class="card">
314
                    <div class="card-header">
16546 anderson 315
                        <h2>LABEL_CONTACT_JOURNAL_PROGRESS</h2>
16399 anderson 316
                        <div class="form-group">
317
                        </div>
318
                    </div>
319
                    <div class="card-body">
320
                        <div class="row">
321
                            <div class="col-lg-12 col-12 chart">
16451 anderson 322
                                <table id="gridTable" class="table table-striped table-hover">
16399 anderson 323
                                    <thead>
324
                                        <tr>
16547 anderson 325
                                            <th>LABEL_FIRST_NAME</th>
326
                                            <th>LABEL_LAST_NAME</th>
327
                                            <th>LABEL_EMAIL</th>
328
                                            <th>LABEL_ADDED</th>
329
                                            <th>LABEL_ADDED_DATE</th>
16399 anderson 330
                                        </tr>
331
                                    </thead>
16451 anderson 332
                                </table>
16399 anderson 333
                            </div>
334
                        </div>
335
                    </div>
336
                </div>
337
            </div>
338
        </div>
16560 anderson 339
</section> -->