Rev 16285 | Rev 16843 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
<?php$acl = $this->viewModel()->getRoot()->getVariable('acl');$currentUser = $this->currentUserHelper();$roleName = $currentUser->getUserTypeId();$route = $this->url('tools/userfile-password-generator');$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-fileinput/css/fileinput.min.css'));$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-fileinput/themes/explorer-fa/theme.css'));$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/plugins/piexif.js'));$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/plugins/sortable.js'));$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/fileinput.js'));$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/locales/es.js'));$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/themes/fa/theme.js'));$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/themes/explorer-fa/theme.js'));$this->inlineScript()->captureStart();echo <<<JSjQuery( document ).ready(function( $ ) {$.validator.setDefaults({debug: true,highlight: function(element) {$(element).closest('.sn-field').addClass('sn-field-has-error');},unhighlight: function(element) {$(element).closest('.sn-field').removeClass('sn-field-has-error');},errorElement: 'div',errorClass: 'sn-field-invalid-feedback',errorPlacement: function(error, element) {console.log(element);if(element.parent('.sn-field').length) {error.insertAfter(element.parent());} else if (element.parent('.fgt-sec').length) {error.insertAfter(element.parent());} else {error.insertAfter(element);}}});$.validator.setDefaults({debug: true,highlight: function(element) {$(element).addClass('form-group-has-error');},unhighlight: function(element) {$(element).removeClass('form-group-has-error');},errorElement: 'div',errorClass: 'form-group-invalid-feedback',errorPlacement: function(error, element) {if(element.parent('.form-group').length) {error.insertAfter(element.parent());} else if(element.parent('.toggle').length) {error.insertAfter(element.parent().parent());} else {error.insertAfter(element);}}});$.fn.showFormErrorValidator = function(fieldname, errors) {var field = $(fieldname);if(field) {$(field).addClass('form-group-has-error');var error = $('<div id="' + fieldname +'-error" class="form-group-invalid-feedback">' + errors + '</div>');if(field.parent('.form-group').length) {error.insertAfter(field.parent());} else if(field.parent('.toggle').length) {error.insertAfter(field.parent().parent());} else {error.insertAfter(field);}}};var validator = $('#form').validate({debug: true,onclick: false,onkeyup: false,onfocusout: false,ignore: [],rules: {'file' : {required: true,extension: 'xls|xlsx',accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel'},},submitHandler: function(form){NProgress.start();var formdata = false;if (window.FormData){formdata = new FormData(form);}$.ajax({'dataType' : 'json','accept' : 'application/json','method' : 'post','url' : '$route','data' : formdata,'processData': false,'contentType': false,}).done(function(response) {if(response['success']) {var anchor = window.document.createElement("a");anchor.href = 'data:application/octet-stream;charset=utf-8;base64,' + response['data']['content'] ;anchor.download = response['data']['basename'];document.body.appendChild(anchor);anchor.click(); // IE: "Access is denied"; see: https://connect.microsoft.com/IE/feedback/details/797361/ie-10-treats-blob-url-as-cross-origin-and-denies-accessdocument.body.removeChild(anchor);} 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) {}});$('#form #file').fileinput({theme: 'fa',language: 'es',showUpload: false,dropZoneEnabled: false,maxFileCount: 1,allowedFileExtensions: ['xls', 'xlsx'],});});JS;$this->inlineScript()->captureEnd();?><!-- Content Header (Page header) --><section class="content-header"><div class="container-fluid"><div class="row mb-2"><div class="col-sm-12"><h1>LABEL_USERFILE_PASSWORD_GENERATOR</h1></div></div></div><!-- /.container-fluid --></section><section class="content"><div class="container-fluid"><div class="row"><div class="col-12"><div class="card"><?php$form = $this->form;$form->setAttributes(['method' => 'post','name' => 'form','id' => 'form']);$form->prepare();echo $this->form()->openTag($form);?><div class="card-body"><div class="form-group"><?php$element = $form->get('file');$element->setOptions(['label' => 'LABEL_EXCEL']);echo $this->formLabel($element);?><div class="file-loading"><?php$element->setAttributes(['class' => 'form-control', 'accept' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel']);echo $this->formFile($element);?></div></div></div><div class="card-footer clearfix"><div style="float:right;"><button type="submit" class="btn btn-sm btn-primary">LABEL_UPLOAD</button></div></div><?php echo $this->form()->closeTag($form); ?></div></div></div></div></section>