Merge branch 'add-personal-info-to-delivery-address-and-order' into 'development'

Add personal info to delivery address and order

See merge request saburly/wiaas/wiaas-legacy!6
This commit was merged in pull request #6.
This commit is contained in:
Nedim Uka
2018-06-27 08:55:05 +00:00
8 changed files with 138 additions and 7 deletions

View File

@@ -0,0 +1,47 @@
<?php
use Phinx\Migration\AbstractMigration;
class AddPersonalInfoToDeliveryAddressAndOrder extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* addCustomColumn
* renameColumn
* addIndex
* addForeignKey
*
* Any other distructive changes will result in an error when trying to
* rollback the migration.
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$deliveryAddressesTable = $this->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();
}
}

View File

@@ -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."',

View File

@@ -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),

View File

@@ -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',

View File

@@ -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',

View File

@@ -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';

View File

@@ -94,6 +94,18 @@ class CartReviewOrderContainer extends Component {
</Row>
<div>
<h4>{cartTexts.labels.DELIVERY_ADDRESS}</h4>
<Row className="cart-customer-main-info-row">
<Col md="4">{cartTexts.labels.FIRST_NAME}</Col>
<Col md="4" id="review-address-first-name">{customerDetails.delivery.firstName || '-'}</Col>
</Row>
<Row className="cart-customer-main-info-row">
<Col md="4">{cartTexts.labels.LAST_NAME}</Col>
<Col md="4" id="review-delivery-last-name">{customerDetails.delivery.lastName || '-'}</Col>
</Row>
<Row className="cart-customer-main-info-row">
<Col md="4">{cartTexts.labels.DELIVERY_MAIL}</Col>
<Col md="4" id="review-delivery-mail">{customerDetails.delivery.deliveryMail || '-'}</Col>
</Row>
<Row className="cart-customer-main-info-row">
<Col md="4">{cartTexts.labels.ADDRESS}</Col>
<Col md="4"id="review-delivery-address">{customerDetails.delivery.detailedAddress}</Col>

View File

@@ -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 (
<div className="address-add-edit-content">
<Form className="address-edit-content">
<h5>{profileTexts.labels.DELEGATE}</h5>
<FormGroup>
<Label for="address-first-name">{profileTexts.labels.FIRST_NAME}</Label>
<Input value={firstName}
autoComplete="nope"
onChange={this.handleChange}
type="text"
name="firstName"
id="address-first-name"
placeholder={profileTexts.labels.FIRST_NAME} />
</FormGroup>
<FormGroup>
<Label for="address-last-name">{profileTexts.labels.LAST_NAME}</Label>
<Input value={lastName}
autoComplete="nope"
onChange={this.handleChange}
type="text"
name="lastName"
id="address-last-name"
placeholder={profileTexts.labels.LAST_NAME} />
</FormGroup>
<FormGroup>
<Label for="address-delivery-mail">{profileTexts.labels.DELIVERY_MAIL}</Label>
<Input value={deliveryMail}
autoComplete="nope"
onChange={this.handleChange}
type="text"
name="deliveryMail"
id="address-delivery-mail"
placeholder={profileTexts.labels.DELIVERY_MAIL} />
</FormGroup>
<h5>{profileTexts.labels.BILLING_ADDRESSES}</h5>
<FormGroup>
<Label for="address-country">{profileTexts.labels.ADDRESS_COUNTRY}<span className="required-icon">*</span></Label>
<Input value={idCountrySelected}