Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 

33 rader
987 B

  1. // assets/scripts/report.js
  2. document.addEventListener('DOMContentLoaded', () => {
  3. document.addEventListener('click', async (e) => {
  4. const btn = e.target.closest('[data-action="toggle-invoiced"]');
  5. if (!btn) return;
  6. const row = btn.closest('[data-entry-id]');
  7. if (!row) return;
  8. const id = row.dataset.entryId;
  9. try {
  10. const res = await fetch(`/api/entries/${id}/invoiced`, { method: 'PATCH' });
  11. if (!res.ok) throw new Error(`HTTP ${res.status}`);
  12. const data = await res.json();
  13. const invoiced = data.invoiced;
  14. row.dataset.invoiced = invoiced ? 'true' : 'false';
  15. row.classList.toggle('report-table__row--invoiced', invoiced);
  16. btn.classList.toggle('report-lock--invoiced', invoiced);
  17. btn.title = invoiced
  18. ? (window.REPORT?.i18n?.btnUnlock ?? '')
  19. : (window.REPORT?.i18n?.btnLock ?? '');
  20. } catch (err) {
  21. console.error('Fehler beim Toggeln des Abrechnungsstatus:', err);
  22. }
  23. });
  24. });