From 6deafabef6031f12fe9fec94d9262ba460f7875b Mon Sep 17 00:00:00 2001 From: anuko Date: Mon, 10 Jul 2017 00:01:34 +0000 Subject: [PATCH] As suggested in PR#33, allowed entry of decimal values with a comma for teams with such delimiter. --- WEB-INF/lib/ttClientHelper.class.php | 2 +- WEB-INF/lib/ttTimeHelper.class.php | 9 ++++++++- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/time.tpl | 2 +- WEB-INF/templates/time_edit.tpl | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/WEB-INF/lib/ttClientHelper.class.php b/WEB-INF/lib/ttClientHelper.class.php index c77dae00..14788ae4 100644 --- a/WEB-INF/lib/ttClientHelper.class.php +++ b/WEB-INF/lib/ttClientHelper.class.php @@ -286,7 +286,7 @@ class ttClientHelper { $sql = "select distinct c.id, c.name, c.projects from tt_user_project_binds upb inner join tt_client_project_binds cpb on (cpb.project_id = upb.project_id) inner join tt_clients c on (c.id = cpb.client_id and c.status = 1) - where upb.user_id = $user_id and upb.status = 1 order by c.name"; + where upb.user_id = $user_id and upb.status = 1 order by upper(c.name)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { diff --git a/WEB-INF/lib/ttTimeHelper.class.php b/WEB-INF/lib/ttTimeHelper.class.php index a2dade9a..13a2d83d 100644 --- a/WEB-INF/lib/ttTimeHelper.class.php +++ b/WEB-INF/lib/ttTimeHelper.class.php @@ -92,7 +92,10 @@ class ttTimeHelper { if (preg_match('/^([0-1]{0,1}[0-9]|2[0-4])h?$/', $value )) { // 0, 1 ... 24 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 + + global $user; + $localizedPattern = '/^([0-1]{0,1}[0-9]|2[0-3])?['.$user->decimal_mark.'][0-9]{1,4}h?$/'; + if (preg_match($localizedPattern, $value )) { // decimal values like 0.5, 1.25h, ... .. 23.9999h (or with comma) return true; } @@ -104,6 +107,10 @@ class ttTimeHelper { $time_value = $value; // If we have a decimal format - convert to time format 00:00. + global $user; + if ($user->decimal_mark == ',') + $time_value = str_replace (',', '.', $time_value); + if((strpos($time_value, '.') !== false) || (strpos($time_value, 'h') !== false)) { $val = floatval($time_value); $mins = round($val * 60); diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 24c305eb..3ea7a01b 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- - + {/if}
 Anuko Time Tracker 1.11.44.3639 | Copyright © Anuko | +  Anuko Time Tracker 1.11.44.3640 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/time.tpl b/WEB-INF/templates/time.tpl index 8328ab41..25fc81c1 100644 --- a/WEB-INF/templates/time.tpl +++ b/WEB-INF/templates/time.tpl @@ -59,7 +59,7 @@ {if (($smarty.const.TYPE_DURATION == $user->record_type) || ($smarty.const.TYPE_ALL == $user->record_type))}
{$i18n.label.duration}:{$forms.timeRecordForm.duration.control} {$i18n.form.time.duration_format}{$forms.timeRecordForm.duration.control} {if $user->decimal_mark == ','}{str_replace('.', ',', $i18n.form.time.duration_format)}{else}{$i18n.form.time.duration_format}{/if}
diff --git a/WEB-INF/templates/time_edit.tpl b/WEB-INF/templates/time_edit.tpl index f6932157..9a13d4c5 100644 --- a/WEB-INF/templates/time_edit.tpl +++ b/WEB-INF/templates/time_edit.tpl @@ -50,7 +50,7 @@ {if (($smarty.const.TYPE_DURATION == $user->record_type) || ($smarty.const.TYPE_ALL == $user->record_type))} {$i18n.label.duration}: - {$forms.timeRecordForm.duration.control} {$i18n.form.time.duration_format} + {$forms.timeRecordForm.duration.control} {if $user->decimal_mark == ','}{str_replace('.', ',', $i18n.form.time.duration_format)}{else}{$i18n.form.time.duration_format}{/if} {/if} -- 2.20.1