2 Commits

  1. 78
      berichtsheft/assets/css/notebook.css
  2. 106
      berichtsheft/assets/js/notebook.js
  3. 319
      berichtsheft/assets/templates/report.html

78
berichtsheft/assets/css/notebook.css

@ -6,6 +6,11 @@ body {
background: darkgray;
}
input {
width: 90%;
height: 100%;
}
#overlay {
position: fixed;
left: 0;
@ -42,53 +47,82 @@ hr {
border-top: 1px solid black;
}
td {
height: 1.5em;
word-break: break-word;
}
table.week {
layout: fixed;
.week {
width: 100%;
height: 80%;
display: flex;
flex-direction: column;
border: 1px solid #000000;
}
table.week th {
height: 2em;
font-weight: normal;
.week-head {
text-align: center;
vertical-align: middle;
align-items: center;
justify-content: center;
background-color: #f2f2f2;
}
table.week tbody:nth-child(odd) tr:nth-child(odd) {
.day {
flex-basis: 18%;
margin-top: -1px;
margin-left: -1px;
margin-right: -1px;
border: 1px solid #000000;
}
.week-foot {
background-color: #f2f2f2;
}
table.week tbody:nth-child(even) tr:nth-child(even) {
.week-foot div:first-child {
text-align: right;
}
.day-line {
align-items: center;
flex-basis: 20%;
}
.day:nth-child(even) .day-line:nth-child(even) {
background-color: #f2f2f2;
}
table.week thead th:nth-last-child(-n+2) {
width: 10%;
font-size: 80%;
.day:nth-child(odd) .day-line:nth-child(odd) {
background-color: #f2f2f2;
}
table.week td:nth-last-child(-n+2) {
text-align: center;
.flexh {
display: flex;
}
table.week tbody:last-child tr:last-child td:first-child {
text-align: right;
.flexv {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.flexgrow {
flex-grow: 1;
}
.vtable {
width: 1em;
.flexten {
flex-basis: 10%;
flex-grow: 0;
flex-shrink: 0;
text-align: center;
}
.flexfive {
flex-basis: 5%;
}
.vertical {
text-align: center;
writing-mode: vertical-lr;
transform: rotate(180deg);
border-left: 1px solid #000000;;
}
.sign {

106
berichtsheft/assets/js/notebook.js

@ -25,6 +25,7 @@ async function init() {
"title": await fetchTemplate("title"),
"blank": await fetchTemplate("blank"),
"report": await fetchTemplate("report"),
"report_input": await fetchTemplate("report_input"),
};
}
userdata.pages = userdata.pages || [];
@ -40,6 +41,7 @@ function pageAdd(template) {
pageNew(template);
userdata.pages.push(emptyPages[template]);
populate(app.children.length);
save();
}
function pageNew(template) {
@ -50,7 +52,7 @@ function pageNew(template) {
}
function populate(pnum) {
if (pnum > 0 && pnum <= app.children.length <= userdata.pages.length) {
if (pnum > 0 && pnum <= app.children.length && pnum <= userdata.pages.length) {
const node = app.children[pnum-1];
const data = userdata.pages[pnum-1];
node.querySelectorAll(".logo").forEach(i=>i.src = userdata.meta.logo);
@ -77,19 +79,26 @@ function populate(pnum) {
date[0].textContent = getDate(startDate);
date[1].textContent = getDate(endDate);
const week = node.getElementsByClassName("week")[0].querySelectorAll(".day");
let week = node.querySelector(".week").querySelectorAll(".day");
let weekh = null;
for (let i=0; i < week.length && i < data.days.length; i++) {
let day = week[i].children;
let dayh = null;
for (let j=0; j < day.length && j < data.days[i].length; j++) {
day[j].querySelectorAll("td")[0].textContent = data.days[i][j][0];
day[j].querySelectorAll("td")[1].textContent = data.days[i][j][1];
dayh += data.days[i][j][1];
for (const i in [...week]) {
let day = week[i].querySelectorAll(".day-line");
for (const j in [...day]) {
if (data.days.length > i && data.days[i].length > j && data.days[i][j].length === 2) {
day[j].querySelectorAll("div")[0].textContent = data.days[i][j][0];
day[j].querySelectorAll("div")[1].textContent = data.days[i][j][1];
}
}
day[day.length-1].querySelector(".subtotal").textContent = dayh;
weekh += dayh;
} node.querySelector(".total").textContent = weekh;
const st = [...week[i].querySelectorAll(".sh")].reduce(
(total,e) => {
return total + Number(e.textContent)
},
0
) || null;
week[i].querySelector(".subtotal").textContent = st;
weekh += st;
}
node.querySelector(".total").textContent = weekh;
case "blank":
node.querySelector(".pnum").textContent = pnum;
@ -105,6 +114,18 @@ function populate(pnum) {
}
}
function getTotal(day) {
let st = [...day.querySelectorAll(".sh")].reduce(
(total,e) => {
return total + Number(e.textContent)},
0
);
st = st || null;
day.querySelector(".subtotal").textContent = st;
return st;
}
function getDate(date) {
let d = date && new Date(...date) || new Date();
return `${String(d.getDate()).padStart(2, "0")}.${String(d.getMonth()+1).padStart(2, "0")}.${d.getFullYear()}`
@ -187,3 +208,64 @@ function exportData() {
e.setAttribute('download', "Berichtsheft.json");
e.click();
}
function editDayOpen(e) {
// Find page and day index
const getIndex = (n, e) => {
for (const i in n) {
if (n[i].contains(e)) {
return i;
}
}
return null;
};
let page = getIndex(app.children, e);
let day = (page !== null && getIndex(app.children[page].querySelectorAll(".day"), e))
if (day !== null && userdata["pages"][page] !== "undefined" && userdata["pages"][page][day] !== "undefined") {
const node = templates["report_input"].content.cloneNode(true).children[0];
const data = userdata["pages"][page]["days"][day];
for (const li in [...node.querySelectorAll(".day-line")]) {
if (data.length <= li || data[li].length !== 2) {
data[li] = ["", ""];
}
const inputs = node.querySelectorAll(".day-line")[li].querySelectorAll("input");
[...inputs].forEach((input,i) => {
input.value = data[li][i];
input.onblur = () => {editDayClose(node, e, page, day)};
if (i === 1) {
input.onchange = () => {
node.querySelector(".subtotal").textContent = [...node.querySelectorAll(".sh")].reduce(
(total,e) => {
return total + Number(e.value)
}, 0) || null;
};
}
});
}
e.style.display = "none";
e.insertAdjacentElement("afterend", node);
node.querySelector("input").focus();
}
}
function editDayClose(node, onode, page, day) {
const inputs = node.querySelectorAll("input");
setTimeout(() => {
if (![...inputs].some(i=>{return document.activeElement === i})) {
for (const li in node.querySelectorAll(".day-line")) {
const data = userdata["pages"][page]["days"][day];
if (data.length > li && data[li].length === 2) {
const inputs = node.querySelectorAll(".day-line")[li].querySelectorAll("input");
[...inputs].forEach((input,i) => {
data[li][i] = input.value;
})
}
}
node.remove();
onode.style.display = "flex";
populate(Number(page)+1);
save();
}
}, 10);
}

319
berichtsheft/assets/templates/report.html

@ -12,164 +12,175 @@
</div>
<div class="pg-content">
<table class="week">
<thead>
<tr>
<th colspan="2">Unterweisungen, ausgeführte Arbeiten usw.</th>
<th>Einzel-<br>Stunden</th>
<th>Gesammt-<br>Stunden</th>
</thead>
<tbody class="day">
<tr>
<th rowspan="5" class="vtable"><div class="vertical">Montag</div></th>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td class="subtotal"></td>
</tr>
</tbody>
<tbody class="day">
<tr>
<th rowspan="5" class="vtable"><div class="vertical">Dienstag</div></th>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td class="subtotal"></td>
</tr>
</tbody>
<div class="week">
<div class="week-head flexh flexfive">
<div class="flexgrow">Unterweisungen, ausgeführte Arbeiten usw.</div>
<div class="flexten">Einzel-Stunden</div>
<div class="flexten">Gesammt-Stunden</div>
</div>
<tbody class="day">
<tr>
<th rowspan="5" class="vtable"><div class="vertical">Mittwoch</div></th>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td class="subtotal"></td>
</tr>
</tbody>
<div class="day flexh">
<div class="vertical">Montag</div>
<div class="day-content flexv" onclick="editDayOpen(this)">
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="subtotal green flexten"></div>
</div>
</div>
</div>
<tbody class="day">
<tr>
<th rowspan="5" class="vtable"><div class="vertical">Donnerstag</div></th>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td class="subtotal"></td>
</tr>
</tbody>
<div class="day flexh">
<div class="vertical">Dienstag</div>
<div class="day-content flexv" onclick="editDayOpen(this)">
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="subtotal green flexten"></div>
</div>
</div>
</div>
<div class="day flexh">
<div class="vertical">Mittwoch</div>
<div class="day-content flexv" onclick="editDayOpen(this)">
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="subtotal green flexten"></div>
</div>
</div>
</div>
<div class="day flexh">
<div class="vertical">Donnerstag</div>
<div class="day-content flexv" onclick="editDayOpen(this)">
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="subtotal green flexten"></div>
</div>
</div>
</div>
<div class="day flexh">
<div class="vertical">Freitag</div>
<div class="day-content flexv" onclick="editDayOpen(this)">
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="sh flexten"></div>
</div>
<div class="day-line flexh">
<div class="flexgrow"></div>
<div class="sh flexten"></div>
<div class="subtotal green flexten"></div>
</div>
</div>
</div>
<div class="week-foot flexh flexfive">
<div class="flexgrow">Wochenstunden</div>
<div class="total flexten"></div>
</div>
</div>
<tbody class="day">
<tr>
<th rowspan="5" class="vtable"><div class="vertical">Freitag</div></th>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td class="subtotal"></td>
</tr>
</tbody>
<tbody>
<tr style="height:1em">
<td colspan="3">Wochenstunden</td>
<td class="total"></td>
</tr>
</tbody>
</table>
<div class="sign">
<table>
<tr>

Loading…
Cancel
Save