Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 17060 | Rev 17062 | 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
 
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
 
17061 stevensc 130
 
1 www 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',
17061 stevensc 142
 
1 www 143
    		'ajax': {
144
    			'url' : '$routeDatatable',
17061 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
 
17061 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']) {
17061 stevensc 672
                $('#table-users-capsule').val(response['data']['capsule']);
1 www 673
 
674
                $('#gridTableUsers tbody').empty();
675
 
676
                $.each(response['data']['items'], function(index, item) {
677
                    var s = '<tr>';
678
                    s = s + '<td>' + item['first_name'] + '</td>';
679
                    s = s + '<td>' + item['last_name'] + '</td>';
680
                    s = s + '<td>' + item['email'] + '</td>';
681
 
682
                    s = s + '<td>';
683
                    if(item['details']['access']) {
684
                        s = s + 'LABEL_ACCESS : ' + item['details']['access'] + '<br>';
685
                    }
686
                    if(item['details']['paid_from']) {
687
                        s = s + 'LABEL_PAID_FROM : ' + item['details']['paid_from'] + '<br>';
688
                    }
689
                    if(item['details']['paid_to']) {
690
                        s = s + 'LABEL_PAID_TO : ' + item['details']['paid_to'] + '<br>';
691
                    }
692
 
693
                    s = s + '</td>';
694
                    s = s + '</tr>';
695
 
696
                    $('#gridTableUsers tbody').append(s);
697
                });
698
 
699
                $('#notificationUsersModal').modal('show');
700
            } else {
701
                $.fn.showError(response['data']);
702
            }
703
        }).fail(function( jqXHR, textStatus, errorThrown) {
704
            $.fn.showError(textStatus);
705
        }).always(function() {
706
            NProgress.done();
707
        });
708
        return false;
709
    });
710
    $('body').on('click', 'button.btn-refresh', function(e) {
711
        e.preventDefault();
712
        gridTable.api().ajax.reload(null, false);
713
    });
16822 efrain 714
 
715
    $('body').on('click', 'button.btn-delete', function(e) {
716
        e.preventDefault();
717
        var action = $(this).data('href');
718
 
719
 
720
          swal.fire({
721
            title: 'LABEL_ARE_YOU_SURE',
722
            icon: 'question',
723
            cancelButtonText: 'LABEL_NO',
724
            showCancelButton: true,
725
            confirmButtonText: 'LABEL_YES'
726
          }).then((result) => {
727
            if (result.isConfirmed) {
728
 
729
                    NProgress.start();
730
                    $.ajax({
731
                        'dataType'  : 'json',
732
                        'accept'    : 'application/json',
733
                        'method'    : 'post',
734
                        'url'       :  action,
735
                    }).done(function(response) {
736
                        if(response['success']) {
737
                            $.fn.showSuccess(response['data']);
738
                            gridTable.api().ajax.reload(null, false);
739
                        } else {
740
                            $.fn.showError(response['data']);
741
                        }
742
                    }).fail(function( jqXHR, textStatus, errorThrown) {
743
                        $.fn.showError(textStatus);
744
                    }).always(function() {
745
                        NProgress.done();
746
                    });
747
                }
748
           });
749
        });
1 www 750
 
6682 nelberth 751
 
16905 efrain 752
  $('#form-add #file').fileinput({
753
                theme: 'fa',
754
                language: 'es',
755
                showUpload: false,
756
                dropZoneEnabled: false,
757
                maxFileCount: 1,
16928 efrain 758
                msgPlaceholder:  'LABEL_RECOMMENDED_SIZE $image_size',
16905 efrain 759
                allowedFileExtensions: ['jpeg', 'jpg', 'png'],
760
            });
6682 nelberth 761
 
16905 efrain 762
  $('#form-add #marketplace').fileinput({
763
                theme: 'fa',
764
                language: 'es',
765
                showUpload: false,
766
                dropZoneEnabled: false,
767
                maxFileCount: 1,
16928 efrain 768
                msgPlaceholder: 'LABEL_RECOMMENDED_SIZE $marketplace_size',
16905 efrain 769
                allowedFileExtensions: ['jpeg', 'jpg', 'png'],
770
            });
771
 
772
            $('#form-edit #file').fileinput({
773
                theme: 'fa',
774
                language: 'es',
775
                showUpload: false,
776
                dropZoneEnabled: false,
777
                maxFileCount: 1,
16928 efrain 778
                msgPlaceholder: 'LABEL_RECOMMENDED_SIZE $image_size',
16905 efrain 779
                allowedFileExtensions: ['jpeg', 'jpg', 'png'],
780
            });
6682 nelberth 781
 
16945 efrain 782
            $('#form-edit #marketplace').fileinput({
16905 efrain 783
                theme: 'fa',
784
                language: 'es',
785
                showUpload: false,
786
                dropZoneEnabled: false,
787
                maxFileCount: 1,
16928 efrain 788
                msgPlaceholder:  'LABEL_RECOMMENDED_SIZE $marketplace_size',
16905 efrain 789
                allowedFileExtensions: ['jpeg', 'jpg', 'png'],
790
            });
791
 
792
        $('body').on('click', 'button.btn-cancel', function(e) {
793
            e.preventDefault();
794
            $('#row-add').hide();
795
            $('#row-edit').hide();
796
            $('#row-listing').show();
797
 
798
        });
8583 nelberth 799
 
1 www 800
});
801
JS;
802
$this->inlineScript()->captureEnd();
803
?>
804
 
15139 stevensc 805
 
16905 efrain 806
<div class="container">
807
	<div class="card" id="row-listing">
808
	 	<div class="card-header">
809
	 		<h6 class="card-title">LABEL_CAPSULES</h6>
810
	 	</div>
811
	 	<div class="card-body">
812
			<div class="row">
813
	 	         <div class="col-12 mt-3">
17061 stevensc 814
					<table id="gridTable" class="table table-bordered">
15139 stevensc 815
							<thead>
816
								<tr>
817
									<th>LABEL_NAME</th>
818
									<th>LABEL_DETAILS</th>
819
									<th>LABEL_IMAGES</th>
820
									<th>LABEL_ACTIONS</th>
821
								</tr>
822
							</thead>
16905 efrain 823
						<tbody>
824
						</tbody>
825
					</table>
826
	 	         </div>
827
	 	     </div>
828
	 	</div>
829
	 	<div class="card-footer text-right">
16992 efrain 830
			<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-sync"></i> LABEL_REFRESH </button>
16905 efrain 831
			<?php if ($allowAdd) : ?>
832
			<button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
833
			<?php endif; ?>
834
	 	</div>
15139 stevensc 835
	</div>
16905 efrain 836
 
837
	<div class="card" id="row-add" style="display: none">
838
	 	<div class="card-header">
839
	 		<h6 class="card-title">LABEL_ADD_CAPSULE</h6>
840
	 	</div>
841
	 	<?php
15139 stevensc 842
		$form = $this->formAdd;
843
		$form->setAttributes([
844
			'method'  => 'post',
845
			'action'  => '',
16905 efrain 846
			'name'    => 'form-add',
847
			'id'      => 'form-add',
15139 stevensc 848
		]);
1 www 849
 
15139 stevensc 850
		$form->prepare();
851
		echo $this->form()->openTag($form);
852
		?>
16905 efrain 853
	 	<div class="card-body">
854
	 		<div class="row">
855
	 	         <div class="col-12 mt-3">
856
    			<?php
857
    			$element = $form->get('name');
858
 
859
    			$element->setAttributes(['class' => 'form-control']);
860
    			$element->setOptions(['label' => 'LABEL_NAME']);
861
    			echo $this->formLabel($element);
862
    			echo $this->formText($element);
863
    			?>
864
    			</div>
865
    		</div>
866
	 		<div class="row">
867
	 	         <div class="col-12 mt-3">
868
        			<?php
869
        			$element = $form->get('description');
870
        			$element->setAttributes(['id' => 'description_add', 'class' => 'form-control', 'rows' => '2', 'class' => 'form-control']);
871
        			$element->setOptions(['label' => 'LABEL_DESCRIPTION']);
872
        			echo $this->formLabel($element);
873
        			echo $this->formTextArea($element);
874
        			?>
875
        		</div>
876
        	</div>
877
	 		<div class="row">
878
	 	         <div class="col-12 mt-3">
879
        			<?php
880
        			$element = $form->get('order');
881
        			$element->setAttributes(['class' => 'form-control']);
882
        			$element->setOptions(['label' => 'LABEL_ORDER']);
883
        			echo $this->formLabel($element);
884
        			echo $this->formText($element);
885
        			?>
886
        		</div>
15139 stevensc 887
			</div>
16905 efrain 888
	 		<div class="row">
889
	 	         <div class="col-12 mt-3">
890
    			<?php
891
    			$element = $form->get('status');
892
    			$element->setAttributes(['class' => 'form-control']);
893
    			$element->setOptions(['label' => 'LABEL_STATUS']);
894
    			echo $this->formLabel($element);
895
    			echo $this->formSelect($element);
896
    			?>
897
				</div>
898
			</div>
899
	 		<div class="row">
900
	 	         <div class="col-12 mt-3">
901
        			<?php
902
        			$element = $form->get('privacy');
903
        			$element->setAttributes(['class' => 'form-control']);
904
        			$element->setOptions(['label' => 'LABEL_PRIVACY']);
905
        			echo $this->formLabel($element);
906
        			echo $this->formSelect($element);
907
        			?>
908
        		</div>
909
        	</div>
910
			<div class="row">
911
	 			<div class="col-12 mt-3">
912
        			<?php
913
        			$element = $form->get('type');
914
        			$element->setAttributes(['class' => 'form-control']);
915
        			$element->setOptions(['label' => 'LABEL_TYPE']);
916
        			echo $this->formLabel($element);
917
        			echo $this->formSelect($element);
918
        			?>
919
        		</div>
920
        	</div>
15139 stevensc 921
 
16905 efrain 922
		  	<div class="row"  id="form-row-cost">
923
	 			<div class="col-12 mt-3">
924
        			<?php
925
        			$element = $form->get('cost');
926
        			$element->setAttributes(['class' => 'form-control']);
927
        			$element->setOptions(['label' => 'LABEL_COST']);
928
        			echo $this->formLabel($element);
929
        			echo $this->formText($element);
930
        			?>
931
				</div>
932
			</div>
933
			<div class="row">
934
	 	 		<div class="col-12 mt-3">
935
                        <?php
936
                        $element = $form->get('file');
937
                        $element->setOptions(['label' => 'LABEL_IMAGE']);
938
                        $element->setAttributes(['class' => 'form-control']);
939
                        $element->setAttributes(['accept' => 'image/jpg,image/jpeg,image/png']);
940
                        echo $this->formLabel($element);
941
                        echo $this->formFile($element);
942
                        ?>
943
            	</div>
944
           	</div>
945
           	<div class="row">
946
	 	         <div class="col-12 mt-3">
947
                        <?php
948
                        $element = $form->get('marketplace');
949
                        $element->setOptions(['label' => 'LABEL_MARKETPLACE']);
950
                        $element->setAttributes(['class' => 'form-control']);
951
                        $element->setAttributes(['accept' => 'image/jpg,image/jpeg,image/png']);
952
                        echo $this->formLabel($element);
953
                        echo $this->formFile($element);
954
                        ?>
955
          		</div>
956
          	</div>
957
	 	</div>
958
	 	<div class="card-footer text-right">
959
			<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
960
      		<button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
961
	 	</div>
962
	 	<?php echo $this->form()->closeTag($form); ?>
15139 stevensc 963
	</div>
16905 efrain 964
 
965
	<div class="card" id="row-edit" style="display: none">
966
	 	<div class="card-header">
967
	 		<h6 class="card-title">LABEL_EDIT_CAPSULE</h6>
968
	 	</div>
969
	 	<?php
15139 stevensc 970
		$form = $this->formEdit;
971
		$form->setAttributes([
16905 efrain 972
		    'method'    => 'post',
973
		    'name'      => 'form-edit',
974
		    'id'        => 'form-edit'
15139 stevensc 975
		]);
1 www 976
 
15139 stevensc 977
		$form->prepare();
978
		echo $this->form()->openTag($form);
979
		?>
16905 efrain 980
	 	<div class="card-body">
981
	 		<div class="row">
982
	 	         <div class="col-12 mt-3">
983
    			<?php
984
    			$element = $form->get('name');
985
 
986
    			$element->setAttributes(['class' => 'form-control']);
987
    			$element->setOptions(['label' => 'LABEL_NAME']);
988
    			echo $this->formLabel($element);
989
    			echo $this->formText($element);
990
    			?>
991
    			</div>
992
    		</div>
993
	 		<div class="row">
994
	 	         <div class="col-12 mt-3">
995
        			<?php
996
        			$element = $form->get('description');
997
        			$element->setAttributes(['id' => 'description_edit', 'class' => 'form-control', 'rows' => '2', 'class' => 'form-control']);
998
        			$element->setOptions(['label' => 'LABEL_DESCRIPTION']);
999
        			echo $this->formLabel($element);
1000
        			echo $this->formTextArea($element);
1001
        			?>
1002
        		</div>
1003
        	</div>
1004
	 		<div class="row">
1005
	 	         <div class="col-12 mt-3">
1006
        			<?php
1007
        			$element = $form->get('order');
1008
        			$element->setAttributes(['class' => 'form-control']);
1009
        			$element->setOptions(['label' => 'LABEL_ORDER']);
1010
        			echo $this->formLabel($element);
1011
        			echo $this->formText($element);
1012
        			?>
1013
        		</div>
15139 stevensc 1014
			</div>
16905 efrain 1015
	 		<div class="row">
1016
	 	         <div class="col-12 mt-3">
1017
    			<?php
1018
    			$element = $form->get('status');
1019
    			$element->setAttributes(['class' => 'form-control']);
1020
    			$element->setOptions(['label' => 'LABEL_STATUS']);
1021
    			echo $this->formLabel($element);
1022
    			echo $this->formSelect($element);
1023
    			?>
1024
				</div>
1025
			</div>
1026
	 		<div class="row">
1027
	 	         <div class="col-12 mt-3">
1028
        			<?php
1029
        			$element = $form->get('privacy');
1030
        			$element->setAttributes(['class' => 'form-control']);
1031
        			$element->setOptions(['label' => 'LABEL_PRIVACY']);
1032
        			echo $this->formLabel($element);
1033
        			echo $this->formSelect($element);
1034
        			?>
1035
        		</div>
1036
        	</div>
1037
			<div class="row">
1038
	 			<div class="col-12 mt-3">
1039
        			<?php
1040
        			$element = $form->get('type');
1041
        			$element->setAttributes(['class' => 'form-control']);
1042
        			$element->setOptions(['label' => 'LABEL_TYPE']);
1043
        			echo $this->formLabel($element);
1044
        			echo $this->formSelect($element);
1045
        			?>
1046
        		</div>
1047
        	</div>
15139 stevensc 1048
 
16905 efrain 1049
		  	<div class="row"  id="form-row-cost">
1050
	 			<div class="col-12 mt-3">
1051
        			<?php
1052
        			$element = $form->get('cost');
1053
        			$element->setAttributes(['class' => 'form-control']);
1054
        			$element->setOptions(['label' => 'LABEL_COST']);
1055
        			echo $this->formLabel($element);
1056
        			echo $this->formText($element);
1057
        			?>
1058
				</div>
1059
			</div>
1060
			<div class="row">
1061
	 	 		<div class="col-12 mt-3">
1062
                        <?php
1063
                        $element = $form->get('file');
1064
                        $element->setOptions(['label' => 'LABEL_IMAGE']);
1065
                        $element->setAttributes(['class' => 'form-control']);
1066
                        $element->setAttributes(['accept' => 'image/jpg,image/jpeg,image/png']);
1067
                        echo $this->formLabel($element);
1068
                        echo $this->formFile($element);
1069
                        ?>
1070
            	</div>
1071
           	</div>
1072
           	<div class="row">
1073
	 	         <div class="col-12 mt-3">
1074
                        <?php
1075
                        $element = $form->get('marketplace');
1076
                        $element->setOptions(['label' => 'LABEL_MARKETPLACE']);
1077
                        $element->setAttributes(['class' => 'form-control']);
1078
                        $element->setAttributes(['accept' => 'image/jpg,image/jpeg,image/png']);
1079
                        echo $this->formLabel($element);
1080
                        echo $this->formFile($element);
1081
                        ?>
1082
          		</div>
1083
          	</div>
1084
	 	</div>
1085
	 	<div class="card-footer text-right">
1086
			<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1087
      		<button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
1088
	 	</div>
1089
	 	<?php echo $this->form()->closeTag($form); ?>
15139 stevensc 1090
	</div>
16905 efrain 1091
</div>
15139 stevensc 1092
 
1093
 
1094
 
1095
 
1096
 
16905 efrain 1097
 
1 www 1098
<!-- The Modal -->
16905 efrain 1099
<div class="modal" id="modalPreviewMarketPlace">
1 www 1100
	<div class="modal-dialog">
1101
		<div class="modal-content">
15139 stevensc 1102
			<!-- Modal Header -->
1103
			<div class="modal-header">
16845 efrain 1104
				<h6 class="modal-title">LABEL_IMAGE_MARKETPLACE</h6>
16822 efrain 1105
				<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
15139 stevensc 1106
			</div>
1 www 1107
 
15139 stevensc 1108
			<!-- Modal body -->
1109
			<div class="modal-body text-center">
1110
				<img src="" class="img img-responsive" style="width: 300px; height: auto" id="image-marketplace" />
1111
			</div>
1112
 
1113
			<!-- Modal footer -->
16891 efrain 1114
			<div class="modal-footer text-right">
15139 stevensc 1115
				<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
1116
			</div>
1117
		</div>
1 www 1118
	</div>
15139 stevensc 1119
</div>
1 www 1120
 
1121
 
1122
<!-- The Modal -->
16905 efrain 1123
<div class="modal" id="modalPreviewImage">
1 www 1124
	<div class="modal-dialog ">
15139 stevensc 1125
		<div class="modal-content">
1 www 1126
 
15139 stevensc 1127
			<!-- Modal Header -->
1128
			<div class="modal-header">
16845 efrain 1129
				<h6 class="modal-title">LABEL_IMAGE</h6>
16822 efrain 1130
				<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
15139 stevensc 1131
			</div>
1 www 1132
 
15139 stevensc 1133
			<!-- Modal body -->
1134
			<div class="modal-body text-center">
1 www 1135
				<img src="" class="img img-responsive" style="width: 300px; height: auto" id="image-app" />
15139 stevensc 1136
			</div>
1137
 
1138
			<!-- Modal footer -->
16891 efrain 1139
			<div class="modal-footer text-right">
15139 stevensc 1140
				<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
1141
			</div>
1142
		</div>
1 www 1143
	</div>
15139 stevensc 1144
</div>
1 www 1145
 
1146
 
1147
 
15139 stevensc 1148
 
1149
 
1150
 
1 www 1151
<!-- The Modal -->
1152
<div class="modal" id="notificationUsersModal">
1153
	<div class="modal-dialog modal-xl">
15139 stevensc 1154
		<div class="modal-content">
1 www 1155
 
15139 stevensc 1156
			<!-- Modal Header -->
1157
			<div class="modal-header">
16845 efrain 1158
				<h6 class="modal-title">LABEL_USERS</h6>
16822 efrain 1159
				<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
15139 stevensc 1160
			</div>
1 www 1161
 
15139 stevensc 1162
			<!-- Modal body -->
1163
			<div class="modal-body">
1164
				<form>
16905 efrain 1165
					<div class="row">
1166
						<div class="col-12 mt-3">
15139 stevensc 1167
						<label>LABEL_CAPSULE</label>
1168
						<input type="text" readonly="readonly" id="table-users-capsule" class="form-control">
16905 efrain 1169
						</div>
1170
					</div>
15139 stevensc 1171
				</form>
16905 efrain 1172
				<div class="row">
1173
					<div class="col-12 mt-3">
1174
        				<div style="height: 300px;overflow: scroll;">
17061 stevensc 1175
        					<table id="gridTableUsers" style="width: 100%" class="table table-bordered">
16905 efrain 1176
        						<thead>
1177
        							<tr>
1178
        								<th>LABEL_FIRST_NAME</th>
1179
        								<th>LABEL_LAST_NAME</th>
1180
        								<th>LABEL_EMAIL</th>
1181
        								<th>LABEL_DETAILS</th>
1182
        							</tr>
1183
        						</thead>
1184
        						<tbody>
1185
        						</tbody>
1186
        					</table>
1187
        				</div>
1188
    				</div>
1189
    			</div>
15139 stevensc 1190
			</div>
1 www 1191
 
15139 stevensc 1192
			<!-- Modal footer -->
16891 efrain 1193
			<div class="modal-footer text-right">
15139 stevensc 1194
				<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
1195
			</div>
1196
 
1197
		</div>
15027 stevensc 1198
	</div>
15139 stevensc 1199
</div>