Proyectos de Subversion LeadersLinked - Backend

Rev

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