コード例 #1
0
 /**
  *  Function to retrieve the list of soft contributons for given contact.
  *  @param int $contact_id contact id 
  *
  *  @return array
  *  @static
  */
 static function getSoftContributionList($contact_id, $isTest = 0)
 {
     $query = "SELECT ccs.id, ccs.amount as amount,\n                         ccs.contribution_id, \n                         ccs.pcp_id,\n                         ccs.pcp_display_in_roll,\n                         ccs.pcp_roll_nickname,\n                         ccs.pcp_personal_note,\n                         cc.receive_date,\n                         cc.contact_id as contributor_id,\n                         cc.contribution_status_id as contribution_status_id,\n                         cp.title as pcp_title,\n                         cc.currency,\n                         contact.display_name,\n                         cct.name as contributionType\n                  FROM civicrm_contribution_soft ccs\n                       LEFT JOIN civicrm_contribution cc\n                              ON ccs.contribution_id = cc.id\n                       LEFT JOIN civicrm_pcp cp \n                              ON ccs.pcp_id = cp.id\n                       LEFT JOIN civicrm_contact contact\n                              ON ccs.contribution_id = cc.id AND\n                                 cc.contact_id = contact.id \n                       LEFT JOIN civicrm_contribution_type cct\n                              ON cc.contribution_type_id = cct.id\n                  WHERE cc.is_test = {$isTest} AND ccs.contact_id = " . $contact_id;
     $cs = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     require_once "CRM/Contribute/PseudoConstant.php";
     $contributionStatus = CRM_Contribute_Pseudoconstant::contributionStatus();
     $result = array();
     while ($cs->fetch()) {
         $result[$cs->id]['amount'] = $cs->amount;
         $result[$cs->id]['currency'] = $cs->currency;
         $result[$cs->id]['contributor_id'] = $cs->contributor_id;
         $result[$cs->id]['contribution_id'] = $cs->contribution_id;
         $result[$cs->id]['contributor_name'] = $cs->display_name;
         $result[$cs->id]['contribution_type'] = $cs->contributionType;
         $result[$cs->id]['receive_date'] = $cs->receive_date;
         $result[$cs->id]['pcp_id'] = $cs->pcp_id;
         $result[$cs->id]['pcp_title'] = $cs->pcp_title;
         $result[$cs->id]['pcp_display_in_roll'] = $cs->pcp_display_in_roll;
         $result[$cs->id]['pcp_roll_nickname'] = $cs->pcp_roll_nickname;
         $result[$cs->id]['pcp_personal_note'] = $cs->pcp_personal_note;
         $result[$cs->id]['contribution_status'] = CRM_Utils_Array::value($cs->contribution_status_id, $contributionStatus);
         if ($isTest) {
             $result[$cs->id]['contribution_status'] = $result[$cs->id]['contribution_status'] . '<br /> (test)';
         }
     }
     return $result;
 }
コード例 #2
0
ファイル: Pledge.php プロジェクト: hampelm/Ginsberg-CiviDemo
 /**
  * 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();
     require_once 'CRM/Pledge/DAO/Pledge.php';
     $honorDAO = new CRM_Pledge_DAO_Pledge();
     $honorDAO->honor_contact_id = $honorId;
     $honorDAO->find();
     //get all status.
     require_once 'CRM/Contribute/PseudoConstant.php';
     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_Contribute_DAO_ContributionType', $honorDAO->contribution_type_id, 'name'), 'display_name' => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $honorDAO->contact_id, 'display_name'));
     }
     return $params;
 }
コード例 #3
0
ファイル: Form.php プロジェクト: konadave/civicrm-core
 /**
  * Generate temporary table to hold all contributions with permissioned FTs.
  *
  * @param object $query
  * @param string $alias
  * @param bool $return
  */
 public function getPermissionedFTQuery(&$query, $alias = NULL, $return = FALSE)
 {
     if (!CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
         return FALSE;
     }
     $financialTypes = NULL;
     CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes);
     if (empty($financialTypes)) {
         $contFTs = "0";
         $liFTs = implode(',', array_keys(CRM_Contribute_Pseudoconstant::financialType()));
     } else {
         $contFTs = $liFTs = implode(',', array_keys($financialTypes));
     }
     if ($alias) {
         $temp = CRM_Utils_Array::value('civicrm_line_item', $query->_aliases);
         $query->_aliases['civicrm_line_item'] = $alias;
     }
     if (empty($query->_where)) {
         $query->_where = "WHERE {$query->_aliases['civicrm_contribution']}.id IS NOT NULL ";
     }
     CRM_Core_DAO::executeQuery("DROP TEMPORARY TABLE IF EXISTS civicrm_contribution_temp");
     $sql = "CREATE TEMPORARY TABLE civicrm_contribution_temp AS SELECT {$query->_aliases['civicrm_contribution']}.id {$query->_from}\n              LEFT JOIN civicrm_line_item   {$query->_aliases['civicrm_line_item']}\n                      ON {$query->_aliases['civicrm_contribution']}.id = {$query->_aliases['civicrm_line_item']}.contribution_id AND\n                         {$query->_aliases['civicrm_line_item']}.entity_table = 'civicrm_contribution'\n                      AND {$query->_aliases['civicrm_line_item']}.financial_type_id NOT IN (" . $liFTs . ")\n              {$query->_where}\n                      AND {$query->_aliases['civicrm_contribution']}.financial_type_id IN (" . $contFTs . ")\n                      AND {$query->_aliases['civicrm_line_item']}.id IS NULL\n              GROUP BY {$query->_aliases['civicrm_contribution']}.id";
     CRM_Core_DAO::executeQuery($sql);
     if (isset($temp)) {
         $query->_aliases['civicrm_line_item'] = $temp;
     }
     $from = " INNER JOIN civicrm_contribution_temp temp ON {$query->_aliases['civicrm_contribution']}.id = temp.id ";
     if ($return) {
         return $from;
     }
     $query->_from .= $from;
 }
コード例 #4
0
function iats_civicrm_buildForm_CRM_Contribute_Form_UpdateSubscription(&$form)
{
    // only do this if the user is allowed to edit contributions. A more stringent permission might be smart.
    if (!CRM_Core_Permission::check('edit contributions')) {
        return;
    }
    // only mangle this form for recurring contributions using iATS, (and not the UKDD version)
    $payment_processor_type = $form->_paymentProcessor['class_name'];
    if (0 !== strpos($payment_processor_type, 'Payment_iATSService')) {
        return;
    }
    if ('Payment_iATSServiceUKDD' == $payment_processor_type) {
        return;
    }
    $settings = civicrm_api3('Setting', 'getvalue', array('name' => 'iats_settings'));
    // don't do this if the site administrator has disabled it
    if (!empty($settings['no_edit_extra'])) {
        return;
    }
    $allow_days = empty($settings['days']) ? array('-1') : $settings['days'];
    if (0 < max($allow_days)) {
        $userAlert = ts('Your next scheduled contribution date will automatically be updated to the next allowable day of the month: %1', array(1 => implode(',', $allow_days)));
        CRM_Core_Session::setStatus($userAlert, ts('Warning'), 'alert');
    }
    $crid = CRM_Utils_Request::retrieve('crid', 'Integer', $form, FALSE);
    /* get the recurring contribution record and the contact record, or quit */
    try {
        $recur = civicrm_api3('ContributionRecur', 'getsingle', array('id' => $crid));
    } catch (CiviCRM_API3_Exception $e) {
        return;
    }
    try {
        $contact = civicrm_api3('Contact', 'getsingle', array('id' => $recur['contact_id']));
    } catch (CiviCRM_API3_Exception $e) {
        return;
    }
    // turn off default notification checkbox, most will want to hide it as well.
    $defaults = array('is_notify' => 0);
    $edit_fields = array('contribution_status_id' => 'Status', 'next_sched_contribution_date' => 'Next Scheduled Contribution', 'start_date' => 'Start Date');
    foreach (array_keys($edit_fields) as $fid) {
        if ($form->elementExists($fid)) {
            unset($edit_fields[$fid]);
        } else {
            $defaults[$fid] = $recur[$fid];
        }
    }
    if (0 == count($edit_fields)) {
        // some other extension, or core, is exposing my fields, so quit
        return;
    }
    // print_r($recur); die();
    $form->addElement('static', 'contact', $contact['display_name']);
    // $form->addElement('static','contact',$contact['display_name']);
    if ($edit_fields['contribution_status_id']) {
        $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
        $form->addElement('select', 'contribution_status_id', ts('Status'), $contributionStatus);
        unset($edit_fields['contribution_status_id']);
    }
    foreach ($edit_fields as $fid => $label) {
        $form->addDateTime($fid, ts($label));
    }
    $form->setDefaults($defaults);
    // now add some more fields for display only
    $pp_label = $form->_paymentProcessor['name'];
    // get my pp
    $form->addElement('static', 'payment_processor', $pp_label);
    $label = CRM_Contribute_Pseudoconstant::financialType($recur['financial_type_id']);
    $form->addElement('static', 'financial_type', $label);
    $labels = CRM_Contribute_Pseudoconstant::paymentInstrument();
    $label = $labels[$recur['payment_instrument_id']];
    $form->addElement('static', 'payment_instrument', $label);
    $form->addElement('static', 'failure_count', $recur['failure_count']);
    CRM_Core_Region::instance('page-body')->add(array('template' => 'CRM/iATS/Subscription.tpl'));
    CRM_Core_Resources::singleton()->addScriptFile('com.iatspayments.civicrm', 'js/subscription.js');
}