diff --git a/src/applications/fund/phortune/FundBackerCart.php b/src/applications/fund/phortune/FundBackerCart.php index 1d823ae03e..7196b21f48 100644 --- a/src/applications/fund/phortune/FundBackerCart.php +++ b/src/applications/fund/phortune/FundBackerCart.php @@ -23,6 +23,10 @@ final class FundBackerCart extends PhortuneCartImplementation { return $this->initiative; } + public function getName() { + return pht('Fund Initiative'); + } + public function willCreateCart( PhabricatorUser $viewer, PhortuneCart $cart) { diff --git a/src/applications/fund/phortune/FundBackerProduct.php b/src/applications/fund/phortune/FundBackerProduct.php index 06f9f23675..a543ecb055 100644 --- a/src/applications/fund/phortune/FundBackerProduct.php +++ b/src/applications/fund/phortune/FundBackerProduct.php @@ -22,7 +22,7 @@ final class FundBackerProduct extends PhortuneProductImplementation { public function getName(PhortuneProduct $product) { $initiative = $this->getInitiative(); return pht( - 'Back Initiative %s %s', + 'Fund %s %s', $initiative->getMonogram(), $initiative->getName()); } diff --git a/src/applications/phortune/cart/PhortuneCartImplementation.php b/src/applications/phortune/cart/PhortuneCartImplementation.php index fe600d0028..43124dce41 100644 --- a/src/applications/phortune/cart/PhortuneCartImplementation.php +++ b/src/applications/phortune/cart/PhortuneCartImplementation.php @@ -12,6 +12,8 @@ abstract class PhortuneCartImplementation { PhabricatorUser $viewer, array $carts); + abstract public function getName(); + abstract public function getCancelURI(PhortuneCart $cart); abstract public function getDoneURI(PhortuneCart $cart); diff --git a/src/applications/phortune/controller/PhortuneAccountViewController.php b/src/applications/phortune/controller/PhortuneAccountViewController.php index 39b23d6dba..f20c5ef878 100644 --- a/src/applications/phortune/controller/PhortuneAccountViewController.php +++ b/src/applications/phortune/controller/PhortuneAccountViewController.php @@ -51,7 +51,6 @@ final class PhortuneAccountViewController extends PhortuneController { ->setObject($account) ->setUser($user); - $properties->addProperty(pht('Balance'), '-'); $properties->setActionList($actions); $payment_methods = $this->buildPaymentMethodsSection($account); @@ -163,39 +162,52 @@ final class PhortuneAccountViewController extends PhortuneController { )) ->execute(); + $phids = array(); + foreach ($carts as $cart) { + $phids[] = $cart->getPHID(); + foreach ($cart->getPurchases() as $purchase) { + $phids[] = $purchase->getPHID(); + } + } + $handles = $this->loadViewerHandles($phids); + $rows = array(); $rowc = array(); foreach ($carts as $cart) { - $cart_link = phutil_tag( - 'a', - array( - 'href' => $this->getApplicationURI('cart/'.$cart->getID().'/'), - ), - pht('Cart %d', $cart->getID())); + $cart_link = $handles[$cart->getPHID()]->renderLink(); + $purchases = $cart->getPurchases(); - $rowc[] = 'highlighted'; + if (count($purchases) == 1) { + $purchase_name = $handles[$purchase->getPHID()]->renderLink(); + $purchases = array(); + } else { + $purchase_name = ''; + } + + $rowc[] = ''; $rows[] = array( - phutil_tag('strong', array(), $cart_link), - '', - '', + phutil_tag( + 'strong', + array(), + $cart_link), + $purchase_name, + phutil_tag( + 'strong', + array(), + $cart->getTotalPriceAsCurrency()->formatForDisplay()), + phabricator_datetime($cart->getDateModified(), $viewer), ); - foreach ($cart->getPurchases() as $purchase) { + foreach ($purchases as $purchase) { $id = $purchase->getID(); $price = $purchase->getTotalPriceAsCurrency()->formatForDisplay(); - $purchase_link = phutil_tag( - 'a', - array( - 'href' => $this->getApplicationURI('purchase/'.$id.'/'), - ), - $purchase->getFullDisplayName()); - $rowc[] = ''; $rows[] = array( '', - $purchase_link, + $handles[$purchase->getPHID()]->renderLink(), $price, + '', ); } } @@ -207,12 +219,14 @@ final class PhortuneAccountViewController extends PhortuneController { pht('Cart'), pht('Purchase'), pht('Amount'), + pht('Updated'), )) ->setColumnClasses( array( '', 'wide', 'right', + 'right', )); $header = id(new PHUIHeaderView()) @@ -240,9 +254,6 @@ final class PhortuneAccountViewController extends PhortuneController { $request = $this->getRequest(); $user = $request->getUser(); - $header = id(new PHUIHeaderView()) - ->setHeader(pht('Account History')); - $xactions = id(new PhortuneAccountTransactionQuery()) ->setViewer($user) ->withObjectPHIDs(array($account->getPHID())) @@ -257,13 +268,7 @@ final class PhortuneAccountViewController extends PhortuneController { ->setTransactions($xactions) ->setMarkupEngine($engine); - $box = id(new PHUIObjectBoxView()) - ->setHeader($header); - - return array( - $box, - $xaction_view, - ); + return $xaction_view; } } diff --git a/src/applications/phortune/controller/PhortuneController.php b/src/applications/phortune/controller/PhortuneController.php index 87bd6eef7b..21b23e2c7b 100644 --- a/src/applications/phortune/controller/PhortuneController.php +++ b/src/applications/phortune/controller/PhortuneController.php @@ -12,25 +12,26 @@ abstract class PhortuneController extends PhabricatorController { $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) { - $cart = $charge->getCart(); - $cart_id = $cart->getID(); - $cart_uri = $this->getApplicationURI("cart/{$cart_id}/"); - $cart_href = phutil_tag( - 'a', - array( - 'href' => $cart_uri, - ), - pht('Cart %d', $cart_id)); - $rows[] = array( $charge->getID(), - $cart_href, - $charge->getProviderPHID(), - $charge->getPaymentMethodPHID(), + $handles[$charge->getCartPHID()]->renderLink(), + $handles[$charge->getProviderPHID()]->renderLink(), + $handles[$charge->getPaymentMethodPHID()]->renderLink(), + $handles[$charge->getMerchantPHID()]->renderLink(), $charge->getAmountAsCurrency()->formatForDisplay(), - $charge->getStatus(), + PhortuneCharge::getNameForStatus($charge->getStatus()), phabricator_datetime($charge->getDateCreated(), $viewer), ); } @@ -42,6 +43,7 @@ abstract class PhortuneController extends PhabricatorController { pht('Cart'), pht('Provider'), pht('Method'), + pht('Merchant'), pht('Amount'), pht('Status'), pht('Created'), @@ -49,7 +51,8 @@ abstract class PhortuneController extends PhabricatorController { ->setColumnClasses( array( '', - 'strong', + '', + '', '', '', 'wide right', diff --git a/src/applications/phortune/phid/PhortuneCartPHIDType.php b/src/applications/phortune/phid/PhortuneCartPHIDType.php index 344286a351..c9488d84ab 100644 --- a/src/applications/phortune/phid/PhortuneCartPHIDType.php +++ b/src/applications/phortune/phid/PhortuneCartPHIDType.php @@ -29,8 +29,9 @@ final class PhortuneCartPHIDType extends PhabricatorPHIDType { $cart = $objects[$phid]; $id = $cart->getID(); + $name = $cart->getImplementation()->getName(); - $handle->setName(pht('Cart %d', $id)); + $handle->setName($name); $handle->setURI("/phortune/cart/{$id}/"); } } diff --git a/src/applications/phortune/phid/PhortuneMerchantPHIDType.php b/src/applications/phortune/phid/PhortuneMerchantPHIDType.php index 143a970fbf..a1b8b73871 100644 --- a/src/applications/phortune/phid/PhortuneMerchantPHIDType.php +++ b/src/applications/phortune/phid/PhortuneMerchantPHIDType.php @@ -30,7 +30,7 @@ final class PhortuneMerchantPHIDType extends PhabricatorPHIDType { $id = $merchant->getID(); - $handle->setName(pht('Merchant %d %s', $id, $merchant->getName())); + $handle->setName($merchant->getName()); $handle->setURI("/phortune/merchant/{$id}/"); } } diff --git a/src/applications/phortune/phid/PhortunePaymentMethodPHIDType.php b/src/applications/phortune/phid/PhortunePaymentMethodPHIDType.php index 6e334b66b3..34501526b2 100644 --- a/src/applications/phortune/phid/PhortunePaymentMethodPHIDType.php +++ b/src/applications/phortune/phid/PhortunePaymentMethodPHIDType.php @@ -30,7 +30,7 @@ final class PhortunePaymentMethodPHIDType extends PhabricatorPHIDType { $id = $method->getID(); - $handle->setName(pht('Method %d', $id)); + $handle->setName($method->getFullDisplayName()); $handle->setURI("/phortune/method/{$id}/"); } } diff --git a/src/applications/phortune/phid/PhortunePaymentProviderPHIDType.php b/src/applications/phortune/phid/PhortunePaymentProviderPHIDType.php index 55be6e460c..7391e71108 100644 --- a/src/applications/phortune/phid/PhortunePaymentProviderPHIDType.php +++ b/src/applications/phortune/phid/PhortunePaymentProviderPHIDType.php @@ -30,8 +30,7 @@ final class PhortunePaymentProviderPHIDType extends PhabricatorPHIDType { $id = $provider_config->getID(); - $handle->setName(pht('Payment Provider %d', $id)); - $handle->setURI("/phortune/provider/{$id}/"); + $handle->setName($provider_config->buildProvider()->getName()); } } diff --git a/src/applications/phortune/phid/PhortunePurchasePHIDType.php b/src/applications/phortune/phid/PhortunePurchasePHIDType.php index f80e191691..5018a47164 100644 --- a/src/applications/phortune/phid/PhortunePurchasePHIDType.php +++ b/src/applications/phortune/phid/PhortunePurchasePHIDType.php @@ -30,7 +30,7 @@ final class PhortunePurchasePHIDType extends PhabricatorPHIDType { $id = $purchase->getID(); - $handle->setName(pht('Purchase %d', $id)); + $handle->setName($purchase->getFullDisplayName()); $handle->setURI("/phortune/purchase/{$id}/"); } } diff --git a/src/applications/phortune/storage/PhortuneCharge.php b/src/applications/phortune/storage/PhortuneCharge.php index 6386c3db7e..3d708416b6 100644 --- a/src/applications/phortune/storage/PhortuneCharge.php +++ b/src/applications/phortune/storage/PhortuneCharge.php @@ -63,6 +63,18 @@ final class PhortuneCharge extends PhortuneDAO ) + parent::getConfiguration(); } + public static function getStatusNameMap() { + return array( + self::STATUS_CHARGING => pht('Charging'), + self::STATUS_CHARGED => pht('Charged'), + self::STATUS_FAILED => pht('Failed'), + ); + } + + public static function getNameForStatus($status) { + return idx(self::getStatusNameMap(), $status, pht('Unknown')); + } + public function generatePHID() { return PhabricatorPHID::generateNewPHID( PhortuneChargePHIDType::TYPECONST); diff --git a/src/applications/phortune/storage/PhortunePurchase.php b/src/applications/phortune/storage/PhortunePurchase.php index 98e6a61c5d..538df69082 100644 --- a/src/applications/phortune/storage/PhortunePurchase.php +++ b/src/applications/phortune/storage/PhortunePurchase.php @@ -60,7 +60,8 @@ final class PhortunePurchase extends PhortuneDAO } public function generatePHID() { - return PhabricatorPHID::generateNewPHID(PhortuneChargePHIDType::TYPECONST); + return PhabricatorPHID::generateNewPHID( + PhortunePurchasePHIDType::TYPECONST); } public function attachCart(PhortuneCart $cart) {