Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15593 | Rev 15595 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
15387 efrain 1
<?php
2
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser    = $this->currentUserHelper();
4
 
5
$roleName = $currentUser->getUserTypeId();
15574 anderson 6
$routeDatatable = $this->url('reports/users-blocked');
15387 efrain 7
 
8
$allowDownload  = $acl->isAllowed($roleName, 'reports/users-blocked/excel') ? 1 : 0;
9
 
10
 
11
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
12
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
13
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.js'));
14
 
15570 anderson 15
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
16
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
17
 
18
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
19
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
20
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
21
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
22
 
15387 efrain 23
$this->headStyle()->captureStart();
24
echo <<<CSS
25
 
26
 
27
#tableStudents {
28
    display: flex;
29
    flex-flow: column;
30
    width: 100%;
31
}
32
 
33
#tableStudents thead {
34
    flex: 0 0 auto;
35
}
36
 
37
#tableStudents tbody {
38
    flex: 1 1 auto;
39
    display: block;
40
    overflow-y: auto;
41
    overflow-x: hidden;
42
}
43
 
44
#tableStudents tr {
45
    width: 100%;
46
    display: table;
47
    table-layout: fixed;
48
}
49
CSS;
50
$this->headStyle()->captureEnd();
51
 
52
 
53
 
54
$this->inlineScript()->captureStart();
55
echo <<<JS
56
jQuery( document ).ready(function( $ ) {
57
 
58
 
15574 anderson 59
    $.fn.loadData = function() {
60
        NProgress.start();
61
        $.ajax({
62
            'dataType'  : 'json',
63
            'accept'    : 'application/json',
64
            'method'    : 'get',
65
            'url'       :  $('#form-filter').attr('action'),
66
            'data'      :  $('#form-filter').serialize(),
67
        }).done(function(response) {
68
            if(response['success']) {
15387 efrain 69
 
70
 
71
 
15574 anderson 72
               $('#gridTable tbody').empty();
73
                if(response['data']['items']) {
15387 efrain 74
 
15574 anderson 75
                    $('#gridTable tbody').append(
76
                        $( "#itemRowTemplate" ).render( response['data']['items'] )
15387 efrain 77
 
15574 anderson 78
                    );
15387 efrain 79
 
15574 anderson 80
                } else {
81
                    $('#gridTable tbody').append(
82
                        $( "#itemEmptyRowTemplate" ).render([])
83
                    );
15387 efrain 84
 
15574 anderson 85
                }
15387 efrain 86
 
15574 anderson 87
                if(response['data']['link_download']) {
88
                    $('button.btn-download').data('href', response['data']['link_download']);
89
                    $('button.btn-download').show();
15387 efrain 90
 
15574 anderson 91
                } else {
92
                     $('button.btn-download').hide();
93
                }
15387 efrain 94
 
15574 anderson 95
            } else {
96
                if(jQuery.type(response['data']) == 'string') {
97
                    $.fn.showError(response['data']);
98
                } else  {
99
                    $.each(response['data'], function( fieldname, errors ) {
100
                        $.fn.showFormErrorValidator('#form-filter #' + fieldname, errors);
101
                    });
102
                }
103
            }
104
        }).fail(function( jqXHR, textStatus, errorThrown) {
105
            $.fn.showError(textStatus);
106
        }).always(function() {
107
            NProgress.done();
108
        });
109
        return false;
110
    }
15387 efrain 111
 
112
 
15574 anderson 113
 
114
 
115
 
116
 
15593 anderson 117
 
15574 anderson 118
    var gridTable = $('#gridTable').dataTable( {
119
            'processing': true,
120
            'serverSide': true,
121
            'searching': true,
122
            'order': [[ 0, 'asc' ]],
123
            'ordering':  true,
124
            'ordenable' : true,
125
            'responsive': true,
126
            'select' : false,
127
        	'paging': true,
128
            'pagingType': 'simple_numbers',
129
    		'ajax': {
130
    			'url' : '$routeDatatable',
131
    			'type' : 'get',
132
                'beforeSend': function (request) {
133
                  NProgress.start();
134
                },
135
                'dataFilter': function(response) {
136
                    var response = jQuery.parseJSON( response );
137
 
138
                    var json                = {};
139
                    json.recordsTotal       = 0;
140
                    json.recordsFiltered    = 0;
141
                    json.data               = [];
142
 
143
 
144
                    if(response.success) {
145
                        json.recordsTotal       = response.data.total;
146
                        json.recordsFiltered    = response.data.total;
147
                        json.data               = response.data.items;
148
                    } else {
149
                        $.fn.showError(response.data)
150
                    }
151
 
152
                    return JSON.stringify( json );
153
                }
154
    		},
155
            'language' : {
156
                'sProcessing':     'LABEL_DATATABLE_SPROCESSING',
157
                'sLengthMenu':     'LABEL_DATATABLE_SLENGTHMENU',
158
                'sZeroRecords':    'LABEL_DATATABLE_SZERORECORDS',
159
                'sEmptyTable':     'LABEL_DATATABLE_SEMPTYTABLE',
160
                'sInfo':           'LABEL_DATATABLE_SINFO',
161
                'sInfoEmpty':      'LABEL_DATATABLE_SINFOEMPTY',
162
                'sInfoFiltered':   'LABEL_DATATABLE_SINFOFILTERED',
163
                'sInfoPostFix':    '',
164
                'sSearch':         'LABEL_DATATABLE_SSEARCH',
165
                'sUrl':            '',
166
                'sInfoThousands':  ',',
167
                'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
168
                'oPaginate': {
169
                    'sFirst':    'LABEL_DATATABLE_SFIRST',
170
                    'sLast':     'LABEL_DATATABLE_SLAST',
171
                    'sNext':     'LABEL_DATATABLE_SNEXT',
172
                    'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
173
                },
174
                'oAria': {
175
                    'sSortAscending':  ': LABEL_DATATABLE_SSORTASCENDING',
176
                    'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
177
                },
178
            },
179
            'drawCallback': function( settings ) {
180
                NProgress.done();
181
                $('button.btn-delete').confirmation({
182
                    rootSelector: 'button.btn-delete',
183
                    title : 'LABEL_ARE_YOU_SURE',
184
                    singleton : true,
185
                    btnOkLabel: 'LABEL_YES',
186
                    btnCancelLabel: 'LABEL_NO',
187
                    onConfirm: function(value) {
188
                        action = $(this).data('href');
189
                        NProgress.start();
190
                        $.ajax({
191
                            'dataType'  : 'json',
192
                            'accept'    : 'application/json',
193
                            'method'    : 'post',
194
                            'url'       :  action,
195
                        }).done(function(response) {
196
                            if(response['success']) {
197
                                $.fn.showSuccess(response['data']);
198
                                gridTable.api().ajax.reload(null, false);
199
                            } else {
200
                                $.fn.showError(response['data']);
201
                            }
202
                        }).fail(function( jqXHR, textStatus, errorThrown) {
203
                            $.fn.showError(textStatus);
204
                        }).always(function() {
205
                            NProgress.done();
206
                        });
207
                    },
208
                });
209
            },
210
            'aoColumns': [
15575 anderson 211
                { 'mDataProp': 'first_name' },
212
                { 'mDataProp': 'last_name' },
15591 anderson 213
                { 'mDataProp': 'status' },
214
                { 'mDataProp': 'actions' },
15574 anderson 215
    	    ],
216
            'columnDefs': [
217
                {
218
                    'targets': 0,
219
                    'className' : 'text-vertical-middle',
220
                },
221
                {
222
                    'targets': 1,
223
                    'className' : 'text-vertical-middle',
224
                },
225
                {
226
                    'targets': -2,
227
                    'orderable': false,
228
                    'className' : 'text-center',
229
                      'render' : function ( data, type, row ) {
230
 
231
                        checked = data == 'a' ? ' checked="checked" ' : '';
232
                        return '<div class="checkbox checkbox-success">' +
233
                            '<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +
234
                            '<label ></label></div>';
235
                    }
236
                },
237
                {
238
                    'targets': -1,
239
                    'orderable': false,
15594 anderson 240
                    // 'render' : function ( data, type, row ) {
241
                    //     s = '';
15574 anderson 242
 
15594 anderson 243
                    //     if(allowEdit &&  data['link_edit']) {
244
                    //         s = s + '<button class="btn btn-primary btn-edit" data-href="' + data['link_edit']+ '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pencil"></i> LABEL_EDIT </button>&nbsp;';
245
                    //     }
246
                    //     if(allowDelete && data['link_delete']) {
247
                    //         s = s + '<button class="btn btn-delete" data-href="' + data['link_delete']+ '" data-toggle="tooltip" title="LABEL_DELETE"><i class="fa fa-trash"></i> LABEL_DELETE </button>&nbsp;';
248
                    //     }
249
                    //     return s;
250
                    // }
15574 anderson 251
                }
252
              ],
253
        });
254
 
255
 
256
 
257
 
258
 
259
 
260
 
261
 
262
 
263
 
264
 
265
 
266
 
15387 efrain 267
    $('button.btn-download').click(function(e) {
268
        e.preventDefault();
269
        var action   = $(this).data('href');
270
 
271
        NProgress.start();
272
        $.ajax({
273
            'dataType'  : 'json',
274
            'method'    : 'get',
275
            'url'       :  action,
276
        }).done(function(response) {
277
            if(response['success']) {
278
                var anchor = window.document.createElement("a");
279
                anchor.href = 'data:application/octet-stream;charset=utf-8;base64,' + response['data']['content'] ;
280
                anchor.download = response['data']['basename'];
281
                document.body.appendChild(anchor);
282
                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
283
                document.body.removeChild(anchor);
284
            } else {
285
                $.fn.showError(response['data']);
286
            }
287
        }).fail(function( jqXHR, textStatus, errorThrown) {
288
            showError(textStatus);
289
        }).always(function() {
290
            NProgress.done();
291
        });
292
 
293
 
294
    });
295
 
296
 
297
    $('button.btn-refresh').click(function(e) {
298
        e.preventDefault();
299
        $.fn.loadData();
300
 
301
 
302
    });
303
 
304
 
305
 
306
    $.fn.loadData();
307
    $('button.btn-download').hide();
308
 
309
});
310
JS;
311
$this->inlineScript()->captureEnd();
312
?>
313
 
314
<!-- Content Header (Page header) -->
315
<section class="content-header">
15570 anderson 316
    <div class="container-fluid">
317
        <div class="row mb-2">
318
            <div class="col-sm-12">
319
                <h1>LABEL_REPORTS_USERS_BLOCKED</h1>
320
            </div>
321
        </div>
322
    </div><!-- /.container-fluid -->
15387 efrain 323
</section>
324
 
325
<section class="content">
15570 anderson 326
    <div class="container-fluid">
327
        <div class="row">
328
            <div class="col-12">
329
                <div class="card">
330
                    <div class="card-header">
331
                        <div class="col-md-12 col-sm-12">
332
                            <div style="float:right;">
333
                                <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
334
                                <?php if ($allowDownload) :  ?>
15387 efrain 335
 
15570 anderson 336
                                    <button type="button" class="btn btn-info btn-download"><i class="fa fa-download"></i> LABEL_DOWNLOAD </button>
337
                                <?php endif; ?>
338
                            </div>
339
                        </div>
340
                    </div>
341
                    <div class="card-body">
342
                        <table id="gridTable" class="table   table-hover">
343
                            <thead>
344
                                <tr>
345
                                    <th style="width: 25%">LABEL_FIRST_NAME</th>
346
                                    <th style="width: 25%">LABEL_LAST_NAME</th>
347
                                    <th style="width: 30%">LABEL_EMAIL</th>
348
                                    <th style="width: 20%">LABEL_REPORTS_LAST_ACTIVITY</th>
15387 efrain 349
 
15570 anderson 350
 
15387 efrain 351
                                </tr>
15570 anderson 352
                            </thead>
353
                            <tbody>
354
                            </tbody>
355
                        </table>
356
                    </div>
357
                </div>
358
            </div>
359
        </div>
360
    </div>
361
</section>
15387 efrain 362
 
363
 
364
 
15570 anderson 365
 
15387 efrain 366
<script id="itemRowTemplate" type="text/x-jsrender">
367
    <tr>
368
        <td style="width: 25%">
369
            {{>first_name}}
370
        </td>
371
        <td style="width: 25%">
372
             {{>last_name}}
373
        </td>
374
        <td style="width: 30%">
375
            {{>email}}
376
        </td>
377
        <td style="width: 30%">
378
            {{>last_activity_on}}
379
        </td>
380
 
381
 
382
 
383
    </tr>
384
</script>
385
 
386
 
387
<script id="itemEmptyRowTemplate" type="text/x-jsrender">
388
    <tr>
389
        <td colspan="4">
390
            LABEL_NOT_RECORDS_FOUND
391
        </td>
392
    </tr>
15570 anderson 393
</script>