Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16367 | Rev 16369 | 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
 
13
 
15857 anderson 14
$this->inlineScript()->appendFile($this->basePath('plugins/chart.js/chart.js'));
15
$this->inlineScript()->appendFile($this->basePath('plugins/chartjs-plugin-datalabels/chartjs-plugin-datalabels.js'));
15760 anderson 16
 
17
echo <<<CSS
18
CSS;
19
$this->headStyle()->captureEnd();
20
 
21
$this->inlineScript()->captureStart();
22
echo <<<JS
15857 anderson 23
jQuery( document ).ready(function( $ ) {
15760 anderson 24
 
15857 anderson 25
    var startDate   = moment().format('YYYY-MM-DD');
26
    var endDate     = moment().format('YYYY-MM-DD');
15760 anderson 27
 
16047 anderson 28
    var ctxchartProgressByDay = document.getElementById("chartProgressByDay").getContext("2d");
15857 anderson 29
 
30
    // draw empty chart
16047 anderson 31
    var chartProgressByDay = new Chart(ctxchartProgressByDay, {
16236 anderson 32
        type: 'line',
15857 anderson 33
        data: {
16218 anderson 34
            labels: [],
15857 anderson 35
            datasets: [
36
                {
16232 anderson 37
                	label : 'LABEL_CONTACT_PROGRESS_BY_DAY',
16090 anderson 38
         			backgroundColor: '#E69090',
39
                    borderColor: '#E69090',
40
                    borderWidth: 1,
41
                    fill: false,
16221 anderson 42
                    data : []
16090 anderson 43
              	},
15857 anderson 44
            ]
45
        },
46
        options: {
47
            tooltips: {
48
                mode: 'index',
49
                intersect: false
15760 anderson 50
            },
15857 anderson 51
            scales: {
52
                yAxes: [{
53
                    ticks: {
54
                        beginAtZero:true
15760 anderson 55
                    }
15857 anderson 56
                }]
57
            }
58
        }
59
    });
16047 anderson 60
 
61
    $.fn.reload = function() {
62
        NProgress.start();
63
        $.ajax({
64
            'dataType'  : 'json',
65
            'accept'    : 'application/json',
66
            'method'    : 'get',
67
            'url'       : '$routeOverview',
68
            'data'      :  {
69
                'startDate' : startDate,
70
                'endDate' : endDate
71
            },
72
        }).done(function(response) {
16221 anderson 73
            if(response['success']) {
16219 anderson 74
                chartProgressByDay.data.labels = response.data.added_on;
16220 anderson 75
                chartProgressByDay.data.datasets[0].data = response.data.total_by_day;
16221 anderson 76
                chartProgressByDay.update();
16336 anderson 77
 
78
                //Table
16356 anderson 79
                $.each(response, (index, value) =>{
16357 anderson 80
                    console.log(value);
16367 anderson 81
                    var data = [
82
                        {
83
                            "name": value.first_name+ " " + value.last_name,
84
                            'last_name':value.last_name,
85
                            "email": value.email,
86
                            "total_by_day": value.total_by_day,
87
                            "added_on": value.added_on,
88
                        },
89
                    ];
16363 anderson 90
                    $.each(data, function (index2, value2) {
16364 anderson 91
                        console.log(index2);
16367 anderson 92
                        var data2 = [ {
93
                             "name": value2.first_name+ " " + value2.last_name,
94
                             'last_name':value2.last_name,
95
                             "email": value2.email,
96
                             "total_by_day": value2.total_by_day,
97
                             "added_on": value2.added_on,
98
                         }]
16368 anderson 99
                         var template = $.templates("#theTmpl");
16367 anderson 100
                    var htmlOutput = template.render(data2);
16361 anderson 101
                    $("#result").html(htmlOutput);
16368 anderson 102
                    });
103
 
16357 anderson 104
                });
105
 
16142 anderson 106
 
16357 anderson 107
 
16358 anderson 108
 
16031 anderson 109
            }else{
16183 anderson 110
                $.fn.showError(response);
16031 anderson 111
            }
15987 anderson 112
        }).fail(function( jqXHR, textStatus, errorThrown) {
113
            $.fn.showError(textStatus);
114
        }).always(function() {
115
            NProgress.done();
15872 anderson 116
        });
15987 anderson 117
        return false;
15872 anderson 118
    }
119
 
16028 anderson 120
    $('#filterdate').daterangepicker({
121
        maxDate: new Date(),
122
        locale: {
123
            format: 'DD/MM/YYYY',
124
            applyLabel: 'Aplicar',
125
            cancelLabel: 'Cancelar',
126
            daysOfWeek: ['Do', 'Lu','Ma', 'Mi', 'Ju', 'Vi', 'Sa'],
127
            monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo',
128
                'Junio',
129
                'Agosto',
130
                'Septiembre',
131
                'Octubre',
132
                'Noviembre',
133
                'Diciembre'
134
            ],
135
        }
136
    });
137
 
16029 anderson 138
    $('#filterdate').on('apply.daterangepicker', function(ev, picker) {
139
        startDate = picker.startDate.format('YYYY-MM-DD');
140
        endDate =picker.endDate.format('YYYY-MM-DD');
16237 anderson 141
 
142
        $.ajax({
143
            'dataType'  : 'json',
144
            'accept'    : 'application/json',
145
            'method'    : 'post',
146
            'url'       :  '$routeOverview',
147
            'data'      :  {
148
                'startDate' : startDate,
149
                'endDate' : endDate
150
            },
151
            'processData': false,
152
            'contentType': false,
153
            success: function (response) {
154
                console.log('enviado');
155
            }
156
        });
16029 anderson 157
        $.fn.reload();
158
    });
159
 
15875 anderson 160
    $.fn.reload();
15873 anderson 161
 
15857 anderson 162
});
15760 anderson 163
JS;
164
$this->inlineScript()->captureEnd();
165
?>
166
 
167
 
168
 
15857 anderson 169
<section class="content">
15759 anderson 170
    <div class="container-fluid">
171
        <div class="row">
15857 anderson 172
            <div class="col-12" id="row-list">
15759 anderson 173
                <div class="card">
174
                    <div class="card-header">
15859 anderson 175
                        <h2>Progreso Diario de contactos</h2>
15857 anderson 176
                        <div class="form-group">
15859 anderson 177
                            <label>LABEL_DATE_RANGE</label>
15857 anderson 178
 
179
                            <div class="input-group">
180
                                <div class="input-group-prepend">
181
                                    <span class="input-group-text"><i class="far fa-calendar"></i></span>
182
                                </div>
183
                                <input type="text" class="form-control float-right" name="filterdate" id="filterdate">
184
                            </div>
185
                            <!-- /.input group -->
186
                        </div>
15759 anderson 187
                    </div>
188
                    <div class="card-body">
15857 anderson 189
                        <div class="row">
190
                            <div class="col-lg-12 col-12 chart">
15988 anderson 191
                                <canvas id="chartProgressByDay" style="min-height: 250px; height: 250px; max-height: 250px; max-width: 100%;"></canvas>
15857 anderson 192
                            </div>
193
                        </div>
15759 anderson 194
                    </div>
195
                </div>
196
            </div>
197
        </div>
198
    </div>
16333 anderson 199
    <div id="result"></div>
200
 
201
<script id="theTmpl" type="text/x-jsrender">
16355 anderson 202
    <div class="row">
203
            <div class="col-12" id="row-list">
204
                <div class="card">
205
                    <div class="card-header">
206
                        <h2>Progreso Diario de contactos</h2>
207
                        <div class="form-group">
208
                            <label>LABEL_DATE_RANGE</label>
209
 
210
                            <div class="input-group">
211
                                <div class="input-group-prepend">
212
                                    <span class="input-group-text"><i class="far fa-calendar"></i></span>
213
                                </div>
214
                                <input type="text" class="form-control float-right" name="filterdate" id="filterdate">
215
                            </div>
216
                            <!-- /.input group -->
217
                        </div>
218
                    </div>
219
                    <div class="card-body">
220
                        <div class="row">
221
                            <div class="col-lg-12 col-12 chart">
222
                                <table class="table table-bordered table-responsive">
223
                                    <thead>
224
                                        <tr>
225
                                            <th>Nombre</th>
226
                                            <th>Apellido</th>
227
                                            <th>Email</th>
228
                                            <th>Total Agregados</th>
229
                                            <th>Fecha</th>
230
                                        </tr>
231
                                    </thead>
232
                                    <tbody>
233
                                        <tr>
234
                                            <td>{{:name}}</td>
235
                                            <td>{{:last_name}}</td>
236
                                            <td>{{:email}}</td>
237
                                            <td>{{:total_by_day}}</td>
238
                                            <td>{{:added_on}}</td>
239
                                        </tr>
240
                                    </tbody>
241
                                </table>
242
                            </div>
243
                        </div>
244
                    </div>
245
                </div>
246
            </div>
247
        </div>
16333 anderson 248
<div>
249
</div>
250
</script>
15759 anderson 251
</section>