Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 2521 | Rev 2523 | 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
 
2510 eleazar 57
$evaluation_0 = \LeadersLinked\Model\RecruitmentSelectionInterview::EVALUATION_0;
58
$evaluation_1 = \LeadersLinked\Model\RecruitmentSelectionInterview::EVALUATION_1;
59
$evaluation_2 = \LeadersLinked\Model\RecruitmentSelectionInterview::EVALUATION_2;
60
$evaluation_3 = \LeadersLinked\Model\RecruitmentSelectionInterview::EVALUATION_3;
61
$evaluation_4 = \LeadersLinked\Model\RecruitmentSelectionInterview::EVALUATION_4;
62
 
63
$points_0 = \LeadersLinked\Model\RecruitmentSelectionInterview::POINTS_0;
64
$points_1 = \LeadersLinked\Model\RecruitmentSelectionInterview::POINTS_1;
65
$points_2 = \LeadersLinked\Model\RecruitmentSelectionInterview::POINTS_2;
66
$points_3 = \LeadersLinked\Model\RecruitmentSelectionInterview::POINTS_3;
67
$points_4 = \LeadersLinked\Model\RecruitmentSelectionInterview::POINTS_4;
68
 
69
 
70
 
1709 eleazar 71
$this->headStyle()->captureStart();
72
echo <<<CSS
73
 
74
CSS;
75
$this->headStyle()->captureEnd();
76
 
77
$this->inlineScript()->captureStart();
78
echo <<<JS
79
 
2503 eleazar 80
const classFormGenerator = function() {
81
    this.id = 0,
82
        this.table = '',
83
        this.text = '',
2506 eleazar 84
        this.behaviors = [],
2503 eleazar 85
        this.clear = function() {
2506 eleazar 86
            this.behaviors = [];
2503 eleazar 87
            this.render();
88
        },
89
 
90
        /**
91
         * Add element to section array
92
         */
2506 eleazar 93
        this.addSection = function( text, value) {
2503 eleazar 94
            var d = new Date();
95
            var slug = 'section' + d.getTime();
96
            var position = 0;
2506 eleazar 97
            $.each(this.behaviors, function(index, section) {
2503 eleazar 98
                if (position < section.position) {
99
                    position = section.position;
100
                }
101
            });
102
            position++;
103
            var section = {
2506 eleazar 104
                'slug_behaviors': slug,
2503 eleazar 105
                'text': text,
106
                'value': value,
107
                'position': position,
108
                'questions': [],
109
                'status': 0
110
            }
2506 eleazar 111
            this.behaviors.push(section);
2503 eleazar 112
        },
113
         /**
114
         * Edit element to section array
115
         */
2506 eleazar 116
        this.editSection = function(slug, text, value) {
2503 eleazar 117
            var renderTable = false;
2506 eleazar 118
            for (i = 0; i < this.behaviors.length; i++) {
119
                if (slug == this.behaviors[i].slug_behaviors) {
120
                    this.behaviors[i].text = text;
121
                    this.behaviors[i].value = value;
2503 eleazar 122
                    renderTable = true;
123
                    break;
124
                }
125
            }
126
            if (renderTable) {
127
                this.renderSection(slug);
128
            }
129
        },
130
         /**
131
         * Remove element to section array
132
         */
133
        this.deleteSection = function(slug) {
134
            var renderTable = false;
2506 eleazar 135
            for (i = 0; i < this.behaviors.length; i++) {
136
                if (slug == this.behaviors[i].slug_behaviors) {
137
                    this.behaviors.splice(i, 1);
2503 eleazar 138
                    renderTable = true;
139
                    break;
140
                }
141
            }
142
            if (renderTable) {
143
                $('#panel' + slug).remove();
144
            }
145
        }
146
}
147
 
2501 eleazar 148
    function htmlEntities(str) {
149
        return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
150
    }
2500 eleazar 151
 
1709 eleazar 152
jQuery( document ).ready(function( $ ) {
2504 eleazar 153
    var objFormGenerator = new classFormGenerator();
2506 eleazar 154
    //objFormGenerator.render();
1877 eleazar 155
    $.validator.setDefaults({
2015 eleazar 156
        debug: true,
157
        highlight: function(element) {
158
            $(element).addClass('is-invalid');
159
        },
160
        unhighlight: function(element) {
161
            $(element).removeClass('is-invalid');
162
        },
163
        errorElement: 'span',
164
        errorClass: 'error invalid-feedback',
165
        errorPlacement: function(error, element) {
166
            if(element.parent('.btn-file').length) {
167
                error.insertAfter(element.parent().parent());
168
            } else if(element.parent('.toggle').length) {
169
                error.insertAfter(element.parent().parent());
170
            } else {
171
                error.insertAfter(element.parent());
1709 eleazar 172
            }
2015 eleazar 173
        }
174
    });
1709 eleazar 175
 
176
 
2015 eleazar 177
    $.fn.showFormErrorValidator = function(fieldname, errors) {
178
        var field = $(fieldname);
179
        if(field) {
180
            $(field).addClass('is-invalid');
1709 eleazar 181
 
2015 eleazar 182
            var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');
183
 
184
            if(element.parent('.btn-file').length) {
185
                error.insertAfter(element.parent().parent());
186
            } else if(element.parent('.toggle').length) {
187
                error.insertAfter(element.parent().parent());
188
            } else {
189
                error.insertAfter(element.parent());
1709 eleazar 190
            }
2015 eleazar 191
        }
192
    };
1827 eleazar 193
 
2521 eleazar 194
 
195
 
2015 eleazar 196
    var validator = $('#form-interview').validate({
1877 eleazar 197
        debug: true,
198
        onclick: false,
199
        onkeyup: false,
200
        ignore: [],
201
        rules: {
2522 eleazar 202
            'text': {
1877 eleazar 203
                required: true,
204
                maxlength: 64,
205
            },
206
            'status': {
207
                required: false,
208
            },
2276 eleazar 209
 
1877 eleazar 210
        },
2522 eleazar 211
        content: function(form){
2521 eleazar 212
            return{
213
                $('[data-behavior-textarea]').map(
214
                    function (idx, td) {
215
                        const uuid = $(td).data('behavior-textarea');
216
                        const textarea = $(td).find('textarea');
217
                        const select = $(td).find('select');
218
 
219
                        return {
220
                            uuid: uuid,
221
                            comment: textarea.val(),
222
                            evaluation: select.val(),
223
                        }
224
                    }
225
                ).get()
226
            }
227
        },
1877 eleazar 228
        submitHandler: function(form) {
229
            $.ajax({
230
                'dataType': 'json',
231
                'accept': 'application/json',
232
                'method': 'post',
2245 eleazar 233
                'url': $('#form').attr('action'),
234
                'data': $('#form').serialize()
1877 eleazar 235
            }).done(function(response) {
236
                NProgress.start();
237
                if (response['success']) {
238
                    $.fn.showSuccess(response['data']);
2521 eleazar 239
                    $('#main').show();
1900 eleazar 240
                    $('#row-form').hide();
1877 eleazar 241
                    gridTable.api().ajax.reload(null, false);
242
                } else {
243
                    validator.resetForm();
244
                    if (jQuery.type(response['data']) == 'string') {
245
                        $.fn.showError(response['data']);
246
                    } else {
247
                        $.each(response['data'], function(fieldname, errors) {
2245 eleazar 248
                            $.fn.showFormErrorValidator('#form #' + fieldname, errors);
1877 eleazar 249
                        });
250
                    }
251
                }
252
            }).fail(function(jqXHR, textStatus, errorThrown) {
253
                $.fn.showError(textStatus);
254
            }).always(function() {
255
                NProgress.done();
256
            });
257
            return false;
258
        },
259
        invalidHandler: function(form, validator) {}
260
    });
1709 eleazar 261
 
2015 eleazar 262
    $('body').on('click', 'button.btn-add', function(e) {
263
        e.preventDefault();
264
        NProgress.start();
265
        $.ajax({
266
            'dataType': 'json',
267
            'accept': 'application/json',
268
            'method': 'get',
2194 eleazar 269
            'url': '$routeAdd'.replaceAll('UUID_PLACEHOLDER', $('#candidate_uuid').val()),
2015 eleazar 270
        }).done(function(response) {
271
            if (response['success']) {
2237 eleazar 272
                var data = response.data
2521 eleazar 273
                $('#form').attr('action', '$routeAdd');
274
                $("#main #vacancy_uuid").val('');
275
                $("#main #candidate_uuid").val('');
276
                $("#interview #competencies-job").val(content);
277
                $("#interview #text-option").val('');
278
                $("#interview #behavior-level").val('');
2264 eleazar 279
                $("#competencies-job").html($("#competenciesTemplate").render(data))
2313 eleazar 280
                $("#interview").show()
1877 eleazar 281
            } else {
2015 eleazar 282
                $.fn.showError(response['data']);
1877 eleazar 283
            }
2015 eleazar 284
        }).fail(function(jqXHR, textStatus, errorThrown) {
285
            $.fn.showError(textStatus);
286
        }).always(function() {
287
            NProgress.done();
1877 eleazar 288
        });
2015 eleazar 289
    });
1709 eleazar 290
 
2015 eleazar 291
    $('#form-interview #status').bootstrapToggle({
292
        'on': 'LABEL_ACTIVE',
293
        'off': 'LABEL_INACTIVE',
294
        'width': '160px',
295
        'height': '40px'
296
    });
1709 eleazar 297
 
2015 eleazar 298
 
2265 eleazar 299
 
2015 eleazar 300
    $('body').on('click', 'button.btn-cancel', function(e) {
301
        e.preventDefault();
2521 eleazar 302
        $('#main').show();
2015 eleazar 303
        $('#row-form').hide();
304
        $('#div-listing').show();
305
    });
306
 
307
    $('#form-filter #vacancy_uuid').change(function(e) {
308
        e.preventDefault();
309
        $('#form-filter #candidates_uuid').empty();
310
    })
2118 eleazar 311
 
2015 eleazar 312
    $('#form-filter #candidates_uuid').change(function(e) {
313
        e.preventDefault();
314
    })
2029 eleazar 315
 
316
    $('#vacancy_uuid').on('change', function () {
2042 eleazar 317
        $('#candidate_uuid').html('');
318
 
2029 eleazar 319
        $.ajax({
320
            'dataType': 'json',
321
            'accept': 'application/json',
322
            'method': 'get',
2031 eleazar 323
            'url': "$routeIndex" + "?vacancy_uuid=" + $('#vacancy_uuid').val(),
2038 eleazar 324
        }).done(function (response) {
325
            var data = response.data
326
 
2036 eleazar 327
            data.candidates.forEach(function (candidate) {
2041 eleazar 328
                var option = $('<option />').val(candidate.uuid).text(candidate.first_name);
329
 
330
                $('#candidate_uuid').append(option);
2036 eleazar 331
            });
2052 eleazar 332
 
2244 eleazar 333
            $('#job-description').html($('#job-description-template').render(response.data));
2029 eleazar 334
        })
335
    });
2032 eleazar 336
 
337
    $('#vacancy_uuid').change();
1709 eleazar 338
});
339
JS;
340
$this->inlineScript()->captureEnd();
341
?>
342
 
343
 
344
<!-- Content Header (Page header) -->
2521 eleazar 345
<section class="main-header">
1709 eleazar 346
	<div class="container-fluid">
347
    	<div class="row mb-2">
348
        	<div class="col-sm-12">
349
            	<h1>LABEL_INTERVIEW</h1>
350
			</div>
351
		</div>
352
	</div><!-- /.container-fluid -->
353
</section>
354
 
2521 eleazar 355
<section class="main">
1709 eleazar 356
	<div class="container-fluid">
357
    	<div class="row">
358
        	<div class="col-12">
359
				<div class="card">
2021 eleazar 360
					<div class="card-header">
1709 eleazar 361
                        <div class="row">
362
                            <div class="col-md-6 col-sm-12">
363
                                <div class="form-group">
2021 eleazar 364
                                    <label for="vacancy_uuid">LABEL_VACANCY</label>
2023 eleazar 365
                                    <select id="vacancy_uuid" name="vacancy_uuid" class="form-control">
2021 eleazar 366
                                        <?php foreach($this->vacancies as $vacancy): ?>
2023 eleazar 367
                                            <option value="<?= $vacancy->uuid ?>"><?= $vacancy->name ?></option>
2021 eleazar 368
                                        <?php endforeach; ?>
369
                                    </select>
1709 eleazar 370
                                </div>
371
                            </div>
372
                            <div class="col-md-6 col-sm-12">
373
                                <div class="form-group">
2040 eleazar 374
                                    <label for="candidate_uuid">LABEL_CANDIDATES</label>
2024 eleazar 375
                                    <select id="candidate_uuid" name="candidate_uuid" class="form-control">
376
                                    </select>
1709 eleazar 377
                                </div>
378
                            </div>
379
                            <div
380
                                class="col-md-12 col-sm-12"
381
                            >
382
                            </div>
383
                        </div>
384
					</div>
385
					<div class="card-body">
2052 eleazar 386
                        <div id="job-description"></div>
1709 eleazar 387
                   	</div>
2015 eleazar 388
 
389
                    <div class="card-footer clearfix">
390
                        <div style="float:right;">
391
                            <?php if($allowAdd) : ?>
392
                                <button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
393
                            <?php endif; ?>
1876 eleazar 394
                        </div>
2015 eleazar 395
                    </div>
396
                </div>
1876 eleazar 397
            </div>
2015 eleazar 398
        </div>
399
 	</div>
400
</section>
2052 eleazar 401
 
402
<script id="job-description-template" type="text/x-jsrender">
403
    <div class="card">
404
        <div class="card-body">
405
            <h5 class="card-title">{{:job_description.name}}</h5>
406
            <p class="card-text">{{:vacancy.description}}</p>
2214 eleazar 407
            <p class="card-text">{{:job_description.objectives}}</p>
408
            <p class="card-text">{{:job_description.functions}}</p>
2052 eleazar 409
        </div>
410
    </div>
2061 eleazar 411
</script>
412
 
2314 eleazar 413
<section id="interview" style="display: none;">
2215 eleazar 414
	<div class="container-fluid">
415
    	<div class="row">
416
        	<div class="col-12">
417
				<div class="card">
418
					<div class="card-header">
419
                        <label>interview</label>
420
					</div>
421
					<div class="card-body">
2217 eleazar 422
                        <div id="competencies-job"></div>
2313 eleazar 423
 
424
                        <div class="form-group">
2515 eleazar 425
                              <label for="text-option">LABEL_FINAL_COMMENT</label>
426
                              <!-- ckeditor -->
427
                              <textarea  name="text-option" id="text-option" rows="5" class="form-control"></textarea>
428
                        </div>
429
                        <div>
430
                            <label for="interviewLevel">LABEL_EVALUATION</label>
431
                            <select class="form-control" id="interviewLevel">
432
                            <option>$points_0</option>
433
                            <option>$points_1</option>
434
                            <option>$points_2</option>
435
                            <option>$points_3</option>
436
                            <option>$points_4</option>
437
                        </div>
438
                   </select>
2313 eleazar 439
                   	</div>
2280 eleazar 440
                    <div class="card-footer clearfix">
2508 eleazar 441
                    <button type="submit" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
442
                    <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
443
                    <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
2280 eleazar 444
                    </div>
2278 eleazar 445
                </div>
2215 eleazar 446
            </div>
447
        </div>
448
 	</div>
449
</section>
450
 
2264 eleazar 451
<script id="competenciesTemplate" type="text/x-jsrender">
2508 eleazar 452
<table class="table table-bordered" id="panel-{{:slug_section}}>
2293 eleazar 453
    <thead>
454
        <tr>
2306 eleazar 455
           <th style="width: 50%;">LABEL_ELEMENT</th>
2293 eleazar 456
           <th style="width: 50%;">LABEL_TITLE</th>
457
        </tr>
458
    </thead>
2300 eleazar 459
    <tbody>
460
        {{for job_description.competencies}}
461
            <tr>
462
               <td class="text-left">LABEL_COMPETENCY</td>
2302 eleazar 463
               <td class="text-left">{{:competency_name}}</td>
2300 eleazar 464
            </tr>
2302 eleazar 465
 
466
            {{for behaviors}}
2308 eleazar 467
                <tr>
2302 eleazar 468
                   <td class="text-left">--LABEL_CONDUCT</td>
469
                   <td class="text-left">
2303 eleazar 470
                      {{:description}}
2508 eleazar 471
                   </td>
2507 eleazar 472
                </tr>
473
                <tr>
2520 eleazar 474
                    <td colspan="2" data-behavior-textarea="{{:uuid}}">
2519 eleazar 475
                        <label for="textarea-{{:uuid}}">LABEL_COMMENT</label>
476
 
477
                        <textarea
478
                            id="textarea-{{:uuid}}"
479
                            class="form-control"
480
                        ></textarea>
481
 
482
                        <label for="select-{{:uuid}}">LABEL_EVALUATION</label>
483
 
484
                        <select class="form-control" id="behavior-level-{{:uuid}}">
485
                            <option value="<?= $points_0 ?>"><?= $points_0 ?></option>
486
                            <option value="<?= $points_1 ?>"><?= $points_1 ?></option>
487
                            <option value="<?= $points_2 ?>"><?= $points_2 ?></option>
488
                            <option value="<?= $points_3 ?>"><?= $points_3 ?></option>
489
                            <option value="<?= $points_4 ?>"><?= $points_4 ?></option>
490
                        </select>
491
                    </td>
2506 eleazar 492
                </tr>
493
            {{/for}}
494
 
2300 eleazar 495
        {{/for}}
496
    </tbody>
2293 eleazar 497
</table>
2241 eleazar 498
</script>