Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16932 | | 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
 
16932 efrain 8
$allowDownload  = $acl->isAllowed($roleName, 'reports/users-blocked/download') ? 1 : 0;
15387 efrain 9
 
10
 
16822 efrain 11
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
12
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
13
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jsrender/jsrender.js'));
15387 efrain 14
 
16822 efrain 15
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));
16
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.css'));
15570 anderson 17
 
16822 efrain 18
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
19
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));
20
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/dataTables.responsive.min.js'));
21
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.min.js'));
15570 anderson 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
 
15613 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']) {
69
 
70
 
71
 
72
               $('#gridTable tbody').empty();
73
                if(response['data']['items']) {
74
 
75
                    $('#gridTable tbody').append(
76
                        $( "#itemRowTemplate" ).render( response['data']['items'] )
15387 efrain 77
 
15613 anderson 78
                    );
79
 
80
                } else {
81
                    $('#gridTable tbody').append(
82
                        $( "#itemEmptyRowTemplate" ).render([])
83
                    );
15387 efrain 84
 
15613 anderson 85
                }
15387 efrain 86
 
87
 
88
 
15613 anderson 89
            } else {
90
                if(jQuery.type(response['data']) == 'string') {
91
                    $.fn.showError(response['data']);
92
                } else  {
93
                    $.each(response['data'], function( fieldname, errors ) {
94
                        $.fn.showFormErrorValidator('#form-filter #' + fieldname, errors);
95
                    });
96
                }
97
            }
98
        }).fail(function( jqXHR, textStatus, errorThrown) {
99
            $.fn.showError(textStatus);
100
        }).always(function() {
101
            NProgress.done();
102
        });
103
        return false;
104
    }
15387 efrain 105
 
15613 anderson 106
 
107
 
108
 
109
 
15574 anderson 110
    var gridTable = $('#gridTable').dataTable( {
111
            'processing': true,
112
            'serverSide': true,
113
            'searching': true,
114
            'order': [[ 0, 'asc' ]],
115
            'ordering':  true,
116
            'ordenable' : true,
117
            'responsive': true,
118
            'select' : false,
119
        	'paging': true,
120
            'pagingType': 'simple_numbers',
121
    		'ajax': {
122
    			'url' : '$routeDatatable',
123
    			'type' : 'get',
124
                'beforeSend': function (request) {
125
                  NProgress.start();
126
                },
127
                'dataFilter': function(response) {
128
                    var response = jQuery.parseJSON( response );
129
 
130
                    var json                = {};
131
                    json.recordsTotal       = 0;
132
                    json.recordsFiltered    = 0;
133
                    json.data               = [];
134
 
135
 
136
                    if(response.success) {
16932 efrain 137
 
138
                        $('button.btn-download').attr('href', response.data.link_download);
139
                        if(response.data.total == 0) {
140
                            $('button.btn-download').hide();
141
                        } else {
142
                            $('button.btn-download').show();
143
                        }
144
 
15574 anderson 145
                        json.recordsTotal       = response.data.total;
146
                        json.recordsFiltered    = response.data.total;
147
                        json.data               = response.data.items;
148
                    } else {
16932 efrain 149
                        $('button.btn-download').hide();
150
 
151
 
15574 anderson 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' },
16842 efrain 191
 
192
 
16932 efrain 193
 
15574 anderson 194
    	    ],
195
            'columnDefs': [
196
                {
197
                    'targets': 0,
198
                    'className' : 'text-vertical-middle',
199
                },
200
                {
201
                    'targets': 1,
15606 anderson 202
                    'orderable': false,
15574 anderson 203
                    'className' : 'text-vertical-middle',
15606 anderson 204
 
15574 anderson 205
                },
15606 anderson 206
 
16842 efrain 207
 
15574 anderson 208
              ],
209
        });
210
 
211
 
15387 efrain 212
    $('button.btn-refresh').click(function(e) {
213
        e.preventDefault();
214
 
16932 efrain 215
        gridTable.api().ajax.reload(null, false);
216
 
15387 efrain 217
    });
218
 
219
 
16932 efrain 220
 
221
   $('body').on('click', 'button.btn-download', function(e) {
222
        e.preventDefault();
223
        var action   = $(this).attr('href');
15387 efrain 224
 
16822 efrain 225
 
16932 efrain 226
        NProgress.start();
227
        $.ajax({
228
            'dataType'  : 'json',
229
            'method'    : 'get',
230
            'url'       :  action,
231
        }).done(function(response) {
232
            if(response['success']) {
233
                var anchor = window.document.createElement("a");
234
                anchor.href = 'data:application/octet-stream;charset=utf-8;base64,' + response['data']['content'] ;
235
                anchor.download = response['data']['basename'];
236
                document.body.appendChild(anchor);
237
                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
238
                document.body.removeChild(anchor);
239
            } else {
240
                $.fn.showError(response['data']);
241
            }
242
        }).fail(function( jqXHR, textStatus, errorThrown) {
243
            $.fn.showError(textStatus);
244
        }).always(function() {
245
            NProgress.done();
246
        });
247
 
248
 
249
 
250
    });
251
 
252
 
15387 efrain 253
 
254
});
255
JS;
256
$this->inlineScript()->captureEnd();
257
?>
258
 
16842 efrain 259
<div class="container">
260
	<div class="card" id="">
261
 
262
	 	<div class="card-body">
263
	 		<h6 class="card-title">LABEL_REPORTS_USERS_BLOCKED</h6>
264
	 		<div class="row">
265
	 	         <div class="col-12 mt-3">
16845 efrain 266
	 	          	<table id="gridTable" class="table   table-bordered">
15570 anderson 267
                            <thead>
268
                                <tr>
269
                                    <th style="width: 25%">LABEL_FIRST_NAME</th>
270
                                    <th style="width: 25%">LABEL_LAST_NAME</th>
271
                                    <th style="width: 30%">LABEL_EMAIL</th>
272
                                    <th style="width: 20%">LABEL_REPORTS_LAST_ACTIVITY</th>
15387 efrain 273
                                </tr>
15570 anderson 274
                            </thead>
275
                            <tbody>
276
                            </tbody>
277
                        </table>
16842 efrain 278
 
279
	 	         </div>
280
	 	     </div>
281
	 	</div>
282
	 	<div class="card-footer text-right">
16992 efrain 283
	 		<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-sync"></i> LABEL_REFRESH </button>
16842 efrain 284
      		<?php if ($allowDownload) :  ?>
16932 efrain 285
			<button type="button" class="btn btn-info btn-download" style="display: none"><i class="fa fa-download"></i> LABEL_DOWNLOAD </button>
16842 efrain 286
    		<?php endif; ?>
287
	 	</div>
288
	</div>
289
</div>
15387 efrain 290
 
291
 
292
 
15570 anderson 293