コード例 #1
0
 function buildOrderDownloadXML($data)
 {
     // builds download XML string for orders
     // clean up some fields
     $temp = explode(' ', $data->info['date_purchased']);
     $order_date = $temp[0];
     // remove the time from the order date stamp
     $this->strXML = '<?xml version="1.0" encoding="UTF-8" ?>' . chr(10);
     $this->strXML .= '<AccessRequest>' . chr(10);
     $this->strXML .= '<AccessUserID>' . MODULE_PHREEBOOKS_ORDER_DOWNLOAD_USER . '</AccessUserID>' . chr(10);
     $this->strXML .= '<AccessPassword>' . MODULE_PHREEBOOKS_ORDER_DOWNLOAD_PW . '</AccessPassword>' . chr(10);
     $this->strXML .= '<AccessFunction>' . $type . '</AccessFunction>' . chr(10);
     $this->strXML .= '<PhreeBooksXMLVersion>1.00</PhreeBooksXMLVersion>' . chr(10);
     $this->strXML .= '<SalesOrderEntry>' . chr(10);
     $this->strXML .= '<OrderRequest>' . chr(10);
     $this->strXML .= '<RequestAction>New</RequestAction>' . chr(10);
     $this->strXML .= '<ReferenceName>' . $data->info['date_purchased'] . '</ReferenceName>' . chr(10);
     $this->strXML .= '<Originator>' . chr(10);
     $this->strXML .= '<StoreID>' . MODULE_PHREEBOOKS_ORDER_DOWNLOAD_STORE_ID . '</StoreID>' . chr(10);
     $this->strXML .= '<SalesRepID>' . MODULE_PHREEBOOKS_ORDER_DOWNLOAD_SALES_REP_ID . '</SalesRepID>' . chr(10);
     $this->strXML .= '<SalesGLAccount>' . MODULE_PHREEBOOKS_ORDER_DOWNLOAD_SALES_GL_ACCOUNT . '</SalesGLAccount>' . chr(10);
     $this->strXML .= '<ReceivablesGLAccount>' . MODULE_PHREEBOOKS_ORDER_DOWNLOAD_AR_GL_ACCOUNT . '</ReceivablesGLAccount>' . chr(10);
     $this->strXML .= '</Originator>' . chr(10);
     $this->strXML .= '</OrderRequest>' . chr(10);
     $this->strXML .= '<SalesOrder>' . chr(10);
     $this->strXML .= '<OrderSummary>' . chr(10);
     $this->strXML .= '<SalesOrderID>' . MODULE_PHREEBOOKS_ORDER_DOWNLOAD_PREFIX . $data->id . '</SalesOrderID>' . chr(10);
     $this->strXML .= '<SalesOrderDate>' . $order_date . '</SalesOrderDate>' . chr(10);
     // get the totals separately since the default order does not include the totals class name
     $result = tep_db_query("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = " . $data->id);
     while ($item = tep_db_fetch_array($result)) {
         switch ($item['class']) {
             // TBD also need to include discounts, fees and other order total modules information
             case 'ot_total':
                 $this->strXML .= '<OrderTotal>' . $item['value'] . '</OrderTotal>' . chr(10);
                 break;
             case 'ot_shipping':
                 $this->strXML .= '<ShippingTotal>' . $item['value'] . '</ShippingTotal>' . chr(10);
                 $this->strXML .= '<ShippingCarrier>' . $item['title'] . '</ShippingCarrier>' . chr(10);
                 $this->strXML .= '<ShippingMethod>' . $item['title'] . '</ShippingMethod>' . chr(10);
                 break;
         }
     }
     //  	$this->strXML .= '<OrderNotes>' . $data->info['ip_address'] . '</OrderNotes>' . chr(10);
     $this->strXML .= '</OrderSummary>' . chr(10);
     $this->strXML .= '<Payment>' . chr(10);
     $this->strXML .= '<CardHolderName>' . $data->info['cc_owner'] . '</CardHolderName>' . chr(10);
     $this->strXML .= '<Method>' . $data->info['payment_method'] . '</Method>' . chr(10);
     $this->strXML .= '<Type>' . $data->info['cc_type'] . '</Type>' . chr(10);
     $this->strXML .= '<CardNumber>' . $data->info['cc_number'] . '</CardNumber>' . chr(10);
     $this->strXML .= '<ExpirationDate>' . $data->info['cc_expires'] . '</ExpirationDate>' . chr(10);
     $this->strXML .= '<CVV2Number>' . $data->info['cc_cvv'] . '</CVV2Number>' . chr(10);
     if (function_exists('osc_set_hint')) {
         $this->strXML .= '<Hint>' . zc_set_hint($data->id) . '</Hint>' . chr(10);
     }
     if (function_exists('osc_set_value')) {
         $temp = strtr(base64_encode(zc_set_value($data->id)), '+/=', '-_,');
         $this->strXML .= '<Encval>' . $temp . '</Encval>' . chr(10);
     }
     $this->strXML .= '</Payment>' . chr(10);
     $this->strXML .= '<Customer>' . chr(10);
     switch (PHREEBOOKS_DOWNLOAD_USER_ID_METHOD) {
         case 'Telephone':
             $customer_id = preg_replace("[^0-9]", "", $data->customer['telephone']);
             break;
         case 'Email':
         default:
             $customer_id = $data->customer['email_address'];
     }
     $this->strXML .= '<CustomerID>' . $customer_id . '</CustomerID>' . chr(10);
     $this->strXML .= '<CompanyName>' . $data->customer['company'] . '</CompanyName>' . chr(10);
     $this->strXML .= '<Contact>' . $data->customer['name'] . '</Contact>' . chr(10);
     $this->strXML .= '<Telephone>' . $data->customer['telephone'] . '</Telephone>' . chr(10);
     $this->strXML .= '<Email>' . $data->customer['email_address'] . '</Email>' . chr(10);
     $this->strXML .= '<Address1>' . $data->customer['street_address'] . '</Address1>' . chr(10);
     $this->strXML .= '<Address2>' . $data->customer['suburb'] . '</Address2>' . chr(10);
     $this->strXML .= '<CityTown>' . $data->customer['city'] . '</CityTown>' . chr(10);
     $codes = $this->getCodes($data->customer['country'], $data->customer['state']);
     $this->strXML .= '<StateProvince>' . $codes['state'] . '</StateProvince>' . chr(10);
     $this->strXML .= '<PostalCode>' . $data->customer['postcode'] . '</PostalCode>' . chr(10);
     $this->strXML .= '<CountryCode>' . $codes['country'] . '</CountryCode>' . chr(10);
     $this->strXML .= '</Customer>' . chr(10);
     $this->strXML .= '<Billing>' . chr(10);
     $this->strXML .= '<CompanyName>' . $data->billing['company'] . '</CompanyName>' . chr(10);
     $this->strXML .= '<Contact>' . $data->billing['name'] . '</Contact>' . chr(10);
     $this->strXML .= '<Address1>' . $data->billing['street_address'] . '</Address1>' . chr(10);
     $this->strXML .= '<Address2>' . $data->billing['suburb'] . '</Address2>' . chr(10);
     $this->strXML .= '<CityTown>' . $data->billing['city'] . '</CityTown>' . chr(10);
     $codes = $this->getCodes($data->billing['country'], $data->billing['state']);
     $this->strXML .= '<StateProvince>' . $codes['state'] . '</StateProvince>' . chr(10);
     $this->strXML .= '<PostalCode>' . $data->billing['postcode'] . '</PostalCode>' . chr(10);
     $this->strXML .= '<CountryCode>' . $codes['country'] . '</CountryCode>' . chr(10);
     $this->strXML .= '</Billing>' . chr(10);
     $this->strXML .= '<Shipping>' . chr(10);
     $this->strXML .= '<CompanyName>' . $data->delivery['company'] . '</CompanyName>' . chr(10);
     $this->strXML .= '<Contact>' . $data->delivery['name'] . '</Contact>' . chr(10);
     $this->strXML .= '<Address1>' . $data->delivery['street_address'] . '</Address1>' . chr(10);
     $this->strXML .= '<Address2>' . $data->delivery['suburb'] . '</Address2>' . chr(10);
     $this->strXML .= '<CityTown>' . $data->delivery['city'] . '</CityTown>' . chr(10);
     $codes = $this->getCodes($data->delivery['country'], $data->delivery['state']);
     $this->strXML .= '<StateProvince>' . $codes['state'] . '</StateProvince>' . chr(10);
     $this->strXML .= '<PostalCode>' . $data->delivery['postcode'] . '</PostalCode>' . chr(10);
     $this->strXML .= '<CountryCode>' . $codes['country'] . '</CountryCode>' . chr(10);
     $this->strXML .= '</Shipping>' . chr(10);
     $this->strXML .= '<LineItems>' . chr(10);
     // get the products separately since the default order does not include the products_id
     $result = tep_db_query("select * from " . TABLE_ORDERS_PRODUCTS . " where orders_id = " . $data->id);
     while ($item = tep_db_fetch_array($result)) {
         $this->strXML .= '<LineItemDetails>' . chr(10);
         $this->strXML .= '<ItemID>' . $this->find_sku($item['products_id'], $item['products_name']) . '</ItemID>' . chr(10);
         $this->strXML .= '<Description>' . $item['products_name'] . '</Description>' . chr(10);
         $this->strXML .= '<Quantity>' . $item['products_quantity'] . '</Quantity>' . chr(10);
         $this->strXML .= '<UnitPrice>' . $item['products_price'] . '</UnitPrice>' . chr(10);
         $this->strXML .= '<SalesTax>' . $item['products_tax'] . '</SalesTax>' . chr(10);
         //			$this->strXML .= '<SalesTaxPercent>' . $item['products_tax'] . '</SalesTaxPercent>' . chr(10);
         $this->strXML .= '<TotalPrice>' . $item['products_quantity'] * $item['products_price'] . '</TotalPrice>' . chr(10);
         $this->strXML .= '</LineItemDetails>' . chr(10);
     }
     $this->strXML .= '</LineItems>' . chr(10);
     $this->strXML .= '</SalesOrder>' . chr(10);
     $this->strXML .= '</SalesOrderEntry>' . chr(10);
     $this->strXML .= '</AccessRequest>' . chr(10);
     return true;
 }
コード例 #2
0
ファイル: phreebooks.php プロジェクト: siwiwit/PhreeBooksERP
 function buildOrderDownloadXML($orders)
 {
     // builds download XML string for orders
     // clean up some fields
     $strXML = '<?xml version="1.0" encoding="UTF-8" ?>' . chr(10);
     $strXML .= '<Request>' . chr(10);
     $strXML .= $this->xmlEntry('UserID', MODULE_PHREEBOOKS_ORDER_DOWNLOAD_USER);
     $strXML .= $this->xmlEntry('Password', MODULE_PHREEBOOKS_ORDER_DOWNLOAD_PW);
     $strXML .= $this->xmlEntry('Version', '1.00');
     $strXML .= $this->xmlEntry('Function', 'SalesOrder');
     $strXML .= $this->xmlEntry('Action', 'New');
     foreach ($orders as $oID) {
         $data = new order($oID);
         // open the order and read all information
         $data->id = $oID;
         $temp = explode(' ', $data->info['date_purchased']);
         $order_date = $temp[0];
         // remove the time from the order date stamp
         $strXML .= '<Order>' . chr(10);
         $strXML .= $this->xmlEntry('Reference', $oID);
         $strXML .= $this->xmlEntry('StoreID', MODULE_PHREEBOOKS_ORDER_DOWNLOAD_STORE_ID);
         $strXML .= $this->xmlEntry('SalesRepID', MODULE_PHREEBOOKS_ORDER_DOWNLOAD_SALES_REP_ID);
         $strXML .= $this->xmlEntry('SalesGLAccount', MODULE_PHREEBOOKS_ORDER_DOWNLOAD_SALES_GL_ACCOUNT);
         $strXML .= $this->xmlEntry('ReceivablesGLAccount', MODULE_PHREEBOOKS_ORDER_DOWNLOAD_AR_GL_ACCOUNT);
         $strXML .= $this->xmlEntry('OrderID', MODULE_PHREEBOOKS_ORDER_DOWNLOAD_PREFIX . $data->id);
         //	  $strXML .= $this->xmlEntry('PurchaseOrderID', 'TBD');
         $strXML .= $this->xmlEntry('OrderDate', $order_date);
         $strXML .= $this->xmlEntry('OrderTotal', $data->info['total']);
         $strXML .= $this->xmlEntry('TaxTotal', $data->info['tax']);
         $freight_totals = $this->getClassInfo('ot_shipping', $data->totals);
         $strXML .= $this->xmlEntry('ShippingTotal', $this->clean_value($freight_totals['text'], $data->info['currency']));
         $strXML .= $this->xmlEntry('ShippingCarrier', $freight_totals['title']);
         $strXML .= $this->xmlEntry('ShippingMethod', $freight_totals['title']);
         //    TBD also need to include discounts, fees and other order total modules information
         // 	  $strXML .= $this->xmlEntry('OrderNotes',     $data->info['ip_address']);
         $strXML .= '<Payment>' . chr(10);
         $strXML .= $this->xmlEntry('CardHolderName', $data->billing['name']);
         $strXML .= $this->xmlEntry('Method', $data->info['payment_method']);
         $strXML .= $this->xmlEntry('CardType', $data->info['cc_type']);
         $strXML .= $this->xmlEntry('CardNumber', $data->info['cc_number']);
         $strXML .= $this->xmlEntry('ExpirationDate', $data->info['cc_expires']);
         $strXML .= $this->xmlEntry('CVV2Number', $data->info['cc_cvv']);
         if (function_exists('zc_set_hint')) {
             $strXML .= $this->xmlEntry('CardHint', zc_set_hint($data->id));
         }
         if (function_exists('zc_set_value')) {
             $temp = strtr(base64_encode(zc_set_value($data->id)), '+/=', '-_,');
             $strXML .= $this->xmlEntry('CardEncodeValue', $temp);
         }
         $strXML .= '</Payment>' . chr(10);
         $strXML .= '<Customer>' . chr(10);
         switch (PHREEBOOKS_DOWNLOAD_USER_ID_METHOD) {
             case 'Telephone':
                 $customer_id = ereg_replace("[^0-9]", "", $data->customer['telephone']);
                 break;
             case 'Email':
             default:
                 $customer_id = $data->customer['email_address'];
                 break;
         }
         $strXML .= $this->xmlEntry('CustomerID', $customer_id);
         $strXML .= $this->xmlEntry('CompanyName', $data->customer['company']);
         $strXML .= $this->xmlEntry('Contact', $data->customer['name']);
         $strXML .= $this->xmlEntry('Telephone', $data->customer['telephone']);
         $strXML .= $this->xmlEntry('Email', $data->customer['email_address']);
         $strXML .= $this->xmlEntry('Address1', $data->customer['street_address']);
         $strXML .= $this->xmlEntry('Address2', $data->customer['suburb']);
         $strXML .= $this->xmlEntry('CityTown', $data->customer['city']);
         $codes = $this->getCodes($data->customer['country'], $data->customer['state']);
         $strXML .= $this->xmlEntry('StateProvince', $codes['state']);
         $strXML .= $this->xmlEntry('PostalCode', $data->customer['postcode']);
         $strXML .= $this->xmlEntry('CountryCode', $codes['country']);
         $strXML .= '</Customer>' . chr(10);
         $strXML .= '<Billing>' . chr(10);
         $strXML .= $this->xmlEntry('CompanyName', $data->billing['company']);
         $strXML .= $this->xmlEntry('Contact', $data->billing['name']);
         $strXML .= $this->xmlEntry('Address1', $data->billing['street_address']);
         $strXML .= $this->xmlEntry('Address2', $data->billing['suburb']);
         $strXML .= $this->xmlEntry('CityTown', $data->billing['city']);
         $codes = $this->getCodes($data->billing['country'], $data->billing['state']);
         $strXML .= $this->xmlEntry('StateProvince', $codes['state']);
         $strXML .= $this->xmlEntry('PostalCode', $data->billing['postcode']);
         $strXML .= $this->xmlEntry('CountryCode', $codes['country']);
         $strXML .= '</Billing>' . chr(10);
         $strXML .= '<Shipping>' . chr(10);
         $strXML .= $this->xmlEntry('CompanyName', $data->delivery['company']);
         $strXML .= $this->xmlEntry('Contact', $data->delivery['name']);
         $strXML .= $this->xmlEntry('Address1', $data->delivery['street_address']);
         $strXML .= $this->xmlEntry('Address2', $data->delivery['suburb']);
         $strXML .= $this->xmlEntry('CityTown', $data->delivery['city']);
         $codes = $this->getCodes($data->delivery['country'], $data->delivery['state']);
         $strXML .= $this->xmlEntry('StateProvince', $codes['state']);
         $strXML .= $this->xmlEntry('PostalCode', $data->delivery['postcode']);
         $strXML .= $this->xmlEntry('CountryCode', $codes['country']);
         $strXML .= '</Shipping>' . chr(10);
         foreach ($data->products as $item) {
             $strXML .= '<Item>' . chr(10);
             $strXML .= $this->xmlEntry('ItemID', $this->find_sku($item['id'], $item['name']));
             $strXML .= $this->xmlEntry('Description', $item['name']);
             $strXML .= $this->xmlEntry('Quantity', $item['qty']);
             $strXML .= $this->xmlEntry('UnitPrice', $item['price']);
             //	    $strXML .= $this->xmlEntry('SalesTax',    $item['tax']);
             $strXML .= $this->xmlEntry('SalesTaxPercent', $item['tax']);
             $strXML .= $this->xmlEntry('TotalPrice', $item['qty'] * $item['price']);
             $strXML .= '</Item>' . chr(10);
         }
         $strXML .= '</Order>' . chr(10);
     }
     $strXML .= '</Request>' . chr(10);
     return $strXML;
 }