Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / phortune / controller / external / PhortuneExternalOverviewController.php
blob5db74ac75e82b40857789e4d2d53bc6b093ca075
1 <?php
3 final class PhortuneExternalOverviewController
4 extends PhortuneExternalController {
6 protected function handleExternalRequest(AphrontRequest $request) {
7 $xviewer = $this->getExternalViewer();
8 $email = $this->getAccountEmail();
9 $account = $email->getAccount();
11 $crumbs = $this->newExternalCrumbs()
12 ->addTextCrumb(pht('Viewing As "%s"', $email->getAddress()))
13 ->setBorder(true);
15 $header = id(new PHUIHeaderView())
16 ->setHeader(pht('Invoices and Receipts: %s', $account->getName()))
17 ->addActionLink(
18 id(new PHUIButtonView())
19 ->setTag('a')
20 ->setIcon('fa-times')
21 ->setText(pht('Unsubscribe'))
22 ->setHref($email->getUnsubscribeURI())
23 ->setWorkflow(true));
25 $external_view = $this->newExternalView();
26 $invoices_view = $this->newInvoicesView();
27 $receipts_view = $this->newReceiptsView();
29 $column_view = id(new PHUITwoColumnView())
30 ->setHeader($header)
31 ->setFooter(
32 array(
33 $external_view,
34 $invoices_view,
35 $receipts_view,
36 ));
38 return $this->newPage()
39 ->setCrumbs($crumbs)
40 ->setTitle(
41 array(
42 pht('Invoices and Receipts'),
43 $account->getName(),
45 ->appendChild($column_view);
48 private function newInvoicesView() {
49 $xviewer = $this->getExternalViewer();
50 $email = $this->getAccountEmail();
51 $account = $email->getAccount();
53 $invoices = id(new PhortuneCartQuery())
54 ->setViewer($xviewer)
55 ->withAccountPHIDs(array($account->getPHID()))
56 ->needPurchases(true)
57 ->withInvoices(true)
58 ->execute();
60 $header = id(new PHUIHeaderView())
61 ->setHeader(pht('Invoices'));
63 $invoices_table = id(new PhortuneOrderTableView())
64 ->setViewer($xviewer)
65 ->setAccountEmail($email)
66 ->setCarts($invoices)
67 ->setIsInvoices(true);
69 return id(new PHUIObjectBoxView())
70 ->setHeader($header)
71 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
72 ->setTable($invoices_table);
75 private function newReceiptsView() {
76 $xviewer = $this->getExternalViewer();
77 $email = $this->getAccountEmail();
78 $account = $email->getAccount();
80 $receipts = id(new PhortuneCartQuery())
81 ->setViewer($xviewer)
82 ->withAccountPHIDs(array($account->getPHID()))
83 ->needPurchases(true)
84 ->withInvoices(false)
85 ->execute();
87 $header = id(new PHUIHeaderView())
88 ->setHeader(pht('Receipts'));
90 $receipts_table = id(new PhortuneOrderTableView())
91 ->setViewer($xviewer)
92 ->setAccountEmail($email)
93 ->setCarts($receipts);
95 return id(new PHUIObjectBoxView())
96 ->setHeader($header)
97 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
98 ->setTable($receipts_table);