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

// @codingStandardsIgnoreFile

/** @var $this Ess_M2ePro_Block_Adminhtml_Amazon_Account_Edit_Tabs_Order */

?>

<div id="block_notice_amazon_accounts_orders" class="block_notices_module" title="<?php echo Mage::helper('M2ePro')->__('Orders'); ?>">
    <?php
        echo Mage::helper('M2ePro')->__('Specify how M2E Pro should manage the Orders imported from Amazon.<br/><br/>
            You are able to configure the different rules of <strong>Magento Order Creation</strong> considering whether the Item was listed via M2E Pro or by some other software.<br/><br/>
            The <strong>Reserve Quantity</strong> feature will automatically work for imported Amazon Orders with Pending Status to hold the Stock until Magento Order is created or the reservation term is expired.<br/><br/>
            Moreover, you can provide the settings for <strong>Orders fulfilled by Amazon</strong>. Specify whether the corresponding Magento Order has to be created or not. Additionally, you are able to reduce Magento Stock taking into account the FBA Orders.<br/><br/>
            Besides, you can set your preferences for the <strong>Refund & Cancellation, Tax, Customer, Order Number</strong> and <strong>Order Status Mapping</strong> Settings as well as specify the automatic creation of invoices and shipment notifications.<br/><br/>
            More detailed information you can find <a href="%url%" target="_blank">here</a>.',
        Mage::helper('M2ePro/Module_Support')->getDocumentationUrl(null, null, 'orders')
        );
    ?>
</div>

<?php
    /** @var Ess_M2ePro_Model_Account $account */
    $account = Mage::helper('M2ePro/Data_Global')->getValue('model_account');

    $formData = $account ? $account->toArray() : array();
    $formData['magento_orders_settings'] = !empty($formData['magento_orders_settings']) ? json_decode($formData['magento_orders_settings'], true) : array();

    $defaults = Mage::getModel('M2ePro/Amazon_Account_Builder')->getDefaultData();

    if (isset($formData['magento_orders_settings']['tax']['excluded_states'])) {
        unset($defaults['magento_orders_settings']['tax']['excluded_states']);
    }

    if (isset($formData['magento_orders_settings']['tax']['excluded_countries'])) {
        unset($defaults['magento_orders_settings']['tax']['excluded_countries']);
    }

    $isEdit = !!$this->getRequest()->getParam('id');
    $isEdit && $defaults['magento_orders_settings']['refund_and_cancellation']['refund_mode'] = 0;

    $formData = Mage::helper('M2ePro')->arrayReplaceRecursive($defaults, $formData);

    if (is_array($formData['magento_orders_settings']['tax']['excluded_states'])) {
        $formData['magento_orders_settings']['tax']['excluded_states'] = implode(',', $formData['magento_orders_settings']['tax']['excluded_states']);
    }

    if (is_array($formData['magento_orders_settings']['tax']['excluded_countries'])) {
        $formData['magento_orders_settings']['tax']['excluded_countries'] = implode(',', $formData['magento_orders_settings']['tax']['excluded_countries']);
    }

?>

<script type="text/javascript">

    // Data for current tab
    //-----------------------------
    M2ePro.translator.add(<?php echo json_encode(array(
        'No Customer entry is found for specified ID.' =>
            Mage::helper('M2ePro')->__('No Customer entry is found for specified ID.'),
        'Select states where tax will be excluded' =>
            Mage::helper('M2ePro')->__('Select states where tax will be excluded'),
        'Select countries where VAT will be excluded' =>
            Mage::helper('M2ePro')->__('Select countries where VAT will be excluded'),
    )); ?>);

    Event.observe(window, 'load', function() {

        $('magento_orders_listings_mode').observe('change', AmazonAccountObj.magentoOrdersListingsModeChange).simulate('change');
        $('magento_orders_listings_store_mode').observe('change', AmazonAccountObj.magentoOrdersListingsStoreModeChange).simulate('change');

        $('magento_orders_listings_other_mode').observe('change', AmazonAccountObj.magentoOrdersListingsOtherModeChange);
        $('magento_orders_listings_other_product_mode').observe('change', AmazonAccountObj.magentoOrdersListingsOtherProductModeChange);

        $('magento_orders_number_source').observe('change', AmazonAccountObj.magentoOrdersNumberSourceChange);

        $('magento_orders_number_prefix_prefix').observe('keyup', AmazonAccountObj.magentoOrdersNumberPrefixPrefixChange);
        $('magento_orders_number_prefix_afn').observe('keyup', AmazonAccountObj.magentoOrdersNumberPrefixPrefixChange);
        $('magento_orders_number_prefix_prime').observe('keyup', AmazonAccountObj.magentoOrdersNumberPrefixPrefixChange);
        $('magento_orders_number_prefix_b2b').observe('keyup', AmazonAccountObj.magentoOrdersNumberPrefixPrefixChange);
        AmazonAccountObj.renderOrderNumberExample();

        $('magento_orders_fba_mode').observe('change', AmazonAccountObj.magentoOrdersFbaModeChange).simulate('change');
        $('magento_orders_fba_store_mode').observe('change', AmazonAccountObj.magentoOrdersFbaStoreModeChange);

        $('magento_orders_customer_mode').observe('change', AmazonAccountObj.magentoOrdersCustomerModeChange);
        $('magento_orders_tax_mode').observe('change', AmazonAccountObj.magentoOrdersTaxModeChange).simulate('change');
        $('magento_orders_tax_amazon_collects').observe('change', AmazonAccountObj.magentoOrdersTaxAmazonCollectsChange).simulate('change');
        $('magento_orders_tax_amazon_collects_for_eea_shipment')
            .observe('change', AmazonAccountObj.magentoOrdersTaxSkipTaxInEEAOrders)
            .simulate('change');
        $('magento_orders_status_mapping_mode').observe('change', AmazonAccountObj.magentoOrdersStatusMappingModeChange);
    });
    //-----------------------------

</script>

<style>
    .magento_orders_number_prefixes {
        border-collapse: collapse;
        margin-top: 5px;
        margin-bottom: 5px;
    }
    .magento_orders_number_prefixes tr.headings th {
        border: 1px solid #d1cfcf !important;
    }
    .magento_orders_number_prefixes td input {
        width: 230px !important;
    }
</style>

<div class="entry-edit" id="magento_block_amazon_accounts_magento_orders_listings">

    <div class="entry-edit-head">
        <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('M2ePro')->__('Product Is Listed By M2E Pro'); ?></h4>
    </div>

    <div class="fieldset">
        <div class="hor-scroll">

            <table class="form-list" cellspacing="0" cellpadding="0">

                <tr>
                    <td class="label">
                        <label for="magento_orders_listings_mode"><?php echo Mage::helper('M2ePro')->__('Create Order in Magento'); ?>:</label>
                    </td>
                    <td class="value">
                        <select id="magento_orders_listings_mode" name="magento_orders_settings[listing][mode]" class="M2ePro-required-when-visible">
                            <option value="0" <?php if ($formData['magento_orders_settings']['listing']['mode'] == 0) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1" <?php if ($formData['magento_orders_settings']['listing']['mode'] == 1) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Whether an Order has to be created in Magento if a sold Product belongs to M2E Pro Listings.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="magento_orders_listings_store_mode_container" <?php if($formData['magento_orders_settings']['listing']['mode'] == 0) echo 'style="display: none;"'; ?>>
                    <td class="label">
                        <label for="magento_orders_listings_store_mode"><?php echo Mage::helper('M2ePro')->__('Store View Source'); ?>:</label>
                    </td>
                    <td class="value">
                        <select id="magento_orders_listings_store_mode" name="magento_orders_settings[listing][store_mode]" class="M2ePro-required-when-visible">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_LISTINGS_STORE_MODE_DEFAULT; ?>" <?php if ($formData['magento_orders_settings']['listing']['store_mode'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_LISTINGS_STORE_MODE_DEFAULT) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Use Store View from Listing'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_LISTINGS_STORE_MODE_CUSTOM; ?>" <?php if ($formData['magento_orders_settings']['listing']['store_mode'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_LISTINGS_STORE_MODE_CUSTOM) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Choose Store View Manually'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('If Store View must be automatically taken from the Listing or manually chosen from available Store View values.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="magento_orders_listings_store_id_container" <?php if($formData['magento_orders_settings']['listing']['store_mode'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_LISTINGS_STORE_MODE_DEFAULT) echo 'style="display: none;"'; ?>>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Store View'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <?php echo $this->getChildHtml('magento_orders_listings_store_id'); ?>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Store in which Orders will be placed.'); ?></span>
                        </p>
                    </td>
                </tr>

            </table>

        </div>
    </div>

</div>

<div class="entry-edit" id="magento_block_amazon_accounts_magento_orders_listings_other">

    <div class="entry-edit-head">
        <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('M2ePro')->__('Product Is Listed By Any Other Software'); ?></h4>
    </div>

    <div class="fieldset">
        <div class="hor-scroll">

            <table class="form-list" cellspacing="0" cellpadding="0">

                <tr>
                    <td class="label">
                        <label for="magento_orders_listings_other_mode"><?php echo Mage::helper('M2ePro')->__('Create Order in Magento'); ?>:</label>
                    </td>
                    <td class="value">
                        <select id="magento_orders_listings_other_mode" name="magento_orders_settings[listing_other][mode]" class="required-entry">
                            <option value="0" <?php if ($formData['magento_orders_settings']['listing_other']['mode'] == 0) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1" <?php if ($formData['magento_orders_settings']['listing_other']['mode'] == 1) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Choose whether a Magento Order should be created if an Amazon Order is received for an item that does <b>not</b> belong to the M2E Pro Listing.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="magento_orders_listings_other_store_id_container" <?php if($formData['magento_orders_settings']['listing_other']['mode'] == 0) echo 'style="display: none;"'; ?>>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Store View'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <?php echo $this->getChildHtml('magento_orders_listings_other_store_id'); ?>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Store in which Orders will be placed.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="magento_orders_listings_other_product_mode_container" <?php if($formData['magento_orders_settings']['listing_other']['mode'] == 0) echo 'style="display: none;"'; ?>>
                    <td class="label">
                        <label for="magento_orders_listings_other_product_mode"><?php echo Mage::helper('M2ePro')->__('Product Not Found'); ?>:</label>
                    </td>
                    <td class="value">
                        <select id="magento_orders_listings_other_product_mode" name="magento_orders_settings[listing_other][product_mode]" class="M2ePro-required-when-visible">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_LISTINGS_OTHER_PRODUCT_MODE_IGNORE; ?>" <?php if ($formData['magento_orders_settings']['listing_other']['product_mode'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_LISTINGS_OTHER_PRODUCT_MODE_IGNORE) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Do Not Create Order'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_LISTINGS_OTHER_PRODUCT_MODE_IMPORT; ?>" <?php if ($formData['magento_orders_settings']['listing_other']['product_mode'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_LISTINGS_OTHER_PRODUCT_MODE_IMPORT) echo ' selected="selected"';?>><?php echo Mage::helper('M2ePro')->__('Create Product and Order'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('What has to be done if a Listed Product does not exist in Magento.'); ?></span><br/>
                            <span id="magento_orders_listings_other_product_mode_note" <?php if ($formData['magento_orders_settings']['listing_other']['product_mode'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_LISTINGS_OTHER_PRODUCT_MODE_IGNORE) echo 'style="display: none;"'; ?>><?php echo Mage::helper('M2ePro')->__('<b>Note:</b> Only Simple Products without Variations can be created in Magento. If there is a Product with Variations on Amazon, M2E Pro creates different Simple Products for each Variation.') ?></span>
                        </p>
                        <?php $canShowBlock = $formData['magento_orders_settings']['listing_other']['product_mode'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_LISTINGS_OTHER_PRODUCT_MODE_IMPORT; ?>
                        <div id="magento_orders_listings_other_product_mode_warning" <?php if (!$canShowBlock): ?>style="display: none;"<?php endif; ?>>
                            <ul class="messages">
                                <li class="warning-msg">
                                <?php echo Mage::helper('M2ePro')->__('Please note that a new Magento Product will be created if the corresponding SKU is not found in your Catalog.'); ?>
                                </li>
                            </ul>
                        </div>
                    </td>
                </tr>

                <tr id="magento_orders_listings_other_product_tax_class_id_container" <?php if (!$canShowBlock): ?>style="display: none;"<?php endif; ?>>
                    <td class="label">
                        <label for="magento_orders_listings_other_product_tax_class_id"><?php echo Mage::helper('M2ePro')->__('Product Tax Class') ?>:</label>
                    </td>
                    <td class="value">
                        <select id="magento_orders_listings_other_product_tax_class_id" name="magento_orders_settings[listing_other][product_tax_class_id]" class="M2ePro-required-when-visible">
                            <?php foreach ($this->productTaxClasses as $taxClass): ?>
                                <option value="<?php echo (int)$taxClass['value'] ?>" <?php if ($formData['magento_orders_settings']['listing_other']['product_tax_class_id'] == $taxClass['value']): ?>selected="selected"<?php endif; ?>><?php echo Mage::helper('M2ePro')->escapeHtml($taxClass['label']) ?></option>
                            <?php endforeach; ?>
                        </select>
                        <p class="note">
                            <?php echo Mage::helper('M2ePro')->__('Tax Class which will be used for Products created by M2E Pro.'); ?>
                        </p>
                    </td>
                </tr>

            </table>

        </div>
    </div>

</div>

<div class="entry-edit" id="magento_block_amazon_accounts_magento_orders_fba">
    <div class="entry-edit-head">
        <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('M2ePro')->__('FBA Orders Settings'); ?></h4>
    </div>

    <div class="fieldset">
        <div class="hor-scroll">

            <div id="block_notice_amazon_accounts_orders_fba" class="block_notices_module" title="<?php echo Mage::helper('M2ePro')->__('FBA Orders Settings'); ?>">
                <?php echo Mage::helper('M2ePro')->__('In this Block you can manage Stock Inventory of Products fulfilled by Amazon  (FBA Orders).<br/>
                <ul class=list>

                <li><b>Yes</b> - after Magento Order Creation of FBA Order, Quantity of Product reduces in Magento.</li>
                <li><b>No</b> - Magento Order Creation of FBA Order does not affect Quantity of Magento Product.</li>
                </ul>'); ?>
            </div>

            <table class="form-list" cellspacing="0" cellpadding="0">

                <tr>
                    <td class="label">
                        <label for="magento_orders_fba_mode"><?php echo Mage::helper('M2ePro')->__('Create Order in Magento'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="magento_orders_fba_mode" name="magento_orders_settings[fba][mode]" class="required-entry">
                            <option value="0" <?php if ($formData['magento_orders_settings']['fba']['mode'] == 0) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1" <?php if ($formData['magento_orders_settings']['fba']['mode'] == 1) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Whether an Order has to be created in Magento if a sold Product is fulfilled by Amazon.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="magento_orders_fba_store_mode_container">
                    <td class="label">
                        <label for="magento_orders_fba_store_mode"><?php echo Mage::helper('M2ePro')->__('Create in separate Store View'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="magento_orders_fba_store_mode" name="magento_orders_settings[fba][store_mode]" class="M2ePro-required-when-visible">
                            <option value="0" <?php if ($formData['magento_orders_settings']['fba']['store_mode'] == 0) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1" <?php if ($formData['magento_orders_settings']['fba']['store_mode'] == 1) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                    </td>
                </tr>

                <tr id="magento_orders_fba_store_id_container">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Store View'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <?php echo $this->getChildHtml('magento_orders_fba_store_id'); ?>
                    </td>
                </tr>

                <tr id="magento_orders_fba_stock_mode_container">
                    <td class="label">
                        <label for="magento_orders_fba_stock_mode"><?php echo Mage::helper('M2ePro')->__('Manage Stock'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="magento_orders_fba_stock_mode" name="magento_orders_settings[fba][stock_mode]" class="M2ePro-required-when-visible">
                            <option value="0" <?php if ($formData['magento_orders_settings']['fba']['stock_mode'] == 0) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1" <?php if ($formData['magento_orders_settings']['fba']['stock_mode'] == 1) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('If <i>Yes</i>, after Magento Order Creation QTY of Magento Product reduces.'); ?></span>
                        </p>
                    </td>
                </tr>

            </table>

        </div>
    </div>

</div>

<div class="entry-edit" id="magento_block_amazon_accounts_magento_orders_shipping_information">

    <div class="entry-edit-head">
        <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('M2ePro')->__('Shipping information'); ?></h4>
    </div>

    <div class="fieldset">
        <div class="hor-scroll">

            <table class="form-list" cellspacing="0" cellpadding="0">

                <tr>
                    <td class="label">
                        <label for="magento_orders_shipping_information_ship_by_date"><?php echo Mage::helper('M2ePro')->__('Import Ship by date to Magento order'); ?>: </label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="magento_orders_shipping_information_ship_by_date" name="magento_orders_settings[shipping_information][ship_by_date]" class="M2ePro-required-when-visible">
                            <option value="1" <?php if ($formData['magento_orders_settings']['shipping_information']['ship_by_date'] == 1) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                            <option value="0" <?php if ($formData['magento_orders_settings']['shipping_information']['ship_by_date'] == 0) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                        </select>
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label for="magento_orders_shipping_information_update_without_track"><?php echo Mage::helper('M2ePro')->__('Update Order as Shipped without Tracking Info'); ?>: </label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="magento_orders_shipping_information_update_without_track" name="magento_orders_settings[shipping_information][update_without_track]" class="M2ePro-required-when-visible">
                            <option value="1" <?php if ($formData['magento_orders_settings']['shipping_information']['update_without_track'] == 1) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                            <option value="0" <?php if ($formData['magento_orders_settings']['shipping_information']['update_without_track'] == 0) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                        </select>
                    </td>
                </tr>

                <tr id="magento_orders_shipping_information_container">
                    <td class="label">
                        <label for="magento_orders_shipping_address_region_override"><?php echo Mage::helper('M2ePro')->__('Override invalid Region/State required value') ?>:</label>
                    </td>
                    <td class="value">
                        <?php $regionOverride = !isset($formData['magento_orders_settings']['shipping_information']['shipping_address_region_override']) ? 1 : $formData['magento_orders_settings']['shipping_information']['shipping_address_region_override']?>
                        <select name="magento_orders_settings[shipping_information][shipping_address_region_override]" id="magento_orders_shipping_address_region_override">
                            <option value="0" <?php if (!$regionOverride): ?>selected="selected"<?php endif; ?>><?php echo Mage::helper('M2ePro')->__('No') ?></option>
                            <option value="1" <?php if ($regionOverride): ?>selected="selected"<?php endif; ?>><?php echo Mage::helper('M2ePro')->__('Yes') ?></option>
                        </select>
                        <p class="note">
                            When enabled, the invalid Region/State value will be replaced with an alternative one to create an order in Magento.
                        </p>
                    </td>
                </tr>
            </table>

        </div>
    </div>

</div>

<div class="entry-edit" id="magento_block_amazon_accounts_magento_orders_number" <?php if(($formData['magento_orders_settings']['listing']['mode'] == 0 && $formData['magento_orders_settings']['listing_other']['mode'] == 0)) echo 'style="display: none;"'; ?>>

    <div class="entry-edit-head">
        <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('M2ePro')->__('Magento Order Number'); ?></h4>
    </div>

    <div class="fieldset">
        <div class="hor-scroll">

            <div id="block_notice_amazon_accounts_orders_number" class="block_notices_module" title="<?php echo Mage::helper('M2ePro')->__('Number Prefix'); ?>">
                <?php echo Mage::helper('M2ePro')->__('Sets Magento Order number basing on the Settings below'); ?>
            </div>

            <table class="form-list" cellspacing="0" cellpadding="0">

                <tr>
                    <td class="label">
                        <label for="magento_orders_number_source"><?php echo Mage::helper('M2ePro')->__('Source'); ?>: </label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="magento_orders_number_source" name="magento_orders_settings[number][source]" class="M2ePro-required-when-visible">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_NUMBER_SOURCE_MAGENTO; ?>" <?php if ($formData['magento_orders_settings']['number']['source'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_NUMBER_SOURCE_MAGENTO) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Magento'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_NUMBER_SOURCE_CHANNEL; ?>" <?php if ($formData['magento_orders_settings']['number']['source'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_NUMBER_SOURCE_CHANNEL) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Amazon'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('If source is set to Magento, Magento Order numbers are created basing on your Magento Settings. If source is set to Amazon, Magento Order numbers are the same as Amazon Order numbers.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Prefix for magento order number'); ?>: </label>
                    </td>
                </tr>

            </table>

            <table class="form-list" cellspacing="0" cellpadding="0">

                <tr id="magento_orders_number_prefix_container">
                    <td class="grid">

                        <input type="hidden" id="sample_magento_order_id" value="<?php echo Mage::helper('M2ePro/Magento')->getNextMagentoOrderId(); ?>" />
                        <input type="hidden" id="sample_amazon_order_id" value="141-4423723-6495633" />

                        <table class="magento_orders_number_prefixes">
                            <thead>
                                <tr class="headings">
                                    <th><span><?php echo Mage::helper('M2ePro')->__('General'); ?></span></th>
                                    <th><span><?php echo Mage::helper('M2ePro')->__('FBA'); ?></span></th>
                                    <th><span><?php echo Mage::helper('M2ePro')->__('Prime'); ?></span></th>
                                    <th><span><?php echo Mage::helper('M2ePro')->__('B2B'); ?></span></th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>
                                        <input id="magento_orders_number_prefix_prefix" maxlength="5" name="magento_orders_settings[number][prefix][prefix]" value="<?php echo $this->escapeHtml(!empty($formData['magento_orders_settings']['number']['prefix']['prefix']) ? $formData['magento_orders_settings']['number']['prefix']['prefix'] : ''); ?>" type="text" class="input-text" />
                                        <p class="note note-no-tool-tip">
                                            <?php echo Mage::helper('M2ePro')->__('e.g.'); ?> <strong><span id="order_number_example_container_regular"></span></strong>
                                        </p>
                                    </td>
                                    <td>
                                        <input id="magento_orders_number_prefix_afn" maxlength="5" name="magento_orders_settings[number][prefix][afn-prefix]" value="<?php echo $this->escapeHtml(!empty($formData['magento_orders_settings']['number']['prefix']['afn-prefix']) ? $formData['magento_orders_settings']['number']['prefix']['afn-prefix'] : ''); ?>" type="text" class="input-text" />
                                        <p class="note note-no-tool-tip">
                                            <?php echo Mage::helper('M2ePro')->__('e.g.'); ?> <strong><span id="order_number_example_container_afn"></span></strong>
                                        </p>
                                    </td>
                                    <td>
                                        <input id="magento_orders_number_prefix_prime" maxlength="5" name="magento_orders_settings[number][prefix][prime-prefix]" value="<?php echo $this->escapeHtml(!empty($formData['magento_orders_settings']['number']['prefix']['prime-prefix']) ? $formData['magento_orders_settings']['number']['prefix']['prime-prefix'] : ''); ?>" type="text" class="input-text" />
                                        <p class="note note-no-tool-tip">
                                            <?php echo Mage::helper('M2ePro')->__('e.g.'); ?> <strong><span id="order_number_example_container_prime"></span></strong>
                                        </p>
                                    </td>
                                    <td>
                                        <input id="magento_orders_number_prefix_b2b" maxlength="5" name="magento_orders_settings[number][prefix][b2b-prefix]" value="<?php echo $this->escapeHtml(!empty($formData['magento_orders_settings']['number']['prefix']['b2b-prefix']) ? $formData['magento_orders_settings']['number']['prefix']['b2b-prefix'] : ''); ?>" type="text" class="input-text" />
                                        <p class="note note-no-tool-tip">
                                            <?php echo Mage::helper('M2ePro')->__('e.g.'); ?> <strong><span id="order_number_example_container_b2b"></span></strong>
                                        </p>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>

            </table>

            <table class="form-list" cellspacing="0" cellpadding="0">

                <tr>
                    <td class="label">
                        <label for="magento_orders_number_apply_to_amazon"><?php echo Mage::helper('M2ePro')->__('Use as Your Seller Order ID'); ?>: </label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="magento_orders_number_apply_to_amazon" name="magento_orders_settings[number][apply_to_amazon]" class="M2ePro-required-when-visible">
                            <option value="0" <?php if ($formData['magento_orders_settings']['number']['apply_to_amazon'] == 0) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1" <?php if ($formData['magento_orders_settings']['number']['apply_to_amazon'] == 1) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Set \'Yes\' to use Magento Order number as Your Seller Order ID in Amazon Order details.'); ?></span>
                        </p>
                    </td>
                </tr>

            </table>

        </div>
    </div>

</div>

<div class="entry-edit" id="magento_block_amazon_accounts_magento_orders_rules" <?php if (($formData['magento_orders_settings']['listing']['mode'] == 0 && $formData['magento_orders_settings']['listing_other']['mode'] == 0)) echo 'style="display: none;"'; ?>>

    <div class="entry-edit-head">
        <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('M2ePro')->__('Quantity Reservation'); ?></h4>
    </div>

    <div class="fieldset">
        <div class="hor-scroll">
            <div id="block_notice_amazon_accounts_magento_orders_rules" class="block_notices_module" title="<?php echo Mage::helper('M2ePro')->__('QTY Reservation'); ?>">
                <?php echo Mage::helper('M2ePro')->__('Use the Reserve Quantity Option to prevent the Item being sold, before Magento Order created (as the Product Stock QTY only reduces after Magento Order Creation). It removes Items from Magento Stock at once Amazon Order comes from Amazon.
                Reserve QTY will be used when Magento Order is created or released when the term of QTY reservation has expired.
                '); ?>
            </div>

            <table class="form-list" cellspacing="0" cellpadding="0">

                <tr id="magento_orders_qty_reservation_days_container">
                    <td class="label">
                        <label for="magento_orders_qty_reservation_days"><?php echo Mage::helper('M2ePro')->__('Reserve Quantity') ?>:</label>
                    </td>
                    <td class="value">
                        <select name="magento_orders_settings[qty_reservation][days]" id="magento_orders_qty_reservation_days">
                            <?php for ($day = 1; $day <= 14; $day++): ?>
                                <option value="<?php echo (int)$day ?>" <?php if ($formData['magento_orders_settings']['qty_reservation']['days'] == $day): ?>selected="selected"<?php endif; ?>>
                                    <?php if ($day == 1): ?>
                                        <?php echo Mage::helper('M2ePro')->__('For %number% day', $day) ?>
                                    <?php else: ?>
                                        <?php echo Mage::helper('M2ePro')->__('For %amount% days', $day) ?>
                                    <?php endif; ?>
                                </option>
                            <?php endfor; ?>
                        </select>
                            <p class="note">
                                <?php echo Mage::helper('M2ePro')->__('For how many days reserve Quantity has to be kept while Magento Order is not created.') ?>
                        </p>
                    </td>
                </tr>

            </table>

        </div>
    </div>

</div>

<div class="entry-edit" id="magento_block_amazon_accounts_magento_orders_refund_and_cancellation" <?php if (($formData['magento_orders_settings']['listing']['mode'] == 0 && $formData['magento_orders_settings']['listing_other']['mode'] == 0)) echo 'style="display: none;"'; ?>>

    <div class="entry-edit-head">
        <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('M2ePro')->__('Refund & Cancellation'); ?></h4>
    </div>

    <div class="fieldset">
        <div class="hor-scroll">
            <div id="block_notice_amazon_accounts_magento_orders_refund" class="block_notices_module" title="<?php echo Mage::helper('M2ePro')->__('Refund & Cancellation'); ?>">
                <?php echo Mage::helper('M2ePro')->__('
                Enable an option Cancellation & Refund if Credit Memo is Created to run automatic Cancellation of Amazon Orders or automatic Refund of Items associated to Amazon Orders at the moment of Credit Memos creation in Magento Orders that were created by M2E Pro. <br/><br/>

                In case Amazon Order has Status Unshipped and you created a Credit Memo for associated Magento Order which include all bought Items, Amazon Order Cancellation will be run automatically. <br/><br/>

                Automatic Refund of bought Items associated to Amazon Order is available in case Amazon Order has Status Shipped. Refund action will be run only for those Items for which Credit Memos were created.'); ?>
            </div>

            <table class="form-list" cellspacing="0" cellpadding="0">

                <tr id="magento_orders_refund_container">
                    <td class="label">
                        <label for="magento_orders_refund"><?php echo Mage::helper('M2ePro')->__('Cancel or Refund if Credit Memo is Created') ?>:</label>
                    </td>
                    <td class="value">
                        <select name="magento_orders_settings[refund_and_cancellation][refund_mode]" id="magento_orders_refund">
                            <option value="0" <?php if (!$formData['magento_orders_settings']['refund_and_cancellation']['refund_mode']): ?>selected="selected"<?php endif; ?>><?php echo Mage::helper('M2ePro')->__('No') ?></option>
                            <option value="1" <?php if ($formData['magento_orders_settings']['refund_and_cancellation']['refund_mode']): ?>selected="selected"<?php endif; ?>><?php echo Mage::helper('M2ePro')->__('Yes') ?></option>
                        </select>
                    </td>
                </tr>

            </table>

        </div>
    </div>

</div>

<div class="entry-edit" id="magento_block_amazon_accounts_magento_orders_customer" <?php if(($formData['magento_orders_settings']['listing']['mode'] == 0 && $formData['magento_orders_settings']['listing_other']['mode'] == 0)) echo 'style="display: none;"'; ?>>

    <div class="entry-edit-head">
        <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('M2ePro')->__('Customer Settings'); ?></h4>
    </div>

    <div class="fieldset">
        <div class="hor-scroll">

            <table class="form-list" cellspacing="0" cellpadding="0">

                <tr>
                    <td class="label">
                        <label for="magento_orders_customer_mode"><?php echo Mage::helper('M2ePro')->__('Customer'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="magento_orders_customer_mode" name="magento_orders_settings[customer][mode]" class="M2ePro-required-when-visible">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_CUSTOMER_MODE_GUEST; ?>" <?php if ($formData['magento_orders_settings']['customer']['mode'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_CUSTOMER_MODE_GUEST) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Guest Account'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_CUSTOMER_MODE_PREDEFINED; ?>" <?php if ($formData['magento_orders_settings']['customer']['mode'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_CUSTOMER_MODE_PREDEFINED) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Predefined Customer'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_CUSTOMER_MODE_NEW; ?>" <?php if ($formData['magento_orders_settings']['customer']['mode'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_CUSTOMER_MODE_NEW) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Create New'); ?></option>
                        </select>
                        <p class="note note-no-tool-tip">
                            <span><?php echo Mage::helper('M2ePro')->__('Customer for which Magento Orders will be created.'); ?></span>
                        </p>
                    </td>
                    <td class="value" style="display: none">
                        <p class="note">
                            <span>
                                <?php echo Mage::helper('M2ePro')->__('There are several ways to specify a Customer for which Magento Orders will be created: <br/><br/>
                                    <b>Guest Account</b> - the System does not require a Customer Account to be created. Default Guest Account will be defined as a Customer. <br/>
                                    <b>Note:</b> The Guest Checkout Option must be enabled in Magento. (<i>Yes</i> must be chosen in the Allow Guest Checkout Option in Magento > System > Configuration > Sales > Checkout Tab). <br/>
                                    <b>Predefined Customer</b> - the System uses one predefined Customer for all Amazon Orders related to this Account. You will be required
                                    to provide an ID of the existing Customer, which you can find in Magento > Customers > Manage Customers Table. <br/>
                                    <b>Create New</b> - a new Customer will be created in Magento, using Amazon Customer data of Amazon Order. <br/>
                                    <b>Note:</b> A unique Customer Identifier is his e-mail address. If the one already exists among Magento Customers e-mails,
                                    the System uses this Customer as owner of Order and links Order to him. A new Customer will not be created. <br/>
                                '); ?>
                            </span>
                        </p>
                    </td>
                </tr>

                <tr id="magento_orders_customer_id_container" <?php if($formData['magento_orders_settings']['customer']['mode'] != Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_CUSTOMER_MODE_PREDEFINED) echo 'style="display: none;"'; ?>>
                    <td class="label">
                        <label for="magento_orders_customer_id"><?php echo Mage::helper('M2ePro')->__('Customer ID'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value" style="width: auto;">
                        <input id="magento_orders_customer_id" name="magento_orders_settings[customer][id]" value="<?php echo $this->escapeHtml($formData['magento_orders_settings']['customer']['id']); ?>" type="text" class="M2ePro-required-when-visible validate-digits M2ePro-account-customer-id input-text" />
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Enter Magento Customer ID.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="magento_orders_customer_new_website_id_container" <?php if($formData['magento_orders_settings']['customer']['mode'] != Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_CUSTOMER_MODE_NEW) echo 'style="display: none;"'; ?>>
                    <td class="label">
                        <label for="magento_orders_customer_new_website_id"><?php echo Mage::helper('M2ePro')->__('Associate to Website'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="magento_orders_customer_new_website_id" name="magento_orders_settings[customer][website_id]" class="M2ePro-required-when-visible">
                            <option value="" <?php if ($formData['magento_orders_settings']['customer']['website_id'] == '') echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('-- Please Select --'); ?></option>
                            <?php foreach($this->websites as $website) { ?>
                                <option value="<?php echo $website['website_id']; ?>" <?php if ($formData['magento_orders_settings']['customer']['website_id'] == $website['website_id']) echo ' selected="selected"'; ?>><?php echo $website['name']; ?></option>
                            <?php } ?>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Website in which a Customer Account will be created.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="magento_orders_customer_new_group_id_container" <?php if($formData['magento_orders_settings']['customer']['mode'] != Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_CUSTOMER_MODE_NEW) echo 'style="display: none;"'; ?>>
                    <td class="label">
                        <label for="magento_orders_customer_new_group_id"><?php echo Mage::helper('M2ePro')->__('Customer Group'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="magento_orders_customer_new_group_id" name="magento_orders_settings[customer][group_id]" class="M2ePro-required-when-visible">
                            <option value="" <?php if ($formData['magento_orders_settings']['customer']['group_id'] == '') echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('-- Please Select --'); ?></option>
                            <?php foreach($this->groups as $group) { ?>
                                <option value="<?php echo $group['customer_group_id']; ?>" <?php if ($formData['magento_orders_settings']['customer']['group_id'] == $group['customer_group_id']) echo ' selected="selected"'; ?>><?php echo $group['customer_group_code']; ?></option>
                            <?php } ?>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Customer Group to which a Customer will be assigned.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="magento_orders_customer_new_notifications_container" <?php if($formData['magento_orders_settings']['customer']['mode'] != Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_CUSTOMER_MODE_NEW) echo 'style="display: none;"'; ?>>
                    <td class="label">
                        <label for="magento_orders_customer_new_notifications"><?php echo Mage::helper('M2ePro')->__('Send Emails When The Following Is Created'); ?>: </label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="magento_orders_customer_new_notifications" name="magento_orders_settings[customer][notifications][]" multiple="multiple">
<!--                            <option value="customer_created" --><?php //if ($formData['magento_orders_settings']['customer']['notifications']['customer_created']) echo ' selected="selected"'; ?><!-->--><?php //echo Mage::helper('M2ePro')->__('Customer Account'); ?><!--</option>-->
                            <option value="order_created" <?php if ($formData['magento_orders_settings']['customer']['notifications']['order_created']) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Magento Order'); ?></option>
                            <option value="invoice_created" <?php if ($formData['magento_orders_settings']['customer']['notifications']['invoice_created']) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Invoice'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Necessary emails will be sent according to Magento Settings in Magento > System > Configuration > Sales Emails.<br/>Hold Ctrl Button, to choose more, than one Option.'); ?></span>
                        </p>
                    </td>
                </tr>

            </table>

            <table class="form-list" cellspacing="0" cellpadding="0">

                <tr>
                    <td class="label">
                        <label for="magento_orders_customer_billing_address_mode"><?php echo Mage::helper('M2ePro')->__('Billing Address Usage'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="magento_orders_customer_billing_address_mode" name="magento_orders_settings[customer][billing_address_mode]" class="M2ePro-required-when-visible">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::USE_SHIPPING_ADDRESS_AS_BILLING_ALWAYS; ?>" <?php if ($formData['magento_orders_settings']['customer']['billing_address_mode'] == Ess_M2ePro_Model_Amazon_Account::USE_SHIPPING_ADDRESS_AS_BILLING_ALWAYS) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Always'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::USE_SHIPPING_ADDRESS_AS_BILLING_IF_SAME_CUSTOMER_AND_RECIPIENT; ?>" <?php if ($formData['magento_orders_settings']['customer']['billing_address_mode'] == Ess_M2ePro_Model_Amazon_Account::USE_SHIPPING_ADDRESS_AS_BILLING_IF_SAME_CUSTOMER_AND_RECIPIENT) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Buyer & Recipient have the same name'); ?></option>
                        </select>
                        <p class="note note-no-tool-tip">
                            <span><?php echo Mage::helper('M2ePro')->__('When to use shipping address as billing.'); ?></span>
                        </p>
                    </td>
                    <td class="value"  style="display: none">
                        <p class="note">
                            <span>
                                <?php echo Mage::helper('M2ePro')->__('Choose if you want to use your customer’s 
                                    shipping address as the billing one regularly or only if the buyer and recipient 
                                    have the same names.'); ?>
                            </span>
                        </p>
                    </td>
                </tr>

            </table>

        </div>
    </div>

</div>

<div class="entry-edit" id="magento_block_amazon_accounts_magento_orders_tax" <?php if (($formData['magento_orders_settings']['listing']['mode'] == 0 && $formData['magento_orders_settings']['listing_other']['mode'] == 0)) echo 'style="display: none;"'; ?>>

    <div class="entry-edit-head">
        <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('M2ePro')->__('Order Tax Settings'); ?></h4>
    </div>

    <div class="fieldset">
        <div class="hor-scroll">
            <table class="form-list" cellspacing="0" cellpadding="0">

                <tr>
                    <td class="label">
                        <label for="magento_orders_tax_mode"><?php echo Mage::helper('M2ePro')->__('Tax Source'); ?>:</label>
                    </td>

                    <td class="value" style="width: auto;">
                        <select id="magento_orders_tax_mode" name="magento_orders_settings[tax][mode]" class="M2ePro-required-when-visible">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_TAX_MODE_NONE; ?>"<?php if ($formData['magento_orders_settings']['tax']['mode'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_TAX_MODE_NONE) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('None'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_TAX_MODE_CHANNEL; ?>"<?php if ($formData['magento_orders_settings']['tax']['mode'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_TAX_MODE_CHANNEL) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Amazon'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_TAX_MODE_MAGENTO; ?>"<?php if ($formData['magento_orders_settings']['tax']['mode'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_TAX_MODE_MAGENTO) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Magento'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_TAX_MODE_MIXED; ?>"<?php if ($formData['magento_orders_settings']['tax']['mode'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_TAX_MODE_MIXED) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Amazon & Magento'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__(
                                    'Choose where the tax settings for your Magento Order will be taken from. See
                                    <a href="%url%" target="_blank">this article</a> for more details.',
                                    Mage::helper('M2ePro/Module_Support')->getDocumentationUrl(
                                        null,
                                        null,
                                        'tax-calculation-settings#c6cc7613a7894cfcaf68e2e4d7e35125'
                                    )
                                ); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="tr_magento_orders_tax_excluded_states">
                    <td class="label">
                        <label for="magento_orders_tax_amazon_collects"><?php echo Mage::helper('M2ePro')->__('Exclude tax collected by Amazon'); ?>:</label>
                    </td>

                    <td class="value" style="width: auto;">
                        <select id="magento_orders_tax_amazon_collects" name="magento_orders_settings[tax][amazon_collects]" class="M2ePro-required-when-visible">
                            <option value="1" <?php if ($formData['magento_orders_settings']['tax']['amazon_collects'] == 1) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                            <option value="0" <?php if ($formData['magento_orders_settings']['tax']['amazon_collects'] == 0): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                        </select>
                    </td>

                    <td class="value" style="display: none">
                        <p class="note">
                            <span>
                                <?php echo Mage::helper('M2ePro')->__(
                                    "Tax won't be included in orders shipped to the selected states."
                                ); ?>
                            </span>
                        </p>
                    </td>

                    <td class="value" style="width: auto;" id="td_show_excluded_states_button">
                        <button id="show_excluded_states_button" type="button" onclick="AmazonAccountObj.openExcludedStatesPopup()"><?php echo Mage::helper('M2ePro')->__('Select states'); ?></button>
                    </td>

                    <input type="hidden" id="magento_orders_tax_excluded_states" name="magento_orders_settings[tax][excluded_states]" value="<?php echo $formData['magento_orders_settings']['tax']['excluded_states']; ?>" />
                </tr>

                <tr id="tr_magento_orders_tax_collect_for_uk">
                    <td class="label">
                        <label for="magento_orders_tax_mode"><?php echo Mage::helper('M2ePro')->__('Exclude UK VAT collected by Amazon');
                        ?>:</label>
                    </td>

                    <td class="value" style="width: auto;">
                        <select id="magento_orders_tax_amazon_collects_for_uk_shipment"
                                name="magento_orders_settings[tax][amazon_collect_for_uk]" class="M2ePro-required-when-visible">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::SKIP_TAX_FOR_UK_SHIPMENT_NONE; ?>"<?php if ($formData['magento_orders_settings']['tax']['amazon_collect_for_uk'] == Ess_M2ePro_Model_Amazon_Account::SKIP_TAX_FOR_UK_SHIPMENT_NONE) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('None'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::SKIP_TAX_FOR_UK_SHIPMENT;
                            ?>"<?php if ($formData['magento_orders_settings']['tax']['amazon_collect_for_uk'] ==
                                Ess_M2ePro_Model_Amazon_Account::SKIP_TAX_FOR_UK_SHIPMENT) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('All orders with UK shipments'); ?></option>
                            <option value="<?php echo
                            Ess_M2ePro_Model_Amazon_Account::SKIP_TAX_FOR_UK_SHIPMENT_WITH_CERTAIN_PRICE; ?>"<?php if
                            ($formData['magento_orders_settings']['tax']['amazon_collect_for_uk'] ==
                                Ess_M2ePro_Model_Amazon_Account::SKIP_TAX_FOR_UK_SHIPMENT_WITH_CERTAIN_PRICE) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Orders under 135GBP price'); ?></option>
                        </select>
                    </td>

                    <td class="value" style="display: none">
                        <p class="note">
                            <span>
                                <?php echo Mage::helper('M2ePro')->__(
                                    "VAT won't be included in orders with UK shipment. Find more info "
                                    . '<a href="%url%" target="_blank">here</a>.',
                                    Mage::helper('M2ePro/Module_Support')->getDocumentationUrl(
                                        null,
                                        null,
                                        'tax-calculation-settings#efafbaa613044c90b3bdb1cdf3209406'
                                    )
                                ); ?>
                            </span>
                        </p>
                    </td>

                </tr>

                <tr id="tr_magento_orders_tax_collect_for_eea">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Exclude EEA VAT collected by Amazon');
                            ?>:</label>
                    </td>

                    <td class="value" style="width: auto;">
                        <select id="magento_orders_tax_amazon_collects_for_eea_shipment"
                                name="magento_orders_settings[tax][amazon_collect_for_eea]" class="M2ePro-required-when-visible">
                            <option value="0"<?php if ($formData['magento_orders_settings']['tax']['amazon_collect_for_eea'] == 0) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1"<?php if ($formData['magento_orders_settings']['tax']['amazon_collect_for_eea'] == 1) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                    </td>

                    <td class="value" style="display: none">
                        <p class="note">
                            <span>
                                <?php echo Mage::helper('M2ePro')->__(
                                    "VAT won't be included in orders shipped to the selected countries."
                                ); ?>
                            </span>
                        </p>
                    </td>

                    <td class="value" style="width: auto;" id="td_show_excluded_countries_button">
                        <button id="show_excluded_countries_button" type="button" onclick="AmazonAccountObj.openExcludedCountriesPopup()"><?php echo Mage::helper('M2ePro')->__('Select countries'); ?></button>
                    </td>

                    <input type="hidden" id="magento_orders_tax_excluded_countries" name="magento_orders_settings[tax][excluded_countries]" value="<?php echo $formData['magento_orders_settings']['tax']['excluded_countries']; ?>" />
                </tr>
                <?php
                $style = 'display: none';
                if (isset($account) && $account->getId() && $account->getChildObject()->getMarketplaceId() == Ess_M2ePro_Helper_Component_Amazon::MARKETPLACE_TR) {
                    $style = '';
                }
                ?>
                <tr id="tr_magento_orders_tax_import_tax_id_in_magento_order" style="<?php echo $style ?>">
                    <td class="label">
                        <label for="magento_orders_tax_import_tax_id_in_magento_order"><?php echo Mage::helper('M2ePro')->__('Import Tax Registration Number to Magento Order');
                            ?>:</label>
                    </td>

                    <td class="value" style="width: auto;">
                        <?php if (isset($account) && $account->getId() && $account->getChildObject()->getMarketplaceId() == Ess_M2ePro_Helper_Component_Amazon::MARKETPLACE_TR) {?>
                        <select id="magento_orders_tax_import_tax_id_in_magento_order" name="magento_orders_settings[tax][import_tax_id_in_magento_order]" class="M2ePro-required-when-visible">
                            <option value="0" <?php if ($formData['magento_orders_settings']['tax']['import_tax_id_in_magento_order'] == 0) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1" <?php if ($formData['magento_orders_settings']['tax']['import_tax_id_in_magento_order'] == 1) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                        <?php } else { ?>
                            <input type="hidden" id="magento_orders_tax_import_tax_id_in_magento_order" name="magento_orders_settings[tax][import_tax_id_in_magento_order]" value="0" />
                        <?php } ?>
                    </td>

                    <td class="value" style="display: none">
                        <p class="note">
                            <span>
                                <?php echo Mage::helper('M2ePro')->__(
                                    'Once enabled, find the Tax Registration Number displayed as VAT in the Shipping Address of your Magento Order.'
                                ); ?>
                            </span>
                        </p>
                    </td>
                </tr>

            </table>

        </div>
    </div>

</div>

<?php $statusList = $this->getMagentoOrderStatusList(); ?>

<div class="entry-edit" id="magento_block_amazon_accounts_magento_orders_status_mapping" <?php if (($formData['magento_orders_settings']['listing']['mode'] == 0 && $formData['magento_orders_settings']['listing_other']['mode'] == 0)) echo 'style="display: none;"'; ?>>

    <div class="entry-edit-head">
        <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('M2ePro')->__('Order Status Mapping'); ?></h4>
    </div>

    <div class="fieldset">
        <div class="hor-scroll">

            <div id="block_notice_amazon_accounts_orders_status" class="block_notices_module" title="<?php echo Mage::helper('M2ePro')->__('Order Status Mapping'); ?>">
                <?php echo Mage::helper('M2ePro')->__('Set the correspondence between Amazon and Magento order statuses. The status of your Magento order will be updated based on these settings.'); ?>
            </div>
            <table class="form-list" cellspacing="0" cellpadding="0">

                <tr>
                    <td class="label">
                        <label for="magento_orders_status_mapping_mode"><?php echo Mage::helper('M2ePro')->__('Status Mapping'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="magento_orders_status_mapping_mode" name="magento_orders_settings[status_mapping][mode]" class="M2ePro-required-when-visible">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_STATUS_MAPPING_MODE_DEFAULT; ?>" <?php if ($formData['magento_orders_settings']['status_mapping']['mode'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_STATUS_MAPPING_MODE_DEFAULT) echo "selected='selected'"; ?>><?php echo Mage::helper('M2ePro')->__('Default Order Statuses'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_STATUS_MAPPING_MODE_CUSTOM; ?>" <?php if ($formData['magento_orders_settings']['status_mapping']['mode'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_STATUS_MAPPING_MODE_CUSTOM) echo "selected='selected'"; ?>><?php echo Mage::helper('M2ePro')->__('Custom Order Statuses'); ?></option>
                        </select>
                    </td>
                </tr>

                <?php $isDisabledStatusStyle = ($formData['magento_orders_settings']['status_mapping']['mode'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_STATUS_MAPPING_MODE_DEFAULT) ? "disabled='disabled'" : ''; ?>
                <?php
                    if ($formData['magento_orders_settings']['status_mapping']['mode'] == Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_STATUS_MAPPING_MODE_DEFAULT) {
                        $formData['magento_orders_settings']['status_mapping']['processing'] = Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_STATUS_MAPPING_PROCESSING;
                        $formData['magento_orders_settings']['status_mapping']['shipped'] = Ess_M2ePro_Model_Amazon_Account::MAGENTO_ORDERS_STATUS_MAPPING_SHIPPED;
                    }
                ?>

                <tr id="magento_orders_status_mapping_processing_container">
                    <td class="label">
                        <label for="magento_orders_status_mapping_processing"><?php echo Mage::helper('M2ePro')->__('Order Status is Unshipped / Partially Shipped'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="magento_orders_status_mapping_processing" name="magento_orders_settings[status_mapping][processing]" class="M2ePro-required-when-visible" <?php echo $isDisabledStatusStyle; ?>>
                            <?php foreach ($statusList as $statusKey => $statusValue) { ?>
                                <option value="<?php echo $statusKey; ?>" <?php if ($formData['magento_orders_settings']['status_mapping']['processing'] == $statusKey) echo 'selected="selected"'; ?>><?php echo $statusValue; ?></option>
                            <?php } ?>
                        </select>
                    </td>
                </tr>

                <tr id="magento_orders_status_mapping_shipped_container" <?php echo $isDisabledStatusStyle; ?>>
                    <td class="label">
                        <label for="magento_orders_status_mapping_shipped"><?php echo Mage::helper('M2ePro')->__('Order Status is Shipped'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="magento_orders_status_mapping_shipped" name="magento_orders_settings[status_mapping][shipped]" class="M2ePro-required-when-visible" <?php echo $isDisabledStatusStyle; ?>>
                            <?php foreach ($statusList as $statusKey => $statusValue) { ?>
                                <option value="<?php echo $statusKey; ?>" <?php if ($formData['magento_orders_settings']['status_mapping']['shipped'] == $statusKey) echo 'selected="selected"'; ?>><?php echo $statusValue; ?></option>
                            <?php } ?>
                        </select>
                    </td>
                </tr>

            </table>

        </div>
    </div>

</div>
