@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Show a very basic purchase history in Phortune

Summary: Ref T2787. This is very basic and just helps me know that the data is inserting correctly.

Test Plan: {F187765}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T2787

Differential Revision: https://secure.phabricator.com/D10205

+77 -2
+51 -2
src/applications/phortune/controller/PhortuneAccountViewController.php
··· 157 157 158 158 private function buildPurchaseHistorySection(PhortuneAccount $account) { 159 159 $request = $this->getRequest(); 160 - $user = $request->getUser(); 160 + $viewer = $request->getUser(); 161 + 162 + $carts = id(new PhortuneCartQuery()) 163 + ->setViewer($viewer) 164 + ->withAccountPHIDs(array($account->getPHID())) 165 + ->needPurchases(true) 166 + ->withStatuses( 167 + array( 168 + PhortuneCart::STATUS_PURCHASING, 169 + PhortuneCart::STATUS_PURCHASED, 170 + )) 171 + ->execute(); 172 + 173 + $rows = array(); 174 + $rowc = array(); 175 + foreach ($carts as $cart) { 176 + $rowc[] = 'highlighted'; 177 + $rows[] = array( 178 + $cart->getPHID(), 179 + '', 180 + '', 181 + ); 182 + foreach ($cart->getPurchases() as $purchase) { 183 + $price = $purchase->getTotalPriceInCents(); 184 + $price = PhortuneCurrency::newFromUSDCents($price)->formatForDisplay(); 185 + 186 + $rowc[] = ''; 187 + $rows[] = array( 188 + '', 189 + $purchase->getPHID(), 190 + $price, 191 + ); 192 + } 193 + } 194 + 195 + $table = id(new AphrontTableView($rows)) 196 + ->setRowClasses($rowc) 197 + ->setHeaders( 198 + array( 199 + pht('Cart'), 200 + pht('Purchase'), 201 + pht('Amount'), 202 + )) 203 + ->setColumnClasses( 204 + array( 205 + '', 206 + 'wide', 207 + 'right', 208 + )); 161 209 162 210 $header = id(new PHUIHeaderView()) 163 211 ->setHeader(pht('Purchase History')); 164 212 165 213 return id(new PHUIObjectBoxView()) 166 - ->setHeader($header); 214 + ->setHeader($header) 215 + ->appendChild($table); 167 216 } 168 217 169 218 private function buildChargeHistorySection(PhortuneAccount $account) {
+26
src/applications/phortune/query/PhortuneCartQuery.php
··· 5 5 6 6 private $ids; 7 7 private $phids; 8 + private $accountPHIDs; 9 + private $statuses; 8 10 9 11 private $needPurchases; 10 12 ··· 15 17 16 18 public function withPHIDs(array $phids) { 17 19 $this->phids = $phids; 20 + return $this; 21 + } 22 + 23 + public function withAccountPHIDs(array $account_phids) { 24 + $this->accountPHIDs = $account_phids; 25 + return $this; 26 + } 27 + 28 + public function withStatuses(array $statuses) { 29 + $this->statuses = $statuses; 18 30 return $this; 19 31 } 20 32 ··· 91 103 $conn, 92 104 'cart.phid IN (%Ls)', 93 105 $this->phids); 106 + } 107 + 108 + if ($this->accountPHIDs !== null) { 109 + $where[] = qsprintf( 110 + $conn, 111 + 'cart.accountPHID IN (%Ls)', 112 + $this->accountPHIDs); 113 + } 114 + 115 + if ($this->statuses !== null) { 116 + $where[] = qsprintf( 117 + $conn, 118 + 'cart.status IN (%Ls)', 119 + $this->statuses); 94 120 } 95 121 96 122 return $this->formatWhereClause($where);