Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tig-robertgrundeken committed Dec 12, 2019
2 parents 7a2acb3 + d19b0e8 commit 095f705
Show file tree
Hide file tree
Showing 68 changed files with 4,240 additions and 583 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ matrix:
# PHP 7.2 is only supported in Magento 2.3.x
include:
- php: 7.1
env: MAGENTO_VERSION=2.2.9
env: MAGENTO_VERSION=2.2.10
- php: 7.1
env: MAGENTO_VERSION=2.3.1
- php: 7.1
env: MAGENTO_VERSION=2.3.2 # DI_COMPILE=true
- php: 7.2
env: MAGENTO_VERSION=2.3.2 CODE_COVERAGE=true
env: MAGENTO_VERSION=2.3.3 CODE_COVERAGE=true

before_script:
- export PATH=$PATH:$HOME/.composer/vendor/bin
Expand Down
4 changes: 2 additions & 2 deletions Api/Shipment/LabelRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
interface LabelRepositoryInterface
{
/**
* @param int $id
* @param int $entityId
*
* @return \TIG\GLS\Api\Shipment\Data\LabelInterface;
*/
public function getById($id);
public function getById($entityId);

/**
* @param int $shipmentId
Expand Down
144 changes: 144 additions & 0 deletions Block/Adminhtml/Carrier/GLS/Grid.php
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();
}
}
82 changes: 82 additions & 0 deletions Block/Adminhtml/Form/Field/Export.php
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();
}
}
46 changes: 46 additions & 0 deletions Block/Adminhtml/Form/Field/Import.php
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');
}
}
90 changes: 90 additions & 0 deletions Block/Adminhtml/Grid/AbstractGrid.php
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);
}
Loading

0 comments on commit 095f705

Please sign in to comment.