3 final class FundInitiativeViewController
4 extends FundController
{
6 public function shouldAllowPublic() {
10 public function handleRequest(AphrontRequest
$request) {
11 $viewer = $request->getViewer();
12 $id = $request->getURIData('id');
14 $initiative = id(new FundInitiativeQuery())
19 return new Aphront404Response();
22 $crumbs = $this->buildApplicationCrumbs();
23 $crumbs->addTextCrumb($initiative->getMonogram());
24 $crumbs->setBorder(true);
28 $initiative->getMonogram(),
29 $initiative->getName());
31 if ($initiative->isClosed()) {
32 $status_icon = 'fa-ban';
33 $status_color = 'indigo';
35 $status_icon = 'fa-check';
36 $status_color = 'bluegrey';
39 FundInitiative
::getStatusNameMap(),
40 $initiative->getStatus());
42 $header = id(new PHUIHeaderView())
43 ->setHeader($initiative->getName())
45 ->setPolicyObject($initiative)
46 ->setStatus($status_icon, $status_color, $status_name)
47 ->setHeaderIcon('fa-heart');
49 $curtain = $this->buildCurtain($initiative);
50 $details = $this->buildPropertySectionView($initiative);
52 $timeline = $this->buildTransactionTimeline(
54 new FundInitiativeTransactionQuery());
55 $timeline->setQuoteRef($initiative->getMonogram());
57 $comment_view = $this->buildCommentForm($initiative, $timeline);
59 $view = id(new PHUITwoColumnView())
61 ->setCurtain($curtain)
62 ->setMainColumn(array(
66 ->addPropertySection(pht('Details'), $details);
68 return $this->newPage()
71 ->setPageObjectPHIDs(array($initiative->getPHID()))
75 private function buildPropertySectionView(FundInitiative
$initiative) {
76 $viewer = $this->getRequest()->getUser();
78 $view = id(new PHUIPropertyListView())
81 $owner_phid = $initiative->getOwnerPHID();
82 $merchant_phid = $initiative->getMerchantPHID();
86 $viewer->renderHandle($owner_phid));
89 pht('Payable to Merchant'),
90 $viewer->renderHandle($merchant_phid));
94 $initiative->getTotalAsCurrency()->formatForDisplay());
96 $description = $initiative->getDescription();
97 if (strlen($description)) {
98 $description = new PHUIRemarkupView($viewer, $description);
99 $view->addSectionHeader(
100 pht('Description'), PHUIPropertyListView
::ICON_SUMMARY
);
101 $view->addTextContent($description);
104 $risks = $initiative->getRisks();
105 if (strlen($risks)) {
106 $risks = new PHUIRemarkupView($viewer, $risks);
107 $view->addSectionHeader(
108 pht('Risks/Challenges'), 'fa-ambulance');
109 $view->addTextContent($risks);
115 private function buildCurtain(FundInitiative
$initiative) {
116 $viewer = $this->getViewer();
118 $id = $initiative->getID();
120 $can_edit = PhabricatorPolicyFilter
::hasCapability(
123 PhabricatorPolicyCapability
::CAN_EDIT
);
125 $curtain = $this->newCurtainView($initiative);
128 id(new PhabricatorActionView())
129 ->setName(pht('Edit Initiative'))
130 ->setIcon('fa-pencil')
131 ->setDisabled(!$can_edit)
132 ->setWorkflow(!$can_edit)
133 ->setHref($this->getApplicationURI("/edit/{$id}/")));
135 if ($initiative->isClosed()) {
136 $close_name = pht('Reopen Initiative');
137 $close_icon = 'fa-check';
139 $close_name = pht('Close Initiative');
140 $close_icon = 'fa-times';
144 id(new PhabricatorActionView())
145 ->setName($close_name)
146 ->setIcon($close_icon)
147 ->setDisabled(!$can_edit)
149 ->setHref($this->getApplicationURI("/close/{$id}/")));
152 id(new PhabricatorActionView())
153 ->setName(pht('Back Initiative'))
154 ->setIcon('fa-money')
155 ->setDisabled($initiative->isClosed())
157 ->setHref($this->getApplicationURI("/back/{$id}/")));
160 id(new PhabricatorActionView())
161 ->setName(pht('View Backers'))
163 ->setHref($this->getApplicationURI("/backers/{$id}/")));
168 private function buildCommentForm(FundInitiative
$initiative, $timeline) {
169 $viewer = $this->getViewer();
170 $box = id(new FundInitiativeEditEngine())
172 ->buildEditEngineCommentView($initiative)
173 ->setTransactionTimeline($timeline);