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

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com
  Copyright (c) 2002 osCommerce

  Gift Voucher System
  Copyright (c) 2001,2002,2003 Ian C Wilson
  http://www.phesis.co.uk

  Released under the GNU General Public License
*/

  require('includes/application_top.php');
  require(DIR_WS_CLASSES . 'currencies.php');
  $currencies = new currencies();

?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<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">
</head>
<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">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
            <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr class="dataTableHeadingRow">
                <td class="dataTableHeadingContent"><?php echo 'Senders Name'; ?></td>
                <td class="dataTableHeadingContent" align="right"><?php echo 'Voucher Value'; ?></td>
                <td class="dataTableHeadingContent" align="center"><?php echo 'Voucher Code'; ?></td>
	          <td class="dataTableHeadingContent" align="right"><?php echo 'Date Sent'; ?></td>		
                  <td class="dataTableHeadingContent" align="center">&nbsp;<?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
              </tr>
<?php
  if ($HTTP_GET_VARS['page'] > 1) $rows = $HTTP_GET_VARS['page'] * 20 - 20;
  $gv_query_raw = "select sent_firstname, sent_surname,customer_id_sent,emailed_to,date_redeemed,ip_address,customer_id_redeem,redeem_flag, gv_id, gv_number, gv_amount, date_created from gv_tracking";

  $gv_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $gv_query_raw, $gv_query_numrows);
  $gv_query = tep_db_query($gv_query_raw);
  while ($gv_list = tep_db_fetch_array($gv_query)) {
    $rows++;

    if (strlen($rows) < 2) {
      $rows = '0' . $rows;
    }
    if (((!$HTTP_GET_VARS['gid']) || (@$HTTP_GET_VARS['gid'] == $gv_list['gv_id'])) && (!$gInfo)) {
    $gInfo = new objectInfo($gv_list);
    }
if ( (is_object($gInfo)) && ($gv_list['gv_id'] == $gInfo->gv_id) ) {
        echo '          <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . tep_href_link('gv_sent.php', tep_get_all_get_params(array('gid', 'action')) . 'gid=' . $gInfo->gv_id . '&action=edit') . '\'">' . "\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('gv_sent.php', tep_get_all_get_params(array('gid', 'action')) . 'gid=' . $gv_list['gv_id']) . '\'">' . "\n";
      }
?>
                <td class="dataTableContent"><?php echo $gv_list['sent_firstname'] . ' ' . $gv_list['sent_surname']; ?></td>
                <td class="dataTableContent" align="right"><?php echo $currencies->format($gv_list['gv_amount']); ?>&nbsp;</td>                
                <td class="dataTableContent" align="center"><?php echo $gv_list['gv_number']; ?>&nbsp;</td>
                <td class="dataTableContent" align="right"><?php echo tep_date_short($gv_list['date_created']); ?>&nbsp;</td>
<?php
      if ($gv_list['gv_id'] == $gInfo->gv_id) {
?>
                <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_GV_SENT, tep_get_all_get_params(array('gid', 'action', 'x', 'y')) . 'gid=' . $gv_list['gv_id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; ?>&nbsp;</td>
<?php
      }
?>
                              </tr>
<?php
  }
?>
            </table></td>
          </td>
          <tr>
            <td colspan="4"><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td class="smallText">&nbsp;<?php echo $gv_split->display_count($gv_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?>&nbsp;</td>
                <td align="right" class="smallText">&nbsp;<?php echo $gv_split->display_links($gv_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?>&nbsp;</td>
              </tr>
            </table></td>

          </tr>
        </table></td>
    <td width="25%">
<?php
    $heading = array();
    $heading[] = array('text' => '['.$gInfo->gv_id.'] '.tep_date_short($gInfo->date_created).' '.$currencies->format($gInfo->gv_amount));
    $contents = array();
    $contents[] = array('text' => 'Senders Id : <b>'.$gInfo->customer_id_sent.'</b>');
    $contents[] = array('text' => 'Amount Sent : <b>'.$currencies->format($gInfo->gv_amount).'</b>');
    $contents[] = array('text' => 'Date Sent : <b>'.tep_date_short($gInfo->date_created).'</b>');
    $contents[] = array('text' => 'Voucher Code : <b>'.$gInfo->gv_number.'</b>');
    $contents[] = array('text' => 'Email Addr : <b>'.$gInfo->emailed_to.'</b>');
    $contents[] = array('text' => '--------------------------');
    if ($gInfo->redeem_flag=='Y') {
      $contents[] = array('text' => 'Date Redeemed : <B>'.tep_date_short($gInfo->date_redeemed).'</B>');
      $contents[] = array('text' => 'ip address : <B>'.$gInfo->ip_address.'</B>');
      $contents[] = array('text' => 'Customer Id : <b>'.$gInfo->customer_id_redeem.'</b>');
    } else {
      $contents[] = array('text' => 'Not Redeemed');
    }
 $box = new box;
    echo $box->infoBox($heading, $contents);
?>
      </tr>
    </table></td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->

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