From 2c5760d0ef774efda5a8b29502145cffd03b750d Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 4 May 2015 11:06:09 -0700 Subject: [PATCH] Allow accounts and merchants to review unpaid invoices in Phortune Summary: Ref T6881. Allows accounts to browse all unpaid invoices (although we currently show all of them on the account screen anyway). Also allows merchants to browse unpaid invoices, which they could not do before. This will let us start suspending instances for nonpayment eventually. Test Plan: - Browsed unpaid invoices as various users. - Browsed merchant unpaid invoices. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T6881 Differential Revision: https://secure.phabricator.com/D12681 --- .../controller/PhortuneCartListController.php | 10 +++-- .../query/PhortuneCartSearchEngine.php | 38 ++++++++++--------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/applications/phortune/controller/PhortuneCartListController.php b/src/applications/phortune/controller/PhortuneCartListController.php index faf1431312..0537417f7c 100644 --- a/src/applications/phortune/controller/PhortuneCartListController.php +++ b/src/applications/phortune/controller/PhortuneCartListController.php @@ -6,6 +6,7 @@ final class PhortuneCartListController private $merchant; private $account; private $subscription; + private $engine; public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); @@ -14,7 +15,8 @@ final class PhortuneCartListController $account_id = $request->getURIData('accountID'); $subscription_id = $request->getURIData('subscriptionID'); - $engine = new PhortuneCartSearchEngine(); + $engine = id(new PhortuneCartSearchEngine()) + ->setViewer($viewer); if ($merchant_id) { $merchant = id(new PhortuneMerchantQuery()) @@ -65,6 +67,8 @@ final class PhortuneCartListController $engine->setSubscription($subscription); } + $this->engine = $engine; + $controller = id(new PhabricatorApplicationSearchController()) ->setQueryKey($request->getURIData('queryKey')) ->setSearchEngine($engine) @@ -79,9 +83,7 @@ final class PhortuneCartListController $nav = new AphrontSideNavFilterView(); $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); - id(new PhortuneCartSearchEngine()) - ->setViewer($viewer) - ->addNavigationItems($nav->getMenu()); + $this->engine->addNavigationItems($nav->getMenu()); $nav->selectFilter(null); diff --git a/src/applications/phortune/query/PhortuneCartSearchEngine.php b/src/applications/phortune/query/PhortuneCartSearchEngine.php index ef91dc47ae..ad29ed4e0d 100644 --- a/src/applications/phortune/query/PhortuneCartSearchEngine.php +++ b/src/applications/phortune/query/PhortuneCartSearchEngine.php @@ -55,15 +55,7 @@ final class PhortuneCartSearchEngine public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { $query = id(new PhortuneCartQuery()) - ->needPurchases(true) - ->withStatuses( - array( - PhortuneCart::STATUS_PURCHASING, - PhortuneCart::STATUS_CHARGED, - PhortuneCart::STATUS_HOLD, - PhortuneCart::STATUS_REVIEW, - PhortuneCart::STATUS_PURCHASED, - )); + ->needPurchases(true); $viewer = $this->requireViewer(); @@ -107,6 +99,19 @@ final class PhortuneCartSearchEngine $query->withSubscriptionPHIDs(array($subscription->getPHID())); } + if ($saved->getParameter('invoices')) { + $query->withInvoices(true); + } else { + $query->withStatuses( + array( + PhortuneCart::STATUS_PURCHASING, + PhortuneCart::STATUS_CHARGED, + PhortuneCart::STATUS_HOLD, + PhortuneCart::STATUS_REVIEW, + PhortuneCart::STATUS_PURCHASED, + )); + } + return $query; } @@ -118,9 +123,9 @@ final class PhortuneCartSearchEngine $merchant = $this->getMerchant(); $account = $this->getAccount(); if ($merchant) { - return '/phortune/merchant/'.$merchant->getID().'/order/'.$path; + return '/phortune/merchant/orders/'.$merchant->getID().'/'.$path; } else if ($account) { - return '/phortune/'.$account->getID().'/order/'; + return '/phortune/'.$account->getID().'/order/'.$path; } else { return '/phortune/order/'.$path; } @@ -128,7 +133,8 @@ final class PhortuneCartSearchEngine protected function getBuiltinQueryNames() { $names = array( - 'all' => pht('All Orders'), + 'all' => pht('Order History'), + 'invoices' => pht('Unpaid Invoices'), ); return $names; @@ -142,6 +148,8 @@ final class PhortuneCartSearchEngine switch ($query_key) { case 'all': return $query; + case 'invoices': + return $query->setParameter('invoices', true); } return parent::buildSavedQueryFromBuiltin($query_key); @@ -180,12 +188,6 @@ final class PhortuneCartSearchEngine $rows[] = array( $cart->getID(), - phutil_tag( - 'a', - array( - 'href' => $href, - ), - $cart->getName()), $handles[$cart->getPHID()]->renderLink(), $handles[$merchant->getPHID()]->renderLink(), $handles[$cart->getAuthorPHID()]->renderLink(),