Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
1709 eleazar 1
<?php
2
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser    = $this->currentUserHelper();
4
$roleName       = $currentUser->getUserTypeId();
5
 
2029 eleazar 6
$routeIndex = $this->url('recruitment-and-selection/interview/form');
2128 eleazar 7
$routeAdd = $this->url('recruitment-and-selection/interview/form/add', ['candidate_uuid' => 'UUID_PLACEHOLDER']);
1877 eleazar 8
 
1827 eleazar 9
$allowAdd = $acl->isAllowed($roleName, 'recruitment-and-selection/interview/form/add') ? 1 : 0;
1709 eleazar 10
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
11
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
12
 
13
 
14
$this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));
15
 
16
 
1885 eleazar 17
$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
1709 eleazar 18
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
19
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
20
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
21
 
22
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
23
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
24
 
25
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
26
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
27
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
28
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
29
 
30
 
31
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
32
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
33
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
34
 
35
 
36
 
37
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
38
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
39
 
40
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
41
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
42
 
43
$this->inlineScript()->appendFile($this->basePath('plugins/moment/moment-with-locales.min.js'));
44
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css'));
45
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'));
46
 
1887 eleazar 47
 
48
$this->inlineScript()->appendFile($this->basePath('plugins/select2/js/select2.js'));
49
$this->inlineScript()->appendFile($this->basePath('plugins/select2/js/i18n/es.js'));
50
$this->headLink()->appendStylesheet($this->basePath('plugins/select2/css/select2.css'));
51
 
52
$this->headLink()->appendStylesheet($this->basePath('plugins/select2-bootstrap4-theme/select2-bootstrap4.css'));
1709 eleazar 53
 
2052 eleazar 54
// JsRender //
55
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.min.js'));
1709 eleazar 56
 
57
$this->headStyle()->captureStart();
58
echo <<<CSS
59
 
60
CSS;
61
$this->headStyle()->captureEnd();
62
 
63
$this->inlineScript()->captureStart();
64
echo <<<JS
65
 
2503 eleazar 66
const classFormGenerator = function() {
67
    this.id = 0,
68
        this.table = '',
69
        this.name = '',
70
        this.text = '',
71
        this.status = 'a',
72
        this.sections = [],
73
        this.clear = function() {
74
            this.sections = [];
75
            this.render();
76
        },
77
 
78
        /**
79
         * Add element to section array
80
         */
81
        this.addSection = function(name, text, value) {
82
            var d = new Date();
83
            var slug = 'section' + d.getTime();
84
            var position = 0;
85
            $.each(this.sections, function(index, section) {
86
                if (position < section.position) {
87
                    position = section.position;
88
                }
89
            });
90
            position++;
91
            var section = {
92
                'slug_section': slug,
93
                'name': name,
94
                'text': text,
95
                'value': value,
96
                'position': position,
97
                'questions': [],
98
                'status': 0
99
            }
100
            this.sections.push(section);
101
        },
102
         /**
103
         * Edit element to section array
104
         */
105
        this.editSection = function(slug, name, text, value) {
106
            var renderTable = false;
107
            for (i = 0; i < this.sections.length; i++) {
108
                if (slug == this.sections[i].slug_section) {
109
                    this.sections[i].name = name;
110
                    this.sections[i].text = text;
111
                    this.sections[i].value = value;
112
                    renderTable = true;
113
                    break;
114
                }
115
            }
116
            if (renderTable) {
117
                this.renderSection(slug);
118
            }
119
        },
120
         /**
121
         * Remove element to section array
122
         */
123
        this.deleteSection = function(slug) {
124
            var renderTable = false;
125
            for (i = 0; i < this.sections.length; i++) {
126
                if (slug == this.sections[i].slug_section) {
127
                    this.sections.splice(i, 1);
128
                    renderTable = true;
129
                    break;
130
                }
131
            }
132
            if (renderTable) {
133
                $('#panel' + slug).remove();
134
            }
135
        }
136
}
137
 
2501 eleazar 138
    function htmlEntities(str) {
139
        return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
140
    }
2500 eleazar 141
 
1709 eleazar 142
jQuery( document ).ready(function( $ ) {
1877 eleazar 143
    $.validator.setDefaults({
2015 eleazar 144
        debug: true,
145
        highlight: function(element) {
146
            $(element).addClass('is-invalid');
147
        },
148
        unhighlight: function(element) {
149
            $(element).removeClass('is-invalid');
150
        },
151
        errorElement: 'span',
152
        errorClass: 'error invalid-feedback',
153
        errorPlacement: function(error, element) {
154
            if(element.parent('.btn-file').length) {
155
                error.insertAfter(element.parent().parent());
156
            } else if(element.parent('.toggle').length) {
157
                error.insertAfter(element.parent().parent());
158
            } else {
159
                error.insertAfter(element.parent());
1709 eleazar 160
            }
2015 eleazar 161
        }
162
    });
1709 eleazar 163
 
164
 
2015 eleazar 165
    $.fn.showFormErrorValidator = function(fieldname, errors) {
166
        var field = $(fieldname);
167
        if(field) {
168
            $(field).addClass('is-invalid');
1709 eleazar 169
 
2015 eleazar 170
            var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');
171
 
172
            if(element.parent('.btn-file').length) {
173
                error.insertAfter(element.parent().parent());
174
            } else if(element.parent('.toggle').length) {
175
                error.insertAfter(element.parent().parent());
176
            } else {
177
                error.insertAfter(element.parent());
1709 eleazar 178
            }
2015 eleazar 179
        }
180
    };
1827 eleazar 181
 
2015 eleazar 182
    var validator = $('#form-interview').validate({
1877 eleazar 183
        debug: true,
184
        onclick: false,
185
        onkeyup: false,
186
        ignore: [],
187
        rules: {
188
            'name': {
189
                required: true,
190
                maxlength: 64,
191
            },
192
            'status': {
193
                required: false,
194
            },
2276 eleazar 195
 
1877 eleazar 196
        },
197
        submitHandler: function(form) {
198
            $.ajax({
199
                'dataType': 'json',
200
                'accept': 'application/json',
201
                'method': 'post',
2245 eleazar 202
                'url': $('#form').attr('action'),
203
                'data': $('#form').serialize()
1877 eleazar 204
            }).done(function(response) {
205
                NProgress.start();
206
                if (response['success']) {
207
                    $.fn.showSuccess(response['data']);
1900 eleazar 208
                    $('#content').show();
209
                    $('#row-form').hide();
1877 eleazar 210
                    gridTable.api().ajax.reload(null, false);
211
                } else {
212
                    validator.resetForm();
213
                    if (jQuery.type(response['data']) == 'string') {
214
                        $.fn.showError(response['data']);
215
                    } else {
216
                        $.each(response['data'], function(fieldname, errors) {
2245 eleazar 217
                            $.fn.showFormErrorValidator('#form #' + fieldname, errors);
1877 eleazar 218
                        });
219
                    }
220
                }
221
            }).fail(function(jqXHR, textStatus, errorThrown) {
222
                $.fn.showError(textStatus);
223
            }).always(function() {
224
                NProgress.done();
225
            });
226
            return false;
227
        },
228
        invalidHandler: function(form, validator) {}
229
    });
1709 eleazar 230
 
2015 eleazar 231
    $('body').on('click', 'button.btn-add', function(e) {
232
        e.preventDefault();
233
        NProgress.start();
234
        $.ajax({
235
            'dataType': 'json',
236
            'accept': 'application/json',
237
            'method': 'get',
2194 eleazar 238
            'url': '$routeAdd'.replaceAll('UUID_PLACEHOLDER', $('#candidate_uuid').val()),
2015 eleazar 239
        }).done(function(response) {
240
            if (response['success']) {
2237 eleazar 241
                var data = response.data
2264 eleazar 242
                $("#competencies-job").html($("#competenciesTemplate").render(data))
2313 eleazar 243
                $("#interview").show()
1877 eleazar 244
            } else {
2015 eleazar 245
                $.fn.showError(response['data']);
1877 eleazar 246
            }
2015 eleazar 247
        }).fail(function(jqXHR, textStatus, errorThrown) {
248
            $.fn.showError(textStatus);
249
        }).always(function() {
250
            NProgress.done();
1877 eleazar 251
        });
2015 eleazar 252
    });
1709 eleazar 253
 
2015 eleazar 254
    $('#form-interview #status').bootstrapToggle({
255
        'on': 'LABEL_ACTIVE',
256
        'off': 'LABEL_INACTIVE',
257
        'width': '160px',
258
        'height': '40px'
259
    });
1709 eleazar 260
 
2015 eleazar 261
 
2265 eleazar 262
 
2015 eleazar 263
    $('body').on('click', 'button.btn-cancel', function(e) {
264
        e.preventDefault();
265
        $('#content').show();
266
        $('#row-form').hide();
267
        $('#div-listing').show();
268
    });
269
 
270
    $('#form-filter #vacancy_uuid').change(function(e) {
271
        e.preventDefault();
272
        $('#form-filter #candidates_uuid').empty();
273
    })
2118 eleazar 274
 
2015 eleazar 275
    $('#form-filter #candidates_uuid').change(function(e) {
276
        e.preventDefault();
277
    })
2029 eleazar 278
 
279
    $('#vacancy_uuid').on('change', function () {
2042 eleazar 280
        $('#candidate_uuid').html('');
281
 
2029 eleazar 282
        $.ajax({
283
            'dataType': 'json',
284
            'accept': 'application/json',
285
            'method': 'get',
2031 eleazar 286
            'url': "$routeIndex" + "?vacancy_uuid=" + $('#vacancy_uuid').val(),
2038 eleazar 287
        }).done(function (response) {
288
            var data = response.data
289
 
2036 eleazar 290
            data.candidates.forEach(function (candidate) {
2041 eleazar 291
                var option = $('<option />').val(candidate.uuid).text(candidate.first_name);
292
 
293
                $('#candidate_uuid').append(option);
2036 eleazar 294
            });
2052 eleazar 295
 
2244 eleazar 296
            $('#job-description').html($('#job-description-template').render(response.data));
2029 eleazar 297
        })
298
    });
2032 eleazar 299
 
300
    $('#vacancy_uuid').change();
1709 eleazar 301
});
302
JS;
303
$this->inlineScript()->captureEnd();
304
?>
305
 
306
 
307
<!-- Content Header (Page header) -->
308
<section class="content-header">
309
	<div class="container-fluid">
310
    	<div class="row mb-2">
311
        	<div class="col-sm-12">
312
            	<h1>LABEL_INTERVIEW</h1>
313
			</div>
314
		</div>
315
	</div><!-- /.container-fluid -->
316
</section>
317
 
318
<section class="content">
319
	<div class="container-fluid">
320
    	<div class="row">
321
        	<div class="col-12">
322
				<div class="card">
2021 eleazar 323
					<div class="card-header">
1709 eleazar 324
                        <div class="row">
325
                            <div class="col-md-6 col-sm-12">
326
                                <div class="form-group">
2021 eleazar 327
                                    <label for="vacancy_uuid">LABEL_VACANCY</label>
2023 eleazar 328
                                    <select id="vacancy_uuid" name="vacancy_uuid" class="form-control">
2021 eleazar 329
                                        <?php foreach($this->vacancies as $vacancy): ?>
2023 eleazar 330
                                            <option value="<?= $vacancy->uuid ?>"><?= $vacancy->name ?></option>
2021 eleazar 331
                                        <?php endforeach; ?>
332
                                    </select>
1709 eleazar 333
                                </div>
334
                            </div>
335
                            <div class="col-md-6 col-sm-12">
336
                                <div class="form-group">
2040 eleazar 337
                                    <label for="candidate_uuid">LABEL_CANDIDATES</label>
2024 eleazar 338
                                    <select id="candidate_uuid" name="candidate_uuid" class="form-control">
339
                                    </select>
1709 eleazar 340
                                </div>
341
                            </div>
342
                            <div
343
                                class="col-md-12 col-sm-12"
344
                            >
345
                            </div>
346
                        </div>
347
					</div>
348
					<div class="card-body">
2052 eleazar 349
                        <div id="job-description"></div>
1709 eleazar 350
                   	</div>
2015 eleazar 351
 
352
                    <div class="card-footer clearfix">
353
                        <div style="float:right;">
354
                            <?php if($allowAdd) : ?>
355
                                <button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
356
                            <?php endif; ?>
1876 eleazar 357
                        </div>
2015 eleazar 358
                    </div>
359
                </div>
1876 eleazar 360
            </div>
2015 eleazar 361
        </div>
362
 	</div>
363
</section>
2052 eleazar 364
 
365
<script id="job-description-template" type="text/x-jsrender">
366
    <div class="card">
367
        <div class="card-body">
368
            <h5 class="card-title">{{:job_description.name}}</h5>
369
            <p class="card-text">{{:vacancy.description}}</p>
2214 eleazar 370
            <p class="card-text">{{:job_description.objectives}}</p>
371
            <p class="card-text">{{:job_description.functions}}</p>
2052 eleazar 372
        </div>
373
    </div>
2061 eleazar 374
</script>
375
 
2314 eleazar 376
<section id="interview" style="display: none;">
2215 eleazar 377
	<div class="container-fluid">
378
    	<div class="row">
379
        	<div class="col-12">
380
				<div class="card">
381
					<div class="card-header">
382
                        <label>interview</label>
383
					</div>
384
					<div class="card-body">
2217 eleazar 385
                        <div id="competencies-job"></div>
2313 eleazar 386
 
387
                        <div class="form-group">
388
                          <label for="text-option">LABEL_FINAL_COMMENT</label>
389
                          <!-- ckeditor -->
2277 eleazar 390
                          <textarea  name="text-option" id="text-option" rows="5" class="form-control"></textarea>
391
                    </div>
2313 eleazar 392
                   	</div>
2280 eleazar 393
                    <div class="card-footer clearfix">
2284 eleazar 394
                        <button type="button" class="btn btn-primary btn-behavior-submit">LABEL_SAVE</button>
395
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
2280 eleazar 396
                    </div>
2278 eleazar 397
                </div>
2215 eleazar 398
            </div>
399
        </div>
400
 	</div>
401
</section>
402
 
2264 eleazar 403
<script id="competenciesTemplate" type="text/x-jsrender">
2293 eleazar 404
<table class="table table-bordered">
405
    <thead>
406
        <tr>
2306 eleazar 407
           <th style="width: 50%;">LABEL_ELEMENT</th>
2293 eleazar 408
           <th style="width: 50%;">LABEL_TITLE</th>
409
        </tr>
410
    </thead>
2300 eleazar 411
    <tbody>
412
        {{for job_description.competencies}}
413
            <tr>
414
               <td class="text-left">LABEL_COMPETENCY</td>
2302 eleazar 415
               <td class="text-left">{{:competency_name}}</td>
2300 eleazar 416
            </tr>
2302 eleazar 417
 
418
            {{for behaviors}}
2308 eleazar 419
                <tr>
2302 eleazar 420
                   <td class="text-left">--LABEL_CONDUCT</td>
421
                   <td class="text-left">
2303 eleazar 422
                      {{:description}}
2302 eleazar 423
                   </td>
424
                </tr>
425
            {{/for}}
2307 eleazar 426
 
2302 eleazar 427
            <tr>
2310 eleazar 428
                <td colspan="2">
2312 eleazar 429
                    <label for="textarea-{{:competency_uuid}}">LABEL_COMMENT</label>
430
                    <textarea
431
                        id="textarea-{{:competency_uuid}}"
432
                        class="form-control"
433
                    ></textarea>
2310 eleazar 434
                </td>
2300 eleazar 435
            </tr>
436
        {{/for}}
437
    </tbody>
2293 eleazar 438
</table>
2241 eleazar 439
</script>