X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=WEB-INF%2Ftemplates%2Fmobile%2Fexpenses.tpl;h=7afde73d27b3d1f28c5f72bdc71986eee2d601e9;hb=0c4f2c49ae759b4f4f9b5002d0a413f89b6498e6;hp=a4a384789058c5bf187314b41ce6b31f5e996f23;hpb=6856837ddde5cc90ac5dad2e5d67204036ec3158;p=timetracker.git
diff --git a/WEB-INF/templates/mobile/expenses.tpl b/WEB-INF/templates/mobile/expenses.tpl
index a4a38478..7afde73d 100644
--- a/WEB-INF/templates/mobile/expenses.tpl
+++ b/WEB-INF/templates/mobile/expenses.tpl
@@ -26,6 +26,14 @@ projects = new Array();
// Mandatory top option for project dropdown.
empty_label_project = '{$i18n.dropdown.select|escape:'javascript'}';
+// Prepare an array of predefined expenses.
+idx = 0;
+var defined_expenses = new Array();
+{foreach $predefined_expenses as $predefined_expense}
+ defined_expenses[idx] = new Array("{$predefined_expense.id}", "{$predefined_expense.name|escape:'javascript'}", "{$predefined_expense.cost}");
+ idx++;
+{/foreach}
+
// The fillProjectDropdown function populates the project combo box with
// projects associated with a selected client (client id is passed here as id).
function fillProjectDropdown(id) {
@@ -66,6 +74,42 @@ function get_date() {
var date = new Date();
return date.strftime("%Y-%m-%d");
}
+
+// The recalculateCost function recalculates cost based on the current selection
+// of predefined expense and quantity and also changes the comment accordingly.
+function recalculateCost() {
+ var quantity_control = document.getElementById("quantity");
+ // Set quantity to 1 if it is not set already.
+ if (!quantity_control.value) {
+ quantity_control.value = "1";
+ }
+
+ var comment_control = document.getElementById("item_name");
+ var cost_control = document.getElementById("cost");
+ var replaceDecimalMark = ("." != "{$user->getDecimalMark()}");
+
+ // Calculate cost.
+ var dropdown = document.getElementById("predefined_expense");
+ if (dropdown.selectedIndex == 0) {
+ quantity_control.value = "";
+ comment_control.value = "";
+ cost_control.value = "";
+ } else {
+ comment_control.value = defined_expenses[dropdown.selectedIndex - 1][1] + " - " + quantity_control.value;
+ var quantity = quantity_control.value;
+ if (isNaN(quantity))
+ cost_control.value = "";
+ else {
+ var expenseCost = defined_expenses[dropdown.selectedIndex - 1][2];
+ if (replaceDecimalMark)
+ expenseCost = expenseCost.replace("{$user->getDecimalMark()}", ".");
+ var newCost = (quantity_control.value * expenseCost).toFixed(2);
+ if (replaceDecimalMark)
+ newCost = newCost.replace(".", "{$user->getDecimalMark()}");
+ cost_control.value = newCost;
+ }
+ }
+}
@@ -82,10 +126,10 @@ function get_date() {
-{if $on_behalf_control}
+{if $user_dropdown}
{$i18n.label.user}: |
- {$forms.expensesForm.onBehalfUser.control} |
+ {$forms.expensesForm.user.control} |
{/if}
{if $user->isPluginEnabled('cl')}
@@ -94,11 +138,21 @@ function get_date() {
{$forms.expensesForm.client.control} |
{/if}
-{if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
+{if $show_project}
{$i18n.label.project} (*): |
{$forms.expensesForm.project.control} |
+{/if}
+{if $predefined_expenses}
+
+ {$i18n.label.expense}: |
+ {$forms.expensesForm.predefined_expense.control} |
+
+
+ {$i18n.label.quantity}: |
+ {$forms.expensesForm.quantity.control} |
+
{/if}
{$i18n.label.item} (*): |
@@ -106,7 +160,7 @@ function get_date() {
{$i18n.label.cost} (*): |
- {$forms.expensesForm.cost.control} {$user->currency|escape} |
+ {$forms.expensesForm.cost.control} {$user->getCurrency()|escape} |
|
@@ -135,7 +189,7 @@ function get_date() {
{if $user->isPluginEnabled('cl')}
{/if}
- {if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
+ {if $show_project}
{/if}
@@ -146,17 +200,23 @@ function get_date() {
{if $user->isPluginEnabled('cl')}
{$item.client|escape} |
{/if}
- {if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
+ {if $show_project}
{$item.project|escape} |
{/if}
- {if $item.invoice_id} {$item.item|escape} {else}{$item.item|escape}{/if} |
+
+ {if $item.approved || $item.invoice_id}
+ {$item.item|escape}
+ {else}
+ {$item.item|escape}
+ {/if}
+ |
{$item.cost} |
{/foreach}
- {$i18n.label.day_total}: {$user->currency|escape} {$day_total} |
+ {$i18n.label.day_total}: {$user->getCurrency()|escape} {$day_total} |
{/if}