3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2016
35 * This class provides the functionality to create PDF letter for a group of contacts or a single contact.
37 class CRM_Contact_Form_Task_PDF
extends CRM_Contact_Form_Task
{
40 * All the existing templates in the system.
44 public $_templates = NULL;
46 public $_single = NULL;
50 public $_activityId = NULL;
53 * Build all the data structures needed to build the form.
55 public function preProcess() {
57 $this->skipOnHold
= $this->skipDeceased
= FALSE;
58 CRM_Contact_Form_Task_PDFLetterCommon
::preProcess($this);
60 // store case id if present
61 $this->_caseId
= CRM_Utils_Request
::retrieve('caseid', 'Positive', $this, FALSE);
63 // retrieve contact ID if this is 'single' mode
64 $cid = CRM_Utils_Request
::retrieve('cid', 'Positive', $this, FALSE);
67 // this is true in non-search context / single mode
68 // in search context 'id' is the default profile id for search display
70 $this->_activityId
= CRM_Utils_Request
::retrieve('id', 'Positive', $this, FALSE);
74 CRM_Contact_Form_Task_PDFLetterCommon
::preProcessSingle($this, $cid);
75 $this->_single
= TRUE;
81 $this->assign('single', $this->_single
);
85 * Set default values for the form.
87 public function setDefaultValues() {
89 if (isset($this->_activityId
)) {
90 $params = array('id' => $this->_activityId
);
91 CRM_Activity_BAO_Activity
::retrieve($params, $defaults);
92 $defaults['html_message'] = CRM_Utils_Array
::value('details', $defaults);
94 $defaults = $defaults + CRM_Contact_Form_Task_PDFLetterCommon
::setDefaultValues();
99 * Build the form object.
101 public function buildQuickForm() {
102 //enable form element
103 $this->assign('suppressForm', FALSE);
104 CRM_Contact_Form_Task_PDFLetterCommon
::buildQuickForm($this);
108 * Process the form after the input has been submitted and validated.
110 public function postProcess() {
111 CRM_Contact_Form_Task_PDFLetterCommon
::postProcess($this);
115 * List available tokens for this form.
119 public function listTokens() {
120 $tokens = CRM_Core_SelectValues
::contactTokens();
121 if (isset($this->_caseId
)) {
122 $caseTypeId = CRM_Core_DAO
::getFieldValue('CRM_Case_DAO_Case', $this->_caseId
, 'case_type_id');
123 $tokens +
= CRM_Core_SelectValues
::caseTokens($caseTypeId);