mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 04:42:40 +01:00
Add a basic invoice view for printing to Phortune
Summary: Makes a more complete PDF looking invoice form for printing in Phortune. Test Plan: Make an invoice, click print view, print. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D16762
This commit is contained in:
parent
1993005651
commit
5fd79479ec
12 changed files with 419 additions and 40 deletions
|
@ -89,6 +89,7 @@ return array(
|
||||||
'rsrc/css/application/pholio/pholio-inline-comments.css' => '8e545e49',
|
'rsrc/css/application/pholio/pholio-inline-comments.css' => '8e545e49',
|
||||||
'rsrc/css/application/pholio/pholio.css' => 'ca89d380',
|
'rsrc/css/application/pholio/pholio.css' => 'ca89d380',
|
||||||
'rsrc/css/application/phortune/phortune-credit-card-form.css' => '8391eb02',
|
'rsrc/css/application/phortune/phortune-credit-card-form.css' => '8391eb02',
|
||||||
|
'rsrc/css/application/phortune/phortune-invoice.css' => '476055e2',
|
||||||
'rsrc/css/application/phortune/phortune.css' => '5b99dae0',
|
'rsrc/css/application/phortune/phortune.css' => '5b99dae0',
|
||||||
'rsrc/css/application/phrequent/phrequent.css' => 'ffc185ad',
|
'rsrc/css/application/phrequent/phrequent.css' => 'ffc185ad',
|
||||||
'rsrc/css/application/phriction/phriction-document-css.css' => '4282e4ad',
|
'rsrc/css/application/phriction/phriction-document-css.css' => '4282e4ad',
|
||||||
|
@ -840,6 +841,7 @@ return array(
|
||||||
'phortune-credit-card-form' => '2290aeef',
|
'phortune-credit-card-form' => '2290aeef',
|
||||||
'phortune-credit-card-form-css' => '8391eb02',
|
'phortune-credit-card-form-css' => '8391eb02',
|
||||||
'phortune-css' => '5b99dae0',
|
'phortune-css' => '5b99dae0',
|
||||||
|
'phortune-invoice-css' => '476055e2',
|
||||||
'phrequent-css' => 'ffc185ad',
|
'phrequent-css' => 'ffc185ad',
|
||||||
'phriction-document-css' => '4282e4ad',
|
'phriction-document-css' => '4282e4ad',
|
||||||
'phui-action-panel-css' => '91c7b835',
|
'phui-action-panel-css' => '91c7b835',
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
ALTER TABLE {$NAMESPACE}_phortune.phortune_merchant
|
||||||
|
ADD invoiceEmail VARCHAR(255) COLLATE {$COLLATE_TEXT} NOT NULL;
|
||||||
|
|
||||||
|
ALTER TABLE {$NAMESPACE}_phortune.phortune_merchant
|
||||||
|
ADD invoiceFooter LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL;
|
|
@ -4174,6 +4174,7 @@ phutil_register_library_map(array(
|
||||||
'PhortuneCurrencyTestCase' => 'applications/phortune/currency/__tests__/PhortuneCurrencyTestCase.php',
|
'PhortuneCurrencyTestCase' => 'applications/phortune/currency/__tests__/PhortuneCurrencyTestCase.php',
|
||||||
'PhortuneDAO' => 'applications/phortune/storage/PhortuneDAO.php',
|
'PhortuneDAO' => 'applications/phortune/storage/PhortuneDAO.php',
|
||||||
'PhortuneErrCode' => 'applications/phortune/constants/PhortuneErrCode.php',
|
'PhortuneErrCode' => 'applications/phortune/constants/PhortuneErrCode.php',
|
||||||
|
'PhortuneInvoiceView' => 'applications/phortune/view/PhortuneInvoiceView.php',
|
||||||
'PhortuneLandingController' => 'applications/phortune/controller/PhortuneLandingController.php',
|
'PhortuneLandingController' => 'applications/phortune/controller/PhortuneLandingController.php',
|
||||||
'PhortuneMemberHasAccountEdgeType' => 'applications/phortune/edge/PhortuneMemberHasAccountEdgeType.php',
|
'PhortuneMemberHasAccountEdgeType' => 'applications/phortune/edge/PhortuneMemberHasAccountEdgeType.php',
|
||||||
'PhortuneMemberHasMerchantEdgeType' => 'applications/phortune/edge/PhortuneMemberHasMerchantEdgeType.php',
|
'PhortuneMemberHasMerchantEdgeType' => 'applications/phortune/edge/PhortuneMemberHasMerchantEdgeType.php',
|
||||||
|
@ -9422,6 +9423,7 @@ phutil_register_library_map(array(
|
||||||
'PhortuneCurrencyTestCase' => 'PhabricatorTestCase',
|
'PhortuneCurrencyTestCase' => 'PhabricatorTestCase',
|
||||||
'PhortuneDAO' => 'PhabricatorLiskDAO',
|
'PhortuneDAO' => 'PhabricatorLiskDAO',
|
||||||
'PhortuneErrCode' => 'PhortuneConstants',
|
'PhortuneErrCode' => 'PhortuneConstants',
|
||||||
|
'PhortuneInvoiceView' => 'AphrontTagView',
|
||||||
'PhortuneLandingController' => 'PhortuneController',
|
'PhortuneLandingController' => 'PhortuneController',
|
||||||
'PhortuneMemberHasAccountEdgeType' => 'PhabricatorEdgeType',
|
'PhortuneMemberHasAccountEdgeType' => 'PhabricatorEdgeType',
|
||||||
'PhortuneMemberHasMerchantEdgeType' => 'PhabricatorEdgeType',
|
'PhortuneMemberHasMerchantEdgeType' => 'PhabricatorEdgeType',
|
||||||
|
|
|
@ -61,6 +61,7 @@ final class PhabricatorPhortuneApplication extends PhabricatorApplication {
|
||||||
'cart/(?P<id>\d+)/' => array(
|
'cart/(?P<id>\d+)/' => array(
|
||||||
'' => 'PhortuneCartViewController',
|
'' => 'PhortuneCartViewController',
|
||||||
'checkout/' => 'PhortuneCartCheckoutController',
|
'checkout/' => 'PhortuneCartCheckoutController',
|
||||||
|
'(?P<action>print)/' => 'PhortuneCartViewController',
|
||||||
'(?P<action>cancel|refund)/' => 'PhortuneCartCancelController',
|
'(?P<action>cancel|refund)/' => 'PhortuneCartCancelController',
|
||||||
'update/' => 'PhortuneCartUpdateController',
|
'update/' => 'PhortuneCartUpdateController',
|
||||||
),
|
),
|
||||||
|
|
|
@ -3,9 +3,12 @@
|
||||||
final class PhortuneCartViewController
|
final class PhortuneCartViewController
|
||||||
extends PhortuneCartController {
|
extends PhortuneCartController {
|
||||||
|
|
||||||
|
private $action = null;
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$viewer = $request->getViewer();
|
$viewer = $request->getViewer();
|
||||||
$id = $request->getURIData('id');
|
$id = $request->getURIData('id');
|
||||||
|
$this->action = $request->getURIData('action');
|
||||||
|
|
||||||
$authority = $this->loadMerchantAuthority();
|
$authority = $this->loadMerchantAuthority();
|
||||||
require_celerity_resource('phortune-css');
|
require_celerity_resource('phortune-css');
|
||||||
|
@ -129,7 +132,7 @@ final class PhortuneCartViewController
|
||||||
|
|
||||||
$header = id(new PHUIHeaderView())
|
$header = id(new PHUIHeaderView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setHeader(pht('Order Detail'))
|
->setHeader($cart->getName())
|
||||||
->setHeaderIcon('fa-shopping-cart');
|
->setHeaderIcon('fa-shopping-cart');
|
||||||
|
|
||||||
if ($cart->getStatus() == PhortuneCart::STATUS_PURCHASED) {
|
if ($cart->getStatus() == PhortuneCart::STATUS_PURCHASED) {
|
||||||
|
@ -188,36 +191,75 @@ final class PhortuneCartViewController
|
||||||
$crumbs->addTextCrumb(pht('Cart %d', $cart->getID()));
|
$crumbs->addTextCrumb(pht('Cart %d', $cart->getID()));
|
||||||
$crumbs->setBorder(true);
|
$crumbs->setBorder(true);
|
||||||
|
|
||||||
$timeline = $this->buildTransactionTimeline(
|
if (!$this->action) {
|
||||||
$cart,
|
$class = 'phortune-cart-page';
|
||||||
new PhortuneCartTransactionQuery());
|
$timeline = $this->buildTransactionTimeline(
|
||||||
$timeline
|
$cart,
|
||||||
->setShouldTerminate(true);
|
new PhortuneCartTransactionQuery());
|
||||||
|
$timeline
|
||||||
|
->setShouldTerminate(true);
|
||||||
|
|
||||||
$view = id(new PHUITwoColumnView())
|
$view = id(new PHUITwoColumnView())
|
||||||
->setHeader($header)
|
->setHeader($header)
|
||||||
->setCurtain($curtain)
|
->setCurtain($curtain)
|
||||||
->setMainColumn(array(
|
->setMainColumn(array(
|
||||||
$error_view,
|
$error_view,
|
||||||
$details,
|
$details,
|
||||||
$cart_box,
|
$cart_box,
|
||||||
$description,
|
$description,
|
||||||
$charges,
|
$charges,
|
||||||
$timeline,
|
$timeline,
|
||||||
));
|
));
|
||||||
|
|
||||||
return $this->newPage()
|
} else {
|
||||||
|
$class = 'phortune-invoice-view';
|
||||||
|
$crumbs = null;
|
||||||
|
$merchant_phid = $cart->getMerchantPHID();
|
||||||
|
$buyer_phid = $cart->getAuthorPHID();
|
||||||
|
$merchant = id(new PhortuneMerchantQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withPHIDs(array($merchant_phid))
|
||||||
|
->needProfileImage(true)
|
||||||
|
->executeOne();
|
||||||
|
$buyer = id(new PhabricatorPeopleQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withPHIDs(array($buyer_phid))
|
||||||
|
->needProfileImage(true)
|
||||||
|
->executeOne();
|
||||||
|
// TODO: Add account "Contact" info
|
||||||
|
|
||||||
|
$merchant_contact = new PHUIRemarkupView(
|
||||||
|
$viewer, $merchant->getContactInfo());
|
||||||
|
$description = null;
|
||||||
|
|
||||||
|
$view = id(new PhortuneInvoiceView())
|
||||||
|
->setMerchantName($merchant->getName())
|
||||||
|
->setMerchantLogo($merchant->getProfileImageURI())
|
||||||
|
->setMerchantContact($merchant_contact)
|
||||||
|
->setMerchantFooter($merchant->getInvoiceFooter())
|
||||||
|
->setAccountName($buyer->getRealName())
|
||||||
|
->setStatus($error_view)
|
||||||
|
->setContent(array(
|
||||||
|
$description,
|
||||||
|
$details,
|
||||||
|
$cart_box,
|
||||||
|
$charges,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$page = $this->newPage()
|
||||||
->setTitle(pht('Cart %d', $cart->getID()))
|
->setTitle(pht('Cart %d', $cart->getID()))
|
||||||
->setCrumbs($crumbs)
|
->addClass($class)
|
||||||
->addClass('phortune-cart-page')
|
|
||||||
->appendChild($view);
|
->appendChild($view);
|
||||||
|
|
||||||
|
if ($crumbs) {
|
||||||
|
$page->setCrumbs($crumbs);
|
||||||
|
}
|
||||||
|
return $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildDetailsView(PhortuneCart $cart) {
|
private function buildDetailsView(PhortuneCart $cart) {
|
||||||
|
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
$view = id(new PHUIPropertyListView())
|
$view = id(new PHUIPropertyListView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setObject($cart);
|
->setObject($cart);
|
||||||
|
@ -229,9 +271,10 @@ final class PhortuneCartViewController
|
||||||
$cart->getMerchantPHID(),
|
$cart->getMerchantPHID(),
|
||||||
));
|
));
|
||||||
|
|
||||||
$view->addProperty(
|
if ($this->action == 'print') {
|
||||||
pht('Order Name'),
|
$view->addProperty(pht('Order Name'), $cart->getName());
|
||||||
$cart->getName());
|
}
|
||||||
|
|
||||||
$view->addProperty(
|
$view->addProperty(
|
||||||
pht('Account'),
|
pht('Account'),
|
||||||
$handles[$cart->getAccountPHID()]->renderLink());
|
$handles[$cart->getAccountPHID()]->renderLink());
|
||||||
|
@ -276,7 +319,7 @@ final class PhortuneCartViewController
|
||||||
$refund_uri = $this->getApplicationURI("{$prefix}cart/{$id}/refund/");
|
$refund_uri = $this->getApplicationURI("{$prefix}cart/{$id}/refund/");
|
||||||
$update_uri = $this->getApplicationURI("{$prefix}cart/{$id}/update/");
|
$update_uri = $this->getApplicationURI("{$prefix}cart/{$id}/update/");
|
||||||
$accept_uri = $this->getApplicationURI("{$prefix}cart/{$id}/accept/");
|
$accept_uri = $this->getApplicationURI("{$prefix}cart/{$id}/accept/");
|
||||||
$print_uri = $this->getApplicationURI("{$prefix}cart/{$id}/?__print__=1");
|
$print_uri = $this->getApplicationURI("{$prefix}cart/{$id}/print/");
|
||||||
|
|
||||||
$curtain->addAction(
|
$curtain->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
|
|
|
@ -129,6 +129,13 @@ final class PhortuneMerchantViewController
|
||||||
|
|
||||||
$view->addProperty(pht('Status'), $status_view);
|
$view->addProperty(pht('Status'), $status_view);
|
||||||
|
|
||||||
|
$invoice_from = $merchant->getInvoiceEmail();
|
||||||
|
if (!$invoice_from) {
|
||||||
|
$invoice_from = pht('No email address set');
|
||||||
|
$invoice_from = phutil_tag('em', array(), $invoice_from);
|
||||||
|
}
|
||||||
|
$view->addProperty(pht('Invoice From'), $invoice_from);
|
||||||
|
|
||||||
$description = $merchant->getDescription();
|
$description = $merchant->getDescription();
|
||||||
if (strlen($description)) {
|
if (strlen($description)) {
|
||||||
$description = new PHUIRemarkupView($viewer, $description);
|
$description = new PHUIRemarkupView($viewer, $description);
|
||||||
|
@ -147,6 +154,15 @@ final class PhortuneMerchantViewController
|
||||||
$view->addTextContent($contact_info);
|
$view->addTextContent($contact_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$footer_info = $merchant->getInvoiceFooter();
|
||||||
|
if (strlen($footer_info)) {
|
||||||
|
$footer_info = new PHUIRemarkupView($viewer, $footer_info);
|
||||||
|
$view->addSectionHeader(
|
||||||
|
pht('Invoice Footer'),
|
||||||
|
PHUIPropertyListView::ICON_SUMMARY);
|
||||||
|
$view->addTextContent($footer_info);
|
||||||
|
}
|
||||||
|
|
||||||
return id(new PHUIObjectBoxView())
|
return id(new PHUIObjectBoxView())
|
||||||
->setHeaderText(pht('Details'))
|
->setHeaderText(pht('Details'))
|
||||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
||||||
|
|
|
@ -84,6 +84,21 @@ final class PhortuneMerchantEditEngine
|
||||||
->setTransactionType(PhortuneMerchantTransaction::TYPE_NAME)
|
->setTransactionType(PhortuneMerchantTransaction::TYPE_NAME)
|
||||||
->setValue($object->getName()),
|
->setValue($object->getName()),
|
||||||
|
|
||||||
|
id(new PhabricatorUsersEditField())
|
||||||
|
->setKey('members')
|
||||||
|
->setAliases(array('memberPHIDs'))
|
||||||
|
->setLabel(pht('Members'))
|
||||||
|
->setUseEdgeTransactions(true)
|
||||||
|
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||||
|
->setMetadataValue(
|
||||||
|
'edge:type',
|
||||||
|
PhortuneMerchantHasMemberEdgeType::EDGECONST)
|
||||||
|
->setDescription(pht('Initial merchant members.'))
|
||||||
|
->setConduitDescription(pht('Set merchant members.'))
|
||||||
|
->setConduitTypeDescription(pht('New list of members.'))
|
||||||
|
->setInitialValue($object->getMemberPHIDs())
|
||||||
|
->setValue($member_phids),
|
||||||
|
|
||||||
id(new PhabricatorRemarkupEditField())
|
id(new PhabricatorRemarkupEditField())
|
||||||
->setKey('description')
|
->setKey('description')
|
||||||
->setLabel(pht('Description'))
|
->setLabel(pht('Description'))
|
||||||
|
@ -100,20 +115,22 @@ final class PhortuneMerchantEditEngine
|
||||||
->setTransactionType(PhortuneMerchantTransaction::TYPE_CONTACTINFO)
|
->setTransactionType(PhortuneMerchantTransaction::TYPE_CONTACTINFO)
|
||||||
->setValue($object->getContactInfo()),
|
->setValue($object->getContactInfo()),
|
||||||
|
|
||||||
id(new PhabricatorUsersEditField())
|
id(new PhabricatorTextEditField())
|
||||||
->setKey('members')
|
->setKey('invoiceEmail')
|
||||||
->setAliases(array('memberPHIDs'))
|
->setLabel(pht('Invoice From Email'))
|
||||||
->setLabel(pht('Members'))
|
->setDescription(pht('Email address invoices are sent from.'))
|
||||||
->setUseEdgeTransactions(true)
|
->setConduitTypeDescription(
|
||||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
pht('Email address invoices are sent from.'))
|
||||||
->setMetadataValue(
|
->setTransactionType(PhortuneMerchantTransaction::TYPE_INVOICEEMAIL)
|
||||||
'edge:type',
|
->setValue($object->getInvoiceEmail()),
|
||||||
PhortuneMerchantHasMemberEdgeType::EDGECONST)
|
|
||||||
->setDescription(pht('Initial merchant members.'))
|
id(new PhabricatorRemarkupEditField())
|
||||||
->setConduitDescription(pht('Set merchant members.'))
|
->setKey('invoiceFooter')
|
||||||
->setConduitTypeDescription(pht('New list of members.'))
|
->setLabel(pht('Invoice Footer'))
|
||||||
->setInitialValue($object->getMemberPHIDs())
|
->setDescription(pht('Footer on invoice forms.'))
|
||||||
->setValue($member_phids),
|
->setConduitTypeDescription(pht('Footer on invoice forms.'))
|
||||||
|
->setTransactionType(PhortuneMerchantTransaction::TYPE_INVOICEFOOTER)
|
||||||
|
->setValue($object->getInvoiceFooter()),
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ final class PhortuneMerchantEditor
|
||||||
$types[] = PhortuneMerchantTransaction::TYPE_DESCRIPTION;
|
$types[] = PhortuneMerchantTransaction::TYPE_DESCRIPTION;
|
||||||
$types[] = PhortuneMerchantTransaction::TYPE_CONTACTINFO;
|
$types[] = PhortuneMerchantTransaction::TYPE_CONTACTINFO;
|
||||||
$types[] = PhortuneMerchantTransaction::TYPE_PICTURE;
|
$types[] = PhortuneMerchantTransaction::TYPE_PICTURE;
|
||||||
|
$types[] = PhortuneMerchantTransaction::TYPE_INVOICEEMAIL;
|
||||||
|
$types[] = PhortuneMerchantTransaction::TYPE_INVOICEFOOTER;
|
||||||
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||||
$types[] = PhabricatorTransactions::TYPE_EDGE;
|
$types[] = PhabricatorTransactions::TYPE_EDGE;
|
||||||
|
|
||||||
|
@ -34,6 +36,10 @@ final class PhortuneMerchantEditor
|
||||||
return $object->getDescription();
|
return $object->getDescription();
|
||||||
case PhortuneMerchantTransaction::TYPE_CONTACTINFO:
|
case PhortuneMerchantTransaction::TYPE_CONTACTINFO:
|
||||||
return $object->getContactInfo();
|
return $object->getContactInfo();
|
||||||
|
case PhortuneMerchantTransaction::TYPE_INVOICEEMAIL:
|
||||||
|
return $object->getInvoiceEmail();
|
||||||
|
case PhortuneMerchantTransaction::TYPE_INVOICEFOOTER:
|
||||||
|
return $object->getInvoiceFooter();
|
||||||
case PhortuneMerchantTransaction::TYPE_PICTURE:
|
case PhortuneMerchantTransaction::TYPE_PICTURE:
|
||||||
return $object->getProfileImagePHID();
|
return $object->getProfileImagePHID();
|
||||||
}
|
}
|
||||||
|
@ -49,6 +55,8 @@ final class PhortuneMerchantEditor
|
||||||
case PhortuneMerchantTransaction::TYPE_NAME:
|
case PhortuneMerchantTransaction::TYPE_NAME:
|
||||||
case PhortuneMerchantTransaction::TYPE_DESCRIPTION:
|
case PhortuneMerchantTransaction::TYPE_DESCRIPTION:
|
||||||
case PhortuneMerchantTransaction::TYPE_CONTACTINFO:
|
case PhortuneMerchantTransaction::TYPE_CONTACTINFO:
|
||||||
|
case PhortuneMerchantTransaction::TYPE_INVOICEEMAIL:
|
||||||
|
case PhortuneMerchantTransaction::TYPE_INVOICEFOOTER:
|
||||||
case PhortuneMerchantTransaction::TYPE_PICTURE:
|
case PhortuneMerchantTransaction::TYPE_PICTURE:
|
||||||
return $xaction->getNewValue();
|
return $xaction->getNewValue();
|
||||||
}
|
}
|
||||||
|
@ -70,6 +78,12 @@ final class PhortuneMerchantEditor
|
||||||
case PhortuneMerchantTransaction::TYPE_CONTACTINFO:
|
case PhortuneMerchantTransaction::TYPE_CONTACTINFO:
|
||||||
$object->setContactInfo($xaction->getNewValue());
|
$object->setContactInfo($xaction->getNewValue());
|
||||||
return;
|
return;
|
||||||
|
case PhortuneMerchantTransaction::TYPE_INVOICEEMAIL:
|
||||||
|
$object->setInvoiceEmail($xaction->getNewValue());
|
||||||
|
return;
|
||||||
|
case PhortuneMerchantTransaction::TYPE_INVOICEFOOTER:
|
||||||
|
$object->setInvoiceFooter($xaction->getNewValue());
|
||||||
|
return;
|
||||||
case PhortuneMerchantTransaction::TYPE_PICTURE:
|
case PhortuneMerchantTransaction::TYPE_PICTURE:
|
||||||
$object->setProfileImagePHID($xaction->getNewValue());
|
$object->setProfileImagePHID($xaction->getNewValue());
|
||||||
return;
|
return;
|
||||||
|
@ -86,6 +100,8 @@ final class PhortuneMerchantEditor
|
||||||
case PhortuneMerchantTransaction::TYPE_NAME:
|
case PhortuneMerchantTransaction::TYPE_NAME:
|
||||||
case PhortuneMerchantTransaction::TYPE_DESCRIPTION:
|
case PhortuneMerchantTransaction::TYPE_DESCRIPTION:
|
||||||
case PhortuneMerchantTransaction::TYPE_CONTACTINFO:
|
case PhortuneMerchantTransaction::TYPE_CONTACTINFO:
|
||||||
|
case PhortuneMerchantTransaction::TYPE_INVOICEEMAIL:
|
||||||
|
case PhortuneMerchantTransaction::TYPE_INVOICEFOOTER:
|
||||||
case PhortuneMerchantTransaction::TYPE_PICTURE:
|
case PhortuneMerchantTransaction::TYPE_PICTURE:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -116,6 +132,29 @@ final class PhortuneMerchantEditor
|
||||||
$error->setIsMissingFieldError(true);
|
$error->setIsMissingFieldError(true);
|
||||||
$errors[] = $error;
|
$errors[] = $error;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case PhortuneMerchantTransaction::TYPE_INVOICEEMAIL:
|
||||||
|
foreach ($xactions as $xaction) {
|
||||||
|
switch ($xaction->getTransactionType()) {
|
||||||
|
case PhortuneMerchantTransaction::TYPE_INVOICEEMAIL:
|
||||||
|
$new_email = $xaction->getNewValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (strlen($new_email)) {
|
||||||
|
$email = new PhutilEmailAddress($new_email);
|
||||||
|
$domain = $email->getDomainName();
|
||||||
|
|
||||||
|
if (!$domain) {
|
||||||
|
$error = new PhabricatorApplicationTransactionValidationError(
|
||||||
|
$type,
|
||||||
|
pht('Invalid'),
|
||||||
|
pht('%s is not a valid email.', $new_email),
|
||||||
|
nonempty(last($xactions), null));
|
||||||
|
|
||||||
|
$errors[] = $error;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ final class PhortuneMerchant extends PhortuneDAO
|
||||||
protected $viewPolicy;
|
protected $viewPolicy;
|
||||||
protected $description;
|
protected $description;
|
||||||
protected $contactInfo;
|
protected $contactInfo;
|
||||||
|
protected $invoiceEmail;
|
||||||
|
protected $invoiceFooter;
|
||||||
protected $profileImagePHID;
|
protected $profileImagePHID;
|
||||||
|
|
||||||
private $memberPHIDs = self::ATTACHABLE;
|
private $memberPHIDs = self::ATTACHABLE;
|
||||||
|
@ -27,6 +29,8 @@ final class PhortuneMerchant extends PhortuneDAO
|
||||||
'name' => 'text255',
|
'name' => 'text255',
|
||||||
'description' => 'text',
|
'description' => 'text',
|
||||||
'contactInfo' => 'text',
|
'contactInfo' => 'text',
|
||||||
|
'invoiceEmail' => 'text255',
|
||||||
|
'invoiceFooter' => 'text',
|
||||||
'profileImagePHID' => 'phid?',
|
'profileImagePHID' => 'phid?',
|
||||||
),
|
),
|
||||||
) + parent::getConfiguration();
|
) + parent::getConfiguration();
|
||||||
|
|
|
@ -6,6 +6,8 @@ final class PhortuneMerchantTransaction
|
||||||
const TYPE_NAME = 'merchant:name';
|
const TYPE_NAME = 'merchant:name';
|
||||||
const TYPE_DESCRIPTION = 'merchant:description';
|
const TYPE_DESCRIPTION = 'merchant:description';
|
||||||
const TYPE_CONTACTINFO = 'merchant:contactinfo';
|
const TYPE_CONTACTINFO = 'merchant:contactinfo';
|
||||||
|
const TYPE_INVOICEEMAIL = 'merchant:invoiceemail';
|
||||||
|
const TYPE_INVOICEFOOTER = 'merchant:invoicefooter';
|
||||||
const TYPE_PICTURE = 'merchant:picture';
|
const TYPE_PICTURE = 'merchant:picture';
|
||||||
|
|
||||||
public function getApplicationName() {
|
public function getApplicationName() {
|
||||||
|
@ -48,6 +50,14 @@ final class PhortuneMerchantTransaction
|
||||||
return pht(
|
return pht(
|
||||||
'%s updated the contact information for this merchant.',
|
'%s updated the contact information for this merchant.',
|
||||||
$this->renderHandleLink($author_phid));
|
$this->renderHandleLink($author_phid));
|
||||||
|
case self::TYPE_INVOICEEMAIL:
|
||||||
|
return pht(
|
||||||
|
'%s updated the invoice email for this merchant.',
|
||||||
|
$this->renderHandleLink($author_phid));
|
||||||
|
case self::TYPE_INVOICEFOOTER:
|
||||||
|
return pht(
|
||||||
|
'%s updated the invoice footer for this merchant.',
|
||||||
|
$this->renderHandleLink($author_phid));
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getTitle();
|
return parent::getTitle();
|
||||||
|
@ -58,6 +68,8 @@ final class PhortuneMerchantTransaction
|
||||||
switch ($this->getTransactionType()) {
|
switch ($this->getTransactionType()) {
|
||||||
case self::TYPE_DESCRIPTION:
|
case self::TYPE_DESCRIPTION:
|
||||||
case self::TYPE_CONTACTINFO:
|
case self::TYPE_CONTACTINFO:
|
||||||
|
case self::TYPE_INVOICEEMAIL:
|
||||||
|
case self::TYPE_INVOICEFOOTER:
|
||||||
return ($old === null);
|
return ($old === null);
|
||||||
}
|
}
|
||||||
return parent::shouldHide();
|
return parent::shouldHide();
|
||||||
|
@ -69,6 +81,10 @@ final class PhortuneMerchantTransaction
|
||||||
return ($this->getOldValue() !== null);
|
return ($this->getOldValue() !== null);
|
||||||
case self::TYPE_CONTACTINFO:
|
case self::TYPE_CONTACTINFO:
|
||||||
return ($this->getOldValue() !== null);
|
return ($this->getOldValue() !== null);
|
||||||
|
case self::TYPE_INVOICEEMAIL:
|
||||||
|
return ($this->getOldValue() !== null);
|
||||||
|
case self::TYPE_INVOICEFOOTER:
|
||||||
|
return ($this->getOldValue() !== null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::hasChangeDetails();
|
return parent::hasChangeDetails();
|
||||||
|
|
159
src/applications/phortune/view/PhortuneInvoiceView.php
Normal file
159
src/applications/phortune/view/PhortuneInvoiceView.php
Normal file
|
@ -0,0 +1,159 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhortuneInvoiceView extends AphrontTagView {
|
||||||
|
|
||||||
|
private $merchantName;
|
||||||
|
private $merchantLogo;
|
||||||
|
private $merchantContact;
|
||||||
|
private $merchantFooter;
|
||||||
|
private $accountName;
|
||||||
|
private $accountContact;
|
||||||
|
private $status;
|
||||||
|
private $content;
|
||||||
|
|
||||||
|
public function setMerchantName($name) {
|
||||||
|
$this->merchantName = $name;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMerchantLogo($logo) {
|
||||||
|
$this->merchantLogo = $logo;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMerchantContact($contact) {
|
||||||
|
$this->merchantContact = $contact;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMerchantFooter($footer) {
|
||||||
|
$this->merchantFooter = $footer;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAccountName($name) {
|
||||||
|
$this->accountName = $name;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAccountContact($contact) {
|
||||||
|
$this->accountContact = $contact;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setStatus($status) {
|
||||||
|
$this->status = $status;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setContent($content) {
|
||||||
|
$this->content = $content;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getTagAttributes() {
|
||||||
|
$classes = array();
|
||||||
|
$classes[] = 'phortune-invoice-view';
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'class' => implode(' ', $classes),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getTagContent() {
|
||||||
|
require_celerity_resource('phortune-invoice-css');
|
||||||
|
|
||||||
|
$logo = phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'phortune-invoice-logo',
|
||||||
|
),
|
||||||
|
phutil_tag(
|
||||||
|
'img',
|
||||||
|
array(
|
||||||
|
'height' => '50',
|
||||||
|
'width' => '50',
|
||||||
|
'alt' => $this->merchantName,
|
||||||
|
'src' => $this->merchantLogo,
|
||||||
|
)));
|
||||||
|
|
||||||
|
$to_title = phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'phortune-mini-header',
|
||||||
|
),
|
||||||
|
pht('To:'));
|
||||||
|
|
||||||
|
$bill_to = phutil_tag(
|
||||||
|
'td',
|
||||||
|
array(
|
||||||
|
'class' => 'phortune-invoice-to',
|
||||||
|
'width' => '50%',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
$to_title,
|
||||||
|
phutil_tag('strong', array(), $this->accountName),
|
||||||
|
phutil_tag('br', array()),
|
||||||
|
$this->accountContact,
|
||||||
|
));
|
||||||
|
|
||||||
|
$from_title = phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'phortune-mini-header',
|
||||||
|
),
|
||||||
|
pht('From:'));
|
||||||
|
|
||||||
|
$bill_from = phutil_tag(
|
||||||
|
'td',
|
||||||
|
array(
|
||||||
|
'class' => 'phortune-invoice-from',
|
||||||
|
'width' => '50%',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
$from_title,
|
||||||
|
phutil_tag('strong', array(), $this->merchantName),
|
||||||
|
phutil_tag('br', array()),
|
||||||
|
$this->merchantContact,
|
||||||
|
));
|
||||||
|
|
||||||
|
$contact = phutil_tag(
|
||||||
|
'table',
|
||||||
|
array(
|
||||||
|
'class' => 'phortune-invoice-contact',
|
||||||
|
'width' => '100%',
|
||||||
|
),
|
||||||
|
phutil_tag(
|
||||||
|
'tr',
|
||||||
|
array(),
|
||||||
|
array(
|
||||||
|
$bill_to,
|
||||||
|
$bill_from,
|
||||||
|
)));
|
||||||
|
|
||||||
|
$status = null;
|
||||||
|
if ($this->status) {
|
||||||
|
$status = phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'phortune-invoice-status',
|
||||||
|
),
|
||||||
|
$this->status);
|
||||||
|
}
|
||||||
|
|
||||||
|
$footer = phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'phortune-invoice-footer',
|
||||||
|
),
|
||||||
|
$this->merchantFooter);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
$logo,
|
||||||
|
$contact,
|
||||||
|
$status,
|
||||||
|
$this->content,
|
||||||
|
$footer,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
75
webroot/rsrc/css/application/phortune/phortune-invoice.css
Normal file
75
webroot/rsrc/css/application/phortune/phortune-invoice.css
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
/**
|
||||||
|
* @provides phortune-invoice-css
|
||||||
|
*/
|
||||||
|
|
||||||
|
.phortune-invoice-view {
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 16px auto;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phortune-invoice-view .phabricator-main-menu {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phortune-invoice-view .phabricator-standard-page-footer {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.device-desktop .phortune-invoice-view .phui-property-list-key {
|
||||||
|
width: 16%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.device-desktop .phortune-invoice-view .phui-property-list-value {
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phortune-invoice-logo {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phortune-invoice-logo img {
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phortune-invoice-contact {
|
||||||
|
margin-bottom: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phortune-invoice-contact td {
|
||||||
|
padding: 4px 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phortune-invoice-to {
|
||||||
|
border-right: 1px solid {$lightblueborder};
|
||||||
|
}
|
||||||
|
|
||||||
|
.phortune-mini-header {
|
||||||
|
color: {$lightbluetext};
|
||||||
|
font-weight: bold;
|
||||||
|
text-transform: uppercase;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
letter-spacing: 0.3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phortune-invoice-status {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phortune-invoice-status .phui-info-view {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phortune-invoice-view .phui-box.phui-object-box {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phortune-invoice-footer {
|
||||||
|
color: {$lightgreytext};
|
||||||
|
margin: 48px 0 64px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phortune-invoice-footer strong {
|
||||||
|
color: #000;
|
||||||
|
}
|
Loading…
Reference in a new issue