Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 17250 | 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']  ) {
17272 stevensc 269
                            s = s + '<button class="btn btn-danger btn-sm btn-revoke" data-action"' + data['link_revoke']+ '" data-toggle="tooltip" title="LABEL_REVOKE"><i class="fa fa-times"></i> LABEL_REVOKE </button>&nbsp;';
1 www 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
 
17272 stevensc 288
    $('body').on('click', 'button.btn-revoke', function(e) {
289
        e.preventDefault();
290
        var action = $(this).data('action');
291
 
292
        swal.fire({
293
            title: 'LABEL_ARE_YOU_SURE',
294
            icon: 'question',
295
            cancelButtonText: 'LABEL_NO',
296
            showCancelButton: true,
297
            confirmButtonText: 'LABEL_YES'
298
          }).then((result) => {
299
            if (result.isConfirmed) {
300
                $.ajax({
301
                    'dataType'  : 'json',
302
                    'accept'    : 'application/json',
303
                    'method'    : 'post',
304
                    'url'       : action
305
                }).done(function(response) {
306
                    if(response['success']) {
307
                        $.fn.showSuccess(response['data']);
308
                        gridTable.api().ajax.reload(null, false);
309
                    } else {
310
                        $.fn.showError(response['data']);
311
                    }
312
                }).fail(function( jqXHR, textStatus, errorThrown) {
313
                    $.fn.showError(textStatus);
314
                }).always(function() {
315
                    NProgress.done();
316
                });
317
            }
318
        });
1 www 319
 
17272 stevensc 320
        return false;
321
    });
322
 
323
 
1 www 324
    $('body').on('click', 'button.btn-notification', function(e) {
325
        e.preventDefault();
326
 
327
        var customer_uuids = [];
328
        $.each($('input[type="checkbox"].chk-customer:checked'), function(index, element) {
329
            customer_uuids.push($(this).val());
330
        });
331
 
332
        if(customer_uuids.length == 0) {
333
            $.fn.showError('ERROR_NOT_SELECTED_CUSTOMERS');
334
            return;
335
        }
336
 
337
        var href = $(this).data('href');
338
        $('#notificationPushModal').modal('show');
339
        $('#form-push-notification').attr('action', href);
340
 
341
    });
342
 
343
 
344
    $('#chk-customer-all').click(function(e) {
345
       // e.preventDefault();
346
 
347
        var checked = $(this).prop('checked');
348
        $.each($('input[type="checkbox"].chk-customer'), function(index, element) {
349
           $(this).prop('checked', checked);
350
        });
351
 
352
 
353
    });
354
 
355
    $('body').on('click', 'input[type="checkbox"].chk-customer', function(e) {
356
        var checked = $(this).prop('checked');
357
        if(!checked) {
358
            $('#chk-customer-all').prop('checked', false );
359
        }
360
    });
361
 
17250 stevensc 362
    var validatorPushNotification = $('#form-push-notification').validate({
1 www 363
        debug: true,
364
        onclick: false,
365
        onkeyup: false,
366
        onfocusout: false,
367
        ignore: [],
368
        rules: {
369
            'push_template_id' : {
370
                required: true,
371
 
372
            },
373
        },
374
 
375
        submitHandler: function(form)
376
        {
377
            var customer_uuids = [];
378
            $.each($('input[type="checkbox"].chk-customer:checked'), function(index, element) {
379
                customer_uuids.push($(this).val());
380
            });
381
 
382
            if(customer_uuids.length == 0) {
383
                $.fn.showError('ERROR_NOT_SELECTED_CUSTOMERS');
384
                return;
385
            }
386
 
387
            var push_template_id = $('#form-push-notification #push_template_id').val();
388
 
389
            $('input[type="submit"]').prop('disabled', true);
390
            NProgress.start();
391
            $.ajax({
392
                'dataType'  : 'json',
393
                'accept'    : 'application/json',
394
                'method'    : 'post',
395
                'url'       : routeNotification,
396
                'data'      : {
397
                    'push_template_id' : push_template_id,
398
                    'customer_uuids' : customer_uuids
399
 
400
                },
401
            }).done(function(response) {
402
                if(response['success']) {
403
                    if(response['data']['push_to_send'] == 1) {
404
                        $.fn.showSuccess(response['data']['push_to_send'] + ' LABEL_PUSH_IN_QUEUE');
405
                    } else {
406
                        $.fn.showSuccess(response['data']['push_to_send'] + ' LABEL_PUSHES_IN_QUEUE');
407
                    }
408
 
409
 
410
                    $('#notificationPushModal').modal('hide');
411
                } else {
412
                    validatorPushNotification.resetForm();
413
                    if(jQuery.type(response['data']) == 'string') {
414
                        $.fn.showError(response['data']);
415
                    } else  {
416
                        $.each(response['data'], function( fieldname, errors ) {
417
                            $.fn.showFormErrorValidator('#form-push-notification #' + fieldname, errors);
418
                        });
419
                    }
420
                }
421
            }).fail(function( jqXHR, textStatus, errorThrown) {
422
                $.fn.showError(textStatus);
423
            }).always(function() {
424
 
425
                NProgress.done();
426
            });
427
            return false;
428
        },
429
        invalidHandler: function(form, validator) {
430
 
431
        }
432
    });
433
 
434
 
17248 stevensc 435
    var validatorTopicCustomer = $('#form-topic-customer').validate({
1 www 436
        debug: true,
437
        onclick: false,
438
        onkeyup: false,
439
        onfocusout: false,
440
        ignore: [],
441
        rules: {
442
            'file' : {
443
                required: true,
444
                extension: 'xls|xlsx',
445
                accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel'
446
            },
447
        },
448
 
449
        submitHandler: function(form)
450
        {
451
            NProgress.start();
452
            var formdata = false;
453
            if (window.FormData){
454
                formdata = new FormData(form);
455
            }
456
            formdata.append('step','validation');
457
 
458
 
459
            $.ajax({
460
                'dataType'  : 'json',
461
                'accept'    : 'application/json',
462
                'method'    : 'post',
463
                'url'       :  routeUpload,
464
                'data'      :  formdata,
465
                'processData': false,
466
                'contentType': false,
467
            }).done(function(response) {
468
                if(response['success']) {
469
 
470
                    $('#table-upload-customers-key').val(response['data']['key']);
471
                    $('#table-upload-customers-topic').val(response['data']['topic']);
472
 
16983 efrain 473
                    $('#gridTableUploadOk tbody').empty();
1 www 474
 
16983 efrain 475
                    $.each(response['data']['items']['ok'], function(index, item) {
1 www 476
 
477
 
478
                        var s = '<tr>';
16983 efrain 479
                        s = s + '<td>' + item['id'] + '</td>';
1 www 480
                        s = s + '<td>' + item['first_name'] + '</td>';
481
                        s = s + '<td>' + item['last_name'] + '</td>';
482
                        s = s + '<td>' + item['email'] + '</td>';
17248 stevensc 483
                        s = s + '<td class="text-right">' + item['assigned_topics'] + '</td>';
1 www 484
                        s = s + '</tr>';
485
 
16983 efrain 486
                        $('#gridTableUploadOk tbody').append(s);
1 www 487
 
488
 
16983 efrain 489
                    });
490
 
491
                    $.each(response['data']['items']['error'], function(index, item) {
1 www 492
 
16983 efrain 493
 
494
                        var s = '<tr>';
495
                        s = s + '<td>' + item['id'] + '</td>';
496
                        s = s + '<td>' + item['first_name'] + '</td>';
497
                        s = s + '<td>' + item['last_name'] + '</td>';
498
                        s = s + '<td>' + item['email'] + '</td>';
499
                        s = s + '<td>' + item['status'] + '</td>';
500
                        s = s + '</tr>';
501
 
502
                        $('#gridTableUploadError tbody').append(s);
503
 
504
 
505
                    });
506
 
17248 stevensc 507
                    $('#modalTopicCustomer').modal('hide');
1 www 508
                    $('#modalUploadCustomers').modal('show');
509
 
510
 
511
 
512
                } else {
17248 stevensc 513
                    validatorTopicCustomer.resetForm();
1 www 514
                    if(jQuery.type(response['data']) == 'string') {
515
                        $.fn.showError(response['data']);
516
                    } else  {
517
                        $.each(response['data'], function( fieldname, errors ) {
17248 stevensc 518
                            $.fn.showFormErrorValidator('#form-topic-customer #' + fieldname, errors);
1 www 519
                        });
520
                    }
521
                }
522
            }).fail(function( jqXHR, textStatus, errorThrown) {
523
                $.fn.showError(textStatus);
524
            }).always(function() {
525
 
526
                NProgress.done();
527
            });
528
            return false;
529
        },
530
        invalidHandler: function(form, validator) {
531
 
532
        }
533
    });
534
 
17250 stevensc 535
    $('#form-filter #topic_uuid').change(function(e) {
536
        e.preventDefault();
537
        gridTable.api().ajax.reload(null, false);
538
    })
1 www 539
 
17248 stevensc 540
    $('#form-topic-customer #file').fileinput({
1 www 541
        theme: 'fas',
542
        language: 'es',
543
        showUpload: false,
544
        dropZoneEnabled: false,
545
        maxFileCount: 1,
546
        allowedFileExtensions: ['xls', 'xlsx'],
547
    });
548
 
549
    $('body').on('click', 'button.btn-upload', function(e) {
550
        e.preventDefault();
551
 
17248 stevensc 552
        $('#form-topic-customer #file').fileinput('reset');
553
        $('#form-topic-customer #file').val('');
1 www 554
 
17248 stevensc 555
        $('#modalTopicCustomer').modal('show');
1 www 556
    });
557
 
558
    $('body').on('click', 'button.btn-upload-customers-step2', function(e) {
559
        e.preventDefault();
560
        NProgress.start();
561
 
562
        $.ajax({
563
            'dataType'  : 'json',
564
            'accept'    : 'application/json',
565
            'method'    : 'post',
566
            'url'       :  routeUpload,
567
            'data'      :  {
568
                'step' : 'process',
569
                'key' : $('#table-upload-customers-key').val(),
570
            }
571
        }).done(function(response) {
572
            if(response['success']) {
15457 efrain 573
 
16983 efrain 574
                var anchor = window.document.createElement("a");
575
                anchor.href = 'data:application/octet-stream;charset=utf-8;base64,' + response['data']['csv_base64_content'] ;
576
                anchor.download = response['data']['csv_filename'];
577
                document.body.appendChild(anchor);
578
                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
579
                document.body.removeChild(anchor);
580
 
15457 efrain 581
                var s = response['data']['users_processed'] + ' LABEL_USTUDENTS_PROCESED <br>' +
582
                response['data']['users_assigned'] + ' LABEL_STUDENTS_ASSIGNED <br>' +
583
                response['data']['users_previous'] + ' LABEL_USTUDENTS_PREVIOUS <br>' +
17248 stevensc 584
                response['data']['users_in_the_topic'] + ' LABEL_STUDENTS_TOTAL';
15457 efrain 585
 
586
                $.fn.showSuccess(s);
587
 
1 www 588
                 gridTable.api().ajax.reload(null, false);
589
                $('#modalUploadCustomers').modal('hide');
590
            } else {
591
                $.fn.showError(response['data']);
592
            }
593
        }).fail(function( jqXHR, textStatus, errorThrown) {
594
            $.fn.showError(textStatus);
595
        }).always(function() {
596
            NProgress.done();
597
        });
598
        return false;
599
    });
600
 
601
    $('body').on('click', 'button.btn-refresh', function(e) {
602
        e.preventDefault();
603
        gridTable.api().ajax.reload(null, false);
604
    });
16822 efrain 605
 
606
     $('body').on('click', 'button.btn-delete', function(e) {
607
        e.preventDefault();
608
        var action = $(this).data('href');
609
 
610
 
611
          swal.fire({
612
            title: 'LABEL_ARE_YOU_SURE',
613
            icon: 'question',
614
            cancelButtonText: 'LABEL_NO',
615
            showCancelButton: true,
616
            confirmButtonText: 'LABEL_YES'
617
          }).then((result) => {
618
            if (result.isConfirmed) {
619
 
620
                    NProgress.start();
621
                    $.ajax({
622
                        'dataType'  : 'json',
623
                        'accept'    : 'application/json',
624
                        'method'    : 'post',
625
                        'url'       :  action,
626
                    }).done(function(response) {
627
                        if(response['success']) {
628
                            $.fn.showSuccess(response['data']);
629
                            gridTable.api().ajax.reload(null, false);
630
                        } else {
631
                            $.fn.showError(response['data']);
632
                        }
633
                    }).fail(function( jqXHR, textStatus, errorThrown) {
634
                        $.fn.showError(textStatus);
635
                    }).always(function() {
636
                        NProgress.done();
637
                    });
638
            }
639
       });
640
    });
641
 
642
    $('body').on('click', 'button.btn-unlimit', function(e) {
643
        e.preventDefault();
644
        var action = $(this).data('href');
645
 
646
 
647
          swal.fire({
648
            title: 'LABEL_ARE_YOU_SURE',
649
            icon: 'question',
650
            cancelButtonText: 'LABEL_NO',
651
            showCancelButton: true,
652
            confirmButtonText: 'LABEL_YES'
653
          }).then((result) => {
654
            if (result.isConfirmed) {
655
 
656
                    NProgress.start();
657
                    $.ajax({
658
                        'dataType'  : 'json',
659
                        'accept'    : 'application/json',
660
                        'method'    : 'post',
661
                        'url'       :  action,
662
                    }).done(function(response) {
663
                        if(response['success']) {
664
                            $.fn.showSuccess(response['data']);
665
                            gridTable.api().ajax.reload(null, false);
666
                        } else {
667
                            $.fn.showError(response['data']);
668
                        }
669
                    }).fail(function( jqXHR, textStatus, errorThrown) {
670
                        $.fn.showError(textStatus);
671
                    }).always(function() {
672
                        NProgress.done();
673
                    });
674
            }
675
       });
676
    });
1 www 677
});
678
JS;
679
$this->inlineScript()->captureEnd();
680
?>
681
 
16891 efrain 682
<div class="container">
683
	<div class="card" id="">
684
	 	<div class="card-header">
685
	 		<h6 class="card-title">LABEL_ACCESS_FOR_STUDENTS</h6>
686
	 	</div>
687
 
688
	 	<?php
1 www 689
                        $form = $this->form;
690
            	        $form->setAttributes([
691
                            'name'    => 'form-filter',
692
                            'id'      => 'form-filter',
693
                        ]);
694
 
695
                        $form->prepare();
696
                        echo $this->form()->openTag($form);
16891 efrain 697
                        ?>
698
 
699
	 	<div class="card-body">
700
	 		<div class="row">
701
                            <div class="col-6 mt-3 ">
702
 
1 www 703
                                    <?php
704
                                    $element = $form->get('topic_uuid');
705
 
706
                                    $element->setOptions(['label' => 'LABEL_TOPIC']);
707
 
708
                                    $element->setAttributes(['class' => 'form-control']);
709
                                    echo $this->formLabel($element);
710
                                    echo $this->formSelect($element);
711
                                    ?>
16891 efrain 712
 
1 www 713
                            </div>
16891 efrain 714
	 		</div>
715
 
716
	 		<div class="row">
717
	 	         <div class="col-12 mt-3">
718
 
719
	 	         	<table id="gridTable" class="table   table-bordered">
1 www 720
                      		<thead>
721
        						<tr>
722
        							<th><input type="checkbox" id="chk-customer-all"></th>
723
                                	<th>LABEL_FIRST_NAME</th>
724
                                	<th>LABEL_LAST_NAME</th>
725
                                	<th>LABEL_EMAIL</th>
726
                                  	<th>LABEL_DETAILS</th>
727
                                  	<th>LABEL_ACTIONS</th>
728
                                </tr>
729
                       		</thead>
730
                         	<tbody>
731
                         	</tbody>
732
                    	</table>
16891 efrain 733
 
734
	 	         </div>
735
	 	     </div>
736
	 	</div>
737
	 	<div class="card-footer text-right">
17178 stevensc 738
	 	    <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-sync"></i> LABEL_REFRESH  </button>
739
            <?php if($allowUpload) : ?>
740
                <button type="button" class="btn btn-primary btn-upload"><i class="fa fa-upload"></i> LABEL_UPLOAD  </button>
741
            <?php endif; ?>
742
            <?php if($allowNotification) : ?>
743
                <button type="button" class="btn btn-primary btn-notification"><i class="fa fa-tablet"></i> LABEL_NOTIFICATION </button>
744
            <?php endif; ?>
16891 efrain 745
	 	</div>
746
	 	<?php echo $this->form()->closeTag($form); ?>
747
	</div>
748
</div>
1 www 749
 
16891 efrain 750
 
751
 
1 www 752
<!-- The Modal -->
753
<div class="modal" id="notificationPushModal">
754
	<div class="modal-dialog modal-sm">
755
    	<div class="modal-content">
756
 
757
            <!-- Modal Header -->
758
      		<div class="modal-header">
16845 efrain 759
        		<h6 class="modal-title">LABEL_PUSH_NOTIFICATION</h6>
16822 efrain 760
        		<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
1 www 761
      		</div>
762
 
16891 efrain 763
	<?php
1 www 764
				        $form = $this->formPushNotification;
765
                        $form->setAttributes([
766
                            'method'    => 'post',
767
                            'name'      => 'form-push-notification',
768
                            'id'        => 'form-push-notification',
769
                        ]);
770
 
771
                        $form->prepare();
772
                        echo $this->form()->openTag($form);
773
                        ?>
16891 efrain 774
      		<div class="modal-body">
775
 
776
                        <div class="row">
777
                        	<div class="col-12 mt-3">
1 www 778
                        	<?php
779
                            $element = $form->get('push_template_id');
780
                            $element->setAttributes([
781
                                'class' => 'form-control'
782
                            ]);
783
                            $element->setLabelAttributes([
784
                                'class' => 'form-label'
785
                            ]);
786
                            $element->setOptions([
787
                                'label' => 'LABEL_TYPE'
788
                            ]);
789
                            echo $this->formLabel($element);
790
                            echo $this->formSelect($element);
791
                            ?>
16891 efrain 792
                            </div>
1 www 793
    					</div>
794
 
16891 efrain 795
 
796
 
1 www 797
 
798
      		</div>
799
 
800
            <!-- Modal footer -->
16891 efrain 801
      		<div class="modal-footer text-right">
802
      		<button type="submit" class="btn btn-primary">LABEL_SEND</button>
1 www 803
        		<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
804
      		</div>
16891 efrain 805
      		<?php
806
                        echo $this->form()->closeTag($form);
807
                        ?>
1 www 808
 
809
    	</div>
810
	</div>
811
</div>
812
 
813
 
814
<!-- The Modal -->
17248 stevensc 815
<div class="modal" id="modalTopicCustomer">
1 www 816
	<div class="modal-dialog  modal-xl">
817
    	<div class="modal-content">
818
 
819
            <!-- Modal Header -->
820
      		<div class="modal-header">
16845 efrain 821
        		<h6 class="modal-title">LABEL_UPLOAD</h6>
16822 efrain 822
        		<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
1 www 823
      		</div>
824
 
16891 efrain 825
 <?php
17248 stevensc 826
                    $form = $this->formTopicCustomer;
1 www 827
            		$form->setAttributes([
828
                        'method'    => 'post',
17248 stevensc 829
                        'name'      => 'form-topic-customer',
830
                        'id'        => 'form-topic-customer'
1 www 831
                    ]);
832
 
833
                    $form->prepare();
834
                    echo $this->form()->openTag($form);
16891 efrain 835
                ?>
836
      		<div class="modal-body">
837
 
1 www 838
 
16891 efrain 839
				<div class="row">
840
                	<div class="col-12 mt-3">
1 www 841
 
842
                 		<?php
843
                        $element = $form->get('file');
844
                        $element->setOptions(['label' => 'LABEL_EXCEL']);
845
                        echo $this->formLabel($element);
846
                        ?>
847
                        <div class="file-loading">
848
                        <?php
16768 efrain 849
                        $element->setAttributes(['class' => 'form-control', 'accept' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel']);
1 www 850
                        echo $this->formFile($element);
851
                        ?>
16891 efrain 852
                        </div>
1 www 853
                	</div>
854
          		</div>
855
 
16891 efrain 856
 
1 www 857
      		</div>
858
 
859
            <!-- Modal footer -->
16891 efrain 860
      		<div class="modal-footer text-right">
861
      			<button type="submit" class="btn btn-primary">LABEL_UPLOAD</button>
1 www 862
        		<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
863
      		</div>
16891 efrain 864
      		<?php echo $this->form()->closeTag($form); ?>
1 www 865
 
866
    	</div>
867
	</div>
868
</div>
869
 
870
 
871
 
872
<!-- The Modal -->
873
<div class="modal" id="modalUploadCustomers">
874
	<div class="modal-dialog modal-xl">
875
    	<div class="modal-content">
876
 
877
            <!-- Modal Header -->
878
      		<div class="modal-header">
16845 efrain 879
        		<h6 class="modal-title">LABEL_CUSTOMERS</h6>
16822 efrain 880
        		<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
1 www 881
      		</div>
882
 
883
            <!-- Modal body -->
884
      		<div class="modal-body">
885
      			<form>
886
      				<input type="hidden" name="table-upload-customers-key" id="table-upload-customers-key">
16891 efrain 887
      				<div class="row">
888
      					<div class="col-12 mt-3">
1 www 889
      					<label>LABEL_TOPIC</label>
890
      					<input type="text" readonly="readonly" id="table-upload-customers-topic" 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>
17248 stevensc 918
                                           		<th>LABEL_TOPICS</th>
16983 efrain 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