/**
  * @param array  $params         (reference ) an assoc array of name/value pairs
  *
  * @return object       CRM_Core_BAO_SEPACreditor object on success, null otherwise
  * @access public
  * @static
  */
 static function add(&$params)
 {
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, 'SepaCreditor', CRM_Utils_Array::value('id', $params), $params);
     $dao = new CRM_Sepa_DAO_SEPACreditor();
     $dao->copyValues($params);
     $dao->save();
     CRM_Utils_Hook::post($hook, 'SepaCreditor', $dao->id, $dao);
     return $dao;
 }
 /**
  * returns the list of fields that can be exported
  *
  * @access public
  * return array
  * @static
  */
 static function &export($prefix = false)
 {
     if (!self::$_export) {
         self::$_export = array();
         $fields = self::fields();
         foreach ($fields as $name => $field) {
             if (CRM_Utils_Array::value('export', $field)) {
                 if ($prefix) {
                     self::$_export['sdd_creditor'] =& $fields[$name];
                 } else {
                     self::$_export[$name] =& $fields[$name];
                 }
             }
         }
         self::$_export = array_merge(self::$_export, CRM_Core_DAO_Country::export(true));
     }
     return self::$_export;
 }
 /**
  * Reads the default creditor from the settings
  * Will only return a creditor if it exists and if it's active
  * 
  * @return CRM_Sepa_BAO_SEPACreditor object or NULL
  */
 static function defaultCreditor()
 {
     $default_creditor_id = (int) CRM_Sepa_Logic_Settings::getSetting('batching_default_creditor');
     if (empty($default_creditor_id)) {
         return NULL;
     }
     $default_creditor = new CRM_Sepa_DAO_SEPACreditor();
     $default_creditor->get('id', $default_creditor_id);
     if (empty($default_creditor->mandate_active)) {
         return NULL;
     } else {
         return $default_creditor;
     }
 }