Proyectos de Subversion LeadersLinked - Backend

Rev

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