| Current Path : /home/rtorresani/www/app/code/WebShopApps/MatrixRate/Block/Adminhtml/Form/Field/ |
| Current File : //home/rtorresani/www/app/code/WebShopApps/MatrixRate/Block/Adminhtml/Form/Field/Export.php |
<?php
/**
* WebShopApps
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* WebShopApps MatrixRate
*
* @category WebShopApps
* @package WebShopApps_MatrixRate
* @copyright Copyright (c) 2014 Zowta LLC (http://www.WebShopApps.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author WebShopApps Team sales@webshopapps.com
*
*/
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace WebShopApps\MatrixRate\Block\Adminhtml\Form\Field;
/**
* Export CSV button for shipping table rates
*
* @author Magento Core Team <core@magentocommerce.com>
*/
class Export extends \Magento\Framework\Data\Form\Element\AbstractElement
{
/**
* @var \Magento\Backend\Model\UrlInterface
*/
protected $backendUrl;
/**
* @param \Magento\Framework\Data\Form\Element\Factory $factoryElement
* @param \Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection
* @param \Magento\Framework\Escaper $escaper
* @param \Magento\Backend\Helper\Data $helper
* @param array $data
*/
public function __construct(
\Magento\Framework\Data\Form\Element\Factory $factoryElement,
\Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection,
\Magento\Framework\Escaper $escaper,
\Magento\Backend\Model\UrlInterface $backendUrl,
array $data = []
) {
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
$this->backendUrl = $backendUrl;
}
/**
* @return string
*/
public function getElementHtml()
{
/** @var \Magento\Backend\Block\Widget\Button $buttonBlock */
$buttonBlock = $this->getForm()->getParent()->getLayout()->createBlock('Magento\Backend\Block\Widget\Button');
$params = ['website' => $buttonBlock->getRequest()->getParam('website')];
$url = $this->backendUrl->getUrl("shqmatrixrate/system/exportMatrixrates", $params);
$data = [
'label' => __('Export CSV'),
'onclick' => "setLocation('" .
$url .
"conditionName/' + $('carriers_matrixrate_condition_name').value)",
'class' => '',
];
$html = $buttonBlock->setData($data)->toHtml();
return $html;
}
}