<?php
class ISC_SIDETOPSELLERS_PANEL extends PRODUCTS_PANEL{
	public function SetPanelSettings(){
		$count = 1;
		if(!GetConfig('ShowProductRating')) {
			$GLOBALS['HideProductRating'] = "display: none";
		}
		$output = "";
		$vendorRestriction = '';

		if(isset($GLOBALS['ISC_CLASS_VENDORS'])) {
			$vendor = $GLOBALS['ISC_CLASS_VENDORS']->GetVendor();
			$vendorRestriction = " AND p.prodvendorid='".(int)$vendor['vendorid']."'";
		}
		$query = $this->getProductQuery('p.prodnumsold > 0 '.$vendorRestriction,'p.prodnumsold DESC',6);
		$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
		$GLOBALS['AlternateClass'] = '';
		while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
			/*if($count == 1) {
				$snippet = "SideTopSellersFirst";
			}else {
				
			}*/
			$snippet = "SideTopSellers";
			$GLOBALS['ProductNumber'] = $count++;
			$GLOBALS['Vendidos'] = $row['prodnumsold'];
			$this->setProductGlobals($row);
			if (isId($row['prodvariationid']) || trim($row['prodconfigfields'])!='' || $row['prodeventdaterequired'] == 1) {
				$GLOBALS['MostrarBTN'] = 'display: block';
				$GLOBALS['MostrarForm'] = 'display: none';
			} else {
				$GLOBALS['MostrarBTN'] = 'display: none';
				$GLOBALS['MostrarForm'] = 'display: block';
			}
			$GLOBALS['ProT'] = simulador_de_rodape($row['productid']);
			$GLOBALS['ProTBoleto'] = simulador_home1($row['productid']);
			$output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet($snippet);
		}
		if ($count == 2) { // if only one product then we need to clear the list by adding an empty list item otherwise the layout can be broken
			$output .= "<li></li>";
		}
		$GLOBALS['SNIPPETS']['SideTopSellers'] = $output;
		if(!$output) {
			$this->DontDisplay = true;
		}
	}
}