+ if (!$time_log_ids && !$expense_item_ids) $err->Add($i18n->get('error.record')); // There are no selected records.
+ // Validation of parameteres ended here.
+ } else {
+ // We are assigning all report items. Get the arrays from session.
+ // Note: getting from session assures we act only on previously displayed records.
+ // Rebuilding from $bean may get us a different set.
+ $item_ids = ttReportHelper::getFromSession();
+ $time_log_ids = $item_ids['report_item_ids'];
+ $expense_item_ids = $item_ids['report_item_expense_ids'];
+ // The above code is here beacues the arrays are used in both "Mark paid" and "Assign to invoice" handlers below.
+ }
+
+ 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.
+
+ // Determine user action.
+ $mark_paid = $request->getParameter('mark_paid_action_options') == 1 ? true : false;
+
+ // Mark as requested.
+ if ($time_log_ids || $expense_item_ids) {
+ ttReportHelper::markPaid($time_log_ids, $expense_item_ids, $mark_paid);
+ }
+
+ // Re-display this form.
+ header('Location: report.php');
+ exit();
+ }
+
+ if ($request->getParameter('btn_assign_invoice')) {
+ // User clicked the Submit button to assign all or some items to a recent invoice.
+
+ // Determine invoice id.
+ $invoice_id = $request->getParameter('recent_invoice');
+
+ // Assign as requested.
+ if ($time_log_ids || $expense_item_ids) {
+ ttReportHelper::assignToInvoice($invoice_id, $time_log_ids, $expense_item_ids);
+ }
+ // Re-display this form.
+ header('Location: report.php');
+ exit();
+ }
+
+ if ($request->getParameter('btn_assign_timesheet')) {
+ // User clicked the Submit button to assign all or some items to a timesheet.
+
+ // Determine invoice id.
+ $timesheet_id = $request->getParameter('timesheet');
+
+ // Assign as requested.
+ if ($time_log_ids) {
+ ttReportHelper::assignToTimesheet($timesheet_id, $time_log_ids);
+ }
+ // Re-display this form.
+ header('Location: report.php');
+ exit();