Proyectos de Subversion LeadersLinked - Backend

Rev

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