From ff7b87b1505f8fbdee189eca771346d3654c38b4 Mon Sep 17 00:00:00 2001 From: Mihai Ardeleanu Date: Wed, 1 Apr 2020 21:18:40 +0300 Subject: [PATCH] MLC-246: Import module from BitBucket --- Block/Adminhtml/Xtea/Edit/Tab/Curier.php | 2 +- Block/Adminhtml/Xtea/EditAwb.php | 2 +- Model/Sources/Tariff.php | 46 +++++++++++++++---- composer.json | 6 +-- etc/module.xml | 2 +- .../ui_component/awb_fields_listing.xml | 2 +- 6 files changed, 44 insertions(+), 16 deletions(-) diff --git a/Block/Adminhtml/Xtea/Edit/Tab/Curier.php b/Block/Adminhtml/Xtea/Edit/Tab/Curier.php index 0830f8d..ff7241d 100644 --- a/Block/Adminhtml/Xtea/Edit/Tab/Curier.php +++ b/Block/Adminhtml/Xtea/Edit/Tab/Curier.php @@ -10,7 +10,7 @@ use Eadesigndev\Awb\Model\Sources\PaymentMethod; use Eadesigndev\Awb\Model\Sources\DeliveryPayment; use Eadesigndev\Awb\Model\Sources\Tariff; -use Eadesigndev\Awb\Model\Sources\PickupId; +use Eadesigndev\Urgent\Model\Sources\PickupId; use Eadesigndev\Awb\Model\Sources\InputType; use Magento\Backend\Block\Template\Context; use Magento\Backend\Block\Widget\Tab\TabInterface; diff --git a/Block/Adminhtml/Xtea/EditAwb.php b/Block/Adminhtml/Xtea/EditAwb.php index a3b8324..d5cf308 100644 --- a/Block/Adminhtml/Xtea/EditAwb.php +++ b/Block/Adminhtml/Xtea/EditAwb.php @@ -92,4 +92,4 @@ public function _construct() __('Delete Awb') ); } -} \ No newline at end of file +} diff --git a/Model/Sources/Tariff.php b/Model/Sources/Tariff.php index 67d3d68..40efd64 100644 --- a/Model/Sources/Tariff.php +++ b/Model/Sources/Tariff.php @@ -6,6 +6,8 @@ namespace Eadesigndev\Awb\Model\Sources; +use Eadesigndev\Urgent\Helper\ConnectUrgent; + /** * Class Tariff * @package Eadesigndev\Awb\ModelSource @@ -13,21 +15,47 @@ class Tariff extends AbstractSource { /** - * Tariff + * @var ConnectUrgent */ - const ACT = 84828; - const MKT = 64252; + private $connectUrgent; + + /** + * Tariff constructor. + * @param ConnectUrgent $connectUrgent + */ + public function __construct( + ConnectUrgent $connectUrgent + ) { + $this->connectUrgent = $connectUrgent; + } /** + * @param $array + * @param $key + * @param $value * @return array */ - public function getAvailable() + public function toOptionArrayReplaceList($array, $key, $value): ?array { - $tariffPlan = [ - self::ACT => __('Act Add 01.11.2018'), - self::MKT => __('Tarif MKT Place 5106'), - ]; + if (!empty($array)) { + $return = []; + foreach ($array as $element) { + $return[$element[$key]] = $element[$value]; + } + return $return; + } + } - return $tariffPlan; + /** + * @return array + */ + public function getAvailable(): array + { + $connectUrgent = $this->connectUrgent; + $tariffPlan = $connectUrgent->connect('PriceTables', \Zend_Http_Client::GET); + if ($tariffPlan != '"Failed to authenticate!"') { + return $this->toOptionArrayReplaceList($tariffPlan, 'PriceTableId', 'Name'); + } + return ['0'=> 'Failed to authenticate!']; } } diff --git a/composer.json b/composer.json index dc1fc71..b646773 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "eadesignro/awb", "description": "AWB module who manages parcel dispatches", "type": "magento2-module", - "version": "1.1.9", + "version": "1.1.11", "autoload": { "files": [ "registration.php" @@ -25,7 +25,7 @@ }, "require": { - "php": "~7.1.3|~7.2.0", + "php": "~7.1.3|~7.2.0|~7.3.0", "magento/module-backend": "101.0.*", "magento/module-sales": "102.0.*", "magento/framework": "102.0.*", @@ -42,4 +42,4 @@ }, "minimum-stability": "dev", "prefer-stable": true -} \ No newline at end of file +} diff --git a/etc/module.xml b/etc/module.xml index 41eb644..9d8cee3 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,5 +1,5 @@ - + diff --git a/view/adminhtml/ui_component/awb_fields_listing.xml b/view/adminhtml/ui_component/awb_fields_listing.xml index 086bca5..e5fb1a4 100644 --- a/view/adminhtml/ui_component/awb_fields_listing.xml +++ b/view/adminhtml/ui_component/awb_fields_listing.xml @@ -287,7 +287,7 @@ - Eadesigndev\Awb\Model\Sources\PickupId + Eadesigndev\Urgent\Model\Sources\PickupId select Magento_Ui/js/grid/columns/select