function view($id = FALSE) { $this->view_data['submenu'] = array(); $this->view_data['project'] = Project::find($id); $this->view_data['project_has_invoices'] = Invoice::all(array('conditions' => array('project_id = ? AND estimate != ?', $id, 1))); if (!isset($this->view_data['project_has_invoices'])) { $this->view_data['project_has_invoices'] = array(); } $tasks = ProjectHasTask::count(array('conditions' => 'project_id = ' . $id)); $this->view_data['alltasks'] = $tasks; $this->view_data['opentasks'] = ProjectHasTask::count(array('conditions' => array('status != ? AND project_id = ?', 'done', $id))); $this->view_data['usercountall'] = User::count(array('conditions' => array('status = ?', 'active'))); $this->view_data['usersassigned'] = ProjectHasWorker::count(array('conditions' => array('project_id = ?', $id))); $this->view_data['assigneduserspercent'] = round($this->view_data['usersassigned'] / $this->view_data['usercountall'] * 100); $this->view_data['time_days'] = round((human_to_unix($this->view_data['project']->end . ' 00:00') - human_to_unix($this->view_data['project']->start . ' 00:00')) / 3600 / 24); $this->view_data['time_left'] = $this->view_data['time_days']; $this->view_data['timeleftpercent'] = 100; if (human_to_unix($this->view_data['project']->start . ' 00:00') < time() && human_to_unix($this->view_data['project']->end . ' 00:00') > time()) { $this->view_data['time_left'] = round((human_to_unix($this->view_data['project']->end . ' 00:00') - time()) / 3600 / 24); $this->view_data['timeleftpercent'] = $this->view_data['time_left'] / $this->view_data['time_days'] * 100; } if (human_to_unix($this->view_data['project']->end . ' 00:00') < time()) { $this->view_data['time_left'] = 0; $this->view_data['timeleftpercent'] = 0; } $this->view_data['mytasks'] = ProjectHasTask::count(array('conditions' => array('status != ? AND project_id = ? AND user_id = ?', 'done', $id, $this->user->id))); $tasks_done = ProjectHasTask::count(array('conditions' => array('status = ? AND project_id = ?', 'done', $id))); $this->view_data['progress'] = $this->view_data['project']->progress; if ($this->view_data['project']->progress_calc == 1) { if ($tasks) { @($this->view_data['progress'] = round($tasks_done / $tasks * 100)); } $attr = array('progress' => $this->view_data['progress']); $this->view_data['project']->update_attributes($attr); } @($this->view_data['opentaskspercent'] = $tasks == 0 ? 0 : $tasks_done / $tasks * 100); $projecthasworker = ProjectHasWorker::all(array('conditions' => array('user_id = ? AND project_id = ?', $this->user->id, $id))); if (!$projecthasworker && $this->user->admin != 1) { $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_no_access_error')); redirect('projects'); } $tracking = $this->view_data['project']->time_spent; if (!empty($this->view_data['project']->tracking)) { $tracking = time() - $this->view_data['project']->tracking + $this->view_data['project']->time_spent; } $this->view_data['timertime'] = $tracking; $this->view_data['time_spent_from_today'] = time() - $this->view_data['project']->time_spent; $tracking = floor($tracking / 60); $tracking_hours = floor($tracking / 60); $tracking_minutes = $tracking - $tracking_hours * 60; $this->view_data['time_spent'] = $tracking_hours . " " . $this->lang->line('application_hours') . " " . $tracking_minutes . " " . $this->lang->line('application_minutes'); $this->view_data['time_spent_counter'] = sprintf("%02s", $tracking_hours) . ":" . sprintf("%02s", $tracking_minutes); $this->content_view = 'projects/view'; }
function view($id = FALSE) { $this->view_data['submenu'] = array(); $this->view_data['project'] = Project::find($id); $this->view_data['project_has_invoices'] = Invoice::all(array('conditions' => array('project_id = ?', $id))); if (!isset($this->view_data['project_has_invoices'])) { $this->view_data['project_has_invoices'] = array(); } $tasks = ProjectHasTask::count(array('conditions' => 'project_id = ' . $id)); $tasks_done = ProjectHasTask::count(array('conditions' => array('status = ? AND project_id = ?', 'done', $id))); $this->view_data['progress'] = $this->view_data['project']->progress; if ($this->view_data['project']->progress_calc == 1) { if ($tasks) { $this->view_data['progress'] = round($tasks_done / $tasks * 100); } $attr = array('progress' => $this->view_data['progress']); $this->view_data['project']->update_attributes($attr); } $projecthasworker = ProjectHasWorker::all(array('conditions' => array('user_id = ? AND project_id = ?', $this->user->id, $id))); if (!$projecthasworker && $this->user->admin != 1) { $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_no_access_error')); redirect('projects'); } $tracking = $this->view_data['project']->time_spent; if (!empty($this->view_data['project']->tracking)) { $tracking = time() - $this->view_data['project']->tracking + $this->view_data['project']->time_spent; } $this->view_data['time_spent_from_today'] = time() - $this->view_data['project']->time_spent; $tracking = floor($tracking / 60); $tracking_hours = floor($tracking / 60); $tracking_minutes = $tracking - $tracking_hours * 60; $this->view_data['time_spent'] = $tracking_hours . " " . $this->lang->line('application_hours') . " " . $tracking_minutes . " " . $this->lang->line('application_minutes'); $this->view_data['time_spent_counter'] = sprintf("%02s", $tracking_hours) . ":" . sprintf("%02s", $tracking_minutes); $this->content_view = 'projects/view'; }