Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 2508 | Rev 2510 | 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']);
2508 eleazar 206
                    var slug = $('#interview #section-slug').val();
207
                    if (slug) {
208
                        objFormGenerator.editSection(
209
                            $('#interview #section-slug').val(),
210
                            $('#interview #section-text').val(),
211
                            $('#interview #section-value').val()
212
                        );
213
                    } else {
214
                        objFormGenerator.addSection(
215
                            $('#interview #section-text').val(),
216
                            $('#interview #section-value').val()
217
                        );
218
                    }
1900 eleazar 219
                    $('#content').show();
220
                    $('#row-form').hide();
1877 eleazar 221
                    gridTable.api().ajax.reload(null, false);
222
                } else {
223
                    validator.resetForm();
224
                    if (jQuery.type(response['data']) == 'string') {
225
                        $.fn.showError(response['data']);
226
                    } else {
227
                        $.each(response['data'], function(fieldname, errors) {
2245 eleazar 228
                            $.fn.showFormErrorValidator('#form #' + fieldname, errors);
1877 eleazar 229
                        });
230
                    }
231
                }
232
            }).fail(function(jqXHR, textStatus, errorThrown) {
233
                $.fn.showError(textStatus);
234
            }).always(function() {
235
                NProgress.done();
236
            });
237
            return false;
238
        },
239
        invalidHandler: function(form, validator) {}
240
    });
1709 eleazar 241
 
2015 eleazar 242
    $('body').on('click', 'button.btn-add', function(e) {
243
        e.preventDefault();
244
        NProgress.start();
245
        $.ajax({
246
            'dataType': 'json',
247
            'accept': 'application/json',
248
            'method': 'get',
2194 eleazar 249
            'url': '$routeAdd'.replaceAll('UUID_PLACEHOLDER', $('#candidate_uuid').val()),
2015 eleazar 250
        }).done(function(response) {
251
            if (response['success']) {
2237 eleazar 252
                var data = response.data
2264 eleazar 253
                $("#competencies-job").html($("#competenciesTemplate").render(data))
2313 eleazar 254
                $("#interview").show()
1877 eleazar 255
            } else {
2015 eleazar 256
                $.fn.showError(response['data']);
1877 eleazar 257
            }
2015 eleazar 258
        }).fail(function(jqXHR, textStatus, errorThrown) {
259
            $.fn.showError(textStatus);
260
        }).always(function() {
261
            NProgress.done();
1877 eleazar 262
        });
2015 eleazar 263
    });
1709 eleazar 264
 
2015 eleazar 265
    $('#form-interview #status').bootstrapToggle({
266
        'on': 'LABEL_ACTIVE',
267
        'off': 'LABEL_INACTIVE',
268
        'width': '160px',
269
        'height': '40px'
270
    });
1709 eleazar 271
 
2015 eleazar 272
 
2265 eleazar 273
 
2015 eleazar 274
    $('body').on('click', 'button.btn-cancel', function(e) {
275
        e.preventDefault();
276
        $('#content').show();
277
        $('#row-form').hide();
278
        $('#div-listing').show();
279
    });
280
 
281
    $('#form-filter #vacancy_uuid').change(function(e) {
282
        e.preventDefault();
283
        $('#form-filter #candidates_uuid').empty();
284
    })
2118 eleazar 285
 
2015 eleazar 286
    $('#form-filter #candidates_uuid').change(function(e) {
287
        e.preventDefault();
288
    })
2029 eleazar 289
 
2509 eleazar 290
    $('body').on('click', 'button.btn-edit-behavior', function(e) {
291
        e.preventDefault();
292
        var competency_id = $(this).data('competency');
293
        var behavior_id = $(this).data('behavior');
294
        competencies_selected.map((item) => {
295
            if (item.competency_id == competency_id) {
296
                item.behaviors.map((b) => {
297
                    if (b.behavior_id == behavior_id) {
298
                        $('#form-behavior #behavior-id').val(b.behavior_id);
299
                        $('#form-behavior #behavior-competency').val(b.competency_id);
300
                        $('#form-behavior #behavior-level').val(b.level);
301
                        $('#modal-behavior h4[class="modal-title"]').html('LABEL_EDIT LABEL_CONDUCT');
302
                        $('#modal-behavior').modal('show');
303
                        return;
304
                    }
305
                });
306
            }
307
        });
308
    });
309
 
310
    $('button.btn-behavior-submit').click(function(e) {
311
        if ($("#behavior-description").val() == "") {
312
            $.fn.showError('ERROR_ENTER_DESCRIPTION');
313
            return;
314
        } else {
315
            editBehavior($("#behavior-competency").val(), $("#behavior-id").val(), $("#behavior-level").val())
316
            $('#modal-behavior').modal('hide');
317
            return;
318
        }
319
    });
320
 
2029 eleazar 321
    $('#vacancy_uuid').on('change', function () {
2042 eleazar 322
        $('#candidate_uuid').html('');
323
 
2029 eleazar 324
        $.ajax({
325
            'dataType': 'json',
326
            'accept': 'application/json',
327
            'method': 'get',
2031 eleazar 328
            'url': "$routeIndex" + "?vacancy_uuid=" + $('#vacancy_uuid').val(),
2038 eleazar 329
        }).done(function (response) {
330
            var data = response.data
331
 
2036 eleazar 332
            data.candidates.forEach(function (candidate) {
2041 eleazar 333
                var option = $('<option />').val(candidate.uuid).text(candidate.first_name);
334
 
335
                $('#candidate_uuid').append(option);
2036 eleazar 336
            });
2052 eleazar 337
 
2244 eleazar 338
            $('#job-description').html($('#job-description-template').render(response.data));
2029 eleazar 339
        })
340
    });
2032 eleazar 341
 
342
    $('#vacancy_uuid').change();
1709 eleazar 343
});
344
JS;
345
$this->inlineScript()->captureEnd();
346
?>
347
 
348
 
349
<!-- Content Header (Page header) -->
350
<section class="content-header">
351
	<div class="container-fluid">
352
    	<div class="row mb-2">
353
        	<div class="col-sm-12">
354
            	<h1>LABEL_INTERVIEW</h1>
355
			</div>
356
		</div>
357
	</div><!-- /.container-fluid -->
358
</section>
359
 
360
<section class="content">
361
	<div class="container-fluid">
362
    	<div class="row">
363
        	<div class="col-12">
364
				<div class="card">
2021 eleazar 365
					<div class="card-header">
1709 eleazar 366
                        <div class="row">
367
                            <div class="col-md-6 col-sm-12">
368
                                <div class="form-group">
2021 eleazar 369
                                    <label for="vacancy_uuid">LABEL_VACANCY</label>
2023 eleazar 370
                                    <select id="vacancy_uuid" name="vacancy_uuid" class="form-control">
2021 eleazar 371
                                        <?php foreach($this->vacancies as $vacancy): ?>
2023 eleazar 372
                                            <option value="<?= $vacancy->uuid ?>"><?= $vacancy->name ?></option>
2021 eleazar 373
                                        <?php endforeach; ?>
374
                                    </select>
1709 eleazar 375
                                </div>
376
                            </div>
377
                            <div class="col-md-6 col-sm-12">
378
                                <div class="form-group">
2040 eleazar 379
                                    <label for="candidate_uuid">LABEL_CANDIDATES</label>
2024 eleazar 380
                                    <select id="candidate_uuid" name="candidate_uuid" class="form-control">
381
                                    </select>
1709 eleazar 382
                                </div>
383
                            </div>
384
                            <div
385
                                class="col-md-12 col-sm-12"
386
                            >
387
                            </div>
388
                        </div>
389
					</div>
390
					<div class="card-body">
2052 eleazar 391
                        <div id="job-description"></div>
1709 eleazar 392
                   	</div>
2015 eleazar 393
 
394
                    <div class="card-footer clearfix">
395
                        <div style="float:right;">
396
                            <?php if($allowAdd) : ?>
397
                                <button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
398
                            <?php endif; ?>
1876 eleazar 399
                        </div>
2015 eleazar 400
                    </div>
401
                </div>
1876 eleazar 402
            </div>
2015 eleazar 403
        </div>
404
 	</div>
405
</section>
2052 eleazar 406
 
407
<script id="job-description-template" type="text/x-jsrender">
408
    <div class="card">
409
        <div class="card-body">
410
            <h5 class="card-title">{{:job_description.name}}</h5>
411
            <p class="card-text">{{:vacancy.description}}</p>
2214 eleazar 412
            <p class="card-text">{{:job_description.objectives}}</p>
413
            <p class="card-text">{{:job_description.functions}}</p>
2052 eleazar 414
        </div>
415
    </div>
2061 eleazar 416
</script>
417
 
2314 eleazar 418
<section id="interview" style="display: none;">
2215 eleazar 419
	<div class="container-fluid">
420
    	<div class="row">
421
        	<div class="col-12">
422
				<div class="card">
423
					<div class="card-header">
424
                        <label>interview</label>
425
					</div>
426
					<div class="card-body">
2217 eleazar 427
                        <div id="competencies-job"></div>
2313 eleazar 428
 
429
                        <div class="form-group">
430
                          <label for="text-option">LABEL_FINAL_COMMENT</label>
431
                          <!-- ckeditor -->
2277 eleazar 432
                          <textarea  name="text-option" id="text-option" rows="5" class="form-control"></textarea>
433
                    </div>
2313 eleazar 434
                   	</div>
2280 eleazar 435
                    <div class="card-footer clearfix">
2508 eleazar 436
                    <button type="submit" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
437
                    <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
438
                    <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
2280 eleazar 439
                    </div>
2278 eleazar 440
                </div>
2215 eleazar 441
            </div>
442
        </div>
443
 	</div>
444
</section>
445
 
2509 eleazar 446
<!--start modal behavior-->
447
<div  id="modal-behavior" class="modal" tabindex="-1" role="dialog">
448
   <div class="modal-dialog modal-lg" role="document">
449
      <form action="#" name="form-behavior" id="form-behavior">
450
         <input type="hidden" name="behavior-id" id="behavior-id" value="" />
451
         <input type="hidden" name="behavior-competency" id="behavior-competency" value="" />
452
         <div class="modal-content">
453
            <div class="modal-header">
454
               <h4 class="modal-title">LABEL_EDIT LABEL_LEVEL</h4>
455
               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
456
               <span aria-hidden="true">&times;</span>
457
               </button>
458
            </div>
459
            <div class="modal-body">
460
               <div class="form-group">
461
                  <label for="behavior-value">LABEL_LEVEL</label>
462
                  <select class="form-control" id="behavior-level" name="behavior-level">
463
                     <option value="0">LABEL_NA</option>
464
                     <option value="1">LABEL_LEVEL_ONE</option>
465
                     <option value="2">LABEL_LEVEL_TWO</option>
466
                     <option value="3">LABEL_LEVEL_THREE</option>
467
                     <option value="4">LABEL_LEVEL_FOUR</option>
468
                  </select>
469
               </div>
470
            </div>
471
            <div class="modal-footer">
472
               <button type="button" class="btn btn-primary btn-behavior-submit">LABEL_SAVE</button>
473
               <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
474
            </div>
475
         </div>
476
      </form>
477
   </div>
478
</div>
479
<!---end modal behavior --->
480
 
2264 eleazar 481
<script id="competenciesTemplate" type="text/x-jsrender">
2508 eleazar 482
<table class="table table-bordered" id="panel-{{:slug_section}}>
2293 eleazar 483
    <thead>
484
        <tr>
2306 eleazar 485
           <th style="width: 50%;">LABEL_ELEMENT</th>
2293 eleazar 486
           <th style="width: 50%;">LABEL_TITLE</th>
487
        </tr>
488
    </thead>
2300 eleazar 489
    <tbody>
490
        {{for job_description.competencies}}
491
            <tr>
492
               <td class="text-left">LABEL_COMPETENCY</td>
2302 eleazar 493
               <td class="text-left">{{:competency_name}}</td>
2300 eleazar 494
            </tr>
2302 eleazar 495
 
496
            {{for behaviors}}
2308 eleazar 497
                <tr>
2302 eleazar 498
                   <td class="text-left">--LABEL_CONDUCT</td>
499
                   <td class="text-left">
2303 eleazar 500
                      {{:description}}
2508 eleazar 501
                   </td>
502
                   <td>
503
                        {{if level == '0'}} LABEL_NA {{/if}}
504
                        {{if level == '1' }} LABEL_LEVEL_ONE {{/if}}
505
                        {{if level == '2' }} LABEL_LEVEL_TWO {{/if}}
506
                        {{if level == '3' }} LABEL_LEVEL_THREE {{/if}}
507
                        {{if level == '4' }} LABEL_LEVEL_FOUR {{/if}}
508
                    </td>
509
                    <td>
510
                        <button type="button"  class="btn btn-default btn-edit-behavior" data-competency="{{:competency_id}}" data-behavior="{{:behavior_id}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_LEVEL"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_LEVEL</button>
511
                    </td>
2507 eleazar 512
                </tr>
513
                <tr>
514
                <td colspan="2">
2312 eleazar 515
                    <label for="textarea-{{:competency_uuid}}">LABEL_COMMENT</label>
516
                    <textarea
517
                        id="textarea-{{:competency_uuid}}"
518
                        class="form-control"
519
                    ></textarea>
2507 eleazar 520
                </td>
2506 eleazar 521
                </tr>
522
            {{/for}}
523
 
2300 eleazar 524
        {{/for}}
525
    </tbody>
2293 eleazar 526
</table>
2241 eleazar 527
</script>