/** * Adds the header elements to the XML object * * @param \Aimeos\MShop\Order\Item\Iface $invoice Order of the customer * @param \Aimeos\MShop\Order\Item\Base\Iface $base Order base item of the customer * @param \DOMDocument $dom DOM document object with contains the XML structure * @param \DOMElement $orderitem DOM element which will be the parent of the new child * @throws DOMException If an error occures */ protected function buildXMLHeader(\Aimeos\MShop\Order\Item\Iface $invoice, \Aimeos\MShop\Order\Item\Base\Iface $base, \DOMDocument $dom, \DOMElement $orderitem) { $regex = '/^(\\d+)\\-(\\d+)\\-(\\d+) (\\d+)\\:(\\d+)\\:(\\d+)$/i'; $date = $invoice->getDatePayment(); if (($pdate = preg_replace($regex, '$1-$2-$3T$4:$5:$6Z', $date)) === null) { throw new \Aimeos\MShop\Service\Exception(sprintf('Invalid characters in purchase date "%1$s"', $date)); } $config = $this->getServiceItem()->getConfig(); if (!isset($config['default.project'])) { $msg = 'Parameter "%1$s" for configuration not available'; throw new \Aimeos\MShop\Service\Exception(sprintf($msg, "project"), parent::ERR_TEMP); } $this->appendChildCDATA('id', $invoice->getId(), $dom, $orderitem); $this->appendChildCDATA('type', $invoice->getType(), $dom, $orderitem); $this->appendChildCDATA('datetime', $pdate, $dom, $orderitem); if ($invoice->getRelatedId() !== null) { $this->appendChildCDATA('relatedid', $invoice->getRelatedId(), $dom, $orderitem); } $this->appendChildCDATA('customerid', $base->getCustomerId(), $dom, $orderitem); $this->appendChildCDATA('projectcode', $config['default.project'], $dom, $orderitem); $this->appendChildCDATA('languagecode', strtoupper($base->getLocale()->getLanguageId()), $dom, $orderitem); $this->appendChildCDATA('currencycode', $base->getPrice()->getCurrencyId(), $dom, $orderitem); }