From bd68d5a0dc9aad9854df9220538bd0c0db7d6ea0 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 16 Aug 2016 18:40:07 +0000 Subject: [PATCH] Made records with 0 duration legal. --- WEB-INF/lib/ttTimeHelper.class.php | 6 ------ WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/mobile/time.tpl | 2 +- WEB-INF/templates/mobile/time_delete.tpl | 2 +- WEB-INF/templates/time.tpl | 4 ++-- WEB-INF/templates/time_delete.tpl | 2 +- mobile/time.php | 6 ++---- mobile/time_edit.php | 2 +- time.php | 6 ++---- time_edit.php | 2 +- 10 files changed, 12 insertions(+), 22 deletions(-) diff --git a/WEB-INF/lib/ttTimeHelper.class.php b/WEB-INF/lib/ttTimeHelper.class.php index 87b5aeaa..a2dade9a 100644 --- a/WEB-INF/lib/ttTimeHelper.class.php +++ b/WEB-INF/lib/ttTimeHelper.class.php @@ -87,18 +87,12 @@ class ttTimeHelper { if ($value == '24:00' || $value == '2400') return true; if (preg_match('/^([0-1]{0,1}[0-9]|2[0-3]):?[0-5][0-9]$/', $value )) { // 0:00 - 23:59, 000 - 2359 - if ('00:00' == ttTimeHelper::normalizeDuration($value)) - return false; return true; } if (preg_match('/^([0-1]{0,1}[0-9]|2[0-4])h?$/', $value )) { // 0, 1 ... 24 - if ('00:00' == ttTimeHelper::normalizeDuration($value)) - return false; return true; } if (preg_match('/^([0-1]{0,1}[0-9]|2[0-3])?[.][0-9]{1,4}h?$/', $value )) { // decimal values like 0.5, 1.25h, ... .. 23.9999h - if ('00:00' == ttTimeHelper::normalizeDuration($value)) - return false; return true; } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 08b96c3c..20d292f7 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- {/if} - {/foreach} diff --git a/WEB-INF/templates/mobile/time_delete.tpl b/WEB-INF/templates/mobile/time_delete.tpl index 3afc823e..bfe367a0 100644 --- a/WEB-INF/templates/mobile/time_delete.tpl +++ b/WEB-INF/templates/mobile/time_delete.tpl @@ -14,7 +14,7 @@ {if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)} {/if} - +
 Anuko Time Tracker 1.9.28.3522 | Copyright © Anuko | +  Anuko Time Tracker 1.9.29.3523 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/mobile/time.tpl b/WEB-INF/templates/mobile/time.tpl index 8a57c8c1..ed83c9cb 100644 --- a/WEB-INF/templates/mobile/time.tpl +++ b/WEB-INF/templates/mobile/time.tpl @@ -226,7 +226,7 @@ function get_date() { {if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)} {$record.project|escape:'html'}{if $record.duration == '0:00'}{/if}{$record.duration}{if $record.duration == '0:00'}{/if} + {if ($record.duration == '0:00' && $record.start <> '')}{/if}{$record.duration}{if ($record.duration == '0:00' && $record.start <> '')}{/if} {if $record.invoice_id} {else}{$i18n.label.edit}{/if}
{$time_rec.project_name|escape:'html'}{if $time_rec.duration<>'0:00'}{$time_rec.duration}{else}{$i18n.form.time.uncompleted}{/if}{if ($time_rec.duration == '0:00' && $time_rec.start <> '')}{$i18n.form.time.uncompleted}{else}{$time_rec.duration}{/if} {if $time_rec.comment}{$time_rec.comment|escape:'html'}{else} {/if}
diff --git a/WEB-INF/templates/time.tpl b/WEB-INF/templates/time.tpl index c36f81f2..ee17d9d4 100644 --- a/WEB-INF/templates/time.tpl +++ b/WEB-INF/templates/time.tpl @@ -326,14 +326,14 @@ function get_time() { {if $record.start}{$record.start}{else} {/if} {if $record.finish}{$record.finish}{else} {/if} {/if} - {if $record.duration <> '0:00'}{$record.duration}{else}{$i18n.form.time.uncompleted}{/if} + {if ($record.duration == '0:00' && $record.start <> '')}{$i18n.form.time.uncompleted}{else}{$record.duration}{/if} {if $record.comment}{$record.comment|escape:'html'}{else} {/if} {if $record.invoice_id}   {else} {$i18n.label.edit} - {if $record.duration == '0:00'} + {if ($record.duration == '0:00' && $record.start <> '')} diff --git a/WEB-INF/templates/time_delete.tpl b/WEB-INF/templates/time_delete.tpl index 8470fc3a..362ced4e 100644 --- a/WEB-INF/templates/time_delete.tpl +++ b/WEB-INF/templates/time_delete.tpl @@ -31,7 +31,7 @@ {if $time_rec.finish<>$time_rec.start}{$time_rec.finish}{else} {/if} {/if} {if (($smarty.const.TYPE_DURATION == $user->record_type) || ($smarty.const.TYPE_ALL == $user->record_type))} - {if $time_rec.duration<>'0:00'}{$time_rec.duration}{else}{$i18n.form.time.uncompleted}{/if} + {if ($time_rec.duration == '0:00' && $time_rec.start <> '')}{$i18n.form.time.uncompleted}{else}{$time_rec.duration}{/if} {/if} {if $time_rec.comment}{$time_rec.comment|escape:'html'}{else} {/if} diff --git a/mobile/time.php b/mobile/time.php index 679dcadf..2dfe239c 100644 --- a/mobile/time.php +++ b/mobile/time.php @@ -199,10 +199,8 @@ if ($request->isPost()) { if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { if (!$cl_task) $err->add($i18n->getKey('error.task')); } - if (!$cl_duration) { - if ('0' == $cl_duration) - $err->add($i18n->getKey('error.field'), $i18n->getKey('label.duration')); - elseif ($cl_start || $cl_finish) { + if (strlen($cl_duration) == 0) { + if ($cl_start || $cl_finish) { if (!ttTimeHelper::isValidTime($cl_start)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.start')); if ($cl_finish) { diff --git a/mobile/time_edit.php b/mobile/time_edit.php index 452baf29..d0d3f448 100644 --- a/mobile/time_edit.php +++ b/mobile/time_edit.php @@ -95,7 +95,7 @@ if ($request->isPost()) { $cl_billable = $time_rec['billable']; // Add an info message to the form if we are editing an uncompleted record. - if (($cl_start == $cl_finish) && ($cl_duration == '0:00')) { + if (strlen($cl_start) > 0 && $cl_start == $cl_finish && $cl_duration == '0:00') { $cl_finish = ''; $cl_duration = ''; $msg->add($i18n->getKey('form.time_edit.uncompleted')); diff --git a/time.php b/time.php index 3543cce0..768a809d 100644 --- a/time.php +++ b/time.php @@ -232,10 +232,8 @@ if ($request->isPost()) { if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { if (!$cl_task) $err->add($i18n->getKey('error.task')); } - if (!$cl_duration) { - if ('0' == $cl_duration) - $err->add($i18n->getKey('error.field'), $i18n->getKey('label.duration')); - elseif ($cl_start || $cl_finish) { + if (strlen($cl_duration) == 0) { + if ($cl_start || $cl_finish) { if (!ttTimeHelper::isValidTime($cl_start)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.start')); if ($cl_finish) { diff --git a/time_edit.php b/time_edit.php index b509fcf9..d486d652 100644 --- a/time_edit.php +++ b/time_edit.php @@ -95,7 +95,7 @@ if ($request->isPost()) { $cl_billable = $time_rec['billable']; // Add an info message to the form if we are editing an uncompleted record. - if (($cl_start == $cl_finish) && ($cl_duration == '0:00')) { + if (strlen($cl_start) > 0 && $cl_start == $cl_finish && $cl_duration == '0:00') { $cl_finish = ''; $cl_duration = ''; $msg->add($i18n->getKey('form.time_edit.uncompleted')); -- 2.20.1