ed
This commit is contained in:
parent
48a36209b5
commit
884f3df7cf
262 changed files with 223207 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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>`;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
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>`;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
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 stats = [];
|
||||
|
||||
stats = [
|
||||
[
|
||||
{name:"files.overview", text : data.data.info[0].files, goto:"files.overview", "gotoAllowed":userrights.has("files.view")},
|
||||
{name:"regvehicle.overview", text : data.data.info[0].regvehicle},
|
||||
{name:"regvehicle_nomot.overview", text : data.data.info[0].regvehicle_no_mot},
|
||||
],
|
||||
[
|
||||
{name:"control_centre", text : data.data.control_centre, bg:controlCenterBg, goto:"controlcentre.dataload", "gotoAllowed":userrights.has("controlcentre.view")},
|
||||
{name:"employees.overview", text : data.data.info[0].employees, goto:"employees.overview","gotoAllowed":userrights.has("employees.view")},
|
||||
{name:"count_employees_available", text : data.data.info[0].employees_available},
|
||||
],
|
||||
[
|
||||
{name:"open_documents.overview", text : data.data.info[0].open_documents},
|
||||
{name:"declined_documents.overview", text : data.data.info[0].declined_documents},
|
||||
{name:"invoiced_documents.overview", text : data.data.info[0].invoiced_documents},
|
||||
{name:"done_documents.overview", text : data.data.info[0].done_documents},
|
||||
],
|
||||
[
|
||||
{name:"vehicle_damages.overview", text : data.data.info[0].vehicle_damages},
|
||||
{name:"vehicle_damages_repaired.overview", text : data.data.info[0].vehicle_damages_repaired},
|
||||
{name:"partacceptance_pos.overview", text : data.data.info[0].partacceptance_pos},
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
|
||||
let statsHTML = ``;
|
||||
for(let i=0; i<stats.length; i++){
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,247 @@
|
|||
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) {
|
||||
|
||||
console.loh("catch");
|
||||
|
||||
grade = row[key]
|
||||
}
|
||||
|
||||
if(grade == -9999){
|
||||
grade = System.getJobGrade(row[key]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return `
|
||||
<td>
|
||||
${System.getLabelByRank(grade)}
|
||||
</td>
|
||||
`;
|
||||
}
|
||||
else {
|
||||
return `<td>${row[key]}</td>`;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -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>`;
|
||||
}
|
||||
}
|
||||
}
|
177
resources/[jobs]/[mdt]/myMechanicMDT/html/js/modules/Files.js
Normal file
177
resources/[jobs]/[mdt]/myMechanicMDT/html/js/modules/Files.js
Normal file
|
@ -0,0 +1,177 @@
|
|||
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 allowFinishmanhunt(){
|
||||
return userrights.has("manhunt.finish");
|
||||
}
|
||||
static allowFinishEntry(){
|
||||
return userrights.has("filesentry.finish");
|
||||
}
|
||||
|
||||
|
||||
static GetColumns(){
|
||||
return ["name","alias","phone","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}' onclick="GenerateRoute(this)">
|
||||
<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 GetExtraForView(data){
|
||||
let retval = {
|
||||
top:"",
|
||||
bottom:"",
|
||||
initTableButtons:false,
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
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"){
|
||||
return `
|
||||
<td>
|
||||
${Form.getViewButtonIcon(row[key], this.name + ".view")}
|
||||
${Form.getEditButtonIcon(row[key] , this.name + ".edit", this.allowEdit())}
|
||||
</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 = {}){
|
||||
|
||||
return {
|
||||
"name": {
|
||||
"val" : data.name ?? ""
|
||||
,"type" : "text"
|
||||
,"mandatory":true
|
||||
}
|
||||
,"alias": {
|
||||
"val" : data.alias ?? ""
|
||||
,"type" : "text"
|
||||
,"mandatory":false
|
||||
}
|
||||
,"phone": {
|
||||
"val" : data.phone ?? ""
|
||||
,"type" : "text"
|
||||
,"mandatory":false
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
resources/[jobs]/[mdt]/myMechanicMDT/html/js/modules/Notes.js
Normal file
133
resources/[jobs]/[mdt]/myMechanicMDT/html/js/modules/Notes.js
Normal 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();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
class Pricelist{
|
||||
constructor(){
|
||||
this.name = "pricelist";
|
||||
}
|
||||
|
||||
static isCustom(){
|
||||
return true;
|
||||
}
|
||||
|
||||
static allowEdit(){
|
||||
return userrights.has("pricelistgroups.edit");
|
||||
}
|
||||
static allowDelete(){
|
||||
return userrights.has("pricelistgroups.delete");
|
||||
}
|
||||
|
||||
static GetColumns(isEditList){
|
||||
if(!isEditList){
|
||||
return ["description","price","max_discount","id"]
|
||||
}
|
||||
else{
|
||||
return ["description","price","amount","discount","total_price","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 == "description") {
|
||||
return `<td class="whitespace-normal">${row[key]}</td>`;
|
||||
}
|
||||
else if(key == "price") {
|
||||
return `<td>${System.FormatNumber(row[key])}</td>`;
|
||||
}
|
||||
else {
|
||||
return `<td>${row[key]}</td>`;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(key == "id"){
|
||||
return `<td class="edittable_row" id = "edittable_row_${row.id}">
|
||||
${Form.Hidden("id_" + row.id, row[key])}
|
||||
${Form.Hidden("max_discount_" + row.id, row["max_discount"])}
|
||||
${Form.Hidden("discounted_price_" + row.id, row["discounted_price"])}
|
||||
</td>`;
|
||||
}
|
||||
else if(key == "description") {
|
||||
return `<td class="whitespace-normal">${row[key]}</td>`;
|
||||
}
|
||||
else if(key == "price"){
|
||||
return `<td>${Form.NumberField(false, "price_" + row.id, row[key], "", true, false)}</td>`;
|
||||
}
|
||||
else if(key == "amount"){
|
||||
return `<td>${Form.NumberField(false, "amount_" + row.id, "0", "pricelistpos_calc_amount", false, false)}</td>`;
|
||||
}
|
||||
else if(key == "discount"){
|
||||
return `<td>${Form.NumberField(false, "discount_" + row.id, "0", "pricelistpos_calc_discount", false, false)}</td>`;
|
||||
}
|
||||
else if(key == "total_price"){
|
||||
return `<td>${Form.NumberField(false, "total_price_" + row.id, "0", "pricelistpos_calc_total_price", true, false)}</td>`;
|
||||
}
|
||||
else {
|
||||
return `<td>${row[key]}</td>`;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static GetEdit(data={}){
|
||||
return {
|
||||
"pricelist_group_id": {
|
||||
"val" : data.pricelist_group_id ?? "-1"
|
||||
,"type" : "hidden"
|
||||
},
|
||||
"description": {
|
||||
"val" : data.description ?? ""
|
||||
,"type" : "text"
|
||||
,"mandatory":true
|
||||
}
|
||||
,"price": {
|
||||
"val" : data.price ?? ""
|
||||
,"type" : "number"
|
||||
,"mandatory":true
|
||||
}
|
||||
,"max_discount": {
|
||||
"val" : data.max_discount ?? 0
|
||||
,"type" : "number"
|
||||
,"mandatory":true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
class PriceListGroups{
|
||||
constructor(){
|
||||
this.name = "pricelistgroups";
|
||||
}
|
||||
|
||||
static allowAddNew(){
|
||||
return userrights.has("pricelists.edit");
|
||||
}
|
||||
static allowEdit(){
|
||||
return userrights.has("pricelists.edit");
|
||||
}
|
||||
static allowDelete(){
|
||||
return userrights.has("pricelists.delete");
|
||||
}
|
||||
|
||||
static isCustom(){
|
||||
return true;
|
||||
}
|
||||
|
||||
static CreateCustom(data, isEditList = false ){
|
||||
if(!isEditList){
|
||||
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 = ``;
|
||||
|
||||
if(!isEditList && this.allowAddNew()){
|
||||
buttons += `<button type="button" class="btn btn-sm btn-success pricelistgroups-add-price" data-parentID="${row.id}">${getTranslation("add_price")}</button>`;
|
||||
}
|
||||
if(!isEditList && this.allowEdit()){
|
||||
buttons += `<button type="button" class="btn btn-sm btn-warning pricelistgroups-edit" data-parentID="${row.id}">${getTranslation("edit")}</button>`;
|
||||
}
|
||||
if(!isEditList && this.allowDelete()){
|
||||
buttons += `<button type="button" class="btn btn-sm btn-error" onclick="Form.openDeleteModal(${row.id}, 'pricelistgroups')">${getTranslation("delete")}</button>`;
|
||||
}
|
||||
|
||||
let collapseClass = "collapse-arrow";
|
||||
|
||||
if(isEditList){
|
||||
collapseClass = "collapse-open";
|
||||
}
|
||||
|
||||
document.getElementById("currentpage-content").innerHTML += `
|
||||
<div class="collapse ${collapseClass} 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="mb-2">
|
||||
${buttons}
|
||||
</div>
|
||||
${System.GetTable(System.getClassByName("pricelist"), row.pricelist, isEditList)}
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
|
||||
if(!isEditList){
|
||||
Form.initTableButtons();
|
||||
|
||||
|
||||
Array.from(document.querySelectorAll(".pricelistgroups-add-price")).forEach(function(button){
|
||||
button.onclick = function(){
|
||||
let staticData = {
|
||||
data:{
|
||||
pricelist_group_id:this.getAttribute("data-parentID")
|
||||
}
|
||||
}
|
||||
loadPage("pricelist.add",-1,"false", staticData)
|
||||
}
|
||||
});
|
||||
Array.from(document.querySelectorAll(".pricelistgroups-edit")).forEach(function(button){
|
||||
button.onclick = function(){
|
||||
loadPage("pricelistgroups.edit",this.getAttribute("data-parentID"),"false", {})
|
||||
}
|
||||
});
|
||||
}
|
||||
else{
|
||||
document.getElementById("currentpage-content").innerHTML += `
|
||||
<table class="table table-compact w-full mt-4">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="text-right">
|
||||
<strong>${getTranslation("total_price_no_discount")}: </strong>
|
||||
<strong id = "summary_total_price_no_discount">0</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-right">
|
||||
<strong>${getTranslation("total_price")}: </strong>
|
||||
<strong id = "summary_total_price">0</strong>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static GetEdit(data={}){
|
||||
return {
|
||||
"name": {
|
||||
"val" : data.name ?? ""
|
||||
,"type" : "text"
|
||||
,"mandatory":true
|
||||
,"isRow":true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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={}){
|
||||
}
|
||||
}
|
|
@ -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={}){
|
||||
}
|
||||
}
|
|
@ -0,0 +1,409 @@
|
|||
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 allowViewMotList(){
|
||||
return userrights.has("regvehicles_mot.view");
|
||||
}
|
||||
static allowAddMotList(){
|
||||
return userrights.has("regvehicles_mot.add");
|
||||
}
|
||||
static allowViewOrders(){
|
||||
return userrights.has("regvehicles_orders.view");
|
||||
}
|
||||
static allowAddOrder(){
|
||||
return userrights.has("regvehicles_orders.add");
|
||||
}
|
||||
static allowViewRegisteredParts(){
|
||||
return userrights.has("regvehicles_parts_registered.view");
|
||||
}
|
||||
static allowAddRegisteredParts(){
|
||||
return userrights.has("regvehicles_parts_registered.add");
|
||||
}
|
||||
static allowRemoveRegisteredParts(){
|
||||
return userrights.has("rregvehicles_parts_registered.delete");
|
||||
}
|
||||
static allowViewDamageReports(){
|
||||
return userrights.has("regvehicles_damage_reports.view");
|
||||
}
|
||||
static allowAddDamageReport(){
|
||||
return userrights.has("regvehicles_damage_reports.add");
|
||||
}
|
||||
|
||||
|
||||
static GetColumns(){
|
||||
return ["plate","veh_type","veh_model","owner","mot","mechanic_state","id"]
|
||||
}
|
||||
|
||||
static GetExtraForView(data){
|
||||
let retval = {
|
||||
top:"",
|
||||
bottom:""
|
||||
}
|
||||
|
||||
let buttons = ``;
|
||||
|
||||
buttons += `<button type="button" onclick="changeDataInColumn('regvehicle','mechanic_vehicle_state','${data.id}','1')" class="btn btn-sm btn-accent" ${data.mechanic_vehicle_state != 1 ? "" : " disabled"}>${getTranslation("in_shop")}</button>`;
|
||||
buttons += `<button type="button" onclick="changeDataInColumn('regvehicle','mechanic_vehicle_state','${data.id}','2')" class="btn btn-sm btn-error" ${data.mechanic_vehicle_state != 2 ? "" : " disabled"}>${getTranslation("waiting_for_cops")}</button>`;
|
||||
buttons += `<button type="button" onclick="changeDataInColumn('regvehicle','mechanic_vehicle_state','${data.id}','3')" class="btn btn-sm btn-primary" ${data.mechanic_vehicle_state != 3 ? "" : " disabled"}>${getTranslation("order_is_done")}</button>`;
|
||||
buttons += `<button type="button" onclick="changeDataInColumn('regvehicle','mechanic_vehicle_state','${data.id}','0')" class="btn btn-sm btn-success" ${data.mechanic_vehicle_state != 0 ? "" : " disabled"}>${getTranslation("given_back")}</button>`;
|
||||
|
||||
retval.bottom += `
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-4 pt-6">
|
||||
${buttons}
|
||||
</div>
|
||||
`;
|
||||
|
||||
if(data.extraData.mot_data !== undefined && data.extraData.mot_data !== null && RegVehicle.allowViewMotList()){
|
||||
let row = data.extraData.mot_data[0];
|
||||
let onlyOne = data.extraData.mot_data.length == 1;
|
||||
|
||||
let addMotButton = ``;
|
||||
|
||||
if(RegVehicle.allowAddMotList()){
|
||||
addMotButton = `<button type="button" class="btn btn-sm btn-warning" onclick="loadPage('regvehicle_mot.add',-1,'false',{data:{vehicle_id:'${data.id}', vehicle_mot:'${data.mot}'}})">${getTranslation("regvehicle_mot.add")}</button>`;
|
||||
}
|
||||
|
||||
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">
|
||||
${addMotButton}
|
||||
<div class="grid grid-cols-1 md:grid-cols-1 gap-4 pt-6">
|
||||
${RegVehicle_MOT.GetDetailView(row, data.id, !onlyOne)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(data.extraData.open_offer_data !== undefined && data.extraData.open_offer_data !== null && RegVehicle.allowViewOrders()){
|
||||
let allowAddOrderBtn = ``;
|
||||
|
||||
if(RegVehicle.allowAddOrder()){
|
||||
allowAddOrderBtn = `<button type="button" class="btn btn-sm btn-warning" onclick="loadPage('regvehicle_dochead.dataload',${data.id},'true')">${getTranslation("regvehicle_dochead.add")}</button>`;
|
||||
}
|
||||
|
||||
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_dochead.overview")}
|
||||
</summary>
|
||||
<div class="collapse-content">
|
||||
${allowAddOrderBtn}
|
||||
<div class="grid grid-cols-1 md:grid-cols-1 gap-4 pt-6">
|
||||
${System.GetTable(System.getClassByName("regvehicle_dochead"), data.extraData.open_offer_data, {})}
|
||||
</div>
|
||||
<button onclick="loadPage('regvehicle_dochead_history.dataload',${data.id})" class="btn btn-sm btn-primary btn-block" >${getTranslation("view_history")}</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
if(data.extraData.part_acceptance !== undefined && data.extraData.part_acceptance !== null && RegVehicle.allowViewRegisteredParts()){
|
||||
let addNewPartAcceptanceBtn = ``;
|
||||
|
||||
if(RegVehicle.allowAddRegisteredParts()){
|
||||
addNewPartAcceptanceBtn = `<button type="button" class="btn btn-sm btn-warning" onclick="loadPage('regvehicle_partacceptance.add',${data.id},'true',{data:{vehicle_id:'${data.id}'}})">${getTranslation("regvehicle_part_acceptance.add")}</button>`;
|
||||
}
|
||||
|
||||
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">
|
||||
${addNewPartAcceptanceBtn}
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 pt-6">
|
||||
`;
|
||||
|
||||
|
||||
let i=0;
|
||||
|
||||
let temp = "";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for(const row of data.extraData.part_acceptance){
|
||||
|
||||
buttons = ``;
|
||||
if(RegVehicle.allowRemoveRegisteredParts()){
|
||||
buttons = `<button onclick="deleteData('regvehicle_partacceptance','${row.id}')" class="btn btn-sm btn-error">${getTranslation("revoke")}</button>`;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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><strong>${getTranslation("price")}</strong>: $${System.FormatNumber(row.total_price)}</p>
|
||||
<p></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 class="card-actions justify-start">
|
||||
${buttons}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
retval.bottom += temp;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
retval.bottom += `
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
if(data.extraData.damages !== undefined && data.extraData.damages !== null && RegVehicle.allowViewDamageReports()){
|
||||
let addDamageRportBtn = ``;
|
||||
|
||||
if(RegVehicle.allowAddDamageReport()){
|
||||
addDamageRportBtn = `<button type="button" class="btn btn-sm btn-primary" onclick="loadPage('regvehicle_damage.add',-1,'false',{data:{vehicle_id:'${data.id}'}})">${getTranslation("regvehicle_damage.add")}</button>`;
|
||||
}
|
||||
|
||||
|
||||
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_damage.overview")}
|
||||
</summary>
|
||||
<div class="collapse-content">
|
||||
${addDamageRportBtn}
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 pt-6">
|
||||
`;
|
||||
|
||||
|
||||
let i=0;
|
||||
|
||||
let temp = "";
|
||||
|
||||
for(const row of data.extraData.damages){
|
||||
buttons = "";
|
||||
|
||||
if(i < 5){
|
||||
let badges = "";
|
||||
let contentHTML = "";
|
||||
|
||||
if(row.content.replace(/ /g, "") !== ""){
|
||||
contentHTML = `<p class="border border-current rounded-xl p-1 break-all">${row.content.replace(/\n/g,"<br>")}</p>`;
|
||||
}
|
||||
|
||||
if(row.repaired != true){
|
||||
buttons += `<button onclick="changeDataInColumn('regvehicle_damage','repaired','${row.id}','1')" class="btn btn-sm btn-primary">${getTranslation("repaired")}</button>`;
|
||||
}
|
||||
else{
|
||||
badges += `<div class="badge badge-primary gap-2 font-bold">${getTranslation("repaired")}</div>`;
|
||||
}
|
||||
|
||||
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></p>
|
||||
${contentHTML}
|
||||
<h2>${badges}</h2>
|
||||
<p></p>
|
||||
<p></p>
|
||||
|
||||
${RegVehicle_Damage.GetVehicleInteractiveModel(row, true, 1)}
|
||||
|
||||
<div class="card-actions justify-start">
|
||||
${buttons}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
retval.bottom += temp;
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
if(i>5){
|
||||
|
||||
let temp = `
|
||||
<div class="card w-full bg-neutral text-neutral-content">
|
||||
<div class="card-body flex justify-center">
|
||||
|
||||
<button onclick="loadPage('regvehicle_damage.dataload',${data.id})" class="btn btn-sm btn-primary btn-block" >${getTranslation("view all")}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
retval.bottom += temp;
|
||||
}
|
||||
}
|
||||
|
||||
retval.bottom += `
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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 == "owner"){
|
||||
let val = row[key];
|
||||
if(val == ""){
|
||||
val = getTranslation("unknown");
|
||||
}
|
||||
|
||||
return `
|
||||
<td>
|
||||
${val}
|
||||
</td>`;
|
||||
}
|
||||
else if(key == "mechanic_state"){
|
||||
let val = row[key];
|
||||
if(val != ""){
|
||||
|
||||
if(val == "in_shop"){
|
||||
val = `<div class="badge badge-accent font-bold">${getTranslation(row[key])}</div>`;
|
||||
}
|
||||
else if(val == "waiting_for_cops"){
|
||||
val = `<div class="badge badge-error font-bold">${getTranslation(row[key])}</div>`;
|
||||
}
|
||||
|
||||
else if(val == "order_is_done"){
|
||||
val = `<div class="badge badge-primary font-bold">${getTranslation(row[key])}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
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={}){
|
||||
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 {
|
||||
"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
|
||||
}
|
||||
,"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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,360 @@
|
|||
class RegVehicle_DocHead{
|
||||
constructor(){
|
||||
this.name = "RegVehicle_DocHead";
|
||||
}
|
||||
|
||||
static GetCustomDestination(data, dest){
|
||||
return (data.vehicle_id ?? "" != "" ? "regvehicle.view" : "regvehicle.overview");
|
||||
}
|
||||
|
||||
static GetCustomDestID(data, destID){
|
||||
return data.vehicle_id ?? destID;
|
||||
}
|
||||
static allowView(){
|
||||
return userrights.has("regvehicles.view");
|
||||
}
|
||||
static allowAddNew(){
|
||||
return true;
|
||||
}
|
||||
static allowEdit(){
|
||||
return userrights.has("regvehicles.edit");
|
||||
}
|
||||
static allowDelete(){
|
||||
return userrights.has("regvehicles.edit");
|
||||
}
|
||||
static GetColumns(){
|
||||
return ["doc_number", "creationdate" ,"status", "totalprice_no_discount","totalprice_discount","id"]
|
||||
}
|
||||
|
||||
static TableDataCreate(row, key){
|
||||
if(key == "id"){
|
||||
return `
|
||||
<td>
|
||||
<button onclick="loadPage('regvehicle_dochead_details.dataload','regvehicle.view|${row[key]}')" class="btn btn-sm btn-accent">
|
||||
<i class="fa-solid fa-circle-info"></i>
|
||||
</button>
|
||||
|
||||
</td>`;
|
||||
}
|
||||
else if(key == "creationdate"){
|
||||
return `
|
||||
<td>
|
||||
${System.formatTimestamp(row.creationdate)}<br>${System.buildEmployeeName(row.creator)}
|
||||
</td>`;
|
||||
}
|
||||
else if(key == "totalprice_no_discount" || key == "totalprice_discount"){
|
||||
return `
|
||||
<td>
|
||||
${System.FormatNumber(row[key])}
|
||||
</td>`;
|
||||
}
|
||||
else if(key == "status"){
|
||||
let selectClass = "";
|
||||
let selected1="";
|
||||
let selected2="";
|
||||
let selected3="";
|
||||
let selected4="";
|
||||
|
||||
if(row["done"] == 1){
|
||||
selectClass = "success";
|
||||
selected4 = " selected";
|
||||
}
|
||||
else if(row["declined"] == 1){
|
||||
selectClass = "error";
|
||||
selected2 = " selected";
|
||||
}
|
||||
else if(row["invoiced"] == 1){
|
||||
selectClass = "primary";
|
||||
selected3 = " selected";
|
||||
}
|
||||
else{
|
||||
selectClass = "info";
|
||||
selected1 = " selected";
|
||||
}
|
||||
|
||||
if(row.allow_decline){
|
||||
return `
|
||||
<td>
|
||||
<select onchange="RegVehicle_DocHead.SetStatus(${row.id}, ${row.vehicle_id}, this)" class="select ignore-readonly bg-${selectClass} text-${selectClass}-content select-${selectClass} select-sm">
|
||||
<option value="0" class="btn btn-info btn-sm btn-block" ${selected1}>${getTranslation("status.open")}</option>
|
||||
<option value="1" class="btn btn-error btn-sm btn-block"${selected2}>${getTranslation("status.declined")}</option>
|
||||
<option value="2" class="btn btn-primary btn-sm btn-block" ${selected3}>${getTranslation("status.invoiced")}</option>
|
||||
<option value="3" class="btn btn-success btn-sm btn-block" ${selected4}>${getTranslation("status.done")}</option>
|
||||
</select>
|
||||
</td>`
|
||||
;
|
||||
}
|
||||
else{
|
||||
return `
|
||||
<td>
|
||||
<select onchange="RegVehicle_DocHead.SetStatus(${row.id}, ${row.vehicle_id}, this)" class="select ignore-readonly bg-${selectClass} text-${selectClass}-content select-${selectClass} select-sm">
|
||||
<option value="0" class="btn btn-info btn-sm btn-block" ${selected1}>${getTranslation("status.open")}</option>
|
||||
<option value="2" class="btn btn-primary btn-sm btn-block" ${selected3}>${getTranslation("status.invoiced")}</option>
|
||||
<option value="3" class="btn btn-success btn-sm btn-block" ${selected4}>${getTranslation("status.done")}</option>
|
||||
</select>
|
||||
</td>`
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
return `<td>${row[key]}</td>`;
|
||||
}
|
||||
}
|
||||
|
||||
static SetStatus(docId, vehicle_id, senderEl){
|
||||
|
||||
let backEndData = {
|
||||
done: senderEl.value == "3" ? "1" : "0",
|
||||
declined: senderEl.value == "1" ? "1" : "0",
|
||||
invoiced: senderEl.value == "2" ? "1" : "0"
|
||||
}
|
||||
|
||||
sendDataToAPI("regvehicle_dochead", "regvehicle.view",docId, vehicle_id, backEndData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static CreateCustom(data){
|
||||
document.getElementById("currentpage-content").innerHTML = Form.BackEditBtn("regvehicle.view", "",-1, false, data.data.vehicle_id);
|
||||
|
||||
let pricelistGroupData = {};
|
||||
pricelistGroupData.data = data.data.pricelist_groups
|
||||
|
||||
|
||||
PriceListGroups.CreateCustom({data: data.data.pricelist_groups}, true);
|
||||
|
||||
document.getElementById("currentpage-content").innerHTML += `
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 pt-6">
|
||||
<button id="input-cancel-button" data-vehicle-id="${data.data.vehicle_id}" class="btn btn-sm btn-error">${getTranslation("cancel")}</button>
|
||||
<button id="input-save-button" data-vehicle-id="${data.data.vehicle_id}" class="btn btn-sm btn-primary">${getTranslation("save")}</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
Form.initViewModeTopButtons();
|
||||
|
||||
document.getElementById("input-cancel-button").onclick=function(){
|
||||
loadPage("regvehicle.view", this.getAttribute("data-vehicle-id"))
|
||||
}
|
||||
document.getElementById("input-save-button").onclick=function(){
|
||||
let saveData = RegVehicle_DocHead.GetDataForSave("edittable_row_", ".edittable_row", ["price","amount","discount","discounted_price","total_price","id"], "amount");
|
||||
|
||||
if(!saveData.isValid){
|
||||
Form.openInfoModal();
|
||||
}
|
||||
else{
|
||||
|
||||
let headData = {
|
||||
vehicle_id : this.getAttribute("data-vehicle-id"),
|
||||
totalprice_no_discount : 0,
|
||||
totalprice_discount : 0
|
||||
};
|
||||
|
||||
for (const key in saveData.posData) {
|
||||
headData.totalprice_no_discount += parseInt(saveData.posData[key].amount) * parseInt(saveData.posData[key].price);
|
||||
headData.totalprice_discount += parseInt(saveData.posData[key].total_price);
|
||||
|
||||
saveData.posData[key].total_price_no_discount = parseInt(saveData.posData[key].amount) * parseInt(saveData.posData[key].price);
|
||||
saveData.posData[key].pricelist_id = saveData.posData[key].id;
|
||||
saveData.posData[key].tuning_option_id = -1;
|
||||
saveData.posData[key].default_price = saveData.posData[key].price;
|
||||
saveData.posData[key].id = null;
|
||||
|
||||
delete saveData.posData[key].price;
|
||||
delete saveData.posData[key].discounted_price;
|
||||
|
||||
}
|
||||
|
||||
let formData = {
|
||||
headData: headData,
|
||||
posData: saveData.posData
|
||||
}
|
||||
sendDataToAPI("regvehicle_dochead", "regvehicle.view",-1, this.getAttribute("data-vehicle-id"), formData);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Array.from(document.getElementById("currentpage-content").querySelectorAll(".pricelistpos_calc_amount")).forEach(function(item){
|
||||
item.onkeyup=function(){
|
||||
RegVehicle_DocHead.CalcAmountAndDiscount(this);
|
||||
}
|
||||
});
|
||||
Array.from(document.getElementById("currentpage-content").querySelectorAll(".pricelistpos_calc_discount")).forEach(function(item){
|
||||
item.onkeyup=function(){
|
||||
RegVehicle_DocHead.CalcAmountAndDiscount(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static GetDataForSave(row_id_prefix, classToSearch, subElements, mustBeBiggerZero){
|
||||
let idElements = Array.from(document.querySelectorAll(classToSearch));
|
||||
|
||||
let retval = [];
|
||||
let isValid = false;
|
||||
|
||||
idElements.forEach(function(row){
|
||||
let rowIsValid = false;
|
||||
let rowID = row.id.replace(row_id_prefix, "");
|
||||
let rowData = {};
|
||||
|
||||
for (const key in subElements) {
|
||||
rowData[subElements[key]] = document.getElementById("input-" + subElements[key] + "_" + rowID).value;
|
||||
|
||||
if(subElements[key] == mustBeBiggerZero && (document.getElementById("input-" + subElements[key] + "_" + rowID).value*1) > 0){
|
||||
isValid = true;
|
||||
rowIsValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(rowIsValid){
|
||||
retval.push(rowData);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
isValid: isValid,
|
||||
posData: retval
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static CalcAmountAndDiscount(element){
|
||||
let rowId = element.id.replace("input-amount_", "").replace("input-discount_","");
|
||||
|
||||
let amount = document.getElementById("input-amount_" + rowId).value;
|
||||
let discount = document.getElementById("input-discount_" + rowId).value;
|
||||
|
||||
let price = document.getElementById("input-price_" + rowId).value;
|
||||
let max_discount = document.getElementById("input-max_discount_" + rowId).value;
|
||||
|
||||
let discountedPriceEl = document.getElementById("input-discounted_price_" + rowId);
|
||||
let totalPriceEl = document.getElementById("input-total_price_" + rowId);
|
||||
|
||||
if(discount.startsWith("0")){
|
||||
document.getElementById("input-discount_" + rowId).value = 1*discount;
|
||||
}
|
||||
|
||||
if(1*discount > 1*max_discount){
|
||||
discount = max_discount;
|
||||
document.getElementById("input-discount_" + rowId).value = discount;
|
||||
}
|
||||
|
||||
if(1*amount < 0){
|
||||
document.getElementById("input-amount_" + rowId).value = 0;
|
||||
amount = 0;
|
||||
}
|
||||
|
||||
let percentage = -1 * ((1*discount / 100) - 1.0)
|
||||
let discountedPrice = parseInt(price * percentage);
|
||||
|
||||
discountedPriceEl.value = discountedPrice;
|
||||
totalPriceEl.value = discountedPrice * amount;
|
||||
|
||||
|
||||
let dataForSave = RegVehicle_DocHead.GetDataForSave("edittable_row_", ".edittable_row", ["price","amount","total_price"], "amount")
|
||||
|
||||
let sum_total_price = 0;
|
||||
let sum_total_price_no_discount = 0;
|
||||
|
||||
if(dataForSave.isValid){
|
||||
for (const key in dataForSave.posData) {
|
||||
sum_total_price_no_discount += parseInt(dataForSave.posData[key].amount) * parseInt(dataForSave.posData[key].price);
|
||||
sum_total_price += parseInt(dataForSave.posData[key].total_price);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
document.getElementById("summary_total_price_no_discount").innerHTML = System.FormatNumber(sum_total_price_no_discount);
|
||||
document.getElementById("summary_total_price").innerHTML = System.FormatNumber(sum_total_price);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static GetDetailView(row, vehicle_id = -1, drawViewButton = false){
|
||||
let bottomButton = "";
|
||||
let contentHtml = ``;
|
||||
|
||||
if(row === undefined || row === null ){
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
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>`;
|
||||
}
|
||||
|
||||
if(drawViewButton){
|
||||
bottomButton = `<button onclick="loadPage('regvehicle_mot.dataload',${vehicle_id})" class="btn btn-sm btn-primary btn-block" >${getTranslation("view_history")}</button>`
|
||||
}
|
||||
|
||||
|
||||
|
||||
return `
|
||||
<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></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>
|
||||
<p></p>
|
||||
${bottomButton}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
static GetEdit(data={}){
|
||||
let retval = {
|
||||
"vehicle_id": {
|
||||
"val" : data.vehicle_id ?? -1
|
||||
,"type" : "text"
|
||||
,"mandatory":true
|
||||
,"isRow":true
|
||||
},
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
class RegVehicle_DocHead_Details{
|
||||
constructor(){
|
||||
this.name = "regvehicle_dochead_details";
|
||||
}
|
||||
static GetColumns(){
|
||||
return ["positionNo","position_type", "name","amount","total_price"]
|
||||
}
|
||||
static allowAddNew(){
|
||||
return userrights.has("regvehicles.edit")
|
||||
}
|
||||
static allowEdit(){
|
||||
return userrights.has("regvehicles.edit")
|
||||
}
|
||||
static allowDelete(){
|
||||
return userrights.has("regvehicles.delete")
|
||||
}
|
||||
|
||||
static CreateCustom(data){
|
||||
document.getElementById("currentpage-content").innerHTML = Form.BackEditBtn(data.data.extraData.fromPage, "",-1, false, data.data.data.headData.vehicle_id);
|
||||
|
||||
|
||||
let badge = "";
|
||||
|
||||
if(data.data.data.headData["done"] == 1){
|
||||
badge = `<span class="badge badge-success font-bold">${getTranslation("status.done")}</span>`;
|
||||
}
|
||||
else if(data.data.data.headData["declined"] == 1){
|
||||
badge = `<span class="badge badge-error font-bold">${getTranslation("status.declined")}</span>`;
|
||||
}
|
||||
else if(data.data.data.headData["invoiced"] == 1){
|
||||
badge = `<span class="badge badge-primary font-bold">${getTranslation("status.invoiced")}</span>`;
|
||||
}
|
||||
else{
|
||||
badge = `<span class="badge badge-info font-bold">${getTranslation("status.open")}</span>`;
|
||||
}
|
||||
|
||||
|
||||
document.getElementById("currentpage-content").innerHTML += `
|
||||
<div class="collapse collapse-open border border-base-300 bg-base-100 rounded-box mt-4">
|
||||
<input type="checkbox" />
|
||||
<div class="collapse-title text-xl font-medium">
|
||||
${data.data.data.headData.doc_number} - ${System.formatTimestamp(data.data.data.headData.creationdate)} ${badge}
|
||||
</div>
|
||||
<div class="collapse-content">
|
||||
<b>${getTranslation("total_price_no_discount")}: </b>${System.FormatNumber(data.data.data.headData.totalprice_no_discount)}<br>
|
||||
<b>${getTranslation("total_price")}: </b>${System.FormatNumber(data.data.data.headData.totalprice_discount)}
|
||||
|
||||
<div class="mt-2">
|
||||
${System.GetTable(System.getClassByName("regvehicle_dochead_details"), data.data.data.posData, {})}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
`;
|
||||
|
||||
|
||||
Form.initViewModeTopButtons();
|
||||
|
||||
|
||||
}
|
||||
|
||||
static TableDataCreate(row, key){
|
||||
|
||||
"positionNo","position_type", "name","amount","total_price"
|
||||
|
||||
if(key == "position_type"){
|
||||
|
||||
if(row.is_part_acceptance == 1){
|
||||
return `
|
||||
<td>
|
||||
${getTranslation("part_acceptance_pos")}
|
||||
</td>`;
|
||||
}
|
||||
else{
|
||||
return `
|
||||
<td>
|
||||
${getTranslation("offer_pos")}
|
||||
</td>`;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if(key == "name"){
|
||||
if(row.is_part_acceptance == 1){
|
||||
return `
|
||||
<td>
|
||||
${row.part_acceptance_name}
|
||||
</td>`;
|
||||
}
|
||||
else{
|
||||
return `
|
||||
<td>
|
||||
${row.pricelist_group_name}<br>${row.pricelist_name}
|
||||
</td>`;
|
||||
}
|
||||
}
|
||||
else if(key == "total_price"){
|
||||
if(row.discount == 0){
|
||||
return `
|
||||
<td>
|
||||
<strong>${System.FormatNumber(row.total_price)}</strong>
|
||||
</td>`;
|
||||
}
|
||||
else{
|
||||
return `
|
||||
<td>
|
||||
${System.FormatNumber(row.total_price_no_discount)}
|
||||
<br>
|
||||
<span class="text-error"><b>-${System.FormatNumber(row.discount)}%</b></span>
|
||||
<br>
|
||||
<br>
|
||||
<strong>${System.FormatNumber(row.total_price)}</strong>
|
||||
</td>`;
|
||||
}
|
||||
}
|
||||
else{
|
||||
return `<td>${row[key]}</td>`;
|
||||
}
|
||||
}
|
||||
|
||||
static GetEdit(data={}){
|
||||
return {
|
||||
"name": {
|
||||
"val" : data.name ?? ""
|
||||
,"type" : "text"
|
||||
,"isRow": true
|
||||
,"mandatory":true
|
||||
},
|
||||
"price": {
|
||||
"val" : data.price ?? ""
|
||||
,"type" : "text"
|
||||
,"isRow": true
|
||||
,"mandatory":true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
class RegVehicle_DocHead_History{
|
||||
constructor(){
|
||||
this.name = "regvehicle_dochead_history";
|
||||
}
|
||||
static GetColumns(){
|
||||
return ["doc_number","creationdate","status","totalprice_no_discount","totalprice_discount", "id"]
|
||||
}
|
||||
static allowAddNew(){
|
||||
return userrights.has("regvehicles.edit")
|
||||
}
|
||||
static allowEdit(){
|
||||
return userrights.has("regvehicles.edit")
|
||||
}
|
||||
static allowDelete(){
|
||||
return userrights.has("regvehicles.delete")
|
||||
}
|
||||
|
||||
static CreateCustom(data){
|
||||
|
||||
document.getElementById("currentpage-content").innerHTML = Form.BackEditBtn("regvehicle.view", "",-1, false, data.data.extraData.vehicle_id);
|
||||
document.getElementById("currentpage-content").innerHTML += System.GetTable(System.getClassByName("regvehicle_dochead_history"), data.data.data, {})
|
||||
|
||||
Form.initViewModeTopButtons();
|
||||
Form.initTableButtons();
|
||||
|
||||
|
||||
}
|
||||
|
||||
static TableDataCreate(row, key){
|
||||
if(key == "id"){
|
||||
return `
|
||||
<td>
|
||||
${Form.getViewButtonIcon("regvehicle_dochead_history.dataload|" + row[key], "regvehicle_dochead_details.dataload")}
|
||||
</td>`;
|
||||
}
|
||||
else if(key == "creationdate"){
|
||||
return `
|
||||
<td>
|
||||
${System.formatTimestamp(row.creationdate)}<br>${System.buildEmployeeName(row.creator)}
|
||||
</td>`;
|
||||
}
|
||||
else if(key == "totalprice_no_discount" || key == "totalprice_discount"){
|
||||
return `
|
||||
<td>
|
||||
${System.FormatNumber(row[key])}
|
||||
</td>`;
|
||||
}
|
||||
else if(key == "status"){
|
||||
if(row["done"] == 1){
|
||||
return `<td class="text-center"><span class="badge badge-success font-bold">${getTranslation("status.done")}</span></td>`;
|
||||
}
|
||||
else if(row["declined"] == 1){
|
||||
return `<td class="text-center"><span class="badge badge-error font-bold">${getTranslation("status.declined")}</span></td>`;
|
||||
}
|
||||
else if(row["invoiced"] == 1){
|
||||
return `<td class="text-center"><span class="badge badge-primary font-bold">${getTranslation("status.invoiced")}</span></td>`;
|
||||
}
|
||||
else{
|
||||
return `<td class="text-center"><span class="badge badge-info font-bold">${getTranslation("status.open")}</span></td>`;
|
||||
}
|
||||
}
|
||||
else{
|
||||
return `<td>${row[key]}</td>`;
|
||||
}
|
||||
}
|
||||
|
||||
static GetEdit(data={}){
|
||||
return {
|
||||
"name": {
|
||||
"val" : data.name ?? ""
|
||||
,"type" : "text"
|
||||
,"isRow": true
|
||||
,"mandatory":true
|
||||
},
|
||||
"price": {
|
||||
"val" : data.price ?? ""
|
||||
,"type" : "text"
|
||||
,"isRow": true
|
||||
,"mandatory":true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,288 @@
|
|||
class RegVehicle_MOT{
|
||||
constructor(){
|
||||
this.name = "regvehicle_mot";
|
||||
}
|
||||
|
||||
static GetCustomDestination(data, dest){
|
||||
return (data.vehicle_id ?? "" != "" ? "regvehicle.view" : "regvehicle.overview");
|
||||
}
|
||||
|
||||
static GetCustomDestID(data, destID){
|
||||
return data.vehicle_id ?? destID;
|
||||
}
|
||||
static allowView(){
|
||||
return userrights.has("regvehicles.view");
|
||||
}
|
||||
static allowAddNew(){
|
||||
return true;
|
||||
}
|
||||
static allowEdit(){
|
||||
return userrights.has("regvehicles.edit");
|
||||
}
|
||||
static allowDelete(){
|
||||
return userrights.has("regvehicles.edit");
|
||||
}
|
||||
static GetColumns(){
|
||||
return ["plate","veh_type","veh_model","owner","mot","state","id"]
|
||||
}
|
||||
|
||||
|
||||
static CreateCustom(data){
|
||||
let html = Form.BackEditBtn("regvehicle.view", "",-1, false, data.data.id);
|
||||
html += `<div class="grid grid-cols-1 md:grid-cols-1 gap-4 pt-6">`;
|
||||
|
||||
|
||||
for(const row of data.data.data){
|
||||
html += this.GetDetailView(row, data.data.id, false);
|
||||
}
|
||||
|
||||
html += `</div>`;
|
||||
|
||||
document.getElementById("currentpage-content").innerHTML = html;
|
||||
|
||||
|
||||
Form.initViewModeTopButtons();
|
||||
|
||||
}
|
||||
|
||||
|
||||
static GetDetailView(row, vehicle_id = -1, drawViewButton = false){
|
||||
let bottomButton = "";
|
||||
let contentHtml = ``;
|
||||
|
||||
if(row === undefined || row === null ){
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
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>`;
|
||||
}
|
||||
|
||||
if(drawViewButton){
|
||||
bottomButton = `<button onclick="loadPage('regvehicle_mot.dataload',${vehicle_id})" class="btn btn-sm btn-primary btn-block" >${getTranslation("view_history")}</button>`
|
||||
}
|
||||
|
||||
|
||||
|
||||
return `
|
||||
<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></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>
|
||||
<p></p>
|
||||
${bottomButton}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
static GetPassedState(){
|
||||
return [
|
||||
{id:0, "name" : getTranslation("mot.not_passed")},
|
||||
{id:1, "name" : getTranslation("mot.passed")}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
static GetEdit(data={}){
|
||||
|
||||
let passedOptions = this.GetPassedState();
|
||||
|
||||
|
||||
|
||||
|
||||
let retval = {
|
||||
"vehicle_id": {
|
||||
"val" : data.vehicle_id ?? -1
|
||||
,"type" : "hidden"
|
||||
,"mandatory":true
|
||||
,"isRow":true
|
||||
},
|
||||
"old_mot": {
|
||||
"val" : data.vehicle_mot ?? -1
|
||||
,"type" : "hidden"
|
||||
,"mandatory":false
|
||||
,"isRow":true
|
||||
},
|
||||
"mot_validity_num": {
|
||||
"val" : mot_validity.num ?? 1
|
||||
,"type" : "hidden"
|
||||
,"mandatory":true
|
||||
,"isRow":true
|
||||
},
|
||||
"mot_validity_type": {
|
||||
"val" : (mot_validity.type ?? "w").toLowerCase()
|
||||
,"type" : "hidden"
|
||||
,"mandatory":true
|
||||
,"isRow":true
|
||||
}
|
||||
|
||||
,"divider_lights": {
|
||||
"type" : "divider"
|
||||
,"text" : getTranslation("mot.lights")
|
||||
}
|
||||
,"headlights": {
|
||||
"val" : data.headlights ?? 1
|
||||
,"type" : "dropdown"
|
||||
,"mandatory":true
|
||||
,"options":passedOptions
|
||||
}
|
||||
,"rear_lights": {
|
||||
"val" : data.rear_lights ?? 1
|
||||
,"type" : "dropdown"
|
||||
,"mandatory":true
|
||||
,"options":passedOptions
|
||||
}
|
||||
,"indicators": {
|
||||
"val" : data.indicators ?? 1
|
||||
,"type" : "dropdown"
|
||||
,"mandatory":true
|
||||
,"options":passedOptions
|
||||
}
|
||||
|
||||
,"divider_brakes_tyres": {
|
||||
"type" : "divider"
|
||||
,"text" : getTranslation("mot.brakes_tyres")
|
||||
}
|
||||
,"front_brakes": {
|
||||
"val" : data.front_brakes ?? 1
|
||||
,"type" : "dropdown"
|
||||
,"mandatory":true
|
||||
,"options":passedOptions
|
||||
}
|
||||
,"rear_brakes": {
|
||||
"val" : data.rear_brakes ?? 1
|
||||
,"type" : "dropdown"
|
||||
,"mandatory":true
|
||||
,"options":passedOptions
|
||||
}
|
||||
,"front_tyres": {
|
||||
"val" : data.front_tyres ?? 1
|
||||
,"type" : "dropdown"
|
||||
,"mandatory":true
|
||||
,"options":passedOptions
|
||||
}
|
||||
,"rear_tyres": {
|
||||
"val" : data.rear_tyres ?? 1
|
||||
,"type" : "dropdown"
|
||||
,"mandatory":true
|
||||
,"options":passedOptions
|
||||
}
|
||||
|
||||
,"divider_windows": {
|
||||
"type" : "divider"
|
||||
,"text" : getTranslation("mot.windows")
|
||||
}
|
||||
,"windscreen": {
|
||||
"val" : data.windscreen ?? 1
|
||||
,"type" : "dropdown"
|
||||
,"mandatory":true
|
||||
,"options":passedOptions
|
||||
}
|
||||
,"rear_window": {
|
||||
"val" : data.rear_window ?? 1
|
||||
,"type" : "dropdown"
|
||||
,"mandatory":true
|
||||
,"options":passedOptions
|
||||
}
|
||||
,"side_windows": {
|
||||
"val" : data.side_windows ?? 1
|
||||
,"type" : "dropdown"
|
||||
,"mandatory":true
|
||||
,"options":passedOptions
|
||||
}
|
||||
|
||||
,"divider_others": {
|
||||
"type" : "divider"
|
||||
,"text" : getTranslation("mot.others")
|
||||
}
|
||||
,"horn": {
|
||||
"val" : data.horn ?? 1
|
||||
,"type" : "dropdown"
|
||||
,"mandatory":true
|
||||
,"options":passedOptions
|
||||
}
|
||||
,"exhaust_system": {
|
||||
"val" : data.exhaust_system ?? 1
|
||||
,"type" : "dropdown"
|
||||
,"mandatory":true
|
||||
,"options":passedOptions
|
||||
}
|
||||
,"engine": {
|
||||
"val" : data.engine ?? 1
|
||||
,"type" : "dropdown"
|
||||
,"mandatory":true
|
||||
,"options":passedOptions
|
||||
}
|
||||
,"bodywork": {
|
||||
"val" : data.bodywork ?? 1
|
||||
,"type" : "dropdown"
|
||||
,"mandatory":true
|
||||
,"options":passedOptions
|
||||
}
|
||||
,"divider_summary": {
|
||||
"type" : "divider"
|
||||
,"text" : getTranslation("mot.summary")
|
||||
}
|
||||
,"passed": {
|
||||
"val" : data.passed ?? 1
|
||||
,"type" : "dropdown"
|
||||
,"mandatory":true
|
||||
,"options":System.GetBooleanOptions()
|
||||
,isRow: true
|
||||
}
|
||||
,"note": {
|
||||
"val" : data.note ?? ""
|
||||
,"type" : "textarea"
|
||||
,"mandatory":false
|
||||
,isRow: true
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
class RegVehicle_NoMOT{
|
||||
constructor(){
|
||||
this.name = "regvehicle_nomot";
|
||||
}
|
||||
|
||||
static allowView(){
|
||||
return userrights.has("regvehicles.view");
|
||||
}
|
||||
static allowAddNew(){
|
||||
return false;
|
||||
}
|
||||
static allowEdit(){
|
||||
return userrights.has("regvehicles.edit");
|
||||
}
|
||||
static allowDelete(){
|
||||
return false;
|
||||
}
|
||||
|
||||
static GetColumns(){
|
||||
return ["plate","veh_type","veh_model","owner","mot","state","id"]
|
||||
}
|
||||
|
||||
static GetExtraForView(data){
|
||||
let retval = {
|
||||
top:"",
|
||||
bottom:""
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static TableDataCreate(row, key){
|
||||
if(key == "state"){
|
||||
|
||||
let badges = ""
|
||||
|
||||
return `
|
||||
<td>
|
||||
${badges}
|
||||
</td>`;
|
||||
}
|
||||
|
||||
else if(key == "id"){
|
||||
return `
|
||||
<td>
|
||||
${Form.getViewButtonIcon(row[key], "regvehicle.view")}
|
||||
${Form.getEditButtonIcon(row[key] , "regvehicle.edit", this.allowEdit())}
|
||||
</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={}){
|
||||
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 {
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
class RegVehicle_PartAcceptance{
|
||||
constructor(){
|
||||
this.name = "regvehicle_partacceptance";
|
||||
}
|
||||
|
||||
static GetCustomDestination(data, dest){
|
||||
return (data.vehicle_id ?? "" != "" ? "regvehicle.view" : "regvehicle.overview");
|
||||
}
|
||||
|
||||
static GetCustomDestID(data, destID){
|
||||
return data.vehicle_id ?? destID;
|
||||
}
|
||||
static allowView(){
|
||||
return userrights.has("regvehicles.view");
|
||||
}
|
||||
static allowAddNew(){
|
||||
return userrights.has("regvehicles.edit");
|
||||
}
|
||||
static allowEdit(){
|
||||
return userrights.has("regvehicles.edit");
|
||||
}
|
||||
static allowDelete(){
|
||||
return userrights.has("regvehicles.edit");
|
||||
}
|
||||
|
||||
static GetExtraForEdit(data){
|
||||
|
||||
let retval = {
|
||||
top:"",
|
||||
bottom:""
|
||||
}
|
||||
|
||||
let gridData = data.extraData.tuning_options;
|
||||
let html = "";
|
||||
|
||||
|
||||
if(gridData.length == 0 || gridData.length == undefined){
|
||||
html += `<h2>${getTranslation("no_data_found")}</h2>`;
|
||||
|
||||
retval.top = html;
|
||||
|
||||
return retval;
|
||||
|
||||
}
|
||||
|
||||
let columns = ["name", "price", "id"];
|
||||
|
||||
html = `<table class = "table table-compact w-full">`
|
||||
for(let i=0; i<gridData.length;i++){
|
||||
|
||||
let row = gridData[i];
|
||||
|
||||
if(i==0){
|
||||
|
||||
html += `<thead>`;
|
||||
html += `<tr>`;
|
||||
|
||||
for(let k=0; k<columns.length;k++){
|
||||
html += `<th>${getTranslation(columns[k])}</th>`;
|
||||
}
|
||||
|
||||
html += `</tr>`;
|
||||
html += `</thead>`;
|
||||
html += `<tbody>`;
|
||||
}
|
||||
|
||||
html+=`<tr>`;
|
||||
|
||||
for(let j=0; j<columns.length;j++){
|
||||
let key = columns[j];
|
||||
|
||||
if(key == "id"){
|
||||
html += `
|
||||
<td>
|
||||
<input onchange="RegVehicle_PartAcceptance.CustomValidation(this)" data-price="${row.price}" type="checkbox" id="input-part_accepted_${row.id}" class="toggle toggle-success ignore-validation part-accepted" />
|
||||
${Form.Hidden("input-part_accepted_price_" + row.id, row.price)}
|
||||
</td>
|
||||
`;
|
||||
}
|
||||
else if(key == "price"){
|
||||
html += `
|
||||
<td>
|
||||
${System.FormatNumber(row[key])}
|
||||
</td>
|
||||
`;
|
||||
}
|
||||
else{
|
||||
html += `
|
||||
<td>
|
||||
${row[key] ?? ""}
|
||||
</td>
|
||||
`;
|
||||
}
|
||||
}
|
||||
html+=`</tr>`;
|
||||
}
|
||||
|
||||
html += `
|
||||
<tr>
|
||||
<td class="text-right">
|
||||
<strong>${getTranslation("sum_total")}:</strong>
|
||||
</td>
|
||||
<td id="part_acceptance_total_price" class="font-bold">
|
||||
0
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
|
||||
html += `</tbody>`;
|
||||
html += `</table>`;
|
||||
|
||||
|
||||
|
||||
|
||||
retval.top = html;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static CustomValidation(){
|
||||
let elements = Array.from(document.querySelectorAll(".part-accepted"));
|
||||
let totalPrice = 0;
|
||||
|
||||
elements.forEach(function(checkbox){
|
||||
let price = parseInt(checkbox.getAttribute("data-price"));
|
||||
|
||||
|
||||
if(price > 0 && checkbox.checked){
|
||||
totalPrice += price;
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById("part_acceptance_total_price").innerHTML = System.FormatNumber(totalPrice);
|
||||
|
||||
|
||||
|
||||
Form.validate();
|
||||
}
|
||||
|
||||
static GetEdit(data={}){
|
||||
let retval = {
|
||||
"vehicle_id": {
|
||||
"val" : data.vehicle_id ?? -1
|
||||
,"type" : "hidden"
|
||||
,"mandatory":true
|
||||
,"isRow":true
|
||||
},
|
||||
"content": {
|
||||
"val" : data.content ?? ""
|
||||
,"type" : "textarea"
|
||||
,"mandatory":true
|
||||
,isRow:true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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>`;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
class TuningOptions{
|
||||
constructor(){
|
||||
this.name = "tuningoptions";
|
||||
}
|
||||
static GetColumns(){
|
||||
return ["name","price","id"]
|
||||
}
|
||||
static allowAddNew(){
|
||||
return userrights.has("parts_acceptance.edit")
|
||||
}
|
||||
static allowEdit(){
|
||||
return userrights.has("parts_acceptance.edit")
|
||||
}
|
||||
static allowDelete(){
|
||||
return userrights.has("parts_acceptance.delete")
|
||||
}
|
||||
|
||||
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 == "price"){
|
||||
return `
|
||||
<td>
|
||||
${System.FormatNumber(row[key])}
|
||||
</td>`;
|
||||
}
|
||||
else{
|
||||
return `<td>${row[key]}</td>`;
|
||||
}
|
||||
}
|
||||
|
||||
static GetEdit(data={}){
|
||||
return {
|
||||
"name": {
|
||||
"val" : data.name ?? ""
|
||||
,"type" : "text"
|
||||
,"isRow": true
|
||||
,"mandatory":true
|
||||
},
|
||||
"price": {
|
||||
"val" : data.price ?? ""
|
||||
,"type" : "number"
|
||||
,"isRow": true
|
||||
,"mandatory":true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue