mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 08:34:42 +01:00
WIP timesheet timers: config to disable timers and overwrite of start&stop time
This commit is contained in:
parent
8fad43b705
commit
59da89fe8b
@ -97,30 +97,30 @@ egw.extend('timer', egw.MODULE_GLOBAL, function()
|
||||
switch(_action)
|
||||
{
|
||||
case 'overall-start':
|
||||
startTimer(overall);
|
||||
startTimer(overall, _time);
|
||||
break;
|
||||
|
||||
case 'overall-pause':
|
||||
stopTimer(overall,true);
|
||||
if (specific?.start) stopTimer(specific, true);
|
||||
stopTimer(overall,true, _time);
|
||||
if (specific?.start) stopTimer(specific, true, _time);
|
||||
break;
|
||||
|
||||
case 'overall-stop':
|
||||
stopTimer(overall);
|
||||
if (specific?.start) stopTimer(specific);
|
||||
stopTimer(overall, false, _time);
|
||||
if (specific?.start) stopTimer(specific, false, _time);
|
||||
break;
|
||||
|
||||
case 'specific-start':
|
||||
if (overall?.paused) startTimer(overall);
|
||||
startTimer(specific);
|
||||
if (overall?.paused) startTimer(overall, _time);
|
||||
startTimer(specific, _time);
|
||||
break;
|
||||
|
||||
case 'specific-pause':
|
||||
stopTimer(specific,true);
|
||||
stopTimer(specific,true, _time);
|
||||
break;
|
||||
|
||||
case 'specific-stop':
|
||||
stopTimer(specific);
|
||||
stopTimer(specific, false, _time);
|
||||
break;
|
||||
}
|
||||
// persist state
|
||||
@ -227,7 +227,7 @@ egw.extend('timer', egw.MODULE_GLOBAL, function()
|
||||
* Start given timer
|
||||
*
|
||||
* @param object _timer
|
||||
* @param string|undefined _start to initialise with time different from current time
|
||||
* @param string|Date|undefined _start to initialise with time different from current time
|
||||
* @param number|undefined _offset to set an offset
|
||||
*/
|
||||
function startTimer(_timer, _start, _offset)
|
||||
@ -241,7 +241,7 @@ egw.extend('timer', egw.MODULE_GLOBAL, function()
|
||||
{
|
||||
_timer.start = new Date();
|
||||
}
|
||||
if (_offset || _timer.offset)
|
||||
if (_offset || _timer.offset && _timer.paused)
|
||||
{
|
||||
_timer.start.setMilliseconds(_timer.start.getMilliseconds()-(_offset || _timer.offset));
|
||||
}
|
||||
@ -265,14 +265,16 @@ egw.extend('timer', egw.MODULE_GLOBAL, function()
|
||||
*
|
||||
* @param object _timer
|
||||
* @param bool|undefined _pause true: pause, else: stop
|
||||
* @param string|Date|undefined _time stop-time, default current time
|
||||
*/
|
||||
function stopTimer(_timer, _pause)
|
||||
function stopTimer(_timer, _pause, _time)
|
||||
{
|
||||
const time = _time ? new Date(_time) : new Date();
|
||||
// update _timer state object
|
||||
_timer.paused = _pause || false;
|
||||
if (_timer.start)
|
||||
{
|
||||
_timer.offset = (new Date()).valueOf() - _timer.start.valueOf();
|
||||
_timer.offset = time.valueOf() - _timer.start.valueOf();
|
||||
_timer.start = undefined;
|
||||
}
|
||||
// update timer display
|
||||
@ -314,8 +316,10 @@ egw.extend('timer', egw.MODULE_GLOBAL, function()
|
||||
|
||||
// set state if given
|
||||
const timer = document.getElementById('topmenu_timer');
|
||||
if (timer && timer.getAttribute('data-state')) {
|
||||
setState(JSON.parse(timer.getAttribute('data-state')));
|
||||
const state = timer && timer.getAttribute('data-state') ? JSON.parse(timer.getAttribute('data-state')) : undefined;
|
||||
if (timer && state)
|
||||
{
|
||||
setState(state);
|
||||
}
|
||||
|
||||
// bind click handler
|
||||
@ -329,7 +333,9 @@ egw.extend('timer', egw.MODULE_GLOBAL, function()
|
||||
callback: (button_id, value) => // return false to prevent dialog closing
|
||||
{
|
||||
if (button_id !== 'close') {
|
||||
timerAction(button_id.replace(/_([a-z]+)\[([a-z]+)\]/, '$1-$2'), value.time);
|
||||
timerAction(button_id.replace(/_([a-z]+)\[([a-z]+)\]/, '$1-$2'),
|
||||
// eT2 operates in user-time, while timers here always operate in UTC
|
||||
value.time ? new Date((new Date(value.time)).valueOf() + egw.getTimezoneOffset() * 60000) : undefined);
|
||||
setButtonState();
|
||||
return false;
|
||||
}
|
||||
@ -342,7 +348,7 @@ egw.extend('timer', egw.MODULE_GLOBAL, function()
|
||||
],
|
||||
value: {
|
||||
content: {
|
||||
disable: 'overwrite'
|
||||
disable: state.disable.join(':')
|
||||
},
|
||||
sel_options: {}
|
||||
}
|
||||
@ -350,16 +356,12 @@ egw.extend('timer', egw.MODULE_GLOBAL, function()
|
||||
// Add to DOM, dialog will auto-open
|
||||
document.body.appendChild(dialog);
|
||||
dialog.getUpdateComplete().then(() => {
|
||||
// add default content to timer-divs
|
||||
dialog._overlayContentNode.querySelectorAll('div.timesheet_timer').forEach(timer => {
|
||||
timer.textContent = '0:00';
|
||||
});
|
||||
// enable/disable buttons based on timer state
|
||||
setButtonState();
|
||||
// update Timers
|
||||
// update timers in dialog
|
||||
update();
|
||||
// set current time for overwrite time input
|
||||
let now = new Date((new Date).valueOf() - egw.getTimezoneOffset() * 60000);
|
||||
// set current time for overwrite time input (eT2 operates in user-time!)
|
||||
//let now = new Date((new Date).valueOf() - egw.getTimezoneOffset() * 60000);
|
||||
//dialog._overlayContentNode.querySelector('et2-date-time').value = now;
|
||||
});
|
||||
});
|
||||
|
@ -218,8 +218,12 @@ class timesheet_hooks
|
||||
public static function add_timer($data)
|
||||
{
|
||||
$state = Events::timerState();
|
||||
$GLOBALS['egw']->framework->_add_topmenu_info_item('<div id="topmenu_timer" title="'.
|
||||
lang('Start & stop timer').'"'.
|
||||
($state ? ' data-state="'.htmlspecialchars(json_encode($state)).'"' : '').'>0:00</div>', 'timer');
|
||||
// only send/display if at least one timer is not disabled
|
||||
if (array_diff(['specific', 'overall'], $state['disable']))
|
||||
{
|
||||
$GLOBALS['egw']->framework->_add_topmenu_info_item('<div id="topmenu_timer" title="'.
|
||||
lang('Start & stop timer').'"'.
|
||||
($state ? ' data-state="'.htmlspecialchars(json_encode($state)).'"' : '').'>0:00</div>', 'timer');
|
||||
}
|
||||
}
|
||||
}
|
@ -28,6 +28,7 @@ deleted timesheet de gelöscht
|
||||
deletes this field timesheet de Dieses Feld löschen
|
||||
determines the order the fields are displayed timesheet de verändert die Reihenfolge der angezeigten Felder
|
||||
directory with documents to insert entries timesheet de Ordner mit Dokumenten zum Einfügen.
|
||||
disable timers timesheet de Zeitnehmer ausschalten
|
||||
each value is a line like <id>[=<label>] timesheet de jeder Wert ist eine Zeile in dem Format <id>[=|label>]
|
||||
edit status common de Status bearbeiten
|
||||
edit this entry timesheet de diesen Eintrag bearbeiten
|
||||
@ -37,6 +38,7 @@ entry deleted timesheet de Eintrag gelöscht
|
||||
entry saved timesheet de Eintrag gespeichert
|
||||
error deleting the entry!!! timesheet de Fehler beim Löschen des Eintrags!!!
|
||||
error saving the entry!!! timesheet de Fehler beim Speichern des Eintrags!!!
|
||||
error storing working time timesheet de Fehler beim Speichern der Arbeitszeit
|
||||
events timesheet de Ereignisse
|
||||
example {{if n_prefix~mr~hello mr.~hello ms.}} - search the field "n_prefix", for "mr", if found, write hello mr., else write hello ms. timesheet de Beispiel: {{IF n_prefix~Herr~sehr geehrter Herr~sehr geehrte Frau}} - wenn im Feld 'n_prefix' 'Herr' steht wird 'sehr geehrter Herr' geschrieben, ansonsten 'sehr geehrte Frau'.
|
||||
example {{letterprefixcustom n_prefix title n_family}} - example: mr dr. james miller timesheet de Beispiel: {{LETTERPREFIXCUSTOM n_prefix title n_family}} - Herr Dr. Müller
|
||||
@ -95,7 +97,10 @@ only admin admin de nur Administratoren
|
||||
only admin can edit this status admin de nur Administratoren dürfen Stundenzettel mit diesen Status bearbeiten
|
||||
or endtime timesheet de oder Endzeit
|
||||
order timesheet de Reihenfolge
|
||||
overwrite common de Überschreiben
|
||||
overwriting start or stop time timesheet de Überschreiben der Start- oder Stop-Zeit
|
||||
parent admin de Übergeordnet
|
||||
pause common de Pause
|
||||
permission denied!!! timesheet de Zugriff verweigert!!!
|
||||
permissions error - %1 could not %2 timesheet de Fehler in den Zugriffsberechtigungen - %1 nicht möglich %2
|
||||
prevent deleting admin de Verhindert Löschung
|
||||
@ -128,6 +133,7 @@ status timesheet de Status
|
||||
status deleted. timesheet de Status gelöscht
|
||||
status of created timesheets timesheet de Status für neue Stundenzettel
|
||||
status updated. timesheet de Status geändert
|
||||
stop common de Stop
|
||||
sum %1: timesheet de Summe %1:
|
||||
tag to mark positions for address labels timesheet de Platzhalter, um die Position der Adresslabels festzulegen
|
||||
the document can contain placeholder like {{%3}}, to be replaced with the data (%1full list of placeholder names%2). timesheet de Das Dokument kann Platzhalter wie {{%3}} beinhalten, die mit den entsprechenden Inhalten ersetzt werden (%1Liste der Platzhalter%2).
|
||||
@ -138,6 +144,7 @@ this month timesheet de Diesen Monat
|
||||
this week timesheet de Diese Woche
|
||||
this year timesheet de Dieses Jahr
|
||||
ticket modified by %1 at %2 timesheet de Ticket geändert von %1 am %2
|
||||
timer common de Zeitnehmer
|
||||
timesheet common de Stundenzettel
|
||||
timesheet csv export timesheet de Export des Stundenzettels als CSV
|
||||
timesheet csv import timesheet de Stundenzettels CSV Import
|
||||
@ -162,6 +169,9 @@ what should be done with unknown values? timesheet de Was soll mit unbekannten W
|
||||
when you merge entries into documents, they will be stored here. if no directory is provided, they will be stored in your home directory (/home/ralf) timesheet de Wenn Sie Einträge in Dokumente einfügen, werden diese hier gespeichert. Wenn kein Verzeichnis angegeben ist, werden sie in Ihrem Home Verzeichnis gespeichert.
|
||||
will be created when saving ... common de Wird beim Speichern angelegt ...
|
||||
working time common de Arbeitszeit
|
||||
working time and timer timesheet de Arbeitszeit und Zeitnehmer
|
||||
working time from %1 timesheet de Arbeitszeit vom %1
|
||||
working time of %1 hours stored timesheet de Arbeitszeit von %1 Stunden gespeichert
|
||||
yes, only admins can purge deleted items admin de Ja, nur Administratoren dürfen gelöschte Einträge endgültig löschen
|
||||
yes, users can purge their deleted items admin de Ja, Benutzer dürfen ihre gelöschten Einträge endgültig löschen
|
||||
yesterday timesheet de Gestern
|
||||
|
@ -28,6 +28,7 @@ deleted timesheet en Deleted
|
||||
deletes this field timesheet en Deletes this field
|
||||
determines the order the fields are displayed timesheet en Determines the order the fields are displayed
|
||||
directory with documents to insert entries timesheet en Directory with documents to insert entries
|
||||
disable timers timesheet en Disable timers
|
||||
each value is a line like <id>[=<label>] timesheet en Each value is a line like <id>[=<label>]
|
||||
edit status common en Edit status
|
||||
edit this entry timesheet en Edit this entry
|
||||
@ -37,6 +38,7 @@ entry deleted timesheet en Entry deleted.
|
||||
entry saved timesheet en Entry saved.
|
||||
error deleting the entry!!! timesheet en Error deleting the entry!
|
||||
error saving the entry!!! timesheet en Error saving the entry!
|
||||
error storing working time timesheet en Error storing working time
|
||||
events timesheet en Events
|
||||
example {{if n_prefix~mr~hello mr.~hello ms.}} - search the field "n_prefix", for "mr", if found, write hello mr., else write hello ms. timesheet en Example {{IF n_prefix~Mr~Hello Mr.~Hello Ms.}} - search the field "n_prefix", for "Mr", if found, write Hello Mr., else write Hello Ms.
|
||||
example {{letterprefixcustom n_prefix title n_family}} - example: mr dr. james miller timesheet en Example {{LETTERPREFIXCUSTOM n_prefix title n_family}} - Example: Mr Dr. James Miller
|
||||
@ -95,7 +97,10 @@ only admin admin en Only admin
|
||||
only admin can edit this status admin en Only admins can edit timesheets with this status
|
||||
or endtime timesheet en or end time
|
||||
order timesheet en Order
|
||||
overwrite common en Overwrite
|
||||
overwriting start or stop time timesheet en Overwriting start or stop time
|
||||
parent admin en Parent
|
||||
pause common en Pause
|
||||
permission denied!!! timesheet en Permission denied!
|
||||
permissions error - %1 could not %2 timesheet en Permissions error - %1 could not %2
|
||||
prevent deleting admin en Prevent deleting
|
||||
@ -128,6 +133,7 @@ status timesheet en Status
|
||||
status deleted. timesheet en Status deleted.
|
||||
status of created timesheets timesheet en Status of created timesheets
|
||||
status updated. timesheet en Status updated.
|
||||
stop common en Stop
|
||||
sum %1: timesheet en Sum %1:
|
||||
tag to mark positions for address labels timesheet en Tag to mark positions for address labels
|
||||
the document can contain placeholder like {{%3}}, to be replaced with the data (%1full list of placeholder names%2). timesheet en The document can contain placeholder like {{%3}}, to be replaced with the data (%1full list of placeholder names%2).
|
||||
@ -138,6 +144,7 @@ this month timesheet en This month
|
||||
this week timesheet en This week
|
||||
this year timesheet en This year
|
||||
ticket modified by %1 at %2 timesheet en Ticket modified by %1 at %2
|
||||
timer common en Timer
|
||||
timesheet common en Time Sheet
|
||||
timesheet csv export timesheet en TimeSheet CSV export
|
||||
timesheet csv import timesheet en TimeSheet CSV import
|
||||
@ -162,6 +169,9 @@ what should be done with unknown values? timesheet en What should be done with u
|
||||
when you merge entries into documents, they will be stored here. if no directory is provided, they will be stored in your home directory (/home/ralf) timesheet en When you merge entries into documents, they will be stored here. If no directory is provided, they will be stored in your home directory (/home/ralf)
|
||||
will be created when saving ... common en Will be created when saving ...
|
||||
working time common en Working time
|
||||
working time and timer timesheet en Working time and timer
|
||||
working time from %1 timesheet en Working time from %1
|
||||
working time of %1 hours stored timesheet en Working time of %1 hours stored
|
||||
yes, only admins can purge deleted items admin en Yes, only admins can purge deleted items
|
||||
yes, users can purge their deleted items admin en Yes, users can purge their deleted items
|
||||
yesterday timesheet en Yesterday
|
||||
|
@ -194,6 +194,10 @@ class Events extends Api\Storage\Base
|
||||
$timer['start'] = (new Api\DateTime($timer['start'], new \DateTimeZone('UTC')))->format(Api\DateTime::ET2);
|
||||
}
|
||||
}
|
||||
// send timer configuration to client-side
|
||||
$config = Api\Config::read(self::APP);
|
||||
$state['disable'] = $config['disable_timer'] ?? [];
|
||||
|
||||
return $state;
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
|
@ -43,7 +43,15 @@
|
||||
</select>
|
||||
</row>
|
||||
<row>
|
||||
<description value="Working time" span="all" class="subHeader"/>
|
||||
<description value="Working time and timer" span="all" class="subHeader"/>
|
||||
</row>
|
||||
<row>
|
||||
<description value="Disable timers"/>
|
||||
<select id="newsettings[disable_timer]" multiple="true">
|
||||
<option value="overall">Working time</option>
|
||||
<option value="specific">Timer</option>
|
||||
<option value="overwrite">Overwriting start or stop time</option>
|
||||
</select>
|
||||
</row>
|
||||
<row>
|
||||
<description value="Category for 'Working time'"/>
|
||||
|
Loading…
Reference in New Issue
Block a user