コード例 #1
0
 $status = xtc_db_fetch_array($status_query);
 //EOF Web28 - 2010-12-06 - read customer status earlier
 // Errechne neue Zwischensumme für Artikel Anfang
 $products_query = xtc_db_query("select SUM(final_price) as subtotal_final from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int) $_POST['oID'] . "' ");
 $products = xtc_db_fetch_array($products_query);
 $subtotal_final = $products['subtotal_final'];
 $subtotal_text = $xtPrice->xtcFormat($subtotal_final, true);
 xtc_db_query("update " . TABLE_ORDERS_TOTAL . " set text = '" . $subtotal_text . "', value = '" . $subtotal_final . "' where orders_id = '" . (int) $_POST['oID'] . "' and class = 'ot_subtotal' ");
 // Errechne neue Zwischensumme für Artikel Ende
 //BOF####### Produkte #######//
 $products_query = xtc_db_query("select final_price, products_tax, allow_tax from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int) $_POST['oID'] . "' ");
 while ($products = xtc_db_fetch_array($products_query)) {
     $tax_rate = $products['products_tax'];
     if ($products['allow_tax'] == '1') {
         $bprice = $products['final_price'];
         $nprice = $xtPrice->xtcRemoveTax($bprice, $tax_rate);
         $tax = $xtPrice->calcTax($nprice, $tax_rate);
     } else {
         $nprice = $products['final_price'];
         $bprice = $xtPrice->xtcAddTax($nprice, $tax_rate);
         $tax = $xtPrice->calcTax($nprice, $tax_rate);
     }
     $sql_data_array = array('orders_id' => (int) $_POST['oID'], 'n_price' => xtc_db_prepare_input($nprice), 'b_price' => xtc_db_prepare_input($bprice), 'tax' => xtc_db_prepare_input($tax), 'tax_rate' => xtc_db_prepare_input($products['products_tax']));
     $insert_sql_data = array('class' => 'products');
     $sql_data_array = xtc_array_merge($sql_data_array, $insert_sql_data);
     xtc_db_perform(TABLE_ORDERS_RECALCULATE, $sql_data_array);
 }
 //EOF####### Produkte #######//
 //BOF#######  Produkte Steuersätze  #######//
 $tax_query = xtc_db_query("SELECT tax_rate, SUM(tax) as tax_value\n                               FROM " . TABLE_ORDERS_RECALCULATE . "\n                              WHERE orders_id = '" . (int) $_POST['oID'] . "'\n                                AND class = 'products'\n                           GROUP BY tax_rate\n                            ");
 while ($tax = xtc_db_fetch_array($tax_query)) {
コード例 #2
0
 public function createDocument($bill_nr = '', $save = false, $download = false)
 {
     require_once DIR_FS_INC . 'xtc_get_vpe_name.inc.php';
     require_once DIR_FS_INC . 'xtc_get_tax_rate.inc.php';
     if ($this->connection != true) {
         $this->makeConnection();
     }
     if (!is_object($xtPrice)) {
         require_once DIR_FS_CATALOG . 'includes/classes/xtcPrice.php';
         $xtPrice = new xtcPrice($this->info['currency'], $this->info['status']);
     }
     $this->setCustomersTaxRate();
     if (!is_object($document)) {
         $document = new stdClass();
     }
     $document->documentID = $this->getDocumentID($bill_nr);
     $document->customerID = $this->customers->customerID;
     $document->currency = $this->info['currency'];
     $document->documentNumber = $bill_nr;
     $positions = array();
     for ($i = 0, $n = sizeof($this->products); $i < $n; $i++) {
         $attributes = '';
         $attributes_total = 0;
         if (isset($this->products[$i]['attributes']) && sizeof($this->products[$i]['attributes']) > 0) {
             for ($j = 0, $n2 = sizeof($this->products[$i]['attributes']); $j < $n2; $j++) {
                 $attributes_value = trim($this->products[$i]['attributes'][$j]['value']);
                 //$products_array attributes output adjustments (overrides)
                 $products_array[$i]['attributes'][$j]['value'] = $attributes_value;
                 $products_array[$i]['attributes'][$j]['price'] = $attributes_price;
                 if ($attributes_value != '') {
                     $attributes .= ' ' . $this->products[$i]['attributes'][$j]['option'] . ': ' . $attributes_value;
                     $attributes_total += $this->products[$i]['attributes'][$j]['price'];
                 }
             }
         }
         $positions[$i]->positionType = 'POSITION';
         $positions[$i]->itemNumber = xtc_not_null($this->products[$i]['model']) ? $this->products[$i]['model'] : $this->products[$i]['id'];
         $positions[$i]->companyPositionID = $this->products[$i]['id'];
         $positions[$i]->itemDescription = utf8_encode($this->products[$i]['name'] . $attributes);
         $positions[$i]->count = $this->products[$i]['qty'];
         $positions[$i]->unit = utf8_encode(xtc_not_null($this->products[$i]['vpe']) && $this->products[$i]['vpe'] != '0' ? xtc_get_vpe_name($this->products[$i]['vpe']) : EASYBILL_UNIT);
         $positions[$i]->ustPercent = $this->products[$i]['tax'];
         if ($this->products[$i]['allow_tax'] == 1) {
             $this->customer['allow_tax'] = 1;
             $positions[$i]->singlePriceNetto = floatval($xtPrice->xtcRemoveTax($this->products[$i]['price'], $positions[$i]->ustPercent) * 100);
         } else {
             $positions[$i]->singlePriceNetto = floatval($this->products[$i]['price'] * 100);
         }
     }
     for ($t = 0, $n = sizeof($this->totals); $t < $n; $t++) {
         switch ($this->totals[$t]['class']) {
             case 'ot_subtotal':
             case 'ot_tax':
             case 'ot_subtotal_no_tax':
             case 'ot_total':
                 // muss nicht übergeben werden
                 break;
             case 'ot_shipping':
                 $positions[$i]->positionType = 'POSITION';
                 $positions[$i]->count = 1;
                 $positions[$i]->unit = utf8_encode(EASYBILL_UNIT);
                 $positions[$i]->itemDescription = utf8_encode(rtrim(strip_tags($this->totals[$t]['title']), ':'));
                 $positions[$i]->ustPercent = $this->getShippingTax();
                 if ($this->customer['allow_tax'] == 1) {
                     $positions[$i]->singlePriceNetto = floatval($xtPrice->xtcRemoveTax($this->totals[$t]['value'], $positions[$i]->ustPercent) * 100);
                 } else {
                     $positions[$i]->singlePriceNetto = floatval($this->totals[$t]['value'] * 100);
                 }
                 // BOC - Hack for wolf-online-shop.de - delete Shipping if cost = 0
                 if ($positions[$i]->singlePriceNetto == 0) {
                     unset($positions[$i]);
                     $i--;
                 }
                 // EOC - Hack for wolf-online-shop.de - delete Shipping if cost = 0
                 $i++;
                 break;
             case 'ot_payment':
                 $positions[$i]->positionType = 'POSITION';
                 $positions[$i]->count = 1;
                 $positions[$i]->unit = utf8_encode(EASYBILL_UNIT);
                 $positions[$i]->itemDescription = utf8_encode(rtrim(strip_tags($this->totals[$t]['title']), ':'));
                 $positions[$i]->ustPercent = 0;
                 $positions[$i]->singlePriceNetto = floatval($this->totals[$t]['value'] * 100);
                 $i++;
                 break;
             case 'ot_billpay_fee':
             case 'ot_billpaybusiness_fee':
             case 'ot_billpaydebit_fee':
             case 'ot_billpaytc_surcharge':
             case 'ot_coupon':
             case 'ot_discount':
             case 'ot_gv':
             case 'ot_ps_fee':
             case 'ot_loworderfee':
             case 'ot_cod_fee':
             case 'ot_shippingfee':
                 $positions[$i]->positionType = 'POSITION';
                 $positions[$i]->count = 1;
                 $positions[$i]->unit = utf8_encode(EASYBILL_UNIT);
                 $positions[$i]->itemDescription = utf8_encode(rtrim(strip_tags($this->totals[$t]['title']), ':'));
                 $positions[$i]->ustPercent = $this->getOrderTotalTax($this->totals[$t]['class']);
                 if ($this->customer['allow_tax'] == 1) {
                     $positions[$i]->singlePriceNetto = floatval($xtPrice->xtcRemoveTax($this->totals[$t]['value'], $positions[$i]->ustPercent) * 100);
                 } else {
                     $positions[$i]->singlePriceNetto = floatval($this->totals[$t]['value'] * 100);
                 }
                 $i++;
                 break;
             default:
                 $positions[$i]->positionType = 'POSITION';
                 $positions[$i]->count = 1;
                 $positions[$i]->unit = utf8_encode(EASYBILL_UNIT);
                 $positions[$i]->itemDescription = utf8_encode(rtrim(strip_tags($this->totals[$t]['title']), ':'));
                 $positions[$i]->ustPercent = xtc_get_tax_rate(MODULE_EASYBILL_STANDARD_TAX_CLASS, $this->customer['country_id'], $this->customer['zone_id']);
                 if ($this->customer['allow_tax'] == 1) {
                     $positions[$i]->singlePriceNetto = floatval($xtPrice->xtcRemoveTax($this->totals[$t]['value'], $positions[$i]->ustPercent) * 100);
                 } else {
                     $positions[$i]->singlePriceNetto = floatval($this->totals[$t]['value'] * 100);
                 }
                 $i++;
                 break;
         }
     }
     $document->documentPosition = $positions;
     // Text before Positions
     $textPrefix = EASYBILL_PAYMENT_HEADING . $this->getPaymentMethod();
     $textPrefix .= EASYBILL_EOL;
     $textPrefix .= EASYBILL_PAYMENT_HEADING_II . $this->info['order_id'];
     $document->textPrefix = utf8_encode($textPrefix);
     // Text after Positions
     $document->text = utf8_encode(constant(strtoupper('MODULE_EASYBILL_PAYMENT_TEXT_' . $this->info['payment_method'])));
     if ($this->info['payment_method'] == 'billpay') {
         $document->text .= $this->getBankData();
     }
     //SOAP Call
     try {
         $this->document = $this->client->CreateDocument($document);
     } catch (SoapFault $e) {
         $this->error[] = $e;
     }
     if ($save == true) {
         $this->saveDocument($this->document->document->documentID, $download);
     } elseif ($download == true) {
         $this->downloadDocument($this->document->document->documentID);
     }
     // After Process
     $this->after_process();
     if (MODULE_EASYBILL_DO_AUTO_PAYMENT == 'True') {
         $check = explode(';', MODULE_EASYBILL_NO_AUTO_PAYMENT);
         if (!in_array($this->info['payment_method'], $check)) {
             $this->setPayment($this->document->document->documentID);
         }
     }
 }