static function get($id)
{
global $user;
+ $replaceDecimalMark = ('.' != $user->decimal_mark);
$mdb2 = getConnection();
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
$val = $res->fetchRow();
- if ($val && $val['id'])
+ if ($val && $val['id']) {
+ if ($replaceDecimalMark)
+ $val['cost'] = str_replace('.', $user->decimal_mark, $val['cost']);
return $val;
+ }
}
return false;
}
// insert function inserts a new predefined expense into database.
static function insert($fields)
{
+ global $user;
+
$mdb2 = getConnection();
$team_id = (int) $fields['team_id'];
$name = $fields['name'];
$cost = $fields['cost'];
+ if ('.' != $user->decimal_mark)
+ $cost = str_replace($user->decimal_mark, '.', $cost);
$sql = "insert into tt_predefined_expenses (team_id, name, cost)
values ($team_id, ".$mdb2->quote($name).", ".$mdb2->quote($cost).")";
// update function - updates a predefined expense in database.
static function update($fields)
{
+ global $user;
+
$mdb2 = getConnection();
$predefined_expense_id = (int) $fields['id'];
$team_id = (int) $fields['team_id'];
$name = $fields['name'];
$cost = $fields['cost'];
+ if ('.' != $user->decimal_mark)
+ $cost = str_replace($user->decimal_mark, '.', $cost);
$sql = "update tt_predefined_expenses set name = ".$mdb2->quote($name).", cost = ".$mdb2->quote($cost).
" where id = $predefined_expense_id and team_id = $team_id";
// getProjects - returns an array of active and inactive projects in a team.
static function getProjects()
{
- global $user;
-
- $result = array();
+ global $user;
+
+ $result = array();
$mdb2 = getConnection();
$sql = "select id, name, tasks from tt_projects
// getPredefinedExpenses - obtains predefined expenses for team.
static function getPredefinedExpenses($team_id) {
+ global $user;
+ $replaceDecimalMark = ('.' != $user->decimal_mark);
+
$mdb2 = getConnection();
$result = array();
$result = array();
if (!is_a($res, 'PEAR_Error')) {
while ($val = $res->fetchRow()) {
+ if ($replaceDecimalMark)
+ $val['cost'] = str_replace('.', $user->decimal_mark, $val['cost']);
$result[] = $val;
}
return $result;
var comment_control = document.getElementById("item_name");
var cost_control = document.getElementById("cost");
+ var replaceDecimalMark = ("." != "{$user->decimal_mark}");
// Calculate cost.
var dropdown = document.getElementById("predefined_expense");
var quantity = quantity_control.value;
if (isNaN(quantity))
cost_control.value = "";
- else
- cost_control.value = (quantity_control.value * defined_expenses[dropdown.selectedIndex - 1][2]).toFixed(2);
+ else {
+ var expenseCost = defined_expenses[dropdown.selectedIndex - 1][2];
+ if (replaceDecimalMark)
+ expenseCost = expenseCost.replace("{$user->decimal_mark}", ".");
+ var newCost = (quantity_control.value * expenseCost).toFixed(2);
+ if (replaceDecimalMark)
+ newCost = newCost.replace(".", "{$user->decimal_mark}");
+ cost_control.value = newCost;
+ }
}
}
</script>
var comment_control = document.getElementById("item_name");
var cost_control = document.getElementById("cost");
+ var replaceDecimalMark = ("." != "{$user->decimal_mark}");
// Calculate cost.
var dropdown = document.getElementById("predefined_expense");
var quantity = quantity_control.value;
if (isNaN(quantity))
cost_control.value = "";
- else
- cost_control.value = (quantity_control.value * defined_expenses[dropdown.selectedIndex - 1][2]).toFixed(2);
+ else {
+ var expenseCost = defined_expenses[dropdown.selectedIndex - 1][2];
+ if (replaceDecimalMark)
+ expenseCost = expenseCost.replace("{$user->decimal_mark}", ".");
+ var newCost = (quantity_control.value * expenseCost).toFixed(2);
+ if (replaceDecimalMark)
+ newCost = newCost.replace(".", "{$user->decimal_mark}");
+ cost_control.value = newCost;
+ }
}
}
</script>
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.13.10.3730 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.13.11.3731 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>