<?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   Varien
 * @package    Varien_Object
 * @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 echo $this->template('header.phtml') ?>

<?php try { ?>
    <?php $_current = $this->get('pear')->getDistCurrent() ?>
    <?php $_avail = $this->get('pear')->getDistAvailable() ?>
    <p>Current version: <?php echo $_current->version.' ('.$_current->state.')' ?></p>
    
    <?php if (!$_avail): ?>
    
    <p>No available version upgrades found within your preferred stability level 
        (<?php echo $this->get('pear')->getPreferredState() ?>).
    </p>
    
    <?php else: ?>

    <form action="<?php echo $this->url('distUpgradePost') ?>" method="post" target="pear_iframe" onsubmit="return onSubmit()">
        <p>Available version upgrades: <select name="version">    
    <?php foreach ($_avail as $_dist): ?>
        <option value="<?php echo $_dist->version ?>"><?php echo $_dist->version.' ('.$_dist->state.')' ?></option>
    <?php endforeach; ?>
        </select></p>
        <p><strong>The upgrade consists of 2 steps:</strong>
        <ul>
            <li>1. Deleting all packages for current version.</li>
            <li>2. Installing packages for the upgraded version.</li>
        </ul></p>
        <br/>
        <p><strong>Please make sure to back up all your customizations and data.</strong></p>
        <p><button type="submit">Upgrade</button></p>
    </form>
    
    <?php endif; ?>
    
<?php } catch (Exception $e) { ?>

    Error retrieving versions information: <?php echo $e->getMessage() ?>

<?php } ?>

<?php echo $this->template('pear/iframe.phtml') ?>

<a name="pear_iframe_result"></a>
<div id="pear_iframe_success" style="display:none">
    <?php $this->set('messages', array('success'=>array('Procedure completed. Please check the output frame for useful information and refresh the page to see changes.'))) ?>
    <?php echo $this->template('messages.phtml') ?>
    <button onclick="location.reload()">Refresh</button>
</div>
<div id="pear_iframe_failure" style="display:none">
    <?php $this->set('messages', array('error'=>array('Please check the output frame for errors and refresh the page to retry changes.'))) ?>
    <?php echo $this->template('messages.phtml') ?>
    <button onclick="location.reload()">Refresh</button>
</div>

<?php echo $this->template('footer.phtml') ?>
