| 17014 | efrain | 1 | <?php
 | 
        
           |  |  | 2 | $acl            = $this->viewModel()->getRoot()->getVariable('acl');
 | 
        
           |  |  | 3 | $currentUser    = $this->currentUserHelper();
 | 
        
           |  |  | 4 |   | 
        
           |  |  | 5 | $roleName = $currentUser->getUserTypeId();
 | 
        
           |  |  | 6 |   | 
        
           |  |  | 7 |   | 
        
           |  |  | 8 | $routeAdd       = $this->url('habits/content/add');
 | 
        
           |  |  | 9 | $routeDatatable = $this->url('habits/content');
 | 
        
           |  |  | 10 |   | 
        
           |  |  | 11 | $allowAdd       = $acl->isAllowed($roleName, 'habits/content/add') ? 1 : 0;
 | 
        
           |  |  | 12 | $allowEdit      = $acl->isAllowed($roleName, 'habits/content/edit') ? 1 : 0;
 | 
        
           |  |  | 13 | $allowDelete    = $acl->isAllowed($roleName, 'habits/content/delete') ? 1 : 0;
 | 
        
           |  |  | 14 |   | 
        
           |  |  | 15 |   | 
        
           |  |  | 16 | $this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
 | 
        
           |  |  | 17 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
 | 
        
           |  |  | 18 |   | 
        
           |  |  | 19 |   | 
        
           |  |  | 20 |   | 
        
           |  |  | 21 |   | 
        
           |  |  | 22 |   | 
        
           |  |  | 23 | $this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));
 | 
        
           |  |  | 24 |   | 
        
           |  |  | 25 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
 | 
        
           |  |  | 26 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));
 | 
        
           |  |  | 27 |   | 
        
           |  |  | 28 |   | 
        
           |  |  | 29 | $this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-fileinput/css/fileinput.min.css'));
 | 
        
           |  |  | 30 | $this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-fileinput/themes/explorer-fas/theme.css'));
 | 
        
           |  |  | 31 |   | 
        
           |  |  | 32 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/plugins/piexif.js'));
 | 
        
           |  |  | 33 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/plugins/sortable.js'));
 | 
        
           |  |  | 34 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/fileinput.js'));
 | 
        
           |  |  | 35 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/locales/es.js'));
 | 
        
           |  |  | 36 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/themes/fas/theme.js'));
 | 
        
           |  |  | 37 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/themes/explorer-fas/theme.js'));
 | 
        
           |  |  | 38 |   | 
        
           |  |  | 39 |   | 
        
           |  |  | 40 |   | 
        
           |  |  | 41 |   | 
        
           |  |  | 42 | $this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
 | 
        
           |  |  | 43 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
 | 
        
           |  |  | 44 |   | 
        
           |  |  | 45 |   | 
        
           |  |  | 46 |   | 
        
           |  |  | 47 |   | 
        
           |  |  | 48 |   | 
        
           |  |  | 49 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-input-number/input-number-format.jquery.js'));
 | 
        
           |  |  | 50 |   | 
        
           |  |  | 51 | $status_active = \LeadersLinked\Model\HabitEmoji::STATUS_ACTIVE;
 | 
        
           |  |  | 52 |   | 
        
           |  |  | 53 | $this->inlineScript()->captureStart();
 | 
        
           |  |  | 54 | echo <<<JS
 | 
        
           |  |  | 55 |     jQuery( document ).ready(function( $ ) {
 | 
        
           |  |  | 56 |   | 
        
           |  |  | 57 |   | 
        
           |  |  | 58 |   | 
        
           |  |  | 59 |   | 
        
           |  |  | 60 |   | 
        
           |  |  | 61 |   | 
        
           |  |  | 62 |         var allowEdit   = $allowEdit;
 | 
        
           |  |  | 63 |         var allowDelete = $allowDelete;
 | 
        
           |  |  | 64 |   | 
        
           |  |  | 65 |         var gridTable = $('#gridTable').dataTable( {
 | 
        
           |  |  | 66 |             'processing': true,
 | 
        
           |  |  | 67 |             'serverSide': true,
 | 
        
           |  |  | 68 |             'searching': true,
 | 
        
           |  |  | 69 |             'order': [[ 0, 'asc' ]],
 | 
        
           |  |  | 70 |             'ordering':  true,
 | 
        
           |  |  | 71 |             'ordenable' : true,
 | 
        
           |  |  | 72 |             'responsive': true,
 | 
        
           |  |  | 73 |             'select' : false,
 | 
        
           |  |  | 74 |         	'paging': true,
 | 
        
           |  |  | 75 |             'pagingType': 'simple_numbers',
 | 
        
           |  |  | 76 |     		'ajax': {
 | 
        
           |  |  | 77 |     			'url' : '$routeDatatable',
 | 
        
           |  |  | 78 |     			'type' : 'get',
 | 
        
           |  |  | 79 |                 'beforeSend': function (request) {
 | 
        
           |  |  | 80 |                   NProgress.start();
 | 
        
           |  |  | 81 |                 },
 | 
        
           |  |  | 82 |                 'dataFilter': function(response) {
 | 
        
           |  |  | 83 |                     var response = jQuery.parseJSON( response );
 | 
        
           |  |  | 84 |   | 
        
           |  |  | 85 |                     var json                = {};
 | 
        
           |  |  | 86 |                     json.recordsTotal       = 0;
 | 
        
           |  |  | 87 |                     json.recordsFiltered    = 0;
 | 
        
           |  |  | 88 |                     json.data               = [];
 | 
        
           |  |  | 89 |   | 
        
           |  |  | 90 |   | 
        
           |  |  | 91 |                     if(response.success) {
 | 
        
           |  |  | 92 |                         json.recordsTotal       = response.data.total;
 | 
        
           |  |  | 93 |                         json.recordsFiltered    = response.data.total;
 | 
        
           |  |  | 94 |                         json.data               = response.data.items;
 | 
        
           |  |  | 95 |                     } else {
 | 
        
           |  |  | 96 |                         $.fn.showError(response.data)
 | 
        
           |  |  | 97 |                     }
 | 
        
           |  |  | 98 |   | 
        
           |  |  | 99 |                     return JSON.stringify( json );
 | 
        
           |  |  | 100 |                 }
 | 
        
           |  |  | 101 |     		},
 | 
        
           |  |  | 102 |             'language' : {
 | 
        
           |  |  | 103 |                 'sProcessing':     'LABEL_DATATABLE_SPROCESSING',
 | 
        
           |  |  | 104 |                 'sLengthMenu':     'LABEL_DATATABLE_SLENGTHMENU',
 | 
        
           |  |  | 105 |                 'sZeroRecords':    'LABEL_DATATABLE_SZERORECORDS',
 | 
        
           |  |  | 106 |                 'sEmptyTable':     'LABEL_DATATABLE_SEMPTYTABLE',
 | 
        
           |  |  | 107 |                 'sInfo':           'LABEL_DATATABLE_SINFO',
 | 
        
           |  |  | 108 |                 'sInfoEmpty':      'LABEL_DATATABLE_SINFOEMPTY',
 | 
        
           |  |  | 109 |                 'sInfoFiltered':   'LABEL_DATATABLE_SINFOFILTERED',
 | 
        
           |  |  | 110 |                 'sInfoPostFix':    '',
 | 
        
           |  |  | 111 |                 'sSearch':         'LABEL_DATATABLE_SSEARCH',
 | 
        
           |  |  | 112 |                 'sUrl':            '',
 | 
        
           |  |  | 113 |                 'sInfoThousands':  ',',
 | 
        
           |  |  | 114 |                 'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
 | 
        
           |  |  | 115 |                 'oPaginate': {
 | 
        
           |  |  | 116 |                     'sFirst':    'LABEL_DATATABLE_SFIRST',
 | 
        
           |  |  | 117 |                     'sLast':     'LABEL_DATATABLE_SLAST',
 | 
        
           |  |  | 118 |                     'sNext':     'LABEL_DATATABLE_SNEXT',
 | 
        
           |  |  | 119 |                     'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
 | 
        
           |  |  | 120 |                 },
 | 
        
           |  |  | 121 |                 'oAria': {
 | 
        
           |  |  | 122 |                     'sSortAscending':  ': LABEL_DATATABLE_SSORTASCENDING',
 | 
        
           |  |  | 123 |                     'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
 | 
        
           |  |  | 124 |                 },
 | 
        
           |  |  | 125 |             },
 | 
        
           |  |  | 126 |             'drawCallback': function( settings ) {
 | 
        
           |  |  | 127 |                 NProgress.done();
 | 
        
           |  |  | 128 |   | 
        
           |  |  | 129 |             },
 | 
        
           |  |  | 130 |             'aoColumns': [
 | 
        
           |  |  | 131 |                 { 'mDataProp': 'order' },
 | 
        
           |  |  | 132 |                 { 'mDataProp': 'name' },
 | 
        
           |  |  | 133 |                 { 'mDataProp': 'type' },
 | 
        
           |  |  | 134 |                 { 'mDataProp': 'file' },
 | 
        
           |  |  | 135 |                 { 'mDataProp': 'actions' },
 | 
        
           |  |  | 136 |   | 
        
           |  |  | 137 |     	    ],
 | 
        
           |  |  | 138 |             'columnDefs': [
 | 
        
           |  |  | 139 |                 {
 | 
        
           |  |  | 140 |                     'targets': 0,
 | 
        
           |  |  | 141 |                     'className' : 'text-vertical-middle',
 | 
        
           |  |  | 142 |                 },
 | 
        
           |  |  | 143 |                 {
 | 
        
           |  |  | 144 |                     'targets': 1,
 | 
        
           |  |  | 145 |                     'orderable': false,
 | 
        
           |  |  | 146 |                 },
 | 
        
           |  |  | 147 |                 {
 | 
        
           |  |  | 148 |                     'targets': 2,
 | 
        
           |  |  | 149 |                     'orderable': false,
 | 
        
           |  |  | 150 |                 },
 | 
        
           |  |  | 151 |                 {
 | 
        
           |  |  | 152 |                     'targets': 3,
 | 
        
           |  |  | 153 |                     'orderable': false,
 | 
        
           |  |  | 154 |                 },
 | 
        
           |  |  | 155 |   | 
        
           |  |  | 156 |                 {
 | 
        
           |  |  | 157 |                     'targets': 4,
 | 
        
           |  |  | 158 |                     'orderable': false,
 | 
        
           |  |  | 159 |                     'render' : function ( data, type, row ) {
 | 
        
           |  |  | 160 |                         s = '';
 | 
        
           |  |  | 161 |   | 
        
           |  |  | 162 |                         if(allowEdit && data['link_edit']) {
 | 
        
           |  |  | 163 |                             s = s + '<button class="btn btn-primary btn-edit" data-href="' + data['link_edit']+ '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pen"></i> LABEL_EDIT </button> ';
 | 
        
           |  |  | 164 |                         }
 | 
        
           |  |  | 165 |                         if(allowDelete && data['link_delete']) {
 | 
        
           |  |  | 166 |                             s = s + '<button class="btn btn-danger btn-delete" data-href="' + data['link_delete']+ '" data-toggle="tooltip" title="LABEL_DELETE"><i class="fa fa-trash"></i> LABEL_DELETE </button> ';
 | 
        
           |  |  | 167 |                         }
 | 
        
           |  |  | 168 |                         return s;
 | 
        
           |  |  | 169 |                     }
 | 
        
           |  |  | 170 |                 }
 | 
        
           |  |  | 171 |               ],
 | 
        
           |  |  | 172 |         });
 | 
        
           |  |  | 173 |   | 
        
           |  |  | 174 |   | 
        
           |  |  | 175 |         var validatorAdd = $('#form-add').validate({
 | 
        
           |  |  | 176 |             debug: true,
 | 
        
           |  |  | 177 |             onclick: false,
 | 
        
           |  |  | 178 |             onkeyup: false,
 | 
        
           |  |  | 179 |             ignore: [],
 | 
        
           |  |  | 180 |             rules: {
 | 
        
           |  |  | 181 |                 'name': {
 | 
        
           |  |  | 182 |                     required: true,
 | 
        
           |  |  | 183 |                     maxlength: 100,
 | 
        
           |  |  | 184 |                 },
 | 
        
           |  |  | 185 |                 'order': {
 | 
        
           |  |  | 186 |                     required: true,
 | 
        
           |  |  | 187 |                     min: 0,
 | 
        
           |  |  | 188 |   | 
        
           |  |  | 189 |                 },
 | 
        
           |  |  | 190 |                 'status': {
 | 
        
           |  |  | 191 |                     required: false,
 | 
        
           |  |  | 192 |   | 
        
           |  |  | 193 |                 },
 | 
        
           |  |  | 194 |                'file': {
 | 
        
           |  |  | 195 |                     required: false,
 | 
        
           |  |  | 196 |                     extension: 'jpg|jpeg|png|webm|mp4|webm|pdf|wav|mp3',
 | 
        
           |  |  | 197 |                     accept: 'image/jpg,image/jpeg,image/png,video/webm,video/mpeg,video/mp4,application/pdf,audio/wav, audio/mpeg'
 | 
        
           |  |  | 198 |                 }
 | 
        
           |  |  | 199 |             },
 | 
        
           |  |  | 200 |             submitHandler: function(form)
 | 
        
           |  |  | 201 |             {
 | 
        
           |  |  | 202 |                 var formdata = false;
 | 
        
           |  |  | 203 |                 if (window.FormData){
 | 
        
           |  |  | 204 |                     formdata = new FormData(form); //form[0]);
 | 
        
           |  |  | 205 |                 }
 | 
        
           |  |  | 206 |   | 
        
           |  |  | 207 |   | 
        
           |  |  | 208 |                 $.ajax({
 | 
        
           |  |  | 209 |                     'dataType'  : 'json',
 | 
        
           |  |  | 210 |                     'accept'    : 'application/json',
 | 
        
           |  |  | 211 |                     'method'    : 'post',
 | 
        
           |  |  | 212 |                     'url'       :  $('#form-add').attr('action'),
 | 
        
           |  |  | 213 |                     'data'      :  formdata ? formdata : $('#form-add').serialize(),
 | 
        
           |  |  | 214 |                     'processData': false,
 | 
        
           |  |  | 215 |                     'contentType': false,
 | 
        
           |  |  | 216 |                 }).done(function(response) {
 | 
        
           |  |  | 217 |                     NProgress.start();
 | 
        
           |  |  | 218 |                     if(response['success']) {
 | 
        
           |  |  | 219 |                         $.fn.showSuccess(response['data']);
 | 
        
           |  |  | 220 |   | 
        
           |  |  | 221 |                         $('#modal-add').modal('hide');
 | 
        
           |  |  | 222 |   | 
        
           |  |  | 223 |   | 
        
           |  |  | 224 |                         gridTable.api().ajax.reload(null, false);
 | 
        
           |  |  | 225 |                     } else {
 | 
        
           |  |  | 226 |                         validatorAdd.resetForm();
 | 
        
           |  |  | 227 |                         if(jQuery.type(response['data']) == 'string') {
 | 
        
           |  |  | 228 |                             $.fn.showError(response['data']);
 | 
        
           |  |  | 229 |                         } else  {
 | 
        
           |  |  | 230 |                             $.each(response['data'], function( fieldname, errors ) {
 | 
        
           |  |  | 231 |                                 $.fn.showFormErrorValidator('#form-add #' + fieldname, errors);
 | 
        
           |  |  | 232 |                             });
 | 
        
           |  |  | 233 |                         }
 | 
        
           |  |  | 234 |                     }
 | 
        
           |  |  | 235 |                 }).fail(function( jqXHR, textStatus, errorThrown) {
 | 
        
           |  |  | 236 |                     $.fn.showError(textStatus);
 | 
        
           |  |  | 237 |                 }).always(function() {
 | 
        
           |  |  | 238 |                     NProgress.done();
 | 
        
           |  |  | 239 |                 });
 | 
        
           |  |  | 240 |                 return false;
 | 
        
           |  |  | 241 |             },
 | 
        
           |  |  | 242 |             invalidHandler: function(form, validator) {
 | 
        
           |  |  | 243 |             }
 | 
        
           |  |  | 244 |         });
 | 
        
           |  |  | 245 |   | 
        
           |  |  | 246 |         var validatorEdit = $('#form-edit').validate({
 | 
        
           |  |  | 247 |             debug: true,
 | 
        
           |  |  | 248 |             onclick: false,
 | 
        
           |  |  | 249 |             onkeyup: false,
 | 
        
           |  |  | 250 |             ignore: [],
 | 
        
           |  |  | 251 |             rules: {
 | 
        
           |  |  | 252 |                 'name': {
 | 
        
           |  |  | 253 |                     required: true,
 | 
        
           |  |  | 254 |                     maxlength: 100,
 | 
        
           |  |  | 255 |                 },
 | 
        
           |  |  | 256 |   | 
        
           |  |  | 257 |                 'order': {
 | 
        
           |  |  | 258 |                     required: true,
 | 
        
           |  |  | 259 |                     min: 0,
 | 
        
           |  |  | 260 |   | 
        
           |  |  | 261 |                 },
 | 
        
           |  |  | 262 |                 'status': {
 | 
        
           |  |  | 263 |                     required: false,
 | 
        
           |  |  | 264 |   | 
        
           |  |  | 265 |                 },
 | 
        
           |  |  | 266 |                'file': {
 | 
        
           |  |  | 267 |                     required: false,
 | 
        
           |  |  | 268 |                     extension: 'jpg|jpeg|png|webm|mp4|webm|pdf|wav|mp3',
 | 
        
           |  |  | 269 |                     accept: 'image/jpg,image/jpeg,image/png,video/webm,video/mpeg,video/mp4,application/pdf,audio/wav, audio/mpeg'
 | 
        
           |  |  | 270 |                 }
 | 
        
           |  |  | 271 |   | 
        
           |  |  | 272 |             },
 | 
        
           |  |  | 273 |             submitHandler: function(form)
 | 
        
           |  |  | 274 |             {
 | 
        
           |  |  | 275 |                 var formdata = false;
 | 
        
           |  |  | 276 |                 if (window.FormData){
 | 
        
           |  |  | 277 |                     formdata = new FormData(form); //form[0]);
 | 
        
           |  |  | 278 |                 }
 | 
        
           |  |  | 279 |   | 
        
           |  |  | 280 |   | 
        
           |  |  | 281 |                 $.ajax({
 | 
        
           |  |  | 282 |                     'dataType'  : 'json',
 | 
        
           |  |  | 283 |                     'accept'    : 'application/json',
 | 
        
           |  |  | 284 |                     'method'    : 'post',
 | 
        
           |  |  | 285 |                     'url'       :  $('#form-edit').attr('action'),
 | 
        
           |  |  | 286 |                     'data'      :  formdata ? formdata : $('#form-edit').serialize(),
 | 
        
           |  |  | 287 |                     'processData': false,
 | 
        
           |  |  | 288 |                     'contentType': false,
 | 
        
           |  |  | 289 |                 }).done(function(response) {
 | 
        
           |  |  | 290 |                     NProgress.start();
 | 
        
           |  |  | 291 |                     if(response['success']) {
 | 
        
           |  |  | 292 |                         $.fn.showSuccess(response['data']);
 | 
        
           |  |  | 293 |   | 
        
           |  |  | 294 |                         $('#modal-edit').modal('hide');
 | 
        
           |  |  | 295 |   | 
        
           |  |  | 296 |   | 
        
           |  |  | 297 |                         gridTable.api().ajax.reload(null, false);
 | 
        
           |  |  | 298 |                     } else {
 | 
        
           |  |  | 299 |                         validatorEdit.resetForm();
 | 
        
           |  |  | 300 |                         if(jQuery.type(response['data']) == 'string') {
 | 
        
           |  |  | 301 |                             $.fn.showError(response['data']);
 | 
        
           |  |  | 302 |                         } else  {
 | 
        
           |  |  | 303 |                             $.each(response['data'], function( fieldname, errors ) {
 | 
        
           |  |  | 304 |                                 $.fn.showFormErrorValidator('#form-edit #' + fieldname, errors);
 | 
        
           |  |  | 305 |                             });
 | 
        
           |  |  | 306 |                         }
 | 
        
           |  |  | 307 |                     }
 | 
        
           |  |  | 308 |                 }).fail(function( jqXHR, textStatus, errorThrown) {
 | 
        
           |  |  | 309 |                     $.fn.showError(textStatus);
 | 
        
           |  |  | 310 |                 }).always(function() {
 | 
        
           |  |  | 311 |                     NProgress.done();
 | 
        
           |  |  | 312 |                 });
 | 
        
           |  |  | 313 |                 return false;
 | 
        
           |  |  | 314 |             },
 | 
        
           |  |  | 315 |             invalidHandler: function(form, validator) {
 | 
        
           |  |  | 316 |             }
 | 
        
           |  |  | 317 |         });
 | 
        
           |  |  | 318 |   | 
        
           |  |  | 319 |         $('body').on('click', 'button.btn-add', function(e) {
 | 
        
           |  |  | 320 |             e.preventDefault();
 | 
        
           |  |  | 321 |   | 
        
           |  |  | 322 |   | 
        
           |  |  | 323 |             $('#form-add #status').bootstrapToggle('on')
 | 
        
           |  |  | 324 |             $('#form-add #name').val('');
 | 
        
           |  |  | 325 |             $('#form-add #order').val('0');
 | 
        
           |  |  | 326 |             $('#form-add #file').fileinput('reset');
 | 
        
           |  |  | 327 |             $('#form-add #file').val('');
 | 
        
           |  |  | 328 |   | 
        
           |  |  | 329 |             validatorAdd.resetForm();
 | 
        
           |  |  | 330 |             $('#modal-add').modal('show');
 | 
        
           |  |  | 331 |   | 
        
           |  |  | 332 |         });
 | 
        
           |  |  | 333 |   | 
        
           |  |  | 334 |         $('body').on('click', 'button.btn-edit', function(e) {
 | 
        
           |  |  | 335 |             e.preventDefault();
 | 
        
           |  |  | 336 |             NProgress.start();
 | 
        
           |  |  | 337 |             var action = $(this).data('href');
 | 
        
           |  |  | 338 |   | 
        
           |  |  | 339 |             $.ajax({
 | 
        
           |  |  | 340 |                 'dataType'  : 'json',
 | 
        
           |  |  | 341 |                 'method'    : 'get',
 | 
        
           |  |  | 342 |                 'url'       :  action,
 | 
        
           |  |  | 343 |             }).done(function(response) {
 | 
        
           |  |  | 344 |                 if(response['success']) {
 | 
        
           |  |  | 345 |   | 
        
           |  |  | 346 |                     $('#form-edit').attr('action', action);
 | 
        
           |  |  | 347 |                     $('#form-edit #status').bootstrapToggle(response['data']['status'] == '$status_active' ? 'on' : 'off')
 | 
        
           |  |  | 348 |                     $('#form-edit #name').val(response['data']['name']);
 | 
        
           |  |  | 349 |                     $('#form-edit #order').val(response['data']['order']);
 | 
        
           |  |  | 350 |                     $('#form-edit #file').fileinput('reset');
 | 
        
           |  |  | 351 |                     $('#form-edit #file').val('');
 | 
        
           |  |  | 352 |   | 
        
           |  |  | 353 |                     validatorEdit.resetForm();
 | 
        
           |  |  | 354 |   | 
        
           |  |  | 355 |                     $('#modal-edit').modal('show');
 | 
        
           |  |  | 356 |                 } else {
 | 
        
           |  |  | 357 |                     $.fn.showError(response['data']);
 | 
        
           |  |  | 358 |                 }
 | 
        
           |  |  | 359 |             }).fail(function( jqXHR, textStatus, errorThrown) {
 | 
        
           |  |  | 360 |                 $.fn.showError(textStatus);
 | 
        
           |  |  | 361 |             }).always(function() {
 | 
        
           |  |  | 362 |                 NProgress.done();
 | 
        
           |  |  | 363 |             });
 | 
        
           |  |  | 364 |         });
 | 
        
           |  |  | 365 |   | 
        
           |  |  | 366 |         $('body').on('click', 'button.btn-refresh', function(e) {
 | 
        
           |  |  | 367 |             e.preventDefault();
 | 
        
           |  |  | 368 |             gridTable.api().ajax.reload(null, false);
 | 
        
           |  |  | 369 |         });
 | 
        
           |  |  | 370 |   | 
        
           |  |  | 371 |   | 
        
           |  |  | 372 |         $('body').on('click', 'button.btn-cancel', function(e) {
 | 
        
           |  |  | 373 |             e.preventDefault();
 | 
        
           |  |  | 374 |             $('#modal-add').modal('hide');
 | 
        
           |  |  | 375 |             $('#modal-edit').modal('hide');
 | 
        
           |  |  | 376 |         });
 | 
        
           |  |  | 377 |   | 
        
           |  |  | 378 |     $('body').on('click', 'button.btn-delete', function(e) {
 | 
        
           |  |  | 379 |         e.preventDefault();
 | 
        
           |  |  | 380 |         var action = $(this).data('href');
 | 
        
           |  |  | 381 |   | 
        
           |  |  | 382 |   | 
        
           |  |  | 383 |           swal.fire({
 | 
        
           |  |  | 384 |             title: 'LABEL_ARE_YOU_SURE',
 | 
        
           |  |  | 385 |             icon: 'question',
 | 
        
           |  |  | 386 |             cancelButtonText: 'LABEL_NO',
 | 
        
           |  |  | 387 |             showCancelButton: true,
 | 
        
           |  |  | 388 |             confirmButtonText: 'LABEL_YES'
 | 
        
           |  |  | 389 |           }).then((result) => {
 | 
        
           |  |  | 390 |             if (result.isConfirmed) {
 | 
        
           |  |  | 391 |   | 
        
           |  |  | 392 |                     NProgress.start();
 | 
        
           |  |  | 393 |                     $.ajax({
 | 
        
           |  |  | 394 |                         'dataType'  : 'json',
 | 
        
           |  |  | 395 |                         'accept'    : 'application/json',
 | 
        
           |  |  | 396 |                         'method'    : 'post',
 | 
        
           |  |  | 397 |                         'url'       :  action,
 | 
        
           |  |  | 398 |                     }).done(function(response) {
 | 
        
           |  |  | 399 |                         if(response['success']) {
 | 
        
           |  |  | 400 |                             $.fn.showSuccess(response['data']);
 | 
        
           |  |  | 401 |                             gridTable.api().ajax.reload(null, false);
 | 
        
           |  |  | 402 |                         } else {
 | 
        
           |  |  | 403 |                             $.fn.showError(response['data']);
 | 
        
           |  |  | 404 |                         }
 | 
        
           |  |  | 405 |                     }).fail(function( jqXHR, textStatus, errorThrown) {
 | 
        
           |  |  | 406 |                         $.fn.showError(textStatus);
 | 
        
           |  |  | 407 |                     }).always(function() {
 | 
        
           |  |  | 408 |                         NProgress.done();
 | 
        
           |  |  | 409 |                     });
 | 
        
           |  |  | 410 |                 }
 | 
        
           |  |  | 411 |            });
 | 
        
           |  |  | 412 |   | 
        
           |  |  | 413 |         });
 | 
        
           |  |  | 414 |   | 
        
           |  |  | 415 |         $('#form-add #status').bootstrapToggle({'on' : 'LABEL_ACTIVE',  'off' : 'LABEL_INACTIVE', 'width' : '160px', 'height' : '40px'});
 | 
        
           |  |  | 416 |         $('#form-edit #status').bootstrapToggle({'on' : 'LABEL_ACTIVE',  'off' : 'LABEL_INACTIVE', 'width' : '160px', 'height' : '40px'});
 | 
        
           |  |  | 417 |   | 
        
           |  |  | 418 |         $('#form-add #order').inputNumberFormat({decimal: 0});
 | 
        
           |  |  | 419 |         $('#form-edit #order').inputNumberFormat({decimal: 0});
 | 
        
           |  |  | 420 |   | 
        
           |  |  | 421 |         $('#form-add #file').fileinput({
 | 
        
           |  |  | 422 |             theme: 'fa',
 | 
        
           |  |  | 423 |             language: 'es',
 | 
        
           |  |  | 424 |             showUpload: false,
 | 
        
           |  |  | 425 |             dropZoneEnabled: false,
 | 
        
           |  |  | 426 |             maxFileCount: 1,
 | 
        
           |  |  | 427 |             allowedFileExtensions: ['jpeg', 'jpg', 'png', 'mp4', 'mpeg','webm', 'pdf', 'wav', 'mp3' ],
 | 
        
           |  |  | 428 |         });
 | 
        
           |  |  | 429 |   | 
        
           |  |  | 430 |         $('#form-edit #file').fileinput({
 | 
        
           |  |  | 431 |             theme: 'fa',
 | 
        
           |  |  | 432 |             language: 'es',
 | 
        
           |  |  | 433 |             showUpload: false,
 | 
        
           |  |  | 434 |             dropZoneEnabled: false,
 | 
        
           |  |  | 435 |             maxFileCount: 1,
 | 
        
           |  |  | 436 |             allowedFileExtensions: ['jpeg', 'jpg', 'png', 'mp4', 'mpeg','webm', 'pdf', 'wav', 'mp3' ],
 | 
        
           |  |  | 437 |         });
 | 
        
           |  |  | 438 |   | 
        
           |  |  | 439 |   | 
        
           |  |  | 440 |     });
 | 
        
           |  |  | 441 | JS;
 | 
        
           |  |  | 442 | $this->inlineScript()->captureEnd();
 | 
        
           |  |  | 443 | ?>
 | 
        
           |  |  | 444 |   | 
        
           |  |  | 445 |   | 
        
           |  |  | 446 | <div class="container">
 | 
        
           |  |  | 447 | 	<div class="card">
 | 
        
           |  |  | 448 | 		<div class="card-header">
 | 
        
           |  |  | 449 |    			<h6 class="card-title">LABEL_CONTENT</h6>
 | 
        
           |  |  | 450 |    		</div>
 | 
        
           |  |  | 451 | 		<div class="card-body">
 | 
        
           |  |  | 452 |           	<table id="gridTable" class="table  table-bordered">
 | 
        
           |  |  | 453 |          		<thead>
 | 
        
           |  |  | 454 |            			<tr>
 | 
        
           |  |  | 455 |            				<th>LABEL_ORDER</th>
 | 
        
           |  |  | 456 |                    		<th>LABEL_NAME</th>
 | 
        
           |  |  | 457 |                   		<th>LABEL_TYPE</th>
 | 
        
           |  |  | 458 |                     	<th>LABEL_FILE</th>
 | 
        
           |  |  | 459 |                        	<th>LABEL_ACTIONS</th>
 | 
        
           |  |  | 460 |                     </tr>
 | 
        
           |  |  | 461 |           		</thead>
 | 
        
           |  |  | 462 |               	<tbody>
 | 
        
           |  |  | 463 |               	</tbody>
 | 
        
           |  |  | 464 |          	</table>
 | 
        
           |  |  | 465 |          </div>
 | 
        
           |  |  | 466 |     	 <div class="card-footer text-right">
 | 
        
           |  |  | 467 | 			<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-sync"></i> LABEL_REFRESH </button>
 | 
        
           |  |  | 468 |         	<?php if ($allowAdd) : ?>
 | 
        
           |  |  | 469 |             <button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
 | 
        
           |  |  | 470 |       		<?php endif; ?>
 | 
        
           |  |  | 471 | 		</div>
 | 
        
           |  |  | 472 |  	</div>
 | 
        
           |  |  | 473 | </div>
 | 
        
           |  |  | 474 |   | 
        
           |  |  | 475 |   | 
        
           |  |  | 476 |   | 
        
           |  |  | 477 | <!-- The Modal -->
 | 
        
           |  |  | 478 | <div class="modal" id="modal-add">
 | 
        
           |  |  | 479 |     <div class="modal-dialog  modal-xl">
 | 
        
           |  |  | 480 |         <div class="modal-content">
 | 
        
           |  |  | 481 |   | 
        
           |  |  | 482 |             <!-- Modal Header -->
 | 
        
           |  |  | 483 |             <div class="modal-header">
 | 
        
           |  |  | 484 |                 <h6 class="modal-title">LABEL_ADD</h6>
 | 
        
           |  |  | 485 |                 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
 | 
        
           |  |  | 486 |             </div>
 | 
        
           |  |  | 487 |   | 
        
           |  |  | 488 | 			<?php
 | 
        
           |  |  | 489 |                 $form = $this->formAdd;
 | 
        
           |  |  | 490 |                 $form->setAttributes([
 | 
        
           |  |  | 491 |                     'method'    => 'post',
 | 
        
           |  |  | 492 |                     'name'      => 'form-add',
 | 
        
           |  |  | 493 |                     'id'        => 'form-add',
 | 
        
           |  |  | 494 |                     'action'    => $routeAdd,
 | 
        
           |  |  | 495 |                 ]);
 | 
        
           |  |  | 496 |   | 
        
           |  |  | 497 |                 $form->prepare();
 | 
        
           |  |  | 498 |                 echo $this->form()->openTag($form);
 | 
        
           |  |  | 499 |             ?>
 | 
        
           |  |  | 500 |             <div class="modal-body">
 | 
        
           |  |  | 501 |   | 
        
           |  |  | 502 |     	 		<div class="row">
 | 
        
           |  |  | 503 |     	 	         <div class="col-12 mt-3">
 | 
        
           |  |  | 504 |                         <?php
 | 
        
           |  |  | 505 |                         $element = $form->get('name');
 | 
        
           |  |  | 506 |                         $element->setOptions(['label' => 'LABEL_NAME']);
 | 
        
           |  |  | 507 |                         $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 508 |   | 
        
           |  |  | 509 |                         echo $this->formLabel($element);
 | 
        
           |  |  | 510 |                         echo $this->formText($element);
 | 
        
           |  |  | 511 |                         ?>
 | 
        
           |  |  | 512 |                 	</div>
 | 
        
           |  |  | 513 |                 </div>
 | 
        
           |  |  | 514 |   | 
        
           |  |  | 515 |              	<div class="row">
 | 
        
           |  |  | 516 | 	 	         	<div class="col-12 mt-3">
 | 
        
           |  |  | 517 |                         <?php
 | 
        
           |  |  | 518 |                         $element = $form->get('order');
 | 
        
           |  |  | 519 |                         $element->setOptions(['label' => 'LABEL_ORDER']);
 | 
        
           |  |  | 520 |                         $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 521 |   | 
        
           |  |  | 522 |                         echo $this->formLabel($element);
 | 
        
           |  |  | 523 |                         echo $this->formNumber($element);
 | 
        
           |  |  | 524 |                         ?>
 | 
        
           |  |  | 525 |                     </div>
 | 
        
           |  |  | 526 |                 </div>
 | 
        
           |  |  | 527 |                       	<div class="row">
 | 
        
           |  |  | 528 | 	 	         	<div class="col-12 mt-3">
 | 
        
           |  |  | 529 |                         <?php
 | 
        
           |  |  | 530 |                         $element = $form->get('file');
 | 
        
           |  |  | 531 |                         $element->setOptions(['label' => 'LABEL_FILE']);
 | 
        
           |  |  | 532 |                         $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 533 |   | 
        
           |  |  | 534 |                         echo $this->formLabel($element);
 | 
        
           |  |  | 535 |                         echo $this->formFile($element);
 | 
        
           |  |  | 536 |                         ?>
 | 
        
           |  |  | 537 |                     </div>
 | 
        
           |  |  | 538 |                 </div>
 | 
        
           |  |  | 539 |             	<div class="row">
 | 
        
           |  |  | 540 | 	 	         	<div class="col-12 mt-3">
 | 
        
           |  |  | 541 |                         <?php
 | 
        
           |  |  | 542 |   | 
        
           |  |  | 543 |                         $element = $form->get('status');
 | 
        
           |  |  | 544 |                         $element->setOptions(['label' => 'LABEL_STATUS']);
 | 
        
           |  |  | 545 |   | 
        
           |  |  | 546 |                         echo $this->formLabel($element);
 | 
        
           |  |  | 547 |                         echo '<br/>';
 | 
        
           |  |  | 548 |                         echo $this->formCheckbox($element);
 | 
        
           |  |  | 549 |                         ?>
 | 
        
           |  |  | 550 |                 	</div>
 | 
        
           |  |  | 551 |                 </div>
 | 
        
           |  |  | 552 |   | 
        
           |  |  | 553 |   | 
        
           |  |  | 554 |   | 
        
           |  |  | 555 |             </div>
 | 
        
           |  |  | 556 |             <div class="modal-footer text-right">
 | 
        
           |  |  | 557 |             	 <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
 | 
        
           |  |  | 558 |             	<button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
 | 
        
           |  |  | 559 |             </div>
 | 
        
           |  |  | 560 |              <?php echo $this->form()->closeTag($form); ?>
 | 
        
           |  |  | 561 |   | 
        
           |  |  | 562 |   | 
        
           |  |  | 563 |         </div>
 | 
        
           |  |  | 564 |     </div>
 | 
        
           |  |  | 565 | </div>
 | 
        
           |  |  | 566 |   | 
        
           |  |  | 567 | <!-- The Modal -->
 | 
        
           |  |  | 568 | <div class="modal" id="modal-edit">
 | 
        
           |  |  | 569 |     <div class="modal-dialog  modal-xl">
 | 
        
           |  |  | 570 |         <div class="modal-content">
 | 
        
           |  |  | 571 |   | 
        
           |  |  | 572 |             <!-- Modal Header -->
 | 
        
           |  |  | 573 |             <div class="modal-header">
 | 
        
           |  |  | 574 |                 <h6 class="modal-title">LABEL_EDIT</h6>
 | 
        
           |  |  | 575 |                 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
 | 
        
           |  |  | 576 |             </div>
 | 
        
           |  |  | 577 |   | 
        
           |  |  | 578 |                 <?php
 | 
        
           |  |  | 579 |                 $form = $this->formEdit;
 | 
        
           |  |  | 580 |                 $form->setAttributes([
 | 
        
           |  |  | 581 |                     'method'    => 'post',
 | 
        
           |  |  | 582 |                     'name'      => 'form-edit',
 | 
        
           |  |  | 583 |                     'id'        => 'form-edit'
 | 
        
           |  |  | 584 |                 ]);
 | 
        
           |  |  | 585 |   | 
        
           |  |  | 586 |                 $form->prepare();
 | 
        
           |  |  | 587 |                 echo $this->form()->openTag($form);
 | 
        
           |  |  | 588 |                 ?>
 | 
        
           |  |  | 589 |             <div class="modal-body">
 | 
        
           |  |  | 590 |   | 
        
           |  |  | 591 |                 <div class="row">
 | 
        
           |  |  | 592 | 	 	         	<div class="col-12 mt-3">
 | 
        
           |  |  | 593 |                         <?php
 | 
        
           |  |  | 594 |                         $element = $form->get('name');
 | 
        
           |  |  | 595 |                         $element->setOptions(['label' => 'LABEL_NAME']);
 | 
        
           |  |  | 596 |                         $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 597 |   | 
        
           |  |  | 598 |                         echo $this->formLabel($element);
 | 
        
           |  |  | 599 |                         echo $this->formText($element);
 | 
        
           |  |  | 600 |                         ?>
 | 
        
           |  |  | 601 |                     </div>
 | 
        
           |  |  | 602 |                 </div>
 | 
        
           |  |  | 603 |   | 
        
           |  |  | 604 | 				<div class="row">
 | 
        
           |  |  | 605 | 	 	         	<div class="col-12 mt-3">
 | 
        
           |  |  | 606 |                         <?php
 | 
        
           |  |  | 607 |                         $element = $form->get('order');
 | 
        
           |  |  | 608 |                         $element->setOptions(['label' => 'LABEL_ORDER']);
 | 
        
           |  |  | 609 |                         $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 610 |   | 
        
           |  |  | 611 |                         echo $this->formLabel($element);
 | 
        
           |  |  | 612 |                         echo $this->formNumber($element);
 | 
        
           |  |  | 613 |                         ?>
 | 
        
           |  |  | 614 |                     </div>
 | 
        
           |  |  | 615 |                 </div>
 | 
        
           |  |  | 616 |                    <div class="row">
 | 
        
           |  |  | 617 | 	 	         	<div class="col-12 mt-3">
 | 
        
           |  |  | 618 |                         <?php
 | 
        
           |  |  | 619 |                         $element = $form->get('file');
 | 
        
           |  |  | 620 |                         $element->setOptions(['label' => 'LABEL_FILE']);
 | 
        
           |  |  | 621 |                         $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 622 |   | 
        
           |  |  | 623 |                         echo $this->formLabel($element);
 | 
        
           |  |  | 624 |                         echo $this->formFile($element);
 | 
        
           |  |  | 625 |                         ?>
 | 
        
           |  |  | 626 |                     </div>
 | 
        
           |  |  | 627 |                 </div>
 | 
        
           |  |  | 628 |                 <div class="row">
 | 
        
           |  |  | 629 | 	 	         	<div class="col-12 mt-3">
 | 
        
           |  |  | 630 |                         <?php
 | 
        
           |  |  | 631 |   | 
        
           |  |  | 632 |                         $element = $form->get('status');
 | 
        
           |  |  | 633 |                         $element->setOptions(['label' => 'LABEL_STATUS']);
 | 
        
           |  |  | 634 |   | 
        
           |  |  | 635 |                         echo $this->formLabel($element);
 | 
        
           |  |  | 636 |                         echo '<br/>';
 | 
        
           |  |  | 637 |                         echo $this->formCheckbox($element);
 | 
        
           |  |  | 638 |                         ?>
 | 
        
           |  |  | 639 |                     </div>
 | 
        
           |  |  | 640 |                 </div>
 | 
        
           |  |  | 641 |   | 
        
           |  |  | 642 |   | 
        
           |  |  | 643 |             </div>
 | 
        
           |  |  | 644 |             <div class="modal-footer text-right">
 | 
        
           |  |  | 645 |                     <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
 | 
        
           |  |  | 646 |                     <button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
 | 
        
           |  |  | 647 |          	</div>
 | 
        
           |  |  | 648 |         	<?php echo $this->form()->closeTag($form); ?>
 | 
        
           |  |  | 649 |   | 
        
           |  |  | 650 |   | 
        
           |  |  | 651 |         </div>
 | 
        
           |  |  | 652 |     </div>
 | 
        
           |  |  | 653 | </div>
 |