/**
  * Retrive the all values for given field id
  *
  * @param int $fieldId price_field_id
  * @param array $values (reference ) to hold the values
  * @param string $orderBy for order by, default weight
  * @param int $isActive is_active, default false
  *
  * @return array $values
  *
  * @access public
  * @static
  */
 static function getValues($fieldId, &$values, $orderBy = 'weight', $isActive = FALSE)
 {
     $fieldValueDAO = new CRM_Price_DAO_PriceFieldValue();
     $fieldValueDAO->price_field_id = $fieldId;
     $fieldValueDAO->orderBy($orderBy, 'label');
     if ($isActive) {
         $fieldValueDAO->is_active = 1;
     }
     $fieldValueDAO->find();
     while ($fieldValueDAO->fetch()) {
         CRM_Core_DAO::storeValues($fieldValueDAO, $values[$fieldValueDAO->id]);
     }
     return $values;
 }
Exemplo n.º 2
0
 /**
  * Retrive the all values for given field id.
  *
  * @param int $fieldId
  *   Price_field_id.
  * @param array $values
  *   (reference ) to hold the values.
  * @param string $orderBy
  *   For order by, default weight.
  * @param bool|int $isActive is_active, default false
  *
  * @return array
  *
  */
 public static function getValues($fieldId, &$values, $orderBy = 'weight', $isActive = FALSE)
 {
     $sql = "SELECT cs.id FROM civicrm_price_set cs INNER JOIN civicrm_price_field cp ON cp.price_set_id = cs.id \n              WHERE cs.name IN ('default_contribution_amount', 'default_membership_type_amount') AND cp.id = {$fieldId} ";
     $setId = CRM_Core_DAO::singleValueQuery($sql);
     $fieldValueDAO = new CRM_Price_DAO_PriceFieldValue();
     $fieldValueDAO->price_field_id = $fieldId;
     if (!$setId) {
         CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes);
         $addWhere = "financial_type_id IN (0)";
         if (!empty($financialTypes)) {
             $addWhere = "financial_type_id IN (" . implode(',', array_keys($financialTypes)) . ")";
         }
         $fieldValueDAO->whereAdd($addWhere);
     }
     $fieldValueDAO->orderBy($orderBy, 'label');
     if ($isActive) {
         $fieldValueDAO->is_active = 1;
     }
     $fieldValueDAO->find();
     while ($fieldValueDAO->fetch()) {
         CRM_Core_DAO::storeValues($fieldValueDAO, $values[$fieldValueDAO->id]);
     }
     return $values;
 }