Merge pull request #18076 from MegaphoneJon/better-on-behalf-of-2
[civicrm-core.git] / CRM / Case / 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 save a search
20 * Saved Searches are used for saving frequently used queries
21 */
22 class CRM_Case_Form_Task_Print extends CRM_Case_Form_Task {
23
24 /**
25 * Build all the data structures needed to build the form.
26 */
27 public function preProcess() {
28 parent::preProcess();
29
30 // set print view, so that print templates are called
31 $this->controller->setPrint(1);
32
33 // get the formatted params
34 $queryParams = $this->get('queryParams');
35
36 $sortID = NULL;
37 if ($this->get(CRM_Utils_Sort::SORT_ID)) {
38 $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
39 $this->get(CRM_Utils_Sort::SORT_DIRECTION)
40 );
41 }
42
43 $selector = new CRM_Case_Selector_Search($queryParams, $this->_action, $this->_componentClause);
44 $controller = new CRM_Core_Selector_Controller($selector, NULL, $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SCREEN);
45 $controller->setEmbedded(TRUE);
46 $controller->run();
47 }
48
49 /**
50 * Build the form object.
51 *
52 * It consists of
53 * - displaying the QILL (query in local language)
54 * - displaying elements for saving the search
55 */
56 public function buildQuickForm() {
57 //
58 // just need to add a javacript to popup the window for printing
59 //
60 $this->addButtons([
61 [
62 'type' => 'next',
63 'name' => ts('Print Case List'),
64 'js' => ['onclick' => 'window.print()'],
65 'isDefault' => TRUE,
66 ],
67 [
68 'type' => 'back',
69 'name' => ts('Done'),
70 ],
71 ]);
72 }
73
74 /**
75 * Process the form after the input has been submitted and validated.
76 */
77 public function postProcess() {
78 // redirect to the main search page after printing is over
79 }
80
81 }