2014-07-23 19:36:25 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
abstract class PhortuneCartController
|
|
|
|
extends PhortuneController {
|
|
|
|
|
2014-10-09 00:33:25 +02:00
|
|
|
protected function buildCartContentTable(PhortuneCart $cart) {
|
2014-07-23 19:36:25 +02:00
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($cart->getPurchases() as $purchase) {
|
|
|
|
$rows[] = array(
|
2014-08-18 22:15:21 +02:00
|
|
|
$purchase->getFullDisplayName(),
|
2014-10-06 19:26:48 +02:00
|
|
|
$purchase->getBasePriceAsCurrency()->formatForDisplay(),
|
2014-07-23 19:36:25 +02:00
|
|
|
$purchase->getQuantity(),
|
2014-10-06 19:26:48 +02:00
|
|
|
$purchase->getTotalPriceAsCurrency()->formatForDisplay(),
|
2014-07-23 19:36:25 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$rows[] = array(
|
|
|
|
phutil_tag('strong', array(), pht('Total')),
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
phutil_tag('strong', array(),
|
2014-10-06 19:26:48 +02:00
|
|
|
$cart->getTotalPriceAsCurrency()->formatForDisplay()),
|
2014-07-23 19:36:25 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$table = new AphrontTableView($rows);
|
|
|
|
$table->setHeaders(
|
|
|
|
array(
|
|
|
|
pht('Item'),
|
|
|
|
pht('Price'),
|
|
|
|
pht('Qty.'),
|
|
|
|
pht('Total'),
|
|
|
|
));
|
|
|
|
$table->setColumnClasses(
|
|
|
|
array(
|
|
|
|
'wide',
|
|
|
|
'right',
|
|
|
|
'right',
|
|
|
|
'right',
|
|
|
|
));
|
|
|
|
|
2014-10-09 00:33:25 +02:00
|
|
|
return $table;
|
2014-07-23 19:36:25 +02:00
|
|
|
}
|
|
|
|
|
2015-04-20 19:05:22 +02:00
|
|
|
protected function renderCartDescription(PhortuneCart $cart) {
|
|
|
|
$description = $cart->getDescription();
|
|
|
|
if (!strlen($description)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$output = PhabricatorMarkupEngine::renderOneObject(
|
|
|
|
id(new PhabricatorMarkupOneOff())
|
|
|
|
->setPreserveLinebreaks(true)
|
|
|
|
->setContent($description),
|
|
|
|
'default',
|
|
|
|
$this->getViewer());
|
|
|
|
|
|
|
|
$box = id(new PHUIBoxView())
|
|
|
|
->addMargin(PHUI::MARGIN_LARGE)
|
|
|
|
->appendChild($output);
|
|
|
|
|
|
|
|
return id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText(pht('Description'))
|
|
|
|
->appendChild($box);
|
|
|
|
}
|
|
|
|
|
2014-07-23 19:36:25 +02:00
|
|
|
}
|