Proyectos de Subversion LeadersLinked - Backend

Rev

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