Page MenuHomePhabricator

D10685.id25653.diff
No OneTemporary

D10685.id25653.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2572,8 +2572,11 @@
'PhortuneCartUpdateController' => 'applications/phortune/controller/PhortuneCartUpdateController.php',
'PhortuneCartViewController' => 'applications/phortune/controller/PhortuneCartViewController.php',
'PhortuneCharge' => 'applications/phortune/storage/PhortuneCharge.php',
+ 'PhortuneChargeListController' => 'applications/phortune/controller/PhortuneChargeListController.php',
'PhortuneChargePHIDType' => 'applications/phortune/phid/PhortuneChargePHIDType.php',
'PhortuneChargeQuery' => 'applications/phortune/query/PhortuneChargeQuery.php',
+ 'PhortuneChargeSearchEngine' => 'applications/phortune/query/PhortuneChargeSearchEngine.php',
+ 'PhortuneChargeTableView' => 'applications/phortune/view/PhortuneChargeTableView.php',
'PhortuneConstants' => 'applications/phortune/constants/PhortuneConstants.php',
'PhortuneController' => 'applications/phortune/controller/PhortuneController.php',
'PhortuneCreditCardForm' => 'applications/phortune/view/PhortuneCreditCardForm.php',
@@ -2602,6 +2605,7 @@
'PhortuneMultiplePaymentProvidersException' => 'applications/phortune/exception/PhortuneMultiplePaymentProvidersException.php',
'PhortuneNoPaymentProviderException' => 'applications/phortune/exception/PhortuneNoPaymentProviderException.php',
'PhortuneNotImplementedException' => 'applications/phortune/exception/PhortuneNotImplementedException.php',
+ 'PhortuneOrderTableView' => 'applications/phortune/view/PhortuneOrderTableView.php',
'PhortunePayPalPaymentProvider' => 'applications/phortune/provider/PhortunePayPalPaymentProvider.php',
'PhortunePaymentMethod' => 'applications/phortune/storage/PhortunePaymentMethod.php',
'PhortunePaymentMethodCreateController' => 'applications/phortune/controller/PhortunePaymentMethodCreateController.php',
@@ -5639,8 +5643,11 @@
'PhortuneDAO',
'PhabricatorPolicyInterface',
),
+ 'PhortuneChargeListController' => 'PhortuneController',
'PhortuneChargePHIDType' => 'PhabricatorPHIDType',
'PhortuneChargeQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'PhortuneChargeSearchEngine' => 'PhabricatorApplicationSearchEngine',
+ 'PhortuneChargeTableView' => 'AphrontView',
'PhortuneController' => 'PhabricatorController',
'PhortuneCurrency' => 'Phobject',
'PhortuneCurrencySerializer' => 'PhabricatorLiskSerializer',
@@ -5670,6 +5677,7 @@
'PhortuneMultiplePaymentProvidersException' => 'Exception',
'PhortuneNoPaymentProviderException' => 'Exception',
'PhortuneNotImplementedException' => 'Exception',
+ 'PhortuneOrderTableView' => 'AphrontView',
'PhortunePayPalPaymentProvider' => 'PhortunePaymentProvider',
'PhortunePaymentMethod' => array(
'PhortuneDAO',
diff --git a/src/applications/phortune/application/PhabricatorPhortuneApplication.php b/src/applications/phortune/application/PhabricatorPhortuneApplication.php
--- a/src/applications/phortune/application/PhabricatorPhortuneApplication.php
+++ b/src/applications/phortune/application/PhabricatorPhortuneApplication.php
@@ -39,6 +39,10 @@
'card/' => array(
'new/' => 'PhortunePaymentMethodCreateController',
),
+ 'order/(?:query/(?P<queryKey>[^/]+)/)?'
+ => 'PhortuneCartListController',
+ 'charge/(?:query/(?P<queryKey>[^/]+)/)?'
+ => 'PhortuneChargeListController',
),
'card/(?P<id>\d+)/' => array(
'edit/' => 'PhortunePaymentMethodEditController',
diff --git a/src/applications/phortune/controller/PhortuneAccountListController.php b/src/applications/phortune/controller/PhortuneAccountListController.php
--- a/src/applications/phortune/controller/PhortuneAccountListController.php
+++ b/src/applications/phortune/controller/PhortuneAccountListController.php
@@ -83,8 +83,8 @@
->setHref($this->getApplicationURI('merchant/'))
->setIcon(
id(new PHUIIconView())
- ->setIconFont('fa-folder-open'))
- ->setText(pht('Browse Merchants')));
+ ->setIconFont('fa-list'))
+ ->setText(pht('View All Merchants')));
$merchant_box = id(new PHUIObjectBoxView())
->setHeader($merchant_header)
diff --git a/src/applications/phortune/controller/PhortuneAccountViewController.php b/src/applications/phortune/controller/PhortuneAccountViewController.php
--- a/src/applications/phortune/controller/PhortuneAccountViewController.php
+++ b/src/applications/phortune/controller/PhortuneAccountViewController.php
@@ -179,6 +179,7 @@
PhortuneCart::STATUS_REVIEW,
PhortuneCart::STATUS_PURCHASED,
))
+ ->setLimit(10)
->execute();
$phids = array();
@@ -190,73 +191,23 @@
}
$handles = $this->loadViewerHandles($phids);
- $rows = array();
- $rowc = array();
- foreach ($carts as $cart) {
- $cart_link = $handles[$cart->getPHID()]->renderLink();
- $purchases = $cart->getPurchases();
-
- if (count($purchases) == 1) {
- $purchase_name = $handles[$purchase->getPHID()]->renderLink();
- $purchases = array();
- } else {
- $purchase_name = '';
- }
-
- $rowc[] = '';
- $rows[] = array(
- $cart->getID(),
- phutil_tag(
- 'strong',
- array(),
- $cart_link),
- $purchase_name,
- phutil_tag(
- 'strong',
- array(),
- $cart->getTotalPriceAsCurrency()->formatForDisplay()),
- PhortuneCart::getNameForStatus($cart->getStatus()),
- phabricator_datetime($cart->getDateModified(), $viewer),
- );
- foreach ($purchases as $purchase) {
- $id = $purchase->getID();
-
- $price = $purchase->getTotalPriceAsCurrency()->formatForDisplay();
-
- $rowc[] = '';
- $rows[] = array(
- '',
- $handles[$purchase->getPHID()]->renderLink(),
- $price,
- '',
- '',
- );
- }
- }
+ $orders_uri = $this->getApplicationURI($account->getID().'/order/');
- $table = id(new AphrontTableView($rows))
- ->setRowClasses($rowc)
- ->setHeaders(
- array(
- pht('ID'),
- pht('Order'),
- pht('Purchase'),
- pht('Amount'),
- pht('Status'),
- pht('Updated'),
- ))
- ->setColumnClasses(
- array(
- '',
- '',
- 'wide',
- 'right',
- '',
- 'right',
- ));
+ $table = id(new PhortuneOrderTableView())
+ ->setUser($viewer)
+ ->setCarts($carts)
+ ->setHandles($handles);
$header = id(new PHUIHeaderView())
- ->setHeader(pht('Order History'));
+ ->setHeader(pht('Recent Orders'))
+ ->addActionLink(
+ id(new PHUIButtonView())
+ ->setTag('a')
+ ->setIcon(
+ id(new PHUIIconView())
+ ->setIconFont('fa-list'))
+ ->setHref($orders_uri)
+ ->setText(pht('View All Orders')));
return id(new PHUIObjectBoxView())
->setHeader($header)
@@ -271,9 +222,40 @@
->setViewer($viewer)
->withAccountPHIDs(array($account->getPHID()))
->needCarts(true)
+ ->setLimit(10)
->execute();
- return $this->buildChargesTable($charges);
+ $phids = array();
+ foreach ($charges as $charge) {
+ $phids[] = $charge->getProviderPHID();
+ $phids[] = $charge->getCartPHID();
+ $phids[] = $charge->getMerchantPHID();
+ $phids[] = $charge->getPaymentMethodPHID();
+ }
+
+ $handles = $this->loadViewerHandles($phids);
+
+ $charges_uri = $this->getApplicationURI($account->getID().'/charge/');
+
+ $table = id(new PhortuneChargeTableView())
+ ->setUser($viewer)
+ ->setCharges($charges)
+ ->setHandles($handles);
+
+ $header = id(new PHUIHeaderView())
+ ->setHeader(pht('Recent Charges'))
+ ->addActionLink(
+ id(new PHUIButtonView())
+ ->setTag('a')
+ ->setIcon(
+ id(new PHUIIconView())
+ ->setIconFont('fa-list'))
+ ->setHref($charges_uri)
+ ->setText(pht('View All Charges')));
+
+ return id(new PHUIObjectBoxView())
+ ->setHeader($header)
+ ->appendChild($table);
}
private function buildAccountHistorySection(PhortuneAccount $account) {
diff --git a/src/applications/phortune/controller/PhortuneCartListController.php b/src/applications/phortune/controller/PhortuneCartListController.php
--- a/src/applications/phortune/controller/PhortuneCartListController.php
+++ b/src/applications/phortune/controller/PhortuneCartListController.php
@@ -3,13 +3,16 @@
final class PhortuneCartListController
extends PhortuneController {
+ private $accountID;
private $merchantID;
private $queryKey;
private $merchant;
+ private $account;
public function willProcessRequest(array $data) {
$this->merchantID = idx($data, 'merchantID');
+ $this->accountID = idx($data, 'accountID');
$this->queryKey = idx($data, 'queryKey');
}
@@ -34,6 +37,23 @@
}
$this->merchant = $merchant;
$engine->setMerchant($merchant);
+ } else if ($this->accountID) {
+ $account = id(new PhortuneAccountQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($this->accountID))
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
+ ->executeOne();
+ if (!$account) {
+ return new Aphront404Response();
+ }
+ $this->account = $account;
+ $engine->setAccount($account);
+ } else {
+ return new Aphront404Response();
}
$controller = id(new PhabricatorApplicationSearchController($request))
@@ -73,6 +93,17 @@
$this->getApplicationURI("merchant/orders/{$id}/"));
}
+ $account = $this->account;
+ if ($account) {
+ $id = $account->getID();
+ $crumbs->addTextCrumb(
+ $account->getName(),
+ $this->getApplicationURI("{$id}/"));
+ $crumbs->addTextCrumb(
+ pht('Orders'),
+ $this->getApplicationURI("{$id}/order/"));
+ }
+
return $crumbs;
}
diff --git a/src/applications/phortune/controller/PhortuneCartViewController.php b/src/applications/phortune/controller/PhortuneCartViewController.php
--- a/src/applications/phortune/controller/PhortuneCartViewController.php
+++ b/src/applications/phortune/controller/PhortuneCartViewController.php
@@ -135,7 +135,24 @@
->needCarts(true)
->execute();
- $charges_table = $this->buildChargesTable($charges, false);
+ $phids = array();
+ foreach ($charges as $charge) {
+ $phids[] = $charge->getProviderPHID();
+ $phids[] = $charge->getCartPHID();
+ $phids[] = $charge->getMerchantPHID();
+ $phids[] = $charge->getPaymentMethodPHID();
+ }
+ $handles = $this->loadViewerHandles($phids);
+
+ $charges_table = id(new PhortuneChargeTableView())
+ ->setUser($viewer)
+ ->setHandles($handles)
+ ->setCharges($charges)
+ ->setShowOrder(false);
+
+ $charges = id(new PHUIObjectBoxView())
+ ->setHeaderText(pht('Charges'))
+ ->appendChild($charges_table);
$account = $cart->getAccount();
@@ -147,7 +164,7 @@
array(
$crumbs,
$cart_box,
- $charges_table,
+ $charges,
),
array(
'title' => pht('Cart'),
diff --git a/src/applications/phortune/controller/PhortuneCartListController.php b/src/applications/phortune/controller/PhortuneChargeListController.php
copy from src/applications/phortune/controller/PhortuneCartListController.php
copy to src/applications/phortune/controller/PhortuneChargeListController.php
--- a/src/applications/phortune/controller/PhortuneCartListController.php
+++ b/src/applications/phortune/controller/PhortuneChargeListController.php
@@ -1,15 +1,15 @@
<?php
-final class PhortuneCartListController
+final class PhortuneChargeListController
extends PhortuneController {
- private $merchantID;
+ private $accountID;
private $queryKey;
- private $merchant;
+ private $account;
public function willProcessRequest(array $data) {
- $this->merchantID = idx($data, 'merchantID');
+ $this->accountID = idx($data, 'accountID');
$this->queryKey = idx($data, 'queryKey');
}
@@ -17,23 +17,25 @@
$request = $this->getRequest();
$viewer = $request->getUser();
- $engine = new PhortuneCartSearchEngine();
+ $engine = new PhortuneChargeSearchEngine();
- if ($this->merchantID) {
- $merchant = id(new PhortuneMerchantQuery())
+ if ($this->accountID) {
+ $account = id(new PhortuneAccountQuery())
->setViewer($viewer)
- ->withIDs(array($this->merchantID))
+ ->withIDs(array($this->accountID))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
- if (!$merchant) {
+ if (!$account) {
return new Aphront404Response();
}
- $this->merchant = $merchant;
- $engine->setMerchant($merchant);
+ $this->account = $account;
+ $engine->setAccount($account);
+ } else {
+ return new Aphront404Response();
}
$controller = id(new PhabricatorApplicationSearchController($request))
@@ -50,7 +52,7 @@
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
- id(new PhortuneCartSearchEngine())
+ id(new PhortuneChargeSearchEngine())
->setViewer($viewer)
->addNavigationItems($nav->getMenu());
@@ -62,15 +64,15 @@
public function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
- $merchant = $this->merchant;
- if ($merchant) {
- $id = $merchant->getID();
+ $account = $this->account;
+ if ($account) {
+ $id = $account->getID();
$crumbs->addTextCrumb(
- $merchant->getName(),
- $this->getApplicationURI("merchant/{$id}/"));
+ $account->getName(),
+ $this->getApplicationURI("{$id}/"));
$crumbs->addTextCrumb(
- pht('Orders'),
- $this->getApplicationURI("merchant/orders/{$id}/"));
+ pht('Charges'),
+ $this->getApplicationURI("{$id}/charge/"));
}
return $crumbs;
diff --git a/src/applications/phortune/controller/PhortuneController.php b/src/applications/phortune/controller/PhortuneController.php
--- a/src/applications/phortune/controller/PhortuneController.php
+++ b/src/applications/phortune/controller/PhortuneController.php
@@ -2,73 +2,6 @@
abstract class PhortuneController extends PhabricatorController {
- protected function buildChargesTable(array $charges, $show_cart = true) {
- $request = $this->getRequest();
- $viewer = $request->getUser();
-
- $phids = array();
- foreach ($charges as $charge) {
- $phids[] = $charge->getProviderPHID();
- $phids[] = $charge->getCartPHID();
- $phids[] = $charge->getMerchantPHID();
- $phids[] = $charge->getPaymentMethodPHID();
- }
-
- $handles = $this->loadViewerHandles($phids);
-
- $rows = array();
- foreach ($charges as $charge) {
- $rows[] = array(
- $charge->getID(),
- $handles[$charge->getCartPHID()]->renderLink(),
- $handles[$charge->getProviderPHID()]->renderLink(),
- $charge->getPaymentMethodPHID()
- ? $handles[$charge->getPaymentMethodPHID()]->renderLink()
- : null,
- $handles[$charge->getMerchantPHID()]->renderLink(),
- $charge->getAmountAsCurrency()->formatForDisplay(),
- $charge->getStatusForDisplay(),
- phabricator_datetime($charge->getDateCreated(), $viewer),
- );
- }
-
- $charge_table = id(new AphrontTableView($rows))
- ->setHeaders(
- array(
- pht('ID'),
- pht('Cart'),
- pht('Provider'),
- pht('Method'),
- pht('Merchant'),
- pht('Amount'),
- pht('Status'),
- pht('Created'),
- ))
- ->setColumnClasses(
- array(
- '',
- '',
- '',
- '',
- '',
- 'wide right',
- '',
- '',
- ))
- ->setColumnVisibility(
- array(
- true,
- $show_cart,
- ));
-
- $header = id(new PHUIHeaderView())
- ->setHeader(pht('Charge History'));
-
- return id(new PHUIObjectBoxView())
- ->setHeader($header)
- ->appendChild($charge_table);
- }
-
protected function addAccountCrumb(
$crumbs,
PhortuneAccount $account,
diff --git a/src/applications/phortune/query/PhortuneCartSearchEngine.php b/src/applications/phortune/query/PhortuneCartSearchEngine.php
--- a/src/applications/phortune/query/PhortuneCartSearchEngine.php
+++ b/src/applications/phortune/query/PhortuneCartSearchEngine.php
@@ -4,6 +4,16 @@
extends PhabricatorApplicationSearchEngine {
private $merchant;
+ private $account;
+
+ public function setAccount(PhortuneAccount $account) {
+ $this->account = $account;
+ return $this;
+ }
+
+ public function getAccount() {
+ return $this->account;
+ }
public function setMerchant(PhortuneMerchant $merchant) {
$this->merchant = $merchant;
@@ -39,6 +49,7 @@
$viewer = $this->requireViewer();
$merchant = $this->getMerchant();
+ $account = $this->getAccount();
if ($merchant) {
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
@@ -49,9 +60,21 @@
pht('You can not query orders for a merchant you do not control.'));
}
$query->withMerchantPHIDs(array($merchant->getPHID()));
+ } else if ($account) {
+ $can_edit = PhabricatorPolicyFilter::hasCapability(
+ $viewer,
+ $account,
+ PhabricatorPolicyCapability::CAN_EDIT);
+ if (!$can_edit) {
+ throw new Exception(
+ pht(
+ 'You can not query orders for an account you are not '.
+ 'a member of.'));
+ }
+ $query->withAccountPHIDs(array($account->getPHID()));
} else {
$accounts = id(new PhortuneAccountQuery())
- ->withMemberPHIDs($viewer->getPHID())
+ ->withMemberPHIDs(array($viewer->getPHID()))
->execute();
if ($accounts) {
$query->withAccountPHIDs(mpull($accounts, 'getPHID'));
@@ -69,8 +92,11 @@
protected function getURI($path) {
$merchant = $this->getMerchant();
+ $account = $this->getAccount();
if ($merchant) {
return '/phortune/merchant/'.$merchant->getID().'/order/'.$path;
+ } else if ($account) {
+ return '/phortune/'.$account->getID().'/order/';
} else {
return '/phortune/order/'.$path;
}
diff --git a/src/applications/phortune/query/PhortuneChargeSearchEngine.php b/src/applications/phortune/query/PhortuneChargeSearchEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phortune/query/PhortuneChargeSearchEngine.php
@@ -0,0 +1,125 @@
+<?php
+
+final class PhortuneChargeSearchEngine
+ extends PhabricatorApplicationSearchEngine {
+
+ private $account;
+
+ public function setAccount(PhortuneAccount $account) {
+ $this->account = $account;
+ return $this;
+ }
+
+ public function getAccount() {
+ return $this->account;
+ }
+
+ public function getResultTypeDescription() {
+ return pht('Phortune Charges');
+ }
+
+ public function buildSavedQueryFromRequest(AphrontRequest $request) {
+ $saved = new PhabricatorSavedQuery();
+
+ return $saved;
+ }
+
+ public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
+ $query = id(new PhortuneChargeQuery());
+
+ $viewer = $this->requireViewer();
+
+ $account = $this->getAccount();
+ if ($account) {
+ $can_edit = PhabricatorPolicyFilter::hasCapability(
+ $viewer,
+ $account,
+ PhabricatorPolicyCapability::CAN_EDIT);
+ if (!$can_edit) {
+ throw new Exception(
+ pht(
+ 'You can not query charges for an account you are not '.
+ 'a member of.'));
+ }
+ $query->withAccountPHIDs(array($account->getPHID()));
+ } else {
+ $accounts = id(new PhortuneAccountQuery())
+ ->withMemberPHIDs(array($viewer->getPHID()))
+ ->execute();
+ if ($accounts) {
+ $query->withAccountPHIDs(mpull($accounts, 'getPHID'));
+ } else {
+ throw new Exception(pht('You have no accounts!'));
+ }
+ }
+
+ return $query;
+ }
+
+ public function buildSearchForm(
+ AphrontFormView $form,
+ PhabricatorSavedQuery $saved_query) {}
+
+ protected function getURI($path) {
+ $account = $this->getAccount();
+ if ($account) {
+ return '/phortune/'.$account->getID().'/charge/';
+ } else {
+ return '/phortune/charge/'.$path;
+ }
+ }
+
+ public function getBuiltinQueryNames() {
+ $names = array(
+ 'all' => pht('All Charges'),
+ );
+
+ return $names;
+ }
+
+ public function buildSavedQueryFromBuiltin($query_key) {
+
+ $query = $this->newSavedQuery();
+ $query->setQueryKey($query_key);
+
+ switch ($query_key) {
+ case 'all':
+ return $query;
+ }
+
+ return parent::buildSavedQueryFromBuiltin($query_key);
+ }
+
+ protected function getRequiredHandlePHIDsForResultList(
+ array $charges,
+ PhabricatorSavedQuery $query) {
+
+ $phids = array();
+ foreach ($charges as $charge) {
+ $phids[] = $charge->getProviderPHID();
+ $phids[] = $charge->getCartPHID();
+ $phids[] = $charge->getMerchantPHID();
+ $phids[] = $charge->getPaymentMethodPHID();
+ }
+
+ return $phids;
+ }
+
+ protected function renderResultList(
+ array $charges,
+ PhabricatorSavedQuery $query,
+ array $handles) {
+ assert_instances_of($charges, 'PhortuneCharge');
+
+ $viewer = $this->requireViewer();
+
+ $table = id(new PhortuneChargeTableView())
+ ->setUser($viewer)
+ ->setCharges($charges)
+ ->setHandles($handles);
+
+ return id(new PHUIObjectBoxView())
+ ->setHeaderText(pht('Charges'))
+ ->appendChild($table);
+ }
+}
diff --git a/src/applications/phortune/view/PhortuneChargeTableView.php b/src/applications/phortune/view/PhortuneChargeTableView.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phortune/view/PhortuneChargeTableView.php
@@ -0,0 +1,89 @@
+<?php
+
+final class PhortuneChargeTableView extends AphrontView {
+
+ private $charges;
+ private $handles;
+ private $showOrder;
+
+ public function setShowOrder($show_order) {
+ $this->showOrder = $show_order;
+ return $this;
+ }
+
+ public function getShowOrder() {
+ return $this->showOrder;
+ }
+
+ public function setHandles(array $handles) {
+ $this->handles = $handles;
+ return $this;
+ }
+
+ public function getHandles() {
+ return $this->handles;
+ }
+
+ public function setCharges(array $charges) {
+ $this->charges = $charges;
+ return $this;
+ }
+
+ public function getCharges() {
+ return $this->charges;
+ }
+
+ public function render() {
+ $charges = $this->getCharges();
+ $handles = $this->getHandles();
+ $viewer = $this->getUser();
+
+ $rows = array();
+ foreach ($charges as $charge) {
+ $rows[] = array(
+ $charge->getID(),
+ $handles[$charge->getCartPHID()]->renderLink(),
+ $handles[$charge->getProviderPHID()]->renderLink(),
+ $charge->getPaymentMethodPHID()
+ ? $handles[$charge->getPaymentMethodPHID()]->renderLink()
+ : null,
+ $handles[$charge->getMerchantPHID()]->renderLink(),
+ $charge->getAmountAsCurrency()->formatForDisplay(),
+ $charge->getStatusForDisplay(),
+ phabricator_datetime($charge->getDateCreated(), $viewer),
+ );
+ }
+
+ $table = id(new AphrontTableView($rows))
+ ->setHeaders(
+ array(
+ pht('ID'),
+ pht('Cart'),
+ pht('Provider'),
+ pht('Method'),
+ pht('Merchant'),
+ pht('Amount'),
+ pht('Status'),
+ pht('Created'),
+ ))
+ ->setColumnClasses(
+ array(
+ '',
+ '',
+ '',
+ '',
+ '',
+ 'wide right',
+ '',
+ '',
+ ))
+ ->setColumnVisibility(
+ array(
+ true,
+ $this->getShowOrder(),
+ ));
+
+ return $table;
+ }
+
+}
diff --git a/src/applications/phortune/view/PhortuneOrderTableView.php b/src/applications/phortune/view/PhortuneOrderTableView.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phortune/view/PhortuneOrderTableView.php
@@ -0,0 +1,100 @@
+<?php
+
+final class PhortuneOrderTableView extends AphrontView {
+
+ private $carts;
+ private $handles;
+
+ public function setHandles(array $handles) {
+ $this->handles = $handles;
+ return $this;
+ }
+
+ public function getHandles() {
+ return $this->handles;
+ }
+
+ public function setCarts(array $carts) {
+ $this->carts = $carts;
+ return $this;
+ }
+
+ public function getCarts() {
+ return $this->carts;
+ }
+
+ public function render() {
+ $carts = $this->getCarts();
+ $handles = $this->getHandles();
+ $viewer = $this->getUser();
+
+ $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 = '';
+ }
+
+ $rowc[] = '';
+ $rows[] = array(
+ $cart->getID(),
+ phutil_tag(
+ 'strong',
+ array(),
+ $cart_link),
+ $purchase_name,
+ phutil_tag(
+ 'strong',
+ array(),
+ $cart->getTotalPriceAsCurrency()->formatForDisplay()),
+ PhortuneCart::getNameForStatus($cart->getStatus()),
+ phabricator_datetime($cart->getDateModified(), $viewer),
+ );
+ foreach ($purchases as $purchase) {
+ $id = $purchase->getID();
+
+ $price = $purchase->getTotalPriceAsCurrency()->formatForDisplay();
+
+ $rowc[] = '';
+ $rows[] = array(
+ '',
+ $handles[$purchase->getPHID()]->renderLink(),
+ $price,
+ '',
+ '',
+ );
+ }
+ }
+
+ $table = id(new AphrontTableView($rows))
+ ->setRowClasses($rowc)
+ ->setHeaders(
+ array(
+ pht('ID'),
+ pht('Order'),
+ pht('Purchase'),
+ pht('Amount'),
+ pht('Status'),
+ pht('Updated'),
+ ))
+ ->setColumnClasses(
+ array(
+ '',
+ '',
+ 'wide',
+ 'right',
+ '',
+ 'right',
+ ));
+
+ return $table;
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 12, 6:09 PM (6 d, 15 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6766238
Default Alt Text
D10685.id25653.diff (26 KB)

Event Timeline