1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Refactor the Phortune account detail page into a series of smaller, more focused sections

Summary:
Ref T13366. Some of the information architecture is a little muddy here, notably an item called "Billing / History" which contains payment methods.

Split things up a bit to prepare for adding support for "Email Addresses".

Test Plan: {F6676988}

Maniphest Tasks: T13366

Differential Revision: https://secure.phabricator.com/D20697
This commit is contained in:
epriestley 2019-08-02 11:29:45 -07:00
parent ecbc82da33
commit 719a7d82c5
12 changed files with 390 additions and 194 deletions

View file

@ -5221,25 +5221,28 @@ phutil_register_library_map(array(
'PhortuneAccount' => 'applications/phortune/storage/PhortuneAccount.php', 'PhortuneAccount' => 'applications/phortune/storage/PhortuneAccount.php',
'PhortuneAccountAddManagerController' => 'applications/phortune/controller/account/PhortuneAccountAddManagerController.php', 'PhortuneAccountAddManagerController' => 'applications/phortune/controller/account/PhortuneAccountAddManagerController.php',
'PhortuneAccountBillingAddressTransaction' => 'applications/phortune/xaction/PhortuneAccountBillingAddressTransaction.php', 'PhortuneAccountBillingAddressTransaction' => 'applications/phortune/xaction/PhortuneAccountBillingAddressTransaction.php',
'PhortuneAccountBillingController' => 'applications/phortune/controller/account/PhortuneAccountBillingController.php',
'PhortuneAccountBillingNameTransaction' => 'applications/phortune/xaction/PhortuneAccountBillingNameTransaction.php', 'PhortuneAccountBillingNameTransaction' => 'applications/phortune/xaction/PhortuneAccountBillingNameTransaction.php',
'PhortuneAccountChargeListController' => 'applications/phortune/controller/account/PhortuneAccountChargeListController.php', 'PhortuneAccountChargeListController' => 'applications/phortune/controller/account/PhortuneAccountChargeListController.php',
'PhortuneAccountChargesController' => 'applications/phortune/controller/account/PhortuneAccountChargesController.php',
'PhortuneAccountController' => 'applications/phortune/controller/account/PhortuneAccountController.php', 'PhortuneAccountController' => 'applications/phortune/controller/account/PhortuneAccountController.php',
'PhortuneAccountDetailsController' => 'applications/phortune/controller/account/PhortuneAccountDetailsController.php',
'PhortuneAccountEditController' => 'applications/phortune/controller/account/PhortuneAccountEditController.php', 'PhortuneAccountEditController' => 'applications/phortune/controller/account/PhortuneAccountEditController.php',
'PhortuneAccountEditEngine' => 'applications/phortune/editor/PhortuneAccountEditEngine.php', 'PhortuneAccountEditEngine' => 'applications/phortune/editor/PhortuneAccountEditEngine.php',
'PhortuneAccountEditor' => 'applications/phortune/editor/PhortuneAccountEditor.php', 'PhortuneAccountEditor' => 'applications/phortune/editor/PhortuneAccountEditor.php',
'PhortuneAccountHasMemberEdgeType' => 'applications/phortune/edge/PhortuneAccountHasMemberEdgeType.php', 'PhortuneAccountHasMemberEdgeType' => 'applications/phortune/edge/PhortuneAccountHasMemberEdgeType.php',
'PhortuneAccountListController' => 'applications/phortune/controller/account/PhortuneAccountListController.php', 'PhortuneAccountListController' => 'applications/phortune/controller/account/PhortuneAccountListController.php',
'PhortuneAccountManagerController' => 'applications/phortune/controller/account/PhortuneAccountManagerController.php', 'PhortuneAccountManagersController' => 'applications/phortune/controller/account/PhortuneAccountManagersController.php',
'PhortuneAccountNameTransaction' => 'applications/phortune/xaction/PhortuneAccountNameTransaction.php', 'PhortuneAccountNameTransaction' => 'applications/phortune/xaction/PhortuneAccountNameTransaction.php',
'PhortuneAccountOrdersController' => 'applications/phortune/controller/account/PhortuneAccountOrdersController.php',
'PhortuneAccountOverviewController' => 'applications/phortune/controller/account/PhortuneAccountOverviewController.php',
'PhortuneAccountPHIDType' => 'applications/phortune/phid/PhortuneAccountPHIDType.php', 'PhortuneAccountPHIDType' => 'applications/phortune/phid/PhortuneAccountPHIDType.php',
'PhortuneAccountPaymentMethodsController' => 'applications/phortune/controller/account/PhortuneAccountPaymentMethodsController.php',
'PhortuneAccountProfileController' => 'applications/phortune/controller/account/PhortuneAccountProfileController.php', 'PhortuneAccountProfileController' => 'applications/phortune/controller/account/PhortuneAccountProfileController.php',
'PhortuneAccountQuery' => 'applications/phortune/query/PhortuneAccountQuery.php', 'PhortuneAccountQuery' => 'applications/phortune/query/PhortuneAccountQuery.php',
'PhortuneAccountSubscriptionController' => 'applications/phortune/controller/account/PhortuneAccountSubscriptionController.php', 'PhortuneAccountSubscriptionController' => 'applications/phortune/controller/account/PhortuneAccountSubscriptionController.php',
'PhortuneAccountTransaction' => 'applications/phortune/storage/PhortuneAccountTransaction.php', 'PhortuneAccountTransaction' => 'applications/phortune/storage/PhortuneAccountTransaction.php',
'PhortuneAccountTransactionQuery' => 'applications/phortune/query/PhortuneAccountTransactionQuery.php', 'PhortuneAccountTransactionQuery' => 'applications/phortune/query/PhortuneAccountTransactionQuery.php',
'PhortuneAccountTransactionType' => 'applications/phortune/xaction/PhortuneAccountTransactionType.php', 'PhortuneAccountTransactionType' => 'applications/phortune/xaction/PhortuneAccountTransactionType.php',
'PhortuneAccountViewController' => 'applications/phortune/controller/account/PhortuneAccountViewController.php',
'PhortuneAdHocCart' => 'applications/phortune/cart/PhortuneAdHocCart.php', 'PhortuneAdHocCart' => 'applications/phortune/cart/PhortuneAdHocCart.php',
'PhortuneAdHocProduct' => 'applications/phortune/product/PhortuneAdHocProduct.php', 'PhortuneAdHocProduct' => 'applications/phortune/product/PhortuneAdHocProduct.php',
'PhortuneAddPaymentMethodAction' => 'applications/phortune/action/PhortuneAddPaymentMethodAction.php', 'PhortuneAddPaymentMethodAction' => 'applications/phortune/action/PhortuneAddPaymentMethodAction.php',
@ -11753,25 +11756,28 @@ phutil_register_library_map(array(
), ),
'PhortuneAccountAddManagerController' => 'PhortuneController', 'PhortuneAccountAddManagerController' => 'PhortuneController',
'PhortuneAccountBillingAddressTransaction' => 'PhortuneAccountTransactionType', 'PhortuneAccountBillingAddressTransaction' => 'PhortuneAccountTransactionType',
'PhortuneAccountBillingController' => 'PhortuneAccountProfileController',
'PhortuneAccountBillingNameTransaction' => 'PhortuneAccountTransactionType', 'PhortuneAccountBillingNameTransaction' => 'PhortuneAccountTransactionType',
'PhortuneAccountChargeListController' => 'PhortuneController', 'PhortuneAccountChargeListController' => 'PhortuneController',
'PhortuneAccountChargesController' => 'PhortuneAccountProfileController',
'PhortuneAccountController' => 'PhortuneController', 'PhortuneAccountController' => 'PhortuneController',
'PhortuneAccountDetailsController' => 'PhortuneAccountProfileController',
'PhortuneAccountEditController' => 'PhortuneController', 'PhortuneAccountEditController' => 'PhortuneController',
'PhortuneAccountEditEngine' => 'PhabricatorEditEngine', 'PhortuneAccountEditEngine' => 'PhabricatorEditEngine',
'PhortuneAccountEditor' => 'PhabricatorApplicationTransactionEditor', 'PhortuneAccountEditor' => 'PhabricatorApplicationTransactionEditor',
'PhortuneAccountHasMemberEdgeType' => 'PhabricatorEdgeType', 'PhortuneAccountHasMemberEdgeType' => 'PhabricatorEdgeType',
'PhortuneAccountListController' => 'PhortuneController', 'PhortuneAccountListController' => 'PhortuneController',
'PhortuneAccountManagerController' => 'PhortuneAccountProfileController', 'PhortuneAccountManagersController' => 'PhortuneAccountProfileController',
'PhortuneAccountNameTransaction' => 'PhortuneAccountTransactionType', 'PhortuneAccountNameTransaction' => 'PhortuneAccountTransactionType',
'PhortuneAccountOrdersController' => 'PhortuneAccountProfileController',
'PhortuneAccountOverviewController' => 'PhortuneAccountProfileController',
'PhortuneAccountPHIDType' => 'PhabricatorPHIDType', 'PhortuneAccountPHIDType' => 'PhabricatorPHIDType',
'PhortuneAccountPaymentMethodsController' => 'PhortuneAccountProfileController',
'PhortuneAccountProfileController' => 'PhortuneAccountController', 'PhortuneAccountProfileController' => 'PhortuneAccountController',
'PhortuneAccountQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhortuneAccountQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhortuneAccountSubscriptionController' => 'PhortuneAccountProfileController', 'PhortuneAccountSubscriptionController' => 'PhortuneAccountProfileController',
'PhortuneAccountTransaction' => 'PhabricatorModularTransaction', 'PhortuneAccountTransaction' => 'PhabricatorModularTransaction',
'PhortuneAccountTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'PhortuneAccountTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhortuneAccountTransactionType' => 'PhabricatorModularTransactionType', 'PhortuneAccountTransactionType' => 'PhabricatorModularTransactionType',
'PhortuneAccountViewController' => 'PhortuneAccountProfileController',
'PhortuneAdHocCart' => 'PhortuneCartImplementation', 'PhortuneAdHocCart' => 'PhortuneCartImplementation',
'PhortuneAdHocProduct' => 'PhortuneProductImplementation', 'PhortuneAdHocProduct' => 'PhortuneProductImplementation',
'PhortuneAddPaymentMethodAction' => 'PhabricatorSystemAction', 'PhortuneAddPaymentMethodAction' => 'PhabricatorSystemAction',

View file

@ -35,7 +35,7 @@ final class PhabricatorPhortuneApplication extends PhabricatorApplication {
'/phortune/' => array( '/phortune/' => array(
'' => 'PhortuneLandingController', '' => 'PhortuneLandingController',
'(?P<accountID>\d+)/' => array( '(?P<accountID>\d+)/' => array(
'' => 'PhortuneAccountViewController', '' => 'PhortuneAccountOverviewController',
'card/' => array( 'card/' => array(
'new/' => 'PhortunePaymentMethodCreateController', 'new/' => 'PhortunePaymentMethodCreateController',
), ),
@ -69,15 +69,17 @@ final class PhabricatorPhortuneApplication extends PhabricatorApplication {
'' => 'PhortuneAccountListController', '' => 'PhortuneAccountListController',
$this->getEditRoutePattern('edit/') $this->getEditRoutePattern('edit/')
=> 'PhortuneAccountEditController', => 'PhortuneAccountEditController',
'edit/(?:(?P<id>\d+)/)?' => 'PhortuneAccountEditController',
'add/manager/(?:(?P<id>\d+)/)?' '(?P<accountID>\d+)/' => array(
=> 'PhortuneAccountAddManagerController', 'details/' => 'PhortuneAccountDetailsController',
'billing/(?:(?P<id>\d+)/)?' => 'PhortuneAccountBillingController', 'methods/' => 'PhortuneAccountPaymentMethodsController',
'subscription/(?:(?P<id>\d+)/)?' 'orders/' => 'PhortuneAccountOrdersController',
=> 'PhortuneAccountSubscriptionController', 'charges/' => 'PhortuneAccountChargesController',
'manager/' => array( 'subscriptions/' => 'PhortuneAccountSubscriptionController',
'(?:(?P<id>\d+)/)?' => 'PhortuneAccountManagerController', 'managers/' => array(
'add/(?:(?P<id>\d+)/)?' => 'PhortuneAccountAddManagerController', '' => 'PhortuneAccountManagersController',
'add/' => 'PhortuneAccountAddManagerController',
),
), ),
), ),
'product/' => array( 'product/' => array(

View file

@ -4,7 +4,7 @@ final class PhortuneAccountAddManagerController extends PhortuneController {
public function handleRequest(AphrontRequest $request) { public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer(); $viewer = $request->getViewer();
$id = $request->getURIData('id'); $id = $request->getURIData('accountID');
$account = id(new PhortuneAccountQuery()) $account = id(new PhortuneAccountQuery())
->setViewer($viewer) ->setViewer($viewer)
@ -21,7 +21,7 @@ final class PhortuneAccountAddManagerController extends PhortuneController {
$v_managers = array(); $v_managers = array();
$e_managers = null; $e_managers = null;
$account_uri = $this->getApplicationURI("/account/manager/{$id}/"); $account_uri = $this->getApplicationURI("/account/{$id}/managers/");
if ($request->isFormPost()) { if ($request->isFormPost()) {
$xactions = array(); $xactions = array();
@ -64,11 +64,11 @@ final class PhortuneAccountAddManagerController extends PhortuneController {
->setError($e_managers)); ->setError($e_managers));
return $this->newDialog() return $this->newDialog()
->setTitle(pht('Add New Manager')) ->setTitle(pht('Add New Managers'))
->appendForm($form) ->appendForm($form)
->setWidth(AphrontDialogView::WIDTH_FORM) ->setWidth(AphrontDialogView::WIDTH_FORM)
->addCancelButton($account_uri) ->addCancelButton($account_uri)
->addSubmitButton(pht('Add Manager')); ->addSubmitButton(pht('Add Managers'));
} }

View file

@ -0,0 +1,79 @@
<?php
final class PhortuneAccountChargesController
extends PhortuneAccountProfileController {
public function handleRequest(AphrontRequest $request) {
$response = $this->loadAccount();
if ($response) {
return $response;
}
$account = $this->getAccount();
$title = $account->getName();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Order History'));
$header = $this->buildHeaderView();
$charge_history = $this->buildChargeHistorySection($account);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter(
array(
$charge_history,
));
$navigation = $this->buildSideNavView('charges');
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->setNavigation($navigation)
->appendChild($view);
}
private function buildChargeHistorySection(PhortuneAccount $account) {
$viewer = $this->getViewer();
$charges = id(new PhortuneChargeQuery())
->setViewer($viewer)
->withAccountPHIDs(array($account->getPHID()))
->needCarts(true)
->setLimit(100)
->execute();
$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('fa-list')
->setHref($charges_uri)
->setText(pht('View All Charges')));
return id(new PHUIObjectBoxView())
->setHeader($header)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setTable($table);
}
}

View file

@ -0,0 +1,132 @@
<?php
final class PhortuneAccountDetailsController
extends PhortuneAccountProfileController {
public function handleRequest(AphrontRequest $request) {
$response = $this->loadAccount();
if ($response) {
return $response;
}
$account = $this->getAccount();
$title = $account->getName();
$viewer = $this->getViewer();
$invoices = id(new PhortuneCartQuery())
->setViewer($viewer)
->withAccountPHIDs(array($account->getPHID()))
->needPurchases(true)
->withInvoices(true)
->execute();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->setBorder(true);
$header = $this->buildHeaderView();
$details = $this->newDetailsView($account);
$curtain = $this->buildCurtainView($account);
$timeline = $this->buildTransactionTimeline(
$account,
new PhortuneAccountTransactionQuery());
$timeline->setShouldTerminate(true);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
->setMainColumn(
array(
$details,
$timeline,
));
$navigation = $this->buildSideNavView('details');
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->setNavigation($navigation)
->appendChild($view);
}
private function buildCurtainView(PhortuneAccount $account) {
$viewer = $this->getViewer();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$account,
PhabricatorPolicyCapability::CAN_EDIT);
$edit_uri = $this->getApplicationURI('account/edit/'.$account->getID().'/');
$curtain = $this->newCurtainView($account);
$curtain->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Account'))
->setIcon('fa-pencil')
->setHref($edit_uri)
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
$member_phids = $account->getMemberPHIDs();
$handles = $viewer->loadHandles($member_phids);
$member_list = id(new PHUIObjectItemListView())
->setSimple(true);
foreach ($member_phids as $member_phid) {
$image_uri = $handles[$member_phid]->getImageURI();
$image_href = $handles[$member_phid]->getURI();
$person = $handles[$member_phid];
$member = id(new PHUIObjectItemView())
->setImageURI($image_uri)
->setHref($image_href)
->setHeader($person->getFullName());
$member_list->addItem($member);
}
$curtain->newPanel()
->setHeaderText(pht('Managers'))
->appendChild($member_list);
return $curtain;
}
private function newDetailsView(PhortuneAccount $account) {
$viewer = $this->getViewer();
$view = id(new PHUIPropertyListView())
->setUser($viewer);
$view->addProperty(pht('Account Name'), $account->getName());
$display_name = $account->getBillingName();
if (!strlen($display_name)) {
$display_name = phutil_tag('em', array(), pht('None'));
}
$display_address = $account->getBillingAddress();
if (!strlen($display_address)) {
$display_address = phutil_tag('em', array(), pht('None'));
} else {
$display_address = phutil_escape_html_newlines($display_address);
}
$view->addProperty(pht('Billing Name'), $display_name);
$view->addProperty(pht('Billing Address'), $display_address);
return id(new PHUIObjectBoxView())
->setHeaderText(pht('Account Details'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->addPropertyList($view);
}
}

View file

@ -1,6 +1,6 @@
<?php <?php
final class PhortuneAccountManagerController final class PhortuneAccountManagersController
extends PhortuneAccountProfileController { extends PhortuneAccountProfileController {
public function handleRequest(AphrontRequest $request) { public function handleRequest(AphrontRequest $request) {
@ -46,11 +46,11 @@ final class PhortuneAccountManagerController
$add = id(new PHUIButtonView()) $add = id(new PHUIButtonView())
->setTag('a') ->setTag('a')
->setText(pht('New Manager')) ->setText(pht('Add Managers'))
->setIcon('fa-plus') ->setIcon('fa-plus')
->setWorkflow(true) ->setWorkflow(true)
->setDisabled(!$can_edit) ->setDisabled(!$can_edit)
->setHref("/phortune/account/manager/add/{$id}/"); ->setHref("/phortune/account/{$id}/managers/add/");
$header = id(new PHUIHeaderView()) $header = id(new PHUIHeaderView())
->setHeader(pht('Account Managers')) ->setHeader(pht('Account Managers'))

View file

@ -0,0 +1,37 @@
<?php
final class PhortuneAccountOrdersController
extends PhortuneAccountProfileController {
public function handleRequest(AphrontRequest $request) {
$response = $this->loadAccount();
if ($response) {
return $response;
}
$account = $this->getAccount();
$title = $account->getName();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Order History'));
$header = $this->buildHeaderView();
$order_history = $this->newRecentOrdersView($account, 100);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter(
array(
$order_history,
));
$navigation = $this->buildSideNavView('orders');
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->setNavigation($navigation)
->appendChild($view);
}
}

View file

@ -1,6 +1,6 @@
<?php <?php
final class PhortuneAccountViewController final class PhortuneAccountOverviewController
extends PhortuneAccountProfileController { extends PhortuneAccountProfileController {
public function handleRequest(AphrontRequest $request) { public function handleRequest(AphrontRequest $request) {
@ -26,25 +26,18 @@ final class PhortuneAccountViewController
$header = $this->buildHeaderView(); $header = $this->buildHeaderView();
$curtain = $this->buildCurtainView($account);
$status = $this->buildStatusView($account, $invoices); $status = $this->buildStatusView($account, $invoices);
$invoices = $this->buildInvoicesSection($account, $invoices); $invoices = $this->buildInvoicesSection($account, $invoices);
$purchase_history = $this->buildPurchaseHistorySection($account); $purchase_history = $this->newRecentOrdersView($account, 10);
$timeline = $this->buildTransactionTimeline(
$account,
new PhortuneAccountTransactionQuery());
$timeline->setShouldTerminate(true);
$view = id(new PHUITwoColumnView()) $view = id(new PHUITwoColumnView())
->setHeader($header) ->setHeader($header)
->setCurtain($curtain) ->setFooter(
->setMainColumn(array( array(
$status, $status,
$invoices, $invoices,
$purchase_history, $purchase_history,
$timeline, ));
));
$navigation = $this->buildSideNavView('overview'); $navigation = $this->buildSideNavView('overview');
@ -53,7 +46,6 @@ final class PhortuneAccountViewController
->setCrumbs($crumbs) ->setCrumbs($crumbs)
->setNavigation($navigation) ->setNavigation($navigation)
->appendChild($view); ->appendChild($view);
} }
private function buildStatusView(PhortuneAccount $account, $invoices) { private function buildStatusView(PhortuneAccount $account, $invoices) {
@ -67,51 +59,6 @@ final class PhortuneAccountViewController
return $view; return $view;
} }
private function buildCurtainView(PhortuneAccount $account) {
$viewer = $this->getViewer();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$account,
PhabricatorPolicyCapability::CAN_EDIT);
$edit_uri = $this->getApplicationURI('account/edit/'.$account->getID().'/');
$curtain = $this->newCurtainView($account);
$curtain->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Account'))
->setIcon('fa-pencil')
->setHref($edit_uri)
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
$member_phids = $account->getMemberPHIDs();
$handles = $viewer->loadHandles($member_phids);
$member_list = id(new PHUIObjectItemListView())
->setSimple(true);
foreach ($member_phids as $member_phid) {
$image_uri = $handles[$member_phid]->getImageURI();
$image_href = $handles[$member_phid]->getURI();
$person = $handles[$member_phid];
$member = id(new PHUIObjectItemView())
->setImageURI($image_uri)
->setHref($image_href)
->setHeader($person->getFullName());
$member_list->addItem($member);
}
$curtain->newPanel()
->setHeaderText(pht('Managers'))
->appendChild($member_list);
return $curtain;
}
private function buildInvoicesSection( private function buildInvoicesSection(
PhortuneAccount $account, PhortuneAccount $account,
array $carts) { array $carts) {
@ -144,55 +91,6 @@ final class PhortuneAccountViewController
->setTable($table); ->setTable($table);
} }
private function buildPurchaseHistorySection(PhortuneAccount $account) {
$viewer = $this->getViewer();
$carts = id(new PhortuneCartQuery())
->setViewer($viewer)
->withAccountPHIDs(array($account->getPHID()))
->needPurchases(true)
->withStatuses(
array(
PhortuneCart::STATUS_PURCHASING,
PhortuneCart::STATUS_CHARGED,
PhortuneCart::STATUS_HOLD,
PhortuneCart::STATUS_REVIEW,
PhortuneCart::STATUS_PURCHASED,
))
->setLimit(10)
->execute();
$phids = array();
foreach ($carts as $cart) {
$phids[] = $cart->getPHID();
foreach ($cart->getPurchases() as $purchase) {
$phids[] = $purchase->getPHID();
}
}
$handles = $this->loadViewerHandles($phids);
$orders_uri = $this->getApplicationURI($account->getID().'/order/');
$table = id(new PhortuneOrderTableView())
->setUser($viewer)
->setCarts($carts)
->setHandles($handles);
$header = id(new PHUIHeaderView())
->setHeader(pht('Recent Orders'))
->addActionLink(
id(new PHUIButtonView())
->setTag('a')
->setIcon('fa-list')
->setHref($orders_uri)
->setText(pht('View All Orders')));
return id(new PHUIObjectBoxView())
->setHeader($header)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setTable($table);
}
protected function buildApplicationCrumbs() { protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs(); $crumbs = parent::buildApplicationCrumbs();

View file

@ -1,6 +1,6 @@
<?php <?php
final class PhortuneAccountBillingController final class PhortuneAccountPaymentMethodsController
extends PhortuneAccountProfileController { extends PhortuneAccountProfileController {
public function handleRequest(AphrontRequest $request) { public function handleRequest(AphrontRequest $request) {
@ -13,20 +13,19 @@ final class PhortuneAccountBillingController
$title = $account->getName(); $title = $account->getName();
$crumbs = $this->buildApplicationCrumbs(); $crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Billing')); $crumbs->addTextCrumb(pht('Payment Methods'));
$header = $this->buildHeaderView(); $header = $this->buildHeaderView();
$methods = $this->buildPaymentMethodsSection($account); $methods = $this->buildPaymentMethodsSection($account);
$charge_history = $this->buildChargeHistorySection($account);
$view = id(new PHUITwoColumnView()) $view = id(new PHUITwoColumnView())
->setHeader($header) ->setHeader($header)
->setFooter(array( ->setFooter(
$methods, array(
$charge_history, $methods,
)); ));
$navigation = $this->buildSideNavView('billing'); $navigation = $this->buildSideNavView('methods');
return $this->newPage() return $this->newPage()
->setTitle($title) ->setTitle($title)
@ -60,7 +59,7 @@ final class PhortuneAccountBillingController
->setUser($viewer) ->setUser($viewer)
->setFlush(true) ->setFlush(true)
->setNoDataString( ->setNoDataString(
pht('No payment methods associated with this account.')); pht('There are no payment methods associated with this account.'));
$methods = id(new PhortunePaymentMethodQuery()) $methods = id(new PhortunePaymentMethodQuery())
->setViewer($viewer) ->setViewer($viewer)
@ -116,46 +115,4 @@ final class PhortuneAccountBillingController
->setObjectList($list); ->setObjectList($list);
} }
private function buildChargeHistorySection(PhortuneAccount $account) {
$viewer = $this->getViewer();
$charges = id(new PhortuneChargeQuery())
->setViewer($viewer)
->withAccountPHIDs(array($account->getPHID()))
->needCarts(true)
->setLimit(10)
->execute();
$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('Charge History'))
->addActionLink(
id(new PHUIButtonView())
->setTag('a')
->setIcon('fa-list')
->setHref($charges_uri)
->setText(pht('View All Charges')));
return id(new PHUIObjectBoxView())
->setHeader($header)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setTable($table);
}
} }

View file

@ -43,21 +43,43 @@ abstract class PhortuneAccountProfileController
'fa-user-circle'); 'fa-user-circle');
$nav->addFilter( $nav->addFilter(
'subscriptions', 'details',
pht('Subscriptions'), pht('Account Details'),
$this->getApplicationURI("/account/subscription/{$id}/"), $this->getApplicationURI("/account/{$id}/details/"),
'fa-retweet'); 'fa-address-card-o');
$nav->addLabel(pht('Payments'));
$nav->addFilter( $nav->addFilter(
'billing', 'methods',
pht('Billing / History'), pht('Payment Methods'),
$this->getApplicationURI("/account/billing/{$id}/"), $this->getApplicationURI("/account/{$id}/methods/"),
'fa-credit-card'); 'fa-credit-card');
$nav->addFilter(
'subscriptions',
pht('Subscriptions'),
$this->getApplicationURI("/account/{$id}/subscriptions/"),
'fa-retweet');
$nav->addFilter(
'orders',
pht('Order History'),
$this->getApplicationURI("/account/{$id}/orders/"),
'fa-shopping-bag');
$nav->addFilter(
'charges',
pht('Charge History'),
$this->getApplicationURI("/account/{$id}/charges/"),
'fa-calculator');
$nav->addLabel(pht('Personnel'));
$nav->addFilter( $nav->addFilter(
'managers', 'managers',
pht('Managers'), pht('Account Managers'),
$this->getApplicationURI("/account/manager/{$id}/"), $this->getApplicationURI("/account/{$id}/managers/"),
'fa-group'); 'fa-group');
$nav->selectFilter($filter); $nav->selectFilter($filter);
@ -65,4 +87,57 @@ abstract class PhortuneAccountProfileController
return $nav; return $nav;
} }
final protected function newRecentOrdersView(
PhortuneAccount $account,
$limit) {
$viewer = $this->getViewer();
$carts = id(new PhortuneCartQuery())
->setViewer($viewer)
->withAccountPHIDs(array($account->getPHID()))
->needPurchases(true)
->withStatuses(
array(
PhortuneCart::STATUS_PURCHASING,
PhortuneCart::STATUS_CHARGED,
PhortuneCart::STATUS_HOLD,
PhortuneCart::STATUS_REVIEW,
PhortuneCart::STATUS_PURCHASED,
))
->setLimit($limit)
->execute();
$phids = array();
foreach ($carts as $cart) {
$phids[] = $cart->getPHID();
foreach ($cart->getPurchases() as $purchase) {
$phids[] = $purchase->getPHID();
}
}
$handles = $this->loadViewerHandles($phids);
$orders_uri = $this->getApplicationURI($account->getID().'/order/');
$table = id(new PhortuneOrderTableView())
->setUser($viewer)
->setCarts($carts)
->setHandles($handles);
$header = id(new PHUIHeaderView())
->setHeader(pht('Recent Orders'))
->addActionLink(
id(new PHUIButtonView())
->setTag('a')
->setIcon('fa-list')
->setHref($orders_uri)
->setText(pht('View All Orders')));
return id(new PHUIObjectBoxView())
->setHeader($header)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setTable($table);
}
} }

View file

@ -62,7 +62,11 @@ final class PhortuneAccountEditEngine
} }
protected function getObjectViewURI($object) { protected function getObjectViewURI($object) {
return $object->getURI(); if ($this->getIsCreate()) {
return $object->getURI();
} else {
return $object->getDetailsURI();
}
} }
protected function buildCustomEditFields($object) { protected function buildCustomEditFields($object) {

View file

@ -103,6 +103,12 @@ final class PhortuneAccount extends PhortuneDAO
return '/phortune/'.$this->getID().'/'; return '/phortune/'.$this->getID().'/';
} }
public function getDetailsURI() {
return urisprintf(
'/phortune/account/%d/details/',
$this->getID());
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */ /* -( PhabricatorApplicationTransactionInterface )------------------------- */