// stores the label
$form->add('hidden', 'pcp_made_through');
- $statusValues = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status');
+ $statusValues = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id');
// Remove status values that are only used for recurring contributions or pledges (In Progress, Overdue).
unset($statusValues['5'], $statusValues['6']);
-
- $form->addSelect('contribution_status_id',
- array('entity' => 'contribution', 'multiple' => 'multiple', 'label' => ts('Contribution Status(s)'), 'option_url' => NULL, 'placeholder' => ts('- any -'))
+ $form->add('select', 'contribution_status_id',
+ ts('Contribution Status'), $statusValues,
+ FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple')
);
// Add fields for thank you and receipt
);
return;
- case 'pledge_status_id':
- if (is_array($value)) {
- foreach ($value as $k => $v) {
- if ($v) {
- $val[$k] = $k;
- }
- }
-
- $status = implode(',', $val);
-
- if (count($val) > 0) {
- $op = 'IN';
- $status = "({$status})";
- }
- }
- else {
- $status = $value;
- }
-
- $statusValues = CRM_Core_OptionGroup::values('contribution_status');
-
- $names = array();
- if (isset($val) && is_array($val)) {
- foreach ($val as $id => $dontCare) {
- $names[] = $statusValues[$id];
- }
- }
- else {
- if (!empty($value)) {
- $names[] = $statusValues[$value];
- }
- }
-
- $query->_qill[$grouping][] = ts('Pledge Status %1', array(1 => $op)) . ' ' . implode(' ' . ts('or') . ' ', $names);
- $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_pledge.status_id',
- $op,
- $status,
- 'Integer'
- );
- $query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1;
- return;
-
case 'pledge_payment_status_id':
- if (is_array($value)) {
- foreach ($value as $k => $v) {
- if ($v) {
- $val[$k] = $k;
- }
- }
-
- $status = implode(',', $val);
-
- if (count($val) > 1) {
- $op = 'IN';
- $status = "({$status})";
- }
+ case 'pledge_status_id':
+ if ($name == 'pledge_status_id') {
+ $tableName = 'civicrm_pledge';
+ $query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1;
+ $label = "Pledge Status";
}
else {
- $status = $value;
- }
-
- $statusValues = CRM_Core_OptionGroup::values('contribution_status');
-
- $names = array();
- if (is_array($val)) {
- foreach ($val as $id => $dontCare) {
- $names[] = $statusValues[$id];
- }
+ $tableName = 'civicrm_pledge_payment';
+ $query->_tables['civicrm_pledge_payment'] = $query->_whereTables['civicrm_pledge_payment'] = 1;
+ $label = "Pledge Payment Status";
}
- else {
- if (!empty($value)) {
- $names[] = $statusValues[$value];
- }
+ $name = 'status_id';
+ if (!empty($value) && is_array($value) && !in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
+ $value = array('IN' => $value);
}
- $query->_qill[$grouping][] = ts('Pledge Payment Status %1', array(1 => $op)) . ' ' . implode(' ' . ts('or') . ' ', $names);
- $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_pledge_payment.status_id',
+ $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("$tableName.$name",
$op,
- $status,
+ $value,
'Integer'
);
- $query->_tables['civicrm_pledge_payment'] = $query->_whereTables['civicrm_pledge_payment'] = 1;
+ list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contribute_DAO_Contribution', 'contribution_status_id', $value, $op);
+ $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $label, 2 => $qillop, 3 => $qillVal));
return;
case 'pledge_test':
// Remove status values that are only used for recurring contributions for now (Failed and In Progress).
unset($statusValues['4']);
- foreach ($statusValues as $key => $val) {
- $status[] = $form->createElement('advcheckbox', $key, NULL, $val);
- }
-
- $form->addGroup($status, 'pledge_status_id', ts('Pledge Status'));
+ $form->add('select', 'pledge_status_id',
+ ts('Pledge Status'), $statusValues,
+ FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple')
+ );
//unset in progress for payment
unset($statusValues['5']);
- foreach ($statusValues as $key => $val) {
- $paymentStatus[] = $form->createElement('advcheckbox', $key, NULL, $val);
- }
-
- $form->addGroup($paymentStatus, 'pledge_payment_status_id', ts('Pledge Payment Status'));
+ $form->add('select', 'pledge_payment_status_id',
+ ts('Pledge Payment Status'), $statusValues,
+ FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple')
+ );
$form->add('select', 'pledge_financial_type_id',
ts('Financial Type'),