Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 258 | Rev 262 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 258 Rev 261
Línea 2... Línea 2...
2
$acl = $this->viewModel()->getRoot()->getVariable('acl');
2
$acl = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser = $this->currentUserHelper();
3
$currentUser = $this->currentUserHelper();
Línea 4... Línea 4...
4
 
4
 
Línea -... Línea 5...
-
 
5
$roleName = $currentUser->getUserTypeId();
5
$roleName = $currentUser->getUserTypeId();
6
 
6
 
7
$routeAdd = $this->url('self-evaluation/forms/add');
Línea -... Línea 8...
-
 
8
$routeDatatable = $this->url('self-evaluation/forms');
7
$routeDatatable = $this->url('self-evaluation/reviews');
9
$routeDashboard = $this->url('dashboard');
-
 
10
 
Línea 8... Línea 11...
8
$routeDashboard = $this->url('dashboard');
11
$allowAdd = $acl->isAllowed($roleName, 'self-evaluation/forms/add') ? 1 : 0;
Línea 44... Línea 47...
44
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
47
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
Línea 45... Línea 48...
45
 
48
 
46
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
49
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
47
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
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'));
48
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-input-number/input-number-format.jquery.js'));
52
 
49
// bootbox Alert //
53
// bootbox Alert //
-
 
54
$this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));
50
$this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));
55
 
51
// JsRender //
56
// JsRender //
Línea -... Línea 57...
-
 
57
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.min.js'));
-
 
58
 
-
 
59
// Page Styles
-
 
60
$this->headLink()->appendStylesheet($this->basePath('css/pages/self-evaluation.css'));
-
 
61
 
-
 
62
$status_active = \LeadersLinked\Model\CompanySelfEvaluationForm::STATUS_ACTIVE;
-
 
63
$status_inactive = \LeadersLinked\Model\CompanySelfEvaluationForm::STATUS_INACTIVE;
-
 
64
 
-
 
65
$lang_es = \LeadersLinked\Model\CompanySelfEvaluationForm::LANGUAGE_SPANISH;
Línea 52... Línea 66...
52
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.min.js'));
66
$lang_en = \LeadersLinked\Model\CompanySelfEvaluationForm::LANGUAGE_ENGLISH;
53
 
67
 
54
 
68
 
55
$this->inlineScript()->captureStart();
69
$this->inlineScript()->captureStart();
Línea 813... Línea 827...
813
                });
827
                });
814
                return false;
828
                return false;
815
            }
829
            }
816
        }
830
        }
817
    });
831
    });
-
 
832
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
-
 
833
    $("#form-section").on('submit', function() {
-
 
834
        for (var instanceName in CKEDITOR.instances) {
-
 
835
            CKEDITOR.instances[instanceName].updateElement();
-
 
836
        }
-
 
837
    })
-
 
838
    /**
-
 
839
     * Validate rules form section
-
 
840
     */
-
 
841
    var validatorFormSection = $("#form-section").validate({
-
 
842
        ignore: [],
-
 
843
        errorClass: 'help-block',
-
 
844
        errorElement: 'span',
-
 
845
        rules: {
-
 
846
            'section-name': {
-
 
847
                required: true,
-
 
848
                minlength: 2,
-
 
849
                maxlength: 50
-
 
850
            },
-
 
851
            'section-text': {
-
 
852
                required: false,
-
 
853
            },
-
 
854
            'section-value': {
-
 
855
                required: true,
-
 
856
                number: true,
-
 
857
                min: 1
-
 
858
            },
-
 
859
        },
-
 
860
        highlight: function(element) {
-
 
861
            $(element).closest('.form-group').addClass('has-error');
-
 
862
        },
-
 
863
        unhighlight: function(element) {
-
 
864
            $(element).closest('.form-group').removeClass('has-error');
-
 
865
        },
-
 
866
        errorPlacement: function(error, element) {
-
 
867
            if (element.attr("data-error-container")) {
-
 
868
                error.appendTo(element.attr("data-error-container"));
-
 
869
            } else {
-
 
870
                error.insertAfter(element);
-
 
871
            }
-
 
872
        },
-
 
873
        invalidHandler: function(form, validator) {
-
 
874
            if (!validator.numberOfInvalids())
-
 
875
                return;
-
 
876
            $('html, body').animate({
-
 
877
                scrollTop: $(validator.errorList[0].element).offset().top - 100
-
 
878
            }, 1000);
-
 
879
        },
-
 
880
        submitHandler: function(form) {
-
 
881
            // do other things for a valid form
-
 
882
            //form.submit();
-
 
883
            var slug = $('#form-section #section-slug').val();
-
 
884
            if (slug) {
-
 
885
                objFormGenerator.editSection(
-
 
886
                    $('#form-section #section-slug').val(),
-
 
887
                    $('#form-section #section-name').val(),
-
 
888
                    $('#form-section #section-text').val(),
-
 
889
                    $('#form-section #section-value').val()
-
 
890
                );
-
 
891
            } else {
-
 
892
                objFormGenerator.addSection(
-
 
893
                    $('#form-section #section-name').val(),
-
 
894
                    $('#form-section #section-text').val(),
-
 
895
                    $('#form-section #section-value').val()
-
 
896
                );
-
 
897
            }
-
 
898
            renderSectionData(objFormGenerator.sections);
-
 
899
            $('#modal-section').modal('hide');
-
 
900
            return false;
-
 
901
        }
-
 
902
    });
-
 
903
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
-
 
904
    $("#form-question").on('submit', function() {
-
 
905
        for (var instanceName in CKEDITOR.instances) {
-
 
906
            CKEDITOR.instances[instanceName].updateElement();
-
 
907
        }
-
 
908
    })
-
 
909
    /**
-
 
910
     * Validate rules form Questions
-
 
911
     */
-
 
912
    var validatorFormQuestion = $("#form-question").validate({
-
 
913
        ignore: [],
-
 
914
        errorClass: 'help-block',
-
 
915
        errorElement: 'span',
-
 
916
        rules: {
-
 
917
            'question-text': {
-
 
918
                required: true,
-
 
919
            },
-
 
920
            'question-value': {
-
 
921
                required: true,
-
 
922
                number: true,
-
 
923
                min: 1
-
 
924
            },
-
 
925
            'question-type': {
-
 
926
                required: true,
-
 
927
            },
-
 
928
            'question-max-length': {
-
 
929
                required: true,
-
 
930
                digits: true,
-
 
931
                min: 0
-
 
932
            },
-
 
933
            'question-range': {
-
 
934
                required: true,
-
 
935
                number: true,
-
 
936
                min: 1
-
 
937
            },
-
 
938
        },
-
 
939
        highlight: function(element) {
-
 
940
            $(element).closest('.form-group').addClass('has-error');
-
 
941
        },
-
 
942
        unhighlight: function(element) {
-
 
943
            $(element).closest('.form-group').removeClass('has-error');
-
 
944
        },
-
 
945
        errorPlacement: function(error, element) {
-
 
946
            if (element.attr("data-error-container")) {
-
 
947
                error.appendTo(element.attr("data-error-container"));
-
 
948
            } else {
-
 
949
                error.insertAfter(element);
-
 
950
            }
-
 
951
        },
-
 
952
        invalidHandler: function(form, validator) {
-
 
953
            if (!validator.numberOfInvalids())
-
 
954
                return;
-
 
955
            $('html, body').animate({
-
 
956
                scrollTop: $(validator.errorList[0].element).offset().top - 100
-
 
957
            }, 1000);
-
 
958
        },
-
 
959
        submitHandler: function(form) {
-
 
960
            if ($('#form-question #question-slug').val()) {
-
 
961
                objFormGenerator.editQuestion(
-
 
962
                    $('#form-question #question-section').val(),
-
 
963
                    $('#form-question #question-slug').val(),
-
 
964
                    $('#form-question #question-text').val(),
-
 
965
                    $('#form-question #question-value').val(),
-
 
966
                    $('#form-question #question-type').val(),
-
 
967
                    $('#form-question #question-max-length').val(),
-
 
968
                    $('#form-question #question-multiline').val(),
-
 
969
                    $('#form-question #question-range').val()
-
 
970
                );
-
 
971
            } else {
-
 
972
                objFormGenerator.addQuestion(
-
 
973
                    $('#form-question #question-section').val(),
-
 
974
                    $('#form-question #question-text').val(),
-
 
975
                    $('#form-question #question-value').val(),
-
 
976
                    $('#form-question #question-type').val(),
-
 
977
                    $('#form-question #question-max-length').val(),
-
 
978
                    $('#form-question #question-multiline').val(),
-
 
979
                    $('#form-question #question-range').val()
-
 
980
                );
-
 
981
            }
-
 
982
            renderSectionData(objFormGenerator.sections);
-
 
983
            $('#modal-question').modal('hide');
-
 
984
            return false;
-
 
985
        }
-
 
986
    });
-
 
987
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
-
 
988
    $("#form-option").on('submit', function() {
-
 
989
        for (var instanceName in CKEDITOR.instances) {
-
 
990
            CKEDITOR.instances[instanceName].updateElement();
-
 
991
        }
818
    
992
    })
-
 
993
    /**
-
 
994
     * Validate rules form options
-
 
995
     */
-
 
996
    var validatorFormOption = $("#form-option").validate({
-
 
997
        ignore: [],
-
 
998
        errorClass: 'help-block',
-
 
999
        errorElement: 'span',
-
 
1000
        rules: {
-
 
1001
            'option-text': {
-
 
1002
                required: true,
-
 
1003
            },
-
 
1004
            'option-value': {
-
 
1005
                required: true,
-
 
1006
                number: true,
-
 
1007
                min: 1
-
 
1008
            }
-
 
1009
        },
-
 
1010
        highlight: function(element) {
-
 
1011
            $(element).closest('.form-group').addClass('has-error');
-
 
1012
        },
-
 
1013
        unhighlight: function(element) {
-
 
1014
            $(element).closest('.form-group').removeClass('has-error');
-
 
1015
        },
-
 
1016
        errorPlacement: function(error, element) {
-
 
1017
            if (element.attr("data-error-container")) {
-
 
1018
                error.appendTo(element.attr("data-error-container"));
-
 
1019
            } else {
-
 
1020
                error.insertAfter(element);
-
 
1021
            }
-
 
1022
        },
-
 
1023
        invalidHandler: function(form, validator) {
-
 
1024
            if (!validator.numberOfInvalids())
-
 
1025
                return;
-
 
1026
            $('html, body').animate({
-
 
1027
                scrollTop: $(validator.errorList[0].element).offset().top - 100
-
 
1028
            }, 1000);
-
 
1029
        },
-
 
1030
        submitHandler: function(form) {
-
 
1031
            if ($('#form-option #option-slug').val()) {
-
 
1032
                objFormGenerator.editOption(
-
 
1033
                    $('#form-option #option-section').val(),
-
 
1034
                    $('#form-option #option-question').val(),
-
 
1035
                    $('#form-option #option-slug').val(),
-
 
1036
                    $('#form-option #option-text').val(),
-
 
1037
                    $('#form-option #option-correct').val(),
-
 
1038
                    $('#form-option #option-value').val()
-
 
1039
                );
-
 
1040
            } else {
-
 
1041
                objFormGenerator.addOption(
-
 
1042
                    $('#form-option #option-section').val(),
-
 
1043
                    $('#form-option #option-question').val(),
-
 
1044
                    $('#form-option #option-text').val(),
-
 
1045
                    $('#form-option #option-correct').val(),
-
 
1046
                    $('#form-option #option-value').val()
-
 
1047
                );
-
 
1048
            }
-
 
1049
            renderSectionData(objFormGenerator.sections);
-
 
1050
            $('#modal-option').modal('hide');
-
 
1051
            return false;
-
 
1052
        }
-
 
1053
    });
-
 
1054
    /**
-
 
1055
     * Clicked on add new section
-
 
1056
     */
-
 
1057
    $('body').on('click', 'button[id="btn-add-section"]', function(e) {
-
 
1058
        e.preventDefault();
-
 
1059
        validatorFormSection.resetForm();
-
 
1060
        $('#form-section #section-slug').val('');
-
 
1061
        $('#form-section #section-name').val('');
-
 
1062
        CKEDITOR.instances['section-text'].setData('');
-
 
1063
        $('#form-section #section-value').val('0');
-
 
1064
        $('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
-
 
1065
        $('#modal-section').modal('show');
-
 
1066
    });
-
 
1067
    /**
-
 
1068
     * Clicked on edit section
-
 
1069
     */
-
 
1070
    $('body').on('click', 'button.btn-edit-section', function(e) {
-
 
1071
        e.preventDefault();
-
 
1072
        var slug = $(this).data('section');
-
 
1073
        var section;
-
 
1074
        var showForm = false;
-
 
1075
        for (i = 0; i < objFormGenerator.sections.length; i++) {
-
 
1076
            section = objFormGenerator.sections[i];
-
 
1077
            if (slug == section.slug_section) {
-
 
1078
                validatorFormSection.resetForm();
-
 
1079
                $('#form-section #section-slug').val(section.slug_section);
-
 
1080
                $('#form-section #section-name').val(section.name);
-
 
1081
                CKEDITOR.instances['section-text'].setData(section.text);
-
 
1082
                $('#form-section #section-value').val(section.value);
-
 
1083
                showForm = true;
-
 
1084
                break;
-
 
1085
            }
-
 
1086
        }
-
 
1087
        if (showForm) {
-
 
1088
            $('#modal-section h4[class="modal-title"]').html('LABEL_EDIT LABEL_SECTION');
-
 
1089
            $('#modal-section').modal('show');
-
 
1090
        }
-
 
1091
    });
-
 
1092
    /**
-
 
1093
     * Clicked on remove section
-
 
1094
     */
-
 
1095
    $('body').on('click', 'button.btn-delete-section', function(e) {
-
 
1096
        e.preventDefault();
-
 
1097
        var slug = $(this).data('section');
-
 
1098
        bootbox.confirm({
-
 
1099
            title: "LABEL_DELETE LABEL_SECTION",
-
 
1100
            message: "LABEL_QUESTION_DELETE",
-
 
1101
            buttons: {
-
 
1102
                cancel: {
-
 
1103
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
-
 
1104
                },
-
 
1105
                confirm: {
-
 
1106
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
-
 
1107
                }
-
 
1108
            },
-
 
1109
            callback: function(result) {
-
 
1110
                if (result) {
-
 
1111
                    objFormGenerator.deleteSection(slug);
-
 
1112
                    renderSectionData(objFormGenerator.sections);
-
 
1113
                }
-
 
1114
            }
-
 
1115
        });
-
 
1116
    });
-
 
1117
    /**
-
 
1118
     * Clicked add new question
-
 
1119
     */
-
 
1120
    $('body').on('click', 'button.btn-add-question', function(e) {
-
 
1121
        e.preventDefault();
-
 
1122
        validatorFormQuestion.resetForm();
-
 
1123
        var slug = $(this).data('section');
-
 
1124
        $('#form-question #question-section').val(slug);
-
 
1125
        $('#form-question #question-slug').val('');
-
 
1126
        CKEDITOR.instances['question-text'].setData('');
-
 
1127
        $('#form-question #question-value').val('0');
-
 
1128
        $('#form-question #question-type').val($('#form-question #question-type option:first').val());
-
 
1129
        $('#form-question #question-max-length').val('0');
-
 
1130
        $('#form-question #question-max-length').parent().show();
-
 
1131
        $('#form-question #question-multiline').val('0');
-
 
1132
        $('#form-question #question-multiline').parent().show();
-
 
1133
        $('#form-question #question-range').val('10');
-
 
1134
        $('#form-question #question-range').parent().hide();
-
 
1135
        $('#modal-question h4[class="modal-title"]').html('LABEL_ADD LABEL_QUESTION');
-
 
1136
        $('#modal-question').modal('show');
-
 
1137
    });
-
 
1138
    /**
-
 
1139
     * Clicked edit question
-
 
1140
     */
-
 
1141
    $('body').on('click', 'button.btn-edit-question', function(e) {
-
 
1142
        e.preventDefault();
-
 
1143
        var slug_section = $(this).data('section');
-
 
1144
        var slug = $(this).data('question');
-
 
1145
        var showForm = false;
-
 
1146
        for (i = 0; i < objFormGenerator.sections.length; i++) {
-
 
1147
            if (slug_section == objFormGenerator.sections[i].slug_section) {
-
 
1148
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
-
 
1149
                    if (slug == objFormGenerator.sections[i].questions[j].slug_question) {
-
 
1150
                        validatorFormQuestion.resetForm();
-
 
1151
                        $('#form-question #question-section').val(objFormGenerator.sections[i].slug_section);
-
 
1152
                        $('#form-question #question-slug').val(objFormGenerator.sections[i].questions[j].slug_question);
-
 
1153
                        CKEDITOR.instances['question-text'].setData(objFormGenerator.sections[i].questions[j].text);
-
 
1154
                        $('#form-question #question-value').val(objFormGenerator.sections[i].questions[j].value);
-
 
1155
                        $('#form-question #question-type').val(objFormGenerator.sections[i].questions[j].type);
-
 
1156
                        if (objFormGenerator.sections[i].questions[j].type == 'open') {
-
 
1157
                            $('#form-question #question-max-length').val(objFormGenerator.sections[i].questions[j].maxlength);
-
 
1158
                            $('#form-question #question-max-length').parent().show();
-
 
1159
                            $('#form-question #question-multiline').val(objFormGenerator.sections[i].questions[j].multiline);
-
 
1160
                            $('#form-question #question-multiline').parent().show();
-
 
1161
                        } else {
-
 
1162
                            $('#form-question #question-max-length').val('0');
-
 
1163
                            $('#form-question #question-max-length').parent().hide();
-
 
1164
                            $('#form-question #question-multiline').val('0');
-
 
1165
                            $('#form-question #question-multiline').parent().hide();
-
 
1166
                        }
-
 
1167
                        if (objFormGenerator.sections[i].questions[j].type == 'rating-range') {
-
 
1168
                            $('#form-question #question-range').val(objFormGenerator.sections[i].questions[j].range);
-
 
1169
                            $('#form-question #question-range').parent().show();
-
 
1170
                        } else {
-
 
1171
                            $('#form-question #question-range').val('10');
-
 
1172
                            $('#form-question #question-range').parent().hide();
-
 
1173
                        }
-
 
1174
                        showForm = true;
-
 
1175
                        break;
-
 
1176
                    }
-
 
1177
                }
-
 
1178
                break;
-
 
1179
            }
-
 
1180
        }
-
 
1181
        if (showForm) {
-
 
1182
            $('#modal-question h4[class="modal-title"]').html('LABEL_EDIT LABEL_QUESTION');
-
 
1183
            $('#modal-question').modal('show');
-
 
1184
        }
-
 
1185
    });
-
 
1186
    /**
-
 
1187
     * Clicked remove question
-
 
1188
     */
-
 
1189
    $('body').on('click', 'button.btn-delete-question', function(e) {
-
 
1190
        e.preventDefault();
-
 
1191
        var slug_section = $(this).data('section');
-
 
1192
        var slug = $(this).data('question');
-
 
1193
        bootbox.confirm({
-
 
1194
            title: "LABEL_DELETE LABEL_QUESTION",
-
 
1195
            message: "LABEL_QUESTION_DELETE",
-
 
1196
            buttons: {
-
 
1197
                cancel: {
-
 
1198
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
-
 
1199
                },
-
 
1200
                confirm: {
-
 
1201
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
-
 
1202
                }
-
 
1203
            },
-
 
1204
            callback: function(result) {
-
 
1205
                if (result) {
-
 
1206
                    objFormGenerator.deleteQuestion(slug_section, slug);
-
 
1207
                    renderSectionData(objFormGenerator.sections);
-
 
1208
                }
-
 
1209
            }
-
 
1210
        });
-
 
1211
    });
-
 
1212
    /**
-
 
1213
     * Clicked add new Option
-
 
1214
     */
-
 
1215
    $('body').on('click', 'button.btn-add-option', function(e) {
-
 
1216
        e.preventDefault();
-
 
1217
        var slug_section = $(this).data('section');
-
 
1218
        var slug_question = $(this).data('question');
-
 
1219
        var showForm = false;
-
 
1220
        for (i = 0; i < objFormGenerator.sections.length; i++) {
-
 
1221
            if (slug_section == objFormGenerator.sections[i].slug_section) {
-
 
1222
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
-
 
1223
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
-
 
1224
                        validatorFormOption.resetForm();
-
 
1225
                        $('#form-option #option-section').val(slug_section);
-
 
1226
                        $('#form-option #option-question').val(slug_question);
-
 
1227
                        $('#form-option #option-slug').val('');
-
 
1228
                        CKEDITOR.instances['option-text'].setData('', function() {
-
 
1229
                            editor.focus();
-
 
1230
                        });
-
 
1231
                        $('#form-option #option-correct').val('0');
-
 
1232
                        if (objFormGenerator.sections[i].questions[j].type == 'rating-open') {
-
 
1233
                            $('#form-option #option-correct').parent().hide();
-
 
1234
                        } else {
-
 
1235
                            $('#form-option #option-correct').parent().show();
-
 
1236
                        }
-
 
1237
                        if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'rating-open') {
-
 
1238
                            $('#form-option #option-value').val('0');
-
 
1239
                            $('#form-option #option-value').parent().show();
-
 
1240
                        } else {
-
 
1241
                            $('#form-option #option-value').val('1');
-
 
1242
                            $('#form-option #option-value').parent().hide();
-
 
1243
                        }
-
 
1244
                        renderSectionData(objFormGenerator.sections);
-
 
1245
                        $('#modal-option h4[class="modal-title"]').html('LABEL_ADD LABEL_OPTION');
-
 
1246
                        $('#modal-option').modal('show');
-
 
1247
                        return true;
-
 
1248
                    }
-
 
1249
                }
-
 
1250
            }
-
 
1251
        }
-
 
1252
    });
-
 
1253
    /**
-
 
1254
     * Clicked edit option
-
 
1255
     */
-
 
1256
    $('body').on('click', 'button.btn-edit-option', function(e) {
-
 
1257
        e.preventDefault();
-
 
1258
        var slug_section = $(this).data('section');
-
 
1259
        var slug_question = $(this).data('question');
-
 
1260
        var slug = $(this).data('slug');
-
 
1261
        var showForm = false;
-
 
1262
        for (i = 0; i < objFormGenerator.sections.length; i++) {
-
 
1263
            if (slug_section == objFormGenerator.sections[i].slug_section) {
-
 
1264
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
-
 
1265
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
-
 
1266
                        for (k = 0; k < objFormGenerator.sections[i].questions[j].options.length; k++) {
-
 
1267
                            if (slug == objFormGenerator.sections[i].questions[j].options[k].slug_option) {
-
 
1268
                                validatorFormOption.resetForm();
-
 
1269
                                $('#form-option #option-section').val(objFormGenerator.sections[i].slug_section);
-
 
1270
                                $('#form-option #option-question').val(objFormGenerator.sections[i].questions[j].slug_question);
-
 
1271
                                $('#form-option #option-slug').val(objFormGenerator.sections[i].questions[j].options[k].slug_option);
-
 
1272
                                CKEDITOR.instances['option-text'].setData(objFormGenerator.sections[i].questions[j].options[k].text,
-
 
1273
                                    function() {
-
 
1274
                                        editor.focus();
-
 
1275
                                    });
-
 
1276
                                $('#form-option #option-correct').val(objFormGenerator.sections[i].questions[j].options[k].correct);
-
 
1277
                                if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'simple') {
-
 
1278
                                    $('#form-option #option-correct').parent().show();
-
 
1279
                                } else {
-
 
1280
                                    $('#form-option #option-correct').parent().hide();
-
 
1281
                                }
-
 
1282
                                $('#form-option #option-value').val(objFormGenerator.sections[i].questions[j].options[k].value);
-
 
1283
                                if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'rating-open') {
-
 
1284
                                    $('#form-option #option-value').parent().show();
-
 
1285
                                } else {
-
 
1286
                                    $('#form-option #option-value').parent().hide();
-
 
1287
                                }
-
 
1288
                                showForm = true;
-
 
1289
                                break;
-
 
1290
                            }
-
 
1291
                        }
-
 
1292
                    }
-
 
1293
                    if (showForm) {
-
 
1294
                        break;
-
 
1295
                    }
-
 
1296
                }
-
 
1297
            }
-
 
1298
            if (showForm) {
-
 
1299
                break;
-
 
1300
            }
-
 
1301
        }
-
 
1302
        if (showForm) {
-
 
1303
            $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
-
 
1304
            $('#modal-option').modal('show');
-
 
1305
        }
-
 
1306
    });
-
 
1307
    /**
-
 
1308
     * Clicked remove option
-
 
1309
     */
-
 
1310
    $('body').on('click', 'button.btn-delete-option', function(e) {
-
 
1311
        e.preventDefault();
-
 
1312
        var slug_section = $(this).data('section');
-
 
1313
        var slug_question = $(this).data('question');
-
 
1314
        var slug = $(this).data('slug');
-
 
1315
        bootbox.confirm({
-
 
1316
            title: "LABEL_DELETE LABEL_OPTION",
-
 
1317
            message: "LABEL_QUESTION_DELETE",
-
 
1318
            buttons: {
-
 
1319
                cancel: {
-
 
1320
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
-
 
1321
                },
-
 
1322
                confirm: {
-
 
1323
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
-
 
1324
                }
-
 
1325
            },
-
 
1326
            callback: function(result) {
-
 
1327
                if (result) {
-
 
1328
                    objFormGenerator.deleteOption(slug_section, slug_question, slug);
-
 
1329
                    renderSectionData(objFormGenerator.sections);
-
 
1330
                }
-
 
1331
            }
-
 
1332
        });
819
   
1333
    })
-
 
1334
    /**
-
 
1335
     * Format input number (Form Section) 
-
 
1336
     */
-
 
1337
    $('#form-section #section-value').inputNumberFormat({
-
 
1338
        'decimal': 2
-
 
1339
    });
-
 
1340
    /**
-
 
1341
     * Format input number (Form Question) 
-
 
1342
     */
-
 
1343
    $('#form-question #question-value').inputNumberFormat({
-
 
1344
        'decimal': 2
-
 
1345
    });
-
 
1346
    /**
-
 
1347
     * Format input number (Form Question) 
-
 
1348
     */
-
 
1349
    $('#form-question #question-max-length').inputNumberFormat({
-
 
1350
        'decimal': 0
-
 
1351
    });
-
 
1352
    /**
-
 
1353
     * Format input number (Form Option) 
-
 
1354
     */
-
 
1355
    $('#form-option #option-value').inputNumberFormat({
-
 
1356
        'decimal': 2
-
 
1357
    });
-
 
1358
    /**
-
 
1359
     * Detect when updating question status and hide/Show options
-
 
1360
     */
-
 
1361
    $('#form-question #question-type').change(function(e) {
-
 
1362
        e.preventDefault();
-
 
1363
        if ($('#form-question #question-type').val() == 'open') {
-
 
1364
            $('#form-question #question-max-length').parent().show();
-
 
1365
            $('#form-question #question-multiline').parent().show();
-
 
1366
        } else {
-
 
1367
            $('#form-question #question-max-length').val('0');
-
 
1368
            $('#form-question #question-max-length').parent().hide();
-
 
1369
            $('#form-question #question-multiline').val('0');
-
 
1370
            $('#form-question #question-multiline').parent().hide();
-
 
1371
        }
-
 
1372
        $('#form-question #question-range').val('10');
-
 
1373
        if ($('#form-question #question-type').val() == 'rating-range') {
-
 
1374
            $('#form-question #question-range').parent().show();
-
 
1375
        } else {
-
 
1376
            $('#form-question #question-range').parent().hide();
-
 
1377
        }
-
 
1378
    });
-
 
1379
    /**
-
 
1380
     * Clicked new Form
-
 
1381
     */
-
 
1382
    $('button.btn-add-form').click(function(e) {
-
 
1383
        e.preventDefault();
-
 
1384
        objFormGenerator.clear();
-
 
1385
        objFormGenerator.render();
-
 
1386
        validatorForm.resetForm();
-
 
1387
        clearSectionData();
-
 
1388
        $('#form-main').attr('action', '$routeAdd');
-
 
1389
        $('#form-main #form-id').val('0');
-
 
1390
        $('#form-main #form-continue').val('0');
-
 
1391
        $('#form-main #form-name').val('');
-
 
1392
        $('#form-main #form-language').val('$lang_es'),
-
 
1393
        $('#form-main #form-status').val('$status_inactive');
-
 
1394
        CKEDITOR.instances['form-text'].setData('');
-
 
1395
        CKEDITOR.instances['form-description'].setData('');
-
 
1396
        $('#row-forms').hide();
-
 
1397
        $('#row-edit').show();
-
 
1398
        $('#form-main #form-name').focus();
-
 
1399
    });
820
    /**
1400
    /**
821
     * Clicked cancel new/edit Form
1401
     * Clicked cancel new/edit Form
822
     */
1402
     */
823
    $('button.btn-edit-cancel').click(function(e) {
1403
    $('button.btn-edit-cancel').click(function(e) {
824
        e.preventDefault();
1404
        e.preventDefault();
Línea 895... Línea 1475...
895
<!-- Content Header (Page header) -->
1475
<!-- Content Header (Page header) -->
896
<section class="content-header">
1476
<section class="content-header">
897
    <div class="container-fluid">
1477
    <div class="container-fluid">
898
        <div class="row mb-2">
1478
        <div class="row mb-2">
899
            <div class="col-sm-12">
1479
            <div class="col-sm-12">
900
                <h1>LABEL_REVIEWS</h1>
1480
                <h1>LABEL_SELF_EVALUATION_FORMS</h1>
901
            </div>
1481
            </div>
902
        </div>
1482
        </div>
903
    </div>
1483
    </div>
904
    <!-- /.container-fluid -->
1484
    <!-- /.container-fluid -->
905
</section>
1485
</section>
Línea 910... Línea 1490...
910
                <div class="card">
1490
                <div class="card">
911
                    <div class="card-body">
1491
                    <div class="card-body">
912
                        <table id="gridTable" class="table   table-hover">
1492
                        <table id="gridTable" class="table   table-hover">
913
                            <thead>
1493
                            <thead>
914
                                <tr>
1494
                                <tr>
915
                                <th>LABEL_USER</th>
-
 
916
                                    <th>LABEL_NAME</th>
1495
                                    <th>LABEL_NAME</th>
917
                                    <th>LABEL_LANGUAGE</th>
1496
                                    <th>LABEL_LANGUAGE</th>
918
                                    <th>LABEL_STATUS</th>
1497
                                    <th>LABEL_ACTIVE</th>
919
                                    <th>LABEL_ACTIONS</th>
1498
                                    <th>LABEL_ACTIONS</th>
920
                                </tr>
1499
                                </tr>
921
                            </thead>
1500
                            </thead>
922
                            <tbody></tbody>
1501
                            <tbody></tbody>
923
                        </table>
1502
                        </table>
924
                    </div>
1503
                    </div>
925
                    <div class="card-footer clearfix">
1504
                    <div class="card-footer clearfix">
926
                        <div style="float:right;">
1505
                        <div style="float:right;">
927
                            <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
1506
                            <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
-
 
1507
                            <?php if ($allowAdd) : ?>
-
 
1508
                                <button type="button" class="btn btn-primary btn-add-form"><i class="fa fa-plus"></i> LABEL_ADD </button>
-
 
1509
                            <?php endif; ?>
928
                        </div>
1510
                        </div>
929
                    </div>
1511
                    </div>
930
                </div>
1512
                </div>
931
            </div>
1513
            </div>
932
        </div>
1514
        </div>
Línea 935... Línea 1517...
935
    <!-- Create/Edit Form -->
1517
    <!-- Create/Edit Form -->
Línea 936... Línea 1518...
936
 
1518
 
937
    <div class="row" id="row-edit" style="display: none">
1519
    <div class="row" id="row-edit" style="display: none">
938
        <div class="col-xs-12 col-md-12">
1520
        <div class="col-xs-12 col-md-12">
-
 
1521
            <form action="#" name="form-main" id="form-main">
-
 
1522
                <input type="hidden" name="form-id" id="form-id" value="0" />
-
 
1523
                <input type="hidden" name="form-continue" id="form-continue" value="0" />
-
 
1524
                <div class="form-group">
-
 
1525
                    <label for="form-name">LABEL_FIRST_NAME</label>
-
 
1526
                    <input type="text" name="form-name" id="form-name" class="form-control" maxlength="50" />
939
            <form action="#" name="form-main" id="form-main">
-
 
-
 
1527
                </div>
-
 
1528
                <div class="form-group">
-
 
1529
                    <label for="form-description">LABEL_DESCRIPTION</label>
-
 
1530
                    <!--  ckeditor -->
-
 
1531
                    <textarea  name="form-description" id="form-description" rows="5" class="ckeditor form-control"></textarea>
-
 
1532
                </div>
-
 
1533
                <div class="form-group">
-
 
1534
                    <label for="form-text">LABEL_TEXT</label>
-
 
1535
                    <!--  ckeditor -->
-
 
1536
                    <textarea  name="form-text" id="form-text" rows="5" class="ckeditor form-control"></textarea>
-
 
1537
                </div>
-
 
1538
                <div class="form-group">
-
 
1539
                    <label for="form-language">LABEL_LANGUAGES</label>
-
 
1540
                    <select name="form-language" id="form-language" class="form-control">
-
 
1541
                        <option value="<?php echo $lang_en; ?>">LABEL_ENGLISH</option>
-
 
1542
                        <option value="<?php echo $lang_es; ?>">LABEL_SPANISH</option>
-
 
1543
                    </select>
-
 
1544
                </div>
-
 
1545
                <div class="form-group">
-
 
1546
                    <label for="form-status">LABEL_STATUS</label>
-
 
1547
                    <select name="form-status" id="form-status" class="form-control">
-
 
1548
                        <option value="<?php echo $status_inactive; ?>">LABEL_INACTIVE</option>
-
 
1549
                        <option value="<?php echo $status_active; ?>">LABEL_ACTIVE</option>
-
 
1550
                    </select>
-
 
1551
                </div>
-
 
1552
                <br/>
-
 
1553
                <div class="row">
-
 
1554
                    <div class="col-xs-12 col-md-12 text-right">
-
 
1555
                        <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>
-
 
1556
                    </div>
-
 
1557
                </div>
-
 
1558
                <br />	
-
 
1559
                <div class="row">
-
 
1560
                    <div class="col-xs-12 col-md-12">
-
 
1561
                        <div class="panel-group" id="rows"></div>
-
 
1562
                    </div>
940
                
1563
                </div>
941
                <div class="form-group">
1564
                <div class="form-group">
942
                    <button type="submit" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
1565
                    <button type="submit" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
943
                    <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
1566
                    <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
944
                    <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
1567
                    <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
945
                </div>
1568
                </div>
946
            </form>
1569
            </form>
947
        </div>
1570
        </div>
Línea -... Línea 1571...
-
 
1571
    </div>
-
 
1572
 
-
 
1573
    <!-- Create/Edit Form-->
-
 
1574
 
-
 
1575
    <!-- Section Modal -->
-
 
1576
    <div  id="modal-section" class="modal" tabindex="-1" role="dialog">
-
 
1577
        <div class="modal-dialog modal-lg" role="document">
-
 
1578
            <form action="#" name="form-section" id="form-section">
-
 
1579
                <input type="hidden" name="section-slug" id="section-slug" value="" />
-
 
1580
                <div class="modal-content">
-
 
1581
                    <div class="modal-header">
-
 
1582
                        <h4 class="modal-title">LABEL_ADD LABEL_SECTION</h4>
-
 
1583
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
-
 
1584
                            <span aria-hidden="true">&times;</span>
-
 
1585
                        </button>
-
 
1586
                    </div>
-
 
1587
                    <div class="modal-body">
-
 
1588
                        <div class="form-group">
-
 
1589
                            <label for="section-name">LABEL_FIRST_NAME</label>
-
 
1590
                            <input type="text" name="section-name" id="section-name" class="form-control" maxlength="50" value="" />
-
 
1591
                        </div>
-
 
1592
                        <div class="form-group">
-
 
1593
                            <label for="section-text">LABEL_TEXT</label>
-
 
1594
                            <!--  ckeditor -->
-
 
1595
                            <textarea  name="section-text" id="section-text" rows="5" class="ckeditor form-control"></textarea>
-
 
1596
                        </div>
-
 
1597
                        <div class="form-group">
-
 
1598
                            <label for="section-value">LABEL_VALUE</label>
-
 
1599
                            <input type="text" name="section-value" id="section-value"  class="form-control" value="0" />
-
 
1600
                        </div>
-
 
1601
                    </div>
-
 
1602
                    <div class="modal-footer">
-
 
1603
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
-
 
1604
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
-
 
1605
                    </div>
-
 
1606
                </div>
-
 
1607
            </form>
-
 
1608
        </div>
-
 
1609
    </div>
-
 
1610
    <!-- End Modal Section -->
-
 
1611
 
-
 
1612
    <!-- Question Modal -->
-
 
1613
 
-
 
1614
    <div  id="modal-question" class="modal" tabindex="-1" role="dialog">
-
 
1615
        <div class="modal-dialog modal-lg" role="document">
-
 
1616
            <form action="#" name="form-question" id="form-question">
-
 
1617
                <input type="hidden" name="question-section" id="question-section" />
-
 
1618
                <input type="hidden" name="question-slug" id="question-slug" />
-
 
1619
                <div class="modal-content">
-
 
1620
                    <div class="modal-header">
-
 
1621
                        <h4 class="modal-title">LABEL_ADD LABEL_QUESTION</h4>
-
 
1622
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
-
 
1623
                            <span aria-hidden="true">&times;</span>
-
 
1624
                        </button>
-
 
1625
                    </div>
-
 
1626
                    <div class="modal-body">
-
 
1627
                        <div class="form-group">
-
 
1628
                            <label for="question-text">LABEL_TEXT</label>
-
 
1629
                            <!--  ckeditor -->
-
 
1630
                            <textarea  name="question-text" id="question-text" rows="5" class="ckeditor form-control"></textarea>
-
 
1631
                        </div>
-
 
1632
                        <div class="form-group">
-
 
1633
                            <label for="question-value">LABEL_VALUE</label>
-
 
1634
                            <input type="text" name="question-value" id="question-value"  class="form-control" />
-
 
1635
                        </div>
-
 
1636
                        <div class="form-group">
-
 
1637
                            <label for="question-type">LABEL_TYPE</label>
-
 
1638
                            <select name="question-type" id="question-type" class="form-control">
-
 
1639
                                <option value="open">LABEL_OPEN</option>
-
 
1640
                                <option value="simple">Simple</option>
-
 
1641
                                <option value="multiple">Multiple</option>
-
 
1642
                                <option value="rating-open">LABEL_RATING_OPEN</option>
-
 
1643
                                <option value="rating-range">LABEL_RATING_RANGE</option>
-
 
1644
                            </select>
-
 
1645
                        </div>
-
 
1646
                        <div class="form-group">
-
 
1647
                            <label for="question-max-length">LABEL_MAXLENGTH</label>
-
 
1648
                            <input type="text" name="question-max-length" id="question-max-length"  class="form-control" />
-
 
1649
                        </div>
-
 
1650
                        <div class="form-group">
-
 
1651
                            <label for="question-multiline">LABEL_MULTI_LINE</label>
-
 
1652
                            <select name="question-multiline" id="question-multiline" class="form-control">
-
 
1653
                                <option value="1">LABEL_YES</option>
-
 
1654
                                <option value="0">LABEL_NOT</option>
-
 
1655
                            </select>
-
 
1656
                        </div>
-
 
1657
                        <div class="form-group">
-
 
1658
                            <label for="question-range">LABEL_RANGE</label>
-
 
1659
                            <select name="question-range" id="question-range" class="form-control">
-
 
1660
                                <option value="10">1-10</option>
-
 
1661
                                <option value="6">1-6</option>
-
 
1662
                                <option value="5">1-5</option>
-
 
1663
                            </select>
-
 
1664
                        </div>
-
 
1665
                    </div>
-
 
1666
                    <div class="modal-footer">
-
 
1667
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
-
 
1668
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
-
 
1669
                    </div>
-
 
1670
                </div>
-
 
1671
            </form>
-
 
1672
        </div>
-
 
1673
    </div>
-
 
1674
 
-
 
1675
    <!-- End Modal Question -->
-
 
1676
 
-
 
1677
    <!-- Modal Options -->
-
 
1678
 
-
 
1679
    <div  id="modal-option" class="modal" tabindex="-1" role="dialog">
-
 
1680
        <div class="modal-dialog modal-lg" role="document">
-
 
1681
            <form action="#" name="form-option" id="form-option">
-
 
1682
                <input type="hidden" name="option-section" id="option-section" value="" />
-
 
1683
                <input type="hidden" name="option-question" id="option-question" value="" />
-
 
1684
                <input type="hidden" name="option-slug" id="option-slug" value="" />
-
 
1685
                <div class="modal-content">
-
 
1686
                    <div class="modal-header">
-
 
1687
                        <h4 class="modal-title">LABEL_OPTION</h4>
-
 
1688
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
-
 
1689
                            <span aria-hidden="true">&times;</span>
-
 
1690
                        </button>
-
 
1691
                    </div>
-
 
1692
                    <div class="modal-body">
-
 
1693
                        <div class="form-group">
-
 
1694
                            <label for="option-text">LABEL_TEXT</label>
-
 
1695
                            <!--  ckeditor -->
-
 
1696
                            <textarea  name="option-text" id="option-text" rows="5" class="ckeditor form-control"></textarea>
-
 
1697
                        </div>
-
 
1698
                        <div class="form-group">
-
 
1699
                            <label for="option-correct">LABEL_ANSWER_CORRECT</label>
-
 
1700
                            <select name="option-correct" id="option-correct" class="form-control">
-
 
1701
                                <option value="1">LABEL_YES</option>
-
 
1702
                                <option value="0">LABEL_NOT</option>
-
 
1703
                            </select>
-
 
1704
                        </div>
-
 
1705
                        <div class="form-group">
-
 
1706
                            <label for="option-value">LABEL_VALUE</label>
-
 
1707
                            <input type="text" name="option-value" id="option-value" class="form-control" />
-
 
1708
                        </div>
-
 
1709
                    </div>
-
 
1710
                    <div class="modal-footer">
-
 
1711
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
-
 
1712
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
-
 
1713
                    </div>
-
 
1714
                </div>
-
 
1715
            </form>
948
    </div>
1716
        </div>
-
 
1717
    </div>
Línea 949... Línea 1718...
949
 
1718
 
950
  
1719
    <!-- End Modal Options -->
951
 
1720
 
952
    <!---Template Sections --->
1721
    <!---Template Sections --->