$this->_componentClause = " civicrm_contribution.id IN ( $id ) ";
$this->_single = TRUE;
$this->assign('totalSelectedContributions', 1);
+
+ // set the redirection after actions
+ $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
+ $url = CRM_Utils_System::url('civicrm/contact/view/contribution',
+ "action=view&reset=1&id={$id}&cid={$contactId}&context=contribution&selectedChild=contribute"
+ );
+
+ CRM_Core_Session::singleton()->pushUserContext($url);
}
else {
parent::preProcess();
'cols' => 40
));
- if (in_array("email", $this->urlPath)) {
+ if ($this->_selectedOutput == 'email') {
$this->addButtons(array(
array(
- 'type' => 'next',
+ 'type' => 'upload',
'name' => ts('Email Invoice'),
'isDefault' => TRUE,
),
array(
- 'type' => 'back',
+ 'type' => 'cancel',
'name' => ts('Cancel'),
),
)
else {
$this->addButtons(array(
array(
- 'type' => 'next',
+ 'type' => 'upload',
'name' => ts('Process Invoice(s)'),
'isDefault' => TRUE,
),
array(
- 'type' => 'back',
+ 'type' => 'cancel',
'name' => ts('Cancel'),
),
)
*/
public function postProcess() {
$params = $this->controller->exportValues($this->_name);
- $this->printPDF($this->_contributionIds, $params, $this->_contactIds);
+ $this->printPDF($this->_contributionIds, $params, $this->_contactIds, $this);
}
/**
* on click of Print Invoices
*
* @param array $contribIDs Contribution Id
- * @param array $params for pdf or email invoices
+ * @param array $params associated array of submitted values
* @param array $contactIds Contact Id
+ * @param object $form form object
* @static
*
*/
- static function printPDF($contribIDs, $params, $contactIds) {
+ static function printPDF($contribIDs, &$params, $contactIds, &$form) {
// get all the details needed to generate a invoice
$messageInvoice = array();
$invoiceTemplate = CRM_Core_Smarty::singleton();
$addressParams = array('contact_id' => $contribution->contact_id);
$addressDetails = CRM_Core_BAO_Address::getValues($addressParams);
- // to get billing address if present
+ // to get billing address if present
$billingAddress = array();
foreach ($addressDetails as $key => $address) {
if ((isset($address['is_billing']) && $address['is_billing'] == 1) && (isset($address['is_primary']) && $address['is_primary'] == 1) && $address['contact_id'] == $contribution->contact_id) {
if ($input['component'] == 'contribute') {
$eid = $contribID;
$etable = 'contribution';
+ $lineItem = CRM_Price_BAO_LineItem::getLineItems($eid, $etable, NULL, TRUE, TRUE);
}
else {
$eid = $contribution->_relatedObjects['participant']->id;
$etable = 'participant';
+ $lineItem = CRM_Price_BAO_LineItem::getLineItems($eid, $etable);
}
- //TO DO: Need to do changes for partially paid to display amount due on PDF invoice
+ //TO DO: Need to do changes for partially paid to display amount due on PDF invoice
$amountDue = ($input['amount'] - $input['amount']);
- // retreiving the subtotal and sum of same tax_rate
- $lineItem = CRM_Price_BAO_LineItem::getLineItems($eid, $etable);
+ // retreiving the subtotal and sum of same tax_rate
$dataArray = array();
$subTotal = 0;
foreach ($lineItem as $entity_id => $taxRate) {
'id' => $contribution->id,
'source' => $source,
'invoice_id' => $invoiceId,
- 'resourceBase' => $config->resourceBase,
+ 'resourceBase' => $config->userFrameworkResourceURL,
'defaultCurrency' => $config->defaultCurrency,
'amount' => $contribution->total_amount,
'amountDue' => $amountDue,
if (isset($creditNoteId)) {
$tplParams['creditnote_id'] = $creditNoteId;
}
-
+
$sendTemplateParams = array(
'groupName' => 'msg_tpl_workflow_contribution',
'valueName' => 'contribution_invoice_receipt',
file_put_contents($fileName, $html);
return $fileName;
}
+
+ /**
+ * Callback to perform action on Print Invoice button.
+ */
+ static function getPrintPDF() {
+ $contributionId = CRM_Utils_Request::retrieve('id', 'Positive', CRM_Core_DAO::$_nullObject, FALSE);
+ $contributionIDs = array($contributionId);
+ $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, FALSE);
+ $params = array('output' => 'pdf_invoice');
+ CRM_Contribute_Form_Task_Invoice::printPDF($contributionIDs, $params, $contactId, CRM_Core_DAO::$_nullObject);
+ }
}