| 16248 | 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('knowledge-area/categories/add');
 | 
        
           |  |  | 9 | $routeDatatable = $this->url('knowledge-area/categories');
 | 
        
           |  |  | 10 |   | 
        
           |  |  | 11 | $allowAdd       = $acl->isAllowed($roleName, 'knowledge-area/categories/add') ? 1 : 0;
 | 
        
           |  |  | 12 | $allowEdit      = $acl->isAllowed($roleName, 'knowledge-area/categories/edit') ? 1 : 0;
 | 
        
           |  |  | 13 | $allowDelete    = $acl->isAllowed($roleName, 'knowledge-area/categories/delete') ? 1 : 0;
 | 
        
           |  |  | 14 |   | 
        
           |  |  | 15 |   | 
        
           |  |  | 16 | $this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
 | 
        
           |  |  | 17 |   | 
        
           |  |  | 18 | $this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
 | 
        
           |  |  | 19 | $this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
 | 
        
           |  |  | 20 |   | 
        
           |  |  | 21 |   | 
        
           |  |  | 22 | $this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
 | 
        
           |  |  | 23 | $this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
 | 
        
           |  |  | 24 | $this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
 | 
        
           |  |  | 25 |   | 
        
           |  |  | 26 | $this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
 | 
        
           |  |  | 27 |   | 
        
           |  |  | 28 | $this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
 | 
        
           |  |  | 29 | $this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
 | 
        
           |  |  | 30 |   | 
        
           |  |  | 31 |   | 
        
           |  |  | 32 | $this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
 | 
        
           |  |  | 33 | $this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
 | 
        
           |  |  | 34 |   | 
        
           |  |  | 35 | $this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
 | 
        
           |  |  | 36 | $this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
 | 
        
           |  |  | 37 |   | 
        
           |  |  | 38 | $this->inlineScript()->appendFile($this->basePath('plugins/select2/js/select2.js'));
 | 
        
           |  |  | 39 | $this->inlineScript()->appendFile($this->basePath('plugins/select2/js/i18n/es.js'));
 | 
        
           |  |  | 40 | $this->headLink()->appendStylesheet($this->basePath('plugins/select2/css/select2.css'));
 | 
        
           |  |  | 41 |   | 
        
           |  |  | 42 | $this->headLink()->appendStylesheet($this->basePath('plugins/select2-bootstrap4-theme/select2-bootstrap4.css'));
 | 
        
           |  |  | 43 |   | 
        
           |  |  | 44 |   | 
        
           |  |  | 45 |   | 
        
           |  |  | 46 | $status_active = \LeadersLinked\Model\MyCoachCategory::STATUS_ACTIVE;
 | 
        
           |  |  | 47 | $privacy_company = \LeadersLinked\Model\MyCoachCategory::PRIVACY_COMPANY;
 | 
        
           |  |  | 48 |   | 
        
           |  |  | 49 | $this->inlineScript()->captureStart();
 | 
        
           |  |  | 50 | echo <<<JS
 | 
        
           |  |  | 51 |     jQuery( document ).ready(function( $ ) {
 | 
        
           |  |  | 52 |   | 
        
           |  |  | 53 |   | 
        
           |  |  | 54 |   | 
        
           |  |  | 55 |   | 
        
           |  |  | 56 |   | 
        
           |  |  | 57 |         var allowEdit   = $allowEdit;
 | 
        
           |  |  | 58 |         var allowDelete = $allowDelete;
 | 
        
           |  |  | 59 |   | 
        
           |  |  | 60 |         $.validator.setDefaults({
 | 
        
           |  |  | 61 |             debug: true,
 | 
        
           |  |  | 62 |             highlight: function(element) {
 | 
        
           |  |  | 63 |                 $(element).addClass('is-invalid');
 | 
        
           |  |  | 64 |             },
 | 
        
           |  |  | 65 |             unhighlight: function(element) {
 | 
        
           |  |  | 66 |                 $(element).removeClass('is-invalid');
 | 
        
           |  |  | 67 |             },
 | 
        
           |  |  | 68 |             errorElement: 'span',
 | 
        
           |  |  | 69 |             errorClass: 'error invalid-feedback',
 | 
        
           |  |  | 70 |                 errorPlacement: function(error, element) {
 | 
        
           |  |  | 71 |                     if(element.parent('.form-group').length) {
 | 
        
           |  |  | 72 |                         error.insertAfter(element);
 | 
        
           |  |  | 73 |                     } else if(element.parent('.toggle').length) {
 | 
        
           |  |  | 74 |                         error.insertAfter(element.parent().parent());
 | 
        
           |  |  | 75 |                     } else {
 | 
        
           |  |  | 76 |                         error.insertAfter(element.parent());
 | 
        
           |  |  | 77 |                     }
 | 
        
           |  |  | 78 |                 }
 | 
        
           |  |  | 79 |         });
 | 
        
           |  |  | 80 |   | 
        
           |  |  | 81 |         $.fn.showFormErrorValidator = function(fieldname, errors) {
 | 
        
           |  |  | 82 |             var field = $(fieldname);
 | 
        
           |  |  | 83 |             if (field) {
 | 
        
           |  |  | 84 |                 $(field).addClass('is-invalid');
 | 
        
           |  |  | 85 |                 var error = $('<span id="' + fieldname + '-error" class="error invalid-feedback">' + errors + '</div>');
 | 
        
           |  |  | 86 |                     if(field.parent('.form-group').length) {
 | 
        
           |  |  | 87 |                         error.insertAfter(field);
 | 
        
           |  |  | 88 |                     } else  if(field.parent('.toggle').length) {
 | 
        
           |  |  | 89 |                         error.insertAfter(field.parent().parent());
 | 
        
           |  |  | 90 |                     } else {
 | 
        
           |  |  | 91 |                         error.insertAfter(field.parent());
 | 
        
           |  |  | 92 |                     }
 | 
        
           |  |  | 93 |             }
 | 
        
           |  |  | 94 |         };
 | 
        
           |  |  | 95 |   | 
        
           |  |  | 96 |         var gridTable = $('#gridTable').dataTable( {
 | 
        
           |  |  | 97 |             'processing': true,
 | 
        
           |  |  | 98 |             'serverSide': true,
 | 
        
           |  |  | 99 |             'searching': true,
 | 
        
           |  |  | 100 |             'order': [[ 0, 'asc' ]],
 | 
        
           |  |  | 101 |             'ordering':  true,
 | 
        
           |  |  | 102 |             'ordenable' : true,
 | 
        
           |  |  | 103 |             'responsive': true,
 | 
        
           |  |  | 104 |             'select' : false,
 | 
        
           |  |  | 105 |         	'paging': true,
 | 
        
           |  |  | 106 |             'pagingType': 'simple_numbers',
 | 
        
           |  |  | 107 |     		'ajax': {
 | 
        
           |  |  | 108 |     			'url' : '$routeDatatable',
 | 
        
           |  |  | 109 |     			'type' : 'get',
 | 
        
           |  |  | 110 |                 'beforeSend': function (request) {
 | 
        
           |  |  | 111 |                   NProgress.start();
 | 
        
           |  |  | 112 |                 },
 | 
        
           |  |  | 113 |                 'dataFilter': function(response) {
 | 
        
           |  |  | 114 |                     var response = jQuery.parseJSON( response );
 | 
        
           |  |  | 115 |   | 
        
           |  |  | 116 |                     var json                = {};
 | 
        
           |  |  | 117 |                     json.recordsTotal       = 0;
 | 
        
           |  |  | 118 |                     json.recordsFiltered    = 0;
 | 
        
           |  |  | 119 |                     json.data               = [];
 | 
        
           |  |  | 120 |   | 
        
           |  |  | 121 |   | 
        
           |  |  | 122 |                     if(response.success) {
 | 
        
           |  |  | 123 |                         json.recordsTotal       = response.data.total;
 | 
        
           |  |  | 124 |                         json.recordsFiltered    = response.data.total;
 | 
        
           |  |  | 125 |                         json.data               = response.data.items;
 | 
        
           |  |  | 126 |                     } else {
 | 
        
           |  |  | 127 |                         $.fn.showError(response.data)
 | 
        
           |  |  | 128 |                     }
 | 
        
           |  |  | 129 |   | 
        
           |  |  | 130 |                     return JSON.stringify( json );
 | 
        
           |  |  | 131 |                 }
 | 
        
           |  |  | 132 |     		},
 | 
        
           |  |  | 133 |             'language' : {
 | 
        
           |  |  | 134 |                 'sProcessing':     'LABEL_DATATABLE_SPROCESSING',
 | 
        
           |  |  | 135 |                 'sLengthMenu':     'LABEL_DATATABLE_SLENGTHMENU',
 | 
        
           |  |  | 136 |                 'sZeroRecords':    'LABEL_DATATABLE_SZERORECORDS',
 | 
        
           |  |  | 137 |                 'sEmptyTable':     'LABEL_DATATABLE_SEMPTYTABLE',
 | 
        
           |  |  | 138 |                 'sInfo':           'LABEL_DATATABLE_SINFO',
 | 
        
           |  |  | 139 |                 'sInfoEmpty':      'LABEL_DATATABLE_SINFOEMPTY',
 | 
        
           |  |  | 140 |                 'sInfoFiltered':   'LABEL_DATATABLE_SINFOFILTERED',
 | 
        
           |  |  | 141 |                 'sInfoPostFix':    '',
 | 
        
           |  |  | 142 |                 'sSearch':         'LABEL_DATATABLE_SSEARCH',
 | 
        
           |  |  | 143 |                 'sUrl':            '',
 | 
        
           |  |  | 144 |                 'sInfoThousands':  ',',
 | 
        
           |  |  | 145 |                 'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
 | 
        
           |  |  | 146 |                 'oPaginate': {
 | 
        
           |  |  | 147 |                     'sFirst':    'LABEL_DATATABLE_SFIRST',
 | 
        
           |  |  | 148 |                     'sLast':     'LABEL_DATATABLE_SLAST',
 | 
        
           |  |  | 149 |                     'sNext':     'LABEL_DATATABLE_SNEXT',
 | 
        
           |  |  | 150 |                     'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
 | 
        
           |  |  | 151 |                 },
 | 
        
           |  |  | 152 |                 'oAria': {
 | 
        
           |  |  | 153 |                     'sSortAscending':  ': LABEL_DATATABLE_SSORTASCENDING',
 | 
        
           |  |  | 154 |                     'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
 | 
        
           |  |  | 155 |                 },
 | 
        
           |  |  | 156 |             },
 | 
        
           |  |  | 157 |             'drawCallback': function( settings ) {
 | 
        
           |  |  | 158 |                 NProgress.done();
 | 
        
           |  |  | 159 |                 $('button.btn-delete').confirmation({
 | 
        
           |  |  | 160 |                     rootSelector: 'button.btn-delete',
 | 
        
           |  |  | 161 |                     title : 'LABEL_ARE_YOU_SURE',
 | 
        
           |  |  | 162 |                     singleton : true,
 | 
        
           |  |  | 163 |                     btnOkLabel: 'LABEL_YES',
 | 
        
           |  |  | 164 |                     btnCancelLabel: 'LABEL_NO',
 | 
        
           |  |  | 165 |                     onConfirm: function(value) {
 | 
        
           |  |  | 166 |                         action = $(this).data('href');
 | 
        
           |  |  | 167 |                         NProgress.start();
 | 
        
           |  |  | 168 |                         $.ajax({
 | 
        
           |  |  | 169 |                             'dataType'  : 'json',
 | 
        
           |  |  | 170 |                             'accept'    : 'application/json',
 | 
        
           |  |  | 171 |                             'method'    : 'post',
 | 
        
           |  |  | 172 |                             'url'       :  action,
 | 
        
           |  |  | 173 |                         }).done(function(response) {
 | 
        
           |  |  | 174 |                             if(response['success']) {
 | 
        
           |  |  | 175 |                                 $.fn.showSuccess(response['data']);
 | 
        
           |  |  | 176 |                                 gridTable.api().ajax.reload(null, false);
 | 
        
           |  |  | 177 |                             } else {
 | 
        
           |  |  | 178 |                                 $.fn.showError(response['data']);
 | 
        
           |  |  | 179 |                             }
 | 
        
           |  |  | 180 |                         }).fail(function( jqXHR, textStatus, errorThrown) {
 | 
        
           |  |  | 181 |                             $.fn.showError(textStatus);
 | 
        
           |  |  | 182 |                         }).always(function() {
 | 
        
           |  |  | 183 |                             NProgress.done();
 | 
        
           |  |  | 184 |                         });
 | 
        
           |  |  | 185 |                     },
 | 
        
           |  |  | 186 |                 });
 | 
        
           |  |  | 187 |             },
 | 
        
           |  |  | 188 |             'aoColumns': [
 | 
        
           |  |  | 189 |                 { 'mDataProp': 'name' },
 | 
        
           |  |  | 190 |                 { 'mDataProp': 'privacy' },
 | 
        
           |  |  | 191 |                 { 'mDataProp': 'status' },
 | 
        
           |  |  | 192 |                 { 'mDataProp': 'actions' },
 | 
        
           |  |  | 193 |     	    ],
 | 
        
           |  |  | 194 |             'columnDefs': [
 | 
        
           |  |  | 195 |                 {
 | 
        
           |  |  | 196 |                     'targets': 0,
 | 
        
           |  |  | 197 |                     'className' : 'text-vertical-middle',
 | 
        
           |  |  | 198 |                 },
 | 
        
           |  |  | 199 |                 {
 | 
        
           |  |  | 200 |                     'targets': 1,
 | 
        
           |  |  | 201 |                     'orderable': false,
 | 
        
           |  |  | 202 |                     'className' : 'text-vertical-middle',
 | 
        
           |  |  | 203 |   | 
        
           |  |  | 204 |                 },
 | 
        
           |  |  | 205 |   | 
        
           |  |  | 206 |                 {
 | 
        
           |  |  | 207 |                     'targets': -2,
 | 
        
           |  |  | 208 |                     'orderable': false,
 | 
        
           |  |  | 209 |                     'className' : 'text-center',
 | 
        
           |  |  | 210 |                       'render' : function ( data, type, row ) {
 | 
        
           |  |  | 211 |   | 
        
           |  |  | 212 |                         checked = data == 'a' ? ' checked="checked" ' : '';
 | 
        
           |  |  | 213 |                         return '<div class="checkbox checkbox-success">' +
 | 
        
           |  |  | 214 |                             '<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +
 | 
        
           |  |  | 215 |                             '<label ></label></div>';
 | 
        
           |  |  | 216 |                     }
 | 
        
           |  |  | 217 |                 },
 | 
        
           |  |  | 218 |                 {
 | 
        
           |  |  | 219 |                     'targets': -1,
 | 
        
           |  |  | 220 |                     'orderable': false,
 | 
        
           |  |  | 221 |                     'render' : function ( data, type, row ) {
 | 
        
           |  |  | 222 |                         s = '';
 | 
        
           |  |  | 223 |   | 
        
           |  |  | 224 |                         if(allowEdit) {
 | 
        
           |  |  | 225 |                             s = s + '<button class="btn btn-primary btn-edit" data-href="' + data['link_edit']+ '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pencil"></i> LABEL_EDIT </button> ';
 | 
        
           |  |  | 226 |                         }
 | 
        
           |  |  | 227 |                         if(allowDelete) {
 | 
        
           |  |  | 228 |                             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> ';
 | 
        
           |  |  | 229 |                         }
 | 
        
           |  |  | 230 |                         return s;
 | 
        
           |  |  | 231 |                     }
 | 
        
           |  |  | 232 |                 }
 | 
        
           |  |  | 233 |               ],
 | 
        
           |  |  | 234 |         });
 | 
        
           |  |  | 235 |   | 
        
           |  |  | 236 |         var validator = $('#form').validate({
 | 
        
           |  |  | 237 |             debug: true,
 | 
        
           |  |  | 238 |             onclick: false,
 | 
        
           |  |  | 239 |             onkeyup: false,
 | 
        
           |  |  | 240 |             ignore: [],
 | 
        
           |  |  | 241 |             rules: {
 | 
        
           |  |  | 242 |                 'name': {
 | 
        
           |  |  | 243 |                     required: true,
 | 
        
           |  |  | 244 |                     maxlength: 128,
 | 
        
           |  |  | 245 |                 },
 | 
        
           |  |  | 246 |                 'description': {
 | 
        
           |  |  | 247 |                     updateCkeditor:function() {
 | 
        
           |  |  | 248 |                         CKEDITOR.instances.description.updateElement();
 | 
        
           |  |  | 249 |                     },
 | 
        
           |  |  | 250 |                     required: true,
 | 
        
           |  |  | 251 |                 },
 | 
        
           |  |  | 252 |   | 
        
           |  |  | 253 |                 'status': {
 | 
        
           |  |  | 254 |                     required: false,
 | 
        
           |  |  | 255 |                 },
 | 
        
           |  |  | 256 |                 'privacy': {
 | 
        
           |  |  | 257 |                     required: true
 | 
        
           |  |  | 258 |                 },
 | 
        
           |  |  | 259 |             },
 | 
        
           |  |  | 260 |             submitHandler: function(form)
 | 
        
           |  |  | 261 |             {
 | 
        
           |  |  | 262 |                 $('#submitBtn').prop('disabled', true);
 | 
        
           |  |  | 263 |                 $.ajax({
 | 
        
           |  |  | 264 |                     'dataType'  : 'json',
 | 
        
           |  |  | 265 |                     'accept'    : 'application/json',
 | 
        
           |  |  | 266 |                     'method'    : 'post',
 | 
        
           |  |  | 267 |                     'url'       :  $('#form').attr('action'),
 | 
        
           |  |  | 268 |                     'data'      :  $('#form').serialize()
 | 
        
           |  |  | 269 |                 }).done(function(response) {
 | 
        
           |  |  | 270 |                     NProgress.start();
 | 
        
           |  |  | 271 |                     if(response['success']) {
 | 
        
           |  |  | 272 |                         $.fn.showSuccess(response['data']);
 | 
        
           |  |  | 273 |   | 
        
           |  |  | 274 |                         $('#modal').modal('hide');
 | 
        
           |  |  | 275 |   | 
        
           |  |  | 276 |   | 
        
           |  |  | 277 |                          gridTable.api().ajax.reload(null, false);
 | 
        
           |  |  | 278 |                     } else {
 | 
        
           |  |  | 279 |                         validator.resetForm();
 | 
        
           |  |  | 280 |                         if(jQuery.type(response['data']) == 'string') {
 | 
        
           |  |  | 281 |                             $.fn.showError(response['data']);
 | 
        
           |  |  | 282 |                         } else  {
 | 
        
           |  |  | 283 |                             $.each(response['data'], function( fieldname, errors ) {
 | 
        
           |  |  | 284 |                                 $.fn.showFormErrorValidator('#form #' + fieldname, errors);
 | 
        
           |  |  | 285 |                             });
 | 
        
           |  |  | 286 |                         }
 | 
        
           |  |  | 287 |                     }
 | 
        
           |  |  | 288 |                     $('#submitBtn').prop('disabled', false);
 | 
        
           |  |  | 289 |                 }).fail(function( jqXHR, textStatus, errorThrown) {
 | 
        
           |  |  | 290 |                    $.fn.showError(textStatus);
 | 
        
           |  |  | 291 |                 }).always(function() {
 | 
        
           |  |  | 292 |                     $('#submitBtn').prop('disabled', false);
 | 
        
           |  |  | 293 |                     NProgress.done();
 | 
        
           |  |  | 294 |                 });
 | 
        
           |  |  | 295 |                 return false;
 | 
        
           |  |  | 296 |             },
 | 
        
           |  |  | 297 |             invalidHandler: function(form, validator) {
 | 
        
           |  |  | 298 |   | 
        
           |  |  | 299 |             }
 | 
        
           |  |  | 300 |         });
 | 
        
           |  |  | 301 |   | 
        
           |  |  | 302 |         $('body').on('click', 'button.btn-add', function(e) {
 | 
        
           |  |  | 303 |             e.preventDefault();
 | 
        
           |  |  | 304 |   | 
        
           |  |  | 305 |             $('span[id="form-title"]').html('LABEL_ADD');
 | 
        
           |  |  | 306 |             $('#form').attr('action', '$routeAdd');
 | 
        
           |  |  | 307 |             $('#form #name').val('');
 | 
        
           |  |  | 308 |             $('#form #description').val('');
 | 
        
           |  |  | 309 |             $('#form #privacy').val('$privacy_company').trigger('change');
 | 
        
           |  |  | 310 |             $('#form #status').bootstrapToggle('on');
 | 
        
           |  |  | 311 |             CKEDITOR.instances.description.setData('');
 | 
        
           |  |  | 312 |   | 
        
           |  |  | 313 |   | 
        
           |  |  | 314 |             validator.resetForm();
 | 
        
           |  |  | 315 |             $('#modal').modal('show');
 | 
        
           |  |  | 316 |   | 
        
           |  |  | 317 |             return false;
 | 
        
           |  |  | 318 |         });
 | 
        
           |  |  | 319 |   | 
        
           |  |  | 320 |         $('body').on('click', 'button.btn-edit', function(e) {
 | 
        
           |  |  | 321 |             e.preventDefault();
 | 
        
           |  |  | 322 |             NProgress.start();
 | 
        
           |  |  | 323 |             var action = $(this).data('href');
 | 
        
           |  |  | 324 |             $('#submitBtn').prop('disabled', true);
 | 
        
           |  |  | 325 |             $.ajax({
 | 
        
           |  |  | 326 |                 'dataType'  : 'json',
 | 
        
           |  |  | 327 |                 'method'    : 'get',
 | 
        
           |  |  | 328 |                 'url'       :  action,
 | 
        
           |  |  | 329 |             }).done(function(response) {
 | 
        
           |  |  | 330 |                 if(response['success']) {
 | 
        
           |  |  | 331 |   | 
        
           |  |  | 332 |                     $('span[id="form-title"]').html('LABEL_EDIT');
 | 
        
           |  |  | 333 |                     $('#form').attr('action', action);
 | 
        
           |  |  | 334 |                     $('#form #name').val(response['data']['name']);
 | 
        
           |  |  | 335 |                     $('#form #privacy').val(response['data']['privacy']).trigger('change');
 | 
        
           |  |  | 336 |                     $('#form #status').bootstrapToggle(response['data']['status'] == '$status_active' ? 'on' : 'off')
 | 
        
           |  |  | 337 |   | 
        
           |  |  | 338 |   | 
        
           |  |  | 339 |                     CKEDITOR.instances.description.setData(response['data']['description']);
 | 
        
           |  |  | 340 |                     validator.resetForm();
 | 
        
           |  |  | 341 |   | 
        
           |  |  | 342 |                     $('#modal').modal('show');
 | 
        
           |  |  | 343 |   | 
        
           |  |  | 344 |                 } else {
 | 
        
           |  |  | 345 |                     $.fn.showError(response['data']);
 | 
        
           |  |  | 346 |                 }
 | 
        
           |  |  | 347 |                 $('#submitBtn').prop('disabled', false);
 | 
        
           |  |  | 348 |             }).fail(function( jqXHR, textStatus, errorThrown) {
 | 
        
           |  |  | 349 |                 $.fn.showError(textStatus);
 | 
        
           |  |  | 350 |             }).always(function() {
 | 
        
           |  |  | 351 |                 NProgress.done();
 | 
        
           |  |  | 352 |                 $('#submitBtn').prop('disabled', false);
 | 
        
           |  |  | 353 |             });
 | 
        
           |  |  | 354 |   | 
        
           |  |  | 355 |             return false;
 | 
        
           |  |  | 356 |         });
 | 
        
           |  |  | 357 |   | 
        
           |  |  | 358 |         $('body').on('click', 'button.btn-refresh', function(e) {
 | 
        
           |  |  | 359 |             e.preventDefault();
 | 
        
           |  |  | 360 |             gridTable.api().ajax.reload(null, false);
 | 
        
           |  |  | 361 |   | 
        
           |  |  | 362 |             return false;
 | 
        
           |  |  | 363 |         });
 | 
        
           |  |  | 364 |   | 
        
           |  |  | 365 |   | 
        
           |  |  | 366 |   | 
        
           |  |  | 367 |   | 
        
           |  |  | 368 |         $('body').on('click', 'button.btn-cancel', function(e) {
 | 
        
           |  |  | 369 |             e.preventDefault();
 | 
        
           |  |  | 370 |             $('#modal').modal('hide');
 | 
        
           |  |  | 371 |         });
 | 
        
           |  |  | 372 |   | 
        
           |  |  | 373 |         $('#form #privacy').select2({
 | 
        
           |  |  | 374 |             theme: 'bootstrap4',
 | 
        
           |  |  | 375 |             width: '100%',
 | 
        
           |  |  | 376 |         });
 | 
        
           |  |  | 377 |   | 
        
           |  |  | 378 |   | 
        
           |  |  | 379 |         CKEDITOR.replace( 'description');
 | 
        
           |  |  | 380 |         $('#form #status').bootstrapToggle({'on' : 'LABEL_ACTIVE',  'off' : 'LABEL_INACTIVE', 'width' : '160px', 'height' : '40px'});
 | 
        
           |  |  | 381 |   | 
        
           |  |  | 382 |     });
 | 
        
           |  |  | 383 | JS;
 | 
        
           |  |  | 384 | $this->inlineScript()->captureEnd();
 | 
        
           |  |  | 385 | ?>
 | 
        
           |  |  | 386 |   | 
        
           |  |  | 387 |   | 
        
           |  |  | 388 |   | 
        
           |  |  | 389 |   | 
        
           |  |  | 390 |   | 
        
           |  |  | 391 | <!-- Content Header (Page header) -->
 | 
        
           |  |  | 392 | <section class="content-header">
 | 
        
           |  |  | 393 |     <div class="container-fluid">
 | 
        
           |  |  | 394 |         <div class="row mb-2">
 | 
        
           |  |  | 395 |             <div class="col-sm-12">
 | 
        
           |  |  | 396 |                 <h1>LABEL_KNOWLEDGE_AREA_CATEGORIES</h1>
 | 
        
           |  |  | 397 |             </div>
 | 
        
           |  |  | 398 |         </div>
 | 
        
           |  |  | 399 |     </div><!-- /.container-fluid -->
 | 
        
           |  |  | 400 | </section>
 | 
        
           |  |  | 401 |   | 
        
           |  |  | 402 | <section class="content">
 | 
        
           |  |  | 403 |     <div class="container-fluid">
 | 
        
           |  |  | 404 |         <div class="row">
 | 
        
           |  |  | 405 |             <div class="col-12">
 | 
        
           |  |  | 406 |                 <div class="card">
 | 
        
           |  |  | 407 |                     <div class="card-body">
 | 
        
           |  |  | 408 |                         <table id="gridTable" class="table table-hover">
 | 
        
           |  |  | 409 |                             <thead>
 | 
        
           |  |  | 410 |                                 <tr>
 | 
        
           |  |  | 411 |                                     <th>LABEL_NAME</th>
 | 
        
           |  |  | 412 |                                     <th>LABEL_PRIVACY</th>
 | 
        
           |  |  | 413 |                                     <th>LABEL_ACTIVE</th>
 | 
        
           |  |  | 414 |                                     <th>LABEL_ACTIONS</th>
 | 
        
           |  |  | 415 |                                 </tr>
 | 
        
           |  |  | 416 |                             </thead>
 | 
        
           |  |  | 417 |                             <tbody>
 | 
        
           |  |  | 418 |                             </tbody>
 | 
        
           |  |  | 419 |                         </table>
 | 
        
           |  |  | 420 |                     </div>
 | 
        
           |  |  | 421 |                     <div class="card-footer clearfix">
 | 
        
           |  |  | 422 |                         <div style="float:right;">
 | 
        
           |  |  | 423 |                             <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
 | 
        
           |  |  | 424 |                             <?php if ($allowAdd) : ?>
 | 
        
           |  |  | 425 |                                 <button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
 | 
        
           |  |  | 426 |                             <?php endif; ?>
 | 
        
           |  |  | 427 |                         </div>
 | 
        
           |  |  | 428 |                     </div>
 | 
        
           |  |  | 429 |                 </div>
 | 
        
           |  |  | 430 |             </div>
 | 
        
           |  |  | 431 |         </div>
 | 
        
           |  |  | 432 |     </div>
 | 
        
           |  |  | 433 | </section>
 | 
        
           |  |  | 434 |   | 
        
           |  |  | 435 | <!-- The Modal -->
 | 
        
           |  |  | 436 | <div class="modal" id="modal">
 | 
        
           |  |  | 437 |     <div class="modal-dialog  modal-xl">
 | 
        
           |  |  | 438 |         <div class="modal-content">
 | 
        
           |  |  | 439 |   | 
        
           |  |  | 440 |             <!-- Modal Header -->
 | 
        
           |  |  | 441 |             <div class="modal-header">
 | 
        
           |  |  | 442 |                 <h4 class="modal-title">LABEL_KNOWLEDGE_AREA_CATEGORIES - <span id="form-title"></span></h4>
 | 
        
           |  |  | 443 |                 <button type="button" class="close" data-dismiss="modal">×</button>
 | 
        
           |  |  | 444 |             </div>
 | 
        
           |  |  | 445 |   | 
        
           |  |  | 446 |             <!-- Modal body -->
 | 
        
           |  |  | 447 |             <div class="modal-body">
 | 
        
           |  |  | 448 |   | 
        
           |  |  | 449 |                 <?php
 | 
        
           |  |  | 450 |                 $form = $this->form;
 | 
        
           |  |  | 451 |                 $form->setAttributes([
 | 
        
           |  |  | 452 |                     'method'    => 'post',
 | 
        
           |  |  | 453 |                     'name'      => 'form',
 | 
        
           |  |  | 454 |                     'id'        => 'form'
 | 
        
           |  |  | 455 |                 ]);
 | 
        
           |  |  | 456 |   | 
        
           |  |  | 457 |                 $form->prepare();
 | 
        
           |  |  | 458 |                 echo $this->form()->openTag($form);
 | 
        
           |  |  | 459 |   | 
        
           |  |  | 460 |                 ?>
 | 
        
           |  |  | 461 |                 <div class="card-body">
 | 
        
           |  |  | 462 |   | 
        
           |  |  | 463 |                  		<div class="from-group">
 | 
        
           |  |  | 464 |                  			<?php
 | 
        
           |  |  | 465 |                             $element = $form->get('name');
 | 
        
           |  |  | 466 |                             $element->setOptions(['label' => 'LABEL_NAME']);
 | 
        
           |  |  | 467 |                             $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 468 |   | 
        
           |  |  | 469 |                             echo $this->formLabel($element);
 | 
        
           |  |  | 470 |                             echo $this->formText($element);
 | 
        
           |  |  | 471 |                             ?>
 | 
        
           |  |  | 472 |                			</div>
 | 
        
           |  |  | 473 |   | 
        
           |  |  | 474 |   | 
        
           |  |  | 475 |   | 
        
           |  |  | 476 |                     	<div class="form-group">
 | 
        
           |  |  | 477 |                   			<?php
 | 
        
           |  |  | 478 |                             $element = $form->get('description');
 | 
        
           |  |  | 479 |                             $element->setOptions(['label' => 'LABEL_DESCRIPTION']);
 | 
        
           |  |  | 480 |                             $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 481 |   | 
        
           |  |  | 482 |                             echo $this->formLabel($element);
 | 
        
           |  |  | 483 |                             echo $this->formTextArea($element);
 | 
        
           |  |  | 484 |                             ?>
 | 
        
           |  |  | 485 |                      	</div>
 | 
        
           |  |  | 486 |   | 
        
           |  |  | 487 |   | 
        
           |  |  | 488 |   | 
        
           |  |  | 489 |                     <div class="form-group ">
 | 
        
           |  |  | 490 |                         <?php
 | 
        
           |  |  | 491 |                         $element = $form->get('privacy');
 | 
        
           |  |  | 492 |                         $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 493 |                         $element->setOptions(['label' => 'LABEL_PRIVACY']);
 | 
        
           |  |  | 494 |   | 
        
           |  |  | 495 |                         echo $this->formLabel($element);
 | 
        
           |  |  | 496 |                         echo $this->formSelect($element);
 | 
        
           |  |  | 497 |                         ?>
 | 
        
           |  |  | 498 |   | 
        
           |  |  | 499 |                     </div>
 | 
        
           |  |  | 500 |   | 
        
           |  |  | 501 |                     <div class="form-group ">
 | 
        
           |  |  | 502 |                         <label>LABEL_STATUS</label>
 | 
        
           |  |  | 503 |                         <br />
 | 
        
           |  |  | 504 |                         <?php
 | 
        
           |  |  | 505 |                         $element = $form->get('status');
 | 
        
           |  |  | 506 |                         $element->setOptions(['label' => 'LABEL_STATUS']);
 | 
        
           |  |  | 507 |                         // echo $this->formLabel($element);
 | 
        
           |  |  | 508 |                         echo $this->formCheckbox($element);
 | 
        
           |  |  | 509 |                         ?>
 | 
        
           |  |  | 510 |   | 
        
           |  |  | 511 |                     </div>
 | 
        
           |  |  | 512 |   | 
        
           |  |  | 513 |   | 
        
           |  |  | 514 |                 </div>
 | 
        
           |  |  | 515 |             </div>
 | 
        
           |  |  | 516 |   | 
        
           |  |  | 517 |             <?php echo $this->form()->closeTag($form); ?>
 | 
        
           |  |  | 518 |             <!-- Modal footer -->
 | 
        
           |  |  | 519 |             <div class="modal-footer">
 | 
        
           |  |  | 520 |                 <button type="submit" id="submitBtn" form="form" class="btn btn-primary">LABEL_SAVE</button>
 | 
        
           |  |  | 521 |                 <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
 | 
        
           |  |  | 522 |             </div>
 | 
        
           |  |  | 523 |         </div>
 | 
        
           |  |  | 524 |   | 
        
           |  |  | 525 |   | 
        
           |  |  | 526 |     </div>
 | 
        
           |  |  | 527 | </div>
 | 
        
           |  |  | 528 | </div>
 |