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