var comment_control = document.getElementById("item_name");
var cost_control = document.getElementById("cost");
- var replaceDecimalMark = ("." != "{$user->decimal_mark}");
+ var replaceDecimalMark = ("." != "{$user->getDecimalMark()}");
// Calculate cost.
var dropdown = document.getElementById("predefined_expense");
else {
var expenseCost = defined_expenses[dropdown.selectedIndex - 1][2];
if (replaceDecimalMark)
- expenseCost = expenseCost.replace("{$user->decimal_mark}", ".");
+ expenseCost = expenseCost.replace("{$user->getDecimalMark()}", ".");
var newCost = (quantity_control.value * expenseCost).toFixed(2);
if (replaceDecimalMark)
- newCost = newCost.replace(".", "{$user->decimal_mark}");
+ newCost = newCost.replace(".", "{$user->getDecimalMark()}");
cost_control.value = newCost;
}
}
<td>{$forms.expenseItemForm.client.control}</td>
</tr>
{/if}
-{if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
+{if $show_project}
<tr>
<td align="right">{$i18n.label.project} (*):</td>
<td>{$forms.expenseItemForm.project.control}</td>
</tr>
<tr>
<td align="right">{$i18n.label.cost}:</td>
- <td>{$forms.expenseItemForm.cost.control} {$user->currency|escape}</td>
+ <td>{$forms.expenseItemForm.cost.control} {$user->getCurrency()|escape}</td>
</tr>
<tr>
<td align="right">{$i18n.label.date}:</td>
header('Location: access_denied.php');
exit();
}
+// End of access checks.
$item_date = new DateAndTime(DB_DATEFORMAT, $expense_item['date']);
$confirm_save = $user->getConfigOption('confirm_save');
+$trackingMode = $user->getTrackingMode();
+$show_project = MODE_PROJECTS == $trackingMode || MODE_PROJECTS_AND_TASKS == $trackingMode;
// Initialize variables.
$cl_date = $cl_client = $cl_project = $cl_item_name = $cl_cost = null;
$cl_item_name = trim($request->getParameter('item_name'));
$cl_cost = trim($request->getParameter('cost'));
} else {
- $cl_date = $item_date->toString($user->date_format);
+ $cl_date = $item_date->toString($user->getDateFormat());
$cl_client = $expense_item['client_id'];
$cl_project = $expense_item['project_id'];
$cl_item_name = $expense_item['name'];
$form = new Form('expenseItemForm');
// Dropdown for clients in MODE_TIME. Use all active clients.
-if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) {
+if (MODE_TIME == $trackingMode && $user->isPluginEnabled('cl')) {
$active_clients = ttGroupHelper::getActiveClients(true);
$form->addInput(array('type'=>'combobox',
'onchange'=>'fillProjectDropdown(this.value);',
// Note: in other modes the client list is filtered to relevant clients only. See below.
}
-if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) {
+if ($show_project) {
// Dropdown for projects assigned to user.
$project_list = $user->getAssignedProjects();
$form->addInput(array('type'=>'combobox',
// Validate user input.
if ($user->isPluginEnabled('cl') && $user->isPluginEnabled('cm') && !$cl_client)
$err->add($i18n->get('error.client'));
- if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) {
- if (!$cl_project) $err->add($i18n->get('error.project'));
- }
+ if ($show_project && !$cl_project)
+ $err->add($i18n->get('error.project'));
if (!ttValidString($cl_item_name)) $err->add($i18n->get('error.field'), $i18n->get('label.item'));
if (!ttValidFloat($cl_cost)) $err->add($i18n->get('error.field'), $i18n->get('label.cost'));
if (!ttValidDate($cl_date)) $err->add($i18n->get('error.field'), $i18n->get('label.date'));
// This is a new date for the expense item.
- $new_date = new DateAndTime($user->date_format, $cl_date);
+ $new_date = new DateAndTime($user->getDateFormat(), $cl_date);
// Prohibit creating entries in future.
- if (!$user->future_entries) {
+ if (!$user->getConfigOption('future_entries')) {
$browser_today = new DateAndTime(DB_DATEFORMAT, $request->getParameter('browser_today', null));
if ($new_date->after($browser_today))
$err->add($i18n->get('error.future_date'));
// Now, an update.
if ($err->no()) {
- if (ttExpenseHelper::update(array('id'=>$cl_id,'date'=>$new_date->toString(DB_DATEFORMAT),'user_id'=>$user->getUser(),
+ if (ttExpenseHelper::update(array('id'=>$cl_id,'date'=>$new_date->toString(DB_DATEFORMAT),
'client_id'=>$cl_client,'project_id'=>$cl_project,'name'=>$cl_item_name,'cost'=>$cl_cost))) {
header('Location: expenses.php?date='.$new_date->toString(DB_DATEFORMAT));
exit();
$smarty->assign('confirm_save', true);
$smarty->assign('entry_date', $cl_date);
}
+$smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('show_project', $show_project);
$smarty->assign('predefined_expenses', $predefined_expenses);
$smarty->assign('client_list', $client_list);
$smarty->assign('project_list', $project_list);
$smarty->assign('task_list', $task_list);
-$smarty->assign('forms', array($form->getName()=>$form->toArray()));
$smarty->assign('title', $i18n->get('title.edit_expense'));
$smarty->assign('content_page_name', 'mobile/expense_edit.tpl');
$smarty->display('mobile/index.tpl');