Execute("SELECT orders_status_id, orders_status_name FROM " . $oosDBTable['orders_status'] . " WHERE orders_languages_id = '" . intval($_SESSION['language_id']) . "'");
while ($orders_status = $orders_status_result->fields) {
$orders_statuses[] = array('id' => $orders_status['orders_status_id'],
'text' => $orders_status['orders_status_name']);
$orders_status_array[$orders_status['orders_status_id']] = $orders_status['orders_status_name'];
$orders_status_result->MoveNext();
}
$action = (isset($_GET['action']) ? $_GET['action'] : 'edit');
//UPDATE_INVENTORY_QUANTITY_START#
$order_result = $db->Execute("SELECT products_id, products_quantity FROM " . $oosDBTable['orders_products'] . " WHERE orders_id = '" . (int)$oID . "'");
if (!empty($action)) {
switch ($action) {
// Update Order
case 'update_order':
$oID = oosDBPrepareInput($_GET['oID']);
$order = new order($oID);
$status = oosDBPrepareInput($_POST['status']);
// Update Order Info
$UpdateOrders = "update " . $oosDBTable['orders'] . " set
customers_name = '" . oosDBInput(stripslashes($update_customer_name)) . "',
customers_company = '" . oosDBInput(stripslashes($update_customer_company)) . "',
customers_street_address = '" . oosDBInput(stripslashes($update_customer_street_address)) . "',
customers_suburb = '" . oosDBInput(stripslashes($update_customer_suburb)) . "',
customers_city = '" . oosDBInput(stripslashes($update_customer_city)) . "',
customers_state = '" . oosDBInput(stripslashes($update_customer_state)) . "',
customers_postcode = '" . oosDBInput($update_customer_postcode) . "',
customers_country = '" . oosDBInput(stripslashes($update_customer_country)) . "',
customers_telephone = '" . oosDBInput($update_customer_telephone) . "',
customers_email_address = '" . oosDBInput($update_customer_email_address) . "',";
if($SeparateBillingFields)
{
$UpdateOrders .= "billing_name = '" . oosDBInput(stripslashes($update_billing_name)) . "',
billing_company = '" . oosDBInput(stripslashes($update_billing_company)) . "',
billing_street_address = '" . oosDBInput(stripslashes($update_billing_street_address)) . "',
billing_suburb = '" . oosDBInput(stripslashes($update_billing_suburb)) . "',
billing_city = '" . oosDBInput(stripslashes($update_billing_city)) . "',
billing_state = '" . oosDBInput(stripslashes($update_billing_state)) . "',
billing_postcode = '" . oosDBInput($update_billing_postcode) . "',
billing_country = '" . oosDBInput(stripslashes($update_billing_country)) . "',";
}
$UpdateOrders .= "delivery_name = '" . oosDBInput(stripslashes($update_delivery_name)) . "',
delivery_company = '" . oosDBInput(stripslashes($update_delivery_company)) . "',
delivery_street_address = '" . oosDBInput(stripslashes($update_delivery_street_address)) . "',
delivery_suburb = '" . oosDBInput(stripslashes($update_delivery_suburb)) . "',
delivery_city = '" . oosDBInput(stripslashes($update_delivery_city)) . "',
delivery_state = '" . oosDBInput(stripslashes($update_delivery_state)) . "',
delivery_postcode = '" . oosDBInput($update_delivery_postcode) . "',
delivery_country = '" . oosDBInput(stripslashes($update_delivery_country)) . "',
payment_method = '" . oosDBInput($update_info_payment_method) . "',
cc_type = '" . oosDBInput($update_info_cc_type) . "',
cc_owner = '" . oosDBInput($update_info_cc_owner) . "',";
if(substr($update_info_cc_number,0,8) != "(Last 4)")
$UpdateOrders .= "cc_number = '$update_info_cc_number',";
$UpdateOrders .= "cc_expires = '$update_info_cc_expires',
orders_status = '" . oosDBInput($status) . "'";
if(!$CommentsWithStatus)
{
$UpdateOrders .= ", comments = '" . oosDBInput($comments) . "'";
}
$UpdateOrders .= " where orders_id = '" . oosDBInput($oID) . "';";
$db->Execute($UpdateOrders);
$order_updated = true;
$check_status_result = $db->Execute("select customers_name, customers_email_address, orders_status, date_purchased from " . $oosDBTable['orders'] . " where orders_id = '" . (int)$oID . "'");
$check_status = $check_status_result->fields;
// Update Status History & Email Customer if Necessary
if ($order->info['orders_status'] != $status)
{
// Notify Customer
$customer_notified = '0';
if (isset($_POST['notify']) && ($_POST['notify'] == 'on'))
{
$notify_comments = '';
if (isset($_POST['notify_comments']) && ($_POST['notify_comments'] == 'on')) {
$notify_comments = sprintf(EMAIL_TEXT_COMMENTS_UPDATE, $comments) . "\n\n";
}
$email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . oosCatalogLink($aFilename['catalog_account_history_info'], 'order_id=' . $oID, 'SSL') . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . oosDateLong($check_status['date_purchased']) . "\n\n" . $notify_comments . sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]);
oosMail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, $email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
$customer_notified = '1';
}
// "Status History" table has gone through a few
// different changes, so here are different versions of
// the status update.
// NOTE: Theoretically, there shouldn't be a
// orders_status field in the ORDERS table. It
// should really just use the latest value from
// this status history table.
if($CommentsWithStatus)
{
$db->Execute("insert into " . $oosDBTable['orders_status_history'] . "
(orders_id, orders_status_id, date_added, customer_notified, comments)
values ('" . oosDBInput($oID) . "', '" . oosDBInput($status) . "', now(), " . oosDBInput($customer_notified) . ", '" . oosDBInput($comments) . "')");
}
else
{
if($OldNewStatusValues)
{
$db->Execute("insert into " . $oosDBTable['orders_status_history'] . "
(orders_id, new_value, old_value, date_added, customer_notified)
values ('" . oosDBInput($oID) . "', '" . oosDBInput($status) . "', '" . $order->info['orders_status'] . "', now(), " . oosDBInput($customer_notified) . ")");
}
else
{
$db->Execute("insert into " . $oosDBTable['orders_status_history'] . "
(orders_id, orders_status_id, date_added, customer_notified)
values ('" . oosDBInput($oID) . "', '" . oosDBInput($status) . "', now(), " . oosDBInput($customer_notified) . ")");
}
}
}
// Update Products
$RunningSubTotal = 0;
$RunningTax = 0;
foreach($update_products as $orders_products_id => $products_details)
{
// Update orders_products Table
//UPDATE_INVENTORY_QUANTITY_START
$order = $order_result->fields;
if ($products_details['qty'] != $order['products_quantity']){
$differenza_quantita = ($products_details['qty'] - $order['products_quantity']);
$db->Execute("UPDATE " . $oosDBTable['products'] . " SET products_quantity = products_quantity - " . $differenza_quantita . ", products_ordered = products_ordered + " . $differenza_quantita . " WHERE products_id = '" . (int)$order['products_id'] . "'");
}
//UPDATE_INVENTORY_QUANTITY_END
if($products_details["qty"] > 0)
{
$Query = "update " . $oosDBTable['orders_products'] . " set
products_model = '" . $products_details["model"] . "',
products_name = '" . str_replace("'", "'", $products_details["name"]) . "',
final_price = '" . $products_details["final_price"] . "',
products_tax = '" . $products_details["tax"] . "',
products_quantity = '" . $products_details["qty"] . "'
where orders_products_id = '$orders_products_id';";
$db->Execute($Query);
// Update Tax and Subtotals
$RunningSubTotal += $products_details["qty"] * $products_details["final_price"];
$RunningTax += (($products_details["tax"]/100) * ($products_details["qty"] * $products_details["final_price"]));
// Update Any Attributes
if(IsSet($products_details[attributes]))
{
foreach($products_details["attributes"] as $orders_products_attributes_id => $attributes_details)
{
$Query = "update " . $oosDBTable['orders_products_attributes'] . " set
products_options = '" . $attributes_details["option"] . "',
products_options_values = '" . $attributes_details["value"] . "'
where orders_products_attributes_id = '$orders_products_attributes_id';";
$db->Execute($Query);
}
}
}
else
{
// 0 Quantity = Delete
$Query = "DELETE FROM " . $oosDBTable['orders_products'] . " where orders_products_id = '$orders_products_id';";
$db->Execute($Query);
//UPDATE_INVENTORY_QUANTITY_START
$order = $order_result->fields;
if ($products_details['qty'] != $order['products_quantity']){
$differenza_quantita = ($products_details['qty'] - $order['products_quantity']);
$db->Execute("UPDATE " . $oosDBTable['products'] . " SET products_quantity = products_quantity - " . $differenza_quantita . ", products_ordered = products_ordered + " . $differenza_quantita . " WHERE products_id = '" . (int)$order['products_id'] . "'");
}
//UPDATE_INVENTORY_QUANTITY_END
$Query = "DELETE FROM " . $oosDBTable['orders_products_attributes'] . " WHERE orders_products_id = '$orders_products_id';";
$db->Execute($Query);
}
}
// Shipping Tax
foreach($update_totals as $total_index => $total_details)
{
extract($total_details,EXTR_PREFIX_ALL,"ot");
if($ot_class == "ot_shipping")
{
$RunningTax += (($AddShippingTax / 100) * $ot_value);
}
}
// Update Totals
$RunningTotal = 0;
$sort_order = 0;
// Do pre-check for Tax field existence
$ot_tax_found = 0;
foreach($update_totals as $total_details)
{
extract($total_details,EXTR_PREFIX_ALL,"ot");
if($ot_class == "ot_tax")
{
$ot_tax_found = 1;
break;
}
}
foreach($update_totals as $total_index => $total_details)
{
extract($total_details,EXTR_PREFIX_ALL,"ot");
if( trim(strtolower($ot_title)) == "tax" || trim(strtolower($ot_title)) == "tax:" )
{
if($ot_class != "ot_tax" && $ot_tax_found == 0)
{
// Inserting Tax
$ot_class = "ot_tax";
$ot_value = "x"; // This gets updated in the next step
$ot_tax_found = 1;
}
}
if( trim($ot_title) && trim($ot_value) )
{
$sort_order++;
// Update ot_subtotal, ot_tax, and ot_total classes
if($ot_class == "ot_subtotal")
$ot_value = $RunningSubTotal;
if($ot_class == "ot_tax")
{
$ot_value = $RunningTax;
// print "ot_value = $ot_value \n";
}
if($ot_class == "ot_total")
$ot_value = $RunningTotal;
// Set $ot_text (display-formatted value)
// $ot_text = "\$" . number_format($ot_value, 2, '.', ',');
$order = new order($oID);
$ot_text = $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']);
if($ot_class == "ot_total")
$ot_text = "" . $ot_text . " ";
if($ot_total_id > 0)
{
// In Database Already - Update
$Query = "update " . $oosDBTable['orders_total'] . " set
title = '$ot_title',
text = '$ot_text',
value = '$ot_value',
sort_order = '$sort_order'
WHERE orders_total_id = '$ot_total_id'";
$db->Execute($Query);
}
else
{
// New Insert
$Query = "insert into " . $oosDBTable['orders_total'] . " set
orders_id = '$oID',
title = '$ot_title',
text = '$ot_text',
value = '$ot_value',
class = '$ot_class',
sort_order = '$sort_order'";
$db->Execute($Query);
}
$RunningTotal += $ot_value;
}
elseif($ot_total_id > 0)
{
// Delete Total Piece
$Query = "DELETE FROM " . $oosDBTable['orders_total'] . " WHERE orders_total_id = '$ot_total_id'";
$db->Execute($Query);
}
}
if ($order_updated)
{
$messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success');
}
oosRedirect(oosLink("edit_orders.php", oosGetAllGetParams(array('action')) . 'action=edit'));
break;
// Add a Product
case 'add_product':
if($step == 5) {
// Get Order Info
$oID = oosDBPrepareInput($_GET['oID']);
$order = new order($oID);
$AddedOptionsPrice = 0;
// Get Product Attribute Info
if(IsSet($add_product_options)) {
foreach($add_product_options as $option_id => $option_value_id) {
$result = $db->Execute("SELECT * FROM " . $oosDBTable['products_attributes'] . " pa LEFT JOIN " . $oosDBTable['products_options'] . " po ON po.products_options_id=pa.options_id LEFT JOIN " . $oosDBTable['products_options_values'] . " pov ON pov.products_options_values_id=pa.options_values_id WHERE products_id='$add_product_products_id' and options_id=$option_id and options_values_id=$option_value_id");
$row = $result->fields;
extract($row, EXTR_PREFIX_ALL, "opt");
$AddedOptionsPrice += $opt_options_values_price;
$option_value_details[$option_id][$option_value_id] = array ("options_values_price" => $opt_options_values_price);
$option_names[$option_id] = $opt_products_options_name;
$option_values_names[$option_value_id] = $opt_products_options_values_name;
}
}
// Get Product Info
$InfoQuery = "select p.products_model,p.products_price,pd.products_name,p.products_tax_class_id from " . $oosDBTable['products'] . " p left join " . $oosDBTable['products_description'] . " pd on pd.products_id=p.products_id WHERE p.products_id='$add_product_products_id'";
$result = $db->Execute($InfoQuery);
$row = $result->fields;
extract($row, EXTR_PREFIX_ALL, "p");
// Following functions are defined at the bottom of this file
$CountryID = oosGetCountryId($order->delivery["country"]);
$ZoneID = oosGetZoneId($CountryID, $order->delivery["state"]);
$ProductsTax = oosGetTaxRate($p_products_tax_class_id, $CountryID, $ZoneID);
$Query = "insert into " . $oosDBTable['orders_products'] . " set
orders_id = $oID,
products_id = $add_product_products_id,
products_model = '$p_products_model',
products_name = '" . str_replace("'", "'", $p_products_name) . "',
products_price = '$p_products_price',
final_price = '" . ($p_products_price + $AddedOptionsPrice) . "',
products_tax = '$ProductsTax',
products_quantity = $add_product_quantity;";
$db->Execute($Query);
$new_product_id = $db->Insert_ID();
//UPDATE_INVENTORY_QUANTITY_START
$db->Execute("UPDATE " . $oosDBTable['products'] . " SET products_quantity = products_quantity - " . $add_product_quantity . ", products_ordered = products_ordered + " . $add_product_quantity . " WHERE products_id = '" . $add_product_products_id . "'");
//UPDATE_INVENTORY_QUANTITY_END
if(IsSet($add_product_options)) {
foreach($add_product_options as $option_id => $option_value_id) {
$Query = "insert into " . $oosDBTable['orders_products_attributes'] . " set
orders_id = $oID,
orders_products_id = $new_product_id,
products_options = '" . $option_names[$option_id] . "',
products_options_values = '" . $option_values_names[$option_value_id] . "',
options_values_price = '" . $option_value_details[$option_id][$option_value_id]["options_values_price"] . "',
price_prefix = '+';";
$db->Execute($Query);
}
}
// Calculate Tax and Sub-Totals
$order = new order($oID);
$RunningSubTotal = 0;
$RunningTax = 0;
for ($i=0; $i < count($order->products); $i++)
{
$RunningSubTotal += ($order->products[$i]['qty'] * $order->products[$i]['final_price']);
$RunningTax += (($order->products[$i]['tax'] / 100) * ($order->products[$i]['qty'] * $order->products[$i]['final_price']));
}
// Tax
$Query = "update " . $oosDBTable['orders_total'] . " set
text = '\$" . number_format($RunningTax, 2, '.', ',') . "',
value = '" . $RunningTax . "'
WHERE class='ot_tax' and orders_id=$oID";
$db->Execute($Query);
// Sub-Total
$Query = "update " . $oosDBTable['orders_total'] . " set
text = '\$" . number_format($RunningSubTotal, 2, '.', ',') . "',
value = '" . $RunningSubTotal . "'
WHERE class='ot_subtotal' and orders_id=$oID";
$db->Execute($Query);
// Total
$Query = "select sum(value) as total_value from " . $oosDBTable['orders_total'] . " WHERE class != 'ot_total' and orders_id=$oID";
$result = $db->Execute($Query);
$row = $result->fields;
$Total = $row["total_value"];
$Query = "update " . $oosDBTable['orders_total'] . " set
text = '\$" . number_format($Total, 2, '.', ',') . " ',
value = '" . $Total . "'
WHERE class='ot_total' and orders_id=$oID";
$db->Execute($Query);
oosRedirect(oosLink("edit_orders.php", oosGetAllGetParams(array('action')) . 'action=edit'));
}
break;
}
}
if (($action == 'edit') && isset($_GET['oID'])) {
$oID = oosDBPrepareInput($_GET['oID']);
$orders_result = $db->Execute("SELECT orders_id FROM " . $oosDBTable['orders'] . " WHERE orders_id = '" . (int)$oID . "'");
$order_exists = true;
if (!$orders_result->RecordCount()) {
$order_exists = false;
$messageStack->add(sprintf(ERROR_ORDER_DOES_NOT_EXIST, $oID), 'error');
}
}
require OOS_INCLUDES . 'oos_header.php';
?>
#
' . oosImageButton('back.gif', IMAGE_BACK) . ''; ?>
products = array();
$orders_products_result = $db->Execute("select * from " . $oosDBTable['orders_products'] . " WHERE orders_id = '" . (int)$oID . "'");
while ($orders_products = $orders_products_result->fields) {
$order->products[$index] = array('qty' => $orders_products['products_quantity'],
'name' => str_replace("'", "'", $orders_products['products_name']),
'model' => $orders_products['products_model'],
'tax' => $orders_products['products_tax'],
'price' => $orders_products['products_price'],
'final_price' => $orders_products['final_price'],
'orders_products_id' => $orders_products['orders_products_id']);
$subindex = 0;
$attributes_result_string = "select * from " . $oosDBTable['orders_products_attributes'] . " WHERE orders_id = '" . (int)$oID . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'";
$attributes_result = $db->Execute($attributes_result_string);
if ($attributes_result->RecordCount()) {
while ($attributes = $attributes_result->fields) {
$order->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++;
$attributes_result->MoveNext();
}
}
$index++;
$orders_products_result->MoveNext();
}
for ($i=0; $i < count($order->products); $i++) {
$orders_products_id = $order->products[$i]['orders_products_id'];
$RowStyle = "dataTableContent";
echo ' ' . "\n" .
' ' . " x \n" .
' ' . " ";
// Has Attributes?
if (count($order->products[$i]['attributes']) > 0) {
for ($j=0; $j < count($order->products[$i]['attributes']); $j++) {
$orders_products_attributes_id = $order->products[$i]['attributes'][$j]['orders_products_attributes_id'];
echo ' - ' . " " . ': ' . " ";
echo ' ';
}
}
echo ' ' . "\n" .
' ' . " " . ' ' . "\n" .
' ' . " " . '% ' . "\n" .
' ' . " " . ' ' . "\n" .
' ' . $currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ' ' . "\n" .
' ' . "\n";
}
?>
">
Execute("select * from " . $oosDBTable['orders_total'] . " WHERE orders_id = '" . (int)$oID . "' order by sort_order");
$order->totals = array();
while ($totals = $totals_result->fields) { $order->totals[] = array('title' => $totals['title'], 'text' => $totals['text'], 'class' => $totals['class'], 'value' => $totals['value'], 'orders_total_id' => $totals['orders_total_id']); $totals_result->MoveNext();}
$TotalsArray = array();
for ($i=0; $i < count($order->totals); $i++) {
$TotalsArray[] = array("Name" => $order->totals[$i]['title'], "Price" => number_format($order->totals[$i]['value'], 2, '.', ''), "Class" => $order->totals[$i]['class'], "TotalID" => $order->totals[$i]['orders_total_id']);
$TotalsArray[] = array("Name" => " ", "Price" => "", "Class" => "ot_custom", "TotalID" => "0");
}
array_pop($TotalsArray);
foreach($TotalsArray as $TotalIndex => $TotalDetails)
{
$TotalStyle = "smallText";
if(($TotalDetails["Class"] == "ot_subtotal") || ($TotalDetails["Class"] == "ot_total"))
{
echo ' ' . "\n" .
' ' . $TotalDetails["Name"] . ' ' .
' ' . $TotalDetails["Price"] .
" " .
" " .
" \n" .
" " . ' ' .
' ' . "\n";
}
elseif($TotalDetails["Class"] == "ot_tax")
{
echo ' ' . "\n" .
' ' . " " . ' ' . "\n" .
' ' . $TotalDetails["Price"] .
" " .
" \n" .
" " . ' ' .
' ' . "\n";
}
else
{
echo ' ' . "\n" .
' ' . " " . ' ' . "\n" .
' ' . " " .
" " .
" " .
' ' . "\n" .
' ' . "\n";
}
}
?>
Execute("select * from " . $oosDBTable['orders_status_history'] . " WHERE orders_id = '" . oosDBInput($oID) . "' order by date_added");
if ($orders_history_result->RecordCount()) {
while ($orders_history = $orders_history_result->fields) {
echo ' ' . "\n" .
' ' . oosDatetimeShort($orders_history['date_added']) . ' ' . "\n" .
' ';
if ($orders_history['customer_notified'] == '1') {
echo oosImage(OOS_ICONS . 'tick.gif', ICON_TICK) . " \n";
} else {
echo oosImage(OOS_ICONS . 'cross.gif', ICON_CROSS) . "\n";
}
echo ' ' . $orders_status_array[$orders_history['orders_status_id']] . ' ' . "\n";
if($CommentsWithStatus) {
echo ' ' . nl2br(oosDBOutput($orders_history['comments'])) . ' ' . "\n";
}
echo ' ' . "\n";
$orders_history_result->MoveNext();
}
} else {
echo ' ' . "\n" .
' ' . TEXT_NO_ORDER_HISTORY . ' ' . "\n" .
' ' . "\n";
}
?>
info['comments']);
}
?>
info['orders_status']); ?>
#
' . oosImageButton('back.gif', IMAGE_BACK) . ''; ?>
Execute("SELECT products_name, p.products_id, cd.categories_name, ptc.categories_id FROM " . $oosDBTable['products'] . " p LEFT JOIN " . $oosDBTable['products_description'] . " pd ON pd.products_id=p.products_id LEFT JOIN " . $oosDBTable['products_to_categories'] . " ptc ON ptc.products_id=p.products_id LEFT JOIN " . $oosDBTable['categories_description'] . " cd ON cd.categories_id=ptc.categories_id LEFT JOIN " . $oosDBTable['categories_description'] . " x ON x.categories_name=cd.categories_name ORDER BY categories_id");
$result = $db->Execute("SELECT products_name, p.products_id, cd.categories_name, ptc.categories_id FROM " . $oosDBTable['products'] . " p LEFT JOIN " . $oosDBTable['products_description'] . " pd ON pd.products_id=p.products_id LEFT JOIN " . $oosDBTable['products_to_categories'] . " ptc ON ptc.products_id=p.products_id LEFT JOIN " . $oosDBTable['categories_description'] . " cd ON cd.categories_id=ptc.categories_id ORDER BY categories_id");
while($row = $result->fields)
{
extract($row,EXTR_PREFIX_ALL,"db");
$ProductList[$db_categories_id][$db_products_id] = $db_products_name;
$CategoryList[$db_categories_id] = $db_categories_name;
$LastCategory = $db_categories_name;
$result->MoveNext();
}
// ksort($ProductList);
$LastOptionTag = "";
$ProductSelectOptions = "Don't Add New Product" . $LastOptionTag . "\n";
$ProductSelectOptions .= " " . $LastOptionTag . "\n";
foreach($ProductList as $Category => $Products)
{
$ProductSelectOptions .= " $Category" . $LastOptionTag . "\n";
$ProductSelectOptions .= " ---------------------------" . $LastOptionTag . "\n";
asort($Products);
foreach($Products as $Product_ID => $Product_Name)
{
$ProductSelectOptions .= " $Product_Name" . $LastOptionTag . "\n";
}
if($Category != $LastCategory)
{
$ProductSelectOptions .= " " . $LastOptionTag . "\n";
$ProductSelectOptions .= " " . $LastOptionTag . "\n";
}
}
echo "\n";
// Set Defaults
if (!IsSet($add_product_categories_id)) {
$add_product_categories_id = 0;
}
if (!IsSet($add_product_products_id)) {
$add_product_products_id = 0;
}
// Step 1: Choose Category
echo ' ' . "\n";
echo ' ' . "\n";
// Step 2: Choose Product
if (($step > 1) && ($add_product_categories_id > 0)) {
echo ' '."\n";
echo ' '."\n";
}
// Step 3: Choose Options
if (($step > 2) && ($add_product_products_id > 0)) {
// Get Options for Products
$result = $db->Execute("SELECT * FROM " . $oosDBTable['products_attributes'] . " pa LEFT JOIN " . $oosDBTable['products_options'] . " po ON po.products_options_id=pa.options_id LEFT JOIN " . $oosDBTable['products_options_values'] . " pov ON pov.products_options_values_id=pa.options_values_id WHERE products_id = '" . $add_product_products_id . "'");
// Skip to Step 4 if no Options
if ($result->RecordCount() == 0) {
echo '' . "\n";
echo 'STEP 3: No Options - Skipped... ';
echo ' '."\n";
$step = 4;
} else {
while ($row = $result->fields) {
extract($row,EXTR_PREFIX_ALL,"db");
$Options[$db_products_options_id] = $db_products_options_name;
$ProductOptionValues[$db_products_options_id][$db_products_options_values_id] = $db_products_options_values_name;
$result->MoveNext();
}
echo ' '."\n";
}
echo ' '."\n";
}
// Step 4: Confirm
if ($step > 3) {
echo ' '."\n";
}
echo '
'."\n";
}
/*vx*/
?>