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

// @codingStandardsIgnoreFile

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

<script type="text/javascript">

    // General for all tabs
    //-----------------------------
    M2ePro.url.add(<?php echo json_encode(Mage::helper('M2ePro')->getControllerActions('adminhtml_configuration_settings')) ?>);

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

    M2ePro.translator.add(<?php echo json_encode(array(
        'Help Blocks have been restored.' => Mage::helper('M2ePro')->__('Help Blocks have been restored.'),
    )); ?>);

    Event.observe(window, 'load', function() {
        SettingsObj = new ConfigurationSettings();

        //------------------------------

        $('product_force_qty_mode').simulate('change');

        //------------------------------

        configEditForm = new varienForm('config_edit_form', '<?php echo $this->getValidationUrl(); ?>');
    });
    //-----------------------------

</script>

<style>
    .columns .form-list td.value {
        width: 280px;
    }
</style>

<div id="block_notice_configuration_settings" class="block_notices_module" title="<?php echo Mage::helper('M2ePro')->__('General'); ?>">
    <p><?php echo Mage::helper('M2ePro')->__('
                Here you can provide global settings for the Module Interface, Inventory, Price, and Variational Product management. 
                Recommendations for the tracking direct database changes can also be found below.
                Read the <a href="%url%" target="_blank">article</a> for more details.<br><br>
                Click <strong>Save Config</strong> if you make any changes.',
            Mage::helper('M2ePro/Module_Support')->getDocumentationUrl(null, null, 'global-settings')
        ); ?></p>
</div>

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

    <input name="form_key" value="<?php echo $this->getFormKey(); ?>" type="hidden" />

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

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

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

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

                    <colgroup class="label"></colgroup>
                    <colgroup class="value"></colgroup>

                    <tbody>

                    <tr>
                        <td class="label">
                            <label for="view_show_products_thumbnails_mode"><?php echo Mage::helper('M2ePro')->__('Products Thumbnails'); ?>: </label>
                        </td>
                        <td class="value">
                            <select id="view_show_products_thumbnails_mode" name="view_show_products_thumbnails_mode" class="required-entry">
                                <option value="0" <?php if (!$this->getConfigurationHelper()->getViewShowProductsThumbnailsMode()): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Do Not Show'); ?></option>
                                <option value="1" <?php if ($this->getConfigurationHelper()->getViewShowProductsThumbnailsMode()): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Show'); ?></option>
                            </select>
                            <p class="note">
                                <span><?php echo Mage::helper('M2ePro')->__('Choose whether you want to see Thumbnail Images for Products on the Add Products and View Listing Pages.'); ?></span>
                            </p>
                        </td>
                    </tr>

                    <tr>
                        <td class="label">
                            <label for="view_show_block_notices_mode"><?php echo Mage::helper('M2ePro')->__('Help Blocks'); ?>: </label>
                        </td>
                        <td class="value">
                            <select id="view_show_block_notices_mode" name="view_show_block_notices_mode" class="required-entry">
                                <option value="0" <?php if (!$this->getConfigurationHelper()->getViewShowBlockNoticesMode()): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Do Not Show'); ?></option>
                                <option value="1" <?php if ($this->getConfigurationHelper()->getViewShowBlockNoticesMode()): echo ' selected="selected"'; endif; ?>><?php echo Mage::helper('M2ePro')->__('Show'); ?></option>
                            </select>
                            <p class="note">
                                <span><?php echo Mage::helper('M2ePro')->__('Choose whether you want the help at the top of each M2E Pro Page to be available.'); ?></span>
                            </p>
                        </td>
                    </tr>

                    <tr id="restore_block_notices_tr">
                        <td class="label"></td>
                        <td class="value">
                            <?php echo $this->getChildHtml('restore_block_notices'); ?>
                            <p class="note">
                                <span><?php echo Mage::helper('M2ePro')->__(
                                    'Restores manually closed help blocks and resets previously remembered choices.<br /><br />
                                     <strong>Note:</strong> after the button is pressed, all ‘Remember my choice’ settings will be discarded.'
                                ); ?></span>
                            </p>
                        </td>
                    </tr>

                    </tbody>

                </table>

            </div>
        </div>

    </div>

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

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

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

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

                    <tbody>

                    <tr>
                        <td class="label">
                            <label for="product_force_qty_mode"><?php echo Mage::helper('M2ePro')->__('Manage Stock "No", Backorders'); ?>: </label>
                        </td>
                        <td class="value" colspan="2">
                            <select id="product_force_qty_mode" name="product_force_qty_mode" onchange="SettingsObj.changeForceQtyMode();">
                                <option value="0"<?php if (!$this->getConfigurationHelper()->isEnableProductForceQtyMode()) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Disallow'); ?></option>
                                <option value="1"<?php if ($this->getConfigurationHelper()->isEnableProductForceQtyMode()) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Allow'); ?></option>
                            </select>
                            <p class="note">
                                <span><?php echo Mage::helper('M2ePro')->__(
                                    'Choose whether M2E Pro is allowed to List Products with unlimited stock or that are temporarily out of stock.<br>
                                    <strong>Disallow</strong> is the recommended setting for eBay Integration.'
                                ); ?></span>
                            </p>
                        </td>
                    </tr>

                    <tr id="product_force_qty_value_tr">
                        <td class="label">
                            <label for="product_force_qty_value"><?php echo Mage::helper('M2ePro')->__('Quantity To Be Listed'); ?>: </label>
                        </td>
                        <td class="value" colspan="2">
                            <input id="product_force_qty_value" name="product_force_qty_value" value="<?php echo $this->getConfigurationHelper()->getProductForceQtyValue(); ?>" type="text" class="M2ePro-required-when-visible input-text validate-greater-than-zero" />
                            <p class="note">
                                <span><?php echo Mage::helper('M2ePro')->__('Set a number to List, e.g. if you have Manage Stock "No" in Magento Product and set this Value to 10, 10 will be sent as available Quantity to the Channel.'); ?></span>
                            </p>
                        </td>
                    </tr>

                    <tr>
                        <td class="label">
                            <label for="magento_attribute_price_type_converting_mode"><?php echo Mage::helper('M2ePro')->__('Convert Magento Price Attribute'); ?>: </label>
                        </td>
                        <td class="value" colspan="2">
                            <select id="magento_attribute_price_type_converting_mode" name="magento_attribute_price_type_converting_mode">
                                <option value="0"<?php if (!$this->getConfigurationHelper()->isEnableMagentoAttributePriceTypeConvertingMode()) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                                <option value="1"<?php if ($this->getConfigurationHelper()->isEnableMagentoAttributePriceTypeConvertingMode()) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                            </select>
                            <p class="note">
                                <span><?php echo Mage::helper('M2ePro')->__(
                                        'Choose whether Magento Price Attribute values should be converted automatically.
                                    With this option enabled, M2E Pro will provide currency conversion based on Magento Currency Settings.<br><br>
                                    <strong>For example</strong>, the Item Price is set to be taken from Magento Price Attribute (e.g. 5 USD).
                                    If this Item is listed on Marketplace with a different Base Currency (e.g. GBP), the currency conversion is performed
                                    automatically based on the set exchange rate (e.g. 1 USD = 0.82 GBP).
                                    The Item will be available on Channel at the Price of 4.1 GBP.'
                                    ); ?></span>
                            </p>
                        </td>
                    </tr>

                    </tbody>

                </table>

            </div>
        </div>

    </div>

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

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

        <div class="fieldset">
            <div class="hor-scroll">
                <table class="form-list" cellspacing="0" cellpadding="0">
                    <tr>
                        <td class="label">
                            <label for="grouped_product_mode"><?php echo Mage::helper('M2ePro')->__('List Grouped Product as'); ?>: </label>
                        </td>
                        <td class="value">

                            <select id="grouped_product_mode" name="grouped_product_mode">
                                <option value="<?php echo Ess_M2ePro_Model_Listing_Product::GROUPED_PRODUCT_MODE_SET ?>" <?php if ($this->getConfigurationHelper()->isGroupedProductModeSet()) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Product Set'); ?></option>
                                <option value="<?php echo Ess_M2ePro_Model_Listing_Product::GROUPED_PRODUCT_MODE_OPTIONS ?>" <?php if ($this->getConfigurationHelper()->isGroupedProductModeOptions()) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Variations'); ?></option>
                            </select>

                            <p class="note">
                                <span>
                                    <?php echo Mage::helper('M2ePro')->__('
                                        <b>Product Set</b> - a group of products will be listed as a Set (Individual Item). Customers can purchase products only as a set. Read the <a href="%url%" target="_blank">article</a> for details.
                                        <b>Variations</b> - a group of products will be listed as a Variational Item. Customers can purchase each option of Variational Product separately.
                                    ', Mage::helper('M2ePro/Module_Support')->getSupportUrl('/support/solutions/articles/9000218437')); ?>
                                </span>
                            </p>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>

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

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

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

                <div id="block_notice_configuration_advanced_settings" class="block_notices_module no-icon" title="<?php echo Mage::helper('M2ePro')->__('Direct Database Changes'); ?>">
                    <?php echo Mage::helper('M2ePro')->__(
                    'If you update Magento Product information over the Magento Core Models (e.g. direct SQL injections), use one of the options below to make M2E Pro detect these changes:
                    <ul class="list">
                        <li><i>M2E Pro Models</i> (Object or Structural Methods). Read the <a href="%url%" target="_blank">article</a> for more information.</li>
                        <li><i>M2E Pro plug-in</i> for the Magmi Import tool. Learn the details <a href="%url2%" target="_blank">here</a>.</li>
                        <li><i>Track Direct Database Changes.</i><strong> Please note</strong>  that this option is resource-consuming and may affect the performance of your Magento site and synchronization with Channels.</li>
                    </ul>',
                    Mage::helper('M2ePro/Module_Support')->getSupportUrl('/support/solutions/articles/9000228198'),
                    Mage::helper('M2ePro/Module_Support')->getSupportUrl('/support/solutions/articles/9000228208')
                    ); ?>
                </div>

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

                    <tbody>

                        <tr>
                            <td class="label">
                                <label for="listing_product_inspector_mode"><?php echo Mage::helper('M2ePro')->__('Track Direct Database Changes'); ?>: </label>
                            </td>
                            <td class="value" colspan="2">
                                <select id="listing_product_inspector_mode" name="listing_product_inspector_mode">
                                    <option value="0"<?php if (!$this->getConfigurationHelper()->isEnableListingProductInspectorMode()) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('No'); ?></option>
                                    <option value="1"<?php if ($this->getConfigurationHelper()->isEnableListingProductInspectorMode()) echo ' selected="selected"'; ?>><?php echo Mage::helper('M2ePro')->__('Yes'); ?></option>
                                </select>
                                <p class="note">
                                    <span><?php echo Mage::helper('M2ePro')->__("<b>Note:</b> Enable this Option if you really need it, as it is very resource and time consuming and may affect Synchronization Performance."); ?></span>
                                </p>
                            </td>
                        </tr>

                    </tbody>

                </table>

            </div>
        </div>

    </div>

</form>