Merge pull request #17298 from demeritcowboy/activity-attachment-delete
[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 * $Id$
17 *
18 */
19
20 /**
21 * This class provides the functionality to create PDF letter for a group of
22 * contacts or a single contact.
23 */
24 class CRM_Member_Form_Task_PDFLetter extends CRM_Member_Form_Task {
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 CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
47 }
48
49 /**
50 * Set defaults.
51 * (non-PHPdoc)
52 * @see CRM_Core_Form::setDefaultValues()
53 */
54 public function setDefaultValues() {
55 return CRM_Contact_Form_Task_PDFLetterCommon::setDefaultValues();
56 }
57
58 /**
59 * Build the form object.
60 *
61 *
62 * @return void
63 */
64 public function buildQuickForm() {
65 //enable form element
66 $this->assign('suppressForm', FALSE);
67 CRM_Contact_Form_Task_PDFLetterCommon::buildQuickForm($this);
68 }
69
70 /**
71 * Process the form after the input has been submitted and validated.
72 *
73 *
74 * @return void
75 */
76 public function postProcess() {
77 // TODO: rewrite using contribution token and one letter by contribution
78 $this->setContactIDs();
79 $skipOnHold = $this->skipOnHold ?? FALSE;
80 $skipDeceased = $this->skipDeceased ?? TRUE;
81 CRM_Member_Form_Task_PDFLetterCommon::postProcessMembers(
82 $this, $this->_memberIds, $skipOnHold, $skipDeceased, $this->_contactIds
83 );
84 }
85
86 /**
87 * List available tokens for this form.
88 *
89 * @return array
90 */
91 public function listTokens() {
92 $tokens = CRM_Core_SelectValues::contactTokens();
93 $tokens = array_merge(CRM_Core_SelectValues::membershipTokens(), $tokens);
94 return $tokens;
95 }
96
97 }