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