ed
This commit is contained in:
parent
48a36209b5
commit
884f3df7cf
262 changed files with 223207 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue