VD : debug require_once('../logger/include.php'); // <- VD class manualOrder { var $info, $totals, $products, $customer, $delivery; function manualOrder($order_id) { $this->info = array(); $this->totals = array(); $this->products = array(); $this->customer = array(); $this->delivery = array(); // -> VDSTCMD : affichage du stock courant dans les commandes admin $this->stock = array(); // <- VDSTCMD $this->query($order_id); } function query($order_id) { // -> VDORED5066 // TIP : totals : array of of table total orders sorted by sort_order // <- VDORED5066 global $shipping; $order_query = tep_db_query("select * from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'"); $order = tep_db_fetch_array($order_query); $totals_query = tep_db_query("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order"); while ($totals = tep_db_fetch_array($totals_query)) { $this->totals[] = array( 'title' => $totals['title'], 'text' => $totals['text'], 'class' => $totals['class'], 'value' => $totals['value'], 'sort_order' => $totals['sort_order'], 'orders_total_id' => $totals['orders_total_id']); } $this->info = array('currency' => $order['currency'], 'currency_value' => $order['currency_value'], 'payment_method' => $order['payment_method'], 'cc_type' => $order['cc_type'], 'cc_owner' => $order['cc_owner'], 'cc_number' => $order['cc_number'], 'cc_expires' => $order['cc_expires'], 'date_purchased' => $order['date_purchased'], 'orders_status' => $order['orders_status'], 'last_modified' => $order['last_modified'], 'shipping_method' => $shipping['title'], 'shipping_cost' => $shipping['cost'], 'shipping_id' => $order['shipping_module'], 'subtotal' => 0, 'orders_comments' => $order['orders_comments'], // -> VDORED5066 'subtotal_wotax' => 0, 'total_wotax' => 0, // <- VDORED5066 'tax' => 0, 'tax_groups' => array()); $this->customer = array('id' => $order['customers_id'], 'name' => $order['customers_name'], 'company' => $order['customers_company'], 'street_address' => $order['customers_street_address'], 'suburb' => $order['customers_suburb'], 'city' => $order['customers_city'], 'postcode' => $order['customers_postcode'], 'state' => $order['customers_state'], 'country' => $order['customers_country'], 'country_id' => oe_get_country_id($order['customers_country']), 'zone_id' => oe_get_zone_id(oe_get_country_id($order['customers_country']), $order['customers_state']), 'format_id' => $order['customers_address_format_id'], 'telephone' => $order['customers_telephone'], 'email_address' => $order['customers_email_address']); $this->delivery = array('name' => $order['delivery_name'], 'company' => $order['delivery_company'], 'street_address' => $order['delivery_street_address'], 'suburb' => $order['delivery_suburb'], 'city' => $order['delivery_city'], 'postcode' => $order['delivery_postcode'], 'state' => $order['delivery_state'], 'country' => $order['delivery_country'], 'country_id' => oe_get_country_id($order['delivery_country']), 'zone_id' => oe_get_zone_id(oe_get_country_id($order['delivery_country']), $order['delivery_state']), 'format_id' => $order['delivery_address_format_id']); $this->billing = array('name' => $order['billing_name'], 'company' => $order['billing_company'], 'street_address' => $order['billing_street_address'], 'suburb' => $order['billing_suburb'], 'city' => $order['billing_city'], 'postcode' => $order['billing_postcode'], 'state' => $order['billing_state'], 'country' => $order['billing_country'], 'country_id' => oe_get_country_id($order['billing_country']), 'zone_id' => oe_get_zone_id(oe_get_country_id($order['billing_country']), $order['billing_state']), 'format_id' => $order['billing_address_format_id']); $index = 0; // -> OSC-1 : Edition des produits livrés dans les commandes // -> MARP256 $orders_products_query = tep_db_query("select orders_products_id, products_id, products_name, products_model, products_price, products_cost, products_tax, products_quantity, qty_sent, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "' order by orders_products_id"); // <- MARP256 // <- OSC-1 : Edition des produits livrés dans les commandes while ($orders_products = tep_db_fetch_array($orders_products_query)) { $orders_products_tax_query = tep_db_query("select products_tax_class_id from " .TABLE_PRODUCTS . " where products_id = " . $orders_products['products_id'] . ""); $orders_products_tax = tep_db_fetch_array($orders_products_tax_query); $this->products[$index] = array( // -> OSC-1 : Edition des produits livrés dans les commandes 'qty' => $orders_products['products_quantity'], 'qty_sent' => $orders_products['qty_sent'], // <- OSC-1 : Edition des produits livrés dans les commandes 'name' => $orders_products['products_name'], 'model' => $orders_products['products_model'], 'tax' => $orders_products['products_tax'], 'tax_description' => tep_get_tax_description($orders_products_tax['products_tax_class_id'], $this->delivery["country_id"], $this->delivery["zone_id"]), 'price' => $orders_products['products_price'], // -> MARP256 'cost' => $orders_products['products_cost'], // <- MARP256 'final_price' => $orders_products['final_price'], 'products_id' => $orders_products['products_id'], 'orders_products_id' => $orders_products['orders_products_id']); $subindex = 0; $attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix, orders_products_attributes_id from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'"); if (tep_db_num_rows($attributes_query)) { while ($attributes = tep_db_fetch_array($attributes_query)) { $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'], 'value' => $attributes['products_options_values'], 'prefix' => $attributes['price_prefix'], 'price' => $attributes['options_values_price'], 'orders_products_attributes_id' => $attributes['orders_products_attributes_id']); $subindex++; } } $shown_price = tep_add_tax($this->products[$index]['final_price'] * $this->products[$index]['qty'], $this->products[$index]['tax']) ; $this->info['subtotal'] += $shown_price; // -> VDORED5066 $this->info['subtotal_wotax'] += $this->products[$index]['final_price'] * $this->products[$index]['qty']; // <- VDORED5066 $products_tax = $this->products[$index]['tax']; $products_tax_description = $this->products[$index]['tax_description']; // -> VDORED5066 : shown price have always taxes !!! if (true or DISPLAY_PRICE_WITH_TAX == 'true') { // <- VDORED5066 $this->info['tax'] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); if (isset($this->info['tax_groups']["$products_tax_description"])) { $this->info['tax_groups']["$products_tax_description"] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); } else { $this->info['tax_groups']["$products_tax_description"] = $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); } } else { $this->info['tax'] += ($products_tax / 100) * $shown_price; if (isset($this->info['tax_groups']["$products_tax_description"])) { $this->info['tax_groups']["$products_tax_description"] += ($products_tax / 100) * $shown_price; } else { $this->info['tax_groups']["$products_tax_description"] = ($products_tax / 100) * $shown_price; } } $index++; } // -> VDORED5066 : shown price have always taxes !!! if (true or DISPLAY_PRICE_WITH_TAX == 'true') { $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost']; $this->info['total_wotax'] = $this->info['subtotal_wotax'] + $this->info['shipping_cost']; // $shipping['tax'] = 19.6; // pas très jolie, jolie, mais cette valeur était 'null' // print "tax=" . $this->info['tax'] . " shipping_cost=" . $this->info['shipping_cost']; // $this->info['tax'] += ( $shipping['tax'] / 100 ) * $this->info['shipping_cost']; // $this->info['total'] = $this->info['total_wotax'] + $this->info['tax']; // $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost']; // <- VDORED5066 } else { $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost']; } } // -> VDSTCMD : affichage du stock courant dans les commandes admin function update_stock() { $this->stock = array(); if (sizeof($this->products)) { $stock_sql = "SELECT products_quantity,products_id FROM " . TABLE_PRODUCTS . " WHERE products_id = 1"; for ($i=0; $iproducts); $i++) { $stock_sql .= " or products_id = " . $this->products[$i]['products_id']; } $stock_query = tep_db_query($stock_sql); while ($s = tep_db_fetch_array($stock_query)) { $this->stock[$s['products_id']] = $s['products_quantity']; } // var_dump($this->stock); } } function get_text_stock($id) { $txt = ""; if (array_key_exists($id, $this->stock)) { $txt .= "
("; if ($this->stock[$id] > 0) { $txt .= "+"; } $txt .= $this->stock[$id]; $txt .= ")
"; } return $txt; } // <- VDSTCMD function adjust_zones() { $customer_country_id = oe_get_country_id($this->customer['country']); $this->customer['country'] = array('id' => $customer_country_id, 'title' => $this->customer['country'], 'iso_code_2' => oe_get_country_iso_code_2($customer_country_id), 'iso_code_3' => oe_get_country_iso_code_3($customer_country_id)); $this->customer['zone_id'] = oe_get_zone_id($customer_country_id, $this->customer['state']); $billing_country_id = oe_get_country_id($this->billing['country']); $this->billing['country'] = array('id' => $billing_country_id, 'title' => $this->billing['country'], 'iso_code_2' => oe_get_country_iso_code_2($billing_country_id), 'iso_code_3' => oe_get_country_iso_code_3($billing_country_id)); $this->billing['zone_id'] = oe_get_zone_id($billing_country_id, $this->billing['state']); $delivery_country_id = oe_get_country_id($this->delivery['country']); $this->delivery['country'] = array('id' => $delivery_country_id, 'title' => $this->delivery['country'], 'iso_code_2' => oe_get_country_iso_code_2($delivery_country_id), 'iso_code_3' => oe_get_country_iso_code_3($delivery_country_id)); $this->delivery['zone_id'] = oe_get_zone_id($delivery_country_id, $this->delivery['state']); } function adjust_totals($order_id) { $totals_query = tep_db_query("select orders_total_id, title, text, class, value from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order"); $this->totals = array(); $i=0; while ($totals = tep_db_fetch_array($totals_query)) { if ($totals['class'] == 'ot_shipping') $shipping_index = $i; $this->totals[] = array('title' => $totals['title'], 'text' => $totals['text'], 'class' => $totals['class'], 'value' => $totals['value'], 'orders_total_id' => $totals['orders_total_id']); $this->totals[] = array('title' => '', 'text' => '', 'class' => 'ot_custom', 'value' => '', 'orders_total_id' => '0'); $i=$i+2; } array_pop($this->totals); return $shipping_index; } } ?>