Proyectos de Subversion LeadersLinked - Backend

Rev

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