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:
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1207,6 +1207,9 @@
|
|||||||
$concatenatedDeliveryAddress = $deliveryInfo['detailedAddress'].", ".$deliveryInfo['city'].", $countryName, ".$deliveryInfo['zipCode'];
|
$concatenatedDeliveryAddress = $deliveryInfo['detailedAddress'].", ".$deliveryInfo['city'].", $countryName, ".$deliveryInfo['zipCode'];
|
||||||
$billingCountryDetails = $this->getCountryDetailsById($billingInfo['idCountrySelected'])[0];
|
$billingCountryDetails = $this->getCountryDetailsById($billingInfo['idCountrySelected'])[0];
|
||||||
$concatenatedBillingAddress = $billingInfo['detailedAddress'].", ".$billingInfo['city'].", ".$billingCountryDetails['countryName'].", ".$billingInfo['zipCode'];
|
$concatenatedBillingAddress = $billingInfo['detailedAddress'].", ".$billingInfo['city'].", ".$billingCountryDetails['countryName'].", ".$billingInfo['zipCode'];
|
||||||
|
$deliveryFirstName = $deliveryInfo['firstName'];
|
||||||
|
$deliveryLastName = $deliveryInfo['lastName'];
|
||||||
|
$deliveryMail = $deliveryInfo['deliveryMail'];
|
||||||
$billingFirstName = $billingInfo['firstName'];
|
$billingFirstName = $billingInfo['firstName'];
|
||||||
$billingLastName = $billingInfo['lastName'];
|
$billingLastName = $billingInfo['lastName'];
|
||||||
$billingMail = $billingInfo['invoiceMail'];
|
$billingMail = $billingInfo['invoiceMail'];
|
||||||
@@ -1222,7 +1225,7 @@
|
|||||||
|
|
||||||
$sql = "
|
$sql = "
|
||||||
INSERT INTO ".TABLES['orders']."
|
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 (
|
VALUES (
|
||||||
$idCustomerInstance,
|
$idCustomerInstance,
|
||||||
'".$orderNumber."',
|
'".$orderNumber."',
|
||||||
@@ -1231,6 +1234,9 @@
|
|||||||
'".$tender."',
|
'".$tender."',
|
||||||
'".$projectNumber."',
|
'".$projectNumber."',
|
||||||
'".$concatenatedDeliveryAddress."',
|
'".$concatenatedDeliveryAddress."',
|
||||||
|
'".$deliveryFirstName."',
|
||||||
|
'".$deliveryLastName."',
|
||||||
|
'".$deliveryMail."',
|
||||||
'".$concatenatedBillingAddress."',
|
'".$concatenatedBillingAddress."',
|
||||||
'".$billingFirstName."',
|
'".$billingFirstName."',
|
||||||
'".$billingLastName."',
|
'".$billingLastName."',
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class AddressHelper{
|
|||||||
|
|
||||||
$sqlDelivery = "SELECT
|
$sqlDelivery = "SELECT
|
||||||
da.id,
|
da.id,
|
||||||
|
da.firstName as firstName,
|
||||||
|
da.lastName as lastName,
|
||||||
|
da.deliveryMail as deliveryMail,
|
||||||
da.detailedAddress AS detailedAddress,
|
da.detailedAddress AS detailedAddress,
|
||||||
da.city AS city,
|
da.city AS city,
|
||||||
da.zip AS zipCode,
|
da.zip AS zipCode,
|
||||||
@@ -187,6 +190,23 @@ class AddressHelper{
|
|||||||
$data['messages'][] = $checkMessage;
|
$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($type === 'billingAddress'){
|
||||||
if(isset($info->invoiceMail) && !empty($info->invoiceMail)) {
|
if(isset($info->invoiceMail) && !empty($info->invoiceMail)) {
|
||||||
$checkMessage = $database->invalidLength('invoiceMail', $info->invoiceMail, 300);
|
$checkMessage = $database->invalidLength('invoiceMail', $info->invoiceMail, 300);
|
||||||
@@ -245,14 +265,20 @@ class AddressHelper{
|
|||||||
|
|
||||||
$idAddress = isset($profileAddress->id) ? $profileAddress->id : 'null';
|
$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.",
|
VALUES(".$idAddress.",
|
||||||
".$idUser.",
|
".$idUser.",
|
||||||
|
'".$profileAddress->firstName."',
|
||||||
|
'".$profileAddress->lastName."',
|
||||||
|
'".$profileAddress->deliveryMail."',
|
||||||
".$profileAddress->idCountrySelected.",
|
".$profileAddress->idCountrySelected.",
|
||||||
'".$profileAddress->city."',
|
'".$profileAddress->city."',
|
||||||
'".$profileAddress->detailedAddress."',
|
'".$profileAddress->detailedAddress."',
|
||||||
'".$profileAddress->zipCode."')
|
'".$profileAddress->zipCode."')
|
||||||
ON DUPLICATE KEY UPDATE
|
ON DUPLICATE KEY UPDATE
|
||||||
|
firstName= VALUES(firstName),
|
||||||
|
lastName= VALUES(lastName),
|
||||||
|
deliveryMail= VALUES(deliveryMail),
|
||||||
idCountry= VALUES(idCountry),
|
idCountry= VALUES(idCountry),
|
||||||
city= VALUES(city),
|
city= VALUES(city),
|
||||||
detailedAddress=VALUES(detailedAddress),
|
detailedAddress=VALUES(detailedAddress),
|
||||||
|
|||||||
@@ -162,7 +162,8 @@ export const cartTexts = {
|
|||||||
SERVICES: 'Services',
|
SERVICES: 'Services',
|
||||||
ACTIONS: 'Actions',
|
ACTIONS: 'Actions',
|
||||||
PROJECT: 'Project',
|
PROJECT: 'Project',
|
||||||
INVOICE_MAIL: 'Invoice mail'
|
INVOICE_MAIL: 'Invoice mail',
|
||||||
|
DELIVERY_MAIL: 'Delivery mail'
|
||||||
},
|
},
|
||||||
buttons: {
|
buttons: {
|
||||||
YES: 'Yes',
|
YES: 'Yes',
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ export const profileTexts = {
|
|||||||
FIRST_NAME: 'First Name',
|
FIRST_NAME: 'First Name',
|
||||||
LAST_NAME: 'Last Name',
|
LAST_NAME: 'Last Name',
|
||||||
DELEGATE: 'Attention',
|
DELEGATE: 'Attention',
|
||||||
INVOICE_MAIL: 'Invoice Mail'
|
INVOICE_MAIL: 'Invoice Mail',
|
||||||
|
DELIVERY_MAIL: 'Delivery Mail'
|
||||||
},
|
},
|
||||||
buttons: {
|
buttons: {
|
||||||
SAVE: 'Save',
|
SAVE: 'Save',
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class CartCustomerDetailsContainer extends Component {
|
|||||||
checkIfInfoCompleted() {
|
checkIfInfoCompleted() {
|
||||||
const {delivery, billing} = this.state;
|
const {delivery, billing} = this.state;
|
||||||
const isDeliveryAddressCompleted = Object.keys(delivery).length ? Object.keys(delivery).every(delivKey => {
|
const isDeliveryAddressCompleted = Object.keys(delivery).length ? Object.keys(delivery).every(delivKey => {
|
||||||
return delivery[delivKey] !== '';
|
return delivery[delivKey] !== ''|| delivKey === 'firstName' || delivKey === 'lastName' || delivKey === 'deliveryMail';;
|
||||||
}) : false;
|
}) : false;
|
||||||
const isBillingAddressCompleted = Object.keys(billing).length ? Object.keys(billing).every(billingKey => {
|
const isBillingAddressCompleted = Object.keys(billing).length ? Object.keys(billing).every(billingKey => {
|
||||||
return billing[billingKey] !== '' || billingKey === 'firstName' || billingKey === 'lastName' || billingKey === 'invoiceMail';
|
return billing[billingKey] !== '' || billingKey === 'firstName' || billingKey === 'lastName' || billingKey === 'invoiceMail';
|
||||||
|
|||||||
@@ -94,6 +94,18 @@ class CartReviewOrderContainer extends Component {
|
|||||||
</Row>
|
</Row>
|
||||||
<div>
|
<div>
|
||||||
<h4>{cartTexts.labels.DELIVERY_ADDRESS}</h4>
|
<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">
|
<Row className="cart-customer-main-info-row">
|
||||||
<Col md="4">{cartTexts.labels.ADDRESS}</Col>
|
<Col md="4">{cartTexts.labels.ADDRESS}</Col>
|
||||||
<Col md="4"id="review-delivery-address">{customerDetails.delivery.detailedAddress}</Col>
|
<Col md="4"id="review-delivery-address">{customerDetails.delivery.detailedAddress}</Col>
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ class AddEditProfileAddress extends Component {
|
|||||||
idCountrySelected: address.idCountrySelected || this.props.params.countries[0].idCountry,
|
idCountrySelected: address.idCountrySelected || this.props.params.countries[0].idCountry,
|
||||||
city: address.city || '',
|
city: address.city || '',
|
||||||
detailedAddress: address.detailedAddress || '',
|
detailedAddress: address.detailedAddress || '',
|
||||||
zipCode: address.zipCode || ''
|
zipCode: address.zipCode || '',
|
||||||
|
firstName: address.firstName || '',
|
||||||
|
lastName: address.lastName || '',
|
||||||
|
deliveryMail: address.deliveryMail || ''
|
||||||
};
|
};
|
||||||
this.props.params.onAddressChange(this.state);
|
this.props.params.onAddressChange(this.state);
|
||||||
|
|
||||||
@@ -30,12 +33,47 @@ class AddEditProfileAddress extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {idCountrySelected, city, detailedAddress, zipCode} = this.state;
|
const {idCountrySelected, city, detailedAddress, zipCode, firstName, lastName, deliveryMail} = this.state;
|
||||||
const {countries} = this.props.params;
|
const {countries} = this.props.params;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="address-add-edit-content">
|
<div className="address-add-edit-content">
|
||||||
<Form className="address-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>
|
<FormGroup>
|
||||||
<Label for="address-country">{profileTexts.labels.ADDRESS_COUNTRY}<span className="required-icon">*</span></Label>
|
<Label for="address-country">{profileTexts.labels.ADDRESS_COUNTRY}<span className="required-icon">*</span></Label>
|
||||||
<Input value={idCountrySelected}
|
<Input value={idCountrySelected}
|
||||||
|
|||||||
Reference in New Issue
Block a user