<?php
/*
  $Id: polls.php,v 1.3 2003/01/11 20:18:13 wilt Exp $

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

  Copyright (c) 2002 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');

 
  if ($HTTP_GET_VARS['action'] == 'update') {
     $update_query="update phesis_poll_desc set ";
     $update_query.="polltitle='" . $HTTP_POST_VARS['title']."' where pollid='".$HTTP_POST_VARS['pollid']."'";
     tep_db_query($update_query);
	for ($i=1;$i<13;$i++){
	$h_voteid='voteid'.$i;
	$polltext = $HTTP_POST_VARS['$h_voteid'];
	$update_query ="update phesis_poll_data set ";
	$update_query .= "optiontext='".$HTTP_POST_VARS[$h_voteid]."' ";
	$update_query .= " where voteid = '" . $i."' and pollid='".$HTTP_POST_VARS['pollid']."'";
	tep_db_query($update_query);
	}
    
   header('Location: ' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action')) . 'info=' . $HTTP_POST_VARS['pollid'], 'NONSSL')); tep_exit();
  } elseif ($HTTP_GET_VARS['action'] == 'save_config') {
      tep_db_query("update phesis_poll_config set configuration_value = '" . $HTTP_POST_VARS['configuration_value'] . "', last_modified = now() where configuration_id = '" . $HTTP_POST_VARS['configuration_id'] . "'");
      header('Location: ' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action')) . 'action=config', 'NONSSL')); tep_exit();
  } elseif ($HTTP_GET_VARS['action'] == 'poll_type') {
    $poll_query=tep_db_query("select poll_type from phesis_poll_desc where pollid=".$HTTP_GET_VARS['info']);
    $poll_type=tep_db_fetch_array($poll_query);
    $new_poll_type=1;
    if ($poll_type['poll_type']==1) {
	$new_poll_type=0;
	}
    $poll_update=tep_db_query("update phesis_poll_desc set poll_type=".$new_poll_type." where pollid=".$HTTP_GET_VARS['info']);
    header('Location: ' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action')) . 'info=' . $HTTP_POST_VARS['pollid'], 'NONSSL')); tep_exit();
 } elseif ($HTTP_GET_VARS['action'] == 'poll_open') {
    $poll_query=tep_db_query("select poll_open from phesis_poll_desc where pollid=".$HTTP_GET_VARS['info']);
    $poll_open=tep_db_fetch_array($poll_query);
    $new_poll_open=1;
    if ($poll_open['poll_open']==1) {
	$new_poll_open=0;
	}
    $poll_update=tep_db_query("update phesis_poll_desc set poll_open=".$new_poll_open." where pollid=".$HTTP_GET_VARS['info']);
    header('Location: ' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action')) . 'info=' . $HTTP_POST_VARS['pollid'], 'NONSSL')); tep_exit();
 } elseif ($HTTP_GET_VARS['action'] == 'deleteconfirm') {
    $delete_query="delete from phesis_poll_desc where pollid='".$HTTP_POST_VARS['cID']."'";
    tep_db_query($delete_query);
    $delete_query="delete from phesis_poll_data where pollid='".$HTTP_POST_VARS['cID']."'";
    tep_db_query($delete_query);
    header('Location: ' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action','info')), 'NONSSL')); 
  } elseif ($HTTP_GET_VARS['action'] == 'updatenew') { 
	$insert_query="insert into phesis_poll_desc (pollid,polltitle,timestamp,voters) values ('NULL','".$HTTP_POST_VARS['title']."', NOW(), '0')";
      tep_db_query($insert_query);
      $pollid_query="select pollid from phesis_poll_desc where polltitle='".$HTTP_POST_VARS['title']."'";
	$result=tep_db_query($pollid_query);
	$pollid_query=tep_db_fetch_array($result);
	$pollid=$pollid_query['pollid'];
	for ($i=1;$i<13;$i++){
	$h_voteid='voteid'.$i;
	$polltext = $HTTP_POST_VARS['$h_voteid'];
      $insert_query="insert into phesis_poll_data (pollid,optiontext,optioncount,voteid) values ($pollid, '".$HTTP_POST_VARS[$h_voteid]."', 0, $i)"; 
 	tep_db_query($insert_query);
	}
    
   header('Location: ' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action')) . 'info=' . $HTTP_POST_VARS['pollid'], 'NONSSL')); tep_exit();
}
?>
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<?php
?>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
        </table></td>
<!-- body_text //-->
    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
<?php
 if ($HTTP_GET_VARS['action'] == 'new') {
?>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading">&nbsp;<?php echo HEADING_TITLE; ?>&nbsp;</td>
            <td align="right">&nbsp;<?php echo tep_image(DIR_WS_IMAGES . 'table_background_account.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?>&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
      <td><table border="0" width="70%" cellspacing="0" cellpadding="0">
       <form name="polls" <?php echo 'action="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action', 'cID')) . 'action=updatenew', 'NONSSL') . '"'; ?> method="post"><input type="hidden" name="pollid" value="NULL">
      <tr>
        <td>&nbsp</td>
      </tr>
	<tr>
        <td><?php echo TEXT_POLL_TITLE; ?>&nbsp</td>
        <td><input type="text" name="title" maxlength="60" size="50" value=""></td>
      </tr>
      <tr>
        <td>&nbsp</td>
      </tr>
<?php
      for ($i=1; $i<13; $i++){
?>
      <tr>
	<td><?php echo TEXT_OPTION . ' ' . $i?>&nbsp</td>
      <td><input type="text" name="voteid<?echo $i?>" maxlength="50" size="50" value=""></td>     
      </tr>
<?php
	}
?>
	<tr>
        <td align="right" class="main"><br><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?>&nbsp;<?php echo '<a href="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action', 'cID')) . 'info=' . $HTTP_GET_VARS['cID'], 'NONSSL') . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
      </tr>
	</form>
      </table></td></tr>
<?php
  } elseif ($HTTP_GET_VARS['action'] == 'config' || $HTTP_GET_VARS['action'] == 'edit_config') {
?>
<tr>
        <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading">&nbsp;<?php echo HEADING_TITLE; ?>&nbsp;</td>
            <td align="right">&nbsp;<?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?>&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr class="dataTableHeadingRow">
                <td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_CONFIGURATION_TITLE; ?>&nbsp;</td>
                <td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_CONFIGURATION_VALUE; ?>&nbsp;</td>
                <td class="dataTableHeadingContent" align="center">&nbsp;<?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
              </tr>
<?php
  $rows = 0;
  $configuration_query = tep_db_query("select configuration_id as cfgID, configuration_title as cfgTitle, configuration_value as cfgValue from phesis_poll_config");
  while ($configuration = tep_db_fetch_array($configuration_query)) {
    $rows++;
    if (((!$HTTP_GET_VARS['info']) || (@$HTTP_GET_VARS['info'] == $configuration['cfgID'])) && (!$cfgInfo) && (substr($HTTP_GET_VARS['action'], 0, 3) != 'new')) {
      $cfg_extra_query = tep_db_query("select configuration_key as cfgKey, configuration_description as cfgDesc, date_added, last_modified from phesis_poll_config where configuration_id = '" . $configuration['cfgID'] . "'");
      $cfg_extra = tep_db_fetch_array($cfg_extra_query);

      $cfgInfo_array = tep_array_merge($configuration, $cfg_extra);
      $cfgInfo = new objectInfo($cfgInfo_array);
    }

    if ( (is_object($cfgInfo)) && ($configuration['cfgID'] == $cfgInfo->cfgID)) {
      echo '                  <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . tep_href_link('polls.php', 'info=' . $cfgInfo->cfgID . '&action=edit_config') . '\'">' . "\n";
    } else {
      echo '                  <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . tep_href_link('polls.php', 'info=' . $configuration['cfgID']. '&action=config') . '\'">' . "\n";
    }
?>
                <td class="smallText">&nbsp;<?php echo $configuration['cfgTitle']; ?>&nbsp;</td>
                <td class="smallText">&nbsp;<?php echo $configuration['cfgValue']; ?>&nbsp;</td>
<?php
    if ($configuration['cfgID'] == $cfgInfo->id) {
?>
                    <td align="center" class="smallText">&nbsp;<?php echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); ?>&nbsp;</td>
<?php
    } else {
?>
                    <td align="center" class="smallText">&nbsp;<?php echo '<a href="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('info', 'action')) . 'action=config&info=' . $configuration['cfgID'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; ?>&nbsp;</td>
<?php
    }
?>
              </tr>
<?php
  }
?>
            </table></td>
<?php
  $heading = array();
  $contents = array();
  if ($cfgInfo) $heading[] = array('align' => 'left', 'text' => '&nbsp;<b>' . $cfgInfo->cfgTitle . '</b>&nbsp;');
  if ((!$peInfo) && ($HTTP_GET_VARS['action'] == 'new')) $heading[] = array('align' => 'left', 'text' => '&nbsp;<b>' . TEXT_INFO_HEADING_NEW_PRODUCT . '</b>&nbsp;');

  if ($HTTP_GET_VARS['action'] == 'edit_config') {
    $form = '<form name="configuration" action="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action')) . 'action=save_config', 'NONSSL') . '" method="post"><input type="hidden" name="configuration_id" value="' . $HTTP_GET_VARS['info'] . '">' . "\n";

    if (tep_not_null($cfgInfo->set_function)) {
      $set_function = $cfgInfo->set_function;
      $value_field = $set_function($cfgInfo->cfgValue);
    } else {
      $value_field = '<input type="text" name="configuration_value" value="' . $cfgInfo->cfgValue . '">';
    }

    $contents[] = array('text' => $form);
    $contents[] = array('align' => 'left', 'text' => TEXT_INFO_EDIT_INTRO . '<br>&nbsp;');
    $contents[] = array('align' => 'left', 'text' => '<b>' . $cfgInfo->cfgTitle . '</b><br>' . $cfgInfo->cfgDesc . '<br>' . $value_field . '<br>&nbsp;');
    $contents[] = array('align' => 'center', 'text' => tep_image_submit('button_update.gif', IMAGE_UPDATE) . '&nbsp;<a href="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action')).'action=config', 'NONSSL') . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
    $contents[] = array('text' => '</form>');
  } else {
    $contents = array('text' => $form);
    $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action')) . 'action=edit_config&configuration_id='. $HTTP_GET_VARS['info'], 'NONSSL') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a>');
    $contents[] = array('align' => 'left', 'text' => '<br>' . TEXT_INFO_DESCRIPTION . '<br>' . $cfgInfo->cfgDesc);
    $contents[] = array('align' => 'left', 'text' => '<br>' . TEXT_INFO_DATE_ADDED . ' ' . $cfgInfo->date_added . '<br>' . TEXT_INFO_LAST_MODIFIED . ' ' . $cfgInfo->last_modified);
    $contents[] = array('text' => '</<form>');
  }
echo '            <td width="25%" valign="top">' . "\n";
  $box = new box;
  echo $box->infoBox($heading, $contents);

    echo '            </td>' . "\n";
?>
<?php
  } elseif ($HTTP_GET_VARS['action'] == 'edit') {
    $poll_query = tep_db_query("select * from phesis_poll_desc where pollid = '" . $HTTP_GET_VARS['cID'] . "'");
    $polls = tep_db_fetch_array($poll_query);
?>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading">&nbsp;<?php echo HEADING_TITLE; ?>&nbsp;</td>
            <td align="right">&nbsp;<?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?>&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
      <td><table border="0" width="70%" cellspacing="0" cellpadding="0">
       <form name="polls" <?php echo 'action="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action', 'cID')) . 'action=update', 'NONSSL') . '"'; ?> method="post"><input type="hidden" name="pollid" value="<?php echo $HTTP_GET_VARS['cID']; ?>">
      <tr>
        <td>&nbsp</td>
      </tr>
	<tr>
        <td><?php echo TEXT_POLL_TITLE; ?>&nbsp</td>
        <td><input type="text" name="title" maxlength="60" size="50" value="<?echo $polls['pollTitle']?>"></td>
      </tr>
      <tr>
        <td>&nbsp</td>
      </tr>
<?php
      for ($i=1; $i<13; $i++){
    $poll_data_query=tep_db_query("select * from phesis_poll_data where pollid = '" . $HTTP_GET_VARS['cID'] . "' and voteid='$i'"); 
    $polls_data=tep_db_fetch_array($poll_data_query);

?>
      <tr>
	<td><?php echo TEXT_OPTION . ' ' . $i?>&nbsp</td>
      <td><input type="text" name="voteid<?echo $i?>" maxlength="50" size="50" value="<?echo$polls_data['optionText']?>"></td>     
      </tr>
<?php
	}
?>
	<tr>
        <td align="right" class="main"><br><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?>&nbsp;<?php echo '<a href="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action', 'cID')) . 'info=' . $HTTP_GET_VARS['cID'], 'NONSSL') . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
      </tr>
	</form>
      </table></td></tr>
<?php
  } else {
?>
      <tr>
        <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading">&nbsp;<?php echo HEADING_TITLE; ?>&nbsp;</td>
            <td align="right">&nbsp;<?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?>&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr class="dataTableHeadingRow">
                <td class="dataTableHeadingContent" align="center">&nbsp;<?php echo TABLE_HEADING_ID; ?>&nbsp;</td>
                <td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_TITLE; ?>&nbsp;</td>
                <td class="dataTableHeadingContent" align="center">&nbsp;<?php echo TABLE_HEADING_VOTES; ?>&nbsp;</td>
                <td class="dataTableHeadingContent" align="center">&nbsp;<?php echo TABLE_HEADING_CREATED; ?>&nbsp;</td>
		    <td class="dataTableHeadingContent" align="center">&nbsp;<?php echo TABLE_HEADING_PUBLIC; ?>&nbsp;</td>
		    <td class="dataTableHeadingContent" align="center">&nbsp;<?php echo TABLE_HEADING_OPEN; ?>&nbsp;</td>
                <td class="dataTableHeadingContent" align="center">&nbsp;<?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
              </tr>
<?php

    $poll_query_raw = "select * from phesis_poll_desc order by pollID asc";
    $polls_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $poll_query_raw, $poll_query_numrows);
    $poll_query=tep_db_query($poll_query_raw);
    $rows = 0;
    while ($polls = tep_db_fetch_array($poll_query)) {
      $rows++;
	if (((!$HTTP_GET_VARS['info']) || (@$HTTP_GET_VARS['info'] == $polls['pollID'])) && (!$poInfo)) {
      $poInfo = new objectInfo($polls);
      }

      if ( (is_object($poInfo)) && ($polls['pollID'] == $poInfo->pollID) ) {
?>
          <tr class="dataTableRowSelected" onmouseover="this.style.cursor='hand'" onclick="document.location.href='<?php echo tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action', 'info', 'x', 'y')) . 'action=edit&cID=' . $poInfo->pollID, 'NONSSL'); ?>'">
<?php
      } else {
?>
          <tr class="dataTableRow" onmouseover="this.className='dataTableRowOver';this.style.cursor='hand'" onmouseout="this.className='dataTableRow'" onclick="document.location.href='<?php echo tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('info', 'action', 'x', 'y')) . 'info=' . $polls['pollID'], 'NONSSL'); ?>'">
<?php
      }
?>
                <td class="dataTableContent" align="center">&nbsp;<?php echo $polls['pollID']; ?>&nbsp;</td>
                <td class="dataTableContent">&nbsp;<?php echo $polls['pollTitle']; ?>&nbsp;</td>
                <td class="dataTableContent" align="center">&nbsp;<?php echo $polls['voters']; ?>&nbsp;</td>
                <td class="dataTableContent" align="center">&nbsp;<?php echo tep_datetime_short($polls['timeStamp']); ?>&nbsp;</td>
                <td class="dataTableContent" align="center">&nbsp;
			<?php 
			if ($polls['poll_type']==1) {
				echo '<a href="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('info', 'action', 'x', 'y')) . 'action=poll_type&info=' . $polls['pollID'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', _ALT_PUBLIC) . '</a>';
				} else {
				echo '<a href="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('info', 'action', 'x', 'y')) . 'action=poll_type&info=' . $polls['pollID'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', _ALT_PRIVATE) . '</a>';
				}
                  ?>
                &nbsp;</td>
                <td class="dataTableContent" align="center">&nbsp;
			<?php
			 if ($polls['poll_open']==1) {
				echo '<a href="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('info', 'action', 'x', 'y')) . 'action=poll_open&info=' . $polls['pollID'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', _ALT_REOPEN) . '</a>';
				} else {
				echo '<a href="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('info', 'action', 'x', 'y')) . 'action=poll_open&info=' . $polls['pollID'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', _ALT_CLOSE) . '</a>';
				}
			?>
			&nbsp;</td>
<?php
      if ($polls['pollID'] == $poInfo->pollID) {
?>
                <td class="smallText" align="center">&nbsp;<?php echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); ?>&nbsp;</td>
<?php
      } else {
?>
                <td class="smallText" align="center">&nbsp;<?php echo '<a href="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('info', 'action', 'x', 'y')) . 'info=' . $polls['pollID'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; ?>&nbsp;</td>
<?php
      }
?>
              </tr>
<?php
    }
?>
              <tr>
                <td colspan="7"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td class="smalltext" valign="top">&nbsp;<?php echo $polls_split->display_count($poll_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_POLLS); ?>&nbsp;&nbsp;</td>
                    <td class="smalltext" align="right">&nbsp;<?php echo $polls_split->display_links($poll_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?>&nbsp;<? echo '<br><br>&nbsp;<a href="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action', 'info')) . 'action=new', 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'button_new_poll.gif', IMAGE_NEW_POLL) . '</a>&nbsp;';?></td>
			</tr>
                </table></td>
              </tr>
            </table></td>
<?php
  $heading=array();
  $contents=array();
  
  $heading[] = array('align' => 'left', 'text' => '&nbsp;<b>' . $poInfo->pollTitle . '</b>&nbsp;');

  if ($HTTP_GET_VARS['action'] == 'confirm') {
    $form = '<form action="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action')) . 'action=deleteconfirm', 'NONSSL') . '" method="post"><input type="hidden" name="cID" value="' . $poInfo->pollID . '">'  ."\n";
    $contents[] = array('text' => $form);
    $contents[] = array('align' => 'left', 'text' => TEXT_DELETE_INTRO . '<br>&nbsp;<b>' . $poInfo->name . '</b><br>&nbsp;');
    $contents[] = array('align' => 'center', 'text' => tep_image_submit('button_delete.gif', IMAGE_DELETE) . '&nbsp;<a href="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action')), 'NONSSL') . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  } else {
    $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action', 'info', 'x', 'y')) . 'action=edit&cID=' . $poInfo->pollID, 'NONSSL') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a>&nbsp;<a href="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action', 'info', 'x', 'y')) . 'action=confirm&info=' . $poInfo->pollID, 'NONSSL') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
}
if ($poll_query_numrows==0){
	$contents[] = array('align' => 'center', 'text' => 'No polls defined');
}
if ($form) $contents[] = array('text' => '</form>');

    echo '            <td width="25%" valign="top">' . "\n";
$box = new box;
echo $box->infoBox($heading, $contents);
    echo '            </td>' . "\n";
}
?>           
          </tr>
        </table></td>
      </tr>
<?php
?>
    </table></td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
