Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16747 | Rev 16842 | 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;
16747 efrain 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
 
16822 efrain 13
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
14
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
15
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jsrender/jsrender.js'));
15387 efrain 16
 
16822 efrain 17
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));
18
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.css'));
15570 anderson 19
 
16822 efrain 20
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
21
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));
22
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/dataTables.responsive.min.js'));
23
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.min.js'));
15570 anderson 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
 
16747 efrain 118
   // var allowEdit   = $allowEdit;
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();
16822 efrain 184
 
15574 anderson 185
            },
186
            'aoColumns': [
15615 anderson 187
                { 'mDataProp': 'first_name' },
15618 anderson 188
                { 'mDataProp': 'last_name' },
189
                { 'mDataProp': 'email' },
190
                { 'mDataProp': 'last_activity_on' },
15619 anderson 191
                { 'mDataProp': 'actions' },
15574 anderson 192
    	    ],
193
            'columnDefs': [
194
                {
195
                    'targets': 0,
196
                    'className' : 'text-vertical-middle',
197
                },
198
                {
199
                    'targets': 1,
15606 anderson 200
                    'orderable': false,
15574 anderson 201
                    'className' : 'text-vertical-middle',
15606 anderson 202
 
15574 anderson 203
                },
15606 anderson 204
 
15574 anderson 205
                {
206
                    'targets': -2,
207
                    'orderable': false,
208
                    'className' : 'text-center',
209
                      'render' : function ( data, type, row ) {
210
 
16822 efrain 211
                        checked = data == 'a'  ? 'checked' : '';
212
                        return '<div class="form-check">' +
213
                            '<input type="checkbox" class="form-check-input" disabled="" checked="' + checked + '">' +
214
                            '<label class="form-check-label" for="checkCheckedDisabled"></label></div>' ;
15574 anderson 215
                    }
216
                },
217
                {
218
                    'targets': -1,
219
                    'orderable': false,
15595 anderson 220
                    'render' : function ( data, type, row ) {
15597 anderson 221
                        s = '';
15606 anderson 222
 
16747 efrain 223
/*
15606 anderson 224
                        if(allowEdit) {
15597 anderson 225
                            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;';
226
                        }
15606 anderson 227
                        if(allowDelete) {
228
                            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 229
                        }
16747 efrain 230
*/
15597 anderson 231
                        return s;
15595 anderson 232
                    }
15574 anderson 233
                }
234
              ],
235
        });
236
 
237
 
15387 efrain 238
    $('button.btn-refresh').click(function(e) {
239
        e.preventDefault();
240
        $.fn.loadData();
241
 
242
 
243
    });
244
 
16822 efrain 245
 $('body').on('click', 'button.btn-delete', function(e) {
246
        e.preventDefault();
247
        var action = $(this).data('href');
15387 efrain 248
 
249
 
16822 efrain 250
          swal.fire({
251
            title: 'LABEL_ARE_YOU_SURE',
252
            icon: 'question',
253
            cancelButtonText: 'LABEL_NO',
254
            showCancelButton: true,
255
            confirmButtonText: 'LABEL_YES'
256
          }).then((result) => {
257
            if (result.isConfirmed) {
258
 
259
                    NProgress.start();
260
                    $.ajax({
261
                        'dataType'  : 'json',
262
                        'accept'    : 'application/json',
263
                        'method'    : 'post',
264
                        'url'       :  action,
265
                    }).done(function(response) {
266
                        if(response['success']) {
267
                            $.fn.showSuccess(response['data']);
268
                            gridTable.api().ajax.reload(null, false);
269
                        } else {
270
                            $.fn.showError(response['data']);
271
                        }
272
                    }).fail(function( jqXHR, textStatus, errorThrown) {
273
                        $.fn.showError(textStatus);
274
                    }).always(function() {
275
                        NProgress.done();
276
                    });
277
            }
278
       });
279
    });
280
 
281
 
15387 efrain 282
    $.fn.loadData();
283
    $('button.btn-download').hide();
284
 
285
});
286
JS;
287
$this->inlineScript()->captureEnd();
288
?>
289
 
290
<!-- Content Header (Page header) -->
291
<section class="content-header">
15570 anderson 292
    <div class="container-fluid">
293
        <div class="row mb-2">
294
            <div class="col-sm-12">
295
                <h1>LABEL_REPORTS_USERS_BLOCKED</h1>
296
            </div>
297
        </div>
298
    </div><!-- /.container-fluid -->
15387 efrain 299
</section>
300
 
301
<section class="content">
15570 anderson 302
    <div class="container-fluid">
303
        <div class="row">
304
            <div class="col-12">
305
                <div class="card">
306
                    <div class="card-header">
307
                        <div class="col-md-12 col-sm-12">
308
                            <div style="float:right;">
309
                                <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
310
                                <?php if ($allowDownload) :  ?>
15387 efrain 311
 
15570 anderson 312
                                    <button type="button" class="btn btn-info btn-download"><i class="fa fa-download"></i> LABEL_DOWNLOAD </button>
313
                                <?php endif; ?>
314
                            </div>
315
                        </div>
316
                    </div>
317
                    <div class="card-body">
318
                        <table id="gridTable" class="table   table-hover">
319
                            <thead>
320
                                <tr>
321
                                    <th style="width: 25%">LABEL_FIRST_NAME</th>
322
                                    <th style="width: 25%">LABEL_LAST_NAME</th>
323
                                    <th style="width: 30%">LABEL_EMAIL</th>
324
                                    <th style="width: 20%">LABEL_REPORTS_LAST_ACTIVITY</th>
15619 anderson 325
                                    <th>LABEL_ACTIONS</th>
15387 efrain 326
                                </tr>
15570 anderson 327
                            </thead>
328
                            <tbody>
329
                            </tbody>
330
                        </table>
331
                    </div>
332
                </div>
333
            </div>
334
        </div>
335
    </div>
336
</section>
15387 efrain 337
 
338
 
339
 
15570 anderson 340
 
15387 efrain 341
<script id="itemRowTemplate" type="text/x-jsrender">
342
    <tr>
343
        <td style="width: 25%">
344
            {{>first_name}}
345
        </td>
346
        <td style="width: 25%">
347
             {{>last_name}}
348
        </td>
349
        <td style="width: 30%">
350
            {{>email}}
351
        </td>
352
        <td style="width: 30%">
353
            {{>last_activity_on}}
354
        </td>
355
 
356
 
357
 
358
    </tr>
359
</script>
360
 
361
 
362
<script id="itemEmptyRowTemplate" type="text/x-jsrender">
363
    <tr>
364
        <td colspan="4">
365
            LABEL_NOT_RECORDS_FOUND
366
        </td>
367
    </tr>
15570 anderson 368
</script>