Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16361 | Rev 16363 | 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);
81
                    var data = [
16358 anderson 82
                        {
16359 anderson 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,
16358 anderson 88
                        },
89
                    ];
16362 anderson 90
                    console.log(data);
16358 anderson 91
                    var template = $.templates("#theTmpl");
92
                    var htmlOutput = template.render(data);
16361 anderson 93
                    $("#result").html(htmlOutput);
16357 anderson 94
                });
95
 
16142 anderson 96
 
16357 anderson 97
 
16358 anderson 98
 
16031 anderson 99
            }else{
16183 anderson 100
                $.fn.showError(response);
16031 anderson 101
            }
15987 anderson 102
        }).fail(function( jqXHR, textStatus, errorThrown) {
103
            $.fn.showError(textStatus);
104
        }).always(function() {
105
            NProgress.done();
15872 anderson 106
        });
15987 anderson 107
        return false;
15872 anderson 108
    }
109
 
16028 anderson 110
    $('#filterdate').daterangepicker({
111
        maxDate: new Date(),
112
        locale: {
113
            format: 'DD/MM/YYYY',
114
            applyLabel: 'Aplicar',
115
            cancelLabel: 'Cancelar',
116
            daysOfWeek: ['Do', 'Lu','Ma', 'Mi', 'Ju', 'Vi', 'Sa'],
117
            monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo',
118
                'Junio',
119
                'Agosto',
120
                'Septiembre',
121
                'Octubre',
122
                'Noviembre',
123
                'Diciembre'
124
            ],
125
        }
126
    });
127
 
16029 anderson 128
    $('#filterdate').on('apply.daterangepicker', function(ev, picker) {
129
        startDate = picker.startDate.format('YYYY-MM-DD');
130
        endDate =picker.endDate.format('YYYY-MM-DD');
16237 anderson 131
 
132
        $.ajax({
133
            'dataType'  : 'json',
134
            'accept'    : 'application/json',
135
            'method'    : 'post',
136
            'url'       :  '$routeOverview',
137
            'data'      :  {
138
                'startDate' : startDate,
139
                'endDate' : endDate
140
            },
141
            'processData': false,
142
            'contentType': false,
143
            success: function (response) {
144
                console.log('enviado');
145
            }
146
        });
16029 anderson 147
        $.fn.reload();
148
    });
149
 
15875 anderson 150
    $.fn.reload();
15873 anderson 151
 
15857 anderson 152
});
15760 anderson 153
JS;
154
$this->inlineScript()->captureEnd();
155
?>
156
 
157
 
158
 
15857 anderson 159
<section class="content">
15759 anderson 160
    <div class="container-fluid">
161
        <div class="row">
15857 anderson 162
            <div class="col-12" id="row-list">
15759 anderson 163
                <div class="card">
164
                    <div class="card-header">
15859 anderson 165
                        <h2>Progreso Diario de contactos</h2>
15857 anderson 166
                        <div class="form-group">
15859 anderson 167
                            <label>LABEL_DATE_RANGE</label>
15857 anderson 168
 
169
                            <div class="input-group">
170
                                <div class="input-group-prepend">
171
                                    <span class="input-group-text"><i class="far fa-calendar"></i></span>
172
                                </div>
173
                                <input type="text" class="form-control float-right" name="filterdate" id="filterdate">
174
                            </div>
175
                            <!-- /.input group -->
176
                        </div>
15759 anderson 177
                    </div>
178
                    <div class="card-body">
15857 anderson 179
                        <div class="row">
180
                            <div class="col-lg-12 col-12 chart">
15988 anderson 181
                                <canvas id="chartProgressByDay" style="min-height: 250px; height: 250px; max-height: 250px; max-width: 100%;"></canvas>
15857 anderson 182
                            </div>
183
                        </div>
15759 anderson 184
                    </div>
185
                </div>
186
            </div>
187
        </div>
188
    </div>
16333 anderson 189
    <div id="result"></div>
190
 
191
<script id="theTmpl" type="text/x-jsrender">
16355 anderson 192
    <div class="row">
193
            <div class="col-12" id="row-list">
194
                <div class="card">
195
                    <div class="card-header">
196
                        <h2>Progreso Diario de contactos</h2>
197
                        <div class="form-group">
198
                            <label>LABEL_DATE_RANGE</label>
199
 
200
                            <div class="input-group">
201
                                <div class="input-group-prepend">
202
                                    <span class="input-group-text"><i class="far fa-calendar"></i></span>
203
                                </div>
204
                                <input type="text" class="form-control float-right" name="filterdate" id="filterdate">
205
                            </div>
206
                            <!-- /.input group -->
207
                        </div>
208
                    </div>
209
                    <div class="card-body">
210
                        <div class="row">
211
                            <div class="col-lg-12 col-12 chart">
212
                                <table class="table table-bordered table-responsive">
213
                                    <thead>
214
                                        <tr>
215
                                            <th>Nombre</th>
216
                                            <th>Apellido</th>
217
                                            <th>Email</th>
218
                                            <th>Total Agregados</th>
219
                                            <th>Fecha</th>
220
                                        </tr>
221
                                    </thead>
222
                                    <tbody>
223
                                        <tr>
224
                                            <td>{{:name}}</td>
225
                                            <td>{{:last_name}}</td>
226
                                            <td>{{:email}}</td>
227
                                            <td>{{:total_by_day}}</td>
228
                                            <td>{{:added_on}}</td>
229
                                        </tr>
230
                                    </tbody>
231
                                </table>
232
                            </div>
233
                        </div>
234
                    </div>
235
                </div>
236
            </div>
237
        </div>
16333 anderson 238
<div>
239
</div>
240
</script>
15759 anderson 241
</section>