} $task = new TaskerMAN\Application\Task($task_id); if (empty($task->id)) { // Unable to load task, throw error throw new TaskerMAN\Application\APIErrorException('Invalid task ID'); } switch ($status) { // Make sure we're not setting the status to a state it's already in case $task->status: throw new TaskerMAN\Application\APIErrorException('Trying to change status to same value as it already has'); break; // allocated // allocated case 1: $task->setStatus(1); $task->setCompletedTime('0000-00-00 00:00:00'); break; // completed // completed case 2: $task->setStatus(2); $task->setCompletedTime(date("Y-m-d H:i:s", $completed_time)); break; // Invalid status code // Invalid status code default: echo TaskerMAN\Application\API::error('Invalid status value (must be 1 or 2)'); exit; break; } // Commit changes
$t->setCreatedByUser($admins[array_rand($admins)]); if (rand(1, 5) > 2) { $status = 2; } else { $status = 1; } $t->setStatus($status); $steps = range(1, rand(1, 3)); foreach ($steps as $step_i) { $t->createStep('Step #' . $step_i, 'Not done yet, sorry'); } if ($status == 2) { // Should this task be completed late or on time? if (rand(0, 10) < 8) { // On time // Generate a time between created time and due date $complete_time = rand(time(), $due_by); } else { // Late // Generate a time between due date, and 2 weeks after due date $complete_time = rand($due_by, $due_by + 14 * 86400); } $t->setCompletedTime(date('Y-m-d H:i:s', $complete_time)); } $t->setTitle($verbs[array_rand($verbs)] . ' the ' . $things[array_rand($things)]); $t->save(); } function rand_future_time() { return time() + rand(3600, 86400) + rand(0, 60) * 86400; }
throw new TaskerMAN\Core\FatalException('404 - Page Not Found', new \Exception('Requested task (' . $task_id . ') was not found')); } TaskerMAN\WebInterface\WebInterface::setTitle('Task ' . $task_id); ?> <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"> <?php if (isset($_POST['submit'])) { try { $task->setTitle(TaskerMAN\Core\IO::POST('task-title')); $task->setDueBy(TaskerMAN\Core\IO::POST('due-date')); $task->setAssignee(TaskerMAN\Core\IO::POST('assigned-to')); // Task changed to completed if ($task->status != 2 && TaskerMAN\Core\IO::POST('status') == 2) { $task->setCompletedTime(); } $task->setStatus(TaskerMAN\Core\IO::POST('status')); $task->save(); } catch (TaskerMAN\Application\TaskException $e) { $alert = '<div class="alert alert-danger" role="alert">' . $e->getMessage() . '</div>'; } } if (isset($alert)) { echo $alert; } switch ($task->status) { case 0: $label = '<span class="label label-default">Abandoned</span>'; break; case 1: