You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
4.4 KiB
1 line
4.4 KiB
window.BackendSettings=window.BackendSettings||{},function(n){"use strict";n.SETTINGS_SYSTEM="SETTINGS_SYSTEM",n.SETTINGS_USER="SETTINGS_USER",n.wp={};var s={};n.initialize=function(e){e=e||!0,$("#cookie-notice-content, #terms-and-conditions-content, #privacy-policy-content").trumbowyg();var a={};GlobalVariables.settings.system.forEach(function(e){$('input[data-field="'+e.name+'"]').val(e.value),$('select[data-field="'+e.name+'"]').val(e.value),"company_working_plan"===e.name&&(a=$.parseJSON(e.value)),"customer_notifications"===e.name&&$("#customer-notifications").prop("checked",Boolean(Number(e.value))),"require_captcha"===e.name&&$("#require-captcha").prop("checked",Boolean(Number(e.value))),"require_phone_number"===e.name&&$("#require-phone-number").prop("checked",Boolean(Number(e.value))),"display_any_provider"===e.name&&$("#display-any-provider").prop("checked",Boolean(Number(e.value))),"display_cookie_notice"===e.name&&$("#display-cookie-notice").prop("checked",Boolean(Number(e.value))),"cookie_notice_content"===e.name&&$("#cookie-notice-content").trumbowyg("html",e.value),"display_terms_and_conditions"===e.name&&$("#display-terms-and-conditions").prop("checked",Boolean(Number(e.value))),"terms_and_conditions_content"===e.name&&$("#terms-and-conditions-content").trumbowyg("html",e.value),"display_privacy_policy"===e.name&&$("#display-privacy-policy").prop("checked",Boolean(Number(e.value))),"privacy_policy_content"===e.name&&$("#privacy-policy-content").trumbowyg("html",e.value)}),n.wp=new WorkingPlan,n.wp.setup(a),n.wp.timepickers(!1),$("#user-id").val(GlobalVariables.settings.user.id),$("#first-name").val(GlobalVariables.settings.user.first_name),$("#last-name").val(GlobalVariables.settings.user.last_name),$("#email").val(GlobalVariables.settings.user.email),$("#mobile-number").val(GlobalVariables.settings.user.mobile_number),$("#phone-number").val(GlobalVariables.settings.user.phone_number),$("#address").val(GlobalVariables.settings.user.address),$("#city").val(GlobalVariables.settings.user.city),$("#state").val(GlobalVariables.settings.user.state),$("#zip-code").val(GlobalVariables.settings.user.zip_code),$("#notes").val(GlobalVariables.settings.user.notes),$("#timezone").val(GlobalVariables.settings.user.timezone),$("#username").val(GlobalVariables.settings.user.settings.username),$("#password, #retype-password").val(""),$("#calendar-view").val(GlobalVariables.settings.user.settings.calendar_view),$("#user-notifications").prop("checked",Boolean(Number(GlobalVariables.settings.user.settings.notifications))),s=new SystemSettings,e&&(n.wp.bindEventHandlers(),$('a[data-toggle="tab"]').on("shown.bs.tab",function(){var e=$(this).attr("href");"#general"===e||"#business-logic"===e||"#legal-contents"===e?s=new SystemSettings:"#current-user"===e&&(s=new UserSettings),Backend.placeFooterToBottom()}),$(".save-settings").on("click",function(){var e=s.get();s.save(e)}),$("#username").focusout(function(){var e,a,n=$(this);!0!==n.prop("readonly")&&""!==n.val()&&(e=GlobalVariables.baseUrl+"/index.php/backend_api/ajax_validate_username",a={csrfToken:GlobalVariables.csrfToken,username:n.val(),user_id:n.parents().eq(2).find("#user-id").val()},$.post(e,a).done(function(e){"false"===e?(n.closest(".form-group").addClass("has-error"),Backend.displayNotification(EALang.username_already_exists),n.attr("already-exists","true")):(n.closest(".form-group").removeClass("has-error"),n.attr("already-exists","false"))}))}),$("#apply-global-working-plan").on("click",function(){var e=[{text:EALang.cancel,click:function(){$("#message-box").dialog("close")}},{text:"OK",click:function(){var e=GlobalVariables.baseUrl+"/index.php/backend_api/ajax_apply_global_working_plan",a={csrfToken:GlobalVariables.csrfToken,working_plan:JSON.stringify(n.wp.get())};$.post(e,a).done(function(){Backend.displayNotification(EALang.working_plans_got_updated)}).always(function(){$("#message-box").dialog("close")})}}];GeneralFunctions.displayMessageBox(EALang.working_plan,EALang.overwrite_existing_working_plans,e)}),$("#settings-page .nav li").not(".d-none").first().find("a").tab("show")),!1===GlobalVariables.user.privileges.system_settings.edit&&($("#general, #business-logic").find("select, input, textarea").prop("readonly",!0),$("#general, #business-logic").find("button").prop("disabled",!0)),!1===GlobalVariables.user.privileges.user_settings.edit&&($("#user").find("select, input, textarea").prop("readonly",!0),$("#user").find("button").prop("disabled",!0)),Backend.placeFooterToBottom()}}(window.BackendSettings); |