Proyectos de Subversion LeadersLinked - Backend

Rev

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