1<?php 2# MantisBT - A PHP based bugtracking system 3 4# MantisBT is free software: you can redistribute it and/or modify 5# it under the terms of the GNU General Public License as published by 6# the Free Software Foundation, either version 2 of the License, or 7# (at your option) any later version. 8# 9# MantisBT is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with MantisBT. If not, see <http://www.gnu.org/licenses/>. 16 17/** 18 * Excel (2003 SP2 and above) export page for billing information 19 * 20 * @package MantisBT 21 * @copyright Copyright 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 22 * @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net 23 * @link http://www.mantisbt.org 24 * 25 * @uses core.php 26 * @uses billing_api.php 27 * @uses bug_api.php 28 * @uses excel_api.php 29 */ 30 31require_once( 'core.php' ); 32require_api( 'billing_api.php' ); 33require_api( 'bug_api.php' ); 34require_api( 'excel_api.php' ); 35 36helper_begin_long_process(); 37 38$t_filename = excel_get_default_filename(); 39$t_date_format = config_get( 'normal_date_format' ); 40 41$f_project_id = gpc_get_int( 'project_id' ); 42$f_cost = gpc_get_int( 'cost' ); 43$f_from = gpc_get_string( 'from' ); 44$f_to = gpc_get_string( 'to' ); 45$f_include_subprojects = gpc_get_bool( 'include_subprojects' ); 46 47billing_ensure_reporting_access( $f_project_id ); 48 49$t_show_cost = ON == config_get( 'time_tracking_with_billing' ) && $f_cost != 0; 50 51$t_billing_rows = billing_get_for_project( $f_project_id, $f_from, $f_to, $f_cost, $f_include_subprojects ); 52 53header( 'Content-Type: application/vnd.ms-excel; charset=UTF-8' ); 54header( 'Pragma: public' ); 55header( 'Content-Disposition: attachment; filename="' . urlencode( file_clean_name( $t_filename ) ) . '.xml"' ) ; 56 57echo excel_get_header( $t_filename ); 58echo excel_get_start_row(); 59echo excel_format_column_title( lang_get( 'issue_id' ) ); 60echo excel_format_column_title( lang_get( 'project_name' ) ); 61echo excel_format_column_title( lang_get( 'category' ) ); 62echo excel_format_column_title( lang_get( 'summary' ) ); 63echo excel_format_column_title( lang_get( 'username' ) ); 64echo excel_format_column_title( lang_get( 'timestamp' ) ); 65echo excel_format_column_title( lang_get( 'minutes' ) ); 66echo excel_format_column_title( lang_get( 'time_tracking_time_spent' ) ); 67 68if( $t_show_cost ) { 69 echo excel_format_column_title( 'cost' ); 70} 71 72echo excel_format_column_title( 'note' ); 73echo '</Row>'; 74 75foreach( $t_billing_rows as $t_billing ) { 76 echo "\n<Row>\n"; 77 echo excel_prepare_number( $t_billing['bug_id'] ); 78 echo excel_prepare_string( $t_billing['project_name'] ); 79 echo excel_prepare_string( $t_billing['bug_category'] ); 80 echo excel_prepare_string( $t_billing['bug_summary'] ); 81 echo excel_prepare_string( $t_billing['reporter_name'] ); 82 echo excel_prepare_string( date( $t_date_format, $t_billing['date_submitted'] ) ); 83 echo excel_prepare_number( $t_billing['minutes'] ); 84 echo excel_prepare_string( $t_billing['duration'] ); 85 86 if( $t_show_cost ) { 87 echo excel_prepare_string( $t_billing['cost'] ); 88 } 89 90 echo excel_prepare_string( $t_billing['note'] ); 91 echo "</Row>\n"; 92} 93 94echo excel_get_footer(); 95 96