*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Pledge_BAO_Pledge extends CRM_Pledge_DAO_Pledge {
* @return CRM_Pledge_BAO_Pledge
*/
public static function &create(&$params) {
- //FIXME: a cludgy hack to fix the dates to MySQL format
+ // FIXME: a cludgy hack to fix the dates to MySQL format
$dateFields = array('start_date', 'create_date', 'acknowledge_date', 'modified_date', 'cancel_date', 'end_date');
foreach ($dateFields as $df) {
if (isset($params[$df])) {
$params['amount'] = $params['installment_amount'] * $params['installments'];
}
- //get All Payments status types.
+ // get All Payments status types.
$paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
- //update the pledge status only if it does NOT come from form
+ // update the pledge status only if it does NOT come from form
if (!isset($params['pledge_status_id'])) {
if (isset($params['contribution_id'])) {
if ($params['installments'] > 1) {
return $pledge;
}
- //handle custom data.
+ // handle custom data.
if (!empty($params['custom']) &&
is_array($params['custom'])
) {
// skip payment stuff inedit mode
if (!isset($params['id']) || !empty($params['is_pledge_pending'])) {
- //if pledge is pending delete all payments and recreate.
+ // if pledge is pending delete all payments and recreate.
if (!empty($params['is_pledge_pending'])) {
CRM_Pledge_BAO_PledgePayment::deletePayments($pledge->id);
}
- //building payment params
+ // building payment params
$paymentParams['pledge_id'] = $pledge->id;
$paymentKeys = array(
'amount',
$transaction = new CRM_Core_Transaction();
- //check for no Completed Payment records with the pledge
+ // check for no Completed Payment records with the pledge
$payment = new CRM_Pledge_DAO_PledgePayment();
$payment->pledge_id = $id;
$payment->find();
while ($payment->fetch()) {
- //also delete associated contribution.
+ // also delete associated contribution.
if ($payment->contribution_id) {
CRM_Contribute_BAO_Contribution::deleteContribution($payment->contribution_id);
}
public static function getTotalAmountAndCount($status = NULL, $startDate = NULL, $endDate = NULL) {
$where = array();
$select = $from = $queryDate = NULL;
- //get all status
+ // get all status
$allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$statusId = array_search($status, $allStatus);
*
* @return array
* return the list of pledge fields
- *
*/
public static function getHonorContacts($honorId) {
$params = array();
$honorDAO->contact_id = $honorId;
$honorDAO->find();
- //get all status.
+ // get all status.
while ($honorDAO->fetch()) {
$pledgePaymentDAO = new CRM_Pledge_DAO_PledgePayment();
$pledgePaymentDAO->contribution_id = $honorDAO->contribution_id;
* Form object.
* @param array $params
* An assoc array of name/value pairs.
- *
- * @return void
*/
public static function sendAcknowledgment(&$form, $params) {
//handle Acknowledgment.
$allPayments = $payments = array();
- //get All Payments status types.
+ // get All Payments status types.
$paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$returnProperties = array('status_id', 'scheduled_amount', 'scheduled_date', 'contribution_id');
- //get all paymnets details.
+ // get all paymnets details.
CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgePayment', 'pledge_id', $params['id'], $allPayments, $returnProperties);
if (!empty($allPayments)) {
)
);
- //get the first valid payment id.
+ // get the first valid payment id.
if (!isset($form->paymentId) && ($paymentStatusTypes[$values['status_id']] == 'Pending' ||
$paymentStatusTypes[$values['status_id']] == 'Overdue'
)
}
}
- //assign pledge fields value to template.
+ // assign pledge fields value to template.
$pledgeFields = array(
'create_date',
'total_pledge_amount',
}
}
- //assign all payments details.
+ // assign all payments details.
if ($payments) {
$form->assign('payments', $payments);
}
- //handle domain token values
+ // handle domain token values
$domain = CRM_Core_BAO_Domain::getDomain();
$tokens = array(
'domain' => array('name', 'phone', 'address', 'email'),
}
$form->assign('domain', $domainValues);
- //handle contact token values.
+ // handle contact token values.
$ids = array($params['contact_id']);
$fields = array_merge(array_keys(CRM_Contact_BAO_Contact::importableFields()),
array('display_name', 'checksum', 'contact_id')
);
$form->assign('contact', $details[0][$params['contact_id']]);
- //handle custom data.
+ // handle custom data.
if (!empty($params['hidden_custom'])) {
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Pledge', CRM_Core_DAO::$_nullObject, $params['id']);
$pledgeParams = array(array('pledge_id', '=', $params['id'], 0, 0));
$customFields["custom_{$k}"] = $field;
}
- //to build array of customgroup & customfields in it
+ // to build array of customgroup & customfields in it
CRM_Core_BAO_UFGroup::getValues($params['contact_id'], $customFields, $customValues, FALSE, $pledgeParams);
$customGroup[$group['title']] = $customValues;
}
$form->assign('customGroup', $customGroup);
}
- //handle acknowledgment email stuff.
+ // handle acknowledgment email stuff.
list($pledgerDisplayName,
$pledgerEmail
) = CRM_Contact_BAO_Contact_Location::getEmailDetails($params['contact_id']);
- //check for online pledge.
+ // check for online pledge.
if (!empty($params['receipt_from_email'])) {
$userName = CRM_Utils_Array::value('receipt_from_name', $params);
$userEmail = CRM_Utils_Array::value('receipt_from_email', $params);
$receiptFrom = $params['from_email_id'];
}
elseif ($userID = CRM_Core_Session::singleton()->get('userID')) {
- //check for logged in user.
+ // check for logged in user.
list($userName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
}
else {
- //set the domain values.
+ // set the domain values.
$userName = CRM_Utils_Array::value('name', $domainValues);
$userEmail = CRM_Utils_Array::value('email', $domainValues);
}
)
);
- //check if activity record exist for this pledge
- //Acknowledgment, if exist do not add activity.
+ // check if activity record exist for this pledge
+ // Acknowledgment, if exist do not add activity.
$activityType = 'Pledge Acknowledgment';
$activity = new CRM_Activity_DAO_Activity();
$activity->source_record_id = $params['id'];
'campaign_id' => CRM_Utils_Array::value('campaign_id', $params),
);
- //lets insert assignee record.
+ // lets insert assignee record.
if (!empty($params['contact_id'])) {
$activityParams['assignee_contact_id'] = $params['contact_id'];
}
$fields = array_merge($fields, CRM_Pledge_DAO_PledgePayment::export());
- //set title to calculated fields
+ // set title to calculated fields
$calculatedFields = array(
'pledge_total_paid' => array('title' => ts('Total Paid')),
'pledge_balance_amount' => array('title' => ts('Balance Amount')),
$status = array();
- //get pending and in progress status
+ // get pending and in progress status
foreach (array(
'Pending',
'In Progress',
$allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
- //unset statues that we never use for pledges
+ // unset statues that we never use for pledges
foreach (array(
'Completed',
'Cancelled',
$domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain);
}
- //get the domain email address, since we don't carry w/ object.
+ // get the domain email address, since we don't carry w/ object.
$domainValue = CRM_Core_BAO_Domain::getNameAndEmail();
$domainValues['email'] = $domainValue[1];
$template = CRM_Core_Smarty::singleton();
$template->assign('domain', $domainValues);
- //set receipt from
+ // set receipt from
$receiptFrom = '"' . $domainValues['name'] . '" <' . $domainValues['email'] . '>';
foreach ($pledgeDetails as $paymentId => $details) {
// 2. send acknowledgement mail
if ($toEmail && !($doNotEmail || $onHold)) {
- //assign value to template
+ // assign value to template
$template->assign('amount_paid', $details['amount_paid'] ? $details['amount_paid'] : 0);
$template->assign('contact', $contactDetails[$contactId]);
$template->assign('next_payment', $details['scheduled_date']);
/**
* Is this pledge free from financial transactions (this is important to know as we allow editing
* when no transactions have taken place - the editing process currently involves deleting all pledge payments & contributions
- * & recreating so we want to block that if appropriate
+ * & recreating so we want to block that if appropriate).
*
* @param int $pledgeID
* @param int $pledgeStatusID
*/
public static function pledgeHasFinancialTransactions($pledgeID, $pledgeStatusID) {
if (empty($pledgeStatusID)) {
- //why would this happen? If we can see where it does then we can see if we should look it up
- //but assuming from form code it CAN be empty
+ // why would this happen? If we can see where it does then we can see if we should look it up.
+ // but assuming from form code it CAN be empty.
return TRUE;
}
if (self::isTransactedStatus($pledgeStatusID)) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Pledge_BAO_PledgeBlock extends CRM_Pledge_DAO_PledgeBlock {
$pledgeBlock = new CRM_Pledge_DAO_PledgeBlock();
- //fix for pledge_frequency_unit
+ // fix for pledge_frequency_unit
$freqUnits = CRM_Utils_Array::value('pledge_frequency_unit', $params);
if ($freqUnits && is_array($freqUnits)) {
CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgePayment', 'pledge_id',
$form->_values['pledge_id'], $allPayments, $returnProperties
);
- //get all status
+ // get all status
$allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$nextPayment = array();
elseif (!$isNextPayment &&
$allStatus[$value['status_id']] == 'Pending'
) {
- //get the next payment.
+ // get the next payment.
$nextPayment = array(
'id' => $payID,
'scheduled_amount' => CRM_Utils_Rule::cleanMoney($value['scheduled_amount']),
}
}
- //build check box array for payments.
+ // build check box array for payments.
$payments = array();
if (!empty($overduePayments)) {
foreach ($overduePayments as $id => $payment) {
));
$payments[$key] = CRM_Utils_Array::value('id', $nextPayment);
}
- //give error if empty or build form for payment.
+ // give error if empty or build form for payment.
if (empty($payments)) {
CRM_Core_Error::fatal(ts("Oops. It looks like there is no valid payment status for online payment."));
}
$pledgeBlock = self::getPledgeBlock($form->_id);
- //build form for pledge creation.
+ // build form for pledge creation.
$pledgeOptions = array(
'0' => ts('I want to make a one-time contribution'),
'1' => ts('I pledge to contribute this amount every'),
else {
$form->add('hidden', 'pledge_frequency_interval', 1);
}
- //Frequency unit drop-down label suffixes switch from *ly to *(s)
+ // Frequency unit drop-down label suffixes switch from *ly to *(s)
$freqUnitVals = explode(CRM_Core_DAO::VALUE_SEPARATOR, $pledgeBlock['pledge_frequency_unit']);
$freqUnits = array();
$frequencyUnits = CRM_Core_OptionGroup::values('recur_frequency_units');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Pledge_BAO_PledgePayment extends CRM_Pledge_DAO_PledgePayment {
}
for ($i = 1; $i <= $params['installments']; $i++) {
- //calculate the scheduled amount for every installment.
+ // calculate the scheduled amount for every installment.
if ($i == $params['installments']) {
$params['scheduled_amount'] = $params['amount'] - ($i - 1) * $params['scheduled_amount'];
}
}
}
- //update pledge status
+ // update pledge status
self::updatePledgePaymentStatus($params['pledge_id']);
$transaction->commit();
* @return bool
*/
public static function resetPledgePayment($contributionID) {
- //get all status
+ // get all status
$allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$transaction = new CRM_Core_Transaction();
$paymentContributionId = NULL;
$editScheduled = FALSE;
- //get all statuses
+ // get all statuses
$allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
// if we get do not get contribution id means we are editing the scheduled payment.
'amount',
'id'
);
- // while editing scheduled we need to check if we are editing last pending
+ // while editing scheduled we need to check if we are editing last pending
$lastPending = FALSE;
if (!$paymentContributionId) {
$checkPendingCount = self::getOldestPledgePayment($pledgeID, 2);
}
$cancelDateClause = $endDateClause = NULL;
- //update pledge and payment status if status is Completed/Cancelled.
+ // update pledge and payment status if status is Completed/Cancelled.
if ($pledgeStatusID && $pledgeStatusID == array_search('Cancelled', $allStatus)) {
$paymentStatusID = $pledgeStatusID;
$cancelDateClause = ", civicrm_pledge.cancel_date = CURRENT_TIMESTAMP ";
$endDateClause = ", civicrm_pledge.end_date = CURRENT_TIMESTAMP ";
}
- //update pledge status
+ // update pledge status
$query = "
UPDATE civicrm_pledge
SET civicrm_pledge.status_id = %1
$date['year'] = (int) substr($scheduled_date, 0, 4);
$date['month'] = (int) substr($scheduled_date, 4, 2);
$date['day'] = (int) substr($scheduled_date, 6, 2);
- //calculation of schedule date according to frequency day of period
- //frequency day is not applicable for daily installments
+ // calculation of schedule date according to frequency day of period
+ // frequency day is not applicable for daily installments
if ($params['frequency_unit'] != 'day' && $params['frequency_unit'] != 'year') {
if ($params['frequency_unit'] != 'week') {
- //for month use day of next month as next payment date
+ // for month use day of next month as next payment date
$date['day'] = $params['frequency_day'];
}
elseif ($params['frequency_unit'] == 'week') {
- //for week calculate day of week ie. Sunday,Monday etc. as next payment date
+ // for week calculate day of week ie. Sunday,Monday etc. as next payment date
$dayOfWeek = date('w', mktime(0, 0, 0, $date['month'], $date['day'], $date['year']));
$frequencyDay = $params['frequency_day'] - $dayOfWeek;
public static function calculatePledgeStatus($pledgeId) {
$paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
- //retrieve all pledge payments for this particular pledge
+ // retrieve all pledge payments for this particular pledge
$allPledgePayments = $allStatus = array();
$returnProperties = array('status_id');
CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgePayment', 'pledge_id', $pledgeId, $allPledgePayments, $returnProperties);
{$paymentClause}
";
- //get all status
+ // get all status
$params = array(1 => array($pledgeId, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
*
* @param int $paymentId
* Payment id.
- *
*/
public static function updateReminderDetails($paymentId) {
$query = "
* associated array of pledge details
*/
public static function getOldestPledgePayment($pledgeID, $limit = 1) {
- //get pending / overdue statuses
+ // get pending / overdue statuses
$pledgeStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
- //get pending and overdue payments
+ // get pending and overdue payments
$status[] = array_search('Pending', $pledgeStatuses);
$status[] = array_search('Overdue', $pledgeStatuses);
}
}
- //Cancel the initial paid amount
+ // Cancel the initial paid amount
CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', reset($paymentIDs), 'status_id', $paymentStatusID, 'id');
CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', reset($paymentIDs), 'actual_amount', $actualAmount, 'id');
- //Add new payment after the last payment for the pledge
+ // Add new payment after the last payment for the pledge
$allPayments = self::getPledgePayments($pledgeID);
$lastPayment = array_pop($allPayments);
if (($actualAmount != $pledgeScheduledAmount) && (($actualAmount < $pledgeScheduledAmount) || (($actualAmount - $pledgeScheduledAmount) < $oldestPayment['amount']))) {
$oldScheduledAmount = $oldestPayment['amount'];
$newScheduledAmount = $oldScheduledAmount + ($pledgeScheduledAmount - $actualAmount);
- //store new amount in oldest pending payment record.
+ // store new amount in oldest pending payment record.
CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment',
$oldestPayment['id'],
'scheduled_amount',
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Pledge_BAO_Query {
/**
* Build select for Pledge.
*
* @param $query
- *
- * @return void
*/
public static function select(&$query) {
$statusId = implode(',', array_keys(CRM_Core_PseudoConstant::accountOptionValues("contribution_status", NULL, " AND v.name IN ('Pending', 'Overdue')")));
$query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1;
}
- //add pledge select
+ // add pledge select
if (!empty($query->_returnProperties['pledge_amount'])) {
$query->_select['pledge_amount'] = 'civicrm_pledge.amount as pledge_amount';
$query->_element['pledge_amount'] = 1;
FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple')
);
- //unset in progress for payment
+ // unset in progress for payment
unset($statusValues['5']);
$form->add('select', 'pledge_payment_status_id',
FALSE, array('class' => 'crm-select2')
);
- //add fields for pledge frequency
+ // add fields for pledge frequency
$form->add('text', 'pledge_frequency_interval', ts('Every'), array('size' => 8, 'maxlength' => 8));
$form->addRule('pledge_frequency_interval', ts('Please enter valid Pledge Frequency Interval'), 'integer');
$frequencies = CRM_Core_OptionGroup::values('recur_frequency_units');
* @param $tables
*/
public static function tableNames(&$tables) {
- //add status table
+ // add status table
if (!empty($tables['pledge_status']) || !empty($tables['civicrm_pledge_payment'])) {
$tables = array_merge(array('civicrm_pledge' => 1), $tables);
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* - the search controller is used for building/processing multiform
* searches.
*
- * Typically the first form will display the search criteria and it's results
- *
- * The second form is used to process search results with the asscociated actions
+ * Typically the first form will display the search criteria and it's results.
*
+ * The second form is used to process search results with the asscociated actions.
*/
class CRM_Pledge_Controller_Search extends CRM_Core_Controller {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for processing a pledge payment
- *
+ * This class generates form components for processing a pledge payment.
*/
class CRM_Pledge_Form_Payment extends CRM_Core_Form {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
// check for edit permission
/**
* Set default values for the form.
- * the default values are retrieved from the database
- *
- *
- * @return void
+ * the default values are retrieved from the database.
*/
public function setDefaultValues() {
$defaults = array();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
- //add various dates
+ // add various dates
$this->addDate('scheduled_date', ts('Scheduled Date'), TRUE);
$this->addMoney('scheduled_amount',
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
- //get the submitted form values.
+ // get the submitted form values.
$formValues = $this->controller->exportValues($this->_name);
$params = array();
$formValues['scheduled_date'] = CRM_Utils_Date::processDate($formValues['scheduled_date']);
if (($formValues['scheduled_amount'] - $pledgeScheduledAmount) >= $oldestPaymentAmount['amount']) {
$adjustTotalAmount = TRUE;
}
- //update pledge status
+ // update pledge status
CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeId,
array($params['id']),
$params['status_id'],
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* This class generates form components for processing a pledge
- *
*/
class CRM_Pledge_Form_Pledge extends CRM_Core_Form {
public $_action;
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
$this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$this->setPageTitle(ts('Pledge'));
- //build custom data
+ // build custom data
CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Pledge', $this->_id);
$this->_values = array();
// current pledge id
if ($this->_id) {
- //get the contribution id
+ // get the contribution id
$this->_contributionID = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment',
$this->_id, 'contribution_id', 'pledge_id'
);
$this->_isPending = (CRM_Pledge_BAO_Pledge::pledgeHasFinancialTransactions($this->_id, CRM_Utils_Array::value('status_id', $this->_values))) ? FALSE : TRUE;
}
- //get the pledge frequency units.
+ // get the pledge frequency units.
$this->_freqUnits = CRM_Core_OptionGroup::values('recur_frequency_units');
$this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
/**
* Set default values for the form.
- * the default values are retrieved from the database
- *
- *
- * @return void
+ * The default values are retrieved from the database.
*/
public function setDefaultValues() {
$defaults = $this->_values;
list($defaults['acknowledge_date']) = CRM_Utils_Date::setDateDefaults($ackDate);
}
- //check is this pledge pending
- // fix the display of the monetary value, CRM-4038
+ // check is this pledge pending.
+ // fix the display of the monetary value, CRM-4038.
if ($this->_isPending) {
$defaults['eachPaymentAmount'] = $this->_values['amount'] / $this->_values['installments'];
$defaults['eachPaymentAmount'] = CRM_Utils_Money::format($defaults['eachPaymentAmount'], NULL, '%a');
$this->assign('installments', $defaults['installments']);
}
else {
- //default values.
+ // default values.
list($now) = CRM_Utils_Date::setDateDefaults();
$defaults['create_date'] = $now;
$defaults['start_date'] = $now;
$pledgeStatus
);
- //assign status.
+ // assign status.
$this->assign('status', CRM_Utils_Array::value(CRM_Utils_Array::value('status_id', $this->_values),
$pledgeStatus,
$defaultPledgeStatus
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
if ($this->_action & CRM_Core_Action::DELETE) {
'open' => 'false',
'id' => $type,
);
- //see if we need to include this paneName in the current form
+ // see if we need to include this paneName in the current form
if ($this->_formType == $type || !empty($_POST["hidden_{$type}"]) ||
CRM_Utils_Array::value("hidden_{$type}", $defaults)
) {
$this->applyFilter('__ALL__', 'trim');
- //pledge fields.
+ // pledge fields.
$attributes = CRM_Core_DAO::getAttribute('CRM_Pledge_DAO_Pledge');
$this->assign('isPending', $this->_isPending);
0 => 'READONLY', // WTF, preserved because its inexplicable
));
- //add various dates
+ // add various dates
if (!$this->_id || $this->_isPending) {
$this->addDate('create_date', ts('Pledge Made'), TRUE);
$this->addDate('start_date', ts('Payments Start'), TRUE);
TRUE
);
- //CRM-7362 --add campaigns.
+ // CRM-7362 --add campaigns.
CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
$pageIds = array();
);
$this->assign('outBound_option', $mailingInfo['outBound_option']);
- //build custom data
+ // build custom data
CRM_Custom_Form_CustomData::buildQuickForm($this);
// make this form an upload since we dont know if the custom data injected dynamically
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
- //get the submitted form values.
+ // get the submitted form values.
$formValues = $this->controller->exportValues($this->_name);
// set the contact, when contact is selected
$session = CRM_Core_Session::singleton();
- //get All Payments status types.
+ // get All Payments status types.
$paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$fields = array(
$params[$f] = CRM_Utils_Array::value($f, $formValues);
}
- //defaults status is "Pending".
- //if update get status.
+ // defaults status is "Pending".
+ // if update get status.
if ($this->_id) {
$params['pledge_status_id'] = $params['status_id'] = $this->_values['status_id'];
}
else {
$params['pledge_status_id'] = $params['status_id'] = array_search('Pending', $paymentStatusTypes);
}
- //format amount
+ // format amount
$params['amount'] = CRM_Utils_Rule::cleanMoney(CRM_Utils_Array::value('amount', $formValues));
$params['currency'] = CRM_Utils_Array::value('currency', $formValues);
$params['original_installment_amount'] = ($params['amount'] / $params['installments']);
$params['contact_id'] = $this->_contactID;
- //format custom data
+ // format custom data
if (!empty($formValues['hidden_custom'])) {
$params['hidden_custom'] = 1;
);
}
- //handle pending pledge.
+ // handle pending pledge.
$params['is_pledge_pending'] = $this->_isPending;
- //create pledge record.
+ // create pledge record.
$pledge = CRM_Pledge_BAO_Pledge::create($params);
$statusMsg = NULL;
if ($pledge->id) {
- //set the status msg.
+ // set the status msg.
if ($this->_action & CRM_Core_Action::ADD) {
$statusMsg = ts('Pledge has been recorded and the payment schedule has been created.<br />');
}
}
}
- //handle Acknowledgment.
+ // handle Acknowledgment.
if (!empty($formValues['is_acknowledge']) && $pledge->id) {
- //calculate scheduled amount.
+ // calculate scheduled amount.
$params['scheduled_amount'] = round($params['amount'] / $params['installments']);
$params['total_pledge_amount'] = $params['amount'];
- //get some required pledge values in params.
+ // get some required pledge values in params.
$params['id'] = $pledge->id;
$params['acknowledge_date'] = $pledge->acknowledge_date;
$params['is_test'] = $pledge->is_test;
$params['from_email_id'] = $formValues['from_email_address'];
$this->paymentId = NULL;
- //send Acknowledgment mail.
+ // send Acknowledgment mail.
CRM_Pledge_BAO_Pledge::sendAcknowledgment($this, $params);
if (!isset($this->userEmail)) {
$statusMsg .= ' ' . ts("An acknowledgment email has been sent to %1.<br />", array(1 => $this->userEmail));
- //build the payment urls.
+ // build the payment urls.
if ($this->paymentId) {
$urlParams = "reset=1&action=add&cid={$this->_contactID}&ppid={$this->paymentId}&context=pledge";
$contribURL = CRM_Utils_System::url('civicrm/contact/view/contribution', $urlParams);
$urlParams .= "&mode=live";
$creditURL = CRM_Utils_System::url('civicrm/contact/view/contribution', $urlParams);
- //check if we can process credit card payment.
+ // check if we can process credit card payment.
$processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE,
"billing_mode IN ( 1, 3 )"
);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* This class generates form components for Pledge
- *
*/
class CRM_Pledge_Form_PledgeView extends CRM_Core_Form {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
$values['honor_type'] = $honor[$values['honor_type_id']];
}
- //handle custom data.
+ // handle custom data.
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Pledge', $this, $params['id']);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
// omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
CRM_Utils_System::setTitle(ts('View Pledge by') . ' ' . $displayName);
- //do check for campaigns
+ // do check for campaigns
if ($campaignId = CRM_Utils_Array::value('campaign_id', $values)) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values['campaign'] = $campaigns[$campaignId];
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->addButtons(array(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
*/
public function preProcess() {
- /**
- * set the button names
- */
+ // set the button names
+
$this->_searchButtonName = $this->getButtonName('refresh');
$this->_actionButtonName = $this->getButtonName('next', 'action');
$this->_done = FALSE;
$this->defaults = array();
- /*
- * we allow the controller to set force/reset externally, useful when we are being
- * driven by the wizard framework
- */
+
+ // we allow the controller to set force/reset externally, useful when we are being
+ // driven by the wizard framework
+
$this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject);
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
$this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
* done.
* The processing consists of using a Selector / Controller framework for getting the
* search results.
- *
- * @param
- *
- * @return void
*/
public function postProcess() {
if ($this->_done) {
* add the rules (mainly global rules) for form.
* All local rules are added near the element
*
- * @return void
* @see valid_date
*/
public function addRules() {
*
* @param array $fields
* Posted values of the form.
- *
- * @return void
*/
public static function formRule($fields) {
$errors = array();
$form->_pledgeIds = $form->_componentIds = $ids;
- //set the context for redirection for any task actions
+ // set the context for redirection for any task actions
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form);
$urlParams = 'force=1';
if (CRM_Utils_Rule::qfKey($qfKey)) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
$this->addDefaultButtons(ts('Delete Pledges'), 'done');
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$deleted = $failed = 0;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
parent::preprocess();
/**
* Build the form object - it consists of
* - displaying the QILL (query in local language)
- * - displaying elements for saving the search
- *
- *
- * @return void
+ * - displaying elements for saving the search.
*/
public function buildQuickForm() {
- //
+
// just need to add a javacript to popup the window for printing
- //
+
$this->addButtons(array(
array(
'type' => 'next',
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
// redirect to the main search page after printing is over
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Used for displaying results
- *
- *
+ * Used for displaying results.
*/
class CRM_Pledge_Form_Task_Result extends CRM_Pledge_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
}
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->addButtons(array(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
parent::preProcess();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->addButtons(array(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Pledge_Info extends CRM_Core_Component_Info {
/**
- * @inheritDoc
+ * {@inheritDoc}
*/
protected $keyword = 'pledge';
/**
- * @inheritDoc
+ * {@inheritDoc}
* Provides permissions that are used by component.
* Needs to be implemented in component's information
* class.
}
/**
- * @inheritDoc
+ * {@inheritDoc}
* Provides information about user dashboard element
* offered by this component.
*
* collection of required dashboard settings,
* null if no element offered
*/
- /**
- * @return array|null
- */
public function getUserDashboardElement() {
return array(
'name' => ts('Pledges'),
}
/**
- * @inheritDoc
+ * {@inheritDoc}
* Provides information about user dashboard element
* offered by this component.
*
* collection of required dashboard settings,
* null if no element offered
*/
- /**
- * @return array|null
- */
public function registerTab() {
return array(
'title' => ts('Pledges'),
}
/**
- * @inheritDoc
+ * {@inheritDoc}
* Provides information about advanced search pane
* offered by this component.
*
* collection of required pane settings,
* null if no element offered
*/
- /**
- * @return array|null
- */
public function registerAdvancedSearchPane() {
return array(
'title' => ts('Pledges'),
}
/**
- * @inheritDoc
+ * {@inheritDoc}
* Provides potential activity types that this
* component might want to register in activity history.
* Needs to be implemented in component's information
* @return array|null
* collection of activity types
*/
- /**
- * @return array|null
- */
public function getActivityTypes() {
return NULL;
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This is page is for Pledge Dashboard
+ * This page is for the Pledge Dashboard.
*/
class CRM_Pledge_Page_DashBoard extends CRM_Core_Page {
/**
- * Heart of the viewing process. The runner gets all the meta data for
+ * Heart of the viewing process: The runner gets all the meta data for
* the contact and calls the appropriate type of page to view.
- *
- * @return void
*/
public function preProcess() {
CRM_Utils_System::setTitle(ts('CiviPledge'));
/**
* the main function that is called when the page loads,
- * it decides the which action has to be taken for the page.
+ * it decides which action has to be taken for the page.
*
* @return null
*/
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Pledge_Page_Payment extends CRM_Core_Page {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Pledge_Page_Tab extends CRM_Core_Page {
public $_permission = NULL;
/**
* called when action is browse.
- *
- * @return void
*/
public function browse() {
$controller = new CRM_Core_Controller_Simple('CRM_Pledge_Form_Search', ts('Pledges'), $this->_action);
$context = CRM_Utils_Request::retrieve('context', 'String', $form, FALSE, 'search');
$qfKey = CRM_Utils_Request::retrieve('key', 'String', $form);
- //validate the qfKey
+ // validate the qfKey
if (!CRM_Utils_Rule::qfKey($qfKey)) {
$qfKey = NULL;
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Pledge_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBoard {
/**
* called when action is browse.
- *
*/
public function listPledges() {
$controller = new CRM_Core_Controller_Simple(
$controller->process();
$controller->run();
- //add honor block.
+ // add honor block.
$honorParams = array();
$honorParams = CRM_Pledge_BAO_Pledge::getHonorContacts($this->_contactId);
if (!empty($honorParams)) {
/**
* the main function that is called when the page
* loads, it decides the which action has to be taken for the page.
- *
*/
public function run() {
parent::preProcess();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*/
/**
/**
* Properties of contact we're interested in displaying
+ *
* @var array
*/
static $_properties = array(
FALSE, FALSE, FALSE, NULL, 'name', FALSE
);
- //get all campaigns.
+ // get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
- //4418 check for view, edit and delete
+ // CRM-4418 check for view, edit and delete
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit pledges')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
}
- //carry campaign on selectors.
+ // carry campaign on selectors.
$row['campaign'] = CRM_Utils_Array::value($result->pledge_campaign_id, $allCampaigns);
$row['campaign_id'] = $result->pledge_campaign_id;
/**
* Get qill (display what was searched on).
*
- * @inheritDoc
+ * {@inheritDoc}
*/
public function getQILL() {
return $this->_query->qill();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Pledge_StateMachine_Search extends CRM_Core_StateMachine {
*/
/**
- *
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* class to represent the actions that can be performed on a group of contacts
- * used by the search forms
- *
+ * used by the search forms.
*/
class CRM_Pledge_Task {
const DELETE_PLEDGES = 1, PRINT_PLEDGES = 2, EXPORT_PLEDGES = 3;
),
);
- //CRM-4418, check for delete
+ // CRM-4418, check for delete
if (!CRM_Core_Permission::check('delete in CiviPledge')) {
unset(self::$_tasks[1]);
}
/**
* These tasks are the core set of tasks that the user can perform
- * on pledges
+ * on pledges.
*
* @param int $value
*