Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16891 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
16285 efrain 1
<?php
2
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser    = $this->currentUserHelper();
4
 
5
$roleName = $currentUser->getUserTypeId();
6
 
7
 
8
$route   = $this->url('tools/userfile-password-generator');
9
 
10
 
11
 
16822 efrain 12
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
13
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
16285 efrain 14
 
15
 
16929 efrain 16
 
17
 
18
 
16822 efrain 19
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-fileinput/css/fileinput.min.css'));
20
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-fileinput/themes/explorer-fa/theme.css'));
16285 efrain 21
 
16843 efrain 22
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/plugins/piexif.js'));
23
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/plugins/sortable.js'));
16822 efrain 24
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/fileinput.js'));
25
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/locales/es.js'));
26
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/themes/fa/theme.js'));
27
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/themes/explorer-fa/theme.js'));
16285 efrain 28
 
29
 
30
$this->inlineScript()->captureStart();
31
echo <<<JS
32
    jQuery( document ).ready(function( $ ) {
33
 
34
        $.validator.setDefaults({
35
            debug: true,
36
            highlight: function(element) {
37
                $(element).closest('.sn-field').addClass('sn-field-has-error');
38
            },
39
            unhighlight: function(element) {
40
                $(element).closest('.sn-field').removeClass('sn-field-has-error');
41
            },
42
            errorElement: 'div',
43
            errorClass: 'sn-field-invalid-feedback',
44
            errorPlacement: function(error, element) {
45
                console.log(element);
46
 
47
                if(element.parent('.sn-field').length) {
48
                    error.insertAfter(element.parent());
49
                } else if (element.parent('.fgt-sec').length) {
50
                    error.insertAfter(element.parent());
51
                } else {
52
                    error.insertAfter(element);
53
                }
54
            }
55
        });
56
 
57
 
58
 
59
    var validator = $('#form').validate({
60
        debug: true,
61
        onclick: false,
62
        onkeyup: false,
63
        onfocusout: false,
64
        ignore: [],
65
        rules: {
66
            'file' : {
67
                required: true,
68
                extension: 'xls|xlsx',
69
                accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel'
70
            },
71
        },
72
 
73
        submitHandler: function(form)
74
        {
75
            NProgress.start();
76
            var formdata = false;
77
            if (window.FormData){
78
                formdata = new FormData(form);
79
            }
80
 
81
 
82
            $.ajax({
83
                'dataType'  : 'json',
84
                'accept'    : 'application/json',
85
                'method'    : 'post',
86
                'url'       : '$route',
87
                'data'      :  formdata,
88
                'processData': false,
89
                'contentType': false,
90
            }).done(function(response) {
91
                if(response['success']) {
92
 
93
 
94
                    var anchor = window.document.createElement("a");
95
                    anchor.href = 'data:application/octet-stream;charset=utf-8;base64,' + response['data']['content'] ;
96
                    anchor.download = response['data']['basename'];
97
                    document.body.appendChild(anchor);
98
                    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-access
99
                    document.body.removeChild(anchor);
100
 
101
 
102
 
103
                } else {
104
                    validator.resetForm();
105
                    if(jQuery.type(response['data']) == 'string') {
106
                        $.fn.showError(response['data']);
107
                    } else  {
108
                        $.each(response['data'], function( fieldname, errors ) {
109
                            $.fn.showFormErrorValidator('#form #' + fieldname, errors);
110
                        });
111
                    }
112
                }
113
            }).fail(function( jqXHR, textStatus, errorThrown) {
114
                $.fn.showError(textStatus);
115
            }).always(function() {
116
 
117
                NProgress.done();
118
            });
119
            return false;
120
        },
121
        invalidHandler: function(form, validator) {
122
 
123
        }
124
    });
125
 
126
    $('#form #file').fileinput({
127
        theme: 'fa',
128
        language: 'es',
129
        showUpload: false,
130
        dropZoneEnabled: false,
131
        maxFileCount: 1,
132
        allowedFileExtensions: ['xls', 'xlsx'],
133
    });
134
 
135
 
136
 
137
 
138
});
139
JS;
140
$this->inlineScript()->captureEnd();
141
 
142
?>
143
 
144
 
145
 
16891 efrain 146
<div class="container">
147
	<div class="card" id="">
148
	 	<div class="card-header">
149
	 		<h6 class="card-title">LABEL_USERFILE_PASSWORD_GENERATOR</h6>
150
	 	</div>
151
	 	<?php
16285 efrain 152
                    $form = $this->form;
153
                    $form->setAttributes([
154
                        'method'    => 'post',
155
                        'name'      => 'form',
156
                        'id'        => 'form'
157
                    ]);
158
 
159
                    $form->prepare();
160
                    echo $this->form()->openTag($form);
161
                    ?>
16891 efrain 162
	 	<div class="card-body">
163
	 		<div class="row">
164
	 	         <div class="col-12 mt-3">
165
 
166
	 	         <?php
16285 efrain 167
                            $element = $form->get('file');
168
                            $element->setOptions(['label' => 'LABEL_EXCEL']);
169
                            echo $this->formLabel($element);
170
                            ?>
171
                            <div class="file-loading">
172
                                <?php
16768 efrain 173
                                $element->setAttributes(['class' => 'form-control', 'accept' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel']);
16285 efrain 174
                                echo $this->formFile($element);
175
                                ?>
176
                            </div>
16891 efrain 177
 
178
	 	         </div>
179
	 	     </div>
180
	 	</div>
181
	 	<div class="card-footer text-right">
182
	 	     <button type="submit" class="btn btn-sm btn-primary">LABEL_UPLOAD</button>
183
	 	</div>
184
	 	 	<?php echo $this->form()->closeTag($form); ?>
185
	</div>
186
 
187
</div>
16285 efrain 188
 
189
 
190
 
191
 
192
 
193
 
194
 
195