Merge pull request #17580 from samuelsov/dev/core#1670
[civicrm-core.git] / CRM / Contribute / Form / Task / Invoice.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 use Dompdf\Dompdf;
13 use Dompdf\Options;
14
15 /**
16 *
17 * @package CRM
18 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 */
20
21 /**
22 * This class provides the functionality to email a group of
23 * contacts.
24 */
25 class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task {
26 /**
27 * Are we operating in "single mode", i.e. updating the task of only
28 * one specific contribution?
29 *
30 * @var bool
31 */
32 public $_single = FALSE;
33
34 /**
35 * Gives all the statues for conribution.
36 * @var int
37 */
38 public $_contributionStatusId;
39
40 /**
41 * Gives the HTML template of PDF Invoice.
42 * @var string
43 */
44 public $_messageInvoice;
45
46 /**
47 * This variable is used to assign parameters for HTML template of PDF Invoice.
48 * @var string
49 */
50 public $_invoiceTemplate;
51
52 /**
53 * Selected output.
54 * @var string
55 */
56 public $_selectedOutput;
57
58 /**
59 * Build all the data structures needed to build the form.
60 */
61 public function preProcess() {
62 $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
63 if ($id) {
64 $this->_contributionIds = [$id];
65 $this->_componentClause = " civicrm_contribution.id IN ( $id ) ";
66 $this->_single = TRUE;
67 $this->assign('totalSelectedContributions', 1);
68
69 // set the redirection after actions
70 $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
71 $url = CRM_Utils_System::url('civicrm/contact/view/contribution',
72 "action=view&reset=1&id={$id}&cid={$contactId}&context=contribution&selectedChild=contribute"
73 );
74
75 CRM_Core_Session::singleton()->pushUserContext($url);
76 }
77 else {
78 parent::preProcess();
79 }
80
81 // check that all the contribution ids have status Completed, Pending, Refunded, or Partially Paid.
82 $this->_contributionStatusId = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
83 $status = ['Completed', 'Pending', 'Refunded', 'Partially paid'];
84 $statusId = [];
85 foreach ($this->_contributionStatusId as $key => $value) {
86 if (in_array($value, $status)) {
87 $statusId[] = $key;
88 }
89 }
90 $Id = implode(",", $statusId);
91 $query = "SELECT count(*) FROM civicrm_contribution WHERE contribution_status_id NOT IN ($Id) AND {$this->_componentClause}";
92 $count = CRM_Core_DAO::singleValueQuery($query);
93 if ($count != 0) {
94 CRM_Core_Error::statusBounce(ts('Please select only contributions with Completed, Pending, Refunded, or Partially Paid status.'));
95 }
96
97 // we have all the contribution ids, so now we get the contact ids
98 parent::setContactIDs();
99 $this->assign('single', $this->_single);
100
101 $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
102 $urlParams = 'force=1';
103 if (CRM_Utils_Rule::qfKey($qfKey)) {
104 $urlParams .= "&qfKey=$qfKey";
105 }
106
107 $url = CRM_Utils_System::url('civicrm/contribute/search', $urlParams);
108 $breadCrumb = [
109 [
110 'url' => $url,
111 'title' => ts('Search Results'),
112 ],
113 ];
114
115 CRM_Utils_System::appendBreadCrumb($breadCrumb);
116
117 $this->_selectedOutput = CRM_Utils_Request::retrieve('select', 'String', $this);
118 $this->assign('selectedOutput', $this->_selectedOutput);
119
120 CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
121 if ($this->_selectedOutput == 'email') {
122 CRM_Utils_System::setTitle(ts('Email Invoice'));
123 }
124 else {
125 CRM_Utils_System::setTitle(ts('Print Contribution Invoice'));
126 }
127 }
128
129 /**
130 * Build the form object.
131 */
132 public function buildQuickForm() {
133 $this->preventAjaxSubmit();
134 if (CRM_Core_Permission::check('administer CiviCRM')) {
135 $this->assign('isAdmin', 1);
136 }
137
138 $this->add('select', 'from_email_address', ts('From'), $this->_fromEmails, TRUE);
139 if ($this->_selectedOutput != 'email') {
140 $this->addElement('radio', 'output', NULL, ts('Email Invoice'), 'email_invoice');
141 $this->addElement('radio', 'output', NULL, ts('PDF Invoice'), 'pdf_invoice');
142 $this->addRule('output', ts('Selection required'), 'required');
143 $this->addFormRule(['CRM_Contribute_Form_Task_Invoice', 'formRule']);
144 }
145 else {
146 $this->addRule('from_email_address', ts('From Email Address is required'), 'required');
147 }
148
149 $this->add('wysiwyg', 'email_comment', ts('If you would like to add personal message to email please add it here. (If sending to more then one receipient the same message will be sent to each contact.)'), [
150 'rows' => 2,
151 'cols' => 40,
152 ]);
153
154 $this->addButtons([
155 [
156 'type' => 'upload',
157 'name' => $this->_selectedOutput == 'email' ? ts('Send Email') : ts('Process Invoice(s)'),
158 'isDefault' => TRUE,
159 ],
160 [
161 'type' => 'cancel',
162 'name' => ts('Cancel'),
163 ],
164 ]);
165 }
166
167 /**
168 * Global validation rules for the form.
169 *
170 * @param array $values
171 *
172 * @return array
173 * list of errors to be posted back to the form
174 */
175 public static function formRule($values) {
176 $errors = [];
177
178 if ($values['output'] == 'email_invoice' && empty($values['from_email_address'])) {
179 $errors['from_email_address'] = ts("From Email Address is required");
180 }
181
182 return $errors;
183 }
184
185 /**
186 * Process the form after the input has been submitted and validated.
187 */
188 public function postProcess() {
189 $params = $this->controller->exportValues($this->_name);
190 self::printPDF($this->_contributionIds, $params, $this->_contactIds);
191 }
192
193 /**
194 * Process the PDf and email with activity and attachment on click of Print Invoices.
195 *
196 * @param array $contribIDs
197 * Contribution Id.
198 * @param array $params
199 * Associated array of submitted values.
200 * @param array $contactIds
201 * Contact Id.
202 */
203 public static function printPDF($contribIDs, &$params, $contactIds) {
204 // get all the details needed to generate a invoice
205 $messageInvoice = [];
206 $invoiceTemplate = CRM_Core_Smarty::singleton();
207 $invoiceElements = CRM_Contribute_Form_Task_PDF::getElements($contribIDs, $params, $contactIds);
208
209 // gives the status id when contribution status is 'Refunded'
210 $contributionStatusID = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
211 $refundedStatusId = CRM_Utils_Array::key('Refunded', $contributionStatusID);
212 $cancelledStatusId = CRM_Utils_Array::key('Cancelled', $contributionStatusID);
213 $pendingStatusId = CRM_Utils_Array::key('Pending', $contributionStatusID);
214
215 foreach ($invoiceElements['details'] as $contribID => $detail) {
216 $input = $ids = $objects = [];
217 if (in_array($detail['contact'], $invoiceElements['excludeContactIds'])) {
218 continue;
219 }
220
221 $input['component'] = $detail['component'];
222
223 $ids['contact'] = $detail['contact'];
224 $ids['contribution'] = $contribID;
225 $ids['contributionRecur'] = NULL;
226 $ids['contributionPage'] = NULL;
227 $ids['membership'] = $detail['membership'] ?? NULL;
228 $ids['participant'] = $detail['participant'] ?? NULL;
229 $ids['event'] = $detail['event'] ?? NULL;
230
231 if (!$invoiceElements['baseIPN']->validateData($input, $ids, $objects, FALSE)) {
232 CRM_Core_Error::statusBounce('Supplied data was not able to be validated');
233 }
234
235 $contribution = &$objects['contribution'];
236
237 $input['amount'] = $contribution->total_amount;
238 $input['invoice_id'] = $contribution->invoice_id;
239 $input['receive_date'] = $contribution->receive_date;
240 $input['contribution_status_id'] = $contribution->contribution_status_id;
241 $input['organization_name'] = $contribution->_relatedObjects['contact']->organization_name;
242
243 $objects['contribution']->receive_date = CRM_Utils_Date::isoToMysql($objects['contribution']->receive_date);
244
245 // Fetch the billing address. getValues should prioritize the billing
246 // address, otherwise will return the primary address.
247 $billingAddress = [];
248
249 $addressDetails = CRM_Core_BAO_Address::getValues([
250 'contact_id' => $contribution->contact_id,
251 'is_billing' => 1,
252 ]);
253
254 if (!empty($addressDetails)) {
255 $billingAddress = array_shift($addressDetails);
256 }
257
258 if ($contribution->contribution_status_id == $refundedStatusId || $contribution->contribution_status_id == $cancelledStatusId) {
259 $creditNoteId = $contribution->creditnote_id;
260 }
261 if (!$contribution->invoice_number) {
262 $contribution->invoice_number = CRM_Contribute_BAO_Contribution::getInvoiceNumber($contribution->id);
263 }
264
265 //to obtain due date for PDF invoice
266 $contributionReceiveDate = date('F j,Y', strtotime(date($input['receive_date'])));
267 $invoiceDate = date("F j, Y");
268 $dueDateSetting = Civi::settings()->get('invoice_due_date');
269 $dueDatePeriodSetting = Civi::settings()->get('invoice_due_date_period');
270 $dueDate = date('F j, Y', strtotime($contributionReceiveDate . "+" . $dueDateSetting . "" . $dueDatePeriodSetting));
271
272 $amountPaid = CRM_Core_BAO_FinancialTrxn::getTotalPayments($contribID, TRUE);
273 $amountDue = ($input['amount'] - $amountPaid);
274
275 // retrieving the subtotal and sum of same tax_rate
276 $dataArray = [];
277 $subTotal = 0;
278 $lineItem = CRM_Price_BAO_LineItem::getLineItemsByContributionID($contribID);
279 foreach ($lineItem as $taxRate) {
280 if (isset($dataArray[(string) $taxRate['tax_rate']])) {
281 $dataArray[(string) $taxRate['tax_rate']] = $dataArray[(string) $taxRate['tax_rate']] + CRM_Utils_Array::value('tax_amount', $taxRate);
282 }
283 else {
284 $dataArray[(string) $taxRate['tax_rate']] = $taxRate['tax_amount'] ?? NULL;
285 }
286 $subTotal += CRM_Utils_Array::value('subTotal', $taxRate);
287 }
288
289 // to email the invoice
290 $mailDetails = [];
291 $values = [];
292 if ($contribution->_component == 'event') {
293 $daoName = 'CRM_Event_DAO_Event';
294 $pageId = $contribution->_relatedObjects['event']->id;
295 $mailElements = [
296 'title',
297 'confirm_from_name',
298 'confirm_from_email',
299 ];
300 CRM_Core_DAO::commonRetrieveAll($daoName, 'id', $pageId, $mailDetails, $mailElements);
301 $values['title'] = $mailDetails[$contribution->_relatedObjects['event']->id]['title'] ?? NULL;
302 $values['confirm_from_name'] = $mailDetails[$contribution->_relatedObjects['event']->id]['confirm_from_name'] ?? NULL;
303 $values['confirm_from_email'] = $mailDetails[$contribution->_relatedObjects['event']->id]['confirm_from_email'] ?? NULL;
304
305 $title = $mailDetails[$contribution->_relatedObjects['event']->id]['title'] ?? NULL;
306 }
307 elseif ($contribution->_component == 'contribute') {
308 $daoName = 'CRM_Contribute_DAO_ContributionPage';
309 $pageId = $contribution->contribution_page_id;
310 $mailElements = [
311 'title',
312 'receipt_from_name',
313 'receipt_from_email',
314 'cc_receipt',
315 'bcc_receipt',
316 ];
317 CRM_Core_DAO::commonRetrieveAll($daoName, 'id', $pageId, $mailDetails, $mailElements);
318
319 $values['title'] = CRM_Utils_Array::value('title', CRM_Utils_Array::value($contribution->contribution_page_id, $mailDetails));
320 $values['receipt_from_name'] = CRM_Utils_Array::value('receipt_from_name', CRM_Utils_Array::value($contribution->contribution_page_id, $mailDetails));
321 $values['receipt_from_email'] = CRM_Utils_Array::value('receipt_from_email', CRM_Utils_Array::value($contribution->contribution_page_id, $mailDetails));
322 $values['cc_receipt'] = CRM_Utils_Array::value('cc_receipt', CRM_Utils_Array::value($contribution->contribution_page_id, $mailDetails));
323 $values['bcc_receipt'] = CRM_Utils_Array::value('bcc_receipt', CRM_Utils_Array::value($contribution->contribution_page_id, $mailDetails));
324
325 $title = CRM_Utils_Array::value('title', CRM_Utils_Array::value($contribution->contribution_page_id, $mailDetails));
326 }
327 $source = $contribution->source;
328
329 $config = CRM_Core_Config::singleton();
330 if (!isset($params['forPage'])) {
331 $config->doNotAttachPDFReceipt = 1;
332 }
333
334 // get organization address
335 $domain = CRM_Core_BAO_Domain::getDomain();
336 $locParams = ['contact_id' => $domain->contact_id];
337 $locationDefaults = CRM_Core_BAO_Location::getValues($locParams);
338 if (isset($locationDefaults['address'][1]['state_province_id'])) {
339 $stateProvinceAbbreviationDomain = CRM_Core_PseudoConstant::stateProvinceAbbreviation($locationDefaults['address'][1]['state_province_id']);
340 }
341 else {
342 $stateProvinceAbbreviationDomain = '';
343 }
344 if (isset($locationDefaults['address'][1]['country_id'])) {
345 $countryDomain = CRM_Core_PseudoConstant::country($locationDefaults['address'][1]['country_id']);
346 }
347 else {
348 $countryDomain = '';
349 }
350
351 $invoiceNotes = Civi::settings()->get('invoice_notes') ?? NULL;
352
353 // parameters to be assign for template
354 $tplParams = [
355 'title' => $title,
356 'component' => $input['component'],
357 'id' => $contribution->id,
358 'source' => $source,
359 'invoice_number' => $contribution->invoice_number,
360 'invoice_id' => $contribution->invoice_id,
361 'resourceBase' => $config->userFrameworkResourceURL,
362 'defaultCurrency' => $config->defaultCurrency,
363 'amount' => $contribution->total_amount,
364 'amountDue' => $amountDue,
365 'amountPaid' => $amountPaid,
366 'invoice_date' => $invoiceDate,
367 'dueDate' => $dueDate,
368 'notes' => $invoiceNotes,
369 'display_name' => $contribution->_relatedObjects['contact']->display_name,
370 'lineItem' => $lineItem,
371 'dataArray' => $dataArray,
372 'refundedStatusId' => $refundedStatusId,
373 'pendingStatusId' => $pendingStatusId,
374 'cancelledStatusId' => $cancelledStatusId,
375 'contribution_status_id' => $contribution->contribution_status_id,
376 'contributionStatusName' => CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $contribution->contribution_status_id),
377 'subTotal' => $subTotal,
378 'street_address' => $billingAddress['street_address'] ?? NULL,
379 'supplemental_address_1' => $billingAddress['supplemental_address_1'] ?? NULL,
380 'supplemental_address_2' => $billingAddress['supplemental_address_2'] ?? NULL,
381 'supplemental_address_3' => $billingAddress['supplemental_address_3'] ?? NULL,
382 'city' => $billingAddress['city'] ?? NULL,
383 'postal_code' => $billingAddress['postal_code'] ?? NULL,
384 'state_province' => $billingAddress['state_province'] ?? NULL,
385 'state_province_abbreviation' => $billingAddress['state_province_abbreviation'] ?? NULL,
386 // Kept for backwards compatibility
387 'stateProvinceAbbreviation' => $billingAddress['state_province_abbreviation'] ?? NULL,
388 'country' => $billingAddress['country'] ?? NULL,
389 'is_pay_later' => $contribution->is_pay_later,
390 'organization_name' => $contribution->_relatedObjects['contact']->organization_name,
391 'domain_organization' => $domain->name,
392 'domain_street_address' => CRM_Utils_Array::value('street_address', CRM_Utils_Array::value('1', $locationDefaults['address'])),
393 'domain_supplemental_address_1' => CRM_Utils_Array::value('supplemental_address_1', CRM_Utils_Array::value('1', $locationDefaults['address'])),
394 'domain_supplemental_address_2' => CRM_Utils_Array::value('supplemental_address_2', CRM_Utils_Array::value('1', $locationDefaults['address'])),
395 'domain_supplemental_address_3' => CRM_Utils_Array::value('supplemental_address_3', CRM_Utils_Array::value('1', $locationDefaults['address'])),
396 'domain_city' => CRM_Utils_Array::value('city', CRM_Utils_Array::value('1', $locationDefaults['address'])),
397 'domain_postal_code' => CRM_Utils_Array::value('postal_code', CRM_Utils_Array::value('1', $locationDefaults['address'])),
398 'domain_state' => $stateProvinceAbbreviationDomain,
399 'domain_country' => $countryDomain,
400 'domain_email' => CRM_Utils_Array::value('email', CRM_Utils_Array::value('1', $locationDefaults['email'])),
401 'domain_phone' => CRM_Utils_Array::value('phone', CRM_Utils_Array::value('1', $locationDefaults['phone'])),
402 ];
403
404 if (isset($creditNoteId)) {
405 $tplParams['creditnote_id'] = $creditNoteId;
406 }
407
408 $pdfFileName = $contribution->invoice_number . ".pdf";
409 $sendTemplateParams = [
410 'groupName' => 'msg_tpl_workflow_contribution',
411 'valueName' => 'contribution_invoice_receipt',
412 'contactId' => $contribution->contact_id,
413 'tplParams' => $tplParams,
414 'PDFFilename' => $pdfFileName,
415 ];
416
417 // from email address
418 $fromEmailAddress = $params['from_email_address'] ?? NULL;
419
420 // condition to check for download PDF Invoice or email Invoice
421 if ($invoiceElements['createPdf']) {
422 list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
423 if (isset($params['forPage'])) {
424 return $html;
425 }
426 else {
427 $mail = [
428 'subject' => $subject,
429 'body' => $message,
430 'html' => $html,
431 ];
432 if ($mail['html']) {
433 $messageInvoice[] = $mail['html'];
434 }
435 else {
436 $messageInvoice[] = nl2br($mail['body']);
437 }
438 }
439 }
440 elseif ($contribution->_component == 'contribute') {
441 $email = CRM_Contact_BAO_Contact::getPrimaryEmail($contribution->contact_id);
442
443 $sendTemplateParams['tplParams'] = array_merge($tplParams, ['email_comment' => $invoiceElements['params']['email_comment']]);
444 $sendTemplateParams['from'] = $fromEmailAddress;
445 $sendTemplateParams['toEmail'] = $email;
446 $sendTemplateParams['cc'] = $values['cc_receipt'] ?? NULL;
447 $sendTemplateParams['bcc'] = $values['bcc_receipt'] ?? NULL;
448
449 list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
450 // functions call for adding activity with attachment
451 $fileName = self::putFile($html, $pdfFileName);
452 self::addActivities($subject, $contribution->contact_id, $fileName, $params, $contribution->id);
453 }
454 elseif ($contribution->_component == 'event') {
455 $email = CRM_Contact_BAO_Contact::getPrimaryEmail($contribution->contact_id);
456
457 $sendTemplateParams['tplParams'] = array_merge($tplParams, ['email_comment' => $invoiceElements['params']['email_comment']]);
458 $sendTemplateParams['from'] = $fromEmailAddress;
459 $sendTemplateParams['toEmail'] = $email;
460 $sendTemplateParams['cc'] = $values['cc_confirm'] ?? NULL;
461 $sendTemplateParams['bcc'] = $values['bcc_confirm'] ?? NULL;
462
463 list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
464 // functions call for adding activity with attachment
465 $fileName = self::putFile($html, $pdfFileName);
466 self::addActivities($subject, $contribution->contact_id, $fileName, $params, $contribution->id);
467 }
468 $invoiceTemplate->clearTemplateVars();
469 }
470
471 if ($invoiceElements['createPdf']) {
472 if (isset($params['forPage'])) {
473 return $html;
474 }
475 else {
476 CRM_Utils_PDF_Utils::html2pdf($messageInvoice, $pdfFileName, FALSE, [
477 'margin_top' => 10,
478 'margin_left' => 65,
479 'metric' => 'px',
480 ]);
481 // functions call for adding activity with attachment
482 $fileName = self::putFile($html, $pdfFileName);
483 self::addActivities($subject, $contactIds, $fileName, $params);
484
485 CRM_Utils_System::civiExit();
486 }
487 }
488 else {
489 if ($invoiceElements['suppressedEmails']) {
490 $status = ts('Email was NOT sent to %1 contacts (no email address on file, or communication preferences specify DO NOT EMAIL, or contact is deceased).', [1 => $invoiceElements['suppressedEmails']]);
491 $msgTitle = ts('Email Error');
492 $msgType = 'error';
493 }
494 else {
495 $status = ts('Your mail has been sent.');
496 $msgTitle = ts('Sent');
497 $msgType = 'success';
498 }
499 CRM_Core_Session::setStatus($status, $msgTitle, $msgType);
500 }
501 }
502
503 /**
504 * Add activity for Email Invoice and the PDF Invoice.
505 *
506 * @param string $subject
507 * Activity subject.
508 * @param array $contactIds
509 * Contact Id.
510 * @param string $fileName
511 * Gives the location with name of the file.
512 * @param array $params
513 * For invoices.
514 * @param int $contributionId
515 * Contribution Id.
516 *
517 */
518 public static function addActivities($subject, $contactIds, $fileName, $params, $contributionId = NULL) {
519 $session = CRM_Core_Session::singleton();
520 $userID = $session->get('userID');
521 $config = CRM_Core_Config::singleton();
522 $config->doNotAttachPDFReceipt = 1;
523
524 if (!empty($params['output']) && $params['output'] == 'pdf_invoice') {
525 $activityType = 'Downloaded Invoice';
526 }
527 else {
528 $activityType = 'Emailed Invoice';
529 }
530
531 $activityParams = [
532 'subject' => $subject,
533 'source_contact_id' => $userID,
534 'target_contact_id' => $contactIds,
535 'activity_type_id' => $activityType,
536 'activity_date_time' => date('YmdHis'),
537 'attachFile_1' => [
538 'uri' => $fileName,
539 'type' => 'application/pdf',
540 'location' => $fileName,
541 'upload_date' => date('YmdHis'),
542 ],
543 ];
544 if ($contributionId) {
545 $activityParams['source_record_id'] = $contributionId;
546 }
547 civicrm_api3('Activity', 'create', $activityParams);
548 }
549
550 /**
551 * Create the Invoice file in upload folder for attachment.
552 *
553 * @param string $html
554 * Content for pdf in html format.
555 *
556 * @param string $name
557 *
558 * @return string
559 * Name of file which is in pdf format
560 */
561 public static function putFile($html, $name = 'Invoice.pdf') {
562 $options = new Options();
563 $options->set('isRemoteEnabled', TRUE);
564
565 $doc = new DOMPDF($options);
566 $doc->load_html($html);
567 $doc->render();
568 $html = $doc->output();
569 $config = CRM_Core_Config::singleton();
570 $fileName = $config->uploadDir . $name;
571 file_put_contents($fileName, $html);
572 return $fileName;
573 }
574
575 /**
576 * Callback to perform action on Print Invoice button.
577 */
578 public static function getPrintPDF() {
579 $contributionId = CRM_Utils_Request::retrieve('id', 'Positive', CRM_Core_DAO::$_nullObject, FALSE);
580 $contributionIDs = [$contributionId];
581 $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, FALSE);
582 $params = ['output' => 'pdf_invoice'];
583 CRM_Contribute_Form_Task_Invoice::printPDF($contributionIDs, $params, $contactId);
584 }
585
586 }