> <?php echo TITLE; ?>
$year_filter=date("Y")-1; $orders_list_query = tep_db_query("SELECT orders_id, date_purchased FROM orders where YEAR(date_purchased) >= " . $year_filter . " ORDER BY orders_id"); // vd: <- $orders_list_array = array(); $orders_list_array[] = array('id' => '', 'text' => '---'); while ($orders_list = tep_db_fetch_array($orders_list_query)) { $orders_list_array[] = array('id' => $orders_list['orders_id'], 'text' => $orders_list['orders_id']." - ".tep_date_short($orders_list['date_purchased'])); } echo '  ' . tep_draw_pull_down_menu('start', $orders_list_array, (isset($_GET['orders_id']) ? $_GET['orders_id'] : ''), 'size="1"') . '   '; ?>
 
 
 
= $start ORDER BY orders_id"); // if both fields are filed in we select orders betwenn $start and $end } else { $orders = tep_db_query("SELECT orders_id, payment_method, date_purchased, customers_name, cc_owner, customers_company, customers_email_address, billing_street_address, billing_city, billing_state, billing_postcode, billing_country, customers_telephone, delivery_name, delivery_company, delivery_street_address, delivery_city, delivery_state, delivery_postcode, delivery_country, cc_type, cc_number, cc_expires FROM orders WHERE orders_id >= $start AND orders_id <= $end ORDER BY orders_id"); } //patch //$csv_output ="\n"; while ($row_orders = mysql_fetch_array($orders)) { //start one loop $Orders_id = $row_orders["orders_id"]; $Date1 = $row_orders["date_purchased"]; //list($Date, $Time) = explode (' ',$Date1); $Date = date('m/d/Y', strtotime($Date1)); $Time= date('H:i:s', strtotime($Date1)); $Name_On_Card1 = $row_orders["customers_name"]; $Name_On_Card = filter_text($Name_On_Card1);// order changed list($First_Name,$Last_Name) = explode(', ',$Name_On_Card1); // order changed $Company = filter_text($row_orders["customers_company"]); $email = filter_text($row_orders["customers_email_address"]); $Billing_Address_1 = filter_text($row_orders["billing_street_address"]); $Billing_Address_2 = ""; $Billing_City = filter_text($row_orders["billing_city"]); $Billing_State = filter_text($row_orders["billing_state"]); $Billing_Zip = filter_text($row_orders["billing_postcode"]); $Billing_Country = str_replace("(48 Contiguous Sta", "", $row_orders["billing_country"]); $Billing_Phone = filter_text($row_orders["customers_telephone"]); $ShipTo_Name1 = $row_orders["delivery_name"]; $ShipTo_Name = filter_text($ShipTo_Name1); // order changed list($ShipTo_First_Name,$ShipTo_Last_Name) = explode(', ',$ShipTo_Name1); // order changed $ShipTo_Company = filter_text($row_orders["delivery_company"]); $ShipTo_Address_1 = filter_text($row_orders["delivery_street_address"]); $ShipTo_Address_2 = ""; $ShipTo_City = filter_text($row_orders["delivery_city"]); $ShipTo_State = filter_text($row_orders["delivery_state"]); $ShipTo_Zip = filter_text($row_orders["delivery_postcode"]); $ShipTo_Country = str_replace("(48 Contiguous Sta", "", $row_orders["delivery_country"]); $ShipTo_Phone = ""; $Payment_Method = filter_text($row_orders["payment_method"]); $Card_Type = $row_orders["cc_type"]; $Card_Number = $row_orders["cc_number"]; $Exp_Date = $row_orders["cc_expires"]; $Bank_Name = ""; $Gateway = ""; $AVS_Code = ""; $Transaction_ID = ""; $Order_Special_Notes = ""; // -> OSC-6 : export des commandes éronné //-------------------- INITIALISATION ------------------------------------// $Comments = ""; $Order_Subtotal = 0; $Order_SubtotalWoTax = 0; $Order_TotalWoTax = 0; $Order_Tax = 0; $Order_Insurance = 0; $Order_Shipping_Total = 0; $Small_Order_Fee = 0; $Order_Grand_Total = 0; $Number_of_Items = 0; // <- OSC-6 // -------------------- QUERIES 1 ------------------------------------// //Orders_status_history for comments $orders_status_history = tep_db_query("select comments from orders_status_history where orders_id = " . $Orders_id); //$row_orders_status_history = tep_db_fetch_array($comments); while($row_orders_status_history = mysql_fetch_array($orders_status_history)) { // end // $Comments = filter_text($row_orders_status_history["comments"]); } // -------------------- QUERIES 2 ------------------------------------// //Orders_subtotal $orders_subtotal = tep_db_query("select value from orders_total where class = 'ot_subtotal' and orders_id = " . $Orders_id); //$row_orders_subtotal = tep_db_fetch_array($orders_subtotal); while($row_orders_subtotal = mysql_fetch_array($orders_subtotal)) { // end // $Order_Subtotal = filter_text($row_orders_subtotal["value"]); } // -------------------- QUERIES 2.1 ------------------------------------// //Orders_subtotal_wotax $orders_subtotal_wotax = tep_db_query("select value from orders_total where class = 'ot_subtotal_wotax' and orders_id = " . $Orders_id); while($row_orders_subtotal_wotax = mysql_fetch_array($orders_subtotal_wotax)) { // end // $Order_SubtotalWoTax = filter_text($row_orders_subtotal_wotax["value"]); } // -------------------- QUERIES 2.2 ------------------------------------// //Orders_total_wotax $orders_total_wotax = tep_db_query("select value from orders_total where class = 'ot_total_wotax' and orders_id = " . $Orders_id); while($row_orders_total_wotax = mysql_fetch_array($orders_total_wotax)) { // end // $Order_TotalWoTax = filter_text($row_orders_total_wotax["value"]); } // -------------------- QUERIES 3 ------------------------------------// //Orders_tax $orders_tax = tep_db_query("select value from orders_total where class = 'ot_tax' and orders_id = " . $Orders_id); //$row_orders_tax = tep_db_fetch_array($orders_tax); while($row_orders_tax = mysql_fetch_array($orders_tax)) { // end // $Order_Tax = filter_text($row_orders_tax["value"]); } // -------------------- QUERIES 4 ------------------------------------// //Orders_Insurance $orders_insurance = tep_db_query("select value from orders_total where class = 'ot_insurance' and orders_id = " . $Orders_id); //$row_orders_insurance = tep_db_fetch_array($orders_insurance); while($row_orders_insurance = mysql_fetch_array($orders_insurance)) { // end // $Order_Insurance = filter_text($row_orders_insurance["value"]); } $Tax_Exempt_Message = ""; // -------------------- QUERIES 5 ------------------------------------// //Orders_Shipping $orders_shipping = tep_db_query("select title, value from orders_total where class = 'ot_shipping' and orders_id = " . $Orders_id); //$row_orders_shipping = tep_db_fetch_array($orders_shipping); while($row_orders_shipping = mysql_fetch_array($orders_shipping)) { // end // $Order_Shipping_Total = $row_orders_shipping["value"]; $Shipping_Method = filter_text($row_orders_shipping["title"]); // Shipping method from query 5 } // -------------------- QUERIES 6 ------------------------------------// //Orders_Residential Del Fee (Giftwrap) $orders_residential_fee = tep_db_query("select value from orders_total where class = 'ot_giftwrap' and orders_id = " . $Orders_id); //$row_orders_residential_fee = tep_db_fetch_array($orders_residential_fee); while($row_orders_residential_fee = mysql_fetch_array($orders_residential_fee)) { // end // $Small_Order_Fee = $row_orders_residential_fee["value"]; } //////////////////////////////////// $Discount_Rate = ""; $Discount_Message = ""; $CODAmount = ""; // -------------------- QUERIES 7 ------------------------------------// //Orders_Total $orders_total = tep_db_query("select value from orders_total where class = 'ot_total' and orders_id = " . $Orders_id); //$row_orders_total = tep_db_fetch_array($orders_total); while($row_orders_total = mysql_fetch_array($orders_total)) { // end // $Order_Grand_Total = $row_orders_total["value"]; } // -------------------- QUERIES 8 ------------------------------------// //Products COunt $orders_count = tep_db_query("select count(products_quantity) as o_count from orders_products where orders_id = " . $Orders_id); //$row_orders_total = tep_db_fetch_array($orders_total); while($row_orders_count = mysql_fetch_array($orders_count)) { // end // $Number_of_Items = $row_orders_count[0]; // used array to show the number of items ordered } // $Shipping_Weight = ""; $Coupon_Code = ""; $Order_security_msg = ""; $Order_Surcharge_Amount = ""; $Order_Surcharge_Something = ""; $Affiliate_code = ""; $Sentiment_message = ""; $Checkout_form_type = ""; $Card_CVV_value = $row_orders["cvvnumber"]; $future1 = ""; $future2 = ""; $future3 = ""; $future4 = ""; $future5 = ""; $future6 = ""; $future7 = ""; $future8 = ""; $future9 = ""; // csv settings $CSV_NEWLINE = "\r\n"; $csv_output .= $Orders_id . $CSV_SEPARATOR ; $csv_output .= $Date . $CSV_SEPARATOR ; $csv_output .= $Time . $CSV_SEPARATOR ; $csv_output .= $First_Name . $CSV_SEPARATOR ; $csv_output .= $Last_Name . $CSV_SEPARATOR ; $csv_output .= $Name_On_Card . $CSV_SEPARATOR ; $csv_output .= $Company . $CSV_SEPARATOR ; $csv_output .= $email . $CSV_SEPARATOR ; $csv_output .= $Billing_Address_1 . $CSV_SEPARATOR ; $csv_output .= $Billing_Address_2 . $CSV_SEPARATOR ; $csv_output .= $Billing_City . $CSV_SEPARATOR ; $csv_output .= $Billing_State . $CSV_SEPARATOR ; $csv_output .= $Billing_Zip . $CSV_SEPARATOR ; $csv_output .= $Billing_Country . $CSV_SEPARATOR ; $csv_output .= $Billing_Phone . $CSV_SEPARATOR ; $csv_output .= $ShipTo_First_Name . $CSV_SEPARATOR ; $csv_output .= $ShipTo_Last_Name . $CSV_SEPARATOR ; $csv_output .= $ShipTo_Name . $CSV_SEPARATOR ; $csv_output .= $ShipTo_Company . $CSV_SEPARATOR ; $csv_output .= $ShipTo_Address_1 . $CSV_SEPARATOR ; $csv_output .= $ShipTo_Address_2 . $CSV_SEPARATOR ; $csv_output .= $ShipTo_City . $CSV_SEPARATOR ; $csv_output .= $ShipTo_State . $CSV_SEPARATOR ; $csv_output .= $ShipTo_Zip . $CSV_SEPARATOR ; $csv_output .= $ShipTo_Country . $CSV_SEPARATOR ; $csv_output .= $ShipTo_Phone . $CSV_SEPARATOR ; $csv_output .= $Payment_Method . $CSV_SEPARATOR ; $csv_output .= $Card_Type . $CSV_SEPARATOR ; $csv_output .= $Card_Number . $CSV_SEPARATOR ; $csv_output .= $Exp_Date . $CSV_SEPARATOR ; $csv_output .= $Bank_Name . $CSV_SEPARATOR ; $csv_output .= $Gateway . $CSV_SEPARATOR ; $csv_output .= $AVS_Code . $CSV_SEPARATOR ; $csv_output .= $Transaction_ID . $CSV_SEPARATOR ; $csv_output .= $Order_Special_Notes . $CSV_SEPARATOR ; $csv_output .= $Comments . $CSV_SEPARATOR ; $csv_output .= $Order_SubtotalWoTax . $CSV_SEPARATOR ; $csv_output .= $Order_TotalWoTax . $CSV_SEPARATOR ; $csv_output .= $Order_Tax . $CSV_SEPARATOR ; $csv_output .= $Order_Subtotal . $CSV_SEPARATOR ; $csv_output .= $Order_Insurance . $CSV_SEPARATOR ; $csv_output .= $Tax_Exempt_Message . $CSV_SEPARATOR ; $csv_output .= $Order_Shipping_Total . $CSV_SEPARATOR ; $csv_output .= $Small_Order_Fee . $CSV_SEPARATOR ; $csv_output .= $Discount_Rate . $CSV_SEPARATOR ; $csv_output .= $Discount_Message . $CSV_SEPARATOR ; $csv_output .= $CODAmount . $CSV_SEPARATOR ; $csv_output .= $Order_Grand_Total . $CSV_SEPARATOR ; $csv_output .= $Number_of_Items . $CSV_SEPARATOR ; $csv_output .= $Shipping_Method . $CSV_SEPARATOR ; $csv_output .= $Shipping_Weight . $CSV_SEPARATOR ; $csv_output .= $Coupon_Code . $CSV_SEPARATOR ; $csv_output .= $Order_security_msg . $CSV_SEPARATOR ; $csv_output .= $Order_Surcharge_Amount . $CSV_SEPARATOR ; $csv_output .= $Order_Surcharge_Something . $CSV_SEPARATOR ; $csv_output .= $Affiliate_code . $CSV_SEPARATOR ; $csv_output .= $Sentiment_message . $CSV_SEPARATOR ; $csv_output .= $Checkout_form_type . $CSV_SEPARATOR ; $csv_output .= $Card_CVV_value . $CSV_SEPARATOR ; $csv_output .= $future1 . $CSV_SEPARATOR ; $csv_output .= $future2 . $CSV_SEPARATOR ; $csv_output .= $future3 . $CSV_SEPARATOR ; $csv_output .= $future4 . $CSV_SEPARATOR ; $csv_output .= $future5 . $CSV_SEPARATOR ; $csv_output .= $future6 . $CSV_SEPARATOR ; $csv_output .= $future7 . $CSV_SEPARATOR ; $csv_output .= $future8 . $CSV_SEPARATOR ; $csv_output .= $future9 ; // -------------------- QUERIES 9 ------------------------------------// //Get list of products ordered $orders_products = tep_db_query("select products_model, products_price, products_quantity, products_name from orders_products where orders_id = " . $Orders_id); // While loop to list the item while($row_orders_products = mysql_fetch_array($orders_products)) { $csv_output .= $CSV_SEPARATOR . "DEBUT_ARTICLE". $CSV_SEPARATOR ; $csv_output .= filter_text($row_orders_products[0]) . $CSV_SEPARATOR ; $csv_output .= $row_orders_products[1] . $CSV_SEPARATOR ; $csv_output .= $row_orders_products[2] . $CSV_SEPARATOR ; $csv_output .= filter_text($row_orders_products[3]) . $CSV_SEPARATOR ; $csv_output .= "FIN_ARTICLE"; } // end while loop for products // --------------------------------------------------------------------------// $csv_output .= "\n"; } // while loop main first //print header("Content-Type: application/force-download\n"); header("Cache-Control: cache, must-revalidate"); header("Pragma: public"); header("Content-Disposition: attachment; filename=ordersexports_" . date("Ymd") . ".csv"); print $csv_output; exit; }//function main function filter_text($text) { $filter_array = array(",","\r","\n","\t"); return str_replace($filter_array,"",$text); } // function for the filter ?>