Merge pull request #15921 from civicrm/5.20
[civicrm-core.git] / CRM / Activity / Form / Task / Print.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 print activity records.
20 */
21 class CRM_Activity_Form_Task_Print extends CRM_Activity_Form_Task {
22
23 /**
24 * Build all the data structures needed to build the form.
25 */
26 public function preProcess() {
27 parent::preprocess();
28
29 // set print view, so that print templates are called
30 $this->controller->setPrint(1);
31
32 // get the formatted params
33 $queryParams = $this->get('queryParams');
34
35 $sortID = NULL;
36 if ($this->get(CRM_Utils_Sort::SORT_ID)) {
37 $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
38 $this->get(CRM_Utils_Sort::SORT_DIRECTION)
39 );
40 }
41
42 $selector = new CRM_Activity_Selector_Search($queryParams, $this->_action, $this->_componentClause);
43 $controller = new CRM_Core_Selector_Controller($selector, NULL, $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SCREEN);
44 $controller->setEmbedded(TRUE);
45 $controller->run();
46 }
47
48 /**
49 * Build the form object.
50 *
51 * Consists of
52 * - displaying the QILL (query in local language)
53 * - displaying elements for saving the search
54 */
55 public function buildQuickForm() {
56
57 // just need to add a javacript to popup the window for printing
58 $this->addButtons([
59 [
60 'type' => 'next',
61 'name' => ts('Print Activities'),
62 'js' => ['onclick' => 'window.print()'],
63 'isDefault' => TRUE,
64 ],
65 [
66 'type' => 'back',
67 'name' => ts('Done'),
68 ],
69 ]);
70 }
71
72 }