/** * Takes a bunch of params that are needed to match certain criteria and * retrieves the relevant objects. Typically the valid params are only * pledge id. We'll tweak this function to be more full featured over a period * of time. This is the inverse function of create. It also stores all the retrieved * values in the default array * * @param array $params (reference ) an assoc array of name/value pairs * @param array $defaults (reference ) an assoc array to hold the flattened values * * @return object CRM_Pledge_BAO_Pledge object * @access public * @static */ static function retrieve(&$params, &$defaults) { $pledge = new CRM_Pledge_DAO_Pledge(); $pledge->copyValues($params); if ($pledge->find(true)) { CRM_Core_DAO::storeValues($pledge, $defaults); return $pledge; } return null; }
/** * Function to get list of pledges In Honor of contact Ids * * @param int $honorId In Honor of Contact ID * * @return return the list of pledge fields * * @access public * @static */ static function getHonorContacts($honorId) { $params = array(); $honorDAO = new CRM_Pledge_DAO_Pledge(); $honorDAO->honor_contact_id = $honorId; $honorDAO->find(); //get all status. while ($honorDAO->fetch()) { $params[$honorDAO->id] = array('honorId' => $honorDAO->contact_id, 'amount' => $honorDAO->amount, 'status' => CRM_Contribute_PseudoConstant::contributionStatus($honorDAO->status_id), 'create_date' => $honorDAO->create_date, 'acknowledge_date' => $honorDAO->acknowledge_date, 'type' => CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $honorDAO->financial_type_id, 'name'), 'display_name' => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $honorDAO->contact_id, 'display_name')); } return $params; }
/** * Get list of pledges In Honor of contact Ids. * * @param int $honorId * In Honor of Contact ID. * * @return array * return the list of pledge fields */ public static function getHonorContacts($honorId) { $params = array(); $honorDAO = new CRM_Contribute_DAO_ContributionSoft(); $honorDAO->contact_id = $honorId; $honorDAO->find(); // get all status. while ($honorDAO->fetch()) { $pledgePaymentDAO = new CRM_Pledge_DAO_PledgePayment(); $pledgePaymentDAO->contribution_id = $honorDAO->contribution_id; if ($pledgePaymentDAO->find(TRUE)) { $pledgeDAO = new CRM_Pledge_DAO_Pledge(); $pledgeDAO->id = $pledgePaymentDAO->pledge_id; if ($pledgeDAO->find(TRUE)) { $params[$pledgeDAO->id] = array('honor_type' => CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_ContributionSoft', 'soft_credit_type_id', $honorDAO->soft_credit_type_id), 'honorId' => $pledgeDAO->contact_id, 'amount' => $pledgeDAO->amount, 'status' => CRM_Contribute_PseudoConstant::contributionStatus($pledgeDAO->status_id), 'create_date' => $pledgeDAO->create_date, 'acknowledge_date' => $pledgeDAO->acknowledge_date, 'type' => CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $pledgeDAO->financial_type_id, 'name'), 'display_name' => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $pledgeDAO->contact_id, 'display_name')); } } } return $params; }