Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
1 www 1
<?php
2
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser    = $this->currentUserHelper();
4
$roleName       = $currentUser->getUserTypeId();
5
 
6
$routeDatatable = $this->url('microlearning/access-for-students');
7
 
8
$allowRevoke = $acl->isAllowed($roleName, 'microlearning/access-for-students/revoke') ? 1 : 0;
9
$allowUnlimit = $acl->isAllowed($roleName, 'microlearning/access-for-students/unlimit') ? 1 : 0;
10
$allowUpload = $acl->isAllowed($roleName, 'microlearning/access-for-students/upload') ? 1 : 0;
11
$allowCancel = $acl->isAllowed($roleName, 'microlearning/access-for-students/cancel') ? 1 : 0;
12
$allowReactive = $acl->isAllowed($roleName, 'microlearning/access-for-students/reactive') ? 1 : 0;
13
$allowNotification = $acl->isAllowed($roleName, 'microlearning/access-for-students/notification') ? 1 : 0;
14
 
16822 efrain 15
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
16
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
1 www 17
 
16822 efrain 18
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));
19
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.css'));
1 www 20
 
16822 efrain 21
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
22
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));
23
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/dataTables.responsive.min.js'));
24
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.min.js'));
1 www 25
 
16822 efrain 26
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
27
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
1 www 28
 
16822 efrain 29
$this->inlineScript()->appendFile($this->basePath('assets/vendors/moment/moment-with-locales.min.js'));
30
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css'));
31
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'));
32
 
33
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-fileinput/css/fileinput.min.css'));
34
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-fileinput/themes/explorer-fas/theme.css'));
35
 
16843 efrain 36
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/plugins/piexif.js'));
37
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/plugins/sortable.js'));
16822 efrain 38
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/fileinput.js'));
39
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/locales/es.js'));
40
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/themes/fas/theme.js'));
41
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/themes/explorer-fas/theme.js'));
42
 
1 www 43
$this->headStyle()->captureStart();
44
echo <<<CSS
45
 
46
 
16983 efrain 47
#gridTableUploadOk {
1 www 48
    display: flex;
49
    flex-flow: column;
50
    width: 100%;
51
}
52
 
16983 efrain 53
#gridTableUploadOk thead {
1 www 54
    flex: 0 0 auto;
55
}
56
 
16983 efrain 57
#gridTableUploadOk tbody {
1 www 58
    flex: 1 1 auto;
59
    display: block;
60
    overflow-y: auto;
61
    overflow-x: hidden;
62
}
63
 
16983 efrain 64
#gridTableUploadOk tr {
1 www 65
    width: 100%;
66
    display: table;
67
    table-layout: fixed;
68
}
16983 efrain 69
 
70
#gridTableUploadError {
71
    display: flex;
72
    flex-flow: column;
73
    width: 100%;
74
}
75
 
76
#gridTableUploadError thead {
77
    flex: 0 0 auto;
78
}
79
 
80
#gridTableUploadError tbody {
81
    flex: 1 1 auto;
82
    display: block;
83
    overflow-y: auto;
84
    overflow-x: hidden;
85
}
86
 
87
#gridTableUploadError tr {
88
    width: 100%;
89
    display: table;
90
    table-layout: fixed;
91
}
92
 
1 www 93
CSS;
94
$this->headStyle()->captureEnd();
95
 
96
$this->inlineScript()->captureStart();
97
echo <<<JS
98
 
99
 
100
jQuery( document ).ready(function( $ ) {
101
 
102
        var routeUpload = '';
103
        var routeNotification = '';
104
 
105
        $.validator.setDefaults({
106
            debug: true,
107
            highlight: function(element) {
108
                $(element).addClass('is-invalid');
109
            },
110
            unhighlight: function(element) {
111
                $(element).removeClass('is-invalid');
112
            },
113
            errorElement: 'span',
114
            errorClass: 'error invalid-feedback',
115
            errorPlacement: function(error, element) {
116
                if(element.parent('.btn-file').length) {
117
                    error.insertAfter(element.parent().parent());
118
                } else if(element.parent('.toggle').length) {
119
                    error.insertAfter(element.parent().parent());
120
                } else {
121
                    error.insertAfter(element.parent());
122
                }
123
            }
124
        });
125
 
126
 
127
        var allowRevoke   = $allowRevoke;
128
        var allowUnlimit  = $allowUnlimit;
129
        var allowCancel   = $allowCancel;
130
        var allowReactive = $allowReactive;
131
        var allowUpload   = $allowUpload;
132
        var allowNotification = $allowNotification;
133
 
134
        var gridTable = $('#gridTable').dataTable( {
135
            'processing': true,
136
            'serverSide': true,
137
            'searching': true,
138
            'order': [[ 1, 'asc' ]],
139
            'ordering':  true,
140
            'ordenable' : true,
141
            'responsive': true,
142
            'select' : false,
143
        	'paging': true,
144
            'pagingType': 'simple_numbers',
145
            'lengthMenu': [ [10, 25, 50, -1], [10, 25, 50, 'All'] ],
146
    		'ajax': {
147
    			'url' : '$routeDatatable',
148
    			'type' : 'get',
149
                'data': function ( d ) {
150
                    d.topic_uuid = $('#form-filter #topic_uuid').val();
151
                    d.capsule_uuid = $('#form-filter #capsule_uuid').val();
152
                },
153
                'beforeSend': function (request) {
154
                  NProgress.start();
155
                },
156
                'dataFilter': function(response) {
157
                    var response = jQuery.parseJSON( response );
158
 
159
                    var json                = {};
160
                    json.recordsTotal       = 0;
161
                    json.recordsFiltered    = 0;
162
                    json.data               = [];
163
 
164
                    if(response.success) {
165
                        $('#form-capsule-add').attr('action', response.data.link_add );
166
 
167
                        if(response.data.capsules) {
168
                            $('#form-filter #capsule_uuid').empty();
169
                            $.each(response.data.capsules, function(index, value) {
170
                                  $('#form-filter #capsule_uuid').append('<option value="' + index + '">' + value + '</option>')
171
                            });
172
                        }
173
 
174
                        routeUpload = response.data.link_upload;
175
                        routeNotification = response.data.link_notification;
176
 
177
                        if(response.data.link_upload) {
178
                            $('button.btn-upload').removeAttr('disabled');
179
                        } else {
180
                            $('button.btn-upload').attr('disabled', 'disabled');
181
                        }
182
 
183
                        if(response.data.link_notification) {
184
                            $('button.btn-notification').removeAttr('disabled');
185
                        } else {
186
                            $('button.btn-notification').attr('disabled', 'disabled');
187
                        }
188
 
189
                        json.recordsTotal       = response.data.total;
190
                        json.recordsFiltered    = response.data.total;
191
                        json.data               = response.data.items;
192
                    } else {
193
                        $.fn.showError(response.data)
194
                    }
195
 
196
                    return JSON.stringify( json );
197
                }
198
    		},
199
            'language' : {
200
                'sProcessing':     'LABEL_DATATABLE_SPROCESSING',
201
                'sLengthMenu':     'LABEL_DATATABLE_SLENGTHMENU',
202
                'sZeroRecords':    'LABEL_DATATABLE_SZERORECORDS',
203
                'sEmptyTable':     'LABEL_DATATABLE_SEMPTYTABLE',
204
                'sInfo':           'LABEL_DATATABLE_SINFO',
205
                'sInfoEmpty':      'LABEL_DATATABLE_SINFOEMPTY',
206
                'sInfoFiltered':   'LABEL_DATATABLE_SINFOFILTERED',
207
                'sInfoPostFix':    '',
208
                'sSearch':         'LABEL_DATATABLE_SSEARCH',
209
                'sUrl':            '',
210
                'sInfoThousands':  ',',
211
                'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
212
                'oPaginate': {
213
                    'sFirst':    'LABEL_DATATABLE_SFIRST',
214
                    'sLast':     'LABEL_DATATABLE_SLAST',
215
                    'sNext':     'LABEL_DATATABLE_SNEXT',
216
                    'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
217
                },
218
                'oAria': {
219
                    'sSortAscending':  ': LABEL_DATATABLE_SSORTASCENDING',
220
                    'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
221
                },
222
            },
223
            'drawCallback': function( settings ) {
224
                NProgress.done();
16822 efrain 225
 
1 www 226
            },
227
            'aoColumns': [
228
                { 'mDataProp': 'uuid' },
229
                { 'mDataProp': 'first_name' },
230
                { 'mDataProp': 'last_name' },
231
                { 'mDataProp': 'email' },
232
                { 'mDataProp': 'details' },
233
                { 'mDataProp': 'actions' },
234
    	    ],
235
            'columnDefs': [
236
                {
237
                    'targets': 0,
238
                    'orderable': false,
239
                    'render' : function ( data, type, row ) {
240
                        s = '<input type="checkbox" class="chk-customer" value="' + data + '">';
241
                        return s;
242
                    }
243
                },
244
                {
245
                    'targets': -2,
246
                    'orderable': false,
247
                    'render' : function ( data, type, row ) {
248
                        s = '';
249
                        if(data['access']) {
250
                            s = s + 'LABEL_ACCESS : ' + data['access'] + '<br>';
251
                        }
252
                        if(data['paid_from']) {
253
                            s = s + 'LABEL_PAID_FROM : ' + data['paid_from'] + '<br>';
254
                        }
255
                        if(data['paid_to']) {
256
                            s = s + 'LABEL_PAID_TO : ' + data['paid_to'] + '<br>';
257
                        }
258
                        if(data['added_on']) {
259
                            s = s + 'LABEL_ADDED_ON : ' + data['added_on'] + '<br>';
260
                        }
261
                        if(data['updated_on']) {
262
                            s = s + 'LABEL_UPDATED_ON : ' + data['updated_on'] + '<br>';
263
                        }
264
 
265
                        return s;
266
                    }
267
                },
268
 
269
 
270
                {
271
                    'targets': -1,
272
                    'orderable': false,
273
                    'render' : function ( data, type, row ) {
274
                        s = '';
275
 
276
                        if(allowRevoke && data['link_revoke']  ) {
277
                            s = s + '<button class="btn btn-danger btn-sm btn-revoke" data-href="' + data['link_revoke']+ '" data-toggle="tooltip" title="LABEL_REVOKE"><i class="fa fa-times"></i> LABEL_REVOKE </button>&nbsp;';
278
                        }
279
                        if(allowCancel && data['link_cancel']  ) {
280
                            s = s + '<button class="btn btn-danger btn-sm btn-cancel" data-href="' + data['link_cancel']+ '" data-toggle="tooltip" title="LABEL_CANCEL"><i class="fa fa-times"></i> LABEL_CANCEL </button>&nbsp;';
281
                        }
282
                        if(allowUnlimit && data['link_unlimit']  ) {
283
                            s = s + '<button class="btn btn-primary btn-sm btn-unlimit" data-href="' + data['link_unlimit']+ '" data-toggle="tooltip" title="LABEL_UNLIMIT"><i class="fa fa-check"></i> LABEL_UNLIMIT </button>&nbsp;';
284
                        }
285
                        if(allowReactive && data['link_reactive']  ) {
286
                            s = s + '<button class="btn btn-success btn-sm btn-reactive" data-href="' + data['link_reactive']+ '" data-toggle="tooltip" title="LABEL_REACTIVE"><i class="fa fa-check"></i> LABEL_REACTIVE </button>&nbsp;';
287
                        }
288
 
289
 
290
                        return s;
291
                    }
292
                }
293
              ],
294
        });
295
 
296
    $('#form-filter #topic_uuid').change(function(e) {
297
        e.preventDefault();
298
 
299
        $('#form-filter #capsule_uuid').empty();
300
        gridTable.api().ajax.reload(null, false);
301
    })
302
 
303
 
304
    $('#form-filter #capsule_uuid').change(function(e) {
305
        e.preventDefault();
306
 
307
        gridTable.api().ajax.reload(null, false);
308
    })
309
 
310
    $('body').on('click', 'button.btn-notification', function(e) {
311
        e.preventDefault();
312
 
313
        var customer_uuids = [];
314
        $.each($('input[type="checkbox"].chk-customer:checked'), function(index, element) {
315
            customer_uuids.push($(this).val());
316
        });
317
 
318
        if(customer_uuids.length == 0) {
319
            $.fn.showError('ERROR_NOT_SELECTED_CUSTOMERS');
320
            return;
321
        }
322
 
323
        var href = $(this).data('href');
324
        $('#notificationPushModal').modal('show');
325
        $('#form-push-notification').attr('action', href);
326
 
327
    });
328
 
329
 
330
    $('#chk-customer-all').click(function(e) {
331
       // e.preventDefault();
332
 
333
        var checked = $(this).prop('checked');
334
        $.each($('input[type="checkbox"].chk-customer'), function(index, element) {
335
           $(this).prop('checked', checked);
336
        });
337
 
338
 
339
    });
340
 
341
    $('body').on('click', 'input[type="checkbox"].chk-customer', function(e) {
342
        var checked = $(this).prop('checked');
343
        if(!checked) {
344
            $('#chk-customer-all').prop('checked', false );
345
        }
346
    });
347
 
348
var validatorPushNotification = $('#form-push-notification').validate({
349
        debug: true,
350
        onclick: false,
351
        onkeyup: false,
352
        onfocusout: false,
353
        ignore: [],
354
        rules: {
355
            'push_template_id' : {
356
                required: true,
357
 
358
            },
359
        },
360
 
361
        submitHandler: function(form)
362
        {
363
            var customer_uuids = [];
364
            $.each($('input[type="checkbox"].chk-customer:checked'), function(index, element) {
365
                customer_uuids.push($(this).val());
366
            });
367
 
368
            if(customer_uuids.length == 0) {
369
                $.fn.showError('ERROR_NOT_SELECTED_CUSTOMERS');
370
                return;
371
            }
372
 
373
            var push_template_id = $('#form-push-notification #push_template_id').val();
374
 
375
            $('input[type="submit"]').prop('disabled', true);
376
            NProgress.start();
377
            $.ajax({
378
                'dataType'  : 'json',
379
                'accept'    : 'application/json',
380
                'method'    : 'post',
381
                'url'       : routeNotification,
382
                'data'      : {
383
                    'push_template_id' : push_template_id,
384
                    'customer_uuids' : customer_uuids
385
 
386
                },
387
            }).done(function(response) {
388
                if(response['success']) {
389
                    if(response['data']['push_to_send'] == 1) {
390
                        $.fn.showSuccess(response['data']['push_to_send'] + ' LABEL_PUSH_IN_QUEUE');
391
                    } else {
392
                        $.fn.showSuccess(response['data']['push_to_send'] + ' LABEL_PUSHES_IN_QUEUE');
393
                    }
394
 
395
 
396
                    $('#notificationPushModal').modal('hide');
397
                } else {
398
                    validatorPushNotification.resetForm();
399
                    if(jQuery.type(response['data']) == 'string') {
400
                        $.fn.showError(response['data']);
401
                    } else  {
402
                        $.each(response['data'], function( fieldname, errors ) {
403
                            $.fn.showFormErrorValidator('#form-push-notification #' + fieldname, errors);
404
                        });
405
                    }
406
                }
407
            }).fail(function( jqXHR, textStatus, errorThrown) {
408
                $.fn.showError(textStatus);
409
            }).always(function() {
410
 
411
                NProgress.done();
412
            });
413
            return false;
414
        },
415
        invalidHandler: function(form, validator) {
416
 
417
        }
418
    });
419
 
420
 
421
    var validatorCapsuleCustomer = $('#form-capsule-customer').validate({
422
        debug: true,
423
        onclick: false,
424
        onkeyup: false,
425
        onfocusout: false,
426
        ignore: [],
427
        rules: {
428
            'file' : {
429
                required: true,
430
                extension: 'xls|xlsx',
431
                accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel'
432
            },
433
        },
434
 
435
        submitHandler: function(form)
436
        {
437
            NProgress.start();
438
            var formdata = false;
439
            if (window.FormData){
440
                formdata = new FormData(form);
441
            }
442
            formdata.append('step','validation');
443
 
444
 
445
            $.ajax({
446
                'dataType'  : 'json',
447
                'accept'    : 'application/json',
448
                'method'    : 'post',
449
                'url'       :  routeUpload,
450
                'data'      :  formdata,
451
                'processData': false,
452
                'contentType': false,
453
            }).done(function(response) {
454
                if(response['success']) {
455
 
456
                    $('#table-upload-customers-key').val(response['data']['key']);
457
                    $('#table-upload-customers-topic').val(response['data']['topic']);
458
          			$('#table-upload-customers-capsule').val(response['data']['capsule']);
459
 
16983 efrain 460
                    $('#gridTableUploadOk tbody').empty();
1 www 461
 
16983 efrain 462
                    $.each(response['data']['items']['ok'], function(index, item) {
1 www 463
 
464
 
465
                        var s = '<tr>';
16983 efrain 466
                        s = s + '<td>' + item['id'] + '</td>';
1 www 467
                        s = s + '<td>' + item['first_name'] + '</td>';
468
                        s = s + '<td>' + item['last_name'] + '</td>';
469
                        s = s + '<td>' + item['email'] + '</td>';
470
                        s = s + '<td class="text-right">' + item['assigned_capsules'] + '</td>';
471
                        s = s + '</tr>';
472
 
16983 efrain 473
                        $('#gridTableUploadOk tbody').append(s);
1 www 474
 
475
 
16983 efrain 476
                    });
477
 
478
                    $.each(response['data']['items']['error'], function(index, item) {
1 www 479
 
16983 efrain 480
 
481
                        var s = '<tr>';
482
                        s = s + '<td>' + item['id'] + '</td>';
483
                        s = s + '<td>' + item['first_name'] + '</td>';
484
                        s = s + '<td>' + item['last_name'] + '</td>';
485
                        s = s + '<td>' + item['email'] + '</td>';
486
                        s = s + '<td>' + item['status'] + '</td>';
487
                        s = s + '</tr>';
488
 
489
                        $('#gridTableUploadError tbody').append(s);
490
 
491
 
492
                    });
493
 
1 www 494
                    $('#modalCapsuleCustomer').modal('hide');
495
                    $('#modalUploadCustomers').modal('show');
496
 
497
 
498
 
499
                } else {
500
                    validatorCapsuleCustomer.resetForm();
501
                    if(jQuery.type(response['data']) == 'string') {
502
                        $.fn.showError(response['data']);
503
                    } else  {
504
                        $.each(response['data'], function( fieldname, errors ) {
505
                            $.fn.showFormErrorValidator('#form-capsule-customer #' + fieldname, errors);
506
                        });
507
                    }
508
                }
509
            }).fail(function( jqXHR, textStatus, errorThrown) {
510
                $.fn.showError(textStatus);
511
            }).always(function() {
512
 
513
                NProgress.done();
514
            });
515
            return false;
516
        },
517
        invalidHandler: function(form, validator) {
518
 
519
        }
520
    });
521
 
522
 
523
    $('#form-capsule-customer #file').fileinput({
524
        theme: 'fas',
525
        language: 'es',
526
        showUpload: false,
527
        dropZoneEnabled: false,
528
        maxFileCount: 1,
529
        allowedFileExtensions: ['xls', 'xlsx'],
530
    });
531
 
532
    $('body').on('click', 'button.btn-upload', function(e) {
533
        e.preventDefault();
534
 
535
        $('#form-capsule-customer #file').fileinput('reset');
536
        $('#form-capsule-customer #file').val('');
537
 
538
        $('#modalCapsuleCustomer').modal('show');
539
    });
540
 
541
    $('body').on('click', 'button.btn-upload-customers-step2', function(e) {
542
        e.preventDefault();
543
        NProgress.start();
544
 
545
        $.ajax({
546
            'dataType'  : 'json',
547
            'accept'    : 'application/json',
548
            'method'    : 'post',
549
            'url'       :  routeUpload,
550
            'data'      :  {
551
                'step' : 'process',
552
                'key' : $('#table-upload-customers-key').val(),
553
            }
554
        }).done(function(response) {
555
            if(response['success']) {
15457 efrain 556
 
16983 efrain 557
                var anchor = window.document.createElement("a");
558
                anchor.href = 'data:application/octet-stream;charset=utf-8;base64,' + response['data']['csv_base64_content'] ;
559
                anchor.download = response['data']['csv_filename'];
560
                document.body.appendChild(anchor);
561
                anchor.click();  // IE: "Access is denied"; see: https://connect.microsoft.com/IE/feedback/details/797361/ie-10-treats-blob-url-as-cross-origin-and-denies-access
562
                document.body.removeChild(anchor);
563
 
15457 efrain 564
                var s = response['data']['users_processed'] + ' LABEL_USTUDENTS_PROCESED <br>' +
565
                response['data']['users_assigned'] + ' LABEL_STUDENTS_ASSIGNED <br>' +
566
                response['data']['users_previous'] + ' LABEL_USTUDENTS_PREVIOUS <br>' +
567
                response['data']['users_in_the_capsule'] + ' LABEL_STUDENTS_TOTAL';
568
 
569
                $.fn.showSuccess(s);
570
 
1 www 571
                 gridTable.api().ajax.reload(null, false);
572
                $('#modalUploadCustomers').modal('hide');
573
            } else {
574
                $.fn.showError(response['data']);
575
            }
576
        }).fail(function( jqXHR, textStatus, errorThrown) {
577
            $.fn.showError(textStatus);
578
        }).always(function() {
579
            NProgress.done();
580
        });
581
        return false;
582
    });
583
 
584
    $('body').on('click', 'button.btn-refresh', function(e) {
585
        e.preventDefault();
586
        gridTable.api().ajax.reload(null, false);
587
    });
16822 efrain 588
 
589
     $('body').on('click', 'button.btn-delete', function(e) {
590
        e.preventDefault();
591
        var action = $(this).data('href');
592
 
593
 
594
          swal.fire({
595
            title: 'LABEL_ARE_YOU_SURE',
596
            icon: 'question',
597
            cancelButtonText: 'LABEL_NO',
598
            showCancelButton: true,
599
            confirmButtonText: 'LABEL_YES'
600
          }).then((result) => {
601
            if (result.isConfirmed) {
602
 
603
                    NProgress.start();
604
                    $.ajax({
605
                        'dataType'  : 'json',
606
                        'accept'    : 'application/json',
607
                        'method'    : 'post',
608
                        'url'       :  action,
609
                    }).done(function(response) {
610
                        if(response['success']) {
611
                            $.fn.showSuccess(response['data']);
612
                            gridTable.api().ajax.reload(null, false);
613
                        } else {
614
                            $.fn.showError(response['data']);
615
                        }
616
                    }).fail(function( jqXHR, textStatus, errorThrown) {
617
                        $.fn.showError(textStatus);
618
                    }).always(function() {
619
                        NProgress.done();
620
                    });
621
            }
622
       });
623
    });
624
 
625
    $('body').on('click', 'button.btn-unlimit', function(e) {
626
        e.preventDefault();
627
        var action = $(this).data('href');
628
 
629
 
630
          swal.fire({
631
            title: 'LABEL_ARE_YOU_SURE',
632
            icon: 'question',
633
            cancelButtonText: 'LABEL_NO',
634
            showCancelButton: true,
635
            confirmButtonText: 'LABEL_YES'
636
          }).then((result) => {
637
            if (result.isConfirmed) {
638
 
639
                    NProgress.start();
640
                    $.ajax({
641
                        'dataType'  : 'json',
642
                        'accept'    : 'application/json',
643
                        'method'    : 'post',
644
                        'url'       :  action,
645
                    }).done(function(response) {
646
                        if(response['success']) {
647
                            $.fn.showSuccess(response['data']);
648
                            gridTable.api().ajax.reload(null, false);
649
                        } else {
650
                            $.fn.showError(response['data']);
651
                        }
652
                    }).fail(function( jqXHR, textStatus, errorThrown) {
653
                        $.fn.showError(textStatus);
654
                    }).always(function() {
655
                        NProgress.done();
656
                    });
657
            }
658
       });
659
    });
1 www 660
});
661
JS;
662
$this->inlineScript()->captureEnd();
663
?>
664
 
16891 efrain 665
<div class="container">
666
	<div class="card" id="">
667
	 	<div class="card-header">
668
	 		<h6 class="card-title">LABEL_ACCESS_FOR_STUDENTS</h6>
669
	 	</div>
670
 
671
	 	<?php
1 www 672
                        $form = $this->form;
673
            	        $form->setAttributes([
674
                            'name'    => 'form-filter',
675
                            'id'      => 'form-filter',
676
                        ]);
677
 
678
                        $form->prepare();
679
                        echo $this->form()->openTag($form);
16891 efrain 680
                        ?>
681
 
682
	 	<div class="card-body">
683
	 		<div class="row">
684
                            <div class="col-6 mt-3 ">
685
 
1 www 686
                                    <?php
687
                                    $element = $form->get('topic_uuid');
688
 
689
                                    $element->setOptions(['label' => 'LABEL_TOPIC']);
690
 
691
                                    $element->setAttributes(['class' => 'form-control']);
692
                                    echo $this->formLabel($element);
693
                                    echo $this->formSelect($element);
694
                                    ?>
16891 efrain 695
 
1 www 696
                            </div>
16891 efrain 697
                            <div class="col-6 mt-3">
698
 
1 www 699
                                    <?php
700
                                    $element = $form->get('capsule_uuid');
701
                                    $element->setOptions(['label' => 'LABEL_CAPSULE']);
702
                                    $element->setAttributes(['class' => 'form-control']);
703
                                    echo $this->formLabel($element);
704
                                    echo $this->formSelect($element);
705
                                    ?>
16891 efrain 706
 
1 www 707
                            </div>
16891 efrain 708
	 		</div>
709
 
710
	 		<div class="row">
711
	 	         <div class="col-12 mt-3">
712
 
713
	 	         	<table id="gridTable" class="table   table-bordered">
1 www 714
                      		<thead>
715
        						<tr>
716
        							<th><input type="checkbox" id="chk-customer-all"></th>
717
                                	<th>LABEL_FIRST_NAME</th>
718
                                	<th>LABEL_LAST_NAME</th>
719
                                	<th>LABEL_EMAIL</th>
720
                                  	<th>LABEL_DETAILS</th>
721
                                  	<th>LABEL_ACTIONS</th>
722
                                </tr>
723
                       		</thead>
724
                         	<tbody>
725
                         	</tbody>
726
                    	</table>
16891 efrain 727
 
728
	 	         </div>
729
	 	     </div>
730
	 	</div>
731
	 	<div class="card-footer text-right">
17178 stevensc 732
	 	    <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-sync"></i> LABEL_REFRESH  </button>
733
            <?php if($allowUpload) : ?>
734
                <button type="button" class="btn btn-primary btn-upload"><i class="fa fa-upload"></i> LABEL_UPLOAD  </button>
735
            <?php endif; ?>
736
            <?php if($allowNotification) : ?>
737
                <button type="button" class="btn btn-primary btn-notification"><i class="fa fa-tablet"></i> LABEL_NOTIFICATION </button>
738
            <?php endif; ?>
16891 efrain 739
	 	</div>
740
	 	<?php echo $this->form()->closeTag($form); ?>
741
	</div>
742
</div>
1 www 743
 
16891 efrain 744
 
745
 
1 www 746
<!-- The Modal -->
747
<div class="modal" id="notificationPushModal">
748
	<div class="modal-dialog modal-sm">
749
    	<div class="modal-content">
750
 
751
            <!-- Modal Header -->
752
      		<div class="modal-header">
16845 efrain 753
        		<h6 class="modal-title">LABEL_PUSH_NOTIFICATION</h6>
16822 efrain 754
        		<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
1 www 755
      		</div>
756
 
16891 efrain 757
	<?php
1 www 758
				        $form = $this->formPushNotification;
759
                        $form->setAttributes([
760
                            'method'    => 'post',
761
                            'name'      => 'form-push-notification',
762
                            'id'        => 'form-push-notification',
763
                        ]);
764
 
765
                        $form->prepare();
766
                        echo $this->form()->openTag($form);
767
                        ?>
16891 efrain 768
      		<div class="modal-body">
769
 
770
                        <div class="row">
771
                        	<div class="col-12 mt-3">
1 www 772
                        	<?php
773
                            $element = $form->get('push_template_id');
774
                            $element->setAttributes([
775
                                'class' => 'form-control'
776
                            ]);
777
                            $element->setLabelAttributes([
778
                                'class' => 'form-label'
779
                            ]);
780
                            $element->setOptions([
781
                                'label' => 'LABEL_TYPE'
782
                            ]);
783
                            echo $this->formLabel($element);
784
                            echo $this->formSelect($element);
785
                            ?>
16891 efrain 786
                            </div>
1 www 787
    					</div>
788
 
16891 efrain 789
 
790
 
1 www 791
 
792
      		</div>
793
 
794
            <!-- Modal footer -->
16891 efrain 795
      		<div class="modal-footer text-right">
796
      		<button type="submit" class="btn btn-primary">LABEL_SEND</button>
1 www 797
        		<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
798
      		</div>
16891 efrain 799
      		<?php
800
                        echo $this->form()->closeTag($form);
801
                        ?>
1 www 802
 
803
    	</div>
804
	</div>
805
</div>
806
 
807
 
808
<!-- The Modal -->
809
<div class="modal" id="modalCapsuleCustomer">
810
	<div class="modal-dialog  modal-xl">
811
    	<div class="modal-content">
812
 
813
            <!-- Modal Header -->
814
      		<div class="modal-header">
16845 efrain 815
        		<h6 class="modal-title">LABEL_UPLOAD</h6>
16822 efrain 816
        		<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
1 www 817
      		</div>
818
 
16891 efrain 819
 <?php
1 www 820
                    $form = $this->formCapsuleCustomer;
821
            		$form->setAttributes([
822
                        'method'    => 'post',
823
                        'name'      => 'form-capsule-customer',
824
                        'id'        => 'form-capsule-customer'
825
                    ]);
826
 
827
                    $form->prepare();
828
                    echo $this->form()->openTag($form);
16891 efrain 829
                ?>
830
      		<div class="modal-body">
831
 
1 www 832
 
16891 efrain 833
				<div class="row">
834
                	<div class="col-12 mt-3">
1 www 835
 
836
                 		<?php
837
                        $element = $form->get('file');
838
                        $element->setOptions(['label' => 'LABEL_EXCEL']);
839
                        echo $this->formLabel($element);
840
                        ?>
841
                        <div class="file-loading">
842
                        <?php
16768 efrain 843
                        $element->setAttributes(['class' => 'form-control', 'accept' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel']);
1 www 844
                        echo $this->formFile($element);
845
                        ?>
16891 efrain 846
                        </div>
1 www 847
                	</div>
848
          		</div>
849
 
16891 efrain 850
 
1 www 851
      		</div>
852
 
853
            <!-- Modal footer -->
16891 efrain 854
      		<div class="modal-footer text-right">
855
      			<button type="submit" class="btn btn-primary">LABEL_UPLOAD</button>
1 www 856
        		<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
857
      		</div>
16891 efrain 858
      		<?php echo $this->form()->closeTag($form); ?>
1 www 859
 
860
    	</div>
861
	</div>
862
</div>
863
 
864
 
865
 
866
<!-- The Modal -->
867
<div class="modal" id="modalUploadCustomers">
868
	<div class="modal-dialog modal-xl">
869
    	<div class="modal-content">
870
 
871
            <!-- Modal Header -->
872
      		<div class="modal-header">
16845 efrain 873
        		<h6 class="modal-title">LABEL_CUSTOMERS</h6>
16822 efrain 874
        		<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
1 www 875
      		</div>
876
 
877
            <!-- Modal body -->
878
      		<div class="modal-body">
879
      			<form>
880
      				<input type="hidden" name="table-upload-customers-key" id="table-upload-customers-key">
16891 efrain 881
      				<div class="row">
882
      					<div class="col-12 mt-3">
1 www 883
      					<label>LABEL_TOPIC</label>
884
      					<input type="text" readonly="readonly" id="table-upload-customers-topic" class="form-control" >
16891 efrain 885
      					</div>
1 www 886
      				</div>
16891 efrain 887
      				<div class="row">
888
      					<div class="col-12 mt-3">
1 www 889
      					<label>LABEL_CAPSULE</label>
890
      					<input type="text" readonly="readonly" id="table-upload-customers-capsule" class="form-control" >
16891 efrain 891
      					</div>
1 www 892
      				</div>
893
      			</form>
15457 efrain 894
 
16891 efrain 895
      			<div class="row">
896
      				<div class="col-12 mt-3">
897
 
898
 
16983 efrain 899
      					<ul class="nav nav-tabs" id="myTab" role="tablist">
900
                  			<li class="nav-item">
901
                    			<a class="nav-link active" id="items-ok-tab" data-bs-toggle="tab" href="#items-ok" role="tab" aria-controls="items-ok" aria-selected="true">LABEL_USERS</a>
902
                  			</li>
903
                  			<li class="nav-item">
904
                    			<a class="nav-link" id="items-error-tab" data-bs-toggle="tab" href="#items-error" role="tab" aria-controls="items-error" aria-selected="false">LABEL_ERRORS</a>
905
                  			</li>
906
                		</ul>
907
                		<div class="tab-content border border-top-0 p-3" id="myTabContent">
908
                  			<div class="tab-pane fade show active" id="items-ok" role="tabpanel" aria-labelledby="items-ok-tab">
909
 
910
                  				<div style="height: 300px;overflow: scroll;">
911
                    				<table id="gridTableUploadOk" style="width: 100%" class="table table-bordered">
912
                                		<thead>
913
                                			<tr>
914
                                				<th>LABEL_ID</th>
915
                                          		<th>LABEL_FIRST_NAME</th>
916
                                         		<th>LABEL_LAST_NAME</th>
917
                                             	<th>LABEL_EMAIL</th>
918
                                           		<th>LABEL_CAPSULES</th>
919
                                 			</tr>
920
                                      	</thead>
921
                                   		<tbody>
922
                                   		</tbody>
923
                             		</table>
924
                         		</div>
925
 
926
                  			</div>
927
                 			<div class="tab-pane fade" id="items-error" role="tabpanel" aria-labelledby="items-error-tab">
928
                 				<div style="height: 300px;overflow: scroll;">
929
                    				<table id="gridTableUploadError" style="width: 100%" class="table table-bordered">
930
                                		<thead>
931
                                			<tr>
932
                                				<th>LABEL_ID</th>
933
                                          		<th>LABEL_FIRST_NAME</th>
934
                                         		<th>LABEL_LAST_NAME</th>
935
                                             	<th>LABEL_EMAIL</th>
936
                                             	<th>LABEL_STATUS</th>
937
                                 			</tr>
938
                                      	</thead>
939
                                   		<tbody>
940
                                   		</tbody>
941
                             		</table>
942
                         		</div>
943
 
944
                 			</div>
945
                		</div>
946
 
947
 
948
 
16891 efrain 949
      				</div>
950
      			</div>
951
 
1 www 952
 
953
      		</div>
954
 
955
            <!-- Modal footer -->
16891 efrain 956
      		<div class="modal-footer text-right">
1 www 957
      			<button type="submit" class="btn btn-primary btn-upload-customers-step2">LABEL_SAVE</button>
958
        		<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
959
      		</div>
960
 
961
    	</div>
962
	</div>
963
</div>
964
 
965
 
966
 
967
 
968