<?php
/**
 * Page Template
 *
 * Loaded automatically by index.php?main_page=adress_book.<br />
 * Allows customer to manage entries in their address book
 *
 * @package templateSystem
 * @copyright Copyright 2003-2005 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 $Id: tpl_address_book_default.php 5369 2006-12-23 10:55:52Z drbyte $
 */
?>
<div class="centerColumn" id="addressBookDefault">
	<div class="stacked-layout">
		<h1 id="addressBookDefaultHeading" class="page-default-heading"><?php echo HEADING_TITLE; ?></h1>
		 
		<?php if ($messageStack->size('addressbook') > 0) echo $messageStack->output('addressbook'); ?> 
		      
		<p id="addressBookDefaultPrimary" class="important"><?php echo PRIMARY_ADDRESS_TITLE; ?></p>
		<address class="back"><?php echo zen_address_label($_SESSION['customer_id'], $_SESSION['customer_default_address_id'], true, ' ', '<br />'); ?></address>
		<br>
		<div class="instructions"><?php echo PRIMARY_ADDRESS_DESCRIPTION; ?></div>
		<br><br>

		<h3 class="section-title"><?php echo ADDRESS_BOOK_TITLE; ?></h3>
		<div class="text-danger"><?php echo sprintf(TEXT_MAXIMUM_ENTRIES, MAX_ADDRESS_BOOK_ENTRIES); ?></div>
		<br class="clearBoth" />
		<?php
		/**
		 * Used to loop thru and display address book entries
		 */
		  foreach ($addressArray as $addresses) {
		?>
		<p class="addressBookDefaultName important"><?php echo zen_output_string_protected($addresses['firstname'] . ' ' . $addresses['lastname']); ?><?php if ($addresses['address_book_id'] == $_SESSION['customer_default_address_id']) echo '&nbsp;' . PRIMARY_ADDRESS ; ?></p>

		<address><?php echo zen_address_format($addresses['format_id'], $addresses['address'], true, ' ', '<br />'); ?></address>
		<br>
		<div class="buttonRow"><?php echo '<a href="' . zen_href_link(FILENAME_ADDRESS_BOOK_PROCESS, 'edit=' . $addresses['address_book_id'], 'SSL') . '" class="button"><i class="fa fa-edit"></i> ' . BUTTON_EDIT_SMALL_ALT . '</a> <a href="' . zen_href_link(FILENAME_ADDRESS_BOOK_PROCESS, 'delete=' . $addresses['address_book_id'], 'SSL') . '" class="button"><i class="fa fa-trash-o"></i> ' . BUTTON_DELETE_SMALL_ALT . '</a>'; ?></div>
		<br><br>
		<?php
		  }
		?>

		<?php
		  if (zen_count_customer_address_book_entries() < MAX_ADDRESS_BOOK_ENTRIES) {
		?>
		   <div class="buttonRow pull-right"><?php echo '<a href="' . zen_href_link(FILENAME_ADDRESS_BOOK_PROCESS, '', 'SSL') . '" class="button">' . BUTTON_ADD_ADDRESS_ALT . '</a>'; ?></div>
		<?php
		  }
		?>
		<div class="buttonRow pull-left"><?php echo '<a href="' . zen_href_link(FILENAME_ACCOUNT, '', 'SSL') . '" class="button button-inverse">' . BUTTON_BACK_ALT . '</a>'; ?></div>
		<br class="clearBoth" />
	</div>
</div>
