# --- BEGIN PLUGIN HELP --- For display information visit: http://homeplatewp.com/TextCommerce/article/67/tc_product_display-001 # --- END PLUGIN HELP --- Coming soon"; //CSS FOR CUSTOMER EDIT //================================== echo n.''; doJS(); $step = 'update_order'; echo n.n.'
'; } function orders_list($event, $step, $message=''){ global $statuses, $comments_disabled_after, $step, $txp_user; pagetop("Orders", $message); extract(get_prefs()); extract(doSlash($_REQUEST)); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); $sesutats = array_flip($statuses); $dir = ($dir == 'desc') ? 'desc' : 'asc'; switch ($sort) { case 'id': $sort_sql = 'id '.$dir; break; case 'user_id': $sort_sql = 'user_id '.$dir; break; default: $dir = 'desc'; $sort_sql = 'id '.$dir; break; } $switch_dir = ($dir == 'desc') ? 'asc' : 'desc'; $criteria = "order_status = 'pending'"; if(isset($show_approved)){ $criteria .= " OR order_status = 'approved'"; $show_approved_selected = "checked='true'"; } if(isset($show_shipped)){ $criteria .= " OR order_status = 'shipped'"; $show_shipped_selected = "checked='true'"; } if(isset($show_declined)){ $criteria .= " OR order_status = 'declined'"; $show_declined_selected = "checked='true'"; } if(isset($show_void)){ $criteria .= " OR order_status = 'void'"; $show_void_selected = "checked='true'"; } $total = safe_count('orders', "$criteria"); $limit = max(@$article_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); $rs = safe_rows_start('*', 'orders', "$criteria order by $sort_sql limit $offset, $limit" ); $exportOptions = ''; if ($rs) { echo n.n.''. n.nav_form('list', $page, $numPages, $sort, $dir, $crit, $search_method). n.pageby_form('list', $article_list_pageby); } } function orders_export($event, $step){ $type = $_GET['type']; $criteria = ''; if($type == "pending" || $type == "approved" || $type=="shipped" || $type=="declined" || $type=="void"){ $criteria .= " order_status = '$type' "; }else if($type == "lastweek"){ $criteria .= " date_created >= ".date('Y-m-d', strtotime("7 days ago")); }else if($type == "lastmonth"){ $criteria .= " date_created >= ".date('Y-m-d', strtotime("30 days ago")); }else{ $criteria .= " id not null"; } $sql = " SELECT id, date_created, subtotal, tax, shipping_handling, discount, total, transaction_id, tracking_number, last_updated, order_status, ship_date, ship_method, memo, note, payment_method, email, billing_firstname, billing_lastname, billing_company, billing_address1, billing_address2, billing_city, billing_state, billing_zip, billing_country, billing_fax, billing_phone, shipping_firstname, shipping_lastname, shipping_company, shipping_address1, shipping_address2, shipping_city, shipping_state, shipping_zip, shipping_country, shipping_fax, shipping_phone FROM orders JOIN txp_users AS users ON users.user_id = orders.user_id WHERE $criteria"; $orders = safe_query($sql); header("Content-type: application/csv"); header("Content-disposition:attachment;filename=order_export_".date("Y-m-d").".csv"); echo "id, date_created, subtotal, tax, shipping_handling, discount, total, transaction_id, tracking_number, last_updated, order_status, ship_date, ship_method, memo, note, payment_method, email, billing_firstname, billing_lastname, billing_company, billing_address1, billing_address2, billing_city, billing_state, billing_zip, billing_country, billing_fax, billing_phone, shipping_firstname, shipping_lastname, shipping_company, shipping_address1, shipping_address2, shipping_city, shipping_state, shipping_zip, shipping_country, shipping_fax, shipping_phone, ITEMS \n"; while($order = mysql_fetch_assoc($orders)){ echo implode(",", $order); $sql = " SELECT * FROM textpattern AS txp JOIN orders_articles AS oa ON oa.article_id = txp.ID WHERE oa.order_id = ".$order['id']; $products = safe_query($sql); while($product = mysql_fetch_assoc($products)){ echo ",". $product['Title'] . " " . $product['custom_1']; } echo "\n"; } die(); } function orders_update($event, $step){ global $txp_user, $vars, $txpcfg, $prefs; extract($prefs); extract(doSlash($_REQUEST)); if(isset($ship_now)){ $ship_date = 'current_timestamp()'; }else{ $ship_date = "'".date("Y-m-d", strtotime($ship_year.'-'.$ship_month.'-'.$ship_day))."'"; } $rs = safe_update('orders', " tracking_number = '$tracking_number', order_status = '$order_status', ship_date = $ship_date, ship_method = '$ship_method', note = '$note'", "id = $id" ); if ($rs) { orders_edit('', '', "Order updated"); }else{ orders_edit("There was an error trying to update the order: ".mysql_error()); } } function orders_delete($event, $step){ global $txp_user, $vars, $txpcfg, $prefs; extract($prefs); extract(doSlash($_REQUEST)); if(isset($id)){ $rs = safe_delete('orders', "id = $id"); } if ($rs) { orders_list('', '', "Order Deleted"); }else{ orders_list("There was an error trying to update the order: ".mysql_error()); } } ?>