Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / phortune / controller / external / PhortuneExternalOrderController.php
blob36522f95aff5d69b0cdce9199ce2eee72e2d9bdf
1 <?php
3 final class PhortuneExternalOrderController
4 extends PhortuneExternalController {
6 protected function handleExternalRequest(AphrontRequest $request) {
7 $xviewer = $this->getExternalViewer();
8 $email = $this->getAccountEmail();
9 $account = $email->getAccount();
11 $order = id(new PhortuneCartQuery())
12 ->setViewer($xviewer)
13 ->withAccountPHIDs(array($account->getPHID()))
14 ->withIDs(array($request->getURIData('orderID')))
15 ->executeOne();
16 if (!$order) {
17 return new Aphront404Response();
20 $is_printable = ($request->getURIData('action') === 'print');
22 $order_view = id(new PhortuneOrderSummaryView())
23 ->setViewer($xviewer)
24 ->setOrder($order)
25 ->setPrintable($is_printable);
27 $crumbs = null;
28 $curtain = null;
30 $main = array();
31 $tail = array();
33 require_celerity_resource('phortune-invoice-css');
35 if ($is_printable) {
36 $body_class = 'phortune-invoice-view';
38 $tail[] = $order_view;
39 } else {
40 $body_class = 'phortune-cart-page';
42 $curtain = $this->newCurtain($order);
44 $crumbs = $this->newExternalCrumbs()
45 ->addTextCrumb($order->getObjectName())
46 ->setBorder(true);
48 $timeline = $this->buildTransactionTimeline($order)
49 ->setShouldTerminate(true);
51 $main[] = $order_view;
52 $main[] = $timeline;
55 $column_view = id(new PHUITwoColumnView())
56 ->setMainColumn($main)
57 ->setFooter($tail);
59 if ($curtain) {
60 $column_view->setCurtain($curtain);
63 $page = $this->newPage()
64 ->addClass($body_class)
65 ->setTitle(
66 array(
67 $order->getObjectName(),
68 $order->getName(),
70 ->appendChild($column_view);
72 if ($crumbs) {
73 $page->setCrumbs($crumbs);
76 return $page;
80 private function newCurtain(PhortuneCart $order) {
81 $xviewer = $this->getExternalViewer();
82 $email = $this->getAccountEmail();
84 $curtain = $this->newCurtainView($order);
86 $print_uri = $email->getExternalOrderPrintURI($order);
88 $curtain->addAction(
89 id(new PhabricatorActionView())
90 ->setName(pht('Printable Version'))
91 ->setHref($print_uri)
92 ->setOpenInNewWindow(true)
93 ->setIcon('fa-print'));
95 return $curtain;