Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16864 | 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');
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
                {
16232 anderson 68
                	label : 'LABEL_CONTACT_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
 
16028 anderson 126
    $('#filterdate').daterangepicker({
127
        maxDate: new Date(),
128
        locale: {
129
            format: 'DD/MM/YYYY',
130
            applyLabel: 'Aplicar',
131
            cancelLabel: 'Cancelar',
132
            daysOfWeek: ['Do', 'Lu','Ma', 'Mi', 'Ju', 'Vi', 'Sa'],
133
            monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo',
134
                'Junio',
135
                'Agosto',
136
                'Septiembre',
137
                'Octubre',
138
                'Noviembre',
139
                'Diciembre'
140
            ],
141
        }
142
    });
143
 
16758 efrain 144
    $('#filterdate').on('apply.daterangepicker', function(ev, picker) {
145
        startDate = picker.startDate.format('YYYY-MM-DD');
146
        endDate =picker.endDate.format('YYYY-MM-DD');
147
        $.fn.reload();
148
    });
16381 anderson 149
 
16758 efrain 150
    $('button.btn-download').click(function(e) {
151
        e.preventDefault();
16421 anderson 152
 
16411 anderson 153
 
16758 efrain 154
        NProgress.start();
16237 anderson 155
        $.ajax({
156
            'dataType'  : 'json',
16758 efrain 157
            'method'    : 'get',
158
            'url'       : '$routeDownload',
16237 anderson 159
            'data'      :  {
160
                'startDate' : startDate,
161
                'endDate' : endDate
162
            },
16758 efrain 163
        }).done(function(response) {
164
            if(response['success']) {
165
                var anchor = window.document.createElement("a");
166
                anchor.href = 'data:application/octet-stream;charset=utf-8;base64,' + response['data']['content'] ;
167
                anchor.download = response['data']['basename'];
168
                document.body.appendChild(anchor);
169
                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
170
                document.body.removeChild(anchor);
171
            } else {
172
                $.fn.showError(response['data']);
16237 anderson 173
            }
16758 efrain 174
        }).fail(function( jqXHR, textStatus, errorThrown) {
175
            showError(textStatus);
176
        }).always(function() {
177
            NProgress.done();
16237 anderson 178
        });
16758 efrain 179
 
180
 
16029 anderson 181
    });
182
 
15875 anderson 183
    $.fn.reload();
15873 anderson 184
 
15857 anderson 185
});
15760 anderson 186
JS;
187
$this->inlineScript()->captureEnd();
188
?>
189
 
16864 efrain 190
<div class="container">
191
	<div class="card">
192
  		<div class="card-header">
193
     		<h6 class="card-title">LABEL_DAILY_PROGRESS_CHART</h6>
194
		</div>
195
   		<div class="card-body">
196
   			<div class="row">
197
   				<div class="col-12 mt-3">
198
             		<label>LABEL_DATE_RANGE</label>
199
             		<div class="input-group mb-3">
200
                      <span class="input-group-text" id="basic-addon1"><i class="far fa-calendar"></i></span>
201
                      <input type="text" class="form-control" name="filterdate" id="filterdate">
15759 anderson 202
                    </div>
16864 efrain 203
   				</div>
204
   			</div>
205
   			<div class="row">
206
           		<div class="col-12 mt-3 chart">
207
                	<canvas id="chartProgressByDay" style="min-height: 250px; height: 250px; max-height: 250px; max-width: 100%;"></canvas>
208
            	</div>
209
          	</div>
210
         	<div class="row">
211
           		<div class="col-12 mt-3" id="row-table">
212
                 	<div style="height: 300px;overflow: scroll;">
213
                    	<table id="tableUsers" style="width: 100%" class="table table-bordered"></table>
214
                  	</div>
215
            	</div>
216
          	</div>
217
    	</div>
218
		<div class="card-footer text-right">
219
  			<button class="btn btn-primary btn-download">LABEL_DOWNLOAD</button>
220
		</div>
221
	</div>
222
</div>
16758 efrain 223
 
16376 anderson 224
 
16633 anderson 225
 
16758 efrain 226
<script id="tableTemplate" type="text/x-jsrender">
227
 
228
        <thead>
229
            <tr>
230
                <th>LABEL_FIRST_NAME</th>
231
                <th>LABEL_LAST_NAME</th>
232
                <th>LABEL_EMAIL</th>
233
                {{for labels}}
234
                    <th>
235
                        {{:date}}
236
                    </th>
237
                {{/for}}
16638 anderson 238
        </tr>
16633 anderson 239
    </thead>
16634 anderson 240
    <tbody>
16758 efrain 241
        {{for users}}
16639 anderson 242
            <tr>
16758 efrain 243
                <td>{{:first_name}}</td>
244
                <td>{{:last_name}}</td>
245
                <td>{{:email}}</td>
246
                {{for values}}
247
                <td class="text-right">
248
                    {{:value}}
16641 anderson 249
                </td>
16758 efrain 250
                {{/for}}
16639 anderson 251
            </tr>
252
        {{/for}}
16634 anderson 253
    </tbody>
16633 anderson 254
 
16611 anderson 255
 
16612 anderson 256
 
16563 anderson 257
</script>
16560 anderson 258