[3526] | 1 | <?php |
---|
| 2 | /** |
---|
| 3 | * eGroupWare |
---|
| 4 | * |
---|
| 5 | * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
---|
| 6 | * @package timesheet |
---|
| 7 | * @subpackage importexport |
---|
| 8 | * @link http://www.egroupware.org |
---|
| 9 | * @author Knut Moeller <k.moeller@metaways.de> |
---|
| 10 | * @copyright Knut Moeller <k.moeller@metaways.de> |
---|
| 11 | * @version $Id: $ |
---|
| 12 | */ |
---|
| 13 | |
---|
| 14 | require_once(PHPGW_INCLUDE_ROOT. '/etemplate/inc/class.etemplate.inc.php'); |
---|
| 15 | require_once(PHPGW_INCLUDE_ROOT. '/importexport/inc/class.export_csv.inc.php'); |
---|
| 16 | require_once(PHPGW_INCLUDE_ROOT. '/importexport/inc/class.iface_export_plugin.inc.php'); |
---|
| 17 | require_once(PHPGW_INCLUDE_ROOT. '/timesheet/inc/class.phpgw_timesheet_record.inc.php'); |
---|
| 18 | require_once(PHPGW_INCLUDE_ROOT. '/timesheet/inc/class.uitimesheet.inc.php'); |
---|
| 19 | |
---|
| 20 | /** |
---|
| 21 | * export plugin of addressbook |
---|
| 22 | */ |
---|
| 23 | class export_timesheet_csv implements iface_export_plugin { |
---|
| 24 | |
---|
| 25 | /** |
---|
| 26 | * Exports records as defined in $_definition |
---|
| 27 | * |
---|
| 28 | * @param phpgw_record $_definition |
---|
| 29 | */ |
---|
| 30 | public static function export( $_stream, $_charset, definition $_definition) { |
---|
| 31 | $options = $_definition->options; |
---|
| 32 | |
---|
| 33 | $uitimesheet = new uitimesheet(); |
---|
| 34 | $selection = array(); |
---|
| 35 | |
---|
| 36 | $query = $GLOBALS['phpgw']->session->appsession('index',TIMESHEET_APP); |
---|
| 37 | $query['num_rows'] = -1; // all |
---|
| 38 | |
---|
| 39 | $uitimesheet->get_rows($query,$selection,$readonlys,true); // true = only return the id's |
---|
| 40 | |
---|
| 41 | $options['begin_with_fieldnames'] = true; |
---|
| 42 | $export_object = new export_csv($_stream, $charset, (array)$options); |
---|
| 43 | |
---|
| 44 | // $options['selection'] is array of identifiers as this plugin doesn't |
---|
| 45 | // support other selectors atm. |
---|
| 46 | foreach ($selection as $identifier) { |
---|
| 47 | $timesheetentry = new phpgw_timesheet_record($identifier); |
---|
| 48 | $export_object->export_record($timesheetentry); |
---|
| 49 | unset($timesheetentry); |
---|
| 50 | } |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | /** |
---|
| 54 | * returns translated name of plugin |
---|
| 55 | * |
---|
| 56 | * @return string name |
---|
| 57 | */ |
---|
| 58 | public static function get_name() { |
---|
| 59 | return lang('Timesheet CSV export'); |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | /** |
---|
| 63 | * returns translated (user) description of plugin |
---|
| 64 | * |
---|
| 65 | * @return string descriprion |
---|
| 66 | */ |
---|
| 67 | public static function get_description() { |
---|
| 68 | return lang("Exports entries from your Timesheet into a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators."); |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | /** |
---|
| 72 | * returns file suffix for exported file |
---|
| 73 | * |
---|
| 74 | * @return string suffix |
---|
| 75 | */ |
---|
| 76 | public static function get_filesuffix() { |
---|
| 77 | return 'csv'; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | /** |
---|
| 81 | * return html for options. |
---|
| 82 | * this way the plugin has all opportunities for options tab |
---|
| 83 | * |
---|
| 84 | * @return string html |
---|
| 85 | */ |
---|
| 86 | public static function get_options_etpl() { |
---|
| 87 | return 'timesheet.export_csv_options'; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | /** |
---|
| 91 | * returns slectors of this plugin via xajax |
---|
| 92 | * |
---|
| 93 | */ |
---|
| 94 | public static function get_selectors_etpl() { |
---|
| 95 | return '<b>Selectors:</b>'; |
---|
| 96 | } |
---|
| 97 | } |
---|