From 2826a42eec988b4a88f517305260db8f59f3e04e Mon Sep 17 00:00:00 2001 From: Rohan Katkar Date: Fri, 6 Jun 2014 12:15:10 +0530 Subject: [PATCH] VAT-388 some minor changes for code --- CRM/Contribute/Form/Task/Invoice.php | 14 +++++++------- CRM/Contribute/Form/Task/PDF.php | 15 +++++++++------ CRM/Price/BAO/LineItem.php | 9 ++++++++- .../contribution_invoice_receipt_html.tpl | 2 +- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/CRM/Contribute/Form/Task/Invoice.php b/CRM/Contribute/Form/Task/Invoice.php index 5cbdd8a856..17cf8b7ac4 100644 --- a/CRM/Contribute/Form/Task/Invoice.php +++ b/CRM/Contribute/Form/Task/Invoice.php @@ -89,7 +89,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { $statusId = array(); foreach ($this->_contributionStatusId as $key => $value) { if (in_array($value, $status)) { - $statusId[]= $key; + $statusId[] = $key; } } $Id = implode(",", $statusId); @@ -167,7 +167,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { // gives the status id when contribution status is 'Refunded' $refundedStatusId = CRM_Utils_Array::key('Refunded', $this->_contributionStatusId); - foreach ($invoiceElements['details'] as $invoiceElements['contribID'] => $detail) { + foreach ($invoiceElements['details'] as $contribID => $detail) { $input = $ids = $objects = array(); if (in_array($detail['contact'], $invoiceElements['excludeContactIds'])) { @@ -177,7 +177,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { $input['component'] = $detail['component']; $ids['contact'] = $detail['contact']; - $ids['contribution'] = $invoiceElements['contribID']; + $ids['contribution'] = $contribID; $ids['contributionRecur'] = NULL; $ids['contributionPage'] = NULL; $ids['membership'] = CRM_Utils_Array::value('membership', $detail); @@ -216,7 +216,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { $stateProvinceAbbreviation = CRM_Core_PseudoConstant::stateProvinceAbbreviation($billingAddress[$contribution->contact_id]['state_province_id']); // getting data from admin page - $prefixValue = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,'contribution_invoice_settings'); + $prefixValue = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,'contribution_invoice_settings'); if ($contribution->contribution_status_id == $refundedStatusId) { $invoiceId = CRM_Utils_Array::value('credit_notes_prefix', $prefixValue)."".$contribution->id; @@ -231,7 +231,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { $dueDate = date('F j ,Y', strtotime($contributionReceiveDate."+".$prefixValue['due_date']."". $prefixValue['due_date_period'])); if ($input['component'] == 'contribute') { - $eid = $invoiceElements['contribID']; + $eid = $contribID; $etable = 'contribution'; } else { @@ -360,7 +360,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { elseif ($contribution->_component == 'contribute') { $email = CRM_Contact_BAO_Contact::getPrimaryEmail($contribution->contact_id); - $sendTemplateParams['tplParams'] =array_merge($tplParams,array('email_comment' => $invoiceElements['params']['email_comment'])); + $sendTemplateParams['tplParams'] = array_merge($tplParams,array('email_comment' => $invoiceElements['params']['email_comment'])); $sendTemplateParams['from'] = CRM_Utils_Array::value('receipt_from_name', $values) . ' <' . $mailDetails[$contribution->contribution_page_id]['receipt_from_email']. '>'; $sendTemplateParams['toEmail'] = $email; $sendTemplateParams['cc'] = CRM_Utils_Array::value('cc_receipt', $values); @@ -371,7 +371,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { elseif ($contribution->_component == 'event') { $email = CRM_Contact_BAO_Contact::getPrimaryEmail($contribution->contact_id); - $sendTemplateParams['tplParams'] =array_merge($tplParams,array('email_comment' => $invoiceElements['params']['email_comment'])); + $sendTemplateParams['tplParams'] = array_merge($tplParams,array('email_comment' => $invoiceElements['params']['email_comment'])); $sendTemplateParams['from'] = CRM_Utils_Array::value('confirm_from_name', $values) . ' <' . $mailDetails[$contribution->_relatedObjects['event']->id]['confirm_from_email']. '>'; $sendTemplateParams['toEmail'] = $email; $sendTemplateParams['cc'] = CRM_Utils_Array::value('cc_confirm', $values); diff --git a/CRM/Contribute/Form/Task/PDF.php b/CRM/Contribute/Form/Task/PDF.php index 445732617f..a89e05afc5 100644 --- a/CRM/Contribute/Form/Task/PDF.php +++ b/CRM/Contribute/Form/Task/PDF.php @@ -151,12 +151,12 @@ AND {$this->_componentClause}"; */ public function postProcess() { // get all the details needed to generate a receipt - $message = array(); - $template = CRM_Core_Smarty::singleton(); + $message = array(); + $template = CRM_Core_Smarty::singleton(); - $elements = self::getElements(); + $elements = self::getElements(); - foreach ($elements['details'] as $elements['contribID'] => $detail) { + foreach ($elements['details'] as $contribID => $detail) { $input = $ids = $objects = array(); if (in_array($detail['contact'], $elements['excludeContactIds'])) { @@ -166,7 +166,7 @@ AND {$this->_componentClause}"; $input['component'] = $detail['component']; $ids['contact'] = $detail['contact']; - $ids['contribution'] = $elements['contribID']; + $ids['contribution'] = $contribID; $ids['contributionRecur'] = NULL; $ids['contributionPage'] = NULL; $ids['membership'] = CRM_Utils_Array::value('membership', $detail); @@ -230,10 +230,12 @@ AND {$this->_componentClause}"; } /** - * to get elements of postprocess function + * declaration of common variables for Invoice and PDF * * @access public * + * @return array array of common elements + * */ public function getElements() { $pdfElements = array(); @@ -272,6 +274,7 @@ AND {$this->_componentClause}"; } } $pdfElements['excludeContactIds'] = $excludeContactIds; + return $pdfElements; } } diff --git a/CRM/Price/BAO/LineItem.php b/CRM/Price/BAO/LineItem.php index 88e8fd9788..1a16f1ee12 100644 --- a/CRM/Price/BAO/LineItem.php +++ b/CRM/Price/BAO/LineItem.php @@ -424,7 +424,14 @@ AND li.entity_id = {$entityId} } /** - * Function to calculate tax rate in percentage + * Calculate tax rate in percentage + * + * @param $lineItemId an assoc array of lineItem + * + * @return tax rate + * + * @access public + * @static */ public static function calculateTaxRate($lineItemId) { if ($lineItemId['html_type'] == 'Text') { diff --git a/xml/templates/message_templates/contribution_invoice_receipt_html.tpl b/xml/templates/message_templates/contribution_invoice_receipt_html.tpl index 81d4b3ddf1..76c4843dfd 100644 --- a/xml/templates/message_templates/contribution_invoice_receipt_html.tpl +++ b/xml/templates/message_templates/contribution_invoice_receipt_html.tpl @@ -7,7 +7,7 @@ - +
-- 2.25.1