From 4319459909a43c9a63e5bd312be724c49045daf2 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Tue, 26 Jun 2018 23:58:37 +0200 Subject: [PATCH 1/7] add migration --- ...nal_info_to_delivery_address_and_order.php | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 api-wiaas/db/migrations/20180626181450_add_personal_info_to_delivery_address_and_order.php diff --git a/api-wiaas/db/migrations/20180626181450_add_personal_info_to_delivery_address_and_order.php b/api-wiaas/db/migrations/20180626181450_add_personal_info_to_delivery_address_and_order.php new file mode 100644 index 0000000..4543b6e --- /dev/null +++ b/api-wiaas/db/migrations/20180626181450_add_personal_info_to_delivery_address_and_order.php @@ -0,0 +1,47 @@ +table('delivery_addresses'); + $deliveryAddressesTable->addColumn('firstName', 'string', ['limit' => 100, 'null' => true, 'after'=>'idUser']) + ->addColumn('lastName', 'string', ['limit'=>100, 'null'=> true, 'after'=>'firstName']) + ->addColumn('deliveryMail', 'string', ['limit'=>300, 'null' => true, 'after'=>'lastName']) + ->save(); + + $ordersTable = $this->table('orders'); + $ordersTable->addColumn('deliveryFirstName', 'string', ['limit' => 100, 'null' => true, 'after'=>'deliveryAddress']) + ->addColumn('deliveryLastName', 'string', ['limit'=>100, 'null'=> true, 'after'=>'deliveryFirstName']) + ->addColumn('deliveryMail', 'string', ['limit'=>300, 'null' => true, 'after'=>'deliveryLastName']) + ->save(); + } +} From 66e2b06fdd96c11d069a9b384cfbbe5163ff3d6b Mon Sep 17 00:00:00 2001 From: GotPPay Date: Tue, 26 Jun 2018 23:58:58 +0200 Subject: [PATCH 2/7] add requested fields to the orders table --- api-wiaas/server/components/v2/cart/CartModel.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api-wiaas/server/components/v2/cart/CartModel.php b/api-wiaas/server/components/v2/cart/CartModel.php index cd62269..cac7c25 100644 --- a/api-wiaas/server/components/v2/cart/CartModel.php +++ b/api-wiaas/server/components/v2/cart/CartModel.php @@ -1207,6 +1207,9 @@ $concatenatedDeliveryAddress = $deliveryInfo['detailedAddress'].", ".$deliveryInfo['city'].", $countryName, ".$deliveryInfo['zipCode']; $billingCountryDetails = $this->getCountryDetailsById($billingInfo['idCountrySelected'])[0]; $concatenatedBillingAddress = $billingInfo['detailedAddress'].", ".$billingInfo['city'].", ".$billingCountryDetails['countryName'].", ".$billingInfo['zipCode']; + $deliveryFirstName = $deliveryInfo['firstName']; + $deliveryLastName = $deliveryInfo['lastName']; + $deliveryMail = $deliveryInfo['deliveryMail']; $billingFirstName = $billingInfo['firstName']; $billingLastName = $billingInfo['lastName']; $billingMail = $billingInfo['invoiceMail']; @@ -1222,7 +1225,7 @@ $sql = " INSERT INTO ".TABLES['orders']." - (idCustomerInstance, orderNumber, orderDate, reference, tender, projectNumber, deliveryAddress, billingAddress, billingFirstName, billingLastName, billingMail, idTerms, idOrderType, idProject) + (idCustomerInstance, orderNumber, orderDate, reference, tender, projectNumber, deliveryAddress, deliveryFirstName, deliveryLastName, deliveryMail, billingAddress, billingFirstName, billingLastName, billingMail, idTerms, idOrderType, idProject) VALUES ( $idCustomerInstance, '".$orderNumber."', @@ -1231,6 +1234,9 @@ '".$tender."', '".$projectNumber."', '".$concatenatedDeliveryAddress."', + '".$deliveryFirstName."', + '".$deliveryLastName."', + '".$deliveryMail."', '".$concatenatedBillingAddress."', '".$billingFirstName."', '".$billingLastName."', From 02209eb558843dc8f381bfd543180ecc5d707147 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Tue, 26 Jun 2018 23:59:27 +0200 Subject: [PATCH 3/7] store and read additional fields in delivery_addresses table --- .../components/v2/helpers/AddressHelper.php | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/api-wiaas/server/components/v2/helpers/AddressHelper.php b/api-wiaas/server/components/v2/helpers/AddressHelper.php index 2a6a879..3b14885 100644 --- a/api-wiaas/server/components/v2/helpers/AddressHelper.php +++ b/api-wiaas/server/components/v2/helpers/AddressHelper.php @@ -9,6 +9,9 @@ class AddressHelper{ $sqlDelivery = "SELECT da.id, + da.firstName as firstName, + da.lastName as lastName, + da.deliveryMail as deliveryMail, da.detailedAddress AS detailedAddress, da.city AS city, da.zip AS zipCode, @@ -187,6 +190,23 @@ class AddressHelper{ $data['messages'][] = $checkMessage; } + + if($type === 'profileAddress'){ + if(isset($info->deliveryMail) && !empty($info->deliveryMail)) { + $checkMessage = $database->invalidLength('deliveryMail', $info->deliveryMail, 300); + if($checkMessage){ + $data['messages'][] = $checkMessage; + } + + if(!filter_var($info->deliveryMail, FILTER_VALIDATE_EMAIL)){ + $data['messages'][] = [ + 'code' => 'error', + 'message' => 'INVALID_DELIVERY_MAIL' + ]; + } + } + } + if($type === 'billingAddress'){ if(isset($info->invoiceMail) && !empty($info->invoiceMail)) { $checkMessage = $database->invalidLength('invoiceMail', $info->invoiceMail, 300); @@ -245,14 +265,20 @@ class AddressHelper{ $idAddress = isset($profileAddress->id) ? $profileAddress->id : 'null'; - $sql = "INSERT INTO ".TABLES['delivery_addresses']." (id, idUser, idCountry, city, detailedAddress, zip) + $sql = "INSERT INTO ".TABLES['delivery_addresses']." (id, idUser, firstName, lastName, deliveryMail, idCountry, city, detailedAddress, zip) VALUES(".$idAddress.", ".$idUser.", + '".$profileAddress->firstName."', + '".$profileAddress->lastName."', + '".$profileAddress->deliveryMail."', ".$profileAddress->idCountrySelected.", '".$profileAddress->city."', '".$profileAddress->detailedAddress."', '".$profileAddress->zipCode."') ON DUPLICATE KEY UPDATE + firstName= VALUES(firstName), + lastName= VALUES(lastName), + deliveryMail= VALUES(deliveryMail), idCountry= VALUES(idCountry), city= VALUES(city), detailedAddress=VALUES(detailedAddress), From f76b74b2ef72a68f48534fafde593387038bc95f Mon Sep 17 00:00:00 2001 From: GotPPay Date: Tue, 26 Jun 2018 23:59:43 +0200 Subject: [PATCH 4/7] add constants --- client-wiaas/src/constants/cartConstants.js | 3 ++- client-wiaas/src/constants/profileSettingsConstants.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client-wiaas/src/constants/cartConstants.js b/client-wiaas/src/constants/cartConstants.js index 63117f2..509ca8a 100644 --- a/client-wiaas/src/constants/cartConstants.js +++ b/client-wiaas/src/constants/cartConstants.js @@ -162,7 +162,8 @@ export const cartTexts = { SERVICES: 'Services', ACTIONS: 'Actions', PROJECT: 'Project', - INVOICE_MAIL: 'Invoice mail' + INVOICE_MAIL: 'Invoice mail', + DELIVERY_MAIL: 'Delivery mail' }, buttons: { YES: 'Yes', diff --git a/client-wiaas/src/constants/profileSettingsConstants.js b/client-wiaas/src/constants/profileSettingsConstants.js index cd4a7de..1de7dcb 100644 --- a/client-wiaas/src/constants/profileSettingsConstants.js +++ b/client-wiaas/src/constants/profileSettingsConstants.js @@ -35,7 +35,8 @@ export const profileTexts = { FIRST_NAME: 'First Name', LAST_NAME: 'Last Name', DELEGATE: 'Attention', - INVOICE_MAIL: 'Invoice Mail' + INVOICE_MAIL: 'Invoice Mail', + DELIVERY_MAIL: 'Delivery Mail' }, buttons: { SAVE: 'Save', From 33d1820884fff824f0c588f0948cbe2a92bec8b5 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Wed, 27 Jun 2018 00:00:15 +0200 Subject: [PATCH 5/7] dont' require name,last name or email to continue --- .../src/containers/cart/CartCustomerDetailsContainer.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client-wiaas/src/containers/cart/CartCustomerDetailsContainer.jsx b/client-wiaas/src/containers/cart/CartCustomerDetailsContainer.jsx index 1cd43bb..46df000 100644 --- a/client-wiaas/src/containers/cart/CartCustomerDetailsContainer.jsx +++ b/client-wiaas/src/containers/cart/CartCustomerDetailsContainer.jsx @@ -123,7 +123,7 @@ class CartCustomerDetailsContainer extends Component { checkIfInfoCompleted() { const {delivery, billing} = this.state; const isDeliveryAddressCompleted = Object.keys(delivery).length ? Object.keys(delivery).every(delivKey => { - return delivery[delivKey] !== ''; + return delivery[delivKey] !== ''|| delivKey === 'firstName' || delivKey === 'lastName' || delivKey === 'deliveryMail';; }) : false; const isBillingAddressCompleted = Object.keys(billing).length ? Object.keys(billing).every(billingKey => { return billing[billingKey] !== '' || billingKey === 'firstName' || billingKey === 'lastName' || billingKey === 'invoiceMail'; From 4cbc207b6cd8824143deb530820b970429521b4a Mon Sep 17 00:00:00 2001 From: GotPPay Date: Wed, 27 Jun 2018 00:00:33 +0200 Subject: [PATCH 6/7] add requested fields in order summary --- .../src/containers/cart/CartReviewOrderContainer.jsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/client-wiaas/src/containers/cart/CartReviewOrderContainer.jsx b/client-wiaas/src/containers/cart/CartReviewOrderContainer.jsx index 7138ea8..2879236 100644 --- a/client-wiaas/src/containers/cart/CartReviewOrderContainer.jsx +++ b/client-wiaas/src/containers/cart/CartReviewOrderContainer.jsx @@ -94,6 +94,18 @@ class CartReviewOrderContainer extends Component {

{cartTexts.labels.DELIVERY_ADDRESS}

+ + {cartTexts.labels.FIRST_NAME} + {customerDetails.delivery.firstName || '-'} + + + {cartTexts.labels.LAST_NAME} + {customerDetails.delivery.lastName || '-'} + + + {cartTexts.labels.DELIVERY_MAIL} + {customerDetails.delivery.deliveryMail || '-'} + {cartTexts.labels.ADDRESS} {customerDetails.delivery.detailedAddress} From 141727c23803443d1e8c336d93550150d3017c06 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Wed, 27 Jun 2018 00:01:02 +0200 Subject: [PATCH 7/7] add requested fields to delivery address form --- .../components/AddEditProfileAddress.jsx | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/client-wiaas/src/containers/profileSettings/components/AddEditProfileAddress.jsx b/client-wiaas/src/containers/profileSettings/components/AddEditProfileAddress.jsx index 275e16d..b026ae1 100644 --- a/client-wiaas/src/containers/profileSettings/components/AddEditProfileAddress.jsx +++ b/client-wiaas/src/containers/profileSettings/components/AddEditProfileAddress.jsx @@ -12,7 +12,10 @@ class AddEditProfileAddress extends Component { idCountrySelected: address.idCountrySelected || this.props.params.countries[0].idCountry, city: address.city || '', detailedAddress: address.detailedAddress || '', - zipCode: address.zipCode || '' + zipCode: address.zipCode || '', + firstName: address.firstName || '', + lastName: address.lastName || '', + deliveryMail: address.deliveryMail || '' }; this.props.params.onAddressChange(this.state); @@ -30,12 +33,47 @@ class AddEditProfileAddress extends Component { } render() { - const {idCountrySelected, city, detailedAddress, zipCode} = this.state; + const {idCountrySelected, city, detailedAddress, zipCode, firstName, lastName, deliveryMail} = this.state; const {countries} = this.props.params; return (
+
{profileTexts.labels.DELEGATE}
+ + + + + + + + + + + + + + + +
{profileTexts.labels.BILLING_ADDRESSES}