Proyectos de Subversion LeadersLinked - Backend

Rev

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