Added paid field and handling to expenses.
[timetracker.git] / report.php
index a34238f..110d5ac 100644 (file)
@@ -39,7 +39,7 @@ if (!ttAccessCheck(right_view_reports)) {
 }
 
 // Use custom fields plugin if it is enabled.
-if (in_array('cf', explode(',', $user->plugins))) {
+if ($user->isPluginEnabled('cf')) {
   require_once('plugins/CustomFields.class.php');
   $custom_fields = new CustomFields($user->team_id);
   $smarty->assign('custom_fields', $custom_fields);
@@ -65,22 +65,25 @@ if ($client_id && $bean->getAttribute('chinvoice') && ('no_grouping' == $bean->g
 }
 
 if ($request->isPost()) {
-  foreach($_POST as $key => $val) {
-    if ('log_id_' == substr($key, 0, 7))
-      $time_log_ids[] = substr($key, 7);
-    if ('item_id_' == substr($key, 0, 8))
-      $expense_item_ids[] = substr($key, 8);
-    if ('recent_invoice' == $key)
-       $invoice_id = $val;
+  if ($request->getParameter('btn_submit')) {
+    // User clicked the Submit button to assign some items to a recent invoice.
+    foreach($_POST as $key => $val) {
+      if ('log_id_' == substr($key, 0, 7))
+        $time_log_ids[] = substr($key, 7);
+      if ('item_id_' == substr($key, 0, 8))
+        $expense_item_ids[] = substr($key, 8);
+      if ('recent_invoice' == $key)
+        $invoice_id = $val;
+    }
+    if ($time_log_ids || $expense_item_ids) {
+      // Some records are checked for invoice editing. Adjust their invoice accordingly.
+      ttReportHelper::assignToInvoice($invoice_id, $time_log_ids, $expense_item_ids);
+    }
+    // Re-display this form.
+    header('Location: report.php');
+    exit();
   }
-  if ($time_log_ids || $expense_item_ids) {
-    // Some records are checked for invoice editing. Adjust their invoice accordingly.
-    ttReportHelper::assignToInvoice($invoice_id, $time_log_ids, $expense_item_ids);
-  }
-  // Re-display this form.
-  header('Location: report.php');
-  exit();
-} // POST
+} // isPost
 
 $group_by = $bean->getAttribute('group_by');