[REF] dev/core#2790 move preProcess static to the trait
[civicrm-core.git] / CRM / Member / Form / Task / PDFLetter.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 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * This class provides the functionality to create PDF letter for a group of
20 * contacts or a single contact.
21 */
22 class CRM_Member_Form_Task_PDFLetter extends CRM_Member_Form_Task {
23
24 use CRM_Contact_Form_Task_PDFTrait;
25
26 /**
27 * All the existing templates in the system.
28 *
29 * @var array
30 */
31 public $_templates = NULL;
32
33 public $_single = NULL;
34
35 public $_cid = NULL;
36
37 /**
38 * Build all the data structures needed to build the form.
39 *
40 * @return void
41 */
42 public function preProcess() {
43 $this->skipOnHold = $this->skipDeceased = FALSE;
44 parent::preProcess();
45 $this->setContactIDs();
46 $this->preProcessPDF();
47 }
48
49 /**
50 * Build the form object.
51 *
52 *
53 * @return void
54 * @throws \CRM_Core_Exception
55 */
56 public function buildQuickForm() {
57 //enable form element
58 $this->assign('suppressForm', FALSE);
59 $this->addPDFElementsToForm();
60 }
61
62 /**
63 * Process the form after the input has been submitted and validated.
64 *
65 *
66 * @return void
67 */
68 public function postProcess() {
69 // TODO: rewrite using contribution token and one letter by contribution
70 $this->setContactIDs();
71 $skipOnHold = $this->skipOnHold ?? FALSE;
72 $skipDeceased = $this->skipDeceased ?? TRUE;
73 CRM_Member_Form_Task_PDFLetterCommon::postProcessMembers(
74 $this, $this->_memberIds, $skipOnHold, $skipDeceased, $this->_contactIds
75 );
76 }
77
78 /**
79 * List available tokens for this form.
80 *
81 * @return array
82 */
83 public function listTokens() {
84 $tokens = CRM_Core_SelectValues::contactTokens();
85 $tokens = array_merge(CRM_Core_SelectValues::membershipTokens(), $tokens);
86 return $tokens;
87 }
88
89 }