Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16420 | Rev 16422 | 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');
15760 anderson 32
 
16047 anderson 33
    var ctxchartProgressByDay = document.getElementById("chartProgressByDay").getContext("2d");
15857 anderson 34
 
35
    // draw empty chart
16047 anderson 36
    var chartProgressByDay = new Chart(ctxchartProgressByDay, {
16236 anderson 37
        type: 'line',
15857 anderson 38
        data: {
16218 anderson 39
            labels: [],
15857 anderson 40
            datasets: [
41
                {
16232 anderson 42
                	label : 'LABEL_CONTACT_PROGRESS_BY_DAY',
16090 anderson 43
         			backgroundColor: '#E69090',
44
                    borderColor: '#E69090',
45
                    borderWidth: 1,
46
                    fill: false,
16221 anderson 47
                    data : []
16090 anderson 48
              	},
15857 anderson 49
            ]
50
        },
51
        options: {
52
            tooltips: {
53
                mode: 'index',
54
                intersect: false
15760 anderson 55
            },
15857 anderson 56
            scales: {
57
                yAxes: [{
58
                    ticks: {
59
                        beginAtZero:true
15760 anderson 60
                    }
15857 anderson 61
                }]
62
            }
63
        }
64
    });
16047 anderson 65
 
66
    $.fn.reload = function() {
67
        NProgress.start();
68
        $.ajax({
69
            'dataType'  : 'json',
70
            'accept'    : 'application/json',
71
            'method'    : 'get',
72
            'url'       : '$routeOverview',
73
            'data'      :  {
74
                'startDate' : startDate,
75
                'endDate' : endDate
76
            },
77
        }).done(function(response) {
16221 anderson 78
            if(response['success']) {
16219 anderson 79
                chartProgressByDay.data.labels = response.data.added_on;
16220 anderson 80
                chartProgressByDay.data.datasets[0].data = response.data.total_by_day;
16221 anderson 81
                chartProgressByDay.update();
16336 anderson 82
 
83
                //Table
16374 anderson 84
                //$.each(response, (index, value) =>{
85
                    //console.log(value);
16367 anderson 86
                    var data = [
87
                        {
16375 anderson 88
                            "name": response.data.first_name+ " " + response.data.last_name,
89
                            'last_name':response.data.last_name,
90
                            "email": response.data.email,
91
                            "total_by_day": response.data.total_by_day,
92
                            "added_on": response.data.added_on,
16367 anderson 93
                        },
94
                    ];
16369 anderson 95
                    var template = $.templates("#theTmpl");
96
                    var htmlOutput = template.render(data);
16361 anderson 97
                    $("#result").html(htmlOutput);
16374 anderson 98
                //});
16357 anderson 99
 
16142 anderson 100
 
16357 anderson 101
 
16358 anderson 102
 
16031 anderson 103
            }else{
16183 anderson 104
                $.fn.showError(response);
16031 anderson 105
            }
15987 anderson 106
        }).fail(function( jqXHR, textStatus, errorThrown) {
107
            $.fn.showError(textStatus);
108
        }).always(function() {
109
            NProgress.done();
15872 anderson 110
        });
15987 anderson 111
        return false;
15872 anderson 112
    }
113
 
16028 anderson 114
    $('#filterdate').daterangepicker({
115
        maxDate: new Date(),
116
        locale: {
117
            format: 'DD/MM/YYYY',
118
            applyLabel: 'Aplicar',
119
            cancelLabel: 'Cancelar',
120
            daysOfWeek: ['Do', 'Lu','Ma', 'Mi', 'Ju', 'Vi', 'Sa'],
121
            monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo',
122
                'Junio',
123
                'Agosto',
124
                'Septiembre',
125
                'Octubre',
126
                'Noviembre',
127
                'Diciembre'
128
            ],
129
        }
130
    });
131
 
16381 anderson 132
    //Datatable
133
 
16417 anderson 134
 
16390 anderson 135
 
16412 anderson 136
    $('#gridTable').DataTable({
16420 anderson 137
        'processing': true,
138
        'serverSide': true,
16412 anderson 139
        ajax: {
16413 anderson 140
            url: '$routeOverview',
16415 anderson 141
            dataSrc: 'data'
16412 anderson 142
        },
16413 anderson 143
        columns: [
16419 anderson 144
            { 'data': 'first_name' },
145
            { 'data': 'last_name' },
146
            { 'data': 'email' },
147
            { 'data': 'total_by_day' },
148
            { 'data': 'added_on' },
16413 anderson 149
         ]
16421 anderson 150
 
151
         console.log(data);
16412 anderson 152
    });
16411 anderson 153
 
154
    // $('#gridTable').DataTable({
155
    //     'ajax': {
156
    // 			'url' : '$routeOverview',
157
    // 			'type' : 'get',
158
    //             'beforeSend': function (request) {
159
    //               NProgress.start();
160
    //             },
161
    //             'dataFilter': function(response) {
162
    //                 var response = jQuery.parseJSON( response );
163
    //                 console.log(response);
164
    //                 var json                = {};
165
    //                 json.recordsTotal       = 0;
166
    //                 json.recordsFiltered    = 0;
167
    //                 json.data               = [];
16400 anderson 168
 
169
 
16411 anderson 170
    //                 if(response.success) {
171
    //                     json.recordsTotal       = response.data.total[0];
172
    //                     json.recordsFiltered    = response.data.total;
173
    //                     json.data               = response.data.total;
174
    //                 } else {
175
    //                     $.fn.showError(response.data)
176
    //                 }
16400 anderson 177
 
16411 anderson 178
    //                 return JSON.stringify( json );
179
    //             }
180
    // 		},
181
    //         'aoColumns': [
182
    //             { 'mDataProp': 'first_name' },
183
    //             { 'mDataProp': 'last_name' },
184
    //             { 'mDataProp': 'email' },
185
    //             { 'mDataProp': 'total_by_day' },
186
    //             { 'mDataProp': 'added_on' },
187
    // 	    ],
188
    // });
16382 anderson 189
 
190
 
16381 anderson 191
    var listar = function () {
16390 anderson 192
        // var table = $('#anderson').DataTable( {
193
        //     ajax: {
194
        //         url: '$routeOverview',
195
        //         method: 'POST'
196
        //     },
197
        //     columns: [
198
        //         {'data':'first_name'},
199
        //         {'data':'last_name'},
200
        //         {'data':'email'},
201
        //         {'data':'total_by_day'}
202
        //     ]
203
        // } );
16381 anderson 204
    }
205
 
16029 anderson 206
    $('#filterdate').on('apply.daterangepicker', function(ev, picker) {
207
        startDate = picker.startDate.format('YYYY-MM-DD');
208
        endDate =picker.endDate.format('YYYY-MM-DD');
16237 anderson 209
 
210
        $.ajax({
211
            'dataType'  : 'json',
212
            'accept'    : 'application/json',
213
            'method'    : 'post',
214
            'url'       :  '$routeOverview',
215
            'data'      :  {
216
                'startDate' : startDate,
217
                'endDate' : endDate
218
            },
219
            'processData': false,
220
            'contentType': false,
221
            success: function (response) {
222
                console.log('enviado');
223
            }
224
        });
16029 anderson 225
        $.fn.reload();
226
    });
227
 
15875 anderson 228
    $.fn.reload();
15873 anderson 229
 
15857 anderson 230
});
15760 anderson 231
JS;
232
$this->inlineScript()->captureEnd();
233
?>
234
 
235
 
236
 
15857 anderson 237
<section class="content">
15759 anderson 238
    <div class="container-fluid">
239
        <div class="row">
15857 anderson 240
            <div class="col-12" id="row-list">
15759 anderson 241
                <div class="card">
242
                    <div class="card-header">
15859 anderson 243
                        <h2>Progreso Diario de contactos</h2>
15857 anderson 244
                        <div class="form-group">
15859 anderson 245
                            <label>LABEL_DATE_RANGE</label>
15857 anderson 246
 
247
                            <div class="input-group">
248
                                <div class="input-group-prepend">
249
                                    <span class="input-group-text"><i class="far fa-calendar"></i></span>
250
                                </div>
251
                                <input type="text" class="form-control float-right" name="filterdate" id="filterdate">
252
                            </div>
253
                            <!-- /.input group -->
254
                        </div>
15759 anderson 255
                    </div>
256
                    <div class="card-body">
15857 anderson 257
                        <div class="row">
258
                            <div class="col-lg-12 col-12 chart">
15988 anderson 259
                                <canvas id="chartProgressByDay" style="min-height: 250px; height: 250px; max-height: 250px; max-width: 100%;"></canvas>
15857 anderson 260
                            </div>
261
                        </div>
15759 anderson 262
                    </div>
263
                </div>
264
            </div>
16376 anderson 265
        </div>
16377 anderson 266
    </div>
16376 anderson 267
 
16399 anderson 268
    <!-- <div id="result"></div> -->
269
 
270
    <!-- <script id="theTmpl" type="text/x-jsrender">
271
        <div class="row">
272
            <div class="col-12" id="row-list">
273
                <div class="card">
274
                    <div class="card-header">
275
                        <h2>Progreso Diario de contactos</h2>
276
                        <div class="form-group">
277
                            <label>LABEL_DATE_RANGE</label>
278
 
279
                            <div class="input-group">
280
                                <div class="input-group-prepend">
281
                                    <span class="input-group-text"><i class="far fa-calendar"></i></span>
282
                                </div>
283
                                <input type="text" class="form-control float-right" name="filterdate" id="filterdate">
284
                            </div>
285
                        </div>
286
                    </div>
287
                    <div class="card-body">
288
                        <div class="row">
289
                            <div class="col-lg-12 col-12 chart">
290
                                <table id="anderson" class="table table-bordered table-responsive">
291
                                    <thead>
292
                                        <tr>
293
                                            <th>Nombre</th>
294
                                            <th>Apellido</th>
295
                                            <th>Email</th>
296
                                            <th>Total Agregados</th>
297
                                            <th>Fecha</th>
298
                                        </tr>
299
                                    </thead>
300
                                    <tbody>
301
                                        <tr>
302
                                            <td>{{:name}}</td>
303
                                            <td>{{:last_name}}</td>
304
                                            <td>{{:email}}</td>
305
                                            <td>{{:total_by_day}}</td>
306
                                            <td>{{:added_on}}</td>
307
                                        </tr>
308
                                    </tbody>
309
                                </table>
310
                            </div>
311
                        </div>
312
                    </div>
313
                </div>
314
            </div>
315
        </div>
316
<div>
317
</div>
318
</script> -->
16392 anderson 319
</section>
16393 anderson 320
 
321
<div class="row">
322
    <div class="col-12">
323
        <div class="card">
324
            <div class="card-header">
325
                <h2>LABEL_CONTACTS</h2>
326
            </div>
327
            <div class="card-body">
328
                <table id="gridTable" class="table table-striped table-hover">
329
                    <thead>
330
                        <tr>
16419 anderson 331
                            <th>Nombre</th>
332
                            <th>Apellido</th>
16396 anderson 333
                            <th>Email</th>
334
                            <th>Total Agregados</th>
16419 anderson 335
                            <th>Fecha</th>
16393 anderson 336
                        </tr>
337
                    </thead>
338
                    <tbody>
339
                    </tbody>
340
                </table>
341
            </div>
342
            <!-- <div class="card-footer clearfix">
16392 anderson 343
                        <div style="float:right;">
344
                            <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
345
                            <?php if ($allowUpload) : ?>
346
                                <button type="button" class="btn btn-primary btn-upload"><i class="fa fa-upload"></i> LABEL_UPLOAD </button>
347
                            <?php endif; ?>
348
                            <?php if ($allowAdd) : ?>
349
                                <button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
350
                            <?php endif; ?>
351
                        </div>
352
                    </div> -->
353
        </div>
354
    </div>
16393 anderson 355
</div>