private function getTreeOfAllSubordinatedActions(C3op_Projects_Action $action, C3op_Projects_ActionMapper $actionMapper) { $tree = array(); $subordinatedIds = $actionMapper->getActionsSubordinatedTo($action); $a = $action->GetId(); if (count($subordinatedIds) > 0) { foreach ($subordinatedIds as $key => $id) { $loopAction = $actionMapper->findById($id); $tree[$id] = $this->getTreeOfAllSubordinatedActions($loopAction, $actionMapper); } } return $tree; }
public function GetAllActionsSubordinatedTo(C3op_Projects_Action $action, C3op_Projects_ActionMapper $actionMapper, C3op_Projects_Project $project, C3op_Projects_ProjectMapper $projectMapper) { echo "<hr>entering getallactionssubordinatedto<br>"; echo "action " . $action->GetId() . " - " . $action->GetTitle() . "<br>"; echo "project " . $project->GetId() . "<br>"; $allActionsBelowMe = array(); $actionsIdJustBelowMe = $actionMapper->getActionsSubordinatedTo($action); while (list(, $actionId) = each($actionsIdJustBelowMe)) { $thisAction = $actionMapper->findById($actionId); $actionsJustBelowMe = $this->GetAllActionsSubordinatedTo($thisAction, $actionMapper, $project, $projectMapper); $allActionsBelowMe[] = array("action" => $thisAction, "actionsBelow" => $actionsJustBelowMe); } echo "returning from getallactionssubordinatedto<br>"; echo "action " . $action->GetId() . " - " . $action->GetTitle() . "<br>"; echo "project " . $project->GetId() . "<br>"; print_r($allActionsBelowMe); echo "count allactionsbelowme " . count($allActionsBelowMe) . "<br><hr><br>"; return $allActionsBelowMe; }
public function detailAction() { $actionMapper = new C3op_Projects_ActionMapper($this->db); if (!isset($this->projectMapper)) { $this->initProjectMapper(); } $projectToBeDetailed = $this->InitProjectWithCheckedId($this->projectMapper); $linkReceivables = $this->manageReceivablesLink($projectToBeDetailed); $linkPayables = $this->managePayablesLink($projectToBeDetailed); $linkUnacknowledged = $this->manageUnacknowledgedLink($projectToBeDetailed); $linkTree = $this->manageTreeLink($projectToBeDetailed); $projectProducts = $this->projectMapper->getAllProductsOf($projectToBeDetailed); $actionsList = array(); reset($actionsList); foreach ($projectProducts as $actionId) { $this->detailProductBreeds = array(); $this->detailProductBrood = 0; $this->detailProductDepth = 0; $thisAction = $actionMapper->findById($actionId); $immediateBreed = $actionMapper->getActionsSubordinatedTo($thisAction); if (count($immediateBreed) > 0) { $broodMessage = count($immediateBreed) . " ações diretamente subordinadas"; if (count($immediateBreed) == 1) { $broodMessage = count($immediateBreed) . " ação diretamente subordinada"; } } else { $broodMessage = "sem ações diretamente subordinadas"; } $actionTitle = sprintf("<a href=/projects/action/detail/?id=%d>%s</a>", $actionId, $thisAction->GetTitle()); $specialActionLabel = $this->buildSpecialActionLabel($thisAction); $actionsList[$actionId] = array('title' => $actionTitle, 'depth' => $this->detailProductDepth, 'brood' => $broodMessage, 'specialAction' => $specialActionLabel, 'editLink' => '/projects/action/edit/?id=' . $actionId); } $projectInfo = array('title' => $projectToBeDetailed->GetTitle(), 'editLink' => '/projects/project/edit/?id=' . $projectToBeDetailed->GetId(), 'linkReceivables' => $linkReceivables, 'linkPayables' => $linkPayables, 'linkUnacknowledged' => $linkUnacknowledged, 'linkTree' => $linkTree, 'beginDate' => C3op_Util_DateDisplay::FormatDateToShow($projectToBeDetailed->GetBeginDate()), 'value' => C3op_Util_CurrencyDisplay::FormatCurrency($projectToBeDetailed->GetValue()), 'linkActionCreate' => '/projects/action/create/?project=' . $projectToBeDetailed->GetId(), 'actionsList' => $actionsList); $this->view->projectInfo = $projectInfo; }