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


PHP CRM_Financial_BAO_FinancialAccount::validateFinancialType方法代码示例

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


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

示例1: create

 /**
  * Takes an associative array and creates a price set object.
  *
  * @param array $params
  *   (reference) an assoc array of name/value pairs.
  *
  * @return CRM_Price_DAO_PriceSet
  */
 public static function create(&$params)
 {
     if (empty($params['id']) && empty($params['name'])) {
         $params['name'] = CRM_Utils_String::munge($params['title'], '_', 242);
     }
     $priceSetID = NULL;
     $validatePriceSet = TRUE;
     if (!empty($params['extends']) && is_array($params['extends'])) {
         if (!array_key_exists(CRM_Core_Component::getComponentID('CiviEvent'), $params['extends']) || !array_key_exists(CRM_Core_Component::getComponentID('CiviMember'), $params['extends'])) {
             $validatePriceSet = FALSE;
         }
         $params['extends'] = CRM_Utils_Array::implodePadded($params['extends']);
     } else {
         $priceSetID = CRM_Utils_Array::value('id', $params);
     }
     // CRM-16189
     if ($validatePriceSet && !empty($params['financial_type_id'])) {
         CRM_Financial_BAO_FinancialAccount::validateFinancialType($params['financial_type_id'], $priceSetID);
     }
     $priceSetBAO = new CRM_Price_BAO_PriceSet();
     $priceSetBAO->copyValues($params);
     if (self::eventPriceSetDomainID()) {
         $priceSetBAO->domain_id = CRM_Core_Config::domainID();
     }
     return $priceSetBAO->save();
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:34,代码来源:PriceSet.php

示例2: formRule

 /**
  * Global validation rules for the form.
  *
  * @param array $fields
  *   Posted values of the form.
  *
  * @param $files
  * @param CRM_Core_Form $form
  *
  * @return array
  *   if errors then list of errors to be posted back to the form,
  *                  true otherwise
  */
 public static function formRule($fields, $files, $form)
 {
     $errors = array();
     if (!empty($fields['count']) && !empty($fields['max_value']) && $fields['count'] > $fields['max_value']) {
         $errors['count'] = ts('Participant count can not be greater than max participants.');
     }
     // CRM-16189
     try {
         CRM_Financial_BAO_FinancialAccount::validateFinancialType($fields['financial_type_id'], $form->_fid, 'PriceField');
     } catch (CRM_Core_Exception $e) {
         $errors['financial_type_id'] = $e->getMessage();
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:27,代码来源:Option.php

示例3: formRule


//.........这里部分代码省略.........
                 }
                 if ($start_date && $end_date && strcmp($end_date, $start_date) < 0) {
                     $errors["discount_end_date[{$i}]"] = ts('The discount end date cannot be prior to the start date.');
                 }
                 if (!$start_date && !$end_date) {
                     $errors["discount_start_date[{$i}]"] = $errors["discount_end_date[{$i}]"] = ts('Please specify either start date or end date.');
                 }
                 if ($i > 1) {
                     $end_date_1 = $values['discount_end_date'][$i - 1] ? CRM_Utils_Date::processDate($values['discount_end_date'][$i - 1]) : 0;
                     if ($start_date && $end_date_1 && strcmp($end_date_1, $start_date) >= 0) {
                         $errors["discount_start_date[{$i}]"] = ts('Select non-overlapping discount start date.');
                     } elseif (!$start_date && !$end_date_1) {
                         $j = $i - 1;
                         $errors["discount_start_date[{$i}]"] = $errors["discount_end_date[{$j}]"] = ts('Select either of the dates.');
                     }
                 }
                 foreach ($occurDiscount as $key => $value) {
                     if ($value > 1 && $key != '') {
                         if ($key == $values['discount_name'][$i]) {
                             $errors['discount_name[' . $i . ']'] = ts('%1 is already used for Discount Name.', array(1 => $key));
                         }
                     }
                 }
                 //validation for discount labels and values
                 for ($index = self::NUM_OPTION; $index > 0; $index--) {
                     $label = TRUE;
                     if (empty($values['discounted_label'][$index]) && !empty($values['discounted_value'][$index][$i])) {
                         $label = FALSE;
                         if (!$label) {
                             $errors["discounted_label[{$index}]"] = ts('Label cannot be empty.');
                         }
                     }
                     if (!empty($values['discounted_label'][$index])) {
                         $duplicateIndex = CRM_Utils_Array::key($values['discounted_label'][$index], $values['discounted_label']);
                         if (!($duplicateIndex === FALSE) && !($duplicateIndex == $index)) {
                             $errors["discounted_label[{$index}]"] = ts('Duplicate label value');
                         }
                     }
                     if (empty($values['discounted_label'][$index]) && empty($values['discounted_value'][$index][$i])) {
                         $countemptyrows++;
                     }
                     if (empty($values['discounted_value'][$index][$i])) {
                         $countemptyvalue++;
                     }
                 }
                 if (!empty($values['_qf_Fee_next']) && ($countemptyrows == 11 || $countemptyvalue == 11)) {
                     $errors["discounted_label[1]"] = $errors["discounted_value[1][{$i}]"] = ts('At least one fee should be entered for your Discount Set. If you do not see the table to enter discount fees, click the "Add Discount Set to Fee Table" button.');
                 }
             }
         }
     }
     if ($values['is_monetary']) {
         //check if financial type is selected
         if (!$values['financial_type_id']) {
             $errors['financial_type_id'] = ts("Please select financial type.");
         }
         //check for the event fee label (mandatory)
         if (!$values['fee_label']) {
             $errors['fee_label'] = ts('Please enter the fee label for the paid event.');
         }
         if (empty($values['price_set_id'])) {
             //check fee label and amount
             $check = 0;
             $optionKeys = array();
             foreach ($values['label'] as $key => $val) {
                 if (trim($val) && trim($values['value'][$key])) {
                     $optionKeys[$key] = $key;
                     $check++;
                 }
             }
             $default = CRM_Utils_Array::value('default', $values);
             if ($default && !in_array($default, $optionKeys)) {
                 $errors['default'] = ts('Please select an appropriate option as default.');
             }
             if (!$check) {
                 if (!$values['label'][1]) {
                     $errors['label[1]'] = ts('Please enter a label for at least one fee level.');
                 }
                 if (!$values['value'][1]) {
                     $errors['value[1]'] = ts('Please enter an amount for at least one fee level.');
                 }
             }
         }
         if (isset($values['is_pay_later'])) {
             if (empty($values['pay_later_text'])) {
                 $errors['pay_later_text'] = ts('Please enter the Pay Later prompt to be displayed on the Registration form.');
             }
             if (empty($values['pay_later_receipt'])) {
                 $errors['pay_later_receipt'] = ts('Please enter the Pay Later instructions to be displayed to your users.');
             }
         }
     }
     // CRM-16189
     try {
         CRM_Financial_BAO_FinancialAccount::validateFinancialType($values['financial_type_id']);
     } catch (CRM_Core_Exception $e) {
         $errors['financial_type_id'] = $e->getMessage();
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:101,代码来源:Fee.php

示例4: add

 /**
  * Add the event.
  *
  * @param array $params
  *   Reference array contains the values submitted by the form.
  *
  * @return CRM_Event_DAO_Event
  */
 public static function add(&$params)
 {
     CRM_Utils_System::flushCache();
     $financialTypeId = NULL;
     if (!empty($params['id'])) {
         CRM_Utils_Hook::pre('edit', 'Event', $params['id'], $params);
         if (empty($params['skipFinancialType'])) {
             $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['id'], 'financial_type_id');
         }
     } else {
         CRM_Utils_Hook::pre('create', 'Event', NULL, $params);
     }
     // CRM-16189
     if (!empty($params['financial_type_id'])) {
         CRM_Financial_BAO_FinancialAccount::validateFinancialType($params['financial_type_id']);
     }
     $event = new CRM_Event_DAO_Event();
     $event->copyValues($params);
     $result = $event->save();
     if (!empty($params['id'])) {
         CRM_Utils_Hook::post('edit', 'Event', $event->id, $event);
     } else {
         CRM_Utils_Hook::post('create', 'Event', $event->id, $event);
     }
     if ($financialTypeId && !empty($params['financial_type_id']) && $financialTypeId != $params['financial_type_id']) {
         CRM_Price_BAO_PriceFieldValue::updateFinancialType($params['id'], 'civicrm_event', $params['financial_type_id']);
     }
     return $result;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:37,代码来源:Event.php

示例5: testValidateFinancialType

 /**
  * Test if financial type has Deferred Revenue Account is relationship with Financial Account.
  *
  */
 public function testValidateFinancialType()
 {
     Civi::settings()->set('contribution_invoice_settings', array('deferred_revenue_enabled' => '1'));
     $financialTypes = CRM_Contribute_PseudoConstant::financialType();
     foreach ($financialTypes as $key => $value) {
         try {
             CRM_Financial_BAO_FinancialAccount::validateFinancialType($key);
             if (!in_array($value, array('Member Dues', 'Event Fee'))) {
                 $this->fail("Missed expected exception");
             }
         } catch (CRM_Core_Exception $e) {
             if (in_array($value, array('Member Dues', 'Event Fees'))) {
                 $this->fail("Should not call exception");
             } else {
                 $this->assertEquals('Deferred revenue account is not configured for selected financial type. Please have an administrator set up the deferred revenue account at Administer > CiviContribute > Financial Accounts, then configure it for financial types at Administer > CiviContribution > Financial Types, Accounts', $e->getMessage());
             }
         }
     }
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:23,代码来源:FinancialAccountTest.php

示例6: formRule

 /**
  * Validation.
  *
  * @param array $params
  *   (ref.) an assoc array of name/value pairs.
  *
  * @return bool|array
  *   mixed true or array of errors
  */
 public static function formRule($params)
 {
     $errors = array();
     if (!$params['name']) {
         $errors['name'] = ts('Please enter a membership type name.');
     }
     if ($params['minimum_fee'] > 0 && !$params['financial_type_id']) {
         $errors['financial_type_id'] = ts('Please enter the financial Type.');
     }
     if (empty($params['duration_interval']) and $params['duration_unit'] != 'lifetime') {
         $errors['duration_interval'] = ts('Please enter a duration interval.');
     }
     if (in_array(CRM_Utils_Array::value('auto_renew', $params), array(1, 2))) {
         if ($params['duration_interval'] > 1 && $params['duration_unit'] == 'year' || $params['duration_interval'] > 12 && $params['duration_unit'] == 'month') {
             $errors['duration_unit'] = ts('Automatic renewals are not supported by the currently available payment processors when the membership duration is greater than 1 year / 12 months.');
         }
     }
     if ($params['period_type'] == 'fixed' && $params['duration_unit'] == 'day') {
         $errors['period_type'] = ts('Period type should be Rolling when duration unit is Day');
     }
     if ($params['period_type'] == 'fixed' && $params['duration_unit'] == 'year') {
         $periods = array('fixed_period_start_day', 'fixed_period_rollover_day');
         foreach ($periods as $period) {
             $month = $params[$period]['M'];
             $date = $params[$period]['d'];
             if (!$month || !$date) {
                 switch ($period) {
                     case 'fixed_period_start_day':
                         $errors[$period] = ts('Please enter a valid fixed period start day');
                         break;
                     case 'fixed_period_rollover_day':
                         $errors[$period] = ts('Please enter a valid fixed period rollover day');
                         break;
                 }
             }
         }
     }
     if ($params['fixed_period_start_day'] && !empty($params['fixed_period_start_day'])) {
         $params['fixed_period_start_day']['Y'] = date('Y');
         if (!CRM_Utils_Rule::qfDate($params['fixed_period_start_day'])) {
             $errors['fixed_period_start_day'] = ts('Please enter valid Fixed Period Start Day');
         }
     }
     if ($params['fixed_period_rollover_day'] && !empty($params['fixed_period_rollover_day'])) {
         $params['fixed_period_rollover_day']['Y'] = date('Y');
         if (!CRM_Utils_Rule::qfDate($params['fixed_period_rollover_day'])) {
             $errors['fixed_period_rollover_day'] = ts('Please enter valid Fixed Period Rollover Day');
         }
     }
     // CRM-16189
     try {
         CRM_Financial_BAO_FinancialAccount::validateFinancialType($params['financial_type_id']);
     } catch (CRM_Core_Exception $e) {
         $errors['financial_type_id'] = $e->getMessage();
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:66,代码来源:MembershipType.php

示例7: formRule

 /**
  * Global validation rules for the form.
  *
  * @param array $fields
  *   Posted values of the form.
  *
  * @param $files
  * @param CRM_Core_Form $form
  *
  * @return array
  *   if errors then list of errors to be posted back to the form,
  *                  true otherwise
  */
 public static function formRule($fields, $files, $form)
 {
     // all option fields are of type "money"
     $errors = array();
     /** Check the option values entered
      *  Appropriate values are required for the selected datatype
      *  Incomplete row checking is also required.
      */
     if (($form->_action & CRM_Core_Action::ADD || $form->_action & CRM_Core_Action::UPDATE) && $fields['html_type'] == 'Text') {
         if ($fields['price'] == NULL) {
             $errors['price'] = ts('Price is a required field');
         }
         if ($fields['financial_type_id'] == '') {
             $errors['financial_type_id'] = ts('Financial Type is a required field');
         } else {
             // CRM-16189
             try {
                 CRM_Financial_BAO_FinancialAccount::validateFinancialType($fields['financial_type_id'], $form->_sid);
             } catch (CRM_Core_Exception $e) {
                 $errors['financial_type_id'] = $e->getMessage();
             }
         }
     }
     //avoid the same price field label in Within PriceSet
     $priceFieldLabel = new CRM_Price_DAO_PriceField();
     $priceFieldLabel->label = $fields['label'];
     $priceFieldLabel->price_set_id = $form->_sid;
     $dupeLabel = FALSE;
     if ($priceFieldLabel->find(TRUE) && $form->_fid != $priceFieldLabel->id) {
         $dupeLabel = TRUE;
     }
     if ($dupeLabel) {
         $errors['label'] = ts('Name already exists in Database.');
     }
     if (is_numeric(CRM_Utils_Array::value('count', $fields)) && CRM_Utils_Array::value('count', $fields) == 0 && CRM_Utils_Array::value('html_type', $fields) == 'Text') {
         $errors['count'] = ts('Participant Count must be greater than zero.');
     }
     if ($form->_action & CRM_Core_Action::ADD) {
         if ($fields['html_type'] != 'Text') {
             $countemptyrows = 0;
             $_flagOption = $_rowError = 0;
             $_showHide = new CRM_Core_ShowHideBlocks('', '');
             for ($index = 1; $index <= self::NUM_OPTION; $index++) {
                 $noLabel = $noAmount = $noWeight = 1;
                 if (!empty($fields['option_label'][$index])) {
                     $noLabel = 0;
                     $duplicateIndex = CRM_Utils_Array::key($fields['option_label'][$index], $fields['option_label']);
                     if (!($duplicateIndex === FALSE) && !($duplicateIndex == $index)) {
                         $errors["option_label[{$index}]"] = ts('Duplicate label value');
                         $_flagOption = 1;
                     }
                 }
                 if ($form->_useForMember) {
                     if (!empty($fields['membership_type_id'][$index])) {
                         $memTypesIDS[] = $fields['membership_type_id'][$index];
                     }
                 }
                 // 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 && !empty($fields['option_financial_type_id']) && $fields['option_financial_type_id'][$index] == '' && $fields['html_type'] != 'Text') {
                     $errors["option_financial_type_id[{$index}]"] = ts('Financial Type is a Required field.');
                 }
                 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;
                 }
//.........这里部分代码省略.........
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:101,代码来源:Field.php

示例8: formRule

 /**
  * Global form rule.
  *
  * @param array $fields
  *   The input form values.
  * @param array $files
  *   The uploaded files if any.
  * @param array $options
  *   Additional user data.
  *
  * @return bool|array
  *   true if no errors, else array of errors
  */
 public static function formRule($fields, $files, $options)
 {
     $errors = array();
     $count = count(CRM_Utils_Array::value('extends', $fields));
     //price sets configured for membership
     if ($count && array_key_exists(CRM_Core_Component::getComponentID('CiviMember'), $fields['extends'])) {
         if ($count > 1) {
             $errors['extends'] = ts('If you plan on using this price set for membership signup and renewal, you can not also use it for Events or Contributions. However, a membership price set may include additional fields for non-membership options that require an additional fee (e.g. magazine subscription).');
         }
     }
     //checks the given price set doesnot start with digit
     $title = $fields['title'];
     // gives the ascii value
     $asciiValue = ord($title[0]);
     if ($asciiValue >= 48 && $asciiValue <= 57) {
         $errors['title'] = ts("Name cannot not start with a digit");
     }
     // CRM-16189
     if (!empty($fields['extends']) && (array_key_exists(CRM_Core_Component::getComponentID('CiviEvent'), $fields['extends']) || array_key_exists(CRM_Core_Component::getComponentID('CiviMember'), $fields['extends']))) {
         try {
             CRM_Financial_BAO_FinancialAccount::validateFinancialType($fields['financial_type_id']);
         } catch (CRM_Core_Exception $e) {
             $errors['financial_type_id'] = $e->getMessage();
         }
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:40,代码来源:Set.php

示例9: add

 /**
  * Add the membership types.
  *
  * @param array $params
  *   Reference array contains the values submitted by the form.
  * @param array $ids
  *   Array contains the id (deprecated).
  *
  *
  * @return object
  */
 public static function add(&$params, $ids = array())
 {
     $id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('membershipType', $ids));
     if (!$id) {
         if (!isset($params['is_active'])) {
             // do we need this?
             $params['is_active'] = FALSE;
         }
         if (!isset($params['domain_id'])) {
             $params['domain_id'] = CRM_Core_Config::domainID();
         }
     }
     // CRM-16189
     if (!empty($params['financial_type_id'])) {
         CRM_Financial_BAO_FinancialAccount::validateFinancialType($params['financial_type_id']);
     }
     // action is taken depending upon the mode
     $membershipType = new CRM_Member_DAO_MembershipType();
     $membershipType->copyValues($params);
     $membershipType->id = $id;
     // $previousID is the old organization id for membership type i.e 'member_of_contact_id'. This is used when an organization is changed.
     $previousID = NULL;
     if ($id) {
         $previousID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $id, 'member_of_contact_id');
     }
     $membershipType->save();
     if ($id) {
         // on update we may need to retrieve some details for the price field function - otherwise we get e-notices on attempts to retrieve
         // name etc - the presence of previous id tells us this is an update
         $params = array_merge(civicrm_api3('membership_type', 'getsingle', array('id' => $membershipType->id)), $params);
     }
     self::createMembershipPriceField($params, $previousID, $membershipType->id);
     // update all price field value for quick config when membership type is set CRM-11718
     if ($id) {
         self::updateAllPriceFieldValue($id, $params);
     }
     self::flush();
     return $membershipType;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:50,代码来源:MembershipType.php


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