forked from Simnation/Main
90 lines
No EOL
2.5 KiB
JavaScript
90 lines
No EOL
2.5 KiB
JavaScript
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>`;
|
|
}
|
|
}
|
|
}
|