This commit is contained in:
Nordi98 2025-08-14 13:21:51 +02:00
parent 48a36209b5
commit 884f3df7cf
262 changed files with 223207 additions and 2 deletions

View file

@ -0,0 +1,14 @@
class FileSearch{
constructor(){
this.timeout = null
}

startTimer(value, element){
if(this.timeout != null){
clearTimeout(this.timeout);
}
this.timeout = setTimeout(function(){
SearchFiles(element)
},value);
}
}

View file

@ -0,0 +1,732 @@
class Form{
constructor(){
}
static TextBox(mandatory, translation_key, value){
let validateClass = "";
if(mandatory){
validateClass = " needs-validation"
}
return `
<div class="form-control">
<label class="label">
<span class="label-text">${getTranslation(translation_key)}</span>
</label>
<input id="input-${translation_key}" type="text" placeholder="" class="input input-sm input-bordered ${validateClass}" value="${value}" />
</div>
`;
}
static Hidden(translation_key, value){
return `
<div class="form-control" style="display:none">
<input id="input-${translation_key}" type="text" placeholder="" class="input input-sm input-bordered" value="${value}" />
</div>
`;
}

static NumberField(mandatory, translation_key, value, field_class = "", readonly = false, includeLabel = true){
let validateClass = "";
let disabled = "";

if(mandatory){
validateClass = " needs-validation"
}
if(field_class != ""){
field_class = " " + field_class;
}
if(readonly){
disabled = " disabled";
}


let disabledKeys = ["+", "." , "-", ","];
let step = "1";

let onkeydownkeyCodes = "";
for(var i=0; i < disabledKeys.length;i++){
onkeydownkeyCodes += (onkeydownkeyCodes == "" ? "" : " || " ) + "event.key==='"+disabledKeys[i]+"'";
}


if(includeLabel){
return `
<div class="form-control">
<label class="label">
<span class="label-text">${getTranslation(translation_key)}</span>
</label>
<input id="input-${translation_key}" type="number" onpaste="return false;" onkeydown="if(${onkeydownkeyCodes}){event.preventDefault();}" placeholder="" class="input input-sm input-bordered ${validateClass} ${field_class}" value="${value}" ${disabled}/>
</div>
`;
}
else{
return `
<div class="form-control">
<input id="input-${translation_key}" type="number" onpaste="return false;" onkeydown="if(${onkeydownkeyCodes}){event.preventDefault();}" placeholder="" class="input input-sm input-bordered ${validateClass} ${field_class}" value="${value}" ${disabled}/>
</div>
`;
}
}


static Float(mandatory, translation_key, value){
let validateClass = "";

if(mandatory){
validateClass = " needs-validation"
}

let disabledKeys = ["+", "-", ","];
let step = "1";

let onkeydownkeyCodes = "";
for(var i=0; i < disabledKeys.length;i++){
onkeydownkeyCodes += (onkeydownkeyCodes == "" ? "" : " || " ) + "event.key==='"+disabledKeys[i]+"'";
}

return `
<div class="form-control">
<label class="label">
<span class="label-text">${getTranslation(translation_key)}</span>
</label>
<input id="input-${translation_key}" type="number" onpaste="return false;" onkeydown="if(${onkeydownkeyCodes}){event.preventDefault();}" placeholder="" class="input input-sm input-bordered ${validateClass}" value="${value}" />
</div>
`;
}

static TextAreaGrow(){
Array.from(document.querySelectorAll(".ta-autogrow")).forEach(function(ta){
ta.style.height='auto';
ta.style.height = (ta.scrollHeight + 2) + 'px';
});
}

static TextArea(mandatory, translation_key, value, autogrow = false, rows = 3){
let validateClass = "";
let onInput = "";
let autoGrowClass = "";

if(mandatory){
validateClass = " needs-validation"
}


if(autogrow){
onInput = `onInput="this.style.height='auto'; this.style.height = (this.scrollHeight + 2) + 'px';"`;
autoGrowClass = " ta-autogrow";
}

return `
<div class="form-control">
<label class="label">
<span class="label-text">${getTranslation(translation_key)}</span>
</label>
<textarea rows="${rows}" id="input-${translation_key}" type="text" placeholder="" ${onInput} class="textarea textarea-sm textarea-bordered ${validateClass}${autoGrowClass}" >${value}</textarea>
</div>
`;
}

static DateField(mandatory, translation_key, value){
let validateClass = "";

if(mandatory){
validateClass = " needs-validation"
}

return `
<div class="form-control">
<label class="label">
<span class="label-text">${getTranslation(translation_key)}</span>
</label>
<input id="input-${translation_key}" type="date" placeholder=""class="input input-sm input-bordered ${validateClass}" value="${value}" />
</div>
`;
}

static Combobox(mandatory, translation_key, value, options, field_class){
let validateClass = "";

if(mandatory){
validateClass = " needs-validation";
}

if(field_class != ""){
field_class = " " + field_class;
}


let optionsHtml = ``;
for(let i=0; i<options.length; i++){
let selected = "";
if(options[i].id == value){
selected = " selected";
}

optionsHtml += `<option value="${options[i].id}" ${selected}>${options[i].name}</option>`;
}

return `
<div class="form-control">
<label class="label">
<span class="label-text">${getTranslation(translation_key)}</span>
</label>
<select id="input-${translation_key}" class="select select-sm select-bordered ${validateClass} ${field_class}" value="${value}">
${optionsHtml}
</select>
</div>
`;
}

static refillFilesDropDown(element, data){
data = data.data

let filesOptions = [
{"id":-1, "name":getTranslation("unknown")}
,{"id":-2, "name":getTranslation("new_file"), "show_extra_field":true}
];

if(sync.isActive("files")){
filesOptions = [
{"id":-1, "name":getTranslation("unknown")}
];
}

data = [...filesOptions, ...data];

let parentDiv = element.parentElement;
let buttonLabel = "...";
let mandatory = element.getAttribute("data-mandatory") == "true";
let translation_key = element.getAttribute("data-translationkey");

let li = parentDiv.getElementsByTagName("li");

while (li[0]){
parentDiv.removeChild(li[0])
}


for(let i=0; i<data.length; i++){
let selected = "";
if(data[i].id == -1){
buttonLabel = data[i].name;
selected = " active"
}

let el = document.createElement("li");
el.setAttribute("data-validate", mandatory);
el.setAttribute("parentId", `input-${translation_key}`);
el.setAttribute("value", data[i].id);
el.setAttribute("show-childtext", data[i].show_extra_field ?? "false");
el.innerHTML = `<a class="${selected}">${data[i].name}</a>`;

el.onclick = function(){
if(!this.classList.contains("active")){
Array.from(this.parentElement.querySelectorAll(".active")).forEach(function(itm){
itm.classList.remove("active");
});

Array.from(this.getElementsByTagName("a")).forEach(function(itm){
itm.classList.add("active");
});

document.getElementById(this.getAttribute("parentId") + "-new-name").value = "";
document.getElementById(this.getAttribute("parentId") + "-button").innerText = this.innerText;
document.getElementById(this.getAttribute("parentId") + "-dropdown").blur();
document.getElementById(this.getAttribute("parentId")).value = this.getAttribute("value");

if(this.getAttribute("show-childtext") == "true"){
document.getElementById(this.getAttribute("parentId") + "-new-name").style.display = "";
if(this.getAttribute("data-validate") == "true"){
document.getElementById(this.getAttribute("parentId") + "-new-name").classList.add("needs-validation");
}
}
else{
document.getElementById(this.getAttribute("parentId") + "-new-name").style.display = "none";
document.getElementById(this.getAttribute("parentId") + "-new-name").classList.remove("needs-validation");
}
}
Form.validate();
}


parentDiv.appendChild(el)
}


}

static initSearchComboboxes(){

Array.from(document.getElementById("currentpage-content").querySelectorAll(".filterablecombobox-search")).forEach(function(item){
item.onkeyup = function(){
globalFileSearcher.startTimer(500, this)
}
});
Array.from(document.getElementById("currentpage-content").querySelectorAll(".filterablecombobox")).forEach(function(item){
//get children
let childs = item.getElementsByTagName("li");
for(let i=0; i<childs.length; i++){
childs[i].onclick = function(){
if(!this.classList.contains("active")){
Array.from(this.parentElement.querySelectorAll(".active")).forEach(function(itm){
itm.classList.remove("active");
});
Array.from(this.getElementsByTagName("a")).forEach(function(itm){
itm.classList.add("active");
});

document.getElementById(this.getAttribute("parentId") + "-new-name").value = "";
document.getElementById(this.getAttribute("parentId") + "-button").innerText = this.innerText;
document.getElementById(this.getAttribute("parentId") + "-dropdown").blur();
document.getElementById(this.getAttribute("parentId")).value = this.getAttribute("value");

if(this.getAttribute("show-childtext") == "true"){
document.getElementById(this.getAttribute("parentId") + "-new-name").style.display = "";
if(this.getAttribute("data-validate") == "true"){
document.getElementById(this.getAttribute("parentId") + "-new-name").classList.add("needs-validation");
}
}
else{
document.getElementById(this.getAttribute("parentId") + "-new-name").style.display = "none";
document.getElementById(this.getAttribute("parentId") + "-new-name").classList.remove("needs-validation");
}
}
Form.validate();
}
}
});
}


static SearchCombobox(mandatory, translation_key, value, options, database_id){
let validateClass = "";

if(mandatory){
validateClass = " needs-validation";
}
let optionsHtml = ``;
let buttonLabel = "..."

let activeFound = false;

for(let i=0; i<options.length; i++){
let selected = "";

if(options[i].id == value){
buttonLabel = options[i].name;
selected = " active"
activeFound = true;


}
optionsHtml += `<li data-validate="${mandatory}" parentId="input-${translation_key}" value="${options[i].id}" show-childtext="${options[i].show_extra_field ?? "false"}"><a class="${selected}">${options[i].name}</a></li>`;
}


return `
<div class="form-control">
<label class="label">
<span class="label-text">${getTranslation(translation_key)}</span>
</label>
<div class="dropdown" >
<button tabindex="0" class="select select-sm select-bordered w-full filterabledropdownbutton" id="input-${translation_key}-button">${buttonLabel}</button>
<ul tabindex="0" id="input-${translation_key}-dropdown" class="dropdown-content menu p-2 shadow bg-base-100 rounded-box w-52 filterablecombobox">
<input type="text" class="input input-sm input-bordered filterablecombobox-search" data-parentid = "${database_id}" data-mandatory="${mandatory}" data-translationkey="${translation_key}" placeholder="Search..">
${optionsHtml}
</ul>
</div>
<input type="text" style="display:none" class="input input-sm input-bordered" id="input-${translation_key}-new-name">
<input type="text" style="display:none" class="input input-sm input-bordered input-searchableDropDown ${validateClass}" id="input-${translation_key}" value="${value}" >
</div>
`;
}

static Divier(text = ""){
return `
<div class="divider">${text}</div>
`;
}


static validate(){
if(document.getElementById("input-save-button")){
let valid = true;
Array.from(document.getElementById("currentpage-content").querySelectorAll(".needs-validation")).forEach(function(el){
if(el.value.trim() === ""){
valid = false;
if(!el.classList.contains("text-pink-600")){
el.classList.add("text-pink-600");
el.classList.add("border-pink-500");
}
}
else{
if(el.classList.contains("text-pink-600")){
el.classList.remove("text-pink-600");
el.classList.remove("border-pink-500");
}
}
});
document.getElementById("input-save-button").disabled = !valid;
}
}

static initValidation(){
Array.from(document.getElementById("currentpage-content").querySelectorAll("input")).forEach(function(el){
if(!el.classList.contains("filterablecombobox-search")){
el.onkeyup = function(){
if(el.classList.contains("lawbook_laws_calc_penalty")){
FileEntry.ValidateAndCalcLawBookLaws();
}
else{
Form.validate();
}
}
}
});
Array.from(document.getElementById("currentpage-content").querySelectorAll("input")).forEach(function(el){
el.onchange = function(){
Form.validate();
}
});
Array.from(document.getElementById("currentpage-content").querySelectorAll("textarea")).forEach(function(el){
el.onkeyup = function(){
Form.validate();
}
});
Array.from(document.getElementById("currentpage-content").querySelectorAll("select")).forEach(function(el){
el.onchange = function(){

if(el.classList.contains("police_fileentry_type_of_entry")){
FileEntry.ToggleLawBooks();
}
else{
Form.validate();
}
}
});
}

static getFormData(){
let retval = {};
Array.from(document.getElementById("currentpage-content").querySelectorAll("input")).forEach(function(el){
if(!el.classList.contains("filterablecombobox-search")){
let key = el.id.replace("input-","");

if(el.type != "checkbox"){
retval[key] = el.value;
}
else{
retval[key] = el.checked ? 1 : 0;
}

}
});
Array.from(document.getElementById("currentpage-content").querySelectorAll("textarea")).forEach(function(el){
let key = el.id.replace("input-","");
retval[key] = el.value;
});
Array.from(document.getElementById("currentpage-content").querySelectorAll("onchange")).forEach(function(el){
let key = el.id.replace("input-","");
retval[key] = el.value;
});
Array.from(document.getElementById("currentpage-content").querySelectorAll("select")).forEach(function(el){
let key = el.id.replace("input-","");
retval[key] = el.value;
});

return retval;
}

static disableAll(){
Array.from(document.getElementById("currentpage-content").querySelectorAll("input")).forEach(function(el){
if(!el.classList.contains("ignore-readonly")){
el.readOnly = true;
}
});
Array.from(document.getElementById("currentpage-content").querySelectorAll("textarea")).forEach(function(el){
if(!el.classList.contains("ignore-readonly")){
el.readOnly = true;
}
});
Array.from(document.getElementById("currentpage-content").querySelectorAll("select")).forEach(function(el){
if(!el.classList.contains("ignore-readonly")){
el.disabled = true;
}
});
Array.from(document.getElementById("currentpage-content").querySelectorAll(".filterabledropdownbutton")).forEach(function(el){
if(!el.classList.contains("ignore-readonly")){
el.disabled = true;
el.readOnly = true;
}
});
}


static cancelButton(source, destination, destination_id){
return `<button id="input-cancel-button" data-destination="${destination}" data-destination-id="${destination_id}" class="btn btn-error btn-sm">${getTranslation("cancel")}</button>`;
}
static saveButton(source, destination, uid, destination_id){
return `<button id="input-save-button" class="btn btn-primary btn-sm" data-destination="${destination}" data-destination-id="${destination_id}" data-uid="${uid}" data-source="${source}" disabled>${getTranslation("save")}</button>`;
}

static initSaveButtons(){
document.getElementById("input-cancel-button").onclick = function(){
loadData(
this.getAttribute("data-destination"),
this.getAttribute("data-destination-id"),
true
)
}
document.getElementById("input-save-button").onclick = function(){
saveData(
this.getAttribute("data-source"),
this.getAttribute("data-destination"),
this.getAttribute("data-uid"),
this.getAttribute("data-destination-id")
)
}
}

static initViewModeTopButtons(){
if(document.getElementById("input-back-button")){
document.getElementById("input-back-button").onclick=function(){
loadPage(this.getAttribute("data-destination"), this.getAttribute("data-destinationId"), "true");
}
}
if(document.getElementById("input-edit-button")){
document.getElementById("input-edit-button").onclick=function(){
loadPage(this.getAttribute("data-destination"), this.getAttribute("data-destinationId"));
}
}
}

static BackEditBtn(backDestination, editDest, editId, allowEditButton, backDestinationId = -1 ){
let editBtn = ``;
if(allowEditButton){
editBtn = `<button id="input-edit-button" data-destination="${editDest}" data-destinationId="${editId}" class="btn btn-sm btn-warning">${getTranslation("edit")}</button>`;
}
return `
<div class="text-xl font-semibold inline-block mb-6">
<button id="input-back-button" data-destination="${backDestination}" data-destinationId="${backDestinationId}" class="btn btn-sm btn-error"><i class="fa-solid fa-arrow-left"></i></button>
${editBtn}
</div>
`;

}

static getViewButtonIcon(recordid, destination){
return `
<button class="btn btn-sm btn-accent table-viewbutton" data-id="${recordid}" data-destination="${destination}">
<i class="fa-solid fa-circle-info"></i>
</button>
`;
}

static getIsWantedButton(recordid, destination, isWanted){

let disabled = isWanted ? " disabled" : ""

return `
<button class="btn btn-sm btn-secondary table-iswantedbutton" data-id="${recordid}" data-destination="${destination}" ${disabled}>
<i class="fa-solid fa-handcuffs"></i>
</button>
`;
}

static getEditButtonIcon(recordid, destination, allowButton=true){
if(!allowButton){
return "";
}

return `
<button class="btn btn-sm btn-warning table-editbutton" data-id="${recordid}" data-destination="${destination}">
<i class="fa-solid fa-pen-to-square"></i>
</button>
`;
}

static getDeleteButtonIcon(recordid, delete_destination , allowButton=true){
if(!allowButton){
return ``;
}
return `
<button class="btn btn-sm btn-error table-deletebutton" data-deleteDestination="${delete_destination}" data-id="${recordid}">
<i class="fa-solid fa-trash-can"></i>
</button>
`;
}


static overviewHeadline(destination, inclSearch = true, allowAddNew = true){
let search = "";
if(inclSearch){

let addBtn = "";
if(allowAddNew){
addBtn = `<button class="btn px-6 btn-sm normal-case btn-primary table-addbutton mr-1" data-destination="${destination}"><i class="fa-solid fa-circle-plus"></i></button>`;
}

return `
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div class="input-group">
${addBtn}
<input id="global-searchbar" type="text" placeholder="${getTranslation("search")}" class="input input-sm input-bordered w-72 mr-1" value="${document.body.getAttribute("data-quicksearch") ?? ""}" />
<button id="global-searchbar-start" class="btn btn-sm btn-square">
<i class="fa-solid fa-magnifying-glass"></i>
</button>
</div>
</div>
`;
}
else{
if(allowAddNew){
return `
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div class="text-left">
<button class="btn px-6 btn-sm normal-case btn-primary table-addbutton" data-destination="${destination}"><i class="fa-solid fa-circle-plus"></i></button>
</div>
</div>
`;
}
else{
return ``;
}
}

}


static getPageChanger(curPage, maxPage){
curPage = curPage + 1;
let nextDisabled = "";
let prevDisabled = "";
if(curPage == 1){
prevDisabled = " disabled";
}
if(curPage >= maxPage){
nextDisabled = " disabled";
}

document.body.setAttribute("data-cur-pageNum", curPage);

return `
<div class="btn-group">
<button id="global-previous-page" class="btn btn-primary btn-sm" ${prevDisabled}>«</button>
<button class="btn btn-ghost btn-sm" data-currentpage="${curPage}" id="global-page-current">${curPage}</button>
<button id="global-next-page" class="btn btn-primary btn-sm" ${nextDisabled}>»</button>
</div>
`;
}

static initPageChange(){
if(document.getElementById("global-previous-page")){
document.getElementById("global-previous-page").onclick=function(){
let curpage = document.body.getAttribute("data-cur-pageNum");
curpage = 1*curpage;
let destPage = curpage-1;
document.body.setAttribute("data-cur-pageNum", destPage);
reload();
}
}
if(document.getElementById("global-next-page")){
document.getElementById("global-next-page").onclick=function(){
let curpage = document.body.getAttribute("data-cur-pageNum");
curpage = 1*curpage;
let destPage = curpage+1;
document.body.setAttribute("data-cur-pageNum", destPage);
reload();
}
}
}

static openDeleteModal(id, source){

document.getElementById("delete-modal-title").innerHTML = getTranslation("delete");
document.getElementById("delete-modal-message").innerHTML = getTranslation("delete_message");
document.getElementById("delete-modal-cancel").innerHTML = getTranslation("cancel");
document.getElementById("delete-modal-delete").innerHTML = getTranslation("delete");

document.getElementById("delete-modal").setAttribute("data-id", id);
document.getElementById("delete-modal").setAttribute("data-delete-destination", source);
document.getElementById("delete-modal").checked = true;
}


static initTableButtons(){
Array.from(document.getElementById("currentpage-content").querySelectorAll(".table-deletebutton")).forEach(function(el){
el.onclick = function(){
Form.openDeleteModal(this.getAttribute("data-id"), this.getAttribute("data-deleteDestination"));
}
});

if(document.getElementById("global-searchbar")){
document.getElementById("global-searchbar").focus();
document.getElementById("global-searchbar").setSelectionRange(document.getElementById("global-searchbar").value.length, document.getElementById("global-searchbar").value.length);

document.getElementById("global-searchbar").onkeyup = function(e){
if(e.key.toLowerCase() == "enter"){
resetPageNum();
reload();
}
}
}

if(document.getElementById("global-searchbar-start")){
document.getElementById("global-searchbar-start").onclick=function(){
resetPageNum();
reload();
}
}
Array.from(document.getElementById("currentpage-content").querySelectorAll(".table-addbutton")).forEach(function(el){
el.onclick = function(){
loadPage(this.getAttribute("data-destination"), -1);
}
});
Array.from(document.getElementById("currentpage-content").querySelectorAll(".table-editbutton")).forEach(function(el){
el.onclick = function(){
loadPage(this.getAttribute("data-destination"), this.getAttribute("data-id"));
}
});
Array.from(document.getElementById("currentpage-content").querySelectorAll(".table-viewbutton")).forEach(function(el){
el.onclick = function(){
loadPage(this.getAttribute("data-destination"), this.getAttribute("data-id"));
}
});
Array.from(document.getElementById("currentpage-content").querySelectorAll(".table-iswantedbutton")).forEach(function(el){
el.onclick = function(){


let fromObj = this.getAttribute("data-destination").toLowerCase();
let fromId = this.getAttribute("data-id");

if(fromObj == "regvehicle" || fromObj == "regvehicleimpounded"){
changeDataInColumn(fromObj, "is_wanted", fromId, 1, true);
}
else if(fromObj == "regweapons"){
changeDataInColumn(fromObj, "is_wanted", fromId, 1, true);
}
else if(fromObj == "files"){
loadPage('fileentry.add',fromId,'true')
}

}
});
}

}

View file

@ -0,0 +1,78 @@
class NavMenu{
constructor(navigation, cursystem){
this.navid = "main_navigation";

let navEl = document.getElementById(this.navid);

Array.from(navEl.getElementsByTagName("li")).forEach(function(itm){
if(!itm.classList.contains("noremoveonrebuild")){
itm.remove();
}
});
Array.from(navEl.querySelectorAll(".divider")).forEach(function(itm){
itm.remove();
});

if(!navigation[cursystem]){
cursystem = "default";
}

if(navigation[cursystem]){

navigation = navigation[cursystem]
Object.keys(navigation).forEach(key=>{

if(key !== "none"){
navEl.innerHTML+=`<div class="divider no-translation nav-checkfor-nextelements mt-1 mb-1" data-tkey="${key}">{{${key}}}</div>`
}
Object.keys(navigation[key]).forEach(subKey=>{
let skeyname = navigation[key][subKey].key;
let destination = navigation[key][subKey].destination;
let forceReload = navigation[key][subKey].forceReload;
navEl.innerHTML+=`
<li id="menuItem-li-${skeyname}" class="nav-checkrights divier-${key}" data-rightkey="${navigation[key][subKey].rightkey ?? ""}">
<a id="menuitem-${skeyname}" class="font-normal no-translation is-navigation-link" data-iconclasses="${navigation[key][subKey].img}" data-tkey="${destination}" data-destination="${destination}", data-forceReload="${forceReload}">
<i class="${navigation[key][subKey].img}"></i>
{{${skeyname}}}
</a>
</li>
`;
});
});
}

Array.from(document.getElementById(this.navid).querySelectorAll(".is-navigation-link")).forEach(function(item){
item.onclick=function(){
handleMenuItemClick(this);
}
});

Array.from(document.getElementById(this.navid).querySelectorAll(".no-translation")).forEach(function(item){
let icon = "";
if(item.getAttribute("data-iconclasses") !== null){
icon = `<i class="${item.getAttribute("data-iconclasses")}"></i> `;
}

item.innerHTML = icon + Translations[locale][item.getAttribute("data-tkey")];
item.classList.remove("no-translation");

});

}

setItemActive(item){
Array.from(document.getElementById(this.navid).querySelectorAll(".bordered")).forEach(function(currentitem){
currentitem.classList.remove("bordered");
});
item.parentElement.classList.add("bordered");

setCurrentPageHeadLine(item.innerText);
}

}

View file

@ -0,0 +1,90 @@
class RadioHud{
constructor(){
this.DefaultMargin = 1.5;
}

SetLocation(value){
this.location = value;
if(value.vertical == "left"){
document.getElementById("radiostates").style.left = 0;
}
else if(value.vertical == "middle"){
document.getElementById("radiostates").style.right = 0;
document.getElementById("radiostates").style.left = 0;
document.getElementById("radiostates").style.marginLeft = "auto";
document.getElementById("radiostates").style.marginRight = "auto";
}
else{
document.getElementById("radiostates").style.right = 0;
}
if(value.horizontal == "top"){
document.getElementById("radiostates").style.top = 0;
}
else if(value.horizontal == "middle"){
document.getElementById("radiostates").style.top = 0;
document.getElementById("radiostates").style.bottom = 0;
document.getElementById("radiostates").style.marginTop = "auto";
document.getElementById("radiostates").style.marginBottom = "auto";
}
else{
document.getElementById("radiostates").style.bottom = 0;
}
}

SetExtraMargins(value){
if(this.location.vertical != "middle"){
document.getElementById("radiostates").style.marginLeft = value.left + this.DefaultMargin + "%";
document.getElementById("radiostates").style.marginRight = value.right + this.DefaultMargin + "%";
}
if(this.location.horizontal != "middle"){
document.getElementById("radiostates").style.marginTop = value.top + this.DefaultMargin + "%";
document.getElementById("radiostates").style.marginBottom = value.bottom + this.DefaultMargin + "%";
}
}

DrawInfo(radioDetails){
document.getElementById("radiostates_info").innerHTML = `
<table class="text-white">
<tr>
<td>
<i class="fa-solid fa-car-on pr-1"></i>
</td>
<td>
${radioDetails.vehicle ?? ""}
</td>
</tr>
<tr>
<td>
<i class="fa-solid fa-tower-broadcast pr-1"></i>
</td>
<td>
${radioDetails.radio ?? radioDetails.radio_default}
</td>
</tr>
</table>
`;
}
DrawButtons(radiostates, current_id, default_state){
let buttons = ``;

if(current_id != -1){
buttons += `<button onclick="SetRadioStateShortcut(-1)" class="btn btn-block btn-sm btn-primary my-1">${default_state}</button>`;
}

if(radiostates.length > 0){
radiostates.forEach(function(element){
if(current_id != element.id){
let bgcolor = element.color;
let FgColor = System.GetFgColorByBgColor(bgcolor);

buttons += `<button onclick="SetRadioStateShortcut(${element.id})" class="btn btn-block btn-sm my-1" style="background-color:${bgcolor}; color:${FgColor}">${element.short_name}</button>`;
}
});
}
document.getElementById("radiostates_actions").innerHTML = buttons;
}

}

View file

@ -0,0 +1,20 @@
class Rights{
constructor(rights){
this.fullright = "*"
this.rights = rights;
}

has(right_key){
let retval = false;

if(this.rights[right_key] !== undefined){
retval = this.rights[right_key];
}
if(!retval && this.rights["*"] !== undefined){
retval = this.rights["*"]
}

return retval;
}
}

View file

@ -0,0 +1,22 @@
class Sync{
constructor(syncData){
this.sync = {}

this.sync.licenses = syncData.LicensesSync

if(syncData.MainSync.active){
this.sync.files = syncData.MainSync.types.Users
this.sync.files_licenses = syncData.MainSync.types.Users && syncData.MainSync.types.UserLicenses
this.sync.regvehicle = syncData.MainSync.types.Vehicles
}
}

isActive(key){
let retval = false;

if(this.sync[key] !== undefined){
retval = this.sync[key];
}
return retval;
}
}

View file

@ -0,0 +1,85 @@
const navigation = {
"police" : {
"none":[
{key:"dashboard", img:"fa-solid fa-chart-line","destination":"dashboard.dataload", "forceReload":true, "rightkey" :null },
{key:"notes", img:"fa-solid fa-circle-info","destination":"notes.dataload", "forceReload":true, "rightkey" :null }
],
"files":[
{key:"files", img:"fa-regular fa-file", "destination":"files.overview", "forceReload":true, "rightkey" :"files.view"},
{key:"criminalcomplaint", img:"fa-regular fa-file", "destination":"criminalcomplaint.overview", "forceReload":true, "rightkey" :"criminalcomplaint.view"},
{key:"manhunt", img:"fa-solid fa-magnifying-glass", "destination":"manhunt.dataload", "forceReload":true, "rightkey" :"manhunt.view"},
{key:"regvehicle", img:"fa-solid fa-car","destination":"regvehicle.overview", "forceReload":true, "rightkey" :"regvehicles.view"},
{key:"regvehicleimpounded", img:"fa-solid fa-car","destination":"regvehicleimpounded.overview", "forceReload":true, "rightkey" :"regvehicles.view"},
{key:"regweapons", img:"fa-solid fa-gun","destination":"regweapons.overview", "forceReload":true, "rightkey" :"regweapons.view"},
{key:"evidencerooms", img:"fa-solid fa-box-archive","destination":"evidencerooms.dataload", "forceReload":true, "rightkey" :"evidencerooms.view"},
{key:"prison", img:"fa-solid fa-handcuffs","destination":"prison.overview", "forceReload":true, "rightkey" :"prison.view"},
{key:"sharedfiles", img:"fa-solid fa-share-nodes","destination":"sharedfiles.overview", "forceReload":true, "rightkey" :"sharedfiles.view"},
],
"speedcams":[
{key:"speedcamsmobile", img:"fa-solid fa-camera","destination":"speedcamsmobile.overview", "forceReload":true, "rightkey" :"speedcams.view"},
{key:"speedcamsprofit", img:"fa-solid fa-hand-holding-dollar","destination":"speedcamsprofit.overview", "forceReload":true, "rightkey" :"speedcamsprofit.view"},
],
"employees":[
{key:"employees", img:"fa-solid fa-people-group","destination":"employees.overview", "forceReload":true, "rightkey" :"employees.view"},
{key:"trainings", img:"fa-solid fa-graduation-cap","destination":"trainings.overview", "forceReload":true, "rightkey" :"trainings.view"},
{key:"missionreport", img:"fa-solid fa-file-lines","destination":"missionreport.overview", "forceReload":true, "rightkey" :"missionreport.view"},
],
"administration":[
{key:"lawbooks", img:"fa-solid fa-section","destination":"lawbooks.dataload", "forceReload":true, "rightkey" :"lawbooks.view"},
{key:"investigation", img:"fa-solid fa-book-atlas", "destination":"investigation.overview", "forceReload":true, "rightkey" :"investigation.view"},
],
"radiotraffic":[
{key:"radiostate", img:"fa-solid fa-tower-broadcast","destination":"radiostate.overview", "forceReload":true, "rightkey" :null},
{key:"emergencyvehicle", img:"fa-solid fa-car-on","destination":"emergencyvehicle.overview", "forceReload":true, "rightkey" :null},
{key:"controlcentre", "img":"fa-solid fa-building-flag", "destination":"controlcentre.dataload", "forceReload":true, "rightkey" :"controlcentre.view"},
],
"system":[
{key:"licenses", img:"fa-solid fa-id-card","destination":"licenses.overview", "forceReload":true, "rightkey" :"licenses.view"},
{key:"rankmanagement", img:"fa-solid fa-user-group","destination":"rankmanagement.dataload", "forceReload":true, "rightkey" :"isboss"},
]
}


,"medic":{
"none":[
{key:"dashboard", img:"fa-solid fa-chart-line","destination":"dashboard.dataload", "forceReload":true, "rightkey" :null },
{key:"notes", img:"fa-solid fa-circle-info","destination":"notes.dataload", "forceReload":true, "rightkey" :null }
],
"files":[
{key:"files", img:"fa-regular fa-file", "destination":"files.overview", "forceReload":true, "rightkey" :"files.view"},
{key:"sharedfiles", img:"fa-solid fa-share-nodes","destination":"sharedfiles.overview", "forceReload":true, "rightkey" :"sharedfiles.view"},
],
"employees":[
{key:"employees", img:"fa-solid fa-people-group","destination":"employees.overview", "forceReload":true, "rightkey" :"employees.view"},
{key:"trainings", img:"fa-solid fa-graduation-cap","destination":"trainings.overview", "forceReload":true, "rightkey" :"trainings.view"},
{key:"missionreport", img:"fa-solid fa-file-lines","destination":"missionreport.overview", "forceReload":true, "rightkey" :"missionreport.view"},
],
"radiotraffic":[
{key:"radiostate", img:"fa-solid fa-tower-broadcast","destination":"radiostate.overview", "forceReload":true, "rightkey" :null},
{key:"emergencyvehicle", img:"fa-solid fa-car-on","destination":"emergencyvehicle.overview", "forceReload":true, "rightkey" :null},
{key:"controlcentre", "img":"fa-solid fa-building-flag", "destination":"controlcentre.dataload", "forceReload":true, "rightkey" :"controlcentre.view"},
],
"system":[
{key:"licenses", img:"fa-solid fa-id-card","destination":"licenses.overview", "forceReload":true, "rightkey" :"licenses.view"},
{key:"rankmanagement", img:"fa-solid fa-user-group","destination":"rankmanagement.dataload", "forceReload":true, "rightkey" :"isboss"},
]
}
,"default":{
"none":[
{key:"dashboard", img:"fa-solid fa-chart-line","destination":"dashboard.dataload", "forceReload":true, "rightkey" :null }
],
"employees":[
{key:"employees", img:"fa-solid fa-people-group","destination":"employees.overview", "forceReload":true, "rightkey" :"employees.view"},
{key:"trainings", img:"fa-solid fa-graduation-cap","destination":"trainings.overview", "forceReload":true, "rightkey" :"trainings.view"},
{key:"missionreport", img:"fa-solid fa-file-lines","destination":"missionreport.overview", "forceReload":true, "rightkey" :"missionreport.view"},
],
"radiotraffic":[
{key:"radiostate", img:"fa-solid fa-tower-broadcast","destination":"radiostate.overview", "forceReload":true, "rightkey" :null},
{key:"emergencyvehicle", img:"fa-solid fa-car-on","destination":"emergencyvehicle.overview", "forceReload":true, "rightkey" :null},
{key:"controlcentre", "img":"fa-solid fa-building-flag", "destination":"controlcentre.dataload", "forceReload":true, "rightkey" :"controlcentre.view"},
],
"system":[
{key:"rankmanagement", img:"fa-solid fa-user-group","destination":"rankmanagement.dataload", "forceReload":true, "rightkey" :"isboss"},
]
}
};

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,79 @@
class ControlCentre{
constructor(){
this.name = "controlcentre";
}
static isCustom(){
return true;
}
static allowTake(){
return userrights.has("controlcentre.take");
}
static CreateCustom(data){
let buttons = ``;
if(this.allowTake()){
if(data.data.control_centre.is_taken){
buttons = `<button onclick="takeControlCentre(true)" class="btn btn-sm btn-error">${getTranslation("current_control_centre_reset")}</button>`
buttons += `<button onclick="takeControlCentre(false)" class="btn btn-sm btn-primary">${getTranslation("current_control_centre_take")}</button>`
}
else{
buttons = `<button onclick="takeControlCentre(false)" class="btn btn-sm btn-primary">${getTranslation("current_control_centre_take")}</button>`
}
}
document.getElementById("currentpage-content").innerHTML = `
<div class="card w-full bg-info text-info-content">
<div class="card-body">
<h2 class="card-title uppercase font-bold">${getTranslation("current_control_centre")}</h2>
<p><strong>${data.data.control_centre.is_taken ? System.buildEmployeeName(data.data.control_centre.name) : getTranslation("no_control_centre") }</strong></p>
<p></p>
<div class="card-actions justify-start">
${buttons}
</div>
</div>
</div>
`;
document.getElementById("currentpage-content").innerHTML += `
<div class="collapse collapse-open border border-base-300 bg-base-100 rounded-box mt-4">
<div class="collapse-title text-xl font-medium">
${getTranslation("emergencyvehicle.overview")}
</div>
<div class="collapse-content">
${System.GetTable(ControlCentreEmergancyVehicles, data.data.emergency_vehicles)}
</div>
</div>
`;
document.getElementById("currentpage-content").innerHTML += `
<div class="collapse collapse-open border border-base-300 bg-base-100 rounded-box mt-4">
<div class="collapse-title text-xl font-medium">
${getTranslation("employees.overview")}
</div>
<div class="collapse-content">
${System.GetTable(ControlCentreEmployees, data.data.employees)}
</div>
</div>
`;
}
static GetEdit(data={}){
return {
"name": {
"val" : data.name ?? ""
,"type" : "text"
,"mandatory":true
,"isRow":true
}
,"short_name": {
"val" : data.short_name ?? ""
,"type" : "text"
,"mandatory":true
,"isRow":true
}
}
}
}

View file

@ -0,0 +1,57 @@
class ControlCentreEmergancyVehicles{
constructor(){
this.name = "controlcentreemployees";
}
static allowEdit(){
return userrights.has("controlcentre.take");
}
static isCustom(){
return true;
}
static GetColumns(){
return ["short_name","name","employees","radio_short_name","id"]
}
static TableDataCreate(row, key){
let FgColor = System.GetFgColorByBgColor(row["radio_color"]);
if(row["radio_color"] == ""){
row["radio_color"] = "#FFFFFF";
}
if(key == "id"){
if(this.allowEdit()){
return `
<td style="color:${FgColor}; background:${row["radio_color"]}">
<button type="button" class="btn btn-sm btn-primary" onclick="resetVehicle('${row["id"]}')">
<i class="fa-solid fa-delete-left"></i>
</button>
<button type="button" class="btn btn-sm btn-warning" onclick="loadPage('emergencyvehicleradio.edit','${row["id"]}')">
<i class="fa-solid fa-tower-broadcast"></i>
</button>
</td>`;
}
else{
return ``;
}
}
else if(key == "radio_short_name"){
return `
<td style="color:${FgColor}; background:${row["radio_color"]}">
${row[key] == "" ? getTranslation("emergency_vehicles_no_radio") : row[key]}
</td>`;
}
else if(key == "employees"){
return `
<td style="color:${FgColor}; background:${row["radio_color"]}">
${System.buildEmployeeName(row[key])}
</td>`;
}
else {
return `<td style="color:${FgColor}; background:${row["radio_color"]}">${row[key]}</td>`;
}
}
}

View file

@ -0,0 +1,59 @@
class ControlCentreEmployees{
constructor(){
this.name = "controlcentreemployees";
}
static allowEdit(){
return userrights.has("controlcentre.take");
}
static isCustom(){
return true;
}
static GetColumns(){
return ["name","radio_short_name","id"]
}
static TableDataCreate(row, key){
let FgColor = System.GetFgColorByBgColor(row["radio_color"]);
if(row["radio_color"] == ""){
row["radio_color"] = "#FFFFFF";
}
if(key == "id"){
if(!this.allowEdit()){
return `<td></td>`
}
return `
<td style="color:${FgColor}; background:${row["radio_color"]}">
<button type="button" class="btn btn-sm btn-primary" onclick="resetEmployeeRadio('${row["id"]}')">
<i class="fa-solid fa-delete-left"></i>
</button>
<button type="button" class="btn btn-sm btn-warning" onclick="loadPage('employeevehicle.edit', '${row["id"]}')">
<i class="fa-solid fa-car-on"></i>
</button>
<button type="button" class="btn btn-sm btn-warning" onclick="loadPage('employeeradio.edit', '${row["id"]}')">
<i class="fa-solid fa-tower-broadcast"></i>
</button>
</td>`;
}
else if(key == "radio_short_name"){
return `
<td style="color:${FgColor}; background:${row["radio_color"]}">
${row[key] == "" ? getTranslation("emergency_vehicles_no_radio") : row[key]}
</td>`;
}
else if(key == "name"){
return `
<td style="color:${FgColor}; background:${row["radio_color"]}">
${row["serviceno"] ?? System.getServiceNo(row.id)} - ${System.buildEmployeeName(row[key])}
</td>`;
}
else {
return `<td style="color:${FgColor}; background:${row["radio_color"]}">${row[key]}</td>`;
}
}
}

View file

@ -0,0 +1,119 @@
class CriminalComplaint{
constructor(){
this.name = "criminalcomplaint";
}
static allowAddNew(){
return userrights.has("criminalcomplaint.edit")
}
static allowEdit(){
return userrights.has("criminalcomplaint.edit")
}
static allowDelete(){
return userrights.has("criminalcomplaint.delete")
}
static GetColumns(){
return ["charge_from","perpetrator","state","id"]
}
static TableDataCreate(row, key){
if(key == "id"){
return `
<td>
${Form.getViewButtonIcon(row[key], this.name + ".view")}
${Form.getEditButtonIcon(row[key] , this.name + ".edit", this.allowEdit())}
${Form.getDeleteButtonIcon(row[key], this.name, this.allowDelete())}
</td>`;
}
else if(key == "state"){
let complaint = System.GetComplaintByID(row[key]);
return `
<td>
<div class="badge font-bold ${complaint.color ?? ""}">${complaint.name ?? ""}</div>
</td>`;
}
else if(key == "charge_from" || key == "perpetrator"){
let val = row[key];
if(val == ""){
val = getTranslation("unknown");
}
return `
<td>
${val}
</td>`;
}
else{
return `<td>${row[key]}</td>`;
}
}
static GetEdit(data={}){
let filesOptions = [
{"id":-1, "name":getTranslation("unknown")}
,{"id":-2, "name":getTranslation("new_file"), "show_extra_field":true}
];
if(sync.isActive("files")){
filesOptions = [
{"id":-1, "name":getTranslation("unknown")}
];
}
let perpetrators = [...filesOptions, ...data.extraData.perpetrators];
let charge_froms = [...filesOptions, ...data.extraData.charge_froms];
return {
"charge_from": {
"val" : data.charge_from_id ?? "-1"
,"type" : "searchdropdown"
,"mandatory":true
,options:charge_froms
}
,"perpetrator": {
"val" : data.perpetrator_id ?? "-1"
,"type" : "searchdropdown"
,"mandatory":true
,options:perpetrators
}
,"perpetrator_description":{
"val" : data.perpetrator_description ?? ""
,"type" : "textarea"
,"isRow": true
,"mandatory":true
,autogrow: false
,rows:3
}
,"state": {
"val" : data.state ?? ""
,"type" : "dropdown"
,"mandatory":true
,"isRow":true
,options:System.GetCompaintStateOptions()
}
,"act_of_crime":{
"val" : data.act_of_crime ?? ""
,"type" : "textarea"
,"isRow": true
,"mandatory":false
,autogrow: false
,rows:3
}
,"notes":{
"val" : data.notes ?? ""
,"type" : "textarea"
,"isRow": true
,"mandatory":false
,autogrow: false
,rows:3
}
}
}
}

View file

@ -0,0 +1,167 @@
class Dashboard{
constructor(){
this.name = "dashboard";
}
static isCustom(){
return true;
}
static CreateCustom(data){
let controlCenterBg = "";
if(data.data.control_centre == ""){
controlCenterBg = "error"
data.data.control_centre = getTranslation("no_control_centre");
}
else{
data.data.control_centre = System.buildEmployeeName(data.data.control_centre)
}
let possibleStats = [];
let stats = [];
if(currentSystem == "police"){

let entries_per_file = 0;
if(data.data.info[0].files > 0 && data.data.info[0].fileentry){
entries_per_file = data.data.info[0].fileentry/data.data.info[0].files;
}

possibleStats = [
[
{name:"files.overview", navItem: "files", text : data.data.info[0].files, goto:"files.overview", "gotoAllowed":userrights.has("files.view")},
{name:"fileentry.overview", navItem: "files", text : data.data.info[0].fileentry},
{name:"avg_files_entry", navItem: "files", text : "&Oslash; " + (entries_per_file).toFixed(2) },
],
[
{name:"control_centre", navItem: "controlcentre", text : data.data.control_centre, bg:controlCenterBg, goto:"controlcentre.dataload", "gotoAllowed":userrights.has("controlcentre.view")},
{name:"employees.overview", navItem: "employees", text : data.data.info[0].employees, goto:"employees.overview","gotoAllowed":userrights.has("employees.view")},
{name:"count_employees_available", navItem: "employees", text : data.data.info[0].employees_available},
],
[
{name:"regvehicle.overview", navItem: "regvehicle", text : data.data.info[0].regvehicle, goto:"regvehicle.overview","gotoAllowed":userrights.has("regvehicles.view")},
{name:"regweapons.overview", navItem: "regweapons", forceHide: useWeaponRegister, text : data.data.info[0].regweapons, goto:"regweapons.overview","gotoAllowed":userrights.has("regweapons.view")},
{name:"investigation.overview", navItem: "investigation", text : data.data.info[0].investigation, goto:"investigation.overview","gotoAllowed":userrights.has("investigation.view")},
{name:"investigation.overview", navItem: "investigation", "nameextra":getTranslation("state_open"), text : data.data.info[0].investigation_open},
],
[
{name:"active_manhunt", navItem: "manhunt", text : data.data.info[0].manhunt_files + data.data.info[0].manhunt_regvehicle + data.data.info[0].manhunt_regweapons, bg:"warning", goto: "manhunt.dataload","gotoAllowed":userrights.has("manhunt.view")},
{name:"files.overview", navItem: "files", "nameextra":getTranslation("tag_is_wanted"), text : data.data.info[0].manhunt_files, bg:"warning", goto: "manhunt.dataload","gotoAllowed":userrights.has("manhunt.view")},
{name:"regvehicle.overview", navItem: "regvehicle", "nameextra":getTranslation("tag_is_wanted"), text : data.data.info[0].manhunt_regvehicle, bg:"warning", goto: "manhunt.dataload","gotoAllowed":userrights.has("manhunt.view")},
{name:"regweapons.overview", navItem: "regweapons", forceHide: useWeaponRegister, "nameextra":getTranslation("tag_is_wanted"), text : data.data.info[0].manhunt_regweapons, bg:"warning", goto: "manhunt.dataload","gotoAllowed":userrights.has("manhunt.view")},
]
];
}
else if(currentSystem == "medic"){
let entries_per_file = 0;
if(data.data.info[0].files > 0 && data.data.info[0].fileentry){
entries_per_file = data.data.info[0].fileentry/data.data.info[0].files;
}
possibleStats = [
[
{name:"files.overview", navItem: "files", text : data.data.info[0].files, goto:"files.overview", "gotoAllowed":userrights.has("files.view")},
{name:"fileentry.overview", navItem: "files", text : data.data.info[0].fileentry},
{name:"avg_files_entry", navItem: "files", text : "&Oslash; " + (entries_per_file).toFixed(2) },
],
[
{name:"control_centre", navItem: "controlcentre", text : data.data.control_centre, bg:controlCenterBg, goto:"controlcentre.dataload", "gotoAllowed":userrights.has("controlcentre.view")},
{name:"employees.overview", navItem: "employees", text : data.data.info[0].employees, goto:"employees.overview","gotoAllowed":userrights.has("employees.view")},
{name:"count_employees_available", navItem: "employees", text : data.data.info[0].employees_available},
],
];
}
else{
possibleStats = [
[
{name:"control_centre", navItem: "controlcentre", text : data.data.control_centre, bg:controlCenterBg, goto:"controlcentre.dataload", "gotoAllowed":userrights.has("controlcentre.view")},
{name:"employees.overview", navItem: "employees", text : data.data.info[0].employees, goto:"employees.overview","gotoAllowed":userrights.has("employees.view")},
{name:"count_employees_available", navItem: "employees", text : data.data.info[0].employees_available},
]
]
}



for(let i=0; i<possibleStats.length; i++){

stats[i] = [];
for(let j=0; j<possibleStats[i].length; j++){
let statEl = possibleStats[i][j];
let display = false;

if(statEl.navItem == undefined || statEl.navItem == null){
display = true;
}
else{
let navItem = document.getElementById("menuItem-li-" + statEl.navItem);
let forceHide = statEl.forceHide;

if(navItem !== null && forceHide != true){
display = true;
}
}

if(display){
stats[i].push(statEl);
}
}
}
let statsHTML = ``;
for(let i=0; i<stats.length; i++){
if (stats[i].length == 0) {
continue;
}

statsHTML += `<div class="grid pt-8 md:grid-cols-${stats[i].length} grid-cols-1 gap-6">`
for(let j=0; j<stats[i].length; j++){
let btn = ``;
let bgClasses = "";
let txtclasses = null;
let txtExtra = "";
if(stats[i][j].goto !== undefined && stats[i][j].goto !== null && stats[i][j].goto != ""){
let allowed = stats[i][j].gotoAllowed ?? true
if(allowed){
btn = `<button class="btn btn-xs" onclick="loadPage('${stats[i][j].goto}',-1)">${getTranslation("goto")} ${getTranslation(stats[i][j].goto)}</button>`
}
}
if(stats[i][j].nameextra !== undefined && stats[i][j].nameextra !== null && stats[i][j].nameextra != ""){
txtExtra = ` (${stats[i][j].nameextra})`
}
if(stats[i][j].bg !== undefined && stats[i][j].bg !== null && stats[i][j].bg != ""){
bgClasses = `bg-${stats[i][j].bg}`
txtclasses = `text-${stats[i][j].bg}-content`
}
let textclass2="text-primary"
textclass2 = "";
statsHTML += `
<div class="stats shadow ${bgClasses}">
<div class="stat">
<div class="stat-title ${txtclasses}">${getTranslation(stats[i][j].name)}${txtExtra}</div>
<div class="stat-value ${txtclasses ?? textclass2}">${stats[i][j].text}</div>
<div class="stat-actions">${btn}</div>
</div>
</div>
`
}
statsHTML += `</div>`
}
document.getElementById("currentpage-content").innerHTML = statsHTML;
}
}

View file

@ -0,0 +1,94 @@
class EmergencyVehicle{
constructor(){
this.name = "emergencyvehicle";
}
static allowAddNew(){
return userrights.has("emergencyvehicle.edit")
}
static allowEdit(){
return userrights.has("emergencyvehicle.edit")
}
static allowDelete(){
return userrights.has("emergencyvehicle.delete")
}
static GetExtraForOverview(data){
let retval = {
top:"",
bottom:""
}
let buttons = ``;
let currentVehicle = getTranslation("no_current_vehicle");
if(data.current_vehicle!== undefined && data.current_vehicle.length > 0 && data.current_vehicle[0].id !== undefined && data.current_vehicle[0].id > -1){
currentVehicle = data.current_vehicle[0].short_name + " - " + data.current_vehicle[0].name
buttons = `
<button type="button" class="btn btn-sm btn-primary" onclick="SetVehicle(-1,'emergencyvehicle.overview')">${getTranslation("leave_patrol")}</button>
`
}
retval.top = `
<div class="alert alert-info shadow-lg mb-4">
<div>
<div>${getTranslation("current_vehicle")}: <strong>${currentVehicle}</strong></div>
<div>
${buttons}
</div>
</div>
</div>
`;
return retval;
}
static GetColumns(){
return ["name","short_name","vehicle","action","id"]
}
static TableDataCreate(row, key){
if(key == "id"){
return `
<td>
${Form.getEditButtonIcon(row[key] , this.name + ".edit", this.allowEdit())}
${Form.getDeleteButtonIcon(row[key], this.name, this.allowDelete())}
</td>`;
}
else if(key == "action"){
return `
<td>
<button type="button" class="btn btn-primary btn-sm" onclick="SetVehicle(${row["id"]}, 'emergencyvehicle.overview')">${getTranslation("set_state")}</button>
</td>`;
}
else{
return `<td>${row[key]}</td>`;
}
}
static GetEdit(data = {}){
return {
"name": {
"val" : data.name ?? ""
,"type" : "text"
,"isRow": true
,"mandatory":true
}
,"short_name": {
"val" : data.short_name ?? ""
,"type" : "text"
,"isRow": true
,"mandatory":true
}
,"vehicle": {
"val" : data.vehicle ?? ""
,"type" : "text"
,"isRow": true
,"mandatory":true
}
}
}
}

View file

@ -0,0 +1,33 @@
class EmergencyVehicleRadio{
constructor(){
this.name = "emergencyvehicleradio";
}
static GetCustomDestination(data, dest){
return "controlcentre.dataload";
}
static GetCustomDestID(data, destID){
return -1;
}
static GetColumns(){
return []
}
static TableDataCreate(row, key){
return `<td>${row[key]}</td>`;
}
static GetEdit(data={}){
return {
"radio_status_id": {
"val" : data.radio_status_id ?? "-1"
,"type" : "dropdown"
,"mandatory":true
,"isRow":true
,"options":data.extraData.radio_states
}
}
}
}

View file

@ -0,0 +1,33 @@
class EmployeeRadio{
constructor(){
this.name = "employeeradio";
}
static GetCustomDestination(data, dest){
return "controlcentre.dataload";
}
static GetCustomDestID(data, destID){
return -1;
}
static GetColumns(){
return []
}
static TableDataCreate(row, key){
return `<td>${row[key]}</td>`;
}
static GetEdit(data={}){
return {
"radio_status_id": {
"val" : data.radio_status_id ?? "-1"
,"type" : "dropdown"
,"mandatory":true
,"isRow":true
,"options":data.extraData.radio_states
}
}
}
}

View file

@ -0,0 +1,33 @@
class EmployeeVehicle{
constructor(){
this.name = "employeevehicle";
}
static GetCustomDestination(data, dest){
return "controlcentre.dataload";
}
static GetCustomDestID(data, destID){
return -1;
}
static GetColumns(){
return []
}
static TableDataCreate(row, key){
return `<td>${row[key]}</td>`;
}
static GetEdit(data={}){
return {
"emegency_vehicle_id": {
"val" : data.emegency_vehicle_id ?? "-1"
,"type" : "dropdown"
,"mandatory":true
,"isRow":true
,"options":data.extraData.vehicles
}
}
}
}

View file

@ -0,0 +1,244 @@
class Employees{
constructor(){
this.name = "employees";
}
static allowEdit(){
return userrights.has("employees.edit");
}
static allowAddNew(){
return false;
}
static allowSuspend(){
return userrights.has("employees.suspend")
}
static allowViewEmployeeEntries(){
return userrights.has("employeesentries.view")
}
static allowEditEmployeeEntries(){
return userrights.has("employeesentries.edit")
}
static allowDeleteEmployeeEntries(){
return userrights.has("employeesentries.delete")
}
static allowFinishEmployeeEntries(){
return userrights.has("employeesentries.finish")
}
static allowViewUserTrainings(){
return userrights.has("trainingsemployees.view")
}
static GetExtraForView(data){
let retval = {
top:"",
bottom:""
}
let suspendedText = getTranslation("suspend");
let suspended_new = 1;
if(data.extraData.is_suspended !== undefined && data.extraData.is_suspended.length > 0 && data.extraData.is_suspended[0].is_suspended == true){
suspendedText = getTranslation("unsuspend");
suspended_new = 0;
}
let buttons = ``;
if(this.allowSuspend()){
buttons += `<button type="button" class="btn btn-sm
btn-warning" onclick="changeDataInColumn('employees','is_suspended','${data.id}','${suspended_new}')">${suspendedText}</button>`;
//buttons += `<button type="button" class="btn btn-sm btn-warning" onclick="EmployeeSuspend('employees','${data.id}','${suspended_new}')">${suspendedText}</button>`;
}
if(this.allowEditEmployeeEntries()){
buttons += `<button type="button" class="btn btn-sm btn-primary" onclick="loadPage('employeesentry.add',-1,'false',{data:{employee_id:'${data.id}'}})">${getTranslation("fileentry.add")}</button>`;
}
if(this.allowViewUserTrainings()){
buttons += `<button type="button" class="btn btn-sm btn-primary" onclick="loadPage('employeestraining.dataload','${data.id}')">${getTranslation("employeestraining.dataload")}</button>`;
}
retval.bottom += `
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 pt-6">
${buttons}
</div>
`;
if(this.allowViewEmployeeEntries() && data.extraData.file_entries !== undefined){
let entryTypes = System.getEmployeeEntryTypes();
retval.bottom += `
<div class="collapse collapse-arrow border border-base-300 bg-base-100 rounded-box mt-4">
<input type="checkbox" />
<div class="collapse-title text-xl font-medium">
${getTranslation("employees_file")}
</div>
<div class="collapse-content">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 pt-6">`;
for(let i=0;i<data.extraData.file_entries.length;i++){
let row = data.extraData.file_entries[i];
let bgColor = entryTypes[row.type_of_entry].color ?? "ghost";
let type_name = entryTypes[row.type_of_entry].name ?? "";
let badges = ``;
badges += `<div class="badge badge-${bgColor} gap-2">${type_name}</div>`;
if(row.closed){
badges += `<div class="badge badge-success gap-2">${getTranslation("entry_finished")}</div>`;
}
let buttons = ``;
if(!row.closed && this.allowFinishEmployeeEntries()){
buttons += `<button onclick="changeDataInColumn('employeesentry', 'closed', '${row.id}', 1)" class="btn btn-sm btn-primary">${getTranslation("finish_file_entry")}</button>`;
}
if(this.allowDeleteEmployeeEntries()){
buttons += `<button onclick="Form.openDeleteModal('${row.id}','employeesentry')" class="btn btn-sm btn-error">${getTranslation("delete")}</button>`;
}
let temp = `
<div class="card w-full bg-neutral text-neutral-content">
<div class="card-body">
<h2 class="card-title uppercase font-bold">${System.buildEmployeeName(row.creator)} - ${System.formatTimestamp(row.creationdate)}</h2>
<h2 class="card-title uppercase font-bold">${badges}</h2>
<p class="border border-current rounded-xl p-1 break-all">${row.content.replace(/\n/g,"<br>")}</p>
<p></p>
<div class="card-actions justify-start">
${buttons}
</div>
</div>
</div>
`;
if( i % 2 === 0){
temp += `<div></div>`
}
else{
temp = `<div></div>` + temp
}
retval.bottom += temp;
}
retval.bottom += `
</div>
</div>
</div>`;
}
return retval;
}
static GetEdit(data={}){
let serviceno = null;
if(data !== null){
if(data.extraData.serviceno !== undefined && data.extraData.serviceno !== null && data.extraData.serviceno.length > 0){
serviceno = data.extraData.serviceno[0].serviceno ?? System.getServiceNo(data.identifier ?? data.citizenid)
}
else{
serviceno = System.getServiceNo(data.identifier ?? data.citizenid);
}
}
return {
"serviceno": {
"val" : serviceno ?? ""
,"type" : "text"
,isRow:true
,hideInEdit:false
},
"firstname": {
"val" : data.firstname ?? System.getFirstName(data.charinfo ?? "")
,"type" : "text"
,hideInEdit:true
},
"lastname": {
"val" : data.lastname ?? System.getLastName(data.charinfo ?? "")
,"type" : "text"
,"mandatory":true
,hideInEdit:true
}
,"rank": {
"val" : data.job_grade ?? System.getJobGrade(data.job)
,"type" : "dropdown"
,"mandatory":true
,isRow:true
,options:System.getRankOptions()
,hideInEdit:true
}
}
}
static GetColumns(){
return ["serviceno","name","rank_name","state","id"]
}
static TableDataCreate(row, key){
if(key == "id"){
return `
<td>
${Form.getViewButtonIcon(row[key], this.name + ".view")}
${Form.getEditButtonIcon(row[key], this.name + ".edit", this.allowEdit())}
</td>`;
}
else if(key == "serviceno"){
return `
<td>
${row[key] ?? System.getServiceNo(row.id)}
</td>`;
}
else if(key == "name"){
return `
<td>
${System.buildEmployeeName(row[key])}
</td>`;
}
else if(key == "state"){
if(row[key] != ""){
return `
<td>
<div class="badge badge-warning font-bold">${getTranslation("state_" + row[key])}</div>
</td>`;
}
else{
return `<td></td>`
}
}
else if(key == "rank_name"){
let grade = -9999
try {
if(typeof JSON.parse(row[key]) == "number"){
grade = row[key]
}
}
catch (e) {
grade = row[key]
}
if(grade == -9999){
grade = System.getJobGrade(row[key]);
}
return `
<td>
${System.getLabelByRank(grade)}
</td>
`;
}
else {
return `<td>${row[key]}</td>`;
}
}
}

View file

@ -0,0 +1,45 @@
class EmployeesEntry{
constructor(){
this.name = "employeesentry";
}
static GetCustomDestination(data, dest){
return (data.employee_id ?? "" != "" ? "employees.view" : "employees.overview");
}
static GetCustomDestID(data, destID){
return data.employee_id ?? destID;
}
static GetColumns(){
return [];
}
static TableDataCreate(row, key){
return `<td>${row[key]}</td>`;
}
static GetEdit(data = {}){
return {
"employee_id": {
"val" : data.employee_id ?? ""
,"type" : "hidden"
,"mandatory":true
}
,"content": {
"val" : data.content ?? ""
,"type" : "textarea"
,"mandatory":true
,"isRow":true
,autogrow: true
}
,"type_of_entry": {
"val" : data.type_of_entry ?? 0
,"type" : "dropdown"
,"mandatory":true
,"isRow":true
,"options":System.getEmployeeEntryTypesOptions()
}
};
}
}

View file

@ -0,0 +1,88 @@
class EmployeesTraining{
constructor(){
this.name = "employeestraining";
}
static GetCustomDestination(data, dest){
return (data.employee_id ?? "" != "" ? "employees.view" : "employees.overview");
}
static GetCustomDestID(data, destID){
return data.employee_id ?? destID;
}
static isCustom(){
return true;
}
static GetColumns(){
return ["name","action","passed","id"]
}
static CreateCustom(data){
document.getElementById("currentpage-content").innerHTML=Form.BackEditBtn("employees.view", "", -1, false, data.data.employee_id);
document.getElementById("currentpage-content").innerHTML+=System.GetTable(this, data.data.trainings);
Form.initViewModeTopButtons();
}
static TableDataCreate(row, key){
if(key == "id"){
if(row.passed > -1){
return `
<td>
<button type="button" class="btn btn-sm btn-error" onclick="trainingPassed(-1, '${row["employee_id"]}', '${row["id"]}', true)">
<i class="fa-solid fa-delete-left"></i>
</button>
</td>`;
}
else{
return `<td></td>`;
}
}
else if(key == "action"){
let disabled = "";
if(row.entered > 0){
disabled = " disabled"
}
let content = `<button type="button" class="btn btn-sm btn-primary" onclick="participateForTraining(${row["id"]}, '${row["employee_id"]}', true)" ${disabled}>${getTranslation("participate")}</button>`
return `
<td>
${content}
</td>`;
}
else if(key == "passed"){
let content = "";
if(row[key] == -1){
content = `
<button type="button" class="btn btn-sm btn-error" onclick="trainingPassed(0, '${row["employee_id"]}', '${row["id"]}', true)">
<i class="fa-solid fa-xmark"></i>
</button>
<button type="button" class="btn btn-sm btn-success" onclick="trainingPassed(1, '${row["employee_id"]}', '${row["id"]}', true)">
<i class="fa-solid fa-check"></i>
</button>`
;
}
else if(row[key] == 0){
content = `<i class="fa-solid fa-xmark text-error"></i>`;
}
else if(row[key] == 1){
content = `<i class="fa-solid fa-check text-success"></i>`;
}
return `
<td>
${content}
</td>`;
}
else{
return `<td>${row[key]}</td>`;
}
}
}

View file

@ -0,0 +1,138 @@
class EvidenceRoomArticles{
constructor(){
this.name = "evidenceroomarticles";
}
static isCustom(){
return true;
}
static allowEdit(){
return userrights.has("evidencerooms.edit");
}
static allowDelete(){
return userrights.has("evidencerooms.delete");
}
static GetColumns(isReadOnly){
if(isReadOnly == true){
return ["name","amount","file_name","state","changedate"]
}
else{
return ["name","amount","file_name","state","changedate","id"]
}
}
static TableDataCreate(row, key,isReadOnly){
if(key == "id"){
return `
<td>
${Form.getEditButtonIcon(row[key], this.name + ".edit", this.allowEdit())}
${Form.getDeleteButtonIcon(row[key], this.name ,this.allowDelete())}
</td>`;
}
else if(key == "changedate") {
return `<td>${row[key]}<br>${System.buildEmployeeName(row.changedby)}</td>`;
}
else if(key == "state"){
let state = this.GetStateByID(row[key]);

return `
<td>
<div class="badge font-bold ${state.color ?? ""}">${state.name ?? ""}</div>
</td>`;
}
else if(key == "file_name"){
let val = row[key];
if(val == ""){
val = getTranslation("unknown");
}

return `
<td>
${val}
</td>`;
}
else {
return `<td>${row[key]}</td>`;
}
}
static GetEdit(data={}){

let filesOptions = [
{"id":-1, "name":getTranslation("unknown")}
,{"id":-2, "name":getTranslation("new_file"), "show_extra_field":true}
];
if(sync.isActive("files")){
filesOptions = [
{"id":-1, "name":getTranslation("unknown")}
];
}
let files = [...filesOptions, ...data.extraData.files];

return {
"evidenceroom_id": {
"val" : data.evidenceroom_id ?? "-1"
,"type" : "hidden"
},
"name": {
"val" : data.name ?? ""
,"type" : "text"
,"isRow":true
,"mandatory":true
}
,"amount": {
"val" : data.amount ?? ""
,"type" : "number"
,"isRow":true
,"mandatory":true
}
,"state": {
"val" : data.state ?? 0
,"type" : "dropdown"
,"isRow":true
,"mandatory":true
,options:this.GetStateOptions()
}
,"file_id": {
"val" : data.file_id ?? -1
,"type" : "searchdropdown"
,"mandatory":true
,"isRow":true
,options:files
}
}
}

static GetStateOptions(){
let retval = [];
let json = this.GetStates();
Object.keys(json).forEach(function(key){
retval.push({"id": key, "name":json[key].name })
});
return retval;
}
static GetStates(){
return {
"0" : {name:getTranslation("state_new"), "color":"badge-primary"},
"1" : {name:getTranslation("state_inprogress"), "color":"badge-warning"},
"2" : {name:getTranslation("state_stored"), "color":"badge-success"},
"3" : {name:getTranslation("state_destoyed"), "color":"badge-error"}
}
}

static GetStateByID(id){
return this.GetStates()[id] ?? {}
}

}

View file

@ -0,0 +1,28 @@
class EvidenceRoomArticlesDestroyed{
constructor(){
this.name = "evidenceroomarticlesdestroyed";
}
static isCustom(){
return true;
}
static allowDelete(){
return userrights.has("evidencerooms.delete");
}
static GetColumns(){
return ["name","amount","file_name","state","changedate"]
}


static CreateCustom(data){
document.getElementById("currentpage-content").innerHTML = Form.BackEditBtn("evidencerooms.dataload", "",-1, false, -1);

document.getElementById("currentpage-content").innerHTML += System.GetTable(System.getClassByName("evidenceroomarticles"), data.data, true)
Form.initViewModeTopButtons();
}


}

View file

@ -0,0 +1,117 @@
class EvidenceRooms{
constructor(){
this.name = "evidencerooms";
}
static allowAddNew(){
return userrights.has("evidencerooms.edit");
}
static allowEdit(){
return userrights.has("evidencerooms.edit");
}
static allowDelete(){
return userrights.has("evidencerooms.delete");
}
static isCustom(){
return true;
}
static CreateCustom(data, isEditMode = false){

let retval = ``;

if(!isEditMode){
document.getElementById("currentpage-content").innerHTML = Form.overviewHeadline(this.name.toLowerCase() + ".add", false, this.allowAddNew());
}

for(let i=0; i<data.data.length; i++){
let row = data.data[i];
let buttons = ``;
let bottomButton = ``;

let mbClass = "";
let mtClass = "";

if(this.allowAddNew()){
buttons += `<button type="button" class="btn btn-sm btn-success evidencerooms-add-entry" data-parentID="${row.id}">${getTranslation("add_entry")}</button>`;
}
if(this.allowEdit()){
buttons += `<button type="button" class="btn btn-sm btn-warning evidencerooms-edit" data-parentID="${row.id}">${getTranslation("edit")}</button>`;
}
if(this.allowDelete()){
buttons += `<button type="button" class="btn btn-sm btn-error" onclick="Form.openDeleteModal(${row.id}, 'evidencerooms')">${getTranslation("delete")}</button>`;
}
if(this.allowEdit()){
bottomButton += `<button type="button" class="btn btn-sm btn-block btn-primary evidencerooms-history" data-parentID="${row.id}">${getTranslation("view_destroyed")}</button>`;
}

if(buttons != ""){
mbClass = "mb-2";
}
if(bottomButton != ""){
mtClass = "mt-2";
}


if(!isEditMode || row.laws.length > 0){
retval += `
<div class="collapse collapse-arrow border border-base-300 bg-base-100 rounded-box mt-4">
<input type="checkbox" />
<div class="collapse-title text-xl font-medium">
${row.name}
</div>
<div class="collapse-content">
<div class="${mbClass}">
${buttons}
</div>
${System.GetTable(System.getClassByName("evidenceroomarticles"), row.articles)}
<div class = "${mtClass}">
${bottomButton}
</div>
</div>
</div>
`;
}
}
document.getElementById("currentpage-content").innerHTML += retval;
Form.initTableButtons();
Array.from(document.querySelectorAll(".evidencerooms-add-entry")).forEach(function(button){
button.onclick = function(){
let staticData = {
data:{
evidenceroom_id:this.getAttribute("data-parentID")
}
}
loadPage("evidenceroomarticles.add",this.getAttribute("data-parentID"),"false", staticData)
}
});
Array.from(document.querySelectorAll(".evidencerooms-edit")).forEach(function(button){
button.onclick = function(){
loadPage("evidencerooms.edit",this.getAttribute("data-parentID"),"true", {})
}
});
Array.from(document.querySelectorAll(".evidencerooms-history")).forEach(function(button){
button.onclick = function(){
loadPage("evidenceroomarticlesdestroyed.dataload",this.getAttribute("data-parentID"),"true", {})
}
});
}
static GetEdit(data={}){
return {
"name": {
"val" : data.name ?? ""
,"type" : "text"
,"mandatory":true
,"isRow":true
}
}
}
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,777 @@
class Files{
constructor(){
this.name = "files";
}
static allowAddNew(){
return userrights.has("files.edit") && !sync.isActive("files");
}
static allowEdit(){
return userrights.has("files.edit");
}
static allowDelete(ingoreSync=false){
return userrights.has("files.delete") && (!sync.isActive("files") || ingoreSync);
}
static allowClose(){
return userrights.has("files.close");
}
static allowBlacken(){
return userrights.has("files.blacken");
}
static allowShare(){
return userrights.has("files.share");
}
static allowLicenses(){
return userrights.has("files.licenses");
}
static allowFinishmanhunt(){
return userrights.has("manhunt.finish");
}
static allowFinishEntry(){
return userrights.has("filesentry.finish");
}
static GetColumns(){
if(currentSystem == "police"){
return ["name","alias","phone","shared","state","id"];
}
else if(currentSystem == "medic"){
return ["name","phone","shared","state","id"];
}
}

static GetPropertyHTML(data){
if(data.extraData.properties == null || data.extraData.properties == undefined){
return "";
}
else{
let tbody = ``;
for(let i=0; i<data.extraData.properties.length; i++){
let row = data.extraData.properties[i];

tbody += `
<tr>
<td>
${row.label}
</td>
<td>
<button type="button" class="btn btn-primary btn-sm" data-entering='${row.entering}' data-is-qs-housing="${row._is_qs_housing}" data-is-my-property="${row._is_myproperty}" onclick="GenerateRoute(this, true)">
<i class="fa-solid fa-location-dot"></i>
<button>
</td>
</tr>
`;
}

return `
<div class="collapse collapse-open border border-base-300 bg-base-100 rounded-box mt-4">
<div class="collapse-title text-xl font-medium">
${getTranslation("properties")}
</div>
<div class="collapse-content">
<table class="table table-compact w-full">
<thead>
<tr>
<th>
${getTranslation("name")}
</th>
<th>
</th>
</tr>
</thead>
<tbody>
${tbody}
</tbody>
</table>
</div>
</div>
`

}
}
static GetFileEntryHTML(data, allowButtons){
let html = ``;
let activeWantingRow = null;

if(data.fromsystem == "police"){

if(data.extraData.file_entries !== undefined){
let entryTypes = System.getFileEntryTypes();
html += `
<div class="collapse collapse-open border border-base-300 bg-base-100 rounded-box mt-4">
<div class="collapse-title text-xl font-medium">
${getTranslation("fileentry.overview")}
</div>
<div class="collapse-content">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 pt-6">`;
for(let i=0;i<data.extraData.file_entries.length;i++){
//check if entry is even
let row = data.extraData.file_entries[i];
let bgColor = entryTypes[row.type_of_entry].color ?? "ghost";
let type_name = entryTypes[row.type_of_entry].name ?? "";
let badges = ``;
if(row.is_wanted){
if(row.is_wanted_done == 1){
badges += `<div class="badge badge-warning font-bold gap-2">${getTranslation("old_manhunt")}</div>`;
}
else{
if(activeWantingRow == null){
activeWantingRow = row;
}
badges += `<div class="badge badge-error font-bold gap-2">${getTranslation("active_manhunt")}</div>`;
}
}
badges += `<div class="badge badge-${bgColor} gap-2 font-bold">${type_name}</div>`;
if(row.closed){
badges += `<div class="badge badge-success gap-2 font-bold">${getTranslation("entry_finished")}</div>`;
}
let buttons = ``;
if(!row.closed && this.allowFinishEntry() && allowButtons == true){
buttons += `<button onclick="changeDataInColumn('fileentry','closed','${row.id}','1')" class="btn btn-primary btn-sm">${getTranslation("finish_file_entry")}</button>`;
}
if(this.allowDelete(true) && allowButtons == true){
buttons += `<button onclick="Form.openDeleteModal('${row.id}','fileentry')" class="btn btn-sm btn-error">${getTranslation("delete")}</button>`;
}

let content = row.content.replace(/\n/g,"<br>");

if(row.crimeData.length > 0){
content+="<br><br>";
content+=`<u>${getTranslation("fine_crime")}:</u><br>`;

let tempContent = "";

for(let j=0;j<row.crimeData.length;j++){
tempContent += (tempContent == "" ? "" : "<br>");

let crime = row.crimeData[j];

if(crime["_deleted"] == 1){
tempContent += "<s>";
}

tempContent+=crime.amount + "x " + crime.lawbook_shortname + " $" + crime.paragraph +" - "+crime.crime;

if(crime["_deleted"] == 1){
tempContent += "</s>";
}
}

content+=tempContent;
}

let temp = `
<div class="card w-full bg-neutral text-neutral-content">
<div class="card-body">
<h2 class="card-title uppercase font-bold">${row.file_entry_id}</h2>
<h2>${badges}</h2>
<p><strong>${System.buildEmployeeName(row.creator)} - ${System.formatTimestamp(row.creationdate)}</strong></p>
<p></p>
<p class="border border-current rounded-xl p-1 break-all">${content}</p>
<p></p>
<p></p>
<p><strong>${getTranslation("fine")}: </strong>${row.fine}</p>
<p><strong>${getTranslation("detention_time")}:</strong> ${row.detention_time}</p>
<div class="card-actions justify-start">
${buttons}
</div>
</div>
</div>
`;
if( i % 2 === 0){
temp += `<div></div>`
}
else{
temp = `<div></div>` + temp
}
html += temp;
}
html += `
</div>
</div>
</div>`;
}
}
else if(data.fromsystem == "medic"){
if(data.extraData.file_entries !== undefined){
let injuryTypes = [
"head"
,"left_shoulder"
,"left_arm"
,"left_hand"
,"right_shoulder"
,"right_arm"
,"right_hand"
,"chest"
,"stomach"
,"left_leg"
,"left_foot"
,"right_leg"
,"right_foot"
];
html += `
<div class="collapse collapse-open border border-base-300 bg-base-100 rounded-box mt-4">
<div class="collapse-title text-xl font-medium">
${getTranslation("fileentry.overview")}
</div>
<div class="collapse-content">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 pt-6">`;
for(let i=0;i<data.extraData.file_entries.length;i++){
//check if entry is even
let row = data.extraData.file_entries[i];
let badges = ``;
if(row.closed){
badges += `<div class="badge badge-success gap-2">${getTranslation("entry_finished")}</div>`;
}
if(row.needs_follow_up_treatment){
badges += `<div class="badge badge-warning gap-2">${getTranslation("needs_follow_up_treatment")}</div>`;
}
let buttons = ``;
if(!row.closed && this.allowFinishEntry() && allowButtons == true){
buttons += `<button onclick="changeDataInColumn('fileentry','closed','${row.id}','1')" class="btn btn-sm btn-primary">${getTranslation("finish_file_entry")}</button>`;
}
if(this.allowDelete(true) && allowButtons == true){
buttons += `<button onclick="Form.openDeleteModal('${row.id}','fileentry')" class="btn btn-sm btn-error">${getTranslation("delete")}</button>`;
}
let knownInjuries = "";
for(let i=0; i<injuryTypes.length;i++){
if(row[`injury_${injuryTypes[i]}`]){
knownInjuries += `
<li>- ${getTranslation(injuryTypes[i])}</li>
`;
}
}
if(knownInjuries != ""){
knownInjuries = `
<ul>
${knownInjuries}
</ul>
`;
}
let temp = `
<div class="card w-full bg-neutral text-neutral-content">
<div class="card-body">
<h2 class="card-title uppercase font-bold">${row.file_entry_id}</h2>
<h2 class="card-title uppercase font-bold">${badges}</h2>
<p><strong>${System.buildEmployeeName(row.creator)} - ${System.formatTimestamp(row.creationdate)}</strong></p>
<p></p>
<p class="border border-current rounded-xl p-1 break-all">${row.content.replace(/\n/g,"<br>")}</p>
<p></p>
<p></p>
<p><strong>${getTranslation("intensity_of_wounds")}: </strong>${row.intensity_of_wounds}</p>
<p><strong>${getTranslation("type_of_bleeding")}:</strong> ${row.type_of_bleeding}</p>
<p><strong>${getTranslation("treatment")}:</strong> ${row.treatment}</p>
<div class="divider">${getTranslation("injuries")}</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 pt-2">
<div>${knownInjuries}</div>
<div class="border border-current rounded-xl p-1 col-span-2 break-all">${row.injury_summary.replace(/\n/g,"<br>")}</div>
</div>
<div class="card-actions justify-start">
${buttons}
</div>
</div>
</div>
`;
if( i % 2 === 0){
temp += `<div></div>`
}
else{
temp = `<div></div>` + temp
}
html += temp;
}
html += `
</div>
</div>
</div>`;
}
}
let retval = {
"html": html,
"activeWantingRow": activeWantingRow
};
return retval;
}

static GetLicensesHTML(data){
if(this.allowLicenses()){
let dropdown = ``;
let table = ``;
if(!sync.isActive("files_licenses") || currentSystem == "medic"){
if(data.extraData.possible_licenses !== undefined && data.extraData.possible_licenses.length>0){
let optionsHtml = ``;
for(let i=0; i<data.extraData.possible_licenses.length; i++){
optionsHtml += `<option value="${data.extraData.possible_licenses[i].id}">${data.extraData.possible_licenses[i].name}</option>`;
}
dropdown = `
<div class="w-full">
<div class="input-group w-full">
<select id="input-files-license" class="select select-sm select-bordered ignore-readonly">
${optionsHtml}
</select>
<button type="button" onclick="addLicenseToFile('${data.id}')" class="btn btn-sm btn-success">${getTranslation("add")}</button>
</div>
</div>
`;
}
}

if(data.extraData.given_licenses !== undefined && data.extraData.given_licenses.length>0){
let tbody = ``;
for(let i=0; i<data.extraData.given_licenses.length; i++){
let row = data.extraData.given_licenses[i];

if(!sync.isActive("files_licenses") || currentSystem == "medic"){
tbody += `
<tr>
<td>
${row.name}
</td>
<td>
<button type="button" class="btn btn-error btn-sm" onclick="deleteData('fileslicenses','${row.id}')">
${getTranslation("remove_license")}
</button>
</td>
</tr>
`;
}
else{
tbody += `
<tr>
<td>
${row.name}
</td>
<td>
</td>
</tr>
`;
}
tbody += `</tr>`
}
table = `
<table class="table table-compact w-full">
<thead>
<tr>
<th>
${getTranslation("name")}
</th>
<th>
</th>
</tr>
</thead>
<tbody>
${tbody}
</tbody>
</table>
`;
}
return `
<div class="collapse collapse-open border border-base-300 bg-base-100 rounded-box mt-4">
<div class="collapse-title text-xl font-medium">
${getTranslation("licenses.overview")}
</div>
<div class="collapse-content">
${dropdown}
${table}
</div>
</div>
`
}
}
static GetExtraForView(data){
let retval = {
top:"",
bottom:"",
initTableButtons:false,
}
if(currentSystem == "police"){
let blackenTxt = getTranslation("blacken");
let shareTxt = getTranslation("share");
let closeTxt = getTranslation("close");
let blacken_new = 1;
let closed_new = 1;
let shared_new = 1;
if(data.blackend){
blackenTxt = getTranslation("deblacken");
blacken_new = 0;
}
if(data.closed){
closeTxt = getTranslation("reopen");
closed_new = 0;
}
if(data.is_shared){
shareTxt = getTranslation("unshare");
shared_new = 0;
}
let buttons = ``;
let cnt = 0;
if(this.allowEdit()){
cnt++;
//buttons += `<button type="button" class="btn btn-sm btn-success" onclick="loadPage('fileentry.add',-1,'false',{data:{file_id:'${data.id}'}})">${getTranslation("fileentry.add")}</button>`;
buttons += `<button type="button" class="btn btn-sm btn-success" onclick="loadPage('fileentry.add','${data.id}','true')">${getTranslation("fileentry.add")}</button>`;
}
if(this.allowBlacken()){
cnt++;
buttons += `<button type="button" class="btn btn-sm btn-warning" onclick="changeDataInColumn('files','blackend','${data.id}','${blacken_new}')">${blackenTxt}</button>`;
}
if(this.allowClose()){
cnt++;
buttons += `<button type="button" class="btn btn-sm btn-error" onclick="changeDataInColumn('files','closed','${data.id}','${closed_new}')">${closeTxt}</button>`;
}
if(this.allowShare()){
cnt++;
buttons += `<button type="button" class="btn btn-sm btn-primary" onclick="changeDataInColumn('sharedfiles','is_shared','${data.id}','${shared_new}')">${shareTxt}</button>`;
}
retval.bottom += `
<div class="grid grid-cols-1 md:grid-cols-${cnt} gap-4 pt-6">
${buttons}
</div>
`;
let activeWantingRow = null;
retval.bottom += this.GetLicensesHTML(data);

retval.bottom += this.GetPropertyHTML(data);
if(RegVehicle.allowView()){
if(data.extraData.vehicles !== undefined){
retval.bottom += `
<div class="collapse collapse-open border border-base-300 bg-base-100 rounded-box mt-4">
<div class="collapse-title text-xl font-medium">
${getTranslation("regvehicle.overview")}
</div>
<div class="collapse-content">
${System.GetTable(RegVehicle, data.extraData.vehicles)}
</div>
</div>
`;
retval.initTableButtons = true
}
}
let temp = this.GetFileEntryHTML(data, true)
retval.bottom += temp.html;
activeWantingRow = temp.activeWantingRow;
if(activeWantingRow !== null){
let btn = ``;
if(this.allowFinishmanhunt()){
btn = `<button onclick="finishManhunt('filesentry','${data.id}')" class="btn btn-sm btn-primary">${getTranslation("is_wanted_end")}</button>`;
}
retval.top = `
<div class="card w-full bg-error text-error-content">
<div class="card-body">
<h2 class="card-title uppercase font-bold">${getTranslation("vehicle_wanted")}</h2>
<p><strong>${System.buildEmployeeName(activeWantingRow.creator)} - ${System.formatTimestamp(activeWantingRow.creationdate)}</strong></p>
<p></p>
<p class="border border-current rounded-xl p-1 break-all">${activeWantingRow.content.replace(/\n/g,"<br>")}</p>
<div class="card-actions justify-start">
${btn}
</div>
</div>
</div>
`;
}
}
else if(currentSystem == "medic"){
let blackenTxt = getTranslation("blacken");
let closeTxt = getTranslation("close");
let blacken_new = 1;
let closed_new = 1;
let shareTxt = getTranslation("share");
let shared_new = 1;
if(data.blackend){
blackenTxt = getTranslation("deblacken");
blacken_new = 0;
}
if(data.closed){
closeTxt = getTranslation("reopen");
closed_new = 0;
}
if(data.is_shared){
shareTxt = getTranslation("unshare");
shared_new = 0;
}
let buttons = ``;
let cnt = 0;
if(this.allowEdit()){
cnt++;
buttons += `<button type="button" class="btn btn-sm btn-success" onclick="loadPage('fileentry.add',-1,'false',{data:{file_id:'${data.id}'}})">${getTranslation("fileentry.add")}</button>`;
}
if(this.allowBlacken()){
cnt++;
buttons += `<button type="button" class="btn btn-sm btn-warning" onclick="changeDataInColumn('files','blackend','${data.id}','${blacken_new}')">${blackenTxt}</button>`;
}
if(this.allowClose()){
cnt++;
buttons += `<button type="button" class="btn btn-sm btn-error" onclick="changeDataInColumn('files','closed','${data.id}','${closed_new}')">${closeTxt}</button>`;
}
if(this.allowShare()){
cnt++;
buttons += `<button type="button" class="btn btn-sm btn-primary" onclick="changeDataInColumn('sharedfiles','is_shared','${data.id}','${shared_new}')">${shareTxt}</button>`;
}
retval.bottom += `
<div class="grid grid-cols-1 md:grid-cols-${cnt} gap-4 pt-6">
${buttons}
</div>
`;
retval.bottom += this.GetLicensesHTML(data);

let temp = this.GetFileEntryHTML(data, true)
retval.bottom += temp.html;
}
return retval;
}
static TableDataCreate(row, key){
if(key == "state"){
let badges = ``;
if(row[key] != ""){
badges += `<div class="badge badge-error font-bold">${getTranslation("tag_" + row[key])}</div>`;
}
if(row.blackend){
badges += `<div class="badge badge-warning font-bold">${getTranslation("tag_blackend")}</div>`;
}
if(row.closed){
badges += `<div class="badge badge-info font-bold">${getTranslation("tag_closed")}</div>`;
}
return `<td>${badges}</td>`;
}
else if(key == "id"){
let isWantedButton = ``;

if(currentSystem == "police"){
if(this.allowEdit()){
isWantedButton = Form.getIsWantedButton(row[key], this.name, row.state == "is_wanted");
}
}

return `
<td>
${Form.getViewButtonIcon(row[key], this.name + ".view")}
${Form.getEditButtonIcon(row[key] , this.name + ".edit", this.allowEdit())}
${isWantedButton}
${Form.getDeleteButtonIcon(row[key], this.name , this.allowDelete())}
</td>`;
}
else if(key == "shared"){
if(row[key]){
return `
<td class="font-bold">
<i class="fa-solid fa-check"></i>
</td>
`;
}
else{
return `<td></td>`;
}
}
else{
return `<td>${row[key]}</td>`;
}
}
static GetEdit(data = {}){
if(currentSystem == "police"){
return {
"name": {
"val" : data.name ?? ""
,"type" : "text"
,"mandatory":true
}
,"alias": {
"val" : data.alias ?? ""
,"type" : "text"
,"mandatory":true
}
,"sex": {
"val" : data.sex ?? ""
,"type" : "dropdown"
,"mandatory":true
,"options":[
{id:0, name:getTranslation("unknown")},
{id:1, name:getTranslation("male")},
{id:2, name:getTranslation("female")},
{id:3, name:getTranslation("diverse")}
]
}
,"phone": {
"val" : data.phone ?? ""
,"type" : "text"
,"mandatory":false
}
,"size": {
"val" : data.size ?? ""
,"type" : "number"
,"mandatory":false
}
,"birth": {
"val" : data.birth ?? ""
,"type" : "date"
,"mandatory":false
}
,"eyecolor": {
"val" : data.eyecolor ?? ""
,"type" : "text"
,"mandatory":false
}
,"haircolor": {
"val" : data.haircolor ?? ""
,"type" : "text"
,"mandatory":false
}
};
}
else if(currentSystem == "medic"){
return {
"name": {
"val" : data.name ?? ""
,"type" : "text"
,"mandatory":true
,"isRow":true
}
,"blood_type": {
"val" : data.blood_type ?? "A"
,"type" : "dropdown"
,"mandatory":true
,options:[
{id:"A", name:"A+"},
{id:"A-", name:"A-"},
{id:"B", name:"B+"},
{id:"B-", name:"B-"},
{id:"AB", name:"AB+"},
{id:"AB-", name:"AB-"},
{id:"0", name:"0+"},
{id:"0-", name:"0-"},
]
}
,"sex": {
"val" : data.sex ?? ""
,"type" : "dropdown"
,"mandatory":true
,"options":[
{id:0, name:getTranslation("unknown")},
{id:1, name:getTranslation("male")},
{id:2, name:getTranslation("female")},
{id:3, name:getTranslation("diverse")}
]
}
,"phone": {
"val" : data.phone ?? ""
,"type" : "text"
,"mandatory":false
}
,"birth": {
"val" : data.birth ?? ""
,"type" : "date"
,"mandatory":false
}
,"size": {
"val" : data.size ?? ""
,"type" : "number"
,"mandatory":false
}
,"weight": {
"val" : data.weight ?? ""
,"type" : "number"
,"mandatory":false
}
,"allergies": {
"val" : data.allergies ?? ""
,"type" : "textarea"
,"mandatory":false
,rows:3
}
,"known_illnesses": {
"val" : data.known_illnesses ?? ""
,"type" : "textarea"
,"mandatory":false
,rows:3
}
};
}
}
}

View file

@ -0,0 +1,111 @@
class Investigation{
constructor(){
this.name = "investigation";
}
static allowAddNew(){
return userrights.has("investigation.edit");
}
static allowEdit(){
return userrights.has("investigation.edit");
}
static allowDelete(){
return userrights.has("investigation.delete");
}
static allowClose(){
return userrights.has("investigation.close");
}
static GetExtraForView(data){
let retval = {
top:"",
bottom:""
}
let closeTxt = getTranslation("close");
let closedValueNew = 1;
if(data.closed){
closeTxt = getTranslation("reopen");
closedValueNew = 0;
}
let buttons = ``;
if(this.allowAddNew()){
buttons += `<button type="button" class="btn btn-sm btn-success" onclick="loadPage('investigationentry.add',-1,'false',{data:{investigation_id:'${data.id}'}})">${getTranslation("add_entry")}</button>`;
}
if(this.allowClose()){
buttons += `<button type="button" class="btn btn-sm btn-primary" onclick="changeDataInColumn('investigation','closed','${data.id}','${closedValueNew}')">${closeTxt}</button>`;
}
retval.bottom += `
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 pt-6 pb-6">
${buttons}
</div>
`;
if(data.extraData.entries !== undefined && data.extraData.entries !== null && data.extraData.entries.length > 0){
retval.bottom += System.GetTable(InvestigationEntry, data.extraData.entries);
}
return retval;
}
static TableDataCreate(row, key){
if(key == "id"){
return `
<td>
${Form.getViewButtonIcon(row[key], this.name + ".view")}
${Form.getEditButtonIcon(row[key] , this.name + ".edit", this.allowEdit())}
${Form.getDeleteButtonIcon(row[key], this.name, this.allowDelete())}
</td>`;
}
else if(key == "reason"){
let txt = row[key];
if(txt.length > 30){
txt = txt.substr(0,30) + "..";
}
return `
<td>
${txt}
</td>`;
}
else if(key == "state"){
if(row.closed){
return `<td><div class="badge badge-info font-bold">${getTranslation("tag_closed")}</div></td>`;
}
else{
return `<td><div class="badge badge-warning font-bold">${getTranslation("state_open")}</div></td>`;
}
}
else{
return `<td>${row[key]}</td>`;
}
}
static GetColumns(){
return ["name","reason","state","id"]
}
static GetEdit(data={}){
return {
"name": {
"val" : data.name ?? ""
,"type" : "text"
,"isRow": true
,"mandatory":true
}
,"reason": {
"val" : data.reason ?? ""
,"type" : "textarea"
,"isRow": true
,"mandatory":true
,autogrow: true
,rows:3
}
}
}
}

View file

@ -0,0 +1,68 @@
class InvestigationEntry{
constructor(){
this.name = "investigationentry";
}
static GetCustomDestination(data, dest){
return data.investigation_id > 0 ? "investigation.view" : dest;
}
static GetCustomDestID(data, destID){
return data.investigation_id ?? destID;
}
static TableDataCreate(row, key){
if(key == "is_important_entry"){
if(row[key]){
return `
<td class="font-bold">
<i class="fa-solid fa-check"></i>
</td>`
;
}
else{
return "<td></td>"
}
}
else if(key == "creator"){
return `<td>${System.buildEmployeeName(row[key])}</td>`;
}
else{
if(row[key].includes(" ")){
//todo everywhere
return `<td class="whitespace-normal break-normal">${row[key].replace(/\n/g,"<br>")}</td>`;
}
else{
return `<td class="whitespace-normal break-all">${row[key].replace(/\n/g,"<br>")}</td>`;
}
}
}
static GetColumns(){
return ["creator","content","is_important_entry"]
}
static GetEdit(data={}){
return {
"investigation_id": {
"val" : data.investigation_id ?? "-1"
,"type" : "hidden"
,"isRow": true
,"mandatory":true
},
"content": {
"val" : data.content ?? ""
,"type" : "textarea"
,"isRow": true
,"mandatory":true
,autogrow: true
,rows:3
}
,"is_important_entry": {
"val" : data.is_important_entry ?? ""
,"type" : "dropdown"
,"isRow": true
,"mandatory":true
,"options":System.GetBooleanOptions()
}
}
}
}

View file

@ -0,0 +1,104 @@
class LawBookLaws{
constructor(){
this.name = "lawbooklaws";
}
static isCustom(){
return true;
}
static allowEdit(){
return userrights.has("lawbooks.edit");
}
static allowDelete(){
return userrights.has("lawbooks.delete");
}
static GetColumns(isEditList){
if(!isEditList){
return ["paragraph","crime","minimum_penalty","detention_time","others","id"]
}
else{
return ["paragraph","crime","minimum_penalty","detention_time","others","id"]
}
}
static TableDataCreate(row, key, isEditList){
if(!isEditList){
if(key == "id"){
return `
<td>
${Form.getEditButtonIcon(row[key], this.name + ".edit", this.allowEdit())}
${Form.getDeleteButtonIcon(row[key], this.name ,this.allowDelete())}
</td>`;
}
else if(key == "crime") {
return `<td class="whitespace-normal">${row[key]}</td>`;
}
else if(key == "others") {
return `<td class="whitespace-normal">${row[key]}</td>`;
}
else {
return `<td>${row[key]}</td>`;
}
}
else{

if(key == "id"){
return `<td class="edittable_row" id = "edittable_row_${row.id}">
${Form.NumberField(false, "lawbook_laws_amount_" + row.id, "0", "lawbook_laws_calc_penalty", false, false)}
${Form.Hidden("lawbook_laws_id_" + row.id, row[key])}
${Form.Hidden("lawbook_laws_minimum_penalty_" + row.id, row["minimum_penalty"])}
${Form.Hidden("lawbook_laws_detention_time_" + row.id, row["detention_time"])}
</td>`;
}
else if(key == "crime") {
return `<td class="whitespace-normal">${row[key]}</td>`;
}
else if(key == "others") {
return `<td class="whitespace-normal">${row[key]}</td>`;
}
else {
return `<td>${row[key]}</td>`;
}
}
}
static GetEdit(data={}){
return {
"lawbook_id": {
"val" : data.lawbook_id ?? "-1"
,"type" : "hidden"
},
"crime": {
"val" : data.crime ?? ""
,"type" : "text"
,"mandatory":true
}
,"paragraph": {
"val" : data.paragraph ?? ""
,"type" : (HandleParagraphsAsNumber ? "float" : "text")
,"mandatory":true
}
,"minimum_penalty": {
"val" : data.minimum_penalty ?? 0
,"type" : "number"
,"mandatory":true
}
,"detention_time": {
"val" : data.detention_time ?? 0
,"type" : "number"
,"mandatory":true
}
,"others": {
"val" : data.others ?? ""
,"type" : "textarea"
,autogrow : true
,"mandatory":false
,"isRow":true
}
}
}
}

View file

@ -0,0 +1,118 @@
class LawBooks{
constructor(){
this.name = "lawbooks";
}
static allowAddNew(){
return userrights.has("lawbooks.edit");
}
static allowEdit(){
return userrights.has("lawbooks.edit");
}
static allowDelete(){
return userrights.has("lawbooks.delete");
}
static isCustom(){
return true;
}
static CreateCustom(data, isEditMode = false){

let retval = ``;

if(!isEditMode){
document.getElementById("currentpage-content").innerHTML = Form.overviewHeadline(this.name.toLowerCase() + ".add", false, this.allowAddNew());
}

for(let i=0; i<data.data.length; i++){
let row = data.data[i];
let buttons = ``;

let mbClass = "";

if(!isEditMode){
if(this.allowAddNew()){
buttons += `<button type="button" class="btn btn-sm btn-success lawbooks-add-crime" data-parentID="${row.id}">${getTranslation("add_crime")}</button>`;
}
if(this.allowEdit()){
buttons += `<button type="button" class="btn btn-sm btn-warning lawbooks-edit" data-parentID="${row.id}">${getTranslation("edit")}</button>`;
}
if(this.allowDelete()){
buttons += `<button type="button" class="btn btn-sm btn-error" onclick="Form.openDeleteModal(${row.id}, 'lawbooks')">${getTranslation("delete")}</button>`;
}
}

if(buttons != ""){
mbClass = "mb-2";
}


if(!isEditMode || row.laws.length > 0){
retval += `
<div class="collapse collapse-arrow border border-base-300 bg-base-100 rounded-box mt-4">
<input type="checkbox" />
<div class="collapse-title text-xl font-medium">
${row.short_name} - ${row.name}
</div>
<div class="collapse-content">
<div class="${mbClass}">
${buttons}
</div>
${System.GetTable(System.getClassByName("lawbooklaws"), row.laws, isEditMode)}
</div>
</div>
`;
}
}
if(!isEditMode){
document.getElementById("currentpage-content").innerHTML += retval;
Form.initTableButtons();
Array.from(document.querySelectorAll(".lawbooks-add-crime")).forEach(function(button){
button.onclick = function(){
let staticData = {
data:{
lawbook_id:this.getAttribute("data-parentID")
}
}
loadPage("lawbooklaws.add",-1,"false", staticData)
}
});
Array.from(document.querySelectorAll(".lawbooks-edit")).forEach(function(button){
button.onclick = function(){
loadPage("lawbooks.edit",this.getAttribute("data-parentID"),"false", {})
}
});
}
else{
return retval;
}
}
static GetEdit(data={}){
return {
"name": {
"val" : data.name ?? ""
,"type" : "text"
,"mandatory":true
,"isRow":true
}
,"short_name": {
"val" : data.short_name ?? ""
,"type" : "text"
,"mandatory":true
,"isRow":true
}
}
}
}

View file

@ -0,0 +1,41 @@
class Licenses{
constructor(){
this.name = "licenses";
}
static GetColumns(){
return ["name","id"]
}
static allowAddNew(){
return userrights.has("licenses.edit") && (!sync.isActive("licenses") || currentSystem == "medic")
}
static allowEdit(){
return userrights.has("licenses.edit") && (!sync.isActive("licenses") || currentSystem == "medic")
}
static allowDelete(){
return userrights.has("licenses.delete") && (!sync.isActive("licenses") || currentSystem == "medic")
}
static TableDataCreate(row, key){
if(key == "id"){
return `
<td>
${Form.getEditButtonIcon(row[key] , this.name + ".edit", this.allowEdit())}
${Form.getDeleteButtonIcon(row[key], this.name, this.allowDelete())}
</td>`;
}
else{
return `<td>${row[key]}</td>`;
}
}
static GetEdit(data={}){
return {
"name": {
"val" : data.name ?? ""
,"type" : "text"
,"isRow": true
,"mandatory":true
}
}
}
}

View file

@ -0,0 +1,116 @@
class Manhunt{
constructor(){
this.name = "manhunt";
}
static isCustom(){
return true;
}
static CreateCustom(data){
document.getElementById("currentpage-content").innerHTML = `
<div class="card w-full p-2 bg-base-100 shadow-xl mt-2 mb-6">
<div class="h-full w-full bg-base-100">
<div class="overflow-x-auto w-full">
${System.GetTable(Manhunt, data.data)}
</div>
</div>
</div>
`;
}
static GetColumns(){
return ["type","last_changed","info","id"]
}
static TableDataCreate(row, key){
if(key == "id"){
let destination = ""
let destinationID = row[key]
let allowed = false;
if(row.type == "files"){
destination = "files.view"
allowed = userrights.has(destination);
}
else if(row.type == "vehicle"){
destination = "regvehicle.view"
allowed = userrights.has("regvehicles.view");
}
else if(row.type == "weapon"){
destination = "regweapons.view"
allowed = userrights.has(destination);
}
if(allowed){
return `
<td>
<button type="button" class="btn btn-sm btn-primary" onclick="loadPage('${destination}','${destinationID}')">${getTranslation(destination)}</button>
</td>`
}
else{
return `<td></td>`
}
}
else if(key == "last_changed"){
return `
<td>
${System.formatTimestamp(row[key])}
</td>`;
}
else if(key == "type"){
return `
<td>
${getTranslation("type_" + row[key])}
</td>`;
}
else if(key == "info"){
if(row.type == "files"){
let displayValue = "";
if(row[key]){
let tmp = row[key].split("\n");
for(let i=0; i<tmp.length;i++){
let breaked = tmp[i].match(/.{1,75}/g) ?? [];
displayValue += (displayValue=="" ? "" : "<br>") + breaked.join("<br>");
}
}
return `
<td>
<p><strong>${getTranslation("name")}: </strong>${row.name}</p>
<br>
<p class="max-w-xs break-all">${displayValue}</p>
</td>`
;
}
else if(row.type=="vehicle"){
return `
<td>
<p><strong>${getTranslation("plate")}: </strong>${row.plate}</p>
<p><strong>${getTranslation("owner")}: </strong>${row.owner}</p>
<p><strong>${getTranslation("veh_type")}: </strong>${row.veh_type}</p>
<p><strong>${getTranslation("veh_model")}: </strong>${row.veh_model}</p>
</td>`
;
}
else if(row.type == "weapon"){
return `
<td>
<p><strong>${getTranslation("serialno")}: </strong>${row.serialno}</p>
<p><strong>${getTranslation("owner")}: </strong>${row.owner}</p>
<p><strong>${getTranslation("weapontype")}: </strong>${row.weapontype}</p>
<p><strong>${getTranslation("weaponmodel")}: </strong>${row.weaponmodel}</p>
</td>`
;
}
}
else{
return `<td>${row[key]}</td>`;
}
}
}

View file

@ -0,0 +1,92 @@
class MissionReport{
constructor(){
this.name = "missionreport";
}
static allowAddNew(){
return userrights.has("missionreport.edit");
}
static allowEdit(){
return userrights.has("missionreport.edit");
}
static allowDelete(){
return userrights.has("missionreport.delete");
}
static GetColumns(){
return ["name","mission_date","createddate","createdby","changeddate","changedby","id"]
}
static TableDataCreate(row, key){
if(key == "id"){
return `
<td>
${Form.getViewButtonIcon(row[key], this.name + ".view")}
${Form.getEditButtonIcon(row[key] , this.name + ".edit", this.allowEdit())}
${Form.getDeleteButtonIcon(row[key], this.name, this.allowDelete())}
</td>`;
}
else if(key == "mission_date"){
return `
<td>
${System.formatDate(row[key])}
</td>`;
}
else if(key == "name"){
return `
<td class="whitespace-normal">
${row[key]}
</td>`;
}
else if(key == "createddate" || key == "changeddate"){
return `
<td>
${System.formatTimestamp(row[key])}
</td>`;
}
else if(key == "createdby" || key == "changedby"){
return `
<td>
${System.buildEmployeeName(row[key])}
</td>`;
}
else{
return `<td>${row[key]}</td>`;
}
}
static GetEdit(data={}){
return {
"name": {
"val" : data.name ?? ""
,"type" : "text"
,"mandatory":true
}
,"mission_date": {
"val" : data.mission_date ?? new Date().toISOString().split('T')[0]
,"type" : "date"
,"mandatory":true
}
,"mission_location":{
"val" : data.mission_location ?? ""
,"type" : "text"
,"mandatory":true
}
,"involved_forces": {
"val" : data.involved_forces ?? ""
,"type" : "text"
,"mandatory":true
}
,"report":{
"val" : data.report ?? ""
,"type" : "textarea"
,"isRow": true
,"mandatory":true
,autogrow: true
,rows:3
}
}
}
}

View file

@ -0,0 +1,133 @@
class Notes{
constructor(){
this.name = "notes";
}

static allowAddNew(){
return userrights.has("notes.edit");
}
static allowEdit(){
return userrights.has("notes.edit");
}
static allowDelete(){
return userrights.has("notes.delete");
}

static isCustom(){
return true;
}

static GetEdit(data={}){
return {
"note_headline": {
"val" : data.note_headline ?? ""
,"type" : "text"
,"mandatory":true
,"isRow":true
},
"note": {
"val" : data.note ?? ""
,"type" : "textarea"
,"isRow": true
,"mandatory":true
,autogrow: true
,rows:3
}
,"is_important_note": {
"val" : data.is_important_note ?? ""
,"type" : "dropdown"
,"isRow": true
,"mandatory":true
,"options":System.GetBooleanOptions()
}
}
}

static CreateCustom(data){

document.getElementById("currentpage-content").innerHTML = Form.overviewHeadline(this.name.toLowerCase() + ".add", false, this.allowAddNew());

let statsHTML = ``;

if(data.data.important_notes.length > 0 || data.data.notes.length > 0){
let badges = ``;

if(data.data.important_notes.length > 0){
let gridCols = data.data.important_notes.length;

if(data.data.important_notes.length > 4){
gridCols = 4;
}

statsHTML += `<div class="grid pt-8 md:grid-cols-${gridCols} grid-cols-1 gap-6">`
for(let i = 0; i<data.data.important_notes.length; i++){
let row = data.data.important_notes[i];
badges = `<div class="badge badge-error gap-2 font-bold">${getTranslation("stat.is_important_note")}</div>`;

let buttons = ``;
if(this.allowEdit()){
buttons += `<button onclick="loadPage('notes.edit','${row.id}')" class="btn btn-primary btn-sm">${getTranslation("edit")}</button>`;
}
if(this.allowDelete()){
buttons += `<button onclick="Form.openDeleteModal('${row.id}','notes')" class="btn btn-sm btn-error">${getTranslation("delete")}</button>`;
}

statsHTML += `
<div class="card w-full bg-warning text-warning-content">
<div class="card-body">
<h2 class="card-title uppercase font-bold">${row.note_headline}</h2>
<h2>${badges}</h2>
<p><strong>${System.buildEmployeeName(row.creator)} - ${System.formatTimestamp(row.creationdate)}</strong></p>
<p class="border border-current rounded-xl p-1 break-all">${row.note.replace(/\n/g, "<br>")}</p>
<div class="card-actions justify-start">
${buttons}
</div>
</div>
</div>
`;
}
statsHTML += `</div>`;
}

if(data.data.notes.length > 0){
statsHTML += `<div class="grid pt-8 md:grid-cols-4 grid-cols-1 gap-6">`

for(let i = 0; i<data.data.notes.length; i++){
let row = data.data.notes[i];
let buttons = ``;
if(this.allowEdit()){
buttons += `<button onclick="loadPage('notes.edit','${row.id}')" class="btn btn-primary btn-sm">${getTranslation("edit")}</button>`;
}
if(this.allowDelete()){
buttons += `<button onclick="Form.openDeleteModal('${row.id}','notes')" class="btn btn-sm btn-error">${getTranslation("delete")}</button>`;
}

statsHTML += `
<div class="card w-full bg-neutral text-neutral-content">
<div class="card-body">
<h2 class="card-title uppercase font-bold">${row.note_headline}</h2>
<p><strong>${System.buildEmployeeName(row.creator)} - ${System.formatTimestamp(row.creationdate)}</strong></p>
<p class="border border-current rounded-xl p-1 break-all">${row.note.replace(/\n/g, "<br>")}</p>
<div class="card-actions justify-start">
${buttons}
</div>
</div>
</div>
`;
}
statsHTML += `</div>`;
}


document.getElementById("currentpage-content").innerHTML += statsHTML;
}

Form.initTableButtons();
}
}

View file

@ -0,0 +1,40 @@
class Prison{
constructor(){
this.name = "prison";
}
static allowView(){
return userrights.has("prison.view");
}
static allowAddNew(){
return false;
}
static allowEdit(){
return false;
}
static allowDelete(){
return false;
}
static GetColumns(){
return ["playername","prison","reason","remainingTime","date"]
}
static TableDataCreate(row, key){
if(key == "date"){
return `
<td>
${row[key]}<br>${row["officerName"]}
</td>`;
}
else if(key == "remainingTime"){
return `
<td>
${System.convertSecondsToTime(row[key])}
</td>`;
}
else{
return `<td>${row[key]}</td>`;
}
}
}

View file

@ -0,0 +1,118 @@
class RadioState{
constructor(){
this.name = "radio_state";
}
static allowAddNew(){
return userrights.has("radiostate.edit")
}
static allowEdit(){
return userrights.has("radiostate.edit")
}
static allowDelete(){
return userrights.has("radiostate.delete")
}
static GetExtraForOverview(data){
let retval = {
top:"",
bottom:""
}
let buttons = ``;
let radioDetails = System.getRadioState(data.current_state_vehicle, data.current_state_person);
let currentRadio = radioDetails.radio_default;
if(radioDetails.vehicle == null){
if(radioDetails.radio !== null){
currentRadio = data.current_state_person[0].state_name
buttons = `
<button type="button" class="btn btn-sm btn-primary" onclick="SetRadioState(-1,'radiostate.overview')">${getTranslation("emergency_vehicles_no_radio")}</button>
`
}
}
else{
currentRadio = currentRadio + " (" + radioDetails.vehicle + ")"
if(radioDetails.radio !== null){
currentRadio = radioDetails.radio + " (" + radioDetails.vehicle + ")"
buttons = `
<button type="button" class="btn btn-sm btn-warning" onclick="SetVehicle(-1,'radiostate.overview')">${getTranslation("leave_patrol")}</button>
<button type="button" class="btn btn-sm btn-primary" onclick="SetRadioState(-1,'radiostate.overview')">${getTranslation("emergency_vehicles_no_radio")}</button>
`
}
else{
buttons = `
<button type="button" class="btn btn-sm btn-warning" onclick="SetVehicle(-1,'radiostate.overview')">${getTranslation("leave_patrol")}</button>
`
}
}
retval.top = `
<div class="alert alert-info shadow-lg mb-4">
<div>
<div>${getTranslation("current_state")}: <strong>${currentRadio}</strong></div>
<div>
${buttons}
</div>
</div>
</div>
`;
return retval;
}
static GetColumns(){
return ["name","short_name","setstate","id"]
}
static TableDataCreate(row, key){
let FgColor = System.GetFgColorByBgColor(row["color"]);
if(key == "id"){
return `
<td style="color:${FgColor}; background:${row["color"]}">
${Form.getEditButtonIcon(row[key] , this.name + ".edit", this.allowEdit())}
${Form.getDeleteButtonIcon(row[key], this.name, this.allowDelete())}
</td>`;
}
else if(key == "setstate"){
return `
<td style="color:${FgColor}; background:${row["color"]}">
<button type="button" class="btn btn-sm btn-primary" onclick="SetRadioState(${row["id"]},'radiostate.overview')">${getTranslation("set_state")}</button>
</td>`;
}
else if(key != "id"){
return `<td style="color:${FgColor}; background:${row["color"]}">${row[key]}</td>`;
}
else{
return `<td style="color:${FgColor}; background:${row["color"]}">${row[key]}</td>`;
}
}
static GetEdit(data = {}){
return {
"name": {
"val" : data.name ?? ""
,"type" : "text"
,"isRow": true
,"mandatory":true
}
,"short_name": {
"val" : data.short_name ?? ""
,"type" : "text"
,"isRow": true
,"mandatory":true
}
,"color": {
"val" : data.color ?? ""
,"type" : "dropdown"
,"isRow": true
,"mandatory":true
,options:System.GetColorOptions()
}
}
}
}

View file

@ -0,0 +1,52 @@
class RankManagement{
static isCustom(){
return true;
}

static allowAddNew(){
return false;
}

static CreateCustom(data){
data.noLimit = true;
data.pageNum = 1;
data.count = data.data.length;

let tempdata = [];

for(let i=0; i<data.data.length; i++){
tempdata[data.data[i].grade] = data.data[i]
}

data.data = []
tempdata.forEach(function(element){
data.data.push(element)
});

System.CreateOverView(this, data)
}
static GetColumns(){
return ["name","id"]
}
static TableDataCreate(row, key){
if(key == "id"){
let disabled = "";
if(row.isboss){
disabled = " disabled"
}
return `
<td>
<button type="button" onclick="loadPage('rankmanagementrights.dataload', '${row.grade}')" class="btn btn-sm btn-primary" ${disabled}>${getTranslation("set_rights")}</button>
</td>`;
}
else{
return `<td>${row[key]}</td>`;
}
}

static GetEdit(data={}){
}
}

View file

@ -0,0 +1,102 @@
class RankManagementRights{
static isCustom(){
return true;
}

static allowAddNew(){
return false;
}

static CreateCustom(data){
let thead = `
<tr>
<th>
<input type="checkbox" id="toggle-all-checkboxes" class="toggle toggle-success"/>
</th>
<th>
${getTranslation("name")}
</th>
</tr>
`

let tbody = ``;
for(let i=0; i<data.data.rights.length; i++){
tbody += `
<tr>
${this.TableDataCreate(data.data.rights[i],"id")}
${this.TableDataCreate(data.data.rights[i],"right_key")}
</tr>
`;
}

document.getElementById("currentpage-content").innerHTML = `
<div class="card w-full p-2 bg-base-100 shadow-xl mt-2 mb-6">
<div class="h-full w-full bg-base-100">
<div class="overflow-x-auto w-full">
<table class="table table-compact w-full">
<thead>
${thead}
</thead>
<tbody>
${tbody}
</tbody>
</table>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 pt-6">
<button id="input-cancel-button" class="btn btn-sm btn-error">${getTranslation("cancel")}</button>
<button id="input-save-button" data-rankid="${data.data.id}" class="btn btn-sm btn-primary">${getTranslation("save")}</button>
</div">
</div>
</div>
</div>
`;

document.getElementById("toggle-all-checkboxes").onclick=function(){
let check = this.checked;

Array.from(document.getElementById("currentpage-content").querySelectorAll(".toggler-input")).forEach(function(item){
item.checked = check ?? false;
});
}


document.getElementById("input-cancel-button").onclick=function(){
loadPage("rankmanagement.dataload",-1)
}
document.getElementById("input-save-button").onclick=function(){

let temp = Form.getFormData();
delete temp["toggle-all-checkboxes"];

let formData = {
rank_id: this.getAttribute("data-rankid"),
data:temp
}

sendDataToAPI("rankmanagementrights", "rankmanagement.dataload",-1, -1, formData);
}
}

static GetColumns(){
return ["name", "id"]
}
static TableDataCreate(row, key){
if(key == "id"){
let checked = "";
if(row.active){
checked = " checked";
}

return `<td><input id="input-${row.right_key}" data-id="${row[key]}" type="checkbox" class="toggle toggle-success toggler-input" ${checked} /></td>`
}
else if(key == "right_key"){
return `<td>${getTranslation(row[key])}</td>`;
}
else{
return `<td>${row[key]}</td>`;
}
}

static GetEdit(data={}){
}
}

View file

@ -0,0 +1,420 @@
class RegVehicle{
constructor(){
this.name = "regvehicle";
}
static allowView(){
return userrights.has("regvehicles.view");
}
static allowAddNew(){
return userrights.has("regvehicles.edit") && !sync.isActive("regvehicle");
}
static allowEdit(){
return userrights.has("regvehicles.edit");
}
static allowDelete(){
return userrights.has("regvehicles.delete") && !sync.isActive("regvehicle");
}
static allowFinishmanhunt(){
return userrights.has("manhunt.finish");
}
static allowSetManhunt(){
return userrights.has("manhunt.add");
}
static GetColumns(){
return ["plate","veh_type","veh_model","owner","mot","state","id"]
}
static GetExtraForView(data){
let retval = {
top:"",
bottom:""
}
if(data.is_wanted == 1){
let btn = ``;
if(this.allowFinishmanhunt()){
btn = `<button onclick="finishManhunt('${this.name}','${data.id}')" class="btn btn-sm btn-primary">${getTranslation("is_wanted_end")}</button>`
}
retval.top = `
<div class="card w-full bg-error text-error-content">
<div class="card-body">
<h2 class="card-title uppercase font-bold">${getTranslation("vehicle_wanted")}</h2>
<p><strong>${getTranslation("reason")}: </strong>${data.is_wanted_reason}</p>
<p></p>
<p>${getTranslation("is_wanted_at_sight")}</p>
<div class="card-actions justify-start">
${btn}
</div>
</div>
</div>
`
}

if(data.extraData.mot_data !== undefined && data.extraData.mot_data !== null && showLastMotDetailFromMyMechanicMDT){
let cardContent = "";

if(data.extraData.mot_data.length > 0){

let row = data.extraData.mot_data[0];

let contentHtml = ``;
if(row.note !== undefined && row.note !== null && row.note.replace(/ /g, "") != ""){
contentHtml = `<p class="border border-current rounded-xl p-1 break-all">${row.note.replace(/\n/g,"<br>")}</p>`;
}

cardContent = `
<p><strong>${System.buildEmployeeName(row.creator)} - ${System.formatTimestamp(row.createddate)}</strong></p>
<p></p>
<p><strong>${getTranslation("passed")}</strong>: <span class="badge badge-${row.passed ? "success" : "error"} gap-2 font-bold">${getTranslation(row.passed == 1 ? "yes": "no")}</span></p>
<p><strong>${getTranslation("new_mot")}</strong>: ${System.formatDate(row.new_mot) }</p>
<p><strong>${getTranslation("old_mot")}</strong>: ${System.formatDate(row.old_mot) }</p>
${contentHtml}

<table>
<thead>
<tr>
<th>${getTranslation("mot.lights")}</th>
<th>${getTranslation("mot.brakes_tyres")}</th>
<th>${getTranslation("mot.windows")}</th>
<th>${getTranslation("mot.others")}</th>
</tr>
</thead>
<tbody>
<tr>
<td class="text-center"><span class="badge badge-${row.headlights ? "success" : "error"} gap-2 font-bold">${getTranslation("headlights")}</span></td>
<td class="text-center"><span class="badge badge-${row.front_brakes ? "success" : "error"} gap-2 font-bold">${getTranslation("front_brakes")}</span></td>
<td class="text-center"><span class="badge badge-${row.windscreen ? "success" : "error"} gap-2 font-bold">${getTranslation("windscreen")}</span></td>
<td class="text-center"><span class="badge badge-${row.horn ? "success" : "error"} gap-2 font-bold">${getTranslation("horn")}</span></td>
</tr>
<tr>
<td class="text-center"><span class="badge badge-${row.rear_lights ? "success" : "error"} gap-2 font-bold">${getTranslation("rear_lights")}</span></td>
<td class="text-center"><span class="badge badge-${row.rear_brakes ? "success" : "error"} gap-2 font-bold">${getTranslation("rear_brakes")}</span></td>
<td class="text-center"><span class="badge badge-${row.rear_window ? "success" : "error"} gap-2 font-bold">${getTranslation("rear_window")}</span></td>
<td class="text-center"><span class="badge badge-${row.exhaust_system ? "success" : "error"} gap-2 font-bold">${getTranslation("exhaust_system")}</span></td>
</tr>
<tr>
<td class="text-center"><span class="badge badge-${row.indicators ? "success" : "error"} gap-2 font-bold">${getTranslation("indicators")}</span></td>
<td class="text-center"><span class="badge badge-${row.front_tyres ? "success" : "error"} gap-2 font-bold">${getTranslation("front_tyres")}</span></td>
<td class="text-center"><span class="badge badge-${row.side_windows ? "success" : "error"} gap-2 font-bold">${getTranslation("side_windows")}</span></td>
<td class="text-center"><span class="badge badge-${row.engine ? "success" : "error"} gap-2 font-bold">${getTranslation("engine")}</span></td>
</tr>
<tr>
<td></td>
<td class="text-center"><span class="badge badge-${row.rear_tyres ? "success" : "error"} gap-2 font-bold">${getTranslation("rear_tyres")}</span></td>
<td></td>
<td class="text-center"><span class="badge badge-${row.bodywork ? "success" : "error"} gap-2 font-bold">${getTranslation("bodywork")}</span></td>
</tr>
</tbody>
</table>
`;

}
else{
cardContent = `<h3>${getTranslation("no_data_found")}</h3>`
}


retval.bottom += `
<div class="collapse border border-base-300 bg-base-100 rounded-box mt-4">
<input type="checkbox" />
<summary class="collapse-title text-xl font-medium">
${getTranslation("regvehicle_mot.overview")}
</summary>
<div class="collapse-content">
<div class="grid grid-cols-1 md:grid-cols-1 gap-4 pt-2">
<div class="card w-full bg-neutral text-neutral-content">
<div class="card-body">
${cardContent}
</div>
</div>

</div>
</div>
</div>
`;
}

if(data.extraData.part_acceptance !== undefined && data.extraData.part_acceptance !== null && showPartAcceptanceFromMyMechanicMDT){
let cardCols = 2;

if(data.extraData.part_acceptance.length == 0){
cardCols = 1;
}

retval.bottom += `
<div class="collapse border border-base-300 bg-base-100 rounded-box mt-4">
<input type="checkbox" />
<summary class="collapse-title text-xl font-medium">
${getTranslation("regvehicle_part_acceptance.overview")}
</summary>
<div class="collapse-content">
<div class="grid grid-cols-1 md:grid-cols-${cardCols} gap-4 pt-2">
`;



if(data.extraData.part_acceptance.length > 0){
let i=0;
for(const row of data.extraData.part_acceptance){
if(i < 9999){
let temp = `
<div class="card w-full bg-neutral text-neutral-content">
<div class="card-body">
<p><strong>${System.buildEmployeeName(row.creator)} - ${System.formatTimestamp(row.createddate)}</strong></p>
<p class="border border-current rounded-xl p-1 break-all">${row.content.replace(/\n/g,"<br>")}</p>
<p>
<p class="p-1 break-all">${(row["_acceptance_name"] ?? "").replace(/\n/g,"<br>")}</p>
</div>
</div>
`;
retval.bottom += temp;
}
i++;
}
}
else{
retval.bottom+= `
<div class="card w-full bg-neutral text-neutral-content">
<div class="card-body">
<h3>${getTranslation("no_data_found")}</h3>
</div>
</div>
`;
}


retval.bottom += `
</div>
</div>
</div>
`;
}
return retval;
}
static TableDataCreate(row, key){
if(key == "state"){

let badges = ""


if(row["Impounded"] == 1){
badges += `<div class="badge badge-secondary font-bold">${getTranslation("tag_impounded")}</div>`;
}



if(row[key] == "1"){
badges += `<div class="badge badge-error font-bold">${getTranslation("tag_is_wanted")}</div>`;
}

return `
<td>
${badges}
</td>`;
}

else if(key == "id"){

let isWantedButton = ``;

if(this.allowSetManhunt()){
isWantedButton = Form.getIsWantedButton(row[key], this.name, row.state == "1");
}

return `
<td>
${Form.getViewButtonIcon(row[key], this.name + ".view")}
${Form.getEditButtonIcon(row[key] , this.name + ".edit", this.allowEdit())}
${isWantedButton}
${Form.getDeleteButtonIcon(row[key], this.name , this.allowDelete())}
</td>`;
}
else if(key == "owner"){
let val = row[key];
if(val == ""){
val = getTranslation("unknown");
}

return `
<td>
${val}
</td>`;
}
else if(key == "mot"){
if(row[key] == ""){
return `<td></td>`;
}
if(new Date(row[key]) < new Date()){
return `
<td>
<div class="badge badge-error font-bold">${System.formatDate(row[key])}</div>
</td>`
;
}
else{
return `
<td>
<div class="badge badge-success font-bold">${System.formatDate(row[key])}</div>
</td>`
;
}
}
else{
return `<td>${row[key]}</td>`;
}
}
static GetEdit(data={}, readMode = false){
let filesOptions = [
{"id":-1, "name":getTranslation("unknown")}
,{"id":-2, "name":getTranslation("new_file"), "show_extra_field":true}
];
if(sync.isActive("files")){
filesOptions = [
{"id":-1, "name":getTranslation("unknown")}
];
}
filesOptions = [...filesOptions, ...data.extraData.files];

if(!readMode && UseMotDateFromMyMechanicMDT){
return {
"plate": {
"val" : data.plate ?? ""
,"type" : "text"
,"mandatory":true
}
,"owner": {
"val" : data.owner_id ?? "-1"
,"type" : "searchdropdown"
,"mandatory":false
,options:filesOptions
}
,"veh_type": {
"val" : data.veh_type ?? ""
,"type" : "text"
,"mandatory":false
,isRow:true
}
,"veh_model": {
"val" : data.veh_model ?? ""
,"type" : "text"
,"mandatory":false
}
,"color": {
"val" : data.color ?? ""
,"type" : "text"
,"mandatory":false
}
,"-": {
"type" : "divider"
}
,"others": {
"val" : data.others ?? ""
,"type" : "textarea"
,"isRow": true
,"mandatory":false
,autogrow: true
,rows:3
}
,"is_wanted": {
"val" : (data.is_wanted ?? false ? 1 : 0)
,"type" : (this.allowSetManhunt() ? "dropdown" : "hidden")
,"isRow": true
,"mandatory":false
,"hideInViewMode":true
,"options":System.GetBooleanOptions()
}
,"is_wanted_reason": {
"val" : data.is_wanted_reason ?? ""
,"type" : (this.allowSetManhunt() ? "text" : "hidden")
,"isRow": true
,"hideInViewMode":true
,"mandatory":false
}
}
}
else{
return {
"plate": {
"val" : data.plate ?? ""
,"type" : "text"
,"mandatory":true
}
,"owner": {
"val" : data.owner_id ?? "-1"
,"type" : "searchdropdown"
,"mandatory":false
,options:filesOptions
}
,"veh_type": {
"val" : data.veh_type ?? ""
,"type" : "text"
,"mandatory":false
}
,"mot": {
"val" : data.mot ?? ""
,"type" : "date"
,"mandatory":false
}
,"veh_model": {
"val" : data.veh_model ?? ""
,"type" : "text"
,"mandatory":false
}
,"color": {
"val" : data.color ?? ""
,"type" : "text"
,"mandatory":false
}
,"-": {
"type" : "divider"
}
,"others": {
"val" : data.others ?? ""
,"type" : "textarea"
,"isRow": true
,"mandatory":false
,autogrow: true
,rows:3
}
,"is_wanted": {
"val" : (data.is_wanted ?? false ? 1 : 0)
,"type" : (this.allowSetManhunt() ? "dropdown" : "hidden")
,"isRow": true
,"mandatory":false
,"hideInViewMode":true
,"options":System.GetBooleanOptions()
}
,"is_wanted_reason": {
"val" : data.is_wanted_reason ?? ""
,"type" : (this.allowSetManhunt() ? "text" : "hidden")
,"isRow": true
,"hideInViewMode":true
,"mandatory":false
}
}
}

}
}

View file

@ -0,0 +1,268 @@
class RegVehicleImpounded{
constructor(){
this.name = "regvehicleimpounded";
}
static allowView(){
return userrights.has("regvehicles.view");
}
static allowAddNew(){
return false;
}
static allowEdit(){
return userrights.has("regvehicles.edit");
}
static allowDelete(){
return userrights.has("regvehicles.delete") && !sync.isActive("regvehicle");
}
static allowFinishmanhunt(){
return userrights.has("manhunt.finish");
}
static allowSetManhunt(){
return userrights.has("manhunt.add");
}
static GetColumns(){
return ["plate","veh_type","veh_model","owner","mot","state","id"]
}
static GetExtraForView(data){
let retval = {
top:"",
bottom:""
}
if(data.is_wanted == 1){
let btn = ``;
if(this.allowFinishmanhunt()){
btn = `<button onclick="finishManhunt('${this.name}','${data.id}')" class="btn btn-sm btn-primary">${getTranslation("is_wanted_end")}</button>`
}
retval.top = `
<div class="card w-full bg-error text-error-content">
<div class="card-body">
<h2 class="card-title uppercase font-bold">${getTranslation("vehicle_wanted")}</h2>
<p><strong>${getTranslation("reason")}: </strong>${data.is_wanted_reason}</p>
<p></p>
<p>${getTranslation("is_wanted_at_sight")}</p>
<div class="card-actions justify-start">
${btn}
</div>
</div>
</div>
`
}
return retval;
}
static TableDataCreate(row, key){
if(key == "state"){

let badges = ""


if(row["Impounded"] == 1){
badges += `<div class="badge badge-secondary font-bold">${getTranslation("tag_impounded")}</div>`;
}



if(row[key] == "1"){
badges += `<div class="badge badge-error font-bold">${getTranslation("tag_is_wanted")}</div>`;
}

return `
<td>
${badges}
</td>`;
}

else if(key == "id"){

let isWantedButton = ``;

if(this.allowSetManhunt()){
isWantedButton = Form.getIsWantedButton(row[key], this.name, row.state == "1");
}

return `
<td>
${Form.getViewButtonIcon(row[key], this.name + ".view")}
${Form.getEditButtonIcon(row[key] , this.name + ".edit", this.allowEdit())}
${isWantedButton}
${Form.getDeleteButtonIcon(row[key], this.name , this.allowDelete())}
</td>`;
}
else if(key == "owner"){
let val = row[key];
if(val == ""){
val = getTranslation("unknown");
}

return `
<td>
${val}
</td>`;
}
else if(key == "mot"){
if(row[key] == ""){
return `<td></td>`;
}
if(new Date(row[key]) < new Date()){
return `
<td>
<div class="badge badge-error font-bold">${System.formatDate(row[key])}</div>
</td>`
;
}
else{
return `
<td>
<div class="badge badge-success font-bold">${System.formatDate(row[key])}</div>
</td>`
;
}
}
else{
return `<td>${row[key]}</td>`;
}
}
static GetEdit(data={}, readMode = false){
let filesOptions = [
{"id":-1, "name":getTranslation("unknown")}
,{"id":-2, "name":getTranslation("new_file"), "show_extra_field":true}
];
if(sync.isActive("files")){
filesOptions = [
{"id":-1, "name":getTranslation("unknown")}
];
}
filesOptions = [...filesOptions, ...data.extraData.files];
if(!readMode && UseMotDateFromMyMechanicMDT){
return {
"plate": {
"val" : data.plate ?? ""
,"type" : "text"
,"mandatory":true
}
,"owner": {
"val" : data.owner ?? "-1"
,"type" : "searchdropdown"
,"mandatory":false
,options:filesOptions
}
,"veh_type": {
"val" : data.veh_type ?? ""
,"type" : "text"
,"mandatory":false
,isRow:true
}
,"veh_model": {
"val" : data.veh_model ?? ""
,"type" : "text"
,"mandatory":false
}
,"color": {
"val" : data.color ?? ""
,"type" : "text"
,"mandatory":false
}
,"-": {
"type" : "divider"
}
,"others": {
"val" : data.others ?? ""
,"type" : "textarea"
,"isRow": true
,"mandatory":false
,autogrow: true
,rows:3
}
,"is_wanted": {
"val" : (data.is_wanted ?? false ? 1 : 0)
,"type" : (this.allowSetManhunt() ? "dropdown" : "hidden")
,"isRow": true
,"mandatory":false
,"hideInViewMode":true
,"options":System.GetBooleanOptions()
}
,"is_wanted_reason": {
"val" : data.is_wanted_reason ?? ""
,"type" : (this.allowSetManhunt() ? "text" : "hidden")
,"isRow": true
,"hideInViewMode":true
,"mandatory":false
}
}
}
else{
return {
"plate": {
"val" : data.plate ?? ""
,"type" : "text"
,"mandatory":true
}
,"owner": {
"val" : data.owner ?? "-1"
,"type" : "searchdropdown"
,"mandatory":false
,options:filesOptions
}
,"veh_type": {
"val" : data.veh_type ?? ""
,"type" : "text"
,"mandatory":false
}
,"mot": {
"val" : data.mot ?? ""
,"type" : "date"
,"mandatory":false
}
,"veh_model": {
"val" : data.veh_model ?? ""
,"type" : "text"
,"mandatory":false
}
,"color": {
"val" : data.color ?? ""
,"type" : "text"
,"mandatory":false
}
,"-": {
"type" : "divider"
}
,"others": {
"val" : data.others ?? ""
,"type" : "textarea"
,"isRow": true
,"mandatory":false
,autogrow: true
,rows:3
}
,"is_wanted": {
"val" : (data.is_wanted ?? false ? 1 : 0)
,"type" : (this.allowSetManhunt() ? "dropdown" : "hidden")
,"isRow": true
,"mandatory":false
,"hideInViewMode":true
,"options":System.GetBooleanOptions()
}
,"is_wanted_reason": {
"val" : data.is_wanted_reason ?? ""
,"type" : (this.allowSetManhunt() ? "text" : "hidden")
,"isRow": true
,"hideInViewMode":true
,"mandatory":false
}
}
}

}
}

View file

@ -0,0 +1,162 @@
class RegWeapons{
constructor(){
this.name = "regweapons";
}
static allowAddNew(){
return userrights.has("regweapons.edit");
}
static allowEdit(){
return userrights.has("regweapons.edit");
}
static allowDelete(){
return userrights.has("regweapons.delete");
}
static allowFinishmanhunt(){
return userrights.has("manhunt.finish");
}
static allowSetManhunt(){
return userrights.has("manhunt.add");
}
static GetColumns(){
return ["serialno","weapontype","weaponmodel","owner","state","id"]
}
static GetExtraForView(data){
let retval = {
top:"",
bottom:""
}
if(data.is_wanted == 1){
let btn = ``;
if(this.allowFinishmanhunt()){
btn = `<button onclick="finishManhunt('${this.name}','${data.id}')" class="btn btn-sm btn-primary">${getTranslation("is_wanted_end")}</button>`;
}
retval.top = `
<div class="card w-full bg-error text-error-content">
<div class="card-body">
<h2 class="card-title uppercase font-bold">${getTranslation("vehicle_wanted")}</h2>
<p><strong>${getTranslation("reason")}: </strong>${data.is_wanted_reason}</p>
<p></p>
<p>${getTranslation("is_wanted_at_sight")}</p>
<div class="card-actions justify-start">
${btn}
</div>
</div>
</div>
`
}
return retval;
}
static TableDataCreate(row, key){
if(key == "state"){
if(row[key] == true){
return `<td><div class="badge badge-error font-bold">${getTranslation("tag_is_wanted")}</div></td>`;
}
else{
return `<td></td>`;
}
}
else if(key == "id"){
let isWantedButton = ``;

if(this.allowSetManhunt()){
isWantedButton = Form.getIsWantedButton(row[key], this.name, row.state == "1");
}

return `
<td>
${Form.getViewButtonIcon(row[key], this.name + ".view")}
${Form.getEditButtonIcon(row[key] , this.name + ".edit", this.allowEdit())}
${isWantedButton}
${Form.getDeleteButtonIcon(row[key], this.name, this.allowDelete())}
</td>`;
}
else if(key == "owner"){
let val = row[key];
if(val == ""){
val = getTranslation("unknown");
}

return `
<td>
${val}
</td>`;
}
else{
return `<td>${row[key]}</td>`;
}
}
static GetEdit(data={}){
let filesOptions = [
{"id":-1, "name":getTranslation("unknown")}
,{"id":-2, "name":getTranslation("new_file"), "show_extra_field":true}
];
if(sync.isActive("files")){
filesOptions = [
{"id":-1, "name":getTranslation("unknown")}
];
}
filesOptions = [...filesOptions, ...data.extraData.files];
return {
"serialno": {
"val" : data.serialno ?? ""
,"type" : "text"
,"mandatory":true
}
,"owner": {
"val" : data.owner_id ?? "-1"
,"type" : "searchdropdown"
,"mandatory":false
,options:filesOptions
}
,"weapontype": {
"val" : data.weapontype ?? ""
,"type" : "text"
,"mandatory":false
}
,"weaponmodel": {
"val" : data.weaponmodel ?? ""
,"type" : "text"
,"mandatory":false
}
,"-": {
"type" : "divider"
}
,"others": {
"val" : data.others ?? ""
,"type" : "textarea"
,"isRow": true
,"mandatory":false
,autogrow: true
,rows:3
}
,"is_wanted": {
"val" : (data.is_wanted ?? false ? 1 : 0)
,"type" : (this.allowSetManhunt() ? "dropdown" : "hidden")
,"isRow": true
,"mandatory":false
,hideInViewMode:true
,"options":System.GetBooleanOptions()
}
,"is_wanted_reason": {
"val" : data.is_wanted_reason ?? ""
,"type" : (this.allowSetManhunt() ? "text" : "hidden")
,"isRow": true
,hideInViewMode:true
,"mandatory":false
}
}
}
}

View file

@ -0,0 +1,179 @@
class SharedFiles{
constructor(){
this.name = "sharedfiles";
}
static allowAddNew(){
return false;
}
static allowEdit(){
return false;
}
static allowDelete(){
return false;
}
static GetColumns(){
return ["fromsystem","name","state","id"];
}
static GetExtraForView(data){
let retval = {
top:"",
bottom:"",
initTableButtons:false,
}
let temp = Files.GetFileEntryHTML(data, false)
retval.bottom += temp.html;
return retval;
}
static TableDataCreate(row, key){
if(key == "state"){
let badges = ``;
if(row[key] != ""){
badges += `<div class="badge badge-error font-bold">${getTranslation("tag_" + row[key])}</div>`;
}
return `<td>${badges}</td>`;
}
else if(key == "fromsystem"){
return `<td>${row[key]}</td>`;
}
else if(key == "id"){
return `
<td>
${Form.getViewButtonIcon(row[key] + "|##|" + row.real_from_system, this.name + ".view")}
</td>`;
}
else{
return `<td>${row[key]}</td>`;
}
}
static GetEdit(data = {}){
if(data.fromsystem == "police"){
return {
"name": {
"val" : data.name ?? ""
,"type" : "text"
,"mandatory":true
}
,"alias": {
"val" : data.alias ?? ""
,"type" : "text"
,"mandatory":true
}
,"sex": {
"val" : data.sex ?? ""
,"type" : "dropdown"
,"mandatory":true
,"options":[
{id:0, name:getTranslation("unknown")},
{id:1, name:getTranslation("male")},
{id:2, name:getTranslation("female")},
{id:3, name:getTranslation("diverse")}
]
}
,"phone": {
"val" : data.phone ?? ""
,"type" : "text"
,"mandatory":false
}
,"size": {
"val" : data.size ?? ""
,"type" : "number"
,"mandatory":false
}
,"birth": {
"val" : data.birth ?? ""
,"type" : "date"
,"mandatory":false
}
,"eyecolor": {
"val" : data.eyecolor ?? ""
,"type" : "text"
,"mandatory":false
}
,"haircolor": {
"val" : data.haircolor ?? ""
,"type" : "text"
,"mandatory":false
}
};
}
else if(data.fromsystem == "medic"){
return {
"name": {
"val" : data.name ?? ""
,"type" : "text"
,"mandatory":true
,"isRow":true
}
,"blood_type": {
"val" : data.blood_type ?? "A"
,"type" : "dropdown"
,"mandatory":true
,options:[
{id:"A", name:"A+"},
{id:"A-", name:"A-"},
{id:"B", name:"B+"},
{id:"B-", name:"B-"},
{id:"AB", name:"AB+"},
{id:"AB-", name:"AB-"},
{id:"0", name:"0+"},
{id:"0-", name:"0-"},
]
}
,"sex": {
"val" : data.sex ?? ""
,"type" : "dropdown"
,"mandatory":true
,"options":[
{id:0, name:getTranslation("unknown")},
{id:1, name:getTranslation("male")},
{id:2, name:getTranslation("female")},
{id:3, name:getTranslation("diverse")}
]
}
,"phone": {
"val" : data.phone ?? ""
,"type" : "text"
,"mandatory":false
}
,"birth": {
"val" : data.birth ?? ""
,"type" : "date"
,"mandatory":false
}
,"size": {
"val" : data.size ?? ""
,"type" : "number"
,"mandatory":false
}
,"weight": {
"val" : data.weight ?? ""
,"type" : "number"
,"mandatory":false
}
,"allergies": {
"val" : data.allergies ?? ""
,"type" : "textarea"
,"mandatory":false
,rows:3
}
,"known_illnesses": {
"val" : data.known_illnesses ?? ""
,"type" : "textarea"
,"mandatory":false
,rows:3
}
};
}
}
}

View file

@ -0,0 +1,32 @@
class SpeedcamsMobile{
constructor(){
this.name = "speedcamsmobile";
}
static allowAddNew(){
return false;
}
static GetColumns(){
return ["name","totalProfit","lastTime","lastProfit","id"]
}
static TableDataCreate(row, key){
if(key == "id"){

let coords = {}
coords.x = row.positionX;
coords.y = row.positionY;

coords = JSON.stringify(coords);

return `
<td>
<button type="button" class="btn btn-primary btn-sm" data-entering='${coords}' onclick="GenerateRoute(this, false)">
<i class="fa-solid fa-location-dot"></i>
<button>
</td>`;
}
else{
return `<td>${row[key]}</td>`;
}
}
}

View file

@ -0,0 +1,59 @@
class SpeedcamsProfit{
constructor(){
this.name = "speedcamsprofit";
}
static allowAddNew(){
return false;
}
static GetColumns(){
return ["state", "type", "name", "totalProfit", "lastTime", "lastProfit", "id"]
}
static TableDataCreate(row, key){
if(key == "id"){

if(row.allowRoute){
let coords = {}
coords.x = row.positionX;
coords.y = row.positionY;
coords = JSON.stringify(coords);
return `
<td>
<button type="button" class="btn btn-primary btn-sm" data-entering='${coords}' onclick="GenerateRoute(this, false)">
<i class="fa-solid fa-location-dot"></i>
<button>
</td>`;
}
else{
return `<td></td>`;
}
}
else if(key == "type"){

let text = getTranslation("speedcamtype." + row[key]);
let badge = `<div class="badge badge-warning font-bold">${text}</div>`;
if(row[key] == "mobile"){
badge = `<div class="badge badge-primary font-bold">${text}</div>`;
}

return `<td>${badge}</td>`;
}
else if(key == "state"){

let text = getTranslation("speedcam_active." + row[key]);
let badge = `<div class="badge badge-error font-bold">${text}</div>`;
if(row[key] == 1){
badge = `<div class="badge badge-success font-bold">${text}</div>`;
}

return `<td>${badge}</td>`;
}
else{
return `<td>${row[key]}</td>`;
}
}
}

View file

@ -0,0 +1,122 @@
class Trainings{
constructor(){
this.name = "trainings";
}
static allowAddNew(){
return userrights.has("trainings.edit")
}
static allowEdit(){
return userrights.has("trainings.edit")
}
static allowDelete(){
return userrights.has("trainings.delete")
}
static allowViewEmployeeTrainings(){
return userrights.has("trainingsemployees.view")
}
static GetExtraForView(data){
let retval = {
top:"",
bottom:""
}
if(this.allowViewEmployeeTrainings){
retval.bottom += `
<div class="collapse collapse-open border border-base-300 bg-base-100 rounded-box mt-4">
<div class="collapse-title text-xl font-medium">
${getTranslation("trainingsparticipants.overview")}
</div>
<div class="collapse-content">
${System.GetTable(TrainingsParticipants, data.extraData.participants)}
</div>
</div>
`;
}
return retval;
}
static GetColumns(){
return ["name","short_name","action","id"]
}
static TableDataCreate(row, key){
if(key == "id"){
return `
<td>
${Form.getViewButtonIcon(row[key], this.name + ".view")}
${Form.getEditButtonIcon(row[key] , this.name + ".edit", this.allowEdit())}
${Form.getDeleteButtonIcon(row[key], this.name, this.allowDelete())}
</td>`;
}
else if(key == "action"){
let content = "";
if(row.allow_self_entry){
let disabled = "";
if(row.entered > 0){
disabled = " disabled"
}
content = `<button type="button" class="btn btn-sm btn-primary" onclick="participateForTraining(${row["id"]})" ${disabled}>${getTranslation("participate")}</button>`
}
return `
<td>
${content}
</td>`;
}
else{
return `<td>${row[key]}</td>`;
}
}
static GetEdit(data={}){
for(let i=0; i<data.extraData.trainees.length; i++){
data.extraData.trainees[i].name = System.buildEmployeeName(data.extraData.trainees[i].name)
}
return {
"name": {
"val" : data.name ?? ""
,"type" : "text"
,"isRow": true
,"mandatory":true
}
,"short_name": {
"val" : data.short_name ?? ""
,"type" : "text"
,"isRow": true
,"mandatory":true
}
,"content": {
"val" : data.content ?? ""
,"type" : "textarea"
,"isRow": true
,"mandatory":true
,autogrow: true
,rows:3
}
,"allow_self_entry": {
"val" : data.allow_self_entry ?? ""
,"type" : "dropdown"
,"mandatory":true
,options:System.GetBooleanOptions()
}
,"min_rank_id": {
"val" : data.min_rank_id ?? ""
,"type" : "dropdown"
,"mandatory":true
,options:System.getRankOptions()
}
,"trainee": {
"val" : data.trainee ?? ""
,"type" : "dropdown"
,"isRow": true
,"mandatory":true
,options:data.extraData.trainees
}
}
}
}

View file

@ -0,0 +1,90 @@
class TrainingsParticipants{
constructor(){
this.name = "trainingsparticipants";
}
static allowEditEmployeeTrainings(){
return userrights.has("trainingsemployees.edit")
}
static GetColumns(){
return ["name","action","passed","id"]
}
static TableDataCreate(row, key){
if(key == "id"){
if(row.passed > -1){
let btn = ``;
if(this.allowEditEmployeeTrainings()){
btn = `
<button type="button" class="btn btn-sm btn-error" onclick="trainingPassed(-1, '${row["employee_id"]}', '${row["training_id"]}')">
<i class="fa-solid fa-delete-left"></i>
</button>
`;
}
return `
<td>
${btn}
</td>`;
}
else{
return `<td></td>`;
}
}
else if(key == "action"){
let disabled = "";
let content = ``;
if(row.participate > 0){
disabled = " disabled"
}
if(this.allowEditEmployeeTrainings()){
content = `<button type="button" class="btn btn-sm btn-primary" onclick="participateForTraining(${row["training_id"]}, '${row["employee_id"]}')" ${disabled}>${getTranslation("participate")}</button>`
}
return `
<td>
${content}
</td>`;
}
else if(key == "passed"){
let content = "";
if(row[key] == -1 && this.allowEditEmployeeTrainings()){
content = `
<button type="button" class="btn btn-sm btn-error" onclick="trainingPassed(0, '${row["employee_id"]}', '${row["training_id"]}')">
<i class="fa-solid fa-xmark"></i>
</button>
<button type="button" class="btn btn-sm btn-success" onclick="trainingPassed(1, '${row["employee_id"]}', '${row["training_id"]}')">
<i class="fa-solid fa-check"></i>
</button>`
;
}
else if(row[key] == 0){
content = `<i class="fa-solid fa-xmark text-error"></i>`;
}
else if(row[key] == 1){
content = `<i class="fa-solid fa-check text-success"></i>`;
}
return `
<td>
${content}
</td>`;
}
else if(key == "name"){
return `
<td>
${System.buildEmployeeName(row[key])}
</td>`;
}
else{
return `<td>${row[key]}</td>`;
}
}
}

View file

@ -0,0 +1,752 @@
let locale = 'en';
let navMenu;
let isInit = true;
let userrights;
let lastjob;
let lastjobgrade;
let currentSystem;
let job_grades = [];
let sync;
let useWeaponRegister = true;
let useMyImpound = true;
let useMySpeedcam = true;
let HandleParagraphsAsNumber = false;
let UseMotDateFromMyMechanicMDT = false;
let showLastMotDetailFromMyMechanicMDT = false;
let showPartAcceptanceFromMyMechanicMDT = false;
let UseMyPrison = false;

let globalFileSearcher = new FileSearch()

const coreFile = "myMDT_core";


(function(){
document.onkeydown = function(e){
if(e.key.toLowerCase() == "escape"){
closeWin();
}
}


document.getElementById("delete-modal-delete").onclick=function(){
let id = document.getElementById("delete-modal").getAttribute("data-id");
let src = document.getElementById("delete-modal").getAttribute("data-delete-destination");
deleteData(src, id);
}


window.addEventListener('message', function( event ) {
if(event.data.message == "show"){
document.documentElement.setAttribute("data-theme",event.data.theme)

useWeaponRegister = event.data.useWeaponRegister
HandleParagraphsAsNumber = event.data.HandleParagraphsAsNumber
UseMotDateFromMyMechanicMDT = event.data.UseMotDateFromMyMechanicMDT
showLastMotDetailFromMyMechanicMDT = event.data.showLastMotDetailFromMyMechanicMDT
showPartAcceptanceFromMyMechanicMDT = event.data.showPartAcceptanceFromMyMechanicMDT
useMyImpound = event.data.useMyImpound
useMySpeedcam = event.data.useMySpeedcam
UseMyPrison = event.data.UseMyPrison

sync=new Sync(event.data.Sync)
locale = event.data.locale
document.getElementById("main_navigation_copname").innerHTML = System.buildEmployeeName(event.data.username);
document.getElementById("main").style.display = "";
document.getElementById("radiostates").style.display = "none";
userrights = new Rights(event.data.rights);
job_grades = event.data.job_grades;

if(lastjob != event.data.job || lastjobgrade != event.data.jobgrade){
isInit = true;
lastjob = event.data.job;
lastjobgrade = event.data.jobgrade;
}

currentSystem = event.data.currentsystem;
System.SetColor(event.data.currentsystem);

navMenu = new NavMenu(navigation, event.data.currentsystem);

Array.from(document.querySelectorAll(".nav-checkrights")).forEach(function(item){
if(item.getAttribute("data-rightkey") != ""){
if(userrights.has(item.getAttribute("data-rightkey"))){
item.style.display = "";
}
else{
item.style.display = "none";
}

if (item.id == "menuItem-li-regweapons" && !useWeaponRegister){
item.style.display = "none";
}
if (item.id == "menuItem-li-prison" && !UseMyPrison){
item.style.display = "none";
}
if (item.id == "menuItem-li-speedcamsmobile" && !useMySpeedcam){
item.style.display = "none";
}
if (item.id == "menuItem-li-speedcamsprofit" && !useMySpeedcam){
item.style.display = "none";
}
if (item.id == "menuItem-li-regvehicleimpounded" && !useMyImpound){
item.style.display = "none";
}
}
});

Array.from(document.querySelectorAll(".nav-checkfor-nextelements")).forEach(function(item){
let itemsVisible = false;

Array.from(document.querySelectorAll(".divier-" + item.getAttribute("data-tkey"))).forEach(function(child){
if(child.style.display != "none"){
itemsVisible = true;
}
});

if(!itemsVisible){
item.style.display="none";
}
else{
item.style.display="";
}
});

if(isInit){
loadPage("dashboard.dataload",-1);
isInit=false;
}
}
else if(event.data.message == "show-radio-states"){
locale = event.data.locale
document.documentElement.setAttribute("data-theme",event.data.theme)

document.getElementById("radiostates").style.display = "block";
document.getElementById("main").style.display = "none";

let radioDetails = System.getRadioState(event.data.curstate.vehicle, event.data.curstate.person);

let radioHud = new RadioHud();

radioHud.SetLocation(event.data.config.Position);
radioHud.SetExtraMargins(event.data.config.extraMargins);
radioHud.DrawInfo(radioDetails);

radioHud.DrawButtons(event.data.data, radioDetails.radio_id, radioDetails.radio_default);

}
});

fetch(`http://${location.host}/NuiReady`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify({})
}).then((response) => {
response.json().then(function(retobj){});
});

})();


function handleMenuItemClick(item){
navMenu.setItemActive(item);
showLoading();

loadPage(item.getAttribute("data-destination"), -1, item.getAttribute("data-forceReload"));
}


function showLoading(){
document.getElementById("currentpage-content").innerHTML = `
Loading..
<progress class="progress progress-accent w-100 "></progress>
`;
}


function setCurrentPageHeadLine(text){
document.getElementById("current_page_name").innerHTML = text;
}

function changeDestination(input){
if(input == "lawbooklaws.dataload"){
input = "lawbooks.dataload"
}
if(input == "evidenceroomarticles.dataload"){
input = "evidencerooms.dataload"
}

return input;
}


function loadPage(destination, id, force = "false", staticData={}){
destination = changeDestination(destination);
document.body.setAttribute("data-quicksearch","")

if(destination.endsWith(".dataload") || destination.endsWith(".overview")){
force = "true";

if(destination.endsWith(".overview")){
document.body.setAttribute("data-quicksearch",document.getElementById("global-searchbar") ? document.getElementById("global-searchbar").value.trim() : "")
}
}

if(destination != document.body.getAttribute("data-lastdest")){
resetPageNum();
document.body.setAttribute("data-quicksearch","");
}
else if(id != document.body.getAttribute("data-last-id")){
resetPageNum();
}

document.body.setAttribute("data-lastdest", destination);
document.body.setAttribute("data-last-id", id);
document.body.setAttribute("data-force-load", force);

setActiveItem(destination);
setCurrentPageHeadLine(getTranslation(destination));
showLoading();



if(id == -1 && force == "false" && destination!="trainings.add" && destination!="criminalcomplaint.add" && destination!="evidenceroomarticles.add" && destination!="regvehicle.add" && destination!="regweapons.add"){
if(destination.endsWith(".view") || destination.endsWith(".edit") || destination.endsWith(".add")){
let loadtype = destination.replace(".view","").replace(".edit","").replace(".add","");
ShowDetails(destination, loadtype, staticData);
}
}
else{
loadData(destination, id, staticData)
}
}


function reload(){
loadPage(document.body.getAttribute("data-lastdest"),document.body.getAttribute("data-last-id"),document.body.getAttribute("data-force-load") )
}

function setActiveItem(destination){

let type = destination.replace(".overview","").replace(".dataload","").replace(".add","").replace(".edit","").replace(".view","");
let item;

if(destination == "trainings.add" || destination == "missionreport.add"){
type += ".add"
}

if(document.getElementById("menuitem-" + type)){
item = document.getElementById("menuitem-" + type);
}

if(item){
navMenu.setItemActive(item);
}
}

function ShowCustom(destination, loadtype, retobj){
let _class = System.getClassByName(loadtype);


if(_class !== null){
_class.CreateCustom(retobj);
}
else{
console.log("no class defined for " + loadtype);
}
}

function ShowOverview(loadtype, data){
let _class = System.getClassByName(loadtype);


if(_class !== null){
System.CreateOverView(
_class
,data
);
}
else{
console.log("no overview defined for " + loadtype)
}
}

function ShowDetails(destination, loadtype = "", data = {}){

let isViewMode = destination.endsWith(".view");
loadtype = loadtype.toLocaleLowerCase();

let _class = System.getClassByName(loadtype);

if(_class !== null){
let dest = "overview";

if (_class.hasOwnProperty("isCustom") && _class.isCustom()) {
dest = "dataload";
}

System.CreateEdit(
_class
,data.data
,isViewMode
,destination
,loadtype + "." + dest
);
}
else{
console.log("no detailsview defined for " + loadtype)
}
}


async function loadData(destination, id, staticData = {}){
destination = changeDestination(destination);

setActiveItem(destination.toLowerCase());
setCurrentPageHeadLine(getTranslation(destination.toLowerCase()));
showLoading();

destination = destination.toLowerCase()

let loadDest = destination;
let loadinfo = destination;

if(destination.endsWith(".overview")){
loadDest = "overview";
loadinfo = destination.replace(".overview","");
}
else if(destination.endsWith(".view") || destination.endsWith(".edit") || destination.endsWith(".add")){
loadDest = "loadDetails";
loadinfo = destination.replace(".view","");
loadinfo = loadinfo.replace(".edit","");
loadinfo = loadinfo.replace(".add","");
}
else{
loadDest = "custom"
loadinfo = destination.replace(".dataload","");
}

let data;
try{
const response = await fetch(`http://${location.host}/${loadDest}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify({
"pageNum": 1*((document.body.getAttribute("data-cur-pageNum")) ?? 1)-1,
"id": id,
"quicksearch": document.body.getAttribute("data-quicksearch"),
"load_info": loadinfo
})
});
data = await response.json();
}
catch(error){
console.log('Error fetching data:', error);
console.log(`--------------------------------------------`)
console.log(`info : http://${location.host}/${loadDest}`)
console.log(`pageNum : ${1*((document.body.getAttribute("data-cur-pageNum")) ?? 1)-1}`)
console.log(`id : ${id}`)
console.log(`load_info : ${loadinfo}`)
console.log(`quicksearch : ${quicksearch}`)
console.log(`--------------------------------------------`)
}

if(data){
if(loadDest == "overview"){
ShowOverview(loadinfo, data);
}
else if(loadDest == "loadDetails"){
if(staticData.data !== undefined && staticData.data !== null){
for (const [key, value] of Object.entries(staticData.data)) {
if(data.data[key] == undefined){
data.data[key] = value
}
}
}

ShowDetails(destination, loadinfo, data);
}
else if(loadDest == "custom"){
ShowCustom(destination, loadinfo, data);
}
}
}



function sendDataToAPI(source, destination, id, destination_id, formdata){
fetch(`http://${location.host}/save-data`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify({
"source": source,
"id": id,
"formData": formdata,
"source": source.toLowerCase()
})
}).then((response) => {
response.json().then(function(retobj){
loadPage(destination.toLowerCase(), destination_id);
});
});
}
function deleteData(source, id){
fetch(`http://${location.host}/delete-data`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify({
"id": id,
"source": source.toLowerCase()
})
}).then((response) => {
response.json().then(function(retobj){
document.getElementById("delete-modal").checked = false;
reload();
});
});
}

function saveData(source, destination, id, destination_id){
sendDataToAPI(source, destination, id, destination_id, Form.getFormData())
}
function finishManhunt(source, id){
fetch(`http://${location.host}/finish-manhunt`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify({
"source": source,
"id": id,
"source": source.toLowerCase()
})
}).then((response) => {
response.json().then(function(retobj){
reload();
});
});
}
async function takeControlCentre(isReset){
let data;
try{
const response = await fetch(`http://${location.host}/takeControlCentre`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify({
"isReset": isReset
})
});
data = await response.json();

reload();
}
catch(error){
console.log('Error fetching data:', error);
console.log(`info : http://${location.host}/takeControlCentre?isReset=${isReset}`)
}
}

async function SetRadioState(newID, destinationPage){
let data;
try{
const response = await fetch(`http://${location.host}/SetRadioState`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify({
"new_state": newID
})
});
data = await response.json();
loadPage(destinationPage,-1)
}
catch(error){
console.log('Error fetching data:', error);
console.log(`info : http://${location.host}/SetRadioState?new_state=${newID}`)
}
}
async function SetRadioStateShortcut(newID){
let data;
try{
const response = await fetch(`http://${location.host}/SetRadioState`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify({
"new_state": newID
})
});
data = await response.json();
closeWin()
}
catch(error){
console.log('Error fetching data:', error);
console.log(`info : http://${location.host}/SetRadioState?new_state=${newID}`)
}
}
async function SetVehicle(newID, destinationPage){
let data;
try{
const response = await fetch(`http://${location.host}/SetVehicle`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify({
"new_state": newID
})
});
data = await response.json();

loadPage(destinationPage, -1);
}
catch(error){
console.log('Error fetching data:', error);
console.log(`info : http://${location.host}/SetVehicle?new_state=${newID}`)
console.log(`destinationpage : ${destinationPage}`)
}
}


async function changeDataInColumn(loadType, columnName, id, new_value){
let formdata = {};
formdata[columnName] = new_value
sendDataToAPI(loadType, document.body.getAttribute("data-lastdest") ,id, document.body.getAttribute("data-last-id"), formdata)
}

async function EmployeeSuspend(loadType, employeeid, value){
let data;

try{
const response = await fetch(`http://${coreFile}/employee_suspend`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify({
"id": employeeid
,"value": value
})
});
data = await response.json();
loadPage(loadType, -1);
}
catch(error){
console.log('Error fetching data:', error);
console.log(`info : http://${location.host}/employee_suspend?id=${employeeid}&value=${value}`)
}
}

async function resetVehicle(vehicleId){
let data;

try{
const response = await fetch(`http://${location.host}/resetVehicle`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify({
"id": vehicleId
})
});
data = await response.json();
loadPage("controlcentre.dataload".toLowerCase(), -1);
}
catch(error){
console.log('Error fetching data:', error);
console.log(`info : http://${location.host}/resetVehicle?id=${vehicleId}`)
}
}
async function resetEmployeeRadio(employeeid){
let data;

try{
const response = await fetch(`http://${location.host}/resetEmployeeRadio`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify({
"id": employeeid
})
});
data = await response.json();
loadPage("controlcentre.dataload".toLowerCase(), -1);
}
catch(error){
console.log('Error fetching data:', error);
console.log(`info : http://${location.host}/resetEmployeeRadio?id=${vehicleId}`)
}
}
async function closeWin(){
let data;
try{
const response = await fetch(`http://${location.host}/closeWindow`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify({})
});
data = await response.json();

document.getElementById("main").style.display = "none";
document.getElementById("radiostates").style.display = "none";
}
catch(error){
console.log('Error while closing');
}
}

async function participateForTraining(trainingId, employee_id = null, fromEmployee = false){
let formdata = {};
formdata.training_id = trainingId
formdata.employee_id = employee_id

let destination = "trainings.overview";
let destId = -1;
if(employee_id !== null){
destination = "trainings.view";
destId = trainingId;
}

if(!fromEmployee){
sendDataToAPI("trainingsemployees", destination,-1, destId, formdata);
}
else{
sendDataToAPI("employeestraining", "employeestraining.dataload",-1, employee_id, formdata)
}
}
async function trainingPassed(passed, employee_id, training_id, fromEmployee = false){
let formdata = {};
formdata.training_id = training_id
formdata.employee_id = employee_id
formdata.passed = passed

if(!fromEmployee){
sendDataToAPI("trainingsemployees", "trainings.view",-1, training_id, formdata)
}
else{
sendDataToAPI("employeestraining", "employeestraining.dataload",-1, employee_id, formdata)
}
}

async function addLicenseToFile(file_id){
let licenseid = document.getElementById("input-files-license").value;

let formdata = {};
formdata.file_id = file_id
formdata.license_id = licenseid
sendDataToAPI("fileslicenses", "files.view",-1, file_id, formdata)
}

async function GenerateRoute(buttonEl, isProperty){
let data;

let coords = buttonEl.getAttribute("data-entering");
let parsed = JSON.parse(coords);
let xPos;
let yPos;

if(isProperty){
let is_my_property = buttonEl.getAttribute("data-is-my-property");
let is_qs_housing = buttonEl.getAttribute("data-is-qs-housing");

if(is_my_property == "1"){
xPos = parsed.x
yPos = parsed.y
}
else if(is_qs_housing == "1"){
xPos = parsed.enter.x
yPos = parsed.enter.y
}
else{
return;
}
}
else{
xPos = parsed.x
yPos = parsed.y
}


try{
const response = await fetch(`http://${location.host}/GenerateRoute`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify({
x: xPos,
y: yPos
})
});
data = await response.json();

closeWin();
}
catch(error){
console.log('Error while set route');
}
}

async function SearchFiles(htmlEl){
let data;

try{
const response = await fetch(`http://${location.host}/filterFilesDropdown`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify({
id: htmlEl.getAttribute("data-parentid"),
search: htmlEl.value
})
});
data = await response.json();
}
catch(error){
console.log('Error while set SearchFiles');
}
Form.refillFilesDropDown(htmlEl, data)

}

function resetPageNum(){
document.body.setAttribute("data-cur-pageNum",1);
}

View file

@ -0,0 +1,764 @@
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 `<s>${getTranslation("employee.unknown")}</s>`;
}

if(input == ""){
return "";
}

let JSONS = input.split("<SEPERATOR>")
let retval = "";

for(let i=0; i<JSONS.length; i++){

let valueseperator = JSONS[i].split("<VALSEPERATOR>");

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<json.length; i++){
let splitted = json[i].split(":");
parsed[splitted[0]] = splitted[1];
}
}
retval += (retval == "" ? "" : "<br> ") + (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 `<h2>${getTranslation("no_data_found")}</h2>`;
}

let columns = _class.GetColumns(additionalData);
let html = `<table class = "table table-compact w-full">`
for(let i=0; i<gridData.length;i++){
if(i==0){

html += `<thead>`;
html += `<tr>`;

for(let k=0; k<columns.length;k++){
html += `<th>${getTranslation(columns[k])}</th>`;
}
html += `</tr>`;
html += `</thead>`;
html += `<tbody>`;
}

html+=`<tr>`;

for(let j=0; j<columns.length;j++){
let key = columns[j];
html+= _class.TableDataCreate(gridData[i], key, additionalData)
}

html+=`</tr>`;

}
html += `</tbody>`;
html += `</table>`;

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 += `<div class="card w-full p-2 bg-base-100 shadow-xl mt-2 mb-6 " >`
html += `<div class="h-full w-full bg-base-100" >`
html += `<div class="overflow-x-auto w-full" >`
html += this.GetTable(_class, gridData);

html += `</div>`
html += `</div>`
html += `</div>`
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 += `
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
`;
groupInit=true;
}
else if((inputData[key].isRow == true || inputData[key].type == "divider") && groupInit ){
html += `
</div>
`;
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+=`</div>`;
}

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 += `
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 pt-6">
${Form.cancelButton(src, dest, destid)}
${Form.saveButton(_class.name, dest, data.id ?? -1, destid)}
</div">
`;

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}`;
}


}