Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15540 | Rev 16891 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
15540 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('engagement/setup');
9
 
16822 efrain 10
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
11
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
15540 efrain 12
 
16822 efrain 13
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/jquery.validate.js'));
14
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/additional-methods.js'));
15
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/localization/messages_es.js'));
15540 efrain 16
 
16822 efrain 17
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-input-number/input-number-format.jquery.js'));
15540 efrain 18
 
19
 
20
$this->inlineScript()->captureStart();
21
echo <<<JS
22
    jQuery( document ).ready(function( $ ) {
23
 
24
        $.validator.setDefaults({
25
            debug: true,
26
            highlight: function(element) {
27
                $(element).addClass('is-invalid');
28
            },
29
            unhighlight: function(element) {
30
                $(element).removeClass('is-invalid');
31
            },
32
            errorElement: 'span',
33
            errorClass: 'error invalid-feedback',
34
            errorPlacement: function(error, element) {
35
                if(element.parent('.form-group').length) {
36
                    error.insertAfter(element);
37
                } else if(element.parent('.toggle').length) {
38
                    error.insertAfter(element.parent().parent());
39
                } else {
40
                    error.insertAfter(element.parent());
41
                }
42
            }
43
        });
44
 
45
 
46
        $.fn.showFormErrorValidator = function(fieldname, errors) {
47
            var field = $(fieldname);
48
            if(field) {
49
                $(field).addClass('is-invalid');
50
 
51
 
52
                var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');
53
                if(field.parent('.form-group').length) {
54
                    error.insertAfter(field);
55
                } else  if(field.parent('.toggle').length) {
56
                    error.insertAfter(field.parent().parent());
57
                } else {
58
                    error.insertAfter(field.parent());
59
                }
60
            }
61
        };
62
 
63
        var validator = $('#form').validate({
64
            debug: true,
65
            onclick: false,
66
            onkeyup: false,
67
            ignore: [],
68
            rules: {
69
                'daily_pulse_how_are_you_feel': {
70
                    required: true,
71
                    min: 0,
72
 
73
                },
74
                'daily_pulse_climate_on_your_organization': {
75
                    required: true,
76
                    min: 0,
77
 
78
                },
79
                'feed_survey': {
80
                    required: true,
81
                    min: 0,
82
 
83
                },
84
                'internal_survey': {
85
                    required: true,
86
                    min: 0,
87
 
88
                },
89
            },
90
            submitHandler: function(form)
91
            {
92
 
93
                $.ajax({
94
                    'dataType'  : 'json',
95
                    'accept'    : 'application/json',
96
                    'method'    : 'post',
97
                    'url'       :  $('#form').attr('action'),
98
                    'data'      :  $('#form').serialize(),
99
                }).done(function(response) {
100
                    NProgress.start();
101
                    if(response['success']) {
102
                        $.fn.showSuccess(response['data']);
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-add #' + fieldname, errors);
110
                            });
111
                        }
112
                    }
113
                }).fail(function( jqXHR, textStatus, errorThrown) {
114
                    $.fn.showError(textStatus);
115
                }).always(function() {
116
                    NProgress.done();
117
                });
118
                return false;
119
            },
120
            invalidHandler: function(form, validator) {
121
            }
122
        });
123
 
124
 
125
        $('#form #daily_pulse_how_are_you_feel').inputNumberFormat({decimal: 0});
126
        $('#form #daily_pulse_climate_on_your_organization').inputNumberFormat({decimal: 0});
127
        $('#form #feed_survey').inputNumberFormat({decimal: 0});
128
        $('#form #internal_survey').inputNumberFormat({decimal: 0});
129
 
130
 
131
 
132
 
133
    });
134
JS;
135
$this->inlineScript()->captureEnd();
136
?>
137
 
138
 
139
 
16822 efrain 140
<div class="container">
15540 efrain 141
        <div class="row">
142
            <div class="col-12">
143
                <div class="card">
16822 efrain 144
               		<h6 class="card-title">LABEL_ENGAGEMENT (LABEL_POINTS)</h6>
15540 efrain 145
                	 <?php
146
                    $form = $this->form;
147
                    $form->setAttributes([
148
                        'method'    => 'post',
149
                        'name'      => 'form',
150
                        'id'        => 'form',
151
                        'action'    => $route,
152
                    ]);
153
 
154
                    $form->prepare();
155
                    echo $this->form()->openTag($form);
156
                    ?>
157
                    <div class="card-body">
158
                        <div class="form-group">
159
                            <?php
160
                            $element = $form->get('daily_pulse_how_are_you_feel');
161
                            $element->setOptions(['label' => 'LABEL_HOW_ARE_YOU_FEEL']);
162
                            $element->setAttributes(['class' => 'form-control']);
163
 
164
                            echo $this->formLabel($element);
165
                            echo $this->formNumber($element);
166
                            ?>
167
                        </div>
168
                      	<div class="form-group">
169
                            <?php
170
                            $element = $form->get('daily_pulse_climate_on_your_organization');
171
                            $element->setOptions(['label' => 'LABEL_CLIMATE_ON_YOUR_ORGANIZATION']);
172
                            $element->setAttributes(['class' => 'form-control']);
173
 
174
                            echo $this->formLabel($element);
175
                            echo $this->formNumber($element);
176
                            ?>
177
                        </div>
178
                        <div class="form-group">
179
                            <?php
180
                            $element = $form->get('feed_survey');
181
                            $element->setOptions(['label' => 'LABEL_FEED_SURVEY']);
182
                            $element->setAttributes(['class' => 'form-control']);
183
 
184
                            echo $this->formLabel($element);
185
                            echo $this->formNumber($element);
186
                            ?>
187
                        </div>
188
                      	<div class="form-group">
189
                            <?php
190
                            $element = $form->get('internal_survey');
191
                            $element->setOptions(['label' => 'LABEL_INTERNAL_SURVEY']);
192
                            $element->setAttributes(['class' => 'form-control']);
193
 
194
                            echo $this->formLabel($element);
195
                            echo $this->formNumber($element);
196
                            ?>
197
                        </div>
198
 
199
 
200
 
201
               		</div>
202
 
203
               		<div class="card-footer">
204
                   		<div class="text-right">
205
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
206
                    	</div>
207
               		</div>
208
               		 <?php echo $this->form()->closeTag($form); ?>
209
                </div>
210
            </div>
211
        </div>
212
    </div>
16822 efrain 213