Proyectos de Subversion LeadersLinked - Backend

Rev

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