From: Nik Okuntseff Date: Mon, 25 Feb 2019 16:54:38 +0000 (+0000) Subject: Added approval handling to reports. X-Git-Tag: timetracker_1.19-1~268 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=cb0478b58a3e34cfffcf41e4e89de5a75685460d;p=timetracker.git Added approval handling to reports. --- diff --git a/WEB-INF/lib/ttReportHelper.class.php b/WEB-INF/lib/ttReportHelper.class.php index 5d9de074..57d00472 100644 --- a/WEB-INF/lib/ttReportHelper.class.php +++ b/WEB-INF/lib/ttReportHelper.class.php @@ -659,6 +659,29 @@ class ttReportHelper { } } + // The markApproved marks a set of records as either approved or unapproved. + static function markApproved($time_log_ids, $expense_item_ids, $approved = true) { + global $user; + $mdb2 = getConnection(); + + $group_id = $user->getGroup(); + $org_id = $user->org_id; + + $approved_val = (int) $approved; + if ($time_log_ids) { + $sql = "update tt_log set approved = $approved_val". + " where id in(".join(', ', $time_log_ids).") and group_id = $group_id and org_id = $org_id"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) die($affected->getMessage()); + } + if ($expense_item_ids) { + $sql = "update tt_expense_items set approved = $approved_val". + " where id in(".join(', ', $expense_item_ids).") and group_id = $group_id and org_id = $org_id"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) die($affected->getMessage()); + } + } + // The markPaid marks a set of records as either paid or unpaid. static function markPaid($time_log_ids, $expense_item_ids, $paid = true) { global $user; diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 4f4adc75..57554741 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.43.4777 | Copyright © Anuko | +  Anuko Time Tracker 1.18.43.4778 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/report.php b/report.php index 6b26fe1c..aacb889a 100644 --- a/report.php +++ b/report.php @@ -142,7 +142,8 @@ if ($user->can('manage_invoices') && if ($request->isPost()) { // Validate parameters and at the same time build arrays of record ids. - if (($request->getParameter('btn_mark_paid') && 2 == $request->getParameter('mark_paid_select_options')) + if (($request->getParameter('btn_mark_approved') && 2 == $request->getParameter('mark_approved_select_options')) + || ($request->getParameter('btn_mark_paid') && 2 == $request->getParameter('mark_paid_select_options')) || ($request->getParameter('btn_assign') && 2 == $request->getParameter('assign_invoice_select_options'))) { // We act on selected records. Are there any? foreach($_POST as $key => $val) { @@ -164,6 +165,22 @@ if ($request->isPost()) { } if ($err->no()) { + if ($request->getParameter('btn_mark_approved')) { + // User clicked the "Mark approved" button to mark some or all items either approved or not approved. + + // Determine user action. + $mark_approved = $request->getParameter('mark_approved_action_options') == 1 ? true : false; + + // Mark as requested. + if ($time_log_ids || $expense_item_ids) { + ttReportHelper::markApproved($time_log_ids, $expense_item_ids, $mark_approved); + } + + // Re-display this form. + header('Location: report.php'); + exit(); + } + if ($request->getParameter('btn_mark_paid')) { // User clicked the "Mark paid" button to mark some or all items either paid or not paid.