Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16891 | | 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');
16758 efrain 4
$routeDownload = $this->url('discovery-contacts/progress-by-day/download');
5
 
6
 
16822 efrain 7
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
8
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
9
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jsrender/jsrender.js'));
15760 anderson 10
 
16822 efrain 11
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/daterangepicker/daterangepicker.css'));
12
$this->inlineScript()->appendFile($this->basePath('assets/vendors/moment/moment.min.js'));
13
$this->inlineScript()->appendFile($this->basePath('assets/vendors/daterangepicker/daterangepicker.js'));
15760 anderson 14
 
16822 efrain 15
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));
15760 anderson 16
 
16822 efrain 17
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
18
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));
16370 anderson 19
 
20
 
16822 efrain 21
$this->inlineScript()->appendFile($this->basePath('assets/vendors/chart.js/chart.js'));
22
$this->inlineScript()->appendFile($this->basePath('assets/vendors/chartjs-plugin-datalabels/chartjs-plugin-datalabels.js'));
15760 anderson 23
 
16758 efrain 24
/*
25
$this->headStyle()->captureStart();
15760 anderson 26
echo <<<CSS
16758 efrain 27
 
28
 
29
#tableUsers {
30
    display: flex;
31
    flex-flow: column;
32
    width: 100%;
33
}
34
 
35
#tableUsers thead {
36
    flex: 0 0 auto;
37
}
38
 
39
#tableUsers tbody {
40
    flex: 1 1 auto;
41
    display: block;
42
    overflow-y: auto;
43
    overflow-x: hidden;
44
}
45
 
46
#tableUsers tr {
47
    width: 100%;
48
    display: table;
49
    table-layout: fixed;
50
}
15760 anderson 51
CSS;
16758 efrain 52
$this->headStyle()->captureEnd();*/
15760 anderson 53
 
54
$this->inlineScript()->captureStart();
55
echo <<<JS
15857 anderson 56
jQuery( document ).ready(function( $ ) {
15760 anderson 57
 
15857 anderson 58
    var startDate   = moment().format('YYYY-MM-DD');
59
    var endDate     = moment().format('YYYY-MM-DD');
15760 anderson 60
 
16047 anderson 61
    var ctxchartProgressByDay = document.getElementById("chartProgressByDay").getContext("2d");
62
    var chartProgressByDay = new Chart(ctxchartProgressByDay, {
16236 anderson 63
        type: 'line',
15857 anderson 64
        data: {
16218 anderson 65
            labels: [],
15857 anderson 66
            datasets: [
67
                {
16971 efrain 68
                	label : 'LABEL_PROGRESS_BY_DAY',
16090 anderson 69
         			backgroundColor: '#E69090',
70
                    borderColor: '#E69090',
71
                    borderWidth: 1,
72
                    fill: false,
16221 anderson 73
                    data : []
16090 anderson 74
              	},
15857 anderson 75
            ]
76
        },
77
        options: {
78
            tooltips: {
79
                mode: 'index',
80
                intersect: false
15760 anderson 81
            },
15857 anderson 82
            scales: {
83
                yAxes: [{
84
                    ticks: {
85
                        beginAtZero:true
15760 anderson 86
                    }
15857 anderson 87
                }]
88
            }
89
        }
90
    });
16047 anderson 91
 
92
    $.fn.reload = function() {
93
        NProgress.start();
94
        $.ajax({
95
            'dataType'  : 'json',
96
            'accept'    : 'application/json',
97
            'method'    : 'get',
98
            'url'       : '$routeOverview',
99
            'data'      :  {
100
                'startDate' : startDate,
101
                'endDate' : endDate
102
            },
103
        }).done(function(response) {
16221 anderson 104
            if(response['success']) {
16569 anderson 105
 
16758 efrain 106
                chartProgressByDay.data.labels = response.data.graph.labels;
107
                chartProgressByDay.data.datasets[0].data = response.data.graph.values;
108
                chartProgressByDay.update()
16628 anderson 109
 
16608 anderson 110
 
16758 efrain 111
                $('#tableUsers').html(
112
                    $('#tableTemplate').render(response.data.table)
113
                );
16608 anderson 114
 
16031 anderson 115
            }else{
16183 anderson 116
                $.fn.showError(response);
16031 anderson 117
            }
15987 anderson 118
        }).fail(function( jqXHR, textStatus, errorThrown) {
119
            $.fn.showError(textStatus);
120
        }).always(function() {
121
            NProgress.done();
15872 anderson 122
        });
15987 anderson 123
        return false;
15872 anderson 124
    }
125
 
16971 efrain 126
 
127
 
128
 
16028 anderson 129
    $('#filterdate').daterangepicker({
130
        maxDate: new Date(),
16971 efrain 131
        ranges: {
132
           'LABEL_DATE_RANGE_TODAY': [moment(), moment()],
133
           'LABEL_DATE_RANGE_YESTERDAY': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
134
           'LABEL_DATE_RANGE_LAST_7_DAYS': [moment().subtract(6, 'days'), moment()],
135
           'LABEL_DATE_RANGE_LAST_30_DAYS': [moment().subtract(29, 'days'), moment()],
136
           'LABEL_DATE_RANGE_THIS_MONTH': [moment().startOf('month'), moment().endOf('month')],
137
           'LABEL_DATE_RANGE_LAST_MONTH': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
138
        },
16028 anderson 139
        locale: {
140
            format: 'DD/MM/YYYY',
16971 efrain 141
            applyLabel: 'LABEL_ACCEPT',
142
            cancelLabel: 'LABEL_CANCEL',
143
            customRangeLabel: 'LABEL_DATE_RANGE_CUSTOM',
144
            daysOfWeek: [
145
                'LABEL_SUNDAY_TWO_CHARACTER_CALENDAR',
146
                'LABEL_MONDAY_TWO_CHARACTER_CALENDAR',
147
                'LABEL_TUESDAY_TWO_CHARACTER_CALENDAR',
148
                'LABEL_WEDNESDAY_TWO_CHARACTER_CALENDAR',
149
                'LABEL_THURSDAY_TWO_CHARACTER_CALENDAR',
150
                'LABEL_FRIDAY_TWO_CHARACTER_CALENDAR',
151
                'LABEL_SATURDAY_TWO_CHARACTER_CALENDAR'
16028 anderson 152
            ],
16971 efrain 153
 
154
            monthNames: [
155
                'LABEL_MONTH_JANUARY',
156
                'LABEL_MONTH_FEBRUARY',
157
                'LABEL_MONTH_MARCH',
158
                'LABEL_MONTH_APRIL',
159
                'LABEL_MONTH_MAY',
160
                'LABEL_MONTH_JUNE',
161
                'LABEL_MONTH_JULY',
162
                'LABEL_MONTH_AUGUST',
163
                'LABEL_MONTH_SEPTEMBER',
164
                'LABEL_MONTH_OCTOBER',
165
                'LABEL_MONTH_NOVEMBER',
166
                'LABEL_MONTH_DECEMBER',
167
 
168
            ],
169
 
16028 anderson 170
        }
171
    });
172
 
16758 efrain 173
    $('#filterdate').on('apply.daterangepicker', function(ev, picker) {
174
        startDate = picker.startDate.format('YYYY-MM-DD');
175
        endDate =picker.endDate.format('YYYY-MM-DD');
176
        $.fn.reload();
177
    });
16381 anderson 178
 
16758 efrain 179
    $('button.btn-download').click(function(e) {
180
        e.preventDefault();
16421 anderson 181
 
16411 anderson 182
 
16758 efrain 183
        NProgress.start();
16237 anderson 184
        $.ajax({
185
            'dataType'  : 'json',
16758 efrain 186
            'method'    : 'get',
187
            'url'       : '$routeDownload',
16237 anderson 188
            'data'      :  {
189
                'startDate' : startDate,
190
                'endDate' : endDate
191
            },
16758 efrain 192
        }).done(function(response) {
193
            if(response['success']) {
194
                var anchor = window.document.createElement("a");
195
                anchor.href = 'data:application/octet-stream;charset=utf-8;base64,' + response['data']['content'] ;
196
                anchor.download = response['data']['basename'];
197
                document.body.appendChild(anchor);
198
                anchor.click();  // IE: "Access is denied"; see: https://connect.microsoft.com/IE/feedback/details/797361/ie-10-treats-blob-url-as-cross-origin-and-denies-access
199
                document.body.removeChild(anchor);
200
            } else {
201
                $.fn.showError(response['data']);
16237 anderson 202
            }
16758 efrain 203
        }).fail(function( jqXHR, textStatus, errorThrown) {
204
            showError(textStatus);
205
        }).always(function() {
206
            NProgress.done();
16237 anderson 207
        });
16758 efrain 208
 
209
 
16029 anderson 210
    });
211
 
15875 anderson 212
    $.fn.reload();
15873 anderson 213
 
15857 anderson 214
});
15760 anderson 215
JS;
216
$this->inlineScript()->captureEnd();
217
?>
218
 
16864 efrain 219
<div class="container">
220
	<div class="card">
221
  		<div class="card-header">
222
     		<h6 class="card-title">LABEL_DAILY_PROGRESS_CHART</h6>
223
		</div>
224
   		<div class="card-body">
225
   			<div class="row">
226
   				<div class="col-12 mt-3">
227
             		<label>LABEL_DATE_RANGE</label>
228
             		<div class="input-group mb-3">
229
                      <span class="input-group-text" id="basic-addon1"><i class="far fa-calendar"></i></span>
230
                      <input type="text" class="form-control" name="filterdate" id="filterdate">
15759 anderson 231
                    </div>
16864 efrain 232
   				</div>
233
   			</div>
234
   			<div class="row">
235
           		<div class="col-12 mt-3 chart">
236
                	<canvas id="chartProgressByDay" style="min-height: 250px; height: 250px; max-height: 250px; max-width: 100%;"></canvas>
237
            	</div>
238
          	</div>
239
         	<div class="row">
240
           		<div class="col-12 mt-3" id="row-table">
241
                 	<div style="height: 300px;overflow: scroll;">
242
                    	<table id="tableUsers" style="width: 100%" class="table table-bordered"></table>
243
                  	</div>
244
            	</div>
245
          	</div>
246
    	</div>
247
		<div class="card-footer text-right">
248
  			<button class="btn btn-primary btn-download">LABEL_DOWNLOAD</button>
249
		</div>
250
	</div>
251
</div>
16758 efrain 252
 
16376 anderson 253
 
16633 anderson 254
 
16758 efrain 255
<script id="tableTemplate" type="text/x-jsrender">
256
 
257
        <thead>
258
            <tr>
259
                <th>LABEL_FIRST_NAME</th>
260
                <th>LABEL_LAST_NAME</th>
261
                <th>LABEL_EMAIL</th>
262
                {{for labels}}
263
                    <th>
264
                        {{:date}}
265
                    </th>
266
                {{/for}}
16638 anderson 267
        </tr>
16633 anderson 268
    </thead>
16634 anderson 269
    <tbody>
16758 efrain 270
        {{for users}}
16639 anderson 271
            <tr>
16758 efrain 272
                <td>{{:first_name}}</td>
273
                <td>{{:last_name}}</td>
274
                <td>{{:email}}</td>
275
                {{for values}}
276
                <td class="text-right">
277
                    {{:value}}
16641 anderson 278
                </td>
16758 efrain 279
                {{/for}}
16639 anderson 280
            </tr>
281
        {{/for}}
16634 anderson 282
    </tbody>
16633 anderson 283
 
16611 anderson 284
 
16612 anderson 285
 
16563 anderson 286
</script>
16560 anderson 287