From: Seamus Lee Date: Fri, 1 May 2020 21:40:12 +0000 (+1000) Subject: [REF] Fix retreiving invoice related settings when doing complete transaction X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e3eb02051a8142b3d3180de97efb4ab5cfca2c40;p=civicrm-core.git [REF] Fix retreiving invoice related settings when doing complete transaction --- diff --git a/CRM/Contribute/BAO/ContributionPage.php b/CRM/Contribute/BAO/ContributionPage.php index d050ef3d7e..32e8555bcd 100644 --- a/CRM/Contribute/BAO/ContributionPage.php +++ b/CRM/Contribute/BAO/ContributionPage.php @@ -447,9 +447,9 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio //send email with pdf invoice $template = CRM_Core_Smarty::singleton(); $taxAmt = $template->get_template_vars('dataArray'); - $prefixValue = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = $prefixValue['invoicing'] ?? NULL; - if (isset($invoicing) && isset($prefixValue['is_email_pdf'])) { + $isEmailPDF = Civi::settings()->get('invoice_is_email_pdf'); + $invoicing = Civi::settings()->get('invoicing'); + if ($invoicing && !empty($isEmailPDF)) { $sendTemplateParams['isEmailPdf'] = TRUE; $sendTemplateParams['contributionId'] = $values['contribution_id']; } diff --git a/CRM/Contribute/Form/Task/Invoice.php b/CRM/Contribute/Form/Task/Invoice.php index fd7db686e2..2be79628b1 100644 --- a/CRM/Contribute/Form/Task/Invoice.php +++ b/CRM/Contribute/Form/Task/Invoice.php @@ -212,9 +212,6 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { $cancelledStatusId = CRM_Utils_Array::key('Cancelled', $contributionStatusID); $pendingStatusId = CRM_Utils_Array::key('Pending', $contributionStatusID); - // getting data from admin page - $prefixValue = Civi::settings()->get('contribution_invoice_settings'); - foreach ($invoiceElements['details'] as $contribID => $detail) { $input = $ids = $objects = []; if (in_array($detail['contact'], $invoiceElements['excludeContactIds'])) { @@ -268,7 +265,9 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { //to obtain due date for PDF invoice $contributionReceiveDate = date('F j,Y', strtotime(date($input['receive_date']))); $invoiceDate = date("F j, Y"); - $dueDate = date('F j, Y', strtotime($contributionReceiveDate . "+" . $prefixValue['due_date'] . "" . $prefixValue['due_date_period'])); + $dueDateSetting = Civi::settings()->get('invoice_due_date'); + $dueDatePeriodSetting = Civi::settings()->get('invoice_due_date_period'); + $dueDate = date('F j, Y', strtotime($contributionReceiveDate . "+" . $dueDateSetting . "" . $dueDatePeriodSetting)); $amountPaid = CRM_Core_BAO_FinancialTrxn::getTotalPayments($contribID, TRUE); $amountDue = ($input['amount'] - $amountPaid); @@ -349,6 +348,8 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { $countryDomain = ''; } + $invoiceNotes = Civi::settings()->get('invoice_notes') ?? NULL; + // parameters to be assign for template $tplParams = [ 'title' => $title, @@ -364,7 +365,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { 'amountPaid' => $amountPaid, 'invoice_date' => $invoiceDate, 'dueDate' => $dueDate, - 'notes' => $prefixValue['notes'] ?? NULL, + 'notes' => $invoiceNotes, 'display_name' => $contribution->_relatedObjects['contact']->display_name, 'lineItem' => $lineItem, 'dataArray' => $dataArray,