<?php

	CLASS ISC_FAVORITOS_PANEL extends PANEL
	{
		public function SetPanelSettings()
		{
			$GLOBALS['ProductId'] = $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId();
			$GLOBALS['ProductName'] = isc_html_escape($GLOBALS['ISC_CLASS_PRODUCT']->GetProductName());
			$wishLists = $this->LoadCustomerWishLists();
			$GLOBALS['WishLists'] = '';

			$i=0;
			foreach ($wishLists as $wishlist) {
				if ($i == 0) {
					$checked = 'checked';
				} else {
					$checked = '';
				}
				++$i;
			}
		}

		private function LoadCustomerWishLists()
		{
			$wishLists = array();
			if(CustomerIsSignedIn()) {
				$GLOBALS['ISC_CLASS_CUSTOMER'] = GetClass('ISC_CUSTOMER');
				$customer_id = $GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerId();

				// get customer's wish list from database
				$query = "SELECT * FROM [|PREFIX|]wishlists WHERE customerid = ".$customer_id;
				$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
				while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
					$wishLists[] = $row;
				}
			}
			return $wishLists;
		}
	}