Ejemplo n.º 1
0
             case 'xlsx':
                 $oPage = new ajax_page("");
                 $oPage->SetContentType('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
                 $oPage->SetContentDisposition('attachment', $sClassDisplayName . '.xlsx');
                 require_once APPROOT . '/application/excelexporter.class.inc.php';
                 $writer = new XLSXWriter();
                 $writer->setAuthor(UserRights::GetUserFriendlyName());
                 $aHeaders = array(0 => explode(',', $sResult));
                 // comma is the default separator
                 $writer->writeSheet($aHeaders, $sClassDisplayName, array());
                 $oPage->add($writer->writeToString());
                 break;
             case 'csv':
             default:
                 $oPage = new CSVPage("");
                 $oPage->add_header("Content-type: text/csv; charset=utf-8");
                 $oPage->add_header("Content-disposition: attachment; filename=\"{$sClassDisplayName}.csv\"");
                 $oPage->no_cache();
                 $oPage->add($sResult);
         }
     } else {
         $oPage = new ajax_page("");
         $oPage->no_cache();
         $oPage->add('<p style="text-align:center">');
         $oPage->add('<div style="display:inline-block;margin:0.5em;"><a style="text-decoration:none" href="' . utils::GetAbsoluteUrlAppRoot() . 'pages/ajax.csvimport.php?operation=get_csv_template&disposition=attachment&class_name=' . $sClassName . '"><img border="0" src="../images/csv.png"><br/>' . $sClassDisplayName . '.csv</a></div>');
         $oPage->add('<div style="display:inline-block;margin:0.5em;"><a style="text-decoration:none" href="' . utils::GetAbsoluteUrlAppRoot() . 'pages/ajax.csvimport.php?operation=get_csv_template&disposition=attachment&format=xlsx&class_name=' . $sClassName . '"><img border="0" src="../images/xlsx.png"><br/>' . $sClassDisplayName . '.xlsx</a></div>');
         $oPage->add('</p>');
         $oPage->add('<p><textarea rows="5" cols="100">' . $sResult . '</textarea></p>');
     }
 } else {
     $oPage = new ajax_page("Class {$sClassName} is not a valid class !");
Ejemplo n.º 2
0
 $oAuditRule = MetaModel::GetObject('AuditRule', $iRuleIndex);
 $sFileName = utils::ReadParam('filename', null, true, 'string');
 $bAdvanced = utils::ReadParam('advanced', false);
 $sAdvanced = $bAdvanced ? '&advanced=1' : '';
 if ($sFileName != null) {
     $oP = new CSVPage("iTop - Export");
     $sCharset = MetaModel::GetConfig()->Get('csv_file_default_charset');
     $sCSVData = cmdbAbstractObject::GetSetAsCSV($oErrorObjectSet, array('localize_values' => true, 'fields_advanced' => $bAdvanced), $sCharset);
     if ($sCharset == 'UTF-8') {
         $sOutputData = UTF8_BOM . $sCSVData;
     } else {
         $sOutputData = $sCSVData;
     }
     if ($sFileName == '') {
         // Plain text => Firefox will NOT propose to download the file
         $oP->add_header("Content-type: text/plain; charset={$sCharset}");
     } else {
         $oP->add_header("Content-type: text/csv; charset={$sCharset}");
     }
     $oP->add($sOutputData);
     $oP->TrashUnexpectedOutput();
     $oP->output();
     exit;
 } else {
     $oP->add('<div class="page_header"><h1>Audit Errors: <span class="hilite">' . $oAuditRule->Get('description') . '</span></h1><img style="margin-top: -20px; margin-right: 10px; float: right;" src="../images/stop.png"/></div>');
     $oP->p('<a href="./audit.php?' . $oAppContext->GetForLink() . '">[Back to audit results]</a>');
     $sBlockId = 'audit_errors';
     $oP->p("<div id=\"{$sBlockId}\" style=\"clear:both\">\n");
     $oBlock = DisplayBlock::FromObjectSet($oErrorObjectSet, 'csv');
     $oBlock->Display($oP, 1);
     $oP->p("</div>\n");