Merge pull request #21310 from eileenmcnaughton/prepro
[civicrm-core.git] / CRM / Case / Form / Task / PDF.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 contacts.
20 */
21 class CRM_Case_Form_Task_PDF extends CRM_Case_Form_Task {
22
23 use CRM_Contact_Form_Task_PDFTrait;
24
25 /**
26 * All the existing templates in the system.
27 *
28 * @var array
29 */
30 public $_templates = NULL;
31
32 public $_single = NULL;
33
34 public $_cid = NULL;
35
36 /**
37 * Build all the data structures needed to build the form.
38 */
39 public function preProcess() {
40 CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
41 $this->skipOnHold = $this->skipDeceased = FALSE;
42 parent::preProcess();
43 $this->setContactIDs();
44 }
45
46 /**
47 * Process the form after the input has been submitted and validated.
48 */
49 public function postProcess() {
50 CRM_Contact_Form_Task_PDFLetterCommon::postProcess($this);
51 }
52
53 /**
54 * List available tokens for this form.
55 *
56 * @return array
57 */
58 public function listTokens() {
59 $tokens = CRM_Core_SelectValues::contactTokens();
60 foreach ($this->_entityIds as $key => $caseId) {
61 $caseTypeId = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseId, 'case_type_id');
62 $tokens += CRM_Core_SelectValues::caseTokens($caseTypeId);
63 }
64 return $tokens;
65 }
66
67 }