diff --git a/src/applications/fund/phortune/FundBackerCart.php b/src/applications/fund/phortune/FundBackerCart.php --- a/src/applications/fund/phortune/FundBackerCart.php +++ b/src/applications/fund/phortune/FundBackerCart.php @@ -23,6 +23,10 @@ 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 --- a/src/applications/fund/phortune/FundBackerProduct.php +++ b/src/applications/fund/phortune/FundBackerProduct.php @@ -22,7 +22,7 @@ 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 --- a/src/applications/phortune/cart/PhortuneCartImplementation.php +++ b/src/applications/phortune/cart/PhortuneCartImplementation.php @@ -12,6 +12,8 @@ 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 --- a/src/applications/phortune/controller/PhortuneAccountViewController.php +++ b/src/applications/phortune/controller/PhortuneAccountViewController.php @@ -51,7 +51,6 @@ ->setObject($account) ->setUser($user); - $properties->addProperty(pht('Balance'), '-'); $properties->setActionList($actions); $payment_methods = $this->buildPaymentMethodsSection($account); @@ -163,39 +162,52 @@ )) ->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(); + + if (count($purchases) == 1) { + $purchase_name = $handles[$purchase->getPHID()]->renderLink(); + $purchases = array(); + } else { + $purchase_name = ''; + } - $rowc[] = 'highlighted'; + $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 @@ pht('Cart'), pht('Purchase'), pht('Amount'), + pht('Updated'), )) ->setColumnClasses( array( '', 'wide', 'right', + 'right', )); $header = id(new PHUIHeaderView()) @@ -240,9 +254,6 @@ $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 @@ ->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 --- a/src/applications/phortune/controller/PhortuneController.php +++ b/src/applications/phortune/controller/PhortuneController.php @@ -12,25 +12,26 @@ $request = $this->getRequest(); $viewer = $request->getUser(); - $rows = array(); + $phids = 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)); + $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(), - $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 @@ pht('Cart'), pht('Provider'), pht('Method'), + pht('Merchant'), pht('Amount'), pht('Status'), pht('Created'), @@ -49,7 +51,8 @@ ->setColumnClasses( array( '', - 'strong', + '', + '', '', '', 'wide right', diff --git a/src/applications/phortune/phid/PhortuneCartPHIDType.php b/src/applications/phortune/phid/PhortuneCartPHIDType.php --- a/src/applications/phortune/phid/PhortuneCartPHIDType.php +++ b/src/applications/phortune/phid/PhortuneCartPHIDType.php @@ -29,8 +29,9 @@ $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 --- a/src/applications/phortune/phid/PhortuneMerchantPHIDType.php +++ b/src/applications/phortune/phid/PhortuneMerchantPHIDType.php @@ -30,7 +30,7 @@ $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 --- a/src/applications/phortune/phid/PhortunePaymentMethodPHIDType.php +++ b/src/applications/phortune/phid/PhortunePaymentMethodPHIDType.php @@ -30,7 +30,7 @@ $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 --- a/src/applications/phortune/phid/PhortunePaymentProviderPHIDType.php +++ b/src/applications/phortune/phid/PhortunePaymentProviderPHIDType.php @@ -30,8 +30,7 @@ $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 --- a/src/applications/phortune/phid/PhortunePurchasePHIDType.php +++ b/src/applications/phortune/phid/PhortunePurchasePHIDType.php @@ -30,7 +30,7 @@ $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 --- a/src/applications/phortune/storage/PhortuneCharge.php +++ b/src/applications/phortune/storage/PhortuneCharge.php @@ -63,6 +63,18 @@ ) + 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 --- a/src/applications/phortune/storage/PhortunePurchase.php +++ b/src/applications/phortune/storage/PhortunePurchase.php @@ -60,7 +60,8 @@ } public function generatePHID() { - return PhabricatorPHID::generateNewPHID(PhortuneChargePHIDType::TYPECONST); + return PhabricatorPHID::generateNewPHID( + PhortunePurchasePHIDType::TYPECONST); } public function attachCart(PhortuneCart $cart) {