Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16642 | Rev 16822 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 16642 Rev 16758
Línea 1... Línea 1...
1
<?php
1
<?php
Línea 2... Línea 2...
2
 
2
 
-
 
3
$routeOverview = $this->url('discovery-contacts/progress-by-day');
-
 
4
$routeDownload = $this->url('discovery-contacts/progress-by-day/download');
-
 
5
 
3
$routeOverview = $this->url('discovery-contacts/progress-by-day');
6
 
4
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
7
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
5
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
8
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
Línea 6... Línea 9...
6
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.js'));
9
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.js'));
Línea 17... Línea 20...
17
 
20
 
18
 
21
 
Línea -... Línea 22...
-
 
22
$this->inlineScript()->appendFile($this->basePath('plugins/chart.js/chart.js'));
-
 
23
$this->inlineScript()->appendFile($this->basePath('plugins/chartjs-plugin-datalabels/chartjs-plugin-datalabels.js'));
19
$this->inlineScript()->appendFile($this->basePath('plugins/chart.js/chart.js'));
24
 
-
 
25
/*
-
 
26
$this->headStyle()->captureStart();
-
 
27
echo <<<CSS
-
 
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%;
20
$this->inlineScript()->appendFile($this->basePath('plugins/chartjs-plugin-datalabels/chartjs-plugin-datalabels.js'));
49
    display: table;
21
 
50
    table-layout: fixed;
Línea 22... Línea 51...
22
echo <<<CSS
51
}
23
CSS;
52
CSS;
24
$this->headStyle()->captureEnd();
53
$this->headStyle()->captureEnd();*/
Línea 25... Línea 54...
25
 
54
 
26
$this->inlineScript()->captureStart();
55
$this->inlineScript()->captureStart();
27
echo <<<JS
-
 
Línea 28... Línea 56...
28
jQuery( document ).ready(function( $ ) {
56
echo <<<JS
29
 
-
 
30
    var startDate   = moment().format('YYYY-MM-DD'); 
-
 
31
    var endDate     = moment().format('YYYY-MM-DD'); 
-
 
32
    var competencies_selected = new Array();
-
 
33
 
-
 
34
    var ctxchartProgressByDay = document.getElementById("chartProgressByDay").getContext("2d");
-
 
35
 
-
 
36
    
-
 
37
    
-
 
38
    
-
 
39
    //Dbujando la tabla con jrender
-
 
40
    // $.fn.renderCompetencies = function() {
-
 
41
 
-
 
42
    //     if(competencies_selected.length > 0) {
-
 
43
 
-
 
44
    //          $('#div-competencies').html($('#competencyTemplate').render(competencies_selected, {
-
 
45
    //             getCompetencyType: (uuid) => competency_types.filter((item) => item.uuid == uuid ? item : false)[0],
-
 
46
    //             getCompetency: (uuid) => competencies.filter((item) => item.uuid == uuid ? item : false)[0],
-
 
47
    //             getBehavior: (uuid) => behaviors.filter((item) => item.uuid == uuid ? item : false)[0]
-
 
48
    //         }));
-
 
49
    //     } else {
-
 
50
 
-
 
51
 
-
 
52
    //          $('#div-competencies').empty();
-
 
53
    //     }
-
 
54
    // }
-
 
55
 
-
 
56
    
-
 
57
 
-
 
58
    
-
 
59
    
-
 
60
    
57
jQuery( document ).ready(function( $ ) {
61
    
58
 
62
    
59
    var startDate   = moment().format('YYYY-MM-DD'); 
63
    
60
    var endDate     = moment().format('YYYY-MM-DD'); 
64
    
61
 
Línea 104... Línea 101...
104
                'startDate' : startDate,
101
                'startDate' : startDate,
105
                'endDate' : endDate
102
                'endDate' : endDate
106
            },
103
            },
107
        }).done(function(response) {
104
        }).done(function(response) {
108
            if(response['success']) {
105
            if(response['success']) {
109
                //console.log(response.items[0].demo);
-
 
110
                var items = response.items;
-
 
111
                chartProgressByDay.data.labels = response.data.added_on;
-
 
112
                chartProgressByDay.data.datasets[0].data = response.data.total_by_day;
-
 
113
                chartProgressByDay.update();
-
 
114
 
-
 
115
                //Dibujamos la tabla
-
 
116
                var myTemplate = $.templates("#peopleTmpl");
-
 
117
 
-
 
118
                app = {
-
 
119
                    people: items
-
 
120
                };
-
 
121
 
-
 
122
                var html = myTemplate.render(app);
-
 
123
 
-
 
124
                $("#peopleList").html(html);
-
 
125
                
-
 
126
                
-
 
127
                
-
 
128
 
-
 
129
 
-
 
130
 
-
 
131
 
-
 
132
 
-
 
133
 
-
 
Línea -... Línea 106...
-
 
106
 
-
 
107
                chartProgressByDay.data.labels = response.data.graph.labels;
-
 
108
                chartProgressByDay.data.datasets[0].data = response.data.graph.values;
Línea -... Línea 109...
-
 
109
                chartProgressByDay.update()
-
 
110
 
-
 
111
 
Línea 134... Línea 112...
134
 
112
                $('#tableUsers').html(
135
 
113
                    $('#tableTemplate').render(response.data.table)
136
 
114
                );
137
 
115
 
Línea 162... Línea 140...
162
                'Diciembre'
140
                'Diciembre'
163
            ],
141
            ],
164
        }
142
        }
165
    });
143
    });
Línea 166... Línea -...
166
 
-
 
167
    //Datatable
-
 
168
 
-
 
169
    $('#gridTable').dataTable({
-
 
170
        'processing': true,
-
 
171
        'serverSide': true,
-
 
172
        'searching': true,
-
 
173
        'order': [[ 0, 'asc' ]],
-
 
174
        'ordering':  true,
-
 
175
        'ordenable' : true,
-
 
176
        'responsive': true,
-
 
177
        'select' : false,
-
 
178
        'paging': true,
-
 
179
        'pagingType': 'simple_numbers',
-
 
180
        'ajax': {
-
 
181
            'url' : '$routeOverview',
-
 
182
            'type' : 'get',
-
 
183
            'beforeSend': function (request) {
-
 
184
                NProgress.start();
-
 
185
            },
-
 
186
            'dataFilter': function(response) {
-
 
187
                var response = jQuery.parseJSON( response );
-
 
188
                
-
 
189
                var json                = {};
-
 
190
                json.recordsTotal       = 0;
-
 
191
                json.recordsFiltered    = 0;
-
 
192
                json.data               = [];
-
 
193
                
-
 
194
                if(response.success) {
-
 
195
                    json.recordsTotal       = response.data.total;
-
 
196
                    json.recordsFiltered    = response.data.total;
-
 
197
                    json.data               = response.items;
-
 
198
                } else {
-
 
199
                    $.fn.showError(response.data)
-
 
200
                }
-
 
201
                return JSON.stringify( json );
-
 
202
            }
-
 
203
        },
-
 
204
        // 'drawCallback': function( settings ) {
-
 
205
        //         NProgress.done();
-
 
206
        // },
-
 
207
        'aoColumns': [ 
-
 
208
            { 'mDataProp': "first_name"},
-
 
209
            { 'mDataProp': "last_name" },
-
 
210
            { 'mDataProp': "email" },
-
 
211
            { 'mDataProp': "total_by_day" },
-
 
212
            { 'mDataProp': "added_on" },
-
 
213
         ]
-
 
214
 
-
 
215
    });
-
 
216
 
144
 
217
    $('#filterdate').on('apply.daterangepicker', function(ev, picker) {
145
    $('#filterdate').on('apply.daterangepicker', function(ev, picker) {
218
        startDate = picker.startDate.format('YYYY-MM-DD');
146
        startDate = picker.startDate.format('YYYY-MM-DD');
-
 
147
        endDate =picker.endDate.format('YYYY-MM-DD');
-
 
148
        $.fn.reload();
219
        endDate =picker.endDate.format('YYYY-MM-DD');
149
    });
-
 
150
 
-
 
151
    $('button.btn-download').click(function(e) {
-
 
152
        e.preventDefault();
-
 
153
 
-
 
154
 
220
        
155
        NProgress.start(); 
221
        $.ajax({
156
        $.ajax({
222
            'dataType'  : 'json',
-
 
223
            'accept'    : 'application/json',
157
            'dataType'  : 'json',
224
            'method'    : 'post',
158
            'method'    : 'get',
225
            'url'       :  '$routeOverview',
159
            'url'       : '$routeDownload',
226
            'data'      :  {
160
            'data'      :  {
227
                'startDate' : startDate,
161
                'startDate' : startDate,
228
                'endDate' : endDate
162
                'endDate' : endDate
-
 
163
            },
229
            },
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'] ;
230
            'processData': false,
168
                anchor.download = response['data']['basename'];
-
 
169
                document.body.appendChild(anchor);
231
            'contentType': false,
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);
232
            success: function (response) {
172
            } else {
233
                console.log('enviado');
173
                $.fn.showError(response['data']);
-
 
174
            }
-
 
175
        }).fail(function( jqXHR, textStatus, errorThrown) {
-
 
176
            showError(textStatus);
-
 
177
        }).always(function() {
234
            }
178
            NProgress.done();
235
        });
-
 
-
 
179
        });
-
 
180
 
236
        $.fn.reload();
181
 
Línea 237... Línea 182...
237
    });
182
    });
Línea 238... Línea 183...
238
 
183
 
Línea 268... Línea 213...
268
                        <div class="row">
213
                        <div class="row">
269
                            <div class="col-lg-12 col-12 chart">
214
                            <div class="col-lg-12 col-12 chart">
270
                                <canvas id="chartProgressByDay" style="min-height: 250px; height: 250px; max-height: 250px; max-width: 100%;"></canvas>
215
                                <canvas id="chartProgressByDay" style="min-height: 250px; height: 250px; max-height: 250px; max-width: 100%;"></canvas>
271
                            </div>
216
                            </div>
272
                        </div>
217
                        </div>
-
 
218
                    	<div class="row">
-
 
219
                            <div class="col-12" id="row-table">
-
 
220
                            	<div style="height: 300px;overflow: scroll;"> 
-
 
221
                    				<table id="tableUsers" style="width: 100%" class="table table-bordered table-hover">
-
 
222
                            		</table>
-
 
223
                            </div>
-
 
224
                        </div> 
-
 
225
                    </div>
-
 
226
                	<div class="card-footer clearfix">
-
 
227
                        <div class="text-right">
-
 
228
                            <button class="btn btn-primary btn-download">LABEL_DOWNLOAD</button>
-
 
229
 
-
 
230
                        </div>
273
                    </div>
231
                    </div>
274
                </div>
232
                </div>
275
            </div>
233
            </div>
276
        </div>
234
        </div>
-
 
235
   </div>     
277
</section>
236
</section>
Línea 278... Línea -...
278
 
-
 
Línea 279... Línea -...
279
<table class="table table-bordered" id="peopleList">
-
 
Línea 280... Línea 237...
280
 
237
 
-
 
238
 
281
</table>
239
 
282
 
240
<script id="tableTemplate" type="text/x-jsrender">
-
 
241
 
-
 
242
        <thead>
283
<script id="peopleTmpl" type="text/x-jsrender">
243
            <tr>
284
    <thead>
244
                <th>LABEL_FIRST_NAME</th>
285
        <tr>
245
                <th>LABEL_LAST_NAME</th>
286
            <th>Usuario</th>
246
                <th>LABEL_EMAIL</th>
287
            {{for people}}
247
                {{for labels}}
288
                <th>
248
                    <th>
289
                    {{:month}}
249
                        {{:date}}
290
                </th>
250
                    </th>
291
            {{/for}}
251
                {{/for}}
292
        </tr>
252
        </tr>
293
    </thead>
253
    </thead>
294
    <tbody>
254
    <tbody>
295
        {{for people}}
255
        {{for users}}
296
            <tr>
256
            <tr>
297
                <td>
257
                <td>{{:first_name}}</td>
-
 
258
                <td>{{:last_name}}</td>
298
                    {{:users}}
259
                <td>{{:email}}</td>
299
                </td>
260
                {{for values}}
-
 
261
                <td class="text-right">
300
                <td>
262
                    {{:value}}
301
                    {{:total}}
263
                </td>
302
                </td>
264
                {{/for}}