Proyectos de Subversion LeadersLinked - Backend

Rev

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