+
+ // getReportOptions - returns an array of report options constructed from session bean.
+ //
+ // Note: similarly to ttFavReportHelper::getReportOptions, this function is a part of
+ // refactoring to simplify maintenance of report generating functions, as we currently
+ // have 2 sets: normal reporting (from bean), and fav report emailing (from db fields).
+ // Using options obtained from either db or bean shall allow us to use only one set of functions.
+ static function getReportOptions($bean) {
+ global $user;
+
+ // Prepare an array of report options.
+ $options = array();
+
+ // Construct one by one.
+ $options['name'] = null; // No name required.
+ $options['user_id'] = $user->id; // Not sure if we need user_id here. Fav reports use it to recycle $user object in cron.php.
+ $options['client_id'] = $bean->getAttribute('client');
+ $options['cf_1_option_id'] = $bean->getAttribute('option');
+ $options['project_id'] = $bean->getAttribute('project');
+ $options['task_id'] = $bean->getAttribute('task');
+ $options['billable'] = $bean->getAttribute('include_records');
+ $options['invoice'] = $bean->getAttribute('invoice');
+ $options['paid_status'] = $bean->getAttribute('paid_status');
+
+/*
+ * TODO: remaining fields to fill in...
+ `users` text default NULL, # Comma-separated list of user ids. Nothing here means "all" users.
+ `period` tinyint(4) default NULL, # selected period type for report
+ `period_start` date default NULL, # period start
+ `period_end` date default NULL, # period end
+ `show_client` tinyint(4) NOT NULL default 0, # whether to show client column
+ `show_invoice` tinyint(4) NOT NULL default 0, # whether to show invoice column
+ `show_paid` tinyint(4) NOT NULL default 0, # whether to show paid column
+ `show_ip` tinyint(4) NOT NULL default 0, # whether to show ip column
+ `show_project` tinyint(4) NOT NULL default 0, # whether to show project column
+ `show_start` tinyint(4) NOT NULL default 0, # whether to show start field
+ `show_duration` tinyint(4) NOT NULL default 0, # whether to show duration field
+ `show_cost` tinyint(4) NOT NULL default 0, # whether to show cost field
+ `show_task` tinyint(4) NOT NULL default 0, # whether to show task column
+ `show_end` tinyint(4) NOT NULL default 0, # whether to show end field
+ `show_note` tinyint(4) NOT NULL default 0, # whether to show note column
+ `show_custom_field_1` tinyint(4) NOT NULL default 0, # whether to show custom field 1
+ `show_work_units` tinyint(4) NOT NULL default 0, # whether to show work units
+ `show_totals_only` tinyint(4) NOT NULL default 0, # whether to show totals only
+ `group_by` varchar(20) default NULL, # group by field
+ `status` tinyint(4) default 1, # favorite report status
+ PRIMARY KEY (`id`)
+);
+ */
+ return $options;
+ }