public function createDashboard() { $role = new Role(); $role->setDecisionId($this->id); $role->setName('Collect everything'); $role->setComment('Collect everything is linked to the Overview -page reporting table. <br><br>If you delete this survey your responses on the overview page will be removed.'); $role->setUpdateable(true); $role->setDashboard(true); $role->setActive(true); $response = new Response(); $response->setDecisionId($this->id); $response->setIpAddress('127.0.0.1'); $response->setEmailAddress('dashboard'); $role->Response->add($response); $role->Response->save(); if ($this->Template->name == 'Default') { $role_estimates = new Role(); $role_estimates->setDecisionId($this->id); $role_estimates->setName('Collect Estimates'); $role_estimates->setUpdateable(false); $role_estimates->setActive(true); $role_estimates->save(); $role_value = new Role(); $role_value->setDecisionId($this->id); $role_value->setName('Collect input on Value'); $role_value->setUpdateable(false); $role_value->setActive(true); $role_value->save(); $role_usability = new Role(); $role_usability->setDecisionId($this->id); $role_usability->setName('Collect input on Usability'); $role_usability->setUpdateable(false); $role_usability->setActive(true); $role_usability->save(); $role_feasibility = new Role(); $role_feasibility->setDecisionId($this->id); $role_feasibility->setName('Collect input on Feasibility'); $role_feasibility->setUpdateable(false); $role_feasibility->setActive(true); $role_feasibility->save(); // create the default item for project $alternative = new Alternative(); $alternative->setDecisionId($this->id); $alternative->setName('Sample item'); $alternative->setStatus('Reviewed'); $alternative->save(); $popularCriteria = PopularCriterionTable::getInstance()->getDashboardDefaultList(); foreach ($popularCriteria as $popularCriterion) { $criterion = new Criterion(); $criterion->setName($popularCriterion->name); $criterion->setMeasurement($popularCriterion->measurement); $criterion->setDescription($popularCriterion->description); $criterion->setVariableType($popularCriterion->variable_type); $criterion->setDecisionId($this->id); $criterion->save(); // set default response as 3 for default item if ($popularCriterion->measurement == 'five point scale') { $alternative_measurement = new AlternativeMeasurement(); $alternative_measurement->setAlternativeHeadId($alternative->id); $alternative_measurement->setScore(3); $alternative_measurement->setResponseId($response->id); $alternative_measurement->setRatingMethod($criterion->getMeasurement()); $alternative_measurement->setCriterionId($criterion->id); $alternative_measurement->save(); } // show by default in the Survey (create default matrix of the default roles) $array = array('Hour Estimate' => $role_estimates->id, 'Feasibility' => $role_feasibility->id, 'Usability' => $role_usability->id, 'Value' => $role_value->id); if (isset($array[$popularCriterion->name])) { $planned = new PlannedAlternativeMeasurement(); $planned->setRoleId($array[$popularCriterion->name]); $planned->setAlternativeId($alternative->id); $planned->setCriterionId($criterion->id); $planned->save(); $cplanned = new PlannedCriterionPrioritization(); $cplanned->setCriterionId($criterion->id); $cplanned->setRoleId($array[$popularCriterion->name]); $cplanned->save(); } } } else { foreach ($this->Template->CriteriaTemplate as $criterionTemplate) { $criterion = new Criterion(); $criterion->setDecisionId($this->id); $criterion->setName($criterionTemplate->name); $criterion->setMeasurement($criterionTemplate->measurement); $criterion->setVariableType($criterionTemplate->variable_type); $criterion->save(); } foreach ($this->Template->RoleTemplate as $roleTemplate) { $role = new Role(); $role->setDecisionId($this->id); $role->setName($roleTemplate->name); $role->save(); } } }