当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate方法代码示例

本文整理汇总了PHP中CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate方法的具体用法?PHP CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate怎么用?PHP CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Member_BAO_MembershipStatus的用法示例。


在下文中一共展示了CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: formRule


//.........这里部分代码省略.........
     if (!empty($params['is_different_contribution_contact'])) {
         if (empty($params['soft_credit_type_id'])) {
             $errors['soft_credit_type_id'] = ts('Please Select a Soft Credit Type');
         }
         if (empty($params['soft_credit_contact_id'])) {
             $errors['soft_credit_contact_id'] = ts('Please select a contact');
         }
     }
     if (!empty($params['payment_processor_id'])) {
         // validate payment instrument (e.g. credit card number)
         CRM_Core_Payment_Form::validatePaymentInstrument($params['payment_processor_id'], $params, $errors, $self);
     }
     $joinDate = NULL;
     if (!empty($params['join_date'])) {
         $joinDate = CRM_Utils_Date::processDate($params['join_date']);
         foreach ($self->_memTypeSelected as $memType) {
             $startDate = NULL;
             if (!empty($params['start_date'])) {
                 $startDate = CRM_Utils_Date::processDate($params['start_date']);
             }
             // if end date is set, ensure that start date is also set
             // and that end date is later than start date
             $endDate = NULL;
             if (!empty($params['end_date'])) {
                 $endDate = CRM_Utils_Date::processDate($params['end_date']);
             }
             $membershipDetails = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($memType);
             if ($startDate && CRM_Utils_Array::value('period_type', $membershipDetails) == 'rolling') {
                 if ($startDate < $joinDate) {
                     $errors['start_date'] = ts('Start date must be the same or later than Member since.');
                 }
             }
             if ($endDate) {
                 if ($membershipDetails['duration_unit'] == 'lifetime') {
                     // Check if status is NOT cancelled or similar. For lifetime memberships, there is no automated
                     // process to update status based on end-date. The user must change the status now.
                     $result = civicrm_api3('MembershipStatus', 'get', array('sequential' => 1, 'is_current_member' => 0));
                     $tmp_statuses = $result['values'];
                     $status_ids = array();
                     foreach ($tmp_statuses as $cur_stat) {
                         $status_ids[] = $cur_stat['id'];
                     }
                     if (empty($params['status_id']) || in_array($params['status_id'], $status_ids) == FALSE) {
                         $errors['status_id'] = ts('Please enter a status that does NOT represent a current membership status.');
                         $errors['is_override'] = ts('This must be checked because you set an End Date for a lifetime membership');
                     }
                 } else {
                     if (!$startDate) {
                         $errors['start_date'] = ts('Start date must be set if end date is set.');
                     }
                     if ($endDate < $startDate) {
                         $errors['end_date'] = ts('End date must be the same or later than start date.');
                     }
                 }
             }
             //  Default values for start and end dates if not supplied
             //  on the form
             $defaultDates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($memType, $joinDate, $startDate, $endDate);
             if (!$startDate) {
                 $startDate = CRM_Utils_Array::value('start_date', $defaultDates);
             }
             if (!$endDate) {
                 $endDate = CRM_Utils_Array::value('end_date', $defaultDates);
             }
             //CRM-3724, check for availability of valid membership status.
             if (empty($params['is_override']) && !isset($errors['_qf_default'])) {
                 $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($startDate, $endDate, $joinDate, 'today', TRUE, $memType, $params);
                 if (empty($calcStatus)) {
                     $url = CRM_Utils_System::url('civicrm/admin/member/membershipStatus', 'reset=1&action=browse');
                     $errors['_qf_default'] = ts('There is no valid Membership Status available for selected membership dates.');
                     $status = ts('Oops, it looks like there is no valid membership status available for the given membership dates. You can <a href="%1">Configure Membership Status Rules</a>.', array(1 => $url));
                     if (!$self->_mode) {
                         $status .= ' ' . ts('OR You can sign up by setting Status Override? to true.');
                     }
                     CRM_Core_Session::setStatus($status, ts('Membership Status Error'), 'error');
                 }
             }
         }
     } else {
         $errors['join_date'] = ts('Please enter the Member Since.');
     }
     if (isset($params['is_override']) && $params['is_override'] && empty($params['status_id'])) {
         $errors['status_id'] = ts('Please enter the status.');
     }
     //total amount condition arise when membership type having no
     //minimum fee
     if (isset($params['record_contribution'])) {
         if (!$params['financial_type_id']) {
             $errors['financial_type_id'] = ts('Please enter the financial Type.');
         }
         if (CRM_Utils_System::isNull($params['total_amount'])) {
             $errors['total_amount'] = ts('Please enter the contribution.');
         }
     }
     // validate contribution status for 'Failed'.
     if ($self->_onlinePendingContributionId && !empty($params['record_contribution']) && CRM_Utils_Array::value('contribution_status_id', $params) == array_search('Failed', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'))) {
         $errors['contribution_status_id'] = ts('Please select a valid payment status before updating.');
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:indydas,项目名称:civi-demo,代码行数:101,代码来源:Membership.php

示例2: civicrm_api3_membership_status_calc

/**
 * Derives the Membership Status of a given Membership Reocrd
 *
 * This API is used for deriving Membership Status of a given Membership
 * record using the rules encoded in the membership_status table.
 *
 * @param  Int     $membershipID  Id of a membership
 * @param  String  $statusDate
 *
 * @return Array  Array of status id and status name
 * @public
 */
function civicrm_api3_membership_status_calc($membershipParams)
{
    if (!($membershipID = CRM_Utils_Array::value('membership_id', $membershipParams))) {
        return civicrm_api3_create_error('membershipParams do not contain membership_id');
    }
    $query = "\nSELECT start_date, end_date, join_date\n  FROM civicrm_membership\n WHERE id = %1\n";
    $params = array(1 => array($membershipID, 'Integer'));
    $dao =& CRM_Core_DAO::executeQuery($query, $params);
    if ($dao->fetch()) {
        require_once 'CRM/Member/BAO/MembershipStatus.php';
        // Take the is_admin column in MembershipStatus into consideration when requested
        if (!CRM_Utils_Array::value('ignore_admin_only', $membershipParams)) {
            $result =& CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($dao->start_date, $dao->end_date, $dao->join_date, 'today', TRUE);
        } else {
            $result =& CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($dao->start_date, $dao->end_date, $dao->join_date);
        }
        //make is error zero only when valid status found.
        if (CRM_Utils_Array::value('id', $result)) {
            $result['is_error'] = 0;
        }
    } else {
        $result = civicrm_api3_create_error('did not find a membership record');
    }
    $dao->free();
    return $result;
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:38,代码来源:MembershipStatus.php

示例3: completeTransaction

 function completeTransaction(&$input, &$ids, &$objects, &$transaction, $recur = FALSE)
 {
     $contribution =& $objects['contribution'];
     $memberships =& $objects['membership'];
     if (is_numeric($memberships)) {
         $memberships = array($objects['membership']);
     }
     $participant =& $objects['participant'];
     $event =& $objects['event'];
     $changeToday = CRM_Utils_Array::value('trxn_date', $input, self::$_now);
     $recurContrib =& $objects['contributionRecur'];
     $values = array();
     if ($input['component'] == 'contribute') {
         if ($contribution->contribution_page_id) {
             CRM_Contribute_BAO_ContributionPage::setValues($contribution->contribution_page_id, $values);
             $source = ts('Online Contribution') . ': ' . $values['title'];
         } elseif ($recurContrib->id) {
             $contribution->contribution_page_id = NULL;
             $values['amount'] = $recurContrib->amount;
             $values['contribution_type_id'] = $objects['contributionType']->id;
             $values['title'] = $source = ts('Offline Recurring Contribution');
             $values['is_email_receipt'] = $recurContrib->is_email_receipt;
             $domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
             $values['receipt_from_name'] = $domainValues[0];
             $values['receipt_from_email'] = $domainValues[1];
         }
         $contribution->source = $source;
         if (CRM_Utils_Array::value('is_email_receipt', $values)) {
             $contribution->receipt_date = self::$_now;
         }
         if (!empty($memberships)) {
             foreach ($memberships as $membershipTypeIdKey => $membership) {
                 if ($membership) {
                     $format = '%Y%m%d';
                     $currentMembership = CRM_Member_BAO_Membership::getContactMembership($membership->contact_id, $membership->membership_type_id, $membership->is_test, $membership->id);
                     // CRM-8141 update the membership type with the value recorded in log when membership created/renewed
                     // this picks up membership type changes during renewals
                     $sql = "\nSELECT    membership_type_id\nFROM      civicrm_membership_log\nWHERE     membership_id={$membership->id}\nORDER BY  id DESC\nLIMIT 1;";
                     $dao = new CRM_Core_DAO();
                     $dao->query($sql);
                     if ($dao->fetch()) {
                         if (!empty($dao->membership_type_id)) {
                             $membership->membership_type_id = $dao->membership_type_id;
                             $membership->save();
                         }
                         // else fall back to using current membership type
                     }
                     // else fall back to using current membership type
                     $dao->free();
                     if ($currentMembership) {
                         /*
                          * Fixed FOR CRM-4433
                          * In BAO/Membership.php(renewMembership function), we skip the extend membership date and status
                          * when Contribution mode is notify and membership is for renewal )
                          */
                         CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, $changeToday);
                         $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id, $changeToday);
                         $dates['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format);
                     } else {
                         $dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membership->membership_type_id);
                     }
                     //get the status for membership.
                     $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($dates['start_date'], $dates['end_date'], $dates['join_date'], 'today', TRUE);
                     $formatedParams = array('status_id' => CRM_Utils_Array::value('id', $calcStatus, 2), 'join_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('join_date', $dates), $format), 'start_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('start_date', $dates), $format), 'end_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('end_date', $dates), $format), 'reminder_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('reminder_date', $dates), $format));
                     //we might be renewing membership,
                     //so make status override false.
                     $formatedParams['is_override'] = FALSE;
                     $membership->copyValues($formatedParams);
                     $membership->save();
                     //updating the membership log
                     $membershipLog = array();
                     $membershipLog = $formatedParams;
                     $logStartDate = $formatedParams['start_date'];
                     if (CRM_Utils_Array::value('log_start_date', $dates)) {
                         $logStartDate = CRM_Utils_Date::customFormat($dates['log_start_date'], $format);
                         $logStartDate = CRM_Utils_Date::isoToMysql($logStartDate);
                     }
                     $membershipLog['start_date'] = $logStartDate;
                     $membershipLog['membership_id'] = $membership->id;
                     $membershipLog['modified_id'] = $membership->contact_id;
                     $membershipLog['modified_date'] = date('Ymd');
                     $membershipLog['membership_type_id'] = $membership->membership_type_id;
                     CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
                     //update related Memberships.
                     CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $formatedParams);
                     //update the membership type key of membership relatedObjects array
                     //if it has changed after membership update
                     if ($membershipTypeIdKey != $membership->membership_type_id) {
                         $memberships[$membership->membership_type_id] = $membership;
                         $contribution->_relatedObjects['membership'][$membership->membership_type_id] = $membership;
                         unset($contribution->_relatedObjects['membership'][$membershipTypeIdKey]);
                         unset($memberships[$membershipTypeIdKey]);
                     }
                 }
             }
         }
     } else {
         // event
         $eventParams = array('id' => $objects['event']->id);
         $values['event'] = array();
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:BaseIPN.php

示例4: completeOrder

 /**
  * Complete an order.
  *
  * Do not call this directly - use the contribution.completetransaction api as this function is being refactored.
  *
  * Currently overloaded to complete a transaction & repeat a transaction - fix!
  *
  * Moving it out of the BaseIPN class is just the first step.
  *
  * @param array $input
  * @param array $ids
  * @param array $objects
  * @param CRM_Core_Transaction $transaction
  * @param int $recur
  * @param CRM_Contribute_BAO_Contribution $contribution
  * @param bool $isRecurring
  *   Duplication of param needs review. Only used by AuthorizeNetIPN
  * @param int $isFirstOrLastRecurringPayment
  *   Deprecated param only used by AuthorizeNetIPN.
  */
 public static function completeOrder(&$input, &$ids, $objects, $transaction, $recur, $contribution, $isRecurring, $isFirstOrLastRecurringPayment)
 {
     $primaryContributionID = isset($contribution->id) ? $contribution->id : $objects['first_contribution']->id;
     // The previous details are used when calculating line items so keep it before any code that 'does something'
     if (!empty($contribution->id)) {
         $input['prevContribution'] = CRM_Contribute_BAO_Contribution::getValues(array('id' => $contribution->id), CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
     }
     $inputContributionWhiteList = array('fee_amount', 'net_amount', 'trxn_id', 'check_number', 'payment_instrument_id', 'is_test', 'campaign_id', 'receive_date');
     $contributionParams = array_merge(array('contribution_status_id' => 'Completed'), array_intersect_key($input, array_fill_keys($inputContributionWhiteList, 1)));
     $participant = CRM_Utils_Array::value('participant', $objects);
     $memberships = CRM_Utils_Array::value('membership', $objects);
     $recurContrib = CRM_Utils_Array::value('contributionRecur', $objects);
     if (!empty($recurContrib->id)) {
         $contributionParams['contribution_recur_id'] = $recurContrib->id;
     }
     self::repeatTransaction($contribution, $input, $contributionParams);
     if (is_numeric($memberships)) {
         $memberships = array($objects['membership']);
     }
     $changeDate = CRM_Utils_Array::value('trxn_date', $input, date('YmdHis'));
     $values = array();
     if (isset($input['is_email_receipt'])) {
         $values['is_email_receipt'] = $input['is_email_receipt'];
     }
     if ($input['component'] == 'contribute') {
         if ($contribution->contribution_page_id) {
             CRM_Contribute_BAO_ContributionPage::setValues($contribution->contribution_page_id, $values);
             $contributionParams['source'] = ts('Online Contribution') . ': ' . $values['title'];
         } elseif ($recurContrib && $recurContrib->id) {
             $contributionParams['contribution_page_id'] = NULL;
             $values['amount'] = $recurContrib->amount;
             $values['financial_type_id'] = $objects['contributionType']->id;
             $values['title'] = $source = ts('Offline Recurring Contribution');
             $domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
             $values['receipt_from_name'] = $domainValues[0];
             $values['receipt_from_email'] = $domainValues[1];
         }
         if ($recurContrib && $recurContrib->id && !isset($input['is_email_receipt'])) {
             //CRM-13273 - is_email_receipt setting on recurring contribution should take precedence over contribution page setting
             // but CRM-16124 if $input['is_email_receipt'] is set then that should not be overridden.
             $values['is_email_receipt'] = $recurContrib->is_email_receipt;
         }
         if (!empty($values['is_email_receipt'])) {
             $contributionParams['receipt_date'] = $changeDate;
         }
         if (!empty($memberships)) {
             foreach ($memberships as $membershipTypeIdKey => $membership) {
                 if ($membership) {
                     $membershipParams = array('id' => $membership->id, 'contact_id' => $membership->contact_id, 'is_test' => $membership->is_test, 'membership_type_id' => $membership->membership_type_id);
                     $currentMembership = CRM_Member_BAO_Membership::getContactMembership($membershipParams['contact_id'], $membershipParams['membership_type_id'], $membershipParams['is_test'], $membershipParams['id']);
                     // CRM-8141 update the membership type with the value recorded in log when membership created/renewed
                     // this picks up membership type changes during renewals
                     $sql = "\nSELECT    membership_type_id\nFROM      civicrm_membership_log\nWHERE     membership_id={$membershipParams['id']}\nORDER BY  id DESC\nLIMIT 1;";
                     $dao = CRM_Core_DAO::executeQuery($sql);
                     if ($dao->fetch()) {
                         if (!empty($dao->membership_type_id)) {
                             $membershipParams['membership_type_id'] = $dao->membership_type_id;
                         }
                     }
                     $dao->free();
                     $membershipParams['num_terms'] = $contribution->getNumTermsByContributionAndMembershipType($membershipParams['membership_type_id'], $primaryContributionID);
                     $dates = array_fill_keys(array('join_date', 'start_date', 'end_date'), NULL);
                     if ($currentMembership) {
                         /*
                          * Fixed FOR CRM-4433
                          * In BAO/Membership.php(renewMembership function), we skip the extend membership date and status
                          * when Contribution mode is notify and membership is for renewal )
                          */
                         CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, $changeDate);
                         // @todo - we should pass membership_type_id instead of null here but not
                         // adding as not sure of testing
                         $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membershipParams['id'], $changeDate, NULL, $membershipParams['num_terms']);
                         $dates['join_date'] = $currentMembership['join_date'];
                     }
                     //get the status for membership.
                     $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($dates['start_date'], $dates['end_date'], $dates['join_date'], 'today', TRUE, $membershipParams['membership_type_id'], $membershipParams);
                     $membershipParams['status_id'] = CRM_Utils_Array::value('id', $calcStatus, 'New');
                     //we might be renewing membership,
                     //so make status override false.
                     $membershipParams['is_override'] = FALSE;
//.........这里部分代码省略.........
开发者ID:nganivet,项目名称:civicrm-core,代码行数:101,代码来源:Contribution.php

示例5: civicrm_api3_membership_status_calc

/**
 * Derives the Membership Status of a given Membership Record.
 *
 * This API is used for deriving Membership Status of a given Membership
 * record using the rules encoded in the membership_status table.
 *
 * @param array $membershipParams
 *
 * @throws API_Exception
 *
 * @return array
 *   Array of status id and status name
 */
function civicrm_api3_membership_status_calc($membershipParams)
{
    if (!($membershipID = CRM_Utils_Array::value('membership_id', $membershipParams))) {
        throw new API_Exception('membershipParams do not contain membership_id');
    }
    if (empty($membershipParams['id'])) {
        //for consistency lets make sure id is set as this will get passed to hooks downstream
        $membershipParams['id'] = $membershipID;
    }
    $query = "\nSELECT start_date, end_date, join_date, membership_type_id\n  FROM civicrm_membership\n WHERE id = %1\n";
    $params = array(1 => array($membershipID, 'Integer'));
    $dao = CRM_Core_DAO::executeQuery($query, $params);
    if ($dao->fetch()) {
        $membershipTypeID = empty($membershipParams['membership_type_id']) ? $dao->membership_type_id : $membershipParams['membership_type_id'];
        $result = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($dao->start_date, $dao->end_date, $dao->join_date, 'today', CRM_Utils_Array::value('ignore_admin_only', $membershipParams), $membershipTypeID, $membershipParams);
        //make is error zero only when valid status found.
        if (!empty($result['id'])) {
            $result['is_error'] = 0;
        }
    } else {
        $dao->free();
        throw new API_Exception('did not find a membership record');
    }
    $dao->free();
    return $result;
}
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:39,代码来源:MembershipStatus.php

示例6: completeTransaction

 function completeTransaction(&$input, &$ids, &$objects, &$transaction, $recur = FALSE)
 {
     $contribution =& $objects['contribution'];
     $primaryContributionID = isset($contribution->id) ? $contribution->id : $objects['first_contribution']->id;
     $memberships =& $objects['membership'];
     if (is_numeric($memberships)) {
         $memberships = array($objects['membership']);
     }
     $participant =& $objects['participant'];
     $event =& $objects['event'];
     $changeToday = CRM_Utils_Array::value('trxn_date', $input, self::$_now);
     $recurContrib =& $objects['contributionRecur'];
     $values = array();
     if (isset($input['is_email_receipt'])) {
         $values['is_email_receipt'] = $input['is_email_receipt'];
     }
     $source = NULL;
     if ($input['component'] == 'contribute') {
         if ($contribution->contribution_page_id) {
             CRM_Contribute_BAO_ContributionPage::setValues($contribution->contribution_page_id, $values);
             $source = ts('Online Contribution') . ': ' . $values['title'];
         } elseif ($recurContrib && $recurContrib->id) {
             $contribution->contribution_page_id = NULL;
             $values['amount'] = $recurContrib->amount;
             $values['financial_type_id'] = $objects['contributionType']->id;
             $values['title'] = $source = ts('Offline Recurring Contribution');
             $domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
             $values['receipt_from_name'] = $domainValues[0];
             $values['receipt_from_email'] = $domainValues[1];
         }
         if ($recurContrib && $recurContrib->id && !isset($input['is_email_receipt'])) {
             //CRM-13273 - is_email_receipt setting on recurring contribution should take precedence over contribution page setting
             // but CRM-16124 if $input['is_email_receipt'] is set then that should not be overridden.
             $values['is_email_receipt'] = $recurContrib->is_email_receipt;
         }
         $contribution->source = $source;
         if (CRM_Utils_Array::value('is_email_receipt', $values)) {
             $contribution->receipt_date = self::$_now;
         }
         if (!empty($memberships)) {
             $membershipsUpdate = array();
             foreach ($memberships as $membershipTypeIdKey => $membership) {
                 if ($membership) {
                     $format = '%Y%m%d';
                     $currentMembership = CRM_Member_BAO_Membership::getContactMembership($membership->contact_id, $membership->membership_type_id, $membership->is_test, $membership->id);
                     // CRM-8141 update the membership type with the value recorded in log when membership created/renewed
                     // this picks up membership type changes during renewals
                     $sql = "\nSELECT    membership_type_id\nFROM      civicrm_membership_log\nWHERE     membership_id={$membership->id}\nORDER BY  id DESC\nLIMIT 1;";
                     $dao = new CRM_Core_DAO();
                     $dao->query($sql);
                     if ($dao->fetch()) {
                         if (!empty($dao->membership_type_id)) {
                             $membership->membership_type_id = $dao->membership_type_id;
                             $membership->save();
                         }
                         // else fall back to using current membership type
                     }
                     // else fall back to using current membership type
                     $dao->free();
                     $num_terms = $contribution->getNumTermsByContributionAndMembershipType($membership->membership_type_id, $primaryContributionID);
                     if ($currentMembership) {
                         /*
                          * Fixed FOR CRM-4433
                          * In BAO/Membership.php(renewMembership function), we skip the extend membership date and status
                          * when Contribution mode is notify and membership is for renewal )
                          */
                         CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, $changeToday);
                         // @todo - we should pass membership_type_id instead of null here but not
                         // adding as not sure of testing
                         $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id, $changeToday, NULL, $num_terms);
                         $dates['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format);
                     } else {
                         $dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membership->membership_type_id, NULL, NULL, NULL, $num_terms);
                     }
                     //get the status for membership.
                     $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($dates['start_date'], $dates['end_date'], $dates['join_date'], 'today', TRUE, $membership->membership_type_id, (array) $membership);
                     $formatedParams = array('status_id' => CRM_Utils_Array::value('id', $calcStatus, 2), 'join_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('join_date', $dates), $format), 'start_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('start_date', $dates), $format), 'end_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('end_date', $dates), $format));
                     //we might be renewing membership,
                     //so make status override false.
                     $formatedParams['is_override'] = FALSE;
                     $membership->copyValues($formatedParams);
                     $membership->save();
                     //updating the membership log
                     $membershipLog = array();
                     $membershipLog = $formatedParams;
                     $logStartDate = $formatedParams['start_date'];
                     if (CRM_Utils_Array::value('log_start_date', $dates)) {
                         $logStartDate = CRM_Utils_Date::customFormat($dates['log_start_date'], $format);
                         $logStartDate = CRM_Utils_Date::isoToMysql($logStartDate);
                     }
                     $membershipLog['start_date'] = $logStartDate;
                     $membershipLog['membership_id'] = $membership->id;
                     $membershipLog['modified_id'] = $membership->contact_id;
                     $membershipLog['modified_date'] = date('Ymd');
                     $membershipLog['membership_type_id'] = $membership->membership_type_id;
                     CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
                     //update related Memberships.
                     CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $formatedParams);
                     //update the membership type key of membership relatedObjects array
                     //if it has changed after membership update
//.........这里部分代码省略.........
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:101,代码来源:BaseIPN.php

示例7: formRule

 /**
  * Function for validation
  *
  * @param array $params (ref.) an assoc array of name/value pairs
  *
  * @return mixed true or array of errors
  * @access public
  * @static
  */
 public function formRule(&$params, &$files, $self)
 {
     $errors = array();
     //check if contact is selected in standalone mode
     if (isset($params['contact_select_id']) && !$params['contact_select_id']) {
         $errors['contact'] = ts('Please select a contact or create new contact');
     }
     if (!$params['membership_type_id'][1]) {
         $errors['membership_type_id'] = ts('Please select a membership type.');
     }
     if ($params['membership_type_id'][1] && CRM_Utils_Array::value('payment_processor_id', $params)) {
         // make sure that credit card number and cvv are valid
         require_once 'CRM/Utils/Rule.php';
         if (CRM_Utils_Array::value('credit_card_type', $params)) {
             if (CRM_Utils_Array::value('credit_card_number', $params) && !CRM_Utils_Rule::creditCardNumber($params['credit_card_number'], $params['credit_card_type'])) {
                 $errors['credit_card_number'] = ts("Please enter a valid Credit Card Number");
             }
             if (CRM_Utils_Array::value('cvv2', $params) && !CRM_Utils_Rule::cvv($params['cvv2'], $params['credit_card_type'])) {
                 $errors['cvv2'] = ts("Please enter a valid Credit Card Verification Number");
             }
         }
     }
     $joinDate = CRM_Utils_Date::processDate($params['join_date']);
     if ($joinDate) {
         require_once 'CRM/Member/BAO/MembershipType.php';
         $membershipDetails = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($params['membership_type_id'][1]);
         $startDate = CRM_Utils_Date::processDate($params['start_date']);
         if ($startDate && $membershipDetails['period_type'] == 'rolling') {
             if ($startDate < $joinDate) {
                 $errors['start_date'] = ts('Start date must be the same or later than join date.');
             }
         }
         // if end date is set, ensure that start date is also set
         // and that end date is later than start date
         // If selected membership type has duration unit as 'lifetime'
         // and end date is set, then give error
         $endDate = CRM_Utils_Date::processDate($params['end_date']);
         if ($endDate) {
             if ($membershipDetails['duration_unit'] == 'lifetime') {
                 $errors['end_date'] = ts('The selected Membership Type has a lifetime duration. You cannot specify an End Date for lifetime memberships. Please clear the End Date OR select a different Membership Type.');
             } else {
                 if (!$startDate) {
                     $errors['start_date'] = ts('Start date must be set if end date is set.');
                 }
                 if ($endDate < $startDate) {
                     $errors['end_date'] = ts('End date must be the same or later than start date.');
                 }
             }
         }
         //CRM-3724, check for availability of valid membership status.
         if (!CRM_Utils_Array::value('is_override', $params)) {
             require_once 'CRM/Member/BAO/MembershipStatus.php';
             $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($startDate, $endDate, $joinDate, 'today', true);
             if (empty($calcStatus)) {
                 $url = CRM_Utils_System::url('civicrm/admin/member/membershipStatus', 'reset=1&action=browse');
                 $errors['_qf_default'] = ts('There is no valid Membership Status available for selected membership dates.');
                 $status = ts('Oops, it looks like there is no valid membership status available for the given membership dates. You can <a href="%1">Configure Membership Status Rules</a>.', array(1 => $url));
                 if (!$self->_mode) {
                     $status .= ' ' . ts('OR You can sign up by setting Status Override? to true.');
                 }
                 CRM_Core_Session::setStatus($status);
             }
         }
     } else {
         $errors['join_date'] = ts('Please enter the join date.');
     }
     if (isset($params['is_override']) && $params['is_override'] && !$params['status_id']) {
         $errors['status_id'] = ts('Please enter the status.');
     }
     //total amount condition arise when membership type having no
     //minimum fee
     if (isset($params['record_contribution'])) {
         if (!$params['contribution_type_id']) {
             $errors['contribution_type_id'] = ts('Please enter the contribution Type.');
         }
         if (!$params['total_amount']) {
             $errors['total_amount'] = ts('Please enter the contribution.');
         }
     }
     // validate contribution status for 'Failed'.
     if ($self->_onlinePendingContributionId && CRM_Utils_Array::value('record_contribution', $params) && CRM_Utils_Array::value('contribution_status_id', $params) == array_search('Failed', CRM_Contribute_PseudoConstant::contributionStatus(null, 'name'))) {
         $errors['contribution_status_id'] = ts("Please select a valid payment status before updating.");
     }
     return empty($errors) ? true : $errors;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:94,代码来源:Membership.php

示例8: transitionComponents


//.........这里部分代码省略.........
             foreach ($memberships as $membership) {
                 if ($membership) {
                     $format = '%Y%m%d';
                     //CRM-4523
                     $currentMembership = CRM_Member_BAO_Membership::getContactMembership($membership->contact_id, $membership->membership_type_id, $membership->is_test, $membership->id);
                     // CRM-8141 update the membership type with the value recorded in log when membership created/renewed
                     // this picks up membership type changes during renewals
                     $sql = "\n              SELECT    membership_type_id\n              FROM      civicrm_membership_log\n              WHERE     membership_id={$membership->id}\n              ORDER BY  id DESC\n              LIMIT     1;";
                     $dao = new CRM_Core_DAO();
                     $dao->query($sql);
                     if ($dao->fetch()) {
                         if (!empty($dao->membership_type_id)) {
                             $membership->membership_type_id = $dao->membership_type_id;
                             $membership->save();
                         }
                     }
                     // else fall back to using current membership type
                     $dao->free();
                     // Figure out number of terms
                     $numterms = 1;
                     $lineitems = CRM_Price_BAO_LineItem::getLineItems($contributionId, 'contribution');
                     foreach ($lineitems as $lineitem) {
                         if ($membership->membership_type_id == CRM_Utils_Array::value('membership_type_id', $lineitem)) {
                             $numterms = CRM_Utils_Array::value('membership_num_terms', $lineitem);
                             // in case membership_num_terms comes through as null or zero
                             $numterms = $numterms >= 1 ? $numterms : 1;
                             break;
                         }
                     }
                     // CRM-15735-to update the membership status as per the contribution receive date
                     $joinDate = NULL;
                     if (!empty($params['receive_date'])) {
                         $joinDate = $params['receive_date'];
                         $status = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($membership->start_date, $membership->end_date, $membership->join_date, $params['receive_date'], FALSE, $membership->membership_type_id, (array) $membership);
                         $membership->status_id = CRM_Utils_Array::value('id', $status, $membership->status_id);
                         $membership->save();
                     }
                     if ($currentMembership) {
                         CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, NULL);
                         $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id, NULL, NULL, $numterms);
                         $dates['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format);
                     } else {
                         $dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membership->membership_type_id, $joinDate, NULL, NULL, $numterms);
                     }
                     //get the status for membership.
                     $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($dates['start_date'], $dates['end_date'], $dates['join_date'], 'today', TRUE, $membership->membership_type_id, (array) $membership);
                     $formattedParams = array('status_id' => CRM_Utils_Array::value('id', $calcStatus, array_search('Current', $membershipStatuses)), 'join_date' => CRM_Utils_Date::customFormat($dates['join_date'], $format), 'start_date' => CRM_Utils_Date::customFormat($dates['start_date'], $format), 'end_date' => CRM_Utils_Date::customFormat($dates['end_date'], $format));
                     CRM_Utils_Hook::pre('edit', 'Membership', $membership->id, $formattedParams);
                     $membership->copyValues($formattedParams);
                     $membership->save();
                     //updating the membership log
                     $membershipLog = array();
                     $membershipLog = $formattedParams;
                     $logStartDate = CRM_Utils_Date::customFormat(CRM_Utils_Array::value('log_start_date', $dates), $format);
                     $logStartDate = $logStartDate ? CRM_Utils_Date::isoToMysql($logStartDate) : $formattedParams['start_date'];
                     $membershipLog['start_date'] = $logStartDate;
                     $membershipLog['membership_id'] = $membership->id;
                     $membershipLog['modified_id'] = $membership->contact_id;
                     $membershipLog['modified_date'] = date('Ymd');
                     $membershipLog['membership_type_id'] = $membership->membership_type_id;
                     CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
                     //update related Memberships.
                     CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $formattedParams);
                     $updateResult['membership_end_date'] = CRM_Utils_Date::customFormat($dates['end_date'], '%B %E%f, %Y');
                     $updateResult['updatedComponents']['CiviMember'] = $membership->status_id;
                     if ($processContributionObject) {
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:67,代码来源:Contribution.php

示例9: fixMembershipStatusBeforeRenew

 /**
  * Method to fix membership status of stale membership
  * 
  * This method first checks if the membership is stale. If it is,
  * then status will be updated based on existing start and end
  * dates and log will be added for the status change.
  * 
  * @param  array  $currentMembership   referance to the array
  *                                     containing all values of
  *                                     the current membership
  * @param  array  $changeToday         array of month, day, year
  *                                     values in case today needs
  *                                     to be customised, null otherwise
  * 
  * @return void
  * @static
  */
 static function fixMembershipStatusBeforeRenew(&$currentMembership, $changeToday)
 {
     $today = null;
     if ($changeToday) {
         $today = CRM_Utils_Date::processDate($changeToday, null, false, 'Y-m-d');
     }
     require_once 'CRM/Member/BAO/MembershipStatus.php';
     $status = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($currentMembership['start_date'], $currentMembership['end_date'], $currentMembership['join_date'], $today);
     if (empty($status) || empty($status['id'])) {
         CRM_Core_Error::fatal(ts('Oops, it looks like there is no valid membership status corresponding to the membership start and end dates for this membership. Contact the site administrator for assistance.'));
     }
     $currentMembership['today_date'] = $today;
     if ($status['id'] !== $currentMembership['status_id']) {
         $memberDAO = new CRM_Member_BAO_Membership();
         $memberDAO->id = $currentMembership['id'];
         $memberDAO->find(true);
         $memberDAO->status_id = $status['id'];
         $memberDAO->join_date = CRM_Utils_Date::isoToMysql($memberDAO->join_date);
         $memberDAO->start_date = CRM_Utils_Date::isoToMysql($memberDAO->start_date);
         $memberDAO->end_date = CRM_Utils_Date::isoToMysql($memberDAO->end_date);
         $memberDAO->save();
         CRM_Core_DAO::storeValues($memberDAO, $currentMembership);
         $memberDAO->free();
         $currentMembership['is_current_member'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $currentMembership['status_id'], 'is_current_member');
         $format = '%Y%m%d';
         $logParams = array('membership_id' => $currentMembership['id'], 'status_id' => $status['id'], 'start_date' => CRM_Utils_Date::customFormat($currentMembership['start_date'], $format), 'end_date' => CRM_Utils_Date::customFormat($currentMembership['end_date'], $format), 'modified_id' => $currentMembership['contact_id'], 'modified_date' => CRM_Utils_Date::customFormat($currentMembership['today_date'], $format), 'renewal_reminder_date' => CRM_Utils_Date::customFormat($currentMembership['reminder_date'], $format));
         $dontCare = null;
         require_once 'CRM/Member/BAO/MembershipLog.php';
         CRM_Member_BAO_MembershipLog::add($logParams, $dontCare);
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:48,代码来源:Membership.php

示例10: completeTransaction

 function completeTransaction(&$input, &$ids, &$objects, &$transaction, $recur = false)
 {
     $contribution =& $objects['contribution'];
     $membership =& $objects['membership'];
     $participant =& $objects['participant'];
     $event =& $objects['event'];
     $values = array();
     if ($input['component'] == 'contribute') {
         require_once 'CRM/Contribute/BAO/ContributionPage.php';
         CRM_Contribute_BAO_ContributionPage::setValues($contribution->contribution_page_id, $values);
         $contribution->source = ts('Online Contribution') . ': ' . $values['title'];
         if ($values['is_email_receipt']) {
             $contribution->receipt_date = self::$_now;
         }
         if ($membership) {
             $format = '%Y%m%d';
             require_once 'CRM/Member/BAO/MembershipType.php';
             require_once 'CRM/Member/BAO/Membership.php';
             $currentMembership = CRM_Member_BAO_Membership::getContactMembership($membership->contact_id, $membership->membership_type_id, $membership->is_test, $membership->id);
             if ($currentMembership) {
                 /*
                  * Fixed FOR CRM-4433
                  * In BAO/Membership.php(renewMembership function), we skip the extend membership date and status 
                  * when Contribution mode is notify and membership is for renewal ) 
                  */
                 CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, $changeToday = null);
                 $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id, $changeToday = null);
                 $dates['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format);
             } else {
                 $dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membership->membership_type_id);
             }
             //get the status for membership.
             require_once 'CRM/Member/BAO/MembershipStatus.php';
             $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($dates['start_date'], $dates['end_date'], $dates['join_date'], 'today', true);
             $formatedParams = array('status_id' => CRM_Utils_Array::value('id', $calcStatus, 2), 'join_date' => CRM_Utils_Date::customFormat($dates['join_date'], $format), 'start_date' => CRM_Utils_Date::customFormat($dates['start_date'], $format), 'end_date' => CRM_Utils_Date::customFormat($dates['end_date'], $format), 'reminder_date' => CRM_Utils_Date::customFormat($dates['reminder_date'], $format));
             $membership->copyValues($formatedParams);
             $membership->save();
             //updating the membership log
             $membershipLog = array();
             $membershipLog = $formatedParams;
             $logStartDate = CRM_Utils_Date::customFormat($dates['log_start_date'], $format);
             $logStartDate = $logStartDate ? CRM_Utils_Date::isoToMysql($logStartDate) : $formatedParams['start_date'];
             $membershipLog['start_date'] = $logStartDate;
             $membershipLog['membership_id'] = $membership->id;
             $membershipLog['modified_id'] = $membership->contact_id;
             $membershipLog['modified_date'] = date('Ymd');
             require_once 'CRM/Member/BAO/MembershipLog.php';
             CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
             //update related Memberships.
             CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $formatedParams);
         }
     } else {
         // event
         $eventParams = array('id' => $objects['event']->id);
         $values['event'] = array();
         require_once 'CRM/Event/BAO/Event.php';
         CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
         $eventParams = array('id' => $objects['event']->id);
         $values['event'] = array();
         require_once 'CRM/Event/BAO/Event.php';
         CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
         //get location details
         $locationParams = array('entity_id' => $objects['event']->id, 'entity_table' => 'civicrm_event');
         require_once 'CRM/Core/BAO/Location.php';
         require_once 'CRM/Event/Form/ManageEvent/Location.php';
         $values['location'] = CRM_Core_BAO_Location::getValues($locationParams);
         require_once 'CRM/Core/BAO/UFJoin.php';
         $ufJoinParams = array('entity_table' => 'civicrm_event', 'entity_id' => $ids['event'], 'weight' => 1);
         $values['custom_pre_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
         $ufJoinParams['weight'] = 2;
         $values['custom_post_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
         $contribution->source = ts('Online Event Registration') . ': ' . $values['event']['title'];
         if ($values['event']['is_email_confirm']) {
             $contribution->receipt_date = self::$_now;
         }
         $participant->status_id = 1;
         $participant->save();
     }
     if ($input['net_amount'] == 0 && $input['fee_amount'] != 0) {
         $input['net_amount'] = $input['amount'] - $input['fee_amount'];
     }
     $contribution->contribution_status_id = 1;
     $contribution->is_test = $input['is_test'];
     $contribution->fee_amount = $input['fee_amount'];
     $contribution->net_amount = $input['net_amount'];
     $contribution->trxn_id = $input['trxn_id'];
     $contribution->receive_date = CRM_Utils_Date::isoToMysql($contribution->receive_date);
     $contribution->cancel_date = 'null';
     if (CRM_Utils_Array::value('check_number', $input)) {
         $contribution->check_number = $input['check_number'];
     }
     if (CRM_Utils_Array::value('payment_instrument_id', $input)) {
         $contribution->payment_instrument_id = $input['payment_instrument_id'];
     }
     $contribution->save();
     // next create the transaction record
     if (isset($objects['paymentProcessor'])) {
         $paymentProcessor = $objects['paymentProcessor']['payment_processor_type'];
     } else {
         $paymentProcessor = '';
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:BaseIPN.php

示例11: formRule


//.........这里部分代码省略.........
     //check if contact is selected in standalone mode
     if (isset($params['contact_select_id'][1]) && !$params['contact_select_id'][1]) {
         $errors['contact[1]'] = ts('Please select a contact or create new contact');
     }
     if (!empty($errors)) {
         return $errors;
     }
     if ($priceSetId && !$self->_mode && !CRM_Utils_Array::value('record_contribution', $params)) {
         $errors['record_contribution'] = ts('Record Membership Payment is required when you using price set.');
     }
     if (CRM_Utils_Array::value('payment_processor_id', $params)) {
         // make sure that credit card number and cvv are valid
         if (CRM_Utils_Array::value('credit_card_type', $params)) {
             if (CRM_Utils_Array::value('credit_card_number', $params) && !CRM_Utils_Rule::creditCardNumber($params['credit_card_number'], $params['credit_card_type'])) {
                 $errors['credit_card_number'] = ts("Please enter a valid Credit Card Number");
             }
             if (CRM_Utils_Array::value('cvv2', $params) && !CRM_Utils_Rule::cvv($params['cvv2'], $params['credit_card_type'])) {
                 $errors['cvv2'] = ts("Please enter a valid Credit Card Verification Number");
             }
         }
     }
     $joinDate = NULL;
     if (CRM_Utils_Array::value('join_date', $params)) {
         $joinDate = CRM_Utils_Date::processDate($params['join_date']);
         foreach ($self->_memTypeSelected as $memType) {
             $startDate = NULL;
             if (CRM_Utils_Array::value('start_date', $params)) {
                 $startDate = CRM_Utils_Date::processDate($params['start_date']);
             }
             // if end date is set, ensure that start date is also set
             // and that end date is later than start date
             // If selected membership type has duration unit as 'lifetime'
             // and end date is set, then give error
             $endDate = NULL;
             if (CRM_Utils_Array::value('end_date', $params)) {
                 $endDate = CRM_Utils_Date::processDate($params['end_date']);
             }
             $membershipDetails = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($memType);
             if ($startDate && CRM_Utils_Array::value('period_type', $membershipDetails) == 'rolling') {
                 if ($startDate < $joinDate) {
                     $errors['start_date'] = ts('Start date must be the same or later than Member since.');
                 }
             }
             if ($endDate) {
                 if ($membershipDetails['duration_unit'] == 'lifetime') {
                     $errors['end_date'] = ts('The selected Membership Type has a lifetime duration. You cannot specify an End Date for lifetime memberships. Please clear the End Date OR select a different Membership Type.');
                 } else {
                     if (!$startDate) {
                         $errors['start_date'] = ts('Start date must be set if end date is set.');
                     }
                     if ($endDate < $startDate) {
                         $errors['end_date'] = ts('End date must be the same or later than start date.');
                     }
                 }
             }
             //  Default values for start and end dates if not supplied
             //  on the form
             $defaultDates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($memType, $joinDate, $startDate, $endDate);
             if (!$startDate) {
                 $startDate = CRM_Utils_Array::value('start_date', $defaultDates);
             }
             if (!$endDate) {
                 $endDate = CRM_Utils_Array::value('end_date', $defaultDates);
             }
             //CRM-3724, check for availability of valid membership status.
             if (!CRM_Utils_Array::value('is_override', $params) && !isset($errors['_qf_default'])) {
                 $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($startDate, $endDate, $joinDate, 'today', TRUE);
                 if (empty($calcStatus)) {
                     $url = CRM_Utils_System::url('civicrm/admin/member/membershipStatus', 'reset=1&action=browse');
                     $errors['_qf_default'] = ts('There is no valid Membership Status available for selected membership dates.');
                     $status = ts('Oops, it looks like there is no valid membership status available for the given membership dates. You can <a href="%1">Configure Membership Status Rules</a>.', array(1 => $url));
                     if (!$self->_mode) {
                         $status .= ' ' . ts('OR You can sign up by setting Status Override? to true.');
                     }
                     CRM_Core_Session::setStatus($status);
                 }
             }
         }
     } else {
         $errors['join_date'] = ts('Please enter the Member Since.');
     }
     if (isset($params['is_override']) && $params['is_override'] && !CRM_Utils_Array::value('status_id', $params)) {
         $errors['status_id'] = ts('Please enter the status.');
     }
     //total amount condition arise when membership type having no
     //minimum fee
     if (isset($params['record_contribution'])) {
         if (!$params['contribution_type_id']) {
             $errors['contribution_type_id'] = ts('Please enter the contribution Type.');
         }
         if (CRM_Utils_System::isNull($params['total_amount'])) {
             $errors['total_amount'] = ts('Please enter the contribution.');
         }
     }
     // validate contribution status for 'Failed'.
     if ($self->_onlinePendingContributionId && CRM_Utils_Array::value('record_contribution', $params) && CRM_Utils_Array::value('contribution_status_id', $params) == array_search('Failed', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'))) {
         $errors['contribution_status_id'] = ts("Please select a valid payment status before updating.");
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Membership.php

示例12: fixMembershipStatusBeforeRenew

 /**
  * Method to fix membership status of stale membership
  *
  * This method first checks if the membership is stale. If it is,
  * then status will be updated based on existing start and end
  * dates and log will be added for the status change.
  *
  * @param  array  $currentMembership   referance to the array
  *                                     containing all values of
  *                                     the current membership
  * @param  array  $changeToday         array of month, day, year
  *                                     values in case today needs
  *                                     to be customised, null otherwise
  *
  * @return void
  * @static
  */
 static function fixMembershipStatusBeforeRenew(&$currentMembership, $changeToday)
 {
     $today = NULL;
     if ($changeToday) {
         $today = CRM_Utils_Date::processDate($changeToday, NULL, FALSE, 'Y-m-d');
     }
     $status = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate(CRM_Utils_Array::value('start_date', $currentMembership), CRM_Utils_Array::value('end_date', $currentMembership), CRM_Utils_Array::value('join_date', $currentMembership), $today, TRUE, $currentMembership['membership_type_id'], $currentMembership);
     if (empty($status) || empty($status['id'])) {
         CRM_Core_Error::fatal(ts('Oops, it looks like there is no valid membership status corresponding to the membership start and end dates for this membership. Contact the site administrator for assistance.'));
     }
     $currentMembership['today_date'] = $today;
     if ($status['id'] !== $currentMembership['status_id']) {
         $memberDAO = new CRM_Member_DAO_Membership();
         $memberDAO->id = $currentMembership['id'];
         $memberDAO->find(TRUE);
         $memberDAO->status_id = $status['id'];
         $memberDAO->join_date = CRM_Utils_Date::isoToMysql($memberDAO->join_date);
         $memberDAO->start_date = CRM_Utils_Date::isoToMysql($memberDAO->start_date);
         $memberDAO->end_date = CRM_Utils_Date::isoToMysql($memberDAO->end_date);
         $memberDAO->save();
         CRM_Core_DAO::storeValues($memberDAO, $currentMembership);
         $memberDAO->free();
         $currentMembership['is_current_member'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $currentMembership['status_id'], 'is_current_member');
         $format = '%Y%m%d';
         $logParams = array('membership_id' => $currentMembership['id'], 'status_id' => $status['id'], 'start_date' => CRM_Utils_Date::customFormat($currentMembership['start_date'], $format), 'end_date' => CRM_Utils_Date::customFormat($currentMembership['end_date'], $format), 'modified_date' => CRM_Utils_Date::customFormat($currentMembership['today_date'], $format), 'membership_type_id' => $currentMembership['membership_type_id'], 'max_related' => $currentMembership['max_related']);
         $session = CRM_Core_Session::singleton();
         // If we have an authenticated session, set modified_id to that user's contact_id, else set to membership.contact_id
         if ($session->get('userID')) {
             $logParams['modified_id'] = $session->get('userID');
         } else {
             $logParams['modified_id'] = $currentMembership['contact_id'];
         }
         CRM_Member_BAO_MembershipLog::add($logParams, CRM_Core_DAO::$_nullArray);
     }
 }
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:52,代码来源:Membership.php

示例13: crm_calc_membership_status

/**
 * Derives the Membership Status of a given Membership Reocrd
 * 
 * This API is used for deriving Membership Status of a given Membership 
 * record using the rules encoded in the membership_status table.
 * 
 * @param  Int     $membershipID  Id of a membership
 * @param  String  $statusDate    
 * 
 * @return Array  Array of status id and status name 
 * @public
 */
function crm_calc_membership_status($membershipID)
{
    if (empty($membershipID)) {
        return _crm_error('Invalid value for membershipID');
    }
    $query = "\nSELECT start_date, end_date, join_date\n  FROM civicrm_membership\n WHERE id = %1\n";
    $params = array(1 => array($membershipID, 'Integer'));
    $dao =& CRM_Core_DAO::executeQuery($query, $params);
    if ($dao->fetch()) {
        require_once 'CRM/Member/BAO/MembershipStatus.php';
        $result =& CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($dao->start_date, $dao->end_date, $dao->join_date);
    } else {
        $result = null;
    }
    $dao->free();
    return $result;
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:29,代码来源:Membership.php

示例14: completeOrder


//.........这里部分代码省略.........
             // but CRM-16124 if $input['is_email_receipt'] is set then that should not be overridden.
             $values['is_email_receipt'] = $recurContrib->is_email_receipt;
         }
         if (!empty($memberships)) {
             foreach ($memberships as $membershipTypeIdKey => $membership) {
                 if ($membership) {
                     $membershipParams = array('id' => $membership->id, 'contact_id' => $membership->contact_id, 'is_test' => $membership->is_test, 'membership_type_id' => $membership->membership_type_id);
                     $currentMembership = CRM_Member_BAO_Membership::getContactMembership($membershipParams['contact_id'], $membershipParams['membership_type_id'], $membershipParams['is_test'], $membershipParams['id']);
                     // CRM-8141 update the membership type with the value recorded in log when membership created/renewed
                     // this picks up membership type changes during renewals
                     $sql = "\nSELECT    membership_type_id\nFROM      civicrm_membership_log\nWHERE     membership_id={$membershipParams['id']}\nORDER BY  id DESC\nLIMIT 1;";
                     $dao = CRM_Core_DAO::executeQuery($sql);
                     if ($dao->fetch()) {
                         if (!empty($dao->membership_type_id)) {
                             $membershipParams['membership_type_id'] = $dao->membership_type_id;
                         }
                     }
                     $dao->free();
                     $membershipParams['num_terms'] = $contribution->getNumTermsByContributionAndMembershipType($membershipParams['membership_type_id'], $primaryContributionID);
                     $dates = array_fill_keys(array('join_date', 'start_date', 'end_date'), NULL);
                     if ($currentMembership) {
                         /*
                          * Fixed FOR CRM-4433
                          * In BAO/Membership.php(renewMembership function), we skip the extend membership date and status
                          * when Contribution mode is notify and membership is for renewal )
                          */
                         CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, $changeDate);
                         // @todo - we should pass membership_type_id instead of null here but not
                         // adding as not sure of testing
                         $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membershipParams['id'], $changeDate, NULL, $membershipParams['num_terms']);
                         $dates['join_date'] = $currentMembership['join_date'];
                     }
                     //get the status for membership.
                     $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($dates['start_date'], $dates['end_date'], $dates['join_date'], 'today', TRUE, $membershipParams['membership_type_id'], $membershipParams);
                     $membershipParams['status_id'] = CRM_Utils_Array::value('id', $calcStatus, 'New');
                     //we might be renewing membership,
                     //so make status override false.
                     $membershipParams['is_override'] = FALSE;
                     //CRM-17723 - reset static $relatedContactIds array()
                     $var = TRUE;
                     CRM_Member_BAO_Membership::createRelatedMemberships($var, $var, TRUE);
                     civicrm_api3('Membership', 'create', $membershipParams);
                 }
             }
         }
     } else {
         if (empty($input['IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved'])) {
             if ($event->is_email_confirm) {
                 // @todo this should be set by the function that sends the mail after sending.
                 $contributionParams['receipt_date'] = $changeDate;
             }
             $participantParams['id'] = $participant->id;
             $participantParams['status_id'] = 'Registered';
             civicrm_api3('Participant', 'create', $participantParams);
         }
     }
     $contributionParams['id'] = $contribution->id;
     // CRM-19309 - if you update the contribution here with financial_type_id it can/will mess with $lineItem
     // unsetting it here does NOT cause any other contribution test to fail!
     unset($contributionParams['financial_type_id']);
     $contributionResult = civicrm_api3('Contribution', 'create', $contributionParams);
     // Add new soft credit against current $contribution.
     if (CRM_Utils_Array::value('contributionRecur', $objects) && $objects['contributionRecur']->id) {
         CRM_Contribute_BAO_ContributionRecur::addrecurSoftCredit($objects['contributionRecur']->id, $contribution->id);
     }
     $contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', array('labelColumn' => 'name', 'flip' => 1));
开发者ID:nielosz,项目名称:civicrm-core,代码行数:67,代码来源:Contribution.php

示例15: transitionComponents


//.........这里部分代码省略.........
             }
             if ($participant) {
                 $updatedStatusId = array_search('Cancelled', $participantStatuses);
                 CRM_Event_BAO_Participant::updateParticipantStatus($participant->id, $oldStatus, $updatedStatusId, true);
                 $updateResult['updatedComponents']['CiviEvent'] = $updatedStatusId;
                 if ($processContributionObject) {
                     $processContribution = true;
                 }
             }
             if ($pledgePayment) {
                 CRM_Pledge_BAO_Payment::updatePledgePaymentStatus($pledgeID, $pledgePaymentIDs, $contributionStatusId);
                 $updateResult['updatedComponents']['CiviPledge'] = $contributionStatusId;
                 if ($processContributionObject) {
                     $processContribution = true;
                 }
             }
         } else {
             if ($contributionStatusId == array_search('Completed', $contributionStatuses)) {
                 // only pending contribution related object processed.
                 if ($previousContriStatusId && $previousContriStatusId != array_search('Pending', $contributionStatuses)) {
                     // this is case when we already processed contribution object.
                     return $updateResult;
                 } else {
                     if (!$previousContriStatusId && $contribution->contribution_status_id != array_search('Pending', $contributionStatuses)) {
                         // this is case when we will going to process contribution object.
                         return $updateResult;
                     }
                 }
                 if ($membership) {
                     $format = '%Y%m%d';
                     require_once 'CRM/Member/BAO/MembershipType.php';
                     //CRM-4523
                     $currentMembership = CRM_Member_BAO_Membership::getContactMembership($membership->contact_id, $membership->membership_type_id, $membership->is_test, $membership->id);
                     if ($currentMembership) {
                         CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, $changeToday = null);
                         $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id, $changeToday = null);
                         $dates['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format);
                     } else {
                         $dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membership->membership_type_id);
                     }
                     //get the status for membership.
                     require_once 'CRM/Member/BAO/MembershipStatus.php';
                     $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($dates['start_date'], $dates['end_date'], $dates['join_date'], 'today', true);
                     $formatedParams = array('status_id' => CRM_Utils_Array::value('id', $calcStatus, array_search('Current', $membershipStatuses)), 'join_date' => CRM_Utils_Date::customFormat($dates['join_date'], $format), 'start_date' => CRM_Utils_Date::customFormat($dates['start_date'], $format), 'end_date' => CRM_Utils_Date::customFormat($dates['end_date'], $format), 'reminder_date' => CRM_Utils_Date::customFormat($dates['reminder_date'], $format));
                     $membership->copyValues($formatedParams);
                     $membership->save();
                     //updating the membership log
                     $membershipLog = array();
                     $membershipLog = $formatedParams;
                     $logStartDate = CRM_Utils_Date::customFormat($dates['log_start_date'], $format);
                     $logStartDate = $logStartDate ? CRM_Utils_Date::isoToMysql($logStartDate) : $formatedParams['start_date'];
                     $membershipLog['start_date'] = $logStartDate;
                     $membershipLog['membership_id'] = $membership->id;
                     $membershipLog['modified_id'] = $membership->contact_id;
                     $membershipLog['modified_date'] = date('Ymd');
                     require_once 'CRM/Member/BAO/MembershipLog.php';
                     CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
                     //update related Memberships.
                     CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $formatedParams);
                     $updateResult['membership_end_date'] = CRM_Utils_Date::customFormat($dates['end_date'], '%B %E%f, %Y');
                     $updateResult['updatedComponents']['CiviMember'] = $membership->status_id;
                     if ($processContributionObject) {
                         $processContribution = true;
                     }
                 }
                 if ($participant) {
                     $updatedStatusId = array_search('Registered', $participantStatuses);
                     CRM_Event_BAO_Participant::updateParticipantStatus($participant->id, $oldStatus, $updatedStatusId, true);
                     $updateResult['updatedComponents']['CiviEvent'] = $updatedStatusId;
                     if ($processContributionObject) {
                         $processContribution = true;
                     }
                 }
                 if ($pledgePayment) {
                     CRM_Pledge_BAO_Payment::updatePledgePaymentStatus($pledgeID, $pledgePaymentIDs, $contributionStatusId);
                     $updateResult['updatedComponents']['CiviPledge'] = $contributionStatusId;
                     if ($processContributionObject) {
                         $processContribution = true;
                     }
                 }
             }
         }
     }
     // process contribution object.
     if ($processContribution) {
         require_once 'CRM/Contribute/BAO/Contribution.php';
         $contributionParams = array();
         $fields = array('contact_id', 'total_amount', 'receive_date', 'is_test', 'payment_instrument_id', 'trxn_id', 'invoice_id', 'contribution_type_id', 'contribution_status_id', 'non_deductible_amount', 'receipt_date', 'check_number');
         foreach ($fields as $field) {
             if (!CRM_Utils_Array::value($field, $params)) {
                 continue;
             }
             $contributionParams[$field] = $params[$field];
         }
         $ids = array('contribution' => $contributionId);
         require_once 'CRM/Contribute/BAO/Contribution.php';
         $contribution =& CRM_Contribute_BAO_Contribution::create($contributionParams, $ids);
     }
     return $updateResult;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Contribution.php


注:本文中的CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。