15127 |
stevensc |
1 |
<?php
|
|
|
2 |
|
1 |
www |
3 |
use LeadersLinked\Model\CompanyService;
|
|
|
4 |
use LeadersLinked\Model\Company;
|
|
|
5 |
|
|
|
6 |
$acl = $this->viewModel()->getRoot()->getVariable('acl');
|
|
|
7 |
$currentUser = $this->currentUserHelper();
|
|
|
8 |
|
|
|
9 |
$roleName = $currentUser->getUserTypeId();
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
$routeDatatable = $this->url('companies');
|
|
|
14 |
$routeDashboard = $this->url('dashboard');
|
|
|
15 |
|
|
|
16 |
$allowEdit = $acl->isAllowed($roleName, 'companies/edit') ? 1 : 0;
|
|
|
17 |
$allowServices = $acl->isAllowed($roleName, 'companies/services') ? 1 : 0;
|
|
|
18 |
$allowRoles = $acl->isAllowed($roleName, 'companies/roles') ? 1 : 0;
|
|
|
19 |
|
|
|
20 |
|
16822 |
efrain |
21 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
|
|
|
22 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
|
1 |
www |
23 |
|
16822 |
efrain |
24 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/ckeditor/ckeditor.js'));
|
1 |
www |
25 |
|
|
|
26 |
|
16822 |
efrain |
27 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/jquery.validate.js'));
|
|
|
28 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/additional-methods.js'));
|
|
|
29 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/localization/messages_es.js'));
|
1 |
www |
30 |
|
16822 |
efrain |
31 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));
|
|
|
32 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.css'));
|
1 |
www |
33 |
|
16822 |
efrain |
34 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
|
|
|
35 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));
|
|
|
36 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/dataTables.responsive.min.js'));
|
|
|
37 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.min.js'));
|
1 |
www |
38 |
|
|
|
39 |
|
|
|
40 |
|
16822 |
efrain |
41 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
|
|
|
42 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
|
1 |
www |
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
16822 |
efrain |
48 |
//$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css'));
|
1 |
www |
49 |
|
16822 |
efrain |
50 |
//$this->inlineScript()->appendFile($this->basePath('assets/vendors/moment/moment-with-locales.js'));
|
|
|
51 |
//$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js'));
|
15620 |
stevensc |
52 |
|
16822 |
efrain |
53 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/moment/moment-with-locales.js'));
|
15620 |
stevensc |
54 |
|
16822 |
efrain |
55 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-datepicker/js/bootstrap-datepicker.js'));
|
|
|
56 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-datepicker/js/bootstrap-datepicker.es.js'));
|
1 |
www |
57 |
|
16822 |
efrain |
58 |
|
|
|
59 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-datepicker/css/bootstrap-datepicker.css'));
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
|
1 |
www |
63 |
$status_active = CompanyService::ACTIVE;
|
|
|
64 |
$status_inactive = CompanyService::INACTIVE;
|
|
|
65 |
$status_cancelled = CompanyService::CANCELLED;
|
|
|
66 |
$status_suspended = CompanyService::SUSPENDED;
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
$this->inlineScript()->captureStart();
|
|
|
70 |
echo <<<JS
|
|
|
71 |
jQuery( document ).ready(function( $ ) {
|
|
|
72 |
|
|
|
73 |
$.validator.setDefaults({
|
|
|
74 |
debug: true,
|
|
|
75 |
highlight: function(element) {
|
|
|
76 |
$(element).addClass('is-invalid');
|
|
|
77 |
},
|
|
|
78 |
unhighlight: function(element) {
|
|
|
79 |
$(element).removeClass('is-invalid');
|
|
|
80 |
},
|
|
|
81 |
errorElement: 'span',
|
|
|
82 |
errorClass: 'error invalid-feedback',
|
|
|
83 |
errorPlacement: function(error, element) {
|
16822 |
efrain |
84 |
if(element.parent('.toggle').length) {
|
1 |
www |
85 |
error.insertAfter(element.parent().parent());
|
|
|
86 |
} else {
|
|
|
87 |
error.insertAfter(element.parent());
|
|
|
88 |
}
|
|
|
89 |
}
|
|
|
90 |
});
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
$.fn.showFormErrorValidator = function(fieldname, errors) {
|
|
|
94 |
var field = $(fieldname);
|
|
|
95 |
if(field) {
|
|
|
96 |
$(field).addClass('is-invalid');
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');
|
16822 |
efrain |
100 |
if(element.parent('.toggle').length) {
|
|
|
101 |
error.insertAfter(element.parent().parent());
|
1 |
www |
102 |
} else {
|
16822 |
efrain |
103 |
error.insertAfter(element.parent());
|
1 |
www |
104 |
}
|
16822 |
efrain |
105 |
|
1 |
www |
106 |
}
|
|
|
107 |
};
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
var allowEdit = $allowEdit;
|
|
|
111 |
var allowServices = $allowServices;
|
|
|
112 |
var allowRoles = $allowRoles;
|
|
|
113 |
|
|
|
114 |
var gridTable = $('#gridTable').dataTable( {
|
|
|
115 |
'processing': true,
|
|
|
116 |
'serverSide': true,
|
|
|
117 |
'searching': true,
|
|
|
118 |
'order': [[ 0, 'asc' ]],
|
|
|
119 |
'ordering': true,
|
|
|
120 |
'ordenable' : true,
|
|
|
121 |
'responsive': true,
|
|
|
122 |
'select' : false,
|
|
|
123 |
'paging': true,
|
|
|
124 |
'pagingType': 'simple_numbers',
|
|
|
125 |
'ajax': {
|
|
|
126 |
'url' : '$routeDatatable',
|
|
|
127 |
'type' : 'get',
|
|
|
128 |
'beforeSend': function (request) {
|
|
|
129 |
NProgress.start();
|
|
|
130 |
},
|
|
|
131 |
'data' : function(data) {
|
|
|
132 |
data.status = $('#form-filter #status').val();
|
15337 |
efrain |
133 |
data.network_id = $('#form-filter #network_id').val();
|
1 |
www |
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();
|
16822 |
efrain |
181 |
|
1 |
www |
182 |
},
|
|
|
183 |
'aoColumns': [
|
|
|
184 |
{ 'mDataProp': 'name' },
|
|
|
185 |
{ 'mDataProp': 'details' },
|
|
|
186 |
{ 'mDataProp': 'security' },
|
|
|
187 |
{ 'mDataProp': 'actions' },
|
|
|
188 |
],
|
|
|
189 |
'columnDefs': [
|
|
|
190 |
{
|
|
|
191 |
'targets': 0,
|
|
|
192 |
'className' : 'text-vertical-middle',
|
|
|
193 |
'orderable': false,
|
|
|
194 |
'render' : function ( data, type, row ) {
|
15337 |
efrain |
195 |
var s = row['name'] + '<br>' + row['network'];
|
|
|
196 |
|
|
|
197 |
|
1 |
www |
198 |
if(row['link_profile'] ) {
|
16822 |
efrain |
199 |
s = s + '<br><button class="btn btn-light btn-profile" data-href="' + row['link_profile']+ '" data-toggle="tooltip" title="LABEL_PROFILE"><i class="fa fa-external-link"></i></button> <br>';
|
1 |
www |
200 |
}
|
|
|
201 |
return s;
|
|
|
202 |
}
|
|
|
203 |
},
|
|
|
204 |
|
|
|
205 |
{
|
|
|
206 |
'targets': -3,
|
|
|
207 |
'orderable': false,
|
|
|
208 |
'render' : function ( data, type, row ) {
|
|
|
209 |
var s = 'LABEL_STATUS : ' + data['status'] + '<br>';
|
|
|
210 |
s = s + 'LABEL_INTERNAL : ' + data['internal'] + '<br>';
|
|
|
211 |
if(allowServices) {
|
16822 |
efrain |
212 |
s = s + 'LABEL_SERVICES: <button class="btn btn-light btn-services" data-href="' + row['actions']['link_services']+ '" data-toggle="tooltip" title="LABEL_SERVICES"><i class="fa fa-external-link"></i></button> <br>';
|
1 |
www |
213 |
} else {
|
|
|
214 |
s = s + 'LABEL_SERVICES: <br>';
|
|
|
215 |
}
|
|
|
216 |
|
|
|
217 |
if(data['services']) {
|
|
|
218 |
|
|
|
219 |
s = s + '<ul>';
|
|
|
220 |
$.each(data['services'], function(index, service) {
|
|
|
221 |
s = s + '<li>' + service + '</li>';
|
|
|
222 |
});
|
|
|
223 |
s = s + '</ul>';
|
|
|
224 |
}
|
|
|
225 |
|
|
|
226 |
if(allowRoles) {
|
16822 |
efrain |
227 |
s = s + 'LABEL_ROLES: <button class="btn btn-light btn-roles" data-href="' + row['actions']['link_roles']+ '" data-toggle="tooltip" title="LABEL_ROLES"><i class="fa fa-external-link"></i></button> <br>';
|
1 |
www |
228 |
} else {
|
|
|
229 |
s = s + 'LABEL_ROLES: <br>';
|
|
|
230 |
}
|
|
|
231 |
|
|
|
232 |
|
|
|
233 |
if(data['roles']) {
|
|
|
234 |
|
|
|
235 |
s = s + '<ul>';
|
|
|
236 |
$.each(data['roles'], function(index, role) {
|
|
|
237 |
s = s + '<li>' + role + '</li>';
|
|
|
238 |
});
|
|
|
239 |
s = s + '</ul>';
|
|
|
240 |
} else {
|
|
|
241 |
s = s + 'LABEL_ROLES: <br>';
|
|
|
242 |
}
|
|
|
243 |
|
|
|
244 |
return s;
|
|
|
245 |
}
|
|
|
246 |
},
|
|
|
247 |
{
|
|
|
248 |
'targets': -2,
|
|
|
249 |
'orderable': false,
|
|
|
250 |
'render' : function ( data, type, row ) {
|
|
|
251 |
var s = 'LABEL_CREATED_BY<br>';
|
|
|
252 |
s = s + '<ul>';
|
|
|
253 |
s = s + '<li> LABEL_FIRST_NAME : ' + data['first_name'] + ' </li>';
|
|
|
254 |
s = s + '<li>LABEL_LAST_NAME : ' + data['last_name'] + ' </li>';
|
|
|
255 |
s = s + '<li>LABEL_EMAIL : ' + data['email'] + ' </li>';
|
|
|
256 |
s = s + '</ul>';
|
|
|
257 |
|
|
|
258 |
|
|
|
259 |
return s;
|
|
|
260 |
}
|
|
|
261 |
},
|
|
|
262 |
{
|
|
|
263 |
'targets': -1,
|
|
|
264 |
'orderable': false,
|
|
|
265 |
'render' : function ( data, type, row ) {
|
|
|
266 |
s = '';
|
|
|
267 |
if(allowEdit) {
|
|
|
268 |
s = s + '<button class="btn btn-sm btn-primary btn-edit" data-href="' + data['link_edit']+ '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pencil"></i> LABEL_EDIT </button> ';
|
|
|
269 |
}
|
|
|
270 |
return s;
|
|
|
271 |
}
|
|
|
272 |
}
|
|
|
273 |
],
|
|
|
274 |
});
|
|
|
275 |
|
|
|
276 |
|
|
|
277 |
|
|
|
278 |
|
|
|
279 |
$('body').on('click', 'button.btn-refresh', function(e) {
|
|
|
280 |
e.preventDefault();
|
|
|
281 |
gridTable.api().ajax.reload(null, false);
|
|
|
282 |
});
|
|
|
283 |
|
|
|
284 |
|
|
|
285 |
$('body').on('click', 'button.btn-profile', function(e) {
|
|
|
286 |
e.preventDefault();
|
|
|
287 |
|
|
|
288 |
var href = $(this).data('href');
|
|
|
289 |
window.open(href, '_blank');
|
|
|
290 |
|
|
|
291 |
});
|
|
|
292 |
|
|
|
293 |
|
|
|
294 |
|
|
|
295 |
$('body').on('click', 'button.btn-services', function(e) {
|
|
|
296 |
e.preventDefault();
|
|
|
297 |
|
|
|
298 |
var href = $(this).data('href');
|
|
|
299 |
$('#form-services').attr('action', href);
|
|
|
300 |
|
|
|
301 |
NProgress.start();
|
|
|
302 |
$.ajax({
|
|
|
303 |
'dataType' : 'json',
|
|
|
304 |
'accept' : 'application/json',
|
|
|
305 |
'method' : 'get',
|
|
|
306 |
'url' : href,
|
|
|
307 |
}).done(function(response) {
|
|
|
308 |
if(response['success']) {
|
|
|
309 |
|
|
|
310 |
$('#table-services tbody').empty();
|
|
|
311 |
|
|
|
312 |
$.each(response['data'], function(index, service) {
|
|
|
313 |
|
|
|
314 |
|
|
|
315 |
var s = '<tr>';
|
|
|
316 |
s = s + '<td>' + service['name'] + '</td>';
|
|
|
317 |
s = s + '<td><select id="status' + service['id'] + '" name="status' + service['id'] + '" class="form-control">';
|
|
|
318 |
selected = service['status'] == '$status_inactive' ? 'selected' : '';
|
|
|
319 |
s = s + '<option value="$status_inactive" ' + selected + '>LABEL_INACTIVE</option>';
|
|
|
320 |
|
|
|
321 |
selected = service['status'] == '$status_active' ? 'selected' : '';
|
|
|
322 |
s = s + '<option value="$status_active" ' + selected + '>LABEL_ACTIVE</option>';
|
|
|
323 |
|
|
|
324 |
selected = service['status'] == '$status_cancelled' ? 'selected' : '';
|
|
|
325 |
s = s + '<option value="$status_cancelled" ' + selected + '>LABEL_CANCELLED</option>';
|
|
|
326 |
|
|
|
327 |
selected = service['status'] == '$status_suspended' ? 'selected' : '';
|
|
|
328 |
s = s + '<option value="$status_suspended" ' + selected + '>LABEL_SUSPENDED</option>';
|
|
|
329 |
s = s + '</select>';
|
|
|
330 |
s = s + '</td>';
|
15136 |
stevensc |
331 |
s = s + '<td><input type="text" id="paid_from' + service['id'] + '" name="paid_from' + service['id'] + '" class="form-control input-paid-from" value="' + service['paid_from']+ '"></td>';
|
1 |
www |
332 |
s = s + '<td><input type="text" id="paid_to' + service['id'] + '" name="paid_to' + service['id'] + '" class="form-control input-paid-to" value="' + service['paid_to']+ '"></td>';
|
|
|
333 |
s = s + '</tr>';
|
|
|
334 |
|
|
|
335 |
$('#table-services tbody').append(s);
|
|
|
336 |
|
|
|
337 |
});
|
|
|
338 |
|
15137 |
stevensc |
339 |
$('input.input-paid-from').datepicker({
|
1 |
www |
340 |
'language' : 'es',
|
|
|
341 |
'format' : 'dd/mm/yyyy',
|
|
|
342 |
});
|
|
|
343 |
|
15137 |
stevensc |
344 |
$('input.input-paid-to').datepicker({
|
1 |
www |
345 |
'language' : 'es',
|
|
|
346 |
'format' : 'dd/mm/yyyy',
|
|
|
347 |
});
|
|
|
348 |
|
|
|
349 |
|
|
|
350 |
$('#modalServices').modal('show');
|
|
|
351 |
|
|
|
352 |
} else {
|
|
|
353 |
$.fn.showError(response['data']);
|
|
|
354 |
}
|
|
|
355 |
}).fail(function( jqXHR, textStatus, errorThrown) {
|
|
|
356 |
$.fn.showError(textStatus);
|
|
|
357 |
}).always(function() {
|
|
|
358 |
NProgress.done();
|
|
|
359 |
});
|
|
|
360 |
|
|
|
361 |
});
|
16822 |
efrain |
362 |
|
|
|
363 |
$('body').on('click', 'button.btn-delete', function(e) {
|
|
|
364 |
e.preventDefault();
|
|
|
365 |
var action = $(this).data('href');
|
|
|
366 |
|
|
|
367 |
|
|
|
368 |
swal.fire({
|
|
|
369 |
title: 'LABEL_ARE_YOU_SURE',
|
|
|
370 |
icon: 'question',
|
|
|
371 |
cancelButtonText: 'LABEL_NO',
|
|
|
372 |
showCancelButton: true,
|
|
|
373 |
confirmButtonText: 'LABEL_YES'
|
|
|
374 |
}).then((result) => {
|
|
|
375 |
if (result.isConfirmed) {
|
|
|
376 |
|
|
|
377 |
NProgress.start();
|
|
|
378 |
$.ajax({
|
|
|
379 |
'dataType' : 'json',
|
|
|
380 |
'accept' : 'application/json',
|
|
|
381 |
'method' : 'post',
|
|
|
382 |
'url' : action,
|
|
|
383 |
}).done(function(response) {
|
|
|
384 |
if(response['success']) {
|
|
|
385 |
$.fn.showSuccess(response['data']);
|
|
|
386 |
gridTable.api().ajax.reload(null, false);
|
|
|
387 |
} else {
|
|
|
388 |
$.fn.showError(response['data']);
|
|
|
389 |
}
|
|
|
390 |
}).fail(function( jqXHR, textStatus, errorThrown) {
|
|
|
391 |
$.fn.showError(textStatus);
|
|
|
392 |
}).always(function() {
|
|
|
393 |
NProgress.done();
|
|
|
394 |
});
|
|
|
395 |
}
|
|
|
396 |
});
|
|
|
397 |
|
|
|
398 |
});
|
1 |
www |
399 |
|
|
|
400 |
$('#form-services').submit(function (e) {
|
|
|
401 |
e.preventDefault();
|
|
|
402 |
NProgress.start();
|
|
|
403 |
$.ajax({
|
|
|
404 |
'dataType' : 'json',
|
|
|
405 |
'accept' : 'application/json',
|
|
|
406 |
'method' : 'post',
|
|
|
407 |
'url' : $('#form-services').attr('action'),
|
|
|
408 |
'data' : $('#form-services').serialize(),
|
|
|
409 |
}).done(function(response) {
|
|
|
410 |
if(response['success']) {
|
|
|
411 |
|
|
|
412 |
$.fn.showSuccess(response['data']);
|
|
|
413 |
$('#modalServices').modal('hide');
|
|
|
414 |
gridTable.api().ajax.reload(null, false);
|
|
|
415 |
|
|
|
416 |
} else {
|
|
|
417 |
$.fn.showError(response['data']);
|
|
|
418 |
}
|
|
|
419 |
}).fail(function( jqXHR, textStatus, errorThrown) {
|
|
|
420 |
$.fn.showError(textStatus);
|
|
|
421 |
}).always(function() {
|
|
|
422 |
NProgress.done();
|
|
|
423 |
});
|
|
|
424 |
return false;
|
|
|
425 |
|
|
|
426 |
});
|
|
|
427 |
|
|
|
428 |
$('body').on('click', 'button.btn-roles', function(e) {
|
|
|
429 |
e.preventDefault();
|
|
|
430 |
|
|
|
431 |
var href = $(this).data('href');
|
|
|
432 |
$('#form-roles').attr('action', href);
|
|
|
433 |
|
|
|
434 |
NProgress.start();
|
|
|
435 |
$.ajax({
|
|
|
436 |
'dataType' : 'json',
|
|
|
437 |
'accept' : 'application/json',
|
|
|
438 |
'method' : 'get',
|
|
|
439 |
'url' : href,
|
|
|
440 |
}).done(function(response) {
|
|
|
441 |
if(response['success']) {
|
|
|
442 |
|
|
|
443 |
$('#table-roles tbody').empty();
|
|
|
444 |
|
|
|
445 |
$.each(response['data'], function(index, role) {
|
|
|
446 |
|
|
|
447 |
var checked = role['checked'] ? ' checked="checked" ' : '';
|
|
|
448 |
var s = '<tr>';
|
|
|
449 |
s = s + '<td>' + role['name'] + '</td>';
|
|
|
450 |
|
16822 |
efrain |
451 |
s = s + '<td><div class="form-check mb-3">' +
|
|
|
452 |
'<input type="checkbox" class="form-check-input" id="checked' + role['id'] + '" name="checked' + role['id'] + '" ' + checked + '>' +
|
|
|
453 |
'<label class="form-check-label" for="exampleCheck1"> </label>'+
|
|
|
454 |
'</div></td>';
|
1 |
www |
455 |
s = s + '</tr>';
|
|
|
456 |
|
|
|
457 |
$('#table-roles tbody').append(s);
|
|
|
458 |
|
|
|
459 |
});
|
|
|
460 |
|
|
|
461 |
|
|
|
462 |
|
|
|
463 |
$('#modalRoles').modal('show');
|
|
|
464 |
|
|
|
465 |
} else {
|
|
|
466 |
$.fn.showError(response['data']);
|
|
|
467 |
}
|
|
|
468 |
}).fail(function( jqXHR, textStatus, errorThrown) {
|
|
|
469 |
$.fn.showError(textStatus);
|
|
|
470 |
}).always(function() {
|
|
|
471 |
NProgress.done();
|
|
|
472 |
});
|
|
|
473 |
|
|
|
474 |
});
|
|
|
475 |
|
|
|
476 |
$('#form-roles').submit(function (e) {
|
|
|
477 |
e.preventDefault();
|
|
|
478 |
NProgress.start();
|
|
|
479 |
$.ajax({
|
|
|
480 |
'dataType' : 'json',
|
|
|
481 |
'accept' : 'application/json',
|
|
|
482 |
'method' : 'post',
|
|
|
483 |
'url' : $('#form-roles').attr('action'),
|
|
|
484 |
'data' : $('#form-roles').serialize(),
|
|
|
485 |
}).done(function(response) {
|
|
|
486 |
if(response['success']) {
|
|
|
487 |
|
|
|
488 |
$.fn.showSuccess(response['data']);
|
|
|
489 |
$('#modalRoles').modal('hide');
|
|
|
490 |
gridTable.api().ajax.reload(null, false);
|
|
|
491 |
|
|
|
492 |
} else {
|
|
|
493 |
$.fn.showError(response['data']);
|
|
|
494 |
}
|
|
|
495 |
}).fail(function( jqXHR, textStatus, errorThrown) {
|
|
|
496 |
$.fn.showError(textStatus);
|
|
|
497 |
}).always(function() {
|
|
|
498 |
NProgress.done();
|
|
|
499 |
});
|
|
|
500 |
return false;
|
|
|
501 |
|
|
|
502 |
});
|
|
|
503 |
|
|
|
504 |
$('body').on('click', 'button.btn-edit', function(e) {
|
|
|
505 |
e.preventDefault();
|
|
|
506 |
|
|
|
507 |
var href = $(this).data('href');
|
|
|
508 |
$('#form-edit').attr('action', href);
|
|
|
509 |
|
|
|
510 |
NProgress.start();
|
|
|
511 |
$.ajax({
|
|
|
512 |
'dataType' : 'json',
|
|
|
513 |
'accept' : 'application/json',
|
|
|
514 |
'method' : 'get',
|
|
|
515 |
'url' : href,
|
|
|
516 |
}).done(function(response) {
|
|
|
517 |
if(response['success']) {
|
|
|
518 |
|
|
|
519 |
$('#form-edit #status').val(response['data']['status']);
|
|
|
520 |
$('#form-edit #user_uuid').empty();
|
|
|
521 |
|
|
|
522 |
$.each(response['data']['users'], function(index, user) {
|
|
|
523 |
|
|
|
524 |
|
|
|
525 |
var s = '<option value="' + user['uuid'] + '">' + user['name'] + '</option>';
|
|
|
526 |
$('#form-edit #user_uuid').append(s);
|
|
|
527 |
|
|
|
528 |
});
|
|
|
529 |
|
|
|
530 |
$('#form-edit #user_uuid').val(response['data']['creator']);
|
|
|
531 |
|
|
|
532 |
$('#modalEdit').modal('show');
|
|
|
533 |
|
|
|
534 |
} else {
|
|
|
535 |
$.fn.showError(response['data']);
|
|
|
536 |
}
|
|
|
537 |
}).fail(function( jqXHR, textStatus, errorThrown) {
|
|
|
538 |
$.fn.showError(textStatus);
|
|
|
539 |
}).always(function() {
|
|
|
540 |
NProgress.done();
|
|
|
541 |
});
|
|
|
542 |
|
|
|
543 |
});
|
|
|
544 |
|
|
|
545 |
$('#form-edit').submit(function (e) {
|
|
|
546 |
e.preventDefault();
|
|
|
547 |
NProgress.start();
|
|
|
548 |
$.ajax({
|
|
|
549 |
'dataType' : 'json',
|
|
|
550 |
'accept' : 'application/json',
|
|
|
551 |
'method' : 'post',
|
|
|
552 |
'url' : $('#form-edit').attr('action'),
|
|
|
553 |
'data' : $('#form-edit').serialize(),
|
|
|
554 |
}).done(function(response) {
|
|
|
555 |
if(response['success']) {
|
|
|
556 |
|
|
|
557 |
$.fn.showSuccess(response['data']);
|
|
|
558 |
$('#modalEdit').modal('hide');
|
|
|
559 |
gridTable.api().ajax.reload(null, false);
|
|
|
560 |
|
|
|
561 |
} else {
|
|
|
562 |
$.fn.showError(response['data']);
|
|
|
563 |
}
|
|
|
564 |
}).fail(function( jqXHR, textStatus, errorThrown) {
|
|
|
565 |
$.fn.showError(textStatus);
|
|
|
566 |
}).always(function() {
|
|
|
567 |
NProgress.done();
|
|
|
568 |
});
|
|
|
569 |
return false;
|
|
|
570 |
|
|
|
571 |
});
|
|
|
572 |
|
|
|
573 |
|
|
|
574 |
$('body').on('click', 'button.btn-cancel', function(e) {
|
|
|
575 |
e.preventDefault();
|
|
|
576 |
$('#modalServices').modal('hide');
|
|
|
577 |
$('#modalRoles').modal('hide');
|
|
|
578 |
$('#modalEdit').modal('hide');
|
|
|
579 |
|
|
|
580 |
|
|
|
581 |
});
|
|
|
582 |
|
15337 |
efrain |
583 |
$('#form-filter #status, #form-filter #network_id').change(function(e) {
|
1 |
www |
584 |
e.preventDefault();
|
|
|
585 |
|
|
|
586 |
gridTable.api().ajax.reload(null, false);
|
|
|
587 |
});
|
|
|
588 |
|
|
|
589 |
|
|
|
590 |
|
|
|
591 |
|
|
|
592 |
});
|
|
|
593 |
JS;
|
|
|
594 |
$this->inlineScript()->captureEnd();
|
|
|
595 |
?>
|
|
|
596 |
|
16822 |
efrain |
597 |
<div class="container">
|
|
|
598 |
<div class="card">
|
|
|
599 |
|
|
|
600 |
<div class="card-body">
|
|
|
601 |
<h6 class="card-title">LABEL_COMPANIES</h6>
|
|
|
602 |
<div class="row">
|
|
|
603 |
<div class="col-12 mb-3 mt-3">
|
|
|
604 |
<form name="form-filter" id="form-filter">
|
|
|
605 |
<table class="table">
|
15127 |
stevensc |
606 |
<thead>
|
|
|
607 |
<tr>
|
16822 |
efrain |
608 |
<th>LABEL_STATUS</th>
|
|
|
609 |
<th>LABEL_PRIVATE_NETWORKS</th>
|
1 |
www |
610 |
</tr>
|
15127 |
stevensc |
611 |
</thead>
|
|
|
612 |
<tbody>
|
16822 |
efrain |
613 |
<tr>
|
|
|
614 |
<td>
|
|
|
615 |
<select id="status" name="status" class="form-control">
|
|
|
616 |
<option value="">LABEL_ALL</option>
|
|
|
617 |
<option value="<?php echo Company::STATUS_PENDING ?>">LABEL_PENDING</option>
|
|
|
618 |
<option value="<?php echo Company::STATUS_ACTIVE ?>">LABEL_ACTIVE</option>
|
|
|
619 |
<option value="<?php echo Company::STATUS_INACTIVE ?>">LABEL_INACTIVE</option>
|
|
|
620 |
<option value="<?php echo Company::STATUS_DELETED ?>">LABEL_DELETED</option>
|
|
|
621 |
<option value="<?php echo Company::STATUS_REJECTED ?>">LABEL_REJECTED</option>
|
|
|
622 |
</select>
|
|
|
623 |
</td>
|
|
|
624 |
<td>
|
|
|
625 |
<select id="network_id" name="network_id" class="form-control">
|
|
|
626 |
<option value="">LABEL_ALL</option>
|
|
|
627 |
<?php foreach ($networks as $value => $label) : ?>
|
|
|
628 |
<option value="<?php echo $value ?>"><?php echo $label ?></option>
|
|
|
629 |
<?php endforeach; ?>
|
|
|
630 |
</select>
|
|
|
631 |
</td>
|
|
|
632 |
</tr>
|
15127 |
stevensc |
633 |
</tbody>
|
16822 |
efrain |
634 |
|
15127 |
stevensc |
635 |
</table>
|
16822 |
efrain |
636 |
</form>
|
15127 |
stevensc |
637 |
</div>
|
16822 |
efrain |
638 |
</div>
|
|
|
639 |
<div class="row">
|
|
|
640 |
<div class="col-12 mb-3 mt-3">
|
|
|
641 |
|
|
|
642 |
<table id="gridTable" class="table table-bordered">
|
|
|
643 |
<thead>
|
|
|
644 |
<tr>
|
|
|
645 |
<th style="width: 30%">LABEL_NAME</th>
|
|
|
646 |
<th style="width: 30%">LABEL_DETAILS</th>
|
|
|
647 |
<th style="width: 30%">LABEL_SECURITY</th>
|
|
|
648 |
<th style="width: 10%">LABEL_ACTIONS</th>
|
|
|
649 |
</tr>
|
|
|
650 |
</thead>
|
|
|
651 |
<tbody>
|
|
|
652 |
</tbody>
|
|
|
653 |
</table>
|
|
|
654 |
</div>
|
|
|
655 |
</div>
|
1 |
www |
656 |
|
16822 |
efrain |
657 |
</div>
|
|
|
658 |
<div class="card-footer text-right">
|
|
|
659 |
<button type="button" class="btn btn-sm btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
|
|
|
660 |
</div>
|
|
|
661 |
</div>
|
|
|
662 |
</div>
|
|
|
663 |
|
1 |
www |
664 |
<!-- The Modal -->
|
|
|
665 |
<div class="modal" id="modalServices">
|
15127 |
stevensc |
666 |
<div class="modal-dialog modal-xl">
|
|
|
667 |
<div class="modal-content">
|
1 |
www |
668 |
|
|
|
669 |
<!-- Modal Header -->
|
15127 |
stevensc |
670 |
<div class="modal-header">
|
|
|
671 |
<h4 class="modal-title">LABEL_SERVICES</h4>
|
16822 |
efrain |
672 |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
|
15127 |
stevensc |
673 |
</div>
|
1 |
www |
674 |
|
|
|
675 |
<!-- Modal body -->
|
16822 |
efrain |
676 |
<form name="form-services" id="form-services">
|
15127 |
stevensc |
677 |
<div class="modal-body">
|
16822 |
efrain |
678 |
<div class="row">
|
|
|
679 |
<div class="col-12 mb-3 mt-3">
|
|
|
680 |
<table id="table-services" class="table table-bordered">
|
|
|
681 |
<thead>
|
|
|
682 |
<tr>
|
|
|
683 |
<th>LABEL_NAME</th>
|
|
|
684 |
<th>LABEL_STATUS</th>
|
|
|
685 |
<th>LABEL_PAID_FROM</th>
|
|
|
686 |
<th>LABEL_PAID_TO</th>
|
|
|
687 |
</tr>
|
|
|
688 |
</thead>
|
|
|
689 |
<tbody>
|
|
|
690 |
</tbody>
|
|
|
691 |
</table>
|
|
|
692 |
</div>
|
|
|
693 |
</div>
|
|
|
694 |
|
1 |
www |
695 |
|
|
|
696 |
|
|
|
697 |
|
16822 |
efrain |
698 |
|
|
|
699 |
|
15127 |
stevensc |
700 |
</div>
|
16822 |
efrain |
701 |
<div class="modal-footer">
|
|
|
702 |
<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
|
|
|
703 |
<button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
|
|
|
704 |
|
|
|
705 |
</div>
|
|
|
706 |
</form>
|
1 |
www |
707 |
|
15127 |
stevensc |
708 |
</div>
|
|
|
709 |
</div>
|
|
|
710 |
</div>
|
1 |
www |
711 |
|
15127 |
stevensc |
712 |
|
1 |
www |
713 |
<!-- The Modal -->
|
|
|
714 |
<div class="modal" id="modalRoles">
|
15127 |
stevensc |
715 |
<div class="modal-dialog modal-xl">
|
|
|
716 |
<div class="modal-content">
|
1 |
www |
717 |
|
|
|
718 |
<!-- Modal Header -->
|
15127 |
stevensc |
719 |
<div class="modal-header">
|
|
|
720 |
<h4 class="modal-title">LABEL_ROLES</h4>
|
16822 |
efrain |
721 |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
|
15127 |
stevensc |
722 |
</div>
|
1 |
www |
723 |
|
|
|
724 |
<!-- Modal body -->
|
16822 |
efrain |
725 |
<form name="form-roles" id="form-roles">
|
15127 |
stevensc |
726 |
<div class="modal-body">
|
16822 |
efrain |
727 |
<div class="row">
|
|
|
728 |
<div class="col-12 mb-3 mt-3">
|
|
|
729 |
<table id="table-roles" class="table table-bordered">
|
|
|
730 |
<thead>
|
|
|
731 |
<tr>
|
|
|
732 |
<th>LABEL_NAME</th>
|
|
|
733 |
<th>LABEL_ACTIVE</th>
|
|
|
734 |
</tr>
|
|
|
735 |
</thead>
|
|
|
736 |
<tbody>
|
|
|
737 |
</tbody>
|
|
|
738 |
</table>
|
|
|
739 |
</div>
|
|
|
740 |
</div>
|
|
|
741 |
|
1 |
www |
742 |
|
|
|
743 |
|
|
|
744 |
|
16822 |
efrain |
745 |
|
15127 |
stevensc |
746 |
</div>
|
16822 |
efrain |
747 |
<div class="modal-footer">
|
|
|
748 |
<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
|
|
|
749 |
<button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
|
|
|
750 |
</div>
|
|
|
751 |
</form>
|
|
|
752 |
|
15127 |
stevensc |
753 |
|
|
|
754 |
</div>
|
|
|
755 |
</div>
|
1 |
www |
756 |
</div>
|
|
|
757 |
|
|
|
758 |
|
|
|
759 |
<!-- The Modal -->
|
|
|
760 |
<div class="modal" id="modalEdit">
|
15127 |
stevensc |
761 |
<div class="modal-dialog modal-xl">
|
|
|
762 |
<div class="modal-content">
|
1 |
www |
763 |
|
|
|
764 |
<!-- Modal Header -->
|
15127 |
stevensc |
765 |
<div class="modal-header">
|
|
|
766 |
<h4 class="modal-title">LABEL_EDIT</h4>
|
16822 |
efrain |
767 |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
|
15127 |
stevensc |
768 |
</div>
|
1 |
www |
769 |
|
|
|
770 |
<!-- Modal body -->
|
16822 |
efrain |
771 |
<form name="form-edit" id="form-edit">
|
15127 |
stevensc |
772 |
<div class="modal-body">
|
16822 |
efrain |
773 |
|
1 |
www |
774 |
|
16822 |
efrain |
775 |
<div class="row">
|
|
|
776 |
<div class="col-12">
|
15127 |
stevensc |
777 |
<label for="status">LABEL_STATUS</label>
|
|
|
778 |
<select id="status" name="status" class="form-control">
|
|
|
779 |
<option value="<?php echo Company::STATUS_ACTIVE ?>">LABEL_ACTIVE</option>
|
|
|
780 |
<option value="<?php echo Company::STATUS_INACTIVE ?>">LABEL_INACTIVE</option>
|
|
|
781 |
<option value="<?php echo Company::STATUS_DELETED ?>">LABEL_DELETED</option>
|
|
|
782 |
<option value="<?php echo Company::STATUS_PENDING ?>">LABEL_PENDING</option>
|
|
|
783 |
<option value="<?php echo Company::STATUS_REJECTED ?>">LABEL_REJECTED</option>
|
|
|
784 |
</select>
|
16822 |
efrain |
785 |
</div>
|
15127 |
stevensc |
786 |
</div>
|
16822 |
efrain |
787 |
<div class="row">
|
|
|
788 |
<div class="col-12">
|
15127 |
stevensc |
789 |
<label for="user_uuid">LABEL_CREATED_BY</label>
|
16821 |
efrain |
790 |
<select id="user_uuid" name="user_uuid" class="form-control">
|
1 |
www |
791 |
|
15127 |
stevensc |
792 |
</select>
|
16822 |
efrain |
793 |
</div>
|
15127 |
stevensc |
794 |
</div>
|
1 |
www |
795 |
|
15127 |
stevensc |
796 |
|
16822 |
efrain |
797 |
|
|
|
798 |
|
|
|
799 |
</div>
|
|
|
800 |
<div class="card-footer text-right">
|
15127 |
stevensc |
801 |
<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
|
|
|
802 |
<button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
|
|
|
803 |
</div>
|
16822 |
efrain |
804 |
</form>
|
15127 |
stevensc |
805 |
|
|
|
806 |
</div>
|
|
|
807 |
</div>
|
|
|
808 |
</div>
|