+ }
+
+ function toCsv($data, $cols, $titles, $filename, $addDate = true)
+ {
+ $this->sessionState(0); // turn off sessions - no locking..
+
+ require_once 'Pman/Core/SimpleExcel.php';
+
+ $fn = (empty($filename) ? 'list-export-' : urlencode($filename)) . (($addDate) ? date('Y-m-d') : '') ;
+
+
+ $se_config= array(
+ 'workbook' => substr($fn, 0, 31),
+ 'cols' => array(),
+ 'leave_open' => true
+ );
+
+
+ $se = false;
+ if (is_object($data)) {
+ $rooar = method_exists($data, 'toRooArray');
+ while($data->fetch()) {
+ $x = $rooar ? $data->toRooArray($q) : $data->toArray();
+
+
+ if ($cols == '*') { /// did we get cols sent to us?
+ $cols = array_keys($x);
+ }
+ if ($titles== '*') {
+ $titles= array_keys($x);
+ }
+ if ($titles !== false) {
+
+ foreach($cols as $i=>$col) {
+ $se_config['cols'][] = array(
+ 'header'=> isset($titles[$i]) ? $titles[$i] : $col,
+ 'dataIndex'=> $col,
+ 'width'=> 100
+ );
+ $se = new Pman_Core_SimpleExcel(array(), $se_config);