Proyectos de Subversion LeadersLinked - Backend

Rev

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