Proyectos de Subversion LeadersLinked - Backend

Rev

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