コード例 #1
0
 /**
  * Pre-processing for the form.
  *
  * @throws \Exception
  */
 public function preProcess()
 {
     $this->setAction(CRM_Core_Action::UPDATE);
     $this->contributionRecurID = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE);
     if ($this->contributionRecurID) {
         $this->_paymentProcessor = CRM_Contribute_BAO_ContributionRecur::getPaymentProcessor($this->contributionRecurID);
         if (!$this->_paymentProcessor) {
             CRM_Core_Error::statusBounce(ts('There is no valid processor for this subscription so it cannot be edited.'));
         }
         $this->_paymentProcessorObj = $this->_paymentProcessor['object'];
         $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->contributionRecurID);
     }
     $this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE);
     if ($this->_coid) {
         $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'info');
         $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj');
         $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
         $this->contributionRecurID = $this->_subscriptionDetails->recur_id;
     } elseif ($this->contributionRecurID) {
         $this->_coid = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $this->contributionRecurID, 'id', 'contribution_recur_id');
     }
     if (!$this->contributionRecurID || $this->_subscriptionDetails == CRM_Core_DAO::$_nullObject) {
         CRM_Core_Error::fatal('Required information missing.');
     }
     if ($this->_subscriptionDetails->membership_id && $this->_subscriptionDetails->auto_renew) {
         CRM_Core_Error::fatal(ts('You cannot update the subscription.'));
     }
     if (!CRM_Core_Permission::check('edit contributions')) {
         $userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this, FALSE);
         if (!CRM_Contact_BAO_Contact_Utils::validChecksum($this->_subscriptionDetails->contact_id, $userChecksum)) {
             CRM_Core_Error::fatal(ts('You do not have permission to update subscription.'));
         }
         $this->_selfService = TRUE;
     }
     $this->assign('self_service', $this->_selfService);
     $this->editableScheduleFields = $this->_paymentProcessorObj->getEditableRecurringScheduleFields();
     $changeHelpText = $this->_paymentProcessorObj->getRecurringScheduleUpdateHelpText();
     if (!in_array('amount', $this->editableScheduleFields)) {
         // Not sure if this is good behaviour - maintaining this existing behaviour for now.
         CRM_Core_Session::setStatus($changeHelpText, ts('Warning'), 'alert');
     } else {
         $this->assign('changeHelpText', $changeHelpText);
     }
     $alreadyHardCodedFields = array('amount', 'installments');
     foreach ($this->editableScheduleFields as $editableScheduleField) {
         if (!in_array($editableScheduleField, $alreadyHardCodedFields)) {
             $this->addField($editableScheduleField, array('entity' => 'ContributionRecur'));
         }
     }
     $this->assign('editableScheduleFields', array_diff($this->editableScheduleFields, $alreadyHardCodedFields));
     $this->assign('paymentProcessor', $this->_paymentProcessor);
     $this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
     $this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
     if ($this->_subscriptionDetails->contact_id) {
         list($this->_donorDisplayName, $this->_donorEmail) = CRM_Contact_BAO_Contact::getContactDetails($this->_subscriptionDetails->contact_id);
     }
     CRM_Utils_System::setTitle(ts('Update Recurring Contribution'));
     // Handle context redirection.
     CRM_Contribute_BAO_ContributionRecur::setSubscriptionContext();
 }
コード例 #2
0
 /**
  * Set variables up before form is built.
  */
 public function preProcess()
 {
     $this->_mid = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE);
     $this->_crid = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE);
     if ($this->_crid) {
         $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'obj');
         $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_crid);
         $this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
         $this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
         $this->assign('amount', $this->_subscriptionDetails->amount);
         $this->assign('installments', $this->_subscriptionDetails->installments);
         // Are we cancelling a recurring contribution that is linked to an auto-renew membership?
         if ($this->_subscriptionDetails->membership_id) {
             $this->_mid = $this->_subscriptionDetails->membership_id;
         }
     }
     if ($this->_mid) {
         $this->_mode = 'auto_renew';
         // CRM-18468: crid is more accurate than mid for getting
         // subscriptionDetails, so don't get them again.
         if (!$this->_crid) {
             $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_mid, 'membership', 'obj');
             $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_mid, 'membership');
         }
         $membershipTypes = CRM_Member_PseudoConstant::membershipType();
         $membershipTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_mid, 'membership_type_id');
         $this->assign('membershipType', CRM_Utils_Array::value($membershipTypeId, $membershipTypes));
     }
     $this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE);
     if ($this->_coid) {
         if (CRM_Contribute_BAO_Contribution::isSubscriptionCancelled($this->_coid)) {
             CRM_Core_Error::fatal(ts('The recurring contribution looks to have been cancelled already.'));
         }
         $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj');
         $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
         $this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
         $this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
         $this->assign('amount', $this->_subscriptionDetails->amount);
         $this->assign('installments', $this->_subscriptionDetails->installments);
     }
     if (!$this->_crid && !$this->_coid && !$this->_mid || $this->_subscriptionDetails == CRM_Core_DAO::$_nullObject) {
         CRM_Core_Error::fatal('Required information missing.');
     }
     if (!CRM_Core_Permission::check('edit contributions')) {
         $userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this, FALSE);
         if (!CRM_Contact_BAO_Contact_Utils::validChecksum($this->_subscriptionDetails->contact_id, $userChecksum)) {
             CRM_Core_Error::fatal(ts('You do not have permission to cancel this recurring contribution.'));
         }
         $this->_selfService = TRUE;
     }
     $this->assign('self_service', $this->_selfService);
     // handle context redirection
     CRM_Contribute_BAO_ContributionRecur::setSubscriptionContext();
     CRM_Utils_System::setTitle($this->_mid ? ts('Cancel Auto-renewal') : ts('Cancel Recurring Contribution'));
     $this->assign('mode', $this->_mode);
     if ($this->_subscriptionDetails->contact_id) {
         list($this->_donorDisplayName, $this->_donorEmail) = CRM_Contact_BAO_Contact::getContactDetails($this->_subscriptionDetails->contact_id);
     }
 }
コード例 #3
0
ファイル: UpdateBilling.php プロジェクト: indydas/civi-demo
 /**
  * Set variables up before form is built.
  *
  * @return void
  */
 public function preProcess()
 {
     $this->_mid = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE);
     $this->_crid = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE);
     if ($this->_crid) {
         $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'info');
         $this->_paymentProcessor['object'] = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'obj');
         $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_crid);
         // Are we cancelling a recurring contribution that is linked to an auto-renew membership?
         if ($this->_subscriptionDetails->membership_id) {
             $this->_mid = $this->_subscriptionDetails->membership_id;
         }
     }
     $this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE);
     if ($this->_coid) {
         $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'info');
         $this->_paymentProcessor['object'] = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj');
         $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
     }
     if ($this->_mid) {
         $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_mid, 'membership', 'info');
         $this->_paymentProcessor['object'] = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_mid, 'membership', 'obj');
         $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_mid, 'membership');
         $membershipTypes = CRM_Member_PseudoConstant::membershipType();
         $membershipTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_mid, 'membership_type_id');
         $this->assign('membershipType', CRM_Utils_Array::value($membershipTypeId, $membershipTypes));
         $this->_mode = 'auto_renew';
     }
     $this->_paymentProcessorObj = CRM_Utils_Array::value('object', $this->_paymentProcessor);
     if (!$this->_crid && !$this->_coid && !$this->_mid || $this->_subscriptionDetails == CRM_Core_DAO::$_nullObject) {
         CRM_Core_Error::fatal('Required information missing.');
     }
     if (!CRM_Core_Permission::check('edit contributions')) {
         $userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this, FALSE);
         if (!CRM_Contact_BAO_Contact_Utils::validChecksum($this->_subscriptionDetails->contact_id, $userChecksum)) {
             CRM_Core_Error::fatal(ts('You do not have permission to cancel subscription.'));
         }
         $this->_selfService = TRUE;
     }
     if (!$this->_paymentProcessor['object']->isSupported('updateSubscriptionBillingInfo')) {
         CRM_Core_Error::fatal(ts("%1 processor doesn't support updating subscription billing details.", array(1 => $this->_paymentProcessor['object']->_processorName)));
     }
     $this->assign('paymentProcessor', $this->_paymentProcessor);
     // get the billing location type
     $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
     $this->_bltID = array_search('Billing', $locationTypes);
     $this->assign('bltID', $this->_bltID);
     if (!$this->_bltID) {
         CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
     }
     $this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
     $this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
     $this->assign('amount', $this->_subscriptionDetails->amount);
     $this->assign('installments', $this->_subscriptionDetails->installments);
     $this->assign('mode', $this->_mode);
     // handle context redirection
     CRM_Contribute_BAO_ContributionRecur::setSubscriptionContext();
 }
コード例 #4
0
 public function preProcess()
 {
     $this->_crid = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE);
     if ($this->_crid) {
         $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'info');
         $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'obj');
         $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_crid);
     }
     $this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE);
     if ($this->_coid) {
         $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'info');
         $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj');
         $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
         $this->_crid = $this->_subscriptionDetails->recur_id;
     } elseif ($this->_crid) {
         $this->_coid = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $this->_crid, 'id', 'contribution_recur_id');
     }
     if (!$this->_crid || $this->_subscriptionDetails == CRM_Core_DAO::$_nullObject) {
         CRM_Core_Error::fatal('Required information missing.');
     }
     if ($this->_subscriptionDetails->membership_id && $this->_subscriptionDetails->auto_renew) {
         CRM_Core_Error::fatal(ts('You cannot update the subscription.'));
     }
     if (!CRM_Core_Permission::check('edit contributions')) {
         $userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this, FALSE);
         if (!CRM_Contact_BAO_Contact_Utils::validChecksum($this->_subscriptionDetails->contact_id, $userChecksum)) {
             CRM_Core_Error::fatal(ts('You do not have permission to update subscription.'));
         }
         $this->_selfService = TRUE;
     }
     $this->assign('self_service', $this->_selfService);
     if (!$this->_paymentProcessorObj->isSupported('changeSubscriptionAmount')) {
         $userAlert = ts('Updates made using this form will change the recurring contribution information stored in your CiviCRM database, but will NOT be sent to the payment processor. You must enter the same changes using the payment processor web site.');
         CRM_Core_Session::setStatus($userAlert, ts('Warning'), 'alert');
     }
     $this->assign('isChangeSupported', $this->_paymentProcessorObj->isSupported('changeSubscriptionAmount'));
     $this->assign('paymentProcessor', $this->_paymentProcessor);
     $this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
     $this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
     if ($this->_subscriptionDetails->contact_id) {
         list($this->_donorDisplayName, $this->_donorEmail) = CRM_Contact_BAO_Contact::getContactDetails($this->_subscriptionDetails->contact_id);
     }
     CRM_Utils_System::setTitle(ts('Update Recurring Contribution'));
     // handle context redirection
     CRM_Contribute_BAO_ContributionRecur::setSubscriptionContext();
 }
コード例 #5
0
ファイル: Tab.php プロジェクト: archcidburnziso/civicrm-core
 /**
  * This function is called when action is browse
  *
  * return null
  * @access public
  */
 function browse()
 {
     CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
     // add annual contribution
     $annual = array();
     list($annual['count'], $annual['amount'], $annual['avg']) = CRM_Contribute_BAO_Contribution::annual($this->_contactId);
     $this->assign('annual', $annual);
     $controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_Search', ts('Contributions'), $this->_action, FALSE, FALSE, TRUE);
     $controller->setEmbedded(TRUE);
     $controller->reset();
     $controller->set('cid', $this->_contactId);
     $controller->set('crid', $this->_crid);
     $controller->set('context', 'Search');
     $controller->set('limit', 50);
     $controller->process();
     $controller->run();
     // add recurring block
     $action = array_sum(array_keys($this->recurLinks()));
     $params = CRM_Contribute_BAO_ContributionRecur::getRecurContributions($this->_contactId);
     if (!empty($params)) {
         foreach ($params as $ids => $recur) {
             $action = array_sum(array_keys($this->recurLinks($ids)));
             // no action allowed if it's not active
             $params[$ids]['is_active'] = $recur['contribution_status_id'] != 3;
             if ($params[$ids]['is_active']) {
                 $details = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($params[$ids]['id'], 'recur');
                 $hideUpdate = $details->membership_id & $details->auto_renew;
                 if ($hideUpdate) {
                     $action -= CRM_Core_Action::UPDATE;
                 }
                 $params[$ids]['action'] = CRM_Core_Action::formLink(self::recurLinks($ids), $action, array('cid' => $this->_contactId, 'crid' => $ids, 'cxt' => 'contribution'), ts('more'), FALSE, 'contribution.selector.recurring', 'Contribution', $ids);
             }
         }
         // assign vars to templates
         $this->assign('action', $this->_action);
         $this->assign('recurRows', $params);
         $this->assign('recur', TRUE);
     }
     //enable/disable soft credit records for test contribution
     $isTest = 0;
     if (CRM_Utils_Request::retrieve('isTest', 'Positive', $this)) {
         $isTest = 1;
     }
     $this->assign('isTest', $isTest);
     $softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionList($this->_contactId, $isTest);
     if (!empty($softCreditList)) {
         $softCreditTotals = array();
         list($softCreditTotals['amount'], $softCreditTotals['avg'], $softCreditTotals['currency']) = CRM_Contribute_BAO_ContributionSoft::getSoftContributionTotals($this->_contactId, $isTest);
         $this->assign('softCredit', TRUE);
         $this->assign('softCreditRows', $softCreditList);
         $this->assign('softCreditTotals', $softCreditTotals);
     }
     if ($this->_contactId) {
         $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
         $this->assign('displayName', $displayName);
         $this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId);
     }
 }
コード例 #6
0
    /**
     * Cancel Recurring contribution.
     *
     * @param int $recurId
     *   Recur contribution id.
     * @param array $objects
     *   An array of objects that is to be cancelled like.
     *                          contribution, membership, event. At least contribution object is a must.
     *
     * @param array $activityParams
     *
     * @return bool
     */
    public static function cancelRecurContribution($recurId, $objects, $activityParams = array())
    {
        if (!$recurId) {
            return FALSE;
        }
        $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
        $canceledId = array_search('Cancelled', $contributionStatus);
        $recur = new CRM_Contribute_DAO_ContributionRecur();
        $recur->id = $recurId;
        $recur->whereAdd("contribution_status_id != {$canceledId}");
        if ($recur->find(TRUE)) {
            $transaction = new CRM_Core_Transaction();
            $recur->contribution_status_id = $canceledId;
            $recur->start_date = CRM_Utils_Date::isoToMysql($recur->start_date);
            $recur->create_date = CRM_Utils_Date::isoToMysql($recur->create_date);
            $recur->modified_date = CRM_Utils_Date::isoToMysql($recur->modified_date);
            $recur->cancel_date = date('YmdHis');
            $recur->save();
            $dao = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($recurId);
            if ($dao && $dao->recur_id) {
                $details = CRM_Utils_Array::value('details', $activityParams);
                if ($dao->auto_renew && $dao->membership_id) {
                    // its auto-renewal membership mode
                    $membershipTypes = CRM_Member_PseudoConstant::membershipType();
                    $membershipType = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $dao->membership_id, 'membership_type_id');
                    $membershipType = CRM_Utils_Array::value($membershipType, $membershipTypes);
                    $details .= '
<br/>' . ts('Automatic renewal of %1 membership cancelled.', array(1 => $membershipType));
                } else {
                    $details .= '
<br/>' . ts('The recurring contribution of %1, every %2 %3 has been cancelled.', array(1 => $dao->amount, 2 => $dao->frequency_interval, 3 => $dao->frequency_unit));
                }
                $activityParams = array('source_contact_id' => $dao->contact_id, 'source_record_id' => CRM_Utils_Array::value('source_record_id', $activityParams), 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', 'Cancel Recurring Contribution', 'name'), 'subject' => CRM_Utils_Array::value('subject', $activityParams, ts('Recurring contribution cancelled')), 'details' => $details, 'activity_date_time' => date('YmdHis'), 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'));
                $session = CRM_Core_Session::singleton();
                $cid = $session->get('userID');
                if ($cid) {
                    $activityParams['target_contact_id'][] = $activityParams['source_contact_id'];
                    $activityParams['source_contact_id'] = $cid;
                }
                CRM_Activity_BAO_Activity::create($activityParams);
            }
            // if there are associated objects, cancel them as well
            if ($objects == CRM_Core_DAO::$_nullObject) {
                $transaction->commit();
                return TRUE;
            } else {
                $baseIPN = new CRM_Core_Payment_BaseIPN();
                return $baseIPN->cancelled($objects, $transaction);
            }
        } else {
            // if already cancelled, return true
            $recur->whereAdd();
            $recur->whereAdd("contribution_status_id = {$canceledId}");
            if ($recur->find(TRUE)) {
                return TRUE;
            }
        }
        return FALSE;
    }
コード例 #7
0
 /**
  * This function is called when action is browse
  *
  * return null
  * @access public
  */
 function browse()
 {
     // add annual contribution
     $annual = array();
     list($annual['count'], $annual['amount'], $annual['avg']) = CRM_Contribute_BAO_Contribution::annual($this->_contactId);
     $this->assign('annual', $annual);
     $controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_Search', ts('Contributions'), $this->_action);
     $controller->setEmbedded(TRUE);
     $controller->reset();
     $controller->set('cid', $this->_contactId);
     $controller->set('crid', $this->_crid);
     $controller->set('context', 'contribution');
     $controller->process();
     $controller->run();
     // add recurring block
     $action = array_sum(array_keys($this->recurLinks()));
     $params = CRM_Contribute_BAO_ContributionRecur::getRecurContributions($this->_contactId);
     if (!empty($params)) {
         foreach ($params as $ids => $recur) {
             $action = array_sum(array_keys($this->recurLinks($ids)));
             // no action allowed if it's not active
             $params[$ids]['is_active'] = $recur['contribution_status_id'] != 3;
             if ($params[$ids]['is_active']) {
                 $details = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($params[$ids]['id'], 'recur');
                 $hideUpdate = $details->membership_id & $details->auto_renew;
                 if ($hideUpdate) {
                     $action -= CRM_Core_Action::UPDATE;
                 }
                 $params[$ids]['action'] = CRM_Core_Action::formLink(self::recurLinks($ids), $action, array('cid' => $this->_contactId, 'crid' => $ids, 'cxt' => 'contribution'));
             }
         }
         // assign vars to templates
         $this->assign('action', $this->_action);
         $this->assign('recurRows', $params);
         $this->assign('recur', TRUE);
     }
     //add honor block
     // form all action links
     $action = array_sum(array_keys($this->honorLinks()));
     $params = array();
     $params = CRM_Contribute_BAO_Contribution::getHonorContacts($this->_contactId);
     if (!empty($params)) {
         foreach ($params as $ids => $honorId) {
             $params[$ids]['action'] = CRM_Core_Action::formLink(self::honorLinks(), $action, array('cid' => $honorId['honorId'], 'id' => $ids, 'cxt' => 'contribution', 'contributionType' => $honorId['type_id'], 'honorId' => $this->_contactId));
         }
         // assign vars to templates
         $this->assign('action', $this->_action);
         $this->assign('honorRows', $params);
         $this->assign('honor', TRUE);
     }
     //enable/disable soft credit records for test contribution
     $isTest = 0;
     if (CRM_Utils_Request::retrieve('isTest', 'Positive', $this)) {
         $isTest = 1;
     }
     $this->assign('isTest', $isTest);
     $softCreditList = CRM_Contribute_BAO_Contribution::getSoftContributionList($this->_contactId, $isTest);
     if (!empty($softCreditList)) {
         $softCreditTotals = array();
         list($softCreditTotals['amount'], $softCreditTotals['avg'], $softCreditTotals['currency']) = CRM_Contribute_BAO_Contribution::getSoftContributionTotals($this->_contactId, $isTest);
         $this->assign('softCredit', TRUE);
         $this->assign('softCreditRows', $softCreditList);
         $this->assign('softCreditTotals', $softCreditTotals);
     }
     if ($this->_contactId) {
         $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
         $this->assign('displayName', $displayName);
     }
 }
コード例 #8
0
 /**
  * Function to build status message while
  * enabling/ disabling various objects
  */
 static function getStatusMsg()
 {
     $recordID = CRM_Utils_Type::escape($_POST['recordID'], 'Integer');
     $recordBAO = CRM_Utils_Type::escape($_POST['recordBAO'], 'String');
     $op = CRM_Utils_Type::escape($_POST['op'], 'String');
     $show = NULL;
     if ($op == 'disable-enable') {
         $status = ts('Are you sure you want to enable this record?');
     } else {
         switch ($recordBAO) {
             case 'CRM_Core_BAO_UFGroup':
                 require_once str_replace('_', DIRECTORY_SEPARATOR, $recordBAO) . '.php';
                 $method = 'getUFJoinRecord';
                 $result = array($recordBAO, $method);
                 $ufJoin = call_user_func_array($result, array($recordID, TRUE));
                 if (!empty($ufJoin)) {
                     $status = ts('This profile is currently used for %1.', array(1 => implode(', ', $ufJoin))) . ' <br/><br/>' . ts('If you disable the profile - it will be removed from these forms and/or modules. Do you want to continue?');
                 } else {
                     $status = ts('Are you sure you want to disable this profile?');
                 }
                 break;
             case 'CRM_Price_BAO_PriceSet':
                 require_once str_replace('_', DIRECTORY_SEPARATOR, $recordBAO) . '.php';
                 $usedBy = CRM_Price_BAO_PriceSet::getUsedBy($recordID);
                 $priceSet = CRM_Price_BAO_PriceSet::getTitle($recordID);
                 if (!CRM_Utils_System::isNull($usedBy)) {
                     $template = CRM_Core_Smarty::singleton();
                     $template->assign('usedBy', $usedBy);
                     $comps = array('Event' => 'civicrm_event', 'Contribution' => 'civicrm_contribution_page', 'EventTemplate' => 'civicrm_event_template');
                     $contexts = array();
                     foreach ($comps as $name => $table) {
                         if (array_key_exists($table, $usedBy)) {
                             $contexts[] = $name;
                         }
                     }
                     $template->assign('contexts', $contexts);
                     $show = 'noButton';
                     $table = $template->fetch('CRM/Price/Page/table.tpl');
                     $status = ts('Unable to disable the \'%1\' price set - it is currently in use by one or more active events, contribution pages or contributions.', array(1 => $priceSet)) . "<br/> {$table}";
                 } else {
                     $status = ts('Are you sure you want to disable \'%1\' Price Set?', array(1 => $priceSet));
                 }
                 break;
             case 'CRM_Event_BAO_Event':
                 $status = ts('Are you sure you want to disable this Event?');
                 break;
             case 'CRM_Core_BAO_UFField':
                 $status = ts('Are you sure you want to disable this CiviCRM Profile field?');
                 break;
             case 'CRM_Contribute_BAO_ManagePremiums':
                 $status = ts('Are you sure you want to disable this premium? This action will remove the premium from any contribution pages that currently offer it. However it will not delete the premium record - so you can re-enable it and add it back to your contribution page(s) at a later time.');
                 break;
             case 'CRM_Contact_BAO_RelationshipType':
                 $status = ts('Are you sure you want to disable this relationship type?') . '<br/><br/>' . ts('Users will no longer be able to select this value when adding or editing relationships between contacts.');
                 break;
             case 'CRM_Financial_BAO_FinancialType':
                 $status = ts('Are you sure you want to disable this financial type?');
                 break;
             case 'CRM_Financial_BAO_FinancialAccount':
                 if (!CRM_Financial_BAO_FinancialAccount::getARAccounts($recordID)) {
                     $show = 'noButton';
                     $status = ts('The selected financial account cannot be disabled because at least one Accounts Receivable type account is required (to ensure that accounting transactions are in balance).');
                 } else {
                     $status = ts('Are you sure you want to disable this financial account?');
                 }
                 break;
             case 'CRM_Financial_BAO_PaymentProcessor':
                 $status = ts('Are you sure you want to disable this payment processor?') . ' <br/><br/>' . ts('Users will no longer be able to select this value when adding or editing transaction pages.');
                 break;
             case 'CRM_Financial_BAO_PaymentProcessorType':
                 $status = ts('Are you sure you want to disable this payment processor type?');
                 break;
             case 'CRM_Core_BAO_LocationType':
                 $status = ts('Are you sure you want to disable this location type?') . ' <br/><br/>' . ts('Users will no longer be able to select this value when adding or editing contact locations.');
                 break;
             case 'CRM_Event_BAO_ParticipantStatusType':
                 $status = ts('Are you sure you want to disable this Participant Status?') . '<br/><br/> ' . ts('Users will no longer be able to select this value when adding or editing Participant Status.');
                 break;
             case 'CRM_Mailing_BAO_Component':
                 $status = ts('Are you sure you want to disable this component?');
                 break;
             case 'CRM_Core_BAO_CustomField':
                 $status = ts('Are you sure you want to disable this custom data field?');
                 break;
             case 'CRM_Core_BAO_CustomGroup':
                 $status = ts('Are you sure you want to disable this custom data group? Any profile fields that are linked to custom fields of this group will be disabled.');
                 break;
             case 'CRM_Core_BAO_MessageTemplate':
                 $status = ts('Are you sure you want to disable this message tempate?');
                 break;
             case 'CRM_ACL_BAO_ACL':
                 $status = ts('Are you sure you want to disable this ACL?');
                 break;
             case 'CRM_ACL_BAO_EntityRole':
                 $status = ts('Are you sure you want to disable this ACL Role Assignment?');
                 break;
             case 'CRM_Member_BAO_MembershipType':
                 $status = ts('Are you sure you want to disable this membership type?');
                 break;
             case 'CRM_Member_BAO_MembershipStatus':
                 $status = ts('Are you sure you want to disable this membership status rule?');
                 break;
             case 'CRM_Price_BAO_PriceField':
                 $status = ts('Are you sure you want to disable this price field?');
                 break;
             case 'CRM_Contact_BAO_Group':
                 $status = ts('Are you sure you want to disable this Group?');
                 break;
             case 'CRM_Core_BAO_OptionGroup':
                 $status = ts('Are you sure you want to disable this Option?');
                 break;
             case 'CRM_Contact_BAO_ContactType':
                 $status = ts('Are you sure you want to disable this Contact Type?');
                 break;
             case 'CRM_Core_BAO_OptionValue':
                 require_once str_replace('_', DIRECTORY_SEPARATOR, $recordBAO) . '.php';
                 $label = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $recordID, 'label');
                 $status = ts('Are you sure you want to disable the \'%1\' option ?', array(1 => $label));
                 $status .= '<br /><br />' . ts('WARNING - Disabling an option which has been assigned to existing records will result in that option being cleared when the record is edited.');
                 break;
             case 'CRM_Contribute_BAO_ContributionRecur':
                 $recurDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($recordID);
                 $status = ts('Are you sure you want to mark this recurring contribution as cancelled?');
                 $status .= '<br /><br /><strong>' . ts('WARNING - This action sets the CiviCRM recurring contribution status to Cancelled, but does NOT send a cancellation request to the payment processor. You will need to ensure that this recurring payment (subscription) is cancelled by the payment processor.') . '</strong>';
                 if ($recurDetails->membership_id) {
                     $status .= '<br /><br /><strong>' . ts('This recurring contribution is linked to an auto-renew membership. If you cancel it, the associated membership will no longer renew automatically. However, the current membership status will not be affected.') . '</strong>';
                 }
                 break;
             case 'CRM_Batch_BAO_Batch':
                 if ($op == 'close') {
                     $status = ts('Are you sure you want to close this batch?');
                 } elseif ($op == 'open') {
                     $status = ts('Are you sure you want to reopen this batch?');
                 } elseif ($op == 'delete') {
                     $status = ts('Are you sure you want to delete this batch?');
                 } elseif ($op == 'remove') {
                     $status = ts('Are you sure you want to remove this financial transaction?');
                 } elseif ($op == 'export') {
                     $status = ts('Are you sure you want to close and export this batch?');
                 } else {
                     $status = ts('Are you sure you want to assign this financial transaction to the batch?');
                 }
                 break;
             default:
                 $status = ts('Are you sure you want to disable this record?');
                 break;
         }
     }
     $statusMessage['status'] = $status;
     $statusMessage['show'] = $show;
     echo json_encode($statusMessage);
     CRM_Utils_System::civiExit();
 }
コード例 #9
0
 /**
  * called when action is browse.
  */
 public function listContribution()
 {
     $controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_Search', ts('Contributions'), NULL, FALSE, FALSE, TRUE, FALSE);
     $controller->setEmbedded(TRUE);
     $controller->reset();
     $controller->set('limit', 12);
     $controller->set('cid', $this->_contactId);
     $controller->set('context', 'user');
     $controller->set('force', 1);
     $controller->process();
     $controller->run();
     //add honor block
     $params = CRM_Contribute_BAO_Contribution::getHonorContacts($this->_contactId);
     if (!empty($params)) {
         // assign vars to templates
         $this->assign('honorRows', $params);
         $this->assign('honor', TRUE);
     }
     $recur = new CRM_Contribute_DAO_ContributionRecur();
     $recur->contact_id = $this->_contactId;
     $recur->is_test = 0;
     $recur->find();
     $config = CRM_Core_Config::singleton();
     $recurStatus = CRM_Contribute_PseudoConstant::contributionStatus();
     $recurRow = array();
     $recurIDs = array();
     while ($recur->fetch()) {
         $mode = $recur->is_test ? 'test' : 'live';
         $paymentProcessor = CRM_Contribute_BAO_ContributionRecur::getPaymentProcessor($recur->id, $mode);
         if (!$paymentProcessor) {
             continue;
         }
         require_once 'api/v3/utils.php';
         //@todo calling api functions directly is not supported
         _civicrm_api3_object_to_array($recur, $values);
         $values['recur_status'] = $recurStatus[$values['contribution_status_id']];
         $recurRow[$values['id']] = $values;
         $action = array_sum(array_keys(CRM_Contribute_Page_Tab::recurLinks($recur->id, 'dashboard')));
         $details = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($recur->id, 'recur');
         $hideUpdate = $details->membership_id & $details->auto_renew;
         if ($hideUpdate) {
             $action -= CRM_Core_Action::UPDATE;
         }
         $recurRow[$values['id']]['action'] = CRM_Core_Action::formLink(CRM_Contribute_Page_Tab::recurLinks($recur->id, 'dashboard'), $action, array('cid' => $this->_contactId, 'crid' => $values['id'], 'cxt' => 'contribution'), ts('more'), FALSE, 'contribution.dashboard.recurring', 'Contribution', $values['id']);
         $recurIDs[] = $values['id'];
         //reset $paymentObject for checking other paymenet processor
         //recurring url
         $paymentObject = NULL;
     }
     if (is_array($recurIDs) && !empty($recurIDs)) {
         $getCount = CRM_Contribute_BAO_ContributionRecur::getCount($recurIDs);
         foreach ($getCount as $key => $val) {
             $recurRow[$key]['completed'] = $val;
             $recurRow[$key]['link'] = CRM_Utils_System::url('civicrm/contribute/search', "reset=1&force=1&recur={$key}");
         }
     }
     $this->assign('recurRows', $recurRow);
     if (!empty($recurRow)) {
         $this->assign('recur', TRUE);
     } else {
         $this->assign('recur', FALSE);
     }
 }
コード例 #10
0
 /**
  * called when action is browse.
  *
  */
 public function browse()
 {
     // add annual contribution
     $annual = array();
     list($annual['count'], $annual['amount'], $annual['avg']) = CRM_Contribute_BAO_Contribution::annual($this->_contactId);
     $this->assign('annual', $annual);
     $controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_Search', ts('Contributions'), $this->_action, FALSE, FALSE, TRUE);
     $controller->setEmbedded(TRUE);
     $controller->reset();
     $controller->set('cid', $this->_contactId);
     $controller->set('crid', $this->_crid);
     $controller->set('context', 'contribution');
     $controller->set('limit', 50);
     $controller->process();
     $controller->run();
     // add recurring block
     $action = array_sum(array_keys($this->recurLinks()));
     $params = CRM_Contribute_BAO_ContributionRecur::getRecurContributions($this->_contactId);
     // Get all backoffice payment processors
     $backOfficePaymentProcessors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors(array('BackOffice'));
     if (!empty($params)) {
         foreach ($params as $ids => $recur) {
             $action = array_sum(array_keys($this->recurLinks($ids)));
             // no action allowed if it's not active
             $params[$ids]['is_active'] = $recur['contribution_status_id'] != 3;
             // Get payment processor name
             $paymentProcessorDetails = CRM_Financial_BAO_PaymentProcessor::getPayment($params[$ids]['payment_processor_id'], 'live');
             $params[$ids]['payment_processor_name'] = $paymentProcessorDetails['name'];
             $details = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($params[$ids]['id'], 'recur');
             $hideUpdate = $details->membership_id & $details->auto_renew;
             if ($hideUpdate) {
                 $action -= CRM_Core_Action::UPDATE;
             }
             $links = self::recurLinks($ids);
             // Disable Edit/Delete link if no back office support
             if (!array_key_exists($recur['payment_processor_id'], $backOfficePaymentProcessors)) {
                 unset($links[2]);
                 unset($links[8]);
             }
             // Remove cancel link for already cancelled recurring records
             if ($recur['contribution_status_id'] == 3) {
                 unset($links[64]);
             }
             $params[$ids]['action'] = CRM_Core_Action::formLink($links, $action, array('cid' => $this->_contactId, 'crid' => $ids, 'cxt' => 'contribution'), ts('more'), FALSE, 'contribution.selector.recurring', 'Contribution', $ids);
         }
         // assign vars to templates
         $this->assign('action', $this->_action);
         $this->assign('recurRows', $params);
         $this->assign('recur', TRUE);
     }
     //enable/disable soft credit records for test contribution
     $isTest = 0;
     if (CRM_Utils_Request::retrieve('isTest', 'Positive', $this)) {
         $isTest = 1;
     }
     $this->assign('isTest', $isTest);
     $softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionList($this->_contactId, NULL, $isTest);
     if (!empty($softCreditList)) {
         $softCreditTotals = array();
         list($softCreditTotals['amount'], $softCreditTotals['avg'], $softCreditTotals['currency']) = CRM_Contribute_BAO_ContributionSoft::getSoftContributionTotals($this->_contactId, $isTest);
         $this->assign('softCredit', TRUE);
         $this->assign('softCreditRows', $softCreditList);
         $this->assign('softCreditTotals', $softCreditTotals);
     }
     if ($this->_contactId) {
         $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
         $this->assign('displayName', $displayName);
         $this->ajaxResponse['tabCount'] = CRM_Contribute_BAO_ContributionRecur::contributionRecurCount($this->_contactId);
     }
 }