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 CRM_Core_Resources
::singleton()
45 ->addScriptFile('civicrm', 'packages/jquery/plugins/jquery.redirect.min.js', 0, 'html-header');
46 $attributes = CRM_Core_DAO
::getAttribute('CRM_Batch_DAO_Batch');
47 $attributes['total']['class'] = $attributes['item_count']['class'] = 'number';
48 $this->add('text', 'title', ts('Batch Name'), $attributes['title']);
50 $batchStatus = CRM_Core_PseudoConstant
::get('CRM_Batch_DAO_Batch', 'status_id', ['labelColumn' => 'name']);
57 array_search('Open', $batchStatus) => ts('Open'),
58 array_search('Closed', $batchStatus) => ts('Closed'),
59 array_search('Exported', $batchStatus) => ts('Exported'),
66 'payment_instrument_id',
68 ['' => ts('- any -')] + CRM_Contribute_PseudoConstant
::paymentInstrument(),
72 $this->add('text', 'total', ts('Total Amount'), $attributes['total']);
74 $this->add('text', 'item_count', ts('Number of Items'), $attributes['item_count']);
75 $this->add('text', 'sort_name', ts('Created By'), CRM_Core_DAO
::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
77 $this->assign('elements', ['status_id', 'title', 'sort_name', 'payment_instrument_id', 'item_count', 'total']);
78 $this->addElement('checkbox', 'toggleSelect', NULL, NULL, ['class' => 'select-rows']);
80 'reopen' => ts('Re-open'),
81 'close' => ts('Close'),
82 'export' => ts('Export'),
83 'delete' => ts('Delete'),
86 foreach ($batchAction as $action => $ignore) {
87 if (!CRM_Batch_BAO_Batch
::checkBatchPermission($action)) {
88 unset($batchAction[$action]);
94 ['' => ts('- actions -')] +
$batchAction);
96 $this->add('xbutton', 'submit', ts('Go'),
99 'class' => 'crm-form-submit',
107 'name' => ts('Search'),
112 parent
::buildQuickForm();
115 public function postProcess() {
117 foreach ($_POST as $key => $value) {
118 if (substr($key, 0, 6) == "check_") {
119 $batch = explode("_", $key);
120 $batchIds[] = $batch[1];
123 if (!empty($_POST['batch_update'])) {
124 CRM_Batch_BAO_Batch
::closeReOpen($batchIds, $_POST['batch_update']);