/** * Adds the header elements to the XML object * * @param MShop_Order_Item_Interface $invoice Order of the customer * @param MShop_Order_Item_Base_Interface $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(MShop_Order_Item_Interface $invoice, MShop_Order_Item_Base_Interface $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 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 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); }