Пример #1
0
     $oPage->add('</div>');
     $aLabels = array('dialog_title' => Dict::S('ExcelExporter:ExportDialogTitle'), 'cancel_button' => Dict::S('UI:Button:Cancel'), 'export_button' => Dict::S('ExcelExporter:ExportButton'), 'download_button' => Dict::Format('ExcelExporter:DownloadButton', 'export.xlsx'));
     $sJSLabels = json_encode($aLabels);
     $sFilter = addslashes($sFilter);
     $sJSPageUrl = addslashes(utils::GetAbsoluteUrlAppRoot() . 'pages/ajax.render.php');
     $oPage->add_ready_script("\$('#XlsxExportDlg').xlsxexporter({filter: '{$sFilter}', labels: {$sJSLabels}, ajax_page_url: '{$sJSPageUrl}'});");
     break;
 case 'xlsx_start':
     $sFilter = utils::ReadParam('filter', '', false, 'raw_data');
     $bAdvanced = utils::ReadParam('advanced', 'false') == 'true';
     $oSearch = DBObjectSearch::unserialize($sFilter);
     $oExcelExporter = new ExcelExporter();
     $oExcelExporter->SetObjectList($oSearch);
     //$oExcelExporter->SetChunkSize(10); //Only for testing
     $oExcelExporter->SetAdvancedMode($bAdvanced);
     $sToken = $oExcelExporter->SaveState();
     $oPage->add(json_encode(array('status' => 'ok', 'token' => $sToken)));
     break;
 case 'xlsx_run':
     $sMemoryLimit = MetaModel::GetConfig()->Get('xlsx_exporter_memory_limit');
     ini_set('memory_limit', $sMemoryLimit);
     ini_set('max_execution_time', max(300, ini_get('max_execution_time')));
     // At least 5 minutes
     $sToken = utils::ReadParam('token', '', false, 'raw_data');
     $oExcelExporter = new ExcelExporter($sToken);
     $aStatus = $oExcelExporter->Run();
     $aResults = array('status' => $aStatus['code'], 'percentage' => $aStatus['percentage'], 'message' => $aStatus['message']);
     if ($aStatus['code'] == 'done') {
         $aResults['statistics'] = $oExcelExporter->GetStatistics('html');
     }
     $oPage->add(json_encode($aResults));