diff --git a/src/Constant.php b/src/Constant.php index 7ff9be96..651bf252 100755 --- a/src/Constant.php +++ b/src/Constant.php @@ -186,6 +186,7 @@ class Constant public const EXCLUSIVE_FIELDS_NL = [ self::SENT_ORDER_STATE_FOR_DIGITAL_STAMPS_CONFIGURATION_NAME, + self::SHARE_CUSTOMER_EMAIL_CONFIGURATION_NAME, ]; public const CARRIER_EXCLUSIVE = [ 'POSTNL' => [ diff --git a/src/Factory/Consignment/ConsignmentFactory.php b/src/Factory/Consignment/ConsignmentFactory.php index 8f9250f2..6090190a 100644 --- a/src/Factory/Consignment/ConsignmentFactory.php +++ b/src/Factory/Consignment/ConsignmentFactory.php @@ -320,6 +320,10 @@ private function setRecipient(): void */ private function getEmailConfiguration(): string { + if ($this->module->isBE()) { + return $this->orderData['email']; + } + $emailConfiguration = Configuration::get(Constant::SHARE_CUSTOMER_EMAIL_CONFIGURATION_NAME); return $emailConfiguration ? $this->orderData['email'] : ''; diff --git a/src/Module/Configuration/AbstractForm.php b/src/Module/Configuration/AbstractForm.php index c36f426d..5ef490f0 100755 --- a/src/Module/Configuration/AbstractForm.php +++ b/src/Module/Configuration/AbstractForm.php @@ -13,8 +13,10 @@ abstract class AbstractForm { - protected const FIELD_TYPE_SELECT = 'select'; - protected const FIELD_TYPE_SWITCH = 'switch'; + protected const FIELD_TYPE_SELECT = 'select'; + protected const FIELD_TYPE_SWITCH = 'switch'; + protected const FIELD_TYPE_TEXT = 'text'; + protected const FIELD_TYPE_CHECKBOX = 'checkbox'; /** @var Module */ protected $module; diff --git a/src/Module/Configuration/CustomsForm.php b/src/Module/Configuration/CustomsForm.php index 9ed3465e..336efe6c 100755 --- a/src/Module/Configuration/CustomsForm.php +++ b/src/Module/Configuration/CustomsForm.php @@ -20,7 +20,7 @@ protected function getFields(): array { return [ Constant::CUSTOMS_FORM_CONFIGURATION_NAME => [ - 'type' => 'select', + 'type' => self::FIELD_TYPE_SELECT, 'label' => $this->module->l('Default customs form', 'customsform'), 'name' => Constant::CUSTOMS_FORM_CONFIGURATION_NAME, 'options' => [ @@ -39,12 +39,12 @@ protected function getFields(): array ], ], Constant::DEFAULT_CUSTOMS_CODE_CONFIGURATION_NAME => [ - 'type' => 'text', + 'type' => self::FIELD_TYPE_TEXT, 'label' => $this->module->l('Default customs code', 'customsform'), 'name' => Constant::DEFAULT_CUSTOMS_CODE_CONFIGURATION_NAME, ], Constant::DEFAULT_CUSTOMS_ORIGIN_CONFIGURATION_NAME => [ - 'type' => 'select', + 'type' => self::FIELD_TYPE_SELECT, 'label' => $this->module->l('Default customs origin', 'customsform'), 'name' => Constant::DEFAULT_CUSTOMS_ORIGIN_CONFIGURATION_NAME, 'options' => [ @@ -55,7 +55,7 @@ protected function getFields(): array 'default_value' => $this->module->isBE() ? AbstractConsignment::CC_BE : AbstractConsignment::CC_NL, ], Constant::CUSTOMS_AGE_CHECK_CONFIGURATION_NAME => [ - 'type' => 'switch', + 'type' => self::FIELD_TYPE_SWITCH, 'label' => $this->module->l('Default customs age check', 'customsform'), 'name' => Constant::CUSTOMS_AGE_CHECK_CONFIGURATION_NAME, 'is_bool' => true, diff --git a/src/Module/Configuration/GeneralForm.php b/src/Module/Configuration/GeneralForm.php index eab32d49..ed2c2f74 100755 --- a/src/Module/Configuration/GeneralForm.php +++ b/src/Module/Configuration/GeneralForm.php @@ -20,7 +20,10 @@ protected function getFields(): array { return [ Constant::SHARE_CUSTOMER_EMAIL_CONFIGURATION_NAME => [ - 'type' => self::FIELD_TYPE_SWITCH, + 'type' => $this->getExclusiveNlFieldType( + self::FIELD_TYPE_SWITCH, + Constant::SHARE_CUSTOMER_EMAIL_CONFIGURATION_NAME + ), 'label' => $this->module->l('Share customer email with MyParcel', $this->getNamespace()), 'name' => Constant::SHARE_CUSTOMER_EMAIL_CONFIGURATION_NAME, ], diff --git a/src/Module/Configuration/LabelForm.php b/src/Module/Configuration/LabelForm.php index 3d7f0599..5836eee7 100755 --- a/src/Module/Configuration/LabelForm.php +++ b/src/Module/Configuration/LabelForm.php @@ -17,7 +17,7 @@ protected function getFields(): array { return [ Constant::LABEL_DESCRIPTION_CONFIGURATION_NAME => [ - 'type' => 'text', + 'type' => self::FIELD_TYPE_TEXT, 'label' => $this->module->l('Label description', 'labelform'), 'name' => Constant::LABEL_DESCRIPTION_CONFIGURATION_NAME, 'placeholder' => '{order.id} {order.reference}', @@ -36,7 +36,7 @@ protected function getFields(): array ], ], Constant::LABEL_SIZE_CONFIGURATION_NAME => [ - 'type' => 'select', + 'type' => self::FIELD_TYPE_SELECT, 'label' => $this->module->l('Default label size', 'labelform'), 'name' => Constant::LABEL_SIZE_CONFIGURATION_NAME, 'options' => [ @@ -49,7 +49,7 @@ protected function getFields(): array ], ], Constant::LABEL_POSITION_CONFIGURATION_NAME => [ - 'type' => 'select', + 'type' => self::FIELD_TYPE_SELECT, 'label' => $this->module->l('Default label position', 'labelform'), 'name' => Constant::LABEL_POSITION_CONFIGURATION_NAME, 'form_group_class' => 'label_position', @@ -65,7 +65,7 @@ protected function getFields(): array ], ], Constant::LABEL_OPEN_DOWNLOAD_CONFIGURATION_NAME => [ - 'type' => 'select', + 'type' => self::FIELD_TYPE_SELECT, 'label' => $this->module->l('Open or download label', 'labelform'), 'name' => Constant::LABEL_OPEN_DOWNLOAD_CONFIGURATION_NAME, 'options' => [ @@ -78,7 +78,7 @@ protected function getFields(): array ], ], Constant::LABEL_PROMPT_POSITION_CONFIGURATION_NAME => [ - 'type' => 'switch', + 'type' => self::FIELD_TYPE_SWITCH, 'label' => $this->module->l('Prompt for label position', 'labelform'), 'name' => Constant::LABEL_PROMPT_POSITION_CONFIGURATION_NAME, 'required' => false, diff --git a/src/Module/Configuration/OrderForm.php b/src/Module/Configuration/OrderForm.php index dba0b30f..8ce0e6d5 100755 --- a/src/Module/Configuration/OrderForm.php +++ b/src/Module/Configuration/OrderForm.php @@ -30,7 +30,7 @@ protected function getFields(): array return [ Constant::LABEL_CREATED_ORDER_STATUS_CONFIGURATION_NAME => [ - 'type' => 'select', + 'type' => self::FIELD_TYPE_SELECT, 'label' => $this->module->l('Order status when label created', 'orderform'), 'name' => Constant::LABEL_CREATED_ORDER_STATUS_CONFIGURATION_NAME, 'options' => [ @@ -40,7 +40,7 @@ protected function getFields(): array ], ], Constant::LABEL_SCANNED_ORDER_STATUS_CONFIGURATION_NAME => [ - 'type' => 'select', + 'type' => self::FIELD_TYPE_SELECT, 'label' => $this->module->l('Order status when label scanned', 'orderform'), 'name' => Constant::LABEL_SCANNED_ORDER_STATUS_CONFIGURATION_NAME, 'default_value' => '0', @@ -51,7 +51,7 @@ protected function getFields(): array ], ], Constant::DELIVERED_ORDER_STATUS_CONFIGURATION_NAME => [ - 'type' => 'select', + 'type' => self::FIELD_TYPE_SELECT, 'label' => $this->module->l('Order status when delivered', 'orderform'), 'name' => Constant::DELIVERED_ORDER_STATUS_CONFIGURATION_NAME, 'options' => [ @@ -61,7 +61,7 @@ protected function getFields(): array ], ], Constant::IGNORE_ORDER_STATUS_CONFIGURATION_NAME => [ - 'type' => 'checkbox', + 'type' => self::FIELD_TYPE_CHECKBOX, 'label' => $this->module->l('Ignore order statuses', 'orderform'), 'name' => Constant::IGNORE_ORDER_STATUS_CONFIGURATION_NAME, 'multiple' => true, @@ -72,7 +72,7 @@ protected function getFields(): array ], ], Constant::STATUS_CHANGE_MAIL_CONFIGURATION_NAME => [ - 'type' => 'switch', + 'type' => self::FIELD_TYPE_SWITCH, 'label' => $this->module->l('Order status mail', 'orderform'), 'name' => Constant::STATUS_CHANGE_MAIL_CONFIGURATION_NAME, 'required' => false, @@ -91,7 +91,7 @@ protected function getFields(): array ], ], Constant::ORDER_NOTIFICATION_AFTER_CONFIGURATION_NAME => [ - 'type' => 'select', + 'type' => self::FIELD_TYPE_SELECT, 'label' => $this->module->l('Send notification after', 'orderform'), 'name' => Constant::ORDER_NOTIFICATION_AFTER_CONFIGURATION_NAME, 'options' => [ @@ -111,7 +111,7 @@ protected function getFields(): array ], Constant::SENT_ORDER_STATE_FOR_DIGITAL_STAMPS_CONFIGURATION_NAME => [ 'type' => $this->getExclusiveNlFieldType( - 'switch', + self::FIELD_TYPE_SWITCH, Constant::SENT_ORDER_STATE_FOR_DIGITAL_STAMPS_CONFIGURATION_NAME ), 'label' => $this->module->l('Automatic set order state to ‘sent’ for digital stamp', 'orderform'),