This manual is deprecated. Please visit https://groupoffice.readthedocs.io for the latest documentation.

Difference between revisions of "Custom exports"

From Group-Office Groupware and CRM Documentation
Jump to: navigation, search
(New page: Create a file in the folder: $config['file_storage_path']/customexports/mycustomexport.class.inc.php <pre> * * Example override for a custom export: class custom_export_query exten...)
 
Line 10: Line 10:
 
{
 
{
 
var $query='orders';
 
var $query='orders';
var $name='OSF gastouders';
+
var $name='My custom export';
  
 
/**
 
/**

Revision as of 10:51, 4 December 2009

Create a file in the folder:

$config['file_storage_path']/customexports/mycustomexport.class.inc.php

/**
 * Example override for a custom export
 */
class custom_export_query extends export_query
{
	var $query='orders';
	var $name='My custom export';

	/**
	 * Optionally hardcode the list and text separator in the constructor
	 */
	function __construct()
	{
		parent::__construct();

		$this->list_separator="\t";
		$this->text_separator='';
	}
	
	/**
	 * Format the raw database record.
	 */

	function format_record(&$record){
		$record['veld6']='T';
		$record['veld8']='False';
		$record['btime']=date('d/m/Y', $record['btime']);
	}
	
	/**
	 * Initialize the columns.
	 * Some example custom fields are used here
	 */

	function init_columns(){
		$crediteurnummer = $this->cf->find_first_field_by_name(7, 'Crediteurnummer');
		$tegenrekening = $this->cf->find_first_field_by_name(7, 'Tegenrekening');

		$this->columns=array('order_id','btime','customer_name', 'col_'.$crediteurnummer['id'],'col_'.$tegenrekening['id'],'veld6', 'total', 'veld8');
		$this->headers=array();
	}
}

Now in the billing module you will have this custom CSV export available.

It's for the billing module because the query is set to 'orders':

var $query='orders';

You can also use contacts, companies, tickets, log etc.