Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 1384 | Rev 1389 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1384 efrain 1
<?php
2
$acl = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser = $this->currentUserHelper();
4
 
5
$roleName = $currentUser->getUserTypeId();
6
 
7
$routeAdd = $this->url('recruitment-and-selection/forms/add');
8
$routeDatatable = $this->url('recruitment-and-selection/forms');
9
$routeDashboard = $this->url('dashboard');
10
 
11
$allowAdd = $acl->isAllowed($roleName, 'recruitment-and-selection/forms/add') ? 1 : 0;
12
$allowEdit = $acl->isAllowed($roleName, 'recruitment-and-selection/forms/edit') ? 1 : 0;
13
$allowDelete = $acl->isAllowed($roleName, 'recruitment-and-selection/forms/delete') ? 1 : 0;
14
 
15
 
16
$this->inlineScript()->appendFile('https://maps.googleapis.com/maps/api/js?key=' . $google_map_key . '&libraries=places');
17
 
18
 
19
$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
20
 
21
 
22
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
23
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
24
 
25
 
26
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
27
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
28
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
29
 
30
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
31
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
32
 
33
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
34
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
35
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
36
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
37
 
38
 
39
$this->headLink()->appendStylesheet($this->basePath('plugins/select2/css/select2.min.css'));
40
$this->headLink()->appendStylesheet($this->basePath('plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css'));
41
 
42
$this->inlineScript()->appendFile($this->basePath('plugins/select2/js/select2.full.min.js'));
43
 
44
$this->inlineScript()->appendFile($this->basePath('plugins/moment/moment-with-locales.min.js'));
45
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css'));
46
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'));
47
 
48
 
49
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
50
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
51
 
52
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
53
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
54
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-input-number/input-number-format.jquery.js'));
55
 
56
// bootbox Alert //
57
$this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));
58
 
59
// JsRender //
60
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.min.js'));
61
 
62
 
63
// Page Styles
64
$this->headLink()->appendStylesheet($this->basePath('css/pages/self-evaluation.css'));
65
 
66
 
1388 eleazar 67
$status_active = \LeadersLinked\Model\RecruitmentSelectionVacancy::STATUS_ACTIVE;
68
$status_inactive = \LeadersLinked\Model\RecruitmentSelectionVacancy::STATUS_INACTIVE;
1384 efrain 69
 
70
$this->inlineScript()->captureStart();
71
echo <<<JS
72
jQuery(document).ready(function($) {
73
    var allowEdit = $allowEdit;
74
    var allowDelete = $allowDelete;
75
    var sections = [];
76
    var competencies_type = [];
77
    /**
78
     * Get rows and set data table
79
     */
80
    var tableForm = $('#gridTable').dataTable({
81
        'processing': true,
82
        'serverSide': true,
83
        'searching': true,
84
        'order': [
85
            [0, 'asc']
86
        ],
87
        'ordering': true,
88
        'ordenable': true,
89
        'responsive': true,
90
        'select': false,
91
        'paging': true,
92
        'pagingType': 'simple_numbers',
93
        'ajax': {
94
            'url': '$routeDatatable',
95
            'type': 'get',
96
            'beforeSend': function(request) {
97
                NProgress.start();
98
            },
99
            'dataFilter': function(response) {
100
                var response = jQuery.parseJSON(response);
101
                var json = {};
102
                json.recordsTotal = 0;
103
                json.recordsFiltered = 0;
104
                json.data = [];
105
                if (response.success) {
106
                    json.recordsTotal = response.data.total;
107
                    json.recordsFiltered = response.data.total;
108
                    json.data = response.data.items;
109
                } else {
110
                    $.fn.showError(response.data)
111
                }
112
                return JSON.stringify(json);
113
            }
114
        },
115
        'language': {
116
            'sProcessing': 'LABEL_DATATABLE_SPROCESSING',
117
            'sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU',
118
            'sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS',
119
            'sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE',
120
            'sInfo': 'LABEL_DATATABLE_SINFO',
121
            'sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY',
122
            'sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED',
123
            'sInfoPostFix': '',
124
            'sSearch': 'LABEL_DATATABLE_SSEARCH',
125
            'sUrl': '',
126
            'sInfoThousands': ',',
127
            'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
128
            'oPaginate': {
129
                'sFirst': 'LABEL_DATATABLE_SFIRST',
130
                'sLast': 'LABEL_DATATABLE_SLAST',
131
                'sNext': 'LABEL_DATATABLE_SNEXT',
132
                'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
133
            },
134
            'oAria': {
135
                'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING',
136
                'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
137
            },
138
        },
139
        'drawCallback': function(settings) {
140
            NProgress.done();
141
            $('button.btn-delete').confirmation({
142
                rootSelector: 'button.btn-delete',
143
                title: 'LABEL_ARE_YOU_SURE',
144
                singleton: true,
145
                btnOkLabel: 'LABEL_YES',
146
                btnCancelLabel: 'LABEL_NO',
147
                onConfirm: function(value) {
148
                    action = $(this).data('href');
149
                    NProgress.start();
150
                    $.ajax({
151
                        'dataType': 'json',
152
                        'accept': 'application/json',
153
                        'method': 'post',
154
                        'url': action,
155
                    }).done(function(response) {
156
                        if (response['success']) {
157
                            $.fn.showSuccess(response['data']);
158
                            tableForm.fnDraw();
159
                        } else {
160
                            $.fn.showError(response['data']);
161
                        }
162
                    }).fail(function(jqXHR, textStatus, errorThrown) {
163
                        $.fn.showError(textStatus);
164
                    }).always(function() {
165
                        NProgress.done();
166
                    });
167
                },
168
            });
169
        },
170
        'aoColumns': [{
171
                'mDataProp': 'name'
172
            },
173
            {
174
                'mDataProp': 'job_description'
175
            },
176
            {
177
                'mDataProp': 'status'
178
            },
179
            {
180
                'mDataProp': 'actions'
181
            },
182
        ],
183
        'columnDefs': [{
184
                'targets': 0,
185
                'className': 'text-vertical-middle',
186
            },
187
            {
188
                'targets': 1,
189
                'className': 'text-vertical-middle',
190
            },
191
            {
192
                'targets': -2,
193
                'orderable': false,
194
                'className': 'text-center',
195
                'render': function(data, type, row) {
196
                    checked = data == 'a' ? ' checked="checked" ' : '';
197
                    return '<div class="checkbox checkbox-success">' +
198
                        '<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +
199
                        '<label ></label></div>';
200
                }
201
            },
202
            {
203
                'targets': -1,
204
                'orderable': false,
205
                'render': function(data, type, row) {
206
                    s = '';
207
                    if (allowEdit) {
208
                        s = s + '<button class="btn btn-primary btn-edit-form" data-href="' + data['link_edit'] + '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pencil"></i> LABEL_EDIT </button>&nbsp;';
209
                    }
210
                    if (allowDelete) {
211
                        s = s + '<button class="btn btn-danger btn-delete" data-href="' + data['link_delete'] + '" data-toggle="tooltip" title="LABEL_DELETE"><i class="fa fa-trash"></i> LABEL_DELETE </button>&nbsp;';
212
                    }
213
                    if (allowReport) {
214
                        s = s + '<a class="btn btn-default btn-pdf" href="' + data['link_report'] + '" target="_blank" data-toggle="tooltip" title="LABEL_PDF"><i class="fa fa-file-o"></i> LABEL_PDF </button>&nbsp;';
215
                    }
216
                    return s;
217
                }
218
            }
219
        ],
220
    });
221
 
222
 
223
 
224
    /**
225
     * Clicked on edit form
226
     */
227
    $('body').on('click', 'button.btn-edit-form', function(e) {
228
        e.preventDefault();
229
        renderCompetenciesData([]);
230
        form_id = $(this).data('id')
231
        var action = $(this).data('href');
232
        $.ajax({
233
            'dataType': 'json',
234
            'accept': 'application/json',
235
            'method': 'get',
236
            'url': action,
237
        }).done(function(response) {
238
            if (response['success']) {
239
                $("#rows").html('');
240
                sections = [];
241
                $('#form-main').attr('action', action);
242
                $('#form-main #form-name').val(response['data']['name']);
243
                $('#form-main #form-location').val(response['data']['location']);
244
                $('#form-main #job_description_id').val(response['data']['job_description_id']).trigger('change');
245
                $('#form-main #job_category_id').val(response['data']['job_category_id']).trigger('change');
246
                $('#form-main #industry_id').val(response['data']['industry_id']).trigger('change');
247
                $('#form-main #form-status').val(response['data']['status']);
248
                CKEDITOR.instances['form-description'].setData(response['data']['description']);
249
 
250
                sections = response['data']['content'] || [];
251
                renderData(sections);
252
                $('#row-lists').hide();
253
                $('#row-form').show();
254
            } else {
255
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
256
            }
257
        }).fail(function(jqXHR, textStatus, errorThrown) {
258
            $.fn.showError(textStatus);
259
        });
260
    });
261
    /**
262
     * Clicked add new section
263
     */
264
    $('#btn-add-section').click(function(e) {
265
        $('#form-section #id-section').val('');
266
        $('#form-section #title-section').val('');
267
        $('#form-section #text-section').val('');
268
        $('#form-section #type-section').val($('#form-section #type-section option:first').val());
269
        $('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
270
        $('#modal-section').modal('show');
271
        return;
272
    });
273
    /**
274
     * Clicked edit section
275
     */
276
    /**
277
     * Clicked save section
278
     */
279
    $('#btn-save-section').click(function(e) {
280
        if ($('#title-section').val() == '') {
281
            $.fn.showError('ERROR_ENTER_TITLE');
282
            return;
283
        } else {
284
            $('#id-section').val() == "" ?
285
                addSection($('#title-section').val(), $('#text-section').val(), $('#type-section').val()) :
286
                editSection($('#id-section').val(), $('#title-section').val(), $('#text-section').val(), $('#type-section').val())
287
            $('#modal-section').modal('hide');
288
            return;
289
        }
290
    });
291
    /**
292
     * Clicked remove section
293
     */
294
    $('body').on('click', 'button.btn-delete-section', function(e) {
295
        var id_section = $(this).data('section');
296
        bootbox.confirm({
297
            title: "LABEL_DELETE LABEL_SECTION",
298
            message: "LABEL_QUESTION_DELETE",
299
            buttons: {
300
                cancel: {
301
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
302
                },
303
                confirm: {
304
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
305
                }
306
            },
307
            callback: function(result) {
308
                if (result) {
309
                    removeSection(id_section);
310
                }
311
            }
312
        });
313
    });
314
    $('body').on('click', 'button.btn-edit-section', function(e) {
315
        var id = $(this).data('section');
316
        sections.map((item) => {
317
            if (item.id_section == id) {
318
                $('#form-section #id-section').val(item.id_section);
319
                $('#form-section #title-section').val(item.title);
320
                $('#form-section #text-section').val(item.text);
321
                $('#form-section #type-section').val(item.type);
322
                $('#modal-section').modal('show');
323
                return;
324
            }
325
        });
326
    });
327
    /**
328
     * Clicked remove option
329
     */
330
    $('body').on('click', 'button.btn-delete-option', function(e) {
331
        var id_section = $(this).data('section');
332
        var id_option = $(this).data('option');
333
        bootbox.confirm({
334
            title: "LABEL_DELETE LABEL_OPTION",
335
            message: "LABEL_QUESTION_DELETE",
336
            buttons: {
337
                cancel: {
338
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
339
                },
340
                confirm: {
341
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
342
                }
343
            },
344
            callback: function(result) {
345
                if (result) {
346
                    removeOption(id_section, id_option);
347
                    return;
348
                }
349
            }
350
        });
351
    });
352
    /**
353
     * Clicked add new Option
354
     */
355
    $('body').on('click', 'button.btn-add-option', function(e) {
356
        var id = $(this).data('section');
357
        $('#section-option').val(id);
358
        $('#text-option').val('');
359
        $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
360
        $('#modal-option').modal('show');
361
        return;
362
    });
363
    /**
364
     * Clicked add new Option
365
     */
366
    $('#btn-save-option').click(function(e) {
367
        if ($('#text-option').val() == '') {
368
            $.fn.showError('ERROR_ENTER_TEXT');
369
            return;
370
        } else {
371
            $('#id-option').val() == "" ?
372
                addOption($('#section-option').val(), $('#text-option').val()) :
373
                editOption($('#section-option').val(), $('#id-option').val(), $('#text-option').val())
374
        }
375
        $('#modal-option').modal('hide');
376
        return;
377
    });
378
    /**
379
     * Clicked edit Option
380
     */
381
    $('body').on('click', 'button.btn-edit-option', function(e) {
382
        var id_section = $(this).data('section');
383
        var id_option = $(this).data('option');
384
        sections.map((item) => {
385
            if (item.id_section == id_section) {
386
                item.options.map((opt) => {
387
                    if (opt.id_option == id_option) {
388
                        $('#id-option').val(opt.id_option);
389
                        $('#section-option').val(opt.id_section);
390
                        $("#text-option").val(opt.title);
391
                        $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
392
                        $('#modal-option').modal('show');
393
                        return;
394
                    }
395
                });
396
            }
397
        });
398
    });
399
    /**
400
     * Clicked new Form
401
     */
402
    $('button.btn-add-form').click(function(e) {
403
        $("#rows").html('');
404
        sections = [];
405
        $('#form-main').attr('action', '$routeAdd');
406
        $('#form-main #form-name').val('');
407
        $('#form-main #form-location').val('');
408
        $('#form-main #job_description_id').val('').trigger('change');
409
        $('#form-main #job_category_id').val('').trigger('change');
410
        $('#form-main #industry_id').val('').trigger('change');
411
        $('#form-main #form-status').val('$status_active');
412
        CKEDITOR.instances['form-description'].setData('');
413
        renderCompetenciesData([]);
414
        $('#row-lists').hide();
415
        $('#row-form').show();
416
        $('#form-main #form-name').focus();
417
        return;
418
    });
419
 
420
 
421
    $.validator.addMethod('checkLocation', function (value, element, param) {
422
        var otherElement = $(param);
423
 
424
        return $.trim(otherElement.val()).length > 0;
425
    }, 'ERROR_PLACED_AUTOCOMPLETE_DOES_NOT_CONTAIN_GEOMETRY');
426
 
427
    var autocompleteLocation = new google.maps.places.Autocomplete(
428
        (document.getElementById('location_search')),
429
        {types: ['(cities)']}
430
    );
431
 
432
    /**
433
     * Clicked cancel new/edit Form
434
     */
435
    $('button.btn-edit-cancel').click(function(e) {
436
        $('#row-form').hide();
437
        $('#row-lists').show();
438
        return;
439
    });
440
    /**
441
     * Clicked save and continue new Form
442
     */
443
    $('button.btn-form-save-continue').click(function(e) {
444
        for (var instanceName in CKEDITOR.instances) {
445
            CKEDITOR.instances[instanceName].updateElement();
446
        }
447
        saveData(1);
448
    });
449
    /**
450
     * Clicked save and close new/edit Form
451
     */
452
    $('button.btn-form-save-close').click(function(e) {
453
        for (var instanceName in CKEDITOR.instances) {
454
            CKEDITOR.instances[instanceName].updateElement();
455
        }
456
        saveData(0);
457
    });
458
    /**
459
     * Save Form Data
460
     */
461
    const saveData = (action) => {
462
        if ($('#form-name').val() == '') {
463
            $.fn.showError('ERROR_ENTER_NAME');
464
        } else if ($('#form-description').val() == '') {
465
            $.fn.showError('ERROR_ENTER_DESCRIPTION');
466
        } else if ($('#form-category').val() == '') {
467
            $.fn.showError('ERROR_ENTER_CATEGORY');
468
        } else if ($('#form-industry').val() == '') {
469
            $.fn.showError('ERROR_ENTER_INDUSTRY');
470
        } else if ($('#form-text').val() == '') {
471
            $.fn.showError('ERROR_ENTER_TEXT');
472
        } else if ($('#form-status').val() == '') {
473
            $.fn.showError('ERROR_SELECT_STATUS');
474
        } else if ($('#job_description_id').val() == '') {
475
            $.fn.showError('ERROR_SELECT_JOB_DESCRIPTION');
476
        } else if (sections.length == 0) {
477
            $.fn.showError('ERROR_NOT_SECTIONS');
478
        } else {
479
            $.ajax({
480
                'dataType': 'json',
481
                'method': 'post',
482
                'url': $('#form-main').attr('action'),
483
                'data': {
484
                    'name': $('#form-main #form-name').val(),
485
                    'job_description_id': $('#form-main #job_description_id').val(),
486
                    'location' :$('#form-main #form-location').val(),
487
                    'job_category_id' :$('#form-main #job_category_id').val(),
488
                    'industry_id' :$('#form-main #industry_id').val(),
489
                    'status': $('#form-main #form-status').val(),
490
                    'description': $('#form-main #form-description').val(),
491
                    'content': JSON.stringify(sections)
492
                },
493
            }).done(function(response) {
494
                if (response['success']) {
495
                    $.fn.showSuccess(response['data']);
496
                    if (action == 1) {
497
                        $('#form-main').attr('action', response['action_edit']);
498
                    } else {
499
                        $('#row-form').hide();
500
                        $('#row-lists').show();
501
                        /*---------- Reset Form -------- */
502
                        $('#form-main')[0].reset();
503
                        /*--------Reset Sections ----------*/
504
                        sections = [];
505
                        tableForm.fnDraw();
506
                    }
507
                    return;
508
                } else {
509
                    $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
510
                    return;
511
                }
512
            });
513
        }
514
    }
515
    /**
516
     * Remove Html Tags
517
     */
518
    const removeTags = (str) => str.toString().replace(/(<([^>]+)>)/ig, '')
519
    /**
520
     * Render Sections data
521
     */
522
    const renderData = (data) => {
523
        $("#rows").html($("#sectionTemplate").render(data));
524
    }
525
    /**
526
     * Add Section to array
527
     */
528
    const addSection = (title, text, type) => {
529
        sections.push({
530
            'id_section': new Date().getTime(),
531
            'title': title,
532
            'type': type,
533
            'text': text,
534
            'answer': '',
535
            'options': []
536
        });
537
        return renderData(sections);
538
    }
539
    /**
540
     * Edit item behavior
541
     */
542
    const editSection = (id, title, text, type) => {
543
        sections.map((item) => {
544
            if (item.id_section == id) {
545
                item.title = title;
546
                item.type = type;
547
                item.text = text;
548
            }
549
        });
550
        return renderData(sections);
551
    }
552
    /**
553
     * Remove behavior
554
     */
555
    const removeSection = (id) => {
556
        sections = sections.filter((item) => item.id_section != id);
557
        return renderData(sections);
558
    }
559
    /**
560
     * Add Option to array
561
     */
562
    const addOption = (id_section, title) => {
563
        sections.map((item) => {
564
            if (item.id_section == id_section) {
565
                item.options.push({
566
                    'id_section': id_section,
567
                    'id_option': new Date().getTime(),
568
                    'title': title,
569
                    'answer': ''
570
                });
571
            }
572
        });
573
        return renderData(sections);
574
    }
575
    /**
576
     * Edit item Option
577
     */
578
    const editOption = (id_section, id, title) => {
579
        sections.map((item) => {
580
            if (item.id_section == id_section) {
581
                item.options.map((opt) => {
582
                    if (opt.id_option == id) {
583
                        opt.title = title
584
                    }
585
                });
586
            }
587
        });
588
        return renderData(sections);
589
    }
590
    /**
591
     * Remove Option
592
     */
593
    const removeOption = (id_section, id) => {
594
        sections.map((item) => {
595
            if (item.id_section == id_section) {
596
                item.options = item.options.filter((opt) => opt.id_option != id) || []
597
            }
598
        });
599
        return renderData(sections);
600
    }
601
    /**
602
     * Clicked refresh button
603
     */
604
    $('button.btn-refresh').click(function(e) {
605
        tableForm.fnDraw();
606
        return;
607
    });
608
    /**
609
     * Initialize select Jobdescription
610
     */
611
    $('#job_description_id').select2({
612
        theme: 'bootstrap4',
613
        width: '100%',
614
    });
615
 
616
    /**
617
     * On change selecte JobDescription
618
     */
619
    $('#job_description_id').on('change', function() {
620
        if ($("#job_description_id").val() != '') {
621
            $.getJSON("/settings/jobs-description/edit/" + $("#job_description_id").val(), function(response) {
622
                if (response['success']) {
623
                    competencies_type = response['data']['competency_types'];
624
                    renderCompetenciesData(response['data']['competencies_selected']);
625
                }
626
            });
627
        }
628
    });
629
 
630
     /**
631
     * Initialize select Jobcategory
632
     */
633
    $('#job_category_id').select2({
634
        theme: 'bootstrap4',
635
        width: '100%',
636
    });
637
     /**
638
     * On change selecte Jobcategory
639
     */
640
    $('#job_category_id').on('change', function() {
641
        if ($("#job_category_id").val() != '') {
642
            $.getJSON("/settings/job-categories/edit/" + $("#job_category_id").val(), function(response) {
643
                if (response['success']) {
644
                    competencies_type = response['data']['competency_types'];
645
                    renderCompetenciesData(response['data']['competencies_selected']);
646
                }
647
            });
648
        }
649
    });
650
 
651
     /**
652
     * Initialize select industry
653
     */
654
    $('#industry_id').select2({
655
        theme: 'bootstrap4',
656
        width: '100%',
657
    });
658
      /**
659
     * On change selecte industry
660
     */
661
    $('#industry_id').on('change', function() {
662
        if ($("#industry_id").val() != '') {
663
            $.getJSON("/settings/industries/edit/" + $("#industry_id").val(), function(response) {
664
                if (response['success']) {
665
                    competencies_type = response['data']['competency_types'];
666
                    renderCompetenciesData(response['data']['competencies_selected']);
667
                }
668
            });
669
        }
670
    });
671
     /**
672
     * Initialize select Location
673
     */
674
 
675
    var validatorLocation = $('#form-location').validate({
676
        debug: true,
677
        onclick: false,
678
        onkeyup: false,
679
        onfocusout: false,
680
        ignore: [],
681
        rules: {
682
            'location_search': {
683
                required: true,
684
                checkLocation: '#form-location #latitude'
685
            }
686
        },
687
        submitHandler: function(form)
688
        {
689
            NProgress.start();
690
            $.ajax({
691
                'dataType'  : 'json',
692
                'accept'    : 'application/json',
693
                'method'    : 'post',
694
                'url'       :  route_location,
695
                'data'      :  $('#form-location').serialize(),
696
            }).done(function(response) {
697
 
698
 
699
 
700
                if(response['success']) {
701
                    $('#overview-location').html(response.data);
702
                    $("#location-box").modal('hide');
703
                } else {
704
                    validatorLocation.resetForm();
705
                    $.fn.showError(response['data']);
706
                }
707
            }).fail(function( jqXHR, textStatus, errorThrown) {
708
                $.fn.showError(textStatus);
709
            }).always(function() {
710
                NProgress.done();
711
            });
712
            return false;
713
        },
714
        invalidHandler: function(form, validator) {
715
 
716
        }
717
    });
718
 
719
    $('body').on('click', 'a.btn-location-edit', function(e) {
720
        e.preventDefault();
721
 
722
        $('#form-location #location_search').val('');
723
        $('#form-location #formatted_address').val('');
724
        $('#form-location #address1').val('');
725
        $('#form-location #address2').val('');
726
        $('#form-location #country').val('');
727
        $('#form-location #state').val('');
728
        $('#form-location #city1').val('');
729
        $('#form-location #city2').val('');
730
        $('#form-location #postal_code').val('');
731
        $('#form-location #latitude').val('');
732
        $('#form-location #longitude').val('');
733
        validatorLocation.resetForm();
734
 
735
        $("#location-box").modal('show');
736
    });
737
 
738
    $('.btn-location-close').on("click", function(e){
739
        e.preventDefault();
740
 
741
        $("#location-box").modal('hide');
742
        return false;
743
    });
744
    /**
745
     * Filter competencie type
746
     */
747
    const filterTypeById = (id) => competencies_type.filter((item) => item.competency_type_id == id ? item : false)[0];
748
    /**
749
     * Render Competencies data
750
     */
751
    const renderCompetenciesData = (data) => {
752
        if (data.length > 0) {
753
            $("#competencies-to-job").show();
754
            $("#rows-job-competencies").html($("#sectionCompetencies").render(data, {
755
                getType: filterTypeById
756
            }));
757
        } else {
758
            $("#competencies-to-job").hide();
759
            $("#rows-job-competencies").html('');
760
        }
761
    }
762
});
763
JS;
764
 
765
$this->inlineScript()->captureEnd();
766
?>
767
<!-- Content Header (Page header) -->
768
<section class="content-header">
769
   <div class="container-fluid">
770
      <div class="row mb-2">
771
         <div class="col-sm-12">
772
            <h1>LABEL_RECRUITMENT_AND_SELECTION</h1>
773
         </div>
774
      </div>
775
   </div>
776
   <!-- /.container-fluid -->
777
</section>
778
<section class="content">
779
<div class="container-fluid" id="row-lists">
780
   <div class="row">
781
      <div class="col-12">
782
         <div class="card">
783
            <div class="card-body">
784
               <table id="gridTable" class="table   table-hover">
785
                  <thead>
786
                     <tr>
787
                        <th style="width:25%">LABEL_NAME</th>
788
                        <th style="width:20%">LABEL_JOB_DESCRIPTION</th>
789
                        <th style="width:10%">LABEL_ACTIVE</th>
790
                        <th style="width:25%">LABEL_ACTIONS</th>
791
                     </tr>
792
                  </thead>
793
                  <tbody></tbody>
794
               </table>
795
            </div>
796
            <div class="card-footer clearfix">
797
               <div style="float:right;">
798
                  <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
799
                  <?php if ($allowAdd) : ?>
800
                  <button type="button" class="btn btn-primary btn-add-form"><i class="fa fa-plus"></i> LABEL_ADD </button>
801
                  <?php endif; ?>
802
               </div>
803
            </div>
804
         </div>
805
      </div>
806
   </div>
807
</div>
808
<!-- Create/Edit Form -->
809
<div class="row" id="row-form" style="display: none; padding: 16px;">
810
   <div class="col-xs-12 col-md-12">
811
      <form action="#" name="form-main" id="form-main">
812
         <div class="form-group">
813
            <label for="form-name">LABEL_FIRST_NAME</label>
814
            <input type="text" name="form-name" id="form-name" class="form-control" maxlength="50" />
815
         </div>
816
         <div class="form-group">
817
            <label for="job_description_id">LABEL_POSITION_EVALUATED</label>
818
            <select name="job_description_id" id="job_description_id" class="form-control">
819
               <option value="">LABEL_SELECT</option>
820
               <?php foreach ($jobsDescription as $rs): ?>
821
               <option value="<?php echo $rs->uuid;?>"><?php echo $rs->name;?></option>
822
               <?php endforeach; ?>
823
            </select>
824
         </div>
825
         <div class="form-group">
826
            <label for="form-location">LABEL_LOCATION</label>
827
            <input type="text" name="form-location" id="location_search" class="form-control" maxlength="50" />
828
         </div>
829
         <div class="form-group">
830
            <label for="job_category_id">LABEL_JOB_CATEGORY</label>
831
            <select name="job_category_id" id="job_category_id" class="form-control">
832
               <option value="">LABEL_SELECT</option>
833
               <?php foreach ($jobCategory as $rs): ?>
834
               <option value="<?php echo $rs->uuid;?>"><?php echo $rs->name;?></option>
835
               <?php endforeach; ?>
836
            </select>
837
         </div>
838
         <div class="form-group">
839
            <label for="job_description_id">LABEL_INDUSTRY</label>
840
            <select name="job_description_id" id="job_description_id" class="form-control">
841
               <option value="">LABEL_SELECT</option>
842
               <?php foreach ($industry as $rs): ?>
843
               <option value="<?php echo $rs->uuid;?>"><?php echo $rs->name;?></option>
844
               <?php endforeach; ?>
845
            </select>
846
         </div>
847
            <label for="form-description">LABEL_DESCRIPTION</label>
848
            <!--  ckeditor -->
849
            <textarea  name="form-description" id="form-description" rows="5" class="ckeditor form-control"></textarea>
850
         </div>
851
         <div class="form-group">
852
            <label for="form-status">LABEL_STATUS</label>
853
            <select name="form-status" id="form-status" class="form-control">
854
               <option value="<?php echo $status_inactive; ?>">LABEL_INACTIVE</option>
855
               <option value="<?php echo $status_active; ?>">LABEL_ACTIVE</option>
856
            </select>
857
         </div>
858
         <div class="row">
859
            <div class="col-xs-12 col-md-12 text-right">
860
               <button type="button" class="btn btn-primary" id="btn-add-section" data-toggle="tooltip" title="LABEL_ADD LABEL_SECTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD LABEL_SECTION</button>
861
            </div>
862
         </div>
863
         <br />
864
         <div class="row">
865
            <div class="col-xs-12 col-md-12">
866
               <div class="panel-group" id="rows"></div>
867
            </div>
868
         </div>
869
         <div class="form-group" id="competencies-to-job" style="display:none">
870
            <div class="row">
871
               <div class="col-xs-12 col-md-12">
872
                  <hr>
873
                  <h4 style="font-size: 18px;font-weight: bold;">LABEL_COMPETENCIES_TO_JOB:</h4>
874
                  <br>
875
                  <div class="panel-group" id="rows-job-competencies"></div>
876
               </div>
877
            </div>
878
         </div>
879
         <div class="form-group">
880
            <button type="button" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
881
            <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
882
            <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
883
         </div>
884
      </form>
885
   </div>
886
</div>
887
<!-- Create/Edit Form-->
888
<!-- section Modal -->
889
<div  id="modal-section" class="modal" tabindex="-1" role="dialog">
890
   <div class="modal-dialog modal-lg" role="document">
891
      <form action="#" name="form-section" id="form-section">
892
         <input type="hidden" name="id-section" id="id-section" />
893
         <div class="modal-content">
894
            <div class="modal-header">
895
               <h4 class="modal-title">LABEL_ADD LABEL_SECTION</h4>
896
               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
897
               <span aria-hidden="true">&times;</span>
898
               </button>
899
            </div>
900
            <div class="modal-body">
901
               <div class="form-group">
902
                  <label for="title-section">LABEL_FIRST_NAME</label>
903
                  <input type="text" name="title-section" id="title-section" class="form-control" maxlength="50" value="" />
904
               </div>
905
               <div class="form-group">
906
                  <label for="text-section">LABEL_TEXT</label>
907
                  <textarea  name="text-section" id="text-section" rows="5" class="form-control"></textarea>
908
               </div>
909
               <div class="form-group">
910
                  <label for="type-section">LABEL_TYPE</label>
911
                  <select name="type-section" id="type-section" class="form-control">
912
                     <option value="simple">Simple</option>
913
                     <option value="multiple">Multiple</option>
914
                  </select>
915
               </div>
916
            </div>
917
            <div class="modal-footer">
918
               <button type="button" id="btn-save-section" class="btn btn-primary">LABEL_SAVE</button>
919
               <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
920
            </div>
921
         </div>
922
      </form>
923
   </div>
924
</div>
925
<!-- End Modal section -->
926
<!-- Modal Options -->
927
<div  id="modal-option" class="modal" tabindex="-1" role="dialog">
928
   <div class="modal-dialog modal-lg" role="document">
929
      <form action="#" name="form-option" id="form-option">
930
         <input type="hidden" name="section-option" id="section-option" value="" />
931
         <input type="hidden" name="id-option" id="id-option" value="" />
932
         <div class="modal-content">
933
            <div class="modal-header">
934
               <h4 class="modal-title">LABEL_OPTION</h4>
935
               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
936
               <span aria-hidden="true">&times;</span>
937
               </button>
938
            </div>
939
            <div class="modal-body">
940
               <div class="form-group">
941
                  <label for="text-option">LABEL_TEXT</label>
942
                  <!--  ckeditor -->
943
                  <textarea  name="text-option" id="text-option" rows="5" class="form-control"></textarea>
944
               </div>
945
            </div>
946
            <div class="modal-footer">
947
               <button type="button" class="btn btn-primary" id="btn-save-option">LABEL_SAVE</button>
948
               <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
949
            </div>
950
         </div>
951
      </form>
952
   </div>
953
</div>
954
 
955
   <!-- End Modal Options -->
956
   <!---Template Sections --->
957
   <script id="sectionTemplate" type="text/x-jsrender">
958
   <div class="panel panel-default" id="panel-{{:id_section}}">
959
   <div class="panel-heading">
960
   <h4 class="panel-title" style="font-size: 18px;">
961
         <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:id_section}}" href="#collapse-{{:id_section}}">
962
         <span class="section-name{{:id_section}}">
963
         {{:title}}
964
         </span>
965
         </a>
966
      </h4>
967
   </div>
968
   <div id="collapse-{{:id_section}}" class="panel-collapse in collapse show">
969
      <div class="panel-body">
970
         <div class="table-responsive">
971
            <table class="table table-bordered">
972
               <thead>
973
                  <tr>
974
                     <th style="width: 10%;">LABEL_ELEMENT</th>
975
                     <th style="width: 30%;">LABEL_TEXT</th>
976
                     <th style="width: 10%;">LABEL_TYPE</th>
977
                     <th style="width: 50%;">LABEL_ACTIONS</th>
978
                  </tr>
979
               </thead>
980
               <tbody>
981
                  <tr>
982
                     <td class="text-left">LABEL_SECTION</td>
983
                     <td class="text-left">{{:title}}</td>
984
                     <td>
985
                        {{if type == 'simple'}} Simple {{/if}}
986
                        {{if type == 'multiple'}} Multiple {{/if}}
987
                     </td>
988
                     <td>
989
                        <button  type="button" class="btn btn-default btn-edit-section" data-section="{{:id_section}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_SECTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_SECTION </button>
990
                        <button  type="button" class="btn btn-default btn-delete-section" data-section="{{:id_section}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_SECTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_SECTION </button>
991
                        {{if type == 'multiple'}}
992
                        <button type="button" class="btn btn-default btn-add-option" data-section="{{:id_section}}" data-toggle="tooltip"  data-original-title="LABEL_ADD  LABEL_OPTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD  LABEL_OPTION </button>
993
                        {{/if}}
994
                     </td>
995
                  </tr>
996
                  {{for options}}
997
                  <tr >
998
                     <td class="text-left">--LABEL_OPTION</td>
999
                     <td class="text-left">
1000
                        {{:title}}
1001
                     </td>
1002
                     <td></td>
1003
                     <td>
1004
                        <button type="button"  class="btn btn-default btn-edit-option" data-section="{{:id_section}}" data-option="{{:id_option}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_OPTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_OPTION</button>
1005
                        <button type="button" class="btn btn-default btn-delete-option" data-section="{{:id_section}}" data-option="{{:id_option}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_OPTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_OPTION</button>
1006
                     </td>
1007
                  </tr>
1008
                  {{/for}}
1009
               </tbody>
1010
            </table>
1011
         </div>
1012
      </div>
1013
   </div>
1014
</div>
1015
   </script>
1016
   <!-- End Template Sections-->
1017
 
1018
  <!---Template Competencies --->
1019
   <script id="sectionCompetencies" type="text/x-jsrender">
1020
   <div class="panel panel-default" id="panel-{{:competency_id}}">
1021
   <div class="panel-heading">
1022
      <h4 class="panel-title" style="font-size: 18px;">
1023
         <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:competency_id}}" href="#collapse-{{:competency_id}}">
1024
         <span class="competency-name{{:competency_id}}">
1025
         {{:~getType(competency_type_id).name}} - {{:name}}
1026
         </span>
1027
         </a>
1028
      </h4>
1029
   </div>
1030
   <div id="collapse-{{:competency_id}}" class="panel-collapse in collapse show">
1031
      <div class="panel-body">
1032
         <div class="table-responsive">
1033
            <table class="table table-bordered">
1034
               <thead>
1035
                  <tr>
1036
                     <th style="width: 80%;">LABEL_CONDUCT</th>
1037
                     <th style="width: 20%;">LABEL_LEVEL</th>
1038
                  </tr>
1039
               </thead>
1040
               <tbody>
1041
                  {{for behaviors}}
1042
                  <tr >
1043
                     <td class="text-left">
1044
                        {{:description}}
1045
                     </td>
1046
                     <td>
1047
                        {{if level == '0'}} LABEL_NA {{/if}}
1048
                        {{if level == '1' }} LABEL_LEVEL_ONE {{/if}}
1049
                        {{if level == '2' }} LABEL_LEVEL_TWO {{/if}}
1050
                        {{if level == '3' }} LABEL_LEVEL_THREE {{/if}}
1051
                        {{if level == '4' }} LABEL_LEVEL_FOUR {{/if}}
1052
                     </td>
1053
 
1054
 
1055
                  </tr>
1056
                  {{/for}}
1057
               </tbody>
1058
            </table>
1059
         </div>
1060
      </div>
1061
   </div>
1062
</div>
1063
   </script>
1064
    <!-- End Template Competencies-->
1065
 
1066
</section>