var $debugEnabled = true; // disable this for public versions of this code.
+ var $do = false; // the dataobject being worked on..
+
function getAuth()
{
parent::getAuth(); // load company!
* toRooArray($request) : array
* - called if singleArray is unavailable on single fetch.
* - always tried for mutiple results.
- * toArray() - the default method if none of the others are found.
+ * toArray() - the default method if none of the others are found.
+ * toSimpleExcelColumn($col) - see toCSV - this enables special columns to be created for exported data.
*
* autoJoin($request)
* - standard DataObject feature - causes all results to show all
$this->toCsv($ret, $_REQUEST['csvCols'], $_REQUEST['csvTitles'],
- empty($_REQUEST['csvFilename']) ? '' : $_REQUEST['csvFilename']
- );
+ empty($_REQUEST['csvFilename']) ? '' : $_REQUEST['csvFilename'] );
function toCsv($data, $cols, $titles, $filename, $addDate = true)
{
-
+ // die('here');
$this->sessionState(0); // turn off sessions - no locking..
require_once 'Pman/Core/SimpleExcel.php';
$titles = explode(',', $titles);
}
foreach($cols as $i=>$col) {
- $se_config['cols'][] = array(
+ $add = array(
'header'=> isset($titles[$i]) ? $titles[$i] : $col,
'dataIndex'=> $col,
'width'=> 100,
// 'color' => 'yellow', // set color for the cell which is a header element
// 'fillBlank' => 'gray', // set
);
- $se = new Pman_Core_SimpleExcel(array(), $se_config);
+ //die('here');
+ if (method_exists($data, 'toSimpleExcelColumn')) {
+ $add = $data->toSimpleExcelColumn($add);
+ }
+
+ $se_config['cols'][] = $add;
+
}
+ $se = new Pman_Core_SimpleExcel(array(), $se_config);
$titles = false;
}
}
-
- foreach($data as $x) {
+ foreach($data as $x) {
//echo "<PRE>"; print_r(array($_REQUEST['csvCols'], $x->toArray())); exit;
$line = array();
}
foreach($cols as $i=>$col) {
- $se_config['cols'][] = array(
+ $add = array(
'header'=> isset($titles[$i]) ? $titles[$i] : $col,
'dataIndex'=> $col,
'width'=> 100,
// 'color' => 'yellow', // set color for the cell which is a header element
// 'fillBlank' => 'gray', // set
);
- $se = new Pman_Core_SimpleExcel(array(),$se_config);
+ //die('here');
+ if (method_exists($this->do, 'toSimpleExcelColumn')) {
+ $add = $this->do->toSimpleExcelColumn($add);
+ }
+
+ $se_config['cols'][] = $add;
+
}
-
+ $se = new Pman_Core_SimpleExcel(array(),$se_config);
+
//fputcsv($fh, $titles);
$titles = false;
if (!is_a($x, 'DB_DataObject') && !is_a($x, 'PDO_DataObject')) {
$this->jerr('invalid url - no dataobject');
}
-
+ $this->do = $x;
return $x;
}