Proyectos de Subversion LeadersLinked - Backend

Rev

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