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