Proyectos de Subversion LeadersLinked - Backend

Rev

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