Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
34cd78e1 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
34cd78e1 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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 | |
34cd78e1 | 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | require_once 'CRM/Core/Form.php'; | |
37 | require_once 'CRM/Core/OptionGroup.php'; | |
a1a55b61 EM |
38 | |
39 | /** | |
40 | * Class CRM_Auction_Form_SearchAuction | |
41 | */ | |
6a488035 | 42 | class CRM_Auction_Form_SearchAuction extends CRM_Core_Form { |
a1a55b61 EM |
43 | /** |
44 | * This virtual function is used to set the default values of | |
45 | * various form elements | |
46 | * | |
47 | * access public | |
48 | * | |
49 | * @return array reference to the array of default values | |
50 | * | |
51 | */ | |
6a488035 TO |
52 | function setDefaultValues() { |
53 | $defaults = array(); | |
54 | $defaults['auctionsByDates'] = 0; | |
55 | ||
56 | require_once 'CRM/Core/ShowHideBlocks.php'; | |
57 | $this->_showHide = new CRM_Core_ShowHideBlocks(); | |
a7488080 | 58 | if (empty($defaults['auctionsByDates'])) { |
6a488035 TO |
59 | $this->_showHide->addHide('id_fromToDates'); |
60 | } | |
61 | ||
62 | $this->_showHide->addToTemplate(); | |
63 | return $defaults; | |
64 | } | |
65 | ||
66 | /** | |
67 | * Build the form | |
68 | * | |
69 | * @access public | |
70 | * | |
71 | * @return void | |
72 | */ | |
73 | public function buildQuickForm() { | |
74 | $this->add('text', 'title', ts('Find'), | |
75 | array(CRM_Core_DAO::getAttribute('CRM_Auction_DAO_Auction', 'title')) | |
76 | ); | |
77 | ||
78 | $auctionsByDates = array(); | |
79 | $searchOption = array(ts('Show Current and Upcoming Auctions'), ts('Search All or by Date Range')); | |
80 | $this->addRadio('auctionsByDates', ts('Auctions by Dates'), $searchOption, array('onclick' => "return showHideByValue('auctionsByDates','1','id_fromToDates','block','radio',true);"), "<br />"); | |
81 | ||
82 | $this->add('date', 'start_date', ts('From'), CRM_Core_SelectValues::date('relative')); | |
83 | $this->addRule('start_date', ts('Select a valid Auction FROM date.'), 'qfDate'); | |
84 | ||
85 | $this->add('date', 'end_date', ts('To'), CRM_Core_SelectValues::date('relative')); | |
86 | $this->addRule('end_date', ts('Select a valid Auction TO date.'), 'qfDate'); | |
87 | ||
88 | $this->addButtons(array( | |
89 | array('type' => 'refresh', | |
90 | 'name' => ts('Search'), | |
91 | 'isDefault' => TRUE, | |
92 | ), | |
93 | )); | |
94 | } | |
95 | ||
96 | function postProcess() { | |
97 | $params = $this->controller->exportValues($this->_name); | |
98 | $parent = $this->controller->getParent(); | |
99 | $parent->set('searchResult', 1); | |
100 | if (!empty($params)) { | |
101 | $fields = array('title', 'event_type_id', 'start_date', 'end_date', 'auctionsByDates'); | |
102 | foreach ($fields as $field) { | |
103 | if (isset($params[$field]) && | |
104 | !CRM_Utils_System::isNull($params[$field]) | |
105 | ) { | |
106 | $parent->set($field, $params[$field]); | |
107 | } | |
108 | else { | |
109 | $parent->set($field, NULL); | |
110 | } | |
111 | } | |
112 | } | |
113 | } | |
114 | } | |
115 |