示例#1
0
文件: Callback.php 项目: Aziz-JH/core
    /**
     * Pass an order to the document
     * @param   DataContainer
     */
    public function printDocument(\DataContainer $dc)
    {
        $strRedirectUrl = str_replace('&key=print_document', '', \Environment::get('request'));
        if (\Input::post('FORM_SUBMIT') == 'tl_iso_print_document') {
            if (($objOrder = Order::findByPk($dc->id)) === null) {
                \Message::addError('Could not find order id.');
                \Controller::redirect($strRedirectUrl);
            }
            if (($objConfig = $objOrder->getRelated('config_id')) === null) {
                \Message::addError('Could not find config id.');
                \Controller::redirect($strRedirectUrl);
            }
            // Set current config
            Isotope::setConfig($objConfig);
            /** @var \Isotope\Interfaces\IsotopeDocument $objDocument */
            if (($objDocument = Document::findByPk(\Input::post('document'))) === null) {
                \Message::addError('Could not find document id.');
                \Controller::redirect($strRedirectUrl);
            }
            $objDocument->outputToBrowser($objOrder);
        }
        $arrSelect = array('name' => 'document', 'label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['document_choice'], 'inputType' => 'select', 'foreignKey' => 'tl_iso_document.name', 'eval' => array('mandatory' => true));
        $objSelect = new \SelectMenu(\SelectMenu::getAttributesFromDca($arrSelect, $arrSelect['name']));
        $strMessages = \Message::generate();
        \Message::reset();
        // Return form
        return '
<div id="tl_buttons">
<a href="' . ampersand($strRedirectUrl) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBT']) . '">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a>
</div>

<h2 class="sub_headline">' . sprintf($GLOBALS['TL_LANG']['tl_iso_product_collection']['print_document'][1], $dc->id) . '</h2>' . $strMessages . '

<form action="' . ampersand(\Environment::get('request'), true) . '" id="tl_iso_product_import" class="tl_form" method="post">
<div class="tl_formbody_edit">
<input type="hidden" name="FORM_SUBMIT" value="tl_iso_print_document">
<input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '">

<div class="tl_tbox block">
  ' . $objSelect->parse() . '
  <p class="tl_help">' . $objSelect->description . '</p>
</div>

</div>

<div class="tl_formbody_submit">

<div class="tl_submit_container">
<input type="submit" name="print" id="print" class="tl_submit" alt="" accesskey="s" value="' . specialchars($GLOBALS['TL_LANG']['tl_iso_product_collection']['print']) . '">
</div>

</div>
</form>';
    }