/**
* The Pledge values if an existing pledge.
+ * @var array
*/
public $_values;
/**
* The Pledge frequency Units.
+ * @var array
*/
public $_freqUnits;
/**
* Is current pledge pending.
+ * @var bool
*/
public $_isPending = FALSE;
list($this->userDisplayName,
$this->userEmail
) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
- $this->assign('displayName', $this->userDisplayName);
}
$this->setPageTitle(ts('Pledge'));
// build custom data
CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Pledge', $this->_id);
- $this->_values = array();
+ $this->_values = [];
// current pledge id
if ($this->_id) {
// get the contribution id
$this->_contributionID = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment',
$this->_id, 'contribution_id', 'pledge_id'
);
- $params = array('id' => $this->_id);
+ $params = ['id' => $this->_id];
CRM_Pledge_BAO_Pledge::getValues($params, $this->_values);
$this->_isPending = (CRM_Pledge_BAO_Pledge::pledgeHasFinancialTransactions($this->_id, CRM_Utils_Array::value('status_id', $this->_values))) ? FALSE : TRUE;
$this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
}
-
/**
* Set default values for the form.
* The default values are retrieved from the database.
$this->assign('installments', $defaults['installments']);
}
else {
+ if ($this->_contactID) {
+ $defaults['contact_id'] = $this->_contactID;
+ }
// default values.
$defaults['create_date'] = date('Y-m-d');
$defaults['start_date'] = date('Y-m-d');
*/
public function buildQuickForm() {
if ($this->_action & CRM_Core_Action::DELETE) {
- $this->addButtons(array(
- array(
+ $this->addButtons([
+ [
'type' => 'next',
'name' => ts('Delete'),
'spacing' => ' ',
'isDefault' => TRUE,
- ),
- array(
+ ],
+ [
'type' => 'cancel',
'name' => ts('Cancel'),
- ),
- )
- );
+ ],
+ ]);
return;
}
- if ($this->_context == 'standalone') {
- $this->addEntityRef('contact_id', ts('Contact'), array(
- 'create' => TRUE,
- 'api' => array('extra' => array('email')),
- ), TRUE);
+ $contactField = $this->addEntityRef('contact_id', ts('Contact'), ['create' => TRUE, 'api' => ['extra' => ['email']]], TRUE);
+ if ($this->_context != 'standalone') {
+ $contactField->freeze();
}
$showAdditionalInfo = FALSE;
$this->_formType = CRM_Utils_Array::value('formType', $_GET);
- $defaults = array();
+ $defaults = [];
- $paneNames = array(
+ $paneNames = [
'Payment Reminders' => 'PaymentReminders',
- );
+ ];
foreach ($paneNames as $name => $type) {
$urlParams = "snippet=4&formType={$type}";
- $allPanes[$name] = array(
+ $allPanes[$name] = [
'url' => CRM_Utils_System::url('civicrm/contact/view/pledge', $urlParams),
'open' => 'false',
'id' => $type,
- );
+ ];
// 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->assign('isPending', $this->_isPending);
- $js = array(
+ $js = [
'onblur' => "calculatedPaymentAmount( );",
'onkeyup' => "calculatedPaymentAmount( );",
- );
+ ];
$amount = $this->addMoney('amount', ts('Total Pledge Amount'), TRUE,
array_merge($attributes['pledge_amount'], $js), TRUE,
$this->addRule('frequency_interval', ts('Please enter a number for frequency (e.g. every "3" months).'), 'positiveInteger');
// Fix frequency unit display for use with frequency_interval
- $freqUnitsDisplay = array();
+ $freqUnitsDisplay = [];
foreach ($this->_freqUnits as $val => $label) {
- $freqUnitsDisplay[$val] = ts('%1(s)', array(1 => $label));
+ $freqUnitsDisplay[$val] = ts('%1(s)', [1 => $label]);
}
$frequencyUnit = $this->add('select', 'frequency_unit',
ts('Frequency'),
- array('' => ts('- select -')) + $freqUnitsDisplay,
+ ['' => ts('- select -')] + $freqUnitsDisplay,
TRUE
);
$frequencyDay = $this->add('number', 'frequency_day', ts('Payments are due on the'), $attributes['frequency_day'], TRUE);
$this->addRule('frequency_day', ts('Please enter a valid payment due day.'), 'positiveInteger');
- $this->add('text', 'eachPaymentAmount', ts('each'), array(
- 'size' => 10,
- 'style' => "background-color:#EBECE4",
- 0 => 'READONLY', // WTF, preserved because its inexplicable
- ));
+ $this->add('text', 'eachPaymentAmount', ts('each'), [
+ 'size' => 10,
+ 'style' => "background-color:#EBECE4",
+ // WTF, preserved because its inexplicable
+ 0 => 'READONLY',
+ ]);
// add various dates
$createDate = $this->add('datepicker', 'create_date', ts('Pledge Made'), [], TRUE, ['time' => FALSE]);
) {
$this->addElement('checkbox', 'is_acknowledge', ts('Send Acknowledgment?'), NULL,
- array('onclick' => "showHideByValue( 'is_acknowledge', '', 'acknowledgeDate', 'table-row', 'radio', true); showHideByValue( 'is_acknowledge', '', 'fromEmail', 'table-row', 'radio', false );")
+ ['onclick' => "showHideByValue( 'is_acknowledge', '', 'acknowledgeDate', 'table-row', 'radio', true); showHideByValue( 'is_acknowledge', '', 'fromEmail', 'table-row', 'radio', false );"]
);
$this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails);
$this->add('select', 'financial_type_id',
ts('Financial Type'),
- array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(),
+ ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::financialType(),
TRUE
);
// CRM-7362 --add campaigns.
CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
- $pageIds = array();
+ $pageIds = [];
CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgeBlock', 'entity_table',
- 'civicrm_contribution_page', $pageIds, array('entity_id')
+ 'civicrm_contribution_page', $pageIds, ['entity_id']
);
$pages = CRM_Contribute_PseudoConstant::contributionPage();
- $pledgePages = array();
+ $pledgePages = [];
foreach ($pageIds as $key => $value) {
$pledgePages[$value['entity_id']] = $pages[$value['entity_id']];
}
$this->add('select', 'contribution_page_id', ts('Self-service Payments Page'),
- array('' => ts('- select -')) + $pledgePages
+ ['' => ts('- select -')] + $pledgePages
);
$mailingInfo = Civi::settings()->get('mailing_backend');
// make this form an upload since we dont know if the custom data injected dynamically
// is of type file etc $uploadNames = $this->get( 'uploadNames' );
- $this->addButtons(array(
- array(
+ $this->addButtons([
+ [
'type' => 'upload',
'name' => ts('Save'),
- 'js' => array('onclick' => "return verify( );"),
+ 'js' => ['onclick' => "return verify( );"],
'isDefault' => TRUE,
- ),
- array(
+ ],
+ [
'type' => 'upload',
'name' => ts('Save and New'),
- 'js' => array('onclick' => "return verify( );"),
+ 'js' => ['onclick' => "return verify( );"],
'subName' => 'new',
- ),
- array(
+ ],
+ [
'type' => 'cancel',
'name' => ts('Cancel'),
- ),
- )
- );
+ ],
+ ]);
- $this->addFormRule(array('CRM_Pledge_Form_Pledge', 'formRule'), $this);
+ $this->addFormRule(['CRM_Pledge_Form_Pledge', 'formRule'], $this);
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
* true if no errors, else array of errors
*/
public static function formRule($fields, $files, $self) {
- $errors = array();
+ $errors = [];
if ($fields['amount'] <= 0) {
$errors['amount'] = ts('Total Pledge Amount should be greater than zero.');
$session = CRM_Core_Session::singleton();
- $fields = array(
+ $fields = [
'frequency_unit',
'frequency_interval',
'frequency_day',
'additional_reminder_day',
'contribution_page_id',
'campaign_id',
- );
+ ];
foreach ($fields as $f) {
$params[$f] = CRM_Utils_Array::value($f, $formValues);
}
$params['currency'] = CRM_Utils_Array::value('currency', $formValues);
$params['original_installment_amount'] = ($params['amount'] / $params['installments']);
- $dates = array('create_date', 'start_date', 'acknowledge_date', 'cancel_date');
+ $dates = ['create_date', 'start_date', 'acknowledge_date', 'cancel_date'];
foreach ($dates as $d) {
if ($this->_id && (!$this->_isPending) && !empty($this->_values[$d])) {
if ($d == 'start_date') {
// send Acknowledgment mail.
CRM_Pledge_BAO_Pledge::sendAcknowledgment($this, $params);
- if (!isset($this->userEmail)) {
- list($this->userDisplayName,
- $this->userEmail
- ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
- }
-
- $statusMsg .= ' ' . ts("An acknowledgment email has been sent to %1.<br />", array(1 => $this->userEmail));
+ $statusMsg .= ' ' . ts("An acknowledgment email has been sent to %1.<br />", [1 => $this->userEmail]);
// build the payment urls.
if ($this->paymentId) {
"billing_mode IN ( 1, 3 )"
);
if (count($processors) > 0) {
- $statusMsg .= ' ' . ts("If a payment is due now, you can record <a href='%1'>a check, EFT, or cash payment for this pledge</a> OR <a href='%2'>submit a credit card payment</a>.", array(
- 1 => $contribURL,
- 2 => $creditURL,
- ));
+ $statusMsg .= ' ' . ts("If a payment is due now, you can record <a href='%1'>a check, EFT, or cash payment for this pledge</a> OR <a href='%2'>submit a credit card payment</a>.", [
+ 1 => $contribURL,
+ 2 => $creditURL,
+ ]);
}
else {
- $statusMsg .= ' ' . ts("If a payment is due now, you can record <a href='%1'>a check, EFT, or cash payment for this pledge</a>.", array(1 => $contribURL));
+ $statusMsg .= ' ' . ts("If a payment is due now, you can record <a href='%1'>a check, EFT, or cash payment for this pledge</a>.", [1 => $contribURL]);
}
}
}