Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Grant cleanup #17967

Merged
merged 1 commit into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 1 addition & 32 deletions CRM/Grant/BAO/Grant.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@
*/
class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {

/**
* Class constructor.
*/
public function __construct() {
parent::__construct();
}

/**
* Get events Summary.
*
Expand Down Expand Up @@ -93,7 +86,7 @@ public static function getGrantStatusOptGroup() {
* @param array $defaults
* (reference ) an assoc array to hold the flattened values.
*
* @return CRM_Grant_BAO_ManageGrant
* @return CRM_Grant_DAO_Grant
*/
public static function retrieve(&$params, &$defaults) {
$grant = new CRM_Grant_DAO_Grant();
Expand All @@ -118,30 +111,6 @@ public static function add($params, $ids = []) {
$hook = $id ? 'edit' : 'create';
CRM_Utils_Hook::pre($hook, 'Grant', $id, $params);

// first clean up all the money fields
$moneyFields = [
'amount_total',
'amount_granted',
'amount_requested',
];
foreach ($moneyFields as $field) {
if (isset($params[$field])) {
$params[$field] = CRM_Utils_Rule::cleanMoney($params[$field]);
}
}
// convert dates to mysql format
$dates = [
'application_received_date',
'decision_date',
'money_transfer_date',
'grant_due_date',
];

foreach ($dates as $d) {
if (isset($params[$d])) {
$params[$d] = CRM_Utils_Date::processDate($params[$d], NULL, TRUE);
}
}
$grant = new CRM_Grant_DAO_Grant();
$grant->id = $id;

Expand Down
12 changes: 10 additions & 2 deletions CRM/Grant/Form/Grant.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ public function getDefaultEntity() {

/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess() {

Expand Down Expand Up @@ -263,6 +261,16 @@ public function postProcess() {
'civicrm_grant',
$this->_id
);
$moneyFields = [
'amount_total',
'amount_granted',
'amount_requested',
];
foreach ($moneyFields as $field) {
if (isset($params[$field])) {
$params[$field] = CRM_Utils_Rule::cleanMoney($params[$field]);
}
}

$grant = CRM_Grant_BAO_Grant::create($params, $ids);

Expand Down
4 changes: 2 additions & 2 deletions CRM/Grant/Form/Task/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ public function postProcess() {
$values[$key] = $value;
}
foreach ($this->_grantIds as $grantId) {
$ids['grant_id'] = $grantId;
$values['id'] = $grantId;

CRM_Grant_BAO_Grant::add($values, $ids);
CRM_Grant_BAO_Grant::add($values);
$updatedGrants++;
}
}
Expand Down