Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15611 | Rev 15613 | 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
 
61
 
62
 
63
 
64
 
65
 
66
 
15597 anderson 67
    var allowEdit   = $allowEdit;
15605 anderson 68
    var allowDelete = $allowDelete;
15593 anderson 69
 
15574 anderson 70
    var gridTable = $('#gridTable').dataTable( {
71
            'processing': true,
72
            'serverSide': true,
73
            'searching': true,
74
            'order': [[ 0, 'asc' ]],
75
            'ordering':  true,
76
            'ordenable' : true,
77
            'responsive': true,
78
            'select' : false,
79
        	'paging': true,
80
            'pagingType': 'simple_numbers',
81
    		'ajax': {
82
    			'url' : '$routeDatatable',
83
    			'type' : 'get',
84
                'beforeSend': function (request) {
85
                  NProgress.start();
86
                },
87
                'dataFilter': function(response) {
88
                    var response = jQuery.parseJSON( response );
89
 
90
                    var json                = {};
91
                    json.recordsTotal       = 0;
92
                    json.recordsFiltered    = 0;
93
                    json.data               = [];
94
 
95
 
96
                    if(response.success) {
97
                        json.recordsTotal       = response.data.total;
98
                        json.recordsFiltered    = response.data.total;
99
                        json.data               = response.data.items;
100
                    } else {
101
                        $.fn.showError(response.data)
102
                    }
103
 
104
                    return JSON.stringify( json );
105
                }
106
    		},
107
            'language' : {
108
                'sProcessing':     'LABEL_DATATABLE_SPROCESSING',
109
                'sLengthMenu':     'LABEL_DATATABLE_SLENGTHMENU',
110
                'sZeroRecords':    'LABEL_DATATABLE_SZERORECORDS',
111
                'sEmptyTable':     'LABEL_DATATABLE_SEMPTYTABLE',
112
                'sInfo':           'LABEL_DATATABLE_SINFO',
113
                'sInfoEmpty':      'LABEL_DATATABLE_SINFOEMPTY',
114
                'sInfoFiltered':   'LABEL_DATATABLE_SINFOFILTERED',
115
                'sInfoPostFix':    '',
116
                'sSearch':         'LABEL_DATATABLE_SSEARCH',
117
                'sUrl':            '',
118
                'sInfoThousands':  ',',
119
                'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
120
                'oPaginate': {
121
                    'sFirst':    'LABEL_DATATABLE_SFIRST',
122
                    'sLast':     'LABEL_DATATABLE_SLAST',
123
                    'sNext':     'LABEL_DATATABLE_SNEXT',
124
                    'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
125
                },
126
                'oAria': {
127
                    'sSortAscending':  ': LABEL_DATATABLE_SSORTASCENDING',
128
                    'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
129
                },
130
            },
131
            'drawCallback': function( settings ) {
132
                NProgress.done();
133
                $('button.btn-delete').confirmation({
134
                    rootSelector: 'button.btn-delete',
135
                    title : 'LABEL_ARE_YOU_SURE',
136
                    singleton : true,
137
                    btnOkLabel: 'LABEL_YES',
138
                    btnCancelLabel: 'LABEL_NO',
139
                    onConfirm: function(value) {
140
                        action = $(this).data('href');
141
                        NProgress.start();
142
                        $.ajax({
143
                            'dataType'  : 'json',
144
                            'accept'    : 'application/json',
145
                            'method'    : 'post',
146
                            'url'       :  action,
147
                        }).done(function(response) {
148
                            if(response['success']) {
149
                                $.fn.showSuccess(response['data']);
150
                                gridTable.api().ajax.reload(null, false);
151
                            } else {
152
                                $.fn.showError(response['data']);
153
                            }
154
                        }).fail(function( jqXHR, textStatus, errorThrown) {
155
                            $.fn.showError(textStatus);
156
                        }).always(function() {
157
                            NProgress.done();
158
                        });
159
                    },
160
                });
161
            },
162
            'aoColumns': [
15608 anderson 163
                { 'mDataProp': 'first_name' },
164
                { 'mDataProp': 'last_name' },
15610 anderson 165
                { 'mDataProp': 'email' },
166
                { 'mDataProp': 'last_activity_on' },
15609 anderson 167
                { 'mDataProp': 'status' },
15591 anderson 168
                { 'mDataProp': 'actions' },
15574 anderson 169
    	    ],
170
            'columnDefs': [
171
                {
172
                    'targets': 0,
173
                    'className' : 'text-vertical-middle',
174
                },
175
                {
176
                    'targets': 1,
15606 anderson 177
                    'orderable': false,
15574 anderson 178
                    'className' : 'text-vertical-middle',
15606 anderson 179
 
15574 anderson 180
                },
15606 anderson 181
 
15574 anderson 182
                {
183
                    'targets': -2,
184
                    'orderable': false,
185
                    'className' : 'text-center',
186
                      'render' : function ( data, type, row ) {
187
 
188
                        checked = data == 'a' ? ' checked="checked" ' : '';
189
                        return '<div class="checkbox checkbox-success">' +
190
                            '<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +
191
                            '<label ></label></div>';
192
                    }
193
                },
194
                {
195
                    'targets': -1,
196
                    'orderable': false,
15595 anderson 197
                    'render' : function ( data, type, row ) {
15597 anderson 198
                        s = '';
15606 anderson 199
 
200
                        if(allowEdit) {
15597 anderson 201
                            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;';
202
                        }
15606 anderson 203
                        if(allowDelete) {
204
                            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 205
                        }
206
                        return s;
15595 anderson 207
                    }
15574 anderson 208
                }
209
              ],
210
        });
211
 
212
 
15387 efrain 213
    $('button.btn-refresh').click(function(e) {
214
        e.preventDefault();
215
        $.fn.loadData();
216
 
217
 
218
    });
219
 
220
 
221
 
222
    $.fn.loadData();
223
    $('button.btn-download').hide();
224
 
225
});
226
JS;
227
$this->inlineScript()->captureEnd();
228
?>
229
 
230
<!-- Content Header (Page header) -->
231
<section class="content-header">
15570 anderson 232
    <div class="container-fluid">
233
        <div class="row mb-2">
234
            <div class="col-sm-12">
235
                <h1>LABEL_REPORTS_USERS_BLOCKED</h1>
236
            </div>
237
        </div>
238
    </div><!-- /.container-fluid -->
15387 efrain 239
</section>
240
 
241
<section class="content">
15570 anderson 242
    <div class="container-fluid">
243
        <div class="row">
244
            <div class="col-12">
245
                <div class="card">
246
                    <div class="card-header">
247
                        <div class="col-md-12 col-sm-12">
248
                            <div style="float:right;">
249
                                <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
250
                                <?php if ($allowDownload) :  ?>
15387 efrain 251
 
15570 anderson 252
                                    <button type="button" class="btn btn-info btn-download"><i class="fa fa-download"></i> LABEL_DOWNLOAD </button>
253
                                <?php endif; ?>
254
                            </div>
255
                        </div>
256
                    </div>
257
                    <div class="card-body">
258
                        <table id="gridTable" class="table   table-hover">
259
                            <thead>
260
                                <tr>
261
                                    <th style="width: 25%">LABEL_FIRST_NAME</th>
262
                                    <th style="width: 25%">LABEL_LAST_NAME</th>
263
                                    <th style="width: 30%">LABEL_EMAIL</th>
264
                                    <th style="width: 20%">LABEL_REPORTS_LAST_ACTIVITY</th>
15387 efrain 265
 
15570 anderson 266
 
15387 efrain 267
                                </tr>
15570 anderson 268
                            </thead>
269
                            <tbody>
270
                            </tbody>
271
                        </table>
272
                    </div>
273
                </div>
274
            </div>
275
        </div>
276
    </div>
277
</section>
15387 efrain 278
 
279
 
280
 
15570 anderson 281
 
15387 efrain 282
<script id="itemRowTemplate" type="text/x-jsrender">
283
    <tr>
284
        <td style="width: 25%">
285
            {{>first_name}}
286
        </td>
287
        <td style="width: 25%">
288
             {{>last_name}}
289
        </td>
290
        <td style="width: 30%">
291
            {{>email}}
292
        </td>
293
        <td style="width: 30%">
294
            {{>last_activity_on}}
295
        </td>
296
 
297
 
298
 
299
    </tr>
300
</script>
301
 
302
 
303
<script id="itemEmptyRowTemplate" type="text/x-jsrender">
304
    <tr>
305
        <td colspan="4">
306
            LABEL_NOT_RECORDS_FOUND
307
        </td>
308
    </tr>
15570 anderson 309
</script>