האתר של יוחאי

מוזמנים להכנס (:

snippets

update meckano hours all at once

// Run in console on hours report page
(function () {
  // All table rows in the hours report
  var rows = document.querySelectorAll('table.hours-report tbody tr');

  rows.forEach(function (tr) {
    // Skip holiday rows
    if (tr.classList.contains('holiday-bg-row')) return;

    // Find check-in/out inputs in this row
    var checkInInput  = tr.querySelector('td.checkIn input.checkIn');
    var checkOutInput = tr.querySelector('td.checkOut input.checkOut');

    // Skip if inputs not found (safety)
    if (!checkInInput || !checkOutInput) return;

    // Optionally skip if row is disabled/read-only:
    if (checkInInput.disabled || checkOutInput.disabled) return;

    // Set times
    checkInInput.value  = '08:00';
    checkOutInput.value = '16:00';

    // Trigger change events so Meckano recalculates
    ['change', 'blur', 'input'].forEach(function (ev) {
      checkInInput.dispatchEvent(new Event(ev, { bubbles: true }));
      checkOutInput.dispatchEvent(new Event(ev, { bubbles: true }));
    });
  });
})();