mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Update Phortune Merchant UI to bring it in line with Account UI
Summary: Depends on D20732. Ref T13366. This generally makes the "Merchant" UI look and work like the "Payment Account" UI. This is mostly simpler since the permissions have largely been sorted out already and there's less going on here and less weirdness around view/edit policies. Test Plan: Browsed all Merchant functions as a merchant member and non-member. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13366 Differential Revision: https://secure.phabricator.com/D20733
This commit is contained in:
parent
c93ac91dc6
commit
9bcd683c08
36 changed files with 1122 additions and 749 deletions
2
resources/sql/autopatches/20190822.merchant.01.view.sql
Normal file
2
resources/sql/autopatches/20190822.merchant.01.view.sql
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE {$NAMESPACE}_phortune.phortune_merchant
|
||||||
|
DROP viewPolicy;
|
|
@ -5271,7 +5271,6 @@ phutil_register_library_map(array(
|
||||||
'PhortuneCartController' => 'applications/phortune/controller/cart/PhortuneCartController.php',
|
'PhortuneCartController' => 'applications/phortune/controller/cart/PhortuneCartController.php',
|
||||||
'PhortuneCartEditor' => 'applications/phortune/editor/PhortuneCartEditor.php',
|
'PhortuneCartEditor' => 'applications/phortune/editor/PhortuneCartEditor.php',
|
||||||
'PhortuneCartImplementation' => 'applications/phortune/cart/PhortuneCartImplementation.php',
|
'PhortuneCartImplementation' => 'applications/phortune/cart/PhortuneCartImplementation.php',
|
||||||
'PhortuneCartListController' => 'applications/phortune/controller/cart/PhortuneCartListController.php',
|
|
||||||
'PhortuneCartPHIDType' => 'applications/phortune/phid/PhortuneCartPHIDType.php',
|
'PhortuneCartPHIDType' => 'applications/phortune/phid/PhortuneCartPHIDType.php',
|
||||||
'PhortuneCartQuery' => 'applications/phortune/query/PhortuneCartQuery.php',
|
'PhortuneCartQuery' => 'applications/phortune/query/PhortuneCartQuery.php',
|
||||||
'PhortuneCartReplyHandler' => 'applications/phortune/mail/PhortuneCartReplyHandler.php',
|
'PhortuneCartReplyHandler' => 'applications/phortune/mail/PhortuneCartReplyHandler.php',
|
||||||
|
@ -5304,6 +5303,7 @@ phutil_register_library_map(array(
|
||||||
'PhortuneMerchantContactInfoTransaction' => 'applications/phortune/xaction/PhortuneMerchantContactInfoTransaction.php',
|
'PhortuneMerchantContactInfoTransaction' => 'applications/phortune/xaction/PhortuneMerchantContactInfoTransaction.php',
|
||||||
'PhortuneMerchantController' => 'applications/phortune/controller/merchant/PhortuneMerchantController.php',
|
'PhortuneMerchantController' => 'applications/phortune/controller/merchant/PhortuneMerchantController.php',
|
||||||
'PhortuneMerchantDescriptionTransaction' => 'applications/phortune/xaction/PhortuneMerchantDescriptionTransaction.php',
|
'PhortuneMerchantDescriptionTransaction' => 'applications/phortune/xaction/PhortuneMerchantDescriptionTransaction.php',
|
||||||
|
'PhortuneMerchantDetailsController' => 'applications/phortune/controller/merchant/PhortuneMerchantDetailsController.php',
|
||||||
'PhortuneMerchantEditController' => 'applications/phortune/controller/merchant/PhortuneMerchantEditController.php',
|
'PhortuneMerchantEditController' => 'applications/phortune/controller/merchant/PhortuneMerchantEditController.php',
|
||||||
'PhortuneMerchantEditEngine' => 'applications/phortune/editor/PhortuneMerchantEditEngine.php',
|
'PhortuneMerchantEditEngine' => 'applications/phortune/editor/PhortuneMerchantEditEngine.php',
|
||||||
'PhortuneMerchantEditor' => 'applications/phortune/editor/PhortuneMerchantEditor.php',
|
'PhortuneMerchantEditor' => 'applications/phortune/editor/PhortuneMerchantEditor.php',
|
||||||
|
@ -5313,18 +5313,26 @@ phutil_register_library_map(array(
|
||||||
'PhortuneMerchantInvoiceEmailTransaction' => 'applications/phortune/xaction/PhortuneMerchantInvoiceEmailTransaction.php',
|
'PhortuneMerchantInvoiceEmailTransaction' => 'applications/phortune/xaction/PhortuneMerchantInvoiceEmailTransaction.php',
|
||||||
'PhortuneMerchantInvoiceFooterTransaction' => 'applications/phortune/xaction/PhortuneMerchantInvoiceFooterTransaction.php',
|
'PhortuneMerchantInvoiceFooterTransaction' => 'applications/phortune/xaction/PhortuneMerchantInvoiceFooterTransaction.php',
|
||||||
'PhortuneMerchantListController' => 'applications/phortune/controller/merchant/PhortuneMerchantListController.php',
|
'PhortuneMerchantListController' => 'applications/phortune/controller/merchant/PhortuneMerchantListController.php',
|
||||||
'PhortuneMerchantManagerController' => 'applications/phortune/controller/merchant/PhortuneMerchantManagerController.php',
|
'PhortuneMerchantManagersController' => 'applications/phortune/controller/merchant/PhortuneMerchantManagersController.php',
|
||||||
'PhortuneMerchantNameTransaction' => 'applications/phortune/xaction/PhortuneMerchantNameTransaction.php',
|
'PhortuneMerchantNameTransaction' => 'applications/phortune/xaction/PhortuneMerchantNameTransaction.php',
|
||||||
|
'PhortuneMerchantOrderListController' => 'applications/phortune/controller/merchant/PhortuneMerchantOrderListController.php',
|
||||||
|
'PhortuneMerchantOrdersController' => 'applications/phortune/controller/merchant/PhortuneMerchantOrdersController.php',
|
||||||
|
'PhortuneMerchantOverviewController' => 'applications/phortune/controller/merchant/PhortuneMerchantOverviewController.php',
|
||||||
'PhortuneMerchantPHIDType' => 'applications/phortune/phid/PhortuneMerchantPHIDType.php',
|
'PhortuneMerchantPHIDType' => 'applications/phortune/phid/PhortuneMerchantPHIDType.php',
|
||||||
'PhortuneMerchantPictureController' => 'applications/phortune/controller/merchant/PhortuneMerchantPictureController.php',
|
'PhortuneMerchantPictureController' => 'applications/phortune/controller/merchant/PhortuneMerchantPictureController.php',
|
||||||
'PhortuneMerchantPictureTransaction' => 'applications/phortune/xaction/PhortuneMerchantPictureTransaction.php',
|
'PhortuneMerchantPictureTransaction' => 'applications/phortune/xaction/PhortuneMerchantPictureTransaction.php',
|
||||||
'PhortuneMerchantProfileController' => 'applications/phortune/controller/merchant/PhortuneMerchantProfileController.php',
|
'PhortuneMerchantProfileController' => 'applications/phortune/controller/merchant/PhortuneMerchantProfileController.php',
|
||||||
|
'PhortuneMerchantProviderDisableController' => 'applications/phortune/controller/merchant/PhortuneMerchantProviderDisableController.php',
|
||||||
|
'PhortuneMerchantProviderEditController' => 'applications/phortune/controller/merchant/PhortuneMerchantProviderEditController.php',
|
||||||
|
'PhortuneMerchantProviderViewController' => 'applications/phortune/controller/merchant/PhortuneMerchantProviderViewController.php',
|
||||||
|
'PhortuneMerchantProvidersController' => 'applications/phortune/controller/merchant/PhortuneMerchantProvidersController.php',
|
||||||
'PhortuneMerchantQuery' => 'applications/phortune/query/PhortuneMerchantQuery.php',
|
'PhortuneMerchantQuery' => 'applications/phortune/query/PhortuneMerchantQuery.php',
|
||||||
'PhortuneMerchantSearchEngine' => 'applications/phortune/query/PhortuneMerchantSearchEngine.php',
|
'PhortuneMerchantSearchEngine' => 'applications/phortune/query/PhortuneMerchantSearchEngine.php',
|
||||||
|
'PhortuneMerchantSubscriptionListController' => 'applications/phortune/controller/merchant/PhortuneMerchantSubscriptionListController.php',
|
||||||
|
'PhortuneMerchantSubscriptionsController' => 'applications/phortune/controller/merchant/PhortuneMerchantSubscriptionsController.php',
|
||||||
'PhortuneMerchantTransaction' => 'applications/phortune/storage/PhortuneMerchantTransaction.php',
|
'PhortuneMerchantTransaction' => 'applications/phortune/storage/PhortuneMerchantTransaction.php',
|
||||||
'PhortuneMerchantTransactionQuery' => 'applications/phortune/query/PhortuneMerchantTransactionQuery.php',
|
'PhortuneMerchantTransactionQuery' => 'applications/phortune/query/PhortuneMerchantTransactionQuery.php',
|
||||||
'PhortuneMerchantTransactionType' => 'applications/phortune/xaction/PhortuneMerchantTransactionType.php',
|
'PhortuneMerchantTransactionType' => 'applications/phortune/xaction/PhortuneMerchantTransactionType.php',
|
||||||
'PhortuneMerchantViewController' => 'applications/phortune/controller/merchant/PhortuneMerchantViewController.php',
|
|
||||||
'PhortuneMonthYearExpiryControl' => 'applications/phortune/control/PhortuneMonthYearExpiryControl.php',
|
'PhortuneMonthYearExpiryControl' => 'applications/phortune/control/PhortuneMonthYearExpiryControl.php',
|
||||||
'PhortuneOrderTableView' => 'applications/phortune/view/PhortuneOrderTableView.php',
|
'PhortuneOrderTableView' => 'applications/phortune/view/PhortuneOrderTableView.php',
|
||||||
'PhortunePayPalPaymentProvider' => 'applications/phortune/provider/PhortunePayPalPaymentProvider.php',
|
'PhortunePayPalPaymentProvider' => 'applications/phortune/provider/PhortunePayPalPaymentProvider.php',
|
||||||
|
@ -5356,8 +5364,6 @@ phutil_register_library_map(array(
|
||||||
'PhortuneProductQuery' => 'applications/phortune/query/PhortuneProductQuery.php',
|
'PhortuneProductQuery' => 'applications/phortune/query/PhortuneProductQuery.php',
|
||||||
'PhortuneProductViewController' => 'applications/phortune/controller/product/PhortuneProductViewController.php',
|
'PhortuneProductViewController' => 'applications/phortune/controller/product/PhortuneProductViewController.php',
|
||||||
'PhortuneProviderActionController' => 'applications/phortune/controller/provider/PhortuneProviderActionController.php',
|
'PhortuneProviderActionController' => 'applications/phortune/controller/provider/PhortuneProviderActionController.php',
|
||||||
'PhortuneProviderDisableController' => 'applications/phortune/controller/provider/PhortuneProviderDisableController.php',
|
|
||||||
'PhortuneProviderEditController' => 'applications/phortune/controller/provider/PhortuneProviderEditController.php',
|
|
||||||
'PhortunePurchase' => 'applications/phortune/storage/PhortunePurchase.php',
|
'PhortunePurchase' => 'applications/phortune/storage/PhortunePurchase.php',
|
||||||
'PhortunePurchasePHIDType' => 'applications/phortune/phid/PhortunePurchasePHIDType.php',
|
'PhortunePurchasePHIDType' => 'applications/phortune/phid/PhortunePurchasePHIDType.php',
|
||||||
'PhortunePurchaseQuery' => 'applications/phortune/query/PhortunePurchaseQuery.php',
|
'PhortunePurchaseQuery' => 'applications/phortune/query/PhortunePurchaseQuery.php',
|
||||||
|
@ -11847,7 +11853,6 @@ phutil_register_library_map(array(
|
||||||
'PhortuneCartController' => 'PhortuneController',
|
'PhortuneCartController' => 'PhortuneController',
|
||||||
'PhortuneCartEditor' => 'PhabricatorApplicationTransactionEditor',
|
'PhortuneCartEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
'PhortuneCartImplementation' => 'Phobject',
|
'PhortuneCartImplementation' => 'Phobject',
|
||||||
'PhortuneCartListController' => 'PhortuneController',
|
|
||||||
'PhortuneCartPHIDType' => 'PhabricatorPHIDType',
|
'PhortuneCartPHIDType' => 'PhabricatorPHIDType',
|
||||||
'PhortuneCartQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'PhortuneCartQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'PhortuneCartReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
|
'PhortuneCartReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
|
||||||
|
@ -11883,32 +11888,41 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorApplicationTransactionInterface',
|
'PhabricatorApplicationTransactionInterface',
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
),
|
),
|
||||||
'PhortuneMerchantAddManagerController' => 'PhortuneController',
|
'PhortuneMerchantAddManagerController' => 'PhortuneMerchantController',
|
||||||
'PhortuneMerchantCapability' => 'PhabricatorPolicyCapability',
|
'PhortuneMerchantCapability' => 'PhabricatorPolicyCapability',
|
||||||
'PhortuneMerchantContactInfoTransaction' => 'PhortuneMerchantTransactionType',
|
'PhortuneMerchantContactInfoTransaction' => 'PhortuneMerchantTransactionType',
|
||||||
'PhortuneMerchantController' => 'PhortuneController',
|
'PhortuneMerchantController' => 'PhortuneController',
|
||||||
'PhortuneMerchantDescriptionTransaction' => 'PhortuneMerchantTransactionType',
|
'PhortuneMerchantDescriptionTransaction' => 'PhortuneMerchantTransactionType',
|
||||||
'PhortuneMerchantEditController' => 'PhortuneMerchantController',
|
'PhortuneMerchantDetailsController' => 'PhortuneMerchantProfileController',
|
||||||
|
'PhortuneMerchantEditController' => 'PhortuneController',
|
||||||
'PhortuneMerchantEditEngine' => 'PhabricatorEditEngine',
|
'PhortuneMerchantEditEngine' => 'PhabricatorEditEngine',
|
||||||
'PhortuneMerchantEditor' => 'PhabricatorApplicationTransactionEditor',
|
'PhortuneMerchantEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
'PhortuneMerchantHasAccountEdgeType' => 'PhabricatorEdgeType',
|
'PhortuneMerchantHasAccountEdgeType' => 'PhabricatorEdgeType',
|
||||||
'PhortuneMerchantHasMemberEdgeType' => 'PhabricatorEdgeType',
|
'PhortuneMerchantHasMemberEdgeType' => 'PhabricatorEdgeType',
|
||||||
'PhortuneMerchantInvoiceCreateController' => 'PhortuneMerchantProfileController',
|
'PhortuneMerchantInvoiceCreateController' => 'PhortuneMerchantController',
|
||||||
'PhortuneMerchantInvoiceEmailTransaction' => 'PhortuneMerchantTransactionType',
|
'PhortuneMerchantInvoiceEmailTransaction' => 'PhortuneMerchantTransactionType',
|
||||||
'PhortuneMerchantInvoiceFooterTransaction' => 'PhortuneMerchantTransactionType',
|
'PhortuneMerchantInvoiceFooterTransaction' => 'PhortuneMerchantTransactionType',
|
||||||
'PhortuneMerchantListController' => 'PhortuneMerchantController',
|
'PhortuneMerchantListController' => 'PhortuneController',
|
||||||
'PhortuneMerchantManagerController' => 'PhortuneMerchantProfileController',
|
'PhortuneMerchantManagersController' => 'PhortuneMerchantProfileController',
|
||||||
'PhortuneMerchantNameTransaction' => 'PhortuneMerchantTransactionType',
|
'PhortuneMerchantNameTransaction' => 'PhortuneMerchantTransactionType',
|
||||||
|
'PhortuneMerchantOrderListController' => 'PhortuneMerchantProfileController',
|
||||||
|
'PhortuneMerchantOrdersController' => 'PhortuneMerchantProfileController',
|
||||||
|
'PhortuneMerchantOverviewController' => 'PhortuneMerchantProfileController',
|
||||||
'PhortuneMerchantPHIDType' => 'PhabricatorPHIDType',
|
'PhortuneMerchantPHIDType' => 'PhabricatorPHIDType',
|
||||||
'PhortuneMerchantPictureController' => 'PhortuneMerchantProfileController',
|
'PhortuneMerchantPictureController' => 'PhortuneMerchantController',
|
||||||
'PhortuneMerchantPictureTransaction' => 'PhortuneMerchantTransactionType',
|
'PhortuneMerchantPictureTransaction' => 'PhortuneMerchantTransactionType',
|
||||||
'PhortuneMerchantProfileController' => 'PhortuneController',
|
'PhortuneMerchantProfileController' => 'PhortuneMerchantController',
|
||||||
|
'PhortuneMerchantProviderDisableController' => 'PhortuneMerchantController',
|
||||||
|
'PhortuneMerchantProviderEditController' => 'PhortuneMerchantController',
|
||||||
|
'PhortuneMerchantProviderViewController' => 'PhortuneMerchantController',
|
||||||
|
'PhortuneMerchantProvidersController' => 'PhortuneMerchantProfileController',
|
||||||
'PhortuneMerchantQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'PhortuneMerchantQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'PhortuneMerchantSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'PhortuneMerchantSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
|
'PhortuneMerchantSubscriptionListController' => 'PhortuneMerchantProfileController',
|
||||||
|
'PhortuneMerchantSubscriptionsController' => 'PhortuneMerchantProfileController',
|
||||||
'PhortuneMerchantTransaction' => 'PhabricatorModularTransaction',
|
'PhortuneMerchantTransaction' => 'PhabricatorModularTransaction',
|
||||||
'PhortuneMerchantTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
'PhortuneMerchantTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||||
'PhortuneMerchantTransactionType' => 'PhabricatorModularTransactionType',
|
'PhortuneMerchantTransactionType' => 'PhabricatorModularTransactionType',
|
||||||
'PhortuneMerchantViewController' => 'PhortuneMerchantProfileController',
|
|
||||||
'PhortuneMonthYearExpiryControl' => 'AphrontFormControl',
|
'PhortuneMonthYearExpiryControl' => 'AphrontFormControl',
|
||||||
'PhortuneOrderTableView' => 'AphrontView',
|
'PhortuneOrderTableView' => 'AphrontView',
|
||||||
'PhortunePayPalPaymentProvider' => 'PhortunePaymentProvider',
|
'PhortunePayPalPaymentProvider' => 'PhortunePaymentProvider',
|
||||||
|
@ -11953,8 +11967,6 @@ phutil_register_library_map(array(
|
||||||
'PhortuneProductQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'PhortuneProductQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'PhortuneProductViewController' => 'PhortuneController',
|
'PhortuneProductViewController' => 'PhortuneController',
|
||||||
'PhortuneProviderActionController' => 'PhortuneController',
|
'PhortuneProviderActionController' => 'PhortuneController',
|
||||||
'PhortuneProviderDisableController' => 'PhortuneMerchantController',
|
|
||||||
'PhortuneProviderEditController' => 'PhortuneMerchantController',
|
|
||||||
'PhortunePurchase' => array(
|
'PhortunePurchase' => array(
|
||||||
'PhortuneDAO',
|
'PhortuneDAO',
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
|
|
|
@ -103,36 +103,40 @@ final class PhabricatorPhortuneApplication extends PhabricatorApplication {
|
||||||
=> 'PhortuneProviderActionController',
|
=> 'PhortuneProviderActionController',
|
||||||
),
|
),
|
||||||
'merchant/' => array(
|
'merchant/' => array(
|
||||||
'(?:query/(?P<queryKey>[^/]+)/)?' => 'PhortuneMerchantListController',
|
$this->getQueryRoutePattern()
|
||||||
'picture/(?:(?P<id>\d+)/)?' => 'PhortuneMerchantPictureController',
|
=> 'PhortuneMerchantListController',
|
||||||
$this->getEditRoutePattern('edit/')
|
$this->getEditRoutePattern('edit/')
|
||||||
=> 'PhortuneMerchantEditController',
|
=> 'PhortuneMerchantEditController',
|
||||||
'orders/(?P<merchantID>\d+)/(?:query/(?P<queryKey>[^/]+)/)?'
|
|
||||||
=> 'PhortuneCartListController',
|
|
||||||
'manager/' => array(
|
|
||||||
'(?:(?P<id>\d+)/)?' => 'PhortuneMerchantManagerController',
|
|
||||||
'add/(?:(?P<id>\d+)/)?' => 'PhortuneMerchantAddManagerController',
|
|
||||||
),
|
|
||||||
'(?P<merchantID>\d+)/' => array(
|
'(?P<merchantID>\d+)/' => array(
|
||||||
'cart/(?P<id>\d+)/' => array(
|
'' => 'PhortuneMerchantOverviewController',
|
||||||
'' => 'PhortuneCartViewController',
|
'details/' => 'PhortuneMerchantDetailsController',
|
||||||
'(?P<action>cancel|refund)/' => 'PhortuneCartCancelController',
|
'providers/' => array(
|
||||||
'update/' => 'PhortuneCartUpdateController',
|
'' => 'PhortuneMerchantProvidersController',
|
||||||
'accept/' => 'PhortuneCartAcceptController',
|
'(?P<providerID>\d+)/' => array(
|
||||||
|
'' => 'PhortuneMerchantProviderViewController',
|
||||||
|
'disable/' => 'PhortuneMerchantProviderDisableController',
|
||||||
|
),
|
||||||
|
$this->getEditRoutePattern('edit/')
|
||||||
|
=> 'PhortuneMerchantProviderEditController',
|
||||||
),
|
),
|
||||||
'subscription/' => array(
|
'orders/' => array(
|
||||||
'(?:query/(?P<queryKey>[^/]+)/)?'
|
'' => 'PhortuneMerchantOrdersController',
|
||||||
=> 'PhortuneSubscriptionListController',
|
$this->getQueryRoutePattern('list/')
|
||||||
'view/(?P<id>\d+)/'
|
=> 'PhortuneMerchantOrderListController',
|
||||||
=> 'PhortuneAccountSubscriptionViewController',
|
|
||||||
'order/(?P<subscriptionID>\d+)/'
|
|
||||||
=> 'PhortuneCartListController',
|
|
||||||
),
|
),
|
||||||
'invoice/' => array(
|
'picture/' => array(
|
||||||
'new/' => 'PhortuneMerchantInvoiceCreateController',
|
'edit/' => 'PhortuneMerchantPictureController',
|
||||||
|
),
|
||||||
|
'subscriptions/' => array(
|
||||||
|
'' => 'PhortuneMerchantSubscriptionsController',
|
||||||
|
$this->getQueryRoutePattern('list/')
|
||||||
|
=> 'PhortuneMerchantSubscriptionListController',
|
||||||
|
),
|
||||||
|
'managers/' => array(
|
||||||
|
'' => 'PhortuneMerchantManagersController',
|
||||||
|
'new/' => 'PhortuneMerchantAddManagerController',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'(?P<id>\d+)/' => 'PhortuneMerchantViewController',
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -11,7 +11,7 @@ final class PhortuneLandingController extends PhortuneController {
|
||||||
|
|
||||||
if (count($accounts) == 1) {
|
if (count($accounts) == 1) {
|
||||||
$account = head($accounts);
|
$account = head($accounts);
|
||||||
$next_uri = $this->getApplicationURI($account->getID().'/');
|
$next_uri = $account->getURI();
|
||||||
} else {
|
} else {
|
||||||
$next_uri = $this->getApplicationURI('account/');
|
$next_uri = $this->getApplicationURI('account/');
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,6 @@ final class PhortuneAccountEmailViewController
|
||||||
->setTitle($address->getObjectName())
|
->setTitle($address->getObjectName())
|
||||||
->setCrumbs($crumbs)
|
->setCrumbs($crumbs)
|
||||||
->appendChild($view);
|
->appendChild($view);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildCurtainView(PhortuneAccountEmail $address) {
|
private function buildCurtainView(PhortuneAccountEmail $address) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ final class PhortuneAccountListController extends PhortuneController {
|
||||||
$item = id(new PHUIObjectItemView())
|
$item = id(new PHUIObjectItemView())
|
||||||
->setSubhead(pht('Account %d', $account->getID()))
|
->setSubhead(pht('Account %d', $account->getID()))
|
||||||
->setHeader($account->getName())
|
->setHeader($account->getName())
|
||||||
->setHref($this->getApplicationURI($account->getID().'/'))
|
->setHref($account->getURI())
|
||||||
->setObject($account)
|
->setObject($account)
|
||||||
->setImageIcon('fa-user-circle');
|
->setImageIcon('fa-user-circle');
|
||||||
|
|
||||||
|
|
|
@ -44,11 +44,8 @@ final class PhortuneAccountOrderListController
|
||||||
$subscription->getURI());
|
$subscription->getURI());
|
||||||
} else if ($this->hasAccount()) {
|
} else if ($this->hasAccount()) {
|
||||||
$account = $this->getAccount();
|
$account = $this->getAccount();
|
||||||
$id = $account->getID();
|
|
||||||
|
|
||||||
$crumbs->addTextCrumb(
|
$crumbs->addTextCrumb(pht('Orders'), $account->getOrdersURI());
|
||||||
pht('Orders'),
|
|
||||||
$account->getOrdersURI());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $crumbs;
|
return $crumbs;
|
||||||
|
|
|
@ -66,22 +66,11 @@ final class PhortuneAccountOverviewController
|
||||||
|
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
$phids = array();
|
|
||||||
foreach ($carts as $cart) {
|
|
||||||
$phids[] = $cart->getPHID();
|
|
||||||
$phids[] = $cart->getMerchantPHID();
|
|
||||||
foreach ($cart->getPurchases() as $purchase) {
|
|
||||||
$phids[] = $purchase->getPHID();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$handles = $this->loadViewerHandles($phids);
|
|
||||||
|
|
||||||
$table = id(new PhortuneOrderTableView())
|
$table = id(new PhortuneOrderTableView())
|
||||||
->setNoDataString(pht('You have no unpaid invoices.'))
|
->setNoDataString(pht('You have no unpaid invoices.'))
|
||||||
->setIsInvoices(true)
|
->setIsInvoices(true)
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setCarts($carts)
|
->setCarts($carts);
|
||||||
->setHandles($handles);
|
|
||||||
|
|
||||||
$header = id(new PHUIHeaderView())
|
$header = id(new PHUIHeaderView())
|
||||||
->setHeader(pht('Invoices Due'));
|
->setHeader(pht('Invoices Due'));
|
||||||
|
|
|
@ -117,21 +117,11 @@ abstract class PhortuneAccountProfileController
|
||||||
->setLimit($limit)
|
->setLimit($limit)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$phids = array();
|
|
||||||
foreach ($carts as $cart) {
|
|
||||||
$phids[] = $cart->getPHID();
|
|
||||||
foreach ($cart->getPurchases() as $purchase) {
|
|
||||||
$phids[] = $purchase->getPHID();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$handles = $this->loadViewerHandles($phids);
|
|
||||||
|
|
||||||
$orders_uri = $account->getOrderListURI();
|
$orders_uri = $account->getOrderListURI();
|
||||||
|
|
||||||
$table = id(new PhortuneOrderTableView())
|
$table = id(new PhortuneOrderTableView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setCarts($carts)
|
->setCarts($carts);
|
||||||
->setHandles($handles);
|
|
||||||
|
|
||||||
$header = id(new PHUIHeaderView())
|
$header = id(new PHUIHeaderView())
|
||||||
->setHeader(pht('Recent Orders'))
|
->setHeader(pht('Recent Orders'))
|
||||||
|
|
|
@ -92,21 +92,10 @@ final class PhortuneAccountSubscriptionViewController
|
||||||
->withInvoices(true)
|
->withInvoices(true)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$phids = array();
|
|
||||||
foreach ($invoices as $invoice) {
|
|
||||||
$phids[] = $invoice->getPHID();
|
|
||||||
$phids[] = $invoice->getMerchantPHID();
|
|
||||||
foreach ($invoice->getPurchases() as $purchase) {
|
|
||||||
$phids[] = $purchase->getPHID();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$handles = $this->loadViewerHandles($phids);
|
|
||||||
|
|
||||||
$invoice_table = id(new PhortuneOrderTableView())
|
$invoice_table = id(new PhortuneOrderTableView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setCarts($invoices)
|
->setCarts($invoices)
|
||||||
->setIsInvoices(true)
|
->setIsInvoices(true);
|
||||||
->setHandles($handles);
|
|
||||||
|
|
||||||
$invoice_header = id(new PHUIHeaderView())
|
$invoice_header = id(new PHUIHeaderView())
|
||||||
->setHeader(pht('Invoices Due'));
|
->setHeader(pht('Invoices Due'));
|
||||||
|
@ -135,19 +124,9 @@ final class PhortuneAccountSubscriptionViewController
|
||||||
->setLimit(50)
|
->setLimit(50)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$phids = array();
|
|
||||||
foreach ($invoices as $invoice) {
|
|
||||||
$phids[] = $invoice->getPHID();
|
|
||||||
foreach ($invoice->getPurchases() as $purchase) {
|
|
||||||
$phids[] = $purchase->getPHID();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$handles = $this->loadViewerHandles($phids);
|
|
||||||
|
|
||||||
$invoice_table = id(new PhortuneOrderTableView())
|
$invoice_table = id(new PhortuneOrderTableView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setCarts($invoices)
|
->setCarts($invoices);
|
||||||
->setHandles($handles);
|
|
||||||
|
|
||||||
$account = $subscription->getAccount();
|
$account = $subscription->getAccount();
|
||||||
$merchant = $subscription->getMerchant();
|
$merchant = $subscription->getMerchant();
|
||||||
|
|
|
@ -1,134 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class PhortuneCartListController
|
|
||||||
extends PhortuneController {
|
|
||||||
|
|
||||||
private $merchant;
|
|
||||||
private $account;
|
|
||||||
private $subscription;
|
|
||||||
private $engine;
|
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
|
||||||
$viewer = $this->getViewer();
|
|
||||||
|
|
||||||
$merchant_id = $request->getURIData('merchantID');
|
|
||||||
$account_id = $request->getURIData('accountID');
|
|
||||||
$subscription_id = $request->getURIData('subscriptionID');
|
|
||||||
|
|
||||||
$engine = id(new PhortuneCartSearchEngine())
|
|
||||||
->setViewer($viewer);
|
|
||||||
|
|
||||||
if ($merchant_id) {
|
|
||||||
$merchant = id(new PhortuneMerchantQuery())
|
|
||||||
->setViewer($viewer)
|
|
||||||
->withIDs(array($merchant_id))
|
|
||||||
->requireCapabilities(
|
|
||||||
array(
|
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
|
||||||
PhabricatorPolicyCapability::CAN_EDIT,
|
|
||||||
))
|
|
||||||
->executeOne();
|
|
||||||
if (!$merchant) {
|
|
||||||
return new Aphront404Response();
|
|
||||||
}
|
|
||||||
$this->merchant = $merchant;
|
|
||||||
$viewer->grantAuthority($merchant);
|
|
||||||
$engine->setMerchant($merchant);
|
|
||||||
} else if ($account_id) {
|
|
||||||
$account = id(new PhortuneAccountQuery())
|
|
||||||
->setViewer($viewer)
|
|
||||||
->withIDs(array($account_id))
|
|
||||||
->requireCapabilities(
|
|
||||||
array(
|
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
|
||||||
PhabricatorPolicyCapability::CAN_EDIT,
|
|
||||||
))
|
|
||||||
->executeOne();
|
|
||||||
if (!$account) {
|
|
||||||
return new Aphront404Response();
|
|
||||||
}
|
|
||||||
$this->account = $account;
|
|
||||||
$engine->setAccount($account);
|
|
||||||
} else {
|
|
||||||
return new Aphront404Response();
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: We must process this after processing the merchant authority, so
|
|
||||||
// it becomes visible in merchant contexts.
|
|
||||||
if ($subscription_id) {
|
|
||||||
$subscription = id(new PhortuneSubscriptionQuery())
|
|
||||||
->setViewer($viewer)
|
|
||||||
->withIDs(array($subscription_id))
|
|
||||||
->executeOne();
|
|
||||||
if (!$subscription) {
|
|
||||||
return new Aphront404Response();
|
|
||||||
}
|
|
||||||
$this->subscription = $subscription;
|
|
||||||
$engine->setSubscription($subscription);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->engine = $engine;
|
|
||||||
|
|
||||||
$controller = id(new PhabricatorApplicationSearchController())
|
|
||||||
->setQueryKey($request->getURIData('queryKey'))
|
|
||||||
->setSearchEngine($engine)
|
|
||||||
->setNavigation($this->buildSideNavView());
|
|
||||||
|
|
||||||
return $this->delegateToController($controller);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildSideNavView() {
|
|
||||||
$viewer = $this->getRequest()->getUser();
|
|
||||||
|
|
||||||
$nav = new AphrontSideNavFilterView();
|
|
||||||
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
|
||||||
|
|
||||||
$this->engine->addNavigationItems($nav->getMenu());
|
|
||||||
|
|
||||||
$nav->selectFilter(null);
|
|
||||||
|
|
||||||
return $nav;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function buildApplicationCrumbs() {
|
|
||||||
$crumbs = parent::buildApplicationCrumbs();
|
|
||||||
|
|
||||||
$subscription = $this->subscription;
|
|
||||||
|
|
||||||
$merchant = $this->merchant;
|
|
||||||
if ($merchant) {
|
|
||||||
$id = $merchant->getID();
|
|
||||||
$this->addMerchantCrumb($crumbs, $merchant);
|
|
||||||
if (!$subscription) {
|
|
||||||
$crumbs->addTextCrumb(
|
|
||||||
pht('Orders'),
|
|
||||||
$this->getApplicationURI("merchant/orders/{$id}/"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$account = $this->account;
|
|
||||||
if ($account) {
|
|
||||||
$id = $account->getID();
|
|
||||||
$this->addAccountCrumb($crumbs, $account);
|
|
||||||
if (!$subscription) {
|
|
||||||
$crumbs->addTextCrumb(
|
|
||||||
pht('Orders'),
|
|
||||||
$this->getApplicationURI("{$id}/order/"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($subscription) {
|
|
||||||
if ($merchant) {
|
|
||||||
$subscription_uri = $subscription->getMerchantURI();
|
|
||||||
} else {
|
|
||||||
$subscription_uri = $subscription->getURI();
|
|
||||||
}
|
|
||||||
$crumbs->addTextCrumb(
|
|
||||||
$subscription->getSubscriptionName(),
|
|
||||||
$subscription_uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $crumbs;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,32 +1,23 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhortuneMerchantAddManagerController extends PhortuneController {
|
final class PhortuneMerchantAddManagerController
|
||||||
|
extends PhortuneMerchantController {
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
protected function shouldRequireMerchantEditCapability() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function handleMerchantRequest(AphrontRequest $request) {
|
||||||
$viewer = $request->getViewer();
|
$viewer = $request->getViewer();
|
||||||
$id = $request->getURIData('id');
|
$merchant = $this->getMerchant();
|
||||||
|
|
||||||
$merchant = id(new PhortuneMerchantQuery())
|
|
||||||
->setViewer($viewer)
|
|
||||||
->withIDs(array($id))
|
|
||||||
->needProfileImage(true)
|
|
||||||
->requireCapabilities(
|
|
||||||
array(
|
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
|
||||||
PhabricatorPolicyCapability::CAN_EDIT,
|
|
||||||
))
|
|
||||||
->executeOne();
|
|
||||||
if (!$merchant) {
|
|
||||||
return new Aphront404Response();
|
|
||||||
}
|
|
||||||
|
|
||||||
$v_members = array();
|
$v_members = array();
|
||||||
$e_members = null;
|
$e_members = null;
|
||||||
$merchant_uri = $this->getApplicationURI("/merchant/manager/{$id}/");
|
$merchant_uri = $merchant->getManagersURI();
|
||||||
|
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormOrHiSecPost()) {
|
||||||
$xactions = array();
|
$xactions = array();
|
||||||
$v_members = $request->getArr('memberPHIDs');
|
$v_members = $request->getArr('managerPHIDs');
|
||||||
$type_edge = PhabricatorTransactions::TYPE_EDGE;
|
$type_edge = PhabricatorTransactions::TYPE_EDGE;
|
||||||
|
|
||||||
$xactions[] = id(new PhortuneMerchantTransaction())
|
$xactions[] = id(new PhortuneMerchantTransaction())
|
||||||
|
@ -59,13 +50,13 @@ final class PhortuneMerchantAddManagerController extends PhortuneController {
|
||||||
->appendControl(
|
->appendControl(
|
||||||
id(new AphrontFormTokenizerControl())
|
id(new AphrontFormTokenizerControl())
|
||||||
->setDatasource(new PhabricatorPeopleDatasource())
|
->setDatasource(new PhabricatorPeopleDatasource())
|
||||||
->setLabel(pht('Members'))
|
->setLabel(pht('New Managers'))
|
||||||
->setName('memberPHIDs')
|
->setName('managerPHIDs')
|
||||||
->setValue($v_members)
|
->setValue($v_members)
|
||||||
->setError($e_members));
|
->setError($e_members));
|
||||||
|
|
||||||
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($merchant_uri)
|
->addCancelButton($merchant_uri)
|
||||||
|
|
|
@ -3,11 +3,80 @@
|
||||||
abstract class PhortuneMerchantController
|
abstract class PhortuneMerchantController
|
||||||
extends PhortuneController {
|
extends PhortuneController {
|
||||||
|
|
||||||
protected function buildApplicationCrumbs() {
|
private $merchant;
|
||||||
$crumbs = parent::buildApplicationCrumbs();
|
|
||||||
$crumbs->addTextCrumb(
|
final protected function setMerchant(PhortuneMerchant $merchant) {
|
||||||
pht('Merchants'),
|
$this->merchant = $merchant;
|
||||||
$this->getApplicationURI('merchant/'));
|
return $this;
|
||||||
return $crumbs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final protected function getMerchant() {
|
||||||
|
return $this->merchant;
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function hasMerchant() {
|
||||||
|
return (bool)$this->merchant;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function handleRequest(AphrontRequest $request) {
|
||||||
|
if ($this->shouldRequireMerchantEditCapability()) {
|
||||||
|
$response = $this->loadMerchantForEdit();
|
||||||
|
} else {
|
||||||
|
$response = $this->loadMerchantForView();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($response) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->handleMerchantRequest($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract protected function shouldRequireMerchantEditCapability();
|
||||||
|
abstract protected function handleMerchantRequest(AphrontRequest $request);
|
||||||
|
|
||||||
|
private function loadMerchantForEdit() {
|
||||||
|
return $this->loadMerchantWithCapabilities(
|
||||||
|
array(
|
||||||
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function loadMerchantForView() {
|
||||||
|
return $this->loadMerchantWithCapabilities(
|
||||||
|
array(
|
||||||
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function loadMerchantWithCapabilities(array $capabilities) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
$request = $this->getRequest();
|
||||||
|
|
||||||
|
$merchant_id = $request->getURIData('merchantID');
|
||||||
|
if (!$merchant_id) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'Controller ("%s") extends controller "%s", but is reachable '.
|
||||||
|
'with no "merchantID" in URI.',
|
||||||
|
get_class($this),
|
||||||
|
__CLASS__));
|
||||||
|
}
|
||||||
|
|
||||||
|
$merchant = id(new PhortuneMerchantQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withIDs(array($merchant_id))
|
||||||
|
->needProfileImage(true)
|
||||||
|
->requireCapabilities($capabilities)
|
||||||
|
->executeOne();
|
||||||
|
if (!$merchant) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setMerchant($merchant);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,151 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhortuneMerchantDetailsController
|
||||||
|
extends PhortuneMerchantProfileController {
|
||||||
|
|
||||||
|
protected function shouldRequireMerchantEditCapability() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function handleMerchantRequest(AphrontRequest $request) {
|
||||||
|
$viewer = $request->getViewer();
|
||||||
|
$id = $request->getURIData('id');
|
||||||
|
|
||||||
|
$merchant = $this->getMerchant();
|
||||||
|
|
||||||
|
$crumbs = $this->buildApplicationCrumbs()
|
||||||
|
->addTextCrumb(pht('Account Details'))
|
||||||
|
->setBorder(true);
|
||||||
|
$header = $this->buildHeaderView();
|
||||||
|
|
||||||
|
$title = pht(
|
||||||
|
'%s %s',
|
||||||
|
$merchant->getObjectName(),
|
||||||
|
$merchant->getName());
|
||||||
|
|
||||||
|
$details = $this->buildDetailsView($merchant);
|
||||||
|
$curtain = $this->buildCurtainView($merchant);
|
||||||
|
|
||||||
|
$timeline = $this->buildTransactionTimeline(
|
||||||
|
$merchant,
|
||||||
|
new PhortuneMerchantTransactionQuery());
|
||||||
|
$timeline->setShouldTerminate(true);
|
||||||
|
|
||||||
|
$navigation = $this->buildSideNavView('details');
|
||||||
|
|
||||||
|
$view = id(new PHUITwoColumnView())
|
||||||
|
->setHeader($header)
|
||||||
|
->setCurtain($curtain)
|
||||||
|
->setMainColumn(array(
|
||||||
|
$details,
|
||||||
|
$timeline,
|
||||||
|
));
|
||||||
|
|
||||||
|
return $this->newPage()
|
||||||
|
->setTitle($title)
|
||||||
|
->setCrumbs($crumbs)
|
||||||
|
->setNavigation($navigation)
|
||||||
|
->appendChild($view);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildDetailsView(PhortuneMerchant $merchant) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$view = id(new PHUIPropertyListView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setObject($merchant);
|
||||||
|
|
||||||
|
$invoice_from = $merchant->getInvoiceEmail();
|
||||||
|
if (!$invoice_from) {
|
||||||
|
$invoice_from = pht('No email address set');
|
||||||
|
$invoice_from = phutil_tag('em', array(), $invoice_from);
|
||||||
|
}
|
||||||
|
$view->addProperty(pht('Invoice From'), $invoice_from);
|
||||||
|
|
||||||
|
$description = $merchant->getDescription();
|
||||||
|
if (strlen($description)) {
|
||||||
|
$description = new PHUIRemarkupView($viewer, $description);
|
||||||
|
$view->addSectionHeader(
|
||||||
|
pht('Description'),
|
||||||
|
PHUIPropertyListView::ICON_SUMMARY);
|
||||||
|
$view->addTextContent($description);
|
||||||
|
}
|
||||||
|
|
||||||
|
$contact_info = $merchant->getContactInfo();
|
||||||
|
if (strlen($contact_info)) {
|
||||||
|
$contact_info = new PHUIRemarkupView($viewer, $contact_info);
|
||||||
|
$view->addSectionHeader(
|
||||||
|
pht('Contact Information'),
|
||||||
|
PHUIPropertyListView::ICON_SUMMARY);
|
||||||
|
$view->addTextContent($contact_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
$footer_info = $merchant->getInvoiceFooter();
|
||||||
|
if (strlen($footer_info)) {
|
||||||
|
$footer_info = new PHUIRemarkupView($viewer, $footer_info);
|
||||||
|
$view->addSectionHeader(
|
||||||
|
pht('Invoice Footer'),
|
||||||
|
PHUIPropertyListView::ICON_SUMMARY);
|
||||||
|
$view->addTextContent($footer_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
return id(new PHUIObjectBoxView())
|
||||||
|
->setHeaderText(pht('Details'))
|
||||||
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
||||||
|
->appendChild($view);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildCurtainView(PhortuneMerchant $merchant) {
|
||||||
|
$viewer = $this->getRequest()->getUser();
|
||||||
|
$id = $merchant->getID();
|
||||||
|
|
||||||
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||||
|
$viewer,
|
||||||
|
$merchant,
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT);
|
||||||
|
|
||||||
|
$curtain = $this->newCurtainView($merchant);
|
||||||
|
|
||||||
|
$curtain->addAction(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setName(pht('Edit Merchant'))
|
||||||
|
->setIcon('fa-pencil')
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow(!$can_edit)
|
||||||
|
->setHref($this->getApplicationURI("merchant/edit/{$id}/")));
|
||||||
|
|
||||||
|
$curtain->addAction(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setName(pht('Edit Logo'))
|
||||||
|
->setIcon('fa-picture-o')
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow(!$can_edit)
|
||||||
|
->setHref($this->getApplicationURI("merchant/{$id}/picture/edit/")));
|
||||||
|
|
||||||
|
$member_phids = $merchant->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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhortuneMerchantEditController
|
final class PhortuneMerchantEditController
|
||||||
extends PhortuneMerchantController {
|
extends PhortuneController {
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
return id(new PhortuneMerchantEditEngine())
|
return id(new PhortuneMerchantEditEngine())
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhortuneMerchantInvoiceCreateController
|
final class PhortuneMerchantInvoiceCreateController
|
||||||
extends PhortuneMerchantProfileController {
|
extends PhortuneMerchantController {
|
||||||
|
|
||||||
|
protected function shouldRequireMerchantEditCapability() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function handleMerchantRequest(AphrontRequest $request) {
|
||||||
|
// TODO: Make this work again, or destroy it.
|
||||||
|
return new Aphront404Response();
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
|
||||||
$viewer = $request->getUser();
|
$viewer = $request->getUser();
|
||||||
|
|
||||||
$merchant = $this->loadMerchantAuthority();
|
$merchant = $this->loadMerchantAuthority();
|
||||||
|
|
|
@ -1,37 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhortuneMerchantListController
|
final class PhortuneMerchantListController
|
||||||
extends PhortuneMerchantController {
|
extends PhortuneController {
|
||||||
|
|
||||||
public function shouldAllowPublic() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$viewer = $request->getViewer();
|
return id(new PhortuneMerchantSearchEngine())
|
||||||
$querykey = $request->getURIData('queryKey');
|
->setController($this)
|
||||||
|
->buildResponse();
|
||||||
$controller = id(new PhabricatorApplicationSearchController())
|
|
||||||
->setQueryKey($querykey)
|
|
||||||
->setSearchEngine(new PhortuneMerchantSearchEngine())
|
|
||||||
->setNavigation($this->buildSideNavView());
|
|
||||||
|
|
||||||
return $this->delegateToController($controller);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildSideNavView() {
|
|
||||||
$viewer = $this->getViewer();
|
|
||||||
|
|
||||||
$nav = new AphrontSideNavFilterView();
|
|
||||||
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
|
||||||
|
|
||||||
id(new PhortuneMerchantSearchEngine())
|
|
||||||
->setViewer($viewer)
|
|
||||||
->addNavigationItems($nav->getMenu());
|
|
||||||
|
|
||||||
$nav->selectFilter(null);
|
|
||||||
|
|
||||||
return $nav;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function buildApplicationCrumbs() {
|
protected function buildApplicationCrumbs() {
|
||||||
|
|
|
@ -1,35 +1,29 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhortuneMerchantManagerController
|
final class PhortuneMerchantManagersController
|
||||||
extends PhortuneMerchantProfileController {
|
extends PhortuneMerchantProfileController {
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
protected function shouldRequireMerchantEditCapability() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function handleMerchantRequest(AphrontRequest $request) {
|
||||||
$viewer = $request->getViewer();
|
$viewer = $request->getViewer();
|
||||||
$id = $request->getURIData('id');
|
$merchant = $this->getMerchant();
|
||||||
|
|
||||||
$merchant = id(new PhortuneMerchantQuery())
|
$crumbs = $this->buildApplicationCrumbs()
|
||||||
->setViewer($viewer)
|
->addTextCrumb(pht('Managers'))
|
||||||
->withIDs(array($id))
|
->setBorder(true);
|
||||||
->needProfileImage(true)
|
|
||||||
->executeOne();
|
|
||||||
if (!$merchant) {
|
|
||||||
return new Aphront404Response();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->setMerchant($merchant);
|
|
||||||
$header = $this->buildHeaderView();
|
|
||||||
|
|
||||||
$crumbs = $this->buildApplicationCrumbs();
|
|
||||||
$crumbs->addTextCrumb(pht('Managers'));
|
|
||||||
|
|
||||||
$header = $this->buildHeaderView();
|
$header = $this->buildHeaderView();
|
||||||
$members = $this->buildMembersSection($merchant);
|
$members = $this->buildMembersSection($merchant);
|
||||||
|
|
||||||
$view = id(new PHUITwoColumnView())
|
$view = id(new PHUITwoColumnView())
|
||||||
->setHeader($header)
|
->setHeader($header)
|
||||||
->setFooter(array(
|
->setFooter(
|
||||||
$members,
|
array(
|
||||||
));
|
$members,
|
||||||
|
));
|
||||||
|
|
||||||
$navigation = $this->buildSideNavView('managers');
|
$navigation = $this->buildSideNavView('managers');
|
||||||
|
|
||||||
|
@ -38,7 +32,6 @@ final class PhortuneMerchantManagerController
|
||||||
->setCrumbs($crumbs)
|
->setCrumbs($crumbs)
|
||||||
->setNavigation($navigation)
|
->setNavigation($navigation)
|
||||||
->appendChild($view);
|
->appendChild($view);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildMembersSection(PhortuneMerchant $merchant) {
|
private function buildMembersSection(PhortuneMerchant $merchant) {
|
||||||
|
@ -51,12 +44,18 @@ final class PhortuneMerchantManagerController
|
||||||
|
|
||||||
$id = $merchant->getID();
|
$id = $merchant->getID();
|
||||||
|
|
||||||
|
$add_uri = urisprintf(
|
||||||
|
'merchant/%d/managers/new/',
|
||||||
|
$merchant->getID());
|
||||||
|
$add_uri = $this->getApplicationURI($add_uri);
|
||||||
|
|
||||||
$add = id(new PHUIButtonView())
|
$add = id(new PHUIButtonView())
|
||||||
->setTag('a')
|
->setTag('a')
|
||||||
->setText(pht('New Manager'))
|
->setText(pht('New Manager'))
|
||||||
->setIcon('fa-plus')
|
->setIcon('fa-plus')
|
||||||
->setWorkflow(true)
|
->setWorkflow(true)
|
||||||
->setHref("/phortune/merchant/manager/add/{$id}/");
|
->setDisabled(!$can_edit)
|
||||||
|
->setHref($add_uri);
|
||||||
|
|
||||||
$header = id(new PHUIHeaderView())
|
$header = id(new PHUIHeaderView())
|
||||||
->setHeader(pht('Merchant Account Managers'))
|
->setHeader(pht('Merchant Account Managers'))
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhortuneMerchantOrderListController
|
||||||
|
extends PhortuneMerchantProfileController {
|
||||||
|
|
||||||
|
private $subscription;
|
||||||
|
|
||||||
|
protected function shouldRequireMerchantEditCapability() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function handleMerchantRequest(AphrontRequest $request) {
|
||||||
|
$viewer = $request->getViewer();
|
||||||
|
$merchant = $this->getMerchant();
|
||||||
|
|
||||||
|
$engine = id(new PhortuneCartSearchEngine())
|
||||||
|
->setController($this)
|
||||||
|
->setMerchant($merchant);
|
||||||
|
|
||||||
|
$subscription_id = $request->getURIData('subscriptionID');
|
||||||
|
if ($subscription_id) {
|
||||||
|
$subscription = id(new PhortuneSubscriptionQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withIDs(array($subscription_id))
|
||||||
|
->executeOne();
|
||||||
|
if (!$subscription) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
$engine->setSubscription($subscription);
|
||||||
|
$this->subscription = $subscription;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $engine->buildResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildApplicationCrumbs() {
|
||||||
|
$crumbs = parent::buildApplicationCrumbs();
|
||||||
|
|
||||||
|
$subscription = $this->subscription;
|
||||||
|
if ($subscription) {
|
||||||
|
$crumbs->addTextCrumb(
|
||||||
|
$subscription->getObjectName(),
|
||||||
|
$subscription->getURI());
|
||||||
|
} else if ($this->hasMerchant()) {
|
||||||
|
$merchant = $this->getMerchant();
|
||||||
|
|
||||||
|
$crumbs->addTextCrumb(pht('Orders'), $merchant->getOrdersURI());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $crumbs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhortuneMerchantOrdersController
|
||||||
|
extends PhortuneMerchantProfileController {
|
||||||
|
|
||||||
|
protected function shouldRequireMerchantEditCapability() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function handleMerchantRequest(AphrontRequest $request) {
|
||||||
|
$merchant = $this->getMerchant();
|
||||||
|
$title = $merchant->getName();
|
||||||
|
|
||||||
|
$crumbs = $this->buildApplicationCrumbs()
|
||||||
|
->addTextCrumb(pht('Orders'))
|
||||||
|
->setBorder(true);
|
||||||
|
|
||||||
|
$header = $this->buildHeaderView();
|
||||||
|
$order_history = $this->newRecentOrdersView($merchant, 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function newRecentOrdersView(
|
||||||
|
PhortuneMerchant $merchant,
|
||||||
|
$limit) {
|
||||||
|
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$carts = id(new PhortuneCartQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withMerchantPHIDs(array($merchant->getPHID()))
|
||||||
|
->needPurchases(true)
|
||||||
|
->withStatuses(
|
||||||
|
array(
|
||||||
|
PhortuneCart::STATUS_PURCHASING,
|
||||||
|
PhortuneCart::STATUS_CHARGED,
|
||||||
|
PhortuneCart::STATUS_HOLD,
|
||||||
|
PhortuneCart::STATUS_REVIEW,
|
||||||
|
PhortuneCart::STATUS_PURCHASED,
|
||||||
|
))
|
||||||
|
->setLimit($limit)
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$orders_uri = $merchant->getOrderListURI();
|
||||||
|
|
||||||
|
$table = id(new PhortuneOrderTableView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setCarts($carts);
|
||||||
|
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,136 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhortuneMerchantOverviewController
|
||||||
|
extends PhortuneMerchantProfileController {
|
||||||
|
|
||||||
|
protected function shouldRequireMerchantEditCapability() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function handleMerchantRequest(AphrontRequest $request) {
|
||||||
|
$viewer = $request->getViewer();
|
||||||
|
$merchant = $this->getMerchant();
|
||||||
|
|
||||||
|
$crumbs = $this->buildApplicationCrumbs()
|
||||||
|
->setBorder(true);
|
||||||
|
|
||||||
|
$header = $this->buildHeaderView();
|
||||||
|
|
||||||
|
$title = pht(
|
||||||
|
'%s %s',
|
||||||
|
$merchant->getObjectName(),
|
||||||
|
$merchant->getName());
|
||||||
|
|
||||||
|
$providers = id(new PhortunePaymentProviderConfigQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withMerchantPHIDs(array($merchant->getPHID()))
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$details = $this->buildDetailsView($merchant, $providers);
|
||||||
|
$navigation = $this->buildSideNavView('overview');
|
||||||
|
|
||||||
|
$view = id(new PHUITwoColumnView())
|
||||||
|
->setHeader($header)
|
||||||
|
->setFooter(
|
||||||
|
array(
|
||||||
|
$details,
|
||||||
|
));
|
||||||
|
|
||||||
|
return $this->newPage()
|
||||||
|
->setTitle($title)
|
||||||
|
->setCrumbs($crumbs)
|
||||||
|
->setNavigation($navigation)
|
||||||
|
->appendChild($view);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildDetailsView(
|
||||||
|
PhortuneMerchant $merchant,
|
||||||
|
array $providers) {
|
||||||
|
|
||||||
|
$viewer = $this->getRequest()->getUser();
|
||||||
|
|
||||||
|
$view = id(new PHUIPropertyListView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setObject($merchant);
|
||||||
|
|
||||||
|
$status_view = new PHUIStatusListView();
|
||||||
|
|
||||||
|
$have_any = false;
|
||||||
|
$any_test = false;
|
||||||
|
foreach ($providers as $provider_config) {
|
||||||
|
$provider = $provider_config->buildProvider();
|
||||||
|
if ($provider->isEnabled()) {
|
||||||
|
$have_any = true;
|
||||||
|
}
|
||||||
|
if (!$provider->isAcceptingLivePayments()) {
|
||||||
|
$any_test = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($have_any) {
|
||||||
|
$status_view->addItem(
|
||||||
|
id(new PHUIStatusItemView())
|
||||||
|
->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')
|
||||||
|
->setTarget(pht('Accepts Payments'))
|
||||||
|
->setNote(pht('This merchant can accept payments.')));
|
||||||
|
|
||||||
|
if ($any_test) {
|
||||||
|
$status_view->addItem(
|
||||||
|
id(new PHUIStatusItemView())
|
||||||
|
->setIcon(PHUIStatusItemView::ICON_WARNING, 'yellow')
|
||||||
|
->setTarget(pht('Test Mode'))
|
||||||
|
->setNote(pht('This merchant is accepting test payments.')));
|
||||||
|
} else {
|
||||||
|
$status_view->addItem(
|
||||||
|
id(new PHUIStatusItemView())
|
||||||
|
->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')
|
||||||
|
->setTarget(pht('Live Mode'))
|
||||||
|
->setNote(pht('This merchant is accepting live payments.')));
|
||||||
|
}
|
||||||
|
} else if ($providers) {
|
||||||
|
$status_view->addItem(
|
||||||
|
id(new PHUIStatusItemView())
|
||||||
|
->setIcon(PHUIStatusItemView::ICON_REJECT, 'red')
|
||||||
|
->setTarget(pht('No Enabled Providers'))
|
||||||
|
->setNote(
|
||||||
|
pht(
|
||||||
|
'All of the payment providers for this merchant are '.
|
||||||
|
'disabled.')));
|
||||||
|
} else {
|
||||||
|
$status_view->addItem(
|
||||||
|
id(new PHUIStatusItemView())
|
||||||
|
->setIcon(PHUIStatusItemView::ICON_WARNING, 'yellow')
|
||||||
|
->setTarget(pht('No Providers'))
|
||||||
|
->setNote(
|
||||||
|
pht(
|
||||||
|
'This merchant does not have any payment providers configured '.
|
||||||
|
'yet, so it can not accept payments. Add a provider.')));
|
||||||
|
}
|
||||||
|
|
||||||
|
$view->addProperty(pht('Status'), $status_view);
|
||||||
|
|
||||||
|
$description = $merchant->getDescription();
|
||||||
|
if (strlen($description)) {
|
||||||
|
$description = new PHUIRemarkupView($viewer, $description);
|
||||||
|
$view->addSectionHeader(
|
||||||
|
pht('Description'),
|
||||||
|
PHUIPropertyListView::ICON_SUMMARY);
|
||||||
|
$view->addTextContent($description);
|
||||||
|
}
|
||||||
|
|
||||||
|
$contact_info = $merchant->getContactInfo();
|
||||||
|
if (strlen($contact_info)) {
|
||||||
|
$contact_info = new PHUIRemarkupView($viewer, $contact_info);
|
||||||
|
$view->addSectionHeader(
|
||||||
|
pht('Contact Information'),
|
||||||
|
PHUIPropertyListView::ICON_SUMMARY);
|
||||||
|
$view->addTextContent($contact_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
return id(new PHUIObjectBoxView())
|
||||||
|
->setHeaderText(pht('Details'))
|
||||||
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
||||||
|
->appendChild($view);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,28 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhortuneMerchantPictureController
|
final class PhortuneMerchantPictureController
|
||||||
extends PhortuneMerchantProfileController {
|
extends PhortuneMerchantController {
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
protected function shouldRequireMerchantEditCapability() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function handleMerchantRequest(AphrontRequest $request) {
|
||||||
$viewer = $request->getViewer();
|
$viewer = $request->getViewer();
|
||||||
$id = $request->getURIData('id');
|
$merchant = $this->getMerchant();
|
||||||
|
|
||||||
$merchant = id(new PhortuneMerchantQuery())
|
$uri = $merchant->getDetailsURI();
|
||||||
->setViewer($viewer)
|
|
||||||
->withIDs(array($id))
|
|
||||||
->needProfileImage(true)
|
|
||||||
->requireCapabilities(
|
|
||||||
array(
|
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
|
||||||
PhabricatorPolicyCapability::CAN_EDIT,
|
|
||||||
))
|
|
||||||
->executeOne();
|
|
||||||
if (!$merchant) {
|
|
||||||
return new Aphront404Response();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->setMerchant($merchant);
|
|
||||||
$uri = $merchant->getURI();
|
|
||||||
|
|
||||||
$supported_formats = PhabricatorFile::getTransformableImageFormats();
|
$supported_formats = PhabricatorFile::getTransformableImageFormats();
|
||||||
$e_file = true;
|
$e_file = true;
|
||||||
|
@ -222,12 +211,9 @@ final class PhortuneMerchantPictureController
|
||||||
$upload_box,
|
$upload_box,
|
||||||
));
|
));
|
||||||
|
|
||||||
$navigation = $this->buildSideNavView();
|
|
||||||
|
|
||||||
return $this->newPage()
|
return $this->newPage()
|
||||||
->setTitle($title)
|
->setTitle($title)
|
||||||
->setCrumbs($crumbs)
|
->setCrumbs($crumbs)
|
||||||
->setNavigation($navigation)
|
|
||||||
->appendChild(
|
->appendChild(
|
||||||
array(
|
array(
|
||||||
$view,
|
$view,
|
||||||
|
|
|
@ -1,22 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
abstract class PhortuneMerchantProfileController
|
abstract class PhortuneMerchantProfileController
|
||||||
extends PhortuneController {
|
extends PhortuneMerchantController {
|
||||||
|
|
||||||
private $merchant;
|
|
||||||
|
|
||||||
public function setMerchant(PhortuneMerchant $merchant) {
|
|
||||||
$this->merchant = $merchant;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMerchant() {
|
|
||||||
return $this->merchant;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildApplicationMenu() {
|
|
||||||
return $this->buildSideNavView()->getMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function buildHeaderView() {
|
protected function buildHeaderView() {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
@ -26,20 +11,20 @@ abstract class PhortuneMerchantProfileController
|
||||||
$header = id(new PHUIHeaderView())
|
$header = id(new PHUIHeaderView())
|
||||||
->setHeader($title)
|
->setHeader($title)
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setPolicyObject($merchant)
|
|
||||||
->setImage($merchant->getProfileImageURI());
|
->setImage($merchant->getProfileImageURI());
|
||||||
|
|
||||||
return $header;
|
return $header;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function buildApplicationCrumbs() {
|
protected function buildApplicationCrumbs() {
|
||||||
$merchant = $this->getMerchant();
|
|
||||||
$id = $merchant->getID();
|
|
||||||
$merchant_uri = $this->getApplicationURI("/merchant/{$id}/");
|
|
||||||
|
|
||||||
$crumbs = parent::buildApplicationCrumbs();
|
$crumbs = parent::buildApplicationCrumbs();
|
||||||
$crumbs->addTextCrumb($merchant->getName(), $merchant_uri);
|
|
||||||
$crumbs->setBorder(true);
|
if ($this->hasMerchant()) {
|
||||||
|
$merchant = $this->getMerchant();
|
||||||
|
$merchant_uri = $merchant->getURI();
|
||||||
|
$crumbs->addTextCrumb($merchant->getName(), $merchant_uri);
|
||||||
|
}
|
||||||
|
|
||||||
return $crumbs;
|
return $crumbs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,31 +43,47 @@ abstract class PhortuneMerchantProfileController
|
||||||
|
|
||||||
$nav->addLabel(pht('Merchant'));
|
$nav->addLabel(pht('Merchant'));
|
||||||
|
|
||||||
$nav->addFilter(
|
$nav->newLink('overview')
|
||||||
'overview',
|
->setName(pht('Overview'))
|
||||||
pht('Overview'),
|
->setHref($merchant->getURI())
|
||||||
$this->getApplicationURI("/merchant/{$id}/"),
|
->setIcon('fa-building-o');
|
||||||
'fa-building-o');
|
|
||||||
|
|
||||||
if ($can_edit) {
|
$nav->newLink('details')
|
||||||
$nav->addFilter(
|
->setName(pht('Account Details'))
|
||||||
'orders',
|
->setHref($merchant->getDetailsURI())
|
||||||
pht('Orders'),
|
->setIcon('fa-address-card-o')
|
||||||
$this->getApplicationURI("merchant/orders/{$id}/"),
|
->setDisabled(!$can_edit)
|
||||||
'fa-retweet');
|
->setWorkflow(!$can_edit);
|
||||||
|
|
||||||
$nav->addFilter(
|
$nav->addLabel(pht('Payments'));
|
||||||
'subscriptions',
|
|
||||||
pht('Subscriptions'),
|
|
||||||
$this->getApplicationURI("merchant/{$id}/subscription/"),
|
|
||||||
'fa-shopping-cart');
|
|
||||||
|
|
||||||
$nav->addFilter(
|
$nav->newLink('providers')
|
||||||
'managers',
|
->setName(pht('Payment Providers'))
|
||||||
pht('Managers'),
|
->setHref($merchant->getPaymentProvidersURI())
|
||||||
$this->getApplicationURI("/merchant/manager/{$id}/"),
|
->setIcon('fa-credit-card')
|
||||||
'fa-group');
|
->setDisabled(!$can_edit)
|
||||||
}
|
->setWorkflow(!$can_edit);
|
||||||
|
|
||||||
|
$nav->newLink('orders')
|
||||||
|
->setName(pht('Orders'))
|
||||||
|
->setHref($merchant->getOrdersURI())
|
||||||
|
->setIcon('fa-shopping-bag')
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow(!$can_edit);
|
||||||
|
|
||||||
|
$nav->newLink('subscriptions')
|
||||||
|
->setName(pht('Subscriptions'))
|
||||||
|
->setHref($merchant->getSubscriptionsURI())
|
||||||
|
->setIcon('fa-retweet')
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow(!$can_edit);
|
||||||
|
|
||||||
|
$nav->addLabel(pht('Personnel'));
|
||||||
|
|
||||||
|
$nav->newLink('managers')
|
||||||
|
->setName(pht('Managers'))
|
||||||
|
->setHref($merchant->getManagersURI())
|
||||||
|
->setIcon('fa-group');
|
||||||
|
|
||||||
$nav->selectFilter($filter);
|
$nav->selectFilter($filter);
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhortuneProviderDisableController
|
final class PhortuneMerchantProviderDisableController
|
||||||
extends PhortuneMerchantController {
|
extends PhortuneMerchantController {
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
protected function shouldRequireMerchantEditCapability() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function handleMerchantRequest(AphrontRequest $request) {
|
||||||
$viewer = $request->getViewer();
|
$viewer = $request->getViewer();
|
||||||
$id = $request->getURIData('id');
|
$merchant = $this->getMerchant();
|
||||||
|
|
||||||
|
$id = $request->getURIData('providerID');
|
||||||
|
|
||||||
$provider_config = id(new PhortunePaymentProviderConfigQuery())
|
$provider_config = id(new PhortunePaymentProviderConfigQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
|
@ -20,9 +26,8 @@ final class PhortuneProviderDisableController
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
$merchant = $provider_config->getMerchant();
|
|
||||||
$merchant_id = $merchant->getID();
|
$merchant_id = $merchant->getID();
|
||||||
$cancel_uri = $this->getApplicationURI("merchant/{$merchant_id}/");
|
$cancel_uri = $provider_config->getURI();
|
||||||
|
|
||||||
$provider = $provider_config->buildProvider();
|
$provider = $provider_config->buildProvider();
|
||||||
|
|
|
@ -1,16 +1,23 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhortuneProviderEditController
|
final class PhortuneMerchantProviderEditController
|
||||||
extends PhortuneMerchantController {
|
extends PhortuneMerchantController {
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
protected function shouldRequireMerchantEditCapability() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function handleMerchantRequest(AphrontRequest $request) {
|
||||||
$viewer = $request->getViewer();
|
$viewer = $request->getViewer();
|
||||||
|
$merchant = $this->getMerchant();
|
||||||
|
|
||||||
$id = $request->getURIData('id');
|
$id = $request->getURIData('id');
|
||||||
|
|
||||||
if ($id) {
|
if ($id) {
|
||||||
$provider_config = id(new PhortunePaymentProviderConfigQuery())
|
$provider_config = id(new PhortunePaymentProviderConfigQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withIDs(array($id))
|
->withIDs(array($id))
|
||||||
|
->withMerchantPHIDs(array($merchant->getPHID()))
|
||||||
->requireCapabilities(
|
->requireCapabilities(
|
||||||
array(
|
array(
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
@ -25,20 +32,8 @@ final class PhortuneProviderEditController
|
||||||
|
|
||||||
$merchant = $provider_config->getMerchant();
|
$merchant = $provider_config->getMerchant();
|
||||||
$merchant_id = $merchant->getID();
|
$merchant_id = $merchant->getID();
|
||||||
$cancel_uri = $this->getApplicationURI("merchant/{$merchant_id}/");
|
$cancel_uri = $provider_config->getURI();
|
||||||
} else {
|
} else {
|
||||||
$merchant = id(new PhortuneMerchantQuery())
|
|
||||||
->setViewer($viewer)
|
|
||||||
->withIDs(array($request->getStr('merchantID')))
|
|
||||||
->requireCapabilities(
|
|
||||||
array(
|
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
|
||||||
PhabricatorPolicyCapability::CAN_EDIT,
|
|
||||||
))
|
|
||||||
->executeOne();
|
|
||||||
if (!$merchant) {
|
|
||||||
return new Aphront404Response();
|
|
||||||
}
|
|
||||||
$merchant_id = $merchant->getID();
|
$merchant_id = $merchant->getID();
|
||||||
|
|
||||||
$current_providers = id(new PhortunePaymentProviderConfigQuery())
|
$current_providers = id(new PhortunePaymentProviderConfigQuery())
|
||||||
|
@ -62,9 +57,7 @@ final class PhortuneProviderEditController
|
||||||
}
|
}
|
||||||
|
|
||||||
$provider_config->setProviderClass($class);
|
$provider_config->setProviderClass($class);
|
||||||
|
$cancel_uri = $merchant->getPaymentProvidersURI();
|
||||||
$cancel_uri = $this->getApplicationURI(
|
|
||||||
'provider/edit/?merchantID='.$merchant_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$provider = $provider_config->buildProvider();
|
$provider = $provider_config->buildProvider();
|
||||||
|
@ -123,10 +116,12 @@ final class PhortuneProviderEditController
|
||||||
|
|
||||||
$xactions = array();
|
$xactions = array();
|
||||||
|
|
||||||
$xactions[] = id(new PhortunePaymentProviderConfigTransaction())
|
if (!$provider_config->getID()) {
|
||||||
->setTransactionType(
|
$xactions[] = id(new PhortunePaymentProviderConfigTransaction())
|
||||||
PhortunePaymentProviderConfigTransaction::TYPE_CREATE)
|
->setTransactionType(
|
||||||
->setNewValue(true);
|
PhortunePaymentProviderConfigTransaction::TYPE_CREATE)
|
||||||
|
->setNewValue(true);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($xaction_values as $key => $value) {
|
foreach ($xaction_values as $key => $value) {
|
||||||
$xactions[] = id(clone $template)
|
$xactions[] = id(clone $template)
|
||||||
|
@ -143,9 +138,9 @@ final class PhortuneProviderEditController
|
||||||
|
|
||||||
$editor->applyTransactions($provider_config, $xactions);
|
$editor->applyTransactions($provider_config, $xactions);
|
||||||
|
|
||||||
$merchant_uri = $this->getApplicationURI(
|
$next_uri = $provider_config->getURI();
|
||||||
'merchant/'.$merchant->getID().'/');
|
|
||||||
return id(new AphrontRedirectResponse())->setURI($merchant_uri);
|
return id(new AphrontRedirectResponse())->setURI($next_uri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -155,7 +150,6 @@ final class PhortuneProviderEditController
|
||||||
|
|
||||||
$form = id(new AphrontFormView())
|
$form = id(new AphrontFormView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->addHiddenInput('merchantID', $merchant->getID())
|
|
||||||
->addHiddenInput('class', $provider_config->getProviderClass())
|
->addHiddenInput('class', $provider_config->getProviderClass())
|
||||||
->addHiddenInput('edit', true)
|
->addHiddenInput('edit', true)
|
||||||
->appendChild(
|
->appendChild(
|
||||||
|
@ -261,7 +255,6 @@ final class PhortuneProviderEditController
|
||||||
|
|
||||||
$form = id(new AphrontFormView())
|
$form = id(new AphrontFormView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->addHiddenInput('merchantID', $merchant->getID())
|
|
||||||
->appendRemarkupInstructions(
|
->appendRemarkupInstructions(
|
||||||
pht('Choose the type of payment provider to add:'))
|
pht('Choose the type of payment provider to add:'))
|
||||||
->appendChild($panel_classes)
|
->appendChild($panel_classes)
|
|
@ -0,0 +1,127 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhortuneMerchantProviderViewController
|
||||||
|
extends PhortuneMerchantController {
|
||||||
|
|
||||||
|
protected function shouldRequireMerchantEditCapability() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function handleMerchantRequest(AphrontRequest $request) {
|
||||||
|
$viewer = $request->getViewer();
|
||||||
|
$merchant = $this->getMerchant();
|
||||||
|
|
||||||
|
$provider = id(new PhortunePaymentProviderConfigQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withIDs(array($request->getURIData('providerID')))
|
||||||
|
->executeOne();
|
||||||
|
if (!$provider) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
$provider_type = $provider->buildProvider();
|
||||||
|
|
||||||
|
$crumbs = $this->buildApplicationCrumbs()
|
||||||
|
->addTextCrumb($merchant->getName(), $merchant->getURI())
|
||||||
|
->addTextCrumb(
|
||||||
|
pht('Payment Providers'),
|
||||||
|
$merchant->getPaymentProvidersURI())
|
||||||
|
->addTextCrumb($provider->getObjectName())
|
||||||
|
->setBorder(true);
|
||||||
|
|
||||||
|
$header = id(new PHUIHeaderView())
|
||||||
|
->setHeader(pht('Payment Provider: %s', $provider_type->getName()));
|
||||||
|
|
||||||
|
$details = $this->newDetailsView($provider);
|
||||||
|
|
||||||
|
$timeline = $this->buildTransactionTimeline(
|
||||||
|
$provider,
|
||||||
|
new PhortunePaymentProviderConfigTransactionQuery());
|
||||||
|
$timeline->setShouldTerminate(true);
|
||||||
|
|
||||||
|
$curtain = $this->buildCurtainView($provider);
|
||||||
|
|
||||||
|
$view = id(new PHUITwoColumnView())
|
||||||
|
->setHeader($header)
|
||||||
|
->setCurtain($curtain)
|
||||||
|
->setMainColumn(
|
||||||
|
array(
|
||||||
|
$details,
|
||||||
|
$timeline,
|
||||||
|
));
|
||||||
|
|
||||||
|
return $this->newPage()
|
||||||
|
->setTitle($provider->getObjectName())
|
||||||
|
->setCrumbs($crumbs)
|
||||||
|
->appendChild($view);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildCurtainView(PhortunePaymentProviderConfig $provider) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
$merchant = $this->getMerchant();
|
||||||
|
|
||||||
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||||
|
$viewer,
|
||||||
|
$provider,
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT);
|
||||||
|
|
||||||
|
$edit_uri = $this->getApplicationURI(
|
||||||
|
urisprintf(
|
||||||
|
'merchant/%d/providers/edit/%d/',
|
||||||
|
$merchant->getID(),
|
||||||
|
$provider->getID()));
|
||||||
|
|
||||||
|
$disable_uri = $this->getApplicationURI(
|
||||||
|
urisprintf(
|
||||||
|
'merchant/%d/providers/%d/disable/',
|
||||||
|
$merchant->getID(),
|
||||||
|
$provider->getID()));
|
||||||
|
|
||||||
|
$curtain = $this->newCurtainView($provider);
|
||||||
|
|
||||||
|
$curtain->addAction(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setName(pht('Edit Provider'))
|
||||||
|
->setIcon('fa-pencil')
|
||||||
|
->setHref($edit_uri)
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow(!$can_edit));
|
||||||
|
|
||||||
|
$provider_type = $provider->buildProvider();
|
||||||
|
|
||||||
|
if ($provider_type->isEnabled()) {
|
||||||
|
$disable_icon = 'fa-times';
|
||||||
|
$disable_name = pht('Disable Provider');
|
||||||
|
} else {
|
||||||
|
$disable_icon = 'fa-check';
|
||||||
|
$disable_name = pht('Enable Provider');
|
||||||
|
}
|
||||||
|
|
||||||
|
$curtain->addAction(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setName($disable_name)
|
||||||
|
->setIcon($disable_icon)
|
||||||
|
->setHref($disable_uri)
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow(true));
|
||||||
|
|
||||||
|
return $curtain;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function newDetailsView(PhortunePaymentProviderConfig $provider) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$view = id(new PHUIPropertyListView())
|
||||||
|
->setUser($viewer);
|
||||||
|
|
||||||
|
$provider_type = $provider->buildProvider();
|
||||||
|
|
||||||
|
$view->addProperty(pht('Provider Type'), $provider_type->getName());
|
||||||
|
|
||||||
|
return id(new PHUIObjectBoxView())
|
||||||
|
->setHeaderText(pht('Payment Provider Details'))
|
||||||
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
||||||
|
->addPropertyList($view);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,116 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhortuneMerchantProvidersController
|
||||||
|
extends PhortuneMerchantProfileController {
|
||||||
|
|
||||||
|
protected function shouldRequireMerchantEditCapability() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function handleMerchantRequest(AphrontRequest $request) {
|
||||||
|
$viewer = $request->getViewer();
|
||||||
|
$merchant = $this->getMerchant();
|
||||||
|
|
||||||
|
$crumbs = $this->buildApplicationCrumbs()
|
||||||
|
->addTextCrumb(pht('Payment Providers'))
|
||||||
|
->setBorder(true);
|
||||||
|
|
||||||
|
$header = $this->buildHeaderView();
|
||||||
|
|
||||||
|
$title = pht(
|
||||||
|
'%s %s',
|
||||||
|
$merchant->getObjectName(),
|
||||||
|
$merchant->getName());
|
||||||
|
|
||||||
|
$providers = id(new PhortunePaymentProviderConfigQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withMerchantPHIDs(array($merchant->getPHID()))
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$provider_list = $this->buildProviderList(
|
||||||
|
$merchant,
|
||||||
|
$providers);
|
||||||
|
|
||||||
|
$navigation = $this->buildSideNavView('providers');
|
||||||
|
|
||||||
|
$view = id(new PHUITwoColumnView())
|
||||||
|
->setHeader($header)
|
||||||
|
->setFooter(
|
||||||
|
array(
|
||||||
|
$provider_list,
|
||||||
|
));
|
||||||
|
|
||||||
|
return $this->newPage()
|
||||||
|
->setTitle($title)
|
||||||
|
->setCrumbs($crumbs)
|
||||||
|
->setNavigation($navigation)
|
||||||
|
->appendChild($view);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildProviderList(
|
||||||
|
PhortuneMerchant $merchant,
|
||||||
|
array $providers) {
|
||||||
|
|
||||||
|
$viewer = $this->getRequest()->getUser();
|
||||||
|
$id = $merchant->getID();
|
||||||
|
|
||||||
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||||
|
$viewer,
|
||||||
|
$merchant,
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT);
|
||||||
|
|
||||||
|
$provider_list = id(new PHUIObjectItemListView())
|
||||||
|
->setNoDataString(pht('This merchant has no payment providers.'));
|
||||||
|
|
||||||
|
foreach ($providers as $provider_config) {
|
||||||
|
$provider = $provider_config->buildProvider();
|
||||||
|
$provider_id = $provider_config->getID();
|
||||||
|
|
||||||
|
$item = id(new PHUIObjectItemView())
|
||||||
|
->setObjectName($provider_config->getObjectName())
|
||||||
|
->setHeader($provider->getName())
|
||||||
|
->setHref($provider_config->getURI());
|
||||||
|
|
||||||
|
if ($provider->isEnabled()) {
|
||||||
|
if ($provider->isAcceptingLivePayments()) {
|
||||||
|
$item->setStatusIcon('fa-check green');
|
||||||
|
} else {
|
||||||
|
$item->setStatusIcon('fa-warning yellow');
|
||||||
|
$item->addIcon('fa-exclamation-triangle', pht('Test Mode'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$item->addAttribute($provider->getConfigureProvidesDescription());
|
||||||
|
} else {
|
||||||
|
$item->setDisabled(true);
|
||||||
|
$item->addAttribute(
|
||||||
|
phutil_tag('em', array(), pht('This payment provider is disabled.')));
|
||||||
|
}
|
||||||
|
|
||||||
|
$provider_list->addItem($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
$add_uri = urisprintf(
|
||||||
|
'merchant/%d/providers/edit/',
|
||||||
|
$merchant->getID());
|
||||||
|
$add_uri = $this->getApplicationURI($add_uri);
|
||||||
|
|
||||||
|
$add_action = id(new PHUIButtonView())
|
||||||
|
->setTag('a')
|
||||||
|
->setHref($add_uri)
|
||||||
|
->setText(pht('Add Payment Provider'))
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow(!$can_edit)
|
||||||
|
->setIcon('fa-plus');
|
||||||
|
|
||||||
|
$header = id(new PHUIHeaderView())
|
||||||
|
->setHeader(pht('Payment Providers'))
|
||||||
|
->addActionLink($add_action);
|
||||||
|
|
||||||
|
return id(new PHUIObjectBoxView())
|
||||||
|
->setHeader($header)
|
||||||
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
||||||
|
->setObjectList($provider_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhortuneMerchantSubscriptionListController
|
||||||
|
extends PhortuneMerchantProfileController {
|
||||||
|
|
||||||
|
protected function shouldRequireMerchantEditCapability() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function handleMerchantRequest(AphrontRequest $request) {
|
||||||
|
$viewer = $request->getViewer();
|
||||||
|
$merchant = $this->getMerchant();
|
||||||
|
|
||||||
|
$engine = id(new PhortuneCartSearchEngine())
|
||||||
|
->setController($this)
|
||||||
|
->setMerchant($merchant);
|
||||||
|
|
||||||
|
$subscription_id = $request->getURIData('subscriptionID');
|
||||||
|
if ($subscription_id) {
|
||||||
|
$subscription = id(new PhortuneSubscriptionQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withIDs(array($subscription_id))
|
||||||
|
->executeOne();
|
||||||
|
if (!$subscription) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
$engine->setSubscription($subscription);
|
||||||
|
$this->subscription = $subscription;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $engine->buildResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildApplicationCrumbs() {
|
||||||
|
$crumbs = parent::buildApplicationCrumbs();
|
||||||
|
|
||||||
|
if ($this->hasMerchant()) {
|
||||||
|
$merchant = $this->getMerchant();
|
||||||
|
|
||||||
|
$crumbs->addTextCrumb(
|
||||||
|
pht('Subscriptions'),
|
||||||
|
$merchant->getSubscriptionsURI());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $crumbs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhortuneMerchantSubscriptionsController
|
||||||
|
extends PhortuneMerchantProfileController {
|
||||||
|
|
||||||
|
protected function shouldRequireMerchantEditCapability() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function handleMerchantRequest(AphrontRequest $request) {
|
||||||
|
$merchant = $this->getMerchant();
|
||||||
|
$title = $merchant->getName();
|
||||||
|
|
||||||
|
$crumbs = $this->buildApplicationCrumbs()
|
||||||
|
->addTextCrumb(pht('Subscriptions'))
|
||||||
|
->setBorder(true);
|
||||||
|
|
||||||
|
$header = $this->buildHeaderView();
|
||||||
|
|
||||||
|
$subscriptions = $this->buildSubscriptionsSection($merchant);
|
||||||
|
|
||||||
|
$view = id(new PHUITwoColumnView())
|
||||||
|
->setHeader($header)
|
||||||
|
->setFooter(
|
||||||
|
array(
|
||||||
|
$subscriptions,
|
||||||
|
));
|
||||||
|
|
||||||
|
$navigation = $this->buildSideNavView('subscriptions');
|
||||||
|
|
||||||
|
return $this->newPage()
|
||||||
|
->setTitle($title)
|
||||||
|
->setCrumbs($crumbs)
|
||||||
|
->setNavigation($navigation)
|
||||||
|
->appendChild($view);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildSubscriptionsSection(PhortuneMerchant $merchant) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$subscriptions = id(new PhortuneSubscriptionQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withMerchantPHIDs(array($merchant->getPHID()))
|
||||||
|
->setLimit(25)
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$subscriptions_uri = $merchant->getSubscriptionListURI();
|
||||||
|
|
||||||
|
$table = id(new PhortuneSubscriptionTableView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setSubscriptions($subscriptions);
|
||||||
|
|
||||||
|
$header = id(new PHUIHeaderView())
|
||||||
|
->setHeader(pht('Subscriptions'))
|
||||||
|
->addActionLink(
|
||||||
|
id(new PHUIButtonView())
|
||||||
|
->setTag('a')
|
||||||
|
->setIcon('fa-list')
|
||||||
|
->setHref($subscriptions_uri)
|
||||||
|
->setText(pht('View All Subscriptions')));
|
||||||
|
|
||||||
|
return id(new PHUIObjectBoxView())
|
||||||
|
->setHeader($header)
|
||||||
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
||||||
|
->setTable($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,324 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class PhortuneMerchantViewController
|
|
||||||
extends PhortuneMerchantProfileController {
|
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
|
||||||
$viewer = $request->getViewer();
|
|
||||||
$id = $request->getURIData('id');
|
|
||||||
|
|
||||||
$merchant = id(new PhortuneMerchantQuery())
|
|
||||||
->setViewer($viewer)
|
|
||||||
->withIDs(array($id))
|
|
||||||
->needProfileImage(true)
|
|
||||||
->executeOne();
|
|
||||||
if (!$merchant) {
|
|
||||||
return new Aphront404Response();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->setMerchant($merchant);
|
|
||||||
$crumbs = $this->buildApplicationCrumbs();
|
|
||||||
$header = $this->buildHeaderView();
|
|
||||||
|
|
||||||
$title = pht(
|
|
||||||
'Merchant %d %s',
|
|
||||||
$merchant->getID(),
|
|
||||||
$merchant->getName());
|
|
||||||
|
|
||||||
$providers = id(new PhortunePaymentProviderConfigQuery())
|
|
||||||
->setViewer($viewer)
|
|
||||||
->withMerchantPHIDs(array($merchant->getPHID()))
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
$details = $this->buildDetailsView($merchant, $providers);
|
|
||||||
$curtain = $this->buildCurtainView($merchant);
|
|
||||||
|
|
||||||
$provider_list = $this->buildProviderList(
|
|
||||||
$merchant,
|
|
||||||
$providers);
|
|
||||||
|
|
||||||
$timeline = $this->buildTransactionTimeline(
|
|
||||||
$merchant,
|
|
||||||
new PhortuneMerchantTransactionQuery());
|
|
||||||
$timeline->setShouldTerminate(true);
|
|
||||||
|
|
||||||
$navigation = $this->buildSideNavView('overview');
|
|
||||||
|
|
||||||
$view = id(new PHUITwoColumnView())
|
|
||||||
->setHeader($header)
|
|
||||||
->setCurtain($curtain)
|
|
||||||
->setMainColumn(array(
|
|
||||||
$details,
|
|
||||||
$provider_list,
|
|
||||||
$timeline,
|
|
||||||
));
|
|
||||||
|
|
||||||
return $this->newPage()
|
|
||||||
->setTitle($title)
|
|
||||||
->setCrumbs($crumbs)
|
|
||||||
->setNavigation($navigation)
|
|
||||||
->appendChild($view);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function buildDetailsView(
|
|
||||||
PhortuneMerchant $merchant,
|
|
||||||
array $providers) {
|
|
||||||
|
|
||||||
$viewer = $this->getRequest()->getUser();
|
|
||||||
|
|
||||||
$view = id(new PHUIPropertyListView())
|
|
||||||
->setUser($viewer)
|
|
||||||
->setObject($merchant);
|
|
||||||
|
|
||||||
$status_view = new PHUIStatusListView();
|
|
||||||
|
|
||||||
$have_any = false;
|
|
||||||
$any_test = false;
|
|
||||||
foreach ($providers as $provider_config) {
|
|
||||||
$provider = $provider_config->buildProvider();
|
|
||||||
if ($provider->isEnabled()) {
|
|
||||||
$have_any = true;
|
|
||||||
}
|
|
||||||
if (!$provider->isAcceptingLivePayments()) {
|
|
||||||
$any_test = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($have_any) {
|
|
||||||
$status_view->addItem(
|
|
||||||
id(new PHUIStatusItemView())
|
|
||||||
->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')
|
|
||||||
->setTarget(pht('Accepts Payments'))
|
|
||||||
->setNote(pht('This merchant can accept payments.')));
|
|
||||||
|
|
||||||
if ($any_test) {
|
|
||||||
$status_view->addItem(
|
|
||||||
id(new PHUIStatusItemView())
|
|
||||||
->setIcon(PHUIStatusItemView::ICON_WARNING, 'yellow')
|
|
||||||
->setTarget(pht('Test Mode'))
|
|
||||||
->setNote(pht('This merchant is accepting test payments.')));
|
|
||||||
} else {
|
|
||||||
$status_view->addItem(
|
|
||||||
id(new PHUIStatusItemView())
|
|
||||||
->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')
|
|
||||||
->setTarget(pht('Live Mode'))
|
|
||||||
->setNote(pht('This merchant is accepting live payments.')));
|
|
||||||
}
|
|
||||||
} else if ($providers) {
|
|
||||||
$status_view->addItem(
|
|
||||||
id(new PHUIStatusItemView())
|
|
||||||
->setIcon(PHUIStatusItemView::ICON_REJECT, 'red')
|
|
||||||
->setTarget(pht('No Enabled Providers'))
|
|
||||||
->setNote(
|
|
||||||
pht(
|
|
||||||
'All of the payment providers for this merchant are '.
|
|
||||||
'disabled.')));
|
|
||||||
} else {
|
|
||||||
$status_view->addItem(
|
|
||||||
id(new PHUIStatusItemView())
|
|
||||||
->setIcon(PHUIStatusItemView::ICON_WARNING, 'yellow')
|
|
||||||
->setTarget(pht('No Providers'))
|
|
||||||
->setNote(
|
|
||||||
pht(
|
|
||||||
'This merchant does not have any payment providers configured '.
|
|
||||||
'yet, so it can not accept payments. Add a provider.')));
|
|
||||||
}
|
|
||||||
|
|
||||||
$view->addProperty(pht('Status'), $status_view);
|
|
||||||
|
|
||||||
$invoice_from = $merchant->getInvoiceEmail();
|
|
||||||
if (!$invoice_from) {
|
|
||||||
$invoice_from = pht('No email address set');
|
|
||||||
$invoice_from = phutil_tag('em', array(), $invoice_from);
|
|
||||||
}
|
|
||||||
$view->addProperty(pht('Invoice From'), $invoice_from);
|
|
||||||
|
|
||||||
$description = $merchant->getDescription();
|
|
||||||
if (strlen($description)) {
|
|
||||||
$description = new PHUIRemarkupView($viewer, $description);
|
|
||||||
$view->addSectionHeader(
|
|
||||||
pht('Description'),
|
|
||||||
PHUIPropertyListView::ICON_SUMMARY);
|
|
||||||
$view->addTextContent($description);
|
|
||||||
}
|
|
||||||
|
|
||||||
$contact_info = $merchant->getContactInfo();
|
|
||||||
if (strlen($contact_info)) {
|
|
||||||
$contact_info = new PHUIRemarkupView($viewer, $contact_info);
|
|
||||||
$view->addSectionHeader(
|
|
||||||
pht('Contact Info'),
|
|
||||||
PHUIPropertyListView::ICON_SUMMARY);
|
|
||||||
$view->addTextContent($contact_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
$footer_info = $merchant->getInvoiceFooter();
|
|
||||||
if (strlen($footer_info)) {
|
|
||||||
$footer_info = new PHUIRemarkupView($viewer, $footer_info);
|
|
||||||
$view->addSectionHeader(
|
|
||||||
pht('Invoice Footer'),
|
|
||||||
PHUIPropertyListView::ICON_SUMMARY);
|
|
||||||
$view->addTextContent($footer_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
return id(new PHUIObjectBoxView())
|
|
||||||
->setHeaderText(pht('Details'))
|
|
||||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
|
||||||
->appendChild($view);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function buildCurtainView(PhortuneMerchant $merchant) {
|
|
||||||
$viewer = $this->getRequest()->getUser();
|
|
||||||
$id = $merchant->getID();
|
|
||||||
|
|
||||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
||||||
$viewer,
|
|
||||||
$merchant,
|
|
||||||
PhabricatorPolicyCapability::CAN_EDIT);
|
|
||||||
|
|
||||||
$curtain = $this->newCurtainView($merchant);
|
|
||||||
|
|
||||||
$curtain->addAction(
|
|
||||||
id(new PhabricatorActionView())
|
|
||||||
->setName(pht('Edit Merchant'))
|
|
||||||
->setIcon('fa-pencil')
|
|
||||||
->setDisabled(!$can_edit)
|
|
||||||
->setWorkflow(!$can_edit)
|
|
||||||
->setHref($this->getApplicationURI("merchant/edit/{$id}/")));
|
|
||||||
|
|
||||||
$curtain->addAction(
|
|
||||||
id(new PhabricatorActionView())
|
|
||||||
->setName(pht('Edit Logo'))
|
|
||||||
->setIcon('fa-camera')
|
|
||||||
->setDisabled(!$can_edit)
|
|
||||||
->setWorkflow(!$can_edit)
|
|
||||||
->setHref($this->getApplicationURI("merchant/picture/{$id}/")));
|
|
||||||
|
|
||||||
$curtain->addAction(
|
|
||||||
id(new PhabricatorActionView())
|
|
||||||
->setName(pht('New Invoice'))
|
|
||||||
->setIcon('fa-fax')
|
|
||||||
->setHref($this->getApplicationURI("merchant/{$id}/invoice/new/"))
|
|
||||||
->setDisabled(!$can_edit)
|
|
||||||
->setWorkflow(!$can_edit));
|
|
||||||
|
|
||||||
$member_phids = $merchant->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 buildProviderList(
|
|
||||||
PhortuneMerchant $merchant,
|
|
||||||
array $providers) {
|
|
||||||
|
|
||||||
$viewer = $this->getRequest()->getUser();
|
|
||||||
$id = $merchant->getID();
|
|
||||||
|
|
||||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
||||||
$viewer,
|
|
||||||
$merchant,
|
|
||||||
PhabricatorPolicyCapability::CAN_EDIT);
|
|
||||||
|
|
||||||
$provider_list = id(new PHUIObjectItemListView())
|
|
||||||
->setFlush(true)
|
|
||||||
->setNoDataString(pht('This merchant has no payment providers.'));
|
|
||||||
|
|
||||||
foreach ($providers as $provider_config) {
|
|
||||||
$provider = $provider_config->buildProvider();
|
|
||||||
$provider_id = $provider_config->getID();
|
|
||||||
|
|
||||||
$item = id(new PHUIObjectItemView())
|
|
||||||
->setHeader($provider->getName());
|
|
||||||
|
|
||||||
if ($provider->isEnabled()) {
|
|
||||||
if ($provider->isAcceptingLivePayments()) {
|
|
||||||
$item->setStatusIcon('fa-check green');
|
|
||||||
} else {
|
|
||||||
$item->setStatusIcon('fa-warning yellow');
|
|
||||||
$item->addIcon('fa-exclamation-triangle', pht('Test Mode'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$item->addAttribute($provider->getConfigureProvidesDescription());
|
|
||||||
} else {
|
|
||||||
// Don't show disabled providers to users who can't manage the merchant
|
|
||||||
// account.
|
|
||||||
if (!$can_edit) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$item->setDisabled(true);
|
|
||||||
$item->addAttribute(
|
|
||||||
phutil_tag('em', array(), pht('This payment provider is disabled.')));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ($can_edit) {
|
|
||||||
$edit_uri = $this->getApplicationURI(
|
|
||||||
"/provider/edit/{$provider_id}/");
|
|
||||||
$disable_uri = $this->getApplicationURI(
|
|
||||||
"/provider/disable/{$provider_id}/");
|
|
||||||
|
|
||||||
if ($provider->isEnabled()) {
|
|
||||||
$disable_icon = 'fa-times';
|
|
||||||
$disable_name = pht('Disable');
|
|
||||||
} else {
|
|
||||||
$disable_icon = 'fa-check';
|
|
||||||
$disable_name = pht('Enable');
|
|
||||||
}
|
|
||||||
|
|
||||||
$item->addAction(
|
|
||||||
id(new PHUIListItemView())
|
|
||||||
->setIcon($disable_icon)
|
|
||||||
->setHref($disable_uri)
|
|
||||||
->setName($disable_name)
|
|
||||||
->setWorkflow(true));
|
|
||||||
|
|
||||||
$item->addAction(
|
|
||||||
id(new PHUIListItemView())
|
|
||||||
->setIcon('fa-pencil')
|
|
||||||
->setHref($edit_uri)
|
|
||||||
->setName(pht('Edit')));
|
|
||||||
}
|
|
||||||
|
|
||||||
$provider_list->addItem($item);
|
|
||||||
}
|
|
||||||
|
|
||||||
$add_action = id(new PHUIButtonView())
|
|
||||||
->setTag('a')
|
|
||||||
->setHref($this->getApplicationURI('provider/edit/?merchantID='.$id))
|
|
||||||
->setText(pht('Add Payment Provider'))
|
|
||||||
->setDisabled(!$can_edit)
|
|
||||||
->setWorkflow(!$can_edit)
|
|
||||||
->setIcon('fa-plus');
|
|
||||||
|
|
||||||
$header = id(new PHUIHeaderView())
|
|
||||||
->setHeader(pht('Payment Providers'))
|
|
||||||
->addActionLink($add_action);
|
|
||||||
|
|
||||||
return id(new PHUIObjectBoxView())
|
|
||||||
->setHeader($header)
|
|
||||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
|
||||||
->setObjectList($provider_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -58,7 +58,7 @@ final class PhortuneMerchantEditEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getObjectViewURI($object) {
|
protected function getObjectViewURI($object) {
|
||||||
return $object->getURI();
|
return $object->getDetailsURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isEngineConfigurable() {
|
public function isEngineConfigurable() {
|
||||||
|
|
|
@ -18,7 +18,6 @@ final class PhortuneMerchantEditor
|
||||||
public function getTransactionTypes() {
|
public function getTransactionTypes() {
|
||||||
$types = parent::getTransactionTypes();
|
$types = parent::getTransactionTypes();
|
||||||
|
|
||||||
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
|
||||||
$types[] = PhabricatorTransactions::TYPE_EDGE;
|
$types[] = PhabricatorTransactions::TYPE_EDGE;
|
||||||
|
|
||||||
return $types;
|
return $types;
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class PhortuneTestPaymentProvider extends PhortunePaymentProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getConfigureInstructions() {
|
public function getConfigureInstructions() {
|
||||||
return pht('This providers does not require any special configuration.');
|
return pht('This provider does not require any special configuration.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canRunConfigurationTest() {
|
public function canRunConfigurationTest() {
|
||||||
|
|
|
@ -6,7 +6,6 @@ final class PhortuneMerchant extends PhortuneDAO
|
||||||
PhabricatorPolicyInterface {
|
PhabricatorPolicyInterface {
|
||||||
|
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $viewPolicy;
|
|
||||||
protected $description;
|
protected $description;
|
||||||
protected $contactInfo;
|
protected $contactInfo;
|
||||||
protected $invoiceEmail;
|
protected $invoiceEmail;
|
||||||
|
@ -18,7 +17,6 @@ final class PhortuneMerchant extends PhortuneDAO
|
||||||
|
|
||||||
public static function initializeNewMerchant(PhabricatorUser $actor) {
|
public static function initializeNewMerchant(PhabricatorUser $actor) {
|
||||||
return id(new PhortuneMerchant())
|
return id(new PhortuneMerchant())
|
||||||
->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy())
|
|
||||||
->attachMemberPHIDs(array())
|
->attachMemberPHIDs(array())
|
||||||
->setContactInfo('')
|
->setContactInfo('')
|
||||||
->setInvoiceEmail('')
|
->setInvoiceEmail('')
|
||||||
|
@ -74,6 +72,49 @@ final class PhortuneMerchant extends PhortuneDAO
|
||||||
return pht('Merchant %d', $this->getID());
|
return pht('Merchant %d', $this->getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDetailsURI() {
|
||||||
|
return urisprintf(
|
||||||
|
'/phortune/merchant/%d/details/',
|
||||||
|
$this->getID());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOrdersURI() {
|
||||||
|
return urisprintf(
|
||||||
|
'/phortune/merchant/%d/orders/',
|
||||||
|
$this->getID());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOrderListURI($path = '') {
|
||||||
|
return urisprintf(
|
||||||
|
'/phortune/merchant/%d/orders/list/%s',
|
||||||
|
$this->getID(),
|
||||||
|
$path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSubscriptionsURI() {
|
||||||
|
return urisprintf(
|
||||||
|
'/phortune/merchant/%d/subscriptions/',
|
||||||
|
$this->getID());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSubscriptionListURI($path = '') {
|
||||||
|
return urisprintf(
|
||||||
|
'/phortune/merchant/%d/subscriptions/list/%s',
|
||||||
|
$this->getID(),
|
||||||
|
$path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getManagersURI() {
|
||||||
|
return urisprintf(
|
||||||
|
'/phortune/merchant/%d/managers/',
|
||||||
|
$this->getID());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPaymentProvidersURI() {
|
||||||
|
return urisprintf(
|
||||||
|
'/phortune/merchant/%d/providers/',
|
||||||
|
$this->getID());
|
||||||
|
}
|
||||||
|
|
||||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
|
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
|
||||||
|
|
||||||
|
@ -100,7 +141,7 @@ final class PhortuneMerchant extends PhortuneDAO
|
||||||
public function getPolicy($capability) {
|
public function getPolicy($capability) {
|
||||||
switch ($capability) {
|
switch ($capability) {
|
||||||
case PhabricatorPolicyCapability::CAN_VIEW:
|
case PhabricatorPolicyCapability::CAN_VIEW:
|
||||||
return $this->getViewPolicy();
|
return PhabricatorPolicies::getMostOpenPolicy();
|
||||||
case PhabricatorPolicyCapability::CAN_EDIT:
|
case PhabricatorPolicyCapability::CAN_EDIT:
|
||||||
return PhabricatorPolicies::POLICY_NOONE;
|
return PhabricatorPolicies::POLICY_NOONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ final class PhortunePaymentProviderConfig extends PhortuneDAO
|
||||||
PhortuneMerchant $merchant) {
|
PhortuneMerchant $merchant) {
|
||||||
return id(new PhortunePaymentProviderConfig())
|
return id(new PhortunePaymentProviderConfig())
|
||||||
->setMerchantPHID($merchant->getPHID())
|
->setMerchantPHID($merchant->getPHID())
|
||||||
|
->attachMerchant($merchant)
|
||||||
->setIsEnabled(1);
|
->setIsEnabled(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +76,17 @@ final class PhortunePaymentProviderConfig extends PhortuneDAO
|
||||||
->setProviderConfig($this);
|
->setProviderConfig($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getObjectName() {
|
||||||
|
return pht('Provider %d', $this->getID());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getURI() {
|
||||||
|
return urisprintf(
|
||||||
|
'/phortune/merchant/%d/providers/%d/',
|
||||||
|
$this->getMerchant()->getID(),
|
||||||
|
$this->getID());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||||
|
|
||||||
|
|
|
@ -3,20 +3,10 @@
|
||||||
final class PhortuneOrderTableView extends AphrontView {
|
final class PhortuneOrderTableView extends AphrontView {
|
||||||
|
|
||||||
private $carts;
|
private $carts;
|
||||||
private $handles;
|
|
||||||
private $noDataString;
|
private $noDataString;
|
||||||
private $isInvoices;
|
private $isInvoices;
|
||||||
private $isMerchantView;
|
private $isMerchantView;
|
||||||
|
|
||||||
public function setHandles(array $handles) {
|
|
||||||
$this->handles = $handles;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHandles() {
|
|
||||||
return $this->handles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCarts(array $carts) {
|
public function setCarts(array $carts) {
|
||||||
$this->carts = $carts;
|
$this->carts = $carts;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -55,12 +45,22 @@ final class PhortuneOrderTableView extends AphrontView {
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
$carts = $this->getCarts();
|
$carts = $this->getCarts();
|
||||||
$handles = $this->getHandles();
|
|
||||||
$viewer = $this->getUser();
|
$viewer = $this->getUser();
|
||||||
|
|
||||||
$is_invoices = $this->getIsInvoices();
|
$is_invoices = $this->getIsInvoices();
|
||||||
$is_merchant = $this->getIsMerchantView();
|
$is_merchant = $this->getIsMerchantView();
|
||||||
|
|
||||||
|
$phids = array();
|
||||||
|
foreach ($carts as $cart) {
|
||||||
|
$phids[] = $cart->getPHID();
|
||||||
|
foreach ($cart->getPurchases() as $purchase) {
|
||||||
|
$phids[] = $purchase->getPHID();
|
||||||
|
}
|
||||||
|
$phids[] = $cart->getMerchantPHID();
|
||||||
|
}
|
||||||
|
|
||||||
|
$handles = $viewer->loadHandles($phids);
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
$rowc = array();
|
$rowc = array();
|
||||||
foreach ($carts as $cart) {
|
foreach ($carts as $cart) {
|
||||||
|
|
Loading…
Reference in a new issue