Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16417 | Rev 16419 | 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({
137
        ajax: {
16413 anderson 138
            url: '$routeOverview',
16415 anderson 139
            dataSrc: 'data'
16412 anderson 140
        },
16413 anderson 141
        columns: [
16418 anderson 142
            {'data': 'first_name'},
143
            {'data': 'numb_name'}
16413 anderson 144
         ]
16412 anderson 145
    });
16411 anderson 146
 
147
    // $('#gridTable').DataTable({
148
    //     'ajax': {
149
    // 			'url' : '$routeOverview',
150
    // 			'type' : 'get',
151
    //             'beforeSend': function (request) {
152
    //               NProgress.start();
153
    //             },
154
    //             'dataFilter': function(response) {
155
    //                 var response = jQuery.parseJSON( response );
156
    //                 console.log(response);
157
    //                 var json                = {};
158
    //                 json.recordsTotal       = 0;
159
    //                 json.recordsFiltered    = 0;
160
    //                 json.data               = [];
16400 anderson 161
 
162
 
16411 anderson 163
    //                 if(response.success) {
164
    //                     json.recordsTotal       = response.data.total[0];
165
    //                     json.recordsFiltered    = response.data.total;
166
    //                     json.data               = response.data.total;
167
    //                 } else {
168
    //                     $.fn.showError(response.data)
169
    //                 }
16400 anderson 170
 
16411 anderson 171
    //                 return JSON.stringify( json );
172
    //             }
173
    // 		},
174
    //         'aoColumns': [
175
    //             { 'mDataProp': 'first_name' },
176
    //             { 'mDataProp': 'last_name' },
177
    //             { 'mDataProp': 'email' },
178
    //             { 'mDataProp': 'total_by_day' },
179
    //             { 'mDataProp': 'added_on' },
180
    // 	    ],
181
    // });
16382 anderson 182
 
183
 
16381 anderson 184
    var listar = function () {
16390 anderson 185
        // var table = $('#anderson').DataTable( {
186
        //     ajax: {
187
        //         url: '$routeOverview',
188
        //         method: 'POST'
189
        //     },
190
        //     columns: [
191
        //         {'data':'first_name'},
192
        //         {'data':'last_name'},
193
        //         {'data':'email'},
194
        //         {'data':'total_by_day'}
195
        //     ]
196
        // } );
16381 anderson 197
    }
198
 
16029 anderson 199
    $('#filterdate').on('apply.daterangepicker', function(ev, picker) {
200
        startDate = picker.startDate.format('YYYY-MM-DD');
201
        endDate =picker.endDate.format('YYYY-MM-DD');
16237 anderson 202
 
203
        $.ajax({
204
            'dataType'  : 'json',
205
            'accept'    : 'application/json',
206
            'method'    : 'post',
207
            'url'       :  '$routeOverview',
208
            'data'      :  {
209
                'startDate' : startDate,
210
                'endDate' : endDate
211
            },
212
            'processData': false,
213
            'contentType': false,
214
            success: function (response) {
215
                console.log('enviado');
216
            }
217
        });
16029 anderson 218
        $.fn.reload();
219
    });
220
 
15875 anderson 221
    $.fn.reload();
15873 anderson 222
 
15857 anderson 223
});
15760 anderson 224
JS;
225
$this->inlineScript()->captureEnd();
226
?>
227
 
228
 
229
 
15857 anderson 230
<section class="content">
15759 anderson 231
    <div class="container-fluid">
232
        <div class="row">
15857 anderson 233
            <div class="col-12" id="row-list">
15759 anderson 234
                <div class="card">
235
                    <div class="card-header">
15859 anderson 236
                        <h2>Progreso Diario de contactos</h2>
15857 anderson 237
                        <div class="form-group">
15859 anderson 238
                            <label>LABEL_DATE_RANGE</label>
15857 anderson 239
 
240
                            <div class="input-group">
241
                                <div class="input-group-prepend">
242
                                    <span class="input-group-text"><i class="far fa-calendar"></i></span>
243
                                </div>
244
                                <input type="text" class="form-control float-right" name="filterdate" id="filterdate">
245
                            </div>
246
                            <!-- /.input group -->
247
                        </div>
15759 anderson 248
                    </div>
249
                    <div class="card-body">
15857 anderson 250
                        <div class="row">
251
                            <div class="col-lg-12 col-12 chart">
15988 anderson 252
                                <canvas id="chartProgressByDay" style="min-height: 250px; height: 250px; max-height: 250px; max-width: 100%;"></canvas>
15857 anderson 253
                            </div>
254
                        </div>
15759 anderson 255
                    </div>
256
                </div>
257
            </div>
16376 anderson 258
        </div>
16377 anderson 259
    </div>
16376 anderson 260
 
16399 anderson 261
    <!-- <div id="result"></div> -->
262
 
263
    <!-- <script id="theTmpl" type="text/x-jsrender">
264
        <div class="row">
265
            <div class="col-12" id="row-list">
266
                <div class="card">
267
                    <div class="card-header">
268
                        <h2>Progreso Diario de contactos</h2>
269
                        <div class="form-group">
270
                            <label>LABEL_DATE_RANGE</label>
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
                        </div>
279
                    </div>
280
                    <div class="card-body">
281
                        <div class="row">
282
                            <div class="col-lg-12 col-12 chart">
283
                                <table id="anderson" class="table table-bordered table-responsive">
284
                                    <thead>
285
                                        <tr>
286
                                            <th>Nombre</th>
287
                                            <th>Apellido</th>
288
                                            <th>Email</th>
289
                                            <th>Total Agregados</th>
290
                                            <th>Fecha</th>
291
                                        </tr>
292
                                    </thead>
293
                                    <tbody>
294
                                        <tr>
295
                                            <td>{{:name}}</td>
296
                                            <td>{{:last_name}}</td>
297
                                            <td>{{:email}}</td>
298
                                            <td>{{:total_by_day}}</td>
299
                                            <td>{{:added_on}}</td>
300
                                        </tr>
301
                                    </tbody>
302
                                </table>
303
                            </div>
304
                        </div>
305
                    </div>
306
                </div>
307
            </div>
308
        </div>
309
<div>
310
</div>
311
</script> -->
16392 anderson 312
</section>
16393 anderson 313
 
314
<div class="row">
315
    <div class="col-12">
316
        <div class="card">
317
            <div class="card-header">
318
                <h2>LABEL_CONTACTS</h2>
319
            </div>
320
            <div class="card-body">
321
                <table id="gridTable" class="table table-striped table-hover">
322
                    <thead>
323
                        <tr>
16417 anderson 324
                            <th>first_name</th>
16413 anderson 325
                            <!-- <th>Apellido</th>
16396 anderson 326
                            <th>Email</th>
327
                            <th>Total Agregados</th>
16413 anderson 328
                            <th>Fecha</th> -->
16393 anderson 329
                        </tr>
330
                    </thead>
331
                    <tbody>
332
                    </tbody>
333
                </table>
334
            </div>
335
            <!-- <div class="card-footer clearfix">
16392 anderson 336
                        <div style="float:right;">
337
                            <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
338
                            <?php if ($allowUpload) : ?>
339
                                <button type="button" class="btn btn-primary btn-upload"><i class="fa fa-upload"></i> LABEL_UPLOAD </button>
340
                            <?php endif; ?>
341
                            <?php if ($allowAdd) : ?>
342
                                <button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
343
                            <?php endif; ?>
344
                        </div>
345
                    </div> -->
346
        </div>
347
    </div>
16393 anderson 348
</div>