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


PHP CRM_Price_BAO_Set::checkAutoRenewForPriceSet方法代码示例

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


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

示例1: buildQuickForm

    /**
     * Function to build the form
     *
     * @return None
     * @access public
     */
    public function buildQuickForm()
    {
        if ($this->_cdType) {
            return CRM_Custom_Form_CustomData::buildQuickForm($this);
        }
        // build price set form.
        $buildPriceSet = FALSE;
        if ($this->_priceSetId || CRM_Utils_Array::value('price_set_id', $_POST)) {
            if (CRM_Utils_Array::value('price_set_id', $_POST)) {
                $buildPriceSet = TRUE;
            }
            $getOnlyPriceSetElements = TRUE;
            if (!$this->_priceSetId) {
                $this->_priceSetId = $_POST['price_set_id'];
                $getOnlyPriceSetElements = FALSE;
            }
            $this->set('priceSetId', $this->_priceSetId);
            CRM_Price_BAO_Set::buildPriceSet($this);
            $optionsMembershipTypes = array();
            foreach ($this->_priceSet['fields'] as $pField) {
                if (empty($pField['options'])) {
                    continue;
                }
                foreach ($pField['options'] as $opId => $opValues) {
                    $optionsMembershipTypes[$opId] = CRM_Utils_Array::value('membership_type_id', $opValues, 0);
                }
            }
            $this->assign('autoRenewOption', CRM_Price_BAO_Set::checkAutoRenewForPriceSet($this->_priceSetId));
            $this->assign('optionsMembershipTypes', $optionsMembershipTypes);
            $this->assign('contributionType', CRM_Utils_Array::value('contribution_type_id', $this->_priceSet));
            // get only price set form elements.
            if ($getOnlyPriceSetElements) {
                return;
            }
        }
        // use to build form during form rule.
        $this->assign('buildPriceSet', $buildPriceSet);
        if ($this->_action & CRM_Core_Action::ADD) {
            $buildPriceSet = FALSE;
            $priceSets = CRM_Price_BAO_Set::getAssoc(FALSE, 'CiviMember');
            if (!empty($priceSets)) {
                $buildPriceSet = TRUE;
            }
            if ($buildPriceSet) {
                $this->add('select', 'price_set_id', ts('Choose price set'), array('' => ts('Choose price set')) + $priceSets, NULL, array('onchange' => "buildAmount( this.value );"));
            }
            $this->assign('hasPriceSets', $buildPriceSet);
        }
        //need to assign custom data type and subtype to the template
        $this->assign('customDataType', 'Membership');
        $this->assign('customDataSubType', $this->_memType);
        $this->assign('entityID', $this->_id);
        if ($this->_action & CRM_Core_Action::DELETE) {
            $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => '         ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
            return;
        }
        if ($this->_context == 'standalone') {
            CRM_Contact_Form_NewContact::buildQuickForm($this);
        }
        $selOrgMemType[0][0] = $selMemTypeOrg[0] = ts('- select -');
        $dao = new CRM_Member_DAO_MembershipType();
        $dao->domain_id = CRM_Core_Config::domainID();
        $dao->find();
        // retrieve all memberships
        $allMemberships = CRM_Member_BAO_Membership::buildMembershipTypeValues($this);
        $allMembershipInfo = $membershipType = array();
        foreach ($allMemberships as $key => $values) {
            if (CRM_Utils_Array::value('is_active', $values)) {
                $membershipType[$key] = CRM_Utils_Array::value('name', $values);
                if ($this->_mode && !CRM_Utils_Array::value('minimum_fee', $values)) {
                    continue;
                } else {
                    $memberOfContactId = CRM_Utils_Array::value('member_of_contact_id', $values);
                    if (!CRM_Utils_Array::value($memberOfContactId, $selMemTypeOrg)) {
                        $selMemTypeOrg[$memberOfContactId] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $memberOfContactId, 'display_name', 'id');
                        $selOrgMemType[$memberOfContactId][0] = ts('- select -');
                    }
                    if (!CRM_Utils_Array::value($key, $selOrgMemType[$memberOfContactId])) {
                        $selOrgMemType[$memberOfContactId][$key] = CRM_Utils_Array::value('name', $values);
                    }
                }
                // build membership info array, which is used to set the payment information block when
                // membership type is selected.
                $allMembershipInfo[$key] = array('contribution_type_id' => CRM_Utils_Array::value('contribution_type_id', $values), 'total_amount' => CRM_Utils_Money::format($values['minimum_fee'], NULL, '%a'), 'auto_renew' => CRM_Utils_Array::value('auto_renew', $values));
            }
        }
        $this->assign('allMembershipInfo', json_encode($allMembershipInfo));
        // show organization by default, if only one organization in
        // the list
        if (count($selMemTypeOrg) == 2) {
            unset($selMemTypeOrg[0], $selOrgMemType[0][0]);
        }
        //sort membership organization and type, CRM-6099
        natcasesort($selMemTypeOrg);
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Membership.php

示例2: formRule


//.........这里部分代码省略.........
                 }
                 // allow for 0 value.
                 if (!empty($fields['option_amount'][$index]) || strlen($fields['option_amount'][$index]) > 0) {
                     $noAmount = 0;
                 }
                 if (!empty($fields['option_weight'][$index])) {
                     $noWeight = 0;
                     $duplicateIndex = CRM_Utils_Array::key($fields['option_weight'][$index], $fields['option_weight']);
                     if (!($duplicateIndex === FALSE) && !($duplicateIndex == $index)) {
                         $errors["option_weight[{$index}]"] = ts('Duplicate weight value');
                         $_flagOption = 1;
                     }
                 }
                 if ($noLabel && !$noAmount) {
                     $errors["option_label[{$index}]"] = ts('Label cannot be empty.');
                     $_flagOption = 1;
                 }
                 if (!$noLabel && $noAmount) {
                     $errors["option_amount[{$index}]"] = ts('Amount cannot be empty.');
                     $_flagOption = 1;
                 }
                 if ($noLabel && $noAmount) {
                     $countemptyrows++;
                     $_emptyRow = 1;
                 } elseif (!empty($fields['option_max_value'][$index]) && !empty($fields['option_count'][$index]) && $fields['option_count'][$index] > $fields['option_max_value'][$index]) {
                     $errors["option_max_value[{$index}]"] = ts('Participant count can not be greater than max participants.');
                     $_flagOption = 1;
                 }
                 $showBlocks = 'optionField_' . $index;
                 if ($_flagOption) {
                     $_showHide->addShow($showBlocks);
                     $_rowError = 1;
                 }
                 if (!empty($_emptyRow)) {
                     $_showHide->addHide($showBlocks);
                 } else {
                     $_showHide->addShow($showBlocks);
                 }
                 if ($index == self::NUM_OPTION) {
                     $hideBlock = 'additionalOption';
                     $_showHide->addHide($hideBlock);
                 }
                 $_flagOption = $_emptyRow = 0;
             }
             if (!empty($memTypesIDS)) {
                 // check for checkboxes allowing user to select multiple memberships from same membership organization
                 if ($fields['html_type'] == 'CheckBox') {
                     $foundDuplicate = FALSE;
                     $orgIds = array();
                     foreach ($memTypesIDS as $key => $val) {
                         $org = CRM_Member_BAO_MembershipType::getMembershipTypeOrganization($val);
                         if (in_array($org[$val], $orgIds)) {
                             $foundDuplicate = TRUE;
                             break;
                         }
                         $orgIds[$val] = $org[$val];
                     }
                     if ($foundDuplicate) {
                         $errors['_qf_default'] = ts('You have selected multiple memberships for the same organization or entity. Please review your selections and choose only one membership per entity.');
                     }
                 }
                 // CRM-10390 - Only one price field in a set can include auto-renew membership options
                 $foundAutorenew = FALSE;
                 foreach ($memTypesIDS as $key => $val) {
                     // see if any price field option values in this price field are for memberships with autorenew
                     $memTypeDetails = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($val);
                     if (CRM_Utils_Array::value('auto_renew', $memTypeDetails)) {
                         $foundAutorenew = TRUE;
                         break;
                     }
                 }
                 if ($foundAutorenew) {
                     // if so, check for other fields in this price set which also have auto-renew membership options
                     $otherFieldAutorenew = CRM_Price_BAO_Set::checkAutoRenewForPriceSet($form->_sid);
                     if ($otherFieldAutorenew) {
                         $errors['_qf_default'] = ts('You can include auto-renew membership choices for only one price field in a price set. Another field in this set already contains one or more auto-renew membership options.');
                     }
                 }
             }
             $_showHide->addToTemplate();
             if ($countemptyrows == 11) {
                 $errors['option_label[1]'] = $errors['option_amount[1]'] = ts('Label and value cannot be empty.');
                 $_flagOption = 1;
             }
         } elseif (!empty($fields['max_value']) && !empty($fields['count']) && $fields['count'] > $fields['max_value']) {
             $errors['max_value'] = ts('Participant count can not be greater than max participants.');
         }
         // do not process if no option rows were submitted
         if (empty($fields['option_amount']) && empty($fields['option_label'])) {
             return TRUE;
         }
         if (empty($fields['option_name'])) {
             $fields['option_amount'] = array();
         }
         if (empty($fields['option_label'])) {
             $fields['option_label'] = array();
         }
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Field.php

示例3: buildMembershipBlock


//.........这里部分代码省略.........
                         $form->assign('membership_name', $memType['name']);
                         if (!$thankPage && $cid) {
                             $membership = new CRM_Member_DAO_Membership();
                             $membership->contact_id = $cid;
                             $membership->membership_type_id = $memType['id'];
                             if ($membership->find(TRUE)) {
                                 $form->assign('renewal_mode', TRUE);
                                 $memType['current_membership'] = $membership->end_date;
                                 $form->_currentMemberships[$membership->membership_type_id] = $membership->membership_type_id;
                             }
                         }
                         $membershipTypes[] = $memType;
                     }
                 } elseif ($memType['is_active']) {
                     $javascriptMethod = NULL;
                     $allowAutoRenewOpt = 1;
                     if (is_array($form->_paymentProcessors)) {
                         foreach ($form->_paymentProcessors as $id => $val) {
                             if (!$val['is_recur']) {
                                 $allowAutoRenewOpt = 0;
                                 continue;
                             }
                         }
                     }
                     $javascriptMethod = array('onclick' => "return showHideAutoRenew( this.value );");
                     $autoRenewMembershipTypeOptions["autoRenewMembershipType_{$value}"] = (int) $allowAutoRenewOpt * CRM_Utils_Array::value($value, $form->_membershipBlock['auto_renew']);
                     if ($allowAutoRenewOpt) {
                         $allowAutoRenewMembership = TRUE;
                     }
                     //add membership type.
                     $radio[$memType['id']] = $form->createElement('radio', NULL, NULL, NULL, $memType['id'], $javascriptMethod);
                     if ($cid) {
                         $membership = new CRM_Member_DAO_Membership();
                         $membership->contact_id = $cid;
                         $membership->membership_type_id = $memType['id'];
                         //show current membership, skip pending and cancelled membership records,
                         //because we take first membership record id for renewal
                         $membership->whereAdd('status_id != 5 AND status_id !=6');
                         if (!is_null($isTest)) {
                             $membership->is_test = $isTest;
                         }
                         //CRM-4297
                         $membership->orderBy('end_date DESC');
                         if ($membership->find(TRUE)) {
                             if (!$membership->end_date) {
                                 unset($radio[$memType['id']]);
                                 $form->assign('islifetime', TRUE);
                                 continue;
                             }
                             $form->assign('renewal_mode', TRUE);
                             $form->_currentMemberships[$membership->membership_type_id] = $membership->membership_type_id;
                             $memType['current_membership'] = $membership->end_date;
                             if (!$endDate) {
                                 $endDate = $memType['current_membership'];
                                 $form->_defaultMemTypeId = $memType['id'];
                             }
                             if ($memType['current_membership'] < $endDate) {
                                 $endDate = $memType['current_membership'];
                                 $form->_defaultMemTypeId = $memType['id'];
                             }
                         }
                     }
                     $membershipTypes[] = $memType;
                 }
             }
         }
         $form->assign('showRadio', $formItems);
         if ($formItems) {
             if (!$membershipPriceset) {
                 if (!$membershipBlock['is_required']) {
                     $form->assign('showRadioNoThanks', TRUE);
                     $radio[''] = $form->createElement('radio', NULL, NULL, NULL, 'no_thanks', NULL);
                     $form->addGroup($radio, 'selectMembership', NULL);
                 } elseif ($membershipBlock['is_required'] && count($radio) == 1) {
                     $temp = array_keys($radio);
                     $form->add('hidden', 'selectMembership', $temp[0], array('id' => 'selectMembership'));
                     $form->assign('singleMembership', TRUE);
                     $form->assign('showRadio', FALSE);
                 } else {
                     $form->addGroup($radio, 'selectMembership', NULL);
                 }
                 $form->addRule('selectMembership', ts('Please select one of the memberships.'), 'required');
             } else {
                 $autoRenewOption = CRM_Price_BAO_Set::checkAutoRenewForPriceSet($form->_priceSetId);
                 $form->assign('autoRenewOption', $autoRenewOption);
             }
             if (!$form->_values['is_pay_later'] && is_array($form->_paymentProcessors) && ($allowAutoRenewMembership || $autoRenewOption)) {
                 $form->addElement('checkbox', 'auto_renew', ts('Please renew my membership automatically.'));
             }
         }
         $form->assign('membershipBlock', $membershipBlock);
         $form->assign('membershipTypes', $membershipTypes);
         $form->assign('allowAutoRenewMembership', $allowAutoRenewMembership);
         $form->assign('autoRenewMembershipTypeOptions', json_encode($autoRenewMembershipTypeOptions));
         //give preference to user submitted auto_renew value.
         $takeUserSubmittedAutoRenew = !empty($_POST) || $form->isSubmitted() ? TRUE : FALSE;
         $form->assign('takeUserSubmittedAutoRenew', $takeUserSubmittedAutoRenew);
     }
     return $separateMembershipPayment;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Membership.php


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