Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16845 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
15457 efrain 1
<?php
2
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser    = $this->currentUserHelper();
4
 
5
$roleName = $currentUser->getUserTypeId();
6
 
7
 
8
//$routeAdd       = $this->url('users/add');
9
$routeDatatable = $this->url('users/request-access');
10
$routeDashboard = $this->url('dashboard');
11
 
12
 
13
$allowApprove   = $acl->isAllowed($roleName, 'users/request-access/approve') ? 1 : 0;
14
$allowReject    = $acl->isAllowed($roleName, 'users/request-access/reject') ? 1 : 0;
15
 
16822 efrain 16
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
17
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
15457 efrain 18
 
16822 efrain 19
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));
20
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.css'));
15457 efrain 21
 
16822 efrain 22
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
23
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));
24
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/dataTables.responsive.min.js'));
25
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.min.js'));
15457 efrain 26
 
27
 
28
 
29
 
30
 
16822 efrain 31
 
15457 efrain 32
$this->inlineScript()->captureStart();
33
echo <<<JS
34
    jQuery( document ).ready(function( $ ) {
35
 
36
 
37
 
38
        var allowApprove = $allowApprove;
39
        var allowReject = $allowReject;
40
 
41
 
42
 
43
 
44
        var gridTable = $('#gridTable').dataTable( {
45
            'processing': true,
46
            'serverSide': true,
47
            'searching': true,
48
            'order': [[ 1, 'asc' ]],
49
            'ordering':  true,
50
            'ordenable' : true,
51
            'responsive': true,
52
            'select' : false,
53
        	'paging': true,
54
            'pagingType': 'simple_numbers',
55
    		'ajax': {
56
    			'url' : '$routeDatatable',
57
    			'type' : 'get',
58
                'beforeSend': function (request) {
59
                  NProgress.start();
60
                },
61
                'dataFilter': function(response) {
62
                    var response = jQuery.parseJSON( response );
63
 
64
                    var json                = {};
65
                    json.recordsTotal       = 0;
66
                    json.recordsFiltered    = 0;
67
                    json.data               = [];
68
 
69
 
70
                    if(response.success) {
71
                        json.recordsTotal       = response.data.total;
72
                        json.recordsFiltered    = response.data.total;
73
                        json.data               = response.data.items;
74
                    } else {
75
                        $.fn.showError(response.data)
76
                    }
77
 
78
                    return JSON.stringify( json );
79
                }
80
    		},
81
            'language' : {
82
                'sProcessing':     'LABEL_DATATABLE_SPROCESSING',
83
                'sLengthMenu':     'LABEL_DATATABLE_SLENGTHMENU',
84
                'sZeroRecords':    'LABEL_DATATABLE_SZERORECORDS',
85
                'sEmptyTable':     'LABEL_DATATABLE_SEMPTYTABLE',
86
                'sInfo':           'LABEL_DATATABLE_SINFO',
87
                'sInfoEmpty':      'LABEL_DATATABLE_SINFOEMPTY',
88
                'sInfoFiltered':   'LABEL_DATATABLE_SINFOFILTERED',
89
                'sInfoPostFix':    '',
90
                'sSearch':         'LABEL_DATATABLE_SSEARCH',
91
                'sUrl':            '',
92
                'sInfoThousands':  ',',
93
                'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
94
                'oPaginate': {
95
                    'sFirst':    'LABEL_DATATABLE_SFIRST',
96
                    'sLast':     'LABEL_DATATABLE_SLAST',
97
                    'sNext':     'LABEL_DATATABLE_SNEXT',
98
                    'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
99
                },
100
                'oAria': {
101
                    'sSortAscending':  ': LABEL_DATATABLE_SSORTASCENDING',
102
                    'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
103
                },
104
            },
105
            'drawCallback': function( settings ) {
106
                NProgress.done();
16822 efrain 107
 
15457 efrain 108
            },
109
            'aoColumns': [
110
                { 'mDataProp': 'first_name' },
111
                { 'mDataProp': 'last_name' },
112
                { 'mDataProp': 'email' },
113
                { 'mDataProp': 'actions' },
114
    	    ],
115
            'columnDefs': [
116
                {
117
                    'targets': 0,
118
                    'className' : 'text-vertical-middle',
119
                },
120
                {
121
                    'targets': 1,
122
                    'className' : 'text-vertical-middle',
123
                },
124
                {
125
                    'targets': 2,
126
                    'className' : 'text-vertical-middle',
127
                },
128
                {
129
                    'targets': -1,
130
                    'orderable': false,
131
                    'render' : function ( data, type, row ) {
132
                        s = '';
133
 
134
                        if(allowApprove && data['link_approve']) {
135
                            s = s + '<button class="btn btn-primary btn-approve" data-href="' + data['link_approve']+ '" data-toggle="tooltip" title="LABEL_APPROVE"><i class="fa fa-check"></i> LABEL_APPROVE </button>&nbsp;';
136
                        }
137
                        if(allowReject && data['link_reject']) {
138
                            s = s + '<button class="btn btn-info btn-reject" data-href="' + data['link_reject']+ '" data-toggle="tooltip" title="LABEL_REJECT"><i class="fa fa-ban"></i> LABEL_REJECT </button>&nbsp;';
139
                        }
140
                        return s;
141
                    }
142
                }
143
 
144
            ],
145
        });
146
 
147
 
148
 
149
 
150
 
151
        $('body').on('click', 'button.btn-refresh', function(e) {
152
            e.preventDefault();
153
            gridTable.api().ajax.reload(null, false);
154
        });
155
 
156
 
16822 efrain 157
 $('body').on('click', 'button.btn-approve', function(e) {
158
        e.preventDefault();
159
        var action = $(this).data('href');
15457 efrain 160
 
161
 
16822 efrain 162
          swal.fire({
163
            title: 'LABEL_ARE_YOU_SURE',
164
            icon: 'question',
165
            cancelButtonText: 'LABEL_NO',
166
            showCancelButton: true,
167
            confirmButtonText: 'LABEL_YES'
168
          }).then((result) => {
169
            if (result.isConfirmed) {
15457 efrain 170
 
16822 efrain 171
                    NProgress.start();
172
                    $.ajax({
173
                        'dataType'  : 'json',
174
                        'accept'    : 'application/json',
175
                        'method'    : 'post',
176
                        'url'       :  action,
177
                    }).done(function(response) {
178
                        if(response['success']) {
179
                            $.fn.showSuccess(response['data']);
180
                            gridTable.api().ajax.reload(null, false);
181
                        } else {
182
                            $.fn.showError(response['data']);
183
                        }
184
                    }).fail(function( jqXHR, textStatus, errorThrown) {
185
                        $.fn.showError(textStatus);
186
                    }).always(function() {
187
                        NProgress.done();
188
                    });
189
            }
190
       });
15457 efrain 191
    });
16822 efrain 192
 
193
 
194
 $('body').on('click', 'button.btn-reject', function(e) {
195
        e.preventDefault();
196
        var action = $(this).data('href');
197
 
198
 
199
          swal.fire({
200
            title: 'LABEL_ARE_YOU_SURE',
201
            icon: 'question',
202
            cancelButtonText: 'LABEL_NO',
203
            showCancelButton: true,
204
            confirmButtonText: 'LABEL_YES'
205
          }).then((result) => {
206
            if (result.isConfirmed) {
207
 
208
                    NProgress.start();
209
                    $.ajax({
210
                        'dataType'  : 'json',
211
                        'accept'    : 'application/json',
212
                        'method'    : 'post',
213
                        'url'       :  action,
214
                    }).done(function(response) {
215
                        if(response['success']) {
216
                            $.fn.showSuccess(response['data']);
217
                            gridTable.api().ajax.reload(null, false);
218
                        } else {
219
                            $.fn.showError(response['data']);
220
                        }
221
                    }).fail(function( jqXHR, textStatus, errorThrown) {
222
                        $.fn.showError(textStatus);
223
                    }).always(function() {
224
                        NProgress.done();
225
                    });
226
            }
227
       });
228
    });
229
 
230
 
231
 
232
    });
15457 efrain 233
JS;
234
$this->inlineScript()->captureEnd();
235
$this->headLink()->appendStylesheet('/css/style.css');
236
?>
237
 
16891 efrain 238
<div class="container">
239
	<div class="card" id="">
240
	 	<div class="card-header">
241
	 		<h6 class="card-title">LABEL_USERS</h6>
242
	 	</div>
243
	 	<div class="card-body">
244
	 		<div class="row">
245
	 	         <div class="col-12 mt-3">
246
 
247
	 	         <table id="gridTable" class="table   table-bordered" style="width: 100%">
15457 efrain 248
                      		<thead>
249
        						<tr>
250
                                	<th>LABEL_FIRST_NAME</th>
251
                                	<th>LABEL_LAST_NAME</th>
252
                                	<th>LABEL_EMAIL</th>
253
                                  	<th>LABEL_ACTIONS</th>
254
                                </tr>
255
                       		</thead>
256
                         	<tbody>
257
                         	</tbody>
258
                    	</table>
16891 efrain 259
 
260
 
261
	 	         </div>
262
	 	     </div>
263
	 	</div>
264
	 	<div class="card-footer text-right">
265
	 	     <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH  </button>
266
	 	</div>
267
	</div>
268
</div>
269
 
270
 
15457 efrain 271
 
272
 
273
 
274
 
275
 
276