From: Nik Okuntseff Date: Wed, 5 Dec 2018 21:10:40 +0000 (+0000) Subject: Finished refactoring mobile expense pages for subgroups. X-Git-Tag: timetracker_1.19-1~470 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=bfc14fc0033335223de2268ecbd9c7a3e8d8aa21;p=timetracker.git Finished refactoring mobile expense pages for subgroups. --- diff --git a/WEB-INF/templates/expense_delete.tpl b/WEB-INF/templates/expense_delete.tpl index e2c1b671..6e5bf12c 100644 --- a/WEB-INF/templates/expense_delete.tpl +++ b/WEB-INF/templates/expense_delete.tpl @@ -16,7 +16,7 @@ {if $user->isPluginEnabled('cl')} - {$expense_item.client_name|escape} + {$expense_item.client_name|escape} {/if} {if $show_project} {$expense_item.project_name|escape} diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 14d272ea..b2cdebb7 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- {if $user->isPluginEnabled('cl')} - + {/if} {if $show_project} diff --git a/WEB-INF/templates/mobile/expense_edit.tpl b/WEB-INF/templates/mobile/expense_edit.tpl index 97140507..708cc23c 100644 --- a/WEB-INF/templates/mobile/expense_edit.tpl +++ b/WEB-INF/templates/mobile/expense_edit.tpl @@ -98,7 +98,7 @@ function recalculateCost() { 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"); @@ -114,10 +114,10 @@ function recalculateCost() { 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; } } @@ -138,7 +138,7 @@ function recalculateCost() { {/if} -{if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)} +{if $show_project} @@ -160,7 +160,7 @@ function recalculateCost() { - + diff --git a/mobile/expense_edit.php b/mobile/expense_edit.php index 0f657973..4c183afd 100644 --- a/mobile/expense_edit.php +++ b/mobile/expense_edit.php @@ -49,9 +49,12 @@ if (!$expense_item || $expense_item['invoice_id']) { 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; @@ -62,7 +65,7 @@ if ($request->isPost()) { $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']; @@ -73,7 +76,7 @@ if ($request->isPost()) { $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);', @@ -86,7 +89,7 @@ if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { // 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', @@ -153,18 +156,17 @@ if ($request->isPost()) { // 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')); @@ -187,7 +189,7 @@ if ($request->isPost()) { // 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(); @@ -222,11 +224,12 @@ if ($confirm_save) { $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');
 Anuko Time Tracker 1.18.29.4594 | Copyright © Anuko | +  Anuko Time Tracker 1.18.29.4595 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/mobile/expense_delete.tpl b/WEB-INF/templates/mobile/expense_delete.tpl index cbd75aed..bd14824e 100644 --- a/WEB-INF/templates/mobile/expense_delete.tpl +++ b/WEB-INF/templates/mobile/expense_delete.tpl @@ -16,7 +16,7 @@
{$expense_item.client_name|escape}{$expense_item.client_name|escape}{$expense_item.project_name|escape}{$forms.expenseItemForm.client.control}
{$i18n.label.project} (*): {$forms.expenseItemForm.project.control}
{$i18n.label.cost}:{$forms.expenseItemForm.cost.control} {$user->currency|escape}{$forms.expenseItemForm.cost.control} {$user->getCurrency()|escape}
{$i18n.label.date}: