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 += `
`; for(const row of data.data.data){ html += this.GetDetailView(row, data.data.id, false); } html += `
`; 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 = `

${row.note.replace(/\n/g,"
")}

`; } if(drawViewButton){ bottomButton = `` } return `

${System.buildEmployeeName(row.creator)} - ${System.formatTimestamp(row.createddate)}

${getTranslation("passed")}: ${getTranslation(row.passed == 1 ? "yes": "no")}

${getTranslation("new_mot")}: ${System.formatDate(row.new_mot) }

${getTranslation("old_mot")}: ${System.formatDate(row.old_mot) }

${contentHtml}
${getTranslation("mot.lights")} ${getTranslation("mot.brakes_tyres")} ${getTranslation("mot.windows")} ${getTranslation("mot.others")}
${getTranslation("headlights")} ${getTranslation("front_brakes")} ${getTranslation("windscreen")} ${getTranslation("horn")}
${getTranslation("rear_lights")} ${getTranslation("rear_brakes")} ${getTranslation("rear_window")} ${getTranslation("exhaust_system")}
${getTranslation("indicators")} ${getTranslation("front_tyres")} ${getTranslation("side_windows")} ${getTranslation("engine")}
${getTranslation("rear_tyres")} ${getTranslation("bodywork")}

${bottomButton}
`; } 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; } }