getParameter('id'); $invoice = ttInvoiceHelper::getInvoice($invoice_id); $invoice_date = new DateAndTime(DB_DATEFORMAT, $invoice['date']); $client = ttClientHelper::getClient($invoice['client_id'], true); if (!$client) // In case client was deleted. $client = ttClientHelper::getDeletedClient($invoice['client_id']); $invoice_items = ttInvoiceHelper::getInvoiceItems($invoice_id); $tax_percent = $client['tax']; $subtotal = 0; $tax = 0; foreach($invoice_items as $item) $subtotal += $item['cost']; if ($tax_percent) { $tax_expenses = in_array('et', explode(',', $user->plugins)); foreach($invoice_items as $item) { if ($item['type'] == 2 && !$tax_expenses) continue; $tax += round($item['cost'] * $tax_percent / 100, 2); } } $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)))); if ('.' != $user->decimal_mark) { foreach ($invoice_items as &$item) $item['cost'] = str_replace('.', $user->decimal_mark, $item['cost']); } // Calculate colspan for invoice summary. $colspan = 4; if (MODE_PROJECTS == $user->tracking_mode) $colspan++; else if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) $colspan += 2; $smarty->assign('invoice_id', $invoice_id); $smarty->assign('invoice_name', $invoice['name']); $smarty->assign('invoice_date', $invoice_date->toString($user->date_format)); $smarty->assign('client_name', $client['name']); $smarty->assign('client_address', $client['address']); $smarty->assign('invoice_items', $invoice_items); $smarty->assign('colspan', $colspan); $smarty->assign('title', $i18n->getKey('title.view_invoice')); $smarty->assign('content_page_name', 'invoice_view.tpl'); $smarty->display('index.tpl'); ?>