<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
+ | CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality for batch entry for contributions/memberships
+ * This class provides the functionality for batch entry for contributions/memberships.
*/
class CRM_Batch_Form_Entry extends CRM_Core_Form {
public $_params;
- public $_membershipId = NULL;
/**
* When not to reset sort_name.
*/
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
$this->_batchId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
if (!$this->_profileId) {
$errors = array();
$batchTypes = CRM_Core_Pseudoconstant::get('CRM_Batch_DAO_Batch', 'type_id', array('flip' => 1), 'validate');
$fields = array(
- 'total_amount' => 'Amount',
- 'financial_type' => 'Financial Type',
- 'payment_instrument' => 'Paid By',
+ 'total_amount' => ts('Amount'),
+ 'financial_type' => ts('Financial Type'),
+ 'payment_instrument' => ts('Payment Method'),
);
//CRM-16480 if contact is selected, validate financial type and amount field.
/**
* Set default values for the form.
- *
- *
- * @return void
*/
public function setDefaultValues() {
if (empty($this->_fields)) {
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$params = $this->controller->exportValues($this->_name);
* @param array $params
* Associated array of submitted values.
*
- *
- * @return void
+ * @return bool
*/
private function processContribution(&$params) {
$dates = array(
'reminder_date',
);
- // get the price set associated with offline memebership
+ // get the price set associated with offline membership
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_membership_type_amount', 'id', 'name');
$this->_priceSet = $priceSets = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
$value['is_renew'] = FALSE;
if (!empty($params['member_option']) && CRM_Utils_Array::value($key, $params['member_option']) == 2) {
+
+ // The following parameter setting may be obsolete.
$this->_params = $params;
$value['is_renew'] = TRUE;
- $membership = CRM_Member_BAO_Membership::renewMembershipFormWrapper(
- $value['contact_id'],
- $value['membership_type_id'],
- FALSE,
- $this,
- NULL,
- NULL,
- $value['custom'],
- 1,
- NULL,
- FALSE
+ $isPayLater = CRM_Utils_Array::value('is_pay_later', $params);
+ $campaignId = NULL;
+ if (isset($this->_values) && is_array($this->_values) && !empty($this->_values)) {
+ $campaignId = CRM_Utils_Array::value('campaign_id', $this->_params);
+ if (!array_key_exists('campaign_id', $this->_params)) {
+ $campaignId = CRM_Utils_Array::value('campaign_id', $this->_values);
+ }
+ }
+
+ list($membership) = CRM_Member_BAO_Membership::renewMembership(
+ $value['contact_id'], $value['membership_type_id'], FALSE,
+ NULL, NULL, $value['custom'], NULL, NULL, FALSE,
+ NULL, NULL, $isPayLater, $campaignId
);
// make contribution entry
$contrbutionParams = array_merge($value, array('membership_id' => $membership->id));
+ // @todo - calling this from here is pretty hacky since it is called from membership.create anyway
+ // This form should set the correct params & not call this fn directly.
CRM_Member_BAO_Membership::recordMembershipContribution($contrbutionParams);
}
else {
*
* @param array $value
* Associated array of submitted values.
- *
- *
- * @return void
*/
private function updateContactInfo(&$value) {
$value['preserveDBName'] = $this->_preserveDefault;
}
/**
- * Function exists purely for unit testing purposes. If you feel tempted to use this in live code
- * then it probably means there is some functionality that needs to be moved
- * out of the form layer
+ * Function exists purely for unit testing purposes.
+ *
+ * If you feel tempted to use this in live code then it probably means there is some functionality
+ * that needs to be moved out of the form layer
*
* @param array $params
*
}
/**
- * Function exists purely for unit testing purposes. If you feel tempted to use this in live code
- * then it probably means there is some functionality that needs to be moved
- * out of the form layer
+ * Function exists purely for unit testing purposes.
+ *
+ * If you feel tempted to use this in live code then it probably means there is some functionality
+ * that needs to be moved out of the form layer.
*
* @param array $params
*