示例#1
0
 public function import()
 {
     $objPHPExcel = @PHPExcel_IOFactory::load($this->file->getTempName());
     /** @var PHPExcel_Worksheet $worksheet */
     foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
         $rowIterator = $worksheet->getRowIterator();
         /** @var PHPExcel_Worksheet_Row $row  */
         foreach ($rowIterator as $row) {
             $criterion = new Criterion();
             $criterion->Decision = $this->decision;
             $cellIterator = $row->getCellIterator();
             $cellIterator->setIterateOnlyExistingCells();
             /** @var PHPExcel_Cell $cell*/
             foreach ($cellIterator as $cell) {
                 if (!is_null($cell)) {
                     $column = $cell->getColumn();
                     if ($column == 'A') {
                         $criterion->name = $cell->getValue();
                         $criterion->save();
                     } else {
                         if ($column == 'B') {
                             $criterion->description = $cell->getValue();
                             $criterion->save();
                         }
                     }
                 }
             }
         }
     }
 }
示例#2
0
 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();
         }
     }
 }
示例#3
0
 public function getCriterionCreateResponse(sfGuardUser $user)
 {
     /** @var sfWebRequest $request */
     $request = $this->getRequest();
     $decision = DecisionTable::getInstance()->getDecisionForUser($user, $request->getParameter('decision_id'));
     if (is_object($decision)) {
         $criterion = new Criterion();
         $criterion->Decision = $decision;
         $criterion->name = $request->getParameter('name', 'New criterion');
         $criterion->description = $request->getParameter('description', '');
         $criterion->variable_type = $request->getParameter('type', 'Benefit');
         $criterion->measurement = $request->getParameter('measure', 'five point scale');
         try {
             $criterion->save();
             $result = array('status' => 'success', 'result' => $criterion->getAPIData());
         } catch (sfException $ex) {
             $result = array('status' => 'error', 'error' => $ex->getMessage());
         }
     } else {
         $result = array('status' => 'error', 'error' => sprintf('Project with id %d does not exist', $request->getParameter('decision_id')));
     }
     return $result;
 }
示例#4
0
 /**
  * @param sfWebRequest $request
  * @return string
  */
 public function executeCreatePopular(sfWebRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     /** @var PopularCriterion $popularCriterion */
     $popularCriterion = $this->getRoute()->getObject();
     $criterion = new Criterion();
     $criterion->name = $popularCriterion->name;
     $criterion->decision_id = $request->getParameter('decision_id');
     $criterion->description = $popularCriterion->description;
     $criterion->variable_type = $popularCriterion->variable_type;
     $criterion->measurement = $popularCriterion->measurement;
     $criterion->save();
     return sfView::NONE;
 }