Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16509 | Rev 16511 | 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
 
16435 anderson 134
    $('#gridTable').dataTable({
16420 anderson 135
        'processing': true,
136
        'serverSide': true,
16436 anderson 137
        'searching': true,
138
        'order': [[ 0, 'asc' ]],
139
        'ordering':  true,
140
        'ordenable' : true,
141
        'responsive': true,
142
        'select' : false,
143
        'paging': true,
144
        'pagingType': 'simple_numbers',
16439 anderson 145
        'ajax': {
16441 anderson 146
            'url' : '$routeOverview',
147
            'type' : 'get',
148
            'beforeSend': function (request) {
149
                NProgress.start();
150
            },
16460 anderson 151
            'dataFilter': function(response) {
152
                var response = jQuery.parseJSON( response );
16458 anderson 153
 
16460 anderson 154
                var json                = {};
155
                json.recordsTotal       = 0;
156
                json.recordsFiltered    = 0;
157
                json.data               = [];
16487 anderson 158
                var data = Object.keys(response.data).map(key => response.data[key]);
16508 anderson 159
                const obj = {}
160
                for(let i= 0; i<data.length ;i++){
16509 anderson 161
                    obj[data[i][0]]=data[i][1]
16508 anderson 162
                }
16441 anderson 163
 
16460 anderson 164
                if(response.success) {
16482 anderson 165
                    json.recordsTotal       = response.data.total;
166
                    json.recordsFiltered    = response.data.total;
16510 anderson 167
                    json.data               = obj;
16440 anderson 168
 
16510 anderson 169
                    console.log(obj);
16460 anderson 170
                } else {
171
                    $.fn.showError(response.data)
172
                }
16441 anderson 173
 
16460 anderson 174
                return JSON.stringify( json );
175
            }
16441 anderson 176
        },
16461 anderson 177
        // 'drawCallback': function( settings ) {
178
        //         NProgress.done();
179
        // },
16441 anderson 180
        'aoColumns': [
16502 anderson 181
            { 'mDataProp': "first_name" },
182
            { 'mDataProp': "last_name" },
16441 anderson 183
            { 'mDataProp': "email" },
184
            { 'mDataProp': "total_by_day" },
185
            { 'mDataProp': "added_on" },
16413 anderson 186
         ]
16421 anderson 187
 
16412 anderson 188
    });
16411 anderson 189
 
16029 anderson 190
    $('#filterdate').on('apply.daterangepicker', function(ev, picker) {
191
        startDate = picker.startDate.format('YYYY-MM-DD');
192
        endDate =picker.endDate.format('YYYY-MM-DD');
16237 anderson 193
 
194
        $.ajax({
195
            'dataType'  : 'json',
196
            'accept'    : 'application/json',
197
            'method'    : 'post',
198
            'url'       :  '$routeOverview',
199
            'data'      :  {
200
                'startDate' : startDate,
201
                'endDate' : endDate
202
            },
203
            'processData': false,
204
            'contentType': false,
205
            success: function (response) {
206
                console.log('enviado');
207
            }
208
        });
16029 anderson 209
        $.fn.reload();
210
    });
211
 
15875 anderson 212
    $.fn.reload();
15873 anderson 213
 
15857 anderson 214
});
15760 anderson 215
JS;
216
$this->inlineScript()->captureEnd();
217
?>
218
 
219
 
220
 
15857 anderson 221
<section class="content">
15759 anderson 222
    <div class="container-fluid">
223
        <div class="row">
15857 anderson 224
            <div class="col-12" id="row-list">
15759 anderson 225
                <div class="card">
226
                    <div class="card-header">
15859 anderson 227
                        <h2>Progreso Diario de contactos</h2>
15857 anderson 228
                        <div class="form-group">
15859 anderson 229
                            <label>LABEL_DATE_RANGE</label>
15857 anderson 230
 
231
                            <div class="input-group">
232
                                <div class="input-group-prepend">
233
                                    <span class="input-group-text"><i class="far fa-calendar"></i></span>
234
                                </div>
235
                                <input type="text" class="form-control float-right" name="filterdate" id="filterdate">
236
                            </div>
237
                            <!-- /.input group -->
238
                        </div>
15759 anderson 239
                    </div>
240
                    <div class="card-body">
15857 anderson 241
                        <div class="row">
16450 anderson 242
                            <div class="col-lg-12 col-12 chart">
15988 anderson 243
                                <canvas id="chartProgressByDay" style="min-height: 250px; height: 250px; max-height: 250px; max-width: 100%;"></canvas>
16446 anderson 244
                                <!-- <table id="gridTable" class="table table-striped table-hover">
16445 anderson 245
                                    <thead>
246
                                        <tr>
247
                                            <th>Nombre</th>
248
                                            <th>Apellido</th>
249
                                            <th>Email</th>
250
                                            <th>Total Agregados</th>
251
                                            <th>Fecha</th>
252
                                        </tr>
253
                                    </thead>
16446 anderson 254
                                </table> -->
15857 anderson 255
                            </div>
16448 anderson 256
                        </div>
15759 anderson 257
                    </div>
258
                </div>
259
            </div>
16424 anderson 260
        </div>
16450 anderson 261
</section>
16376 anderson 262
 
16450 anderson 263
<section class="content">
264
    <div class="container-fluid">
16399 anderson 265
        <div class="row">
266
            <div class="col-12" id="row-list">
267
                <div class="card">
268
                    <div class="card-header">
269
                        <h2>Progreso Diario de contactos</h2>
270
                        <div class="form-group">
16453 anderson 271
                            <!-- <label>LABEL_DATE_RANGE</label>
16399 anderson 272
 
16453 anderson 273
                            <div class="input-group">
16399 anderson 274
                                <div class="input-group-prepend">
275
                                    <span class="input-group-text"><i class="far fa-calendar"></i></span>
276
                                </div>
277
                                <input type="text" class="form-control float-right" name="filterdate" id="filterdate">
16452 anderson 278
                            </div> -->
16450 anderson 279
                            <!-- /.input group -->
16399 anderson 280
                        </div>
281
                    </div>
282
                    <div class="card-body">
283
                        <div class="row">
284
                            <div class="col-lg-12 col-12 chart">
16451 anderson 285
                                <table id="gridTable" class="table table-striped table-hover">
16399 anderson 286
                                    <thead>
287
                                        <tr>
288
                                            <th>Nombre</th>
289
                                            <th>Apellido</th>
290
                                            <th>Email</th>
291
                                            <th>Total Agregados</th>
292
                                            <th>Fecha</th>
293
                                        </tr>
294
                                    </thead>
16451 anderson 295
                                </table>
16399 anderson 296
                            </div>
297
                        </div>
298
                    </div>
299
                </div>
300
            </div>
301
        </div>
16424 anderson 302
</section>