示例#1
0
 /**
  * Function to copy discount codes
  *
  * @param  int  $itemID     ID of the discount code to be copied.
  *
  * @access public
  * @static
  * @return true on success else false
  */
 static function copy($itemID, $params, $newCode)
 {
     $item = new CRM_CiviDiscount_DAO_Item();
     $item->id = $itemID;
     if ($item->find(TRUE)) {
         unset($item->id);
         $item->count_use = 0;
         $item->code = $newCode;
         if (isset($item->description) && $item->description != '') {
             $item->description = 'Copy of ' . $item->description;
         }
         CRM_Utils_Hook::pre('create', 'CiviDiscount', null, $params);
         $item->save();
         CRM_Utils_Hook::post('create', 'CiviDiscount', $item->id, $item);
         return TRUE;
     }
     return FALSE;
 }
示例#2
0
 /**
  * returns the list of fields that can be exported
  *
  * @access public
  * return array
  */
 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['ount_item'] =& $fields[$name];
                 } else {
                     self::$_export[$name] =& $fields[$name];
                 }
             }
         }
     }
     return self::$_export;
 }