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

Custom exports

From Group-Office Groupware and CRM Documentation
Revision as of 15:38, 18 February 2010 by Admin (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Create a file in the folder:

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

/**
 * Example override for a custom export
 *
 * We'll base this export on the CSV export so include it.
 */
require_once($GO_CONFIG->class_path.'export/csv_export_query.class.inc.php');

class custom_export_query extends csv_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(){
		$customfield = $this->cf->find_first_field_by_name(7, 'Some custom field');
		
		$this->columns=array('order_id','btime','customer_name', 'col_'.$customfield['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.