<?php
/*
 * @author     M2E Pro Developers Team
 * @copyright  M2E LTD
 * @license    Commercial use is forbidden
 */

// @codingStandardsIgnoreFile

/** @var $this Ess_M2ePro_Block_Adminhtml_Ebay_Listing_Transferring_Destination */
?>

<script type="text/javascript">

    $('to_account_id')
        .observe('change', EbayListingTransferringObj.accountIdChange.bind(EbayListingTransferringObj))
        .simulate('change');

    $('to_marketplace_id')
        .observe('change', EbayListingTransferringObj.marketplaceIdChange.bind(EbayListingTransferringObj))
        .simulate('change');

    $('to_store_id')
        .observe('change', EbayListingTransferringObj.storeIdChange.bind(EbayListingTransferringObj))
        .simulate('change');

</script>

<style>
    .destination-table-grid label {
        font-weight: bold;
    }

    .destination-table-grid td , .destination-table-grid th {
        padding: 4px 8px 4px 8px !important;
    }

    .destination-table-grid td select {
        width: 100% !important;
    }
</style>

<table class="destination-table-grid" cellpadding="0" cellspacing="0">
    <thead>
        <tr class="headings">
            <th style="width: 20%;"></th>
            <th style="width: 40%;"><span><?php echo Mage::helper('M2ePro')->__('From'); ?></span></th>
            <th style="width: 40%;"><span><?php echo Mage::helper('M2ePro')->__('To'); ?></span></th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>
                <label for="to_account_id"><?php echo Mage::helper('M2ePro')->__('Account'); ?></label>
            </td>
            <td>
                <input id="from_account_id" type="hidden" value="<?php echo $this->getListing()->getAccount()->getId(); ?>">
                <span><?php echo Mage::helper('M2ePro')->escapeHtml($this->getListing()->getAccount()->getTitle()); ?></span>
            </td>
            <td>
                <select id="to_account_id" name="to_account_id" class="required-entry">
                    <option class="empty"></option>
                    <?php foreach ($this->getAccounts()->getItems() as $account) : ?>
                        <option class="value" value="<?php echo $account->getId(); ?>" <?php if ($this->getListing()->getAccount()->getId() == $account->getId()) : echo 'selected'; endif; ?>><?php echo Mage::helper('M2ePro')->escapeHtml($account->getTitle()); ?></option>
                    <?php endforeach; ?>
                </select>
            </td>
        </tr>
        <tr>
            <td>
                <label for="to_marketplace_id"><?php echo Mage::helper('M2ePro')->__('Marketplace'); ?></label>
            </td>
            <td>
                <input id="from_marketplace_id" type="hidden" value="<?php echo $this->getListing()->getMarketplace()->getId(); ?>">
                <span><?php echo Mage::helper('M2ePro')->escapeHtml($this->getListing()->getMarketplace()->getTitle()); ?></span>
            </td>
            <td>
                <select id="to_marketplace_id" name="to_marketplace_id" class="required-entry">
                    <option class="empty"></option>
                    <?php foreach ($this->getMarketplaces()->getItems() as $marketplace) : ?>
                        <option class="value" data_status="<?php echo $marketplace->getStatus(); ?>" value="<?php echo $marketplace->getId(); ?>" <?php if ($this->getListing()->getMarketplace()->getId() == $marketplace->getId()) : echo 'selected'; endif; ?>><?php echo Mage::helper('M2ePro')->escapeHtml($marketplace->getTitle()); ?></option>
                    <?php endforeach; ?>
                </select>
            </td>
        </tr>
        <tr>
            <td>
                <label for="to_store_id"><?php echo Mage::helper('M2ePro')->__('Store View'); ?></label>
            </td>
            <td>
                <input id="from_store_id" type="hidden" value="<?php echo $this->getListing()->getStoreId(); ?>">
                <span>
                    <?php echo Mage::helper('M2ePro')->escapeHtml($this->getStore()->getWebsite()->getName()); ?><br>
                    &nbsp;&nbsp;<?php echo Mage::helper('M2ePro')->escapeHtml($this->getStore()->getGroup()->getName()); ?><br>
                    &nbsp;&nbsp;&nbsp;&nbsp;<?php echo Mage::helper('M2ePro')->escapeHtml($this->getStore()->getName()); ?>
                </span>
            </td>
            <td>
                <?php echo $this->getChildHtml('store_switcher'); ?>
            </td>
        </tr>
        <tr>
            <td>
                <label for="to_listing_id"><?php echo Mage::helper('M2ePro')->__('Listing'); ?></label>
            </td>
            <td>
                <input id="from_listing_id" type="hidden" value="<?php echo $this->getListing()->getId(); ?>">
                <span><?php echo Mage::helper('M2ePro')->escapeHtml($this->getListing()->getTitle()); ?></span>
            </td>
            <td>
                <select id="to_listing_id" name="to_listing_id" class="required-entry">
                    <option class="empty"></option>
                    <option class="value" style="color: brown;" value="<?php echo Ess_M2ePro_Model_Ebay_Listing_Transferring::PARAM_LISTING_ID_DESTINATION_CREATE_NEW; ?>"><?php echo Mage::helper('M2ePro')->__('Create New'); ?></option>
                </select>
            </td>
        </tr>
    </tbody>
</table>

<div style="float: right; padding: 10px;">
    <span><a href="javascript:void(0);" onclick="Windows.getFocusedWindow().close()"><?php echo Mage::helper('M2ePro')->__('Cancel') ?></a></span>
    &nbsp;&nbsp;&nbsp;&nbsp;
    <span><?php echo $this->getChildHtml('continue_button'); ?></span>
</div>