use Combodo\iTop\Application\UI\Base\Component\FieldSet\FieldSetUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\Html\Html; use Combodo\iTop\Application\UI\Base\Component\Input\InputUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\Input\Select\SelectOptionUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\Panel\PanelUIBlockFactory; use Combodo\iTop\Application\UI\Base\Layout\UIContentBlockUIBlockFactory; /** * Bulk export: PDF export, based on the HTML export converted to PDF * * @copyright Copyright (C) 2015 Combodo SARL * @license http://opensource.org/licenses/AGPL-3.0 */ class PDFBulkExport extends HTMLBulkExport { public function DisplayUsage(Page $oP) { $oP->p(" * pdf format options:"); $oP->p(" *\tfields: (mandatory) the comma separated list of field codes to export (e.g: name,org_id,service_name...)."); $oP->p(" *\tpage_size: (optional) size of the page. One of A4, A3, Letter (default is 'A4')."); $oP->p(" *\tpage_orientation: (optional) the orientation of the page. Either Portrait or Landscape (default is 'Portrait')."); $oP->p(" *\tdate_format: the format to use when exporting date and time fields (default = the SQL format). e.g. 'Y-m-d H:i:s'"); } public function EnumFormParts() { return array_merge(array('pdf_options' => array('pdf_options')), parent::EnumFormParts()); } /** * @param \WebPage $oP * @param $sPartId * * @return UIContentBlock */ public function GetFormPart(WebPage $oP, $sPartId) { switch ($sPartId) { case 'pdf_options': $oPanel = PanelUIBlockFactory::MakeNeutral(Dict::S('Core:BulkExport:PDFOptions')); $oMulticolumn = UIContentBlockUIBlockFactory::MakeStandard(); $oMulticolumn->AddCSSClass('ibo-multi-column'); $oPanel->AddSubBlock($oMulticolumn); $oFieldSetFormat = FieldSetUIBlockFactory::MakeStandard(Dict::S('Core:BulkExport:PDFPageFormat')); $oFieldSetFormat->AddCSSClass('ibo-column'); $oMulticolumn->AddSubBlock($oFieldSetFormat); //page format $oSelectFormat = InputUIBlockFactory::MakeForSelectWithLabel("page_size", Dict::S('Core:BulkExport:PDFPageSize')); $oSelectFormat->SetBeforeInput(false); $oFieldSetFormat->AddSubBlock($oSelectFormat); $aPossibleFormat = ['A3', 'A4', 'Letter']; $sDefaultFormat = 'A4'; foreach ($aPossibleFormat as $sVal) { $oSelectFormat->GetInput()->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption($sVal, htmlentities(Dict::S('Core:BulkExport:PageSize-'.$sVal), ENT_QUOTES, 'UTF-8'), ($sVal == $sDefaultFormat))); } $oFieldSetFormat->AddSubBlock(new Html('')); $oSelectOrientation = InputUIBlockFactory::MakeForSelectWithLabel("page_size", Dict::S('Core:BulkExport:PDFPageOrientation')); $oSelectOrientation->SetBeforeInput(false); $oFieldSetFormat->AddSubBlock($oSelectOrientation); $aPossibleOrientation = ['P', 'L']; $sDefaultOrientation = 'L'; foreach ($aPossibleOrientation as $sVal) { $oSelectOrientation->GetInput()->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption($sVal, htmlentities(Dict::S('Core:BulkExport:PageOrientation-'.$sVal), ENT_QUOTES, 'UTF-8'), ($sVal == $sDefaultOrientation))); } //date format $oFieldSetDate = FieldSetUIBlockFactory::MakeStandard(Dict::S('Core:BulkExport:DateTimeFormat')); $oFieldSetDate->AddCSSClass('ibo-column'); $oMulticolumn->AddSubBlock($oFieldSetDate); $sDateTimeFormat = utils::ReadParam('date_format', (string)AttributeDateTime::GetFormat(), true, 'raw_data'); $sDefaultFormat = htmlentities((string)AttributeDateTime::GetFormat(), ENT_QUOTES, 'UTF-8'); $sExample = htmlentities(date((string)AttributeDateTime::GetFormat()), ENT_QUOTES, 'UTF-8'); $oRadioDefault = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatDefault_Example', $sDefaultFormat, $sExample), "pdf_custom_date_time_format", "default", "pdf_date_time_format_default", "radio"); $oRadioDefault->GetInput()->SetIsChecked(($sDateTimeFormat == (string)AttributeDateTime::GetFormat())); $oRadioDefault->SetBeforeInput(false); $oFieldSetDate->AddSubBlock($oRadioDefault); $oFieldSetDate->AddSubBlock(new Html('')); $sFormatInput = ''; $oRadioCustom = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatCustom_Format', $sFormatInput), "pdf_custom_date_time_format", "custom", "pdf_date_time_format_custom", "radio"); $oRadioCustom->GetInput()->SetIsChecked($sDateTimeFormat !== (string)AttributeDateTime::GetFormat()); $oRadioCustom->SetBeforeInput(false); $oFieldSetDate->AddSubBlock($oRadioCustom); $sJSTooltip = json_encode('