Rev 17008 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
<?php$acl = $this->viewModel()->getRoot()->getVariable('acl');$currentUser = $this->currentUserHelper();$roleName = $currentUser->getUserTypeId();$routeAdd = $this->url('habits/skills/add');$routeDatatable = $this->url('habits/skills');$routeDashboard = $this->url('dashboard');$allowAdd = $acl->isAllowed($roleName, 'habits/skills/add') ? 1 : 0;$allowEdit = $acl->isAllowed($roleName, 'habits/skills/edit') ? 1 : 0;$allowDelete = $acl->isAllowed($roleName, 'habits/skills/delete') ? 1 : 0;$this->inlineScript()->appendFile($this->basePath('assets/vendors/ckeditor/ckeditor.js'));$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.css'));$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/dataTables.responsive.min.js'));$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.min.js'));$this->inlineScript()->appendFile($this->basePath('assets/vendors/moment/moment-with-locales.min.js'));$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css'));$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'));$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-maxlength/bootstrap-maxlength.min.js'));$this->headLink()->appendStylesheet($this->basePath('assets/vendors/select2/css/select2.min.css'));$this->headLink()->appendStylesheet($this->basePath('assets/vendors/select2-bootstrap5-theme/select2-bootstrap-5-theme.css'));$this->inlineScript()->appendFile($this->basePath('assets/vendors/select2/js/select2.min.js'));$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-input-number/input-number-format.jquery.js'));$this->inlineScript()->captureStart();echo <<<JSjQuery( document ).ready(function( $ ) {var allowEdit = $allowEdit;var allowDelete = $allowDelete;var gridTable = $('#gridTable').dataTable( {'processing': true,'serverSide': true,'searching': true,'order': [[ 0, 'asc' ]],'ordering': true,'ordenable' : true,'responsive': true,'select' : false,'paging': true,'pagingType': 'simple_numbers','ajax': {'url' : '$routeDatatable','type' : 'get','beforeSend': function (request) {NProgress.start();},'dataFilter': function(response) {var response = jQuery.parseJSON( response );var json = {};json.recordsTotal = 0;json.recordsFiltered = 0;json.data = [];if(response.success) {json.recordsTotal = response.data.total;json.recordsFiltered = response.data.total;json.data = response.data.items;} else {$.fn.showError(response.data)}return JSON.stringify( json );}},'language' : {'sProcessing': 'LABEL_DATATABLE_SPROCESSING','sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU','sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS','sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE','sInfo': 'LABEL_DATATABLE_SINFO','sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY','sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED','sInfoPostFix': '','sSearch': 'LABEL_DATATABLE_SSEARCH','sUrl': '','sInfoThousands': ',','sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS','oPaginate': {'sFirst': 'LABEL_DATATABLE_SFIRST','sLast': 'LABEL_DATATABLE_SLAST','sNext': 'LABEL_DATATABLE_SNEXT','sPrevious': 'LABEL_DATATABLE_SPREVIOUS'},'oAria': {'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING','sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'},},'drawCallback': function( settings ) {NProgress.done();},'aoColumns': [{ 'mDataProp': 'name' },{ 'mDataProp': 'intelligence' },{ 'mDataProp': 'actions' },],'columnDefs': [{'targets': 0,'className' : 'text-vertical-middle',},{'targets': 1,'className' : 'text-vertical-middle',},{'targets': 2,'orderable': false,'render' : function ( data, type, row ) {s = '';if(allowEdit) {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> ';}if(allowDelete) {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> ';}return s;}}],});var validator = $('#form').validate({debug: true,onclick: false,onkeyup: false,ignore: [],rules: {'name': {required: true,maxlength: 100,},'description': {maxlength: 500,},'quantitative_value': {required: true,},'qualitative_description': {required: true,},},submitHandler: function(form){NProgress.start();$.ajax({'dataType' : 'json','accept' : 'application/json','method' : 'post','url' : $('#form').attr('action'),'data' : $('#form').serialize()}).done(function(response) {if(response['success']) {$.fn.showSuccess(response['message' ]);$('#modal').modal('hide');gridTable.api().ajax.reload(null, false);} else {validator.resetForm();if(jQuery.type(response['data']) == 'string') {$.fn.showError(response['data']);} else {$.each(response['data'], function( fieldname, errors ) {$.fn.showFormErrorValidator('#form #' + fieldname, errors);});}}}).fail(function( jqXHR, textStatus, errorThrown) {$.fn.showError(textStatus);}).always(function() {NProgress.done();});return false;},invalidHandler: function(form, validator) {}});$('body').on('click', 'button.btn-add', function(e) {e.preventDefault();$('.nav-tabs a[href="#general"]').tab('show')$('#form').attr('action', '$routeAdd');$('#form #name').val('');$('#form #description').val('');$('#form #quantitative_value').val('0');$('#form #qualitative_description').val('');$('#form #notification_10min_before').prop('checked', false);$('#form #notification_30min_before').prop('checked', false);$('#form #monday_active').prop('checked', false);$('#form #tuesday_active').prop('checked', false);$('#form #wednesday_active').prop('checked', false);$('#form #thursday_active').prop('checked', false);$('#form #friday_active').prop('checked', false);$('#form #saturday_active').prop('checked', false);$('#form #sunday_active').prop('checked', false);$('#form #monday_hour').prop('selectedIndex', 0);$('#form #monday_minute').prop('selectedIndex', 0);$('#form #tuesday_hour').prop('selectedIndex', 0);$('#form #tuesday_minute').prop('selectedIndex', 0);$('#form #wednesday_hour').prop('selectedIndex', 0);$('#form #wednesday_minute').prop('selectedIndex', 0);$('#form #thursday_hour').prop('selectedIndex', 0);$('#form #thursday_minute').prop('selectedIndex', 0);$('#form #friday_hour').prop('selectedIndex', 0);$('#form #friday_minute').prop('selectedIndex', 0);$('#form #saturday_hour').prop('selectedIndex', 0);$('#form #saturday_minute').prop('selectedIndex', 0);$('#form #sunday_hour').prop('selectedIndex', 0);$('#form #sunday_minute').prop('selectedIndex', 0);$('#form #intelligence').prop('selectedIndex', 0);validator.resetForm();$('#modal').modal('show');});$('body').on('click', 'button.btn-edit', function(e) {e.preventDefault();NProgress.start();var action = $(this).data('href');$.ajax({'dataType' : 'json','accept' : 'application/json','method' : 'get','url' : action,}).done(function(response) {if(response['success']) {$('#form').attr('action', action);$('#form #name').val(response['data']['name']);$('#form #description').val(response['data']['description']);$('#form #quantitative_value').val(response['data']['quantitative_value']);$('#form #qualitative_description').val(response['data']['qualitative_description']);$('#form #notification_10min_before').prop('checked', response['data']['notification_10min_before']);$('#form #notification_30min_before').prop('checked', response['data']['notification_30min_before']);$('#form #monday_active').prop('checked', response['data']['monday_active']);$('#form #tuesday_active').prop('checked', response['data']['tuesday_active']);$('#form #wednesday_active').prop('checked', response['data']['wednesday_active']);$('#form #thursday_active').prop('checked', response['data']['thursday_active']);$('#form #friday_active').prop('checked', response['data']['friday_active']);$('#form #saturday_active').prop('checked', response['data']['saturday_active']);$('#form #sunday_active').prop('checked', response['data']['sunday_active']);$('#form #monday_hour').val(response['data']['monday_hour']);$('#form #monday_minute').val(response['data']['monday_minute']);$('#form #tuesday_hour').val(response['data']['tuesday_hour']);$('#form #tuesday_minute').val(response['data']['tuesday_minute']);$('#form #wednesday_hour').val(response['data']['wednesday_hour']);$('#form #wednesday_minute').val(response['data']['wednesday_minute']);$('#form #thursday_hour').val(response['data']['thursday_hour']);$('#form #thursday_minute').val(response['data']['thursday_minute']);$('#form #friday_hour').val(response['data']['friday_hour']);$('#form #friday_minute').val(response['data']['friday_minute']);$('#form #saturday_hour').val(response['data']['saturday_hour']);$('#form #saturday_minute').val(response['data']['saturday_minute']);$('#form #sunday_hour').val(response['data']['sunday_hour']);$('#form #sunday_minute').val(response['data']['sunday_minute']);$('#form #intelligence').val(response['data']['intelligence']);validator.resetForm();$('#modal').modal('show');} else {$.fn.showError(response['data']);}}).fail(function( jqXHR, textStatus, errorThrown) {$.fn.showError(textStatus);}).always(function() {NProgress.done();});});$('body').on('click', 'button.btn-delete', function(e) {e.preventDefault();var action = $(this).data('href');swal.fire({title: 'LABEL_ARE_YOU_SURE',icon: 'question',cancelButtonText: 'LABEL_NO',showCancelButton: true,confirmButtonText: 'LABEL_YES'}).then((result) => {if (result.isConfirmed) {NProgress.start();$.ajax({'dataType' : 'json','accept' : 'application/json','method' : 'post','url' : action,}).done(function(response) {if(response['success']) {$.fn.showSuccess(response['data']);gridTable.api().ajax.reload(null, false);} else {$.fn.showError(response['data']);}}).fail(function( jqXHR, textStatus, errorThrown) {$.fn.showError(textStatus);}).always(function() {NProgress.done();});}});});$('body').on('click', 'button.btn-refresh', function(e) {e.preventDefault();gridTable.api().ajax.reload(null, false);});$('body').on('click', 'button.btn-cancel', function(e) {e.preventDefault();$('#modal').modal('hide');});$('#form #quantitative_value').inputNumberFormat({decimal: 2});$('#form #description').maxlength({alwaysShow: true,validate: true});});JS;$this->inlineScript()->captureEnd();?><div class="container"><div class="row"><div class="col-12 mt-3"><div class="card"><div class="card-body"><h6 class="card-title">LABEL_SKILLS</h6><div class="row"><div class="col-12 mt-3"><table id="gridTable" class="table table-bordered"><thead><tr><th>LABEL_NAME</th><th>LABEL_INTELLIGENCE</th><th>LABEL_ACTIONS</th></tr></thead><tbody></tbody></table></div></div></div><div class="card-footer text-right"><button type="button" class="btn btn-info btn-refresh"><i class="fa fa-sync"></i> LABEL_REFRESH </button><?php if($allowAdd) : ?><button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button><?php endif; ?></div></div></div></div></div><!-- The Modal --><div class="modal" id="modal"><div class="modal-dialog modal-md"><div class="modal-content"><!-- Modal Header --><div class="modal-header"><h6 class="modal-title">LABEL_SKILLS</h6><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button></div><?php$form = $this->form;$form->setAttributes(['method' => 'post','name' => 'form','id' => 'form']);$form->prepare();echo $this->form()->openTag($form);?><!-- Modal body --><div class="modal-body"><ul class="nav nav-tabs" id="myTab" role="tablist"><li class="nav-item"><a class="nav-link active" id="general-tab" data-bs-toggle="tab" href="#general" role="tab" aria-controls="general" aria-selected="true">LABEL_GENERAL</a></li><li class="nav-item"><a class="nav-link" id="calendar-tab" data-bs-toggle="tab" href="#calendar" role="tab" aria-controls="calendar" aria-selected="false">LABEL_CALENDAR</a></li><li class="nav-item"><a class="nav-link" id="notification-tab" data-bs-toggle="tab" href="#notification" role="tab" aria-controls="notification" aria-selected="false">LABEL_NOTIFICATION</a></li></ul><div class="tab-content border border-top-0 p-3" id="myTabContent"><div class="tab-pane fade show active" id="general" role="tabpanel" aria-labelledby="general-tab"><div class="row"><div class="col mt-3"><?php$element = $form->get('name');$element->setOptions(['label' => 'LABEL_NAME']);$element->setAttributes(['class' => 'form-control', 'maxlength' => 100]);echo $this->formLabel($element);echo $this->formText($element);?></div></div><div class="row"><div class="col mt-3"><?php$element = $form->get('description');$element->setOptions(['label' => 'LABEL_DESCRIPTION']);$element->setAttributes(['class' => 'form-control', 'maxlength' => 500]);echo $this->formLabel($element);echo $this->formTextArea($element);?></div></div><div class="row"><div class="col mt-3"><?php$element = $form->get('quantitative_value');$element->setOptions(['label' => 'LABEL_QUANTITATIVE_VALUE']);$element->setAttributes(['class' => 'form-control', 'maxlength' => 5]);echo $this->formLabel($element);echo $this->formText($element);?></div></div><div class="row"><div class="col mt-3"><?php$element = $form->get('qualitative_description');$element->setOptions(['label' => 'LABEL_QUALITATIVE_DESCRIPTION']);$element->setAttributes(['class' => 'form-control', 'maxlength' => 50]);echo $this->formLabel($element);echo $this->formText($element);?></div></div><div class="row"><div class="col mt-3"><?php$element = $form->get('intelligence');$element->setOptions(['label' => 'LABEL_INTELLIGENCE']);$element->setAttributes(['class' => 'form-control']);echo $this->formLabel($element);echo $this->formSelect($element);?></div></div></div><div class="tab-pane fade" id="calendar" role="tabpanel" aria-labelledby="calendar-tab"><div class="row"><div class="col-12 mt-3"><table class="table table-bordered"><thead><tr><th>LABEL_DAY</th><th>LABEL_ACTIVE</th><th>LABEL_HOUR</th><th>LABEL_MINUTE</th></tr></thead><tbody><?php$days = ['monday','tuesday','wednesday','thursday','friday','saturday','sunday',];foreach($days as $day) :$label = 'LABEL_' . strtoupper($day);$checkbox = $day . '_active';$hour = $day . '_hour';$minute = $day . '_minute';?><tr><td><?php echo $label ?></td><td><div class="form-check form-check-inline"><?php$element = $form->get($checkbox);$element->setAttributes(['class' => 'form-check-input']);echo $this->formCheckbox($element);?></div></td><td><?php$element = $form->get($hour);$element->setAttributes(['class' => 'form-control']);echo $this->formSelect($element);?></td><td><?php$element = $form->get($minute);$element->setAttributes(['class' => 'form-control']);echo $this->formSelect($element);?></td></tr><?php endforeach; ?></tbody></table></div></div></div><div class="tab-pane fade" id="notification" role="tabpanel" aria-labelledby="notification-tab"><div class="row"><div class="col-12 mt-3"><div class="form-check form-check-inline mt-3"><?php$element = $form->get( 'notification_10min_before');$element->setOptions(['label' => 'LABEL_NOTIFICATION_10_MIN_BEFORE', 'class' => 'form-check-label']);$element->setAttributes(['class' => 'form-check-input']);echo $this->formCheckbox($element);echo $this->formLabel($element);?></div><br/><div class="form-check form-check-inline mt-3"><?php$element = $form->get('notification_30min_before');$element->setOptions(['label' => 'LABEL_NOTIFICATION_30_MIN_BEFORE', 'class' => 'form-check-label']);$element->setAttributes(['class' => 'form-check-input']);echo $this->formCheckbox($element);echo $this->formLabel($element);?></div></div></div></div></div></div><!-- Modal footer --><div class="modal-footer text-right"><button type="submit" class="btn btn-primary">LABEL_SAVE</button><button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button></div><?php echo $this->form()->closeTag($form); ?></div></div></div>