diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 80a7a4695..208363c93 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -6,11 +6,13 @@ + + - + diff --git a/core/lib/Thelia/Core/Template/Loop/Address.php b/core/lib/Thelia/Core/Template/Loop/Address.php new file mode 100755 index 000000000..e776e21b4 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/Address.php @@ -0,0 +1,144 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Log\Tlog; + +use Thelia\Model\AddressQuery; +use Thelia\Model\ConfigQuery; +use Thelia\Type\TypeCollection; +use Thelia\Type; + +/** + * + * Address loop + * + * + * Class Address + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class Address extends BaseLoop +{ + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + new Argument( + 'customer', + new TypeCollection( + new Type\IntType(), + new Type\EnumType(array('current')) + ), + 'current' + ), + Argument::createBooleanTypeArgument('default'), + Argument::createIntListTypeArgument('exclude') + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = AddressQuery::create(); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + $customer = $this->getCustomer(); + + if ($customer === 'current') { + $currentCustomer = $this->request->getSession()->getCustomerUser(); + if($currentCustomer === null) { + return new LoopResult(); + } else { + $search->filterByCustomerId($currentCustomer->getId(), Criteria::EQUAL); + } + } else { + $search->filterByCustomerId($customer, Criteria::EQUAL); + } + + $default = $this->getDefault(); + + if ($default === true) { + $search->filterByIsDefault(1, Criteria::EQUAL); + } elseif($default === false) { + $search->filterByIsDefault(1, Criteria::NOT_EQUAL); + } + + $exclude = $this->getExclude(); + + if (!is_null($exclude)) { + $search->filterById($exclude, Criteria::NOT_IN); + } + + $addresses = $this->search($search, $pagination); + + $loopResult = new LoopResult(); + + foreach ($addresses as $address) { + + if ($this->not_empty && $address->countAllProducts() == 0) continue; + + $loopResultRow = new LoopResultRow(); + $loopResultRow->set("ID", $address->getId()); + $loopResultRow->set("NAME", $address->getName()); + $loopResultRow->set("CUSTOMER", $address->getCustomerId()); + $loopResultRow->set("TITLE", $address->getTitleId()); + $loopResultRow->set("COMPANY", $address->getCompany()); + $loopResultRow->set("FIRSTNAME", $address->getFirstname()); + $loopResultRow->set("LASTNAME", $address->getLastname()); + $loopResultRow->set("ADDRESS1", $address->getAddress1()); + $loopResultRow->set("ADDRESS2", $address->getAddress2()); + $loopResultRow->set("ADDRESS3", $address->getAddress3()); + $loopResultRow->set("ZIPCODE", $address->getZipcode()); + $loopResultRow->set("CITY", $address->getCity()); + $loopResultRow->set("COUNTRY", $address->getCountryId()); + $loopResultRow->set("PHONE", $address->getPhone()); + $loopResultRow->set("CELLPHONE", $address->getCellphone()); + $loopResultRow->set("DEFAULT", $address->getIsDefault()); + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Template/Loop/Customer.php b/core/lib/Thelia/Core/Template/Loop/Customer.php index 31345e2b8..29c832cdf 100755 --- a/core/lib/Thelia/Core/Template/Loop/Customer.php +++ b/core/lib/Thelia/Core/Template/Loop/Customer.php @@ -124,7 +124,7 @@ class Customer extends BaseLoop $loopResultRow = new LoopResultRow(); $loopResultRow->set("ID", $customer->getId()); $loopResultRow->set("REF", $customer->getRef()); - $loopResultRow->set("TITLE", $customer->getTitleid()); + $loopResultRow->set("TITLE", $customer->getTitleId()); $loopResultRow->set("FIRSTNAME", $customer->getFirstname()); $loopResultRow->set("LASTNAME", $customer->getLastname()); $loopResultRow->set("EMAIL", $customer->getEmail()); diff --git a/core/lib/Thelia/Core/Template/Loop/Title.php b/core/lib/Thelia/Core/Template/Loop/Title.php new file mode 100755 index 000000000..2cd5b13fd --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/Title.php @@ -0,0 +1,108 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Log\Tlog; + +use Thelia\Model\CustomerTitleQuery; +use Thelia\Model\ConfigQuery; +use Thelia\Type\TypeCollection; +use Thelia\Type; + +/** + * + * Title loop + * + * + * Class Title + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class Title extends BaseLoop +{ + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id') + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = CustomerTitleQuery::create(); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + /** + * Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation. + * + * @todo : verify here if we want results for row without translations. + */ + + $search->joinWithI18n( + $this->request->getSession()->getLocale(), + (ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN + ); + + $search->orderByPosition(); + + $titles = $this->search($search, $pagination); + + $loopResult = new LoopResult(); + + foreach ($titles as $title) { + + if ($this->not_empty && $title->countAllProducts() == 0) continue; + + $loopResultRow = new LoopResultRow(); + $loopResultRow->set("ID", $title->getId()); + $loopResultRow->set("DEFAULT", $title->getByDefault()); + $loopResultRow->set("SHORT", $title->getShort()); + $loopResultRow->set("LONG", $title->getLong()); + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Model/Base/Address.php b/core/lib/Thelia/Model/Base/Address.php index 4a017946d..45cad61aa 100755 --- a/core/lib/Thelia/Model/Base/Address.php +++ b/core/lib/Thelia/Model/Base/Address.php @@ -21,6 +21,8 @@ use Thelia\Model\Address as ChildAddress; use Thelia\Model\AddressQuery as ChildAddressQuery; use Thelia\Model\Cart as ChildCart; use Thelia\Model\CartQuery as ChildCartQuery; +use Thelia\Model\Country as ChildCountry; +use Thelia\Model\CountryQuery as ChildCountryQuery; use Thelia\Model\Customer as ChildCustomer; use Thelia\Model\CustomerQuery as ChildCustomerQuery; use Thelia\Model\CustomerTitle as ChildCustomerTitle; @@ -68,10 +70,10 @@ abstract class Address implements ActiveRecordInterface protected $id; /** - * The value for the title field. + * The value for the name field. * @var string */ - protected $title; + protected $name; /** * The value for the customer_id field. @@ -80,10 +82,10 @@ abstract class Address implements ActiveRecordInterface protected $customer_id; /** - * The value for the customer_title_id field. + * The value for the title_id field. * @var int */ - protected $customer_title_id; + protected $title_id; /** * The value for the company field. @@ -180,6 +182,11 @@ abstract class Address implements ActiveRecordInterface */ protected $aCustomerTitle; + /** + * @var Country + */ + protected $aCountry; + /** * @var ObjectCollection|ChildCart[] Collection to store aggregation of ChildCart objects. */ @@ -491,14 +498,14 @@ abstract class Address implements ActiveRecordInterface } /** - * Get the [title] column value. + * Get the [name] column value. * * @return string */ - public function getTitle() + public function getName() { - return $this->title; + return $this->name; } /** @@ -513,14 +520,14 @@ abstract class Address implements ActiveRecordInterface } /** - * Get the [customer_title_id] column value. + * Get the [title_id] column value. * * @return int */ - public function getCustomerTitleId() + public function getTitleId() { - return $this->customer_title_id; + return $this->title_id; } /** @@ -717,25 +724,25 @@ abstract class Address implements ActiveRecordInterface } // setId() /** - * Set the value of [title] column. + * Set the value of [name] column. * * @param string $v new value * @return \Thelia\Model\Address The current object (for fluent API support) */ - public function setTitle($v) + public function setName($v) { if ($v !== null) { $v = (string) $v; } - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = AddressTableMap::TITLE; + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = AddressTableMap::NAME; } return $this; - } // setTitle() + } // setName() /** * Set the value of [customer_id] column. @@ -763,20 +770,20 @@ abstract class Address implements ActiveRecordInterface } // setCustomerId() /** - * Set the value of [customer_title_id] column. + * Set the value of [title_id] column. * * @param int $v new value * @return \Thelia\Model\Address The current object (for fluent API support) */ - public function setCustomerTitleId($v) + public function setTitleId($v) { if ($v !== null) { $v = (int) $v; } - if ($this->customer_title_id !== $v) { - $this->customer_title_id = $v; - $this->modifiedColumns[] = AddressTableMap::CUSTOMER_TITLE_ID; + if ($this->title_id !== $v) { + $this->title_id = $v; + $this->modifiedColumns[] = AddressTableMap::TITLE_ID; } if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) { @@ -785,7 +792,7 @@ abstract class Address implements ActiveRecordInterface return $this; - } // setCustomerTitleId() + } // setTitleId() /** * Set the value of [company] column. @@ -972,6 +979,10 @@ abstract class Address implements ActiveRecordInterface $this->modifiedColumns[] = AddressTableMap::COUNTRY_ID; } + if ($this->aCountry !== null && $this->aCountry->getId() !== $v) { + $this->aCountry = null; + } + return $this; } // setCountryId() @@ -1125,14 +1136,14 @@ abstract class Address implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AddressTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AddressTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; - $this->title = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AddressTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; + $this->name = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AddressTableMap::translateFieldName('CustomerId', TableMap::TYPE_PHPNAME, $indexType)]; $this->customer_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AddressTableMap::translateFieldName('CustomerTitleId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->customer_title_id = (null !== $col) ? (int) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AddressTableMap::translateFieldName('TitleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title_id = (null !== $col) ? (int) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AddressTableMap::translateFieldName('Company', TableMap::TYPE_PHPNAME, $indexType)]; $this->company = (null !== $col) ? (string) $col : null; @@ -1214,9 +1225,12 @@ abstract class Address implements ActiveRecordInterface if ($this->aCustomer !== null && $this->customer_id !== $this->aCustomer->getId()) { $this->aCustomer = null; } - if ($this->aCustomerTitle !== null && $this->customer_title_id !== $this->aCustomerTitle->getId()) { + if ($this->aCustomerTitle !== null && $this->title_id !== $this->aCustomerTitle->getId()) { $this->aCustomerTitle = null; } + if ($this->aCountry !== null && $this->country_id !== $this->aCountry->getId()) { + $this->aCountry = null; + } } // ensureConsistency /** @@ -1258,6 +1272,7 @@ abstract class Address implements ActiveRecordInterface $this->aCustomer = null; $this->aCustomerTitle = null; + $this->aCountry = null; $this->collCartsRelatedByAddressDeliveryId = null; $this->collCartsRelatedByAddressInvoiceId = null; @@ -1403,6 +1418,13 @@ abstract class Address implements ActiveRecordInterface $this->setCustomerTitle($this->aCustomerTitle); } + if ($this->aCountry !== null) { + if ($this->aCountry->isModified() || $this->aCountry->isNew()) { + $affectedRows += $this->aCountry->save($con); + } + $this->setCountry($this->aCountry); + } + if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { @@ -1479,14 +1501,14 @@ abstract class Address implements ActiveRecordInterface if ($this->isColumnModified(AddressTableMap::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(AddressTableMap::TITLE)) { - $modifiedColumns[':p' . $index++] = 'TITLE'; + if ($this->isColumnModified(AddressTableMap::NAME)) { + $modifiedColumns[':p' . $index++] = 'NAME'; } if ($this->isColumnModified(AddressTableMap::CUSTOMER_ID)) { $modifiedColumns[':p' . $index++] = 'CUSTOMER_ID'; } - if ($this->isColumnModified(AddressTableMap::CUSTOMER_TITLE_ID)) { - $modifiedColumns[':p' . $index++] = 'CUSTOMER_TITLE_ID'; + if ($this->isColumnModified(AddressTableMap::TITLE_ID)) { + $modifiedColumns[':p' . $index++] = 'TITLE_ID'; } if ($this->isColumnModified(AddressTableMap::COMPANY)) { $modifiedColumns[':p' . $index++] = 'COMPANY'; @@ -1544,14 +1566,14 @@ abstract class Address implements ActiveRecordInterface case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case 'TITLE': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + case 'NAME': + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); break; case 'CUSTOMER_ID': $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT); break; - case 'CUSTOMER_TITLE_ID': - $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT); + case 'TITLE_ID': + $stmt->bindValue($identifier, $this->title_id, PDO::PARAM_INT); break; case 'COMPANY': $stmt->bindValue($identifier, $this->company, PDO::PARAM_STR); @@ -1661,13 +1683,13 @@ abstract class Address implements ActiveRecordInterface return $this->getId(); break; case 1: - return $this->getTitle(); + return $this->getName(); break; case 2: return $this->getCustomerId(); break; case 3: - return $this->getCustomerTitleId(); + return $this->getTitleId(); break; case 4: return $this->getCompany(); @@ -1741,9 +1763,9 @@ abstract class Address implements ActiveRecordInterface $keys = AddressTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), - $keys[1] => $this->getTitle(), + $keys[1] => $this->getName(), $keys[2] => $this->getCustomerId(), - $keys[3] => $this->getCustomerTitleId(), + $keys[3] => $this->getTitleId(), $keys[4] => $this->getCompany(), $keys[5] => $this->getFirstname(), $keys[6] => $this->getLastname(), @@ -1772,6 +1794,9 @@ abstract class Address implements ActiveRecordInterface if (null !== $this->aCustomerTitle) { $result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } + if (null !== $this->aCountry) { + $result['Country'] = $this->aCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } if (null !== $this->collCartsRelatedByAddressDeliveryId) { $result['CartsRelatedByAddressDeliveryId'] = $this->collCartsRelatedByAddressDeliveryId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1816,13 +1841,13 @@ abstract class Address implements ActiveRecordInterface $this->setId($value); break; case 1: - $this->setTitle($value); + $this->setName($value); break; case 2: $this->setCustomerId($value); break; case 3: - $this->setCustomerTitleId($value); + $this->setTitleId($value); break; case 4: $this->setCompany($value); @@ -1891,9 +1916,9 @@ abstract class Address implements ActiveRecordInterface $keys = AddressTableMap::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setTitle($arr[$keys[1]]); + if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setCustomerId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCustomerTitleId($arr[$keys[3]]); + if (array_key_exists($keys[3], $arr)) $this->setTitleId($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setCompany($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setFirstname($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setLastname($arr[$keys[6]]); @@ -1920,9 +1945,9 @@ abstract class Address implements ActiveRecordInterface $criteria = new Criteria(AddressTableMap::DATABASE_NAME); if ($this->isColumnModified(AddressTableMap::ID)) $criteria->add(AddressTableMap::ID, $this->id); - if ($this->isColumnModified(AddressTableMap::TITLE)) $criteria->add(AddressTableMap::TITLE, $this->title); + if ($this->isColumnModified(AddressTableMap::NAME)) $criteria->add(AddressTableMap::NAME, $this->name); if ($this->isColumnModified(AddressTableMap::CUSTOMER_ID)) $criteria->add(AddressTableMap::CUSTOMER_ID, $this->customer_id); - if ($this->isColumnModified(AddressTableMap::CUSTOMER_TITLE_ID)) $criteria->add(AddressTableMap::CUSTOMER_TITLE_ID, $this->customer_title_id); + if ($this->isColumnModified(AddressTableMap::TITLE_ID)) $criteria->add(AddressTableMap::TITLE_ID, $this->title_id); if ($this->isColumnModified(AddressTableMap::COMPANY)) $criteria->add(AddressTableMap::COMPANY, $this->company); if ($this->isColumnModified(AddressTableMap::FIRSTNAME)) $criteria->add(AddressTableMap::FIRSTNAME, $this->firstname); if ($this->isColumnModified(AddressTableMap::LASTNAME)) $criteria->add(AddressTableMap::LASTNAME, $this->lastname); @@ -2000,9 +2025,9 @@ abstract class Address implements ActiveRecordInterface */ public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { - $copyObj->setTitle($this->getTitle()); + $copyObj->setName($this->getName()); $copyObj->setCustomerId($this->getCustomerId()); - $copyObj->setCustomerTitleId($this->getCustomerTitleId()); + $copyObj->setTitleId($this->getTitleId()); $copyObj->setCompany($this->getCompany()); $copyObj->setFirstname($this->getFirstname()); $copyObj->setLastname($this->getLastname()); @@ -2126,9 +2151,9 @@ abstract class Address implements ActiveRecordInterface public function setCustomerTitle(ChildCustomerTitle $v = null) { if ($v === null) { - $this->setCustomerTitleId(NULL); + $this->setTitleId(NULL); } else { - $this->setCustomerTitleId($v->getId()); + $this->setTitleId($v->getId()); } $this->aCustomerTitle = $v; @@ -2153,8 +2178,8 @@ abstract class Address implements ActiveRecordInterface */ public function getCustomerTitle(ConnectionInterface $con = null) { - if ($this->aCustomerTitle === null && ($this->customer_title_id !== null)) { - $this->aCustomerTitle = ChildCustomerTitleQuery::create()->findPk($this->customer_title_id, $con); + if ($this->aCustomerTitle === null && ($this->title_id !== null)) { + $this->aCustomerTitle = ChildCustomerTitleQuery::create()->findPk($this->title_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be @@ -2167,6 +2192,57 @@ abstract class Address implements ActiveRecordInterface return $this->aCustomerTitle; } + /** + * Declares an association between this object and a ChildCountry object. + * + * @param ChildCountry $v + * @return \Thelia\Model\Address The current object (for fluent API support) + * @throws PropelException + */ + public function setCountry(ChildCountry $v = null) + { + if ($v === null) { + $this->setCountryId(NULL); + } else { + $this->setCountryId($v->getId()); + } + + $this->aCountry = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildCountry object, it will not be re-added. + if ($v !== null) { + $v->addAddress($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCountry object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCountry The associated ChildCountry object. + * @throws PropelException + */ + public function getCountry(ConnectionInterface $con = null) + { + if ($this->aCountry === null && ($this->country_id !== null)) { + $this->aCountry = ChildCountryQuery::create()->findPk($this->country_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aCountry->addAddresses($this); + */ + } + + return $this->aCountry; + } + /** * Initializes a collection based on the name of a relation. @@ -2728,9 +2804,9 @@ abstract class Address implements ActiveRecordInterface public function clear() { $this->id = null; - $this->title = null; + $this->name = null; $this->customer_id = null; - $this->customer_title_id = null; + $this->title_id = null; $this->company = null; $this->firstname = null; $this->lastname = null; @@ -2787,6 +2863,7 @@ abstract class Address implements ActiveRecordInterface $this->collCartsRelatedByAddressInvoiceId = null; $this->aCustomer = null; $this->aCustomerTitle = null; + $this->aCountry = null; } /** diff --git a/core/lib/Thelia/Model/Base/AddressQuery.php b/core/lib/Thelia/Model/Base/AddressQuery.php index 42be34bb0..c67c79b02 100755 --- a/core/lib/Thelia/Model/Base/AddressQuery.php +++ b/core/lib/Thelia/Model/Base/AddressQuery.php @@ -22,9 +22,9 @@ use Thelia\Model\Map\AddressTableMap; * * * @method ChildAddressQuery orderById($order = Criteria::ASC) Order by the id column - * @method ChildAddressQuery orderByTitle($order = Criteria::ASC) Order by the title column + * @method ChildAddressQuery orderByName($order = Criteria::ASC) Order by the name column * @method ChildAddressQuery orderByCustomerId($order = Criteria::ASC) Order by the customer_id column - * @method ChildAddressQuery orderByCustomerTitleId($order = Criteria::ASC) Order by the customer_title_id column + * @method ChildAddressQuery orderByTitleId($order = Criteria::ASC) Order by the title_id column * @method ChildAddressQuery orderByCompany($order = Criteria::ASC) Order by the company column * @method ChildAddressQuery orderByFirstname($order = Criteria::ASC) Order by the firstname column * @method ChildAddressQuery orderByLastname($order = Criteria::ASC) Order by the lastname column @@ -41,9 +41,9 @@ use Thelia\Model\Map\AddressTableMap; * @method ChildAddressQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildAddressQuery groupById() Group by the id column - * @method ChildAddressQuery groupByTitle() Group by the title column + * @method ChildAddressQuery groupByName() Group by the name column * @method ChildAddressQuery groupByCustomerId() Group by the customer_id column - * @method ChildAddressQuery groupByCustomerTitleId() Group by the customer_title_id column + * @method ChildAddressQuery groupByTitleId() Group by the title_id column * @method ChildAddressQuery groupByCompany() Group by the company column * @method ChildAddressQuery groupByFirstname() Group by the firstname column * @method ChildAddressQuery groupByLastname() Group by the lastname column @@ -71,6 +71,10 @@ use Thelia\Model\Map\AddressTableMap; * @method ChildAddressQuery rightJoinCustomerTitle($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CustomerTitle relation * @method ChildAddressQuery innerJoinCustomerTitle($relationAlias = null) Adds a INNER JOIN clause to the query using the CustomerTitle relation * + * @method ChildAddressQuery leftJoinCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the Country relation + * @method ChildAddressQuery rightJoinCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Country relation + * @method ChildAddressQuery innerJoinCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the Country relation + * * @method ChildAddressQuery leftJoinCartRelatedByAddressDeliveryId($relationAlias = null) Adds a LEFT JOIN clause to the query using the CartRelatedByAddressDeliveryId relation * @method ChildAddressQuery rightJoinCartRelatedByAddressDeliveryId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CartRelatedByAddressDeliveryId relation * @method ChildAddressQuery innerJoinCartRelatedByAddressDeliveryId($relationAlias = null) Adds a INNER JOIN clause to the query using the CartRelatedByAddressDeliveryId relation @@ -83,9 +87,9 @@ use Thelia\Model\Map\AddressTableMap; * @method ChildAddress findOneOrCreate(ConnectionInterface $con = null) Return the first ChildAddress matching the query, or a new ChildAddress object populated from the query conditions when no match is found * * @method ChildAddress findOneById(int $id) Return the first ChildAddress filtered by the id column - * @method ChildAddress findOneByTitle(string $title) Return the first ChildAddress filtered by the title column + * @method ChildAddress findOneByName(string $name) Return the first ChildAddress filtered by the name column * @method ChildAddress findOneByCustomerId(int $customer_id) Return the first ChildAddress filtered by the customer_id column - * @method ChildAddress findOneByCustomerTitleId(int $customer_title_id) Return the first ChildAddress filtered by the customer_title_id column + * @method ChildAddress findOneByTitleId(int $title_id) Return the first ChildAddress filtered by the title_id column * @method ChildAddress findOneByCompany(string $company) Return the first ChildAddress filtered by the company column * @method ChildAddress findOneByFirstname(string $firstname) Return the first ChildAddress filtered by the firstname column * @method ChildAddress findOneByLastname(string $lastname) Return the first ChildAddress filtered by the lastname column @@ -102,9 +106,9 @@ use Thelia\Model\Map\AddressTableMap; * @method ChildAddress findOneByUpdatedAt(string $updated_at) Return the first ChildAddress filtered by the updated_at column * * @method array findById(int $id) Return ChildAddress objects filtered by the id column - * @method array findByTitle(string $title) Return ChildAddress objects filtered by the title column + * @method array findByName(string $name) Return ChildAddress objects filtered by the name column * @method array findByCustomerId(int $customer_id) Return ChildAddress objects filtered by the customer_id column - * @method array findByCustomerTitleId(int $customer_title_id) Return ChildAddress objects filtered by the customer_title_id column + * @method array findByTitleId(int $title_id) Return ChildAddress objects filtered by the title_id column * @method array findByCompany(string $company) Return ChildAddress objects filtered by the company column * @method array findByFirstname(string $firstname) Return ChildAddress objects filtered by the firstname column * @method array findByLastname(string $lastname) Return ChildAddress objects filtered by the lastname column @@ -207,7 +211,7 @@ abstract class AddressQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, TITLE, CUSTOMER_ID, CUSTOMER_TITLE_ID, COMPANY, FIRSTNAME, LASTNAME, ADDRESS1, ADDRESS2, ADDRESS3, ZIPCODE, CITY, COUNTRY_ID, PHONE, CELLPHONE, IS_DEFAULT, CREATED_AT, UPDATED_AT FROM address WHERE ID = :p0'; + $sql = 'SELECT ID, NAME, CUSTOMER_ID, TITLE_ID, COMPANY, FIRSTNAME, LASTNAME, ADDRESS1, ADDRESS2, ADDRESS3, ZIPCODE, CITY, COUNTRY_ID, PHONE, CELLPHONE, IS_DEFAULT, CREATED_AT, UPDATED_AT FROM address WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -338,32 +342,32 @@ abstract class AddressQuery extends ModelCriteria } /** - * Filter the query on the title column + * Filter the query on the name column * * Example usage: * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * $query->filterByName('fooValue'); // WHERE name = 'fooValue' + * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' * * - * @param string $title The value to use as filter. + * @param string $name The value to use as filter. * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildAddressQuery The current query, for fluid interface */ - public function filterByTitle($title = null, $comparison = null) + public function filterByName($name = null, $comparison = null) { if (null === $comparison) { - if (is_array($title)) { + if (is_array($name)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); + } elseif (preg_match('/[\%\*]/', $name)) { + $name = str_replace('*', '%', $name); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(AddressTableMap::TITLE, $title, $comparison); + return $this->addUsingAlias(AddressTableMap::NAME, $name, $comparison); } /** @@ -410,18 +414,18 @@ abstract class AddressQuery extends ModelCriteria } /** - * Filter the query on the customer_title_id column + * Filter the query on the title_id column * * Example usage: * - * $query->filterByCustomerTitleId(1234); // WHERE customer_title_id = 1234 - * $query->filterByCustomerTitleId(array(12, 34)); // WHERE customer_title_id IN (12, 34) - * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12 + * $query->filterByTitleId(1234); // WHERE title_id = 1234 + * $query->filterByTitleId(array(12, 34)); // WHERE title_id IN (12, 34) + * $query->filterByTitleId(array('min' => 12)); // WHERE title_id > 12 * * * @see filterByCustomerTitle() * - * @param mixed $customerTitleId The value to use as filter. + * @param mixed $titleId The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -429,16 +433,16 @@ abstract class AddressQuery extends ModelCriteria * * @return ChildAddressQuery The current query, for fluid interface */ - public function filterByCustomerTitleId($customerTitleId = null, $comparison = null) + public function filterByTitleId($titleId = null, $comparison = null) { - if (is_array($customerTitleId)) { + if (is_array($titleId)) { $useMinMax = false; - if (isset($customerTitleId['min'])) { - $this->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId['min'], Criteria::GREATER_EQUAL); + if (isset($titleId['min'])) { + $this->addUsingAlias(AddressTableMap::TITLE_ID, $titleId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($customerTitleId['max'])) { - $this->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL); + if (isset($titleId['max'])) { + $this->addUsingAlias(AddressTableMap::TITLE_ID, $titleId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -449,7 +453,7 @@ abstract class AddressQuery extends ModelCriteria } } - return $this->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId, $comparison); + return $this->addUsingAlias(AddressTableMap::TITLE_ID, $titleId, $comparison); } /** @@ -694,6 +698,8 @@ abstract class AddressQuery extends ModelCriteria * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12 * * + * @see filterByCountry() + * * @param mixed $countryId The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. @@ -997,14 +1003,14 @@ abstract class AddressQuery extends ModelCriteria { if ($customerTitle instanceof \Thelia\Model\CustomerTitle) { return $this - ->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison); + ->addUsingAlias(AddressTableMap::TITLE_ID, $customerTitle->getId(), $comparison); } elseif ($customerTitle instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AddressTableMap::TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByCustomerTitle() only accepts arguments of type \Thelia\Model\CustomerTitle or Collection'); } @@ -1018,7 +1024,7 @@ abstract class AddressQuery extends ModelCriteria * * @return ChildAddressQuery The current query, for fluid interface */ - public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); $relationMap = $tableMap->getRelation('CustomerTitle'); @@ -1053,13 +1059,88 @@ abstract class AddressQuery extends ModelCriteria * * @return \Thelia\Model\CustomerTitleQuery A secondary query class using the current class as primary query */ - public function useCustomerTitleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useCustomerTitleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinCustomerTitle($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'CustomerTitle', '\Thelia\Model\CustomerTitleQuery'); } + /** + * Filter the query by a related \Thelia\Model\Country object + * + * @param \Thelia\Model\Country|ObjectCollection $country The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildAddressQuery The current query, for fluid interface + */ + public function filterByCountry($country, $comparison = null) + { + if ($country instanceof \Thelia\Model\Country) { + return $this + ->addUsingAlias(AddressTableMap::COUNTRY_ID, $country->getId(), $comparison); + } elseif ($country instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(AddressTableMap::COUNTRY_ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByCountry() only accepts arguments of type \Thelia\Model\Country or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Country relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildAddressQuery The current query, for fluid interface + */ + public function joinCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Country'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Country'); + } + + return $this; + } + + /** + * Use the Country relation Country object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CountryQuery A secondary query class using the current class as primary query + */ + public function useCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCountry($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Country', '\Thelia\Model\CountryQuery'); + } + /** * Filter the query by a related \Thelia\Model\Cart object * diff --git a/core/lib/Thelia/Model/Base/Country.php b/core/lib/Thelia/Model/Base/Country.php index 4d21c09c2..704375de2 100755 --- a/core/lib/Thelia/Model/Base/Country.php +++ b/core/lib/Thelia/Model/Base/Country.php @@ -17,6 +17,8 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; +use Thelia\Model\Address as ChildAddress; +use Thelia\Model\AddressQuery as ChildAddressQuery; use Thelia\Model\Area as ChildArea; use Thelia\Model\AreaQuery as ChildAreaQuery; use Thelia\Model\Country as ChildCountry; @@ -114,6 +116,12 @@ abstract class Country implements ActiveRecordInterface protected $collTaxRuleCountries; protected $collTaxRuleCountriesPartial; + /** + * @var ObjectCollection|ChildAddress[] Collection to store aggregation of ChildAddress objects. + */ + protected $collAddresses; + protected $collAddressesPartial; + /** * @var ObjectCollection|ChildCountryI18n[] Collection to store aggregation of ChildCountryI18n objects. */ @@ -148,6 +156,12 @@ abstract class Country implements ActiveRecordInterface */ protected $taxRuleCountriesScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $addressesScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -792,6 +806,8 @@ abstract class Country implements ActiveRecordInterface $this->aArea = null; $this->collTaxRuleCountries = null; + $this->collAddresses = null; + $this->collCountryI18ns = null; } // if (deep) @@ -956,6 +972,23 @@ abstract class Country implements ActiveRecordInterface } } + if ($this->addressesScheduledForDeletion !== null) { + if (!$this->addressesScheduledForDeletion->isEmpty()) { + \Thelia\Model\AddressQuery::create() + ->filterByPrimaryKeys($this->addressesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->addressesScheduledForDeletion = null; + } + } + + if ($this->collAddresses !== null) { + foreach ($this->collAddresses as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->countryI18nsScheduledForDeletion !== null) { if (!$this->countryI18nsScheduledForDeletion->isEmpty()) { \Thelia\Model\CountryI18nQuery::create() @@ -1174,6 +1207,9 @@ abstract class Country implements ActiveRecordInterface if (null !== $this->collTaxRuleCountries) { $result['TaxRuleCountries'] = $this->collTaxRuleCountries->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collAddresses) { + $result['Addresses'] = $this->collAddresses->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collCountryI18ns) { $result['CountryI18ns'] = $this->collCountryI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1363,6 +1399,12 @@ abstract class Country implements ActiveRecordInterface } } + foreach ($this->getAddresses() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addAddress($relObj->copy($deepCopy)); + } + } + foreach ($this->getCountryI18ns() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addCountryI18n($relObj->copy($deepCopy)); @@ -1463,6 +1505,9 @@ abstract class Country implements ActiveRecordInterface if ('TaxRuleCountry' == $relationName) { return $this->initTaxRuleCountries(); } + if ('Address' == $relationName) { + return $this->initAddresses(); + } if ('CountryI18n' == $relationName) { return $this->initCountryI18ns(); } @@ -1736,6 +1781,274 @@ abstract class Country implements ActiveRecordInterface return $this->getTaxRuleCountries($query, $con); } + /** + * Clears out the collAddresses collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addAddresses() + */ + public function clearAddresses() + { + $this->collAddresses = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collAddresses collection loaded partially. + */ + public function resetPartialAddresses($v = true) + { + $this->collAddressesPartial = $v; + } + + /** + * Initializes the collAddresses collection. + * + * By default this just sets the collAddresses collection to an empty array (like clearcollAddresses()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initAddresses($overrideExisting = true) + { + if (null !== $this->collAddresses && !$overrideExisting) { + return; + } + $this->collAddresses = new ObjectCollection(); + $this->collAddresses->setModel('\Thelia\Model\Address'); + } + + /** + * Gets an array of ChildAddress objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildCountry is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAddress[] List of ChildAddress objects + * @throws PropelException + */ + public function getAddresses($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collAddressesPartial && !$this->isNew(); + if (null === $this->collAddresses || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAddresses) { + // return empty collection + $this->initAddresses(); + } else { + $collAddresses = ChildAddressQuery::create(null, $criteria) + ->filterByCountry($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collAddressesPartial && count($collAddresses)) { + $this->initAddresses(false); + + foreach ($collAddresses as $obj) { + if (false == $this->collAddresses->contains($obj)) { + $this->collAddresses->append($obj); + } + } + + $this->collAddressesPartial = true; + } + + $collAddresses->getInternalIterator()->rewind(); + + return $collAddresses; + } + + if ($partial && $this->collAddresses) { + foreach ($this->collAddresses as $obj) { + if ($obj->isNew()) { + $collAddresses[] = $obj; + } + } + } + + $this->collAddresses = $collAddresses; + $this->collAddressesPartial = false; + } + } + + return $this->collAddresses; + } + + /** + * Sets a collection of Address objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $addresses A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCountry The current object (for fluent API support) + */ + public function setAddresses(Collection $addresses, ConnectionInterface $con = null) + { + $addressesToDelete = $this->getAddresses(new Criteria(), $con)->diff($addresses); + + + $this->addressesScheduledForDeletion = $addressesToDelete; + + foreach ($addressesToDelete as $addressRemoved) { + $addressRemoved->setCountry(null); + } + + $this->collAddresses = null; + foreach ($addresses as $address) { + $this->addAddress($address); + } + + $this->collAddresses = $addresses; + $this->collAddressesPartial = false; + + return $this; + } + + /** + * Returns the number of related Address objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related Address objects. + * @throws PropelException + */ + public function countAddresses(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collAddressesPartial && !$this->isNew(); + if (null === $this->collAddresses || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAddresses) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getAddresses()); + } + + $query = ChildAddressQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCountry($this) + ->count($con); + } + + return count($this->collAddresses); + } + + /** + * Method called to associate a ChildAddress object to this object + * through the ChildAddress foreign key attribute. + * + * @param ChildAddress $l ChildAddress + * @return \Thelia\Model\Country The current object (for fluent API support) + */ + public function addAddress(ChildAddress $l) + { + if ($this->collAddresses === null) { + $this->initAddresses(); + $this->collAddressesPartial = true; + } + + if (!in_array($l, $this->collAddresses->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddAddress($l); + } + + return $this; + } + + /** + * @param Address $address The address object to add. + */ + protected function doAddAddress($address) + { + $this->collAddresses[]= $address; + $address->setCountry($this); + } + + /** + * @param Address $address The address object to remove. + * @return ChildCountry The current object (for fluent API support) + */ + public function removeAddress($address) + { + if ($this->getAddresses()->contains($address)) { + $this->collAddresses->remove($this->collAddresses->search($address)); + if (null === $this->addressesScheduledForDeletion) { + $this->addressesScheduledForDeletion = clone $this->collAddresses; + $this->addressesScheduledForDeletion->clear(); + } + $this->addressesScheduledForDeletion[]= clone $address; + $address->setCountry(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Country is new, it will return + * an empty collection; or if this Country has previously + * been saved, it will retrieve related Addresses from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Country. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAddress[] List of ChildAddress objects + */ + public function getAddressesJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildAddressQuery::create(null, $criteria); + $query->joinWith('Customer', $joinBehavior); + + return $this->getAddresses($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Country is new, it will return + * an empty collection; or if this Country has previously + * been saved, it will retrieve related Addresses from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Country. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAddress[] List of ChildAddress objects + */ + public function getAddressesJoinCustomerTitle($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildAddressQuery::create(null, $criteria); + $query->joinWith('CustomerTitle', $joinBehavior); + + return $this->getAddresses($query, $con); + } + /** * Clears out the collCountryI18ns collection * @@ -1997,6 +2310,11 @@ abstract class Country implements ActiveRecordInterface $o->clearAllReferences($deep); } } + if ($this->collAddresses) { + foreach ($this->collAddresses as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collCountryI18ns) { foreach ($this->collCountryI18ns as $o) { $o->clearAllReferences($deep); @@ -2012,6 +2330,10 @@ abstract class Country implements ActiveRecordInterface $this->collTaxRuleCountries->clearIterator(); } $this->collTaxRuleCountries = null; + if ($this->collAddresses instanceof Collection) { + $this->collAddresses->clearIterator(); + } + $this->collAddresses = null; if ($this->collCountryI18ns instanceof Collection) { $this->collCountryI18ns->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/CountryQuery.php b/core/lib/Thelia/Model/Base/CountryQuery.php index 04a66530c..6c3a1c950 100755 --- a/core/lib/Thelia/Model/Base/CountryQuery.php +++ b/core/lib/Thelia/Model/Base/CountryQuery.php @@ -50,6 +50,10 @@ use Thelia\Model\Map\CountryTableMap; * @method ChildCountryQuery rightJoinTaxRuleCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the TaxRuleCountry relation * @method ChildCountryQuery innerJoinTaxRuleCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the TaxRuleCountry relation * + * @method ChildCountryQuery leftJoinAddress($relationAlias = null) Adds a LEFT JOIN clause to the query using the Address relation + * @method ChildCountryQuery rightJoinAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Address relation + * @method ChildCountryQuery innerJoinAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the Address relation + * * @method ChildCountryQuery leftJoinCountryI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the CountryI18n relation * @method ChildCountryQuery rightJoinCountryI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CountryI18n relation * @method ChildCountryQuery innerJoinCountryI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the CountryI18n relation @@ -654,6 +658,79 @@ abstract class CountryQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'TaxRuleCountry', '\Thelia\Model\TaxRuleCountryQuery'); } + /** + * Filter the query by a related \Thelia\Model\Address object + * + * @param \Thelia\Model\Address|ObjectCollection $address the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCountryQuery The current query, for fluid interface + */ + public function filterByAddress($address, $comparison = null) + { + if ($address instanceof \Thelia\Model\Address) { + return $this + ->addUsingAlias(CountryTableMap::ID, $address->getCountryId(), $comparison); + } elseif ($address instanceof ObjectCollection) { + return $this + ->useAddressQuery() + ->filterByPrimaryKeys($address->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByAddress() only accepts arguments of type \Thelia\Model\Address or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Address relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCountryQuery The current query, for fluid interface + */ + public function joinAddress($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Address'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Address'); + } + + return $this; + } + + /** + * Use the Address relation Address object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\AddressQuery A secondary query class using the current class as primary query + */ + public function useAddressQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinAddress($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Address', '\Thelia\Model\AddressQuery'); + } + /** * Filter the query by a related \Thelia\Model\CountryI18n object * diff --git a/core/lib/Thelia/Model/Base/Customer.php b/core/lib/Thelia/Model/Base/Customer.php index 295d56920..c3315ac6f 100755 --- a/core/lib/Thelia/Model/Base/Customer.php +++ b/core/lib/Thelia/Model/Base/Customer.php @@ -2153,6 +2153,31 @@ abstract class Customer implements ActiveRecordInterface return $this->getAddresses($query, $con); } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Customer is new, it will return + * an empty collection; or if this Customer has previously + * been saved, it will retrieve related Addresses from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Customer. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAddress[] List of ChildAddress objects + */ + public function getAddressesJoinCountry($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildAddressQuery::create(null, $criteria); + $query->joinWith('Country', $joinBehavior); + + return $this->getAddresses($query, $con); + } + /** * Clears out the collOrders collection * diff --git a/core/lib/Thelia/Model/Base/CustomerTitle.php b/core/lib/Thelia/Model/Base/CustomerTitle.php index 5d34c95e5..5f8b11dd9 100755 --- a/core/lib/Thelia/Model/Base/CustomerTitle.php +++ b/core/lib/Thelia/Model/Base/CustomerTitle.php @@ -883,10 +883,9 @@ abstract class CustomerTitle implements ActiveRecordInterface if ($this->addressesScheduledForDeletion !== null) { if (!$this->addressesScheduledForDeletion->isEmpty()) { - foreach ($this->addressesScheduledForDeletion as $address) { - // need to save related object because we set the relation to null - $address->save($con); - } + \Thelia\Model\AddressQuery::create() + ->filterByPrimaryKeys($this->addressesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->addressesScheduledForDeletion = null; } } @@ -1777,7 +1776,7 @@ abstract class CustomerTitle implements ActiveRecordInterface $this->addressesScheduledForDeletion = clone $this->collAddresses; $this->addressesScheduledForDeletion->clear(); } - $this->addressesScheduledForDeletion[]= $address; + $this->addressesScheduledForDeletion[]= clone $address; $address->setCustomerTitle(null); } @@ -1809,6 +1808,31 @@ abstract class CustomerTitle implements ActiveRecordInterface return $this->getAddresses($query, $con); } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CustomerTitle is new, it will return + * an empty collection; or if this CustomerTitle has previously + * been saved, it will retrieve related Addresses from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in CustomerTitle. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAddress[] List of ChildAddress objects + */ + public function getAddressesJoinCountry($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildAddressQuery::create(null, $criteria); + $query->joinWith('Country', $joinBehavior); + + return $this->getAddresses($query, $con); + } + /** * Clears out the collCustomerTitleI18ns collection * diff --git a/core/lib/Thelia/Model/Base/CustomerTitleQuery.php b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php index f3c372248..ea34c8c91 100755 --- a/core/lib/Thelia/Model/Base/CustomerTitleQuery.php +++ b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php @@ -523,7 +523,7 @@ abstract class CustomerTitleQuery extends ModelCriteria { if ($address instanceof \Thelia\Model\Address) { return $this - ->addUsingAlias(CustomerTitleTableMap::ID, $address->getCustomerTitleId(), $comparison); + ->addUsingAlias(CustomerTitleTableMap::ID, $address->getTitleId(), $comparison); } elseif ($address instanceof ObjectCollection) { return $this ->useAddressQuery() @@ -542,7 +542,7 @@ abstract class CustomerTitleQuery extends ModelCriteria * * @return ChildCustomerTitleQuery The current query, for fluid interface */ - public function joinAddress($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinAddress($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); $relationMap = $tableMap->getRelation('Address'); @@ -577,7 +577,7 @@ abstract class CustomerTitleQuery extends ModelCriteria * * @return \Thelia\Model\AddressQuery A secondary query class using the current class as primary query */ - public function useAddressQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useAddressQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinAddress($relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Map/AddressTableMap.php b/core/lib/Thelia/Model/Map/AddressTableMap.php index 2402b3302..dabd6a54e 100755 --- a/core/lib/Thelia/Model/Map/AddressTableMap.php +++ b/core/lib/Thelia/Model/Map/AddressTableMap.php @@ -75,9 +75,9 @@ class AddressTableMap extends TableMap const ID = 'address.ID'; /** - * the column name for the TITLE field + * the column name for the NAME field */ - const TITLE = 'address.TITLE'; + const NAME = 'address.NAME'; /** * the column name for the CUSTOMER_ID field @@ -85,9 +85,9 @@ class AddressTableMap extends TableMap const CUSTOMER_ID = 'address.CUSTOMER_ID'; /** - * the column name for the CUSTOMER_TITLE_ID field + * the column name for the TITLE_ID field */ - const CUSTOMER_TITLE_ID = 'address.CUSTOMER_TITLE_ID'; + const TITLE_ID = 'address.TITLE_ID'; /** * the column name for the COMPANY field @@ -171,11 +171,11 @@ class AddressTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Title', 'CustomerId', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'Cellphone', 'IsDefault', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'title', 'customerId', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'cellphone', 'isDefault', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(AddressTableMap::ID, AddressTableMap::TITLE, AddressTableMap::CUSTOMER_ID, AddressTableMap::CUSTOMER_TITLE_ID, AddressTableMap::COMPANY, AddressTableMap::FIRSTNAME, AddressTableMap::LASTNAME, AddressTableMap::ADDRESS1, AddressTableMap::ADDRESS2, AddressTableMap::ADDRESS3, AddressTableMap::ZIPCODE, AddressTableMap::CITY, AddressTableMap::COUNTRY_ID, AddressTableMap::PHONE, AddressTableMap::CELLPHONE, AddressTableMap::IS_DEFAULT, AddressTableMap::CREATED_AT, AddressTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'TITLE', 'CUSTOMER_ID', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'COUNTRY_ID', 'PHONE', 'CELLPHONE', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'title', 'customer_id', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'country_id', 'phone', 'cellphone', 'is_default', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'Name', 'CustomerId', 'TitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'Cellphone', 'IsDefault', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'name', 'customerId', 'titleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'cellphone', 'isDefault', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AddressTableMap::ID, AddressTableMap::NAME, AddressTableMap::CUSTOMER_ID, AddressTableMap::TITLE_ID, AddressTableMap::COMPANY, AddressTableMap::FIRSTNAME, AddressTableMap::LASTNAME, AddressTableMap::ADDRESS1, AddressTableMap::ADDRESS2, AddressTableMap::ADDRESS3, AddressTableMap::ZIPCODE, AddressTableMap::CITY, AddressTableMap::COUNTRY_ID, AddressTableMap::PHONE, AddressTableMap::CELLPHONE, AddressTableMap::IS_DEFAULT, AddressTableMap::CREATED_AT, AddressTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'NAME', 'CUSTOMER_ID', 'TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'COUNTRY_ID', 'PHONE', 'CELLPHONE', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'name', 'customer_id', 'title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'country_id', 'phone', 'cellphone', 'is_default', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); @@ -186,11 +186,11 @@ class AddressTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Title' => 1, 'CustomerId' => 2, 'CustomerTitleId' => 3, 'Company' => 4, 'Firstname' => 5, 'Lastname' => 6, 'Address1' => 7, 'Address2' => 8, 'Address3' => 9, 'Zipcode' => 10, 'City' => 11, 'CountryId' => 12, 'Phone' => 13, 'Cellphone' => 14, 'IsDefault' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'title' => 1, 'customerId' => 2, 'customerTitleId' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'countryId' => 12, 'phone' => 13, 'cellphone' => 14, 'isDefault' => 15, 'createdAt' => 16, 'updatedAt' => 17, ), - self::TYPE_COLNAME => array(AddressTableMap::ID => 0, AddressTableMap::TITLE => 1, AddressTableMap::CUSTOMER_ID => 2, AddressTableMap::CUSTOMER_TITLE_ID => 3, AddressTableMap::COMPANY => 4, AddressTableMap::FIRSTNAME => 5, AddressTableMap::LASTNAME => 6, AddressTableMap::ADDRESS1 => 7, AddressTableMap::ADDRESS2 => 8, AddressTableMap::ADDRESS3 => 9, AddressTableMap::ZIPCODE => 10, AddressTableMap::CITY => 11, AddressTableMap::COUNTRY_ID => 12, AddressTableMap::PHONE => 13, AddressTableMap::CELLPHONE => 14, AddressTableMap::IS_DEFAULT => 15, AddressTableMap::CREATED_AT => 16, AddressTableMap::UPDATED_AT => 17, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'TITLE' => 1, 'CUSTOMER_ID' => 2, 'CUSTOMER_TITLE_ID' => 3, 'COMPANY' => 4, 'FIRSTNAME' => 5, 'LASTNAME' => 6, 'ADDRESS1' => 7, 'ADDRESS2' => 8, 'ADDRESS3' => 9, 'ZIPCODE' => 10, 'CITY' => 11, 'COUNTRY_ID' => 12, 'PHONE' => 13, 'CELLPHONE' => 14, 'IS_DEFAULT' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ), - self::TYPE_FIELDNAME => array('id' => 0, 'title' => 1, 'customer_id' => 2, 'customer_title_id' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'country_id' => 12, 'phone' => 13, 'cellphone' => 14, 'is_default' => 15, 'created_at' => 16, 'updated_at' => 17, ), + self::TYPE_PHPNAME => array('Id' => 0, 'Name' => 1, 'CustomerId' => 2, 'TitleId' => 3, 'Company' => 4, 'Firstname' => 5, 'Lastname' => 6, 'Address1' => 7, 'Address2' => 8, 'Address3' => 9, 'Zipcode' => 10, 'City' => 11, 'CountryId' => 12, 'Phone' => 13, 'Cellphone' => 14, 'IsDefault' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'name' => 1, 'customerId' => 2, 'titleId' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'countryId' => 12, 'phone' => 13, 'cellphone' => 14, 'isDefault' => 15, 'createdAt' => 16, 'updatedAt' => 17, ), + self::TYPE_COLNAME => array(AddressTableMap::ID => 0, AddressTableMap::NAME => 1, AddressTableMap::CUSTOMER_ID => 2, AddressTableMap::TITLE_ID => 3, AddressTableMap::COMPANY => 4, AddressTableMap::FIRSTNAME => 5, AddressTableMap::LASTNAME => 6, AddressTableMap::ADDRESS1 => 7, AddressTableMap::ADDRESS2 => 8, AddressTableMap::ADDRESS3 => 9, AddressTableMap::ZIPCODE => 10, AddressTableMap::CITY => 11, AddressTableMap::COUNTRY_ID => 12, AddressTableMap::PHONE => 13, AddressTableMap::CELLPHONE => 14, AddressTableMap::IS_DEFAULT => 15, AddressTableMap::CREATED_AT => 16, AddressTableMap::UPDATED_AT => 17, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'NAME' => 1, 'CUSTOMER_ID' => 2, 'TITLE_ID' => 3, 'COMPANY' => 4, 'FIRSTNAME' => 5, 'LASTNAME' => 6, 'ADDRESS1' => 7, 'ADDRESS2' => 8, 'ADDRESS3' => 9, 'ZIPCODE' => 10, 'CITY' => 11, 'COUNTRY_ID' => 12, 'PHONE' => 13, 'CELLPHONE' => 14, 'IS_DEFAULT' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ), + self::TYPE_FIELDNAME => array('id' => 0, 'name' => 1, 'customer_id' => 2, 'title_id' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'country_id' => 12, 'phone' => 13, 'cellphone' => 14, 'is_default' => 15, 'created_at' => 16, 'updated_at' => 17, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); @@ -211,9 +211,9 @@ class AddressTableMap extends TableMap $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('NAME', 'Name', 'VARCHAR', false, 255, null); $this->addForeignKey('CUSTOMER_ID', 'CustomerId', 'INTEGER', 'customer', 'ID', true, null, null); - $this->addForeignKey('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', 'customer_title', 'ID', false, null, null); + $this->addForeignKey('TITLE_ID', 'TitleId', 'INTEGER', 'customer_title', 'ID', true, null, null); $this->addColumn('COMPANY', 'Company', 'VARCHAR', false, 255, null); $this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null); $this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null); @@ -222,7 +222,7 @@ class AddressTableMap extends TableMap $this->addColumn('ADDRESS3', 'Address3', 'VARCHAR', true, 255, null); $this->addColumn('ZIPCODE', 'Zipcode', 'VARCHAR', true, 10, null); $this->addColumn('CITY', 'City', 'VARCHAR', true, 255, null); - $this->addColumn('COUNTRY_ID', 'CountryId', 'INTEGER', true, null, null); + $this->addForeignKey('COUNTRY_ID', 'CountryId', 'INTEGER', 'country', 'ID', true, null, null); $this->addColumn('PHONE', 'Phone', 'VARCHAR', false, 20, null); $this->addColumn('CELLPHONE', 'Cellphone', 'VARCHAR', false, 20, null); $this->addColumn('IS_DEFAULT', 'IsDefault', 'TINYINT', false, null, 0); @@ -236,7 +236,8 @@ class AddressTableMap extends TableMap public function buildRelations() { $this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('CustomerTitle', '\\Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), 'RESTRICT', 'RESTRICT'); + $this->addRelation('CustomerTitle', '\\Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('title_id' => 'id', ), 'RESTRICT', 'RESTRICT'); + $this->addRelation('Country', '\\Thelia\\Model\\Country', RelationMap::MANY_TO_ONE, array('country_id' => 'id', ), 'RESTRICT', 'RESTRICT'); $this->addRelation('CartRelatedByAddressDeliveryId', '\\Thelia\\Model\\Cart', RelationMap::ONE_TO_MANY, array('id' => 'address_delivery_id', ), null, null, 'CartsRelatedByAddressDeliveryId'); $this->addRelation('CartRelatedByAddressInvoiceId', '\\Thelia\\Model\\Cart', RelationMap::ONE_TO_MANY, array('id' => 'address_invoice_id', ), null, null, 'CartsRelatedByAddressInvoiceId'); } // buildRelations() @@ -393,9 +394,9 @@ class AddressTableMap extends TableMap { if (null === $alias) { $criteria->addSelectColumn(AddressTableMap::ID); - $criteria->addSelectColumn(AddressTableMap::TITLE); + $criteria->addSelectColumn(AddressTableMap::NAME); $criteria->addSelectColumn(AddressTableMap::CUSTOMER_ID); - $criteria->addSelectColumn(AddressTableMap::CUSTOMER_TITLE_ID); + $criteria->addSelectColumn(AddressTableMap::TITLE_ID); $criteria->addSelectColumn(AddressTableMap::COMPANY); $criteria->addSelectColumn(AddressTableMap::FIRSTNAME); $criteria->addSelectColumn(AddressTableMap::LASTNAME); @@ -412,9 +413,9 @@ class AddressTableMap extends TableMap $criteria->addSelectColumn(AddressTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.NAME'); $criteria->addSelectColumn($alias . '.CUSTOMER_ID'); - $criteria->addSelectColumn($alias . '.CUSTOMER_TITLE_ID'); + $criteria->addSelectColumn($alias . '.TITLE_ID'); $criteria->addSelectColumn($alias . '.COMPANY'); $criteria->addSelectColumn($alias . '.FIRSTNAME'); $criteria->addSelectColumn($alias . '.LASTNAME'); diff --git a/core/lib/Thelia/Model/Map/CountryTableMap.php b/core/lib/Thelia/Model/Map/CountryTableMap.php index 3060da70f..e7c356f08 100755 --- a/core/lib/Thelia/Model/Map/CountryTableMap.php +++ b/core/lib/Thelia/Model/Map/CountryTableMap.php @@ -180,6 +180,7 @@ class CountryTableMap extends TableMap { $this->addRelation('Area', '\\Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'SET NULL', 'RESTRICT'); $this->addRelation('TaxRuleCountry', '\\Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'CASCADE', 'RESTRICT', 'TaxRuleCountries'); + $this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'RESTRICT', 'RESTRICT', 'Addresses'); $this->addRelation('CountryI18n', '\\Thelia\\Model\\CountryI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CountryI18ns'); } // buildRelations() diff --git a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php index 44b16fafd..c10ce2500 100755 --- a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php @@ -167,7 +167,7 @@ class CustomerTitleTableMap extends TableMap public function buildRelations() { $this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::ONE_TO_MANY, array('id' => 'title_id', ), 'RESTRICT', 'RESTRICT', 'Customers'); - $this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_title_id', ), 'RESTRICT', 'RESTRICT', 'Addresses'); + $this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'title_id', ), 'RESTRICT', 'RESTRICT', 'Addresses'); $this->addRelation('CustomerTitleI18n', '\\Thelia\\Model\\CustomerTitleI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CustomerTitleI18ns'); } // buildRelations() diff --git a/install/insert.sql b/install/insert.sql index fb6b68ab9..6fe5db6d8 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -22,3 +22,268 @@ INSERT INTO `customer_title_i18n` (`id`, `locale`, `short`, `long`) VALUES (3, 'en_US', 'Miss', 'Miss'), (3, 'fr_FR', 'Mlle', 'Madamemoiselle'); +INSERT INTO `country` (`id`, `area_id`, `isocode`, `isoalpha2`, `isoalpha3`, `created_at`, `updated_at`) VALUES +(1, NULL, '4', 'AF', 'AFG', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(2, NULL, '710', 'ZA', 'ZAF', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(3, NULL, '8', 'AL', 'ALB', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(4, NULL, '12', 'DZ', 'DZA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(5, NULL, '276', 'DE', 'DEU', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(6, NULL, '20', 'AD', 'AND', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(7, NULL, '24', 'AO', 'AGO', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(8, NULL, '28', 'AG', 'ATG', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(9, NULL, '682', 'SA', 'SAU', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(10, NULL, '32', 'AR', 'ARG', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(11, NULL, '51', 'AM', 'ARM', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(12, NULL, '36', 'AU', 'AUS', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(13, NULL, '40', 'AT', 'AUT', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(14, NULL, '31', 'AZ', 'AZE', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(15, NULL, '44', 'BS', 'BHS', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(16, NULL, '48', 'BR', 'BHR', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(17, NULL, '50', 'BD', 'BGD', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(18, NULL, '52', 'BB', 'BRB', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(19, NULL, '585', 'PW', 'PLW', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(20, NULL, '56', 'BE', 'BEL', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(21, NULL, '84', 'BL', 'BLZ', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(22, NULL, '204', 'BJ', 'BEN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(23, NULL, '64', 'BT', 'BTN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(24, NULL, '112', 'BY', 'BLR', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(25, NULL, '104', 'MM', 'MMR', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(26, NULL, '68', 'BO', 'BOL', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(27, NULL, '70', 'BA', 'BIH', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(28, NULL, '72', 'BW', 'BWA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(29, NULL, '76', 'BR', 'BRA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(30, NULL, '96', 'BN', 'BRN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(31, NULL, '100', 'BG', 'BGR', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(32, NULL, '854', 'BF', 'BFA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(33, NULL, '108', 'BI', 'BDI', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(34, NULL, '116', 'KH', 'KHM', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(35, NULL, '120', 'CM', 'CMR', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(37, NULL, '132', 'CV', 'CPV', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(38, NULL, '152', 'CL', 'CHL', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(39, NULL, '156', 'CN', 'CHN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(40, NULL, '196', 'CY', 'CYP', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(41, NULL, '170', 'CO', 'COL', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(42, NULL, '174', 'KM', 'COM', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(43, NULL, '178', 'CG', 'COG', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(44, NULL, '184', 'CK', 'COK', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(45, NULL, '408', 'KP', 'PRK', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(46, NULL, '410', 'KR', 'KOR', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(47, NULL, '188', 'CR', 'CRI', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(48, NULL, '384', 'CI', 'CIV', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(49, NULL, '191', 'HR', 'HRV', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(50, NULL, '192', 'CU', 'CUB', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(51, NULL, '208', 'DK', 'DNK', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(52, NULL, '262', 'DJ', 'DJI', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(53, NULL, '212', 'DM', 'DMA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(54, NULL, '818', 'EG', 'EGY', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(55, NULL, '784', 'AE', 'ARE', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(56, NULL, '218', 'EC', 'ECU', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(57, NULL, '232', 'ER', 'ERI', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(58, NULL, '724', 'ES', 'ESP', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(59, NULL, '233', 'EE', 'EST', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(61, NULL, '231', 'ET', 'ETH', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(62, NULL, '242', 'FJ', 'FJI', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(63, NULL, '246', 'FI', 'FIN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(64, NULL, '250', 'FR', 'FRA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(65, NULL, '266', 'GA', 'GAB', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(66, NULL, '270', 'GM', 'GMB', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(67, NULL, '268', 'GE', 'GEO', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(68, NULL, '288', 'GH', 'GHA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(69, NULL, '300', 'GR', 'GRC', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(70, NULL, '308', 'GD', 'GRD', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(71, NULL, '320', 'GT', 'GTM', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(72, NULL, '324', 'GN', 'GIN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(73, NULL, '624', 'GW', 'GNB', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(74, NULL, '226', 'GQ', 'GNQ', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(75, NULL, '328', 'GY', 'GUY', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(76, NULL, '332', 'HT', 'HTI', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(77, NULL, '340', 'HN', 'HND', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(78, NULL, '348', 'HU', 'HUN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(79, NULL, '356', 'IN', 'IND', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(80, NULL, '360', 'ID', 'IDN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(81, NULL, '364', 'IR', 'IRN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(82, NULL, '368', 'IQ', 'IRQ', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(83, NULL, '372', 'IE', 'IRL', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(84, NULL, '352', 'IS', 'ISL', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(85, NULL, '376', 'IL', 'ISR', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(86, NULL, '380', 'IT', 'ITA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(87, NULL, '388', 'JM', 'JAM', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(88, NULL, '392', 'JP', 'JPN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(89, NULL, '400', 'JO', 'JOR', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(90, NULL, '398', 'KZ', 'KAZ', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(91, NULL, '404', 'KE', 'KEN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(92, NULL, '417', 'KG', 'KGZ', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(93, NULL, '296', 'KI', 'KIR', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(94, NULL, '414', 'KW', 'KWT', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(95, NULL, '418', 'LA', 'LAO', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(96, NULL, '426', 'LS', 'LSO', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(97, NULL, '428', 'LV', 'LVA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(98, NULL, '422', 'LB', 'LBN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(99, NULL, '430', 'LR', 'LBR', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(100, NULL, '343', 'LY', 'LBY', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(101, NULL, '438', 'LI', 'LIE', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(102, NULL, '440', 'LT', 'LTU', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(103, NULL, '442', 'LU', 'LUX', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(104, NULL, '807', 'MK', 'MKD', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(105, NULL, '450', 'MD', 'MDG', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(106, NULL, '458', 'MY', 'MYS', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(107, NULL, '454', 'MW', 'MWI', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(108, NULL, '462', 'MV', 'MDV', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(109, NULL, '466', 'ML', 'MLI', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(110, NULL, '470', 'MT', 'MLT', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(111, NULL, '504', 'MA', 'MAR', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(112, NULL, '584', 'MH', 'MHL', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(113, NULL, '480', 'MU', 'MUS', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(114, NULL, '478', 'MR', 'MRT', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(115, NULL, '484', 'MX', 'MEX', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(116, NULL, '583', 'FM', 'FSM', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(117, NULL, '498', 'MD', 'MDA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(118, NULL, '492', 'MC', 'MCO', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(119, NULL, '496', 'MN', 'MNG', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(120, NULL, '508', 'MZ', 'MOZ', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(121, NULL, '516', 'NA', 'NAM', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(122, NULL, '520', 'NR', 'NRU', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(123, NULL, '524', 'NP', 'NPL', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(124, NULL, '558', 'NI', 'NIC', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(125, NULL, '562', 'NE', 'NER', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(126, NULL, '566', 'NG', 'NGA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(127, NULL, '570', 'NU', 'NIU', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(128, NULL, '578', 'NO', 'NOR', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(129, NULL, '554', 'NZ', 'NZL', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(130, NULL, '512', 'OM', 'OMN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(131, NULL, '800', 'UG', 'UGA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(132, NULL, '860', 'UZ', 'UZB', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(133, NULL, '586', 'PK', 'PAK', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(134, NULL, '591', 'PA', 'PAN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(135, NULL, '598', 'PG', 'PNG', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(136, NULL, '600', 'PY', 'PRY', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(137, NULL, '528', 'NL', 'NLD', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(138, NULL, '604', 'PE', 'PER', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(139, NULL, '608', 'PH', 'PHL', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(140, NULL, '616', 'PL', 'POL', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(141, NULL, '620', 'PT', 'PRT', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(142, NULL, '634', 'QA', 'QAT', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(143, NULL, '140', 'CF', 'CAF', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(144, NULL, '214', 'DO', 'DOM', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(145, NULL, '203', 'CZ', 'CZE', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(146, NULL, '642', 'RO', 'ROU', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(147, NULL, '826', 'GB', 'GBR', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(148, NULL, '643', 'RU', 'RUS', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(149, NULL, '646', 'RW', 'RWA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(150, NULL, '659', 'KN', 'KNA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(151, NULL, '662', 'LC', 'LCA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(152, NULL, '674', 'SM', 'SMR', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(153, NULL, '670', 'VC', 'VCT', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(154, NULL, '90', 'SB', 'SLB', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(155, NULL, '222', 'SV', 'SLV', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(156, NULL, '882', 'WS', 'WSM', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(157, NULL, '678', 'ST', 'STP', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(158, NULL, '686', 'SN', 'SEN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(159, NULL, '690', 'SC', 'SYC', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(160, NULL, '694', 'SL', 'SLE', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(161, NULL, '702', 'SG', 'SGP', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(162, NULL, '703', 'SK', 'SVK', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(163, NULL, '705', 'SI', 'SVN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(164, NULL, '706', 'SO', 'SOM', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(165, NULL, '729', 'SD', 'SDN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(166, NULL, '144', 'LK', 'LKA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(167, NULL, '752', 'SE', 'SWE', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(168, NULL, '756', 'CH', 'CHE', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(169, NULL, '740', 'SR', 'SUR', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(170, NULL, '748', 'SZ', 'SWZ', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(171, NULL, '760', 'SY', 'SYR', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(172, NULL, '762', 'TJ', 'TJK', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(173, NULL, '834', 'TZ', 'TZA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(174, NULL, '148', 'TD', 'TCD', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(175, NULL, '764', 'TH', 'THA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(176, NULL, '768', 'TG', 'TGO', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(177, NULL, '776', 'TO', 'TON', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(178, NULL, '780', 'TT', 'TTO', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(179, NULL, '788', 'TN', 'TUN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(180, NULL, '795', 'TM', 'TKM', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(181, NULL, '792', 'TR', 'TUR', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(182, NULL, '798', 'TV', 'TUV', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(183, NULL, '804', 'UA', 'UKR', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(184, NULL, '858', 'UY', 'URY', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(185, NULL, '336', 'VA', 'VAT', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(186, NULL, '548', 'VU', 'VUT', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(187, NULL, '862', 'VE', 'VEN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(188, NULL, '704', 'VN', 'VNM', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(189, NULL, '887', 'YE', 'YEM', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(190, NULL, '807', 'MK', 'MKD', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(191, NULL, '180', 'CD', 'COD', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(192, NULL, '894', 'ZM', 'ZMB', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(193, NULL, '716', 'ZW', 'ZWE', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(196, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(197, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(198, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(199, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(200, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(201, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(202, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(203, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(204, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(205, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(206, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(207, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(208, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(209, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(210, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(211, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(212, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(213, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(214, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(215, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(216, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(217, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(218, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(219, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(220, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(221, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(222, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(223, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(224, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(225, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(226, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(227, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(228, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(229, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(230, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(231, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(232, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(233, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(234, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(235, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(236, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(237, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(238, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(239, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(240, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(241, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(242, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(243, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(244, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(245, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(246, NULL, '124', 'CA', 'CAN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(247, NULL, '124', 'CA', 'CAN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(248, NULL, '124', 'CA', 'CAN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(249, NULL, '124', 'CA', 'CAN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(250, NULL, '124', 'CA', 'CAN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(251, NULL, '124', 'CA', 'CAN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(252, NULL, '124', 'CA', 'CAN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(253, NULL, '124', 'CA', 'CAN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(254, NULL, '124', 'CA', 'CAN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(255, NULL, '124', 'CA', 'CAN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(256, NULL, '124', 'CA', 'CAN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(257, NULL, '124', 'CA', 'CAN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(258, NULL, '124', 'CA', 'CAN', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(259, NULL, '312', 'GP', 'GLP', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(260, NULL, '254', 'GF', 'GUF', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(261, NULL, '474', 'MQ', 'MTQ', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(262, NULL, '175', 'YT', 'MYT', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(263, NULL, '638', 'RE', 'REU', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(264, NULL, '666', 'PM', 'SPM', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(265, NULL, '540', 'NC', 'NCL', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(266, NULL, '258', 'PF', 'PYF', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(267, NULL, '876', 'WF', 'WLF', '2013-07-26 14:44:00', '2013-07-26 14:44:00'), +(268, NULL, '840', 'US', 'USA', '2013-07-26 14:44:00', '2013-07-26 14:44:00'); diff --git a/install/thelia.sql b/install/thelia.sql index 62326cc2e..006d86d19 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -483,9 +483,9 @@ DROP TABLE IF EXISTS `address`; CREATE TABLE `address` ( `id` INTEGER NOT NULL AUTO_INCREMENT, - `title` VARCHAR(255), + `name` VARCHAR(255), `customer_id` INTEGER NOT NULL, - `customer_title_id` INTEGER, + `title_id` INTEGER NOT NULL, `company` VARCHAR(255), `firstname` VARCHAR(255) NOT NULL, `lastname` VARCHAR(255) NOT NULL, @@ -502,16 +502,22 @@ CREATE TABLE `address` `updated_at` DATETIME, PRIMARY KEY (`id`), INDEX `idx_address_customer_id` (`customer_id`), - INDEX `idx_address_customer_title_id` (`customer_title_id`), + INDEX `idx_address_customer_title_id` (`title_id`), + INDEX `idx_address_country_id` (`country_id`), CONSTRAINT `fk_address_customer_id` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, CONSTRAINT `fk_address_customer_title_id` - FOREIGN KEY (`customer_title_id`) + FOREIGN KEY (`title_id`) REFERENCES `customer_title` (`id`) ON UPDATE RESTRICT + ON DELETE RESTRICT, + CONSTRAINT `fk_address_country_id` + FOREIGN KEY (`country_id`) + REFERENCES `country` (`id`) + ON UPDATE RESTRICT ON DELETE RESTRICT ) ENGINE=InnoDB; diff --git a/local/config/schema.xml b/local/config/schema.xml index 2ef29e927..de7e6751e 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -351,9 +351,9 @@ - + - + @@ -370,13 +370,19 @@ - + + + + - + + + +
diff --git a/templates/default/customer.html b/templates/default/customer.html index 4d7a30115..1bfc4e6e4 100755 --- a/templates/default/customer.html +++ b/templates/default/customer.html @@ -1,5 +1,10 @@ +

CUSTOMER

+ +

Information

+ +{loop name="customer" type="customer"} + - {loop name="customer" type="customer"} @@ -10,7 +15,11 @@ - + @@ -36,5 +45,63 @@ - {/loop} -
ID #ID
Title#TITLE + {loop name="title" type="title" id="#TITLE"} + #LONG (#SHORT) + {/loop} +
FirstnameDiscount #DISCOUNT %
\ No newline at end of file + + +{/loop} + +

Addresses

+ +{loop name="addresses" type="address"} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID#ID
Name#NAME
Title + {loop name="title" type="title"} + #LONG (#SHORT) + {/loop} +
Company#COMPANY
Firstname#FIRSTNAME
Lastname#LASTNAME
Address#ADDRESS1
#ADDRESS2
#ADDRESS3
Zipcode#ZIPCODE
City#CITY
Phone#PHONE
Cellphone#CELLPHONE
+ +{/loop} \ No newline at end of file