Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phortune/controller/cart/PhortuneCartController.php
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | abstract class PhortuneCartController | ||||
final protected function hasAccountAuthority() { | final protected function hasAccountAuthority() { | ||||
return (bool)PhabricatorPolicyFilter::hasCapability( | return (bool)PhabricatorPolicyFilter::hasCapability( | ||||
$this->getViewer(), | $this->getViewer(), | ||||
$this->getCart(), | $this->getCart(), | ||||
PhabricatorPolicyCapability::CAN_EDIT); | PhabricatorPolicyCapability::CAN_EDIT); | ||||
} | } | ||||
protected function buildCartContentTable(PhortuneCart $cart) { | |||||
$rows = array(); | |||||
foreach ($cart->getPurchases() as $purchase) { | |||||
$rows[] = array( | |||||
$purchase->getFullDisplayName(), | |||||
$purchase->getBasePriceAsCurrency()->formatForDisplay(), | |||||
$purchase->getQuantity(), | |||||
$purchase->getTotalPriceAsCurrency()->formatForDisplay(), | |||||
); | |||||
} | |||||
$rows[] = array( | |||||
phutil_tag('strong', array(), pht('Total')), | |||||
'', | |||||
'', | |||||
phutil_tag('strong', array(), | |||||
$cart->getTotalPriceAsCurrency()->formatForDisplay()), | |||||
); | |||||
$table = new AphrontTableView($rows); | |||||
$table->setHeaders( | |||||
array( | |||||
pht('Item'), | |||||
pht('Price'), | |||||
pht('Qty.'), | |||||
pht('Total'), | |||||
)); | |||||
$table->setColumnClasses( | |||||
array( | |||||
'wide', | |||||
'right', | |||||
'right', | |||||
'right', | |||||
)); | |||||
return $table; | |||||
} | |||||
protected function renderCartDescription(PhortuneCart $cart) { | |||||
$description = $cart->getDescription(); | |||||
if (!strlen($description)) { | |||||
return null; | |||||
} | |||||
$output = new PHUIRemarkupView($this->getViewer(), $description); | |||||
$box = id(new PHUIBoxView()) | |||||
->addMargin(PHUI::MARGIN_LARGE) | |||||
->appendChild($output); | |||||
return id(new PHUIObjectBoxView()) | |||||
->setHeaderText(pht('Description')) | |||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | |||||
->appendChild($box); | |||||
} | |||||
} | } |