commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / CRM / Contact / Form / Task / Print.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
32 * $Id$
33 *
34 */
35
36 /**
37 * This class provides the functionality to save a search
38 * Saved Searches are used for saving frequently used queries
39 */
40 class CRM_Contact_Form_Task_Print extends CRM_Contact_Form_Task {
41
42 /**
43 * Build all the data structures needed to build the form.
44 *
45 * @return void
46 */
47 public function preProcess() {
48 parent::preprocess();
49
50 // set print view, so that print templates are called
51 $this->controller->setPrint(1);
52 $this->assign('id', $this->get('id'));
53 $this->assign('pageTitle', ts('CiviCRM Contact Listing'));
54
55 $params = $this->get('queryParams');
56 if (!empty($this->_contactIds)) {
57 //using _contactIds field for creating params for query so that multiple selections on multiple pages
58 //can be printed.
59 foreach ($this->_contactIds as $contactId) {
60 $params[] = array(
61 CRM_Core_Form::CB_PREFIX . $contactId,
62 '=',
63 1,
64 0,
65 0,
66 );
67 }
68 }
69
70 // create the selector, controller and run - store results in session
71 $fv = $this->get('formValues');
72 $returnProperties = $this->get('returnProperties');
73
74 $sortID = NULL;
75 if ($this->get(CRM_Utils_Sort::SORT_ID)) {
76 $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
77 $this->get(CRM_Utils_Sort::SORT_DIRECTION)
78 );
79 }
80
81 $includeContactIds = FALSE;
82 if ($fv['radio_ts'] == 'ts_sel') {
83 $includeContactIds = TRUE;
84 }
85
86 $selectorName = $this->controller->selectorName();
87 require_once str_replace('_', DIRECTORY_SEPARATOR, $selectorName) . '.php';
88
89 $returnP = isset($returnPropeties) ? $returnPropeties : "";
90 $customSearchClass = $this->get('customSearchClass');
91 $selector = new $selectorName($customSearchClass,
92 $fv,
93 $params,
94 $returnP,
95 $this->_action,
96 $includeContactIds
97 );
98 $controller = new CRM_Core_Selector_Controller($selector,
99 NULL,
100 $sortID,
101 CRM_Core_Action::VIEW,
102 $this,
103 CRM_Core_Selector_Controller::SCREEN
104 );
105 $controller->setEmbedded(TRUE);
106 $controller->run();
107 }
108
109 /**
110 * Build the form object - it consists of
111 * - displaying the QILL (query in local language)
112 * - displaying elements for saving the search
113 *
114 *
115 * @return void
116 */
117 public function buildQuickForm() {
118 //
119 // just need to add a javacript to popup the window for printing
120 //
121 $this->addButtons(array(
122 array(
123 'type' => 'next',
124 'name' => ts('Print Contact List'),
125 'js' => array('onclick' => 'window.print()'),
126 'isDefault' => TRUE,
127 ),
128 array(
129 'type' => 'back',
130 'name' => ts('Done'),
131 ),
132 )
133 );
134 }
135
136 /**
137 * Process the form after the input has been submitted and validated.
138 *
139 *
140 * @return void
141 */
142 public function postProcess() {
143 // redirect to the main search page after printing is over
144 }
145
146 }