Differential D20740 Diff 49453 src/applications/phortune/controller/external/PhortuneExternalOrderController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phortune/controller/external/PhortuneExternalOrderController.php
Show All 11 Lines | $order = id(new PhortuneCartQuery()) | ||||
->setViewer($xviewer) | ->setViewer($xviewer) | ||||
->withAccountPHIDs(array($account->getPHID())) | ->withAccountPHIDs(array($account->getPHID())) | ||||
->withIDs(array($request->getURIData('orderID'))) | ->withIDs(array($request->getURIData('orderID'))) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$order) { | if (!$order) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$timeline = $this->buildTransactionTimeline( | $is_printable = ($request->getURIData('action') === 'print'); | ||||
$order, | |||||
new PhortuneCartTransactionQuery()); | $order_view = id(new PhortuneOrderSummaryView()) | ||||
$timeline->setShouldTerminate(true); | ->setViewer($xviewer) | ||||
->setOrder($order) | |||||
->setPrintable($is_printable); | |||||
$crumbs = null; | |||||
$curtain = null; | |||||
$main = array(); | |||||
$tail = array(); | |||||
require_celerity_resource('phortune-invoice-css'); | |||||
if ($is_printable) { | |||||
$body_class = 'phortune-invoice-view'; | |||||
$tail[] = $order_view; | |||||
} else { | |||||
$body_class = 'phortune-cart-page'; | |||||
$curtain = $this->newCurtain($order); | |||||
$crumbs = $this->newExternalCrumbs() | $crumbs = $this->newExternalCrumbs() | ||||
->addTextCrumb($order->getObjectName()); | ->addTextCrumb($order->getObjectName()) | ||||
->setBorder(true); | |||||
$timeline = $this->buildTransactionTimeline($order) | |||||
->setShouldTerminate(true); | |||||
$main[] = $order_view; | |||||
$main[] = $timeline; | |||||
} | |||||
$column_view = id(new PHUITwoColumnView()) | |||||
->setMainColumn($main) | |||||
->setFooter($tail); | |||||
$view = id(new PHUITwoColumnView()) | if ($curtain) { | ||||
->setMainColumn( | $column_view->setCurtain($curtain); | ||||
} | |||||
$page = $this->newPage() | |||||
->addClass($body_class) | |||||
->setTitle( | |||||
array( | array( | ||||
$timeline, | $order->getObjectName(), | ||||
)); | $order->getName(), | ||||
)) | |||||
->appendChild($column_view); | |||||
if ($crumbs) { | |||||
$page->setCrumbs($crumbs); | |||||
} | |||||
return $page; | |||||
} | |||||
private function newCurtain(PhortuneCart $order) { | |||||
$xviewer = $this->getExternalViewer(); | |||||
$email = $this->getAccountEmail(); | |||||
$curtain = $this->newCurtainView($order); | |||||
$print_uri = $email->getExternalOrderPrintURI($order); | |||||
$curtain->addAction( | |||||
id(new PhabricatorActionView()) | |||||
->setName(pht('Printable Version')) | |||||
->setHref($print_uri) | |||||
->setOpenInNewWindow(true) | |||||
->setIcon('fa-print')); | |||||
return $this->newPage() | return $curtain; | ||||
->setTitle(pht('Order %d', $order->getID())) | |||||
->setCrumbs($crumbs) | |||||
->appendChild($view); | |||||
} | } | ||||
} | } |