'm', 'customers_firstname' => $_POST["customer_firstname"], 'customers_lastname' => $_POST["customer_lastname"], 'customers_dob' => '1970-01-01 00:00:00', 'entry_tva_intracom' => $_POST["customer_tva"], 'customers_email_address' => $_POST["customer_mail"], // 'customers_default_address_id' => , // will be set later 'customers_telephone' => $_POST["customer_phone"], 'customers_password' => "" ); tep_db_perform(TABLE_CUSTOMERS, $sql_data_array); $new_customer_id = tep_db_insert_id(); $sql_data_array = array( 'customers_id' => $new_customer_id, 'entry_gender' => 'm', 'entry_company' => $_POST["customer_compagny"], 'entry_tva_intracom' => $_POST["customer_tva"], 'entry_firstname' => $_POST["customer_firstname"], 'entry_lastname' => $_POST["customer_lastname"], 'entry_street_address' => $_POST["customer_adress"], 'entry_suburb' => '', 'entry_postcode' => $_POST["customer_zipcode"], 'entry_city' => $_POST["customer_city"], 'entry_state' => '', 'entry_country_id' => '74', 'entry_zone_id' => 0 ); tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array); $address_book_id = tep_db_insert_id(); $sql_data_array = array( 'customers_id' => $new_customer_id, 'customers_default_address_id' => $address_book_id ); tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', 'customers_id = ' . $new_customer_id); $sql_data_array = array( 'customers_info_id' => $new_customer_id, 'customers_info_date_account_created' => "now()" ); tep_db_perform(TABLE_CUSTOMERS_INFO, $sql_data_array); $customer_id = $new_customer_id; } $update_customer_id_devis = tep_db_query('UPDATE devis SET customers_id="'.$customer_id.'" WHERE customers_name="'.$_POST["customer_firstname"].' '.$_POST["customer_lastname"].'"'); $numprod = $_POST["numprod"]; $taxe = $_POST["taxe"]; $sql_data_array = array('customers_id' => $customer_id, 'customers_name' =>$_POST["customer_firstname"] . ' ' .$_POST["customer_lastname"], 'customers_company' => $_POST["customer_compagny"], 'customers_street_address' => $_POST["customer_street"], 'customers_suburb' => '', 'customers_city' => $_POST["customer_city"], 'customers_postcode' => $_POST["customer_zipcode"], 'customers_state' => $_POST["customer_country"], 'customers_country' => $_POST["customer_country"], 'customers_telephone' => $_POST["customer_phone"], 'customers_email_address' => $_POST["customer_mail"], 'customers_address_format_id' => $order->customer['format_id'], 'delivery_name' => $_POST["customer_firstname_shipping"] . ' ' . $_POST["customer_lastname_shipping"], 'delivery_company' => $_POST["customer_shipping_compagny"], 'delivery_street_address' => $_POST["customer_adress_shipping"], 'delivery_suburb' => '', 'delivery_city' => $_POST["customer_city_shipping"], 'delivery_postcode' => $_POST["customer_zipcode_shipping"], 'delivery_state' => '', 'delivery_country' => $_POST["customer_country_shipping"], 'delivery_address_format_id' => $order->delivery['format_id'], 'billing_name' => $_POST["customer_firstname"] . ' ' . $_POST["customer_lastname"], 'billing_company' => $_POST["customer_compagny"], // -> TVAINT 'billing_tva_intracom' => $order->billing['tva_intracom'], // <- TVAINT 'billing_street_address' => $_POST["customer_street"], 'billing_suburb' => '', 'billing_city' => $_POST["customer_city"], 'billing_postcode' => $_POST["customer_zipcode"], 'billing_state' => '', 'billing_country' => $_POST["customer_country"], 'billing_address_format_id' => $order->billing['format_id'], 'payment_method' => $order->info['payment_method'], // -> ORED5066 'shipping_module' => $shipping['id'], // <- ORED5066 'cc_type' => $order->info['cc_type'], 'cc_owner' => $order->info['cc_owner'], 'cc_number' => $order->info['cc_number'], 'cc_expires' => $order->info['cc_expires'], 'date_purchased' => 'now()', 'orders_status' => $order->info['order_status'], 'currency' => $order->info['currency'], 'currency_value' => $order->info['currency_value']); tep_db_perform(TABLE_ORDERS, $sql_data_array); $insert_id = tep_db_insert_id(); for ($i=0; $i < $num_prod ; $i++) { $product_query = tep_db_query("select * from " . TABLE_PRODUCTS . " where products_model = '".$_POST["ref".$i]."'"); $product = tep_db_fetch_array($product_query); $sql_data_array = array('orders_id' => $insert_id, 'products_id' => $product["products_id"], 'products_model' => $_POST["ref".$i], 'products_name' => $_POST["product".$i], 'products_price' => $_POST["price".$i], // -> MARP256 'products_cost' => $product ["products_cost"], // <- MARP256 'final_price' => $_POST["price".$i], 'products_tax' =>$taxe, 'products_quantity' => $_POST["qty".$i]); tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array); $new_product_id = tep_db_insert_id(); var_dump($prduct); $order_query = tep_db_query(" SELECT products_id, products_quantity FROM " . TABLE_ORDERS_PRODUCTS . " WHERE orders_id = '" . (int)$insert_id . "' AND orders_products_id = '" . (int)$product["products_id"] . "'"); $order_products = tep_db_fetch_array($order_query); // First we do a stock check if ($_POST["qty".$i] != $order_products['products_quantity']){ if (STOCK_LIMITED == 'true'){ tep_db_query("UPDATE " . TABLE_PRODUCTS . " SET products_quantity = products_quantity - " . $_POST["qty".$i] . ", products_ordered = products_ordered + " . $_POST["qty".$i] . " WHERE products_id = '" . (int)$product["products_id"] . "'"); } else { tep_db_query ("UPDATE " . TABLE_PRODUCTS . " SET products_ordered = products_ordered + " . $_POST["qty".$i] . " WHERE products_id = '" . (int)$product["products_id"] . "'"); } } } $sql_data_array = array('orders_id' => $insert_id, 'orders_status_id' => $new_value, 'date_added' => 'now()'); tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array); $subtotalHT=(float)number_format(($totalHT+$_POST['customer_shipping_cost'])*0.2,2); $totalTTC= (float)number_format(($totalHT+$_POST['customer_shipping_cost'])*1.2,2); // -> VDMANORM155 $sql_data_array = array('orders_id' => $insert_id, 'title' => TEXT_SUBTOTAL_WOTAX, 'text' => number_format($_POST['totalHT'],2)."EUR", 'value' => (float)number_format($_POST['totalHT'],2), 'class' => "ot_subtotal_wotax", 'sort_order' => 1); tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array); $sql_data_array = array('orders_id' => $insert_id, 'title' => "frais de livraison:", 'text' => number_format($_POST['customer_shipping_cost'],2).'EUR', 'value' => (float)number_format($_POST['customer_shipping_cost'],2), 'class' => "ot_shipping", 'sort_order' => 2); tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array); tep_db_query("UPDATE " . TABLE_ORDERS . " SET shipping_module = '" . "tableadv2_tableadv2" . "' WHERE orders_id = '" . (int)$insert_id . "'"); $sql_data_array = array('orders_id' => $insert_id, 'title' => TEXT_TOTAL_WOTAX, 'text' => number_format($_POST['customer_shipping_cost']+$totalHT,2)."EUR", 'value' => (float)number_format($_POST['customer_shipping_cost']+$totalHT,2), 'class' => "ot_total_wotax", 'sort_order' => 3); tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array); if ($taxe != 0 ) { $sql_data_array = array('orders_id' => $insert_id, 'title' => 'TVA 20%:', 'text' => number_format(($totalHT+$_POST['customer_shipping_cost'])*0.2,2).'EUR', 'value' => $totalTTC-$subtotalHT, 'class' => "ot_tax", 'sort_order' => 4); tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array); $sql_data_array = array('orders_id' => $insert_id, 'title' => TEXT_TOTAL, 'text' => number_format(($totalHT+$_POST['customer_shipping_cost'])*1.2,2).'EUR', 'value' => $totalTTC, 'class' => "ot_total", 'sort_order' => 6); tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array); } else { $sql_data_array = array('orders_id' => $insert_id, 'title' => TEXT_TOTAL, 'text' => number_format(($totalHT+$_POST['customer_shipping_cost']),2).'EUR', 'value' => $totalTTC, 'class' => "ot_total", 'sort_order' => 6); tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array); } tep_redirect(tep_href_link(FILENAME_ORDERS_EDIT, 'oID=' . $insert_id, 'SSL')); require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>