<?php
/**
  @licence GPL 2005-2010  The osCSS developers - osCSS Open Source E-commerce
  @portion code Copyright (c) 2002 osCommerce
  @package osCSS-2 <www http://www.oscss.org>
  @version 2.1.0
  @date  10/11/10, 22:08
  @author oscim <mail aurelien@oscim.fr> <www http://www.oscim.fr>
  @encode UTF-8
*/

$wishlist_sql = "select * from " . TABLE_WISHLIST . " where customers_id = '" . $customer_id . "' and products_id > 0 order by products_name";
$wishlist_query = tep_db_query($wishlist_sql);

?>

<div id="privacy">
  <h2 class="content title <?php echo $language ;?>"><?php echo HEADING_TITLE; ?></h2>

  <div class="prod_box_big">
    <div class="top_prod_box_big"></div>
      <div class="center_prod_box_big">

  <?php
  $info_box_contents = array();
  if (tep_db_num_rows($wishlist_query)) {
    $product_ids = '';
    while ($wishlist = tep_db_fetch_array($wishlist_query)) { $product_ids .= $wishlist['products_id'] . ','; }
    $product_ids = substr($product_ids, 0, -1);

    $products_query = tep_db_query("select pd.products_id, pd.products_name, pd.products_description, p.products_image, p.products_price, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id in (" . $product_ids . ") and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' order by products_name");
  ?>
  <?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_WISHLIST, tep_get_all_get_params(array('action')) . 'action=add_del_products_wishlist')); ?>
    <?php while ($products = tep_db_fetch_array($products_query)) : ?>
      <div >
	<ul>
	  <li><a href="<?php echo tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products['products_id'], 'NONSSL'); ?>"><?php echo tep_image(DIR_WS_IMAGES . $products['products_image'], $products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); ?></a></li>
	  <li><a href="<?php echo tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products['products_id'], 'NONSSL'); ?>"><?php echo $products['products_name']; ?></a></li>
	  <?php
	  // Begin Wish List Code w/Attributes
	  $attributes_addon_price = 0;

	  // Now get and populate product attributes
	  if ($customer_id > 0) {
	    $wishlist_products_attributes_query = tep_db_query("select products_options_id as po, products_options_value_id as pov from " . TABLE_WISHLIST_ATTRIBUTES . " where customers_id='" . $customer_id . "' and products_id = '" . $products['products_id'] . "'");
	    while ($wishlist_products_attributes = tep_db_fetch_array($wishlist_products_attributes_query)) {
	      // We now populate $id[] hidden form field with product attributes
	      echo tep_draw_hidden_field('id['.$products['products_id'].']['.$wishlist_products_attributes['po'].']', $wishlist_products_attributes['pov']);
	      // And Output the appropriate attribute name
	      $attributes = tep_db_query("select poptt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix
		from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_TEXT . " poptt,  " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
		where pa.products_id = '" . $products['products_id'] . "'
		and pa.options_id = '" . $wishlist_products_attributes['po'] . "'
		and pa.options_id = popt.products_options_id
		and pa.options_values_id = '" . $wishlist_products_attributes['pov'] . "'
		and pa.options_values_id = poval.products_options_values_id
		and poptt.products_options_text_id = popt.products_options_id
		and poptt.language_id = '" . $languages_id . "'
		and poval.language_id = '" . $languages_id . "'");
	      $attributes_values = tep_db_fetch_array($attributes);
	      if ($attributes_values['price_prefix'] == '+')
		  { $attributes_addon_price += $attributes_values['options_values_price']; }
	      else if ($attributes_values['price_prefix'] == '-')
		  { $attributes_addon_price -= $attributes_values['options_values_price']; }
		  echo '<br><small><i>' . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name'] . '</i></small>';
	    } // end while attributes for product

	    if ($new_price = tep_get_products_special_price($products['products_id'])) {
	      $products_price = '<s>' . $currencies->display_price($products['products_price']+$attributes_addon_price, tep_get_tax_rate($products['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price+$attributes_addon_price, tep_get_tax_rate($products['products_tax_class_id'])) . '</span>';
	    } else {
	      $products_price = $currencies->display_price($products['products_price']+$attributes_addon_price, tep_get_tax_rate($products['products_tax_class_id']));
	    }
	  }
	  echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '5').'<br>';
	  echo BOX_TEXT_PRICE . '&nbsp;' . $products_price. '<br>';
	  // End Wish List Code w/Attributes
	  ?>
	  <li>
	    <div class="actioninline">
	    <ul>
	      <li><?php echo BOX_TEXT_MOVE_TO_CART ?><?php echo  tep_draw_checkbox_field('add_wishprod[]','',$products['products_id']); ?> </li>
	      <li><?php echo BOX_TEXT_DELETE; ?><?php echo tep_draw_checkbox_field('del_wishprod[]','',$products['products_id']); ?> </li>
	    </ul>
	  </div>
	  </li>
	</ul>
      </div>
    <?php endwhile; ?>
    <div class="navBt">
      <a href="<?php echo tep_href_link(FILENAME_DEFAULT); ?>"><?php echo tep_image_submit('button_continue_shopping.gif', IMAGE_BUTTON_CONTINUE_SHOPPING); ?></a>
      <a href="<?php echo tep_href_link(FILENAME_SHOPPING_CART); ?>"><?php echo tep_image_submit('button_view_cart.gif', IMAGE_BUTTON_IN_CART); ?></a>
      <?php echo tep_image_submit('button_update.gif', IMAGE_BUTTON_UPDATE); ?>
    </div>


  </form>

  <?php } else { ?>
    <p><?php echo BOX_TEXT_NO_ITEMS;?></p>
  <?php } ?>

      </div>
    <div class="bottom_prod_box_big"></div>
  </div>
</div>