private function buildPaymentMethodsSection(PhortuneAccount $account)
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $account, PhabricatorPolicyCapability::CAN_EDIT);
     $id = $account->getID();
     $header = id(new PHUIHeaderView())->setHeader(pht('Payment Methods'))->addActionLink(id(new PHUIButtonView())->setTag('a')->setHref($this->getApplicationURI($id . '/card/new/'))->setText(pht('Add Payment Method'))->setIcon(id(new PHUIIconView())->setIconFont('fa-plus')));
     $list = id(new PHUIObjectItemListView())->setUser($viewer)->setNoDataString(pht('No payment methods associated with this account.'));
     $methods = id(new PhortunePaymentMethodQuery())->setViewer($viewer)->withAccountPHIDs(array($account->getPHID()))->execute();
     if ($methods) {
         $this->loadHandles(mpull($methods, 'getAuthorPHID'));
     }
     foreach ($methods as $method) {
         $id = $method->getID();
         $item = new PHUIObjectItemView();
         $item->setHeader($method->getFullDisplayName());
         switch ($method->getStatus()) {
             case PhortunePaymentMethod::STATUS_ACTIVE:
                 $item->setBarColor('green');
                 $disable_uri = $this->getApplicationURI('card/' . $id . '/disable/');
                 $item->addAction(id(new PHUIListItemView())->setIcon('fa-times')->setHref($disable_uri)->setDisabled(!$can_edit)->setWorkflow(true));
                 break;
             case PhortunePaymentMethod::STATUS_DISABLED:
                 $item->setDisabled(true);
                 break;
         }
         $provider = $method->buildPaymentProvider();
         $item->addAttribute($provider->getPaymentMethodProviderDescription());
         $item->setImageURI($provider->getPaymentMethodIcon());
         $edit_uri = $this->getApplicationURI('card/' . $id . '/edit/');
         $item->addAction(id(new PHUIListItemView())->setIcon('fa-pencil')->setHref($edit_uri)->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
         $list->addItem($item);
     }
     return id(new PHUIObjectBoxView())->setHeader($header)->appendChild($list);
 }
예제 #2
0
 public function render()
 {
     $handles = $this->handles;
     require_celerity_resource('maniphest-task-summary-css');
     $list = new PHUIObjectItemListView();
     $list->setFlush(true);
     $status_map = ManiphestTaskStatus::getTaskStatusMap();
     $color_map = ManiphestTaskPriority::getColorMap();
     if ($this->showBatchControls) {
         Javelin::initBehavior('maniphest-list-editor');
     }
     foreach ($this->tasks as $task) {
         $item = new PHUIObjectItemView();
         $item->setObjectName('T' . $task->getID());
         $item->setHeader($task->getTitle());
         $item->setHref('/T' . $task->getID());
         if ($task->getOwnerPHID()) {
             $owner = $handles[$task->getOwnerPHID()];
             $item->addByline(pht('Assigned: %s', $owner->renderLink()));
         }
         $status = $task->getStatus();
         if ($task->isClosed()) {
             $item->setDisabled(true);
         }
         $item->setBarColor(idx($color_map, $task->getPriority(), 'grey'));
         $item->addIcon('none', phabricator_datetime($task->getDateModified(), $this->getUser()));
         if ($this->showSubpriorityControls) {
             $item->setGrippable(true);
         }
         if ($this->showSubpriorityControls || $this->showBatchControls) {
             $item->addSigil('maniphest-task');
         }
         $project_handles = array_select_keys($handles, $task->getProjectPHIDs());
         $item->addAttribute(id(new PHUIHandleTagListView())->setLimit(4)->setNoDataString(pht('No Projects'))->setSlim(true)->setHandles($project_handles));
         $item->setMetadata(array('taskID' => $task->getID()));
         if ($this->showBatchControls) {
             $href = new PhutilURI('/maniphest/task/edit/' . $task->getID() . '/');
             if (!$this->showSubpriorityControls) {
                 $href->setQueryParam('ungrippable', 'true');
             }
             $item->addAction(id(new PHUIListItemView())->setIcon('fa-pencil')->addSigil('maniphest-edit-task')->setHref($href));
         }
         $list->addItem($item);
     }
     return $list;
 }
 protected function renderResultList(array $questions, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($questions, 'PonderQuestion');
     $viewer = $this->requireViewer();
     $view = id(new PHUIObjectItemListView())->setUser($viewer);
     foreach ($questions as $question) {
         $item = new PHUIObjectItemView();
         $item->setObjectName('Q' . $question->getID());
         $item->setHeader($question->getTitle());
         $item->setHref('/Q' . $question->getID());
         $item->setObject($question);
         $item->setBarColor(PonderQuestionStatus::getQuestionStatusTagColor($question->getStatus()));
         $created_date = phabricator_date($question->getDateCreated(), $viewer);
         $item->addIcon('none', $created_date);
         $item->addByline(pht('Asked by %s', $handles[$question->getAuthorPHID()]->renderLink()));
         $item->addAttribute(pht('%d Answer(s)', $question->getAnswerCount()));
         $view->addItem($item);
     }
     return $view;
 }
예제 #4
0
 protected function renderResultList(array $usertimes, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($usertimes, 'PhrequentUserTime');
     $viewer = $this->requireViewer();
     $view = id(new PHUIObjectItemListView())->setUser($viewer);
     foreach ($usertimes as $usertime) {
         $item = new PHUIObjectItemView();
         if ($usertime->getObjectPHID() === null) {
             $item->setHeader($usertime->getNote());
         } else {
             $obj = $handles[$usertime->getObjectPHID()];
             $item->setHeader($obj->getLinkName());
             $item->setHref($obj->getURI());
         }
         $item->setObject($usertime);
         $item->addByline(pht('Tracked: %s', $handles[$usertime->getUserPHID()]->renderLink()));
         $started_date = phabricator_date($usertime->getDateStarted(), $viewer);
         $item->addIcon('none', $started_date);
         $block = new PhrequentTimeBlock(array($usertime));
         $time_spent = $block->getTimeSpentOnObject($usertime->getObjectPHID(), PhabricatorTime::getNow());
         $time_spent = $time_spent == 0 ? 'none' : phutil_format_relative_time_detailed($time_spent);
         if ($usertime->getDateEnded() !== null) {
             $item->addAttribute(pht('Tracked %s', $time_spent));
             $item->addAttribute(pht('Ended on %s', phabricator_datetime($usertime->getDateEnded(), $viewer)));
         } else {
             $item->addAttribute(pht('Tracked %s so far', $time_spent));
             if ($usertime->getObjectPHID() !== null && $usertime->getUserPHID() === $viewer->getPHID()) {
                 $item->addAction(id(new PHUIListItemView())->setIcon('fa-stop')->addSigil('phrequent-stop-tracking')->setWorkflow(true)->setRenderNameAsTooltip(true)->setName(pht('Stop'))->setHref('/phrequent/track/stop/' . $usertime->getObjectPHID() . '/'));
             }
             $item->setBarColor('green');
         }
         $view->addItem($item);
     }
     return $view;
 }