public function render() { $carts = $this->getCarts(); $handles = $this->getHandles(); $viewer = $this->getUser(); $is_invoices = $this->getIsInvoices(); $is_merchant = $this->getIsMerchantView(); $rows = array(); $rowc = array(); foreach ($carts as $cart) { $cart_link = $handles[$cart->getPHID()]->renderLink(); $purchases = $cart->getPurchases(); if (count($purchases) == 1) { $purchase = head($purchases); $purchase_name = $handles[$purchase->getPHID()]->renderLink(); $purchases = array(); } else { $purchase_name = ''; } if ($is_invoices) { $merchant_link = $handles[$cart->getMerchantPHID()]->renderLink(); } else { $merchant_link = null; } $rowc[] = ''; $rows[] = array($cart->getID(), $merchant_link, phutil_tag('strong', array(), $cart_link), $purchase_name, phutil_tag('strong', array(), $cart->getTotalPriceAsCurrency()->formatForDisplay()), PhortuneCart::getNameForStatus($cart->getStatus()), phabricator_datetime($cart->getDateModified(), $viewer), phabricator_datetime($cart->getDateCreated(), $viewer), phutil_tag('a', array('href' => $cart->getCheckoutURI(), 'class' => 'small green button'), pht('Pay Now'))); foreach ($purchases as $purchase) { $id = $purchase->getID(); $price = $purchase->getTotalPriceAsCurrency()->formatForDisplay(); $rowc[] = ''; $rows[] = array('', '', $handles[$purchase->getPHID()]->renderLink(), $price, '', '', '', ''); } } $table = id(new AphrontTableView($rows))->setNoDataString($this->getNoDataString())->setRowClasses($rowc)->setHeaders(array(pht('ID'), pht('Merchant'), $is_invoices ? pht('Invoice') : pht('Order'), pht('Purchase'), pht('Amount'), pht('Status'), pht('Updated'), pht('Invoice Date'), null))->setColumnClasses(array('', '', '', 'wide', 'right', '', 'right', 'right', 'action'))->setColumnVisibility(array(true, $is_invoices, true, true, true, !$is_invoices, !$is_invoices, $is_invoices, $is_invoices && !$is_merchant)); return $table; }
private function buildPropertyListView(PhortuneCart $cart) { $viewer = $this->getRequest()->getUser(); $view = id(new PHUIPropertyListView())->setUser($viewer)->setObject($cart); $handles = $this->loadViewerHandles(array($cart->getAccountPHID(), $cart->getAuthorPHID(), $cart->getMerchantPHID())); $view->addProperty(pht('Order Name'), $cart->getName()); $view->addProperty(pht('Account'), $handles[$cart->getAccountPHID()]->renderLink()); $view->addProperty(pht('Authorized By'), $handles[$cart->getAuthorPHID()]->renderLink()); $view->addProperty(pht('Merchant'), $handles[$cart->getMerchantPHID()]->renderLink()); $view->addProperty(pht('Status'), PhortuneCart::getNameForStatus($cart->getStatus())); $view->addProperty(pht('Updated'), phabricator_datetime($cart->getDateModified(), $viewer)); return $view; }
protected function renderResultList(array $carts, PhabricatorSavedQuery $query, array $handles) { assert_instances_of($carts, 'PhortuneCart'); $viewer = $this->requireViewer(); $rows = array(); foreach ($carts as $cart) { $merchant = $cart->getMerchant(); if ($this->getMerchant()) { $href = $this->getApplicationURI('merchant/' . $merchant->getID() . '/cart/' . $cart->getID() . '/'); } else { $href = $cart->getDetailURI(); } $rows[] = array($cart->getID(), $handles[$cart->getPHID()]->renderLink(), $handles[$merchant->getPHID()]->renderLink(), $handles[$cart->getAuthorPHID()]->renderLink(), $cart->getTotalPriceAsCurrency()->formatForDisplay(), PhortuneCart::getNameForStatus($cart->getStatus()), phabricator_datetime($cart->getDateModified(), $viewer)); } $table = id(new AphrontTableView($rows))->setNoDataString(pht('No orders match the query.'))->setHeaders(array(pht('ID'), pht('Order'), pht('Merchant'), pht('Authorized By'), pht('Amount'), pht('Status'), pht('Updated')))->setColumnClasses(array('', 'pri', '', '', 'wide right', '', 'right')); $merchant = $this->getMerchant(); if ($merchant) { $notice = pht('Orders for %s', $merchant->getName()); } else { $notice = pht('Your Orders'); } $table->setNotice($notice); $result = new PhabricatorApplicationSearchResultView(); $result->setTable($table); return $result; }
private function buildDetailsView(PhortuneCart $cart) { $viewer = $this->getViewer(); $view = id(new PHUIPropertyListView())->setUser($viewer)->setObject($cart); $handles = $this->loadViewerHandles(array($cart->getAccountPHID(), $cart->getAuthorPHID(), $cart->getMerchantPHID())); $view->addProperty(pht('Order Name'), $cart->getName()); $view->addProperty(pht('Account'), $handles[$cart->getAccountPHID()]->renderLink()); $view->addProperty(pht('Authorized By'), $handles[$cart->getAuthorPHID()]->renderLink()); $view->addProperty(pht('Merchant'), $handles[$cart->getMerchantPHID()]->renderLink()); $view->addProperty(pht('Status'), PhortuneCart::getNameForStatus($cart->getStatus())); $view->addProperty(pht('Updated'), phabricator_datetime($cart->getDateModified(), $viewer)); return id(new PHUIObjectBoxView())->setHeaderText(pht('Details'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->appendChild($view); }