1
0
Fork 0
forked from Simnation/Main
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,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
}
}
}
}

View file

@ -0,0 +1,275 @@
class FileEntry{
constructor(){
this.name = "fileentry";
}
static GetCustomDestination(data, dest){
return (data.file_id ?? "" != "" ? "files.view" : "files.overview");
}
static GetCustomDestID(data, destID){
return data.file_id ?? destID;
}
static GetColumns(){
if(currentSystem == "police"){
return ["name","alias","phone","id"];
}
else if(currentSystem == "medic"){
return ["name","alias","phone","state","id"];
}
}
static GetExtraForEdit(data){
let retval = {
top:"",
bottom:""
}
if(currentSystem == "medic"){
retval.bottom = `
<div class="divider pt-4 pb-4">${getTranslation("injuries")}</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div class="human-body human-body-height">
<svg onclick="System.ToggleInjury(this)" id='injury-injury_head' class='head' xmlns='http://www.w3.org/2000/svg' width='56.594' height='95.031' viewBox='0 0 56.594 95.031'><path d='M15.92 68.5l8.8 12.546 3.97 13.984-9.254-7.38-4.622-15.848zm27.1 0l-8.8 12.546-3.976 13.988 9.254-7.38 4.622-15.848zm6.11-27.775l.108-11.775-21.16-14.742L8.123 26.133 8.09 40.19l-3.24.215 1.462 9.732 5.208 1.81 2.36 11.63 9.72 11.018 10.856-.324 9.56-10.37 1.918-11.952 5.207-1.81 1.342-9.517zm-43.085-1.84l-.257-13.82L28.226 11.9l23.618 15.755-.216 10.37 4.976-17.085L42.556 2.376 25.49 0 10.803 3.673.002 24.415z'/></svg>
<svg onclick="System.ToggleInjury(this)" id='injury-injury_left_shoulder' class='left-shoulder' xmlns='http://www.w3.org/2000/svg' width='109.532' height='46.594' viewBox='0 0 109.532 46.594'><path d='m 38.244,-0.004 1.98,9.232 -11.653,2.857 -7.474,-2.637 z M 17.005,10.536 12.962,8.35 0.306,22.35 0.244,27.675 c 0,0 16.52,-17.015 16.764,-17.14 z m 1.285,0.58 C 18.3,11.396 0.528,30.038 0.528,30.038 L -0.01,46.595 6.147,36.045 18.017,30.989 26.374,15.6 Z'/></svg>
<svg onclick="System.ToggleInjury(this)" id='injury-injury_right_shoulder' class='right-shoulder' xmlns='http://www.w3.org/2000/svg' width='109.532' height='46.594' viewBox='0 0 109.532 46.594'><path d='m 3.2759972,-0.004 -1.98,9.232 11.6529998,2.857 7.473999,-2.637 z m 21.2379988,10.54 4.044,-2.187 12.656,14 0.07,5.33 c 0,0 -16.524,-17.019 -16.769,-17.144 z m -1.285,0.58 c -0.008,0.28 17.762,18.922 17.762,18.922 l 0.537,16.557 -6.157,-10.55 -11.871,-5.057 L 15.147997,15.6 Z'/></svg>
<svg onclick="System.ToggleInjury(this)" id='injury-injury_left_arm' class='left-arm' xmlns='http://www.w3.org/2000/svg' width='156.344' height='119.25' viewBox='0 0 156.344 119.25'><path d='m21.12,56.5a1.678,1.678 0 0 1 -0.427,0.33l0.935,8.224l12.977,-13.89l1.2,-8.958a168.2,168.2 0 0 0 -14.685,14.294zm1.387,12.522l-18.07,48.91l5.757,1.333l19.125,-39.44l3.518,-22.047l-10.33,11.244zm-5.278,-18.96l2.638,18.74l-17.2,46.023l-2.657,-1.775l6.644,-35.518l10.575,-27.47zm18.805,-12.323a1.78,1.78 0 0 1 0.407,-0.24l3.666,-27.345l-7.037,-10.139l-7.258,10.58l-6.16,37.04l0.566,4.973a151.447,151.447 0 0 1 15.808,-14.87l0.008,0.001zm-13.742,-28.906l-3.3,35.276l-2.2,-26.238l5.5,-9.038z'/></svg>
<svg onclick="System.ToggleInjury(this)" id='injury-injury_right_arm' class='right-arm' xmlns='http://www.w3.org/2000/svg' width='156.344' height='119.25' viewBox='0 0 156.344 119.25'><path d='m 18.997,56.5 a 1.678,1.678 0 0 0 0.427,0.33 L 18.489,65.054 5.512,51.164 4.312,42.206 A 168.2,168.2 0 0 1 18.997,56.5 Z m -1.387,12.522 18.07,48.91 -5.757,1.333 L 10.798,79.825 7.28,57.778 17.61,69.022 Z m 5.278,-18.96 -2.638,18.74 17.2,46.023 2.657,-1.775 L 33.463,77.532 22.888,50.062 Z M 4.083,37.739 A 1.78,1.78 0 0 0 3.676,37.499 L 0.01,10.154 7.047,0.015 l 7.258,10.58 6.16,37.04 -0.566,4.973 A 151.447,151.447 0 0 0 4.091,37.738 l -0.008,10e-4 z m 13.742,-28.906 3.3,35.276 2.2,-26.238 -5.5,-9.038 z'/></svg>
<svg onclick="System.ToggleInjury(this)" id='injury-injury_chest' class='chest' xmlns='http://www.w3.org/2000/svg' width='86.594' height='45.063' viewBox='0 0 86.594 45.063'><path d='M19.32 0l-9.225 16.488-10.1 5.056 6.15 4.836 4.832 14.07 11.2 4.616 17.85-8.828-4.452-34.7zm47.934 0l9.225 16.488 10.1 5.056-6.15 4.836-4.833 14.07-11.2 4.616-17.844-8.828 4.45-34.7z'/></svg>
<svg onclick="System.ToggleInjury(this)" id='injury-injury_stomach' class='stomach' xmlns='http://www.w3.org/2000/svg' width='75.25' height='107.594' viewBox='0 0 75.25 107.594'><path d='M19.25 7.49l16.6-7.5-.5 12.16-14.943 7.662zm-10.322 8.9l6.9 3.848-.8-9.116zm5.617-8.732L1.32 2.15 6.3 15.6zm-8.17 9.267l9.015 5.514 1.54 11.028-8.795-5.735zm15.53 5.89l.332 8.662 12.286-2.665.664-11.826zm14.61 84.783L33.28 76.062l-.08-20.53-11.654-5.736-1.32 37.5zM22.735 35.64L22.57 46.3l11.787 3.166.166-16.657zm-14.16-5.255L16.49 35.9l1.1 11.25-8.8-7.06zm8.79 22.74l-9.673-7.28-.84 9.78L-.006 68.29l10.564 14.594 5.5.883 1.98-20.735zM56 7.488l-16.6-7.5.5 12.16 14.942 7.66zm10.32 8.9l-6.9 3.847.8-9.116zm-5.617-8.733L73.93 2.148l-4.98 13.447zm8.17 9.267l-9.015 5.514-1.54 11.03 8.8-5.736zm-15.53 5.89l-.332 8.662-12.285-2.665-.664-11.827zm-14.61 84.783l3.234-31.536.082-20.532 11.65-5.735 1.32 37.5zm13.78-71.957l.166 10.66-11.786 3.168-.166-16.657zm14.16-5.256l-7.915 5.514-1.1 11.25 8.794-7.06zm-8.79 22.743l9.673-7.28.84 9.78 6.862 12.66-10.564 14.597-5.5.883-1.975-20.74z'/></svg>
<svg onclick="System.ToggleInjury(this)" id='injury-injury_left_leg' class='left-leg' xmlns='http://www.w3.org/2000/svg' width='93.626' height='250.625' viewBox='0 0 93.626 250.625'><path d='m 18.00179,139.99461 -0.664,5.99 4.647,5.77 1.55,9.1 3.1,1.33 2.655,-13.755 1.77,-4.88 -1.55,-3.107 z m 20.582,0.444 -3.32,9.318 -7.082,13.755 1.77,12.647 5.09,-14.2 4.205,-7.982 z m -26.557,-12.645 5.09,27.29 -3.32,-1.777 -2.656,8.875 z m 22.795,42.374 -1.55,4.88 -3.32,20.634 -0.442,27.51 4.65,26.847 -0.223,-34.39 4.87,-13.754 0.663,-15.087 z m -10.623,12.424 1.106,41.267 c 14.157565,64.57987 -5.846437,10.46082 -16.8199998,-29.07 l 5.5329998,-36.384 z m -9.71,-178.164003 0,22.476 15.71,31.073 9.923,30.850003 -1.033,-21.375 z m 25.49,30.248 0.118,-0.148 -0.793,-2.024 -16.545,-18.16 -1.242,-0.44 10.984,28.378 z m -6.255,10.766 6.812,17.6 2.274,-21.596 -1.344,-3.43 z m -26.4699998,17.82 0.827,25.340003 12.8159998,35.257 -3.928,10.136 -12.6099998,-44.51 z M 31.81879,76.04161 l 0.345,0.826 6.47,15.48 -4.177,38.342 -6.594,-3.526 5.715,-35.7 z m -21.465,-74.697003 0.827,21.373 L 4.1527902,65.02561 0.84679017,30.870607 Z m 2.068,27.323 14.677,32.391 3.307,26.000003 -6.2,36.58 -13.437,-37.241 -0.8269998,-38.342003 z'/></svg>
<svg onclick="System.ToggleInjury(this)" id='injury-injury_right_leg' class='right-leg' xmlns='http://www.w3.org/2000/svg' width='80' height='250.625' viewBox='0 0 80 250.625'><path d='m 26.664979,139.7913 0.663,5.99 -4.647,5.77 -1.55,9.1 -3.1,1.33 -2.655,-13.755 -1.77,-4.88 1.55,-3.107 z m -20.5820002,0.444 3.3200005,9.318 7.0799997,13.755 -1.77,12.647 -5.0899997,-14.2 -4.2000005,-7.987 z m 3.7620005,29.73 1.5499997,4.88 3.32,20.633 0.442,27.51 -4.648,26.847 0.22,-34.39 -4.8670002,-13.754 -0.67,-15.087 z m 10.6229997,12.424 -1.107,41.267 -8.852,33.28 9.627,-4.55 16.046,-57.8 -5.533,-36.384 z m -13.9460002,74.991 c -5.157661,19.45233 -2.5788305,9.72616 0,0 z M 30.177979,4.225305 l 0,22.476 -15.713,31.072 -9.9230002,30.850005 1.033,-21.375005 z m -25.4930002,30.249 -0.118,-0.15 0.793,-2.023 16.5450002,-18.16 1.24,-0.44 -10.98,28.377 z m 6.2550002,10.764 -6.8120002,17.6 -2.274,-21.595 1.344,-3.43 z m 26.47,17.82 -0.827,25.342005 -12.816,35.25599 3.927,10.136 12.61,-44.50999 z m -24.565,12.783005 -0.346,0.825 -6.4700002,15.48 4.1780002,38.34199 6.594,-3.527 -5.715,-35.69999 z m 19.792,51.74999 -5.09,27.29 3.32,-1.776 2.655,8.875 z m 1.671,-126.452995 -0.826,21.375 7.03,42.308 3.306,-34.155 z m -2.066,27.325 -14.677,32.392 -3.308,26.000005 6.2,36.57999 13.436,-37.23999 0.827,-38.340005 z'/></svg>
<svg onclick="System.ToggleInjury(this)" id='injury-injury_left_hand' class='left-hand' xmlns='http://www.w3.org/2000/svg' width='90' height='38.938' viewBox='0 0 90 38.938'><path d='m 21.255,-0.00198191 2.88,6.90000201 8.412,1.335 0.664,12.4579799 -4.427,17.8 -2.878,-0.22 2.8,-11.847 -2.99,-0.084 -4.676,12.6 -3.544,-0.446 4.4,-12.736 -3.072,-0.584 -5.978,13.543 -4.428,-0.445 6.088,-14.1 -2.1,-1.25 L 4.878,34.934 1.114,34.489 12.4,12.9 11.293,11.12 0.665,15.57 0,13.124 8.635,5.3380201 Z' /></svg>
<svg onclick="System.ToggleInjury(this)" id='injury-injury_right_hand' class='right-hand' xmlns='http://www.w3.org/2000/svg' width='90' height='38.938' viewBox='0 0 90 38.938'><path d='m 13.793386,-0.00198533 -2.88,6.90000163 -8.4120002,1.335 -0.664,12.4579837 4.427,17.8 2.878,-0.22 -2.8,-11.847 2.99,-0.084 4.6760002,12.6 3.544,-0.446 -4.4,-12.736 3.072,-0.584 5.978,13.543 4.428,-0.445 -6.088,-14.1 2.1,-1.25 7.528,12.012 3.764,-0.445 -11.286,-21.589 1.107,-1.78 10.628,4.45 0.665,-2.447 -8.635,-7.7859837 z'/></svg>
<svg onclick="System.ToggleInjury(this)" id='injury-injury_left_foot' class='left-foot' xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'><path d='m 19.558357,1.92821 c -22.1993328,20.55867 -11.0996668,10.27933 0,0 z m 5.975,5.989 -0.664,18.415 -1.55,6.435 -4.647,0 -1.327,-4.437 -1.55,-0.222 0.332,4.437 -5.864,-1.778 -1.5499998,-0.887 -6.64,-1.442 -0.22,-5.214 6.418,-10.87 4.4259998,-5.548 c 9.991542,-3.26362 9.41586,-8.41457 12.836,1.111 z'/></svg>
<svg onclick="System.ToggleInjury(this)" id='injury-injury_right_foot' class='right-foot' xmlns='http://www.w3.org/2000/svg' width='90' height='38.938' viewBox='0 0 90 38.938'><path d='m 11.723492,2.35897 c -40.202667,20.558 -20.1013335,10.279 0,0 z m -5.9740005,5.989 0.663,18.415 1.546,6.435 4.6480005,0 1.328,-4.437 1.55,-0.222 -0.333,4.437 5.863,-1.778 1.55,-0.887 6.638,-1.442 0.222,-5.214 -6.418,-10.868 -4.426,-5.547 -10.8440005,-4.437 z'/> </svg>
</div>
<textarea id="input-injury_summary" type="text" placeholder="" class="textarea textarea-sm textarea-bordered col-span-2" ></textarea>
</div>
`;
}
else if(currentSystem == "police"){
retval.bottom = '<div id = "file_entry_fine_crime_view" class="mt-4">';
retval.bottom += `<p class="text-xl">${getTranslation("fine_crime")}</p>`;
retval.bottom += LawBooks.CreateCustom(data, true);
retval.bottom += `
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
${Form.NumberField(true, "fine", 0)}
${Form.NumberField(true, "detention_time", 0)}
</div>
`
retval.bottom += '</div>';
}
return retval;
}
static ToggleLawBooks(){
if(document.getElementById("input-type_of_entry").value == 0){
document.getElementById("file_entry_fine_crime_view").style.display = "block";
}
else{
document.getElementById("file_entry_fine_crime_view").style.display = "none";
}
}
static ValidateAndCalcLawBookLaws(){
let resFine = 0;
let resDetentionTime = 0;
Array.from(document.getElementById("currentpage-content").querySelectorAll(".lawbook_laws_calc_penalty")).forEach(function(el){
let amount = parseInt(el.value);
let rowId = el.id.replace("input-lawbook_laws_amount_", "");
if(amount > 0){
let minPenalty = document.getElementById("input-lawbook_laws_minimum_penalty_" + rowId).value;
let detentionTime = document.getElementById("input-lawbook_laws_detention_time_" + rowId).value;
resFine += parseInt(minPenalty) * parseInt(amount);
resDetentionTime += parseInt(detentionTime) * parseInt(amount);
}
});
resFine = parseInt(resFine);
resDetentionTime = parseInt(resDetentionTime);
document.getElementById("input-fine").value = resFine;
document.getElementById("input-detention_time").value = resDetentionTime;
Form.validate();
}
static TableDataCreate(row, key){
return `<td>${row[key]}</td>`;
}
static GetEdit(data = {}){
if(currentSystem == "police"){
return {
"file_id": {
"val" : data.file_id ?? ""
,"type" : "hidden"
,"mandatory":true
},
"file_entry_id": {
"val" : data.file_entry_id ?? System.getDate() + "-CPENT"
,"type" : "hidden"
,"mandatory":true
}
,"content": {
"val" : data.content ?? ""
,"type" : "textarea"
,"mandatory":true
,"isRow":true
,autogrow: true
}
,"is_wanted": {
"val" : (data.is_wanted ?? false ? 1 : 0)
,"type" : "dropdown"
,"mandatory":true
,"options":System.GetBooleanOptions()
}
,"type_of_entry": {
"val" : data.type_of_entry ?? 0
,"extraClass" : "police_fileentry_type_of_entry"
,"type" : "dropdown"
,"mandatory":true
,"options":System.getFileEntryTypesOptions()
}
/*
,"fine": {
"val" : data.fine ?? "0"
,"type" : "number"
,"mandatory":true
}
,"detention_time": {
"val" : data.detention_time ?? "0"
,"type" : "number"
,"mandatory":true
}
*/
};
}
else if(currentSystem == "medic"){
return {
"file_id": {
"val" : data.file_id ?? ""
,"type" : "hidden"
,"mandatory":true
},
"file_entry_id": {
"val" : data.file_entry_id ?? System.getDate() + "-MDENT"
,"type" : "hidden"
,"mandatory":true
}
,"content": {
"val" : data.content ?? ""
,"type" : "textarea"
,"mandatory":true
,"isRow":true
,autogrow: true
}
,"intensity_of_wounds": {
"val" : data.intensity_of_wounds ?? ""
,"type" : "text"
,"mandatory":true
,"isRow":false
}
,"type_of_bleeding": {
"val" : data.type_of_bleeding ?? ""
,"type" : "text"
,"mandatory":true
,"isRow":false
}
,"treatment": {
"val" : data.treatment ?? ""
,"type" : "text"
,"mandatory":true
}
,"needs_follow_up_treatment": {
"val" : data.needs_follow_up_treatment ?? "0"
,"type" : "dropdown"
,"mandatory":true
,options:System.GetBooleanOptions()
}
,"injury_head": {
"val" : data.injury_head ?? "0"
,"type" : "hidden"
,"mandatory":false
}
,"injury_left_shoulder": {
"val" : data.injury_left_shoulder ?? "0"
,"type" : "hidden"
,"mandatory":false
}
,"injury_right_shoulder": {
"val" : data.injury_right_shoulder ?? "0"
,"type" : "hidden"
,"mandatory":false
}
,"injury_left_arm": {
"val" : data.injury_left_arm ?? "0"
,"type" : "hidden"
,"mandatory":false
}
,"injury_right_arm": {
"val" : data.injury_right_arm ?? "0"
,"type" : "hidden"
,"mandatory":false
}
,"injury_chest": {
"val" : data.injury_chest ?? "0"
,"type" : "hidden"
,"mandatory":false
}
,"injury_stomach": {
"val" : data.injury_stomach ?? "0"
,"type" : "hidden"
,"mandatory":false
}
,"injury_left_leg": {
"val" : data.injury_left_leg ?? "0"
,"type" : "hidden"
,"mandatory":false
}
,"injury_right_leg": {
"val" : data.injury_right_leg ?? "0"
,"type" : "hidden"
,"mandatory":false
}
,"injury_left_hand": {
"val" : data.injury_left_hand ?? "0"
,"type" : "hidden"
,"mandatory":false
}
,"injury_right_hand": {
"val" : data.injury_right_hand ?? "0"
,"type" : "hidden"
,"mandatory":false
}
,"injury_left_foot": {
"val" : data.injury_left_foot ?? "0"
,"type" : "hidden"
,"mandatory":false
}
,"injury_right_foot": {
"val" : data.injury_right_foot ?? "0"
,"type" : "hidden"
,"mandatory":false
}
,"type_of_entry": {
"val" : -1
,"type" : "hidden"
}
};
}
}
}

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