<?php
/*
  www.oscGold.com (C) Kamelia-Net Jacek Krysiak
  modul oscGold wer 4.0
*/
?>

<table align="center" width="100%" cellspacing="0" cellpadding="4" border="0">	  
<tr class="productListing-heading">
  <td class="productListing-heading"><?php echo _TYTUL_ANKIETY; ?></td>
  <td class="productListing-heading" align="center"><?php echo _ILE_GLOSOW ?></td>
  <td class="productListing-heading" align="center"><?php echo _ILOSC_KOMENTARZY; ?></td>
  <td class="productListing-heading">&nbsp;</td>
</tr>
<?php
$result=tep_db_query("SELECT pollid, timestamp, voters, poll_type, poll_open FROM phesis_poll_desc ORDER BY timestamp desc");
$row=0;
while ($polls=tep_db_fetch_array($result)) {
	$row++;
	$idpoll=$polls['pollid'];
	//
	$title_query = tep_db_query("Select optionText from phesis_poll_data where pollid='".$idpoll."' and voteid='0' and language_id = '" . $languages_id . "'");
	$title = tep_db_fetch_array($title_query);
	$fullresults="<a href=\"".tep_href_link('pollbooth.php','op=results&pollid='.$idpoll,'NONSSL')."\">"._POLLRESULTS."</a>";
	$result1 = tep_db_query("SELECT SUM(optioncount) AS sum FROM phesis_poll_data WHERE pollid='".$idpoll."' and language_id='".$languages_id."'");
	$poll_sum=tep_db_fetch_array($result1);
	$sum=$poll_sum['sum'];
	$query1=tep_db_query("select count(pollid) as comments from phesis_comments where pollid='".$idpoll."' and language_id='".$languages_id."'");
	$result1 = tep_db_fetch_array($query1);
	$comments = $result1['comments'];
	//
	if ($polls['poll_open']=='0' && (int)$sum > 0) {
		if ($polls['poll_type']=='0') {
			echo("<tr><td class=\"main\" align=\"left\"><b>".$title['optionText']."</b></td><td class=\"main\" align=\"center\">".$sum."</td><td class=\"main\" align=\"center\">".$comments."</td><td class=\"main\" align=\"center\">".$fullresults."</td>");
			echo '</tr>';
			} else if ((int)$customer_id > 0) {
			echo("<tr><td class=\"main\" align=\"left\"><b>".$title['optionText']."</b></td><td class=\"main\" align=\"center\">".$sum."</td><td class=\"main\" align=\"center\">".$comments."</td><td class=\"main\" align=\"center\">".$fullresults."</td>");
			echo '</tr>';
		}
	}
	//
}
?>
</table>&nbsp;<br>

