Пример #1
0
 public function postUp()
 {
     $decisions = DecisionTable::getInstance()->createQuery('d')->innerJoin('d.Roles r')->where('r.dashboard = 0')->execute();
     foreach ($decisions as $decision) {
         $decision->createDashboard();
     }
 }
 public function postUp()
 {
     foreach (DecisionTable::getInstance()->findAll() as $decision) {
         $analyzeCollapse = new AnalyzeCollapse();
         $analyzeCollapse->Decision = $decision;
         $analyzeCollapse->save();
     }
 }
 /**
  * @param mixed $value
  * @return mixed|string
  * @throws sfValidatorError
  */
 protected function doClean($value)
 {
     $clean = parent::doClean($value);
     if (!DecisionTable::getInstance()->verifyAvailableNameByUserId($this->getOption('user_id'), $clean, $this->getOption('decision_id'))) {
         throw new sfValidatorError($this, 'busy_name');
     }
     return $clean;
 }
 public function up()
 {
     $result = Doctrine_Manager::getInstance()->connection()->execute("SELECT id from `decision` WHERE id not in (SELECT d.id FROM `decision` d LEFT JOIN `role` r ON d.id = r.decision_id WHERE r.dashboard = 1) limit 500")->fetchAll();
     foreach ($result as $decision_row) {
         $decision = DecisionTable::getInstance()->find($decision_row['id']);
         $decision->createDashboard();
     }
 }
Пример #5
0
 public function executeImportTrello(sfWebRequest $request)
 {
     $this->external_ids = array();
     $external_decisions = DecisionTable::getInstance()->createQuery('d')->select('d.external_id')->where('d.external_id IS NOT NULL')->andWhereIn('d.user_id', sfGuardUserTable::getInstance()->getUsersInTeamIDs($this->getUser()->getGuardUser()))->fetchArray();
     foreach ($external_decisions as $external_decision) {
         $this->external_ids[] = $external_decision['external_id'];
     }
 }
Пример #6
0
 public function executeExport(sfWebRequest $request)
 {
     $decision_id = $request->getParameter('decision_id', false);
     $decision = DecisionTable::getInstance()->getDecisionForUser($this->getUser()->getGuardUser(), $decision_id);
     $this->forward404Unless($decision);
     header('Content-type: application/force-download');
     header('Content-Disposition: attachment; filename="' . $decision->name . '.xlsx"');
     $table = new ResponseTableView();
     $table->load($decision_id);
     $excelExporter = new ResponseExcelExporter($table);
     $excelExporter->export();
     exit;
 }
Пример #7
0
 public function executeExport(sfWebRequest $request)
 {
     //$this->forward404Unless(in_array($this->getUser()->getGuardUser()->account_type, array('Pro', 'Enterprise')));
     $decision_id = $request->getParameter('decision_id', false);
     $decision = DecisionTable::getInstance()->getDecisionForUser($this->getUser()->getGuardUser(), $decision_id);
     $this->forward404Unless(is_object($decision));
     header('Content-type: application/force-download');
     header('Content-Disposition: attachment; filename="' . $decision->name . '.pptx"');
     $exporter = new WallPowerPointExporter();
     $exporter->setDecisionId($decision_id);
     $exporter->load();
     $exporter->export();
     exit;
 }
Пример #8
0
 /**
  * @param sfWebRequest $request
  * @return sfView
  */
 public function executeCreateRelease(sfWebRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
     /** @var Decision $decision  */
     $decision = DecisionTable::getInstance()->find($request->getParameter('decision_id'));
     $this->forward404Unless($decision);
     $release = new ProjectRelease();
     $release->decision_id = $decision->id;
     $release->criterion_id = $request->getParameter('criterion_id');
     $form = new ProjectReleaseForm($release);
     $form->bind($request->getParameter($form->getName()));
     if ($form->isValid()) {
         $form->save();
         // Process tags
         $tags_request = json_decode($request->getParameter('tags'));
         foreach ($tags_request as $tag_request) {
             Tag::newTag($this->getUser()->getGuardUser(), $release->id, $tag_request, 'release');
         }
         $release->refresh(true);
         // Create log
         $log = new Log();
         $log->injectDataAndPersist($release, $this->getUser()->getGuardUser(), array('action' => 'new'));
         return $this->renderText(json_encode(array('html' => $this->getPartial('release', array('release' => $release)), 'id' => $release->id)));
     } else {
         return $this->renderPartial('form', array('form' => $form, 'type' => 'new'));
     }
 }
Пример #9
0
 /**
  * @param sfWebRequest $request
  */
 public function executePlanner(sfWebRequest $request)
 {
     $decision_id = $request->getParameter('decision_id', false);
     $this->decision = DecisionTable::getInstance()->getDecisionForUser($this->getUser()->getGuardUser(), $decision_id);
     $this->forward404Unless($this->decision);
     $this->criteriaAnalyze = new CriteriaAnalyze();
     $this->criteriaAnalyze->setDecisionId($decision_id);
     $this->criteriaAnalyze->load();
     $this->logicalFilter = new LogicalFilterView();
     $this->logicalFilter->setDecisionId($decision_id);
     $this->logicalFilter->load();
     $this->roleFilter = new RoleFilterView();
     $this->roleFilter->setDecisionId($decision_id);
     $this->roleFilter->load();
     $this->statusFilter = new StatusFilterView();
     $this->statusFilter->setDecisionId($decision_id);
     $this->statusFilter->load();
     $this->tagFilter = new TagFilterView();
     $this->tagFilter->setDecisionId($decision_id);
     $this->tagFilter->load();
     $this->stackedBarChart = new StackedBarChart();
     $this->stackedBarChart->setDecisionId($decision_id);
     $this->stackedBarChart->setCriteriaValues($this->criteriaAnalyze->getCriteriaValues());
     $this->stackedBarChart->setRoleFilterData($this->roleFilter->getData());
     $this->stackedBarChart->setStatusFilterData($this->statusFilter->getData());
     $this->stackedBarChart->setTagFilterData($this->tagFilter->getDataForSQL());
     $this->stackedBarChart->setFilteredAlternativesIds($this->logicalFilter->getFilteredAlternativesIds());
     $this->stackedBarChart->load();
     $this->costAnalyze = new CostAnalyze();
     $this->costAnalyze->setDecisionId($decision_id);
     $this->costAnalyze->setSortedAlternativeIds($this->stackedBarChart->getSortedAlternativeIds());
     $this->costAnalyze->setRoleFilterData($this->roleFilter->getData());
     $this->costAnalyze->setStatusFilterData($this->statusFilter->getData());
     $this->costAnalyze->setTagFilterData($this->tagFilter->getDataForSQL());
     $this->costAnalyze->setCumulativeData($this->stackedBarChart->getCumulativeData());
     $this->costAnalyze->setFilteredAlternativesIds($this->logicalFilter->getFilteredAlternativesIds());
     $this->costAnalyze->load();
     // release planner
     $this->alternatives_json = AlternativeTable::getInstance()->getDashboardReleaseJSON($decision_id, $this->stackedBarChart->getSortedAlternativeIds());
     $this->releases = ProjectReleaseTable::getInstance()->getList($decision_id);
 }
Пример #10
0
 public function getRoleCreateResponse(sfGuardUser $user)
 {
     /** @var sfWebRequest $request */
     $request = $this->getRequest();
     $decision = DecisionTable::getInstance()->getDecisionForUser($user, $request->getParameter('decision_id'));
     if (is_object($decision)) {
         $role = new Role();
         $role->Decision = $decision;
         $role->name = $request->getParameter('name', 'New role');
         $role->comment = $request->getParameter('description', '');
         try {
             $role->save();
             $result = array('status' => 'success', 'result' => $role->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;
 }
Пример #11
0
 public function executeEdit(sfWebRequest $request, $form = false)
 {
     $this->forward404Unless($roadmap = Doctrine_Core::getTable('Roadmap')->find(array($request->getParameter('id'))), sprintf('Object decision does not exist (%s).', $request->getParameter('id')));
     if (!$form) {
         $form = new RoadmapForm($roadmap);
     }
     $decisions = DecisionTable::getInstance()->getForUser($this->getUser()->getGuardUser(), true);
     $un_grouped_decisions = $grouped_decisions = array();
     foreach ($decisions as $decision) {
         if ($decision->getFolderId()) {
             $grouped_decisions[$decision->getFolder()->getName()][] = $decision;
         } else {
             $un_grouped_decisions[] = $decision;
         }
     }
     $roadmap_decisions = array();
     foreach ($roadmap->getRoadmapDecision() as $roadmap_decision) {
         $roadmap_decisions[] = $roadmap_decision->getDecision()->getId();
     }
     return $this->renderPartial('form', array('form' => $form, 'grouped_decisions' => $grouped_decisions, 'un_grouped_decisions' => $un_grouped_decisions, 'roadmap_decisions' => $roadmap_decisions));
 }
Пример #12
0
 public function executeImport(sfWebRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     $decision_id = $request->getParameter('decision_id', false);
     /** @var Decision $decision */
     $decision = DecisionTable::getInstance()->getDecisionForUser($this->getUser()->getGuardUser(), $decision_id);
     $fileValidator = new sfValidatorFile(array('required' => true));
     $importerClass = $this->model . 'Importer';
     $importer = new $importerClass();
     $importer->setDecision($decision);
     if ($this->model == 'Alternative') {
         $importer->setCreatedAndUpdatedBy(Alternative::generateUpdateAndCreatedBy($this->getUser()->getGuardUser()));
     }
     foreach ($request->getFiles('files') as $file) {
         $validatedFile = $fileValidator->clean($file);
         $importer->setFile($validatedFile);
         $importer->import();
     }
     $this->setLayout(false);
     $this->getResponse()->setHttpHeader('Content-Type', 'application/json; charset=utf-8');
     return $this->renderText(json_encode(array(array())));
 }
Пример #13
0
 /**
  * @param sfWebRequest $request
  * @return sfView
  */
 public function executeImportFromCustomFields(sfWebRequest $request)
 {
     $decision_id = $request->getParameter('decision_id', false);
     $decision = DecisionTable::getInstance()->getDecisionForUser($this->getUser()->getGuardUser(), $decision_id);
     $this->forward404Unless(is_object($decision));
     $header = $request->getParameter('header');
     $data = $request->getParameter('data');
     if (array_search('name', $header) === false) {
         return $this->renderText(json_encode(array('status' => 'error', 'text' => 'Please ensure that data field "Name" is mapped to a column in your SpreadSheet.')));
     }
     foreach ($data as $item) {
         $alternative = null;
         if (array_key_exists('id', $item) && !empty($item['id'])) {
             $alternative = AlternativeTable::getInstance()->createQuery('a')->leftJoin('a.Decision d')->leftJoin('d.User u')->leftJoin('u.TeamMember tm')->whereIn('d.user_id', sfGuardUserTable::getInstance()->getUsersInTeamIDs($this->getUser()->getGuardUser()))->andWhere('a.item_id = ?', $item['id'])->andWhere('d.id = ?', $decision->getId())->fetchOne();
         }
         if (!is_object($alternative)) {
             $alternative = new Alternative();
             $alternative->setDecision($decision);
             $alternative->setCreatedBy(Alternative::generateUpdateAndCreatedBy($this->getUser()->getGuardUser()));
             $alternative->setUpdatedBy(Alternative::generateUpdateAndCreatedBy($this->getUser()->getGuardUser()));
         }
         $custom_fields = array();
         foreach ($item as $prop => $value) {
             if (array_key_exists($prop, $header)) {
                 if ($header[$prop] == '_new') {
                     $custom_fields[$prop] = $value;
                 } elseif (!in_array($header[$prop], array('id')) && in_array($header[$prop], array('name', 'status', 'work progress', 'additional info', 'notes', 'due date', 'notify date', 'tags'))) {
                     if ($header[$prop] == 'tags') {
                         // Process tags
                         $tags_request = array_map('trim', explode(',', $value));
                         $tags = array();
                         foreach ($alternative->getTagAlternative() as $tag) {
                             $tags[] = $tag->Tag->name;
                         }
                         foreach (array_diff($tags_request, $tags) as $result) {
                             Tag::newTag($this->getUser()->getGuardUser(), $alternative->getId(), $result, 'alternative');
                         }
                         foreach (array_diff($tags, $tags_request) as $result) {
                             Tag::removeTag($this->getUser()->getGuardUser(), $alternative->getId(), $result, 'alternative');
                         }
                     } else {
                         $alternative->{str_replace(' ', '_', $header[$prop])} = $value;
                     }
                 }
             }
         }
         if ($custom_fields) {
             $alternative->setCustomFields(json_encode($custom_fields));
         }
         if (!$alternative->getName()) {
             $alternative->setName('New ' . InterfaceLabelTable::getInstance()->get($this->getUser()->getGuardUser(), InterfaceLabelTable::ITEM_TYPE));
         }
         $alternative->save();
     }
     return $this->renderText(json_encode(array('status' => 'success')));
 }
Пример #14
0
 public function executeAlternativeImport(sfWebRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     $decision_id = $request->getParameter('decision_id', false);
     /** @var Decision $decision */
     $decision = DecisionTable::getInstance()->getDecisionForUser($this->getUser()->getGuardUser(), $decision_id);
     $fileValidator = new sfValidatorFile(array('required' => true));
     $importer = new AlternativeImporter();
     $importer->setDecision($decision);
     $importer->setCreatedAndUpdatedBy(Alternative::generateUpdateAndCreatedBy($this->getUser()->getGuardUser()));
     foreach ($request->getFiles('files') as $file) {
         $validatedFile = $fileValidator->clean($file);
         $importer->setFile($validatedFile);
         $importer->import();
     }
     $dashboard_role = $decision->getDashboardRole();
     if ($dashboard_role) {
         foreach ($importer->getAlternatives() as $alternative) {
             foreach ($decision->getCriterion() as $criterion) {
                 $planned_alternative_measurement = new PlannedAlternativeMeasurement();
                 $planned_alternative_measurement->setAlternative($alternative);
                 $planned_alternative_measurement->setCriterion($criterion);
                 $dashboard_role->PlannedAlternativeMeasurement->add($planned_alternative_measurement);
             }
         }
         $dashboard_role->PlannedAlternativeMeasurement->save();
     }
     $this->setLayout(false);
     $this->getResponse()->setHttpHeader('Content-Type', 'application/json; charset=utf-8');
     return $this->renderText(json_encode(array(array())));
 }
Пример #15
0
 /**
  * @param sfWebRequest $request
  * @return sfView
  */
 public function executeImportFromTrello(sfWebRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     if (!DecisionTable::getInstance()->verifyAvailableName($this->getUser()->getGuardUser(), $request->getParameter('board_name'))) {
         return $this->renderText(json_encode(array('status' => 'error', 'message' => 'A project with that name already exists')));
     }
     $decision = new Decision();
     $decision->setName($request->getParameter('board_name'));
     $decision->setUserId($this->getUser()->getGuardUser()->getId());
     $decision->setExternalId($request->getParameter('board_id'));
     $decision->setTypeId(2);
     $type_template = TypeTemplate::getInstance()->createQuery('t')->where('t.user_id is NULL')->andWhere('t.type_id = ?', 2)->andWhere('t.name = ?', 'Default')->fetchOne();
     $decision->setTemplateId($type_template->getId());
     // Default template
     $decision->setFolderId(FolderTable::getInstance()->getNotDeletableForUser($this->getUser()->getGuardUser(), Folder::TYPE_PROJECT)->getId());
     $decision->save();
     $dashboard_role = $decision->getDashboardRole();
     foreach (json_decode($request->getParameter('cards', '{}')) as $card) {
         $alternative = new Alternative();
         $alternative->setName($card->name);
         $alternative->setDecisionId($decision->getId());
         $alternative->setAdditionalInfo($card->desc);
         $alternative->setNotes($card->notes);
         $alternative->setExternalId($card->id);
         $alternative->setCreatedBy($request->getParameter('full_name') . ' (via Trello)');
         $alternative->setUpdatedBy($request->getParameter('full_name') . ' (via Trello)');
         if ($card->due) {
             $date = DateTime::createFromFormat('Y-m-d\\TH:i:s.000Z', $card->due);
             $alternative->setDueDate($date->format('Y-m-d H:i:s'));
             $alternative->setNotifyDate($date->format('Y-m-d H:i:s'));
         }
         $alternative->save();
         foreach ($card->labels as $label) {
             Tag::newTag($this->getUser()->getGuardUser(), $alternative->getId(), $label, 'alternative');
         }
         if ($dashboard_role) {
             foreach ($decision->getCriterion() as $criterion) {
                 $planned_alternative_measurement = new PlannedAlternativeMeasurement();
                 $planned_alternative_measurement->setAlternative($alternative);
                 $planned_alternative_measurement->setCriterion($criterion);
                 $dashboard_role->PlannedAlternativeMeasurement->add($planned_alternative_measurement);
             }
         }
     }
     $dashboard_role->PlannedAlternativeMeasurement->save();
     if ($request->getParameter('wizard')) {
         $user = $this->getUser()->getGuardUser();
         $user->setWizard(false);
         $user->save();
     }
     // Create log
     $log = new Log();
     $log->setAction('project_create');
     $log->setUserId($this->getUser()->getGuardUser()->id);
     $log->setInformation(json_encode(array('decision_name' => $decision->getName(), 'decision_type' => $decision->getTypeId(), 'decision_template' => $decision->getTemplateId(), 'imported' => 'Trello')));
     $log->save();
     return $this->renderText(json_encode(array('status' => 'success', 'dashboard_url' => $this->generateUrl('dashboard', array('decision_id' => $decision->getId())))));
 }
Пример #16
0
 public function render()
 {
     $decision = DecisionTable::getInstance()->find($this->decision_id);
     sfContext::getInstance()->getConfiguration()->loadHelpers('Partial');
     include_partial('criteria_chart', array('analyze' => $this, 'decision' => $decision));
 }