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

// @codingStandardsIgnoreFile

/** @var $this Ess_M2ePro_Block_Adminhtml_Amazon_Synchronization_Edit_Form */

$translations = array();

$text = 'Synchronization Settings have been saved.';
$translations[$text] = Mage::helper('M2ePro')->__($text);

$translations = json_encode($translations);

?>

    <script type="text/javascript">

        M2ePro.url.add(<?php echo json_encode(array(
            'formSubmit' => $this->getUrl('M2ePro/adminhtml_amazon_synchronization/save')
        )); ?>);

        M2ePro.translator.add(<?php echo $translations; ?>);

        Event.observe(window, 'load', function() {
            setTimeout(function() {
                SynchronizationObj = new Synchronization();
                editForm = new varienForm('edit_form', '<?php echo $this->getValidationUrl(); ?>');
            }, 350);
        });

    </script>

    <form id="<?php echo $this->getForm()->getId(); ?>" action="<?php echo $this->getForm()->getData('action'); ?>" method="post" enctype="multipart/form-data">

        <div id="<?php echo $this->getContainerId(); ?>">

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

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

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

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

                            <tr>
                                <td class="label">
                                    <label for="amazon_instructions_mode"><?php echo Mage::helper('M2ePro')->__('Enabled'); ?>:</label>
                                </td>
                                <td class="value">
                                    <?php $instructions_mode = $this->instructionsMode ? $this->instructionsMode : 0; ?>
                                    <select id="amazon_instructions_mode" name="amazon_instructions_mode">
                                        <option value="0"<?php if (0 == $instructions_mode) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                                        <option value="1"<?php if (1 == $instructions_mode) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                                    </select>
                                    <p class="note">
                                        <span><?php echo Mage::helper('M2ePro')->__('Enable to automatically update Amazon Listings based on Synchronization Rules'); ?></span>
                                    </p>
                                </td>
                            </tr>

                        </table>

                        <div style="padding: 12px"></div>

                    </div>
                </div>

            </div>

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

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

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

                        <div class="block_notices_module" style="border: 0 !important; margin-bottom: 0 !important;" title="" subtitle="" collapseable="no" hideblock="no" always_show="yes">
                            <?php echo Mage::helper('M2ePro')->__('
                        If you update Magento Product Information not via Magento backend and Standard Magento Model functionality
                        (e.g. direct SQL injections or Custom Code that does not support a Magento Core Models), you can use
                        predefined <strong>M2E Pro Models</strong> to notify Extension about Product changes.<br/>
                        More detailed information you can find <a href="%url1%" target="_blank">here</a><br/><br/>

                        If you use Magmi Import Tool to update Magento Product Information, it is required to set up a predefined
                        <strong>M2E Pro Plug-in for Magmi Import Tool</strong> to notify Extension about Product Changes.<br/>
                        More detailed information you can find <a href="%url2%" target="_blank">here</a><br/><br/>

                        It is <strong>highly recommended</strong> to use one of the options above to decrease the impact on M2E Pro performance.',
                                Mage::helper('M2ePro/Module_Support')->getSupportUrl('/support/solutions/articles/9000228198'),
                                Mage::helper('M2ePro/Module_Support')->getSupportUrl('/support/solutions/articles/9000228208')
                            ) ?>
                        </div>

                        <div id="block_notice_amazon_synchronization_stock_level" class="block_notices_module" style="border: 0 !important; margin-bottom: 0 !important;" title="" subtitle="" collapseable="no" hideblock="no" always_show="yes">
                            <?php $inspectorMode = ($this->inspectorMode == 1)?'<span style="color: green"> (enabled) </span>':''; ?>
                            <?php echo Mage::helper('M2ePro')->__('
                                Alternatively, you can enable
                                <a target="_blank" href="%url%#magento_block_configuration_settings_advanced">\'Track Direct Database Changes\'</a>
                                %mode_status% to detect Product changes.<br/><br/>

                                <strong>Important note:</strong> the tracking of direct Database changes is resource-consuming and may affect the performance
                                of your Magento Site and Synchronization with Channels. Set \'Yes\' only in case of extreme necessity
                                when the use of other predefined M2E Pro Models is impossible for some reasons.',
                                Mage::helper('M2ePro/View_Configuration')->getSettingsUrl(),
                                $inspectorMode
                            ) ?>
                        </div>

                    </div>
                </div>

            </div>

        </div>

    </form>
