Ejemplo n.º 1
0
 function filter($condition)
 {
     switch ($condition) {
         case 'open':
             $options = array('conditions' => 'progress < 100');
             break;
         case 'closed':
             $options = array('conditions' => 'progress = 100');
             break;
     }
     $this->view_data['project'] = Project::all($options);
     $this->content_view = 'projects/all';
     $this->view_data['projects_assigned_to_me'] = ProjectHasWorker::find_by_sql('select count(distinct(projects.id)) AS "amount" FROM projects, project_has_workers WHERE projects.progress != "100" AND (projects.id = project_has_workers.project_id AND project_has_workers.user_id = "' . $this->user->id . '") ');
     $this->view_data['tasks_assigned_to_me'] = ProjectHasTask::count(array('conditions' => 'user_id = ' . $this->user->id . ' and status = "open"'));
     $now = time();
     $beginning_of_week = strtotime('last Monday', $now);
     // BEGINNING of the week
     $end_of_week = strtotime('next Sunday', $now) + 86400;
     // END of the last day of the week
     $this->view_data['projects_opened_this_week'] = Project::find_by_sql('select count(id) AS "amount", DATE_FORMAT(FROM_UNIXTIME(`datetime`), "%w") AS "date_day", DATE_FORMAT(FROM_UNIXTIME(`datetime`), "%Y-%m-%d") AS "date_formatted" from projects where datetime >= "' . $beginning_of_week . '" AND datetime <= "' . $end_of_week . '" ');
 }