+ * $query->filterByProductSaleElementsRef('fooValue'); // WHERE product_sale_elements_ref = 'fooValue'
+ * $query->filterByProductSaleElementsRef('%fooValue%'); // WHERE product_sale_elements_ref LIKE '%fooValue%'
+ *
+ *
+ * @param string $productSaleElementsRef 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 ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByProductSaleElementsRef($productSaleElementsRef = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($productSaleElementsRef)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $productSaleElementsRef)) {
+ $productSaleElementsRef = str_replace('*', '%', $productSaleElementsRef);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF, $productSaleElementsRef, $comparison);
+ }
+
/**
* Filter the query on the title column
*
@@ -406,6 +467,35 @@ abstract class OrderProductQuery extends ModelCriteria
return $this->addUsingAlias(OrderProductTableMap::TITLE, $title, $comparison);
}
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo 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 ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::CHAPO, $chapo, $comparison);
+ }
+
/**
* Filter the query on the description column
*
@@ -436,32 +526,32 @@ abstract class OrderProductQuery extends ModelCriteria
}
/**
- * Filter the query on the chapo column
+ * Filter the query on the postscriptum column
*
* Example usage:
*
- * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
- * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
*
*
- * @param string $chapo The value to use as filter.
+ * @param string $postscriptum 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 ChildOrderProductQuery The current query, for fluid interface
*/
- public function filterByChapo($chapo = null, $comparison = null)
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
{
if (null === $comparison) {
- if (is_array($chapo)) {
+ if (is_array($postscriptum)) {
$comparison = Criteria::IN;
- } elseif (preg_match('/[\%\*]/', $chapo)) {
- $chapo = str_replace('*', '%', $chapo);
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
$comparison = Criteria::LIKE;
}
}
- return $this->addUsingAlias(OrderProductTableMap::CHAPO, $chapo, $comparison);
+ return $this->addUsingAlias(OrderProductTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
}
/**
@@ -547,16 +637,45 @@ abstract class OrderProductQuery extends ModelCriteria
}
/**
- * Filter the query on the tax column
+ * Filter the query on the promo_price column
*
* Example usage:
*
- * $query->filterByTax(1234); // WHERE tax = 1234
- * $query->filterByTax(array(12, 34)); // WHERE tax IN (12, 34)
- * $query->filterByTax(array('min' => 12)); // WHERE tax > 12
+ * $query->filterByPromoPrice('fooValue'); // WHERE promo_price = 'fooValue'
+ * $query->filterByPromoPrice('%fooValue%'); // WHERE promo_price LIKE '%fooValue%'
*
*
- * @param mixed $tax The value to use as filter.
+ * @param string $promoPrice 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 ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByPromoPrice($promoPrice = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($promoPrice)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $promoPrice)) {
+ $promoPrice = str_replace('*', '%', $promoPrice);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::PROMO_PRICE, $promoPrice, $comparison);
+ }
+
+ /**
+ * Filter the query on the was_new column
+ *
+ * Example usage:
+ *
+ * $query->filterByWasNew(1234); // WHERE was_new = 1234
+ * $query->filterByWasNew(array(12, 34)); // WHERE was_new IN (12, 34)
+ * $query->filterByWasNew(array('min' => 12)); // WHERE was_new > 12
+ *
+ *
+ * @param mixed $wasNew 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.
@@ -564,16 +683,16 @@ abstract class OrderProductQuery extends ModelCriteria
*
* @return ChildOrderProductQuery The current query, for fluid interface
*/
- public function filterByTax($tax = null, $comparison = null)
+ public function filterByWasNew($wasNew = null, $comparison = null)
{
- if (is_array($tax)) {
+ if (is_array($wasNew)) {
$useMinMax = false;
- if (isset($tax['min'])) {
- $this->addUsingAlias(OrderProductTableMap::TAX, $tax['min'], Criteria::GREATER_EQUAL);
+ if (isset($wasNew['min'])) {
+ $this->addUsingAlias(OrderProductTableMap::WAS_NEW, $wasNew['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
- if (isset($tax['max'])) {
- $this->addUsingAlias(OrderProductTableMap::TAX, $tax['max'], Criteria::LESS_EQUAL);
+ if (isset($wasNew['max'])) {
+ $this->addUsingAlias(OrderProductTableMap::WAS_NEW, $wasNew['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
@@ -584,7 +703,135 @@ abstract class OrderProductQuery extends ModelCriteria
}
}
- return $this->addUsingAlias(OrderProductTableMap::TAX, $tax, $comparison);
+ return $this->addUsingAlias(OrderProductTableMap::WAS_NEW, $wasNew, $comparison);
+ }
+
+ /**
+ * Filter the query on the was_in_promo column
+ *
+ * Example usage:
+ *
+ * $query->filterByWasInPromo(1234); // WHERE was_in_promo = 1234
+ * $query->filterByWasInPromo(array(12, 34)); // WHERE was_in_promo IN (12, 34)
+ * $query->filterByWasInPromo(array('min' => 12)); // WHERE was_in_promo > 12
+ *
+ *
+ * @param mixed $wasInPromo 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.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByWasInPromo($wasInPromo = null, $comparison = null)
+ {
+ if (is_array($wasInPromo)) {
+ $useMinMax = false;
+ if (isset($wasInPromo['min'])) {
+ $this->addUsingAlias(OrderProductTableMap::WAS_IN_PROMO, $wasInPromo['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($wasInPromo['max'])) {
+ $this->addUsingAlias(OrderProductTableMap::WAS_IN_PROMO, $wasInPromo['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::WAS_IN_PROMO, $wasInPromo, $comparison);
+ }
+
+ /**
+ * Filter the query on the weight column
+ *
+ * Example usage:
+ *
+ * $query->filterByWeight('fooValue'); // WHERE weight = 'fooValue'
+ * $query->filterByWeight('%fooValue%'); // WHERE weight LIKE '%fooValue%'
+ *
+ *
+ * @param string $weight 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 ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByWeight($weight = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($weight)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $weight)) {
+ $weight = str_replace('*', '%', $weight);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::WEIGHT, $weight, $comparison);
+ }
+
+ /**
+ * Filter the query on the tax_rule_title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTaxRuleTitle('fooValue'); // WHERE tax_rule_title = 'fooValue'
+ * $query->filterByTaxRuleTitle('%fooValue%'); // WHERE tax_rule_title LIKE '%fooValue%'
+ *
+ *
+ * @param string $taxRuleTitle 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 ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByTaxRuleTitle($taxRuleTitle = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($taxRuleTitle)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $taxRuleTitle)) {
+ $taxRuleTitle = str_replace('*', '%', $taxRuleTitle);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::TAX_RULE_TITLE, $taxRuleTitle, $comparison);
+ }
+
+ /**
+ * Filter the query on the tax_rule_description column
+ *
+ * Example usage:
+ *
+ * $query->filterByTaxRuleDescription('fooValue'); // WHERE tax_rule_description = 'fooValue'
+ * $query->filterByTaxRuleDescription('%fooValue%'); // WHERE tax_rule_description LIKE '%fooValue%'
+ *
+ *
+ * @param string $taxRuleDescription 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 ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByTaxRuleDescription($taxRuleDescription = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($taxRuleDescription)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $taxRuleDescription)) {
+ $taxRuleDescription = str_replace('*', '%', $taxRuleDescription);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::TAX_RULE_DESCRIPTION, $taxRuleDescription, $comparison);
}
/**
@@ -790,40 +1037,40 @@ abstract class OrderProductQuery extends ModelCriteria
}
/**
- * Filter the query by a related \Thelia\Model\OrderFeature object
+ * Filter the query by a related \Thelia\Model\OrderProductAttributeCombination object
*
- * @param \Thelia\Model\OrderFeature|ObjectCollection $orderFeature the related object to use as filter
+ * @param \Thelia\Model\OrderProductAttributeCombination|ObjectCollection $orderProductAttributeCombination the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildOrderProductQuery The current query, for fluid interface
*/
- public function filterByOrderFeature($orderFeature, $comparison = null)
+ public function filterByOrderProductAttributeCombination($orderProductAttributeCombination, $comparison = null)
{
- if ($orderFeature instanceof \Thelia\Model\OrderFeature) {
+ if ($orderProductAttributeCombination instanceof \Thelia\Model\OrderProductAttributeCombination) {
return $this
- ->addUsingAlias(OrderProductTableMap::ID, $orderFeature->getOrderProductId(), $comparison);
- } elseif ($orderFeature instanceof ObjectCollection) {
+ ->addUsingAlias(OrderProductTableMap::ID, $orderProductAttributeCombination->getOrderProductId(), $comparison);
+ } elseif ($orderProductAttributeCombination instanceof ObjectCollection) {
return $this
- ->useOrderFeatureQuery()
- ->filterByPrimaryKeys($orderFeature->getPrimaryKeys())
+ ->useOrderProductAttributeCombinationQuery()
+ ->filterByPrimaryKeys($orderProductAttributeCombination->getPrimaryKeys())
->endUse();
} else {
- throw new PropelException('filterByOrderFeature() only accepts arguments of type \Thelia\Model\OrderFeature or Collection');
+ throw new PropelException('filterByOrderProductAttributeCombination() only accepts arguments of type \Thelia\Model\OrderProductAttributeCombination or Collection');
}
}
/**
- * Adds a JOIN clause to the query using the OrderFeature relation
+ * Adds a JOIN clause to the query using the OrderProductAttributeCombination relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildOrderProductQuery The current query, for fluid interface
*/
- public function joinOrderFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinOrderProductAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('OrderFeature');
+ $relationMap = $tableMap->getRelation('OrderProductAttributeCombination');
// create a ModelJoin object for this join
$join = new ModelJoin();
@@ -838,14 +1085,14 @@ abstract class OrderProductQuery extends ModelCriteria
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
- $this->addJoinObject($join, 'OrderFeature');
+ $this->addJoinObject($join, 'OrderProductAttributeCombination');
}
return $this;
}
/**
- * Use the OrderFeature relation OrderFeature object
+ * Use the OrderProductAttributeCombination relation OrderProductAttributeCombination object
*
* @see useQuery()
*
@@ -853,13 +1100,86 @@ abstract class OrderProductQuery extends ModelCriteria
* 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\OrderFeatureQuery A secondary query class using the current class as primary query
+ * @return \Thelia\Model\OrderProductAttributeCombinationQuery A secondary query class using the current class as primary query
*/
- public function useOrderFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useOrderProductAttributeCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
- ->joinOrderFeature($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'OrderFeature', '\Thelia\Model\OrderFeatureQuery');
+ ->joinOrderProductAttributeCombination($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderProductAttributeCombination', '\Thelia\Model\OrderProductAttributeCombinationQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\OrderProductTax object
+ *
+ * @param \Thelia\Model\OrderProductTax|ObjectCollection $orderProductTax the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByOrderProductTax($orderProductTax, $comparison = null)
+ {
+ if ($orderProductTax instanceof \Thelia\Model\OrderProductTax) {
+ return $this
+ ->addUsingAlias(OrderProductTableMap::ID, $orderProductTax->getOrderProductId(), $comparison);
+ } elseif ($orderProductTax instanceof ObjectCollection) {
+ return $this
+ ->useOrderProductTaxQuery()
+ ->filterByPrimaryKeys($orderProductTax->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrderProductTax() only accepts arguments of type \Thelia\Model\OrderProductTax or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderProductTax relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function joinOrderProductTax($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderProductTax');
+
+ // 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, 'OrderProductTax');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderProductTax relation OrderProductTax 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\OrderProductTaxQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderProductTaxQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrderProductTax($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderProductTax', '\Thelia\Model\OrderProductTaxQuery');
}
/**
diff --git a/core/lib/Thelia/Model/Map/OrderProductTableMap.php b/core/lib/Thelia/Model/Map/OrderProductTableMap.php
index 038d12863..8144f23a7 100644
--- a/core/lib/Thelia/Model/Map/OrderProductTableMap.php
+++ b/core/lib/Thelia/Model/Map/OrderProductTableMap.php
@@ -57,7 +57,7 @@ class OrderProductTableMap extends TableMap
/**
* The total number of columns
*/
- const NUM_COLUMNS = 12;
+ const NUM_COLUMNS = 19;
/**
* The number of lazy-loaded columns
@@ -67,7 +67,7 @@ class OrderProductTableMap extends TableMap
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
- const NUM_HYDRATE_COLUMNS = 12;
+ const NUM_HYDRATE_COLUMNS = 19;
/**
* the column name for the ID field
@@ -84,20 +84,30 @@ class OrderProductTableMap extends TableMap
*/
const PRODUCT_REF = 'order_product.PRODUCT_REF';
+ /**
+ * the column name for the PRODUCT_SALE_ELEMENTS_REF field
+ */
+ const PRODUCT_SALE_ELEMENTS_REF = 'order_product.PRODUCT_SALE_ELEMENTS_REF';
+
/**
* the column name for the TITLE field
*/
const TITLE = 'order_product.TITLE';
+ /**
+ * the column name for the CHAPO field
+ */
+ const CHAPO = 'order_product.CHAPO';
+
/**
* the column name for the DESCRIPTION field
*/
const DESCRIPTION = 'order_product.DESCRIPTION';
/**
- * the column name for the CHAPO field
+ * the column name for the POSTSCRIPTUM field
*/
- const CHAPO = 'order_product.CHAPO';
+ const POSTSCRIPTUM = 'order_product.POSTSCRIPTUM';
/**
* the column name for the QUANTITY field
@@ -110,9 +120,34 @@ class OrderProductTableMap extends TableMap
const PRICE = 'order_product.PRICE';
/**
- * the column name for the TAX field
+ * the column name for the PROMO_PRICE field
*/
- const TAX = 'order_product.TAX';
+ const PROMO_PRICE = 'order_product.PROMO_PRICE';
+
+ /**
+ * the column name for the WAS_NEW field
+ */
+ const WAS_NEW = 'order_product.WAS_NEW';
+
+ /**
+ * the column name for the WAS_IN_PROMO field
+ */
+ const WAS_IN_PROMO = 'order_product.WAS_IN_PROMO';
+
+ /**
+ * the column name for the WEIGHT field
+ */
+ const WEIGHT = 'order_product.WEIGHT';
+
+ /**
+ * the column name for the TAX_RULE_TITLE field
+ */
+ const TAX_RULE_TITLE = 'order_product.TAX_RULE_TITLE';
+
+ /**
+ * the column name for the TAX_RULE_DESCRIPTION field
+ */
+ const TAX_RULE_DESCRIPTION = 'order_product.TAX_RULE_DESCRIPTION';
/**
* the column name for the PARENT field
@@ -141,12 +176,12 @@ class OrderProductTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- self::TYPE_PHPNAME => array('Id', 'OrderId', 'ProductRef', 'Title', 'Description', 'Chapo', 'Quantity', 'Price', 'Tax', 'Parent', 'CreatedAt', 'UpdatedAt', ),
- self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'productRef', 'title', 'description', 'chapo', 'quantity', 'price', 'tax', 'parent', 'createdAt', 'updatedAt', ),
- self::TYPE_COLNAME => array(OrderProductTableMap::ID, OrderProductTableMap::ORDER_ID, OrderProductTableMap::PRODUCT_REF, OrderProductTableMap::TITLE, OrderProductTableMap::DESCRIPTION, OrderProductTableMap::CHAPO, OrderProductTableMap::QUANTITY, OrderProductTableMap::PRICE, OrderProductTableMap::TAX, OrderProductTableMap::PARENT, OrderProductTableMap::CREATED_AT, OrderProductTableMap::UPDATED_AT, ),
- self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'PRODUCT_REF', 'TITLE', 'DESCRIPTION', 'CHAPO', 'QUANTITY', 'PRICE', 'TAX', 'PARENT', 'CREATED_AT', 'UPDATED_AT', ),
- self::TYPE_FIELDNAME => array('id', 'order_id', 'product_ref', 'title', 'description', 'chapo', 'quantity', 'price', 'tax', 'parent', 'created_at', 'updated_at', ),
- self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
+ self::TYPE_PHPNAME => array('Id', 'OrderId', 'ProductRef', 'ProductSaleElementsRef', 'Title', 'Chapo', 'Description', 'Postscriptum', 'Quantity', 'Price', 'PromoPrice', 'WasNew', 'WasInPromo', 'Weight', 'TaxRuleTitle', 'TaxRuleDescription', 'Parent', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'productRef', 'productSaleElementsRef', 'title', 'chapo', 'description', 'postscriptum', 'quantity', 'price', 'promoPrice', 'wasNew', 'wasInPromo', 'weight', 'taxRuleTitle', 'taxRuleDescription', 'parent', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(OrderProductTableMap::ID, OrderProductTableMap::ORDER_ID, OrderProductTableMap::PRODUCT_REF, OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF, OrderProductTableMap::TITLE, OrderProductTableMap::CHAPO, OrderProductTableMap::DESCRIPTION, OrderProductTableMap::POSTSCRIPTUM, OrderProductTableMap::QUANTITY, OrderProductTableMap::PRICE, OrderProductTableMap::PROMO_PRICE, OrderProductTableMap::WAS_NEW, OrderProductTableMap::WAS_IN_PROMO, OrderProductTableMap::WEIGHT, OrderProductTableMap::TAX_RULE_TITLE, OrderProductTableMap::TAX_RULE_DESCRIPTION, OrderProductTableMap::PARENT, OrderProductTableMap::CREATED_AT, OrderProductTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'PRODUCT_REF', 'PRODUCT_SALE_ELEMENTS_REF', 'TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'QUANTITY', 'PRICE', 'PROMO_PRICE', 'WAS_NEW', 'WAS_IN_PROMO', 'WEIGHT', 'TAX_RULE_TITLE', 'TAX_RULE_DESCRIPTION', 'PARENT', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'order_id', 'product_ref', 'product_sale_elements_ref', 'title', 'chapo', 'description', 'postscriptum', 'quantity', 'price', 'promo_price', 'was_new', 'was_in_promo', 'weight', 'tax_rule_title', 'tax_rule_description', 'parent', '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, 18, )
);
/**
@@ -156,12 +191,12 @@ class OrderProductTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
- self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'ProductRef' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'Quantity' => 6, 'Price' => 7, 'Tax' => 8, 'Parent' => 9, 'CreatedAt' => 10, 'UpdatedAt' => 11, ),
- self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'productRef' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'quantity' => 6, 'price' => 7, 'tax' => 8, 'parent' => 9, 'createdAt' => 10, 'updatedAt' => 11, ),
- self::TYPE_COLNAME => array(OrderProductTableMap::ID => 0, OrderProductTableMap::ORDER_ID => 1, OrderProductTableMap::PRODUCT_REF => 2, OrderProductTableMap::TITLE => 3, OrderProductTableMap::DESCRIPTION => 4, OrderProductTableMap::CHAPO => 5, OrderProductTableMap::QUANTITY => 6, OrderProductTableMap::PRICE => 7, OrderProductTableMap::TAX => 8, OrderProductTableMap::PARENT => 9, OrderProductTableMap::CREATED_AT => 10, OrderProductTableMap::UPDATED_AT => 11, ),
- self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'PRODUCT_REF' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'QUANTITY' => 6, 'PRICE' => 7, 'TAX' => 8, 'PARENT' => 9, 'CREATED_AT' => 10, 'UPDATED_AT' => 11, ),
- self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'product_ref' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'quantity' => 6, 'price' => 7, 'tax' => 8, 'parent' => 9, 'created_at' => 10, 'updated_at' => 11, ),
- self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
+ self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'ProductRef' => 2, 'ProductSaleElementsRef' => 3, 'Title' => 4, 'Chapo' => 5, 'Description' => 6, 'Postscriptum' => 7, 'Quantity' => 8, 'Price' => 9, 'PromoPrice' => 10, 'WasNew' => 11, 'WasInPromo' => 12, 'Weight' => 13, 'TaxRuleTitle' => 14, 'TaxRuleDescription' => 15, 'Parent' => 16, 'CreatedAt' => 17, 'UpdatedAt' => 18, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'productRef' => 2, 'productSaleElementsRef' => 3, 'title' => 4, 'chapo' => 5, 'description' => 6, 'postscriptum' => 7, 'quantity' => 8, 'price' => 9, 'promoPrice' => 10, 'wasNew' => 11, 'wasInPromo' => 12, 'weight' => 13, 'taxRuleTitle' => 14, 'taxRuleDescription' => 15, 'parent' => 16, 'createdAt' => 17, 'updatedAt' => 18, ),
+ self::TYPE_COLNAME => array(OrderProductTableMap::ID => 0, OrderProductTableMap::ORDER_ID => 1, OrderProductTableMap::PRODUCT_REF => 2, OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF => 3, OrderProductTableMap::TITLE => 4, OrderProductTableMap::CHAPO => 5, OrderProductTableMap::DESCRIPTION => 6, OrderProductTableMap::POSTSCRIPTUM => 7, OrderProductTableMap::QUANTITY => 8, OrderProductTableMap::PRICE => 9, OrderProductTableMap::PROMO_PRICE => 10, OrderProductTableMap::WAS_NEW => 11, OrderProductTableMap::WAS_IN_PROMO => 12, OrderProductTableMap::WEIGHT => 13, OrderProductTableMap::TAX_RULE_TITLE => 14, OrderProductTableMap::TAX_RULE_DESCRIPTION => 15, OrderProductTableMap::PARENT => 16, OrderProductTableMap::CREATED_AT => 17, OrderProductTableMap::UPDATED_AT => 18, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'PRODUCT_REF' => 2, 'PRODUCT_SALE_ELEMENTS_REF' => 3, 'TITLE' => 4, 'CHAPO' => 5, 'DESCRIPTION' => 6, 'POSTSCRIPTUM' => 7, 'QUANTITY' => 8, 'PRICE' => 9, 'PROMO_PRICE' => 10, 'WAS_NEW' => 11, 'WAS_IN_PROMO' => 12, 'WEIGHT' => 13, 'TAX_RULE_TITLE' => 14, 'TAX_RULE_DESCRIPTION' => 15, 'PARENT' => 16, 'CREATED_AT' => 17, 'UPDATED_AT' => 18, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'product_ref' => 2, 'product_sale_elements_ref' => 3, 'title' => 4, 'chapo' => 5, 'description' => 6, 'postscriptum' => 7, 'quantity' => 8, 'price' => 9, 'promo_price' => 10, 'was_new' => 11, 'was_in_promo' => 12, 'weight' => 13, 'tax_rule_title' => 14, 'tax_rule_description' => 15, 'parent' => 16, 'created_at' => 17, 'updated_at' => 18, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, )
);
/**
@@ -182,13 +217,20 @@ class OrderProductTableMap extends TableMap
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', true, null, null);
- $this->addColumn('PRODUCT_REF', 'ProductRef', 'VARCHAR', false, 255, null);
+ $this->addColumn('PRODUCT_REF', 'ProductRef', 'VARCHAR', true, 255, null);
+ $this->addColumn('PRODUCT_SALE_ELEMENTS_REF', 'ProductSaleElementsRef', 'VARCHAR', true, 255, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
- $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
$this->addColumn('QUANTITY', 'Quantity', 'FLOAT', true, null, null);
$this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null);
- $this->addColumn('TAX', 'Tax', 'FLOAT', false, null, null);
+ $this->addColumn('PROMO_PRICE', 'PromoPrice', 'VARCHAR', false, 45, null);
+ $this->addColumn('WAS_NEW', 'WasNew', 'TINYINT', true, null, null);
+ $this->addColumn('WAS_IN_PROMO', 'WasInPromo', 'TINYINT', true, null, null);
+ $this->addColumn('WEIGHT', 'Weight', 'VARCHAR', false, 45, null);
+ $this->addColumn('TAX_RULE_TITLE', 'TaxRuleTitle', 'VARCHAR', false, 255, null);
+ $this->addColumn('TAX_RULE_DESCRIPTION', 'TaxRuleDescription', 'CLOB', false, null, null);
$this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
@@ -200,7 +242,8 @@ class OrderProductTableMap extends TableMap
public function buildRelations()
{
$this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('OrderFeature', '\\Thelia\\Model\\OrderFeature', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderFeatures');
+ $this->addRelation('OrderProductAttributeCombination', '\\Thelia\\Model\\OrderProductAttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderProductAttributeCombinations');
+ $this->addRelation('OrderProductTax', '\\Thelia\\Model\\OrderProductTax', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderProductTaxes');
} // buildRelations()
/**
@@ -222,7 +265,8 @@ class OrderProductTableMap extends TableMap
{
// Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- OrderFeatureTableMap::clearInstancePool();
+ OrderProductAttributeCombinationTableMap::clearInstancePool();
+ OrderProductTaxTableMap::clearInstancePool();
}
/**
@@ -366,12 +410,19 @@ class OrderProductTableMap extends TableMap
$criteria->addSelectColumn(OrderProductTableMap::ID);
$criteria->addSelectColumn(OrderProductTableMap::ORDER_ID);
$criteria->addSelectColumn(OrderProductTableMap::PRODUCT_REF);
+ $criteria->addSelectColumn(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF);
$criteria->addSelectColumn(OrderProductTableMap::TITLE);
- $criteria->addSelectColumn(OrderProductTableMap::DESCRIPTION);
$criteria->addSelectColumn(OrderProductTableMap::CHAPO);
+ $criteria->addSelectColumn(OrderProductTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(OrderProductTableMap::POSTSCRIPTUM);
$criteria->addSelectColumn(OrderProductTableMap::QUANTITY);
$criteria->addSelectColumn(OrderProductTableMap::PRICE);
- $criteria->addSelectColumn(OrderProductTableMap::TAX);
+ $criteria->addSelectColumn(OrderProductTableMap::PROMO_PRICE);
+ $criteria->addSelectColumn(OrderProductTableMap::WAS_NEW);
+ $criteria->addSelectColumn(OrderProductTableMap::WAS_IN_PROMO);
+ $criteria->addSelectColumn(OrderProductTableMap::WEIGHT);
+ $criteria->addSelectColumn(OrderProductTableMap::TAX_RULE_TITLE);
+ $criteria->addSelectColumn(OrderProductTableMap::TAX_RULE_DESCRIPTION);
$criteria->addSelectColumn(OrderProductTableMap::PARENT);
$criteria->addSelectColumn(OrderProductTableMap::CREATED_AT);
$criteria->addSelectColumn(OrderProductTableMap::UPDATED_AT);
@@ -379,12 +430,19 @@ class OrderProductTableMap extends TableMap
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.ORDER_ID');
$criteria->addSelectColumn($alias . '.PRODUCT_REF');
+ $criteria->addSelectColumn($alias . '.PRODUCT_SALE_ELEMENTS_REF');
$criteria->addSelectColumn($alias . '.TITLE');
- $criteria->addSelectColumn($alias . '.DESCRIPTION');
$criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
$criteria->addSelectColumn($alias . '.QUANTITY');
$criteria->addSelectColumn($alias . '.PRICE');
- $criteria->addSelectColumn($alias . '.TAX');
+ $criteria->addSelectColumn($alias . '.PROMO_PRICE');
+ $criteria->addSelectColumn($alias . '.WAS_NEW');
+ $criteria->addSelectColumn($alias . '.WAS_IN_PROMO');
+ $criteria->addSelectColumn($alias . '.WEIGHT');
+ $criteria->addSelectColumn($alias . '.TAX_RULE_TITLE');
+ $criteria->addSelectColumn($alias . '.TAX_RULE_DESCRIPTION');
$criteria->addSelectColumn($alias . '.PARENT');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
diff --git a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php
index a06230c37..c50a30c90 100644
--- a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php
+++ b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php
@@ -143,7 +143,7 @@ class TaxI18nTableMap extends TableMap
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
- $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
} // initialize()
/**
diff --git a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php
index 012ad2e72..24f8a41d7 100644
--- a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php
+++ b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php
@@ -143,7 +143,7 @@ class TaxRuleI18nTableMap extends TableMap
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax_rule', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
- $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
} // initialize()
/**
diff --git a/core/lib/Thelia/Model/Order.php b/core/lib/Thelia/Model/Order.php
index c5d03b7e7..5249a1366 100755
--- a/core/lib/Thelia/Model/Order.php
+++ b/core/lib/Thelia/Model/Order.php
@@ -2,10 +2,17 @@
namespace Thelia\Model;
+use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\Connection\ConnectionInterface;
+use Propel\Runtime\Propel;
use Thelia\Core\Event\OrderEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Base\Order as BaseOrder;
+use Thelia\Model\Base\OrderProductTaxQuery;
+use Thelia\Model\Map\OrderProductTaxTableMap;
+use Thelia\Model\OrderProductQuery;
+use Thelia\Model\Map\OrderTableMap;
+use \PDO;
class Order extends BaseOrder
{
@@ -19,20 +26,209 @@ class Order extends BaseOrder
*/
public function preInsert(ConnectionInterface $con = null)
{
- $this->dispatchEvent(TheliaEvents::ORDER_SET_REFERENCE, new OrderEvent($this));
+ $this->dispatchEvent(TheliaEvents::ORDER_BEFORE_CREATE, new OrderEvent($this));
return true;
}
+ /**
+ * {@inheritDoc}
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::ORDER_AFTER_CREATE, new OrderEvent($this));
+ }
+
/**
* calculate the total amount
*
- * @TODO create body method
+ * @param int $tax
*
- * @return int
+ * @return int|string|Base\double
*/
- public function getTotalAmount()
+ public function getTotalAmount(&$tax = 0)
{
- return 2;
+ $amount = 0;
+ $tax = 0;
+
+ /* browse all products */
+ $orderProductIds = array();
+ foreach($this->getOrderProducts() as $orderProduct) {
+ $taxAmount = OrderProductTaxQuery::create()
+ ->withColumn('SUM(' . OrderProductTaxTableMap::AMOUNT . ')', 'total_tax')
+ ->filterByOrderProductId($orderProduct->getId(), Criteria::EQUAL)
+ ->findOne();
+ $amount += ($orderProduct->getWasInPromo() == 1 ? $orderProduct->getPromoPrice() : $orderProduct->getPrice()) * $orderProduct->getQuantity();
+ $tax += round($taxAmount->getVirtualColumn('total_tax'), 2) * $orderProduct->getQuantity();
+ }
+
+ return $amount + $tax + $this->getPostage(); // @todo : manage discount
+ }
+
+ /**
+ * PROPEL SHOULD FIX IT
+ *
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = OrderTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(OrderTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(OrderTableMap::REF)) {
+ $modifiedColumns[':p' . $index++] = 'REF';
+ }
+ if ($this->isColumnModified(OrderTableMap::CUSTOMER_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CUSTOMER_ID';
+ }
+ if ($this->isColumnModified(OrderTableMap::INVOICE_ORDER_ADDRESS_ID)) {
+ $modifiedColumns[':p' . $index++] = 'INVOICE_ORDER_ADDRESS_ID';
+ }
+ if ($this->isColumnModified(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID)) {
+ $modifiedColumns[':p' . $index++] = 'DELIVERY_ORDER_ADDRESS_ID';
+ }
+ if ($this->isColumnModified(OrderTableMap::INVOICE_DATE)) {
+ $modifiedColumns[':p' . $index++] = 'INVOICE_DATE';
+ }
+ if ($this->isColumnModified(OrderTableMap::CURRENCY_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CURRENCY_ID';
+ }
+ if ($this->isColumnModified(OrderTableMap::CURRENCY_RATE)) {
+ $modifiedColumns[':p' . $index++] = 'CURRENCY_RATE';
+ }
+ if ($this->isColumnModified(OrderTableMap::TRANSACTION_REF)) {
+ $modifiedColumns[':p' . $index++] = 'TRANSACTION_REF';
+ }
+ if ($this->isColumnModified(OrderTableMap::DELIVERY_REF)) {
+ $modifiedColumns[':p' . $index++] = 'DELIVERY_REF';
+ }
+ if ($this->isColumnModified(OrderTableMap::INVOICE_REF)) {
+ $modifiedColumns[':p' . $index++] = 'INVOICE_REF';
+ }
+ if ($this->isColumnModified(OrderTableMap::POSTAGE)) {
+ $modifiedColumns[':p' . $index++] = 'POSTAGE';
+ }
+ if ($this->isColumnModified(OrderTableMap::PAYMENT_MODULE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'PAYMENT_MODULE_ID';
+ }
+ if ($this->isColumnModified(OrderTableMap::DELIVERY_MODULE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'DELIVERY_MODULE_ID';
+ }
+ if ($this->isColumnModified(OrderTableMap::STATUS_ID)) {
+ $modifiedColumns[':p' . $index++] = 'STATUS_ID';
+ }
+ if ($this->isColumnModified(OrderTableMap::LANG_ID)) {
+ $modifiedColumns[':p' . $index++] = 'LANG_ID';
+ }
+ if ($this->isColumnModified(OrderTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(OrderTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $db = Propel::getServiceContainer()->getAdapter(OrderTableMap::DATABASE_NAME);
+
+ if ($db->useQuoteIdentifier()) {
+ $tableName = $db->quoteIdentifierTable(OrderTableMap::TABLE_NAME);
+ } else {
+ $tableName = OrderTableMap::TABLE_NAME;
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO %s (%s) VALUES (%s)',
+ $tableName,
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'REF':
+ $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
+ break;
+ case 'CUSTOMER_ID':
+ $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT);
+ break;
+ case 'INVOICE_ORDER_ADDRESS_ID':
+ $stmt->bindValue($identifier, $this->invoice_order_address_id, PDO::PARAM_INT);
+ break;
+ case 'DELIVERY_ORDER_ADDRESS_ID':
+ $stmt->bindValue($identifier, $this->delivery_order_address_id, PDO::PARAM_INT);
+ break;
+ case 'INVOICE_DATE':
+ $stmt->bindValue($identifier, $this->invoice_date ? $this->invoice_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'CURRENCY_ID':
+ $stmt->bindValue($identifier, $this->currency_id, PDO::PARAM_INT);
+ break;
+ case 'CURRENCY_RATE':
+ $stmt->bindValue($identifier, $this->currency_rate, PDO::PARAM_STR);
+ break;
+ case 'TRANSACTION_REF':
+ $stmt->bindValue($identifier, $this->transaction_ref, PDO::PARAM_STR);
+ break;
+ case 'DELIVERY_REF':
+ $stmt->bindValue($identifier, $this->delivery_ref, PDO::PARAM_STR);
+ break;
+ case 'INVOICE_REF':
+ $stmt->bindValue($identifier, $this->invoice_ref, PDO::PARAM_STR);
+ break;
+ case 'POSTAGE':
+ $stmt->bindValue($identifier, $this->postage, PDO::PARAM_STR);
+ break;
+ case 'PAYMENT_MODULE_ID':
+ $stmt->bindValue($identifier, $this->payment_module_id, PDO::PARAM_INT);
+ break;
+ case 'DELIVERY_MODULE_ID':
+ $stmt->bindValue($identifier, $this->delivery_module_id, PDO::PARAM_INT);
+ break;
+ case 'STATUS_ID':
+ $stmt->bindValue($identifier, $this->status_id, PDO::PARAM_INT);
+ break;
+ case 'LANG_ID':
+ $stmt->bindValue($identifier, $this->lang_id, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
}
}
diff --git a/core/lib/Thelia/Model/OrderProduct.php b/core/lib/Thelia/Model/OrderProduct.php
old mode 100755
new mode 100644
index 2c0e189aa..235eaf259
--- a/core/lib/Thelia/Model/OrderProduct.php
+++ b/core/lib/Thelia/Model/OrderProduct.php
@@ -2,8 +2,30 @@
namespace Thelia\Model;
+use Propel\Runtime\Connection\ConnectionInterface;
+use Thelia\Core\Event\OrderEvent;
+use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Base\OrderProduct as BaseOrderProduct;
-class OrderProduct extends BaseOrderProduct {
+class OrderProduct extends BaseOrderProduct
+{
+ use \Thelia\Model\Tools\ModelEventDispatcherTrait;
+ /**
+ * {@inheritDoc}
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::ORDER_PRODUCT_BEFORE_CREATE, new OrderEvent($this->getOrder()));
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::ORDER_PRODUCT_AFTER_CREATE, new OrderEvent($this->getOrder()));
+ }
}
diff --git a/core/lib/Thelia/Model/OrderProductQuery.php b/core/lib/Thelia/Model/OrderProductQuery.php
old mode 100755
new mode 100644
index b894e9b49..de2c22404
--- a/core/lib/Thelia/Model/OrderProductQuery.php
+++ b/core/lib/Thelia/Model/OrderProductQuery.php
@@ -15,6 +15,7 @@ use Thelia\Model\Base\OrderProductQuery as BaseOrderProductQuery;
* long as it does not already exist in the output directory.
*
*/
-class OrderProductQuery extends BaseOrderProductQuery {
+class OrderProductQuery extends BaseOrderProductQuery
+{
} // OrderProductQuery
diff --git a/core/lib/Thelia/Model/OrderQuery.php b/core/lib/Thelia/Model/OrderQuery.php
index 13cb1cbf1..8d5e4c085 100755
--- a/core/lib/Thelia/Model/OrderQuery.php
+++ b/core/lib/Thelia/Model/OrderQuery.php
@@ -2,8 +2,11 @@
namespace Thelia\Model;
+use Propel\Runtime\Exception\PropelException;
+use Propel\Runtime\Propel;
use Thelia\Model\Base\OrderQuery as BaseOrderQuery;
-
+use \PDO;
+use Thelia\Model\Map\OrderTableMap;
/**
* Skeleton subclass for performing query and update operations on the 'order' table.
@@ -15,6 +18,38 @@ use Thelia\Model\Base\OrderQuery as BaseOrderQuery;
* long as it does not already exist in the output directory.
*
*/
-class OrderQuery extends BaseOrderQuery {
+class OrderQuery extends BaseOrderQuery
+{
+ /**
+ * PROPEL SHOULD FIX IT
+ *
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return Order A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, REF, CUSTOMER_ID, INVOICE_ORDER_ADDRESS_ID, DELIVERY_ORDER_ADDRESS_ID, INVOICE_DATE, CURRENCY_ID, CURRENCY_RATE, TRANSACTION_REF, DELIVERY_REF, INVOICE_REF, POSTAGE, PAYMENT_MODULE_ID, DELIVERY_MODULE_ID, STATUS_ID, LANG_ID, CREATED_AT, UPDATED_AT FROM `order` WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (\Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new Order();
+ $obj->hydrate($row);
+ OrderTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+ return $obj;
+ }
} // OrderQuery
diff --git a/core/lib/Thelia/Model/TaxRule.php b/core/lib/Thelia/Model/TaxRule.php
index 36f80a044..024fd8923 100755
--- a/core/lib/Thelia/Model/TaxRule.php
+++ b/core/lib/Thelia/Model/TaxRule.php
@@ -3,7 +3,25 @@
namespace Thelia\Model;
use Thelia\Model\Base\TaxRule as BaseTaxRule;
+use Thelia\TaxEngine\Calculator;
+use Thelia\TaxEngine\OrderProductTaxCollection;
-class TaxRule extends BaseTaxRule {
+class TaxRule extends BaseTaxRule
+{
+ /**
+ * @param Country $country
+ * @param $untaxedAmount
+ * @param null $askedLocale
+ *
+ * @return OrderProductTaxCollection
+ */
+ public function getTaxDetail(Country $country, $untaxedAmount, $askedLocale = null)
+ {
+ $taxCalculator = new Calculator();
+ $taxCollection = new OrderProductTaxCollection();
+ $taxCalculator->loadTaxRule($this, $country)->getTaxedPrice($untaxedAmount, $taxCollection, $askedLocale);
+
+ return $taxCollection;
+ }
}
diff --git a/core/lib/Thelia/Model/TaxRuleQuery.php b/core/lib/Thelia/Model/TaxRuleQuery.php
index d5ce47546..572500003 100755
--- a/core/lib/Thelia/Model/TaxRuleQuery.php
+++ b/core/lib/Thelia/Model/TaxRuleQuery.php
@@ -21,13 +21,19 @@ class TaxRuleQuery extends BaseTaxRuleQuery
{
const ALIAS_FOR_TAX_RULE_COUNTRY_POSITION = 'taxRuleCountryPosition';
- public function getTaxCalculatorCollection(Product $product, Country $country)
+ /**
+ * @param TaxRule $taxRule
+ * @param Country $country
+ *
+ * @return array|mixed|\Propel\Runtime\Collection\ObjectCollection
+ */
+ public function getTaxCalculatorCollection(TaxRule $taxRule, Country $country)
{
$search = TaxQuery::create()
->filterByTaxRuleCountry(
TaxRuleCountryQuery::create()
->filterByCountry($country, Criteria::EQUAL)
- ->filterByTaxRuleId($product->getTaxRuleId())
+ ->filterByTaxRuleId($taxRule->getId())
->orderByPosition()
->find()
)
diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php
index f559c1fd5..8efc76e6e 100755
--- a/core/lib/Thelia/Module/BaseModule.php
+++ b/core/lib/Thelia/Module/BaseModule.php
@@ -25,7 +25,9 @@
namespace Thelia\Module;
use Symfony\Component\DependencyInjection\ContainerAware;
+use Thelia\Model\ModuleI18nQuery;
use Thelia\Model\Map\ModuleImageTableMap;
+use Thelia\Model\ModuleI18n;
use Thelia\Tools\Image;
use Thelia\Exception\ModuleException;
use Thelia\Model\Module;
@@ -76,6 +78,27 @@ abstract class BaseModule extends ContainerAware
return $this->container;
}
+ public function setTitle(Module $module, $titles)
+ {
+ if(is_array($titles)) {
+ foreach($titles as $locale => $title) {
+ $moduleI18n = ModuleI18nQuery::create()->filterById($module->getId())->filterByLocale($locale)->findOne();
+ if(null === $moduleI18n) {
+ $moduleI18n = new ModuleI18n();
+ $moduleI18n
+ ->setId($module->getId())
+ ->setLocale($locale)
+ ->setTitle($title)
+ ;
+ $moduleI18n->save();
+ } else {
+ $moduleI18n->setTitle($title);
+ $moduleI18n->save();
+ }
+ }
+ }
+ }
+
public function deployImageFolder(Module $module, $folderPath)
{
try {
diff --git a/core/lib/Thelia/TaxEngine/Calculator.php b/core/lib/Thelia/TaxEngine/Calculator.php
index b5a2f995e..8039dec39 100755
--- a/core/lib/Thelia/TaxEngine/Calculator.php
+++ b/core/lib/Thelia/TaxEngine/Calculator.php
@@ -24,8 +24,11 @@ namespace Thelia\TaxEngine;
use Thelia\Exception\TaxEngineException;
use Thelia\Model\Country;
+use Thelia\Model\OrderProductTax;
use Thelia\Model\Product;
+use Thelia\Model\TaxRule;
use Thelia\Model\TaxRuleQuery;
+use Thelia\Tools\I18n;
/**
* Class Calculator
@@ -68,14 +71,34 @@ class Calculator
$this->product = $product;
$this->country = $country;
- $this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($product, $country);
+ $this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($product->getTaxRule(), $country);
return $this;
}
- public function getTaxAmountFromUntaxedPrice($untaxedPrice)
+ public function loadTaxRule(TaxRule $taxRule, Country $country)
{
- return $this->getTaxedPrice($untaxedPrice) - $untaxedPrice;
+ $this->product = null;
+ $this->country = null;
+ $this->taxRulesCollection = null;
+
+ if($taxRule->getId() === null) {
+ throw new TaxEngineException('TaxRule id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_TAX_RULE);
+ }
+ if($country->getId() === null) {
+ throw new TaxEngineException('Country id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_COUNTRY);
+ }
+
+ $this->country = $country;
+
+ $this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($taxRule, $country);
+
+ return $this;
+ }
+
+ public function getTaxAmountFromUntaxedPrice($untaxedPrice, &$taxCollection = null)
+ {
+ return $this->getTaxedPrice($untaxedPrice, $taxCollection) - $untaxedPrice;
}
public function getTaxAmountFromTaxedPrice($taxedPrice)
@@ -83,7 +106,15 @@ class Calculator
return $taxedPrice - $this->getUntaxedPrice($taxedPrice);
}
- public function getTaxedPrice($untaxedPrice)
+ /**
+ * @param $untaxedPrice
+ * @param null $taxCollection returns OrderProductTaxCollection
+ * @param null $askedLocale
+ *
+ * @return int
+ * @throws \Thelia\Exception\TaxEngineException
+ */
+ public function getTaxedPrice($untaxedPrice, &$taxCollection = null, $askedLocale = null)
{
if(null === $this->taxRulesCollection) {
throw new TaxEngineException('Tax rules collection is empty in Calculator::getTaxAmount', TaxEngineException::UNDEFINED_TAX_RULES_COLLECTION);
@@ -97,6 +128,9 @@ class Calculator
$currentPosition = 1;
$currentTax = 0;
+ if(null !== $taxCollection) {
+ $taxCollection = new OrderProductTaxCollection();
+ }
foreach($this->taxRulesCollection as $taxRule) {
$position = (int)$taxRule->getTaxRuleCountryPosition();
@@ -109,7 +143,17 @@ class Calculator
$currentPosition = $position;
}
- $currentTax += $taxType->calculate($taxedPrice);
+ $taxAmount = round($taxType->calculate($taxedPrice), 2);
+ $currentTax += $taxAmount;
+
+ if(null !== $taxCollection) {
+ $taxI18n = I18n::forceI18nRetrieving($askedLocale, 'Tax', $taxRule->getId());
+ $orderProductTax = new OrderProductTax();
+ $orderProductTax->setTitle($taxI18n->getTitle());
+ $orderProductTax->setDescription($taxI18n->getDescription());
+ $orderProductTax->setAmount($taxAmount);
+ $taxCollection->addTax($orderProductTax);
+ }
}
$taxedPrice += $currentTax;
diff --git a/core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php b/core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php
new file mode 100755
index 000000000..5c4ac2022
--- /dev/null
+++ b/core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php
@@ -0,0 +1,126 @@
+. */
+/* */
+/*************************************************************************************/
+namespace Thelia\TaxEngine;
+
+use Thelia\Model\OrderProductTax;
+
+/**
+ *
+ * @author Etienne Roudeix A summary of your order email has been sent to the following address: email@toto.com
+A summary of your order email has been sent to the following address: {customer attr="email"}
Your order will be confirmed by us upon receipt of your payment.