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
Line 1: | Line 1: | ||
Create a file in the folder: | Create a file in the folder: | ||
− | $config['file_storage_path'] | + | $config['file_storage_path'] customexports/mycustomexport.class.inc.php |
<pre> | <pre> | ||
/** | /** | ||
* Example override for a custom export | * Example override for a custom export | ||
+ | * | ||
+ | * We'll base this export on the CSV export so include it. | ||
*/ | */ | ||
− | class custom_export_query extends | + | 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 $query='orders'; | ||
Line 22: | Line 26: | ||
$this->text_separator=''; | $this->text_separator=''; | ||
} | } | ||
− | + | ||
/** | /** | ||
* Format the raw database record. | * Format the raw database record. | ||
Line 32: | Line 36: | ||
$record['btime']=date('d/m/Y', $record['btime']); | $record['btime']=date('d/m/Y', $record['btime']); | ||
} | } | ||
− | + | ||
/** | /** | ||
* Initialize the columns. | * Initialize the columns. | ||
Line 39: | Line 43: | ||
function init_columns(){ | 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->columns=array('order_id','btime','customer_name', 'col_'.$ | + | |
$this->headers=array(); | $this->headers=array(); | ||
} | } |
Latest revision as of 15:38, 18 February 2010
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.