function getProjects() { if (empty($this->projects)) { $this->projects = Project::getMany(array('company_id' => $this->id)); } return $this->projects; }
function index($params) { $criteria = array(); if (!empty($this->search_for_projects)) { $criteria = $this->search_for_projects; } $criteria['sort'] = array('sort' => 'status DESC, launch_date'); $this->data->projects = Project::getMany($criteria); $this->data->new_project = new Project(); $this->data->new_project->set(array('staff_id' => Session::getUserId())); $this->data->search_project = new Project(); $this->data->search_project->set($criteria); }
function makeCriteriaCompany($value) { $sql = array(); $projects = Project::getMany(array('company_id' => $value)); if ($projects) { $project_ids = array(); $sql[] = $this->makeCriteriaProject(array_map(function ($item) { return $item->id; }, $projects)); } $support_contracts = SupportContract::getMany(array('company_id' => $value)); if ($support_contracts) { $sql[] = $this->makeCriteriaSupportContract(array_map(function ($item) { return $item->id; }, $support_contracts)); } return '(' . implode(' or ', $sql) . ') '; }