Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 1005 | Rev 1007 | 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;
977 geraldo 14
 
15
 
16
$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
17
 
18
 
19
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
20
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
21
 
22
 
23
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
24
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
25
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
26
 
27
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
28
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
29
 
30
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
31
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
32
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
33
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
34
 
35
 
36
$this->headLink()->appendStylesheet($this->basePath('plugins/select2/css/select2.min.css'));
37
$this->headLink()->appendStylesheet($this->basePath('plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css'));
38
 
39
$this->inlineScript()->appendFile($this->basePath('plugins/select2/js/select2.full.min.js'));
40
 
41
$this->inlineScript()->appendFile($this->basePath('plugins/moment/moment-with-locales.min.js'));
42
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css'));
43
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'));
44
 
45
 
46
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
47
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
48
 
49
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
50
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
51
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-input-number/input-number-format.jquery.js'));
52
 
53
// bootbox Alert //
54
$this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));
55
 
56
// JsRender //
57
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.min.js'));
58
 
59
$this->inlineScript()->captureStart();
60
echo <<<JS
1006 geraldo 61
 
62
jQuery(document).ready(function($) {
977 geraldo 63
 
64
    var allowEdit = $allowEdit;
65
    var allowDelete = $allowDelete;
66
    /**
67
     * Get rows and set data table
68
     */
69
    var tableForm = $('#gridTable').dataTable({
70
        'processing': true,
71
        'serverSide': true,
72
        'searching': true,
73
        'order': [
74
            [0, 'asc']
75
        ],
76
        'ordering': true,
77
        'ordenable': true,
78
        'responsive': true,
79
        'select': false,
80
        'paging': true,
81
        'pagingType': 'simple_numbers',
82
        'ajax': {
83
            'url': '$routeDatatable',
84
            'type': 'get',
85
            'beforeSend': function(request) {
86
                NProgress.start();
87
            },
88
            'dataFilter': function(response) {
89
                var response = jQuery.parseJSON(response);
90
                var json = {};
91
                json.recordsTotal = 0;
92
                json.recordsFiltered = 0;
93
                json.data = [];
94
                if (response.success) {
95
                    json.recordsTotal = response.data.total;
96
                    json.recordsFiltered = response.data.total;
97
                    json.data = response.data.items;
98
                } else {
99
                    $.fn.showError(response.data)
100
                }
101
                return JSON.stringify(json);
102
            }
103
        },
104
        'language': {
105
            'sProcessing': 'LABEL_DATATABLE_SPROCESSING',
106
            'sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU',
107
            'sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS',
108
            'sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE',
109
            'sInfo': 'LABEL_DATATABLE_SINFO',
110
            'sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY',
111
            'sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED',
112
            'sInfoPostFix': '',
113
            'sSearch': 'LABEL_DATATABLE_SSEARCH',
114
            'sUrl': '',
115
            'sInfoThousands': ',',
116
            'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
117
            'oPaginate': {
118
                'sFirst': 'LABEL_DATATABLE_SFIRST',
119
                'sLast': 'LABEL_DATATABLE_SLAST',
120
                'sNext': 'LABEL_DATATABLE_SNEXT',
121
                'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
122
            },
123
            'oAria': {
124
                'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING',
125
                'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
126
            },
127
        },
128
        'drawCallback': function(settings) {
129
            NProgress.done();
130
            $('button.btn-delete').confirmation({
131
                rootSelector: 'button.btn-delete',
132
                title: 'LABEL_ARE_YOU_SURE',
133
                singleton: true,
134
                btnOkLabel: 'LABEL_YES',
135
                btnCancelLabel: 'LABEL_NO',
136
                onConfirm: function(value) {
137
                    action = $(this).data('href');
138
                    NProgress.start();
139
                    $.ajax({
140
                        'dataType': 'json',
141
                        'accept': 'application/json',
142
                        'method': 'post',
143
                        'url': action,
144
                    }).done(function(response) {
145
                        if (response['success']) {
146
                            $.fn.showSuccess(response['data']);
147
                            tableForm.fnDraw();
148
                        } else {
149
                            $.fn.showError(response['data']);
150
                        }
151
                    }).fail(function(jqXHR, textStatus, errorThrown) {
152
                        $.fn.showError(textStatus);
153
                    }).always(function() {
154
                        NProgress.done();
155
                    });
156
                },
157
            });
158
        },
159
        'aoColumns': [{
160
                'mDataProp': 'name'
161
            },
162
            {
163
                'mDataProp': 'language'
164
            },
165
            {
166
                'mDataProp': 'status'
167
            },
168
            {
169
                'mDataProp': 'actions'
170
            },
171
        ],
172
        'columnDefs': [{
173
                'targets': 0,
174
                'className': 'text-vertical-middle',
175
            },
176
            {
177
                'targets': 1,
178
                'className': 'text-vertical-middle',
179
            },
180
            {
181
                'targets': -2,
182
                'orderable': false,
183
                'className': 'text-center',
184
                'render': function(data, type, row) {
185
                    checked = data == 'a' ? ' checked="checked" ' : '';
186
                    return '<div class="checkbox checkbox-success">' +
187
                        '<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +
188
                        '<label ></label></div>';
189
                }
190
            },
191
            {
192
                'targets': -1,
193
                'orderable': false,
194
                'render': function(data, type, row) {
195
                    s = '';
196
                    if (allowEdit) {
197
                        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;';
198
                    }
199
                    if (allowDelete) {
200
                        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;';
201
                    }
202
                    return s;
203
                }
204
            }
205
        ],
206
    });
207
    /**
208
     * Clicked on edit form
209
     */
210
    $('body').on('click', 'button.btn-edit-form', function(e) {
211
        e.preventDefault();
212
        form_id = $(this).data('id')
213
        var action = $(this).data('href');
214
        $.ajax({
215
            'dataType': 'json',
216
            'accept': 'application/json',
217
            'method': 'get',
218
            'url': action,
219
        }).done(function(response) {
220
            if (response['success']) {
1006 geraldo 221
 
977 geraldo 222
                $('#form-main').attr('action', action);
223
                $('#form-main #form-id').val(response['data']['id']),
224
                $('#form-main #form-continue').val('0');
225
                $('#form-main #form-name').val(response['data']['name']),
226
 
227
                /*----------Set Ckeditor ------------*/
228
                CKEDITOR.instances['form-description'].setData(response['data']['description']);
229
                CKEDITOR.instances['form-text'].setData(response['data']['text']);
230
 
231
                $('#form-main #form-language').val(response['data']['language']),
232
                $('#form-main #form-status').val(response['data']['status']);
233
 
234
                /*-------------Render Sections -------*/
235
 
1006 geraldo 236
                renderSectionData();
977 geraldo 237
 
1005 geraldo 238
                $('#row-lists').hide();
239
                $('#row-form').show();
977 geraldo 240
                $('#form-main #form-name').focus();
241
 
242
            } else {
243
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
244
            }
245
        }).fail(function(jqXHR, textStatus, errorThrown) {
246
            $.fn.showError(textStatus);
247
        });
248
    });
1006 geraldo 249
 
977 geraldo 250
 
251
    /**
997 geraldo 252
     * Clicked add new section
977 geraldo 253
     */
1004 geraldo 254
    $('#btn-add-section').click(function(e) {
1005 geraldo 255
        $('#form-section #section-id').val('');
256
        CKEDITOR.instances['section-text'].setData('');
257
        $('#form-section #section-type').val($('#form-section #section-type option:first').val());
258
        $('#form-section #section-max-length').val('0');
259
        $('#form-section #section-max-length').parent().show();
260
        $('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
993 geraldo 261
        $('#modal-section').modal('show');
977 geraldo 262
    });
263
    /**
997 geraldo 264
     * Clicked edit section
977 geraldo 265
     */
1005 geraldo 266
    $('#btn-edit-section').click(function(e) {
267
        console.log(0)
268
        $('#modal-section').modal('show');
977 geraldo 269
    });
270
    /**
997 geraldo 271
     * Clicked remove section
977 geraldo 272
     */
1005 geraldo 273
    $('#btn-delete-section').click(function(e) {
274
        var id = $(this).data('section');
977 geraldo 275
        bootbox.confirm({
993 geraldo 276
            title: "LABEL_DELETE LABEL_SECTION",
277
            message: "LABEL_SECTION_DELETE",
977 geraldo 278
            buttons: {
279
                cancel: {
280
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
281
                },
282
                confirm: {
283
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
284
                }
285
            },
286
            callback: function(result) {
287
                if (result) {
1005 geraldo 288
                    objFormGenerator.deletesection(id);
977 geraldo 289
                    renderSectionData(objFormGenerator.sections);
290
                }
291
            }
292
        });
293
    });
1006 geraldo 294
 
977 geraldo 295
    /**
296
     * Clicked new Form
297
     */
298
    $('button.btn-add-form').click(function(e) {
299
        $('#form-main').attr('action', '$routeAdd');
300
        $('#form-main #form-id').val('0');
301
        $('#form-main #form-continue').val('0');
302
        $('#form-main #form-name').val('');
1005 geraldo 303
        $('#row-lists').hide();
304
        $('#row-form').show();
977 geraldo 305
        $('#form-main #form-name').focus();
306
    });
307
    /**
308
     * Clicked cancel new/edit Form
309
     */
310
    $('button.btn-edit-cancel').click(function(e) {
311
        e.preventDefault();
1005 geraldo 312
        $('#row-form').hide();
313
        $('#row-lists').show();
977 geraldo 314
    });
315
    /**
316
     * Clicked save and continue new Form
317
     */
318
    $('button.btn-form-save-continue').click(function(e) {
319
        e.preventDefault();
320
        $('#form-main #form-continue').val('1')
321
        $('#form-main').submit();
322
    });
323
    /**
324
     * Clicked save and close new/edit Form
325
     */
326
    $('button.btn-form-save-close').click(function(e) {
327
        e.preventDefault();
328
        $('#form-main #form-continue').val('0')
329
        $('#form-main').submit();
330
    });
331
    /**
332
     * Remove Html Tags
333
     */
334
    const removeTags = (str) => str.toString().replace( /(<([^>]+)>)/ig, '')
335
    /**
336
     * Render Sections data
337
     */
998 geraldo 338
    const renderSectionData = (data) => $("#rows").html('');
977 geraldo 339
 
340
 
341
    /**
342
     * Clear Div Section data
343
     */
344
    const clearSectionData = () => $("#rows").html('');
345
    /**
346
     * Clicked refresh button
347
     */
348
    $('button.btn-refresh').click(function(e) {
349
        tableForm.fnDraw();
350
    });
351
 
352
});
353
JS;
354
$this->inlineScript()->captureEnd();
355
?>
356
 
357
<!-- Content Header (Page header) -->
358
<section class="content-header">
359
    <div class="container-fluid">
360
        <div class="row mb-2">
361
            <div class="col-sm-12">
984 geraldo 362
                <h1>LABEL_PERFORMANCE_EVALUATION</h1>
977 geraldo 363
            </div>
364
        </div>
365
    </div>
366
    <!-- /.container-fluid -->
367
</section>
368
<section class="content">
1005 geraldo 369
    <div class="container-fluid" id="row-lists">
977 geraldo 370
        <div class="row">
371
            <div class="col-12">
372
                <div class="card">
373
                    <div class="card-body">
374
                        <table id="gridTable" class="table   table-hover">
375
                            <thead>
376
                                <tr>
990 geraldo 377
                                    <th>LABEL_NAME</th>
378
                                    <th>LABEL_LANGUAGE</th>
379
                                    <th>LABEL_ACTIVE</th>
977 geraldo 380
                                    <th>LABEL_ACTIONS</th>
381
                                </tr>
382
                            </thead>
383
                            <tbody></tbody>
384
                        </table>
385
                    </div>
386
                    <div class="card-footer clearfix">
387
                        <div style="float:right;">
388
                            <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
389
                            <?php if ($allowAdd) : ?>
390
                                <button type="button" class="btn btn-primary btn-add-form"><i class="fa fa-plus"></i> LABEL_ADD </button>
391
                            <?php endif; ?>
392
                        </div>
393
                    </div>
394
                </div>
395
            </div>
396
        </div>
397
    </div>
398
 
399
    <!-- Create/Edit Form -->
400
 
1005 geraldo 401
    <div class="row" id="row-form" style="display: none">
977 geraldo 402
        <div class="col-xs-12 col-md-12">
403
            <form action="#" name="form-main" id="form-main">
404
                <input type="hidden" name="form-id" id="form-id" value="0" />
405
                <input type="hidden" name="form-continue" id="form-continue" value="0" />
990 geraldo 406
                <div class="form-group">
407
                    <label for="form-name">LABEL_FIRST_NAME</label>
408
                    <input type="text" name="form-name" id="form-name" class="form-control" maxlength="50" />
409
                </div>
977 geraldo 410
                <div class="row">
411
                    <div class="col-xs-12 col-md-12 text-right">
994 geraldo 412
                        <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>
977 geraldo 413
                    </div>
414
                </div>
415
                <br />
416
                <div class="row">
417
                    <div class="col-xs-12 col-md-12">
418
                        <div class="panel-group" id="rows"></div>
419
                    </div>
420
                </div>
421
                <div class="form-group">
422
                    <button type="submit" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
423
                    <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
424
                    <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
425
                </div>
426
            </form>
427
        </div>
428
    </div>
429
 
430
    <!-- Create/Edit Form-->
431
 
1005 geraldo 432
     <!-- section Modal -->
977 geraldo 433
 
993 geraldo 434
    <div  id="modal-section" class="modal" tabindex="-1" role="dialog">
977 geraldo 435
        <div class="modal-dialog modal-lg" role="document">
1005 geraldo 436
            <form action="#" name="form-section" id="form-section">
437
                <input type="hidden" name="section-id" id="section-id" />
438
                <div class="modal-content">
439
                    <div class="modal-header">
440
                        <h4 class="modal-title">LABEL_ADD LABEL_SECTION</h4>
441
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
442
                            <span aria-hidden="true">&times;</span>
443
                        </button>
444
                    </div>
445
                    <div class="modal-body">
446
                        <div class="form-group">
447
                            <label for="section-text">LABEL_TEXT</label>
448
                            <!--  ckeditor -->
449
                            <textarea  name="section-text" id="section-text" rows="5" class="ckeditor form-control"></textarea>
450
                        </div>
451
                        <div class="form-group">
452
                            <label for="section-type">LABEL_TYPE</label>
453
                            <select name="section-type" id="section-type" class="form-control">
454
                                <option value="open">LABEL_OPEN</option>
455
                                <option value="simple">Simple</option>
456
                                <option value="multiple">Multiple</option>
457
                            </select>
458
                        </div>
459
                        <div class="form-group">
460
                            <label for="section-max-length">LABEL_MAXLENGTH</label>
461
                            <input type="text" name="section-max-length" id="section-max-length"  class="form-control" />
462
                        </div>
463
                    </div>
464
                    <div class="modal-footer">
465
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
466
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
467
                    </div>
468
                </div>
469
            </form>
977 geraldo 470
        </div>
471
    </div>
472
 
1005 geraldo 473
    <!-- End Modal section -->
474
 
475
    <!-- Modal Options -->
476
 
477
    <div  id="modal-option" class="modal" tabindex="-1" role="dialog">
478
        <div class="modal-dialog modal-lg" role="document">
479
            <form action="#" name="form-option" id="form-option">
480
                <input type="hidden" name="option-section" id="option-section" value="" />
481
                <input type="hidden" name="option-section" id="option-section" value="" />
482
                <input type="hidden" name="option-slug" id="option-slug" value="" />
483
                <div class="modal-content">
484
                    <div class="modal-header">
485
                        <h4 class="modal-title">LABEL_OPTION</h4>
486
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
487
                            <span aria-hidden="true">&times;</span>
488
                        </button>
489
                    </div>
490
                    <div class="modal-body">
491
                        <div class="form-group">
492
                            <label for="option-text">LABEL_TEXT</label>
493
                            <!--  ckeditor -->
494
                            <textarea  name="option-text" id="option-text" rows="5" class="ckeditor form-control"></textarea>
495
                        </div>
496
                    </div>
497
                    <div class="modal-footer">
498
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
499
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
500
                    </div>
501
                </div>
502
            </form>
503
        </div>
504
    </div>
505
 
506
    <!-- End Modal Options -->
507
 
1002 geraldo 508
 
977 geraldo 509
 
510
</section>