2016-06-27 01:45:38 +02:00
var isEnddateSet ;
2018-02-02 14:43:40 +01:00
var numberOfDocumentationTypes ;
2018-10-10 16:43:11 +02:00
var canvasWidth ;
2018-02-07 14:14:08 +01:00
$ ( document ) . ready ( function ( ) {
2018-11-24 14:28:46 -04:00
startBeWoMobile ( ) ;
} ) ;
function startBeWoMobile ( ) {
if ( ! $ ( "#zeiterfassung" ) . length ) {
2016-06-27 01:45:38 +02:00
return ;
}
2018-03-12 12:07:53 +01:00
toggleErrorPopup2 ( "errorPopupDiv2" ) ;
2016-06-27 01:45:38 +02:00
2017-04-26 14:57:32 +02:00
$ ( "#leistungen_select,#kategorien_select,#recordLoader_select,#textbausteine_select" ) . prop ( "disabled" , false ) ;
2018-04-18 14:33:21 +02:00
2016-06-27 01:45:38 +02:00
toggleSelectClassesForElement ( "#kategorien_select" , "#kategorien-select-container" ) ;
toggleSelectClassesForElement ( "#leistungen_select" , "#leistungen-select-container" ) ;
toggleSelectClassesForElement ( "#recordLoader_select" , "#record-loader-select-container" ) ;
2017-04-26 14:57:32 +02:00
toggleSelectClassesForElement ( "#textbausteine_select" , "#textbausteine-select-container" ) ;
2016-06-27 01:45:38 +02:00
2017-04-26 14:57:32 +02:00
initializeDocumentationTextareas ( ) ;
2016-06-27 01:45:38 +02:00
checkEndDate ( ) ;
initBeWoMobile ( loadGoalsUrl ) ;
2018-06-29 16:35:19 +02:00
var height = $ ( "#datum_textbox" ) . css ( "height" ) ;
2016-06-27 01:45:38 +02:00
2018-02-02 14:43:40 +01:00
$ ( ".dropdownlist-for" ) . css ( "height" , height ) ;
2016-06-27 01:45:38 +02:00
2018-02-02 14:43:40 +01:00
$ ( "#statistik-button" ) . css ( "height" , height ) ;
$ ( "#statistik-button" ) . css ( "width" , height ) ;
2016-06-27 01:45:38 +02:00
2018-02-02 14:43:40 +01:00
$ ( "#statistik-button-td" ) . css ( "width" , height ) ;
2018-03-12 12:07:53 +01:00
$ ( ".gruppenbuchungsCheckboxContainer" ) . css ( "width" , height ) ;
2016-06-27 01:45:38 +02:00
2018-02-07 14:14:08 +01:00
//if(localStorage.getItem("Zeitdaten") != null || localStorage.getItem("Kalenderdaten") != null) {
// console.log("a service record has been found in the local storage");
// if($("#ErrorZeiterfassungAfterCrashSchalter").value == 1 ||
// $("#ErrorZeiterfassungAfterCrashSchalter").value == null ||
// $("#ErrorZeiterfassungAfterCrashSchalter").value == 0) {
// console.log("loading service records...");
2017-02-01 13:53:59 +01:00
// LoadOnly(1, 2);
2018-02-07 14:14:08 +01:00
// clearLocalStorage(1);
// clearLocalStorage(2);
2017-02-01 13:53:59 +01:00
// } else {
2018-02-07 14:14:08 +01:00
// showErrorAfterCrash();
// console.log("an error occurred")
2018-06-22 20:25:13 +02:00
// }
2017-02-01 13:53:59 +01:00
//} else {
// console.log("Ich bin hier drinne weil Storage nicht vorhanden");
//}
2018-06-22 20:25:13 +02:00
2016-06-27 01:45:38 +02:00
ErfolgteSpx ( ) ;
2018-06-22 20:25:13 +02:00
2018-11-24 14:28:46 -04:00
var count = 0 ;
if ( typeof vm !== 'undefined' ) {
count = vm . vorname . getSubscriptionsCount ( ) ;
}
2016-06-27 01:45:38 +02:00
vm = new KlientenVM ( ) ;
2018-11-24 14:28:46 -04:00
if ( count === 0 ) {
ko . applyBindings ( vm ) ;
}
2016-06-27 01:45:38 +02:00
2018-10-10 16:43:11 +02:00
var documentWidth = $ ( document ) . width ( ) ;
canvasWidth = documentWidth * scaleFactor ;
$ ( "#sketchpad" ) . prop ( "width" , canvasWidth ) ;
2018-11-24 14:28:46 -04:00
2018-06-22 20:25:13 +02:00
loadSettingsAccordingToBWP ( ) ;
2018-11-24 14:28:46 -04:00
}
2016-06-27 01:45:38 +02:00
2018-10-10 16:43:11 +02:00
var scaleFactor = . 8 ;
$ ( window ) . resize ( function ( ) {
var documentWidth = $ ( document ) . width ( ) ;
if ( canvasWidth !== ( documentWidth * scaleFactor ) && $ ( "#sketchpad" ) . css ( "display" ) === "inline" ) {
$ ( "#sketchpad" ) . prop ( "width" , documentWidth * scaleFactor ) ;
}
} ) ;
2016-06-27 01:45:38 +02:00
function initBeWoMobile ( actionPath ) {
try {
2017-04-26 14:57:32 +02:00
$ ( "#recordLoader_select, #kategorien_select, #leistungen_select, #textbausteine_select" ) . prop ( "disabled" , true ) ;
2016-06-27 01:45:38 +02:00
toggleSelectClassesForElement ( "#kategorien_select" , "#kategorien-select-container" ) ;
toggleSelectClassesForElement ( "#leistungen_select" , "#leistungen-select-container" ) ;
toggleSelectClassesForElement ( "#recordLoader_select" , "#record-loader-select-container" ) ;
2017-04-26 14:57:32 +02:00
toggleSelectClassesForElement ( "#textbausteine_select" , "#textbausteine-select-container" ) ;
2016-06-27 01:45:38 +02:00
2018-12-10 23:40:38 -04:00
var selectedServiceCategory = $ ( "#scDropDown" ) . find ( ":selected" ) . val ( )
2016-06-27 01:45:38 +02:00
2018-05-22 17:19:56 +02:00
if ( isInGroupBookingMode ( ) && isInEditingMode ( ) ) {
if ( getGroupEditingFlag ( ) . flag === false ) {
loadSavedValuesIntoForm ( ) ;
} else {
saveFormValuesLocally ( ) ;
}
setGroupEditingFlag ( false ) ;
}
2018-06-22 20:25:13 +02:00
2018-11-24 14:28:46 -04:00
var shouldActivateForm = isInGroupBookingMode ( ) ? $ ( "#leftContent input:checked" ) . length > 0 : selectedServiceCategory !== "-1" ;
2016-06-27 01:45:38 +02:00
2018-04-18 14:33:21 +02:00
if ( shouldActivateForm ) {
$ ( "#recordLoader_select" ) . prop ( "disabled" , false ) ;
2018-06-22 20:25:13 +02:00
2018-05-22 17:19:56 +02:00
activateForm ( actionPath ) ;
2016-06-27 01:45:38 +02:00
2018-04-18 14:33:21 +02:00
if ( ! isInEditingMode ( ) ) {
$ ( "#datum_textbox" ) . val ( getDateStringWithLeadingZeros ( new Date ( ) ) ) ;
}
2016-06-27 01:45:38 +02:00
}
2018-06-22 20:25:13 +02:00
$ ( ".not-required-input" ) . on ( "click blur change focus" ,
2018-01-31 17:52:28 +01:00
function ( ) {
2018-06-29 16:35:19 +02:00
var v = $ ( this ) . attr ( "id" ) ;
2018-01-31 17:52:28 +01:00
setTimeout ( function ( ) { toggleLabel ( v ) ; } , 1 ) ;
2016-06-27 01:45:38 +02:00
}
) ;
2018-04-18 14:33:21 +02:00
$ ( "#start_textbox" ) . on ( "blur" , function ( ) {
2018-06-29 16:35:19 +02:00
var startHasValue = $ ( "#start_textbox" ) . val ( ) !== "" ;
var endHasValue = $ ( "#ende_textbox" ) . val ( ) !== "" ;
var durationHasValue = $ ( "#duration_textbox" ) . val ( ) !== "" ;
2016-06-27 01:45:38 +02:00
2018-01-31 17:52:28 +01:00
if ( startHasValue && endHasValue ) {
2016-06-27 01:45:38 +02:00
calcDurationByStartEnd ( ) ;
2018-01-31 17:52:28 +01:00
} else if ( startHasValue && durationHasValue ) {
2016-06-27 01:45:38 +02:00
calcEndByStartDuration ( ) ;
}
} ) ;
$ ( "#ende_textbox" ) . on ( "blur" , function ( ) {
2018-06-29 16:35:19 +02:00
var startHasValue = $ ( "#start_textbox" ) . val ( ) !== "" ;
var endHasValue = $ ( "#ende_textbox" ) . val ( ) !== "" ;
var durationHasValue = $ ( "#duration_textbox" ) . val ( ) !== "" ;
2016-06-27 01:45:38 +02:00
2018-04-18 14:33:21 +02:00
if ( endHasValue && startHasValue ) {
2016-06-27 01:45:38 +02:00
calcDurationByStartEnd ( ) ;
2018-04-18 14:33:21 +02:00
} else if ( endHasValue && durationHasValue ) {
2016-06-27 01:45:38 +02:00
calcStartByEndDuration ( ) ;
}
} ) ;
$ ( "#duration_textbox" ) . on ( "blur" , function ( ) {
2018-06-29 16:35:19 +02:00
var startHasValue = $ ( "#start_textbox" ) . val ( ) !== "" ;
var endHasValue = $ ( "#ende_textbox" ) . val ( ) !== "" ;
var durationHasValue = $ ( "#duration_textbox" ) . val ( ) !== "" ;
2016-06-27 01:45:38 +02:00
clearZED ( ) ;
2018-04-18 14:33:21 +02:00
if ( durationHasValue && startHasValue ) {
2016-06-27 01:45:38 +02:00
calcEndByStartDuration ( ) ;
} else if ( durationHasValue && endHasValue ) {
calcStartByEndDuration ( ) ;
}
} ) ;
2018-04-18 14:33:21 +02:00
2018-11-24 14:28:46 -04:00
var supportConceptTableHasEntries = $ ( "#leftContent input:checked" ) . length ;
2018-12-10 23:40:38 -04:00
var employeesTableHasEntries = $ ( "#employeeCollapsible input:checked" ) . length ;
2018-04-18 14:33:21 +02:00
2018-11-24 14:28:46 -04:00
if ( isInGroupBookingMode ( ) ) {
2018-12-10 23:40:38 -04:00
var value = supportConceptTableHasEntries > 0 && employeesTableHasEntries > 0 ? false : true ;
2018-11-26 13:27:16 -04:00
$ ( "#anlegenEditierenBtn" ) . prop ( "disabled" , value ) ;
2018-04-18 14:33:21 +02:00
}
} catch ( err ) {
2018-06-22 20:25:13 +02:00
console . log ( 'Fehler: ' + err . message ) ;
2016-06-27 01:45:38 +02:00
}
}
function toggleSelectClassesForElement ( elementIdentifier , parentElement ) {
2018-06-29 16:35:19 +02:00
var enabled = $ ( elementIdentifier ) . prop ( "disabled" ) === "false" ;
2018-06-22 20:25:13 +02:00
2018-04-18 14:33:21 +02:00
if ( enabled ) {
2016-06-27 01:45:38 +02:00
$ ( parentElement ) . removeClass ( "disabled-select-container" ) ;
$ ( parentElement ) . addClass ( "styled-select-div" ) ;
} else {
$ ( parentElement ) . removeClass ( "styled-select-div" ) ;
$ ( parentElement ) . addClass ( "disabled-select-container" ) ;
}
}
function toggleErrorPopup2 ( errorMessage ) {
2018-06-29 16:35:19 +02:00
var isDisplayNone = $ ( "#errorPopupDiv2" ) . css ( "display" ) === "none" ;
var displayValue = isDisplayNone ? "block" : "none" ;
2016-06-27 01:45:38 +02:00
$ ( "#errorPopupDiv2" ) . css ( "display" , displayValue ) ;
$ ( ".modalWrapper" ) . css ( "display" , displayValue ) ;
$ ( ".modalWrapper" ) . css ( "height" , $ ( document ) . height ( ) ) ;
2018-03-12 12:07:53 +01:00
if ( isDisplayNone ) {
2016-06-27 01:45:38 +02:00
$ ( "#errorPopupText2" ) . text ( errorMessage ) ;
2018-06-29 16:35:19 +02:00
var h = 0 ;
var t = $ ( "#errorPopupTitle2" ) . outerHeight ( ) ;
var u = $ ( "#errorPopupText2" ) . outerHeight ( ) ;
var v = $ ( "#errorPopupBtnDiv2" ) . outerHeight ( ) ;
var w = $ ( "#errorPopupOkBtn2" ) . outerHeight ( ) ;
2016-06-27 01:45:38 +02:00
h += t + u + v + w + w ;
$ ( "#errorPopupDiv2" ) . css ( "height" , h + "px" ) ;
$ ( "#errorPopupDiv2" ) . css ( "top" , window . pageYOffset + window . innerHeight / 2 - h / 2 ) ;
$ ( "#errorPopupDiv2" ) . css ( "margin-top" , "0" ) ;
} else {
$ ( "#errorPopupDiv2" ) . css ( "margin-top" , "auto" ) ;
}
}
function logoutSettingsAccordingToBWP ( timeoutTime ) {
2018-04-18 14:33:21 +02:00
if ( timeoutTime > 0 ) {
2016-06-27 01:45:38 +02:00
timeoutTime = timeoutTime * 1000 * 60 ;
clearTimeout ( ) ;
setTimeout ( function ( ) {
$ . ajax ( {
type : "POST" ,
url : LogoutUrl ,
success : function ( ) {
writeFatalErrorMessage ( "Ihre Sitzung ist abgelaufen." ) ;
setTimeout ( function ( ) {
location . reload ( ) ;
} , 3000 ) ;
} ,
error : function ( ) { }
} ) ;
} , timeoutTime ) ;
}
}
2018-01-29 12:57:10 +01:00
var timeoutSetting ;
2016-06-27 01:45:38 +02:00
function loadSettingsAccordingToBWP ( ) {
$ . ajax ( {
type : "GET" ,
url : LoadSessionSettingsFromBWPUrl ,
success : function ( json ) {
2018-06-29 16:35:19 +02:00
var timeOutSettingsString = $ . parseJSON ( json ) ;
2018-01-31 17:52:28 +01:00
timeoutSetting = parseInt ( timeOutSettingsString ) ;
2018-01-29 12:57:10 +01:00
logoutSettingsAccordingToBWP ( timeoutSetting ) ;
2016-06-27 01:45:38 +02:00
}
} ) ;
}
2017-04-26 14:57:32 +02:00
function initializeDocumentationTextareas ( ) {
2018-12-10 23:40:38 -04:00
makeAjaxCall (
"GET" ,
CheckDokuReiterUrl ,
function ( json ) {
var dokuTypes = $ . parseJSON ( json ) ;
numberOfDocumentationTypes = dokuTypes . length ;
2016-06-27 01:45:38 +02:00
2018-12-10 23:40:38 -04:00
var tabWidth = 100 / numberOfDocumentationTypes ;
$ ( ".doku-tab-link" ) . css ( "width" , tabWidth + "%" ) ;
if ( numberOfDocumentationTypes === 0 ) {
2017-04-26 14:57:32 +02:00
$ ( "#tddokureiter" ) . css ( "display" , "none" ) ;
$ ( "#trnormalDoku" ) . css ( "display" , "table-row" ) ;
2018-01-31 17:52:28 +01:00
window . focusedDokuTextarea = $ ( "#notiz_textbox" ) ;
2017-04-26 14:57:32 +02:00
} else {
2018-01-31 17:52:28 +01:00
window . focusedDokuTextarea = $ ( "#notiz_textbox1" ) ;
2016-06-27 01:45:38 +02:00
}
2016-09-21 14:28:04 +02:00
2018-12-10 23:40:38 -04:00
if ( numberOfDocumentationTypes === 1 ) {
2017-04-26 14:57:32 +02:00
$ ( "#tddokureiter" ) . css ( "display" , "none" ) ;
$ ( "#trnormalDoku" ) . css ( "display" , "table-row" ) ;
2018-12-10 23:40:38 -04:00
$ ( "#trnormalDokuLabel" ) . text ( dokuTypes [ 0 ] . TypeDescription ) ;
2016-06-27 01:45:38 +02:00
}
2017-04-26 14:57:32 +02:00
2018-12-10 23:40:38 -04:00
if ( numberOfDocumentationTypes > 1 ) {
var height = 0 ;
for ( var i = 0 ; i < numberOfDocumentationTypes ; i ++ ) {
2018-06-29 16:35:19 +02:00
var idNumber = i + 1 ;
2017-04-26 14:57:32 +02:00
2018-12-10 23:40:38 -04:00
var dokuTab = $ ( "#doku-name-" + idNumber ) ;
dokuTab . html ( dokuTypes [ i ] . TypeDescription ) ;
2018-12-12 14:27:40 -04:00
dokuTab . show ( ) ;
2018-12-10 23:40:38 -04:00
var outerHeight = dokuTab . outerHeight ( ) ;
if ( outerHeight > height ) {
height = outerHeight ;
}
2018-01-31 17:52:28 +01:00
}
2018-12-10 23:40:38 -04:00
$ ( ".doku-tab-link" ) . css ( "height" , height + "px" ) ;
2016-06-27 01:45:38 +02:00
}
2017-02-01 13:53:59 +01:00
2018-12-10 23:40:38 -04:00
if ( numberOfDocumentationTypes > 0 ) {
focusOnDoku ( 1 ) ;
2017-02-01 13:53:59 +01:00
}
2018-12-10 23:40:38 -04:00
} ,
null ,
null
) ;
2018-05-22 17:19:56 +02:00
}
2018-12-10 23:40:38 -04:00
// Formulardaten im Browser speichern, um nach einem erneuten Laden der Seite (z.B. beim Hinzufügen von Hilfeplänen bzw. Gruppen oder Mitarbeitern) die Daten wiederherzustellen.
2018-05-22 17:19:56 +02:00
var savedEditFormValues = { } ;
$ ( document ) . on ( "change" , ".edit-form-input" ,
function ( ) {
saveFormValuesLocally ( ) ;
} ) ;
function saveFormValuesLocally ( ) {
2018-06-29 16:35:19 +02:00
var recordObject = {
2018-05-22 17:19:56 +02:00
category : $ ( "#kategorien_select" ) . val ( ) ,
serviceDescription : $ ( "#leistungen_select" ) . val ( ) ,
startDate : $ ( "#datum_textbox" ) . val ( ) ,
endDate : $ ( "#enddatum_textbox" ) . val ( ) ,
startTime : $ ( "#start_textbox" ) . val ( ) ,
endTime : $ ( "#ende_textbox" ) . val ( ) ,
duration : $ ( "#duration_textbox" ) . val ( ) ,
distance : $ ( "#distance_textbox" ) . val ( ) ,
notice : $ ( "#notiz_textbox" ) . val ( ) ,
notice2 : $ ( "#notiz_textbox2" ) . val ( ) ,
notice3 : $ ( "#notiz_textbox3" ) . val ( ) ,
notice4 : $ ( "#notiz_textbox4" ) . val ( ) ,
notice5 : $ ( "#notiz_textbox5" ) . val ( )
} ;
savedEditFormValues . obj = recordObject ;
localStorage . savedEditFormValues = JSON . stringify ( savedEditFormValues ) ;
}
function deleteSavedEditFormValues ( ) {
localStorage . savedEditFormValues = undefined ;
savedEditFormValues = undefined ;
}
function loadSavedEditFormValues ( ) {
2018-06-29 16:35:19 +02:00
var storageData = localStorage . savedEditFormValues ;
2018-05-22 17:19:56 +02:00
if ( storageData !== "undefined" ) {
savedEditFormValues = JSON . parse ( storageData ) ;
} else {
savedEditFormValues = { } ;
}
2018-06-22 20:25:13 +02:00
2018-05-22 17:19:56 +02:00
return savedEditFormValues . obj ;
}
function loadSavedValuesIntoForm ( ) {
2018-06-29 16:35:19 +02:00
var values = loadSavedEditFormValues ( ) ;
2018-05-22 17:19:56 +02:00
if ( values . category !== "undefined" ) {
$ ( "#kategorien_select" ) . val ( values . category ) ;
}
2018-06-22 20:25:13 +02:00
2018-05-22 17:19:56 +02:00
if ( values . serviceDescription !== "undefined" ) {
$ ( "#leistungen_select" ) . val ( values . serviceDescription ) ;
}
if ( values . startDate !== "undefined" ) {
$ ( "#datum_textbox" ) . val ( values . startDate ) ;
}
if ( values . endDate !== "undefined" ) {
$ ( "#enddatum_textbox" ) . val ( values . endDate ) ;
}
if ( values . startTime !== "undefined" ) {
$ ( "#start_textbox" ) . val ( values . startTime ) ;
}
if ( values . endTime !== "undefined" ) {
$ ( "#ende_textbox" ) . val ( values . endTime ) ;
}
if ( values . duration !== "undefined" ) {
$ ( "#duration_textbox" ) . val ( values . duration ) ;
}
if ( values . distance !== "undefined" ) {
$ ( "#distance_textbox" ) . val ( values . distance ) ;
}
if ( values . notice !== "undefined" ) {
$ ( "#notiz_textbox" ) . val ( values . notice ) ;
}
if ( values . notice1 !== "undefined" ) {
$ ( "#notiz_textbox1" ) . val ( values . notice ) ;
}
if ( values . notice2 !== "undefined" ) {
$ ( "#notiz_textbox2" ) . val ( values . notice2 ) ;
}
if ( values . notice3 !== "undefined" ) {
$ ( "#notiz_textbox3" ) . val ( values . notice3 ) ;
}
if ( values . notice4 !== "undefined" ) {
$ ( "#notiz_textbox4" ) . val ( values . notice4 ) ;
}
if ( values . notice5 !== "undefined" ) {
$ ( "#notiz_textbox5" ) . val ( values . notice5 ) ;
}
2018-06-22 20:25:13 +02:00
}