$group_id = $user->getGroup();
$org_id = $user->org_id;
- if ($user->isClient()) $client_part = "and client_id = $user->client_id";
+ if ($user->isClient()) $client_part = "and ts.client_id = $user->client_id";
- $sql = "select * from tt_timesheets".
- " where id = $timesheet_id and group_id = $group_id and org_id = $org_id $client_part and status is not null";
+ $sql = "select ts.id, ts.user_id, u.name as user_name, ts.client_id, c.name as client_name, ts.name from tt_timesheets ts".
+ " left join tt_users u on (u.id = ts.user_id)".
+ " left join tt_clients c on (c.id = ts.client_id)".
+ " where ts.id = $timesheet_id and ts.group_id = $group_id and ts.org_id = $org_id $client_part and ts.status is not null";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
if ($val = $res->fetchRow())
<tr>
<td>
<table border=0 width=100%>
- <tr><td align="center"><b style="font-size: 15pt; font-family: Arial, Helvetica, sans-serif;">{$timesheet_name|escape} </b></td></tr>
- <tr><td align="left"><b>{$i18n.label.date}:</b> {$invoice_date}</td></tr>
- <tr><td align="left"><b>{$i18n.label.client}:</b> {$client_name|escape}</td></tr>
- <tr><td align="left"><b>{$i18n.label.client_address}:</b> {$client_address|escape}</td></tr>
+ <tr><td align="center"><b style="font-size: 15pt; font-family: Arial, Helvetica, sans-serif;">{$timesheet['name']|escape} </b></td></tr>
+ <tr><td align="left"><b>{$i18n.label.user}:</b> {$timesheet['user_name']|escape}</td></tr>
+{if $timesheet['client_id']}
+ <tr><td align="left"><b>{$i18n.label.client}:</b> {$timesheet['client_name']|escape}</td></tr>
+{/if}
</table>
</td>
</tr>
<td>{if $timesheet.submit_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if}</td>
{/if}
{if $show_approval_status}
+ {if $timesheet.approval_status == null}
+ <td></td>
+ {else}
<td>{if $timesheet.approval_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if}</td>
+ {/if}
{/if}
<td><a href="timesheet_view.php?id={$timesheet.id}">{$i18n.label.view}</a></td>
{if !$user->isClient()}
// TODO: add other checks here for timesheet being appropriate for user role.
// End of access checks.
-$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($cl_invoice_id);
-$tax_percent = $client['tax'];
-
-$subtotal = 0;
-$tax = 0;
-foreach($invoice_items as $item)
- $subtotal += $item['cost'];
-if ($tax_percent > 0) {
- $tax_expenses = $user->isPluginEnabled('et');
- foreach($invoice_items as $item) {
- if ($item['type'] == 2 && !$tax_expenses)
- continue;
- $tax += round($item['cost'] * $tax_percent / 100, 2);
- }
-}
-$total = $subtotal + $tax;
+// $timesheet_items = ttTimesheetHelper::getTimesheetItems($timesheet_id);
$currency = $user->getCurrency();
$decimalMark = $user->getDecimalMark();
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
$smarty->assign('invoice_id', $cl_invoice_id);
-$smarty->assign('timesheet_name', $timesheet['name']);
-$smarty->assign('invoice_date', $invoice_date->toString($user->getDateFormat()));
+$smarty->assign('timesheet', $timesheet);
$smarty->assign('client_name', $client['name']);
$smarty->assign('client_address', $client['address']);
$smarty->assign('show_project', MODE_PROJECTS == $trackingMode || MODE_PROJECTS_AND_TASKS == $trackingMode);