Пример #1
0
$todays_tasks = array();
foreach ($day_tasks as $task) {
    $class = '';
    $from = strtotime($task['from_time']);
    $to = strtotime($task['to_time']);
    if (date('Y-m-d', $from) != $day) {
        //Some tasks may start the day before.
        $from = strtotime("{$day} 00:00:00");
        //Set the starting point as today midnight.
    }
    if ($task['to_time'] == '0000-00-00 00:00:00') {
        //Active Task.
        $class .= 'active ';
        $to = time();
    }
    $left = getTimePercentage($from);
    $width = time2percent(0, ($to - $from) / 60);
    list($hour_difference, $minute_difference) = getTimeDifference($from, $to);
    if ($minute_difference < 3 and $hour_difference == 0) {
        continue;
    }
    //Too small as task to list(or its a accidental click)
    $from_time = date('h:i a', $from);
    $to_time = date('h:i a', $to);
    if ($width < 4) {
        $class .= 'small ';
    }
    $todays_tasks[] = array('class' => $class, 'left' => $left, 'width' => $width, 'name' => $task['name'], 'from_time' => $from_time, 'to_time' => $to_time, 'hour_difference' => $hour_difference, 'minute_difference' => $minute_difference);
    // Find the total time taken for each task.
    $task_id = $task['id'];
    if (!isset($tasks_aggregate[$task_id])) {
Пример #2
0
$periods = new Periods($user->getId());
$review = new Review($user->getId(), $periods);
$review->setUserEmail($user->getUsername());
switch ($_REQUEST['action']) {
    // gets info about requested period with period stats (done/not done)
    case 'get_period':
        $totalCount = $periods->getPeriodCount();
        $position = !empty($_REQUEST['position']) ? intval($_REQUEST['position']) : $periods->getCurrentPeriodCount();
        $period_info = $periods->getPeriodByPosition($position);
        if ($period_info !== null) {
            $period_info = $review->getPeriodById($period_info['id']);
        }
        $period_stats = $review->getPeriodStats($period_info['id']);
        $time_percentage = 0;
        if ($period_info['status'] == 0) {
            $time_percentage = getTimePercentage($period_info['start_date'], $period_info['end_date']);
        }
        echo json_encode(array('info' => $period_info, 'stats' => $period_stats, 'count' => $totalCount, 'position' => $position, 'time_percentage' => $time_percentage));
        break;
        /*        
            case 'add_period':
                $end_date = $_REQUEST['end_date']; 
                echo json_encode($periods -> addPeriod($end_date));
                break;
                
            case 'delete_period':
                $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : -1;
                echo json_encode($periods -> deletePeriod($id));
                break;
                
            case 'change_status_period':