Uebersicht: Sidebar Suche/Uebersicht, API-Gruppierung, Versanddatum, 3-Uhr-Mail

uebersicht:
- Secondary-Sidebar: "Uebersicht" + "Suche". Suche wie frueher (Empfaenger
  suchen -> Schriftstueckart -> In Warteschlange, fuer Nachdruck).
- API-Auftraege als aufklappbare Charge-Gruppe (Kopf mit Summen: Schriftstuecke,
  Kuverts, Format, Versand). Versandfertig unterteilt: schnellstmoeglich / Datum.
- Versanddatum je Auftrag editierbar (leer = schnellstmoeglich).

bootstrap: orders.versanddatum (date).
produktion: Charge-Kopf zeigt Summen (Schriftstuecke/Kuverts/Format/Versand).
mailer: 03:00-Mail listet zusaetzlich "heute zu versenden" (faelliges Versanddatum).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
s4luorth
2026-10-01 11:21:49 +02:00
parent d2559de22c
commit 6a6b09d49d
4 changed files with 259 additions and 95 deletions

View File

@@ -309,7 +309,22 @@ export default (register, { services, getSchema, logger }) => {
+ `<td style="${td}text-align:right;border-top:2px solid #333;"><strong>${gesamtA}</strong></td>`
+ `<td style="${td}text-align:right;border-top:2px solid #333;"><strong>${gesamtM}</strong></td></tr></tfoot>`
+ '</table>';
const nachricht = { to, subject: `Auftragsübersicht ${heute} – ${gesamtA} Aufträge`, html, text: htmlZuText(html), replyTo: REPLY_TO };
// Heute zu versenden: versandfertige Aufträge mit fälligem (≤ heute) Versanddatum.
let faelligHtml = ''; let faelligN = 0;
try {
const heuteStr = new Date().toISOString().slice(0, 10);
const faellig = await new ItemsService('orders', { schema, accountability: null }).readByQuery({
filter: { _and: [{ production_status: { _eq: 'versandfertig' } }, { versanddatum: { _nnull: true } }, { versanddatum: { _lte: heuteStr } }] },
fields: ['order_number', 'order_name', 'versanddatum', 'entries_count'], limit: -1, sort: ['versanddatum'],
});
faelligN = (faellig || []).length;
if (faelligN) {
const z = faellig.map((o) => `<li><strong>${esc(o.order_name || o.order_number)}</strong> – ${o.entries_count || 0} Stk., Versand ${esc(o.versanddatum)}</li>`).join('');
faelligHtml = `<p style="margin-top:18px;color:#a32d2d;"><strong>Heute zu versenden (${faelligN}):</strong></p><ul>${z}</ul>`;
}
} catch (e) { logger.warn(`[skrift-mailer] Fälligkeits-Check: ${e.message}`); }
const htmlFull = html + faelligHtml;
const nachricht = { to, subject: `Auftragsübersicht ${heute} – ${gesamtA} Aufträge${faelligN ? ` · ${faelligN} heute versenden` : ''}`, html: htmlFull, text: htmlZuText(htmlFull), replyTo: REPLY_TO };
if (settings.sender_email) nachricht.from = settings.sender_name ? `${settings.sender_name} <${settings.sender_email}>` : settings.sender_email;
await new MailService({ schema, accountability: null }).send(nachricht);
logger.info(`[skrift-mailer] Auftragsübersicht verschickt: ${gesamtA} Aufträge in ${Object.keys(agg).length} Status`);