Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16842 | Rev 16932 | 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
 
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
 
15613 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
 
15613 anderson 91
                } else {
92
                     $('button.btn-download').hide();
93
                }
15387 efrain 94
 
15613 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
 
15613 anderson 112
 
113
 
114
 
115
 
15574 anderson 116
    var gridTable = $('#gridTable').dataTable( {
117
            'processing': true,
118
            'serverSide': true,
119
            'searching': true,
120
            'order': [[ 0, 'asc' ]],
121
            'ordering':  true,
122
            'ordenable' : true,
123
            'responsive': true,
124
            'select' : false,
125
        	'paging': true,
126
            'pagingType': 'simple_numbers',
127
    		'ajax': {
128
    			'url' : '$routeDatatable',
129
    			'type' : 'get',
130
                'beforeSend': function (request) {
131
                  NProgress.start();
132
                },
133
                'dataFilter': function(response) {
134
                    var response = jQuery.parseJSON( response );
135
 
136
                    var json                = {};
137
                    json.recordsTotal       = 0;
138
                    json.recordsFiltered    = 0;
139
                    json.data               = [];
140
 
141
 
142
                    if(response.success) {
143
                        json.recordsTotal       = response.data.total;
144
                        json.recordsFiltered    = response.data.total;
145
                        json.data               = response.data.items;
146
                    } else {
147
                        $.fn.showError(response.data)
148
                    }
149
 
150
                    return JSON.stringify( json );
151
                }
152
    		},
153
            'language' : {
154
                'sProcessing':     'LABEL_DATATABLE_SPROCESSING',
155
                'sLengthMenu':     'LABEL_DATATABLE_SLENGTHMENU',
156
                'sZeroRecords':    'LABEL_DATATABLE_SZERORECORDS',
157
                'sEmptyTable':     'LABEL_DATATABLE_SEMPTYTABLE',
158
                'sInfo':           'LABEL_DATATABLE_SINFO',
159
                'sInfoEmpty':      'LABEL_DATATABLE_SINFOEMPTY',
160
                'sInfoFiltered':   'LABEL_DATATABLE_SINFOFILTERED',
161
                'sInfoPostFix':    '',
162
                'sSearch':         'LABEL_DATATABLE_SSEARCH',
163
                'sUrl':            '',
164
                'sInfoThousands':  ',',
165
                'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
166
                'oPaginate': {
167
                    'sFirst':    'LABEL_DATATABLE_SFIRST',
168
                    'sLast':     'LABEL_DATATABLE_SLAST',
169
                    'sNext':     'LABEL_DATATABLE_SNEXT',
170
                    'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
171
                },
172
                'oAria': {
173
                    'sSortAscending':  ': LABEL_DATATABLE_SSORTASCENDING',
174
                    'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
175
                },
176
            },
177
            'drawCallback': function( settings ) {
178
                NProgress.done();
16822 efrain 179
 
15574 anderson 180
            },
181
            'aoColumns': [
15615 anderson 182
                { 'mDataProp': 'first_name' },
15618 anderson 183
                { 'mDataProp': 'last_name' },
184
                { 'mDataProp': 'email' },
185
                { 'mDataProp': 'last_activity_on' },
15619 anderson 186
                { 'mDataProp': 'actions' },
16842 efrain 187
 
188
 
15574 anderson 189
    	    ],
190
            'columnDefs': [
191
                {
192
                    'targets': 0,
193
                    'className' : 'text-vertical-middle',
194
                },
195
                {
196
                    'targets': 1,
15606 anderson 197
                    'orderable': false,
15574 anderson 198
                    'className' : 'text-vertical-middle',
15606 anderson 199
 
15574 anderson 200
                },
15606 anderson 201
 
15574 anderson 202
                {
203
                    'targets': -1,
204
                    'orderable': false,
15595 anderson 205
                    'render' : function ( data, type, row ) {
16842 efrain 206
                        s = '&nbsp;';
207
 
15597 anderson 208
                        return s;
15595 anderson 209
                    }
15574 anderson 210
                }
211
              ],
212
        });
213
 
214
 
15387 efrain 215
    $('button.btn-refresh').click(function(e) {
216
        e.preventDefault();
217
        $.fn.loadData();
218
 
219
 
220
    });
221
 
222
 
223
 
16822 efrain 224
 
15387 efrain 225
    $.fn.loadData();
226
    $('button.btn-download').hide();
227
 
228
});
229
JS;
230
$this->inlineScript()->captureEnd();
231
?>
232
 
16842 efrain 233
<div class="container">
234
	<div class="card" id="">
235
 
236
	 	<div class="card-body">
237
	 		<h6 class="card-title">LABEL_REPORTS_USERS_BLOCKED</h6>
238
	 		<div class="row">
239
	 	         <div class="col-12 mt-3">
16845 efrain 240
	 	          	<table id="gridTable" class="table   table-bordered">
15570 anderson 241
                            <thead>
242
                                <tr>
243
                                    <th style="width: 25%">LABEL_FIRST_NAME</th>
244
                                    <th style="width: 25%">LABEL_LAST_NAME</th>
245
                                    <th style="width: 30%">LABEL_EMAIL</th>
246
                                    <th style="width: 20%">LABEL_REPORTS_LAST_ACTIVITY</th>
15619 anderson 247
                                    <th>LABEL_ACTIONS</th>
15387 efrain 248
                                </tr>
15570 anderson 249
                            </thead>
250
                            <tbody>
251
                            </tbody>
252
                        </table>
16842 efrain 253
 
254
	 	         </div>
255
	 	     </div>
256
	 	</div>
257
	 	<div class="card-footer text-right">
258
	 		<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
259
      		<?php if ($allowDownload) :  ?>
260
			<button type="button" class="btn btn-info btn-download"><i class="fa fa-download"></i> LABEL_DOWNLOAD </button>
261
    		<?php endif; ?>
262
	 	</div>
263
	</div>
264
</div>
15387 efrain 265
 
266
 
267
 
15570 anderson 268
 
15387 efrain 269
<script id="itemRowTemplate" type="text/x-jsrender">
270
    <tr>
271
        <td style="width: 25%">
272
            {{>first_name}}
273
        </td>
274
        <td style="width: 25%">
275
             {{>last_name}}
276
        </td>
277
        <td style="width: 30%">
278
            {{>email}}
279
        </td>
280
        <td style="width: 30%">
281
            {{>last_activity_on}}
282
        </td>
283
 
284
 
285
 
286
    </tr>
287
</script>
288
 
289
 
290
<script id="itemEmptyRowTemplate" type="text/x-jsrender">
291
    <tr>
292
        <td colspan="4">
293
            LABEL_NOT_RECORDS_FOUND
294
        </td>
295
    </tr>
15570 anderson 296
</script>