@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+516 -320
+12 -6
src/__phutil_library_map__.php
··· 5221 5221 'PhortuneAccount' => 'applications/phortune/storage/PhortuneAccount.php', 5222 5222 'PhortuneAccountAddManagerController' => 'applications/phortune/controller/account/PhortuneAccountAddManagerController.php', 5223 5223 'PhortuneAccountBillingAddressTransaction' => 'applications/phortune/xaction/PhortuneAccountBillingAddressTransaction.php', 5224 - 'PhortuneAccountBillingController' => 'applications/phortune/controller/account/PhortuneAccountBillingController.php', 5225 5224 'PhortuneAccountBillingNameTransaction' => 'applications/phortune/xaction/PhortuneAccountBillingNameTransaction.php', 5226 5225 'PhortuneAccountChargeListController' => 'applications/phortune/controller/account/PhortuneAccountChargeListController.php', 5226 + 'PhortuneAccountChargesController' => 'applications/phortune/controller/account/PhortuneAccountChargesController.php', 5227 5227 'PhortuneAccountController' => 'applications/phortune/controller/account/PhortuneAccountController.php', 5228 + 'PhortuneAccountDetailsController' => 'applications/phortune/controller/account/PhortuneAccountDetailsController.php', 5228 5229 'PhortuneAccountEditController' => 'applications/phortune/controller/account/PhortuneAccountEditController.php', 5229 5230 'PhortuneAccountEditEngine' => 'applications/phortune/editor/PhortuneAccountEditEngine.php', 5230 5231 'PhortuneAccountEditor' => 'applications/phortune/editor/PhortuneAccountEditor.php', 5231 5232 'PhortuneAccountHasMemberEdgeType' => 'applications/phortune/edge/PhortuneAccountHasMemberEdgeType.php', 5232 5233 'PhortuneAccountListController' => 'applications/phortune/controller/account/PhortuneAccountListController.php', 5233 - 'PhortuneAccountManagerController' => 'applications/phortune/controller/account/PhortuneAccountManagerController.php', 5234 + 'PhortuneAccountManagersController' => 'applications/phortune/controller/account/PhortuneAccountManagersController.php', 5234 5235 'PhortuneAccountNameTransaction' => 'applications/phortune/xaction/PhortuneAccountNameTransaction.php', 5236 + 'PhortuneAccountOrdersController' => 'applications/phortune/controller/account/PhortuneAccountOrdersController.php', 5237 + 'PhortuneAccountOverviewController' => 'applications/phortune/controller/account/PhortuneAccountOverviewController.php', 5235 5238 'PhortuneAccountPHIDType' => 'applications/phortune/phid/PhortuneAccountPHIDType.php', 5239 + 'PhortuneAccountPaymentMethodsController' => 'applications/phortune/controller/account/PhortuneAccountPaymentMethodsController.php', 5236 5240 'PhortuneAccountProfileController' => 'applications/phortune/controller/account/PhortuneAccountProfileController.php', 5237 5241 'PhortuneAccountQuery' => 'applications/phortune/query/PhortuneAccountQuery.php', 5238 5242 'PhortuneAccountSubscriptionController' => 'applications/phortune/controller/account/PhortuneAccountSubscriptionController.php', 5239 5243 'PhortuneAccountTransaction' => 'applications/phortune/storage/PhortuneAccountTransaction.php', 5240 5244 'PhortuneAccountTransactionQuery' => 'applications/phortune/query/PhortuneAccountTransactionQuery.php', 5241 5245 'PhortuneAccountTransactionType' => 'applications/phortune/xaction/PhortuneAccountTransactionType.php', 5242 - 'PhortuneAccountViewController' => 'applications/phortune/controller/account/PhortuneAccountViewController.php', 5243 5246 'PhortuneAdHocCart' => 'applications/phortune/cart/PhortuneAdHocCart.php', 5244 5247 'PhortuneAdHocProduct' => 'applications/phortune/product/PhortuneAdHocProduct.php', 5245 5248 'PhortuneAddPaymentMethodAction' => 'applications/phortune/action/PhortuneAddPaymentMethodAction.php', ··· 11753 11756 ), 11754 11757 'PhortuneAccountAddManagerController' => 'PhortuneController', 11755 11758 'PhortuneAccountBillingAddressTransaction' => 'PhortuneAccountTransactionType', 11756 - 'PhortuneAccountBillingController' => 'PhortuneAccountProfileController', 11757 11759 'PhortuneAccountBillingNameTransaction' => 'PhortuneAccountTransactionType', 11758 11760 'PhortuneAccountChargeListController' => 'PhortuneController', 11761 + 'PhortuneAccountChargesController' => 'PhortuneAccountProfileController', 11759 11762 'PhortuneAccountController' => 'PhortuneController', 11763 + 'PhortuneAccountDetailsController' => 'PhortuneAccountProfileController', 11760 11764 'PhortuneAccountEditController' => 'PhortuneController', 11761 11765 'PhortuneAccountEditEngine' => 'PhabricatorEditEngine', 11762 11766 'PhortuneAccountEditor' => 'PhabricatorApplicationTransactionEditor', 11763 11767 'PhortuneAccountHasMemberEdgeType' => 'PhabricatorEdgeType', 11764 11768 'PhortuneAccountListController' => 'PhortuneController', 11765 - 'PhortuneAccountManagerController' => 'PhortuneAccountProfileController', 11769 + 'PhortuneAccountManagersController' => 'PhortuneAccountProfileController', 11766 11770 'PhortuneAccountNameTransaction' => 'PhortuneAccountTransactionType', 11771 + 'PhortuneAccountOrdersController' => 'PhortuneAccountProfileController', 11772 + 'PhortuneAccountOverviewController' => 'PhortuneAccountProfileController', 11767 11773 'PhortuneAccountPHIDType' => 'PhabricatorPHIDType', 11774 + 'PhortuneAccountPaymentMethodsController' => 'PhortuneAccountProfileController', 11768 11775 'PhortuneAccountProfileController' => 'PhortuneAccountController', 11769 11776 'PhortuneAccountQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 11770 11777 'PhortuneAccountSubscriptionController' => 'PhortuneAccountProfileController', 11771 11778 'PhortuneAccountTransaction' => 'PhabricatorModularTransaction', 11772 11779 'PhortuneAccountTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 11773 11780 'PhortuneAccountTransactionType' => 'PhabricatorModularTransactionType', 11774 - 'PhortuneAccountViewController' => 'PhortuneAccountProfileController', 11775 11781 'PhortuneAdHocCart' => 'PhortuneCartImplementation', 11776 11782 'PhortuneAdHocProduct' => 'PhortuneProductImplementation', 11777 11783 'PhortuneAddPaymentMethodAction' => 'PhabricatorSystemAction',
+12 -10
src/applications/phortune/application/PhabricatorPhortuneApplication.php
··· 35 35 '/phortune/' => array( 36 36 '' => 'PhortuneLandingController', 37 37 '(?P<accountID>\d+)/' => array( 38 - '' => 'PhortuneAccountViewController', 38 + '' => 'PhortuneAccountOverviewController', 39 39 'card/' => array( 40 40 'new/' => 'PhortunePaymentMethodCreateController', 41 41 ), ··· 69 69 '' => 'PhortuneAccountListController', 70 70 $this->getEditRoutePattern('edit/') 71 71 => 'PhortuneAccountEditController', 72 - 'edit/(?:(?P<id>\d+)/)?' => 'PhortuneAccountEditController', 73 - 'add/manager/(?:(?P<id>\d+)/)?' 74 - => 'PhortuneAccountAddManagerController', 75 - 'billing/(?:(?P<id>\d+)/)?' => 'PhortuneAccountBillingController', 76 - 'subscription/(?:(?P<id>\d+)/)?' 77 - => 'PhortuneAccountSubscriptionController', 78 - 'manager/' => array( 79 - '(?:(?P<id>\d+)/)?' => 'PhortuneAccountManagerController', 80 - 'add/(?:(?P<id>\d+)/)?' => 'PhortuneAccountAddManagerController', 72 + 73 + '(?P<accountID>\d+)/' => array( 74 + 'details/' => 'PhortuneAccountDetailsController', 75 + 'methods/' => 'PhortuneAccountPaymentMethodsController', 76 + 'orders/' => 'PhortuneAccountOrdersController', 77 + 'charges/' => 'PhortuneAccountChargesController', 78 + 'subscriptions/' => 'PhortuneAccountSubscriptionController', 79 + 'managers/' => array( 80 + '' => 'PhortuneAccountManagersController', 81 + 'add/' => 'PhortuneAccountAddManagerController', 82 + ), 81 83 ), 82 84 ), 83 85 'product/' => array(
+4 -4
src/applications/phortune/controller/account/PhortuneAccountAddManagerController.php
··· 4 4 5 5 public function handleRequest(AphrontRequest $request) { 6 6 $viewer = $request->getViewer(); 7 - $id = $request->getURIData('id'); 7 + $id = $request->getURIData('accountID'); 8 8 9 9 $account = id(new PhortuneAccountQuery()) 10 10 ->setViewer($viewer) ··· 21 21 22 22 $v_managers = array(); 23 23 $e_managers = null; 24 - $account_uri = $this->getApplicationURI("/account/manager/{$id}/"); 24 + $account_uri = $this->getApplicationURI("/account/{$id}/managers/"); 25 25 26 26 if ($request->isFormPost()) { 27 27 $xactions = array(); ··· 64 64 ->setError($e_managers)); 65 65 66 66 return $this->newDialog() 67 - ->setTitle(pht('Add New Manager')) 67 + ->setTitle(pht('Add New Managers')) 68 68 ->appendForm($form) 69 69 ->setWidth(AphrontDialogView::WIDTH_FORM) 70 70 ->addCancelButton($account_uri) 71 - ->addSubmitButton(pht('Add Manager')); 71 + ->addSubmitButton(pht('Add Managers')); 72 72 73 73 } 74 74
+8 -51
src/applications/phortune/controller/account/PhortuneAccountBillingController.php src/applications/phortune/controller/account/PhortuneAccountPaymentMethodsController.php
··· 1 1 <?php 2 2 3 - final class PhortuneAccountBillingController 3 + final class PhortuneAccountPaymentMethodsController 4 4 extends PhortuneAccountProfileController { 5 5 6 6 public function handleRequest(AphrontRequest $request) { ··· 13 13 $title = $account->getName(); 14 14 15 15 $crumbs = $this->buildApplicationCrumbs(); 16 - $crumbs->addTextCrumb(pht('Billing')); 16 + $crumbs->addTextCrumb(pht('Payment Methods')); 17 17 18 18 $header = $this->buildHeaderView(); 19 19 $methods = $this->buildPaymentMethodsSection($account); 20 - $charge_history = $this->buildChargeHistorySection($account); 21 20 22 21 $view = id(new PHUITwoColumnView()) 23 22 ->setHeader($header) 24 - ->setFooter(array( 25 - $methods, 26 - $charge_history, 27 - )); 23 + ->setFooter( 24 + array( 25 + $methods, 26 + )); 28 27 29 - $navigation = $this->buildSideNavView('billing'); 28 + $navigation = $this->buildSideNavView('methods'); 30 29 31 30 return $this->newPage() 32 31 ->setTitle($title) ··· 60 59 ->setUser($viewer) 61 60 ->setFlush(true) 62 61 ->setNoDataString( 63 - pht('No payment methods associated with this account.')); 62 + pht('There are no payment methods associated with this account.')); 64 63 65 64 $methods = id(new PhortunePaymentMethodQuery()) 66 65 ->setViewer($viewer) ··· 114 113 ->setHeader($header) 115 114 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 116 115 ->setObjectList($list); 117 - } 118 - 119 - private function buildChargeHistorySection(PhortuneAccount $account) { 120 - $viewer = $this->getViewer(); 121 - 122 - $charges = id(new PhortuneChargeQuery()) 123 - ->setViewer($viewer) 124 - ->withAccountPHIDs(array($account->getPHID())) 125 - ->needCarts(true) 126 - ->setLimit(10) 127 - ->execute(); 128 - 129 - $phids = array(); 130 - foreach ($charges as $charge) { 131 - $phids[] = $charge->getProviderPHID(); 132 - $phids[] = $charge->getCartPHID(); 133 - $phids[] = $charge->getMerchantPHID(); 134 - $phids[] = $charge->getPaymentMethodPHID(); 135 - } 136 - 137 - $handles = $this->loadViewerHandles($phids); 138 - 139 - $charges_uri = $this->getApplicationURI($account->getID().'/charge/'); 140 - 141 - $table = id(new PhortuneChargeTableView()) 142 - ->setUser($viewer) 143 - ->setCharges($charges) 144 - ->setHandles($handles); 145 - 146 - $header = id(new PHUIHeaderView()) 147 - ->setHeader(pht('Charge History')) 148 - ->addActionLink( 149 - id(new PHUIButtonView()) 150 - ->setTag('a') 151 - ->setIcon('fa-list') 152 - ->setHref($charges_uri) 153 - ->setText(pht('View All Charges'))); 154 - 155 - return id(new PHUIObjectBoxView()) 156 - ->setHeader($header) 157 - ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 158 - ->setTable($table); 159 116 } 160 117 161 118 }
+79
src/applications/phortune/controller/account/PhortuneAccountChargesController.php
··· 1 + <?php 2 + 3 + final class PhortuneAccountChargesController 4 + extends PhortuneAccountProfileController { 5 + 6 + public function handleRequest(AphrontRequest $request) { 7 + $response = $this->loadAccount(); 8 + if ($response) { 9 + return $response; 10 + } 11 + 12 + $account = $this->getAccount(); 13 + $title = $account->getName(); 14 + 15 + $crumbs = $this->buildApplicationCrumbs(); 16 + $crumbs->addTextCrumb(pht('Order History')); 17 + 18 + $header = $this->buildHeaderView(); 19 + $charge_history = $this->buildChargeHistorySection($account); 20 + 21 + $view = id(new PHUITwoColumnView()) 22 + ->setHeader($header) 23 + ->setFooter( 24 + array( 25 + $charge_history, 26 + )); 27 + 28 + $navigation = $this->buildSideNavView('charges'); 29 + 30 + return $this->newPage() 31 + ->setTitle($title) 32 + ->setCrumbs($crumbs) 33 + ->setNavigation($navigation) 34 + ->appendChild($view); 35 + } 36 + 37 + private function buildChargeHistorySection(PhortuneAccount $account) { 38 + $viewer = $this->getViewer(); 39 + 40 + $charges = id(new PhortuneChargeQuery()) 41 + ->setViewer($viewer) 42 + ->withAccountPHIDs(array($account->getPHID())) 43 + ->needCarts(true) 44 + ->setLimit(100) 45 + ->execute(); 46 + 47 + $phids = array(); 48 + foreach ($charges as $charge) { 49 + $phids[] = $charge->getProviderPHID(); 50 + $phids[] = $charge->getCartPHID(); 51 + $phids[] = $charge->getMerchantPHID(); 52 + $phids[] = $charge->getPaymentMethodPHID(); 53 + } 54 + 55 + $handles = $this->loadViewerHandles($phids); 56 + 57 + $charges_uri = $this->getApplicationURI($account->getID().'/charge/'); 58 + 59 + $table = id(new PhortuneChargeTableView()) 60 + ->setUser($viewer) 61 + ->setCharges($charges) 62 + ->setHandles($handles); 63 + 64 + $header = id(new PHUIHeaderView()) 65 + ->setHeader(pht('Recent Charges')) 66 + ->addActionLink( 67 + id(new PHUIButtonView()) 68 + ->setTag('a') 69 + ->setIcon('fa-list') 70 + ->setHref($charges_uri) 71 + ->setText(pht('View All Charges'))); 72 + 73 + return id(new PHUIObjectBoxView()) 74 + ->setHeader($header) 75 + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 76 + ->setTable($table); 77 + } 78 + 79 + }
+132
src/applications/phortune/controller/account/PhortuneAccountDetailsController.php
··· 1 + <?php 2 + 3 + final class PhortuneAccountDetailsController 4 + extends PhortuneAccountProfileController { 5 + 6 + public function handleRequest(AphrontRequest $request) { 7 + $response = $this->loadAccount(); 8 + if ($response) { 9 + return $response; 10 + } 11 + 12 + $account = $this->getAccount(); 13 + $title = $account->getName(); 14 + 15 + $viewer = $this->getViewer(); 16 + 17 + $invoices = id(new PhortuneCartQuery()) 18 + ->setViewer($viewer) 19 + ->withAccountPHIDs(array($account->getPHID())) 20 + ->needPurchases(true) 21 + ->withInvoices(true) 22 + ->execute(); 23 + 24 + $crumbs = $this->buildApplicationCrumbs(); 25 + $crumbs->setBorder(true); 26 + 27 + $header = $this->buildHeaderView(); 28 + 29 + $details = $this->newDetailsView($account); 30 + 31 + $curtain = $this->buildCurtainView($account); 32 + 33 + $timeline = $this->buildTransactionTimeline( 34 + $account, 35 + new PhortuneAccountTransactionQuery()); 36 + $timeline->setShouldTerminate(true); 37 + 38 + 39 + $view = id(new PHUITwoColumnView()) 40 + ->setHeader($header) 41 + ->setCurtain($curtain) 42 + ->setMainColumn( 43 + array( 44 + $details, 45 + $timeline, 46 + )); 47 + 48 + $navigation = $this->buildSideNavView('details'); 49 + 50 + return $this->newPage() 51 + ->setTitle($title) 52 + ->setCrumbs($crumbs) 53 + ->setNavigation($navigation) 54 + ->appendChild($view); 55 + 56 + } 57 + 58 + private function buildCurtainView(PhortuneAccount $account) { 59 + $viewer = $this->getViewer(); 60 + 61 + $can_edit = PhabricatorPolicyFilter::hasCapability( 62 + $viewer, 63 + $account, 64 + PhabricatorPolicyCapability::CAN_EDIT); 65 + 66 + $edit_uri = $this->getApplicationURI('account/edit/'.$account->getID().'/'); 67 + 68 + $curtain = $this->newCurtainView($account); 69 + $curtain->addAction( 70 + id(new PhabricatorActionView()) 71 + ->setName(pht('Edit Account')) 72 + ->setIcon('fa-pencil') 73 + ->setHref($edit_uri) 74 + ->setDisabled(!$can_edit) 75 + ->setWorkflow(!$can_edit)); 76 + 77 + $member_phids = $account->getMemberPHIDs(); 78 + $handles = $viewer->loadHandles($member_phids); 79 + 80 + $member_list = id(new PHUIObjectItemListView()) 81 + ->setSimple(true); 82 + 83 + foreach ($member_phids as $member_phid) { 84 + $image_uri = $handles[$member_phid]->getImageURI(); 85 + $image_href = $handles[$member_phid]->getURI(); 86 + $person = $handles[$member_phid]; 87 + 88 + $member = id(new PHUIObjectItemView()) 89 + ->setImageURI($image_uri) 90 + ->setHref($image_href) 91 + ->setHeader($person->getFullName()); 92 + 93 + $member_list->addItem($member); 94 + } 95 + 96 + $curtain->newPanel() 97 + ->setHeaderText(pht('Managers')) 98 + ->appendChild($member_list); 99 + 100 + return $curtain; 101 + } 102 + 103 + private function newDetailsView(PhortuneAccount $account) { 104 + $viewer = $this->getViewer(); 105 + 106 + $view = id(new PHUIPropertyListView()) 107 + ->setUser($viewer); 108 + 109 + $view->addProperty(pht('Account Name'), $account->getName()); 110 + 111 + $display_name = $account->getBillingName(); 112 + if (!strlen($display_name)) { 113 + $display_name = phutil_tag('em', array(), pht('None')); 114 + } 115 + 116 + $display_address = $account->getBillingAddress(); 117 + if (!strlen($display_address)) { 118 + $display_address = phutil_tag('em', array(), pht('None')); 119 + } else { 120 + $display_address = phutil_escape_html_newlines($display_address); 121 + } 122 + 123 + $view->addProperty(pht('Billing Name'), $display_name); 124 + $view->addProperty(pht('Billing Address'), $display_address); 125 + 126 + return id(new PHUIObjectBoxView()) 127 + ->setHeaderText(pht('Account Details')) 128 + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 129 + ->addPropertyList($view); 130 + } 131 + 132 + }
+3 -3
src/applications/phortune/controller/account/PhortuneAccountManagerController.php src/applications/phortune/controller/account/PhortuneAccountManagersController.php
··· 1 1 <?php 2 2 3 - final class PhortuneAccountManagerController 3 + final class PhortuneAccountManagersController 4 4 extends PhortuneAccountProfileController { 5 5 6 6 public function handleRequest(AphrontRequest $request) { ··· 46 46 47 47 $add = id(new PHUIButtonView()) 48 48 ->setTag('a') 49 - ->setText(pht('New Manager')) 49 + ->setText(pht('Add Managers')) 50 50 ->setIcon('fa-plus') 51 51 ->setWorkflow(true) 52 52 ->setDisabled(!$can_edit) 53 - ->setHref("/phortune/account/manager/add/{$id}/"); 53 + ->setHref("/phortune/account/{$id}/managers/add/"); 54 54 55 55 $header = id(new PHUIHeaderView()) 56 56 ->setHeader(pht('Account Managers'))
+37
src/applications/phortune/controller/account/PhortuneAccountOrdersController.php
··· 1 + <?php 2 + 3 + final class PhortuneAccountOrdersController 4 + extends PhortuneAccountProfileController { 5 + 6 + public function handleRequest(AphrontRequest $request) { 7 + $response = $this->loadAccount(); 8 + if ($response) { 9 + return $response; 10 + } 11 + 12 + $account = $this->getAccount(); 13 + $title = $account->getName(); 14 + 15 + $crumbs = $this->buildApplicationCrumbs(); 16 + $crumbs->addTextCrumb(pht('Order History')); 17 + 18 + $header = $this->buildHeaderView(); 19 + $order_history = $this->newRecentOrdersView($account, 100); 20 + 21 + $view = id(new PHUITwoColumnView()) 22 + ->setHeader($header) 23 + ->setFooter( 24 + array( 25 + $order_history, 26 + )); 27 + 28 + $navigation = $this->buildSideNavView('orders'); 29 + 30 + return $this->newPage() 31 + ->setTitle($title) 32 + ->setCrumbs($crumbs) 33 + ->setNavigation($navigation) 34 + ->appendChild($view); 35 + } 36 + 37 + }
+136
src/applications/phortune/controller/account/PhortuneAccountOverviewController.php
··· 1 + <?php 2 + 3 + final class PhortuneAccountOverviewController 4 + extends PhortuneAccountProfileController { 5 + 6 + public function handleRequest(AphrontRequest $request) { 7 + $response = $this->loadAccount(); 8 + if ($response) { 9 + return $response; 10 + } 11 + 12 + $account = $this->getAccount(); 13 + $title = $account->getName(); 14 + 15 + $viewer = $this->getViewer(); 16 + 17 + $invoices = id(new PhortuneCartQuery()) 18 + ->setViewer($viewer) 19 + ->withAccountPHIDs(array($account->getPHID())) 20 + ->needPurchases(true) 21 + ->withInvoices(true) 22 + ->execute(); 23 + 24 + $crumbs = $this->buildApplicationCrumbs(); 25 + $crumbs->setBorder(true); 26 + 27 + $header = $this->buildHeaderView(); 28 + 29 + $status = $this->buildStatusView($account, $invoices); 30 + $invoices = $this->buildInvoicesSection($account, $invoices); 31 + $purchase_history = $this->newRecentOrdersView($account, 10); 32 + 33 + $view = id(new PHUITwoColumnView()) 34 + ->setHeader($header) 35 + ->setFooter( 36 + array( 37 + $status, 38 + $invoices, 39 + $purchase_history, 40 + )); 41 + 42 + $navigation = $this->buildSideNavView('overview'); 43 + 44 + return $this->newPage() 45 + ->setTitle($title) 46 + ->setCrumbs($crumbs) 47 + ->setNavigation($navigation) 48 + ->appendChild($view); 49 + } 50 + 51 + private function buildStatusView(PhortuneAccount $account, $invoices) { 52 + $status_items = $this->getStatusItemsForAccount($account, $invoices); 53 + $view = array(); 54 + foreach ($status_items as $item) { 55 + $view[] = id(new PHUIInfoView()) 56 + ->setSeverity(idx($item, 'severity')) 57 + ->appendChild(idx($item, 'note')); 58 + } 59 + return $view; 60 + } 61 + 62 + private function buildInvoicesSection( 63 + PhortuneAccount $account, 64 + array $carts) { 65 + 66 + $viewer = $this->getViewer(); 67 + 68 + $phids = array(); 69 + foreach ($carts as $cart) { 70 + $phids[] = $cart->getPHID(); 71 + $phids[] = $cart->getMerchantPHID(); 72 + foreach ($cart->getPurchases() as $purchase) { 73 + $phids[] = $purchase->getPHID(); 74 + } 75 + } 76 + $handles = $this->loadViewerHandles($phids); 77 + 78 + $table = id(new PhortuneOrderTableView()) 79 + ->setNoDataString(pht('You have no unpaid invoices.')) 80 + ->setIsInvoices(true) 81 + ->setUser($viewer) 82 + ->setCarts($carts) 83 + ->setHandles($handles); 84 + 85 + $header = id(new PHUIHeaderView()) 86 + ->setHeader(pht('Invoices Due')); 87 + 88 + return id(new PHUIObjectBoxView()) 89 + ->setHeader($header) 90 + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 91 + ->setTable($table); 92 + } 93 + 94 + protected function buildApplicationCrumbs() { 95 + $crumbs = parent::buildApplicationCrumbs(); 96 + 97 + $crumbs->addAction( 98 + id(new PHUIListItemView()) 99 + ->setIcon('fa-exchange') 100 + ->setHref($this->getApplicationURI('account/')) 101 + ->setName(pht('Switch Accounts'))); 102 + 103 + return $crumbs; 104 + } 105 + 106 + private function getStatusItemsForAccount( 107 + PhortuneAccount $account, 108 + array $invoices) { 109 + $viewer = $this->getViewer(); 110 + 111 + assert_instances_of($invoices, 'PhortuneCart'); 112 + $items = array(); 113 + 114 + $methods = id(new PhortunePaymentMethodQuery()) 115 + ->setViewer($viewer) 116 + ->withAccountPHIDs(array($account->getPHID())) 117 + ->withStatuses( 118 + array( 119 + PhortunePaymentMethod::STATUS_ACTIVE, 120 + )) 121 + ->execute(); 122 + 123 + if ($invoices) { 124 + $items[] = array( 125 + 'severity' => PHUIInfoView::SEVERITY_ERROR, 126 + 'note' => pht('You have %d unpaid invoice(s).', count($invoices)), 127 + ); 128 + } 129 + 130 + // TODO: If a payment method has expired or is expiring soon, we should 131 + // add a status check for it. 132 + 133 + return $items; 134 + } 135 + 136 + }
+82 -7
src/applications/phortune/controller/account/PhortuneAccountProfileController.php
··· 43 43 'fa-user-circle'); 44 44 45 45 $nav->addFilter( 46 + 'details', 47 + pht('Account Details'), 48 + $this->getApplicationURI("/account/{$id}/details/"), 49 + 'fa-address-card-o'); 50 + 51 + $nav->addLabel(pht('Payments')); 52 + 53 + $nav->addFilter( 54 + 'methods', 55 + pht('Payment Methods'), 56 + $this->getApplicationURI("/account/{$id}/methods/"), 57 + 'fa-credit-card'); 58 + 59 + $nav->addFilter( 46 60 'subscriptions', 47 61 pht('Subscriptions'), 48 - $this->getApplicationURI("/account/subscription/{$id}/"), 62 + $this->getApplicationURI("/account/{$id}/subscriptions/"), 49 63 'fa-retweet'); 50 64 51 65 $nav->addFilter( 52 - 'billing', 53 - pht('Billing / History'), 54 - $this->getApplicationURI("/account/billing/{$id}/"), 55 - 'fa-credit-card'); 66 + 'orders', 67 + pht('Order History'), 68 + $this->getApplicationURI("/account/{$id}/orders/"), 69 + 'fa-shopping-bag'); 70 + 71 + $nav->addFilter( 72 + 'charges', 73 + pht('Charge History'), 74 + $this->getApplicationURI("/account/{$id}/charges/"), 75 + 'fa-calculator'); 76 + 77 + $nav->addLabel(pht('Personnel')); 56 78 57 79 $nav->addFilter( 58 80 'managers', 59 - pht('Managers'), 60 - $this->getApplicationURI("/account/manager/{$id}/"), 81 + pht('Account Managers'), 82 + $this->getApplicationURI("/account/{$id}/managers/"), 61 83 'fa-group'); 62 84 63 85 $nav->selectFilter($filter); 64 86 65 87 return $nav; 66 88 } 89 + 90 + final protected function newRecentOrdersView( 91 + PhortuneAccount $account, 92 + $limit) { 93 + 94 + $viewer = $this->getViewer(); 95 + 96 + $carts = id(new PhortuneCartQuery()) 97 + ->setViewer($viewer) 98 + ->withAccountPHIDs(array($account->getPHID())) 99 + ->needPurchases(true) 100 + ->withStatuses( 101 + array( 102 + PhortuneCart::STATUS_PURCHASING, 103 + PhortuneCart::STATUS_CHARGED, 104 + PhortuneCart::STATUS_HOLD, 105 + PhortuneCart::STATUS_REVIEW, 106 + PhortuneCart::STATUS_PURCHASED, 107 + )) 108 + ->setLimit($limit) 109 + ->execute(); 110 + 111 + $phids = array(); 112 + foreach ($carts as $cart) { 113 + $phids[] = $cart->getPHID(); 114 + foreach ($cart->getPurchases() as $purchase) { 115 + $phids[] = $purchase->getPHID(); 116 + } 117 + } 118 + $handles = $this->loadViewerHandles($phids); 119 + 120 + $orders_uri = $this->getApplicationURI($account->getID().'/order/'); 121 + 122 + $table = id(new PhortuneOrderTableView()) 123 + ->setUser($viewer) 124 + ->setCarts($carts) 125 + ->setHandles($handles); 126 + 127 + $header = id(new PHUIHeaderView()) 128 + ->setHeader(pht('Recent Orders')) 129 + ->addActionLink( 130 + id(new PHUIButtonView()) 131 + ->setTag('a') 132 + ->setIcon('fa-list') 133 + ->setHref($orders_uri) 134 + ->setText(pht('View All Orders'))); 135 + 136 + return id(new PHUIObjectBoxView()) 137 + ->setHeader($header) 138 + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 139 + ->setTable($table); 140 + } 141 + 67 142 68 143 }
-238
src/applications/phortune/controller/account/PhortuneAccountViewController.php
··· 1 - <?php 2 - 3 - final class PhortuneAccountViewController 4 - extends PhortuneAccountProfileController { 5 - 6 - public function handleRequest(AphrontRequest $request) { 7 - $response = $this->loadAccount(); 8 - if ($response) { 9 - return $response; 10 - } 11 - 12 - $account = $this->getAccount(); 13 - $title = $account->getName(); 14 - 15 - $viewer = $this->getViewer(); 16 - 17 - $invoices = id(new PhortuneCartQuery()) 18 - ->setViewer($viewer) 19 - ->withAccountPHIDs(array($account->getPHID())) 20 - ->needPurchases(true) 21 - ->withInvoices(true) 22 - ->execute(); 23 - 24 - $crumbs = $this->buildApplicationCrumbs(); 25 - $crumbs->setBorder(true); 26 - 27 - $header = $this->buildHeaderView(); 28 - 29 - $curtain = $this->buildCurtainView($account); 30 - $status = $this->buildStatusView($account, $invoices); 31 - $invoices = $this->buildInvoicesSection($account, $invoices); 32 - $purchase_history = $this->buildPurchaseHistorySection($account); 33 - 34 - $timeline = $this->buildTransactionTimeline( 35 - $account, 36 - new PhortuneAccountTransactionQuery()); 37 - $timeline->setShouldTerminate(true); 38 - 39 - $view = id(new PHUITwoColumnView()) 40 - ->setHeader($header) 41 - ->setCurtain($curtain) 42 - ->setMainColumn(array( 43 - $status, 44 - $invoices, 45 - $purchase_history, 46 - $timeline, 47 - )); 48 - 49 - $navigation = $this->buildSideNavView('overview'); 50 - 51 - return $this->newPage() 52 - ->setTitle($title) 53 - ->setCrumbs($crumbs) 54 - ->setNavigation($navigation) 55 - ->appendChild($view); 56 - 57 - } 58 - 59 - private function buildStatusView(PhortuneAccount $account, $invoices) { 60 - $status_items = $this->getStatusItemsForAccount($account, $invoices); 61 - $view = array(); 62 - foreach ($status_items as $item) { 63 - $view[] = id(new PHUIInfoView()) 64 - ->setSeverity(idx($item, 'severity')) 65 - ->appendChild(idx($item, 'note')); 66 - } 67 - return $view; 68 - } 69 - 70 - private function buildCurtainView(PhortuneAccount $account) { 71 - $viewer = $this->getViewer(); 72 - 73 - $can_edit = PhabricatorPolicyFilter::hasCapability( 74 - $viewer, 75 - $account, 76 - PhabricatorPolicyCapability::CAN_EDIT); 77 - 78 - $edit_uri = $this->getApplicationURI('account/edit/'.$account->getID().'/'); 79 - 80 - $curtain = $this->newCurtainView($account); 81 - $curtain->addAction( 82 - id(new PhabricatorActionView()) 83 - ->setName(pht('Edit Account')) 84 - ->setIcon('fa-pencil') 85 - ->setHref($edit_uri) 86 - ->setDisabled(!$can_edit) 87 - ->setWorkflow(!$can_edit)); 88 - 89 - $member_phids = $account->getMemberPHIDs(); 90 - $handles = $viewer->loadHandles($member_phids); 91 - 92 - $member_list = id(new PHUIObjectItemListView()) 93 - ->setSimple(true); 94 - 95 - foreach ($member_phids as $member_phid) { 96 - $image_uri = $handles[$member_phid]->getImageURI(); 97 - $image_href = $handles[$member_phid]->getURI(); 98 - $person = $handles[$member_phid]; 99 - 100 - $member = id(new PHUIObjectItemView()) 101 - ->setImageURI($image_uri) 102 - ->setHref($image_href) 103 - ->setHeader($person->getFullName()); 104 - 105 - $member_list->addItem($member); 106 - } 107 - 108 - $curtain->newPanel() 109 - ->setHeaderText(pht('Managers')) 110 - ->appendChild($member_list); 111 - 112 - return $curtain; 113 - } 114 - 115 - private function buildInvoicesSection( 116 - PhortuneAccount $account, 117 - array $carts) { 118 - 119 - $viewer = $this->getViewer(); 120 - 121 - $phids = array(); 122 - foreach ($carts as $cart) { 123 - $phids[] = $cart->getPHID(); 124 - $phids[] = $cart->getMerchantPHID(); 125 - foreach ($cart->getPurchases() as $purchase) { 126 - $phids[] = $purchase->getPHID(); 127 - } 128 - } 129 - $handles = $this->loadViewerHandles($phids); 130 - 131 - $table = id(new PhortuneOrderTableView()) 132 - ->setNoDataString(pht('You have no unpaid invoices.')) 133 - ->setIsInvoices(true) 134 - ->setUser($viewer) 135 - ->setCarts($carts) 136 - ->setHandles($handles); 137 - 138 - $header = id(new PHUIHeaderView()) 139 - ->setHeader(pht('Invoices Due')); 140 - 141 - return id(new PHUIObjectBoxView()) 142 - ->setHeader($header) 143 - ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 144 - ->setTable($table); 145 - } 146 - 147 - private function buildPurchaseHistorySection(PhortuneAccount $account) { 148 - $viewer = $this->getViewer(); 149 - 150 - $carts = id(new PhortuneCartQuery()) 151 - ->setViewer($viewer) 152 - ->withAccountPHIDs(array($account->getPHID())) 153 - ->needPurchases(true) 154 - ->withStatuses( 155 - array( 156 - PhortuneCart::STATUS_PURCHASING, 157 - PhortuneCart::STATUS_CHARGED, 158 - PhortuneCart::STATUS_HOLD, 159 - PhortuneCart::STATUS_REVIEW, 160 - PhortuneCart::STATUS_PURCHASED, 161 - )) 162 - ->setLimit(10) 163 - ->execute(); 164 - 165 - $phids = array(); 166 - foreach ($carts as $cart) { 167 - $phids[] = $cart->getPHID(); 168 - foreach ($cart->getPurchases() as $purchase) { 169 - $phids[] = $purchase->getPHID(); 170 - } 171 - } 172 - $handles = $this->loadViewerHandles($phids); 173 - 174 - $orders_uri = $this->getApplicationURI($account->getID().'/order/'); 175 - 176 - $table = id(new PhortuneOrderTableView()) 177 - ->setUser($viewer) 178 - ->setCarts($carts) 179 - ->setHandles($handles); 180 - 181 - $header = id(new PHUIHeaderView()) 182 - ->setHeader(pht('Recent Orders')) 183 - ->addActionLink( 184 - id(new PHUIButtonView()) 185 - ->setTag('a') 186 - ->setIcon('fa-list') 187 - ->setHref($orders_uri) 188 - ->setText(pht('View All Orders'))); 189 - 190 - return id(new PHUIObjectBoxView()) 191 - ->setHeader($header) 192 - ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 193 - ->setTable($table); 194 - } 195 - 196 - protected function buildApplicationCrumbs() { 197 - $crumbs = parent::buildApplicationCrumbs(); 198 - 199 - $crumbs->addAction( 200 - id(new PHUIListItemView()) 201 - ->setIcon('fa-exchange') 202 - ->setHref($this->getApplicationURI('account/')) 203 - ->setName(pht('Switch Accounts'))); 204 - 205 - return $crumbs; 206 - } 207 - 208 - private function getStatusItemsForAccount( 209 - PhortuneAccount $account, 210 - array $invoices) { 211 - $viewer = $this->getViewer(); 212 - 213 - assert_instances_of($invoices, 'PhortuneCart'); 214 - $items = array(); 215 - 216 - $methods = id(new PhortunePaymentMethodQuery()) 217 - ->setViewer($viewer) 218 - ->withAccountPHIDs(array($account->getPHID())) 219 - ->withStatuses( 220 - array( 221 - PhortunePaymentMethod::STATUS_ACTIVE, 222 - )) 223 - ->execute(); 224 - 225 - if ($invoices) { 226 - $items[] = array( 227 - 'severity' => PHUIInfoView::SEVERITY_ERROR, 228 - 'note' => pht('You have %d unpaid invoice(s).', count($invoices)), 229 - ); 230 - } 231 - 232 - // TODO: If a payment method has expired or is expiring soon, we should 233 - // add a status check for it. 234 - 235 - return $items; 236 - } 237 - 238 - }
+5 -1
src/applications/phortune/editor/PhortuneAccountEditEngine.php
··· 62 62 } 63 63 64 64 protected function getObjectViewURI($object) { 65 - return $object->getURI(); 65 + if ($this->getIsCreate()) { 66 + return $object->getURI(); 67 + } else { 68 + return $object->getDetailsURI(); 69 + } 66 70 } 67 71 68 72 protected function buildCustomEditFields($object) {
+6
src/applications/phortune/storage/PhortuneAccount.php
··· 103 103 return '/phortune/'.$this->getID().'/'; 104 104 } 105 105 106 + public function getDetailsURI() { 107 + return urisprintf( 108 + '/phortune/account/%d/details/', 109 + $this->getID()); 110 + } 111 + 106 112 107 113 /* -( PhabricatorApplicationTransactionInterface )------------------------- */ 108 114