diff --git a/core/bulkexport.class.inc.php b/core/bulkexport.class.inc.php
index 01453616a..2faa4c699 100644
--- a/core/bulkexport.class.inc.php
+++ b/core/bulkexport.class.inc.php
@@ -25,7 +25,8 @@ define('EXPORTER_DEFAULT_CHUNK_SIZE', 1000);
class BulkExportException extends Exception
{
protected $sLocalizedMessage;
- public function __construct($message, $sLocalizedMessage, $code = null, $previous = null)
+
+ public function __construct($message, $sLocalizedMessage, $code = 0, $previous = null)
{
parent::__construct($message, $code, $previous);
$this->sLocalizedMessage = $sLocalizedMessage;
diff --git a/core/displayablegraph.class.inc.php b/core/displayablegraph.class.inc.php
index b7fbe7475..24557769d 100644
--- a/core/displayablegraph.class.inc.php
+++ b/core/displayablegraph.class.inc.php
@@ -25,6 +25,7 @@ use Combodo\iTop\Application\WebPage\iTopPDF;
use Combodo\iTop\Application\WebPage\PDFPage;
use Combodo\iTop\Application\WebPage\WebPage;
use Combodo\iTop\Renderer\BlockRenderer;
+use Combodo\iTop\Service\Router\Router;
/**
* Special kind of Graph for producing some nice output
@@ -1470,6 +1471,7 @@ class DisplayableGraph extends SimpleGraph
try {
$this->InitFromGraphviz();
$sExportAsPdfURL = utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php?operation=relation_pdf&relation='.$sRelation.'&direction='.($this->bDirectionDown ? 'down' : 'up');
+ $sExportAsPdfURL2 = Router::GetInstance()->GenerateUrl('export.choose_global_params', ['format' => 'pdf']);
$sContext = $oAppContext->GetForLink();
$sDrillDownURL = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=details&class=%1$s&id=%2$s&'.$sContext;
$sExportAsDocumentURL = utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php?operation=relation_attachment&relation='.$sRelation.'&direction='.($this->bDirectionDown ? 'down' : 'up');
@@ -1495,7 +1497,8 @@ class DisplayableGraph extends SimpleGraph
'sources' => ($this->bDirectionDown ? $this->aSourceObjects : $this->aSinkObjects),
'excluded' => $aExcludedByClass,
'grouping_threshold' => $iGroupingThreshold,
- 'export_as_pdf' => array('url' => $sExportAsPdfURL, 'label' => Dict::S('UI:Relation:ExportAsPDF')),
+ 'export_as_pdf' => array('url' => $sExportAsPdfURL, 'label' => Dict::S('UI:Relation:ExportAsPDF')),
+ 'export_as_bob' => array('url' => $sExportAsPdfURL2, 'label' => Dict::S('UI:Relation:ExportAsBob')),
'transaction_id' => utils::GetNewTransactionId(),
'export_as_attachment' => array('url' => $sExportAsDocumentURL, 'label' => Dict::S('UI:Relation:ExportAsAttachment'), 'obj_class' => $sObjClass, 'obj_key' => $iObjKey),
'drill_down' => array('url' => $sDrillDownURL, 'label' => Dict::S('UI:Relation:DrillDown')),
diff --git a/js/simple_graph.js b/js/simple_graph.js
index 65ecedfe9..4d40dd4f8 100644
--- a/js/simple_graph.js
+++ b/js/simple_graph.js
@@ -496,6 +496,7 @@ $(function()
{
sHtml += '
';
}
+ sHtml += '';
//sHtml += '';
sHtml += '';
sHtml += '';
@@ -507,6 +508,9 @@ $(function()
var me = this;
+ $('#' + sPopupMenuId + '_bob').on('click', function () {
+ me.export_as_bob();
+ });
$('#'+sPopupMenuId+'_pdf').on('click', function() { me.export_as_pdf(); });
$('#'+sPopupMenuId+'_attachment').on('click', function() { me.export_as_attachment(); });
$('#'+sId+'_zoom').slider({ min: 0, max: 5, value: 1, step: 0.25, change: function() { me._on_zoom_change( $(this).slider('value')); } });
@@ -575,8 +579,47 @@ $(function()
});
},
- export_as_pdf: function()
+ export_as_bob: function ()
{
+ var sId = this.element.attr('id');
+ var me = this;
+ var oParams = {};
+ oParams.g = this.options.grouping_threshold;
+ oParams.context_key = this.options.context_key;
+ oParams.transaction_id = this.options.transaction_id;
+ oParams.contexts = {};
+ $('#' + sId + '_contexts').multiselect('getChecked').each(function () {
+ oParams.contexts[$(this).val()] = me.options.additional_contexts[$(this).val()].oql;
+ });
+
+ oParams.excluded_classes = {};
+ for (k in this.options.excluded_classes) {
+ oParams.excluded_classes[k] = this.options.excluded_classes[k];
+ }
+ oParams.sources = {};
+ for (var k1 in this.options.sources) {
+ oParams.sources[k1] = {};
+ for (var k2 in this.options.sources[k1]) {
+ oParams.sources[k1][k2] = this.options.sources[k1][k2];
+ }
+ }
+ oParams.excluded = {};
+ for (var k1 in this.options.excluded) {
+ oParams.options.excluded[k1] = {};
+ for (var k2 in this.options.excluded[k1]) {
+ oParams.excluded[k1][k2] = this.options.excluded[k1][k2];
+ }
+ }
+ oParams.list_classes = {};
+ $("#dh_flash_criterion_outer [name= 'excluded[]']").each(function (index, element) {
+ oParams.list_classes[index] = $(element).val();
+ });
+
+ $.post(this.options.export_as_bob.url, oParams, function (data) {
+ $('body').append(data);
+ });
+ },
+ export_as_pdf: function () {
this._export_dlg(this.options.labels.export_pdf_title, this.options.export_as_pdf.url, 'download_pdf');
},
_export_dlg: function(sTitle, sSubmitUrl, sOperation)
diff --git a/js/utils.js b/js/utils.js
index 354c975e2..ddf8ede56 100644
--- a/js/utils.js
+++ b/js/utils.js
@@ -595,6 +595,22 @@ function ExportInitButton(sSelector) {
});
}
+function ExportImpactButton(sSelector) {
+ $(sSelector).on('click', function () {
+ var form = $('#export-form');
+ var actionUrl = form.attr('action');
+
+ $.ajax({
+ type: "POST",
+ url: actionUrl,
+ data: form.serialize(), // serializes the form's elements.
+ success: function (data) {
+ $(sSelector).html(data); // show response from the php script.
+ }
+ });
+ });
+}
+
/**
* @deprecated 3.0.0 N°4367 deprecated, use {@see CombodoSanitizer.EscapeHtml} instead
*
diff --git a/sources/Controller/Export/ExportController.php b/sources/Controller/Export/ExportController.php
new file mode 100644
index 000000000..f67ed3af3
--- /dev/null
+++ b/sources/Controller/Export/ExportController.php
@@ -0,0 +1,840 @@
+add('');
+ $oP->add_ready_script(
+ <<| '+this.options.labels.title+' | | ';
+ sHtmlForm += '| '+this.options.labels.comments+' | |
';
+*/
+ /* first select params specific to the export format */
+ $oExporter = BulkExport::FindExporter($sFormat);
+ if ($oExporter === null) {
+ $aSupportedFormats = BulkExport::FindSupportedFormats();
+ $oP->add("Invalid output format: '$sFormat'. The supported formats are: ".implode(', ', array_keys($aSupportedFormats)));
+ $oP->add('
');
+ return $oP;
+ }
+ $UIContentBlock = UIContentBlockUIBlockFactory::MakeStandard('form_part_'.$sFormat)->AddCSSClass('form_part');
+ $oForm->AddSubBlock($UIContentBlock);
+ $UIContentBlock->AddSubBlock($oExporter->GetFormPart($oP, $sFormat.'_options'));
+
+ $aSelectedClasses = utils::ReadParam('list_classes', '', false, utils::ENUM_SANITIZATION_FILTER_RAW_DATA);
+
+ $oPanel = PanelUIBlockFactory::MakeNeutral(Dict::S('UI:Export:Class:SelectedClasses'));
+ $oForm->AddSubBlock($oPanel);
+ $oMulticolumn = MultiColumnUIBlockFactory::MakeStandard('selected_classes');
+ $oPanel->AddSubBlock($oMulticolumn);
+ $oMulticolumn->AddCSSClass('ibo-multi-column--export');
+ $oColumn1 = ColumnUIBlockFactory::MakeStandard();
+ $oMulticolumn->AddColumn($oColumn1);
+ $oColumn2 = ColumnUIBlockFactory::MakeStandard();
+ $oMulticolumn->AddColumn($oColumn2);
+ foreach ($aSelectedClasses as $i => $sClass) {
+ $oBlock = FieldUIBlockFactory::MakeStandard(MetaModel::GetName($sClass)) ;
+ $oValue = SelectUIBlockFactory::MakeForSelect($sClass);
+ $oValue->AddOption(SelectOptionUIBlockFactory::MakeForSelectOption('standard', Dict::S('UI:Export:Class:Standard'), true));
+ $oValue->AddOption(SelectOptionUIBlockFactory::MakeForSelectOption('user', Dict::S('UI:Export:Class:User'), false));
+ $oValue->AddOption(SelectOptionUIBlockFactory::MakeForSelectOption('custom', Dict::S('UI:Export:Class:Custom'), false));
+ $oBlock->AddSubBlock($oValue);
+ if ($i%2 == 0) {
+ $oColumn1->AddSubBlock($oBlock);
+ } else {
+ $oColumn2->AddSubBlock($oBlock);
+ }
+ }
+
+ $oP->add('');
+
+
+ return $oP;
+ }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+///
+///
+/// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /* function DisplayForm(WebPage $oP, $sAction = '', $sExpression = '', $sFormat = null)
+ {
+ $oExportSearch = null;
+ $oP->add_script(DateTimeFormat::GetJSSQLToCustomFormat());
+ $sJSDefaultDateTimeFormat = json_encode((string)AttributeDateTime::GetFormat());
+ $oP->add_script(
+ <<LinkScriptFromAppRoot('js/tabularfieldsselector.js');
+ $oP->LinkScriptFromAppRoot('js/jquery.dragtable.js');
+ $oP->LinkStylesheetFromAppRoot('css/dragtable.css');
+
+ /* $oForm = FormUIBlockFactory::MakeStandard("export-form");
+ $oForm->SetAction($sAction);
+ $oForm->AddDataAttribute("state", "not-yet-started");
+ $oP->AddSubBlock($oForm);*
+
+ $bExpressionIsValid = true;
+ $sExpressionError = '';
+ if ($sExpression === null) {
+ $bExpressionIsValid = false;
+ } else if ($sExpression !== '') {
+ try {
+ $oExportSearch = DBObjectSearch::FromOQL($sExpression);
+ $oExportSearch->UpdateContextFromUser();
+ }
+ catch (OQLException $e) {
+ $bExpressionIsValid = false;
+ $sExpressionError = $e->getMessage();
+ }
+ }
+
+ if (!$bExpressionIsValid) {
+ DisplayExpressionForm($oP, $sAction, $sExpression, $sExpressionError,$oForm);
+
+ return;
+ }
+
+
+ $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("expression", $sExpression));
+ $oExportSearch = DBObjectSearch::FromOQL($sExpression);
+ $oExportSearch->UpdateContextFromUser();
+
+ $aFormPartsByFormat = array();
+ $aAllFormParts = array();
+
+ // One specific format was chosen
+ $oSelect = InputUIBlockFactory::MakeForHidden("format", utils::EscapeHtml($sFormat));
+ $oForm->AddSubBlock($oSelect);
+
+ /* $oExporter = BulkExport::FindExporter($sFormat, $oExportSearch);
+ $aParts = $oExporter->EnumFormParts();
+ foreach ($aParts as $sPartId => $void) {
+ $aAllFormParts[$sPartId] = $oExporter;
+ }
+ $aFormPartsByFormat[$sFormat] = array_keys($aAllFormParts);
+
+ foreach ($aAllFormParts as $sPartId => $oExport) {
+ $UIContentBlock = UIContentBlockUIBlockFactory::MakeStandard('form_part_'.$sPartId)->AddCSSClass('form_part');
+ $oForm->AddSubBlock($UIContentBlock);
+ $UIContentBlock->AddSubBlock($oExport->GetFormPart($oP, $sPartId));
+ }*
+ //end of form
+ $oBlockExport = UIContentBlockUIBlockFactory::MakeStandard("export-feedback")->SetIsHidden(true);
+ $oBlockExport->AddSubBlock(new Html(''.Dict::S('ExcelExport:PreparingExport').'
'));
+ $oBlockExport->AddSubBlock(new Html(''));
+ $oP->AddSubBlock($oBlockExport);
+ if ($sFormat == null) {//if it's global export
+ $oP->AddSubBlock(ButtonUIBlockFactory::MakeForPrimaryAction('export', Dict::S('UI:Button:Export'), 'export', false, 'export-btn'));
+ }
+ $oBlockResult = UIContentBlockUIBlockFactory::MakeStandard("export_text_result")->SetIsHidden(true);
+ $oBlockResult->AddSubBlock(new Html(Dict::S('Core:BulkExport:ExportResult')));
+
+ $oTextArea = new TextArea('export_content', '', 'export_content');
+ $oTextArea->AddCSSClass('ibo-input-text--export');
+ $oBlockResult->AddSubBlock($oTextArea);
+ $oP->AddSubBlock($oBlockResult);
+
+ $sJSParts = json_encode($aFormPartsByFormat);
+ $oP->add_ready_script(
+ <<