[ Index ]
 

Code source de Mantis 1.1.0rc3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/ -> print_all_bug_page_excel.php (source)

   1  <?php
   2  # Mantis - a php based bugtracking system
   3  
   4  # Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
   5  # Copyright (C) 2002 - 2007  Mantis Team   - mantisbt-dev@lists.sourceforge.net
   6  
   7  # Mantis is free software: you can redistribute it and/or modify
   8  # it under the terms of the GNU General Public License as published by
   9  # the Free Software Foundation, either version 2 of the License, or
  10  # (at your option) any later version.
  11  #
  12  # Mantis is distributed in the hope that it will be useful,
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  # GNU General Public License for more details.
  16  #
  17  # You should have received a copy of the GNU General Public License
  18  # along with Mantis.  If not, see <http://www.gnu.org/licenses/>.
  19  
  20      # --------------------------------------------------------
  21      # $Id: print_all_bug_page_excel.php,v 1.56.2.1 2007-10-13 22:34:16 giallu Exp $
  22      # --------------------------------------------------------
  23  ?>
  24  <?php
  25      # Excel (97 and above) export page
  26      # The bugs displayed in print_all_bug_page.php are saved in a .xls file
  27      # The IE icon allows to see or directly print the same result
  28  ?>
  29  <?php
  30      require_once ( 'core.php' );
  31  
  32      $t_core_path = config_get( 'core_path' );
  33  
  34      require_once( $t_core_path.'current_user_api.php' );
  35      require_once( $t_core_path.'bug_api.php' );
  36      require_once( $t_core_path.'string_api.php' );
  37  ?>
  38  <?php require ( 'print_all_bug_options_inc.php' ) ?>
  39  <?php auth_ensure_user_authenticated() ?>
  40  <?php
  41      $f_type_page    = gpc_get_string( 'type_page', 'excel' );
  42      $f_search        = gpc_get_string( 'search', false ); # @@@ need a better default
  43      $f_offset        = gpc_get_int( 'offset', 0 );
  44      $f_export        = gpc_get_string( 'export' );
  45      $f_show_flag    = gpc_get_bool( 'show_flag' );
  46  
  47      helper_begin_long_process();
  48  
  49      # excel or html export
  50      if ( $f_type_page != 'html' ) {
  51          $t_export_title = helper_get_default_export_filename( '' );
  52          $t_export_title = ereg_replace( '[\/:*?"<>|]', '', $t_export_title );
  53  
  54          # Make sure that IE can download the attachments under https.
  55          header( 'Pragma: public' );
  56  
  57          header( 'Content-Type: application/vnd.ms-excel' );
  58  
  59                  if ( preg_match( "/MSIE/", $_SERVER["HTTP_USER_AGENT"] ) ) {
  60                          header( 'Content-Disposition: attachment; filename="' . urlencode( $t_export_title ) . '.xls"' ) ;
  61                  } else {
  62                          header( 'Content-Disposition: attachment; filename="' . $t_export_title . '.xls"' );
  63                  }
  64      }
  65  
  66      #settings for choosing the fields to print
  67      # get the fields list
  68      $t_field_name_arr = get_field_names();
  69  
  70      # This is where we used to do the entire actual filter ourselves
  71      $t_page_number = gpc_get_int( 'page_number', 1 );
  72      $t_per_page = -1;
  73      $t_bug_count = null;
  74      $t_page_count = null;
  75  
  76      $result = filter_get_bug_rows( $t_page_number, $t_per_page, $t_page_count, $t_bug_count );
  77      if ( $result === false ) {
  78          print_header_redirect( 'view_all_set.php?type=0&amp;print=1' );
  79      }
  80      $row_count = sizeof( $result );
  81  
  82      #settings for choosing the fields to print
  83      # get the fields list
  84      $t_field_name_arr = get_field_names();
  85      $field_name_count = count( $t_field_name_arr );
  86  
  87      # get printing preferences
  88      $t_user_id = auth_get_current_user_id();
  89      $t_user_print_pref_table = config_get( 'mantis_user_print_pref_table' );
  90      $query3 ="SELECT print_pref ".
  91              "FROM $t_user_print_pref_table ".
  92              "WHERE user_id='$t_user_id' ";
  93  
  94      $result3 = db_query( $query3 );
  95      $row = db_fetch_array( $result3 );
  96      $t_prefs = $row['print_pref'];
  97  ?>
  98  
  99  <html xmlns:o="urn:schemas-microsoft-com:office:office"
 100  xmlns:x="urn:schemas-microsoft-com:office:excel"
 101  xmlns="http://www.w3.org/TR/REC-html40">
 102  
 103  <?php html_page_top1() ?>
 104  <style id="Classeur1_16681_Styles">
 105  </style>
 106  
 107  <?php html_head_end() ?>
 108  <?php html_body_begin() ?>
 109  
 110  <div id="Classeur1_16681" align=center x:publishsource="Excel">
 111  
 112  <table x:str border=0 cellpadding=0 cellspacing=0 width=100% style='border-collapse:
 113   collapse'>
 114  
 115  <tr>
 116      <?php
 117          # titles desactivated for html pages
 118          if ( $f_type_page != 'html' ) {
 119              for ( $i=0 ; $i <$field_name_count ; $i++ ) {
 120                  if ( isset( $t_prefs[$i] ) && ( 1 == $t_prefs[$i] ) ) {  ?>
 121      <td class=xl2316681 style='border-left:none'><?php echo lang_get( $t_field_name_arr[$i] ) ?></td>
 122  <?php
 123                  } //if isset
 124              } //for
 125          } //if
 126  ?>
 127  </tr>
 128  
 129  <?php
 130      $field_name_count = $field_name_count;
 131  
 132      $f_bug_arr = explode_enum_string( $f_export );
 133  
 134      # @@debug var_dump($t_field_name_arr);
 135      for( $i=0; $i < $row_count; $i++ ) {
 136  
 137          # prefix bug data with v_
 138          extract( $result[$i], EXTR_PREFIX_ALL, 'v' );
 139  
 140          if ( in_array( $v_id, $f_bug_arr ) || ( $f_show_flag==0 ) ) {
 141              $t_last_updated = date( $g_short_date_format, $v_last_updated );
 142  
 143              # grab the bugnote count
 144              $bugnote_count = bug_get_bugnote_count( $v_id );
 145  
 146              # grab the project name
 147              $project_name = project_get_field( $v_project_id, 'name' );
 148  
 149              $t_bug_text_table = config_get( 'mantis_bug_text_table' );
 150              $query4 = "SELECT *
 151                  FROM $t_bug_text_table
 152                  WHERE id='$v_bug_text_id'";
 153              $result4 = db_query( $query4 );
 154              $row = db_fetch_array( $result4 );
 155              extract( $row, EXTR_PREFIX_ALL, 'v2' );
 156  
 157              $v_os                         = string_display( $v_os );
 158              $v_os_build                    = string_display( $v_os_build );
 159              $v_platform                    = string_display( $v_platform );
 160              $v_version                     = string_display( $v_version );
 161              $v_summary                     = string_display_links( $v_summary );
 162  
 163              # line feeds are desactivated in case of excel export, to avoid multiple lines
 164              if ( $f_type_page != 'html' ) {
 165                  $v2_description = stripslashes( htmlspecialchars( str_replace( '\n',' ',$v2_description ) ) );
 166                  $v2_steps_to_reproduce  = stripslashes( htmlspecialchars( str_replace( '\n',' ',$v2_steps_to_reproduce ) ) );
 167                  $v2_additional_information = stripslashes( htmlspecialchars( str_replace( '\n',' ',$v2_additional_information ) ) );
 168              } else {
 169                  $v2_description             = string_display_links( $v2_description );
 170                  $v2_steps_to_reproduce         = string_display_links( $v2_steps_to_reproduce );
 171                  $v2_additional_information     = string_display_links( $v2_additional_information );
 172              }
 173  
 174              # an index for incrementing the array position
 175              $name_index=0;
 176  
 177  ?>
 178  <tr>
 179      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 180      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 181      <?php echo $v_id;
 182            echo "</td>";
 183              }
 184      $name_index++;  ?>
 185  
 186      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 187      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 188      <?php echo $v_category;
 189            echo "</td>";
 190              }
 191      $name_index++;  ?>
 192  
 193      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 194      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 195      <?php echo get_enum_element( 'severity', $v_severity );
 196            echo "</td>";
 197              }
 198      $name_index++;  ?>
 199  
 200      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 201      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 202      <?php echo get_enum_element( 'reproducibility', $v_reproducibility );
 203            echo "</td>";
 204              }
 205      $name_index++;  ?>
 206  
 207      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 208      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 209      <?php echo date( config_get( 'normal_date_format' ), $v_date_submitted );
 210            echo "</td>";
 211              }
 212      $name_index++;  ?>
 213  
 214      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 215      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 216      <?php echo date( config_get( 'normal_date_format' ),$v_last_updated );
 217            echo "</td>";
 218              }
 219      $name_index++;  ?>
 220  
 221      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 222      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 223      <?php print_user_with_subject( $v_reporter_id, $v_id ) ;
 224            echo "</td>";
 225              }
 226      $name_index++;  ?>
 227  
 228      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 229      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 230      <?php      if ( access_has_bug_level( config_get( 'view_handler_threshold' ), $v_id ) ) {
 231                      print_user_with_subject( $v_handler_id, $v_id ); 
 232                  }
 233            echo "</td>";
 234              }
 235      $name_index++;  ?>
 236  
 237      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 238      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 239      <?php echo get_enum_element( 'priority', $v_priority );
 240            echo "</td>";
 241              }
 242      $name_index++;  ?>
 243  
 244      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 245      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 246      <?php echo get_enum_element( 'status', $v_status );
 247            echo "</td>";
 248              }
 249      $name_index++;  ?>
 250  
 251      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 252      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 253      <?php echo $v_build;
 254            echo "</td>";
 255              }
 256      $name_index++;  ?>
 257  
 258      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 259      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 260      <?php echo get_enum_element( 'projection', $v_projection );
 261            echo "</td>";
 262              }
 263      $name_index++;  ?>
 264  
 265      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 266      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 267      <?php echo get_enum_element( 'eta', $v_eta );
 268            echo "</td>";
 269              }
 270      $name_index++;  ?>
 271  
 272      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 273      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 274      <?php echo $v_platform;
 275            echo "</td>";
 276              }
 277      $name_index++;  ?>
 278  
 279      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 280      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 281      <?php echo $v_os;
 282            echo "</td>";
 283              }
 284      $name_index++;  ?>
 285  
 286      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 287      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 288      <?php echo $v_os_build;
 289            echo "</td>";
 290              }
 291      $name_index++;  ?>
 292  
 293      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 294      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 295      <?php echo $v_version;
 296            echo "</td>";
 297              }
 298      $name_index++;  ?>
 299  
 300      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 301      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 302      <?php echo get_enum_element( 'resolution', $v_resolution );
 303            echo "</td>";
 304              }
 305      $name_index++;  ?>
 306  
 307      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 308      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 309      <?php echo $v_duplicate_id;
 310            echo "</td>";
 311              }
 312      $name_index++;  ?>
 313  
 314      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 315      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 316      <?php echo $v_summary;
 317            echo "</td>";
 318              }
 319      $name_index++;  ?>
 320  
 321      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 322      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 323      <?php echo $v2_description ;
 324            echo "</td>";
 325              }
 326      $name_index++;  ?>
 327  
 328      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 329      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 330      <?php echo $v2_steps_to_reproduce;
 331            echo "</td>";
 332              }
 333      $name_index++;  ?>
 334  
 335      <?php if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 336      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 337      <?php echo $v2_additional_information;
 338            echo "</td>";
 339              }
 340      $name_index++;  ?>
 341  
 342  <?php
 343      if ( ( $name_index < $field_name_count ) && ( !isset( $t_prefs[$name_index] ) || ( 1 == $t_prefs[$name_index] ) ) ) { ?>
 344      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 345  <?php
 346              $t_file_table = config_get( 'mantis_bug_file_table' );
 347              $query5 = "SELECT filename, filesize, date_added
 348                      FROM $t_file_table
 349                      WHERE bug_id='$v_id'";
 350              $result5 = db_query( $query5 );
 351              $num_files = db_num_rows( $result5 );
 352              for ( $j=0;$j<$num_files;$j++ ) {
 353                  $row = db_fetch_array( $result5 );
 354                  extract( $row, EXTR_PREFIX_ALL, 'v2' );
 355                  $v2_filesize = round( $v2_filesize / 1024 );
 356                  $v2_date_added = date( config_get( 'normal_date_format' ), db_unixtimestamp( $v2_date_added ) );
 357                  echo "$v2_filename ($v2_filesize KB) $v2_date_added";
 358  
 359                  if ( $j != ( $num_files - 1 ) &&  ( $f_type_page == 'html' ) ) {
 360                      PRINT '<br />';
 361                  }
 362                  else {
 363                      PRINT ' ';
 364                  } #if
 365              } #for loop
 366  
 367              echo "</td>";
 368          }# if index
 369      $name_index++;
 370  ?>
 371  <?php # Bugnotes BEGIN (3 rows) ?>
 372  <td colspan="3">
 373  <?php  # print bugnotes
 374          # get the bugnote data
 375           if ( !access_has_bug_level( config_get( 'private_bugnote_threshold' ), $v_id ) ) {
 376               $t_restriction = 'AND view_state=' . VS_PUBLIC;
 377           } else {
 378               $t_restriction = '';
 379           }
 380  
 381          $t_bugnote_table        = config_get( 'mantis_bugnote_table' );
 382          $t_bugnote_text_table    = config_get( 'mantis_bugnote_text_table' );
 383          $t_bugnote_order = current_user_get_pref( 'bugnote_order' );
 384  
 385          $query6 = "SELECT *
 386                  FROM $t_bugnote_table
 387                  WHERE bug_id='$v_id' $t_restriction
 388                  ORDER BY date_submitted $t_bugnote_order";
 389          $result6 = db_query( $query6 );
 390          $num_notes = db_num_rows( $result6 );
 391  
 392          # save the index, and use an own bugnote_index
 393          $bugnote_index = $name_index ;
 394  
 395          for ( $k=0; $k < $num_notes; $k++ ) {
 396              # prefix all bugnote data with v3_
 397              $row = db_fetch_array( $result6 );
 398              extract( $row, EXTR_PREFIX_ALL, 'v3' );
 399              $v3_date_submitted = date( config_get( 'normal_date_format' ), ( db_unixtimestamp( $v3_date_submitted ) ) );
 400  
 401              # grab the bugnote text and id and prefix with v3_
 402              $query6 = "SELECT note, id
 403                      FROM $t_bugnote_text_table
 404                      WHERE id='$v3_bugnote_text_id'";
 405              $result7 = db_query( $query6 );
 406              $v3_note = db_result( $result7, 0, 0 );
 407              $v3_bugnote_text_id = db_result( $result7, 0, 1 );
 408              $t_note = '';
 409  
 410              switch ( $v3_note_type ) {
 411                  case REMINDER:
 412                      $t_note .= lang_get( 'reminder_sent_to' ) . ': ';
 413                      $v3_note_attr = substr( $v3_note_attr, 1, strlen( $v3_note_attr ) - 2 );
 414                      $t_to = array();
 415                      foreach ( explode( '|', $v3_note_attr ) as $t_recipient ) {
 416                          $t_to[] = prepare_user_name( $t_recipient );
 417                      }
 418                      $t_note .=  implode( ', ', $t_to ) . '|';
 419                  default:
 420                      $t_note .=  $v3_note;
 421              }
 422              if ( $f_type_page != 'html' ) {
 423                  $v3_note = stripslashes( str_replace( '\n','|',$t_note ));
 424              } else {
 425                  $v3_note = string_display_links( $t_note );
 426              }
 427      ?>
 428  <table>
 429  <tr>
 430      <?php if ( ( $bugnote_index < $field_name_count ) && ( !isset( $t_prefs[$bugnote_index] )||( 1 == $t_prefs[$bugnote_index] ) ) ) { ?>
 431      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 432      <?php print_user( $v3_reporter_id ) ;
 433            echo "</td>";
 434              }
 435      $bugnote_index++;  ?>
 436  
 437      <?php if ( ( $bugnote_index < $field_name_count ) && ( !isset( $t_prefs[$bugnote_index] )||( 1 == $t_prefs[$bugnote_index] ) ) ) { ?>
 438      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 439      <?php echo $v3_date_submitted;
 440            echo "</td>";
 441              }
 442      $bugnote_index++;  ?>
 443  
 444      <?php if ( ( $bugnote_index < $field_name_count ) && ( !isset( $t_prefs[$bugnote_index] )||( 1 == $t_prefs[$bugnote_index] ) ) ) { ?>
 445      <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
 446      <?php echo $v3_note;
 447            echo "</td>";
 448              }
 449      $bugnote_index++;  ?>
 450  </tr>
 451  </table>
 452      <?php
 453          # get back
 454          $bugnote_index = $name_index ;
 455              } # end for bugnote
 456      ?>
 457  <?php # Bugnotes END ?>
 458  
 459  </tr>
 460  <?php
 461          } #in_array
 462  } #for loop
 463  ?>
 464  </table>
 465  </div>


Généré le : Thu Nov 29 09:42:17 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics