Proyectos de Subversion LeadersLinked - Backend

Rev

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