# --- 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.'
'; echo hInput('id', $id). eInput('orders'). sInput($step). ''. startTable('edit'). ''.n; //if ($view == 'text') //{ //-- markup help -------------- echo ''.n; echo "
". n."Products"; echo n.""; echo n.""; while($product = mysql_fetch_assoc($products)){ extract($product); echo ""; } echo n."
ProductPriceQuantity
$Title$$custom_1$quantity
"; echo "
"; echo n."".n; echo n."".n; echo n."".n; if(!empty($discount)){ echo n."".n; } echo n."
Subtotal: $$subtotal
Tax: $$tax
Shipping & Handling: $$shipping_handling
Discount: $$discount
Total: $$total
".n; echo n.'
'; echo "
"; echo ""; if(isset($shipping_same_as_billing) && $shipping_same_as_billing == "1"){ echo ''; }else{ echo ''; } echo n."'; echo "
Ship to [edit]'.br.$RealName.br.$billing_address1.br; if(isset($billing_address2) && !empty($billing_address2)){ echo $billing_address2.br; } echo $billing_city.', '; echo $billing_state.' '; echo $billing_zip.br; echo $billing_country.''.$shipping_address1.br; if(isset($shipping_address2)){ echo $shipping_address2.br; } echo $shipping_city.br; echo $shipping_state.br; echo $shipping_zip.br; echo $shipping_country.'Bill to [edit]".br; echo $RealName.br.$billing_address1.br; if(isset($billing_address2) && !empty($billing_address2)){ echo $billing_address2.br; } echo $billing_city.', '; echo $billing_state.' '; echo $billing_zip.br; echo $billing_country.'
".br; echo n."

Payment info".br; echo n.'Method: '.$payment_method.br. n.'Transaction ID: '.$transaction_id.br.'

'; echo n.'
'; echo "
". n."Order Update"; if(isset($ship_date) && !empty($ship_date)){ $ship_date = strtotime($ship_date); $ship_year = date("Y", $ship_date); $ship_month = date("m", $ship_date); $ship_day = date("d", $ship_date); }else{ $ship_year = date("Y"); $ship_month = date("m"); $ship_day = date("d"); } if(isset($order_status)){ if($order_status == "pending"){ $pending_selected = "selected='true'"; }else if($order_status == "approved"){ $approved_selected = "selected='true'"; }else if($order_status == "shipped"){ $shipped_selected = "selected='true'"; }else if($order_status == "declined"){ $declined_selected = "selected='true'"; }else if($order_status == "void"){ $void_selected = "selected='true'"; } } echo n.''. n.''.br. n.''. n.listbox_year('ship_year', '2004', date('Y'), $ship_year) . ' ' . get_html_select_month("ship_month", $ship_month). n.'   '. br . n.'
Shipped today
'. br. n.''. n.'   '. br. n.'

Example: USPS Priority, FedEx, etc.

'. n.''. n.'   '. br. n.''. n.''. br . br; echo n.'
'; echo ''; echo ''; //start article-col-2 echo 'Print packing slip'.br.br; //-- publish button -------------- echo (has_privs('article.publish')) ? fInput('submit','publish',gTxt('update'),"publish", '', '', '', 4) : fInput('submit','publish',gTxt('update'),"publish", '', '', '', 4); if($user_id){ $orders = safe_rows("*", "orders", "user_id = $user_id AND id != $id ORDER BY last_updated DESC"); if(count($orders) > 0){ echo br.br."
". n.'Other Orders by '. $RealName .''. n.''; echo '
'; } } echo '
'; } 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.''.n. n.startTable('list','','','','700'). n.tr( n.tda("Displaying $offset - $limit of $total orders ", ' colspan="2" style="border: none; padding-bottom: 15px;"'). n.tda('Export orders'.$exportOptions, ' colspan="3" style="text-align: right; border: none; padding-bottom: 15px;"') ). n.tr( n.tda('Show Pending Approved Shipped Declined Void ', ' colspan="4" style="border: none; padding-bottom: 15px;"') ). n.tr( n.column_head('Order #', 'id', 'orders', true, $switch_dir, $crit, $search_method). column_head('Customer', 'user_id', 'orders', true, $switch_dir, $crit, $search_method). column_head('Order Date', 'date_created', 'orders', true, $switch_dir, $crit, $search_method). column_head('Total', 'total', 'orders', true, $switch_dir, $crit, $search_method). column_head('Status', 'order_status', 'orders', true, $switch_dir, $crit, $search_method) ); include_once txpath.'/publish/taghandlers.php'; while ($a = nextRow($rs)) { extract($a); $edit_link = ''.$id.' [Edit | Delete]'; $user = safe_row("RealName, user_id", "txp_users", "user_id = '$user_id'"); $user_link = ''.$user['RealName'].''; echo n.n.tr( n.td($edit_link). td($user_link). td($date_created). td('$'.$total). td($order_status) ); } echo n.endTable(). 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()); } } ?>