From: Nik Okuntseff Date: Fri, 22 Feb 2019 21:38:50 +0000 (+0000) Subject: More progress on timesheet approval workflow. X-Git-Tag: timetracker_1.19-1~295 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=8fd871c1242b3309b8a374a97969ab74d5375069;p=timetracker.git More progress on timesheet approval workflow. --- diff --git a/WEB-INF/lib/ttTimesheetHelper.class.php b/WEB-INF/lib/ttTimesheetHelper.class.php index 0d4556bc..df1e4e48 100644 --- a/WEB-INF/lib/ttTimesheetHelper.class.php +++ b/WEB-INF/lib/ttTimesheetHelper.class.php @@ -215,7 +215,7 @@ class ttTimesheetHelper { if ($user->isClient()) $client_part = "and ts.client_id = $user->client_id"; $sql = "select ts.id, ts.user_id, u.name as user_name, ts.client_id, c.name as client_name,". - " ts.name, ts.submitter_comment, ts.submit_status from tt_timesheets ts". + " ts.name, ts.submitter_comment, ts.submit_status, ts.approval_status, ts.manager_comment 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"; @@ -346,4 +346,27 @@ class ttTimesheetHelper { } return $approvers; } + + // submitTimesheet marks a timesheet as submitted and sends an email to an approver. + static function submitTimesheet($fields) { + global $user; + $mdb2 = getConnection(); + + $group_id = $user->getGroup(); + $org_id = $user->org_id; + + // First, mark a timesheet as submitted. + // Even if mail part below does not work, this will get us a functioning workflow + // (without email notifications). + $timesheet_id = $fields['timesheet_id']; + $sql = "update tt_timesheets set submit_status = 1". + " where id = $timesheet_id and group_id = $group_id and org_id = $org_id"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) return false; + + // TODO: send email to approver here... + // $approver_id = $fields['approver_id']; + + return true; + } } diff --git a/WEB-INF/resources/ca.lang.php b/WEB-INF/resources/ca.lang.php index 6dd031c2..4830b0e7 100644 --- a/WEB-INF/resources/ca.lang.php +++ b/WEB-INF/resources/ca.lang.php @@ -151,6 +151,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'button.close' => 'Close', // 'button.stop' => 'Stop', +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. // TODO: translate the following. diff --git a/WEB-INF/resources/cs.lang.php b/WEB-INF/resources/cs.lang.php index 771a0f29..9cbdba5e 100644 --- a/WEB-INF/resources/cs.lang.php +++ b/WEB-INF/resources/cs.lang.php @@ -153,6 +153,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'button.close' => 'Close', // 'button.stop' => 'Stop', +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. // TODO: translate the following. diff --git a/WEB-INF/resources/da.lang.php b/WEB-INF/resources/da.lang.php index 702958d4..1d39ffbf 100644 --- a/WEB-INF/resources/da.lang.php +++ b/WEB-INF/resources/da.lang.php @@ -144,6 +144,9 @@ $i18n_key_words = array( 'button.import' => 'Importer team', // TODO: replace "team" with "group". 'button.close' => 'Luk', 'button.stop' => 'Stop', +// TODO: translate the following. +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. 'label.group_name' => 'Team navn', // TODO: replace "team" with "group". diff --git a/WEB-INF/resources/de.lang.php b/WEB-INF/resources/de.lang.php index 257ab7e9..6a967bd4 100644 --- a/WEB-INF/resources/de.lang.php +++ b/WEB-INF/resources/de.lang.php @@ -138,6 +138,9 @@ $i18n_key_words = array( 'button.import' => 'Gruppe importieren', 'button.close' => 'Schließen', 'button.stop' => 'Stop', +// TODO: translate the following. +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. 'label.group_name' => 'Gruppenname', diff --git a/WEB-INF/resources/en.lang.php b/WEB-INF/resources/en.lang.php index 7621a83d..0534e60b 100644 --- a/WEB-INF/resources/en.lang.php +++ b/WEB-INF/resources/en.lang.php @@ -131,6 +131,8 @@ $i18n_key_words = array( 'button.import' => 'Import group', 'button.close' => 'Close', 'button.stop' => 'Stop', +'button.approve' => 'Approve', +'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. 'label.group_name' => 'Group name', diff --git a/WEB-INF/resources/es.lang.php b/WEB-INF/resources/es.lang.php index 19a8ed51..02d62154 100644 --- a/WEB-INF/resources/es.lang.php +++ b/WEB-INF/resources/es.lang.php @@ -150,6 +150,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'button.close' => 'Close', // 'button.stop' => 'Stop', +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. // TODO: translate the following. diff --git a/WEB-INF/resources/et.lang.php b/WEB-INF/resources/et.lang.php index 170c447a..a5b4319c 100644 --- a/WEB-INF/resources/et.lang.php +++ b/WEB-INF/resources/et.lang.php @@ -152,6 +152,10 @@ $i18n_key_words = array( 'button.import' => 'Impordi grupp', 'button.close' => 'Sulge', 'button.stop' => 'Stopp', +// TODO: translate the following. +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', + // Labels for controls on forms. Labels in this section are used on multiple forms. 'label.group_name' => 'Grupi nimi', diff --git a/WEB-INF/resources/fa.lang.php b/WEB-INF/resources/fa.lang.php index 783a1b5a..e4983f40 100644 --- a/WEB-INF/resources/fa.lang.php +++ b/WEB-INF/resources/fa.lang.php @@ -151,6 +151,9 @@ $i18n_key_words = array( 'button.import' => 'وارد کردن تیم', // TODO: replace "team" with "group". 'button.close' => 'بستن', 'button.stop' => 'توقف', +// TODO: translate the following. +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. 'label.group_name' => 'نام تیم', // TODO: replace "team" with "group". diff --git a/WEB-INF/resources/fi.lang.php b/WEB-INF/resources/fi.lang.php index 175c993e..2dc50b61 100644 --- a/WEB-INF/resources/fi.lang.php +++ b/WEB-INF/resources/fi.lang.php @@ -146,6 +146,9 @@ $i18n_key_words = array( 'button.import' => 'Tuo tiimi', // TODO: replace "team" with "group". 'button.close' => 'Sulje', 'button.stop' => 'Lopeta', +// TODO: translate the following. +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. 'label.group_name' => 'Tiimin nimi', // TODO: replace "team" with "group". diff --git a/WEB-INF/resources/fr.lang.php b/WEB-INF/resources/fr.lang.php index 9d7a7c7e..a26bba75 100644 --- a/WEB-INF/resources/fr.lang.php +++ b/WEB-INF/resources/fr.lang.php @@ -144,6 +144,9 @@ $i18n_key_words = array( 'button.import' => 'Importer une équipe', // TODO: replace "team" with "group". 'button.close' => 'Fermer', 'button.stop' => 'Arrêter', +// TODO: translate the following. +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. 'label.group_name' => 'Nom équipe', // TODO: replace "team" with "group". diff --git a/WEB-INF/resources/gr.lang.php b/WEB-INF/resources/gr.lang.php index 9e22079e..0159ff29 100644 --- a/WEB-INF/resources/gr.lang.php +++ b/WEB-INF/resources/gr.lang.php @@ -139,6 +139,9 @@ $i18n_key_words = array( 'button.import' => 'Εισαγωγή ομάδας', 'button.close' => 'Κλείσιμο', 'button.stop' => 'Τέλος', +// TODO: translate the following. +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. 'label.group_name' => 'Όνομα ομάδας', diff --git a/WEB-INF/resources/he.lang.php b/WEB-INF/resources/he.lang.php index 3418d106..ab5d1b02 100644 --- a/WEB-INF/resources/he.lang.php +++ b/WEB-INF/resources/he.lang.php @@ -161,6 +161,9 @@ $i18n_key_words = array( 'button.import' => 'ייבא צוות', // TODO: replace "team" with "group". 'button.close' => 'סגור', 'button.stop' => 'עצור', +// TODO: translate the following. +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. 'label.group_name' => 'שם הצוות', // TODO: replace "team" with "group". diff --git a/WEB-INF/resources/hu.lang.php b/WEB-INF/resources/hu.lang.php index 9157dd68..521b42e5 100644 --- a/WEB-INF/resources/hu.lang.php +++ b/WEB-INF/resources/hu.lang.php @@ -152,6 +152,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'button.close' => 'Close', // 'button.stop' => 'Stop', +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. // TODO: translate the following. diff --git a/WEB-INF/resources/it.lang.php b/WEB-INF/resources/it.lang.php index 51768b0d..ca39ee64 100644 --- a/WEB-INF/resources/it.lang.php +++ b/WEB-INF/resources/it.lang.php @@ -143,6 +143,9 @@ $i18n_key_words = array( 'button.import' => 'Importa gruppo', 'button.close' => 'Chiudi', 'button.stop' => 'Stop', +// TODO: translate the following. +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. 'label.group_name' => 'Nome del gruppo', diff --git a/WEB-INF/resources/ja.lang.php b/WEB-INF/resources/ja.lang.php index e19c4a4b..f85d3ef1 100644 --- a/WEB-INF/resources/ja.lang.php +++ b/WEB-INF/resources/ja.lang.php @@ -156,6 +156,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'button.close' => 'Close', // 'button.stop' => 'Stop', +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. // TODO: translate the following. diff --git a/WEB-INF/resources/ko.lang.php b/WEB-INF/resources/ko.lang.php index 3999a097..ba9b4e02 100644 --- a/WEB-INF/resources/ko.lang.php +++ b/WEB-INF/resources/ko.lang.php @@ -155,6 +155,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'button.close' => 'Close', // 'button.stop' => 'Stop', +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. // TODO: translate the following. diff --git a/WEB-INF/resources/nl.lang.php b/WEB-INF/resources/nl.lang.php index 58fdd720..a416da5e 100644 --- a/WEB-INF/resources/nl.lang.php +++ b/WEB-INF/resources/nl.lang.php @@ -132,6 +132,9 @@ $i18n_key_words = array( 'button.import' => 'Groep importeren', 'button.close' => 'Sluiten', 'button.stop' => 'Stop', +// TODO: translate the following. +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. 'label.group_name' => 'Groepsnaam', diff --git a/WEB-INF/resources/no.lang.php b/WEB-INF/resources/no.lang.php index 1a88ce30..3973be83 100644 --- a/WEB-INF/resources/no.lang.php +++ b/WEB-INF/resources/no.lang.php @@ -156,6 +156,8 @@ $i18n_key_words = array( 'button.close' => 'Lukk', // TODO: translate the following. // 'button.stop' => 'Stop', +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. // TODO: translate the following. diff --git a/WEB-INF/resources/pl.lang.php b/WEB-INF/resources/pl.lang.php index 8af61cf8..0b867ff3 100644 --- a/WEB-INF/resources/pl.lang.php +++ b/WEB-INF/resources/pl.lang.php @@ -148,6 +148,9 @@ $i18n_key_words = array( 'button.import' => 'Importuj zespół', // TODO: replace "team" with "group". 'button.close' => 'Zamknij', 'button.stop' => 'Zatrzymaj', +// TODO: translate the following. +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. 'label.group_name' => 'Nazwa zespołu', // TODO: replace "team" with "group". diff --git a/WEB-INF/resources/pt-br.lang.php b/WEB-INF/resources/pt-br.lang.php index 018c7717..3a48decc 100644 --- a/WEB-INF/resources/pt-br.lang.php +++ b/WEB-INF/resources/pt-br.lang.php @@ -145,6 +145,9 @@ $i18n_key_words = array( 'button.import' => 'Importar equipe', // TODO: replace "team" with "group". 'button.close' => 'Fechar', 'button.stop' => 'Parar', +// TODO: translate the following. +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. 'label.group_name' => 'Nome da equipe', // TODO: replace "team" with "group". diff --git a/WEB-INF/resources/pt.lang.php b/WEB-INF/resources/pt.lang.php index d8f1611c..6ee9363b 100644 --- a/WEB-INF/resources/pt.lang.php +++ b/WEB-INF/resources/pt.lang.php @@ -148,6 +148,8 @@ $i18n_key_words = array( // 'button.import' => 'Import group', // 'button.close' => 'Close', // 'button.stop' => 'Stop', +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. // TODO: translate the following. diff --git a/WEB-INF/resources/ro.lang.php b/WEB-INF/resources/ro.lang.php index 47ae568c..f2bd2e95 100644 --- a/WEB-INF/resources/ro.lang.php +++ b/WEB-INF/resources/ro.lang.php @@ -156,6 +156,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'button.close' => 'Close', // 'button.stop' => 'Stop', +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. // TODO: translate the following. diff --git a/WEB-INF/resources/ru.lang.php b/WEB-INF/resources/ru.lang.php index 97cab56c..b30765a0 100644 --- a/WEB-INF/resources/ru.lang.php +++ b/WEB-INF/resources/ru.lang.php @@ -130,6 +130,8 @@ $i18n_key_words = array( 'button.import' => 'Импортировать группу', 'button.close' => 'Закрыть', 'button.stop' => 'Завершить', +'button.approve' => 'Одобрить', +'button.disapprove' => 'Не одобрить', // Labels for controls on forms. Labels in this section are used on multiple forms. 'label.group_name' => 'Название группы', diff --git a/WEB-INF/resources/sk.lang.php b/WEB-INF/resources/sk.lang.php index fa0df1d5..f6a0a068 100644 --- a/WEB-INF/resources/sk.lang.php +++ b/WEB-INF/resources/sk.lang.php @@ -152,6 +152,8 @@ $i18n_key_words = array( 'button.close' => 'Zatvoriť', // TODO: translate the following. // 'button.stop' => 'Stop', +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. 'label.group_name' => 'Názov tímu', // TODO: replace "team" with "group". diff --git a/WEB-INF/resources/sl.lang.php b/WEB-INF/resources/sl.lang.php index 620a8b84..0e602e42 100644 --- a/WEB-INF/resources/sl.lang.php +++ b/WEB-INF/resources/sl.lang.php @@ -146,6 +146,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'button.close' => 'Close', // 'button.stop' => 'Stop', +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. // TODO: translate the following. diff --git a/WEB-INF/resources/sr.lang.php b/WEB-INF/resources/sr.lang.php index 8163a808..cfc2dac5 100644 --- a/WEB-INF/resources/sr.lang.php +++ b/WEB-INF/resources/sr.lang.php @@ -145,6 +145,9 @@ $i18n_key_words = array( 'button.import' => 'Uvezi tim', // TODO: replace "team" with "group". 'button.close' => 'Zatvori', 'button.stop' => 'Stani', +// TODO: translate the following. +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. 'label.group_name' => 'Naziv tim-a', // TODO: replace "team" with "group". diff --git a/WEB-INF/resources/sv.lang.php b/WEB-INF/resources/sv.lang.php index 8ddf01ad..24072b0e 100644 --- a/WEB-INF/resources/sv.lang.php +++ b/WEB-INF/resources/sv.lang.php @@ -143,6 +143,9 @@ $i18n_key_words = array( 'button.import' => 'Importera grupp', 'button.close' => 'Stäng', 'button.stop' => 'Avsluta', +// TODO: translate the following. +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. 'label.group_name' => 'Namn på grupp', diff --git a/WEB-INF/resources/tr.lang.php b/WEB-INF/resources/tr.lang.php index 4f82410f..cccf336c 100644 --- a/WEB-INF/resources/tr.lang.php +++ b/WEB-INF/resources/tr.lang.php @@ -159,6 +159,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'button.close' => 'Close', // 'button.stop' => 'Stop', +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. // TODO: translate the following. diff --git a/WEB-INF/resources/zh-cn.lang.php b/WEB-INF/resources/zh-cn.lang.php index 41e4acdf..6f4f6389 100644 --- a/WEB-INF/resources/zh-cn.lang.php +++ b/WEB-INF/resources/zh-cn.lang.php @@ -147,6 +147,8 @@ $i18n_key_words = array( 'button.close' => '关闭', // TODO: translate the following. // 'button.stop' => 'Stop', +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. 'label.group_name' => '团队名称', // TODO: replace "team" with "group". diff --git a/WEB-INF/resources/zh-tw.lang.php b/WEB-INF/resources/zh-tw.lang.php index 5e582399..49bfb85d 100644 --- a/WEB-INF/resources/zh-tw.lang.php +++ b/WEB-INF/resources/zh-tw.lang.php @@ -152,6 +152,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'button.close' => 'Close', // 'button.stop' => 'Stop', +// 'button.approve' => 'Approve', +// 'button.disapprove' => 'Disapprove', // Labels for controls on forms. Labels in this section are used on multiple forms. // TODO: translate the following. diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index a84e3246..71d49f2e 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- {/if} + {if $timesheet['submit_status']} + {/if} + {/if} + {if $timesheet['manager_comment']} + + {/if} {/if}
 Anuko Time Tracker 1.18.37.4752 | Copyright © Anuko | +  Anuko Time Tracker 1.18.37.4753 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/timesheet_view.tpl b/WEB-INF/templates/timesheet_view.tpl index c22df7ac..17114439 100644 --- a/WEB-INF/templates/timesheet_view.tpl +++ b/WEB-INF/templates/timesheet_view.tpl @@ -16,6 +16,12 @@ {if $timesheet['submitter_comment']}
{$i18n.label.comment}: {$timesheet['submitter_comment']|escape}
{$i18n.label.approved}: {if $timesheet.approval_status != null}{if $timesheet.approval_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if}
{$i18n.label.note}: {$timesheet['manager_comment']|escape}
@@ -42,6 +48,32 @@ {$user->currency|escape} {if $user->can('manage_invoices') || $user->isClient()}{$totals['cost']}{else}{$totals['expenses']}{/if} + +{$forms.timesheetForm.open} + {if $show_submit} + + + + +
+ + +
{$i18n.form.mail.to}: {$forms.timesheetForm.approver.control} {$forms.timesheetForm.btn_submit.control}
+
+ {/if} + {if $show_approve} + + + + +
+ + +
{$forms.timesheetForm.btn_approve.control} {$forms.timesheetForm.btn_disapprove.control}
+
+ {/if} +{$forms.timesheetForm.close} + diff --git a/timesheet_view.php b/timesheet_view.php index bd97a52a..0e9a7ea9 100644 --- a/timesheet_view.php +++ b/timesheet_view.php @@ -45,6 +45,7 @@ if (!$timesheet) { exit(); } // TODO: add other checks here for timesheet being appropriate for user role. +// TODO: if this is a timeheet submit, validate approver id, too. // End of access checks. $options = ttTimesheetHelper::getReportOptions($timesheet); @@ -52,14 +53,54 @@ $subtotals = ttReportHelper::getSubtotals($options); $totals = ttReportHelper::getTotals($options); $notClient = !$user->isClient(); -// Determine managers we can submit this timesheet for approval to. -$approvers = ttTimesheetHelper::getApprovers($timesheet['user_id']); +// Determine which controls to show and obtain date for them. +$showSubmit = $notClient && !$timesheet['submit_status']; +if ($showSubmit) $approvers = ttTimesheetHelper::getApprovers($timesheet['user_id']); +$canApprove = $user->can('approve_timesheets') || $user_>can('approve_all_timesheets'); +$showApprove = $notClient && $timesheet['submit_status'] && !$timesheet['approval_status']; + +// Add a form with controls. +$form = new Form('timesheetForm'); +$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$timesheet['id'])); + +if ($showSubmit) { + if (count($approvers) >= 1) { + $form->addInput(array('type'=>'combobox', + 'name'=>'approver', + 'style'=>'width: 200px;', + 'data'=>$approvers, + 'datakeys'=>array('id','name'))); + } + $form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->get('button.submit'))); +} + +if ($showApprove) { + $form->addInput(array('type'=>'submit','name'=>'btn_approve','value'=>$i18n->get('button.approve'))); + $form->addInput(array('type'=>'submit','name'=>'btn_disapprove','value'=>$i18n->get('button.disapprove'))); +} + +// Submit. +if ($request->isPost()) { + if ($request->getParameter('btn_submit')) { + $fields = array('timesheet_id' => $timesheet['id'], + 'approver_id' => $approver_id); // TODO: obtain (and check) approver id above during access checks. + if (ttTimesheetHelper::submitTimesheet($fields)) { + // Redirect to self. + header('Location: timesheet_view.php?id='.$timesheet['id']); + exit(); + } else + $err->add($i18n->get('error.db')); + } +} $smarty->assign('not_client', $notClient); $smarty->assign('group_by_header', ttReportHelper::makeGroupByHeader($options)); $smarty->assign('timesheet', $timesheet); $smarty->assign('subtotals', $subtotals); $smarty->assign('totals', $totals); +$smarty->assign('show_submit', $showSubmit); +$smarty->assign('show_approve', $showApprove); +$smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('title', $i18n->get('title.timesheet')); $smarty->assign('content_page_name', 'timesheet_view.tpl'); $smarty->display('index.tpl');