<?php
/**
 * Page Template
 *
 * Loaded automatically by index.php?main_page=account.<br />
 * Displays previous orders and options to change various Customer Account settings
 *
 * @package templateSystem
 * @copyright Copyright 2003-2012 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version GIT: $Id: Author: DrByte  Sun Aug 5 20:48:10 2012 -0400 Modified in v1.5.1 $
 */
?>

<div class="centerColumn" id="accountDefault">

<h1 id="accountDefaultHeading" class="page-default-heading"><?php echo HEADING_TITLE; ?></h1>

<?php if ($messageStack->size('account') > 0) echo $messageStack->output('account'); ?>

<?php
    if (zen_count_customer_orders() > 0) {
  ?>
<?php echo '<a href="' . zen_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL') . '" class="button pull-right">' . OVERVIEW_SHOW_ALL_ORDERS . '</a>'; ?>
<div class="clearfix"></div>
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0" id="prevOrders">
<caption class="text-left"><h3 class="section-title"><?php echo OVERVIEW_PREVIOUS_ORDERS; ?></h3></caption>
  <tr class="tableHeading">
    <th scope="col"><?php echo TABLE_HEADING_DATE; ?></th>
    <th scope="col"><?php echo TABLE_HEADING_ORDER_NUMBER; ?></th>
    <th scope="col"><?php echo TABLE_HEADING_SHIPPED_TO; ?></th>
    <th scope="col"><?php echo TABLE_HEADING_STATUS; ?></th>
    <th scope="col"><?php echo TABLE_HEADING_TOTAL; ?></th>
    <th scope="col"><?php echo TABLE_HEADING_VIEW; ?></th>
  </tr>
<?php
  foreach($ordersArray as $orders) {
?>
  <tr>
    <td><?php echo zen_date_short($orders['date_purchased']); ?></td>
    <td><?php echo TEXT_NUMBER_SYMBOL . $orders['orders_id']; ?></td>
    <td><address><?php echo zen_output_string_protected($orders['order_name']) . '<br />' . $orders['order_country']; ?></address></td>
    <td><?php echo $orders['orders_status_name']; ?></td>
    <td><?php echo $orders['order_total']; ?></td>
    <td><?php echo '<a href="' . zen_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'], 'SSL') . '" class="button button-inverse"> ' . BUTTON_VIEW_SMALL_ALT . '</a>'; ?></td>
  </tr>

<?php
  }
?>
</table>
<?php
  }
?>
<br class="clearBoth" />
<div id="accountLinksWrapper">
<h2 class="page-default-heading"><?php echo MY_ACCOUNT_TITLE; ?></h2>
<ul id="myAccountGen">
<li><?php echo ' <a href="' . zen_href_link(FILENAME_ACCOUNT_EDIT, '', 'SSL') . '">' . MY_ACCOUNT_INFORMATION . '</a>'; ?></li>
<li><?php echo ' <a href="' . zen_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL') . '">' . MY_ACCOUNT_ADDRESS_BOOK . '</a>'; ?></li>
<li><?php echo ' <a href="' . zen_href_link(FILENAME_ACCOUNT_PASSWORD, '', 'SSL') . '">' . MY_ACCOUNT_PASSWORD . '</a>'; ?></li>
</ul>


<?php
	// BEGIN CEON BACK IN STOCK NOTIFICATIONS 1 of 3
  if (SHOW_NEWSLETTER_UNSUBSCRIBE_LINK !='false' or CUSTOMERS_PRODUCTS_NOTIFICATION_STATUS !='0' ||
    BACK_IN_STOCK_NOTIFICATION_ENABLED == 1) {
    	/*
// END CEON BACK IN STOCK NOTIFICATIONS 1 of 3
  //if ((int)ACCOUNT_NEWSLETTER_STATUS > 0 or CUSTOMERS_PRODUCTS_NOTIFICATION_STATUS !='0') {
  	// BEGIN CEON BACK IN STOCK NOTIFICATIONS 2 of 3
*/
// END CEON BACK IN STOCK NOTIFICATIONS 2 of 3
?>
<h2 class="page-default-heading"><?php echo EMAIL_NOTIFICATIONS_TITLE; ?></h2>
<ul id="myAccountNotify" class="list">
<?php
  if ((int)ACCOUNT_NEWSLETTER_STATUS > 0) {
?>
<li><?php echo ' <a href="' . zen_href_link(FILENAME_ACCOUNT_NEWSLETTERS, '', 'SSL') . '">' . EMAIL_NOTIFICATIONS_NEWSLETTERS . '</a>'; ?></li>
<?php } //endif newsletter unsubscribe ?>
<?php 
// BEGIN CEON BACK IN STOCK NOTIFICATIONS 3 of 3
  if (BACK_IN_STOCK_NOTIFICATION_ENABLED == 1) {
      if ($subscribed_to_notification_lists) {
          echo '<li><a href="' . zen_href_link(FILENAME_ACCOUNT_BACK_IN_STOCK_NOTIFICATIONS, '', 'SSL') . '">' . EMAIL_NOTIFICATIONS_BACK_IN_STOCK_NOTIFICATIONS . '</a></li>';
      } else {
          echo '<li>' . EMAIL_NOTIFICATIONS_NO_BACK_IN_STOCK_NOTIFICATIONS . '</li>';
      }
  }
// END CEON BACK IN STOCK NOTIFICATIONS 3 of 3
?>
<?php
  if (CUSTOMERS_PRODUCTS_NOTIFICATION_STATUS == '1') {
?>
<li><?php echo ' <a href="' . zen_href_link(FILENAME_ACCOUNT_NOTIFICATIONS, '', 'SSL') . '">' . EMAIL_NOTIFICATIONS_PRODUCTS . '</a>'; ?></li>

<?php } //endif product notification ?>
</ul>

<?php } // endif don't show unsubscribe or notification ?>
</div>

<?php
// only show when there is a GV balance
  if ($customer_has_gv_balance ) {
?>
<div id="sendSpendWrapper">
<?php require($template->get_template_dir('tpl_modules_send_or_spend.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_send_or_spend.php'); ?>
</div>
<?php
  }
?>
<br class="clearBoth" />
</div>