Proyectos de Subversion LeadersLinked - Backend

Rev

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