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

// @codingStandardsIgnoreFile

/** @var $this Ess_M2ePro_Block_Adminhtml_Amazon_Template_Description_Edit_Tabs_Definition */

?>

<div id="block_notice_amazon_template_description_definition" class="block_notices_module" title="<?php echo Mage::helper('M2ePro')->__('Definition'); ?>">
    <?php echo Mage::helper('M2ePro')->__(
        'On this Tab you can specify Settings for common Product Information. <br/>
        It is available to choose just those Magento Attributes that are used for all Attribute Sets. <br/><br/>

        <b>Note:</b> Title value is required for creation of all Description Policies because of technical reasons.<br/><br/>

        More detailed information about ability to work with this Page you can find <a href="%url%" target="_blank">here</a>.',
        Mage::helper('M2ePro/Module_Support')->getDocumentationUrl(null, null, 'definition')
    ); ?>
</div>

<?php

/** @var Ess_M2ePro_Block_Adminhtml_Amazon_Template_Description_Edit_Tabs_Definition $this */

$isEdit = !!$this->getRequest()->getParam('id');
$formData = array('definition' => array());
$isEdit && $formData = array(
    'definition' => Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getChildObject()->getDefinitionTemplate()->getData()
);

$default = array(
    'definition' => Mage::getModel('M2ePro/Amazon_Template_Description_Definition_Builder')->getDefaultData()
);

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

!empty($formData['definition']['target_audience']) && $formData['definition']['target_audience'] = json_decode($formData['definition']['target_audience'], true);
!empty($formData['definition']['bullet_points'])   && $formData['definition']['bullet_points'] = json_decode($formData['definition']['bullet_points'], true);
!empty($formData['definition']['search_terms'])    && $formData['definition']['search_terms'] = json_decode($formData['definition']['search_terms'], true);

$formData['definition']['package_weight_custom_value'] == 0  && $formData['definition']['package_weight_custom_value'] = '';
$formData['definition']['shipping_weight_custom_value'] == 0 && $formData['definition']['shipping_weight_custom_value'] = '';
$formData['definition']['item_dimensions_weight_custom_value'] == 0 && $formData['definition']['item_dimensions_weight_custom_value'] = '';

/** @var Ess_M2ePro_Helper_Magento_Attribute $magentoAttributeHelper */
$magentoAttributeHelper = Mage::helper('M2ePro/Magento_Attribute');

$attributesByInputTypes = array(
    'text' => $magentoAttributeHelper->filterByInputTypes($this->getData('all_attributes'), array('text')),
    'text_select' => $magentoAttributeHelper->filterByInputTypes($this->getData('all_attributes'), array('text', 'select')),
    'text_select_multiselect' => $magentoAttributeHelper->filterByInputTypes($this->getData('all_attributes'), array('text', 'select', 'multiselect')),
    'text_weight' => $magentoAttributeHelper->filterByInputTypes($this->getData('all_attributes'), array('text', 'weight')),
    'text_images' => $magentoAttributeHelper->filterByInputTypes(
        $this->getData('all_attributes'),
        array('text', 'image', 'media_image', 'gallery', 'multiline', 'textarea', 'select', 'multiselect')
    ),
    'text_price' => $magentoAttributeHelper->filterByInputTypes($this->getData('all_attributes'), array('text', 'price')),
);
?>

<script type="text/javascript">

    M2ePro.php.setConstants(<?php echo Mage::helper('M2ePro')->getClassConstantAsJson(
        'Ess_M2ePro_Model_Amazon_Template_Description_Definition'); ?>,'Ess_M2ePro_Model_Amazon_Template_Description_Definition'
    );

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

        AmazonTemplateDescriptionDefinitionObj = new AmazonTemplateDescriptionDefinition();

        AmazonTemplateDescriptionDefinitionObj.setConstants(
            '<?php echo Mage::helper('M2ePro')->getClassConstantAsJson('Ess_M2ePro_Model_Amazon_Template_Description_Definition'); ?>'
        );

        M2ePro.formData.definition = <?php echo json_encode($formData['definition']); ?>;

        $('title_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.title_mode_change)
            .simulate('change');

        $('brand_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.brand_mode_change)
            .simulate('change');

        $('manufacturer_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.manufacturer_mode_change)
            .simulate('change');

        $('manufacturer_part_number_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.manufacturer_part_number_mode_change)
            .simulate('change');

        // ---

        $('item_package_quantity_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.onChangeItemPackageQuantityMode)
            .simulate('change');

        $('number_of_items_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.onChangeNumberOfItemsMode)
            .simulate('change');

        // ---

        var msrpRrpMode = $('msrp_rrp_mode');
        if (msrpRrpMode) {
            msrpRrpMode
                .observe('change', AmazonTemplateDescriptionDefinitionObj.onChangeMsrpRrpMode)
                .simulate('change');
        }

        // ---

        $('item_dimensions_volume_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.item_dimensions_volume_mode_change)
            .simulate('change');

        $('item_dimensions_volume_unit_of_measure_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.item_dimensions_volume_unit_of_measure_mode_change)
            .simulate('change');

        $('item_dimensions_weight_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.item_dimensions_weight_mode_change)
            .simulate('change');

        $('item_dimensions_weight_unit_of_measure_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.item_dimensions_weight_unit_of_measure_mode_change)
            .simulate('change');

        // ---

        $('package_dimensions_volume_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.package_dimensions_volume_mode_change)
            .simulate('change');

        $('package_dimensions_volume_unit_of_measure_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.package_dimensions_volume_unit_of_measure_mode_change)
            .simulate('change');

        // ---

        $('package_weight_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.package_weight_mode_change)
            .simulate('change');

        $('package_weight_unit_of_measure_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.package_weight_unit_of_measure_mode_change)
            .simulate('change');

        $('shipping_weight_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.shipping_weight_mode_change)
            .simulate('change');

        $('shipping_weight_unit_of_measure_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.shipping_weight_unit_of_measure_mode_change)
            .simulate('change');

        // ---

        $('target_audience_mode')
            .observe('change', function () {
                AmazonTemplateDescriptionDefinitionObj.multi_element_mode_change.call(this,'target_audience',4);
            })
            .simulate('change');

        $('bullet_points_mode')
            .observe('change', function () {
                AmazonTemplateDescriptionDefinitionObj.multi_element_mode_change.call(this,'bullet_points',5);
            })
            .simulate('change');

        $('search_terms_mode')
            .observe('change', function () {
                AmazonTemplateDescriptionDefinitionObj.multi_element_mode_change.call(this,'search_terms',5);
            })
            .simulate('change');

        $('description_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.description_mode_change)
            .simulate('change');

        $('image_main_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.image_main_mode_change)
            .simulate('change');

        $('image_variation_difference_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.image_variation_difference_mode_change)
            .simulate('change');

        $('gallery_images_mode')
            .observe('change', AmazonTemplateDescriptionDefinitionObj.gallery_images_mode_change)
            .simulate('change');

        AmazonTemplateDescriptionObj.onChangeNewAsinAccepted.bind($('new_asin_accepted'))();
    });

</script>

<style type="text/css">

    .input-text-small {
        width: 120px !important;
    }
    .textarea {
        width: 98% !important;
        height: 250px !important;
    }
    select.select-main {
        width: 356px !important;
    }
    .select-wrapper {
        margin-left: 15px;
    }
    a.action-disabled {
        color: gray !important;
        text-decoration: none !important;
    }
    a.action-disabled:hover {
        color: gray !important;
        text-decoration: none !important;
    }
    td.value {
        width: auto !important;
    }
</style>

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

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

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

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

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Title'); ?>: </label>
                    </td>
                    <td class="value">
                        <select id="title_mode" name="definition[title_mode]" class="select required-entry">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::TITLE_MODE_PRODUCT; ?>" <?php if ($formData['definition']['title_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::TITLE_MODE_PRODUCT): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Product Name'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::TITLE_MODE_CUSTOM; ?>" <?php if ($formData['definition']['title_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::TITLE_MODE_CUSTOM): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Custom Value'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Item\'s Title that buyers will see on Amazon Listing.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="custom_title_tr" style="display: none;">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Title Value'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <input id="title_template" name="definition[title_template]" value="<?php echo Mage::helper('M2ePro')->escapeHtml($formData['definition']['title_template']); ?>" type="text" class="input-text M2ePro-required-when-visible" />
                    </td>
                    <td class="value">
                        <span id="select_attributes_for_title_span" class="select-wrapper">
                             <select id="select_attributes_for_title" class="M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text,select" apply_to_all_attribute_sets="0" style="width: 150px;">
                                 <?php foreach($attributesByInputTypes['text_select'] as $attribute) : ?>
                                     <option value="<?php echo $attribute['code']; ?>">
                                         <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                     </option>
                                 <?php endforeach; ?>
                             </select>
                        </span>
                        <?php echo $this->getChildHtml('select_attributes_for_title_button'); ?>
                    </td>
                </tr>

                <tr>
                    <td colspan="2" style="padding: 10px 0">
                        <hr style="border: 1px solid silver; border-bottom: none;">
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Brand'); ?>:</label>
                    </td>
                    <td class="value">
                        <input type="hidden" id="brand_custom_attribute" name="definition[brand_custom_attribute]" value="<?php echo $formData['definition']['brand_custom_attribute']; ?>" />

                        <select id="brand_mode" name="definition[brand_mode]" class="select M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text,select">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::BRAND_MODE_NONE; ?>" <?php if ($formData['definition']['brand_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::BRAND_MODE_NONE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('None'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::BRAND_MODE_CUSTOM_VALUE; ?>" <?php if ($formData['definition']['brand_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::BRAND_MODE_CUSTOM_VALUE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Custom Value'); ?></option>

                            <optgroup class="M2ePro-custom-attribute-optgroup" label="Magento Attribute">
                                <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['brand_custom_attribute'], $attributesByInputTypes['text_select'], Ess_M2ePro_Model_Amazon_Template_Description_Definition::BRAND_MODE_CUSTOM_ATTRIBUTE); ?>
                                <?php foreach($attributesByInputTypes['text_select'] as $attribute) : ?>
                                    <option attribute_code="<?php echo $attribute['code']; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::BRAND_MODE_CUSTOM_ATTRIBUTE; ?>" <?php if ($attribute['code'] == $formData['definition']['brand_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                        <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                    </option>
                                <?php endforeach; ?>
                            </optgroup>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Required for creating new ASIN/ISBN.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="brand_custom_value_tr" style="display: none;">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Brand Value'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <input id="brand_custom_value" name="definition[brand_custom_value]" value="<?php echo Mage::helper('M2ePro')->escapeHtml($formData['definition']['brand_custom_value']); ?>" type="text" class="input-text M2ePro-required-when-visible" />
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Manufacturer'); ?>:</label>
                    </td>
                    <td class="value">
                        <input type="hidden" id="manufacturer_custom_attribute" name="definition[manufacturer_custom_attribute]" value="<?php echo $formData['definition']['manufacturer_custom_attribute']; ?>" />

                        <select id="manufacturer_mode" name="definition[manufacturer_mode]" class="select M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text,select">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::MANUFACTURER_MODE_NONE; ?>" <?php if ($formData['definition']['manufacturer_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::MANUFACTURER_MODE_NONE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('None'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::MANUFACTURER_MODE_CUSTOM_VALUE; ?>" <?php if ($formData['definition']['manufacturer_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::MANUFACTURER_MODE_CUSTOM_VALUE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Custom Value'); ?></option>

                            <optgroup class="M2ePro-custom-attribute-optgroup" label="Magento Attribute">
                                <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['manufacturer_custom_attribute'], $attributesByInputTypes['text_select'], Ess_M2ePro_Model_Amazon_Template_Description_Definition::MANUFACTURER_MODE_CUSTOM_ATTRIBUTE); ?>
                                <?php foreach($attributesByInputTypes['text_select'] as $attribute) : ?>
                                    <option attribute_code="<?php echo $attribute['code']; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::MANUFACTURER_MODE_CUSTOM_ATTRIBUTE; ?>" <?php if ($attribute['code'] == $formData['definition']['manufacturer_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                        <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                    </option>
                                <?php endforeach; ?>
                            </optgroup>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Required for creating new ASIN/ISBN.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="manufacturer_custom_value_tr" style="display: none;">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Manufacturer Value'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <input id="manufacturer_custom_value" name="definition[manufacturer_custom_value]" value="<?php echo Mage::helper('M2ePro')->escapeHtml($formData['definition']['manufacturer_custom_value']); ?>" type="text" class="input-text M2ePro-required-when-visible" />
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Manufacturer Part Number'); ?>:</label>
                    </td>
                    <td class="value">
                        <input type="hidden" id="manufacturer_part_number_custom_attribute" name="definition[manufacturer_part_number_custom_attribute]" value="<?php echo $formData['definition']['manufacturer_part_number_custom_attribute']; ?>" />

                        <select id="manufacturer_part_number_mode" name="definition[manufacturer_part_number_mode]" class="select M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::MANUFACTURER_PART_NUMBER_MODE_NONE; ?>" <?php if ($formData['definition']['manufacturer_part_number_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::MANUFACTURER_PART_NUMBER_MODE_NONE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('None'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::MANUFACTURER_PART_NUMBER_MODE_CUSTOM_VALUE; ?>" <?php if ($formData['definition']['manufacturer_part_number_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::MANUFACTURER_PART_NUMBER_MODE_CUSTOM_VALUE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Custom Value'); ?></option>

                            <optgroup class="M2ePro-custom-attribute-optgroup" label="Magento Attribute">
                                <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['manufacturer_part_number_custom_attribute'], $attributesByInputTypes['text'], Ess_M2ePro_Model_Amazon_Template_Description_Definition::MANUFACTURER_PART_NUMBER_MODE_CUSTOM_ATTRIBUTE); ?>
                                <?php foreach($attributesByInputTypes['text'] as $attribute) : ?>
                                    <option attribute_code="<?php echo $attribute['code']; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::MANUFACTURER_PART_NUMBER_MODE_CUSTOM_ATTRIBUTE; ?>" <?php if ($attribute['code'] == $formData['definition']['manufacturer_part_number_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                        <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                    </option>
                                <?php endforeach; ?>
                            </optgroup>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Manufacturer Part Number of the Product(s). Max. 40 characters.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="manufacturer_part_number_custom_value_tr" style="display: none;">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Manufacturer Part Number Value'); ?>:&nbsp<span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <input id="manufacturer_part_number_custom_value" name="definition[manufacturer_part_number_custom_value]" value="<?php echo Mage::helper('M2ePro')->escapeHtml($formData['definition']['manufacturer_part_number_custom_value']); ?>" type="text" class="input-text M2ePro-required-when-visible" />
                    </td>
                </tr>

                <tr>
                    <td colspan="2" style="padding: 10px 0">
                        <hr style="border: 1px solid silver; border-bottom: none;">
                    </td>
                </tr>

                <tr class="entry-edit" id="item_package_quantity_mode_tr">
                    <td class="label">
                        <label for="item_package_quantity_mode"><?php echo Mage::helper('M2ePro')->__('Package Quantity') ?>: </label>
                    </td>
                    <td class="value">
                        <input type="hidden" id="item_package_quantity_custom_attribute" name="definition[item_package_quantity_custom_attribute]" value="<?php echo $formData['definition']['item_package_quantity_custom_attribute']; ?>" />

                        <select name="definition[item_package_quantity_mode]" class="M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text,select" id="item_package_quantity_mode">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::ITEM_PACKAGE_QUANTITY_MODE_NONE; ?>" <?php if ($formData['definition']['item_package_quantity_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::ITEM_PACKAGE_QUANTITY_MODE_NONE) echo 'selected="selected"' ?>><?php echo Mage::helper('M2ePro')->__('None') ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::ITEM_PACKAGE_QUANTITY_MODE_CUSTOM_VALUE; ?>" <?php if ($formData['definition']['item_package_quantity_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::ITEM_PACKAGE_QUANTITY_MODE_CUSTOM_VALUE) echo 'selected="selected"' ?>><?php echo Mage::helper('M2ePro')->__('Custom Value') ?></option>

                            <optgroup class="M2ePro-custom-attribute-optgroup" label="Magento Attribute">
                                <?php if ($formData['definition']['item_package_quantity_custom_attribute'] != '' && !$magentoAttributeHelper->isExistInAttributesArray($formData['definition']['item_package_quantity_custom_attribute'], $attributesByInputTypes['text_select'])) : ?>
                                    <option attribute_code="<?php echo $formData['definition']['item_package_quantity_custom_attribute']; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::ITEM_PACKAGE_QUANTITY_MODE_CUSTOM_ATTRIBUTE ?>" selected="selected" >
                                        <?php echo Mage::helper('M2ePro')->escapeHtml($magentoAttributeHelper->getAttributeLabel($formData['definition']['item_package_quantity_custom_attribute'])); ?>
                                    </option>
                                <?php endif; ?>
                                <?php foreach($attributesByInputTypes['text_select'] as $attribute) : ?>
                                    <option attribute_code="<?php echo $attribute['code']; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::ITEM_PACKAGE_QUANTITY_MODE_CUSTOM_ATTRIBUTE ?>" <?php if ($attribute['code'] == $formData['definition']['item_package_quantity_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                        <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                    </option>
                                <?php endforeach; ?>
                            </optgroup>
                        </select>
                        <p class="note">
                            <?php echo Mage::helper('M2ePro')->__(
                                'The number of units included in the Item you are offering for sale, <br/>such that each unit is packaged for individual sale.'
                            ); ?>
                        </p>
                    </td>
                </tr>

                <tr class="entry-edit" id="item_package_quantity_custom_value_tr">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Package Quantity Value'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <input id="item_package_quantity_custom_value" name="definition[item_package_quantity_custom_value]" value="<?php echo Mage::helper('M2ePro')->escapeHtml($formData['definition']['item_package_quantity_custom_value']); ?>" type="text" class="input-text M2ePro-required-when-visible M2ePro-validate-greater-than" min_value="1" />
                    </td>
                </tr>

                <tr class="entry-edit" id="number_of_items_mode_tr">
                    <td class="label">
                        <label for="number_of_items_mode"><?php echo Mage::helper('M2ePro')->__('Number of Items') ?>: </label>
                    </td>
                    <td class="value">
                        <input type="hidden" id="number_of_items_custom_attribute" name="definition[number_of_items_custom_attribute]" value="<?php echo $formData['definition']['number_of_items_custom_attribute']; ?>" />

                        <select name="definition[number_of_items_mode]" id="number_of_items_mode" class="M2ePro-required-when-visible M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text,select" >
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::NUMBER_OF_ITEMS_MODE_NONE; ?>" <?php if ($formData['definition']['number_of_items_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::NUMBER_OF_ITEMS_MODE_NONE) echo 'selected="selected"' ?>><?php echo Mage::helper('M2ePro')->__('None') ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::NUMBER_OF_ITEMS_MODE_CUSTOM_VALUE; ?>" <?php if ($formData['definition']['number_of_items_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::NUMBER_OF_ITEMS_MODE_CUSTOM_VALUE) echo 'selected="selected"' ?>><?php echo Mage::helper('M2ePro')->__('Custom Value') ?></option>

                            <optgroup class="M2ePro-custom-attribute-optgroup" label="Magento Attribute">
                                <?php if ($formData['definition']['number_of_items_custom_attribute'] != '' && !$magentoAttributeHelper->isExistInAttributesArray($formData['definition']['number_of_items_custom_attribute'], $attributesByInputTypes['text_select'])) : ?>
                                    <option attribute_code="<?php echo $formData['definition']['number_of_items_custom_attribute']; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::NUMBER_OF_ITEMS_MODE_CUSTOM_ATTRIBUTE ?>" selected="selected" >
                                        <?php echo Mage::helper('M2ePro')->escapeHtml($magentoAttributeHelper->getAttributeLabel($formData['definition']['number_of_items_custom_attribute'])); ?>
                                    </option>
                                <?php endif; ?>
                                <?php foreach($attributesByInputTypes['text_select'] as $attribute) : ?>
                                    <option attribute_code="<?php echo $attribute['code']; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::NUMBER_OF_ITEMS_MODE_CUSTOM_ATTRIBUTE ?>" <?php if ($attribute['code'] == $formData['definition']['number_of_items_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                        <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                    </option>
                                <?php endforeach; ?>
                            </optgroup>
                        </select>
                        <p class="note">
                            <?php echo Mage::helper('M2ePro')->__(
                                'The number of discrete Items included in the Item you are offering for sale,
                                 such that each Item is not packaged for individual sale.<br/><br/>
                                <strong>For ex.</strong>, if you are selling a case of 10 packages of socks,
                                and each package contains
                                <br/>3 pairs of socks, the case would have Package Quantity = 10 and Number of Items = 30.'
                            ); ?>
                        </p>
                    </td>
                </tr>

                <tr class="entry-edit" id="number_of_items_custom_value_tr">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Number of Items Value'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <input id="number_of_items_custom_value" name="definition[number_of_items_custom_value]" value="<?php echo Mage::helper('M2ePro')->escapeHtml($formData['definition']['number_of_items_custom_value']); ?>" type="text" class="input-text M2ePro-required-when-visible M2ePro-validate-greater-than" min_value="1" />
                    </td>
                </tr>

            </table>

        </div>
    </div>

</div>

<?php if ($formData['definition']['msrp_rrp_mode'] != Ess_M2ePro_Model_Amazon_Template_Description_Definition::MSRP_RRP_MODE_NONE): ?>
    <div class="entry-edit" id="magento_block_amazon_template_description_price">

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

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

                <table class="form-list" cellspacing="0" cellpadding="0">
                    <tr>
                        <td class="label">
                            <label for="image_main_mode"><?php echo Mage::helper('M2ePro')->__('MSRP / RRP'); ?>
                                :</label>
                        </td>
                        <td class="value" style="width: auto;">
                            <input type="hidden" id="msrp_rrp_custom_attribute"
                                   name="definition[msrp_rrp_custom_attribute]"
                                   value="<?php echo $formData['definition']['msrp_rrp_custom_attribute']; ?>"/>

                            <select id="msrp_rrp_mode" name="definition[msrp_rrp_mode]"
                                    class="M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text,price">
                                <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::MSRP_RRP_MODE_NONE; ?>"><?php echo Mage::helper('M2ePro')->__('None'); ?></option>

                                <optgroup class="M2ePro-custom-attribute-optgroup" label="Magento Attribute">
                                    <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['msrp_rrp_custom_attribute'], $attributesByInputTypes['text_price'], Ess_M2ePro_Model_Amazon_Template_Description_Definition::MSRP_RRP_MODE_ATTRIBUTE); ?>
                                    <?php foreach ($attributesByInputTypes['text_price'] as $attribute) : ?>
                                        <option attribute_code="<?php echo $attribute['code']; ?>"
                                                value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::MSRP_RRP_MODE_ATTRIBUTE; ?>"
                                                <?php if ($attribute['code'] == $formData['definition']['msrp_rrp_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                            <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                        </option>
                                    <?php endforeach; ?>
                                </optgroup>
                            </select>
                            <p class="note">
                            <span>
                                <?php echo Mage::helper('M2ePro')->__(
                                    'Manufacturer\'s suggested retail price (MSRP), or the recommended retail price (RRP) is the price at which manufacturer recommends the retailers to sell the Product.<br>
                                    <strong>Note:</strong> It is not the price that buyers will pay for your Item. Your retail price should be set in Selling Policy.'
                                ); ?>
                            </span>
                            </p>
                        </td>
                    </tr>
                </table>

            </div>
        </div>

    </div>
<?php endif; ?>

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

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

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

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

                <tr>
                    <td class="label">
                        <label for="image_main_mode"><?php echo Mage::helper('M2ePro')->__('Main Image'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <input type="hidden" id="image_main_attribute" name="definition[image_main_attribute]" value="<?php echo $formData['definition']['image_main_attribute']; ?>" />

                        <select id="image_main_mode" name="definition[image_main_mode]" class="M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text,textarea,select,multiselect">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::IMAGE_MAIN_MODE_NONE; ?>" <?php if ($formData['definition']['image_main_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::IMAGE_MAIN_MODE_NONE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('None'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::IMAGE_MAIN_MODE_PRODUCT; ?>" <?php if ($formData['definition']['image_main_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::IMAGE_MAIN_MODE_PRODUCT): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Product Base Image'); ?></option>

                            <optgroup class="M2ePro-custom-attribute-optgroup" label="Magento Attribute">
                                <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['image_main_attribute'], $attributesByInputTypes['text_images'], Ess_M2ePro_Model_Amazon_Template_Description_Definition::IMAGE_MAIN_MODE_ATTRIBUTE); ?>
                                <?php foreach($attributesByInputTypes['text_images'] as $attribute) : ?>
                                    <option attribute_code="<?php echo $attribute['code']; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::IMAGE_MAIN_MODE_ATTRIBUTE; ?>" <?php if ($attribute['code'] == $formData['definition']['image_main_attribute']): ?>selected="selected"<?php endif; ?>>
                                        <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                    </option>
                                <?php endforeach; ?>
                            </optgroup>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Required for creating new ASIN/ISBN.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="gallery_images_mode_tr">
                    <td class="label">
                        <label for="gallery_images_mode"><?php echo Mage::helper('M2ePro')->__('Additional Images'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <input type="hidden" id="gallery_images_limit" name="definition[gallery_images_limit]" value="<?php echo $formData['definition']['gallery_images_limit']; ?>" />
                        <input type="hidden" id="gallery_images_attribute" name="definition[gallery_images_attribute]" value="<?php echo $formData['definition']['gallery_images_attribute']; ?>" />

                        <select id="gallery_images_mode" name="definition[gallery_images_mode]" class="M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text,textarea,select,multiselect">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::GALLERY_IMAGES_MODE_NONE; ?>" <?php if ($formData['definition']['gallery_images_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::GALLERY_IMAGES_MODE_NONE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('None'); ?></option>

                            <optgroup label="Product Images Quantity">
                                <?php for ($i = 1; $i <= 8; $i++): ?>
                                    <option attribute_code="<?php echo $i; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::GALLERY_IMAGES_MODE_PRODUCT; ?>" <?php if ($formData['definition']['gallery_images_limit'] == $i): echo ' selected="selected"'; endif; ?>>
                                        <?php echo $i == 1 ? $i : Mage::helper('M2ePro')->__('Up to') . ' ' . $i; ?>
                                    </option>
                                <?php endfor ?>
                            </optgroup>

                            <optgroup class="M2ePro-custom-attribute-optgroup" label="Magento Attribute">
                                <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['gallery_images_attribute'], $attributesByInputTypes['text_images'], Ess_M2ePro_Model_Amazon_Template_Description_Definition::GALLERY_IMAGES_MODE_ATTRIBUTE); ?>
                                <?php foreach($attributesByInputTypes['text_images'] as $attribute) : ?>
                                    <option attribute_code="<?php echo $attribute['code']; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::GALLERY_IMAGES_MODE_ATTRIBUTE; ?>" <?php if ($attribute['code'] == $formData['definition']['gallery_images_attribute']): ?>selected="selected"<?php endif; ?>>
                                        <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                    </option>
                                <?php endforeach; ?>
                            </optgroup>
                        </select>
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label for="image_variation_difference_mode"><?php echo Mage::helper('M2ePro')->__('Swatch Image'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <input type="hidden" id="image_variation_difference_attribute" name="definition[image_variation_difference_attribute]" value="<?php echo $formData['definition']['image_variation_difference_attribute']; ?>" />

                        <select id="image_variation_difference_mode" name="definition[image_variation_difference_mode]" class="M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text,textarea,select,multiselect">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::IMAGE_VARIATION_DIFFERENCE_MODE_NONE; ?>" <?php if ($formData['definition']['image_variation_difference_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::IMAGE_VARIATION_DIFFERENCE_MODE_NONE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('None'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::IMAGE_VARIATION_DIFFERENCE_MODE_PRODUCT; ?>" <?php if ($formData['definition']['image_variation_difference_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::IMAGE_VARIATION_DIFFERENCE_MODE_PRODUCT): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Product Base Image'); ?></option>

                            <optgroup class="M2ePro-custom-attribute-optgroup" label="Magento Attribute">
                                <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['image_variation_difference_attribute'], $attributesByInputTypes['text_images'], Ess_M2ePro_Model_Amazon_Template_Description_Definition::IMAGE_VARIATION_DIFFERENCE_MODE_ATTRIBUTE); ?>
                                <?php foreach($attributesByInputTypes['text_images'] as $attribute) : ?>
                                    <option attribute_code="<?php echo $attribute['code']; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::IMAGE_VARIATION_DIFFERENCE_MODE_ATTRIBUTE; ?>" <?php if ($attribute['code'] == $formData['definition']['image_variation_difference_attribute']): ?>selected="selected"<?php endif; ?>>
                                        <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                    </option>
                                <?php endforeach; ?>
                            </optgroup>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Allows to display Variations of Amazon Product by the main images of Child Products.'); ?></span>
                        </p>
                    </td>
                </tr>

            </table>

        </div>
    </div>

</div>

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

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

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

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

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Description'); ?>: </label>
                    </td>
                    <td class="value">
                        <select id="description_mode" name="definition[description_mode]" class="required-entry">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::DESCRIPTION_MODE_NONE; ?>" <?php if ($formData['definition']['description_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::DESCRIPTION_MODE_NONE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('None'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::DESCRIPTION_MODE_PRODUCT; ?>" <?php if ($formData['definition']['description_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::DESCRIPTION_MODE_PRODUCT): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Product Description'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::DESCRIPTION_MODE_SHORT; ?>" <?php if ($formData['definition']['description_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::DESCRIPTION_MODE_SHORT): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Product Short Description'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::DESCRIPTION_MODE_CUSTOM; ?>" <?php if ($formData['definition']['description_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::DESCRIPTION_MODE_CUSTOM): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Custom Value'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Description is limited to 2\'000 characters.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr class="c-custom_description_tr" style="display: none;">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Description Value'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">

                        <script type="text/javascript">
                            wysiwygtext = {
                                isEnabled: function() {
                                    return false;
                                }
                            };
                        </script>

                        <textarea id="description_template" name="definition[description_template]" class="textarea M2ePro-required-when-visible"><?php echo Mage::helper('M2ePro')->escapeHtml($formData['definition']['description_template']); ?></textarea>

                    </td>
                </tr>

                <tr class="c-custom_description_tr" style="display: none;">
                    <td class="label"></td>
                    <td class="value">

                        <div class="entry-edit-head" style="background: #D6D6D6;">
                            <h4 class="icon-head head-edit-form fieldset-legend" style="color: #EA7601;"><?php echo Mage::helper('M2ePro')->__('Custom Inserts'); ?></h4>
                        </div>

                        <div class="fieldset">
                            <div class="hor-scroll">
                                <table cellspacing="0" class="form-list">
                                    <tr>
                                        <td class="label">
                                            <label for="select_attributes_span"><?php echo Mage::helper('M2ePro')->__('Product Attribute');?>:</label>
                                        </td>
                                        <td class="value">
                                                <span id="select_attributes_span">
                                                    <select id="select_attributes" class="M2ePro-custom-attribute-can-be-created" style="width: 150px;">
                                                        <?php foreach($this->getData('all_attributes') as $attribute) : ?>
                                                            <option value="<?php echo $attribute['code']; ?>">
                                                                <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                                            </option>
                                                        <?php endforeach; ?>
                                                    </select>
                                                </span>
                                            &nbsp;
                                            <?php echo $this->getChildHtml('add_product_attribute_button'); ?>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>

                    </td>
                </tr>

            </table>

        </div>
    </div>
</div>

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

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

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

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

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Volume') ?>:</label>
                    </td>
                    <td class="value">
                        <select id="item_dimensions_volume_mode" name="definition[item_dimensions_volume_mode]" class="select">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_MODE_NONE; ?>" <?php if ($formData['definition']['item_dimensions_volume_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_MODE_NONE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('None'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_MODE_CUSTOM_VALUE; ?>" <?php if ($formData['definition']['item_dimensions_volume_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_MODE_CUSTOM_VALUE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Custom Value'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_MODE_CUSTOM_ATTRIBUTE; ?>" <?php if ($formData['definition']['item_dimensions_volume_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_MODE_CUSTOM_ATTRIBUTE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Custom Attribute'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Physical dimensions of Product without package'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="item_dimensions_volume_custom_value_tr" style="display: none;">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Length x Width x Height'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <input name="definition[item_dimensions_volume_length_custom_value]" value="<?php echo $this->escapeHtml($formData['definition']['item_dimensions_volume_length_custom_value']); ?>" type="text" class="input-text M2ePro-required-when-visible M2ePro-validation-float M2ePro-validate-greater-than" style="width: 80px;" min_value="0.01" /> x
                        <input name="definition[item_dimensions_volume_width_custom_value]" value="<?php echo $this->escapeHtml($formData['definition']['item_dimensions_volume_width_custom_value']); ?>" type="text" class="input-text M2ePro-required-when-visible M2ePro-validation-float M2ePro-validate-greater-than" style="width: 79px;" min_value="0.01"/> x
                        <input name="definition[item_dimensions_volume_height_custom_value]" value="<?php echo $this->escapeHtml($formData['definition']['item_dimensions_volume_height_custom_value']); ?>" type="text" class="input-text M2ePro-required-when-visible M2ePro-validation-float M2ePro-validate-greater-than" style="width: 79px;" min_value="0.01"/>
                    </td>
                </tr>

                <tr id="item_dimensions_volume_custom_attribute_tr" style="display: none;">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Length x Width x Height'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <select name="definition[item_dimensions_volume_length_custom_attribute]" id="item_dimensions_volume_length_custom_attribute" class="M2ePro-required-when-visible M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text" style="width: 86px;">
                            <option value="" style="display: none;"></option>
                            <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['item_dimensions_volume_length_custom_attribute'], $attributesByInputTypes['text_weight']); ?>
                            <?php foreach($attributesByInputTypes['text_weight'] as $attribute) : ?>
                                <option value="<?php echo $attribute['code']; ?>" <?php if ($attribute['code'] == $formData['definition']['item_dimensions_volume_length_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                    <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                </option>
                            <?php endforeach; ?>
                        </select>
                        x
                        <select name="definition[item_dimensions_volume_width_custom_attribute]" id="item_dimensions_volume_width_custom_attribute" class="M2ePro-required-when-visible M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text" style="width: 85px;">
                            <option value="" style="display: none;"></option>
                            <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['item_dimensions_volume_width_custom_attribute'], $attributesByInputTypes['text_weight']); ?>
                            <?php foreach($attributesByInputTypes['text_weight'] as $attribute) : ?>
                                <option value="<?php echo $attribute['code']; ?>" <?php if ($attribute['code'] == $formData['definition']['item_dimensions_volume_width_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                    <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                </option>
                            <?php endforeach; ?>
                        </select>
                        x
                        <select name="definition[item_dimensions_volume_height_custom_attribute]" id="item_dimensions_volume_height_custom_attribute" class="M2ePro-required-when-visible M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text" style="width: 85px;">
                            <option value="" style="display: none;"></option>
                            <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['item_dimensions_volume_height_custom_attribute'], $attributesByInputTypes['text_weight']); ?>
                            <?php foreach($attributesByInputTypes['text_weight'] as $attribute) : ?>
                                <option value="<?php echo $attribute['code']; ?>" <?php if ($attribute['code'] == $formData['definition']['item_dimensions_volume_height_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                    <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                </option>
                            <?php endforeach; ?>
                        </select>
                    </td>
                </tr>

                <tr id="item_dimensions_volume_unit_of_measure_mode_tr" style="display: none;">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Measure Units') ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <input type="hidden" id="item_dimensions_volume_unit_of_measure_custom_value" name="definition[item_dimensions_volume_unit_of_measure_custom_value]" value="<?php echo $formData['definition']['item_dimensions_volume_unit_of_measure_custom_value']; ?>" />
                        <input type="hidden" id="item_dimensions_volume_unit_of_measure_custom_attribute" name="definition[item_dimensions_volume_unit_of_measure_custom_attribute]" value="<?php echo $formData['definition']['item_dimensions_volume_unit_of_measure_custom_attribute']; ?>" />

                        <select id="item_dimensions_volume_unit_of_measure_mode" name="definition[item_dimensions_volume_unit_of_measure_mode]" class="select M2ePro-required-when-visible M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text">
                            <option style="display: none;"></option>

                            <optgroup label="Custom Value">
                                <?php foreach($this->getDimensionsUnits() as $unitName) : ?>
                                    <option attribute_code="<?php echo $unitName; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_UNIT_OF_MEASURE_MODE_CUSTOM_VALUE; ?>" <?php if ($formData['definition']['item_dimensions_volume_unit_of_measure_custom_value'] == $unitName): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__($unitName); ?></option>
                                <?php endforeach; ?>
                            </optgroup>

                            <optgroup class="M2ePro-custom-attribute-optgroup" label="Magento Attribute">
                                <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['item_dimensions_volume_unit_of_measure_custom_attribute'], $attributesByInputTypes['text_select'], Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_UNIT_OF_MEASURE_MODE_CUSTOM_ATTRIBUTE); ?>
                                <?php foreach($attributesByInputTypes['text_select'] as $attribute) : ?>
                                    <option attribute_code="<?php echo $attribute['code']; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_UNIT_OF_MEASURE_MODE_CUSTOM_ATTRIBUTE; ?>" <?php if ($attribute['code'] == $formData['definition']['item_dimensions_volume_unit_of_measure_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                        <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                    </option>
                                <?php endforeach; ?>
                            </optgroup>
                        </select>
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Weight'); ?>:</label>
                    </td>
                    <td class="value">
                        <input type="hidden" id="item_dimensions_weight_custom_attribute" name="definition[item_dimensions_weight_custom_attribute]" value="<?php echo $formData['definition']['item_dimensions_weight_custom_attribute']; ?>" />

                        <select id="item_dimensions_weight_mode" name="definition[item_dimensions_weight_mode]" class="select M2ePro-required-when-visible M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_MODE_NONE; ?>" <?php if ($formData['definition']['item_dimensions_weight_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_MODE_NONE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('None'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_MODE_CUSTOM_VALUE; ?>" <?php if ($formData['definition']['item_dimensions_weight_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_MODE_CUSTOM_VALUE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Custom Value'); ?></option>

                            <optgroup class="M2ePro-custom-attribute-optgroup" label="Magento Attribute">
                                <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['item_dimensions_weight_custom_attribute'], $attributesByInputTypes['text_weight'], Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_MODE_CUSTOM_ATTRIBUTE); ?>
                                <?php foreach($attributesByInputTypes['text_weight'] as $attribute) : ?>
                                    <option attribute_code="<?php echo $attribute['code']; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_MODE_CUSTOM_ATTRIBUTE; ?>" <?php if ($attribute['code'] == $formData['definition']['item_dimensions_weight_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                        <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                    </option>
                                <?php endforeach; ?>
                            </optgroup>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Physical weight of Products without package'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="item_dimensions_weight_custom_value_tr" style="display: none;">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Weight Value'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <input id="item_dimensions_weight_custom_value" name="definition[item_dimensions_weight_custom_value]" value="<?php echo Mage::helper('M2ePro')->escapeHtml($formData['definition']['item_dimensions_weight_custom_value']); ?>" type="text" class="input-text M2ePro-required-when-visible M2ePro-validate-greater-than" min_value="0.01" />
                    </td>
                </tr>

                <tr id="item_dimensions_weight_unit_of_measure_mode_tr" style="display: none;">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Weight Units'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <input type="hidden" id="item_dimensions_weight_unit_of_measure_custom_value" name="definition[item_dimensions_weight_unit_of_measure_custom_value]" value="<?php echo $formData['definition']['item_dimensions_weight_unit_of_measure_custom_value']; ?>" />
                        <input type="hidden" id="item_dimensions_weight_unit_of_measure_custom_attribute" name="definition[item_dimensions_weight_unit_of_measure_custom_attribute]" value="<?php echo $formData['definition']['item_dimensions_weight_unit_of_measure_custom_attribute']; ?>" />

                        <select id="item_dimensions_weight_unit_of_measure_mode" name="definition[item_dimensions_weight_unit_of_measure_mode]" class="select M2ePro-required-when-visible M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text,select">
                            <option value="" style="display: none;"></option>

                            <optgroup label="Custom Value">
                                <?php foreach($this->getWeightUnits() as $unitName) : ?>
                                    <option attribute_code="<?php echo $unitName; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_MODE_CUSTOM_VALUE; ?>" <?php if ($formData['definition']['item_dimensions_weight_unit_of_measure_custom_value'] == $unitName): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__($unitName); ?></option>
                                <?php endforeach; ?>
                            </optgroup>

                            <optgroup class="M2ePro-custom-attribute-optgroup" label="Magento Attribute">
                                <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['item_dimensions_weight_unit_of_measure_custom_attribute'], $attributesByInputTypes['text_select'], Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_MODE_CUSTOM_ATTRIBUTE); ?>
                                <?php foreach($attributesByInputTypes['text_select'] as $attribute) : ?>
                                    <option attribute_code="<?php echo $attribute['code']; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_MODE_CUSTOM_ATTRIBUTE; ?>" <?php if ($attribute['code'] == $formData['definition']['item_dimensions_weight_unit_of_measure_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                        <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                    </option>
                                <?php endforeach; ?>
                            </optgroup>
                        </select>
                    </td>
                </tr>

            </table>

        </div>
    </div>

</div>

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

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

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

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

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Volume') ?>:</label>
                    </td>
                    <td class="value">
                        <select id="package_dimensions_volume_mode" name="definition[package_dimensions_volume_mode]" class="select">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_MODE_NONE; ?>" <?php if ($formData['definition']['package_dimensions_volume_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_MODE_NONE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('None'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_MODE_CUSTOM_VALUE; ?>" <?php if ($formData['definition']['package_dimensions_volume_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_MODE_CUSTOM_VALUE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Custom Value'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_MODE_CUSTOM_ATTRIBUTE; ?>" <?php if ($formData['definition']['package_dimensions_volume_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_MODE_CUSTOM_ATTRIBUTE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Custom Attribute'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Physical dimensions of package'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="package_dimensions_volume_custom_value_tr" style="display: none;">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Length x Width x Height'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <input name="definition[package_dimensions_volume_length_custom_value]" value="<?php echo $this->escapeHtml($formData['definition']['package_dimensions_volume_length_custom_value']); ?>" type="text" class="input-text M2ePro-required-when-visible M2ePro-validation-float M2ePro-validate-greater-than" style="width: 80px;" min_value="0.01" /> x
                        <input name="definition[package_dimensions_volume_width_custom_value]" value="<?php echo $this->escapeHtml($formData['definition']['package_dimensions_volume_width_custom_value']); ?>" type="text" class="input-text M2ePro-required-when-visible M2ePro-validation-float M2ePro-validate-greater-than" style="width: 79px;" min_value="0.01" /> x
                        <input name="definition[package_dimensions_volume_height_custom_value]" value="<?php echo $this->escapeHtml($formData['definition']['package_dimensions_volume_height_custom_value']); ?>" type="text" class="input-text M2ePro-required-when-visible M2ePro-validation-float M2ePro-validate-greater-than" style="width: 79px;" min_value="0.01" />
                    </td>
                </tr>

                <tr id="package_dimensions_volume_custom_attribute_tr" style="display: none;">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Length x Width x Height'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <select name="definition[package_dimensions_volume_length_custom_attribute]" id="package_dimensions_volume_length_custom_attribute" class="M2ePro-required-when-visible M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text" style="width: 86px;">
                            <option value="" style="display: none;"></option>
                            <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['package_dimensions_volume_length_custom_attribute'], $attributesByInputTypes['text_weight']); ?>
                            <?php foreach($attributesByInputTypes['text_weight'] as $attribute) : ?>
                                <option value="<?php echo $attribute['code']; ?>" <?php if ($attribute['code'] == $formData['definition']['package_dimensions_volume_length_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                    <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                </option>
                            <?php endforeach; ?>
                        </select>
                        x
                        <select name="definition[package_dimensions_volume_width_custom_attribute]" id="package_dimensions_volume_width_custom_attribute" class="M2ePro-required-when-visible M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text" style="width: 85px;">
                            <option value="" style="display: none;"></option>
                            <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['package_dimensions_volume_width_custom_attribute'], $attributesByInputTypes['text_weight']); ?>
                            <?php foreach($attributesByInputTypes['text_weight'] as $attribute) : ?>
                                <option value="<?php echo $attribute['code']; ?>" <?php if ($attribute['code'] == $formData['definition']['package_dimensions_volume_width_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                    <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                </option>
                            <?php endforeach; ?>
                        </select>
                        x
                        <select name="definition[package_dimensions_volume_height_custom_attribute]" id="package_dimensions_volume_height_custom_attribute" class="M2ePro-required-when-visible M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text" style="width: 85px;">
                            <option value="" style="display: none;"></option>
                            <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['package_dimensions_volume_height_custom_attribute'], $attributesByInputTypes['text_weight']); ?>
                            <?php foreach($attributesByInputTypes['text_weight'] as $attribute) : ?>
                                <option value="<?php echo $attribute['code']; ?>" <?php if ($attribute['code'] == $formData['definition']['package_dimensions_volume_height_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                    <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                </option>
                            <?php endforeach; ?>
                        </select>
                    </td>
                </tr>

                <tr id="package_dimensions_volume_unit_of_measure_mode_tr" style="display: none;">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Measure Units'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <input type="hidden" id="package_dimensions_volume_unit_of_measure_custom_value" name="definition[package_dimensions_volume_unit_of_measure_custom_value]" value="<?php echo $formData['definition']['package_dimensions_volume_unit_of_measure_custom_value']; ?>" />
                        <input type="hidden" id="package_dimensions_volume_unit_of_measure_custom_attribute" name="definition[package_dimensions_volume_unit_of_measure_custom_attribute]" value="<?php echo $formData['definition']['package_dimensions_volume_unit_of_measure_custom_attribute']; ?>" />

                        <select id="package_dimensions_volume_unit_of_measure_mode" name="definition[package_dimensions_volume_unit_of_measure_mode]" class="select M2ePro-required-when-visible M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text,select">
                            <option value="" style="display: none;"></option>

                            <optgroup label="Magento Attribute">
                                <?php foreach($this->getDimensionsUnits() as $unitName) : ?>
                                    <option attribute_code="<?php echo $unitName; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_MODE_CUSTOM_VALUE; ?>" <?php if ($formData['definition']['package_dimensions_volume_unit_of_measure_custom_value'] == $unitName): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__($unitName); ?></option>
                                <?php endforeach; ?>
                            </optgroup>

                            <optgroup class="M2ePro-custom-attribute-optgroup" label="Magento Attribute">
                                <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['package_dimensions_volume_unit_of_measure_custom_attribute'], $attributesByInputTypes['text_select'], Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_MODE_CUSTOM_ATTRIBUTE); ?>
                                <?php foreach($attributesByInputTypes['text_select'] as $attribute) : ?>
                                    <option attribute_code="<?php echo $attribute['code']; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::DIMENSION_VOLUME_MODE_CUSTOM_ATTRIBUTE; ?>" <?php if ($attribute['code'] == $formData['definition']['package_dimensions_volume_unit_of_measure_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                        <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                    </option>
                                <?php endforeach; ?>
                            </optgroup>
                        </select>
                    </td>
                </tr>

            </table>

        </div>
    </div>

</div>

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

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

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

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

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Package Weight'); ?>:</label>
                    </td>
                    <td class="value">
                        <input type="hidden" id="package_weight_custom_attribute" name="definition[package_weight_custom_attribute]" value="<?php echo $formData['definition']['package_weight_custom_attribute']; ?>" />

                        <select id="package_weight_mode" name="definition[package_weight_mode]" class="select M2ePro-required-when-visible M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_MODE_NONE; ?>" <?php if ($formData['definition']['package_weight_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_MODE_NONE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('None'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_MODE_CUSTOM_VALUE; ?>" <?php if ($formData['definition']['package_weight_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_MODE_CUSTOM_VALUE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Custom Value'); ?></option>

                            <optgroup class="M2ePro-custom-attribute-optgroup" label="Magento Attribute">
                                <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['package_weight_custom_attribute'], $attributesByInputTypes['text_weight'], Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_MODE_CUSTOM_ATTRIBUTE); ?>
                                <?php foreach($attributesByInputTypes['text_weight'] as $attribute) : ?>
                                    <option attribute_code="<?php echo $attribute['code']; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_MODE_CUSTOM_ATTRIBUTE; ?>" <?php if ($attribute['code'] == $formData['definition']['package_weight_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                        <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                    </option>
                                <?php endforeach; ?>
                            </optgroup>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Package Weight of the Product(s).'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="package_weight_custom_value_tr" style="display: none;">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Package Weight Value'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <input id="package_weight_custom_value" name="definition[package_weight_custom_value]" value="<?php echo Mage::helper('M2ePro')->escapeHtml($formData['definition']['package_weight_custom_value']); ?>" type="text" class="input-text M2ePro-required-when-visible M2ePro-validate-greater-than" min_value="0.01" />
                    </td>
                </tr>

                <tr id="package_weight_unit_of_measure_mode_tr" style="display: none;">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Package Weight Units'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <input type="hidden" id="package_weight_unit_of_measure_custom_value" name="definition[package_weight_unit_of_measure_custom_value]" value="<?php echo $formData['definition']['package_weight_unit_of_measure_custom_value']; ?>" />
                        <input type="hidden" id="package_weight_unit_of_measure_custom_attribute" name="definition[package_weight_unit_of_measure_custom_attribute]" value="<?php echo $formData['definition']['package_weight_unit_of_measure_custom_attribute']; ?>" />

                        <select id="package_weight_unit_of_measure_mode" name="definition[package_weight_unit_of_measure_mode]" class="select M2ePro-required-when-visible M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text,select">
                            <option value="" style="display: none;"></option>

                            <optgroup label="Custom Value">
                                <?php foreach($this->getWeightUnits() as $unitName) : ?>
                                    <option attribute_code="<?php echo $unitName; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_UNIT_OF_MEASURE_MODE_CUSTOM_VALUE; ?>" <?php if ($formData['definition']['package_weight_unit_of_measure_custom_value'] == $unitName): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__($unitName); ?></option>
                                <?php endforeach; ?>
                            </optgroup>

                            <optgroup class="M2ePro-custom-attribute-optgroup" label="Magento Attribute">
                                <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['package_weight_unit_of_measure_custom_attribute'], $attributesByInputTypes['text_select'], Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_UNIT_OF_MEASURE_MODE_CUSTOM_ATTRIBUTE); ?>
                                <?php foreach($attributesByInputTypes['text_select'] as $attribute) : ?>
                                    <option attribute_code="<?php echo $attribute['code']; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_UNIT_OF_MEASURE_MODE_CUSTOM_ATTRIBUTE; ?>" <?php if ($attribute['code'] == $formData['definition']['package_weight_unit_of_measure_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                        <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                    </option>
                                <?php endforeach; ?>
                            </optgroup>
                        </select>
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Shipping Weight'); ?>:</label>
                    </td>
                    <td class="value">
                        <input type="hidden" id="shipping_weight_custom_attribute" name="definition[shipping_weight_custom_attribute]" value="<?php echo $formData['definition']['shipping_weight_custom_attribute']; ?>" />

                        <select id="shipping_weight_mode" name="definition[shipping_weight_mode]" class="select M2ePro-required-when-visible M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_MODE_NONE; ?>" <?php if ($formData['definition']['shipping_weight_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_MODE_NONE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('None'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_MODE_CUSTOM_VALUE; ?>" <?php if ($formData['definition']['shipping_weight_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_MODE_CUSTOM_VALUE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Custom Value'); ?></option>

                            <optgroup class="M2ePro-custom-attribute-optgroup" label="Magento Attribute">
                                <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['shipping_weight_custom_attribute'], $attributesByInputTypes['text_weight'], Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_MODE_CUSTOM_ATTRIBUTE); ?>
                                <?php foreach($attributesByInputTypes['text_weight'] as $attribute) : ?>
                                    <option attribute_code="<?php echo $attribute['code']; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_MODE_CUSTOM_ATTRIBUTE; ?>" <?php if ($attribute['code'] == $formData['definition']['shipping_weight_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                        <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                    </option>
                                <?php endforeach; ?>
                            </optgroup>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Shipping Weight of the Product(s).'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="shipping_weight_custom_value_tr" style="display: none;">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Shipping Weight Value'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <input id="shipping_weight_custom_value" name="definition[shipping_weight_custom_value]" value="<?php echo Mage::helper('M2ePro')->escapeHtml($formData['definition']['shipping_weight_custom_value']); ?>" type="text" class="input-text M2ePro-required-when-visible M2ePro-validate-greater-than" min_value="0.01" />
                    </td>
                </tr>

                <tr id="shipping_weight_unit_of_measure_mode_tr" style="display: none;">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Shipping Weight Units'); ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <input type="hidden" id="shipping_weight_unit_of_measure_custom_value" name="definition[shipping_weight_unit_of_measure_custom_value]" value="<?php echo $formData['definition']['shipping_weight_unit_of_measure_custom_value']; ?>" />
                        <input type="hidden" id="shipping_weight_unit_of_measure_custom_attribute" name="definition[shipping_weight_unit_of_measure_custom_attribute]" value="<?php echo $formData['definition']['shipping_weight_unit_of_measure_custom_attribute']; ?>" />

                        <select id="shipping_weight_unit_of_measure_mode" name="definition[shipping_weight_unit_of_measure_mode]" class="select M2ePro-required-when-visible M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text,select">
                            <option value="" style="display: none;"></option>

                            <optgroup label="Custom Value">
                                <?php foreach($this->getWeightUnits() as $unitName) : ?>
                                    <option attribute_code="<?php echo $unitName; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_UNIT_OF_MEASURE_MODE_CUSTOM_VALUE; ?>" <?php if ($formData['definition']['shipping_weight_unit_of_measure_custom_value'] == $unitName): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__($unitName); ?></option>
                                <?php endforeach; ?>
                            </optgroup>

                            <optgroup class="M2ePro-custom-attribute-optgroup" label="Magento Attribute">
                                <?php echo $this->getForceAddedAttributeOptionHtml($formData['definition']['shipping_weight_unit_of_measure_custom_attribute'], $attributesByInputTypes['text_select'], Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_UNIT_OF_MEASURE_MODE_CUSTOM_ATTRIBUTE); ?>
                                <?php foreach($attributesByInputTypes['text_select'] as $attribute) : ?>
                                    <option attribute_code="<?php echo $attribute['code']; ?>" value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::WEIGHT_UNIT_OF_MEASURE_MODE_CUSTOM_ATTRIBUTE; ?>" <?php if ($attribute['code'] == $formData['definition']['shipping_weight_unit_of_measure_custom_attribute']): ?>selected="selected"<?php endif; ?>>
                                        <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                    </option>
                                <?php endforeach; ?>
                            </optgroup>
                        </select>
                    </td>
                </tr>

            </table>

        </div>
    </div>

</div>

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

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

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

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

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Target Audience Mode') ?>:</label>
                    </td>
                    <td class="value">
                        <select id="target_audience_mode" name="definition[target_audience_mode]" class="select">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::TARGET_AUDIENCE_MODE_NONE; ?>" <?php if ($formData['definition']['target_audience_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::TARGET_AUDIENCE_MODE_NONE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('None'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::TARGET_AUDIENCE_MODE_CUSTOM; ?>" <?php if ($formData['definition']['target_audience_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::TARGET_AUDIENCE_MODE_CUSTOM): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Custom Value'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('For whom the Product is intended.'); ?></span>
                        </p>
                    </td>
                </tr>

                <?php for ($i = 0; $i < 4; $i++): ?>
                    <tr class="target_audience_tr" style="display: none;">
                        <td class="label">
                            <label><?php echo Mage::helper('M2ePro')->__('Target Audience Value #%s', $i + 1); ?>: <span class="required">*</span></label>
                        </td>
                        <td class="value">
                            <input id="target_audience_<?php echo $i; ?>" onkeyup="AmazonTemplateDescriptionDefinitionObj.multi_element_keyup('target_audience',this)"
                                   name="definition[target_audience][]" type="text" class="input-text M2ePro-required-when-visible"
                                   value="<?php echo !empty($formData['definition']['target_audience'][$i]) ? Mage::helper('M2ePro')->escapeHtml($formData['definition']['target_audience'][$i]) : ''; ?>">
                            <p class="note">
                                <span><?php echo Mage::helper('M2ePro')->__('Max. 50 characters.'); ?></span>
                            </p>
                        </td>
                        <td class="value attributes-container-td">
                                <span id="select_attributes_for_target_audience_<?php echo $i; ?>_span" class="select-wrapper">
                                    <select id="select_attributes_for_target_audience_<?php echo $i; ?>" class="M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text,select,multiselect" apply_to_all_attribute_sets="0" style="width: 150px;">
                                        <?php foreach($attributesByInputTypes['text_select_multiselect'] as $attribute) : ?>
                                            <option value="<?php echo $attribute['code']; ?>">
                                                <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                            </option>
                                        <?php endforeach; ?>
                                    </select>
                                </span>
                            <?php echo $this->getChildHtml("select_attributes_for_target_audience_{$i}_button"); ?>
                        </td>
                    </tr>
                <?php endfor; ?>

                <tr id="target_audience_actions_tr" style="display: none;">
                    <td></td>
                    <td class="value" style="padding-top: 0 !important;">
                        <a id="show_target_audience_action" href="javascript: void(0);" onclick="AmazonTemplateDescriptionDefinitionObj.showElement('target_audience');"><?php echo Mage::helper('M2ePro')->__('Add New') ?></a>
                        /
                        <a id="hide_target_audience_action" href="javascript: void(0);" onclick="AmazonTemplateDescriptionDefinitionObj.hideElement('target_audience');"><?php echo Mage::helper('M2ePro')->__('Remove') ?></a>
                    </td>
                </tr>

                <tr>
                    <td colspan="2" style="padding: 10px 0">
                        <hr style="border: 1px solid silver; border-bottom: none;">
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Search Terms Mode') ?>:</label>
                    </td>
                    <td class="value">
                        <select id="search_terms_mode" name="definition[search_terms_mode]" class="select">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::SEARCH_TERMS_MODE_NONE; ?>" <?php if ($formData['definition']['search_terms_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::SEARCH_TERMS_MODE_NONE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('None'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::SEARCH_TERMS_MODE_CUSTOM; ?>" <?php if ($formData['definition']['search_terms_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::SEARCH_TERMS_MODE_CUSTOM): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Custom Value'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Provide specific Search Terms to help customers find your Product(s) on Amazon.'); ?></span>
                        </p>
                    </td>
                </tr>

                <?php for ($i = 0; $i < 5; $i++): ?>
                    <tr class="search_terms_tr" style="display: none;">
                        <td class="label">
                            <label><?php echo Mage::helper('M2ePro')->__('Search Terms Value #%s', $i + 1); ?>: <span class="required">*</span></label>
                        </td>
                        <td class="value">
                            <input id="search_terms_<?php echo $i; ?>" onkeyup="AmazonTemplateDescriptionDefinitionObj.multi_element_keyup('search_terms',this)"
                                   name="definition[search_terms][]" type="text" class="input-text M2ePro-required-when-visible"
                                   maxlength="250"
                                   value="<?php echo !empty($formData['definition']['search_terms'][$i]) ? Mage::helper('M2ePro')->escapeHtml($formData['definition']['search_terms'][$i]) : ''; ?>">
                            <p class="note">
                                <span><?php echo Mage::helper('M2ePro')->__('Max. 250 characters.'); ?></span>
                            </p>
                        </td>
                        <td class="value">
                            <span id="select_attributes_for_search_terms_<?php echo $i; ?>_span" class="select-wrapper">
                                <select id="select_attributes_for_search_terms_<?php echo $i; ?>" class="M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text,select,multiselect" apply_to_all_attribute_sets="0" style="width: 150px;">
                                    <?php foreach($attributesByInputTypes['text_select_multiselect'] as $attribute) : ?>
                                        <option value="<?php echo $attribute['code']; ?>">
                                            <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                        </option>
                                    <?php endforeach; ?>
                                </select>
                            </span>
                            <?php echo $this->getChildHtml("select_attributes_for_search_terms_{$i}_button"); ?>
                        </td>
                    </tr>
                <?php endfor; ?>

                <tr id="search_terms_actions_tr" style="display: none;">
                    <td></td>
                    <td class="value" style="padding-top: 0 !important;">
                        <a id="show_search_terms_action" href="javascript: void(0);" onclick="AmazonTemplateDescriptionDefinitionObj.showElement('search_terms');"><?php echo Mage::helper('M2ePro')->__('Add New') ?></a>
                        /
                        <a id="hide_search_terms_action" href="javascript: void(0);" onclick="AmazonTemplateDescriptionDefinitionObj.hideElement('search_terms');"><?php echo Mage::helper('M2ePro')->__('Remove') ?></a>
                    </td>
                </tr>

                <tr>
                    <td colspan="2" style="padding: 10px 0">
                        <hr style="border: 1px solid silver; border-bottom: none;">
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Bullet Points Mode') ?>:</label>
                    </td>
                    <td class="value">
                        <select id="bullet_points_mode" name="definition[bullet_points_mode]" class="select">
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::BULLET_POINTS_MODE_NONE; ?>" <?php if ($formData['definition']['bullet_points_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::BULLET_POINTS_MODE_NONE): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('None'); ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Amazon_Template_Description_Definition::BULLET_POINTS_MODE_CUSTOM; ?>" <?php if ($formData['definition']['bullet_points_mode'] == Ess_M2ePro_Model_Amazon_Template_Description_Definition::BULLET_POINTS_MODE_CUSTOM): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Custom Value'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Allows highlighting some of the Product\'s most important qualities.'); ?></span>
                        </p>
                    </td>
                </tr>

                <?php for ($i = 0; $i < 5; $i++): ?>
                    <tr class="bullet_points_tr" style="display: none;">
                        <td class="label">
                            <label><?php echo Mage::helper('M2ePro')->__('Bullet Points Value #%s', $i + 1); ?>: <span class="required">*</span></label>
                        </td>
                        <td class="value">
                            <input id="bullet_points_<?php echo $i; ?>" onkeyup="AmazonTemplateDescriptionDefinitionObj.multi_element_keyup('bullet_points',this)"
                                   name="definition[bullet_points][]" type="text" class="input-text M2ePro-required-when-visible"
                                   value="<?php echo !empty($formData['definition']['bullet_points'][$i]) ? Mage::helper('M2ePro')->escapeHtml($formData['definition']['bullet_points'][$i]) : ''; ?>">
                            <p class="note">
                                <span><?php echo Mage::helper('M2ePro')->__('Max. 500 characters.'); ?></span>
                            </p>
                        </td>
                        <td class="value">
                            <span id="select_attributes_for_bullet_points_<?php echo $i; ?>_span" class="select-wrapper">
                                 <select id="select_attributes_for_bullet_points_<?php echo $i; ?>"class="M2ePro-custom-attribute-can-be-created" allowed_attribute_types="text,select,multiselect" apply_to_all_attribute_sets="0" style="width: 150px;">
                                     <?php foreach($attributesByInputTypes['text_select_multiselect'] as $attribute) : ?>
                                         <option value="<?php echo $attribute['code']; ?>">
                                             <?php echo Mage::helper('M2ePro')->escapeHtml($attribute['label']); ?>
                                         </option>
                                     <?php endforeach; ?>
                                 </select>
                            </span>
                            <?php echo $this->getChildHtml("select_attributes_for_bullet_points_{$i}_button"); ?>
                        </td>
                    </tr>
                <?php endfor; ?>

                <tr id="bullet_points_actions_tr" style="display: none;">
                    <td></td>
                    <td class="value" style="padding-top: 0 !important;">
                        <a id="show_bullet_points_action" href="javascript: void(0);" onclick="AmazonTemplateDescriptionDefinitionObj.showElement('bullet_points');"><?php echo Mage::helper('M2ePro')->__('Add New') ?></a>
                        /
                        <a id="hide_bullet_points_action" href="javascript: void(0);" onclick="AmazonTemplateDescriptionDefinitionObj.hideElement('bullet_points');"><?php echo Mage::helper('M2ePro')->__('Remove') ?></a>
                    </td>
                </tr>

            </table>

        </div>
    </div>

</div>
