<?xml version="1.0"?>
<!--
/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Advanced MSI for Magento 2
 */-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="advanced_msi" translate="label" showInDefault="1" showInWebsite="0" showInStore="0">
            <label>Advanced MSI</label>
            <tab>amasty</tab>
            <resource>Amasty_AdvancedMSI::config</resource>
            <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
                <label>General Settings</label>
                <field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Enable Module</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>
            </group>
            <group id="delivery" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
                <label>Minimal Delivery Cost Algorithm Settings</label>
                <field id="default_algorithm" translate="label comment tooltip" type="select" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Default Source Selection Algorithm</label>
                    <source_model>Amasty\AdvancedMSI\Model\Config\AvailableSourceList</source_model>
                    <comment>The selected algorithm will be immediately applied to the ordered items on the shipment creation page or while creating an order by a customer if the below setting 'Enable Automatic Source Selection' is set to YES.</comment>
                    <tooltip>Please provide google API key in order to enable distance priority algorithm. The setting is located at Stores->Configuration->Catalog->Inventory->Google Distance Provider</tooltip>
                </field>
                <field id="combined_value" translate="label tooltip" type="text" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Criteria Prioritization for Combined Algorithm</label>
                    <frontend_model>Amasty\AdvancedMSI\Block\Adminhtml\System\Config\Field\CombinedAlgorithmPriority</frontend_model>
                    <backend_model>Magento\Config\Model\Config\Backend\Serialized\ArraySerialized</backend_model>
                    <frontend_class>dispatch</frontend_class>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <tooltip>The algorithm will apply the upper criteria first. If the result consists of several sources that fit the condition of the first criteria, the list of these several warehouses will be transferred to the next lower criteria for processing. The sources that don't fit the first criteria will not be processed by the second one. But they will be available on the shipment creation page with lower priority.</tooltip>
                    <depends>
                        <field id="default_algorithm">combined</field>
                    </depends>
                </field>
                <field id="round_distance" translate="label comment" type="text" sortOrder="50" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Distance to Warehouse Round off, Km</label>
                    <validate>validate-number validate-zero-or-greater</validate>
                    <comment>The round off will be used in the Amasty Combined Source Selection Algorithm. If the distance between the closest and other warehouses is less than the value, the warehouses are considered to be equally distant from the customer.</comment>
                    <depends>
                        <field id="default_algorithm">combined</field>
                    </depends>
                </field>
            </group>
            <group id="shipping" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
                <label>Automatic Source Selection &amp; Shipping Cost Calculating</label>
                <field id="shipping_address_depend" translate="label tooltip" type="select" sortOrder="70" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Enable Automatic Source Selection</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <tooltip><![CDATA[
                        This option allows using shipping services (like UPS, USPS, FedEx, DHL) with Multi-Source Inventory. The origin sources
                        will be chosen during order creation, and a customer will be charged for the shipping costs immediately on the checkout page. Shipping costs will be calculated for each source (warehouse) depending on its address and then summarized.<br>
                        Please note, that Shipping(s) for an order will be created immediately after a click on 'Ship' button on the order details page in the admin area.
                        ]]>
                    </tooltip>
                </field>
            </group>
            <group id="email_notifications" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
                <label>Email Notifications</label>
                <field id="low_stock" translate="label" type="select" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
                    <label>Low Stock Notification Template</label>
                    <source_model>Amasty\AdvancedMSI\Model\Config\Source\Email\Template</source_model>
                </field>
                <field id="shipment" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
                    <label>Shipment Email Notification Template</label>
                    <source_model>Amasty\AdvancedMSI\Model\Config\Source\Email\Template</source_model>
                </field>
            </group>
        </section>
    </system>
</config>
