コード例 #1
0
<?php

TaskerMAN\WebInterface\WebInterface::setTitle('Create New Task');
if (isset($_POST['submit'])) {
    try {
        $task = new TaskerMAN\Application\Task();
        $task->setCreatedByUser(TaskerMAN\WebInterface\WebInterface::$user->getID());
        $task->setAssignee(TaskerMAN\Core\IO::POST('assigned-to'));
        $task->setDueBy(TaskerMAN\Core\IO::POST('due-date'));
        $task->setStatus(1);
        // Allocated
        $task->setTitle(TaskerMAN\Core\IO::POST('task-title'));
        $task->createStep(TaskerMAN\Core\IO::POST('step-text'));
        $task->save();
        header('Location: index.php?p=task&id=' . $task->id);
        exit;
    } catch (TaskerMAN\Application\UserManagementException $e) {
        $alert = '<div class="alert alert-danger" role="alert">' . $e->getMessage() . '</div>';
    } catch (TaskerMAN\Application\TaskException $e) {
        $alert = '<div class="alert alert-danger" role="alert">' . $e->getMessage() . '</div>';
    }
}
?>

<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">

	<?php 
if (isset($alert)) {
    echo $alert;
}
?>
コード例 #2
0
}
foreach ($tasks as $i) {
    $t = new TaskerMAN\Application\Task();
    $t->setAssignee($users[array_rand($users)]);
    $due_by = rand_future_time();
    $t->setDueBy(date('Y-m-d', $due_by));
    $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)]);