public function load(sfGuardUser $user, $decision_id) { $this->criteria = CriterionTable::getInstance()->getArrayForUser($user, $decision_id); $alternatives = AlternativeTable::getInstance()->getArrayForUser($user, $decision_id); $values = AlternativeMeasurementTable::getInstance()->getForDashboard($user, $decision_id); foreach ($alternatives as $alternative) { $this->body[$alternative['id']][0] = $alternative['name']; foreach ($this->criteria as $criterion) { $cell = new stdClass(); $cell->measurement = str_replace(' ', '_', $criterion['measurement']); $cell->value = isset($values[$alternative['id']][$criterion['id']]) ? $values[$alternative['id']][$criterion['id']] : null; $this->body[$alternative['id']][$criterion['id']] = $cell; } } }
public function postSave($event) { if ($this->prioritize) { if (!$this->PlannedCriteria->count()) { $criteria = CriterionTable::getInstance()->createQuery('c')->select('c.id')->where("c.decision_id = ? AND c.variable_type = 'Benefit'", $this->decision_id)->fetchArray(); foreach ($criteria as $criterion) { $plannedCriterionPrioritization = new PlannedCriterionPrioritization(); $plannedCriterionPrioritization->role_id = $this->id; $plannedCriterionPrioritization->criterion_id = $criterion['id']; $plannedCriterionPrioritization->save(); } } } else { Doctrine_Query::create()->from('PlannedCriterionPrioritization pcp')->where('pcp.role_id = ?', $this->id)->delete()->execute(); } $this->refresh(true); }
public function configure() { unset($this['decision_id']); $this->widgetSchema['criterion_id']->setOption('query', CriterionTable::getInstance()->createQuery()->where('decision_id = ?', $this->getObject()->decision_id)); $this->validatorSchema['criterion_id']->setOption('query', CriterionTable::getInstance()->createQuery()->where('decision_id = ?', $this->getObject()->decision_id)); }
public function getCriterionDetailsResponse(sfGuardUser $user) { /** @var sfWebRequest $request */ $request = $this->getRequest(); $criterion = CriterionTable::getInstance()->getOneForUser($user, $request->getParameter('id')); if (is_object($criterion)) { $result = array('status' => 'success', 'result' => $criterion->getAPIData()); } else { $result = array('status' => 'error', 'error' => sprintf('Item with id %d does not exist', $request->getParameter('id'))); } return $result; }
public function setCriteriaValues($criteria) { $criteria_ids = array(0); $criteria_values = array(); foreach ($criteria as $criterion) { $criteria_ids[] = $criterion['id']; $criteria_values[$criterion['id']] = $criterion['value'] / 10; } $collection = CriterionTable::getInstance()->createQuery('c')->select('c.id, c.name')->whereIn('c.id', $criteria_ids)->fetchArray(); foreach ($collection as $item) { if ($this->max_criterion_name_length < strlen($item['name'])) { $this->max_criterion_name_length = strlen($item['name']); } $this->collection[] = array('title' => $item['name'], 'value' => $criteria_values[$item['id']], 'id' => $item['id']); } $this->calculateGraphSizes(); }