Esempio n. 1
0
 public function action_addtask($project_id)
 {
     if (!($project = Model_Project::find($project_id))) {
         \Fuel\Core\Session::set_flash('error', "Cannot find the selected project # {$project_id}");
         \Fuel\Core\Response::redirect_back('user/projects');
     }
     $val = Model_Projecttask::validate('create');
     if (\Fuel\Core\Input::method() == 'POST') {
         if ($val->run()) {
             $projecttask = Model_Projecttask::forge(array('project_id' => Input::post('project_id'), 'user_id' => Input::post('user_id'), 'project_task_name_id' => Input::post('project_task_name_id'), 'hourly_rate' => Input::post('hourly_rate'), 'task_status' => 0, 'task_due' => Input::post('task_due'), 'project_task_description' => Input::post('project_task_description'), 'comment' => Input::post('comment'), 'priority' => Input::post('priority')));
             if ($projecttask and $projecttask->save()) {
                 Session::set_flash('success', e('Added task #' . $projecttask->id . '.'));
                 Response::redirect('user/projects/view/' . $project_id);
             } else {
                 Session::set_flash('error', e('Could not save task.'));
             }
         } else {
             \Fuel\Core\Session::set_flash('error', $val->error());
         }
     }
     $this->load_presenter($project, Model_Projecttask::forge(array('id' => 0, 'project_id' => $project->id, 'user_id' => $this->current_user->id, 'task_status' => 0, 'hourly_rate' => 456, 'task_due' => date('Y-m-d'))));
     $this->template->set_global('project_task_names', Model_Projecttaskname::find('all', array('order_by' => array(array('name', 'asc')))));
     $this->template->set_global('users', array(Model_User::find($this->current_user->id)));
     $this->template->set_global('priorities', THelper::get_priorities());
     $this->template->title = 'My Projects';
     $this->template->content = Fuel\Core\View::forge('user/projects/addtask');
 }
				    <th>TASK</th>
				    <th>BILLABLE?</th>
				    <th style="width: 800px;">COMMENT</th>
				</tr>
                            </thead>
                            <tbody>
                                    <?php 
foreach ($timezones as $zone) {
    ?>
                                
                                        <?php 
    $checked = false;
    $comment = '';
    $date = date('Y-m-d', $timestamp);
    $log = new Model_Projecttasklog(array('id' => 0, 'is_billable' => 0));
    $current_task = Model_Projecttask::forge(array('id' => 0));
    foreach ($today_logs as $item) {
        $zone_starts = strtotime(date($date . ' ' . $zone->starts));
        $zone_ends = strtotime(date($date . ' ' . $zone->ends));
        if (in_array($zone_starts, range(strtotime($item->task_started), strtotime($item->task_completed) - 1))) {
            $checked = true;
            $log = $item;
            $current_task = $item->get_project_task();
            break;
        }
    }
    ?>
                                    <tr> 
                                        <td nowrap>
                                            <div class="checkbox">
                                                <label>
 public function get_project_task()
 {
     return !is_null($this->project_task) ? $this->project_task : Model_Projecttask::forge(array('id' => 0));
 }