Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 2689 | Rev 2744 | 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(),
2694 eleazar 217
                    comment: $('#comment').val()
2523 eleazar 218
                }
1877 eleazar 219
            }).done(function(response) {
220
                NProgress.start();
221
                if (response['success']) {
222
                    $.fn.showSuccess(response['data']);
2521 eleazar 223
                    $('#main').show();
2536 eleazar 224
                    $('#interview').hide();
1877 eleazar 225
                    gridTable.api().ajax.reload(null, false);
226
                } else {
227
                    validator.resetForm();
228
                    if (jQuery.type(response['data']) == 'string') {
229
                        $.fn.showError(response['data']);
230
                    } else {
231
                        $.each(response['data'], function(fieldname, errors) {
2531 eleazar 232
                            $.fn.showFormErrorValidator('#interview #' + fieldname, errors);
1877 eleazar 233
                        });
234
                    }
235
                }
236
            }).fail(function(jqXHR, textStatus, errorThrown) {
237
                $.fn.showError(textStatus);
238
            }).always(function() {
239
                NProgress.done();
240
            });
241
            return false;
242
        },
243
        invalidHandler: function(form, validator) {}
244
    });
1709 eleazar 245
 
2015 eleazar 246
    $('body').on('click', 'button.btn-add', function(e) {
247
        e.preventDefault();
248
        NProgress.start();
249
        $.ajax({
250
            'dataType': 'json',
251
            'accept': 'application/json',
252
            'method': 'get',
2194 eleazar 253
            'url': '$routeAdd'.replaceAll('UUID_PLACEHOLDER', $('#candidate_uuid').val()),
2015 eleazar 254
        }).done(function(response) {
255
            if (response['success']) {
2237 eleazar 256
                var data = response.data
2521 eleazar 257
                $("#interview #text-option").val('');
258
                $("#interview #behavior-level").val('');
2264 eleazar 259
                $("#competencies-job").html($("#competenciesTemplate").render(data))
2313 eleazar 260
                $("#interview").show()
1877 eleazar 261
            } else {
2015 eleazar 262
                $.fn.showError(response['data']);
1877 eleazar 263
            }
2015 eleazar 264
        }).fail(function(jqXHR, textStatus, errorThrown) {
265
            $.fn.showError(textStatus);
266
        }).always(function() {
267
            NProgress.done();
1877 eleazar 268
        });
2015 eleazar 269
    });
1709 eleazar 270
 
2015 eleazar 271
    $('#form-interview #status').bootstrapToggle({
272
        'on': 'LABEL_ACTIVE',
273
        'off': 'LABEL_INACTIVE',
274
        'width': '160px',
275
        'height': '40px'
276
    });
1709 eleazar 277
 
2015 eleazar 278
 
2265 eleazar 279
 
2015 eleazar 280
    $('body').on('click', 'button.btn-cancel', function(e) {
281
        e.preventDefault();
2521 eleazar 282
        $('#main').show();
2015 eleazar 283
        $('#row-form').hide();
284
        $('#div-listing').show();
285
    });
286
 
287
    $('#form-filter #vacancy_uuid').change(function(e) {
288
        e.preventDefault();
2577 eleazar 289
        $('#form-filter #candidate_uuid').empty();
2015 eleazar 290
    })
2118 eleazar 291
 
2577 eleazar 292
    $('#form-filter #candidate_uuid').change(function(e) {
2015 eleazar 293
        e.preventDefault();
294
    })
2525 eleazar 295
     /**
296
     * Clicked cancel new/edit Form
297
     */
298
    $('button.btn-edit-cancel').click(function(e) {
299
        e.preventDefault();
2526 eleazar 300
        $('#interview').hide();
2525 eleazar 301
    });
302
    /**
303
     * Clicked save and continue new Form
304
     */
305
    $('button.btn-form-save-continue').click(function(e) {
306
        e.preventDefault();
307
        $('#interview #form-continue').val('1')
2540 eleazar 308
        $('#form-interview').submit();
2525 eleazar 309
    });
310
    /**
311
     * Clicked save and close new/edit Form
312
     */
313
    $('button.btn-form-save-close').click(function(e) {
314
        e.preventDefault();
315
        $('#interview #form-continue').val('0')
2540 eleazar 316
        $('#form-interview').submit();
2525 eleazar 317
    });
2029 eleazar 318
 
319
    $('#vacancy_uuid').on('change', function () {
2042 eleazar 320
        $('#candidate_uuid').html('');
321
 
2029 eleazar 322
        $.ajax({
323
            'dataType': 'json',
324
            'accept': 'application/json',
325
            'method': 'get',
2031 eleazar 326
            'url': "$routeIndex" + "?vacancy_uuid=" + $('#vacancy_uuid').val(),
2038 eleazar 327
        }).done(function (response) {
328
            var data = response.data
329
 
2036 eleazar 330
            data.candidates.forEach(function (candidate) {
2041 eleazar 331
                var option = $('<option />').val(candidate.uuid).text(candidate.first_name);
332
 
333
                $('#candidate_uuid').append(option);
2036 eleazar 334
            });
2052 eleazar 335
 
2244 eleazar 336
            $('#job-description').html($('#job-description-template').render(response.data));
2029 eleazar 337
        })
338
    });
2032 eleazar 339
 
340
    $('#vacancy_uuid').change();
1709 eleazar 341
});
342
JS;
343
$this->inlineScript()->captureEnd();
344
?>
345
 
346
 
347
<!-- Content Header (Page header) -->
2521 eleazar 348
<section class="main-header">
1709 eleazar 349
	<div class="container-fluid">
350
    	<div class="row mb-2">
351
        	<div class="col-sm-12">
352
            	<h1>LABEL_INTERVIEW</h1>
353
			</div>
354
		</div>
355
	</div><!-- /.container-fluid -->
356
</section>
357
 
2521 eleazar 358
<section class="main">
1709 eleazar 359
	<div class="container-fluid">
360
    	<div class="row">
361
        	<div class="col-12">
2537 eleazar 362
 
363
				<div class="card">
364
					<div class="card-header">
365
                        <div class="row">
366
                            <div class="col-md-6 col-sm-12">
367
                                <div class="form-group">
368
                                    <label for="vacancy_uuid">LABEL_VACANCY</label>
369
                                    <select id="vacancy_uuid" name="vacancy_uuid" class="form-control">
370
                                        <?php foreach($this->vacancies as $vacancy): ?>
371
                                            <option value="<?= $vacancy->uuid ?>"><?= $vacancy->name ?></option>
372
                                        <?php endforeach; ?>
373
                                    </select>
374
                                </div>
1709 eleazar 375
                            </div>
2537 eleazar 376
                            <div class="col-md-6 col-sm-12">
377
                                <div class="form-group">
378
                                    <label for="candidate_uuid">LABEL_CANDIDATES</label>
379
                                    <select id="candidate_uuid" name="candidate_uuid" class="form-control">
380
                                    </select>
381
                                </div>
1709 eleazar 382
                            </div>
2537 eleazar 383
                            <div
384
                                class="col-md-12 col-sm-12"
385
                            >
386
                            </div>
1709 eleazar 387
                        </div>
2537 eleazar 388
					</div>
389
					<div class="card-body">
390
                        <div id="job-description"></div>
391
                   	</div>
392
                    <div class="card-footer clearfix">
393
                        <div style="float:right;">
394
                            <?php if($allowAdd) : ?>
395
                                <button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
396
                            <?php endif; ?>
397
                        </div>
2015 eleazar 398
                    </div>
2537 eleazar 399
                 </div>
1876 eleazar 400
            </div>
2015 eleazar 401
        </div>
402
 	</div>
403
</section>
2052 eleazar 404
 
405
<script id="job-description-template" type="text/x-jsrender">
406
    <div class="card">
407
        <div class="card-body">
408
            <h5 class="card-title">{{:job_description.name}}</h5>
409
            <p class="card-text">{{:vacancy.description}}</p>
2214 eleazar 410
            <p class="card-text">{{:job_description.objectives}}</p>
411
            <p class="card-text">{{:job_description.functions}}</p>
2052 eleazar 412
        </div>
413
    </div>
2061 eleazar 414
</script>
415
 
2314 eleazar 416
<section id="interview" style="display: none;">
2215 eleazar 417
	<div class="container-fluid">
418
    	<div class="row">
419
        	<div class="col-12">
2537 eleazar 420
                <form action="#" name="form-interview" id="form-interview">
421
                    <input type="hidden" name="form-continue" id="form-continue" value="0" />
2689 eleazar 422
			    	<div class="card">
423
                    <?php
424
                         $form->setAttributes([
425
                             'method' => 'post',
426
                             'name' => 'form-add',
427
                             'id' => 'form-add'
428
                         ]);
429
                         $form->prepare();
430
                         echo $this->form()->openTag($form);
431
                         ?>
2537 eleazar 432
			    		<div class="card-header">
433
                            <label>interview</label>
434
			    		</div>
435
			    		<div class="card-body">
436
                            <div id="competencies-job"></div>
2683 eleazar 437
                                <div class="form-group">
438
                                    <?php
439
                                    $element = $form->get('comment');
440
                                    $element->setOptions(['label' => 'LABEL_COMMENT']);
441
                                    $element->setAttributes(['class' => 'form-control']);
442
                                    echo $this->formLabel($element);
443
                                    echo $this->formText($element);
444
                                    ?>
445
                                </div>
446
                                <div class="form-group">
447
                                    <?php
448
                                    $element = $form->get('points');
449
                                    $element->setAttributes(['class' => 'form-control']);
450
                                    $element->setOptions(['label' => 'LABEL_EVALUATION']);
451
                                    echo $this->formLabel($element);
452
                                    echo $this->formSelect($element);
453
                                    ?>
454
                                </div>
2537 eleazar 455
                            </div>
456
                       	</div>
457
                        <div class="card-footer clearfix">
458
                        <button type="submit" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
459
                        <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
460
                        <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
2515 eleazar 461
                        </div>
2280 eleazar 462
                    </div>
2537 eleazar 463
                </form>
2215 eleazar 464
            </div>
465
        </div>
466
 	</div>
467
</section>
468
 
2264 eleazar 469
<script id="competenciesTemplate" type="text/x-jsrender">
2508 eleazar 470
<table class="table table-bordered" id="panel-{{:slug_section}}>
2293 eleazar 471
    <thead>
472
        <tr>
2306 eleazar 473
           <th style="width: 50%;">LABEL_ELEMENT</th>
2293 eleazar 474
           <th style="width: 50%;">LABEL_TITLE</th>
475
        </tr>
476
    </thead>
2300 eleazar 477
    <tbody>
478
        {{for job_description.competencies}}
479
            <tr>
480
               <td class="text-left">LABEL_COMPETENCY</td>
2302 eleazar 481
               <td class="text-left">{{:competency_name}}</td>
2300 eleazar 482
            </tr>
2302 eleazar 483
 
484
            {{for behaviors}}
2308 eleazar 485
                <tr>
2302 eleazar 486
                   <td class="text-left">--LABEL_CONDUCT</td>
487
                   <td class="text-left">
2303 eleazar 488
                      {{:description}}
2508 eleazar 489
                   </td>
2507 eleazar 490
                </tr>
491
                <tr>
2520 eleazar 492
                    <td colspan="2" data-behavior-textarea="{{:uuid}}">
2519 eleazar 493
                        <label for="textarea-{{:uuid}}">LABEL_COMMENT</label>
494
 
495
                        <textarea
496
                            id="textarea-{{:uuid}}"
497
                            class="form-control"
498
                        ></textarea>
499
 
500
                        <label for="select-{{:uuid}}">LABEL_EVALUATION</label>
501
 
502
                        <select class="form-control" id="behavior-level-{{:uuid}}">
503
                            <option value="<?= $points_0 ?>"><?= $points_0 ?></option>
504
                            <option value="<?= $points_1 ?>"><?= $points_1 ?></option>
505
                            <option value="<?= $points_2 ?>"><?= $points_2 ?></option>
506
                            <option value="<?= $points_3 ?>"><?= $points_3 ?></option>
507
                            <option value="<?= $points_4 ?>"><?= $points_4 ?></option>
508
                        </select>
509
                    </td>
2506 eleazar 510
                </tr>
511
            {{/for}}
512
 
2300 eleazar 513
        {{/for}}
514
    </tbody>
2293 eleazar 515
</table>
2241 eleazar 516
</script>