<?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@magento.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.magento.com for more information.
 *
 * @category    design
 * @package     default_default
 * @copyright   Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<script type="text/javascript">
function runProfile(popup)
{
    var url = '<?php echo $this->getUrl('*/*/run', array('id'=>$this->getProfileId())) ?>';
    if ($('profile_direction') != undefined
        && $('profile_data_transfer') != undefined
        && getDirection() == 'import' && getTransferType() == 'interactive') {
        var file = getSelectedFiles();
        if (file == '') {
            alert('Please select imported files');
            $('file_list').show();
            return false;
        }
        url += 'files/' + file + '/';
    }

    if (!popup) {
        $('run_iframe').style.display = 'block';
        $('run_iframe').src = url;
    } else {
        window.open(url);
    }
}

function getDirection()
{
    return $('profile_direction').options[$('profile_direction').options.selectedIndex].value;
}

function getSelectedFiles()
{
    return $('files').options[$('files').options.selectedIndex].value;
}

function getTransferType()
{
    return $('profile_data_transfer').options[$('profile_data_transfer').options.selectedIndex].value;
}
</script>
<ul class="messages">
<li class="notice-msg">
    <ul>
        <li><?php echo $this->__('Please make sure that your changes were saved before running the profile.') ?></li>
    </ul>
</li>
</ul>
<div id="file_list" style="display: none;">
<select id="files" name="files">
    <option value="">Select a file</option>
<?php if ($files = $this->getImportedFiles()) :
    foreach ($files as $file) : ?>
        <option value=<?php echo $file ?>><?php echo $file ?></option>
<?php   endforeach;
    endif; ?>
</select>
<br />&nbsp;
</div>

<?php echo $this->getRunButtonHtml() ?><br/>
<iframe id="run_iframe" src="<?php echo $this->getJsUrl() ?>blank.html" frameborder=0 style="display:none; width:100%; height:400px;"></iframe>
