class System{ static Files(){ return Files; } static SharedFiles(){ return SharedFiles; } static RegVehicle(){ return RegVehicle; } static RegVehicleImpounded(){ return RegVehicleImpounded; } static RegWeapons(){ return RegWeapons; } static SpeedcamsMobile(){ return SpeedcamsMobile; } static SpeedcamsProfit(){ return SpeedcamsProfit; } static ControlCentre(){ return ControlCentre; } static Employees(){ return Employees; } static EmployeesEntry(){ return EmployeesEntry; } static RankManagement(){ return RankManagement; } static RankManagementRights(){ return RankManagementRights; } static Manhunt(){ return Manhunt; } static Trainings(){ return Trainings; } static Licenses(){ return Licenses; } static Investigation(){ return Investigation; } static InvestigationEntry(){ return InvestigationEntry; } static MissionReport(){ return MissionReport; } static RadioState(){ return RadioState; } static EmergencyVehicle(){ return EmergencyVehicle; } static CriminalComplaint(){ return CriminalComplaint; } static LawBooks(){ return LawBooks; } static EvidenceRooms(){ return EvidenceRooms; } static Prison(){ return Prison; } static LawBookLaws(){ return LawBookLaws; } static EvidenceRoomArticles(){ return EvidenceRoomArticles; } static EvidenceRoomArticlesDestroyed(){ return EvidenceRoomArticlesDestroyed; } static FileEntry(){ return FileEntry; } static EmployeeVehicle(){ return EmployeeVehicle; } static EmergencyVehicleRadio(){ return EmergencyVehicleRadio; } static EmployeeRadio(){ return EmployeeRadio; } static EmployeesTraining(){ return EmployeesTraining; } static Dashboard(){ return Dashboard; } static Notes(){ return Notes; } static getServiceNo(str){ if(str){ return str.toLowerCase().replace(new RegExp("[a-z]","gm"),"").replace(":","").substr(1,6) } else{ return "error.."; } } static GetFgColorByBgColor(bgColor){ let colors = this.GetColors(); if(colors[bgColor]){ return colors[bgColor].fgColor; } else{ return "#000000"; } } static ToggleInjury(sender){ let fieldId = sender.id.replace("injury-","input-"); let inputEl = document.getElementById(fieldId); if(inputEl){ if(sender.querySelector("path").classList.contains("active")){ sender.querySelector("path").classList.remove("active"); inputEl.value = 0; } else{ sender.querySelector("path").classList.add("active"); inputEl.value = 1; } Form.validate(); } else{ console.log("no field found for " + fieldId); } } static GetComplaintByID(id){ return this.getComplaintStates()[id] ?? {} } static getFirstName(input){ if(input == ""){ return ""; } let parsed = JSON.parse(input); return parsed.firstname } static getLastName(input){ if(input == ""){ return ""; } let parsed = JSON.parse(input); return parsed.lastname } static getJobGrade(input){ if(input === null || input == ""){ return 0; } let parsed = JSON.parse(input); return parsed.grade.level } static buildEmployeeName(input){ if(input == null){ return `${getTranslation("employee.unknown")}`; } if(input == ""){ return ""; } let JSONS = input.split("") let retval = ""; for(let i=0; i"); let parsed = {}; let validJson = false; let identifier = valueseperator[1] ?? ''; let serviceno = valueseperator[2] ?? ''; let retServiceno = serviceno; if(retServiceno === '' && identifier !== ''){ retServiceno = System.getServiceNo(identifier); } try{ parsed = JSON.parse(valueseperator[0]); validJson = true; } catch(e){ } if(!validJson){ let json = valueseperator[0].replace('{','').replace('}','').split(","); let temp = {}; for(let i=0; i ") + (retServiceno == '' ? '' : retServiceno + ' - ') + parsed.firstname + " " + parsed.lastname; } return retval; } static SetColor(sys){ let colors = { police : "primary", medic : "error", default : "accent" } let el = document.getElementById("main_navigation_copname"); if(!colors[sys]){ sys = "default"; } Object.keys(colors).forEach(function(job){ if(el.classList.contains("bg-" + colors[job])){ el.classList.remove("bg-" + colors[job]); el.classList.remove("text-" + colors[job] + "-content"); } }); el.classList.add("bg-" + colors[sys] ?? "ghost"); el.classList.add("text-" + colors[sys] + "-content" ?? "text-ghost-content"); } static getRadioState(vehicleData, persondata){ let retval = { vehicle:null, radio:null, radio_default:getTranslation("emergency_vehicles_no_radio"), radio_id:-1 } if(vehicleData.length == 0){ if(persondata[0] !== null && persondata[0] !== undefined && persondata[0].state_name !== undefined && persondata[0].state_name !== ""){ retval.radio = persondata[0].state_name retval.radio_id = persondata[0].state_id } } else{ retval.vehicle = vehicleData[0].vehname_short + " - " + vehicleData[0].vehname if(vehicleData[0].state_name !== undefined && vehicleData[0].state_name !== ""){ retval.radio = vehicleData[0].state_name retval.radio_id = vehicleData[0].state_id } } return retval; } static getDate(){ let date = new Date(); let yyyy = date.getFullYear().toString(); let MM = this.padNum(date.getMonth() + 1,2); let dd = this.padNum(date.getDate(), 2); let hh = this.padNum(date.getHours(), 2); let mm = this.padNum(date.getMinutes(), 2) let ss = this.padNum(date.getSeconds(), 2) return yyyy + MM + dd + "-" + hh + mm + ss; } static padNum(num, length){ var str = '' + num; while (str.length < length) { str = '0' + str; } return str; } static formatDate(input){ if(input == ""){ return ""; } if(locale == "de"){ let temp = input.split("-"); return `${temp[2]}.${temp[1]}.${temp[0]}` } else{ return input; } } static formatTimestamp(input){ if(input == ""){ return ""; } if(locale == "de"){ let splitted = input.split(" "); let datesplit = splitted[0].split("-"); let timesplit = splitted[1].split(":"); return `${datesplit[2]}.${datesplit[1]}.${datesplit[0]} ${timesplit[0]}:${timesplit[1]}` } else{ let splitted = input.split(" "); let datesplit = splitted[0].split("-"); let timesplit = splitted[1].split(":"); return `${splitted[0]} ${timesplit[0]}:${timesplit[1]}` } } static getEmployeeEntryTypes(){ return { "0" : {name:getTranslation("note"), "color":"info"}, "1" : {name:getTranslation("positiv"), "color":"success"}, "2" : {name:getTranslation("negative"), "color":"error"} } } static getEmployeeEntryTypesOptions(){ let retval = []; let json = this.getEmployeeEntryTypes(); Object.keys(json).forEach(function(key){ retval.push({"id": key, "name":json[key].name }) }); return retval; } static getFileEntryTypes(){ return { "0" : {name:getTranslation("fine_crime"), "color":"error"}, "1" : {name:getTranslation("positiv"), "color":"success"}, "2" : {name:getTranslation("neutral"), "color":"info"} } } static getRankOptions(){ let retval = []; Object.keys(job_grades).forEach(function(i){ retval.push({"id": job_grades[i].grade, "name":job_grades[i].label}) }) return retval; } static getLabelByRank(in_rank_id){ let retval = "unknown"; Object.keys(job_grades).forEach(function(i){ if(job_grades[i].grade == in_rank_id){ retval = job_grades[i].label; } }) return retval; } static getFileEntryTypesOptions(){ let retval = []; let json = this.getFileEntryTypes(); Object.keys(json).forEach(function(key){ retval.push({"id": key, "name":json[key].name }) }); return retval; } static GetCompaintStateOptions(){ let retval = []; let json = this.getComplaintStates(); Object.keys(json).forEach(function(key){ retval.push({"id": key, "name":json[key].name }) }); return retval; } static getComplaintStates(){ return { "0" : {name:getTranslation("state_open"), "color":"badge-error"}, "1" : {name:getTranslation("state_inprogress"), "color":"badge-warning"}, "2" : {name:getTranslation("state_closed"), "color":"badge-success"} } } static GetColors(){ return { "#008000": { bgcolor : "#008000" ,fgColor : "#FFFFFF" ,name : getTranslation("color-green") }, "#FF0000": { bgcolor : "#FF0000" ,fgColor : "#FFFFFF" ,name : getTranslation("color-red") }, "#0000FF": { bgcolor : "#0000FF" ,fgColor : "#FFFFFF" ,name : getTranslation("color-blue") }, "#ffa500": { bgcolor : "#ffa500" ,fgColor : "#000000" ,name : getTranslation("color-orange") }, "#ffc0cb": { bgcolor : "#ffc0cb" ,fgColor : "#000000" ,name : getTranslation("color-pink") }, "#888888": { bgcolor : "#888888" ,fgColor : "#000000" ,name : getTranslation("color-gray") }, "#880000": { bgcolor : "#880000" ,fgColor : "#FFFFFF" ,name : getTranslation("color-dark_red") }, "#000000": { bgcolor : "#000000" ,fgColor : "#FFFFFF" ,name : getTranslation("color-black") } } } static GetColorOptions(){ let json = this.GetColors(); let options = []; Object.keys(json).forEach(function(key){ options.push({"id": key, "name":json[key].name }) }); return options; } static getClassByName(name){ let _classes = { "files": this.Files() ,"sharedfiles": this.SharedFiles() ,"regvehicle": this.RegVehicle() ,"regvehicleimpounded": this.RegVehicleImpounded() ,"regweapons": this.RegWeapons() ,"radiostate": this.RadioState() ,"speedcamsmobile": this.SpeedcamsMobile() ,"speedcamsprofit": this.SpeedcamsProfit() ,"manhunt": this.Manhunt() ,"emergencyvehicle": this.EmergencyVehicle() ,"trainings": this.Trainings() ,"criminalcomplaint": this.CriminalComplaint() ,"missionreport": this.MissionReport() ,"investigation": this.Investigation() ,"employees": this.Employees() ,"employeesentry": this.EmployeesEntry() ,"employeestraining": this.EmployeesTraining() ,"lawbooks": this.LawBooks() ,"evidencerooms": this.EvidenceRooms() ,"prison": this.Prison() ,"lawbooklaws": this.LawBookLaws() ,"evidenceroomarticles": this.EvidenceRoomArticles() ,"evidenceroomarticlesdestroyed": this.EvidenceRoomArticlesDestroyed() ,"controlcentre": this.ControlCentre() ,"fileentry": this.FileEntry() ,"investigationentry": this.InvestigationEntry() ,"licenses": this.Licenses() ,"employeevehicle": this.EmployeeVehicle() ,"emergencyvehicleradio": this.EmergencyVehicleRadio() ,"employeeradio": this.EmployeeRadio() ,"dashboard": this.Dashboard() ,"notes": this.Notes() ,"rankmanagement": this.RankManagement() ,"rankmanagementrights": this.RankManagementRights() } if(_classes[name]){ return _classes[name]; } else{ return null; } } static GetBooleanOptions(){ return [ {id:0, "name" : getTranslation("no")}, {id:1, "name" : getTranslation("yes")} ] } static GetTable(_class, gridData, additionalData = null){ if(gridData.length == 0 || gridData.length == undefined){ return `

${getTranslation("no_data_found")}

`; } let columns = _class.GetColumns(additionalData); let html = `` for(let i=0; i`; html += ``; for(let k=0; k${getTranslation(columns[k])}`; } html += ``; html += ``; html += ``; } html+=``; for(let j=0; j`; } html += ``; html += `
`; return html; } static CreateOverView(_class, data={}){ let html = ``; let gridData = data.data; let maxData = data.count; let maxPages = data.count / 10; let curPage = data.pageNum ?? 0; let withoutLimit = data.noLimit; let extraHtml = {} let allowAddNew = true; if (_class.hasOwnProperty("allowAddNew")) { allowAddNew = _class.allowAddNew(); } if (_class.hasOwnProperty("GetExtraForOverview")) { extraHtml = _class.GetExtraForOverview(data.xtraData); } html = extraHtml.top ?? ""; html += Form.overviewHeadline(_class.name.toLowerCase() + ".add", !withoutLimit, allowAddNew); html += `
` html += `
` html += `
` html += this.GetTable(_class, gridData); html += `
` html += `
` html += `
` if(!withoutLimit){ html += Form.getPageChanger(curPage,maxPages); } document.getElementById("currentpage-content").innerHTML = html; Form.initTableButtons(); Form.initPageChange(); } static CreateEdit(_class, data = {}, readMode = false, src = "", dest = "", destid = -1){ let inputData = {}; let initTableButtons = false if (_class.hasOwnProperty("GetEdit")) { inputData = _class.GetEdit(data, readMode); } if (_class.hasOwnProperty("GetCustomDestID")) { destid = _class.GetCustomDestID(data, destid); } if (_class.hasOwnProperty("GetCustomDestination")) { dest = _class.GetCustomDestination(data, dest); } let html = ``; let groupInit = false; Object.keys(inputData).forEach(key=>{ if(inputData[key].hideInViewMode != true && readMode || (!readMode && inputData[key].hideInEdit != true)){ if(inputData[key].isRow != true && inputData[key].type != "divider" && !groupInit){ html += `
`; groupInit=true; } else if((inputData[key].isRow == true || inputData[key].type == "divider") && groupInit ){ html += `
`; groupInit=false; } if(inputData[key].type === "text"){ html += Form.TextBox(inputData[key].mandatory, key, inputData[key].val); } else if(inputData[key].type === "hidden"){ html += Form.Hidden(key, inputData[key].val); } else if(inputData[key].type === "date"){ html += Form.DateField(inputData[key].mandatory, key, inputData[key].val); } else if(inputData[key].type === "number"){ html += Form.NumberField(inputData[key].mandatory, key, inputData[key].val); } else if(inputData[key].type === "float"){ html += Form.Float(inputData[key].mandatory, key, inputData[key].val); } else if(inputData[key].type === "textarea"){ html += Form.TextArea(inputData[key].mandatory, key, inputData[key].val, inputData[key].autogrow, inputData[key].rows); } else if(inputData[key].type === "dropdown"){ html += Form.Combobox(inputData[key].mandatory, key, inputData[key].val, inputData[key].options, inputData[key].extraClass); } else if(inputData[key].type === "searchdropdown"){ //html += Form.SearchCombobox("", "", 1, ""); html += Form.SearchCombobox(inputData[key].mandatory, key, inputData[key].val, inputData[key].options, data.id ?? -1); } else if(inputData[key].type === "divider"){ html += Form.Divier(); } } }); if(groupInit){ html+=``; } if(!readMode){ let extraHtml = {} if (_class.hasOwnProperty("GetExtraForEdit")) { extraHtml = _class.GetExtraForEdit(data); } if(extraHtml.bottom!== undefined && extraHtml.bottom!= null && extraHtml.bottom != ""){ html += extraHtml.bottom; } html += `
${Form.cancelButton(src, dest, destid)} ${Form.saveButton(_class.name, dest, data.id ?? -1, destid)} `; if(extraHtml.top!== undefined && extraHtml.top!= null && extraHtml.top != ""){ html = extraHtml.top + html; } } else{ let extraHtml = {} if (_class.hasOwnProperty("GetExtraForView")) { extraHtml = _class.GetExtraForView(data); } if(extraHtml.initTableButtons == true){ initTableButtons = true; } let editDest = src.replace(".view",".edit") let allowEdit = true; if (_class.hasOwnProperty("allowEdit")) { allowEdit = _class.allowEdit(); } let tempTop = Form.BackEditBtn(dest, editDest, data.id ?? destid, allowEdit); if(extraHtml.top!== undefined && extraHtml.top!= null && extraHtml.top != ""){ tempTop += extraHtml.top; } html = tempTop + html; if(extraHtml.bottom!== undefined && extraHtml.bottom!= null && extraHtml.bottom != ""){ html += extraHtml.bottom; } } document.getElementById("currentpage-content").innerHTML = html; if(!readMode){ Form.initSearchComboboxes(); Form.initValidation(); Form.initSaveButtons(); if(Object.keys(inputData).length == 1){ Form.validate(); } } else{ if(initTableButtons){ Form.initTableButtons(); } Form.disableAll(); Form.initViewModeTopButtons(); } Form.TextAreaGrow(); } static convertSecondsToTime(input){ let hours = Math.floor(input / 3600); let remainingSeconds = input % 3600; let minutes = Math.floor(input / 60); let secs = input % 60; // Führende Nullen hinzufügen, wenn die Zahl < 10 ist hours = hours.toString().padStart(2, '0'); minutes = minutes.toString().padStart(2, '0'); secs = secs.toString().padStart(2, '0'); return `${hours}:${minutes}:${secs}`; } }