<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="locationSec" translate="label" sortOrder="401" class="location-extension">
<label>Location Availability</label>
</tab>
<section id="locationSec" translate="label" type="text" sortOrder="8887" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Pin Code Management</label>
<tab>locationSec</tab>
<resource>Codilar_LocationAvailability::configuration</resource>
<group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Location Availability</label>
<field id="notice_enable1" translate="label comment" type="select" sortOrder="11" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Location Configuration</label>
<source_model>Codilar\LocationAvailability\Model\Config\Source\AvailConf</source_model>
<comment>Select Option to Configure.</comment>
</field>
<field id="custom_file_upload" translate="label" type="Magento\Config\Block\System\Config\Form\Field\File" sortOrder="13" showInDefault="1" showInWebsite="1" >
<label>Upload ZipCode</label>
<backend_model>Codilar\LocationAvailability\Model\Config\Backend\CustomFileType</backend_model>
<upload_dir config="system" scope_info="1">test</upload_dir>
<comment>Select categories that you want to receive notifications</comment>
<depends>
<field id="notice_enable1">2</field>
</depends>
<comment>Upload CSV.</comment>
</field>
<field id="zipCodeDelete" translate="label" type="Magento\Config\Block\System\Config\Form\Field\File" sortOrder="13" showInDefault="1" showInWebsite="1" >
<label>Remove ZipCode</label>
<backend_model>Codilar\LocationAvailability\Model\Config\Backend\RemoveZipCode</backend_model>
<upload_dir config="system" scope_info="1">test</upload_dir>
<comment>Select categories that you want to receive notifications</comment>
<depends>
<field id="notice_enable1">2</field>
</depends>
<comment>Remove ZipCodes.</comment>
</field>
<field id="download" translate="label" type="Magento\Config\Block\System\Config\Form\Field\File" sortOrder="13" showInDefault="1" showInWebsite="1" >
<label>Export ZipCode</label>
<backend_model>Codilar\LocationAvailability\Model\Config\Backend\RemoveZipCode</backend_model>
<upload_dir config="system" scope_info="1">test</upload_dir>
<comment>Select categories that you want to receive notifications</comment>
<depends>
<field id="notice_enable1">2</field>
</depends>
<comment>Remove ZipCodes.</comment>
</field> <field id="mageworx_collect" translate="label comment" type="button" sortOrder="13" showInDefault="1" showInWebsite="1" showInStore="0">
<frontend_model>Codilar\LocationAvailability\Block\Collect</frontend_model>
<label>Export</label>
</field>
</group>
</section>
</system>
</config>
<?xml version="1.0"?>
<!---Default Value Setting--->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<locationSec>
<general>
<notice_enable1>1</notice_enable1>
<notice_type>disable,use_attribute,use_csv</notice_type>
<menu>0</menu>
</general>
</locationSec>
</default>
</config>
<?php
use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
class Collect extends Field
{
/**
* @var string
*/
protected $_template = 'Codilar_LocationAvailability::system/config/collect.phtml';
/**
* @param Context $context
* @param array $data
*/
public function __construct(
Context $context,
array $data = []
) {
parent::__construct($context, $data);
}
/**
* Remove scope label
*
* @param AbstractElement $element
* @return string
*/
public function render(AbstractElement $element)
{
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
return parent::render($element);
}
/**
* Return element html
*
* @param AbstractElement $element
* @return string
*/
protected function _getElementHtml(AbstractElement $element)
{
return $this->_toHtml();
}
/**
* Return ajax url for collect button
*
* @return string
*/
public function getAjaxUrl()
{
return $this->getUrl('zipcode/export/index');
}
/**
* Generate collect button html
*
* @return string
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getButtonHtml()
{
$button = $this->getLayout()->createBlock(
'Magento\Backend\Block\Widget\Button'
)->setData(
[
'id' => 'collect_button',
'label' => __('Download'),
'href' => 'www.google.com',
]
);
return $button->toHtml();
}
}