| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | Copyright CiviCRM LLC. All rights reserved. | |
| 5 | | | |
| 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 | +--------------------------------------------------------------------+ |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * |
| 14 | * @package CRM |
| 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
| 16 | */ |
| 17 | |
| 18 | /** |
| 19 | * This class generates form components generic to Contribution admin. |
| 20 | */ |
| 21 | class CRM_Contribute_Form extends CRM_Admin_Form { |
| 22 | |
| 23 | /** |
| 24 | * Set default values for the form. |
| 25 | * |
| 26 | * @return array |
| 27 | */ |
| 28 | public function setDefaultValues() { |
| 29 | $defaults = []; |
| 30 | |
| 31 | if (isset($this->_id)) { |
| 32 | $params = ['id' => $this->_id]; |
| 33 | if (!empty($this->_BAOName)) { |
| 34 | $baoName = $this->_BAOName; |
| 35 | $baoName::retrieve($params, $defaults); |
| 36 | } |
| 37 | } |
| 38 | if ($this->_action == CRM_Core_Action::DELETE && !empty($defaults['name'])) { |
| 39 | $this->assign('delName', $defaults['name']); |
| 40 | } |
| 41 | elseif ($this->_action == CRM_Core_Action::ADD) { |
| 42 | $condition = " AND is_default = 1"; |
| 43 | $values = CRM_Core_OptionGroup::values('financial_account_type', FALSE, FALSE, FALSE, $condition); |
| 44 | $defaults['financial_account_type_id'] = array_keys($values); |
| 45 | $defaults['is_active'] = 1; |
| 46 | |
| 47 | } |
| 48 | elseif ($this->_action & CRM_Core_Action::UPDATE) { |
| 49 | if (!empty($defaults['contact_id']) || !empty($defaults['created_id'])) { |
| 50 | $contactID = !empty($defaults['created_id']) ? $defaults['created_id'] : $defaults['contact_id']; |
| 51 | $this->assign('created_id', $contactID); |
| 52 | $this->assign('organisationId', $contactID); |
| 53 | } |
| 54 | |
| 55 | if ($parentId = CRM_Utils_Array::value('parent_id', $defaults)) { |
| 56 | $this->assign('parentId', $parentId); |
| 57 | } |
| 58 | } |
| 59 | return $defaults; |
| 60 | } |
| 61 | |
| 62 | } |