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

// @codingStandardsIgnoreFile

/** @var Ess_M2ePro_Block_Adminhtml_Ebay_Template_Synchronization_Edit_Form_Tabs_Revise $this */

$default = $this->getDefault();
$formData = $this->getFormData();

$formData = array_merge($default, $formData);

?>

<script type="text/javascript">

    var init = function() {
        $('revise_update_qty')
            .observe('change', EbayTemplateSynchronizationObj.reviseQty_change)
            .simulate('change');

        $('revise_update_qty_max_applied_value_mode')
            .observe('change', EbayTemplateSynchronizationObj.reviseQtyMaxAppliedValueMode_change)
            .simulate('change');
    };

    <?php if ($this->getRequest()->isXmlHttpRequest()): ?>
        init();
    <?php else: ?>
        Event.observe(window, 'load', init);
    <?php endif; ?>

</script>

<div id="block_notice_ebay_template_synchronization_form_data_revise" class="block_notices_module no-icon" title="<?php echo Mage::helper('M2ePro')->__('Revise Rules'); ?>">
    <?php echo Mage::helper('M2ePro')->__(
        'Specify which Channel data should be automatically revised by M2E Pro.<br/><br/>
Selected Item Properties will be automatically updated by the Module once any related changes are detected in Magento Attributes or Policy Templates.<br/><br/>
More detailed information on how to work with this Page can be found <a href="%url%" target="_blank">here</a>.',
        Mage::helper('M2ePro/Module_Support')->getDocumentationUrl(null, null, 'revise-action')
    ); ?>
</div>

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

    <div class="entry-edit-head">
        <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('M2ePro')->__('Revise Conditions'); ?></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')->__('Quantity'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="revise_update_qty" name="synchronization[revise_update_qty]" disabled="disabled" class="required-entry">
                            <option value="1" selected="selected"><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Automatically revises Item Quantity on eBay when Product Quantity, Magento Attribute used for Item Quantity or Custom Quantity value are modified in Magento or Policy Template. The Quantity management is the basic functionality the Magento-to-eBay integration is based on and it cannot be disabled.'); ?></span>
                        </p>
                    </td>
                </tr>

                <!-- max Affected value-->
                <tr id="revise_update_qty_max_applied_value_mode_tr" style="display: none;">
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Conditional Revise'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="revise_update_qty_max_applied_value_mode" name="synchronization[revise_update_qty_max_applied_value_mode]" class="required-entry">
                            <option value="0" <?php if ($formData['revise_update_qty_max_applied_value_mode'] == 0): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Disabled'); ?></option>
                            <option value="1" <?php if ($formData['revise_update_qty_max_applied_value_mode'] == 1): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Revise When Less or Equal to'); ?></option>
                        </select>
                        <input id="revise_update_qty_max_applied_value" name="synchronization[revise_update_qty_max_applied_value]" value="<?php echo $this->escapeHtml($formData['revise_update_qty_max_applied_value']); ?>" type="text" class="input-text validate-qty input-text M2ePro-required-when-visible" style="width: 72px" />
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Set the Quantity In Stock limit at which the Revise Action should be triggered. We recommend keeping this value relatively low, between 10 and 20 Items.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr id="revise_update_qty_max_applied_value_line_tr">
                    <td class="value" colspan="2" style="width: auto;">
                        <hr style="border: 1px solid silver; border-bottom: none;">
                    </td>
                <tr>

                <tr>

                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Price'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="revise_update_price" name="synchronization[revise_update_price]" class="required-entry">
                            <option value="0" <?php if ($formData['revise_update_price'] == 0): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1" <?php if ($formData['revise_update_price'] == 1): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                         <p class="note">
                             <span><?php echo Mage::helper('M2ePro')->__('Automatically revises Item Price on eBay when Product Price, Special Price or Magento Attribute used for Item Price are modified in Magento or Policy Template.'); ?></span>
                         </p>
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Title'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="revise_update_title" name="synchronization[revise_update_title]" class="required-entry">
                            <option value="0>" <?php if ($formData['revise_update_title'] == 0): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1" <?php if ($formData['revise_update_title'] == 1): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                         <p class="note">
                             <span><?php echo Mage::helper('M2ePro')->__('Automatically revises Item Title on eBay when Product Name, Magento Attribute used for Item Title or Custom Title value are modified in Magento or Policy Template.'); ?></span>
                         </p>
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Subtitle'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="revise_update_sub_title" name="synchronization[revise_update_sub_title]" class="required-entry">
                            <option value="0" <?php if ($formData['revise_update_sub_title'] == 0): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1" <?php if ($formData['revise_update_sub_title'] == 1): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                         <p class="note">
                             <span><?php echo Mage::helper('M2ePro')->__('Automatically revises Item Subtitle on eBay when Magento Attribute used for Item Subtitle or Custom Subtitle value are modified in Magento or Policy Template.'); ?></span>
                         </p>
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Description'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="revise_update_description" name="synchronization[revise_update_description]" class="required-entry">
                            <option value="0" <?php if ($formData['revise_update_description'] == 0): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1" <?php if ($formData['revise_update_description'] == 1): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Automatically revises Item Description on eBay when Product Description, Product Short Description or Custom Description value are modified in Magento or Policy Template.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Images'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="revise_update_images" name="synchronization[revise_update_images]" class="required-entry">
                            <option value="0" <?php if ($formData['revise_update_images'] == 0): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1" <?php if ($formData['revise_update_images'] == 1): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Automatically revises Item Image(s) on eBay when Product Image(s) or Magento Attribute used for Product Image(s) are modified in Magento or Policy Template.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Categories / Specifics'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="revise_update_categories" name="synchronization[revise_update_categories]" class="required-entry">
                            <option value="0" <?php if ($formData['revise_update_categories'] == 0): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1" <?php if ($formData['revise_update_categories'] == 1): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Automatically revises Item Categories/Specifics on eBay when Categories/Specifics data or Magento Attributes used for Categories/Specifics are modified.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('eBay Parts Compatibility'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="revise_update_parts" name="synchronization[revise_update_parts]"
                                class="required-entry">
                            <option value="0" <?php if ($formData['revise_update_parts'] == 0): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1" <?php if ($formData['revise_update_parts'] == 1): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Automatically revises Parts Compatibility data on eBay once the related data is modified.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Shipping'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="revise_update_shipping" name="synchronization[revise_update_shipping]" class="required-entry">
                            <option value="0" <?php if ($formData['revise_update_shipping'] == 0): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1" <?php if ($formData['revise_update_shipping'] == 1): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Automatically revises Item Shipping information on eBay when the Shipping Policy Template or Magento Attributes used in Shipping Policy Template are modified.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Payment'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="revise_update_payment" name="synchronization[revise_update_payment]" class="required-entry">
                            <option value="0" <?php if ($formData['revise_update_payment'] == 0): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1" <?php if ($formData['revise_update_payment'] == 1): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Automatically revises Item Payment information on eBay when Payment Policy Template is modified.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Return'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="revise_update_return" name="synchronization[revise_update_return]" class="required-entry">
                            <option value="0" <?php if ($formData['revise_update_return'] == 0): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1" <?php if ($formData['revise_update_return'] == 1): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Automatically revises Item Return information on eBay when Return Policy Template is modified.'); ?></span>
                        </p>
                    </td>
                </tr>

                <tr>
                    <td class="label">
                        <label><?php echo Mage::helper('M2ePro')->__('Other'); ?>:</label>
                    </td>
                    <td class="value" style="width: auto;">
                        <select id="revise_update_other" name="synchronization[revise_update_other]" class="required-entry">
                            <option value="0" <?php if ($formData['revise_update_other'] == 0): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                            <option value="1" <?php if ($formData['revise_update_other'] == 1): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                        </select>
                        <p class="note">
                            <span><?php echo Mage::helper('M2ePro')->__('Automatically revises Item Condition, Condition Note, Lot Size, Taxation and Best Offer information on eBay when the related data is modified in Policy Templates.'); ?></span>
                        </p>
                    </td>
                </tr>

            </table>

        </div>
    </div>

</div>

<div id="revise_qty_max_applied_value_confirmation_popup_template" style="display: none;">
    <div style="padding: 5px">
        <?php echo Mage::helper('M2ePro')->__(
            '<br/>Disabling this option might affect synchronization performance. Please read <a href="%url%" target="_blank">this article</a> before using the option.',
            Mage::helper('M2ePro/Module_Support')->getSupportUrl('/support/solutions/articles/9000200401')
        ); ?>
    </div>

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