Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 17059 | Rev 17061 | Ir a la última revisión | | 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
 
17060 stevensc 102
        // Configuración de validación de formularios
1 www 103
        $.validator.setDefaults({
104
            debug: true,
105
            highlight: function(element) {
106
                $(element).addClass('is-invalid');
107
            },
108
            unhighlight: function(element) {
109
                $(element).removeClass('is-invalid');
110
            },
111
            errorElement: 'span',
112
            errorClass: 'error invalid-feedback',
113
            errorPlacement: function(error, element) {
114
                if(element.parent('.btn-file').length) {
115
                    error.insertAfter(element.parent().parent());
116
                } else if(element.parent('.toggle').length) {
117
                    error.insertAfter(element.parent().parent());
118
                } else {
119
                    error.insertAfter(element.parent());
120
                }
121
            }
122
        });
123
 
124
 
125
 
126
 
127
        var allowEdit   = $allowEdit;
128
        var allowDelete = $allowDelete;
129
        var allowUsers  = $allowUsers;
130
 
17060 stevensc 131
        // Configuración de la tabla principal
1 www 132
        var gridTable = $('#gridTable').dataTable( {
133
            'processing': true,
134
            'serverSide': true,
135
            'searching': true,
136
            'order': [[ 0, 'asc' ]],
137
            'ordering':  true,
138
            'ordenable' : true,
139
            'responsive': true,
140
            'select' : false,
141
        	'paging': true,
142
            'pagingType': 'simple_numbers',
143
    		'ajax': {
144
    			'url' : '$routeDatatable',
17060 stevensc 145
    			'type' : 'get',,
1 www 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) {
16905 efrain 158
                        $('#form-add').attr('action', response.data.link_add );
1 www 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();
16822 efrain 196
 
1 www 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']  ) {
16932 efrain 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>';
1 www 218
                         } else {
219
                            s += 'LABEL_TOTAL_USERS: ' + data['total_users']  + '<br/>';
220
                         }
221
                         if(allowUsers && row['actions']['link_total_users_actives']  ) {
16932 efrain 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>';
1 www 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
 
6903 nelberth 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;" /> '
1 www 238
                        }  else {
239
                            s = s + '';
240
                        }
6903 nelberth 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;" /> '
1 www 244
                        }  else {
245
                            s = s + '';
246
                        }
247
 
248
 
249
 
6903 nelberth 250
 
251
 
1 www 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']  ) {
16906 efrain 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;';
1 www 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
 
17060 stevensc 277
    var seleccionarCampo;
16905 efrain 278
    var validatorAdd = $('#form-add').validate({
1 www 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,
16905 efrain 296
                extension: 'jpg|jpeg|png',
297
                accept: 'image/jpg,image/jpeg,image/png'
1 www 298
            },
299
            'order' : {
300
                required: true,
301
                digits: true,
302
                min: 1,
303
                max: 250
304
            },
305
           'marketplace': {
16905 efrain 306
                required: false,
307
                extension: 'jpg|jpeg|png',
308
                accept: 'image/jpg,image/jpeg,image/png'
1 www 309
            },
310
            'status' : {
311
                required: true,
312
            },
313
            'privacy' : {
314
                required: true,
315
            },
316
            'type' : {
317
                required: true,
318
            },
319
            'cost' : {
320
                required: function() {
16905 efrain 321
                    return $('#form-add #type').val() == 's';
1 www 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
 
16945 efrain 334
 
6859 nelberth 335
			NProgress.start();
1 www 336
            $.ajax({
337
                'dataType'  : 'json',
338
                'accept'    : 'application/json',
339
                'method'    : 'post',
16905 efrain 340
                'url'       :  $('#form-add').attr('action'),
1 www 341
                'data'      :  formdata,
342
                'processData': false,
343
                'contentType': false,
344
            }).done(function(response) {
345
                if(response['success']) {
346
                    $.fn.showSuccess(response['data']);
16905 efrain 347
 
348
					gridTable.api().ajax.reload(null, false);
349
 
350
                    $('#row-add').hide();
351
                    $('#row-edit').hide();
352
                    $('#row-listing').show();
353
 
354
 
1 www 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 ) {
16905 efrain 361
                            $.fn.showFormErrorValidator('#form-add #' + fieldname, errors);
1 www 362
                        });
363
                    }
364
                }
365
            }).fail(function( jqXHR, textStatus, errorThrown) {
6936 nelberth 366
				console.log(jqXHR)
1 www 367
                $.fn.showError(textStatus);
368
            }).always(function() {
16945 efrain 369
 
1 www 370
                NProgress.done();
371
            });
372
            return false;
373
        },
374
        invalidHandler: function(form, validator) {
375
 
376
        }
377
    });
378
 
16905 efrain 379
    var validatorEdit  = $('#form-edit').validate({
1 www 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': {
16905 efrain 396
                required: false,
397
                extension: 'jpg|jpeg|png',
398
                accept: 'image/jpg,image/jpeg,image/png'
1 www 399
            },
400
            'order' : {
401
                required: true,
402
                digits: true,
403
                min: 1,
404
                max: 250
405
            },
406
           'marketplace': {
16905 efrain 407
                required: false,
408
                extension: 'jpg|jpeg|png',
409
                accept: 'image/jpg,image/jpeg,image/png'
1 www 410
            },
411
            'status' : {
412
                required: true,
413
            },
414
            'privacy' : {
415
                required: true,
416
            },
417
            'type' : {
418
                required: true,
419
            },
420
            'cost' : {
421
                required: function() {
16905 efrain 422
                    return $('#form-edit #type').val() == 's';
1 www 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
 
16945 efrain 435
 
6992 nelberth 436
			NProgress.start();
1 www 437
            $.ajax({
438
                'dataType'  : 'json',
439
                'accept'    : 'application/json',
440
                'method'    : 'post',
16905 efrain 441
                'url'       :  $('#form-edit').attr('action'),
1 www 442
                'data'      :  formdata,
443
                'processData': false,
444
                'contentType': false,
445
            }).done(function(response) {
446
                if(response['success']) {
447
                    $.fn.showSuccess(response['data']);
16905 efrain 448
 
1 www 449
                    gridTable.api().ajax.reload(null, false);
16905 efrain 450
 
451
                    $('#row-add').hide();
452
                    $('#row-edit').hide();
453
                    $('#row-listing').show();
454
 
455
 
1 www 456
                } else {
16905 efrain 457
                    validatorEdit.resetForm();
1 www 458
                    if(jQuery.type(response['data']) == 'string') {
459
                        $.fn.showError(response['data']);
460
                    } else  {
461
                        $.each(response['data'], function( fieldname, errors ) {
16905 efrain 462
                            $.fn.showFormErrorValidator('#form-edit #' + fieldname, errors);
1 www 463
                        });
464
                    }
465
                }
466
            }).fail(function( jqXHR, textStatus, errorThrown) {
16905 efrain 467
 
1 www 468
                $.fn.showError(textStatus);
469
            }).always(function() {
6996 nelberth 470
 
16905 efrain 471
 
1 www 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'));
16905 efrain 487
            $('#modalPreviewMarketPlace').modal('show');
1 www 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'));
16905 efrain 495
            $('#modalPreviewImage').modal('show');
1 www 496
            return false;
497
        });
498
 
16905 efrain 499
        $('#form-add #order').inputNumberFormat({decimal: 0});
1 www 500
 
501
 
502
 
503
 
504
        $('body').on('click', 'button.btn-add', function(e) {
505
            e.preventDefault();
506
 
16905 efrain 507
            $('#form-add #name').val('');
508
            $('#form-add #order').val('1');
1 www 509
 
16905 efrain 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('');
1 www 518
 
519
            CKEDITOR.instances.description_add.setData('');
520
            validatorAdd.resetForm();
521
 
16905 efrain 522
            $('#row-listing').hide();
523
            $('#row-edit').hide();
524
            $('#row-add').show();
1 www 525
        });
526
 
527
 
16905 efrain 528
        $('#form-edit #order').inputNumberFormat({decimal: 0});
1 www 529
 
6859 nelberth 530
 
1 www 531
 
6991 nelberth 532
 
1 www 533
 
534
        $('body').on('click', 'button.btn-edit', function(e) {
535
            e.preventDefault();
7045 nelberth 536
			NProgress.start();
1 www 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']) {
6980 nelberth 545
					console.log(response)
16905 efrain 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']);
1 www 552
 
553
                    if('s' == response['data']['type']) {
16905 efrain 554
                        $('#form-edit #form-row-cost').show();
555
                        $('#form-edit #cost').val(response['data']['cost']);
1 www 556
                    } else {
16905 efrain 557
                        $('#form-edit #form-row-cost').hide();
558
                        $('#form-edit #cost').val('');
1 www 559
                    }
16905 efrain 560
 
16945 efrain 561
                    $('#form-edit #file').fileinput('reset');
562
                    $('#form-edit #file').val('');
563
                    $('#form-edit #marketplace').fileinput('reset');
564
                    $('#form-edit #marketplace').val('');
1 www 565
 
566
                    CKEDITOR.instances.description_edit.setData(response['data']['description']);
567
                    validatorEdit.resetForm();
15027 stevensc 568
 
16905 efrain 569
                    $('#row-listing').hide();
570
                    $('#row-add').hide();
571
                    $('#row-edit').show();
572
 
1 www 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 ) {
16905 efrain 579
                            $.fn.showFormErrorValidator('#form-edit #' + fieldname, errors);
1 www 580
                        });
581
                    }
582
                }
583
            }).fail(function( jqXHR, textStatus, errorThrown) {
584
                $.fn.showError(textStatus);
585
            }).always(function() {
586
                NProgress.done();
587
            });
588
        });
589
 
6886 nelberth 590
 
1 www 591
 
592
 
8290 stevensc 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
		});
1 www 621
 
16905 efrain 622
        $('#form-add #type').change(function(e) {
1 www 623
            e.preventDefault();
624
 
625
            if('s' == $(this).val()) {
16905 efrain 626
                $('#form-add #form-row-cost').show();
1 www 627
            } else {
16905 efrain 628
                $('#form-add #cost').val(0);
629
                $('#form-add #form-row-cost').hide();
1 www 630
            }
631
 
632
        });
633
 
16905 efrain 634
        $('#form-edit #type').change(function(e) {
1 www 635
            e.preventDefault();
636
 
637
            if('s' == $(this).val()) {
16905 efrain 638
                $('#form-edit #form-row-cost').show();
1 www 639
            } else {
16905 efrain 640
                $('#form-edit #cost').val(0);
641
                $('#form-edit #form-row-cost').hide();
1 www 642
            }
643
 
644
        });
645
 
16905 efrain 646
        $('#form-add #order').inputNumberFormat({decimal: 0});
647
        $('#form-add #cost').inputNumberFormat({decimal: 2});
1 www 648
 
649
        $('#form-filter #topic_uuid').change(function(e) {
650
            e.preventDefault();
651
 
652
            gridTable.api().ajax.reload(null, false);
653
 
654
        });
655
 
656
 
657
 
658
 
659
 
660
    $('body').on('click', 'button.btn-view-total-users', function(e) {
661
        e.preventDefault();
662
 
663
        var href = $(this).data('href');
664
        NProgress.start();
665
        $.ajax({
666
            'dataType'  : 'json',
667
            'accept'    : 'application/json',
668
            'method'    : 'get',
669
            'url'       : href,
670
        }).done(function(response) {
671
            if(response['success']) {
672
      			$('#table-users-capsule').val(response['data']['capsule']);
673
 
674
                $('#gridTableUsers tbody').empty();
675
 
676
                $.each(response['data']['items'], function(index, item) {
677
 
678
                    console.log(item);
679
 
680
                    var s = '<tr>';
681
                    s = s + '<td>' + item['first_name'] + '</td>';
682
                    s = s + '<td>' + item['last_name'] + '</td>';
683
                    s = s + '<td>' + item['email'] + '</td>';
684
 
685
                    s = s + '<td>';
686
                    if(item['details']['access']) {
687
                        s = s + 'LABEL_ACCESS : ' + item['details']['access'] + '<br>';
688
                    }
689
                    if(item['details']['paid_from']) {
690
                        s = s + 'LABEL_PAID_FROM : ' + item['details']['paid_from'] + '<br>';
691
                    }
692
                    if(item['details']['paid_to']) {
693
                        s = s + 'LABEL_PAID_TO : ' + item['details']['paid_to'] + '<br>';
694
                    }
695
 
696
                    s = s + '</td>';
697
                    s = s + '</tr>';
698
 
699
                    $('#gridTableUsers tbody').append(s);
700
 
701
 
702
                });
703
 
704
                $('#notificationUsersModal').modal('show');
705
 
706
            } else {
707
                $.fn.showError(response['data']);
708
 
709
            }
710
        }).fail(function( jqXHR, textStatus, errorThrown) {
711
            $.fn.showError(textStatus);
712
        }).always(function() {
713
 
714
            NProgress.done();
715
        });
716
        return false;
717
 
718
    });
719
    $('body').on('click', 'button.btn-refresh', function(e) {
720
        e.preventDefault();
721
        gridTable.api().ajax.reload(null, false);
722
    });
16822 efrain 723
 
724
    $('body').on('click', 'button.btn-delete', function(e) {
725
        e.preventDefault();
726
        var action = $(this).data('href');
727
 
728
 
729
          swal.fire({
730
            title: 'LABEL_ARE_YOU_SURE',
731
            icon: 'question',
732
            cancelButtonText: 'LABEL_NO',
733
            showCancelButton: true,
734
            confirmButtonText: 'LABEL_YES'
735
          }).then((result) => {
736
            if (result.isConfirmed) {
737
 
738
                    NProgress.start();
739
                    $.ajax({
740
                        'dataType'  : 'json',
741
                        'accept'    : 'application/json',
742
                        'method'    : 'post',
743
                        'url'       :  action,
744
                    }).done(function(response) {
745
                        if(response['success']) {
746
                            $.fn.showSuccess(response['data']);
747
                            gridTable.api().ajax.reload(null, false);
748
                        } else {
749
                            $.fn.showError(response['data']);
750
                        }
751
                    }).fail(function( jqXHR, textStatus, errorThrown) {
752
                        $.fn.showError(textStatus);
753
                    }).always(function() {
754
                        NProgress.done();
755
                    });
756
                }
757
           });
758
        });
1 www 759
 
6682 nelberth 760
 
16905 efrain 761
  $('#form-add #file').fileinput({
762
                theme: 'fa',
763
                language: 'es',
764
                showUpload: false,
765
                dropZoneEnabled: false,
766
                maxFileCount: 1,
16928 efrain 767
                msgPlaceholder:  'LABEL_RECOMMENDED_SIZE $image_size',
16905 efrain 768
                allowedFileExtensions: ['jpeg', 'jpg', 'png'],
769
            });
6682 nelberth 770
 
16905 efrain 771
  $('#form-add #marketplace').fileinput({
772
                theme: 'fa',
773
                language: 'es',
774
                showUpload: false,
775
                dropZoneEnabled: false,
776
                maxFileCount: 1,
16928 efrain 777
                msgPlaceholder: 'LABEL_RECOMMENDED_SIZE $marketplace_size',
16905 efrain 778
                allowedFileExtensions: ['jpeg', 'jpg', 'png'],
779
            });
780
 
781
            $('#form-edit #file').fileinput({
782
                theme: 'fa',
783
                language: 'es',
784
                showUpload: false,
785
                dropZoneEnabled: false,
786
                maxFileCount: 1,
16928 efrain 787
                msgPlaceholder: 'LABEL_RECOMMENDED_SIZE $image_size',
16905 efrain 788
                allowedFileExtensions: ['jpeg', 'jpg', 'png'],
789
            });
6682 nelberth 790
 
16945 efrain 791
            $('#form-edit #marketplace').fileinput({
16905 efrain 792
                theme: 'fa',
793
                language: 'es',
794
                showUpload: false,
795
                dropZoneEnabled: false,
796
                maxFileCount: 1,
16928 efrain 797
                msgPlaceholder:  'LABEL_RECOMMENDED_SIZE $marketplace_size',
16905 efrain 798
                allowedFileExtensions: ['jpeg', 'jpg', 'png'],
799
            });
800
 
801
        $('body').on('click', 'button.btn-cancel', function(e) {
802
            e.preventDefault();
803
            $('#row-add').hide();
804
            $('#row-edit').hide();
805
            $('#row-listing').show();
806
 
807
        });
8583 nelberth 808
 
1 www 809
});
810
JS;
811
$this->inlineScript()->captureEnd();
812
?>
813
 
15139 stevensc 814
 
16905 efrain 815
<div class="container">
816
	<div class="card" id="row-listing">
817
	 	<div class="card-header">
818
	 		<h6 class="card-title">LABEL_CAPSULES</h6>
819
	 	</div>
820
	 	<div class="card-body">
821
			<div class="row">
822
	 	         <div class="col-12 mt-3">
823
					<table id="gridTable" class="table   table-bordered">
15139 stevensc 824
							<thead>
825
								<tr>
826
									<th>LABEL_NAME</th>
827
									<th>LABEL_DETAILS</th>
828
									<th>LABEL_IMAGES</th>
829
									<th>LABEL_ACTIONS</th>
830
								</tr>
831
							</thead>
16905 efrain 832
						<tbody>
833
						</tbody>
834
					</table>
835
	 	         </div>
836
	 	     </div>
837
	 	</div>
838
	 	<div class="card-footer text-right">
16992 efrain 839
			<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-sync"></i> LABEL_REFRESH </button>
16905 efrain 840
			<?php if ($allowAdd) : ?>
841
			<button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
842
			<?php endif; ?>
843
	 	</div>
15139 stevensc 844
	</div>
16905 efrain 845
 
846
	<div class="card" id="row-add" style="display: none">
847
	 	<div class="card-header">
848
	 		<h6 class="card-title">LABEL_ADD_CAPSULE</h6>
849
	 	</div>
850
	 	<?php
15139 stevensc 851
		$form = $this->formAdd;
852
		$form->setAttributes([
853
			'method'  => 'post',
854
			'action'  => '',
16905 efrain 855
			'name'    => 'form-add',
856
			'id'      => 'form-add',
15139 stevensc 857
		]);
1 www 858
 
15139 stevensc 859
		$form->prepare();
860
		echo $this->form()->openTag($form);
861
		?>
16905 efrain 862
	 	<div class="card-body">
863
	 		<div class="row">
864
	 	         <div class="col-12 mt-3">
865
    			<?php
866
    			$element = $form->get('name');
867
 
868
    			$element->setAttributes(['class' => 'form-control']);
869
    			$element->setOptions(['label' => 'LABEL_NAME']);
870
    			echo $this->formLabel($element);
871
    			echo $this->formText($element);
872
    			?>
873
    			</div>
874
    		</div>
875
	 		<div class="row">
876
	 	         <div class="col-12 mt-3">
877
        			<?php
878
        			$element = $form->get('description');
879
        			$element->setAttributes(['id' => 'description_add', 'class' => 'form-control', 'rows' => '2', 'class' => 'form-control']);
880
        			$element->setOptions(['label' => 'LABEL_DESCRIPTION']);
881
        			echo $this->formLabel($element);
882
        			echo $this->formTextArea($element);
883
        			?>
884
        		</div>
885
        	</div>
886
	 		<div class="row">
887
	 	         <div class="col-12 mt-3">
888
        			<?php
889
        			$element = $form->get('order');
890
        			$element->setAttributes(['class' => 'form-control']);
891
        			$element->setOptions(['label' => 'LABEL_ORDER']);
892
        			echo $this->formLabel($element);
893
        			echo $this->formText($element);
894
        			?>
895
        		</div>
15139 stevensc 896
			</div>
16905 efrain 897
	 		<div class="row">
898
	 	         <div class="col-12 mt-3">
899
    			<?php
900
    			$element = $form->get('status');
901
    			$element->setAttributes(['class' => 'form-control']);
902
    			$element->setOptions(['label' => 'LABEL_STATUS']);
903
    			echo $this->formLabel($element);
904
    			echo $this->formSelect($element);
905
    			?>
906
				</div>
907
			</div>
908
	 		<div class="row">
909
	 	         <div class="col-12 mt-3">
910
        			<?php
911
        			$element = $form->get('privacy');
912
        			$element->setAttributes(['class' => 'form-control']);
913
        			$element->setOptions(['label' => 'LABEL_PRIVACY']);
914
        			echo $this->formLabel($element);
915
        			echo $this->formSelect($element);
916
        			?>
917
        		</div>
918
        	</div>
919
			<div class="row">
920
	 			<div class="col-12 mt-3">
921
        			<?php
922
        			$element = $form->get('type');
923
        			$element->setAttributes(['class' => 'form-control']);
924
        			$element->setOptions(['label' => 'LABEL_TYPE']);
925
        			echo $this->formLabel($element);
926
        			echo $this->formSelect($element);
927
        			?>
928
        		</div>
929
        	</div>
15139 stevensc 930
 
16905 efrain 931
		  	<div class="row"  id="form-row-cost">
932
	 			<div class="col-12 mt-3">
933
        			<?php
934
        			$element = $form->get('cost');
935
        			$element->setAttributes(['class' => 'form-control']);
936
        			$element->setOptions(['label' => 'LABEL_COST']);
937
        			echo $this->formLabel($element);
938
        			echo $this->formText($element);
939
        			?>
940
				</div>
941
			</div>
942
			<div class="row">
943
	 	 		<div class="col-12 mt-3">
944
                        <?php
945
                        $element = $form->get('file');
946
                        $element->setOptions(['label' => 'LABEL_IMAGE']);
947
                        $element->setAttributes(['class' => 'form-control']);
948
                        $element->setAttributes(['accept' => 'image/jpg,image/jpeg,image/png']);
949
                        echo $this->formLabel($element);
950
                        echo $this->formFile($element);
951
                        ?>
952
            	</div>
953
           	</div>
954
           	<div class="row">
955
	 	         <div class="col-12 mt-3">
956
                        <?php
957
                        $element = $form->get('marketplace');
958
                        $element->setOptions(['label' => 'LABEL_MARKETPLACE']);
959
                        $element->setAttributes(['class' => 'form-control']);
960
                        $element->setAttributes(['accept' => 'image/jpg,image/jpeg,image/png']);
961
                        echo $this->formLabel($element);
962
                        echo $this->formFile($element);
963
                        ?>
964
          		</div>
965
          	</div>
966
	 	</div>
967
	 	<div class="card-footer text-right">
968
			<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
969
      		<button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
970
	 	</div>
971
	 	<?php echo $this->form()->closeTag($form); ?>
15139 stevensc 972
	</div>
16905 efrain 973
 
974
	<div class="card" id="row-edit" style="display: none">
975
	 	<div class="card-header">
976
	 		<h6 class="card-title">LABEL_EDIT_CAPSULE</h6>
977
	 	</div>
978
	 	<?php
15139 stevensc 979
		$form = $this->formEdit;
980
		$form->setAttributes([
16905 efrain 981
		    'method'    => 'post',
982
		    'name'      => 'form-edit',
983
		    'id'        => 'form-edit'
15139 stevensc 984
		]);
1 www 985
 
15139 stevensc 986
		$form->prepare();
987
		echo $this->form()->openTag($form);
988
		?>
16905 efrain 989
	 	<div class="card-body">
990
	 		<div class="row">
991
	 	         <div class="col-12 mt-3">
992
    			<?php
993
    			$element = $form->get('name');
994
 
995
    			$element->setAttributes(['class' => 'form-control']);
996
    			$element->setOptions(['label' => 'LABEL_NAME']);
997
    			echo $this->formLabel($element);
998
    			echo $this->formText($element);
999
    			?>
1000
    			</div>
1001
    		</div>
1002
	 		<div class="row">
1003
	 	         <div class="col-12 mt-3">
1004
        			<?php
1005
        			$element = $form->get('description');
1006
        			$element->setAttributes(['id' => 'description_edit', 'class' => 'form-control', 'rows' => '2', 'class' => 'form-control']);
1007
        			$element->setOptions(['label' => 'LABEL_DESCRIPTION']);
1008
        			echo $this->formLabel($element);
1009
        			echo $this->formTextArea($element);
1010
        			?>
1011
        		</div>
1012
        	</div>
1013
	 		<div class="row">
1014
	 	         <div class="col-12 mt-3">
1015
        			<?php
1016
        			$element = $form->get('order');
1017
        			$element->setAttributes(['class' => 'form-control']);
1018
        			$element->setOptions(['label' => 'LABEL_ORDER']);
1019
        			echo $this->formLabel($element);
1020
        			echo $this->formText($element);
1021
        			?>
1022
        		</div>
15139 stevensc 1023
			</div>
16905 efrain 1024
	 		<div class="row">
1025
	 	         <div class="col-12 mt-3">
1026
    			<?php
1027
    			$element = $form->get('status');
1028
    			$element->setAttributes(['class' => 'form-control']);
1029
    			$element->setOptions(['label' => 'LABEL_STATUS']);
1030
    			echo $this->formLabel($element);
1031
    			echo $this->formSelect($element);
1032
    			?>
1033
				</div>
1034
			</div>
1035
	 		<div class="row">
1036
	 	         <div class="col-12 mt-3">
1037
        			<?php
1038
        			$element = $form->get('privacy');
1039
        			$element->setAttributes(['class' => 'form-control']);
1040
        			$element->setOptions(['label' => 'LABEL_PRIVACY']);
1041
        			echo $this->formLabel($element);
1042
        			echo $this->formSelect($element);
1043
        			?>
1044
        		</div>
1045
        	</div>
1046
			<div class="row">
1047
	 			<div class="col-12 mt-3">
1048
        			<?php
1049
        			$element = $form->get('type');
1050
        			$element->setAttributes(['class' => 'form-control']);
1051
        			$element->setOptions(['label' => 'LABEL_TYPE']);
1052
        			echo $this->formLabel($element);
1053
        			echo $this->formSelect($element);
1054
        			?>
1055
        		</div>
1056
        	</div>
15139 stevensc 1057
 
16905 efrain 1058
		  	<div class="row"  id="form-row-cost">
1059
	 			<div class="col-12 mt-3">
1060
        			<?php
1061
        			$element = $form->get('cost');
1062
        			$element->setAttributes(['class' => 'form-control']);
1063
        			$element->setOptions(['label' => 'LABEL_COST']);
1064
        			echo $this->formLabel($element);
1065
        			echo $this->formText($element);
1066
        			?>
1067
				</div>
1068
			</div>
1069
			<div class="row">
1070
	 	 		<div class="col-12 mt-3">
1071
                        <?php
1072
                        $element = $form->get('file');
1073
                        $element->setOptions(['label' => 'LABEL_IMAGE']);
1074
                        $element->setAttributes(['class' => 'form-control']);
1075
                        $element->setAttributes(['accept' => 'image/jpg,image/jpeg,image/png']);
1076
                        echo $this->formLabel($element);
1077
                        echo $this->formFile($element);
1078
                        ?>
1079
            	</div>
1080
           	</div>
1081
           	<div class="row">
1082
	 	         <div class="col-12 mt-3">
1083
                        <?php
1084
                        $element = $form->get('marketplace');
1085
                        $element->setOptions(['label' => 'LABEL_MARKETPLACE']);
1086
                        $element->setAttributes(['class' => 'form-control']);
1087
                        $element->setAttributes(['accept' => 'image/jpg,image/jpeg,image/png']);
1088
                        echo $this->formLabel($element);
1089
                        echo $this->formFile($element);
1090
                        ?>
1091
          		</div>
1092
          	</div>
1093
	 	</div>
1094
	 	<div class="card-footer text-right">
1095
			<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1096
      		<button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
1097
	 	</div>
1098
	 	<?php echo $this->form()->closeTag($form); ?>
15139 stevensc 1099
	</div>
16905 efrain 1100
</div>
15139 stevensc 1101
 
1102
 
1103
 
1104
 
1105
 
16905 efrain 1106
 
1 www 1107
<!-- The Modal -->
16905 efrain 1108
<div class="modal" id="modalPreviewMarketPlace">
1 www 1109
	<div class="modal-dialog">
1110
		<div class="modal-content">
15139 stevensc 1111
			<!-- Modal Header -->
1112
			<div class="modal-header">
16845 efrain 1113
				<h6 class="modal-title">LABEL_IMAGE_MARKETPLACE</h6>
16822 efrain 1114
				<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
15139 stevensc 1115
			</div>
1 www 1116
 
15139 stevensc 1117
			<!-- Modal body -->
1118
			<div class="modal-body text-center">
1119
				<img src="" class="img img-responsive" style="width: 300px; height: auto" id="image-marketplace" />
1120
			</div>
1121
 
1122
			<!-- Modal footer -->
16891 efrain 1123
			<div class="modal-footer text-right">
15139 stevensc 1124
				<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
1125
			</div>
1126
		</div>
1 www 1127
	</div>
15139 stevensc 1128
</div>
1 www 1129
 
1130
 
1131
<!-- The Modal -->
16905 efrain 1132
<div class="modal" id="modalPreviewImage">
1 www 1133
	<div class="modal-dialog ">
15139 stevensc 1134
		<div class="modal-content">
1 www 1135
 
15139 stevensc 1136
			<!-- Modal Header -->
1137
			<div class="modal-header">
16845 efrain 1138
				<h6 class="modal-title">LABEL_IMAGE</h6>
16822 efrain 1139
				<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
15139 stevensc 1140
			</div>
1 www 1141
 
15139 stevensc 1142
			<!-- Modal body -->
1143
			<div class="modal-body text-center">
1 www 1144
				<img src="" class="img img-responsive" style="width: 300px; height: auto" id="image-app" />
15139 stevensc 1145
			</div>
1146
 
1147
			<!-- Modal footer -->
16891 efrain 1148
			<div class="modal-footer text-right">
15139 stevensc 1149
				<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
1150
			</div>
1151
		</div>
1 www 1152
	</div>
15139 stevensc 1153
</div>
1 www 1154
 
1155
 
1156
 
15139 stevensc 1157
 
1158
 
1159
 
1 www 1160
<!-- The Modal -->
1161
<div class="modal" id="notificationUsersModal">
1162
	<div class="modal-dialog modal-xl">
15139 stevensc 1163
		<div class="modal-content">
1 www 1164
 
15139 stevensc 1165
			<!-- Modal Header -->
1166
			<div class="modal-header">
16845 efrain 1167
				<h6 class="modal-title">LABEL_USERS</h6>
16822 efrain 1168
				<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
15139 stevensc 1169
			</div>
1 www 1170
 
15139 stevensc 1171
			<!-- Modal body -->
1172
			<div class="modal-body">
1173
				<form>
16905 efrain 1174
					<div class="row">
1175
						<div class="col-12 mt-3">
15139 stevensc 1176
						<label>LABEL_CAPSULE</label>
1177
						<input type="text" readonly="readonly" id="table-users-capsule" class="form-control">
16905 efrain 1178
						</div>
1179
					</div>
15139 stevensc 1180
				</form>
16905 efrain 1181
				<div class="row">
1182
					<div class="col-12 mt-3">
1183
        				<div style="height: 300px;overflow: scroll;">
1184
        					<table id="gridTableUsers" style="width: 100%" class="table   table-bordered">
1185
        						<thead>
1186
        							<tr>
1187
        								<th>LABEL_FIRST_NAME</th>
1188
        								<th>LABEL_LAST_NAME</th>
1189
        								<th>LABEL_EMAIL</th>
1190
        								<th>LABEL_DETAILS</th>
1191
        							</tr>
1192
        						</thead>
1193
        						<tbody>
1194
        						</tbody>
1195
        					</table>
1196
        				</div>
1197
    				</div>
1198
    			</div>
1 www 1199
 
15139 stevensc 1200
			</div>
1 www 1201
 
15139 stevensc 1202
			<!-- Modal footer -->
16891 efrain 1203
			<div class="modal-footer text-right">
15139 stevensc 1204
				<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
1205
			</div>
1206
 
1207
		</div>
15027 stevensc 1208
	</div>
15139 stevensc 1209
</div>