Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
977 geraldo 1
<?php
2
$acl = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser = $this->currentUserHelper();
4
 
5
$roleName = $currentUser->getUserTypeId();
6
 
985 geraldo 7
$routeAdd = $this->url('performance-evaluation/forms/add');
8
$routeDatatable = $this->url('performance-evaluation/forms');
977 geraldo 9
$routeDashboard = $this->url('dashboard');
10
 
985 geraldo 11
$allowAdd = $acl->isAllowed($roleName, 'performance-evaluation/forms/add') ? 1 : 0;
12
$allowEdit = $acl->isAllowed($roleName, 'performance-evaluation/forms/edit') ? 1 : 0;
13
$allowDelete = $acl->isAllowed($roleName, 'performance-evaluation/forms/delete') ? 1 : 0;
1263 geraldo 14
$allowReport = $acl->isAllowed($roleName, 'performance-evaluation/forms/report') ? 1 : 0;
977 geraldo 15
 
12154 stevensc 16
 
17
$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
18
 
19
 
20
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
21
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
22
 
23
 
24
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
25
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
26
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
27
 
28
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
29
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
30
 
31
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
32
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
33
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
34
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
35
 
36
 
37
$this->headLink()->appendStylesheet($this->basePath('plugins/select2/css/select2.min.css'));
38
$this->headLink()->appendStylesheet($this->basePath('plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css'));
39
 
40
$this->inlineScript()->appendFile($this->basePath('plugins/select2/js/select2.full.min.js'));
41
 
42
$this->inlineScript()->appendFile($this->basePath('plugins/moment/moment-with-locales.min.js'));
43
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css'));
44
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'));
45
 
46
 
47
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
48
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
49
 
50
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
51
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
52
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-input-number/input-number-format.jquery.js'));
53
 
54
// bootbox Alert //
55
$this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));
56
 
57
// JsRender //
58
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.min.js'));
59
 
60
 
1088 geraldo 61
// Page Styles
62
$this->headLink()->appendStylesheet($this->basePath('css/pages/self-evaluation.css'));
63
 
12154 stevensc 64
 
65
$status_active = \LeadersLinked\Model\CompanyPerformanceEvaluationForm::STATUS_ACTIVE;
66
$status_inactive = \LeadersLinked\Model\CompanyPerformanceEvaluationForm::STATUS_INACTIVE;
67
 
68
$this->inlineScript()->captureStart();
69
echo <<<JS
70
jQuery(document).ready(function($) {
71
    var allowEdit = $allowEdit;
72
    var allowDelete = $allowDelete;
73
    var allowReport = $allowReport;
74
    var sections = [];
75
    var competencies_type = [];
76
    /**
77
     * Get rows and set data table
78
     */
79
    var tableForm = $('#gridTable').dataTable({
80
        'processing': true,
81
        'serverSide': true,
82
        'searching': true,
83
        'order': [
84
            [0, 'asc']
85
        ],
86
        'ordering': true,
87
        'ordenable': true,
88
        'responsive': true,
89
        'select': false,
90
        'paging': true,
91
        'pagingType': 'simple_numbers',
92
        'ajax': {
93
            'url': '$routeDatatable',
94
            'type': 'get',
95
            'beforeSend': function(request) {
96
                NProgress.start();
97
            },
98
            'dataFilter': function(response) {
99
                var response = jQuery.parseJSON(response);
100
                var json = {};
101
                json.recordsTotal = 0;
102
                json.recordsFiltered = 0;
103
                json.data = [];
104
                if (response.success) {
105
                    json.recordsTotal = response.data.total;
106
                    json.recordsFiltered = response.data.total;
107
                    json.data = response.data.items;
108
                } else {
109
                    $.fn.showError(response.data)
110
                }
111
                return JSON.stringify(json);
112
            }
113
        },
114
        'language': {
115
            'sProcessing': 'LABEL_DATATABLE_SPROCESSING',
116
            'sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU',
117
            'sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS',
118
            'sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE',
119
            'sInfo': 'LABEL_DATATABLE_SINFO',
120
            'sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY',
121
            'sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED',
122
            'sInfoPostFix': '',
123
            'sSearch': 'LABEL_DATATABLE_SSEARCH',
124
            'sUrl': '',
125
            'sInfoThousands': ',',
126
            'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
127
            'oPaginate': {
128
                'sFirst': 'LABEL_DATATABLE_SFIRST',
129
                'sLast': 'LABEL_DATATABLE_SLAST',
130
                'sNext': 'LABEL_DATATABLE_SNEXT',
131
                'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
132
            },
133
            'oAria': {
134
                'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING',
135
                'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
136
            },
137
        },
138
        'drawCallback': function(settings) {
139
            NProgress.done();
140
            $('button.btn-delete').confirmation({
141
                rootSelector: 'button.btn-delete',
142
                title: 'LABEL_ARE_YOU_SURE',
143
                singleton: true,
144
                btnOkLabel: 'LABEL_YES',
145
                btnCancelLabel: 'LABEL_NO',
146
                onConfirm: function(value) {
147
                    action = $(this).data('href');
148
                    NProgress.start();
149
                    $.ajax({
150
                        'dataType': 'json',
151
                        'accept': 'application/json',
152
                        'method': 'post',
153
                        'url': action,
154
                    }).done(function(response) {
155
                        if (response['success']) {
156
                            $.fn.showSuccess(response['data']);
157
                            tableForm.fnDraw();
158
                        } else {
159
                            $.fn.showError(response['data']);
160
                        }
161
                    }).fail(function(jqXHR, textStatus, errorThrown) {
162
                        $.fn.showError(textStatus);
163
                    }).always(function() {
164
                        NProgress.done();
165
                    });
166
                },
167
            });
168
        },
169
        'aoColumns': [{
170
                'mDataProp': 'name'
171
            },
172
            {
173
                'mDataProp': 'job_description'
174
            },
175
            {
176
                'mDataProp': 'status'
177
            },
178
            {
179
                'mDataProp': 'actions'
180
            },
181
        ],
182
        'columnDefs': [{
183
                'targets': 0,
184
                'className': 'text-vertical-middle',
185
            },
186
            {
187
                'targets': 1,
188
                'className': 'text-vertical-middle',
189
            },
190
            {
191
                'targets': -2,
192
                'orderable': false,
193
                'className': 'text-center',
194
                'render': function(data, type, row) {
195
                    checked = data == 'a' ? ' checked="checked" ' : '';
196
                    return '<div class="checkbox checkbox-success">' +
197
                        '<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +
198
                        '<label ></label></div>';
199
                }
200
            },
201
            {
202
                'targets': -1,
203
                'orderable': false,
204
                'render': function(data, type, row) {
205
                    s = '';
206
                    if (allowEdit) {
207
                        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;';
208
                    }
209
                    if (allowDelete) {
210
                        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;';
211
                    }
212
                    if (allowReport) {
213
                        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;';
214
                    }
215
                    return s;
216
                }
217
            }
218
        ],
219
    });
220
    /**
221
     * Clicked on edit form
222
     */
223
    $('body').on('click', 'button.btn-edit-form', function(e) {
224
        e.preventDefault();
225
        renderCompetenciesData([]);
226
        form_id = $(this).data('id')
227
        var action = $(this).data('href');
228
        $.ajax({
229
            'dataType': 'json',
230
            'accept': 'application/json',
231
            'method': 'get',
232
            'url': action,
233
        }).done(function(response) {
234
            if (response['success']) {
235
                $("#rows").html('');
236
                sections = [];
237
                $('#form-main').attr('action', action);
238
                $('#form-main #form-name').val(response['data']['name']);
239
                $('#form-main #job_description_id').val(response['data']['job_description_id']).trigger('change');
240
                $('#form-main #form-status').val(response['data']['status']);
241
                CKEDITOR.instances['form-description'].setData(response['data']['description']);
242
                $('#row-lists').hide();
243
                $('#row-form').show();
244
            } else {
245
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
246
            }
247
        }).fail(function(jqXHR, textStatus, errorThrown) {
248
            $.fn.showError(textStatus);
249
        });
250
    });
251
 
252
    /**
253
     * Clicked new Form
254
     */
255
    $('button.btn-add-form').click(function(e) {
256
        $("#rows").html('');
257
        sections = [];
258
        $('#form-main').attr('action', '$routeAdd');
259
        $('#form-main #form-name').val('');
260
        $('#form-main #job_description_id').val('').trigger('change');
261
        $('#form-main #form-status').val('$status_active');
262
        CKEDITOR.instances['form-description'].setData('');
263
        renderCompetenciesData([]);
264
        $('#row-lists').hide();
265
        $('#row-form').show();
266
        $('#form-main #form-name').focus();
267
        return;
268
    });
269
    /**
270
     * Clicked cancel new/edit Form
271
     */
272
    $('button.btn-edit-cancel').click(function(e) {
273
        $('#row-form').hide();
274
        $('#row-lists').show();
275
        return;
276
    });
277
    /**
278
     * Clicked save and continue new Form
279
     */
280
    $('button.btn-form-save-continue').click(function(e) {
281
        for (var instanceName in CKEDITOR.instances) {
282
            CKEDITOR.instances[instanceName].updateElement();
283
        }
284
        saveData(1);
285
    });
286
    /**
287
     * Clicked save and close new/edit Form
288
     */
289
    $('button.btn-form-save-close').click(function(e) {
290
        for (var instanceName in CKEDITOR.instances) {
291
            CKEDITOR.instances[instanceName].updateElement();
292
        }
293
        saveData(0);
294
    });
295
    /**
296
     * Save Form Data
297
     */
298
    const saveData = (action) => {
299
        if ($('#form-name').val() == '') {
300
            $.fn.showError('ERROR_ENTER_NAME');
301
        } else if ($('#form-description').val() == '') {
302
            $.fn.showError('ERROR_ENTER_DESCRIPTION');
303
        } else if ($('#form-text').val() == '') {
304
            $.fn.showError('ERROR_ENTER_TEXT');
305
        } else if ($('#form-status').val() == '') {
306
            $.fn.showError('ERROR_SELECT_STATUS');
307
        } else if ($('#job_description_id').val() == '') {
308
            $.fn.showError('ERROR_SELECT_JOB_DESCRIPTION');
309
        } else {
310
            $.ajax({
311
                'dataType': 'json',
312
                'method': 'post',
313
                'url': $('#form-main').attr('action'),
314
                'data': {
315
                    'name': $('#form-main #form-name').val(),
316
                    'job_description_id': $('#form-main #job_description_id').val(),
317
                    'status': $('#form-main #form-status').val(),
318
                    'description': $('#form-main #form-description').val(),
319
                    'content': JSON.stringify(sections)
320
                },
321
            }).done(function(response) {
322
                if (response['success']) {
323
                    $.fn.showSuccess(response['data']);
324
                    if (action == 1) {
325
                        $('#form-main').attr('action', response['action_edit']);
326
                    } else {
327
                        $('#row-form').hide();
328
                        $('#row-lists').show();
329
                        /*---------- Reset Form -------- */
330
                        $('#form-main')[0].reset();
331
                        /*--------Reset Sections ----------*/
332
                        sections = [];
333
                        tableForm.fnDraw();
334
                    }
335
                    return;
336
                } else {
337
                    $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
338
                    return;
339
                }
340
            });
341
        }
342
    }
343
    /**
344
     * Remove Html Tags
345
     */
346
    const removeTags = (str) => str.toString().replace(/(<([^>]+)>)/ig, '')
347
    /**
348
 
349
    /**
350
     * Clicked refresh button
351
     */
352
    $('button.btn-refresh').click(function(e) {
353
        tableForm.fnDraw();
354
        return;
355
    });
356
    /**
357
     * Initialize select Jobdescription
358
     */
359
    $('#job_description_id').select2({
360
        theme: 'bootstrap4',
361
        width: '100%',
362
    });
363
    /**
364
     * On change selecte JobDescription
365
     */
366
    $('#job_description_id').on('change', function() {
367
        if ($("#job_description_id").val() != '') {
368
            $.getJSON("/settings/jobs-description/edit/" + $("#job_description_id").val(), function(response) {
369
                if (response['success']) {
370
                    competencies_type = response['data']['competency_types'];
371
                    renderCompetenciesData(response['data']['competencies_selected']);
372
                }
373
            });
374
        }
375
    });
376
    /**
377
     * Filter competencie type
378
     */
379
    const filterTypeById = (id) => competencies_type.filter((item) => item.competency_type_id == id ? item : false)[0];
380
    /**
381
     * Render Competencies data
382
     */
383
    const renderCompetenciesData = (data) => {
384
        if (data.length > 0) {
385
            $("#competencies-to-job").show();
386
            $("#rows-job-competencies").html($("#sectionCompetencies").render(data, {
387
                getType: filterTypeById
388
            }));
389
        } else {
390
            $("#competencies-to-job").hide();
391
            $("#rows-job-competencies").html('');
392
        }
393
    }
394
});
395
JS;
396
 
397
$this->inlineScript()->captureEnd();
398
 
12137 stevensc 399
$jsonJobsDescription = json_encode($jobsDescription);
400
 
11960 stevensc 401
$js = <<<JS
402
	const backendVariables= {
403
        add_link: "$routeAdd",
404
        table_link: "$routeDatatable",
405
        dashboard_link: "$routeDashboard",
12137 stevensc 406
        jobsDescription: $jsonJobsDescription,
11960 stevensc 407
        permisions: {
408
            allowAdd: $allowAdd,
409
            allowDelete: $allowDelete,
410
            allowEdit: $allowEdit,
411
            allowReport: $allowReport
412
        }
413
	}
414
JS;
415
 
416
$this->inlineScript()->appendScript($js);
417
$this->headLink()->appendStylesheet('/react-bundles/performance_evaluations/forms/main.css');
418
$this->inlineScript()->appendFile('/react-bundles/performance_evaluations/forms/formsBundle.js');
977 geraldo 419
?>
11960 stevensc 420
 
421
<div id="evaluations-forms">
12154 stevensc 422
</div>
423
 
424
<!-- Content Header (Page header) -->
425
<section class="content-header">
426
    <div class="container-fluid">
427
        <div class="row mb-2">
428
            <div class="col-sm-12">
429
                <h1>LABEL_PERFORMANCE_EVALUATION</h1>
430
            </div>
431
        </div>
432
    </div>
433
    <!-- /.container-fluid -->
434
</section>
435
<section class="content">
436
    <div class="container-fluid" id="row-lists">
437
        <div class="row">
438
            <div class="col-12">
439
                <div class="card">
440
                    <div class="card-body">
441
                        <table id="gridTable" class="table   table-hover">
442
                            <thead>
443
                                <tr>
444
                                    <th style="width:25%">LABEL_NAME</th>
445
                                    <th style="width:20%">LABEL_JOB_DESCRIPTION</th>
446
                                    <th style="width:10%">LABEL_ACTIVE</th>
447
                                    <th style="width:25%">LABEL_ACTIONS</th>
448
                                </tr>
449
                            </thead>
450
                            <tbody></tbody>
451
                        </table>
452
                    </div>
453
                    <div class="card-footer clearfix">
454
                        <div style="float:right;">
455
                            <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
456
                            <?php if ($allowAdd) : ?>
457
                                <button type="button" class="btn btn-primary btn-add-form"><i class="fa fa-plus"></i> LABEL_ADD </button>
458
                            <?php endif; ?>
459
                        </div>
460
                    </div>
461
                </div>
462
            </div>
463
        </div>
464
    </div>
465
    <!-- Create/Edit Form -->
466
    <div class="row" id="row-form" style="display: none; padding: 16px;">
467
        <div class="col-xs-12 col-md-12">
468
            <form action="#" name="form-main" id="form-main">
469
                <div class="form-group">
470
                    <label for="form-name">LABEL_FIRST_NAME</label>
471
                    <input type="text" name="form-name" id="form-name" class="form-control" maxlength="50" />
472
                </div>
473
                <div class="form-group">
474
                    <label for="job_description_id">LABEL_POSITION_EVALUATED</label>
475
                    <select name="job_description_id" id="job_description_id" class="form-control">
476
                        <option value="">LABEL_SELECT</option>
477
                        <?php foreach ($jobsDescription as $rs) : ?>
478
                            <option value="<?php echo $rs->uuid; ?>"><?php echo $rs->name; ?></option>
479
                        <?php endforeach; ?>
480
                    </select>
481
                </div>
482
                <div class="form-group">
483
                    <label for="form-description">LABEL_DESCRIPTION</label>
484
                    <!--  ckeditor -->
485
                    <textarea name="form-description" id="form-description" rows="5" class="ckeditor form-control"></textarea>
486
                </div>
487
                <div class="form-group">
488
                    <label for="form-status">LABEL_STATUS</label>
489
                    <select name="form-status" id="form-status" class="form-control">
490
                        <option value="<?php echo $status_inactive; ?>">LABEL_INACTIVE</option>
491
                        <option value="<?php echo $status_active; ?>">LABEL_ACTIVE</option>
492
                    </select>
493
                </div>
494
 
495
                <br />
496
                <div class="row">
497
                    <div class="col-xs-12 col-md-12">
498
                        <div class="panel-group" id="rows"></div>
499
                    </div>
500
                </div>
501
                <div class="form-group" id="competencies-to-job" style="display:none">
502
                    <div class="row">
503
                        <div class="col-xs-12 col-md-12">
504
                            <hr>
505
                            <h4 style="font-size: 18px;font-weight: bold;">LABEL_COMPETENCIES_TO_JOB:</h4>
506
                            <br>
507
                            <div class="panel-group" id="rows-job-competencies"></div>
508
                        </div>
509
                    </div>
510
                </div>
511
                <div class="form-group">
512
                    <button type="button" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
513
                    <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
514
                    <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
515
                </div>
516
            </form>
517
        </div>
518
    </div>
519
    <!-- Create/Edit Form-->
520
 
521
 
522
    <!---Template Competencies --->
523
    <script id="sectionCompetencies" type="text/x-jsrender">
524
        <div class="panel panel-default" id="panel-{{:competency_id}}">
525
   <div class="panel-heading">
526
      <h4 class="panel-title" style="font-size: 18px;">
527
         <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:competency_id}}" href="#collapse-{{:competency_id}}">
528
         <span class="competency-name{{:competency_id}}">
529
         {{:~getType(competency_type_id).name}} - {{:name}}
530
         </span>
531
         </a>
532
      </h4>
533
   </div>
534
   <div id="collapse-{{:competency_id}}" class="panel-collapse in collapse show">
535
      <div class="panel-body">
536
         <div class="table-responsive">
537
            <table class="table table-bordered">
538
               <thead>
539
                  <tr>
540
                     <th style="width: 80%;">LABEL_CONDUCT</th>
541
                     <th style="width: 20%;">LABEL_LEVEL</th>
542
                  </tr>
543
               </thead>
544
               <tbody>
545
                  {{for behaviors}}
546
                  <tr >
547
                     <td class="text-left">
548
                        {{:description}}
549
                     </td>
550
                     <td>
551
                        {{if level == '0'}} LABEL_NA {{/if}}
552
                        {{if level == '1' }} LABEL_LEVEL_ONE {{/if}}
553
                        {{if level == '2' }} LABEL_LEVEL_TWO {{/if}}
554
                        {{if level == '3' }} LABEL_LEVEL_THREE {{/if}}
555
                        {{if level == '4' }} LABEL_LEVEL_FOUR {{/if}}
556
                     </td>
557
 
558
 
559
                  </tr>
560
                  {{/for}}
561
               </tbody>
562
            </table>
563
         </div>
564
      </div>
565
   </div>
566
</div>
567
   </script>
568
    <!-- End Template Competencies-->
569
 
570
</section>