Style - Remove @access
[civicrm-core.git] / CRM / Contact / Form / Task / PDF.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2014
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 /**
43 * All the existing templates in the system
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 /**
56 * Build all the data structures needed to build the form
57 *
58 * @return void
59 */
60 public function preProcess() {
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
89 /**
90 * Set default values for the form. Relationship that in edit/view action
91 * the default values are retrieved from the database
92 *
93 *
94 * @return void
95 */
96 /**
97 *
98 */
99 public function setDefaultValues() {
100 $defaults = array();
101 if (isset($this->_activityId)) {
102 $params = array('id' => $this->_activityId);
103 CRM_Activity_BAO_Activity::retrieve($params, $defaults);
104 $defaults['html_message'] = CRM_Utils_Array::value('details', $defaults);
105 }
106 $defaults = $defaults + CRM_Contact_Form_Task_PDFLetterCommon::setDefaultValues();
107 return $defaults;
108 }
109
110 /**
111 * Build the form object
112 *
113 *
114 * @return void
115 */
116 public function buildQuickForm() {
117 //enable form element
118 $this->assign('suppressForm', FALSE);
119 CRM_Contact_Form_Task_PDFLetterCommon::buildQuickForm($this);
120 }
121
122 /**
123 * Process the form after the input has been submitted and validated
124 *
125 *
126 * @return void
127 */
128 public function postProcess() {
129 CRM_Contact_Form_Task_PDFLetterCommon::postProcess($this);
130 }
131 }
132