From: Nik Okuntseff Date: Thu, 21 Feb 2019 14:13:34 +0000 (+0000) Subject: A bit more work in progress on timesheet view. X-Git-Tag: timetracker_1.19-1~300 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=bc06bc6aacd3a6ecde7d55980a2702809fc26c49;p=timetracker.git A bit more work in progress on timesheet view. --- diff --git a/WEB-INF/lib/ttTimesheetHelper.class.php b/WEB-INF/lib/ttTimesheetHelper.class.php index 056fc685..49808359 100644 --- a/WEB-INF/lib/ttTimesheetHelper.class.php +++ b/WEB-INF/lib/ttTimesheetHelper.class.php @@ -212,10 +212,12 @@ class ttTimesheetHelper { $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()) diff --git a/WEB-INF/templates/timesheet_view.tpl b/WEB-INF/templates/timesheet_view.tpl index 736d65b0..79ce95a3 100644 --- a/WEB-INF/templates/timesheet_view.tpl +++ b/WEB-INF/templates/timesheet_view.tpl @@ -6,10 +6,11 @@ - - - - + + +{if $timesheet['client_id']} + +{/if}
{$timesheet_name|escape}
{$i18n.label.date}: {$invoice_date}
{$i18n.label.client}: {$client_name|escape}
{$i18n.label.client_address}: {$client_address|escape}
{$timesheet['name']|escape}
{$i18n.label.user}: {$timesheet['user_name']|escape}
{$i18n.label.client}: {$timesheet['client_name']|escape}
diff --git a/WEB-INF/templates/timesheets.tpl b/WEB-INF/templates/timesheets.tpl index dc5c8155..845a94f2 100644 --- a/WEB-INF/templates/timesheets.tpl +++ b/WEB-INF/templates/timesheets.tpl @@ -40,7 +40,11 @@ {if $timesheet.submit_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if} {/if} {if $show_approval_status} + {if $timesheet.approval_status == null} + + {else} {if $timesheet.approval_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if} + {/if} {/if} {$i18n.label.view} {if !$user->isClient()} diff --git a/timesheet_view.php b/timesheet_view.php index 136c7f11..5cbd3cfc 100644 --- a/timesheet_view.php +++ b/timesheet_view.php @@ -47,27 +47,7 @@ if (!$timesheet) { // 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(); @@ -118,8 +98,7 @@ if ($request->isPost()) { $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);