Proyectos de Subversion LeadersLinked - Backend

Rev

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