Proyectos de Subversion LeadersLinked - Backend

Rev

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