Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions .github/workflows/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,31 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Cache vendor folder
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}

- name: Cache composer folder
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: php-composer-cache

- run: composer install
- run: composer install --no-interaction --prefer-source

- name: Run auto indexing
run: php vendor/bin/autoindex

- uses: stefanzweifel/git-auto-commit-action@v4
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Adding auto indexes

Expand All @@ -36,26 +41,30 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Cache vendor folder
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}

- name: Cache composer folder
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: php-composer-cache

- run: composer install
- run: composer install --no-interaction --prefer-source

- name: Adding licenses
run: vendor/bin/header-stamp --license=assets/afl.txt --exclude=vendor,node_modules

- uses: stefanzweifel/git-auto-commit-action@v4
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Automatic license addition applying

4 changes: 4 additions & 0 deletions config/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,15 @@ services:
- '@invertus.dpdbaltics_api.factory.apirequest.collection_request_factory'
- '@dpdbaltics'

invertus.dpdbaltics.service.api.parser.courier_request_response_parser:
class: 'Invertus\dpdBaltics\Service\API\Parser\CourierRequestResponseParser'

invertus.dpdbaltics.service.api.courier_request_service:
class: 'Invertus\dpdBaltics\Service\API\CourierRequestService'
arguments:
- '@invertus.dpdbaltics_api.factory.apirequest.courier_request_factory'
- '@dpdbaltics'
- '@invertus.dpdbaltics.service.api.parser.courier_request_response_parser'

invertus.dpdbaltics.service.parcel.parcel_update_service:
class: 'Invertus\dpdBaltics\Service\Parcel\ParcelUpdateService'
Expand Down
63 changes: 54 additions & 9 deletions controllers/admin/AdminDPDBalticsCourierRequestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Invertus\dpdBaltics\Repository\PhonePrefixRepository;
use Invertus\dpdBaltics\Service\API\CourierRequestService;
use Invertus\dpdBaltics\Service\Exception\ExceptionService;
use Invertus\dpdBaltics\Util\PickupTimeSlotUtility;
use Invertus\dpdBaltics\Util\TimeZoneUtility;
use Invertus\dpdBaltics\Validate\CourierRequest\CourierRequestValidator;
use Invertus\dpdBalticsApi\Exception\DPDBalticsAPIException;
Expand Down Expand Up @@ -156,16 +157,35 @@ private function initForm()
'required' => true,
],
[
'label' => $this->l('Desired pick-up time'),
'name' => 'pick_up_time',
'type' => 'datetime',
'label' => $this->l('Pick-up date'),
'name' => 'pick_up_date',
'type' => 'date',
'required' => true,
],
[
'label' => $this->l('Last pick-up time'),
'name' => 'sender_work_until',
'type' => 'datetime',
'label' => $this->l('Pick-up time from'),
'name' => 'pick_up_time_from',
'type' => 'select',
'class' => 'fixed-width-xxl',
'required' => true,
'desc' => $this->l('Only these time slots are accepted by DPD.'),
'options' => [
'id' => 'id',
'name' => 'name',
'query' => $this->getPickupTimeSlotOptions(PickupTimeSlotUtility::getPickupTimeFromSlots()),
],
],
[
'label' => $this->l('Pick-up time until'),
'name' => 'pick_up_time_to',
'type' => 'select',
'class' => 'fixed-width-xxl',
'required' => true,
'options' => [
'id' => 'id',
'name' => 'name',
'query' => $this->getPickupTimeSlotOptions(PickupTimeSlotUtility::getPickupTimeToSlots()),
],
],
[
'label' => $this->l('Weight'),
Expand Down Expand Up @@ -247,9 +267,11 @@ private function initForm()
$phoneData['sender_phone_code_list']
);

if (!Tools::getValue('pick_up_time') && !Tools::getValue('sender_work_until')) {
$this->fields_value['pick_up_time'] = TimeZoneUtility::getCourierDefaultPickUpTime();
$this->fields_value['sender_work_until'] = TimeZoneUtility::getCourierDefaultWorkUntil();
if (!Tools::getValue('pick_up_date')) {
$defaultPickUpSlot = TimeZoneUtility::getCourierDefaultPickUpSlot();
$this->fields_value['pick_up_date'] = $defaultPickUpSlot['date'];
$this->fields_value['pick_up_time_from'] = $defaultPickUpSlot['from'];
$this->fields_value['pick_up_time_to'] = $defaultPickUpSlot['to'];
}
if (!Tools::getValue('order_nr')) {
$this->fields_value['order_nr'] = (new DateTime())->getTimestamp();
Expand Down Expand Up @@ -311,6 +333,16 @@ public function setMedia($isNewTheme = false)
$this->addCSS($this->module->getPathUri() . 'views/css/admin/courier_request.css');
}

private function getPickupTimeSlotOptions(array $slots)
{
$options = [];
foreach ($slots as $slot) {
$options[] = ['id' => $slot, 'name' => $slot];
}

return $options;
}

private function renderPrefillSelect($prefix)
{
/** @var AddressRepository $addressRepository */
Expand All @@ -333,11 +365,24 @@ public function postProcess()
/** @var CourierRequestValidator $courierRequestValidator */
$formDataConverter = $this->module->getModuleContainer('invertus.dpdbaltics.converter.form_data_converter');
$courierRequestValidator = $this->module->getModuleContainer('invertus.dpdbaltics.validate.courier_request.courier_request_validator');

$_POST['pick_up_time'] = Tools::getValue('pick_up_date') . ' ' . Tools::getValue('pick_up_time_from') . ':00';
$_POST['sender_work_until'] = Tools::getValue('pick_up_date') . ' ' . Tools::getValue('pick_up_time_to') . ':00';

$data = Tools::getAllValues();

/** @var CourierRequestData $courierRequestObj */
$courierRequestObj = $formDataConverter->convertCourierRequestFormDataToCourierRequestObj($data);

if (!$courierRequestValidator->validatePickupTimeSlots($courierRequestObj)) {
$this->errors[] = sprintf(
$this->l('Pick-up time must use the time slots DPD accepts. "From" slots: %s. "Until" slots: %s.'),
implode(', ', PickupTimeSlotUtility::getPickupTimeFromSlots()),
implode(', ', PickupTimeSlotUtility::getPickupTimeToSlots())
);
return parent::postProcess();
}

$countryIso = Configuration::get(Config::WEB_SERVICE_COUNTRY);
if (!$courierRequestValidator->validate($courierRequestObj, $countryIso)) {
$this->errors[] = sprintf(
Expand Down
7 changes: 7 additions & 0 deletions src/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ class Config
const COURIER_SAME_DAY_TIME_LIMITATION = '15:00';
const COURIER_SAME_DAY_TIME_ADDITIONAL_MINUTES = '30';

const COURIER_PICKUP_TIME_FROM_SLOTS = [
'08:00', '09:00', '10:00', '11:00', '12:00', '12:30', '13:00', '13:30', '14:00', '14:30', '15:00',
];
const COURIER_PICKUP_TIME_TO_SLOTS = ['15:00', '16:00', '17:00', '18:00'];
const COURIER_DEFAULT_PICKUP_TIME_FROM_SLOT = '08:00';
const COURIER_DEFAULT_PICKUP_TIME_TO_SLOT = '17:00';

const SAME_DAY_DELIVERY_CITY = 'Rīga';
const DOCUMENT_RETURN_CODE = '-DOCRET';

Expand Down
63 changes: 63 additions & 0 deletions src/DTO/CourierRequestData.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@ class CourierRequestData
*/
private $pickupTime;

/**
* @var string
*/
private $pickupDate;

/**
* @var string
*/
private $pickupTimeFrom;

/**
* @var string
*/
private $pickupTimeTo;

/**
* @var string
*/
Expand Down Expand Up @@ -338,6 +353,54 @@ public function setPickupTime($pickupTime)
$this->pickupTime = $pickupTime;
}

/**
* @return string
*/
public function getPickupDate()
{
return $this->pickupDate;
}

/**
* @param string $pickupDate
*/
public function setPickupDate($pickupDate)
{
$this->pickupDate = $pickupDate;
}

/**
* @return string
*/
public function getPickupTimeFrom()
{
return $this->pickupTimeFrom;
}

/**
* @param string $pickupTimeFrom
*/
public function setPickupTimeFrom($pickupTimeFrom)
{
$this->pickupTimeFrom = $pickupTimeFrom;
}

/**
* @return string
*/
public function getPickupTimeTo()
{
return $this->pickupTimeTo;
}

/**
* @param string $pickupTimeTo
*/
public function setPickupTimeTo($pickupTimeTo)
{
$this->pickupTimeTo = $pickupTimeTo;
}

/**
* @return string
*/
Expand Down
19 changes: 19 additions & 0 deletions src/Infrastructure/Adapter/ModuleFactory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/


namespace Invertus\dpdBaltics\Infrastructure\Adapter;

Expand Down
19 changes: 19 additions & 0 deletions src/Infrastructure/Bootstrap/Install/Installer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/


namespace Invertus\dpdBaltics\Infrastructure\Bootstrap\Install;

Expand Down
19 changes: 19 additions & 0 deletions src/Infrastructure/Bootstrap/ModuleTabs.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/


namespace Invertus\dpdBaltics\Infrastructure\Bootstrap;

Expand Down
Loading