X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=invoice_view.php;h=605a5302027b0e85501ba651969d84ff3b70561f;hb=be5e813f87f627d207c8d2606da4c9fea1fe36a8;hp=22383c0265523332ff03b57b8b328981340f9a09;hpb=cc1f9442f83ebfa3a67b917548ffd70cdba7bc9a;p=timetracker.git diff --git a/invoice_view.php b/invoice_view.php index 22383c02..605a5302 100644 --- a/invoice_view.php +++ b/invoice_view.php @@ -33,7 +33,7 @@ import('ttClientHelper'); import('form.Form'); // Access checks. -if (!(ttAccessAllowed('manage_invoices') || ttAccessAllowed('view_own_invoices'))) { +if (!(ttAccessAllowed('manage_invoices') || ttAccessAllowed('view_client_invoices'))) { header('Location: access_denied.php'); exit(); } @@ -61,7 +61,7 @@ $subtotal = 0; $tax = 0; foreach($invoice_items as $item) $subtotal += $item['cost']; -if ($tax_percent) { +if ($tax_percent > 0) { $tax_expenses = $user->isPluginEnabled('et'); foreach($invoice_items as $item) { if ($item['type'] == 2 && !$tax_expenses) @@ -69,22 +69,26 @@ if ($tax_percent) { $tax += round($item['cost'] * $tax_percent / 100, 2); } } -$total = $subtotal + $tax; +$total = $subtotal + $tax; -$smarty->assign('subtotal', $user->currency.' '.str_replace('.', $user->decimal_mark, sprintf('%8.2f', round($subtotal, 2)))); -if ($tax) $smarty->assign('tax', $user->currency.' '.str_replace('.', $user->decimal_mark, sprintf('%8.2f', round($tax, 2)))); -$smarty->assign('total', $user->currency.' '.str_replace('.', $user->decimal_mark, sprintf('%8.2f', round($total, 2)))); +$currency = $user->getCurrency(); +$decimalMark = $user->getDecimalMark(); -if ('.' != $user->decimal_mark) { +$smarty->assign('subtotal', $currency.' '.str_replace('.', $decimalMark, sprintf('%8.2f', round($subtotal, 2)))); +if ($tax) $smarty->assign('tax', $currency.' '.str_replace('.', $decimalMark, sprintf('%8.2f', round($tax, 2)))); +$smarty->assign('total', $currency.' '.str_replace('.', $decimalMark, sprintf('%8.2f', round($total, 2)))); + +if ('.' != $decimalMark) { foreach ($invoice_items as &$item) - $item['cost'] = str_replace('.', $user->decimal_mark, $item['cost']); + $item['cost'] = str_replace('.', $decimalMark, $item['cost']); } // Calculate colspan for invoice summary. $colspan = 4; -if (MODE_PROJECTS == $user->tracking_mode) +$trackingMode = $user->getTrackingMode(); +if (MODE_PROJECTS == $trackingMode) $colspan++; -elseif (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) +elseif (MODE_PROJECTS_AND_TASKS == $trackingMode) $colspan += 2; $form = new Form('invoiceForm'); @@ -117,9 +121,11 @@ if ($request->isPost()) { $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('invoice_id', $cl_invoice_id); $smarty->assign('invoice_name', $invoice['name']); -$smarty->assign('invoice_date', $invoice_date->toString($user->date_format)); +$smarty->assign('invoice_date', $invoice_date->toString($user->getDateFormat())); $smarty->assign('client_name', $client['name']); $smarty->assign('client_address', $client['address']); +$smarty->assign('show_project', MODE_PROJECTS == $trackingMode || MODE_PROJECTS_AND_TASKS == $trackingMode); +$smarty->assign('show_task', MODE_PROJECTS_AND_TASKS == $trackingMode); $smarty->assign('invoice_items', $invoice_items); $smarty->assign('colspan', $colspan); $smarty->assign('title', $i18n->get('title.view_invoice'));