Exemplo n.º 1
0
 function view($id = FALSE)
 {
     if (!$id) {
         redirect('/projects');
     }
     $project = $this->projects->get($id);
     $data['start'] = $start = $this->time->earliest_time_date($project->id);
     $data['end'] = $end = time();
     $times = $this->time->span_time(NULL, NULL, $project->id);
     $data['series'][$project->name] = array();
     $data['series'][$project->name]['name'] = $project->name;
     for ($day = strtotime($start); $day <= $end; $day = strtotime('+1 day', $day)) {
         $date = date('Y-m-d', $day);
         $data['series'][$project->name]['data'][] = isset($times[$project->name][$date]) ? $times[$project->name][$date] + 0.0 : 0;
     }
     $project->chart = $this->load->view('graphs/time_line', $data, TRUE);
     $project->hours = decimal_to_time($project->hours);
     $project->numtasks = isset($numtasks[$project->id]) ? $numtasks[$project->id] : 0;
     $project->tasks = $this->tasks->view_by_project($project->id);
     $project->times = $this->time->view_by_project($project->id, 20);
     $data['title'] = $project->name;
     $data['project'] = $project;
     $this->load->view('includes/header', $data);
     $this->load->view('projects/view', $data);
     $this->load->view('includes/footer');
 }
Exemplo n.º 2
0
 function index()
 {
     $start = $this->input->post('time-start');
     if (!$start) {
         $start = $this->time->earliest_time_date();
     }
     // If no start date specified, set it to the first day of the month.
     $end = $this->input->post('time-end');
     if (!$end) {
         $end = date('Y-m-d');
     }
     // If no end date specified, set it to today.
     $data['title'] = "Your Time";
     $data['entries'] = $this->time->view_all($start, $end, 50);
     $data['start'] = $start;
     $data['end'] = $end;
     $this->load->view('includes/header', $data);
     if (!count($data['entries'])) {
         // No time has been logged yet.
         $data['content'] = "<div class='block first center'><div class='block-header'><h2>No time added yet</h2></div><div class='block-content'><p>You haven't added any time yet. Sweet, I love this part!</p><p>See that form at the top right? Just enter a time, a project name (the project will be created for you), and a description, and you're on your way.</p></div>";
         $this->load->view('utility/content', $data);
     } else {
         // If there has been some time logged.
         foreach ($data['entries'] as $entry) {
             $entry->duration = decimal_to_time($entry->duration);
             if (date('Y-m-d') == $entry->date) {
                 // Change today's date to read "Today" instead.
                 $entry->date = 'Today';
             }
         }
         $times = $this->time->span_time($start, $end);
         foreach ($times as $project => $value) {
             $data['series'][$project] = array();
             $data['series'][$project]['name'] = $project;
         }
         // Loop through dates using timestamp (the 60*60 below is to account for DST),
         // adding a day (60*60*24) each time.
         for ($day = strtotime($start); $day <= strtotime($end); $day = strtotime('+1 day', $day)) {
             $date = date('Y-m-d', $day);
             foreach ($times as $project => $value) {
                 $data['series'][$project]['data'][] = isset($times[$project][$date]) ? $times[$project][$date] + 0.0 : 0;
             }
         }
         $data['allgraph'] = $this->load->view('graphs/time_line', $data, TRUE);
         $data['sumtimes'] = $this->time->sum_time(date('Y-m-d'));
         $data['daytotal'] = array_sum($data['sumtimes']);
         $data['daygraph'] = $this->load->view('graphs/time_pie', $data, TRUE);
         $data['sumtimes'] = $this->time->sum_time(date('Y-m-d', time() - 60 * 60 * 24 * date('w')), date('Y-m-d'));
         $data['weektotal'] = array_sum($data['sumtimes']);
         $data['weekgraph'] = $this->load->view('graphs/time_pie', $data, TRUE);
         $data['sumtimes'] = $this->time->sum_time(date('Y-m-01'), date('Y-m-d'));
         $data['monthtotal'] = array_sum($data['sumtimes']);
         $data['monthgraph'] = $this->load->view('graphs/time_pie', $data, TRUE);
         $this->load->view('time/list', $data);
     }
     $this->load->view('includes/footer');
 }
Exemplo n.º 3
0
echo decimal_to_time($daytotal);
?>
</h2></div>
  <div class="block-content"><?php 
echo $daygraph;
?>
</div>
</div>

<div class="block second onethird">
  <div class="block-header"><h2>This Week - <?php 
echo decimal_to_time($weektotal);
?>
</h2></div>
  <div class="block-content"><?php 
echo $weekgraph;
?>
</div>
</div>

<div class="block second onethird">
  <div class="block-header"><h2>This Month - <?php 
echo decimal_to_time($monthtotal);
?>
</h2></div>
  <div class="block-content"><?php 
echo $monthgraph;
?>
</div>
</div>
Exemplo n.º 4
0
            <th>Date</th>
            <th>Time</th>
            <th>Description</th>
          </tr>
        </thead>
        <tbody>
          <?php 
    foreach ($project->times as $time) {
        ?>
            <tr>
              <td class="nonlinks"><?php 
        echo $time->date;
        ?>
</td>
              <td class="nonlinks"><?php 
        echo decimal_to_time($time->duration);
        ?>
</td>
              <td class="nonlinks"><?php 
        echo $time->description;
        ?>
</td>
            </tr>
          <?php 
    }
    ?>
        </tbody>
      </table>

    <?php 
} else {