3 final class PhortuneOrderSummaryView
4 extends PhortuneOrderView
{
9 public function setResumeURI($resume_uri) {
10 $this->resumeURI
= $resume_uri;
14 public function getResumeURI() {
15 return $this->resumeURI
;
18 public function setPrintable($printable) {
19 $this->printable
= $printable;
23 public function getPrintable() {
24 return $this->printable
;
27 public function render() {
28 $is_printable = $this->getPrintable();
33 $content[] = $this->newContactHeader();
36 $content[] = $this->newMessagesView();
37 $content[] = $this->newDetailsView();
38 $content[] = $this->newDescriptionView();
39 $content[] = $this->newItemsView();
40 $content[] = $this->newChargesView();
43 $content[] = $this->newContactFooter();
49 private function newMessagesView() {
50 $viewer = $this->getViewer();
51 $order = $this->getOrder();
56 $resume_uri = $this->getResumeURI();
58 $can_edit = PhabricatorPolicyFilter
::hasCapability(
61 PhabricatorPolicyCapability
::CAN_EDIT
);
63 $can_merchant = PhabricatorPolicyFilter
::hasCapability(
65 $order->getMerchant(),
66 PhabricatorPolicyCapability
::CAN_EDIT
);
68 switch ($order->getStatus()) {
69 case PhortuneCart
::STATUS_READY
:
70 if ($order->getIsInvoice()) {
71 $severity = PHUIInfoView
::SEVERITY_NOTICE
;
72 $messages[] = pht('This invoice is ready for payment.');
75 case PhortuneCart
::STATUS_PURCHASING
:
79 'The checkout process has been started, but not yet completed. '.
80 'You can continue checking out by clicking %s, or cancel the '.
81 'order, or contact the merchant for assistance.',
82 phutil_tag('strong', array(), pht('Continue Checkout')));
85 'The checkout process has been started, but an error occurred. '.
86 'You can cancel the order or contact the merchant for '.
91 case PhortuneCart
::STATUS_CHARGED
:
94 'You have been charged, but processing could not be completed. '.
95 'You can cancel your order, or contact the merchant for '.
99 case PhortuneCart
::STATUS_HOLD
:
102 'Payment for this order is on hold. You can click %s to check '.
103 'for updates, cancel the order, or contact the merchant for '.
105 phutil_tag('strong', array(), pht('Update Status')));
108 case PhortuneCart
::STATUS_REVIEW
:
111 'This order has been flagged for manual review. Review the order '.
112 'and choose %s to accept it or %s to reject it.',
113 phutil_tag('strong', array(), pht('Accept Order')),
114 phutil_tag('strong', array(), pht('Refund Order')));
115 } else if ($can_edit) {
117 'This order requires manual processing and will complete once '.
118 'the merchant accepts it.');
121 case PhortuneCart
::STATUS_PURCHASED
:
122 $severity = PHUIInfoView
::SEVERITY_SUCCESS
;
123 $messages[] = pht('This purchase has been completed.');
131 if ($severity === null) {
132 $severity = PHUIInfoView
::SEVERITY_WARNING
;
135 $messages_view = id(new PHUIInfoView())
136 ->setSeverity($severity)
137 ->appendChild($messages);
139 $is_printable = $this->getPrintable();
141 $messages_view = phutil_tag(
144 'class' => 'phortune-invoice-status',
149 return $messages_view;
152 private function newDetailsView() {
153 $viewer = $this->getViewer();
154 $order = $this->getOrder();
155 $is_printable = $this->getPrintable();
157 $view = id(new PHUIPropertyListView())
161 $account_phid = $order->getAccountPHID();
162 $author_phid = $order->getAuthorPHID();
163 $merchant_phid = $order->getMerchantPHID();
165 $handles = $viewer->loadHandles(
173 $account_link = $handles[$account_phid]->getFullName();
174 $author_link = $handles[$author_phid]->getFullName();
175 $merchant_link = $handles[$merchant_phid]->getFullName();
177 $account_link = $handles[$account_phid]->renderLink();
178 $author_link = $handles[$author_phid]->renderLink();
179 $merchant_link = $handles[$merchant_phid]->renderLink();
183 $view->addProperty(pht('Order Name'), $order->getName());
186 $view->addProperty(pht('Account'), $account_link);
187 $view->addProperty(pht('Authorized By'), $author_link);
188 $view->addProperty(pht('Merchant'), $merchant_link);
192 PhortuneCart
::getNameForStatus($order->getStatus()));
195 phabricator_datetime($order->getDateCreated(), $viewer));
198 phabricator_datetime($order->getDateModified(), $viewer));
200 return id(new PHUIObjectBoxView())
201 ->setHeaderText(pht('Details'))
202 ->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
)
203 ->appendChild($view);
206 private function newChargesView() {
207 $viewer = $this->getViewer();
208 $order = $this->getOrder();
210 $charges = id(new PhortuneChargeQuery())
212 ->withCartPHIDs(array($order->getPHID()))
216 $charges_table = id(new PhortuneChargeTableView())
218 ->setCharges($charges)
219 ->setShowOrder(false);
221 $charges_view = id(new PHUIObjectBoxView())
222 ->setHeaderText(pht('Charges'))
223 ->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
)
224 ->setTable($charges_table);
226 return $charges_view;
229 private function newDescriptionView() {
230 $viewer = $this->getViewer();
231 $order = $this->getOrder();
233 return id(new PhortuneOrderDescriptionView())
238 private function newItemsView() {
239 $viewer = $this->getViewer();
240 $order = $this->getOrder();
242 return id(new PhortuneOrderItemsView())
247 private function newContactHeader() {
248 $viewer = $this->getViewer();
249 $order = $this->getOrder();
251 $merchant = id(new PhortuneMerchantQuery())
253 ->withPHIDs(array($order->getMerchant()->getPHID()))
254 ->needProfileImage(true)
257 $merchant_name = $merchant->getName();
258 $merchant_image = $merchant->getProfileImageURI();
260 $account = $order->getAccount();
261 $account_name = $account->getBillingName();
263 $account_contact = $account->getBillingAddress();
264 if (strlen($account_contact)) {
265 $account_contact = new PHUIRemarkupView(
270 $merchant_contact = $merchant->getContactInfo();
271 if (strlen($merchant_contact)) {
272 $merchant_contact = new PHUIRemarkupView(
274 $merchant->getContactInfo());
280 'class' => 'phortune-invoice-logo',
287 'alt' => $merchant_name,
288 'src' => $merchant_image,
291 $to_title = phutil_tag(
294 'class' => 'phortune-mini-header',
298 $bill_to = phutil_tag(
301 'class' => 'phortune-invoice-to',
306 phutil_tag('strong', array(), $account_name),
307 phutil_tag('br', array()),
311 $from_title = phutil_tag(
314 'class' => 'phortune-mini-header',
318 $bill_from = phutil_tag(
321 'class' => 'phortune-invoice-from',
326 phutil_tag('strong', array(), $merchant_name),
327 phutil_tag('br', array()),
331 $contact = phutil_tag(
334 'class' => 'phortune-invoice-contact',
351 private function newContactFooter() {
352 $viewer = $this->getViewer();
353 $order = $this->getOrder();
355 $merchant = $order->getMerchant();
356 $footer = $merchant->getInvoiceFooter();
358 if (!strlen($footer)) {
365 'class' => 'phortune-invoice-footer',