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

// @codingStandardsIgnoreFile

/** @var $this Ess_M2ePro_Block_Adminhtml_Ebay_Listing_AutoAction_Mode_Category_Form */

$formData = array_merge($this->getDefault(), $this->getFormData());

?>

<script type="text/javascript">
    M2ePro.php.setConstants(<?php echo Mage::helper('M2ePro')->getClassConstantAsJson('Ess_M2ePro_Model_Listing'); ?>, 'Ess_M2ePro_Model_Listing');
    M2ePro.php.setConstants(<?php echo Mage::helper('M2ePro')->getClassConstantAsJson('Ess_M2ePro_Model_Ebay_Listing'); ?>, 'Ess_M2ePro_Model_Ebay_Listing');
</script>

<script type="text/javascript">

    ListingAutoActionObj.magentoCategoryIdsFromOtherGroups = <?php echo json_encode($this->getCategoriesFromOtherGroups()) ?>;

    $('adding_mode')
        .observe('change', ListingAutoActionObj.addingModeChange)
        .simulate('change');

    $('continue_button')
        .stopObserving('click')
        .observe('click', ListingAutoActionObj.categoryStepTwo);

    $('reset_button')
        .observe('click', function() {
            ListingAutoActionObj.reset(false);
        });

</script>

<style type="text/css">
    #category_tree_container:hover {
        overflow: auto;
    }

    #category_tree_container {
        float: left;
        width: 230px;
        max-height: 350px;
        overflow: hidden;
        border-right: 1px solid #e0e0e0;
    }

    #category_form_container {
        float: left;
        padding: 0 10px;
    }

    #magento_block_ebay_category_specific_item_specifics table tr.headings th {
        padding: 1px 4px 0 4px;
    }

    #magento_block_ebay_category_specific_item_specifics table tr.filter th, #magento_block_ebay_category_specific_item_specifics table td {
        padding: 5px;
    }

    #magento_block_ebay_category_specific_item_specifics td.label, #magento_block_ebay_category_specific_item_specifics td.label {
        width: 100px;
    }
</style>

<div id="data_container">

    <div id="category_tree_container">
        <?php echo $this->getChildHtml('category_tree') ?>
    </div>

    <div id="category_form_container">
        <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" />
            <input name="id" value="<?php echo $formData['id'] ?>" type="hidden" id="group_id" />
            <input name="auto_mode" value="<?php echo Ess_M2ePro_Model_Listing::AUTO_MODE_CATEGORY ?>" type="hidden" id="auto_mode" />

            <table class="form-list">
                <tr>
                    <td class="label">
                        <label for="group_title"><?php echo Mage::helper('M2ePro')->__('Title') ?>: <span class="required">*</span></label>
                    </td>
                    <td class="value">
                        <input type="group_title" name="title" id="group_title" class="input-text required-entry M2ePro-validate-category-group-title" value="<?php echo Mage::helper('M2ePro')->escapeHtml($formData['title']) ?>" style="padding: 2px 0; width: 275px;" />
                    </td>
                </tr>

                <tr>
                    <td class="label" style="width: 200px;">
                        <label for="adding_mode"><?php echo Mage::helper('M2ePro')->__('Product Assigned to Categories') ?>:</label>
                    </td>
                    <td class="value">
                        <select name="adding_mode" id="adding_mode" style="width: 275px;">
                            <option value="<?php echo Ess_M2ePro_Model_Listing::ADDING_MODE_NONE ?>" <?php if ($formData['adding_mode'] == Ess_M2ePro_Model_Listing::ADDING_MODE_NONE): ?>selected="selected"<?php endif; ?> ><?php echo Mage::helper('M2ePro')->__('No Action') ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Ebay_Listing::ADDING_MODE_ADD_AND_ASSIGN_CATEGORY ?>" <?php if ($formData['adding_mode'] == Ess_M2ePro_Model_Ebay_Listing::ADDING_MODE_ADD_AND_ASSIGN_CATEGORY): ?>selected="selected"<?php endif; ?> ><?php echo Mage::helper('M2ePro')->__('Add to the Listing and Assign eBay Category') ?></option>
                        </select>
                    </td>
                    <td class="value">
                        <img src="<?php echo $this->getSkinUrl('M2ePro/images/tool-tip-icon.png'); ?>" class="tool-tip-image">
                        <span class="tool-tip-message tip-left" style="left: 650px; display: none;">
                            <img src="<?php echo $this->getSkinUrl('M2ePro/images/help.png'); ?>">
                            <span><?php echo Mage::helper('M2ePro')->__('Action which will be applied automatically.'); ?></span>
                        </span>
                    </td>
                </tr>

                <tr id="adding_add_not_visible_field">
                    <td class="label" style="width: 200px;">
                        <label for="adding_add_not_visible"><?php echo Mage::helper('M2ePro')->__('Add not Visible Individually Products') ?>:</label>
                    </td>
                    <td class="value">
                        <select name="adding_add_not_visible" id="adding_add_not_visible" style="width: 275px;">
                            <option value="<?php echo Ess_M2ePro_Model_Listing::AUTO_ADDING_ADD_NOT_VISIBLE_NO ?>" <?php if ($formData['adding_add_not_visible'] == Ess_M2ePro_Model_Listing::AUTO_ADDING_ADD_NOT_VISIBLE_NO): ?>selected="selected"<?php endif; ?> ><?php echo Mage::helper('M2ePro')->__('No') ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Listing::AUTO_ADDING_ADD_NOT_VISIBLE_YES ?>" <?php if ($formData['adding_add_not_visible'] == Ess_M2ePro_Model_Listing::AUTO_ADDING_ADD_NOT_VISIBLE_YES): ?>selected="selected"<?php endif; ?> ><?php echo Mage::helper('M2ePro')->__('Yes') ?></option>
                        </select>
                    </td>
                    <td class="value">
                        <img src="<?php echo $this->getSkinUrl('M2ePro/images/tool-tip-icon.png'); ?>" class="tool-tip-image">
                    <span class="tool-tip-message" style="display: none;">
                        <img src="<?php echo $this->getSkinUrl('M2ePro/images/help.png'); ?>">
                        <span><?php echo Mage::helper('M2ePro')->__('
                            Set to <strong>Yes</strong> if you want the Magento Products with
                            Visibility \'Not visible Individually\' to be added to the Listing
                            Automatically.<br/>
                            If set to <strong>No</strong>, only Variation (i.e.
                            Parent) Magento Products will be added to the Listing Automatically,
                            excluding Child Products.
                        '); ?></span>
                    </span>
                    </td>
                </tr>

            </table>

            <div style="padding-top: 20px;"></div>

            <table class="form-list">
                <tr>
                    <td class="label" style="width: 200px;">
                        <label for=""><?php echo Mage::helper('M2ePro')->__('Product Deleted from Categories') ?>:</label>
                    </td>
                    <td class="value">
                        <select name="deleting_mode" id="deleting_mode" style="width: 275px;">
                            <option value="<?php echo Ess_M2ePro_Model_Listing::DELETING_MODE_NONE ?>" <?php if ($formData['deleting_mode'] == Ess_M2ePro_Model_Listing::DELETING_MODE_NONE): ?>selected="selected"<?php endif; ?> ><?php echo Mage::helper('M2ePro')->__('No Action') ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Listing::DELETING_MODE_STOP ?>" <?php if ($formData['deleting_mode'] == Ess_M2ePro_Model_Listing::DELETING_MODE_STOP): ?>selected="selected"<?php endif; ?> ><?php echo Mage::helper('M2ePro')->__('Stop on Channel') ?></option>
                            <option value="<?php echo Ess_M2ePro_Model_Listing::DELETING_MODE_STOP_REMOVE ?>" <?php if ($formData['deleting_mode'] == Ess_M2ePro_Model_Listing::DELETING_MODE_STOP_REMOVE): ?>selected="selected"<?php endif; ?> ><?php echo Mage::helper('M2ePro')->__('Stop on Channel and Delete from Listing') ?></option>
                        </select>
                    </td>
                    <td class="value">
                        <img src="<?php echo $this->getSkinUrl('M2ePro/images/tool-tip-icon.png'); ?>" class="tool-tip-image">
                        <span class="tool-tip-message tip-left" style="left: 650px; display: none;">
                            <img src="<?php echo $this->getSkinUrl('M2ePro/images/help.png'); ?>">
                            <span><?php echo Mage::helper('M2ePro')->__('Action which will be applied automatically.'); ?></span>
                        </span>
                    </td>
                </tr>
            </table>

        </form>
    </div>

</div>
<div id="ebay_category_chooser"></div>

<div>
    <input type="hidden" name="validate_category_selection" id="validate_category_selection" class="M2ePro-validate-category-selection" />
</div>

<div style="clear: both;"></div>

<div style="display: none;">
    <?php echo $this->getChildHtml('confirm') ?>
</div>

<div id="dialog_confirm_content" style="display: none;">
    <div style="margin: 10px; ">
        <?php echo Mage::helper('M2ePro')->__('This Category is already used in the Rule %s. If you press "Confirm" Button, Category will be removed from that Rule.') ?>
    </div>
</div>