Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
15333 stevensc 1
<?php
2
 
1 www 3
use LeadersLinked\Model\CompanyUser;
4
 
5
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
6
$currentUser    = $this->currentUserHelper();
7
 
8
$roleName = $currentUser->getUserTypeId();
9
 
10
 
11
//$routeAdd       = $this->url('users/add');
12
$routeDatatable = $this->url('users');
13
$routeInvite    = $this->url('users/invite');
14
$routeUpload    = $this->url('users/upload');
15
 
16
 
17
 
18
$allowInvite            = $acl->isAllowed($roleName, 'users/invite') ? 1 : 0;
19
$allowAccept            = $acl->isAllowed($roleName, 'users/accept') ? 1 : 0;
20
$allowCancel            = $acl->isAllowed($roleName, 'users/cancel') ? 1 : 0;
21
$allowReject            = $acl->isAllowed($roleName, 'users/reject') ? 1 : 0;
22
$allowEdit              = $acl->isAllowed($roleName, 'users/edit') ? 1 : 0;
23
$allowUpload            = $acl->isAllowed($roleName, 'users/upload') ? 1 : 0;
24
$allowChangePassword    = $acl->isAllowed($roleName, 'users/change-password') ? 1 : 0;
25
$allowUnblock           = $acl->isAllowed($roleName, 'users/unblock') ? 1 : 0;
26
 
27
 
16822 efrain 28
$this->inlineScript()->appendFile($this->basePath('assets/vendors/popper/umd/popper.js'));
29
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
30
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
1 www 31
 
16822 efrain 32
$this->inlineScript()->appendFile($this->basePath('assets/vendors/ckeditor/ckeditor.js'));
1 www 33
 
34
 
35
 
16912 efrain 36
 
16929 efrain 37
 
38
 
39
 
16822 efrain 40
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));
16912 efrain 41
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.css'));
1 www 42
 
16822 efrain 43
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
44
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));
16912 efrain 45
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/dataTables.responsive.min.js'));
46
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.min.js'));
1 www 47
 
48
 
16822 efrain 49
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
50
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
1 www 51
 
52
 
16926 efrain 53
$this->inlineScript()->appendFile($this->basePath('assets/vendors/typeahead.js/typeahead.bundle.min.js'));
1 www 54
 
55
 
16822 efrain 56
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-autocomplete/bootstrap-autocomplete.js'));
1 www 57
 
58
 
16822 efrain 59
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-fileinput/css/fileinput.min.css'));
60
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-fileinput/themes/explorer-fa/theme.css'));
61
 
16843 efrain 62
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/plugins/piexif.js'));
63
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/plugins/sortable.js'));
16822 efrain 64
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/fileinput.js'));
65
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/locales/es.js'));
66
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/themes/fa/theme.js'));
67
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/themes/explorer-fa/theme.js'));
68
 
1 www 69
$this->headStyle()->captureStart();
70
 
71
$this->inlineScript()->captureStart();
72
echo <<<JS
73
    jQuery( document ).ready(function( $ ) {
74
        $.validator.addMethod('passwordStrengthCheck', function(value) {
75
            return /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$^x%x*-]).{6,16}$/.test(value)
76
        }, 'ERROR_PASSWORD_STRENGTH');
77
 
78
        $.validator.setDefaults({
79
            debug: true,
80
            highlight: function(element) {
81
                $(element).closest('.sn-field').addClass('sn-field-has-error');
82
            },
83
            unhighlight: function(element) {
84
                $(element).closest('.sn-field').removeClass('sn-field-has-error');
85
            },
86
            errorElement: 'div',
87
            errorClass: 'sn-field-invalid-feedback',
88
            errorPlacement: function(error, element) {
89
 
90
                if(element.parent('.sn-field').length) {
91
                    error.insertAfter(element.parent());
92
                } else if (element.parent('.fgt-sec').length) {
93
                    error.insertAfter(element.parent());
94
                } else {
95
                    error.insertAfter(element);
96
                }
97
            }
98
        });
99
 
100
 
101
        var allowInvite = $allowInvite;
102
        var allowAccept = $allowAccept;
103
        var allowCancel = $allowCancel;
104
        var allowReject = $allowReject;
105
        var allowEdit  = $allowEdit;
106
        var allowUpload = $allowUpload;
107
        var allowChangePassword = $allowChangePassword;
108
        var allowUnblock = $allowUnblock;
109
 
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
                'data' : function(data) {
125
                    data.status = $('#form-filter #status').val();
126
                } ,
127
                'beforeSend': function (request) {
128
                  NProgress.start();
129
                },
130
                'dataFilter': function(response) {
131
                    var response = jQuery.parseJSON( response );
132
 
133
                    var json                = {};
134
                    json.recordsTotal       = 0;
135
                    json.recordsFiltered    = 0;
136
                    json.data               = [];
137
 
138
 
139
                    if(response.success) {
140
                        json.recordsTotal       = response.data.total;
141
                        json.recordsFiltered    = response.data.total;
142
                        json.data               = response.data.items;
143
                    } else {
144
                        $.fn.showError(response.data)
145
                    }
146
 
147
                    return JSON.stringify( json );
148
                }
149
    		},
150
            'language' : {
151
                'sProcessing':     'LABEL_DATATABLE_SPROCESSING',
152
                'sLengthMenu':     'LABEL_DATATABLE_SLENGTHMENU',
153
                'sZeroRecords':    'LABEL_DATATABLE_SZERORECORDS',
154
                'sEmptyTable':     'LABEL_DATATABLE_SEMPTYTABLE',
155
                'sInfo':           'LABEL_DATATABLE_SINFO',
156
                'sInfoEmpty':      'LABEL_DATATABLE_SINFOEMPTY',
157
                'sInfoFiltered':   'LABEL_DATATABLE_SINFOFILTERED',
158
                'sInfoPostFix':    '',
159
                'sSearch':         'LABEL_DATATABLE_SSEARCH',
160
                'sUrl':            '',
161
                'sInfoThousands':  ',',
162
                'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
163
                'oPaginate': {
164
                    'sFirst':    'LABEL_DATATABLE_SFIRST',
165
                    'sLast':     'LABEL_DATATABLE_SLAST',
166
                    'sNext':     'LABEL_DATATABLE_SNEXT',
167
                    'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
168
                },
169
                'oAria': {
170
                    'sSortAscending':  ': LABEL_DATATABLE_SSORTASCENDING',
171
                    'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
172
                },
173
            },
174
            'drawCallback': function( settings ) {
175
                NProgress.done();
16822 efrain 176
 
1 www 177
            },
178
            'aoColumns': [
179
                { 'mDataProp': 'first_name' },
180
                { 'mDataProp': 'last_name' },
181
                { 'mDataProp': 'email' },
182
                { 'mDataProp': 'details' },
183
                { 'mDataProp': 'actions' },
184
    	    ],
185
            'columnDefs': [
186
                {
187
                    'targets': 0,
188
                    'className' : 'text-vertical-middle',
189
                },
190
                {
191
                    'targets': 1,
192
                    'className' : 'text-vertical-middle',
193
                },
194
                {
195
                    'targets': 2,
196
                    'className' : 'text-vertical-middle',
197
                },
198
                {
199
                    'targets': -2,
200
                    'orderable': false,
201
                    'render' : function ( data, type, row ) {
202
                        var s =  '';
203
                        s = s + 'LABEL_STATUS : <br>' + data['status'] + '<br>';
204
                        s = s + 'LABEL_ACCESS_BACKEND : ' + data['backend'] + '<br>';
205
                        s = s + 'LABEL_CREATOR : ' + data['creator'] + '<br>';
206
 
207
                        s = s + 'LABEL_EDIT : <br>';
208
 
209
                        $.each(data['roles'], function(i, role) {
210
                            s = s + role + '<br>';
211
                        });
212
 
213
                        s = s + 'LABEL_BLOCKED : ' + data['blocked'] + '<br>';
214
                        s = s + 'LABEL_EMAIL_VERIFIED : ' + data['email_verified'] + '<br>';
215
                        s = s + 'LABEL_LOGIN_ATTEMP : ' + data['login_attempt'] + '<br>';
216
                        return s;
217
                    }
218
                },
219
                {
220
                    'targets': -1,
221
                    'orderable': false,
222
                    'render' : function ( data, type, row ) {
223
                        s = '';
15333 stevensc 224
 
225
                        $('#gridTable_wrapper .row:nth-child(2) .col-sm-12').addClass( "table table-responsive" );
1 www 226
 
227
                        if(allowAccept && data['link_accept']) {
16822 efrain 228
                            s = s + '<button class="btn btn-sm btn-accept btn-primary" style="margin-top: 5px" data-href="' + data['link_accept']+ '" data-toggle="tooltip" title="LABEL_ACCEPT"><i class="fa fa-check"></i> LABEL_ACCEPT </button><br>';
1 www 229
                        }
15261 stevensc 230
                        if(allowEdit && data['link_edit']) {
16906 efrain 231
                            s = s + '<button class="btn btn-sm btn-edit btn-primary" style="margin-top: 5px" data-href="' + data['link_edit']+ '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pen"></i> LABEL_EDIT </button><br>';
15261 stevensc 232
                        }
1 www 233
                        if(allowCancel && data['link_cancel']) {
16822 efrain 234
                            s = s + '<button class="btn btn-sm btn-cancel btn-danger" style="margin-top: 5px" data-href="' + data['link_cancel']+ '" data-toggle="tooltip" data-singleton="true" title="LABEL_CANCEL"><i class="fa fa-times"></i> LABEL_CANCEL </button><br>';
1 www 235
                        }
236
                        if(allowReject && data['link_reject']) {
16822 efrain 237
                            s = s + '<button class="btn btn-sm btn-reject btn-danger" style="margin-top: 5px" data-href="' + data['link_reject']+ '" data-toggle="tooltip" title="LABEL_REJECT"><i class="fa fa-times"></i> LABEL_REJECT </button><br>';
1 www 238
                        }
239
 
240
                        if(allowChangePassword && data['link_change_password']) {
16822 efrain 241
                            s = s + '<button class="btn btn-sm btn-primary btn-change-password" style="margin-top: 5px" data-href="' + data['link_change_password']+ '" data-toggle="tooltip" title="LABEL_CHANGE_PASSWORD"><i class="fa fa-key"></i> LABEL_PASSWORD </button><br>';
1 www 242
                        }
243
                        if(allowUnblock && data['link_unblock']) {
16822 efrain 244
                            s = s + '<button class="btn btn-sm btn-info btn-unblock" style="margin-top: 5px" data-href="' + data['link_unblock']+ '" data-toggle="tooltip" title="LABEL_UNBLOCK"><i class="fa fa-unlock"></i> LABEL_UNBLOCK </button><br>';
1 www 245
                        }
246
 
247
 
248
                        return s;
249
                    }
250
                }
251
 
252
            ],
253
        });
254
 
255
 
256
        $('#form-filter #status').change(function(e) {
257
            e.preventDefault();
258
            gridTable.api().ajax.reload(null, false);
259
        });
260
 
261
 
262
        $('body').on('click', 'button.btn-refresh', function(e) {
263
            e.preventDefault();
264
            gridTable.api().ajax.reload(null, false);
265
        });
266
 
16822 efrain 267
    $('body').on('click', 'button.btn-unblock', function(e) {
268
        e.preventDefault();
269
        var action = $(this).data('href');
1 www 270
 
271
 
16822 efrain 272
          swal.fire({
273
            title: 'LABEL_ARE_YOU_SURE',
274
            icon: 'question',
275
            cancelButtonText: 'LABEL_NO',
276
            showCancelButton: true,
277
            confirmButtonText: 'LABEL_YES'
278
          }).then((result) => {
279
            if (result.isConfirmed) {
1 www 280
 
16822 efrain 281
                    NProgress.start();
282
                    $.ajax({
283
                        'dataType'  : 'json',
284
                        'accept'    : 'application/json',
285
                        'method'    : 'post',
286
                        'url'       :  action,
287
                    }).done(function(response) {
288
                        if(response['success']) {
289
                            $.fn.showSuccess(response['data']);
290
                            gridTable.api().ajax.reload(null, false);
291
                        } else {
292
                            $.fn.showError(response['data']);
293
                        }
294
                    }).fail(function( jqXHR, textStatus, errorThrown) {
295
                        $.fn.showError(textStatus);
296
                    }).always(function() {
297
                        NProgress.done();
298
                    });
299
            }
300
       });
301
    });
1 www 302
 
16822 efrain 303
 $('body').on('click', 'button.btn-reject', function(e) {
304
        e.preventDefault();
305
        var action = $(this).data('href');
306
 
307
 
308
          swal.fire({
309
            title: 'LABEL_ARE_YOU_SURE',
310
            icon: 'question',
311
            cancelButtonText: 'LABEL_NO',
312
            showCancelButton: true,
313
            confirmButtonText: 'LABEL_YES'
314
          }).then((result) => {
315
            if (result.isConfirmed) {
316
 
317
                    NProgress.start();
318
                    $.ajax({
319
                        'dataType'  : 'json',
320
                        'accept'    : 'application/json',
321
                        'method'    : 'post',
322
                        'url'       :  action,
323
                    }).done(function(response) {
324
                        if(response['success']) {
325
                            $.fn.showSuccess(response['data']);
326
                            gridTable.api().ajax.reload(null, false);
327
                        } else {
328
                            $.fn.showError(response['data']);
329
                        }
330
                    }).fail(function( jqXHR, textStatus, errorThrown) {
331
                        $.fn.showError(textStatus);
332
                    }).always(function() {
333
                        NProgress.done();
334
                    });
335
            }
336
       });
337
    });
338
 
339
 $('body').on('click', 'button.btn-cancel', function(e) {
340
        e.preventDefault();
341
        var action = $(this).data('href');
342
 
343
 
344
          swal.fire({
345
            title: 'LABEL_ARE_YOU_SURE',
346
            icon: 'question',
347
            cancelButtonText: 'LABEL_NO',
348
            showCancelButton: true,
349
            confirmButtonText: 'LABEL_YES'
350
          }).then((result) => {
351
            if (result.isConfirmed) {
352
 
353
                    NProgress.start();
354
                    $.ajax({
355
                        'dataType'  : 'json',
356
                        'accept'    : 'application/json',
357
                        'method'    : 'post',
358
                        'url'       :  action,
359
                    }).done(function(response) {
360
                        if(response['success']) {
361
                            $.fn.showSuccess(response['data']);
362
                            gridTable.api().ajax.reload(null, false);
363
                        } else {
364
                            $.fn.showError(response['data']);
365
                        }
366
                    }).fail(function( jqXHR, textStatus, errorThrown) {
367
                        $.fn.showError(textStatus);
368
                    }).always(function() {
369
                        NProgress.done();
370
                    });
371
            }
372
       });
373
    });
374
 
375
 
1 www 376
        $('body').on('click', 'button.btn-invite', function(e) {
377
            e.preventDefault();
16926 efrain 378
 
1 www 379
            $('#form-invite #user_uuid').autoComplete('clear');
380
            $('#form-invite #user_uuid_selected').val('');
381
            $('#modalInvite').modal('show');
382
        });
383
 
384
        $('body').on('click', 'button.btn-accept', function(e) {
385
            e.preventDefault();
386
            action = $(this).data('href');
387
            NProgress.start();
388
            $.ajax({
389
                'dataType'  : 'json',
390
                'accept'    : 'application/json',
391
                'method'    : 'post',
392
                'url'       :  action
393
            }).done(function(response) {
394
                if(response['success']) {
395
                    $.fn.showSuccess(response['data']);
396
                    gridTable.api().ajax.reload(null, false);
397
                } else {
398
                    $.fn.showError(response['data']);
399
                }
400
            }).fail(function( jqXHR, textStatus, errorThrown) {
401
                $.fn.showError(textStatus);
402
            }).always(function() {
403
                NProgress.done();
404
            });
405
        });
406
 
16926 efrain 407
        $('#form-invite #user_uuid').typeahead({
408
            source: function (query, process) {
409
                return $.get('/typeahead', { query: query }, function (data) {
410
                    return process(data.options);
411
                });
412
            }
413
        });
1 www 414
 
16926 efrain 415
 
416
 
1 www 417
        $('#form-invite #user_uuid').autoComplete({
418
            resolver: 'custom',
419
            events: {
420
 
421
                search: function (qry, callback) {
422
                    NProgress.start();
423
                    $.ajax({
424
                        'url' : '$routeInvite',
425
                        'method': 'get',
426
				        'data': { 'search': qry }
427
				    }).done(function (response) {
428
                        if(response['success']) {
429
                            callback(response['data'])
430
                        } else {
431
                            $.fn.showError(response['data']);
432
                        }
433
					}).fail(function( jqXHR, textStatus, errorThrown) {
434
                        $.fn.showError(textStatus);
435
                    }).always(function() {
436
                        NProgress.done();
437
                    });
438
                }
439
            }
440
        });
441
 
442
	    $('#form-invite #user_uuid').on('autocomplete.select', function (evt, item) {
443
            $('#form-invite #user_uuid_selected').val(item['value']);
444
        });
445
 
446
        var validatorFormInvite = $('#form-invite').validate({
447
            debug: true,
448
            onclick: false,
449
            onkeyup: false,
450
            ignore: [':hidden'],
451
            rules: {
452
 
453
                'user_uuid': {
454
                    required: true,
455
                },
456
            },
457
            submitHandler: function(form)
458
            {
459
                NProgress.start();
460
                $.ajax({
461
                    'dataType'  : 'json',
462
                    'accept'    : 'application/json',
463
                    'method'    : 'post',
464
                    'url'       : '$routeInvite',
465
                    'data'      : {
466
                        'id' : $('#form-invite #user_uuid_selected').val(),
467
                    }
468
                 }).done(function(response) {
469
                    if(response.success) {
470
                        $.fn.showSuccess(response.data);
471
 
472
                        $('#modalInvite').modal('hide');
473
                         gridTable.api().ajax.reload(null, false);
474
                    } else {
475
                        if(jQuery.type(response.data) == 'string') {
476
                            $.fn.showError(response.data)
477
                        } else  {
478
                            $.each(response.data, function( fieldname, errors ) {
479
                                $.fn.showFormErrorValidator('#form-invite #' + fieldname, errors);
480
                            });
481
                        }
482
                    }
483
                }).fail(function( jqXHR, textStatus, errorThrown) {
484
                    $.fn.showError(textStatus)
485
 
486
                }).always(function() {
487
                    NProgress.done();
488
                })
489
            },
490
            invalidHandler: function(form, validator) {
491
            }
492
        });
493
 
15460 efrain 494
    var validatorUploadUsers = $('#form-upload-users').validate({
1 www 495
        debug: true,
496
        onclick: false,
497
        onkeyup: false,
498
        onfocusout: false,
499
        ignore: [],
500
        rules: {
501
            'file' : {
502
                required: true,
503
                extension: 'xls|xlsx',
504
                accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel'
505
            },
506
        },
507
 
508
        submitHandler: function(form)
509
        {
510
            NProgress.start();
511
            var formdata = false;
512
            if (window.FormData){
513
                formdata = new FormData(form);
514
            }
515
            formdata.append('step','validation');
516
 
517
 
518
            $.ajax({
519
                'dataType'  : 'json',
520
                'accept'    : 'application/json',
521
                'method'    : 'post',
522
                'url'       : '$routeUpload',
523
                'data'      :  formdata,
524
                'processData': false,
525
                'contentType': false,
526
            }).done(function(response) {
527
                if(response['success']) {
528
 
529
                    $('#table-upload-users-key').val(response['data']['key']);
530
 
531
                    $('#gridTableUploadUsers tbody').empty();
532
 
533
                    $.each(response['data']['items'], function(index, item) {
534
 
535
 
536
                        var s = '<tr>';
537
                        s = s + '<td>' + item['first_name'] + '</td>';
538
                        s = s + '<td>' + item['last_name'] + '</td>';
539
                        s = s + '<td>' + item['email'] + '</td>';
540
                        s = s + '<td>' + item['password'] + '</td>';
15460 efrain 541
                        s = s + '<td>' + item['is_adult'] + '</td>';
1 www 542
                        s = s + '</tr>';
543
 
544
                        $('#gridTableUploadUsers tbody').append(s);
545
 
546
 
547
                    });
548
 
549
                    $('#modalFormUploadUsers').modal('hide');
550
                    $('#modalUploadUsers').modal('show');
551
 
552
 
553
 
554
                } else {
15460 efrain 555
                    validatorUploadUsers.resetForm();
1 www 556
                    if(jQuery.type(response['data']) == 'string') {
557
                        $.fn.showError(response['data']);
558
                    } else  {
559
                        $.each(response['data'], function( fieldname, errors ) {
560
                            $.fn.showFormErrorValidator('#form-upload-users #' + fieldname, errors);
561
                        });
562
                    }
563
                }
564
            }).fail(function( jqXHR, textStatus, errorThrown) {
565
                $.fn.showError(textStatus);
566
            }).always(function() {
567
 
568
                NProgress.done();
569
            });
570
            return false;
571
        },
572
        invalidHandler: function(form, validator) {
573
 
574
        }
575
    });
576
 
577
 
578
    $('#form-upload-users #file').fileinput({
15460 efrain 579
        theme: 'fa',
1 www 580
        language: 'es',
581
        showUpload: false,
582
        dropZoneEnabled: false,
583
        maxFileCount: 1,
584
        allowedFileExtensions: ['xls', 'xlsx'],
585
    });
586
 
587
    $('body').on('click', 'button.btn-upload', function(e) {
588
        e.preventDefault();
589
 
590
        $('#form-upload-users #file').fileinput('reset');
591
        $('#form-upload-users #file').val('');
592
 
593
        $('#modalFormUploadUsers').modal('show');
594
    });
595
 
596
    $('body').on('click', 'button.btn-upload-users-step2', function(e) {
597
        e.preventDefault();
598
        NProgress.start();
599
 
600
        $.ajax({
601
            'dataType'  : 'json',
602
            'accept'    : 'application/json',
603
            'method'    : 'post',
604
            'url'       : '$routeUpload',
605
            'data'      :  {
606
                'step' : 'process',
607
                'key' : $('#table-upload-users-key').val(),
608
            }
609
        }).done(function(response) {
610
            if(response['success']) {
15460 efrain 611
                if(response['data']['users_created'] == 1) {
612
                    $.fn.showSuccess(response['data']['users_created'] + ' LABEL_USER_CREATED');
1 www 613
                } else {
15460 efrain 614
                    $.fn.showSuccess(response['data']['users_created'] + ' LABEL_USERS_CREATED');
1 www 615
                }
616
                 gridTable.api().ajax.reload(null, false);
617
                $('#modalUploadUsers').modal('hide');
618
            } else {
619
                $.fn.showError(response['data']);
620
            }
621
        }).fail(function( jqXHR, textStatus, errorThrown) {
622
            $.fn.showError(textStatus);
623
        }).always(function() {
624
            NProgress.done();
625
        });
626
        return false;
627
    });
628
 
629
    $('body').on('click', 'button.btn-edit', function(e) {
630
        e.preventDefault();
631
 
632
        var href = $(this).data('href');
633
        $('#form-edit').attr('action', href);
634
 
635
        NProgress.start();
636
        $.ajax({
637
            'dataType'  : 'json',
638
            'accept'    : 'application/json',
639
            'method'    : 'get',
640
            'url'       :  href,
641
        }).done(function(response) {
642
            if(response['success']) {
643
                $('#form-edit #backend').prop('checked', response['data']['backend'] );
644
                $('#table-roles tbody').empty();
645
 
646
                $.each(response['data']['roles'], function(index, role) {
647
 
648
                    var checked = role['checked'] ? ' checked="checked" ' : '';
649
                    var s = '<tr>';
650
                    s = s + '<td>' + role['name'] + '</td>';
16927 efrain 651
                    s = s + '<td><div class="form-check mb-3">';
16943 efrain 652
                    s = s + '<input type="checkbox" value="1" class="form-check-input" id="checked' + role['id'] + '" name="checked' + role['id'] + '" ' + checked + '> ';
16927 efrain 653
					s = s + '<label class="form-check-label" >&nbsp;</label>';
654
			        s = s + '</div></td>';
1 www 655
                    s = s + '</tr>';
656
 
657
                    $('#table-roles tbody').append(s);
658
 
659
                });
660
 
661
                $('#modalEdit').modal('show');
662
 
16926 efrain 663
 
16927 efrain 664
 
1 www 665
            } else {
666
                $.fn.showError(response['data']);
667
            }
668
        }).fail(function( jqXHR, textStatus, errorThrown) {
669
            $.fn.showError(textStatus);
670
        }).always(function() {
671
            NProgress.done();
672
        });
673
 
674
    });
675
 
676
    $('#form-edit').submit(function (e) {
677
        e.preventDefault();
678
        NProgress.start();
679
        $.ajax({
680
            'dataType'  : 'json',
681
            'accept'    : 'application/json',
682
            'method'    : 'post',
683
            'url'       : $('#form-edit').attr('action'),
684
            'data'      : $('#form-edit').serialize(),
685
        }).done(function(response) {
686
            if(response['success']) {
687
 
688
                $.fn.showSuccess(response['data']);
689
                $('#modalEdit').modal('hide');
690
                gridTable.api().ajax.reload(null, false);
691
 
692
            } else {
693
                $.fn.showError(response['data']);
694
            }
695
        }).fail(function( jqXHR, textStatus, errorThrown) {
696
            $.fn.showError(textStatus);
697
        }).always(function() {
698
            NProgress.done();
699
        });
700
        return false;
701
 
702
    });
703
 
704
    $('body').on('click', 'button.btn-cancel-modal', function(e) {
705
        e.preventDefault();
706
        $('#modalInvite').modal('hide');
707
        $('#modalFormUploadUsers').modal('hide');
708
        $('#modalEdit').modal('hide');
709
        $('#modalChangePassword').modal('hide');
710
    });
711
 
712
    var validatorChangePassword = $('#form-change-password').validate({
713
        debug: true,
714
        onclick: false,
715
        onkeyup: false,
716
        ignore: [':hidden'],
717
            rules: {
718
 
719
                'password': {
720
                    required: true,
721
                    minlength: 6,
722
                    maxlength: 16,
723
                    passwordStrengthCheck: true,
724
                },
725
                'confirmation' : {
726
                    required: true,
727
                    minlength: 6,
728
                    maxlength: 16,
729
                    equalTo: '#form-change-password #password'
730
                },
731
            },
732
            submitHandler: function(form)
733
            {
734
                NProgress.start();
735
                $.ajax({
736
                    'dataType'  : 'json',
737
                    'accept'    : 'application/json',
738
                    'method'    : 'post',
739
                    'url'       : $('#form-change-password').attr('action'),
740
                    'data'      : $('#form-change-password').serialize()
741
                 }).done(function(response) {
742
                    if(response.success) {
743
                        $.fn.showSuccess(response.data);
744
 
745
                        $('#modalChangePassword').modal('hide');
746
                         gridTable.api().ajax.reload(null, false);
747
                    } else {
748
                        if(jQuery.type(response.data) == 'string') {
749
                            $.fn.showError(response.data)
750
                        } else  {
751
                            $.each(response.data, function( fieldname, errors ) {
752
                                $.fn.showFormErrorValidator('#form-change-password #' + fieldname, errors);
753
                            });
754
                        }
755
                    }
756
                }).fail(function( jqXHR, textStatus, errorThrown) {
757
                    $.fn.showError(textStatus)
758
 
759
                }).always(function() {
760
                    NProgress.done();
761
                })
762
            },
763
            invalidHandler: function(form, validator) {
764
            }
765
        });
766
 
767
        $('body').on('click', 'button.btn-change-password', function(e) {
768
            e.preventDefault();
769
 
770
            NProgress.start();
771
            var action = $(this).data('href');
772
 
773
            $.ajax({
774
                'dataType'  : 'json',
775
                'accept'    : 'application/json',
776
                'method'    : 'get',
777
                'url'       :  action,
778
            }).done(function(response) {
779
                if(response['success']) {
780
 
781
                    $('#form-change-password').attr('action', action);
782
                    $('#form-change-password #first_name').val(response['data']['first_name']);
783
                    $('#form-change-password #last_name').val(response['data']['last_name']);
784
                    $('#form-change-password #email').val(response['data']['email']);
785
                    $('#form-change-password #password').val('');
786
                    $('#form-change-password #confirmation').val('');
787
                    validatorChangePassword.resetForm();
788
 
789
                    $('#modalChangePassword').modal('show');
790
                } else {
791
                    $.fn.showError(response['data']);
792
                }
793
            }).fail(function( jqXHR, textStatus, errorThrown) {
794
                $.fn.showError(textStatus);
795
            }).always(function() {
796
                NProgress.done();
797
            });
798
 
799
        });
800
 
801
 
802
 
803
    });
804
JS;
805
$this->inlineScript()->captureEnd();
15333 stevensc 806
?>
807
 
1 www 808
 
809
 
16840 efrain 810
<div class="container">
16912 efrain 811
	<div class= "card">
812
		<div class="card-header">
813
			<h6 class="card-title">LABEL_USERS_FOR_COMPANY</h6>
814
		</div>
815
		<div class="card-body">
816
 
817
 
818
    		<form name="form-filter" id="form-filter">
819
    			<div class="row">
820
          			<div class="col-12  mt-3">
821
                   		<label for="status">LABEL_STATUS</label>
822
                  		<select id="status" name="status" class="form-control">
823
    						<option value="">LABEL_ALL</option>
824
                         	<option value="<?php echo CompanyUser::STATUS_PENDING ?>">LABEL_PENDING</option>
825
                        	<option value="<?php echo CompanyUser::STATUS_ACCEPTED ?>">LABEL_ACCEPTED</option>
826
                           	<option value="<?php echo CompanyUser::STATUS_ADMIN_WILL_ADD ?>">LABEL_ADMIN_WILL_ADD</option>
827
                          	<option value="<?php echo CompanyUser::STATUS_SENT ?>">LABEL_INVITED</option>
828
                            <option value="<?php echo CompanyUser::STATUS_CANCELLED ?>">LABEL_CANCELLED</option>
829
                     		<option value="<?php echo CompanyUser::STATUS_REJECTED ?>">LABEL_REJECTED</option>
830
                      	</select>
831
                  	</div>
832
         		</div>
833
    	 	</form>
834
    	 	<div class="row">
835
          		<div class="col-12  mt-3">
836
    				<table id="gridTable" class="table table-bordered">
837
                        <thead>
838
                 			<tr>
839
                           		<th>LABEL_FIRST_NAME</th>
840
                           		<th>LABEL_LAST_NAME</th>
841
                               	<th>LABEL_EMAIL</th>
842
                           		<th>LABEL_DETAILS</th>
843
                               	<th>LABEL_ACTIONS</th>
844
                           	</tr>
845
    					</thead>
846
           				<tbody>
847
                     	</tbody>
848
                 	</table>
849
               	</div>
850
            </div>
851
		</div>
852
     	<div class="card-footer text-right">
853
    		<button type="button" class="btn btn-sm btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH</button>
854
        	<?php if ($allowUpload) : ?>
855
            <button type="button" class="btn btn-sm btn-primary btn-upload"><i class="fa fa-upload"></i> LABEL_UPLOAD </button>
856
     		<?php endif; ?>
857
           	<?php if ($allowInvite) : ?>
858
           	<button type="button" class="btn btn-sm btn-primary btn-invite"><i class="fa fa-plus"></i> LABEL_INVITE </button>
859
    		<?php endif; ?>
15333 stevensc 860
        </div>
16912 efrain 861
   	</div>
16840 efrain 862
</div>
15333 stevensc 863
 
864
 
1 www 865
<!-- The Modal -->
866
<div class="modal" id="modalInvite">
15333 stevensc 867
    <div class="modal-dialog  modal-xl">
868
        <div class="modal-content">
1 www 869
 
870
            <!-- Modal Header -->
15333 stevensc 871
            <div class="modal-header">
16935 efrain 872
                <h6 class="modal-title">LABEL_INVITE</h6>
15333 stevensc 873
            </div>
1 www 874
 
875
            <!-- Modal body -->
16840 efrain 876
            <form name="form-invite" id="form-invite">
15333 stevensc 877
            <div class="modal-body">
16840 efrain 878
 
15333 stevensc 879
                    <input type="hidden" name="user_uuid_selected" id="user_uuid_selected" />
16840 efrain 880
                    <div class="row">
16841 efrain 881
                    	<div class="col-12  mt-3">
15333 stevensc 882
                        <label for="user_uuid">LABEL_USER (LABEL_MIN_LENGTH_3)</label>
16927 efrain 883
                        <br/>
15333 stevensc 884
                        <input autocomplete="off" type="text" name="user_uuid" id="user_uuid" class="form-control" data-noresults-text="LABEL_AUTOCOMPLETE_USERS_NOT_FOUND">
16840 efrain 885
                    	</div>
886
                    </div>
1 www 887
 
888
 
16840 efrain 889
 
890
 
15333 stevensc 891
            </div>
16840 efrain 892
            <div class="modal-footer text-right">
893
            	<button type="submit" class="btn btn-sm btn-primary">LABEL_INVITE</button>
894
         		<button type="button" class="btn btn-sm btn-light btn-cancel-modal">LABEL_CANCEL</button>
895
          	 </div>
896
            </form>
15333 stevensc 897
        </div>
898
    </div>
899
</div>
1 www 900
 
901
 
15333 stevensc 902
 
1 www 903
<!-- The Modal -->
904
<div class="modal" id="modalFormUploadUsers">
15333 stevensc 905
    <div class="modal-dialog  modal-xl">
906
        <div class="modal-content">
1 www 907
 
908
            <!-- Modal Header -->
15333 stevensc 909
            <div class="modal-header">
16935 efrain 910
                <h6 class="modal-title">LABEL_UPLOAD</h6>
15333 stevensc 911
            </div>
1 www 912
 
16840 efrain 913
			 <?php
15333 stevensc 914
                $form = $this->formUploadUsers;
915
                $form->setAttributes([
916
                    'method'    => 'post',
917
                    'name'      => 'form-upload-users',
918
                    'id'        => 'form-upload-users'
919
                ]);
1 www 920
 
15333 stevensc 921
                $form->prepare();
922
                echo $this->form()->openTag($form);
923
                ?>
16840 efrain 924
            <!-- Modal body -->
925
            <div class="modal-body">
926
 
15333 stevensc 927
 
16840 efrain 928
                <div class="row">
16841 efrain 929
                	<div class="col-12  mt-3">
15333 stevensc 930
 
931
 
932
                    <?php
933
                    $element = $form->get('file');
934
                    $element->setOptions(['label' => 'LABEL_EXCEL']);
935
                    echo $this->formLabel($element);
936
                    ?>
937
                    <div class="file-loading">
938
                        <?php
16816 stevensc 939
 
16768 efrain 940
                        $element->setAttributes(['class' => 'form-control', 'accept' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel']);
1 www 941
                        echo $this->formFile($element);
942
                        ?>
16840 efrain 943
                        </div>
15333 stevensc 944
                    </div>
945
                </div>
1 www 946
 
947
 
948
 
16840 efrain 949
 
950
            </div>
951
          	<div class="modal-footer text-right">
15333 stevensc 952
                    <button type="submit" class="btn btn-sm btn-primary">LABEL_UPLOAD</button>
953
                    <button type="button" class="btn btn-sm btn-light btn-cancel-modal">LABEL_CANCEL</button>
16840 efrain 954
      		</div>
955
        	<?php echo $this->form()->closeTag($form); ?>
15333 stevensc 956
        </div>
957
    </div>
958
</div>
1 www 959
 
960
 
15333 stevensc 961
 
1 www 962
<!-- The Modal -->
963
<div class="modal" id="modalUploadUsers">
15333 stevensc 964
    <div class="modal-dialog modal-xl">
965
        <div class="modal-content">
1 www 966
 
967
            <!-- Modal Header -->
15333 stevensc 968
            <div class="modal-header">
16935 efrain 969
                <h6 class="modal-title">LABEL_USERS_FOR_COMPANY</h6>
16822 efrain 970
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
15333 stevensc 971
            </div>
1 www 972
 
973
            <!-- Modal body -->
15333 stevensc 974
            <div class="modal-body">
975
                <form>
976
                    <input type="hidden" name="table-upload-users-key" id="table-upload-users-key">
977
                </form>
16840 efrain 978
                <div class="row">
16841 efrain 979
                	<div class="col-12  mt-3" style="height: 300px;overflow: scroll;">
16840 efrain 980
                    	<table id="gridTableUploadUsers" style="width: 100%" class="table table-bordered">
981
                            <thead>
982
                                <tr>
983
                                    <th>LABEL_FIRST_NAME</th>
984
                                    <th>LABEL_LAST_NAME</th>
985
                                    <th>LABEL_EMAIL</th>
986
                                    <th>LABEL_PASSWORD</th>
987
                                    <th>LABEL_IS_ADULT</th>
988
                                </tr>
989
                            </thead>
990
                            <tbody>
991
                            </tbody>
992
                        </table>
993
 
994
                	</div>
15333 stevensc 995
                </div>
1 www 996
 
16840 efrain 997
 
15333 stevensc 998
            </div>
999
 
1 www 1000
            <!-- Modal footer -->
16891 efrain 1001
            <div class="modal-footer text-right">
15333 stevensc 1002
                <button type="submit" class="btn btn-sm btn-primary btn-upload-users-step2">LABEL_SAVE</button>
1003
                <button type="button" class="btn btn-sm btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
1004
            </div>
1 www 1005
 
15333 stevensc 1006
        </div>
1007
    </div>
1008
</div>
1 www 1009
 
1010
 
1011
<!-- The Modal -->
1012
<div class="modal" id="modalEdit">
15333 stevensc 1013
    <div class="modal-dialog  modal-xl">
1014
        <div class="modal-content">
1 www 1015
 
1016
            <!-- Modal Header -->
15333 stevensc 1017
            <div class="modal-header">
16935 efrain 1018
                <h6 class="modal-title">LABEL_USER_FOR_COMPANY - LABEL_EDIT</h6>
15333 stevensc 1019
            </div>
1 www 1020
 
16840 efrain 1021
			<form name="form-edit" id="form-edit">
1 www 1022
            <!-- Modal body -->
15333 stevensc 1023
            <div class="modal-body">
16840 efrain 1024
 
15333 stevensc 1025
                    <div class="row">
16841 efrain 1026
                        <div class="col-md-12 col-sm-12  mt-3">
16927 efrain 1027
                        	<div class="form-check mb-3">
1028
                        	 	<input type="checkbox" name="backend" id="backend" value="y" class="form-check-input" style="width: 20px; height: 20px">                              <label for="backend" class="form-check-label">LABEL_ACCESS_BACKEND</label>
1029
 
15333 stevensc 1030
                            </div>
1031
                        </div>
1032
                    </div>
1033
                    <div class="row">
16841 efrain 1034
                        <div class="col-md-12 col-sm-12  mt-3">
16822 efrain 1035
                            <table id="table-roles" class="table table-bordered">
15333 stevensc 1036
                                <thead>
1037
                                    <tr>
1038
                                        <th>LABEL_NAME</th>
1039
                                        <th>LABEL_ACTIVE</th>
1040
                                    </tr>
1041
                                </thead>
1042
                                <tbody>
1043
                                </tbody>
1044
                            </table>
1 www 1045
 
15333 stevensc 1046
                        </div>
1047
                    </div>
1048
 
16840 efrain 1049
 
1050
            </div>
1051
         	<div class="modal-footer text-right">
15333 stevensc 1052
                        <button type="submit" class="btn btn-sm btn-primary">LABEL_SAVE</button>
1053
                        <button type="button" class="btn btn-sm btn-light btn-cancel-modal">LABEL_CANCEL</button>
1054
                    </div>
1055
                </form>
1056
        </div>
1057
    </div>
1 www 1058
</div>
1059
 
1060
 
1061
 
1062
<!-- The Modal -->
1063
<div class="modal" id="modalChangePassword">
15333 stevensc 1064
    <div class="modal-dialog">
1065
        <div class="modal-content">
1 www 1066
 
1067
            <!-- Modal Header -->
15333 stevensc 1068
            <div class="modal-header">
16935 efrain 1069
                <h6 class="modal-title">LABEL_USERS</h6>
15333 stevensc 1070
            </div>
1 www 1071
 
16929 efrain 1072
 <?php
15333 stevensc 1073
                $form = $this->formChangePassword;
1074
                $form->setAttributes([
1075
                    'method'    => 'post',
1076
                    'name'      => 'form-change-password',
1077
                    'id'        => 'form-change-password'
1078
                ]);
1 www 1079
 
15333 stevensc 1080
                $form->prepare();
1081
                echo $this->form()->openTag($form);
1082
                ?>
16929 efrain 1083
            <div class="modal-body">
1084
 
1085
               	<div class="row">
1086
               		<div class="col-12 mt-3">
15333 stevensc 1087
                    <?php
1088
                    $element = $form->get('first_name');
1089
                    $element->setOptions(['label' => 'LABEL_FIRST_NAME']);
1090
                    $element->setAttributes(['class' => 'form-control', 'readonly' => 'readonly']);
1 www 1091
 
15333 stevensc 1092
                    echo $this->formLabel($element);
1093
                    echo $this->formText($element);
1094
                    ?>
16929 efrain 1095
                    </div>
15333 stevensc 1096
                </div>
16929 efrain 1097
               	<div class="row">
1098
               		<div class="col-12 mt-3">
15333 stevensc 1099
                    <?php
1100
                    $element = $form->get('last_name');
1101
                    $element->setOptions(['label' => 'LABEL_LAST_NAME']);
1102
                    $element->setAttributes(['class' => 'form-control', 'readonly' => 'readonly']);
1 www 1103
 
15333 stevensc 1104
                    echo $this->formLabel($element);
1105
                    echo $this->formText($element);
1106
                    ?>
16929 efrain 1107
                    </div>
15333 stevensc 1108
                </div>
16929 efrain 1109
               	<div class="row">
1110
               		<div class="col-12 mt-3">
15333 stevensc 1111
                    <?php
1112
                    $element = $form->get('email');
1113
                    $element->setOptions(['label' => 'LABEL_EMAIL']);
1114
                    $element->setAttributes(['class' => 'form-control', 'readonly' => 'readonly']);
1 www 1115
 
15333 stevensc 1116
                    echo $this->formLabel($element);
1117
                    echo $this->formText($element);
1118
                    ?>
16929 efrain 1119
                    </div>
15333 stevensc 1120
                </div>
16929 efrain 1121
               	<div class="row">
1122
               		<div class="col-12 mt-3">
15333 stevensc 1123
                    <?php
1124
                    $element = $form->get('password');
1125
                    $element->setOptions(['label' => 'LABEL_PASSWORD']);
1126
                    $element->setAttributes(['class' => 'form-control']);
1 www 1127
 
15333 stevensc 1128
                    echo $this->formLabel($element);
1129
                    echo $this->formPassword($element);
1130
                    ?>
16929 efrain 1131
                    </div>
15333 stevensc 1132
                </div>
16929 efrain 1133
               	<div class="row">
1134
               		<div class="col-12 mt-3">
15333 stevensc 1135
                    <?php
1136
                    $element = $form->get('confirmation');
1137
                    $element->setOptions(['label' => 'LABEL_CONFIRMATION']);
1138
                    $element->setAttributes(['class' => 'form-control']);
1 www 1139
 
15333 stevensc 1140
                    echo $this->formLabel($element);
1141
                    echo $this->formPassword($element);
1142
                    ?>
16929 efrain 1143
                    </div>
15333 stevensc 1144
                </div>
1145
 
1146
 
16929 efrain 1147
 
1148
            </div>
1149
            <div class="modal-footer text-right">
15333 stevensc 1150
                    <button type="submit" class="btn btn-sm btn-primary">LABEL_SAVE</button>
1151
                    <button type="button" class="btn btn-sm btn-light btn-cancel-modal">LABEL_CANCEL</button>
1152
                </div>
1153
                <?php echo $this->form()->closeTag($form); ?>
1154
 
1155
        </div>
1156
    </div>
1157
</div>