3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * @todo Add comments if possible.
21 class CRM_Financial_Form_Search
extends CRM_Core_Form
{
25 public function preProcess() {
26 $this->_batchStatus
= CRM_Utils_Request
::retrieve('batchStatus', 'Positive', CRM_Core_DAO
::$_nullObject, FALSE, NULL);
27 $this->assign('batchStatus', $this->_batchStatus
);
33 public function setDefaultValues() {
35 $status = CRM_Utils_Request
::retrieve('status', 'Positive', CRM_Core_DAO
::$_nullObject, FALSE, 1);
36 $defaults['batch_update'] = $status;
37 if ($this->_batchStatus
) {
38 $defaults['status_id'] = $this->_batchStatus
;
43 public function buildQuickForm() {
44 $attributes = CRM_Core_DAO
::getAttribute('CRM_Batch_DAO_Batch');
45 $attributes['total']['class'] = $attributes['item_count']['class'] = 'number';
46 $this->add('text', 'title', ts('Batch Name'), $attributes['title']);
48 $batchStatus = CRM_Core_PseudoConstant
::get('CRM_Batch_DAO_Batch', 'status_id', ['labelColumn' => 'name']);
55 array_search('Open', $batchStatus) => ts('Open'),
56 array_search('Closed', $batchStatus) => ts('Closed'),
57 array_search('Exported', $batchStatus) => ts('Exported'),
64 'payment_instrument_id',
66 ['' => ts('- any -')] + CRM_Contribute_PseudoConstant
::paymentInstrument(),
70 $this->add('text', 'total', ts('Total Amount'), $attributes['total']);
72 $this->add('text', 'item_count', ts('Number of Items'), $attributes['item_count']);
73 $this->add('text', 'sort_name', ts('Created By'), CRM_Core_DAO
::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
75 $this->assign('elements', ['status_id', 'title', 'sort_name', 'payment_instrument_id', 'item_count', 'total']);
76 $this->addElement('checkbox', 'toggleSelect', NULL, NULL, ['class' => 'select-rows']);
78 'reopen' => ts('Re-open'),
79 'close' => ts('Close'),
80 'export' => ts('Export'),
81 'delete' => ts('Delete'),
84 foreach ($batchAction as $action => $ignore) {
85 if (!CRM_Batch_BAO_Batch
::checkBatchPermission($action)) {
86 unset($batchAction[$action]);
92 ['' => ts('- actions -')] +
$batchAction);
94 $this->add('xbutton', 'submit', ts('Go'),
97 'class' => 'crm-form-submit',
105 'name' => ts('Search'),
110 parent
::buildQuickForm();
113 public function postProcess() {
115 foreach ($_POST as $key => $value) {
116 if (substr($key, 0, 6) == "check_") {
117 $batch = explode("_", $key);
118 $batchIds[] = $batch[1];
121 if (!empty($_POST['batch_update'])) {
122 CRM_Batch_BAO_Batch
::closeReOpen($batchIds, $_POST['batch_update']);