This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
68 changed files
with
4,240 additions
and
583 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<?php | ||
/** | ||
* | ||
* ..::.. | ||
* ..::::::::::::.. | ||
* ::'''''':''::''''':: | ||
* ::.. ..: : ....:: | ||
* :::: ::: : : :: | ||
* :::: ::: : ''' :: | ||
* ::::..:::..::.....:: | ||
* ''::::::::::::'' | ||
* ''::'' | ||
* | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Creative Commons License. | ||
* It is available through the world-wide-web at this URL: | ||
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US | ||
* If you are unable to obtain it through the world-wide-web, please send an email | ||
* to servicedesk@tig.nl so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. If you wish to customize this module for your | ||
* needs please contact servicedesk@tig.nl for more information. | ||
* | ||
* @copyright Copyright (c) Total Internet Group B.V. https://tig.nl/copyright | ||
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US | ||
*/ | ||
|
||
namespace TIG\GLS\Block\Adminhtml\Carrier\GLS; | ||
|
||
/** | ||
* This is a stripped version of \Magento\OfflineShipping\Block\Adminhtml\Carrier\Tablerate\Grid. | ||
* | ||
* Class Grid | ||
* @package TIG\GLS\Block\Adminhtml\Carrier\GLS | ||
* @version Magento 2.3.3 | ||
* @since 1.2.0 | ||
*/ | ||
class Grid extends \Magento\Backend\Block\Widget\Grid\Extended | ||
{ | ||
/** @var \TIG\GLS\Model\Carrier\GLS $glsCarrier */ | ||
private $glsCarrier; | ||
|
||
/** @var \TIG\GLS\Model\ResourceModel\Carrier\GLS\CollectionFactory */ | ||
private $collectionFactory; | ||
|
||
/** | ||
* Grid constructor. | ||
* | ||
* @param \Magento\Backend\Block\Template\Context $context | ||
* @param \Magento\Backend\Helper\Data $backendHelper | ||
* @param \TIG\GLS\Model\ResourceModel\Carrier\GLS\CollectionFactory $collectionFactory | ||
* @param \TIG\GLS\Model\Carrier\GLS $glsCarrier | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Magento\Backend\Helper\Data $backendHelper, | ||
\TIG\GLS\Model\ResourceModel\Carrier\GLS\CollectionFactory $collectionFactory, | ||
\TIG\GLS\Model\Carrier\GLS $glsCarrier, | ||
array $data = [] | ||
) { | ||
$this->collectionFactory = $collectionFactory; | ||
$this->glsCarrier = $glsCarrier; | ||
parent::__construct($context, $backendHelper, $data); | ||
} | ||
|
||
/** | ||
* Define grid properties | ||
* | ||
* @return void | ||
*/ | ||
// @codingStandardsIgnoreLine | ||
protected function _construct() | ||
{ | ||
parent::_construct(); | ||
$this->setId('glsShippingTablerateGrid'); | ||
$this->_exportPageSize = 10000; | ||
} | ||
|
||
/** | ||
* @return \Magento\Backend\Block\Widget\Grid\Extended | ||
*/ | ||
// @codingStandardsIgnoreLine | ||
protected function _prepareCollection() | ||
{ | ||
/** @var $collection \TIG\GLS\Model\ResourceModel\Carrier\GLS\Collection */ | ||
$collection = $this->collectionFactory->create(); | ||
|
||
$this->setCollection($collection); | ||
|
||
return parent::_prepareCollection(); | ||
} | ||
|
||
/** | ||
* @return \Magento\Backend\Block\Widget\Grid\Extended | ||
* @throws \Exception | ||
*/ | ||
// @codingStandardsIgnoreLine | ||
protected function _prepareColumns() | ||
{ | ||
$this->addColumn( | ||
'dest_country', | ||
[ | ||
// @codingStandardsIgnoreLine | ||
'header' => 'Country', | ||
'index' => 'dest_country', | ||
'default' => '*' | ||
] | ||
); | ||
|
||
$this->addColumn( | ||
'dest_region', | ||
[ | ||
'header' => 'Region/State', | ||
'index' => 'dest_region', | ||
'default' => '*' | ||
] | ||
); | ||
|
||
$this->addColumn( | ||
'dest_zip', | ||
[ | ||
'header' => 'Zip/Postal Code', | ||
'index' => 'dest_zip', | ||
'default' => '*' | ||
] | ||
); | ||
|
||
$this->addColumn( | ||
'price', | ||
[ | ||
'header' => 'Shipping Price', | ||
'index' => 'price' | ||
] | ||
); | ||
|
||
return parent::_prepareColumns(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
/** | ||
* | ||
* ..::.. | ||
* ..::::::::::::.. | ||
* ::'''''':''::''''':: | ||
* ::.. ..: : ....:: | ||
* :::: ::: : : :: | ||
* :::: ::: : ''' :: | ||
* ::::..:::..::.....:: | ||
* ''::::::::::::'' | ||
* ''::'' | ||
* | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Creative Commons License. | ||
* It is available through the world-wide-web at this URL: | ||
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US | ||
* If you are unable to obtain it through the world-wide-web, please send an email | ||
* to servicedesk@tig.nl so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. If you wish to customize this module for your | ||
* needs please contact servicedesk@tig.nl for more information. | ||
* | ||
* @copyright Copyright (c) Total Internet Group B.V. https://tig.nl/copyright | ||
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US | ||
*/ | ||
|
||
namespace TIG\GLS\Block\Adminhtml\Form\Field; | ||
|
||
class Export extends \Magento\Framework\Data\Form\Element\AbstractElement | ||
{ | ||
/** | ||
* @var \Magento\Backend\Model\UrlInterface | ||
*/ | ||
private $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\Model\UrlInterface $backendUrl | ||
* @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 */ | ||
// @codingStandardsIgnoreLine | ||
$buttonBlock = $this->getForm()->getParent()->getLayout()->createBlock( | ||
\Magento\Backend\Block\Widget\Button::class | ||
); | ||
// @codingStandardsIgnoreLine | ||
$params = ['website' => $buttonBlock->getRequest()->getParam('website')]; | ||
$url = $this->backendUrl->getUrl("*/*/exportGlsTablerates", $params); | ||
$data = [ | ||
'label' => __('Export CSV'), | ||
'onclick' => "setLocation('$url" . "gls_tablerates.csv')", | ||
'class' => '', | ||
]; | ||
$buttonBlock->setData($data); | ||
|
||
return $buttonBlock->toHtml(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* | ||
* ..::.. | ||
* ..::::::::::::.. | ||
* ::'''''':''::''''':: | ||
* ::.. ..: : ....:: | ||
* :::: ::: : : :: | ||
* :::: ::: : ''' :: | ||
* ::::..:::..::.....:: | ||
* ''::::::::::::'' | ||
* ''::'' | ||
* | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Creative Commons License. | ||
* It is available through the world-wide-web at this URL: | ||
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US | ||
* If you are unable to obtain it through the world-wide-web, please send an email | ||
* to servicedesk@tig.nl so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. If you wish to customize this module for your | ||
* needs please contact servicedesk@tig.nl for more information. | ||
* | ||
* @copyright Copyright (c) Total Internet Group B.V. https://tig.nl/copyright | ||
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US | ||
*/ | ||
|
||
namespace TIG\GLS\Block\Adminhtml\Form\Field; | ||
|
||
class Import extends \Magento\Framework\Data\Form\Element\AbstractElement | ||
{ | ||
/** | ||
* @return void | ||
*/ | ||
// @codingStandardsIgnoreLine | ||
protected function _construct() | ||
{ | ||
parent::_construct(); | ||
$this->setType('file'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
/** | ||
* | ||
* ..::.. | ||
* ..::::::::::::.. | ||
* ::'''''':''::''''':: | ||
* ::.. ..: : ....:: | ||
* :::: ::: : : :: | ||
* :::: ::: : ''' :: | ||
* ::::..:::..::.....:: | ||
* ''::::::::::::'' | ||
* ''::'' | ||
* | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Creative Commons License. | ||
* It is available through the world-wide-web at this URL: | ||
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US | ||
* If you are unable to obtain it through the world-wide-web, please send an email | ||
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. If you wish to customize this module for your | ||
* needs please contact servicedesk@tig.nl for more information. | ||
* | ||
* @copyright Copyright (c) Total Internet Group B.V. https://tig.nl/copyright | ||
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US | ||
*/ | ||
namespace TIG\GLS\Block\Adminhtml\Grid; | ||
|
||
use Magento\Ui\Component\Listing\Columns\Column; | ||
|
||
abstract class AbstractGrid extends Column | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
// @codingStandardsIgnoreLine | ||
protected $items = []; | ||
|
||
/** | ||
* @param array $dataSource | ||
* | ||
* @return array | ||
*/ | ||
public function prepareDataSource(array $dataSource) | ||
{ | ||
if (isset($dataSource['data']['items'])) { | ||
$this->items = $dataSource['data']['items']; | ||
|
||
$this->prepareData(); | ||
$this->handleItems(); | ||
|
||
$dataSource['data']['items'] = $this->items; | ||
} | ||
|
||
return $dataSource; | ||
} | ||
|
||
/** | ||
* Load all the needed data in only 1 query. | ||
*/ | ||
// @codingStandardsIgnoreLine | ||
protected function prepareData() | ||
{ | ||
return null; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
// @codingStandardsIgnoreLine | ||
protected function handleItems() | ||
{ | ||
foreach ($this->items as $index => $item) { | ||
$this->items[$index][$this->getName()] = $this->getCellContents($item); | ||
} | ||
} | ||
|
||
/** | ||
* @param object $item | ||
* | ||
* @return string | ||
*/ | ||
// @codingStandardsIgnoreLine | ||
abstract public function getCellContents($item); | ||
} |
Oops, something went wrong.