Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16945 | | Comparar con el anterior | Ultima modificación | Ver Log |

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