Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
06b69b18 | 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * This class provides the functionality to create PDF letter for a group of | |
38 | * contacts or a single contact. | |
39 | */ | |
40 | class CRM_Contact_Form_Task_PDF extends CRM_Contact_Form_Task { | |
41 | ||
42 | /** | |
100fef9d | 43 | * All the existing templates in the system |
6a488035 TO |
44 | * |
45 | * @var array | |
46 | */ | |
47 | public $_templates = NULL; | |
48 | ||
49 | public $_single = NULL; | |
50 | ||
51 | public $_cid = NULL; | |
52 | ||
53 | public $_activityId = NULL; | |
54 | ||
55 | /** | |
100fef9d | 56 | * Build all the data structures needed to build the form |
6a488035 TO |
57 | * |
58 | * @return void | |
6a488035 | 59 | */ |
00be9182 | 60 | public function preProcess() { |
6a488035 TO |
61 | |
62 | $this->skipOnHold = $this->skipDeceased = FALSE; | |
63 | CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this); | |
64 | ||
65 | // store case id if present | |
66 | $this->_caseId = CRM_Utils_Request::retrieve('caseid', 'Positive', $this, FALSE); | |
67 | ||
68 | // retrieve contact ID if this is 'single' mode | |
69 | $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE); | |
70 | ||
71 | if ($cid) { | |
72 | // this is true in non-search context / single mode | |
73 | // in search context 'id' is the default profile id for search display | |
74 | // CRM-11227 | |
75 | $this->_activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE); | |
76 | } | |
77 | ||
78 | if ($cid) { | |
79 | CRM_Contact_Form_Task_PDFLetterCommon::preProcessSingle($this, $cid); | |
80 | $this->_single = TRUE; | |
81 | $this->_cid = $cid; | |
82 | } | |
83 | else { | |
84 | parent::preProcess(); | |
85 | } | |
86 | $this->assign('single', $this->_single); | |
87 | } | |
88 | ||
86538308 | 89 | /** |
c490a46a | 90 | * Set default values for the form. Relationship that in edit/view action |
86538308 EM |
91 | * the default values are retrieved from the database |
92 | * | |
86538308 EM |
93 | * |
94 | * @return void | |
95 | */ | |
96 | /** | |
86538308 | 97 | */ |
00be9182 | 98 | public function setDefaultValues() { |
6a488035 TO |
99 | $defaults = array(); |
100 | if (isset($this->_activityId)) { | |
101 | $params = array('id' => $this->_activityId); | |
102 | CRM_Activity_BAO_Activity::retrieve($params, $defaults); | |
103 | $defaults['html_message'] = CRM_Utils_Array::value('details', $defaults); | |
104 | } | |
105 | $defaults = $defaults + CRM_Contact_Form_Task_PDFLetterCommon::setDefaultValues(); | |
106 | return $defaults; | |
107 | } | |
108 | ||
109 | /** | |
c490a46a | 110 | * Build the form object |
6a488035 | 111 | * |
6a488035 TO |
112 | * |
113 | * @return void | |
114 | */ | |
115 | public function buildQuickForm() { | |
116 | //enable form element | |
117 | $this->assign('suppressForm', FALSE); | |
118 | CRM_Contact_Form_Task_PDFLetterCommon::buildQuickForm($this); | |
119 | } | |
120 | ||
121 | /** | |
100fef9d | 122 | * Process the form after the input has been submitted and validated |
6a488035 | 123 | * |
6a488035 | 124 | * |
355ba699 | 125 | * @return void |
6a488035 TO |
126 | */ |
127 | public function postProcess() { | |
128 | CRM_Contact_Form_Task_PDFLetterCommon::postProcess($this); | |
129 | } | |
96025800 | 130 | |
6a488035 | 131 | } |