<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   design_default
 * @package    Mage
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php
/**
 * Temlate for Mage_Customer_Block_Address_Book block
 * @var $test Mage_Customer_Block_Address_Book
 */
?>
<div class="page-head button-level">
    <h3><?php echo $this->__('Address Book') ?></h3>
    <button class="form-button" onclick="window.location='<?php echo $this->getAddAddressUrl() ?>';"><span><?php echo $this->__('Add New Address') ?></span></button>
</div>
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<div class="col2-set">
    <div class="col-1 primary-address-list">
        <h4><?php echo $this->__('Default Addresses') ?></h4>
        <ol>
        <?php if($_pAddsses = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling()): ?>
            <li>
                <h5><?php echo $this->__('Default Billing Address') ?></h5>
                <address>
                <?php echo $this->getAddressHtml(Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses)) ?><br/>
                <strong><a href="<?php echo $this->getAddressEditUrl(Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses)) ?>"><?php echo $this->__('Change Billing Address') ?></a></strong></address>
           </li>
           <?php elseif($_pAddsses = Mage::getSingleton('customer/session')->getCustomer()->getDefaultShipping()): ?>
           <li>
                <h5><?php echo $this->__('Default Billing Address') ?></h5>
                <address>
                    <?php echo $this->getAddressHtml(Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses)) ?><br/>
                    <strong><a href="<?php echo $this->getAddressEditUrl(Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses)) ?>"><?php echo $this->__('Change Billing Address') ?></a></strong>
                </address>
            </li>
            <?php else: ?>
            <li>
                <h5><?php echo $this->__('Default Billing Address') ?></h5>
                <?php echo $this->__('You have no default billing address in your address book.') ?></li>
            <?php endif ?>
            <?php if($_pAddsses = Mage::getSingleton('customer/session')->getCustomer()->getDefaultShipping()): ?>
            <li>
                <h5><?php echo $this->__('Default Shipping Address') ?></h5>
                <address>
                    <?php echo $this->getAddressHtml(Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses)) ?><br/>
                    <strong><a href="<?php echo $this->getAddressEditUrl(Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses)) ?>"><?php echo $this->__('Change Shipping Address') ?></a></strong>
                </address>
            </li>
            <?php elseif($_pAddsses = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling()): ?>
            <li>
                <h5><?php echo $this->__('Default Shipping Address') ?></h5><address>
                <?php echo $this->getAddressHtml(Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses)) ?><br/>
                <strong><a href="<?php echo $this->getAddressEditUrl(Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses)) ?>"><?php echo $this->__('Change Shipping Address') ?></a></strong>
                </address>
            </li>
            <?php else: ?>
            <li>
                <h5><?php echo $this->__('Default Shipping Address') ?></h5><?php echo $this->__('You have no default shipping address in your address book.') ?>
            </li>
            <?php endif ?>
        </ol>
    </div>
    <div class="col-2 address-list">
        <h4><?php echo $this->__('Additional Address Entries') ?></h4>
        <ol>
        <?php if($_pAddsses = $this->getAdditionalAddresses()): ?>
            <?php foreach($_pAddsses as $_address): ?>
            <li>
                <address>
                    <?php echo $this->getAddressHtml($_address) ?><br/>
                    <strong><a href="<?php echo $this->getUrl('customer/address/edit', array('id'=>$_address->getId())) ?>"><?php echo $this->__('Edit Address') ?></a></strong>
                    <span class="pipe">|</span>
                    <strong><a href="#" onclick="return deleteAddress('<?php echo $_address->getId() ?>');" class="link-remove"><?php echo $this->__('Delete Address') ?></a></strong>
                </address>
            </li>
            <?php endforeach; ?>
        <?php else: ?>
            <li> <strong><?php echo $this->__('You have no additional address entries in your address book.') ?></strong></li>
        <?php endif ?>
        </ol>
    </div>
</div>
<div class="button-set">
    <a href="<?php echo $this->getBackUrl() ?>" class="left">&laquo; <?php echo $this->__('Back') ?></a>
</div>
<script type="text/javascript">
//<![CDATA[
    function deleteAddress(addressId) {
        if(confirm('<?php echo $this->__('Are you sure you want to delete this address?') ?>')) {
            window.location='<?php echo $this->getDeleteUrl() ?>id/'+addressId;
        }
        return false;
    }
//]]>
</script>