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 ;
}
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 ;
2018-12-17 18:32:32 -04:00
if ( typeof vm !== "undefined" ) {
2018-11-24 14:28:46 -04:00
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
2019-04-30 19:29:17 +02:00
var width = $ ( "body" ) . width ( ) ;
canvasWidth = width * scaleFactor ;
2018-10-10 16:43:11 +02:00
$ ( "#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
2019-04-30 19:29:17 +02:00
var scaleFactor = . 95 ;
2018-10-10 16:43:11 +02:00
$ ( window ) . resize ( function ( ) {
2019-04-30 19:29:17 +02:00
var bodyWidth = $ ( "body" ) . width ( ) ;
2018-10-10 16:43:11 +02:00
2019-04-30 19:29:17 +02:00
if ( $ ( "#sketchpad" ) . css ( "display" ) === "inline" ) {
$ ( "#sketchpad" ) . prop ( "width" , bodyWidth * scaleFactor ) ;
2018-10-10 16:43:11 +02:00
}
} ) ;
2016-06-27 01:45:38 +02:00
function initBeWoMobile ( actionPath ) {
try {
2018-12-17 18:32:32 -04:00
var selectedServiceCategory = $ ( "#scDropDown" ) . find ( ":selected" ) . val ( ) ;
2019-03-29 14:04:12 +01:00
var shouldLoadServiceDescriptions = true ;
2016-06-27 01:45:38 +02:00
2019-03-29 14:04:12 +01:00
if ( isInGroupBookingMode ( ) && isInEditingMode ( ) ) {
if ( getGroupEditingFlag ( ) . flag === false ) {
2018-05-22 17:19:56 +02:00
loadSavedValuesIntoForm ( ) ;
} else {
2019-03-29 14:04:12 +01:00
var serviceCategoryOid = $ ( "#selectedServiceCategoryOidHolder" ) . val ( ) ;
var serviceDescriptionOid = $ ( "#selectedServiceDescriptionOidHolder" ) . val ( ) ;
2018-06-22 20:25:13 +02:00
2019-03-29 14:04:12 +01:00
shouldLoadServiceDescriptions = false ;
2016-06-27 01:45:38 +02:00
2019-03-29 14:04:12 +01:00
showSanduhr ( ) ;
makeAjaxCall ( "GET" , window . loadServiceCategoriesUrl , function ( result ) {
if ( isEmptyOrSpaces ( result ) ) {
window . location . href = window . redirectLink ;
return ;
}
2018-12-17 18:32:32 -04:00
2019-03-29 14:04:12 +01:00
if ( result === "SessionTimeout" ) {
window . location . href = redirectLink ;
return ;
}
2018-12-17 18:32:32 -04:00
2019-03-29 14:04:12 +01:00
$ ( "#kategorien_select" ) . val ( serviceCategoryOid ) ;
2018-12-17 18:32:32 -04:00
2019-03-29 14:04:12 +01:00
var liste = $ . parseJSON ( result ) ;
$ ( "#leistungen_select" ) . empty ( ) ;
$ ( "#leistungen_select" ) . val ( "" ) ;
2018-12-17 18:32:32 -04:00
2019-03-29 14:04:12 +01:00
$ . each ( liste , function ( index , leistung ) {
$ ( "#leistungen_select" ) . append ( '<option value="' + leistung . ServiceDescriptionOid + '">' + leistung . Name + '</option>' ) ;
} ) ;
2018-12-17 18:32:32 -04:00
2019-03-29 14:04:12 +01:00
$ ( "#leistungen_select" ) . val ( serviceDescriptionOid ) ;
2018-06-22 20:25:13 +02:00
2019-03-29 14:04:12 +01:00
makeAjaxCall ( "GET" , window . setServiceDescriptionUrl , function ( ) {
hideSanduhr ( ) ;
2016-06-27 01:45:38 +02:00
2019-03-29 14:04:12 +01:00
saveFormValuesLocally ( ) ;
} , { pServiceDescriptionOid : serviceDescriptionOid } , null ) ;
} , { pServiceCategoryOid : serviceCategoryOid } , null ) ;
2018-04-18 14:33:21 +02:00
}
2018-12-17 18:32:32 -04:00
2019-03-29 14:04:12 +01:00
setGroupEditingFlag ( false ) ;
}
2018-12-17 18:32:32 -04:00
2019-03-29 14:04:12 +01:00
var shouldActivateForm = isInGroupBookingMode ( ) ? $ ( "#leftContent input:checked" ) . length > 0 : selectedServiceCategory !== "-1" ;
2018-12-17 18:32:32 -04:00
2019-03-29 14:04:12 +01:00
if ( shouldActivateForm ) {
activateInputForm ( actionPath , shouldLoadServiceDescriptions ) ;
} else {
deactivateInputForm ( ) ;
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-12-17 18:32:32 -04:00
console . log ( "Fehler: " + err . message ) ;
2016-06-27 01:45:38 +02:00
}
}
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 ) {
2018-12-17 18:32:32 -04:00
$ ( "#tddokureiter" ) . hide ( ) ;
2017-04-26 14:57:32 +02:00
$ ( "#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 ) {
2018-12-17 18:32:32 -04:00
$ ( "#tddokureiter" ) . hide ( ) ;
2017-04-26 14:57:32 +02:00
$ ( "#trnormalDoku" ) . css ( "display" , "table-row" ) ;
2019-03-29 14:04:12 +01:00
$ ( "#trnormalDokuLabel" ) . val ( 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 ) ;
2019-03-29 14:04:12 +01:00
dokuTab . val ( 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 . 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 ) ;
}
2019-03-29 14:04:12 +01:00
if ( values . serviceDescription !== "undefined" ) {
$ ( "#leistungen_select" ) . val ( values . serviceDescription ) ;
}
2018-06-22 20:25:13 +02:00
}