Proyectos de Subversion LeadersLinked - Backend

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
17003 efrain 1
<?php
2
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser    = $this->currentUserHelper();
4
 
5
$roleName = $currentUser->getUserTypeId();
6
 
7
 
8
 
9
$routeDatatable = $this->url('microlearning/content/capsules');
10
 
11
$allowAdd       = $acl->isAllowed($roleName, 'microlearning/content/capsules/add') ? 1 : 0;
12
$allowEdit      = $acl->isAllowed($roleName, 'microlearning/content/capsules/edit') ? 1 : 0;
13
$allowDelete    = $acl->isAllowed($roleName, 'microlearning/content/capsules/delete') ? 1 : 0;
14
$allowUsers     = $acl->isAllowed($roleName, 'microlearning/content/capsules/users') ? 1 : 0;
15
 
16
 
17
 
18
 
19
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
20
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
21
 
22
$this->inlineScript()->appendFile($this->basePath('assets/vendors/ckeditor/ckeditor.js'));
23
 
24
 
25
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-fileinput/css/fileinput.min.css'));
26
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-fileinput/themes/explorer-fas/theme.css'));
27
 
28
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/plugins/piexif.js'));
29
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/plugins/sortable.js'));
30
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/fileinput.js'));
31
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/locales/es.js'));
32
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/themes/fas/theme.js'));
33
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/themes/explorer-fas/theme.js'));
34
 
35
 
36
 
37
 
38
 
39
 
40
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));
41
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.css'));
42
 
43
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
44
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));
45
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/dataTables.responsive.min.js'));
46
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.min.js'));
47
 
48
 
49
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
50
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
51
 
52
 
53
 
54
 
55
 
56
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-input-number/input-number-format.jquery.js'));
57
 
58
 
59
$this->headStyle()->captureStart();
60
echo <<<CSS
61
 
62
 
63
#gridTableUsers {
64
    display: flex;
65
    flex-flow: column;
66
    width: 100%;
67
}
68
 
69
#gridTableUsers thead {
70
    flex: 0 0 auto;
71
}
72
 
73
#gridTableUsers tbody {
74
    flex: 1 1 auto;
75
    display: block;
76
    overflow-y: auto;
77
    overflow-x: hidden;
78
}
79
 
80
#gridTableUsers tr {
81
    width: 100%;
82
    display: table;
83
    table-layout: fixed;
84
}
85
.imagen-contaner{
86
	border:1px solid rgb(200,200,200);
87
	border-radius:5px;
88
	padding:10px;
89
	display:flex;
90
	flex-flow:column;
91
	align-items:center;
92
}
93
CSS;
94
$this->headStyle()->captureEnd();
95
 
96
$this->headLink()->captureStart();
97
 
98
$this->inlineScript()->captureStart();
99
echo <<<JS
100
    jQuery( document ).ready(function( $ ) {
101
 
102
        $.validator.setDefaults({
103
            debug: true,
104
            highlight: function(element) {
105
                $(element).addClass('is-invalid');
106
            },
107
            unhighlight: function(element) {
108
                $(element).removeClass('is-invalid');
109
            },
110
            errorElement: 'span',
111
            errorClass: 'error invalid-feedback',
112
            errorPlacement: function(error, element) {
113
                if(element.parent('.btn-file').length) {
114
                    error.insertAfter(element.parent().parent());
115
                } else if(element.parent('.toggle').length) {
116
                    error.insertAfter(element.parent().parent());
117
                } else {
118
                    error.insertAfter(element.parent());
119
                }
120
            }
121
        });
122
 
123
 
124
 
125
 
126
        var allowEdit   = $allowEdit;
127
        var allowDelete = $allowDelete;
128
        var allowUsers  = $allowUsers;
129
 
130
 
131
        var gridTable = $('#gridTable').dataTable( {
132
            'processing': true,
133
            'serverSide': true,
134
            'searching': true,
135
            'order': [[ 0, 'asc' ]],
136
            'ordering':  true,
137
            'ordenable' : true,
138
            'responsive': true,
139
            'select' : false,
140
        	'paging': true,
141
            'pagingType': 'simple_numbers',
142
 
143
    		'ajax': {
144
    			'url' : '$routeDatatable',
145
    			'type' : 'get',
146
                'beforeSend': function (request) {
147
                  NProgress.start();
148
                },
149
                'dataFilter': function(response) {
150
                    var response = jQuery.parseJSON( response );
151
 
152
                    var json                = {};
153
                    json.recordsTotal       = 0;
154
                    json.recordsFiltered    = 0;
155
                    json.data               = [];
156
 
157
                    if(response.success) {
158
                        $('#form-add').attr('action', response.data.link_add );
159
 
160
                        json.recordsTotal       = response.data.total;
161
                        json.recordsFiltered    = response.data.total;
162
                        json.data               = response.data.items;
163
                    } else {
164
                        $.fn.showError(response.data)
165
                    }
166
 
167
                    return JSON.stringify( json );
168
                }
169
    		},
170
            'language' : {
171
                'sProcessing':     'LABEL_DATATABLE_SPROCESSING',
172
                'sLengthMenu':     'LABEL_DATATABLE_SLENGTHMENU',
173
                'sZeroRecords':    'LABEL_DATATABLE_SZERORECORDS',
174
                'sEmptyTable':     'LABEL_DATATABLE_SEMPTYTABLE',
175
                'sInfo':           'LABEL_DATATABLE_SINFO',
176
                'sInfoEmpty':      'LABEL_DATATABLE_SINFOEMPTY',
177
                'sInfoFiltered':   'LABEL_DATATABLE_SINFOFILTERED',
178
                'sInfoPostFix':    '',
179
                'sSearch':         'LABEL_DATATABLE_SSEARCH',
180
                'sUrl':            '',
181
                'sInfoThousands':  ',',
182
                'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
183
                'oPaginate': {
184
                    'sFirst':    'LABEL_DATATABLE_SFIRST',
185
                    'sLast':     'LABEL_DATATABLE_SLAST',
186
                    'sNext':     'LABEL_DATATABLE_SNEXT',
187
                    'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
188
                },
189
                'oAria': {
190
                    'sSortAscending':  ': LABEL_DATATABLE_SSORTASCENDING',
191
                    'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
192
                },
193
            },
194
            'drawCallback': function( settings ) {
195
                NProgress.done();
196
 
197
            },
198
            'aoColumns': [
199
                { 'mDataProp': 'name' },
200
                { 'mDataProp': 'details' },
201
                { 'mDataProp': 'images' },
202
                { 'mDataProp': 'actions' },
203
    	    ],
204
            'columnDefs': [
205
                {
206
                    'targets': 0,
207
                    'className' : 'text-vertical-middle',
208
                },
209
                {
210
                    'targets': -3,
211
                    'orderable': false,
212
                    'render' : function ( data, type, row ) {
213
                        var s = '';
214
                        s += 'LABEL_STATUS: ' + data['status']  + '<br/>';
215
 
216
                         if(allowUsers && row['actions']['link_total_users']  ) {
217
                            s += 'LABEL_TOTAL_USERS: ' + data['total_users']  + ' <button class="btn btn-view-total-users" data-href="' + row['actions']['link_total_users'] + '" data-toggle="tooltip" title="LABEL_VIEW"><i class="fa fa-external-link-alt"></i></button> <br>';
218
                         } else {
219
                            s += 'LABEL_TOTAL_USERS: ' + data['total_users']  + '<br/>';
220
                         }
221
                         if(allowUsers && row['actions']['link_total_users_actives']  ) {
222
                            s += 'LABEL_TOTAL_USERS_ACTIVE: ' + data['total_users_active']  + ' <button class="btn btn-view-total-users" data-href="' + row['actions']['link_total_users_actives'] + '" data-toggle="tooltip" title="LABEL_VIEW"><i class="fa fa-external-link-alt"></i></button> <br>';
223
                         } else {
224
                            s += 'LABEL_TOTAL_USERS_ACTIVE: ' + data['total_users_active']  + '<br/>';
225
                         }
226
 
227
                        return s;
228
                    }
229
                },
230
                {
231
                    'targets': -2,
232
                    'orderable': false,
233
                    'render' : function ( data, type, row ) {
234
                        s = '';
235
 
236
						if( data['marketplace'] )  {
237
                            s = s + '&nbsp; <img class="btn-view-image-marketplace" data-href="' + data['marketplace'] + '" data-toggle="tooltip" src="'+data['marketplace']+'" title="LABEL_VIEW" style="width: 40px; object-fit: cover; height: 40px;" /> '
238
                        }  else {
239
                            s = s + '';
240
                        }
241
 
242
                        if( data['image'] )  {
243
                            s = s + '&nbsp; <img class="btn-view-image-app" data-href="' + data['image'] + '" data-toggle="tooltip" src="'+data['image']+'" title="LABEL_VIEW" style="width: 40px; object-fit: cover; height: 40px;" /> '
244
                        }  else {
245
                            s = s + '';
246
                        }
247
 
248
 
249
 
250
 
251
 
252
                        return s;
253
                    }
254
                },
255
 
256
 
257
                {
258
                    'targets': -1,
259
                    'orderable': false,
260
                    'render' : function ( data, type, row ) {
261
                        s = '';
262
 
263
                        if(allowEdit && data['link_edit']  ) {
264
                            s = s + '<button class="btn btn-info btn-sm btn-edit" data-href="' + data['link_edit']+ '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pen"></i> LABEL_EDIT </button>&nbsp;';
265
                        }
266
                        if(allowDelete && data['link_delete']  ) {
267
                            s = s + '<button class="btn btn-danger btn-sm btn-delete" data-href="' + data['link_delete']+ '" data-toggle="tooltip" title="LABEL_DELETE"><i class="fa fa-trash"></i> LABEL_DELETE </button>&nbsp;';
268
                        }
269
 
270
                        return s;
271
                    }
272
                }
273
              ],
274
        });
275
 
276
 
277
        var seleccionarCampo;
278
    var validatorAdd = $('#form-add').validate({
279
        debug: true,
280
        onclick: false,
281
        onkeyup: false,
282
        ignore: [],
283
        rules: {
284
            'name': {
285
                required: true,
286
                maxlength: 128,
287
            },
288
            'description': {
289
                updateCkeditor:function() {
290
                        CKEDITOR.instances.description_add.updateElement();
291
                },
292
                required: true
293
            },
294
           'file': {
295
                required: true,
296
                extension: 'jpg|jpeg|png',
297
                accept: 'image/jpg,image/jpeg,image/png'
298
            },
299
            'order' : {
300
                required: true,
301
                digits: true,
302
                min: 1,
303
                max: 250
304
            },
305
           'marketplace': {
306
                required: false,
307
                extension: 'jpg|jpeg|png',
308
                accept: 'image/jpg,image/jpeg,image/png'
309
            },
310
            'status' : {
311
                required: true,
312
            },
313
            'privacy' : {
314
                required: true,
315
            },
316
            'type' : {
317
                required: true,
318
            },
319
            'cost' : {
320
                required: function() {
321
                    return $('#form-add #type').val() == 's';
322
                },
323
                'number' : true,
324
                'min' : 0
325
            }
326
        },
327
        submitHandler: function(form)
328
        {
329
            var formdata = false;
330
            if (window.FormData){
331
                formdata = new FormData(form); //form[0]);
332
            }
333
 
334
 
335
			NProgress.start();
336
            $.ajax({
337
                'dataType'  : 'json',
338
                'accept'    : 'application/json',
339
                'method'    : 'post',
340
                'url'       :  $('#form-add').attr('action'),
341
                'data'      :  formdata,
342
                'processData': false,
343
                'contentType': false,
344
            }).done(function(response) {
345
                if(response['success']) {
346
                    $.fn.showSuccess(response['data']);
347
 
348
					gridTable.api().ajax.reload(null, false);
349
 
350
                    $('#row-add').hide();
351
                    $('#row-edit').hide();
352
                    $('#row-listing').show();
353
 
354
 
355
                } else {
356
                    validatorAdd.resetForm();
357
                    if(jQuery.type(response['data']) == 'string') {
358
                        $.fn.showError(response['data']);
359
                    } else  {
360
                        $.each(response['data'], function( fieldname, errors ) {
361
                            $.fn.showFormErrorValidator('#form-add #' + fieldname, errors);
362
                        });
363
                    }
364
                }
365
            }).fail(function( jqXHR, textStatus, errorThrown) {
366
				console.log(jqXHR)
367
                $.fn.showError(textStatus);
368
            }).always(function() {
369
 
370
                NProgress.done();
371
            });
372
            return false;
373
        },
374
        invalidHandler: function(form, validator) {
375
 
376
        }
377
    });
378
 
379
    var validatorEdit  = $('#form-edit').validate({
380
        debug: true,
381
        onclick: false,
382
        onkeyup: false,
383
        ignore: [],
384
        rules: {
385
              'name': {
386
                required: true,
387
                maxlength: 128,
388
            },
389
            'description': {
390
                updateCkeditor:function() {
391
                        CKEDITOR.instances.description_edit.updateElement();
392
                },
393
                required: true
394
            },
395
           'file': {
396
                required: false,
397
                extension: 'jpg|jpeg|png',
398
                accept: 'image/jpg,image/jpeg,image/png'
399
            },
400
            'order' : {
401
                required: true,
402
                digits: true,
403
                min: 1,
404
                max: 250
405
            },
406
           'marketplace': {
407
                required: false,
408
                extension: 'jpg|jpeg|png',
409
                accept: 'image/jpg,image/jpeg,image/png'
410
            },
411
            'status' : {
412
                required: true,
413
            },
414
            'privacy' : {
415
                required: true,
416
            },
417
            'type' : {
418
                required: true,
419
            },
420
            'cost' : {
421
                required: function() {
422
                    return $('#form-edit #type').val() == 's';
423
                },
424
                'number' : true,
425
                'min' : 0
426
            }
427
        },
428
        submitHandler: function(form)
429
        {
430
            var formdata = false;
431
            if (window.FormData){
432
                formdata = new FormData(form); //form[0]);
433
            }
434
 
435
 
436
			NProgress.start();
437
            $.ajax({
438
                'dataType'  : 'json',
439
                'accept'    : 'application/json',
440
                'method'    : 'post',
441
                'url'       :  $('#form-edit').attr('action'),
442
                'data'      :  formdata,
443
                'processData': false,
444
                'contentType': false,
445
            }).done(function(response) {
446
                if(response['success']) {
447
                    $.fn.showSuccess(response['data']);
448
 
449
                    gridTable.api().ajax.reload(null, false);
450
 
451
                    $('#row-add').hide();
452
                    $('#row-edit').hide();
453
                    $('#row-listing').show();
454
 
455
 
456
                } else {
457
                    validatorEdit.resetForm();
458
                    if(jQuery.type(response['data']) == 'string') {
459
                        $.fn.showError(response['data']);
460
                    } else  {
461
                        $.each(response['data'], function( fieldname, errors ) {
462
                            $.fn.showFormErrorValidator('#form-edit #' + fieldname, errors);
463
                        });
464
                    }
465
                }
466
            }).fail(function( jqXHR, textStatus, errorThrown) {
467
 
468
                $.fn.showError(textStatus);
469
            }).always(function() {
470
 
471
 
472
                NProgress.done();
473
            });
474
            return false;
475
        },
476
        invalidHandler: function(form, validator) {
477
 
478
        }
479
    });
480
 
481
 
482
 
483
        $('body').on('click', '.btn-view-image-marketplace', function(e) {
484
            e.preventDefault();
485
 
486
            $('#image-marketplace').attr('src', $(this).data('href'));
487
            $('#modalPreviewMarketPlace').modal('show');
488
            return false;
489
        });
490
 
491
        $('body').on('click', '.btn-view-image-app', function(e) {
492
            e.preventDefault();
493
 
494
            $('#image-app').attr('src', $(this).data('href'));
495
            $('#modalPreviewImage').modal('show');
496
            return false;
497
        });
498
 
499
        $('#form-add #order').inputNumberFormat({decimal: 0});
500
 
501
 
502
 
503
 
504
        $('body').on('click', 'button.btn-add', function(e) {
505
            e.preventDefault();
506
 
507
            $('#form-add #name').val('');
508
            $('#form-add #order').val('1');
509
 
510
            $('#form-add #privacy').val('');
511
            $('#form-add #status').val('');
512
            $('#form-add #cost').val('');
513
            $('#form-add #form-row-cost').hide();
514
            $('#form-add #file').fileinput('reset');
515
            $('#form-add #file').val('');
516
            $('#form-add #marketplace').fileinput('reset');
517
            $('#form-add #marketplace').val('');
518
 
519
            CKEDITOR.instances.description_add.setData('');
520
            validatorAdd.resetForm();
521
 
522
            $('#row-listing').hide();
523
            $('#row-edit').hide();
524
            $('#row-add').show();
525
        });
526
 
527
 
528
        $('#form-edit #order').inputNumberFormat({decimal: 0});
529
 
530
 
531
 
532
 
533
 
534
        $('body').on('click', 'button.btn-edit', function(e) {
535
            e.preventDefault();
536
			NProgress.start();
537
            var url = $(this).data('href');
538
            $.ajax({
539
                'dataType'  : 'json',
540
                'accept'    : 'application/json',
541
                'method'    : 'get',
542
                'url'       :  url,
543
            }).done(function(response) {
544
                if(response['success']) {
545
					console.log(response)
546
                    $('#form-edit').attr('action',url);
547
                    $('#form-edit #name').val(response['data']['name']);
548
                    $('#form-edit #order').val(response['data']['order']);
549
                    $('#form-edit #privacy').val(response['data']['privacy']);
550
                    $('#form-edit #type').val(response['data']['type']);
551
                    $('#form-edit #status').val(response['data']['status']);
552
 
553
                    if('s' == response['data']['type']) {
554
                        $('#form-edit #form-row-cost').show();
555
                        $('#form-edit #cost').val(response['data']['cost']);
556
                    } else {
557
                        $('#form-edit #form-row-cost').hide();
558
                        $('#form-edit #cost').val('');
559
                    }
560
 
561
                    $('#form-edit #file').fileinput('reset');
562
                    $('#form-edit #file').val('');
563
                    $('#form-edit #marketplace').fileinput('reset');
564
                    $('#form-edit #marketplace').val('');
565
 
566
                    CKEDITOR.instances.description_edit.setData(response['data']['description']);
567
                    validatorEdit.resetForm();
568
 
569
                    $('#row-listing').hide();
570
                    $('#row-add').hide();
571
                    $('#row-edit').show();
572
 
573
                } else {
574
                    validatorEdit.resetForm();
575
                    if(jQuery.type(response['data']) == 'string') {
576
                        $.fn.showError(response['data']);
577
                    } else  {
578
                        $.each(response['data'], function( fieldname, errors ) {
579
                            $.fn.showFormErrorValidator('#form-edit #' + fieldname, errors);
580
                        });
581
                    }
582
                }
583
            }).fail(function( jqXHR, textStatus, errorThrown) {
584
                $.fn.showError(textStatus);
585
            }).always(function() {
586
                NProgress.done();
587
            });
588
        });
589
 
590
 
591
 
592
 
593
        CKEDITOR.replace('description_add', {
594
			toolbar: [
595
                    { name: 'editing', items: ['Scayt'] },
596
                    { name: 'links', items: ['Link', 'Unlink'] },
597
                    { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
598
                    { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
599
                    '/',
600
                    { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
601
                    { name: 'styles', items: ['Styles', 'Format'] },
602
                    { name: 'tools', items: ['Maximize'] }
603
                ],
604
                removePlugins: 'elementspath,Anchor',
605
                heigth: 100
606
		});
607
        CKEDITOR.replace('description_edit', {
608
			toolbar: [
609
                    { name: 'editing', items: ['Scayt'] },
610
                    { name: 'links', items: ['Link', 'Unlink'] },
611
                    { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
612
                    { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
613
                    '/',
614
                    { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
615
                    { name: 'styles', items: ['Styles', 'Format'] },
616
                    { name: 'tools', items: ['Maximize'] }
617
                ],
618
                removePlugins: 'elementspath,Anchor',
619
                heigth: 100
620
		});
621
 
622
        $('#form-add #type').change(function(e) {
623
            e.preventDefault();
624
 
625
            if('s' == $(this).val()) {
626
                $('#form-add #form-row-cost').show();
627
            } else {
628
                $('#form-add #cost').val(0);
629
                $('#form-add #form-row-cost').hide();
630
            }
631
 
632
        });
633
 
634
        $('#form-edit #type').change(function(e) {
635
            e.preventDefault();
636
 
637
            if('s' == $(this).val()) {
638
                $('#form-edit #form-row-cost').show();
639
            } else {
640
                $('#form-edit #cost').val(0);
641
                $('#form-edit #form-row-cost').hide();
642
            }
643
 
644
        });
645
 
646
        $('#form-add #order').inputNumberFormat({decimal: 0});
647
        $('#form-add #cost').inputNumberFormat({decimal: 2});
648
 
649
 
650
 
651
 
652
 
653
 
654
    $('body').on('click', 'button.btn-view-total-users', function(e) {
655
        e.preventDefault();
656
 
657
        var href = $(this).data('href');
658
        NProgress.start();
659
        $.ajax({
660
            'dataType'  : 'json',
661
            'accept'    : 'application/json',
662
            'method'    : 'get',
663
            'url'       : href,
664
        }).done(function(response) {
665
            if(response['success']) {
666
 
667
 
668
      			$('#table-users-capsule').val(response['data']['capsule']);
669
 
670
                $('#gridTableUsers tbody').empty();
671
 
672
                $.each(response['data']['items'], function(index, item) {
673
 
674
                    console.log(item);
675
 
676
                    var s = '<tr>';
677
                    s = s + '<td>' + item['first_name'] + '</td>';
678
                    s = s + '<td>' + item['last_name'] + '</td>';
679
                    s = s + '<td>' + item['email'] + '</td>';
680
 
681
                    s = s + '<td>';
682
                    if(item['details']['access']) {
683
                        s = s + 'LABEL_ACCESS : ' + item['details']['access'] + '<br>';
684
                    }
685
                    if(item['details']['paid_from']) {
686
                        s = s + 'LABEL_PAID_FROM : ' + item['details']['paid_from'] + '<br>';
687
                    }
688
                    if(item['details']['paid_to']) {
689
                        s = s + 'LABEL_PAID_TO : ' + item['details']['paid_to'] + '<br>';
690
                    }
691
 
692
                    s = s + '</td>';
693
                    s = s + '</tr>';
694
 
695
                    $('#gridTableUsers tbody').append(s);
696
 
697
 
698
                });
699
 
700
                $('#notificationUsersModal').modal('show');
701
 
702
            } else {
703
                $.fn.showError(response['data']);
704
 
705
            }
706
        }).fail(function( jqXHR, textStatus, errorThrown) {
707
            $.fn.showError(textStatus);
708
        }).always(function() {
709
 
710
            NProgress.done();
711
        });
712
        return false;
713
 
714
    });
715
    $('body').on('click', 'button.btn-refresh', function(e) {
716
        e.preventDefault();
717
        gridTable.api().ajax.reload(null, false);
718
    });
719
 
720
    $('body').on('click', 'button.btn-delete', function(e) {
721
        e.preventDefault();
722
        var action = $(this).data('href');
723
 
724
 
725
          swal.fire({
726
            title: 'LABEL_ARE_YOU_SURE',
727
            icon: 'question',
728
            cancelButtonText: 'LABEL_NO',
729
            showCancelButton: true,
730
            confirmButtonText: 'LABEL_YES'
731
          }).then((result) => {
732
            if (result.isConfirmed) {
733
 
734
                    NProgress.start();
735
                    $.ajax({
736
                        'dataType'  : 'json',
737
                        'accept'    : 'application/json',
738
                        'method'    : 'post',
739
                        'url'       :  action,
740
                    }).done(function(response) {
741
                        if(response['success']) {
742
                            $.fn.showSuccess(response['data']);
743
                            gridTable.api().ajax.reload(null, false);
744
                        } else {
745
                            $.fn.showError(response['data']);
746
                        }
747
                    }).fail(function( jqXHR, textStatus, errorThrown) {
748
                        $.fn.showError(textStatus);
749
                    }).always(function() {
750
                        NProgress.done();
751
                    });
752
                }
753
           });
754
        });
755
 
756
 
757
  $('#form-add #file').fileinput({
758
                theme: 'fa',
759
                language: 'es',
760
                showUpload: false,
761
                dropZoneEnabled: false,
762
                maxFileCount: 1,
763
                msgPlaceholder:  'LABEL_RECOMMENDED_SIZE $image_size',
764
                allowedFileExtensions: ['jpeg', 'jpg', 'png'],
765
            });
766
 
767
  $('#form-add #marketplace').fileinput({
768
                theme: 'fa',
769
                language: 'es',
770
                showUpload: false,
771
                dropZoneEnabled: false,
772
                maxFileCount: 1,
773
                msgPlaceholder: 'LABEL_RECOMMENDED_SIZE $marketplace_size',
774
                allowedFileExtensions: ['jpeg', 'jpg', 'png'],
775
            });
776
 
777
            $('#form-edit #file').fileinput({
778
                theme: 'fa',
779
                language: 'es',
780
                showUpload: false,
781
                dropZoneEnabled: false,
782
                maxFileCount: 1,
783
                msgPlaceholder: 'LABEL_RECOMMENDED_SIZE $image_size',
784
                allowedFileExtensions: ['jpeg', 'jpg', 'png'],
785
            });
786
 
787
            $('#form-edit #marketplace').fileinput({
788
                theme: 'fa',
789
                language: 'es',
790
                showUpload: false,
791
                dropZoneEnabled: false,
792
                maxFileCount: 1,
793
                msgPlaceholder:  'LABEL_RECOMMENDED_SIZE $marketplace_size',
794
                allowedFileExtensions: ['jpeg', 'jpg', 'png'],
795
            });
796
 
797
        $('body').on('click', 'button.btn-cancel', function(e) {
798
            e.preventDefault();
799
            $('#row-add').hide();
800
            $('#row-edit').hide();
801
            $('#row-listing').show();
802
 
803
        });
804
 
805
});
806
JS;
807
$this->inlineScript()->captureEnd();
808
?>
809
 
810
 
811
<div class="container">
812
	<div class="card" id="row-listing">
813
	 	<div class="card-header">
814
	 		<h6 class="card-title">LABEL_CAPSULES</h6>
815
	 	</div>
816
	 	<div class="card-body">
817
	 						<?php
818
						$form = $this->form;
819
						$form->setAttributes([
820
							'name'    => 'form-filter',
821
							'id'      => 'form-filter',
822
						]);
823
 
824
						$form->prepare();
825
						echo $this->form()->openTag($form);
826
						?>
827
						<div class="row">
828
	 	         <div class="col-12 mt-3">
829
							<?php
830
							$element = $form->get('topic_uuid');
831
 
832
							$element->setAttributes(['class' => 'form-control']);
833
							$element->setLabel('LABEL_TOPIC');
834
							echo $this->formLabel($element);
835
							echo $this->formSelect($element);
836
							?>
837
 
838
	 	         </div>
839
	 	     </div>
840
						<?php echo $this->form()->closeTag($form); ?>
841
			<div class="row">
842
	 	         <div class="col-12 mt-3">
843
					<table id="gridTable" class="table   table-bordered">
844
							<thead>
845
								<tr>
846
									<th>LABEL_NAME</th>
847
									<th>LABEL_DETAILS</th>
848
									<th>LABEL_IMAGES</th>
849
									<th>LABEL_ACTIONS</th>
850
								</tr>
851
							</thead>
852
						<tbody>
853
						</tbody>
854
					</table>
855
	 	         </div>
856
	 	     </div>
857
	 	</div>
858
	 	<div class="card-footer text-right">
859
			<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-sync"></i> LABEL_REFRESH </button>
860
			<?php if ($allowAdd) : ?>
861
			<button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
862
			<?php endif; ?>
863
	 	</div>
864
	</div>
865
 
866
	<div class="card" id="row-add" style="display: none">
867
	 	<div class="card-header">
868
	 		<h6 class="card-title">LABEL_ADD_CAPSULE</h6>
869
	 	</div>
870
	 	<?php
871
		$form = $this->formAdd;
872
		$form->setAttributes([
873
			'method'  => 'post',
874
			'action'  => '',
875
			'name'    => 'form-add',
876
			'id'      => 'form-add',
877
		]);
878
 
879
		$form->prepare();
880
		echo $this->form()->openTag($form);
881
		?>
882
	 	<div class="card-body">
883
	 		<div class="row">
884
	 	         <div class="col-12 mt-3">
885
    			<?php
886
    			$element = $form->get('name');
887
 
888
    			$element->setAttributes(['class' => 'form-control']);
889
    			$element->setOptions(['label' => 'LABEL_NAME']);
890
    			echo $this->formLabel($element);
891
    			echo $this->formText($element);
892
    			?>
893
    			</div>
894
    		</div>
895
	 		<div class="row">
896
	 	         <div class="col-12 mt-3">
897
        			<?php
898
        			$element = $form->get('description');
899
        			$element->setAttributes(['id' => 'description_add', 'class' => 'form-control', 'rows' => '2', 'class' => 'form-control']);
900
        			$element->setOptions(['label' => 'LABEL_DESCRIPTION']);
901
        			echo $this->formLabel($element);
902
        			echo $this->formTextArea($element);
903
        			?>
904
        		</div>
905
        	</div>
906
	 		<div class="row">
907
	 	         <div class="col-12 mt-3">
908
        			<?php
909
        			$element = $form->get('order');
910
        			$element->setAttributes(['class' => 'form-control']);
911
        			$element->setOptions(['label' => 'LABEL_ORDER']);
912
        			echo $this->formLabel($element);
913
        			echo $this->formText($element);
914
        			?>
915
        		</div>
916
			</div>
917
	 		<div class="row">
918
	 	         <div class="col-12 mt-3">
919
    			<?php
920
    			$element = $form->get('status');
921
    			$element->setAttributes(['class' => 'form-control']);
922
    			$element->setOptions(['label' => 'LABEL_STATUS']);
923
    			echo $this->formLabel($element);
924
    			echo $this->formSelect($element);
925
    			?>
926
				</div>
927
			</div>
928
	 		<div class="row">
929
	 	         <div class="col-12 mt-3">
930
        			<?php
931
        			$element = $form->get('privacy');
932
        			$element->setAttributes(['class' => 'form-control']);
933
        			$element->setOptions(['label' => 'LABEL_PRIVACY']);
934
        			echo $this->formLabel($element);
935
        			echo $this->formSelect($element);
936
        			?>
937
        		</div>
938
        	</div>
939
			<div class="row">
940
	 			<div class="col-12 mt-3">
941
        			<?php
942
        			$element = $form->get('type');
943
        			$element->setAttributes(['class' => 'form-control']);
944
        			$element->setOptions(['label' => 'LABEL_TYPE']);
945
        			echo $this->formLabel($element);
946
        			echo $this->formSelect($element);
947
        			?>
948
        		</div>
949
        	</div>
950
 
951
		  	<div class="row"  id="form-row-cost">
952
	 			<div class="col-12 mt-3">
953
        			<?php
954
        			$element = $form->get('cost');
955
        			$element->setAttributes(['class' => 'form-control']);
956
        			$element->setOptions(['label' => 'LABEL_COST']);
957
        			echo $this->formLabel($element);
958
        			echo $this->formText($element);
959
        			?>
960
				</div>
961
			</div>
962
			<div class="row">
963
	 	 		<div class="col-12 mt-3">
964
                        <?php
965
                        $element = $form->get('file');
966
                        $element->setOptions(['label' => 'LABEL_IMAGE']);
967
                        $element->setAttributes(['class' => 'form-control']);
968
                        $element->setAttributes(['accept' => 'image/jpg,image/jpeg,image/png']);
969
                        echo $this->formLabel($element);
970
                        echo $this->formFile($element);
971
                        ?>
972
            	</div>
973
           	</div>
974
           	<div class="row">
975
	 	         <div class="col-12 mt-3">
976
                        <?php
977
                        $element = $form->get('marketplace');
978
                        $element->setOptions(['label' => 'LABEL_MARKETPLACE']);
979
                        $element->setAttributes(['class' => 'form-control']);
980
                        $element->setAttributes(['accept' => 'image/jpg,image/jpeg,image/png']);
981
                        echo $this->formLabel($element);
982
                        echo $this->formFile($element);
983
                        ?>
984
          		</div>
985
          	</div>
986
	 	</div>
987
	 	<div class="card-footer text-right">
988
			<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
989
      		<button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
990
	 	</div>
991
	 	<?php echo $this->form()->closeTag($form); ?>
992
	</div>
993
 
994
	<div class="card" id="row-edit" style="display: none">
995
	 	<div class="card-header">
996
	 		<h6 class="card-title">LABEL_EDIT_CAPSULE</h6>
997
	 	</div>
998
	 	<?php
999
		$form = $this->formEdit;
1000
		$form->setAttributes([
1001
		    'method'    => 'post',
1002
		    'name'      => 'form-edit',
1003
		    'id'        => 'form-edit'
1004
		]);
1005
 
1006
		$form->prepare();
1007
		echo $this->form()->openTag($form);
1008
		?>
1009
	 	<div class="card-body">
1010
	 		<div class="row">
1011
	 	         <div class="col-12 mt-3">
1012
    			<?php
1013
    			$element = $form->get('name');
1014
 
1015
    			$element->setAttributes(['class' => 'form-control']);
1016
    			$element->setOptions(['label' => 'LABEL_NAME']);
1017
    			echo $this->formLabel($element);
1018
    			echo $this->formText($element);
1019
    			?>
1020
    			</div>
1021
    		</div>
1022
	 		<div class="row">
1023
	 	         <div class="col-12 mt-3">
1024
        			<?php
1025
        			$element = $form->get('description');
1026
        			$element->setAttributes(['id' => 'description_edit', 'class' => 'form-control', 'rows' => '2', 'class' => 'form-control']);
1027
        			$element->setOptions(['label' => 'LABEL_DESCRIPTION']);
1028
        			echo $this->formLabel($element);
1029
        			echo $this->formTextArea($element);
1030
        			?>
1031
        		</div>
1032
        	</div>
1033
	 		<div class="row">
1034
	 	         <div class="col-12 mt-3">
1035
        			<?php
1036
        			$element = $form->get('order');
1037
        			$element->setAttributes(['class' => 'form-control']);
1038
        			$element->setOptions(['label' => 'LABEL_ORDER']);
1039
        			echo $this->formLabel($element);
1040
        			echo $this->formText($element);
1041
        			?>
1042
        		</div>
1043
			</div>
1044
	 		<div class="row">
1045
	 	         <div class="col-12 mt-3">
1046
    			<?php
1047
    			$element = $form->get('status');
1048
    			$element->setAttributes(['class' => 'form-control']);
1049
    			$element->setOptions(['label' => 'LABEL_STATUS']);
1050
    			echo $this->formLabel($element);
1051
    			echo $this->formSelect($element);
1052
    			?>
1053
				</div>
1054
			</div>
1055
	 		<div class="row">
1056
	 	         <div class="col-12 mt-3">
1057
        			<?php
1058
        			$element = $form->get('privacy');
1059
        			$element->setAttributes(['class' => 'form-control']);
1060
        			$element->setOptions(['label' => 'LABEL_PRIVACY']);
1061
        			echo $this->formLabel($element);
1062
        			echo $this->formSelect($element);
1063
        			?>
1064
        		</div>
1065
        	</div>
1066
			<div class="row">
1067
	 			<div class="col-12 mt-3">
1068
        			<?php
1069
        			$element = $form->get('type');
1070
        			$element->setAttributes(['class' => 'form-control']);
1071
        			$element->setOptions(['label' => 'LABEL_TYPE']);
1072
        			echo $this->formLabel($element);
1073
        			echo $this->formSelect($element);
1074
        			?>
1075
        		</div>
1076
        	</div>
1077
 
1078
		  	<div class="row"  id="form-row-cost">
1079
	 			<div class="col-12 mt-3">
1080
        			<?php
1081
        			$element = $form->get('cost');
1082
        			$element->setAttributes(['class' => 'form-control']);
1083
        			$element->setOptions(['label' => 'LABEL_COST']);
1084
        			echo $this->formLabel($element);
1085
        			echo $this->formText($element);
1086
        			?>
1087
				</div>
1088
			</div>
1089
			<div class="row">
1090
	 	 		<div class="col-12 mt-3">
1091
                        <?php
1092
                        $element = $form->get('file');
1093
                        $element->setOptions(['label' => 'LABEL_IMAGE']);
1094
                        $element->setAttributes(['class' => 'form-control']);
1095
                        $element->setAttributes(['accept' => 'image/jpg,image/jpeg,image/png']);
1096
                        echo $this->formLabel($element);
1097
                        echo $this->formFile($element);
1098
                        ?>
1099
            	</div>
1100
           	</div>
1101
           	<div class="row">
1102
	 	         <div class="col-12 mt-3">
1103
                        <?php
1104
                        $element = $form->get('marketplace');
1105
                        $element->setOptions(['label' => 'LABEL_MARKETPLACE']);
1106
                        $element->setAttributes(['class' => 'form-control']);
1107
                        $element->setAttributes(['accept' => 'image/jpg,image/jpeg,image/png']);
1108
                        echo $this->formLabel($element);
1109
                        echo $this->formFile($element);
1110
                        ?>
1111
          		</div>
1112
          	</div>
1113
	 	</div>
1114
	 	<div class="card-footer text-right">
1115
			<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1116
      		<button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
1117
	 	</div>
1118
	 	<?php echo $this->form()->closeTag($form); ?>
1119
	</div>
1120
</div>
1121
 
1122
 
1123
 
1124
 
1125
 
1126
 
1127
<!-- The Modal -->
1128
<div class="modal" id="modalPreviewMarketPlace">
1129
	<div class="modal-dialog">
1130
		<div class="modal-content">
1131
			<!-- Modal Header -->
1132
			<div class="modal-header">
1133
				<h6 class="modal-title">LABEL_IMAGE_MARKETPLACE</h6>
1134
				<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
1135
			</div>
1136
 
1137
			<!-- Modal body -->
1138
			<div class="modal-body text-center">
1139
				<img src="" class="img img-responsive" style="width: 300px; height: auto" id="image-marketplace" />
1140
			</div>
1141
 
1142
			<!-- Modal footer -->
1143
			<div class="modal-footer text-right">
1144
				<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
1145
			</div>
1146
		</div>
1147
	</div>
1148
</div>
1149
 
1150
 
1151
<!-- The Modal -->
1152
<div class="modal" id="modalPreviewImage">
1153
	<div class="modal-dialog ">
1154
		<div class="modal-content">
1155
 
1156
			<!-- Modal Header -->
1157
			<div class="modal-header">
1158
				<h6 class="modal-title">LABEL_IMAGE</h6>
1159
				<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
1160
			</div>
1161
 
1162
			<!-- Modal body -->
1163
			<div class="modal-body text-center">
1164
				<img src="" class="img img-responsive" style="width: 300px; height: auto" id="image-app" />
1165
			</div>
1166
 
1167
			<!-- Modal footer -->
1168
			<div class="modal-footer text-right">
1169
				<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
1170
			</div>
1171
		</div>
1172
	</div>
1173
</div>
1174
 
1175
 
1176
 
1177
 
1178
 
1179
 
1180
<!-- The Modal -->
1181
<div class="modal" id="notificationUsersModal">
1182
	<div class="modal-dialog modal-xl">
1183
		<div class="modal-content">
1184
 
1185
			<!-- Modal Header -->
1186
			<div class="modal-header">
1187
				<h6 class="modal-title">LABEL_USERS</h6>
1188
				<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
1189
			</div>
1190
 
1191
			<!-- Modal body -->
1192
			<div class="modal-body">
1193
				<form>
1194
					<div class="row">
1195
						<div class="col-12 mt-3">
1196
						<label>LABEL_TOPIC</label>
1197
						<input type="text" readonly="readonly" id="table-users-topic" class="form-control">
1198
						</div>
1199
					</div>
1200
					<div class="row">
1201
						<div class="col-12 mt-3">
1202
						<label>LABEL_CAPSULE</label>
1203
						<input type="text" readonly="readonly" id="table-users-capsule" class="form-control">
1204
						</div>
1205
					</div>
1206
				</form>
1207
				<div class="row">
1208
					<div class="col-12 mt-3">
1209
        				<div style="height: 300px;overflow: scroll;">
1210
        					<table id="gridTableUsers" style="width: 100%" class="table   table-bordered">
1211
        						<thead>
1212
        							<tr>
1213
        								<th>LABEL_FIRST_NAME</th>
1214
        								<th>LABEL_LAST_NAME</th>
1215
        								<th>LABEL_EMAIL</th>
1216
        								<th>LABEL_DETAILS</th>
1217
        							</tr>
1218
        						</thead>
1219
        						<tbody>
1220
        						</tbody>
1221
        					</table>
1222
        				</div>
1223
    				</div>
1224
    			</div>
1225
 
1226
			</div>
1227
 
1228
			<!-- Modal footer -->
1229
			<div class="modal-footer text-right">
1230
				<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
1231
			</div>
1232
 
1233
		</div>
1234
	</div>
1235
</div>