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(); + } +} 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."', 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), 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', 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'; 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 {