0)) && ($tid !== 'new')) { $_SESSION['msg'] = "Invalid Task ID."; header('location:task-manager.php'); die(); } $custid = isused_else($_GET['c'], 0); $custid = isused_else($_POST['cid'], $custid); $orderid = isused_else($_GET['o'], 0); $orderid = isused_else($_POST['oid'], $orderid); $act = isused_else($_POST['act'], ''); $flds = array('TaskTitle','TaskType','TaskDateOpen','TaskDateLast','TaskMadeBy', 'TaskDesc','TaskStatus','AssignedTo','OrderID','CustomerID'); switch ($act) { case '': break; case "Save Changes": if ((integer)$orderid > 0) { $crow = Customer::_fetch_by_order($orderid); $custid = $crow['CustomerID']; } $nrow = array('TaskID'=>$tid, 'TaskType'=>isused_else($_POST['TaskType'], 0), 'TaskDateLast'=>time(), 'TaskStatus'=>isused_else($_POST['TaskStatus'], 0), 'AssignedTo'=>isused_else($_POST['AssignedTo'], 0), 'OrderID'=>$orderid,'CustomerID'=>$custid); $x = Task::_update($nrow); $note = isused_else($_POST['Note'], 'No description provided'); if ($x != 1) { $msg = "WARNING! $x records updated!"; } else { $msg = "Record updated."; $note .= "\n\n" . Task::_fetch_task_summary($tid); $x = Task::_add_note($tid,$note); if (!($x > 0)) { $msg .= "\nFAILED TO ADD A NOTE TO THIS TASK!"; elog("task-view-act:failed to add note during update task $tid\n$note",1); } } break; case "Add Task": if ($tid !== 'new') { $_SESSION['msg'] = "Invalid action requested"; header("location:task-view.php?i=$tid"); die(); } if ((integer)$orderid > 0) { $crow = Customer::_fetch_by_order($orderid); $custid = $crow['CustomerID']; } foreach ($flds as $val) { $nrow[$val] = isused_else($_POST[$val], ''); } $nrow['OrderID'] = $orderid; $nrow['CustomerID'] = $custid; $x = Task::_add($nrow); if (!(integer)$x > 0) { $msg = "An error occurred while adding the task."; } else { $tid = $x; $msg = "Task $tid added."; $note = "Task #$tid added by {$gbl_EMP->EmpCode} on " . date('M j, Y g:i:s a',time()) . "\n\n" . isused_else($_POST['TaskDesc'], 'No description provided'); $x = Task::_add_note($tid,$note); if (!($x > 0)) { $msg .= "\nFAILED TO ADD A NOTE TO THIS TASK!"; elog("task-view-act:failed to add note during add task $tid\n$note", 1); } if ($custid > 0) { $x = Customer::_add_note($custid,$note); } if ($orderid > 0) { $x = Order::_add_note($orderid,$note); } } break; default: elog("task-view-act:INFO:invalid action:$act:",3); $msg = "Invalid action."; break; } $_SESSION['msg'] = $msg; header("location:task-view.php?i=$tid"); die(); ?>