1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-07 04:18:31 +01:00
phorge-phorge/src/applications/phortune/controller/PhortuneController.php

90 lines
2.1 KiB
PHP
Raw Normal View History

2013-03-28 09:10:34 -07:00
<?php
abstract class PhortuneController extends PhabricatorController {
protected function loadActiveAccount(PhabricatorUser $user) {
return PhortuneAccountQuery::loadActiveAccountForUser(
$user,
PhabricatorContentSource::newFromRequest($this->getRequest()));
2013-03-28 09:10:34 -07:00
}
protected function buildChargesTable(array $charges, $show_cart = true) {
$request = $this->getRequest();
$viewer = $request->getUser();
$rows = array();
foreach ($charges as $charge) {
$cart = $charge->getCart();
$cart_id = $cart->getID();
$cart_uri = $this->getApplicationURI("cart/{$cart_id}/");
$cart_href = phutil_tag(
'a',
array(
'href' => $cart_uri,
),
pht('Cart %d', $cart_id));
$rows[] = array(
$charge->getID(),
$cart_href,
$charge->getPaymentProviderKey(),
$charge->getPaymentMethodPHID(),
$charge->getAmountAsCurrency()->formatForDisplay(),
$charge->getStatus(),
phabricator_datetime($charge->getDateCreated(), $viewer),
);
}
$charge_table = id(new AphrontTableView($rows))
->setHeaders(
array(
pht('ID'),
pht('Cart'),
pht('Provider'),
pht('Method'),
pht('Amount'),
pht('Status'),
pht('Created'),
))
->setColumnClasses(
array(
'',
'strong',
'',
'',
'wide right',
'',
'',
))
->setColumnVisibility(
array(
true,
$show_cart,
));
$header = id(new PHUIHeaderView())
->setHeader(pht('Charge History'));
return id(new PHUIObjectBoxView())
->setHeader($header)
->appendChild($charge_table);
}
2013-03-28 09:10:34 -07:00
protected function addAccountCrumb(
$crumbs,
PhortuneAccount $account,
$link = true) {
$name = pht('Account');
$href = null;
if ($link) {
$href = $this->getApplicationURI($account->getID().'/');
$crumbs->addTextCrumb($name, $href);
} else {
$crumbs->addTextCrumb($name);
}
}
2013-03-28 09:10:34 -07:00
}