3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
35 class CRM_Financial_Form_Search
extends CRM_Core_Form
{
39 function preProcess() {
40 $this->_batchStatus
= CRM_Utils_Request
::retrieve('batchStatus', 'Positive', CRM_Core_DAO
::$_nullObject, FALSE, NULL);
41 $this->assign('batchStatus', $this->_batchStatus
);
44 function setDefaultValues() {
46 $status = CRM_Utils_Request
::retrieve('status', 'Positive', CRM_Core_DAO
::$_nullObject, FALSE, 1);
47 $defaults['batch_update'] = $status;
48 if ($this->_batchStatus
) {
49 $defaults['status_id'] = $this->_batchStatus
;
54 public function buildQuickForm() {
55 CRM_Core_Resources
::singleton()->addScriptFile('civicrm', 'packages/jquery/plugins/jquery.redirect.min.js', 0, 'html-header');
56 $attributes = CRM_Core_DAO
::getAttribute('CRM_Batch_DAO_Batch');
57 $attributes['total']['class'] = $attributes['item_count']['class'] = 'number';
58 $this->add('text', 'title', ts('Batch Name'), $attributes['title']);
60 $batchStatus = CRM_Core_PseudoConstant
::get('CRM_Batch_DAO_Batch', 'status_id', array('labelColumn' => 'name'));
67 array_search('Open', $batchStatus) => ts('Open'),
68 array_search('Closed', $batchStatus) => ts('Closed'),
69 array_search('Exported', $batchStatus) => ts('Exported'),
76 'payment_instrument_id',
77 ts('Payment Instrument'),
78 array('' => ts('- any -' )) + CRM_Contribute_PseudoConstant
::paymentInstrument(),
82 $this->add('text', 'total', ts('Total Amount'), $attributes['total']);
84 $this->add('text', 'item_count', ts('Number of Items'), $attributes['item_count']);
85 $this->add('text', 'sort_name', ts('Created By'), CRM_Core_DAO
::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
87 $this->assign('elements', array('status_id', 'title', 'sort_name', 'payment_instrument_id', 'item_count', 'total'));
88 $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('class' => 'select-rows'));
90 'reopen' => ts('Re-open'),
91 'close' => ts('Close'),
92 'export' => ts('Export'),
93 'delete' => ts('Delete'),
99 array('' => ts('- actions -')) +
$batchAction);
101 $this->add('submit','submit', ts('Go'),
103 'class' => 'form-submit',
111 'name' => ts('Search'),
116 parent
::buildQuickForm();
119 function postProcess() {
121 foreach ($_POST as $key => $value) {
122 if (substr($key,0,6) == "check_") {
123 $batch = explode("_",$key);
124 $batchIds[] = $batch[1];
127 if (!empty($_POST['batch_update'])) {
128 CRM_Batch_BAO_Batch
::closeReOpen($batchIds, $_POST['batch_update']);