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:
parent
ecbc82da33
commit
719a7d82c5
12 changed files with 390 additions and 194 deletions
|
@ -5221,25 +5221,28 @@ phutil_register_library_map(array(
|
|||
'PhortuneAccount' => 'applications/phortune/storage/PhortuneAccount.php',
|
||||
'PhortuneAccountAddManagerController' => 'applications/phortune/controller/account/PhortuneAccountAddManagerController.php',
|
||||
'PhortuneAccountBillingAddressTransaction' => 'applications/phortune/xaction/PhortuneAccountBillingAddressTransaction.php',
|
||||
'PhortuneAccountBillingController' => 'applications/phortune/controller/account/PhortuneAccountBillingController.php',
|
||||
'PhortuneAccountBillingNameTransaction' => 'applications/phortune/xaction/PhortuneAccountBillingNameTransaction.php',
|
||||
'PhortuneAccountChargeListController' => 'applications/phortune/controller/account/PhortuneAccountChargeListController.php',
|
||||
'PhortuneAccountChargesController' => 'applications/phortune/controller/account/PhortuneAccountChargesController.php',
|
||||
'PhortuneAccountController' => 'applications/phortune/controller/account/PhortuneAccountController.php',
|
||||
'PhortuneAccountDetailsController' => 'applications/phortune/controller/account/PhortuneAccountDetailsController.php',
|
||||
'PhortuneAccountEditController' => 'applications/phortune/controller/account/PhortuneAccountEditController.php',
|
||||
'PhortuneAccountEditEngine' => 'applications/phortune/editor/PhortuneAccountEditEngine.php',
|
||||
'PhortuneAccountEditor' => 'applications/phortune/editor/PhortuneAccountEditor.php',
|
||||
'PhortuneAccountHasMemberEdgeType' => 'applications/phortune/edge/PhortuneAccountHasMemberEdgeType.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',
|
||||
'PhortuneAccountOrdersController' => 'applications/phortune/controller/account/PhortuneAccountOrdersController.php',
|
||||
'PhortuneAccountOverviewController' => 'applications/phortune/controller/account/PhortuneAccountOverviewController.php',
|
||||
'PhortuneAccountPHIDType' => 'applications/phortune/phid/PhortuneAccountPHIDType.php',
|
||||
'PhortuneAccountPaymentMethodsController' => 'applications/phortune/controller/account/PhortuneAccountPaymentMethodsController.php',
|
||||
'PhortuneAccountProfileController' => 'applications/phortune/controller/account/PhortuneAccountProfileController.php',
|
||||
'PhortuneAccountQuery' => 'applications/phortune/query/PhortuneAccountQuery.php',
|
||||
'PhortuneAccountSubscriptionController' => 'applications/phortune/controller/account/PhortuneAccountSubscriptionController.php',
|
||||
'PhortuneAccountTransaction' => 'applications/phortune/storage/PhortuneAccountTransaction.php',
|
||||
'PhortuneAccountTransactionQuery' => 'applications/phortune/query/PhortuneAccountTransactionQuery.php',
|
||||
'PhortuneAccountTransactionType' => 'applications/phortune/xaction/PhortuneAccountTransactionType.php',
|
||||
'PhortuneAccountViewController' => 'applications/phortune/controller/account/PhortuneAccountViewController.php',
|
||||
'PhortuneAdHocCart' => 'applications/phortune/cart/PhortuneAdHocCart.php',
|
||||
'PhortuneAdHocProduct' => 'applications/phortune/product/PhortuneAdHocProduct.php',
|
||||
'PhortuneAddPaymentMethodAction' => 'applications/phortune/action/PhortuneAddPaymentMethodAction.php',
|
||||
|
@ -11753,25 +11756,28 @@ phutil_register_library_map(array(
|
|||
),
|
||||
'PhortuneAccountAddManagerController' => 'PhortuneController',
|
||||
'PhortuneAccountBillingAddressTransaction' => 'PhortuneAccountTransactionType',
|
||||
'PhortuneAccountBillingController' => 'PhortuneAccountProfileController',
|
||||
'PhortuneAccountBillingNameTransaction' => 'PhortuneAccountTransactionType',
|
||||
'PhortuneAccountChargeListController' => 'PhortuneController',
|
||||
'PhortuneAccountChargesController' => 'PhortuneAccountProfileController',
|
||||
'PhortuneAccountController' => 'PhortuneController',
|
||||
'PhortuneAccountDetailsController' => 'PhortuneAccountProfileController',
|
||||
'PhortuneAccountEditController' => 'PhortuneController',
|
||||
'PhortuneAccountEditEngine' => 'PhabricatorEditEngine',
|
||||
'PhortuneAccountEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||
'PhortuneAccountHasMemberEdgeType' => 'PhabricatorEdgeType',
|
||||
'PhortuneAccountListController' => 'PhortuneController',
|
||||
'PhortuneAccountManagerController' => 'PhortuneAccountProfileController',
|
||||
'PhortuneAccountManagersController' => 'PhortuneAccountProfileController',
|
||||
'PhortuneAccountNameTransaction' => 'PhortuneAccountTransactionType',
|
||||
'PhortuneAccountOrdersController' => 'PhortuneAccountProfileController',
|
||||
'PhortuneAccountOverviewController' => 'PhortuneAccountProfileController',
|
||||
'PhortuneAccountPHIDType' => 'PhabricatorPHIDType',
|
||||
'PhortuneAccountPaymentMethodsController' => 'PhortuneAccountProfileController',
|
||||
'PhortuneAccountProfileController' => 'PhortuneAccountController',
|
||||
'PhortuneAccountQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PhortuneAccountSubscriptionController' => 'PhortuneAccountProfileController',
|
||||
'PhortuneAccountTransaction' => 'PhabricatorModularTransaction',
|
||||
'PhortuneAccountTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||
'PhortuneAccountTransactionType' => 'PhabricatorModularTransactionType',
|
||||
'PhortuneAccountViewController' => 'PhortuneAccountProfileController',
|
||||
'PhortuneAdHocCart' => 'PhortuneCartImplementation',
|
||||
'PhortuneAdHocProduct' => 'PhortuneProductImplementation',
|
||||
'PhortuneAddPaymentMethodAction' => 'PhabricatorSystemAction',
|
||||
|
|
|
@ -35,7 +35,7 @@ final class PhabricatorPhortuneApplication extends PhabricatorApplication {
|
|||
'/phortune/' => array(
|
||||
'' => 'PhortuneLandingController',
|
||||
'(?P<accountID>\d+)/' => array(
|
||||
'' => 'PhortuneAccountViewController',
|
||||
'' => 'PhortuneAccountOverviewController',
|
||||
'card/' => array(
|
||||
'new/' => 'PhortunePaymentMethodCreateController',
|
||||
),
|
||||
|
@ -69,15 +69,17 @@ final class PhabricatorPhortuneApplication extends PhabricatorApplication {
|
|||
'' => 'PhortuneAccountListController',
|
||||
$this->getEditRoutePattern('edit/')
|
||||
=> 'PhortuneAccountEditController',
|
||||
'edit/(?:(?P<id>\d+)/)?' => 'PhortuneAccountEditController',
|
||||
'add/manager/(?:(?P<id>\d+)/)?'
|
||||
=> 'PhortuneAccountAddManagerController',
|
||||
'billing/(?:(?P<id>\d+)/)?' => 'PhortuneAccountBillingController',
|
||||
'subscription/(?:(?P<id>\d+)/)?'
|
||||
=> 'PhortuneAccountSubscriptionController',
|
||||
'manager/' => array(
|
||||
'(?:(?P<id>\d+)/)?' => 'PhortuneAccountManagerController',
|
||||
'add/(?:(?P<id>\d+)/)?' => 'PhortuneAccountAddManagerController',
|
||||
|
||||
'(?P<accountID>\d+)/' => array(
|
||||
'details/' => 'PhortuneAccountDetailsController',
|
||||
'methods/' => 'PhortuneAccountPaymentMethodsController',
|
||||
'orders/' => 'PhortuneAccountOrdersController',
|
||||
'charges/' => 'PhortuneAccountChargesController',
|
||||
'subscriptions/' => 'PhortuneAccountSubscriptionController',
|
||||
'managers/' => array(
|
||||
'' => 'PhortuneAccountManagersController',
|
||||
'add/' => 'PhortuneAccountAddManagerController',
|
||||
),
|
||||
),
|
||||
),
|
||||
'product/' => array(
|
||||
|
|
|
@ -4,7 +4,7 @@ final class PhortuneAccountAddManagerController extends PhortuneController {
|
|||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $request->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
$id = $request->getURIData('accountID');
|
||||
|
||||
$account = id(new PhortuneAccountQuery())
|
||||
->setViewer($viewer)
|
||||
|
@ -21,7 +21,7 @@ final class PhortuneAccountAddManagerController extends PhortuneController {
|
|||
|
||||
$v_managers = array();
|
||||
$e_managers = null;
|
||||
$account_uri = $this->getApplicationURI("/account/manager/{$id}/");
|
||||
$account_uri = $this->getApplicationURI("/account/{$id}/managers/");
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$xactions = array();
|
||||
|
@ -64,11 +64,11 @@ final class PhortuneAccountAddManagerController extends PhortuneController {
|
|||
->setError($e_managers));
|
||||
|
||||
return $this->newDialog()
|
||||
->setTitle(pht('Add New Manager'))
|
||||
->setTitle(pht('Add New Managers'))
|
||||
->appendForm($form)
|
||||
->setWidth(AphrontDialogView::WIDTH_FORM)
|
||||
->addCancelButton($account_uri)
|
||||
->addSubmitButton(pht('Add Manager'));
|
||||
->addSubmitButton(pht('Add Managers'));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
final class PhortuneAccountManagerController
|
||||
final class PhortuneAccountManagersController
|
||||
extends PhortuneAccountProfileController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
|
@ -46,11 +46,11 @@ final class PhortuneAccountManagerController
|
|||
|
||||
$add = id(new PHUIButtonView())
|
||||
->setTag('a')
|
||||
->setText(pht('New Manager'))
|
||||
->setText(pht('Add Managers'))
|
||||
->setIcon('fa-plus')
|
||||
->setWorkflow(true)
|
||||
->setDisabled(!$can_edit)
|
||||
->setHref("/phortune/account/manager/add/{$id}/");
|
||||
->setHref("/phortune/account/{$id}/managers/add/");
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader(pht('Account Managers'))
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
final class PhortuneAccountViewController
|
||||
final class PhortuneAccountOverviewController
|
||||
extends PhortuneAccountProfileController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
|
@ -26,24 +26,17 @@ final class PhortuneAccountViewController
|
|||
|
||||
$header = $this->buildHeaderView();
|
||||
|
||||
$curtain = $this->buildCurtainView($account);
|
||||
$status = $this->buildStatusView($account, $invoices);
|
||||
$invoices = $this->buildInvoicesSection($account, $invoices);
|
||||
$purchase_history = $this->buildPurchaseHistorySection($account);
|
||||
|
||||
$timeline = $this->buildTransactionTimeline(
|
||||
$account,
|
||||
new PhortuneAccountTransactionQuery());
|
||||
$timeline->setShouldTerminate(true);
|
||||
$purchase_history = $this->newRecentOrdersView($account, 10);
|
||||
|
||||
$view = id(new PHUITwoColumnView())
|
||||
->setHeader($header)
|
||||
->setCurtain($curtain)
|
||||
->setMainColumn(array(
|
||||
->setFooter(
|
||||
array(
|
||||
$status,
|
||||
$invoices,
|
||||
$purchase_history,
|
||||
$timeline,
|
||||
));
|
||||
|
||||
$navigation = $this->buildSideNavView('overview');
|
||||
|
@ -53,7 +46,6 @@ final class PhortuneAccountViewController
|
|||
->setCrumbs($crumbs)
|
||||
->setNavigation($navigation)
|
||||
->appendChild($view);
|
||||
|
||||
}
|
||||
|
||||
private function buildStatusView(PhortuneAccount $account, $invoices) {
|
||||
|
@ -67,51 +59,6 @@ final class PhortuneAccountViewController
|
|||
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(
|
||||
PhortuneAccount $account,
|
||||
array $carts) {
|
||||
|
@ -144,55 +91,6 @@ final class PhortuneAccountViewController
|
|||
->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() {
|
||||
$crumbs = parent::buildApplicationCrumbs();
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
final class PhortuneAccountBillingController
|
||||
final class PhortuneAccountPaymentMethodsController
|
||||
extends PhortuneAccountProfileController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
|
@ -13,20 +13,19 @@ final class PhortuneAccountBillingController
|
|||
$title = $account->getName();
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb(pht('Billing'));
|
||||
$crumbs->addTextCrumb(pht('Payment Methods'));
|
||||
|
||||
$header = $this->buildHeaderView();
|
||||
$methods = $this->buildPaymentMethodsSection($account);
|
||||
$charge_history = $this->buildChargeHistorySection($account);
|
||||
|
||||
$view = id(new PHUITwoColumnView())
|
||||
->setHeader($header)
|
||||
->setFooter(array(
|
||||
->setFooter(
|
||||
array(
|
||||
$methods,
|
||||
$charge_history,
|
||||
));
|
||||
|
||||
$navigation = $this->buildSideNavView('billing');
|
||||
$navigation = $this->buildSideNavView('methods');
|
||||
|
||||
return $this->newPage()
|
||||
->setTitle($title)
|
||||
|
@ -60,7 +59,7 @@ final class PhortuneAccountBillingController
|
|||
->setUser($viewer)
|
||||
->setFlush(true)
|
||||
->setNoDataString(
|
||||
pht('No payment methods associated with this account.'));
|
||||
pht('There are no payment methods associated with this account.'));
|
||||
|
||||
$methods = id(new PhortunePaymentMethodQuery())
|
||||
->setViewer($viewer)
|
||||
|
@ -116,46 +115,4 @@ final class PhortuneAccountBillingController
|
|||
->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);
|
||||
}
|
||||
|
||||
}
|
|
@ -43,21 +43,43 @@ abstract class PhortuneAccountProfileController
|
|||
'fa-user-circle');
|
||||
|
||||
$nav->addFilter(
|
||||
'subscriptions',
|
||||
pht('Subscriptions'),
|
||||
$this->getApplicationURI("/account/subscription/{$id}/"),
|
||||
'fa-retweet');
|
||||
'details',
|
||||
pht('Account Details'),
|
||||
$this->getApplicationURI("/account/{$id}/details/"),
|
||||
'fa-address-card-o');
|
||||
|
||||
$nav->addLabel(pht('Payments'));
|
||||
|
||||
$nav->addFilter(
|
||||
'billing',
|
||||
pht('Billing / History'),
|
||||
$this->getApplicationURI("/account/billing/{$id}/"),
|
||||
'methods',
|
||||
pht('Payment Methods'),
|
||||
$this->getApplicationURI("/account/{$id}/methods/"),
|
||||
'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(
|
||||
'managers',
|
||||
pht('Managers'),
|
||||
$this->getApplicationURI("/account/manager/{$id}/"),
|
||||
pht('Account Managers'),
|
||||
$this->getApplicationURI("/account/{$id}/managers/"),
|
||||
'fa-group');
|
||||
|
||||
$nav->selectFilter($filter);
|
||||
|
@ -65,4 +87,57 @@ abstract class PhortuneAccountProfileController
|
|||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -62,7 +62,11 @@ final class PhortuneAccountEditEngine
|
|||
}
|
||||
|
||||
protected function getObjectViewURI($object) {
|
||||
if ($this->getIsCreate()) {
|
||||
return $object->getURI();
|
||||
} else {
|
||||
return $object->getDetailsURI();
|
||||
}
|
||||
}
|
||||
|
||||
protected function buildCustomEditFields($object) {
|
||||
|
|
|
@ -103,6 +103,12 @@ final class PhortuneAccount extends PhortuneDAO
|
|||
return '/phortune/'.$this->getID().'/';
|
||||
}
|
||||
|
||||
public function getDetailsURI() {
|
||||
return urisprintf(
|
||||
'/phortune/account/%d/details/',
|
||||
$this->getID());
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
|
||||
|
||||
|
|
Loading…
Reference in a new issue