Beispiel #1
0
 /**
  * Creates a new DOMIT_Document node and appends a documentElement with the specified info
  * @param string The namespaceURI of the documentElement
  * @param string The $qualifiedName of the documentElement
  * @param Object A document type node
  * @return Object The new document fragment node
  */
 function &createDocument($namespaceURI, $qualifiedName, &$docType)
 {
     $xmldoc = new DOMIT_Document();
     $documentElement =& $xmldoc->createElementNS($namespaceURI, $qualifiedName);
     $xmldoc->setDocumentElement($documentElement);
     if ($docType != null) {
         $xmldoc->doctype =& $docType;
     }
     return $xmldoc;
 }
Beispiel #2
0
 /**
  * process export
  * @name process_export
  * @param Filterstatement to select orders
  * @param db-object
  * @return bool true/false
  */
 function process_export(&$db)
 {
     global $mosConfig_absolute_path, $database;
     $xmldoc = new DOMIT_Document();
     $xmldoc->appendEntityTranslationTable(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES));
     //damit sollte htmlspecialchars nicht mehr notwendig sein
     $xmldoc->expandEmptyElementTags(false);
     $xmldoc->appendChild($xmldoc->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"IS0-8859-1\""));
     $xmldoc->setDocumentElement($xmldoc->createElement('OLOrders'));
     $xmldoc->documentElement->appendChild($xmldoc->createElement('Version1.1'));
     $order_status = vmGet($_REQUEST, 'status', '');
     $order_from = vmGet($_REQUEST, 'from', '');
     $order_since = vmGet($_REQUEST, 'since', '');
     $order_since = vmGet($_REQUEST, 'since', '');
     $order_to = vmGet($_REQUEST, 'to', '');
     $order_id = vmGet($_REQUEST, 'order_id', '');
     $where = array();
     if (!$order_status && !$order_from && !$order_since && !$order_to && !$order_id) {
         $order_status = 'P';
     }
     if ($order_status) {
         $where[] = "order_status = '" . $db->getEscaped($order_status) . "'";
     }
     if ($order_from) {
         $where[] = "order_id >= '" . $db->getEscaped($order_from) . "'";
     } elseif ($order_since) {
         $where[] = "order_id > '" . $db->getEscaped($order_since) . "'";
     } elseif ($order_id) {
         $where[] = "order_id = '" . $db->getEscaped($order_id) . "'";
     }
     if ($order_to && !$order_id) {
         $where[] = "order_id <= '" . $db->getEscaped($order_to) . "'";
     }
     //select the orders to export
     $q = 'SELECT * FROM #__{vm}_orders WHERE vendor_id=\'' . $db->f('vendor_id') . '\' AND ';
     $q .= implode($where);
     $db->setQuery($q);
     $orders = $db->loadAssocList();
     for ($i = 0; $i < count($orders); $i++) {
         //get billing and shipping address
         $q = "SELECT * FROM #__{vm}_order_user_info WHERE order_id='" . $orders[$i]['order_id'] . "'";
         $db->setQuery($q);
         $orders[$i]['user_info'] = $db->loadAssocList();
         //get shipping address
         $q = "SELECT * FROM #__{vm}_order_item WHERE order_id='" . $orders[$i]['order_id'] . "'";
         $db->setQuery($q);
         $orders[$i]['item'] = $db->loadAssocList();
         //get payment info
         $q = "SELECT * FROM #__{vm}_order_payment WHERE order_id='" . $orders[$i]['order_id'] . "'";
         $db->setQuery($q);
         $orders[$i]['payment'] = $db->loadAssocList();
     }
     foreach ($orders as $order) {
         //print_r($order);
         $OLWebOrder['OLWebOrder']['TransactionHeader']['TransactionID'] = $order['order_id'];
         $OLWebOrder['OLWebOrder']['OrderHeader']['ProcessingOptions']['OrderDate'] = date('d.m.Y H:i:s', $order['cdate']);
         $OLWebOrder['OLWebOrder']['OrderHeader']['HeaderText'] = $order['customer_note'];
         $OLWebOrder['OLWebOrder']['OrderHeader']['ProcessingOptions']['RefNo'] = str_pad($order['order_id'], 8, 0, STR_PAD_LEFT);
         for ($i = 0; $i < count($order['user_info']); $i++) {
             switch ($order['user_info'][$i]['address_type']) {
                 case 'BT':
                 default:
                     if ($order['company']) {
                         $OLWebOrder['OLWebOrder']['OrderHeader']['Address']['Name1'] = $order['user_info'][$i]['company'];
                         $OLWebOrder['OLWebOrder']['OrderHeader']['Address']['Name2'] = $order['user_info'][$i]['first_name'] . ($order['user_info'][$i]['middle_name'] ? ' ' . $order['user_info'][$i]['middle_name'] . ' ' : ' ') . $order['user_info'][$i]['last_name'];
                         $OLWebOrder['OLWebOrder']['OrderHeader']['Address']['Matchcode'] = $order['user_info'][$i]['company'] . ', ' . $order['user_info'][$i]['customers_city'];
                     } else {
                         $OLWebOrder['OLWebOrder']['OrderHeader']['Address']['Name1'] = $order['user_info'][$i]['last_name'];
                         $OLWebOrder['OLWebOrder']['OrderHeader']['Address']['Name2'] = $order['user_info'][$i]['first_name'] . ($order['user_info'][$i]['middle_name'] ? ' ' . $order['user_info'][$i]['middle_name'] : '');
                         $OLWebOrder['OLWebOrder']['OrderHeader']['Address']['Matchcode'] = $order['user_info'][$i]['last_name'] . ', ' . $order['user_info'][$i]['city'];
                     }
                     $OLWebOrder['OLWebOrder']['OrderHeader']['Address']['Title'] = $order['user_info'][$i]['title'];
                     $OLWebOrder['OLWebOrder']['OrderHeader']['Address']['Street'] = $order['user_info'][$i]['address_1'] . ($order['user_info'][$i]['address_2'] ? ', ' . $order['user_info'][$i]['address_2'] : '');
                     $OLWebOrder['OLWebOrder']['OrderHeader']['Address']['ZIPCode'] = $order['user_info'][$i]['zip'];
                     $OLWebOrder['OLWebOrder']['OrderHeader']['Address']['City'] = $order['user_info'][$i]['city'];
                     $OLWebOrder['OLWebOrder']['OrderHeader']['Address']['State'] = $order['user_info'][$i]['state'];
                     $OLWebOrder['OLWebOrder']['OrderHeader']['Address']['Country'] = $this->getISOCode2($order['user_info'][$i]['country']);
                     $OLWebOrder['OLWebOrder']['OrderHeader']['Address']['EMail'] = $order['user_info'][$i]['user_email'];
                     $OLWebOrder['OLWebOrder']['OrderHeader']['Address']['AddrTelefon'] = $order['user_info'][$i]['phone_1'];
                     $OLWebOrder['OLWebOrder']['OrderHeader']['Address']['AddrFax'] = $order['user_info'][$i]['fax'];
                     break;
                 case 'ST':
                     if ($order['company']) {
                         $OLWebOrder['OLWebOrder']['OrderHeader']['DeliveryAddress']['DAName1'] = $order['user_info'][$i]['company'];
                         $OLWebOrder['OLWebOrder']['OrderHeader']['DeliveryAddress']['DAName2'] = $order['user_info'][$i]['first_name'] . ($order['user_info'][$i]['middle_name'] ? ' ' . $order['user_info'][$i]['middle_name'] . ' ' : ' ') . $order['user_info'][$i]['last_name'];
                     } else {
                         $OLWebOrder['OLWebOrder']['OrderHeader']['DeliveryAddress']['DAName1'] = $order['user_info'][$i]['last_name'];
                         $OLWebOrder['OLWebOrder']['OrderHeader']['DeliveryAddress']['DAName2'] = $order['user_info'][$i]['first_name'] . ($order['user_info'][$i]['middle_name'] ? ' ' . $order['user_info'][$i]['middle_name'] : '');
                     }
                     $OLWebOrder['OLWebOrder']['OrderHeader']['DeliveryAddress']['DATitle'] = $order['user_info'][$i]['title'];
                     $OLWebOrder['OLWebOrder']['OrderHeader']['DeliveryAddress']['DAStreet'] = $order['user_info'][$i]['address_1'] . ($order['user_info'][$i]['address_2'] ? ', ' . $order['user_info'][$i]['address_2'] : '');
                     $OLWebOrder['OLWebOrder']['OrderHeader']['DeliveryAddress']['DAZIPCode'] = $order['user_info'][$i]['zip'];
                     $OLWebOrder['OLWebOrder']['OrderHeader']['DeliveryAddress']['DACity'] = $order['user_info'][$i]['city'];
                     $OLWebOrder['OLWebOrder']['OrderHeader']['DeliveryAddress']['DAState'] = $order['user_info'][$i]['state'];
                     $OLWebOrder['OLWebOrder']['OrderHeader']['DeliveryAddress']['DACountry'] = $this->getISOCode2($order['user_info'][$i]['country']);
                     break;
             }
         }
         $OLWebOrder['OLWebOrder']['OrderHeader']['ProcessingOptions']['CarrierCode'] = $this->getCarrierCode($order[$i]['ship_method_id']);
         $OLWebOrder['OLWebOrder']['OrderHeader']['ProcessingOptions']['DeliveryPriceGross'] = 0;
         $OLWebOrder['OLWebOrder']['OrderHeader']['Payment']['Currency'] = $order['order_currency'];
         $OLWebOrder['OLWebOrder']['OrderHeader']['Payment']['BelOLPayCond'] = $this->getPaymentCode($order['payment'][0]['payment_method_id']);
         $this->OLWebOrder[] = $OLWebOrder;
         $OLWebOrder = array();
     }
     $this->xmldoc =& $xmldoc;
     return true;
 }