3 final class PhortuneOrderTableView
extends AphrontView
{
8 private $isMerchantView;
11 public function setCarts(array $carts) {
12 $this->carts
= $carts;
16 public function getCarts() {
20 public function setIsInvoices($is_invoices) {
21 $this->isInvoices
= $is_invoices;
25 public function getIsInvoices() {
26 return $this->isInvoices
;
29 public function setNoDataString($no_data_string) {
30 $this->noDataString
= $no_data_string;
34 public function getNoDataString() {
35 return $this->noDataString
;
38 public function setIsMerchantView($is_merchant_view) {
39 $this->isMerchantView
= $is_merchant_view;
43 public function getIsMerchantView() {
44 return $this->isMerchantView
;
47 public function setAccountEmail(PhortuneAccountEmail
$account_email) {
48 $this->accountEmail
= $account_email;
52 public function getAccountEmail() {
53 return $this->accountEmail
;
56 public function render() {
57 $carts = $this->getCarts();
58 $viewer = $this->getUser();
60 $is_invoices = $this->getIsInvoices();
61 $is_merchant = $this->getIsMerchantView();
62 $is_external = (bool)$this->getAccountEmail();
64 $email = $this->getAccountEmail();
67 foreach ($carts as $cart) {
68 $phids[] = $cart->getPHID();
69 foreach ($cart->getPurchases() as $purchase) {
70 $phids[] = $purchase->getPHID();
72 $phids[] = $cart->getMerchantPHID();
75 $handles = $viewer->loadHandles($phids);
79 foreach ($carts as $cart) {
81 $cart_link = phutil_tag(
84 'href' => $email->getExternalOrderURI($cart),
86 $handles[$cart->getPHID()]->getName());
88 $cart_link = $handles[$cart->getPHID()]->renderLink();
90 $purchases = $cart->getPurchases();
92 if (count($purchases) == 1) {
93 $purchase = head($purchases);
94 $purchase_name = $handles[$purchase->getPHID()]->getName();
102 $merchant_link = $handles[$cart->getMerchantPHID()]->getName();
104 $merchant_link = $handles[$cart->getMerchantPHID()]->renderLink();
107 $merchant_link = null;
122 $cart->getTotalPriceAsCurrency()->formatForDisplay()),
123 PhortuneCart
::getNameForStatus($cart->getStatus()),
124 phabricator_datetime($cart->getDateModified(), $viewer),
125 phabricator_datetime($cart->getDateCreated(), $viewer),
126 id(new PHUIButtonView())
129 ->setHref($cart->getCheckoutURI())
130 ->setText(pht('Pay Now'))
131 ->setIcon('fa-credit-card'),
133 foreach ($purchases as $purchase) {
134 $id = $purchase->getID();
136 $price = $purchase->getTotalPriceAsCurrency()->formatForDisplay();
142 $handles[$purchase->getPHID()]->renderLink(),
152 $table = id(new AphrontTableView($rows))
153 ->setNoDataString($this->getNoDataString())
154 ->setRowClasses($rowc)
159 $is_invoices ?
pht('Invoice') : pht('Order'),
179 ->setColumnVisibility(
190 // We show "Pay Now" for due invoices, but not if the viewer is the
191 // merchant, since it doesn't make sense for them to pay.
192 ($is_invoices && !$is_merchant && !$is_external),