<?php
/*
  $Id: order_details.php,v 1.3 2007/06/12 06:02:10 ryu Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
  
  modified for Koshoten.net2
  http://www.koshoten.net/
*/
?>
<!-- orderDetails -->
<?php
  echo '<table>' . "\n";
  echo '<tr>' . "\n";

  if (strstr($PHP_SELF, FILENAME_SHOPPING_CART)) {
    echo '<th><label for="calcel">' . TABLE_HEADING_REMOVE . '</label></th>' . "\n";
  }

  echo '<th><label for="number">' . TABLE_HEADING_QUANTITY . '</label></th>' . "\n";

  if ((KN_CFG_PRODUCT_LIST_MODEL > 0) && strstr($PHP_SELF, FILENAME_SHOPPING_CART)) {
    echo '<th>' . TABLE_HEADING_MODEL . '</th>' . "\n";
  }

  echo '<th>' . TABLE_HEADING_PRODUCTS . '</th>' . "\n";

  if (!strstr($PHP_SELF, FILENAME_SHOPPING_CART)) {
    echo '<th>' . TABLE_HEADING_TAX . '</th>' . "\n";
  }

  echo '<th>' . TABLE_HEADING_TOTAL . '</th>' . "\n";
  echo '</tr>' . "\n";

  for ($i=0, $n=sizeof($products); $i<$n; $i++) {
    echo '<tr>' . "\n";

// Delete box only for shopping cart
    if (strstr($PHP_SELF, FILENAME_SHOPPING_CART)) {
      echo '<td class="remove">' . tep_draw_checkbox_field('cart_delete[]', $products[$i]['id']) . '</td>' . "\n";
    }

// Quantity box or information as an input box or text
    if (strstr($PHP_SELF, FILENAME_SHOPPING_CART)) {
      echo '<td class="quantity">' . tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']) . '</td>' . "\n";
    } else {
      echo '<td class="quantity">' . $products[$i]['quantity'] . '</td>' . "\n";
    }

// Model
    if ((KN_CFG_PRODUCT_LIST_MODEL > 0) && strstr($PHP_SELF, FILENAME_SHOPPING_CART)) {
      echo '<td class="model"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . $products[$i]['model'] . '</a></td>' . "\n";
    }
  
// Product name, with or without link
    if (strstr($PHP_SELF, FILENAME_SHOPPING_CART)) {
      echo '<td class="product"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . $products[$i]['name'] . '</a>';
    } else {
      echo '<td class="product">' . $products[$i]['name'] . '';
    }

// Display marker if stock quantity insufficient
    if (!strstr($PHP_SELF, FILENAME_ACCOUNT_HISTORY_INFO)) {
      if (STOCK_CHECK == 'true') {
        echo $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);
        if ($stock_check) $any_out_of_stock = 1;
      }
    }

// Product options names
    $attributes_exist = ((isset($products[$i]['attributes'])) ? 1 : 0);

    if ($attributes_exist == 1) {
      reset($products[$i]['attributes']);
      while (list($option, $value) = each($products[$i]['attributes'])) {
        echo '<br /><span class="options"> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</span>';
      }
    }

    echo '</td>' . "\n";

// Tax (not in shopping cart, tax rate may be unknown)
    if (!strstr($PHP_SELF, FILENAME_SHOPPING_CART)) {
      echo '<td class="tax">' . number_format($products[$i]['tax'], TAX_DECIMAL_PLACES) . '%</td>' . "\n";
    }

// Product price  
    if (!strstr($PHP_SELF, FILENAME_ACCOUNT_HISTORY_INFO)) {
      echo '<td class="price">' . $currencies->display_price($products[$i]['price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']);
    } else {
      echo '<td class="price">' . $currencies->display_price($products[$i]['price'], $products[$i]['tax'], $products[$i]['quantity']);
    }

// Product options prices
    if ($attributes_exist == 1) {
      reset($products[$i]['attributes']);
      while (list($option, $value) = each($products[$i]['attributes'])) {
        if ($products[$i][$option]['options_values_price'] != 0) {
          if (!strstr($PHP_SELF, FILENAME_ACCOUNT_HISTORY_INFO)) {
            echo '<br /><span class="options">' . $products[$i][$option]['price_prefix'] . $currencies->display_price($products[$i][$option]['options_values_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</span>';
          } else {
            echo '<br /><span class="options">' . $products[$i][$option]['price_prefix'] . $currencies->display_price($products[$i][$option]['options_values_price'], $products[$i]['tax'], $products[$i]['quantity']) . '</span>';
          }
        } else {
// Keep price aligned with corresponding option
          echo '<br /><span class="options">&nbsp;</span>';
        }
      }
    }

    echo '</td>' . "\n" .
           '</tr>' . "\n";
  }
  echo '</table>' . "\n";
?>
<!-- /orderDetails -->
