Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15619 | Rev 16822 | 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
 
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
 
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();
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' },
15618 anderson 215
                { 'mDataProp': 'last_name' },
216
                { 'mDataProp': 'email' },
217
                { 'mDataProp': 'last_activity_on' },
15619 anderson 218
                { 'mDataProp': 'actions' },
15574 anderson 219
    	    ],
220
            'columnDefs': [
221
                {
222
                    'targets': 0,
223
                    'className' : 'text-vertical-middle',
224
                },
225
                {
226
                    'targets': 1,
15606 anderson 227
                    'orderable': false,
15574 anderson 228
                    'className' : 'text-vertical-middle',
15606 anderson 229
 
15574 anderson 230
                },
15606 anderson 231
 
15574 anderson 232
                {
233
                    'targets': -2,
234
                    'orderable': false,
235
                    'className' : 'text-center',
236
                      'render' : function ( data, type, row ) {
237
 
238
                        checked = data == 'a' ? ' checked="checked" ' : '';
239
                        return '<div class="checkbox checkbox-success">' +
240
                            '<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +
241
                            '<label ></label></div>';
242
                    }
243
                },
244
                {
245
                    'targets': -1,
246
                    'orderable': false,
15595 anderson 247
                    'render' : function ( data, type, row ) {
15597 anderson 248
                        s = '';
15606 anderson 249
 
16747 efrain 250
/*
15606 anderson 251
                        if(allowEdit) {
15597 anderson 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
                        }
15606 anderson 254
                        if(allowDelete) {
255
                            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 256
                        }
16747 efrain 257
*/
15597 anderson 258
                        return s;
15595 anderson 259
                    }
15574 anderson 260
                }
261
              ],
262
        });
263
 
264
 
15387 efrain 265
    $('button.btn-refresh').click(function(e) {
266
        e.preventDefault();
267
        $.fn.loadData();
268
 
269
 
270
    });
271
 
272
 
273
 
274
    $.fn.loadData();
275
    $('button.btn-download').hide();
276
 
277
});
278
JS;
279
$this->inlineScript()->captureEnd();
280
?>
281
 
282
<!-- Content Header (Page header) -->
283
<section class="content-header">
15570 anderson 284
    <div class="container-fluid">
285
        <div class="row mb-2">
286
            <div class="col-sm-12">
287
                <h1>LABEL_REPORTS_USERS_BLOCKED</h1>
288
            </div>
289
        </div>
290
    </div><!-- /.container-fluid -->
15387 efrain 291
</section>
292
 
293
<section class="content">
15570 anderson 294
    <div class="container-fluid">
295
        <div class="row">
296
            <div class="col-12">
297
                <div class="card">
298
                    <div class="card-header">
299
                        <div class="col-md-12 col-sm-12">
300
                            <div style="float:right;">
301
                                <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
302
                                <?php if ($allowDownload) :  ?>
15387 efrain 303
 
15570 anderson 304
                                    <button type="button" class="btn btn-info btn-download"><i class="fa fa-download"></i> LABEL_DOWNLOAD </button>
305
                                <?php endif; ?>
306
                            </div>
307
                        </div>
308
                    </div>
309
                    <div class="card-body">
310
                        <table id="gridTable" class="table   table-hover">
311
                            <thead>
312
                                <tr>
313
                                    <th style="width: 25%">LABEL_FIRST_NAME</th>
314
                                    <th style="width: 25%">LABEL_LAST_NAME</th>
315
                                    <th style="width: 30%">LABEL_EMAIL</th>
316
                                    <th style="width: 20%">LABEL_REPORTS_LAST_ACTIVITY</th>
15619 anderson 317
                                    <th>LABEL_ACTIONS</th>
15387 efrain 318
                                </tr>
15570 anderson 319
                            </thead>
320
                            <tbody>
321
                            </tbody>
322
                        </table>
323
                    </div>
324
                </div>
325
            </div>
326
        </div>
327
    </div>
328
</section>
15387 efrain 329
 
330
 
331
 
15570 anderson 332
 
15387 efrain 333
<script id="itemRowTemplate" type="text/x-jsrender">
334
    <tr>
335
        <td style="width: 25%">
336
            {{>first_name}}
337
        </td>
338
        <td style="width: 25%">
339
             {{>last_name}}
340
        </td>
341
        <td style="width: 30%">
342
            {{>email}}
343
        </td>
344
        <td style="width: 30%">
345
            {{>last_activity_on}}
346
        </td>
347
 
348
 
349
 
350
    </tr>
351
</script>
352
 
353
 
354
<script id="itemEmptyRowTemplate" type="text/x-jsrender">
355
    <tr>
356
        <td colspan="4">
357
            LABEL_NOT_RECORDS_FOUND
358
        </td>
359
    </tr>
15570 anderson 360
</script>