Conflicts:
	core/lib/Thelia/Core/Event/TheliaEvents.php
	templates/admin/default/admin-layout.tpl
This commit is contained in:
franck
2013-09-12 13:04:12 +02:00
78 changed files with 2887 additions and 1001 deletions

View File

@@ -75,6 +75,12 @@ abstract class ProductSaleElements implements ActiveRecordInterface
*/
protected $product_id;
/**
* The value for the ref field.
* @var string
*/
protected $ref;
/**
* The value for the quantity field.
* @var double
@@ -452,6 +458,17 @@ abstract class ProductSaleElements implements ActiveRecordInterface
return $this->product_id;
}
/**
* Get the [ref] column value.
*
* @return string
*/
public function getRef()
{
return $this->ref;
}
/**
* Get the [quantity] column value.
*
@@ -582,6 +599,27 @@ abstract class ProductSaleElements implements ActiveRecordInterface
return $this;
} // setProductId()
/**
* Set the value of [ref] column.
*
* @param string $v new value
* @return \Thelia\Model\ProductSaleElements The current object (for fluent API support)
*/
public function setRef($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->ref !== $v) {
$this->ref = $v;
$this->modifiedColumns[] = ProductSaleElementsTableMap::REF;
}
return $this;
} // setRef()
/**
* Set the value of [quantity] column.
*
@@ -759,25 +797,28 @@ abstract class ProductSaleElements implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductSaleElementsTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)];
$this->product_id = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductSaleElementsTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductSaleElementsTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)];
$this->ref = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductSaleElementsTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)];
$this->quantity = (null !== $col) ? (double) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductSaleElementsTableMap::translateFieldName('Promo', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductSaleElementsTableMap::translateFieldName('Promo', TableMap::TYPE_PHPNAME, $indexType)];
$this->promo = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductSaleElementsTableMap::translateFieldName('Newness', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductSaleElementsTableMap::translateFieldName('Newness', TableMap::TYPE_PHPNAME, $indexType)];
$this->newness = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductSaleElementsTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductSaleElementsTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)];
$this->weight = (null !== $col) ? (double) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductSaleElementsTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductSaleElementsTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductSaleElementsTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductSaleElementsTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
@@ -790,7 +831,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface
$this->ensureConsistency();
}
return $startcol + 8; // 8 = ProductSaleElementsTableMap::NUM_HYDRATE_COLUMNS.
return $startcol + 9; // 9 = ProductSaleElementsTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\ProductSaleElements object", 0, $e);
@@ -1089,6 +1130,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface
if ($this->isColumnModified(ProductSaleElementsTableMap::PRODUCT_ID)) {
$modifiedColumns[':p' . $index++] = 'PRODUCT_ID';
}
if ($this->isColumnModified(ProductSaleElementsTableMap::REF)) {
$modifiedColumns[':p' . $index++] = 'REF';
}
if ($this->isColumnModified(ProductSaleElementsTableMap::QUANTITY)) {
$modifiedColumns[':p' . $index++] = 'QUANTITY';
}
@@ -1124,6 +1168,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface
case 'PRODUCT_ID':
$stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
break;
case 'REF':
$stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
break;
case 'QUANTITY':
$stmt->bindValue($identifier, $this->quantity, PDO::PARAM_STR);
break;
@@ -1211,21 +1258,24 @@ abstract class ProductSaleElements implements ActiveRecordInterface
return $this->getProductId();
break;
case 2:
return $this->getQuantity();
return $this->getRef();
break;
case 3:
return $this->getPromo();
return $this->getQuantity();
break;
case 4:
return $this->getNewness();
return $this->getPromo();
break;
case 5:
return $this->getWeight();
return $this->getNewness();
break;
case 6:
return $this->getCreatedAt();
return $this->getWeight();
break;
case 7:
return $this->getCreatedAt();
break;
case 8:
return $this->getUpdatedAt();
break;
default:
@@ -1259,12 +1309,13 @@ abstract class ProductSaleElements implements ActiveRecordInterface
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getProductId(),
$keys[2] => $this->getQuantity(),
$keys[3] => $this->getPromo(),
$keys[4] => $this->getNewness(),
$keys[5] => $this->getWeight(),
$keys[6] => $this->getCreatedAt(),
$keys[7] => $this->getUpdatedAt(),
$keys[2] => $this->getRef(),
$keys[3] => $this->getQuantity(),
$keys[4] => $this->getPromo(),
$keys[5] => $this->getNewness(),
$keys[6] => $this->getWeight(),
$keys[7] => $this->getCreatedAt(),
$keys[8] => $this->getUpdatedAt(),
);
$virtualColumns = $this->virtualColumns;
foreach($virtualColumns as $key => $virtualColumn)
@@ -1326,21 +1377,24 @@ abstract class ProductSaleElements implements ActiveRecordInterface
$this->setProductId($value);
break;
case 2:
$this->setQuantity($value);
$this->setRef($value);
break;
case 3:
$this->setPromo($value);
$this->setQuantity($value);
break;
case 4:
$this->setNewness($value);
$this->setPromo($value);
break;
case 5:
$this->setWeight($value);
$this->setNewness($value);
break;
case 6:
$this->setCreatedAt($value);
$this->setWeight($value);
break;
case 7:
$this->setCreatedAt($value);
break;
case 8:
$this->setUpdatedAt($value);
break;
} // switch()
@@ -1369,12 +1423,13 @@ abstract class ProductSaleElements implements ActiveRecordInterface
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setQuantity($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setPromo($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setNewness($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setWeight($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
if (array_key_exists($keys[2], $arr)) $this->setRef($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setQuantity($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setPromo($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setNewness($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setWeight($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
}
/**
@@ -1388,6 +1443,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface
if ($this->isColumnModified(ProductSaleElementsTableMap::ID)) $criteria->add(ProductSaleElementsTableMap::ID, $this->id);
if ($this->isColumnModified(ProductSaleElementsTableMap::PRODUCT_ID)) $criteria->add(ProductSaleElementsTableMap::PRODUCT_ID, $this->product_id);
if ($this->isColumnModified(ProductSaleElementsTableMap::REF)) $criteria->add(ProductSaleElementsTableMap::REF, $this->ref);
if ($this->isColumnModified(ProductSaleElementsTableMap::QUANTITY)) $criteria->add(ProductSaleElementsTableMap::QUANTITY, $this->quantity);
if ($this->isColumnModified(ProductSaleElementsTableMap::PROMO)) $criteria->add(ProductSaleElementsTableMap::PROMO, $this->promo);
if ($this->isColumnModified(ProductSaleElementsTableMap::NEWNESS)) $criteria->add(ProductSaleElementsTableMap::NEWNESS, $this->newness);
@@ -1458,6 +1514,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface
public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setProductId($this->getProductId());
$copyObj->setRef($this->getRef());
$copyObj->setQuantity($this->getQuantity());
$copyObj->setPromo($this->getPromo());
$copyObj->setNewness($this->getNewness());
@@ -2383,6 +2440,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface
{
$this->id = null;
$this->product_id = null;
$this->ref = null;
$this->quantity = null;
$this->promo = null;
$this->newness = null;

View File

@@ -23,6 +23,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap;
*
* @method ChildProductSaleElementsQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildProductSaleElementsQuery orderByProductId($order = Criteria::ASC) Order by the product_id column
* @method ChildProductSaleElementsQuery orderByRef($order = Criteria::ASC) Order by the ref column
* @method ChildProductSaleElementsQuery orderByQuantity($order = Criteria::ASC) Order by the quantity column
* @method ChildProductSaleElementsQuery orderByPromo($order = Criteria::ASC) Order by the promo column
* @method ChildProductSaleElementsQuery orderByNewness($order = Criteria::ASC) Order by the newness column
@@ -32,6 +33,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap;
*
* @method ChildProductSaleElementsQuery groupById() Group by the id column
* @method ChildProductSaleElementsQuery groupByProductId() Group by the product_id column
* @method ChildProductSaleElementsQuery groupByRef() Group by the ref column
* @method ChildProductSaleElementsQuery groupByQuantity() Group by the quantity column
* @method ChildProductSaleElementsQuery groupByPromo() Group by the promo column
* @method ChildProductSaleElementsQuery groupByNewness() Group by the newness column
@@ -64,6 +66,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap;
*
* @method ChildProductSaleElements findOneById(int $id) Return the first ChildProductSaleElements filtered by the id column
* @method ChildProductSaleElements findOneByProductId(int $product_id) Return the first ChildProductSaleElements filtered by the product_id column
* @method ChildProductSaleElements findOneByRef(string $ref) Return the first ChildProductSaleElements filtered by the ref column
* @method ChildProductSaleElements findOneByQuantity(double $quantity) Return the first ChildProductSaleElements filtered by the quantity column
* @method ChildProductSaleElements findOneByPromo(int $promo) Return the first ChildProductSaleElements filtered by the promo column
* @method ChildProductSaleElements findOneByNewness(int $newness) Return the first ChildProductSaleElements filtered by the newness column
@@ -73,6 +76,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap;
*
* @method array findById(int $id) Return ChildProductSaleElements objects filtered by the id column
* @method array findByProductId(int $product_id) Return ChildProductSaleElements objects filtered by the product_id column
* @method array findByRef(string $ref) Return ChildProductSaleElements objects filtered by the ref column
* @method array findByQuantity(double $quantity) Return ChildProductSaleElements objects filtered by the quantity column
* @method array findByPromo(int $promo) Return ChildProductSaleElements objects filtered by the promo column
* @method array findByNewness(int $newness) Return ChildProductSaleElements objects filtered by the newness column
@@ -167,7 +171,7 @@ abstract class ProductSaleElementsQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, PRODUCT_ID, QUANTITY, PROMO, NEWNESS, WEIGHT, CREATED_AT, UPDATED_AT FROM product_sale_elements WHERE ID = :p0';
$sql = 'SELECT ID, PRODUCT_ID, REF, QUANTITY, PROMO, NEWNESS, WEIGHT, CREATED_AT, UPDATED_AT FROM product_sale_elements WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -340,6 +344,35 @@ abstract class ProductSaleElementsQuery extends ModelCriteria
return $this->addUsingAlias(ProductSaleElementsTableMap::PRODUCT_ID, $productId, $comparison);
}
/**
* Filter the query on the ref column
*
* Example usage:
* <code>
* $query->filterByRef('fooValue'); // WHERE ref = 'fooValue'
* $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%'
* </code>
*
* @param string $ref 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 ChildProductSaleElementsQuery The current query, for fluid interface
*/
public function filterByRef($ref = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($ref)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $ref)) {
$ref = str_replace('*', '%', $ref);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(ProductSaleElementsTableMap::REF, $ref, $comparison);
}
/**
* Filter the query on the quantity column
*

View File

@@ -66,10 +66,16 @@ abstract class Tax implements ActiveRecordInterface
protected $id;
/**
* The value for the rate field.
* @var double
* The value for the type field.
* @var string
*/
protected $rate;
protected $type;
/**
* The value for the serialized_requirements field.
* @var string
*/
protected $serialized_requirements;
/**
* The value for the created_at field.
@@ -395,14 +401,25 @@ abstract class Tax implements ActiveRecordInterface
}
/**
* Get the [rate] column value.
* Get the [type] column value.
*
* @return double
* @return string
*/
public function getRate()
public function getType()
{
return $this->rate;
return $this->type;
}
/**
* Get the [serialized_requirements] column value.
*
* @return string
*/
public function getSerializedRequirements()
{
return $this->serialized_requirements;
}
/**
@@ -467,25 +484,46 @@ abstract class Tax implements ActiveRecordInterface
} // setId()
/**
* Set the value of [rate] column.
* Set the value of [type] column.
*
* @param double $v new value
* @param string $v new value
* @return \Thelia\Model\Tax The current object (for fluent API support)
*/
public function setRate($v)
public function setType($v)
{
if ($v !== null) {
$v = (double) $v;
$v = (string) $v;
}
if ($this->rate !== $v) {
$this->rate = $v;
$this->modifiedColumns[] = TaxTableMap::RATE;
if ($this->type !== $v) {
$this->type = $v;
$this->modifiedColumns[] = TaxTableMap::TYPE;
}
return $this;
} // setRate()
} // setType()
/**
* Set the value of [serialized_requirements] column.
*
* @param string $v new value
* @return \Thelia\Model\Tax The current object (for fluent API support)
*/
public function setSerializedRequirements($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->serialized_requirements !== $v) {
$this->serialized_requirements = $v;
$this->modifiedColumns[] = TaxTableMap::SERIALIZED_REQUIREMENTS;
}
return $this;
} // setSerializedRequirements()
/**
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
@@ -569,16 +607,19 @@ abstract class Tax implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TaxTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
$this->id = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxTableMap::translateFieldName('Rate', TableMap::TYPE_PHPNAME, $indexType)];
$this->rate = (null !== $col) ? (double) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxTableMap::translateFieldName('Type', TableMap::TYPE_PHPNAME, $indexType)];
$this->type = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxTableMap::translateFieldName('SerializedRequirements', TableMap::TYPE_PHPNAME, $indexType)];
$this->serialized_requirements = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : TaxTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
@@ -591,7 +632,7 @@ abstract class Tax implements ActiveRecordInterface
$this->ensureConsistency();
}
return $startcol + 4; // 4 = TaxTableMap::NUM_HYDRATE_COLUMNS.
return $startcol + 5; // 5 = TaxTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\Tax object", 0, $e);
@@ -852,8 +893,11 @@ abstract class Tax implements ActiveRecordInterface
if ($this->isColumnModified(TaxTableMap::ID)) {
$modifiedColumns[':p' . $index++] = 'ID';
}
if ($this->isColumnModified(TaxTableMap::RATE)) {
$modifiedColumns[':p' . $index++] = 'RATE';
if ($this->isColumnModified(TaxTableMap::TYPE)) {
$modifiedColumns[':p' . $index++] = 'TYPE';
}
if ($this->isColumnModified(TaxTableMap::SERIALIZED_REQUIREMENTS)) {
$modifiedColumns[':p' . $index++] = 'SERIALIZED_REQUIREMENTS';
}
if ($this->isColumnModified(TaxTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
@@ -875,8 +919,11 @@ abstract class Tax implements ActiveRecordInterface
case 'ID':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case 'RATE':
$stmt->bindValue($identifier, $this->rate, PDO::PARAM_STR);
case 'TYPE':
$stmt->bindValue($identifier, $this->type, PDO::PARAM_STR);
break;
case 'SERIALIZED_REQUIREMENTS':
$stmt->bindValue($identifier, $this->serialized_requirements, PDO::PARAM_STR);
break;
case 'CREATED_AT':
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
@@ -950,12 +997,15 @@ abstract class Tax implements ActiveRecordInterface
return $this->getId();
break;
case 1:
return $this->getRate();
return $this->getType();
break;
case 2:
return $this->getCreatedAt();
return $this->getSerializedRequirements();
break;
case 3:
return $this->getCreatedAt();
break;
case 4:
return $this->getUpdatedAt();
break;
default:
@@ -988,9 +1038,10 @@ abstract class Tax implements ActiveRecordInterface
$keys = TaxTableMap::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getRate(),
$keys[2] => $this->getCreatedAt(),
$keys[3] => $this->getUpdatedAt(),
$keys[1] => $this->getType(),
$keys[2] => $this->getSerializedRequirements(),
$keys[3] => $this->getCreatedAt(),
$keys[4] => $this->getUpdatedAt(),
);
$virtualColumns = $this->virtualColumns;
foreach($virtualColumns as $key => $virtualColumn)
@@ -1043,12 +1094,15 @@ abstract class Tax implements ActiveRecordInterface
$this->setId($value);
break;
case 1:
$this->setRate($value);
$this->setType($value);
break;
case 2:
$this->setCreatedAt($value);
$this->setSerializedRequirements($value);
break;
case 3:
$this->setCreatedAt($value);
break;
case 4:
$this->setUpdatedAt($value);
break;
} // switch()
@@ -1076,9 +1130,10 @@ abstract class Tax implements ActiveRecordInterface
$keys = TaxTableMap::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setRate($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
if (array_key_exists($keys[1], $arr)) $this->setType($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setSerializedRequirements($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
}
/**
@@ -1091,7 +1146,8 @@ abstract class Tax implements ActiveRecordInterface
$criteria = new Criteria(TaxTableMap::DATABASE_NAME);
if ($this->isColumnModified(TaxTableMap::ID)) $criteria->add(TaxTableMap::ID, $this->id);
if ($this->isColumnModified(TaxTableMap::RATE)) $criteria->add(TaxTableMap::RATE, $this->rate);
if ($this->isColumnModified(TaxTableMap::TYPE)) $criteria->add(TaxTableMap::TYPE, $this->type);
if ($this->isColumnModified(TaxTableMap::SERIALIZED_REQUIREMENTS)) $criteria->add(TaxTableMap::SERIALIZED_REQUIREMENTS, $this->serialized_requirements);
if ($this->isColumnModified(TaxTableMap::CREATED_AT)) $criteria->add(TaxTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(TaxTableMap::UPDATED_AT)) $criteria->add(TaxTableMap::UPDATED_AT, $this->updated_at);
@@ -1157,7 +1213,8 @@ abstract class Tax implements ActiveRecordInterface
*/
public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setRate($this->getRate());
$copyObj->setType($this->getType());
$copyObj->setSerializedRequirements($this->getSerializedRequirements());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
@@ -1729,7 +1786,8 @@ abstract class Tax implements ActiveRecordInterface
public function clear()
{
$this->id = null;
$this->rate = null;
$this->type = null;
$this->serialized_requirements = null;
$this->created_at = null;
$this->updated_at = null;
$this->alreadyInSave = false;

View File

@@ -23,12 +23,14 @@ use Thelia\Model\Map\TaxTableMap;
*
*
* @method ChildTaxQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildTaxQuery orderByRate($order = Criteria::ASC) Order by the rate column
* @method ChildTaxQuery orderByType($order = Criteria::ASC) Order by the type column
* @method ChildTaxQuery orderBySerializedRequirements($order = Criteria::ASC) Order by the serialized_requirements column
* @method ChildTaxQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildTaxQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
* @method ChildTaxQuery groupById() Group by the id column
* @method ChildTaxQuery groupByRate() Group by the rate column
* @method ChildTaxQuery groupByType() Group by the type column
* @method ChildTaxQuery groupBySerializedRequirements() Group by the serialized_requirements column
* @method ChildTaxQuery groupByCreatedAt() Group by the created_at column
* @method ChildTaxQuery groupByUpdatedAt() Group by the updated_at column
*
@@ -48,12 +50,14 @@ use Thelia\Model\Map\TaxTableMap;
* @method ChildTax findOneOrCreate(ConnectionInterface $con = null) Return the first ChildTax matching the query, or a new ChildTax object populated from the query conditions when no match is found
*
* @method ChildTax findOneById(int $id) Return the first ChildTax filtered by the id column
* @method ChildTax findOneByRate(double $rate) Return the first ChildTax filtered by the rate column
* @method ChildTax findOneByType(string $type) Return the first ChildTax filtered by the type column
* @method ChildTax findOneBySerializedRequirements(string $serialized_requirements) Return the first ChildTax filtered by the serialized_requirements column
* @method ChildTax findOneByCreatedAt(string $created_at) Return the first ChildTax filtered by the created_at column
* @method ChildTax findOneByUpdatedAt(string $updated_at) Return the first ChildTax filtered by the updated_at column
*
* @method array findById(int $id) Return ChildTax objects filtered by the id column
* @method array findByRate(double $rate) Return ChildTax objects filtered by the rate column
* @method array findByType(string $type) Return ChildTax objects filtered by the type column
* @method array findBySerializedRequirements(string $serialized_requirements) Return ChildTax objects filtered by the serialized_requirements column
* @method array findByCreatedAt(string $created_at) Return ChildTax objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildTax objects filtered by the updated_at column
*
@@ -144,7 +148,7 @@ abstract class TaxQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, RATE, CREATED_AT, UPDATED_AT FROM tax WHERE ID = :p0';
$sql = 'SELECT ID, TYPE, SERIALIZED_REQUIREMENTS, CREATED_AT, UPDATED_AT FROM tax WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -275,44 +279,61 @@ abstract class TaxQuery extends ModelCriteria
}
/**
* Filter the query on the rate column
* Filter the query on the type column
*
* Example usage:
* <code>
* $query->filterByRate(1234); // WHERE rate = 1234
* $query->filterByRate(array(12, 34)); // WHERE rate IN (12, 34)
* $query->filterByRate(array('min' => 12)); // WHERE rate > 12
* $query->filterByType('fooValue'); // WHERE type = 'fooValue'
* $query->filterByType('%fooValue%'); // WHERE type LIKE '%fooValue%'
* </code>
*
* @param mixed $rate 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 $type 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 ChildTaxQuery The current query, for fluid interface
*/
public function filterByRate($rate = null, $comparison = null)
public function filterByType($type = null, $comparison = null)
{
if (is_array($rate)) {
$useMinMax = false;
if (isset($rate['min'])) {
$this->addUsingAlias(TaxTableMap::RATE, $rate['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($rate['max'])) {
$this->addUsingAlias(TaxTableMap::RATE, $rate['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
if (null === $comparison) {
if (is_array($type)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $type)) {
$type = str_replace('*', '%', $type);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(TaxTableMap::RATE, $rate, $comparison);
return $this->addUsingAlias(TaxTableMap::TYPE, $type, $comparison);
}
/**
* Filter the query on the serialized_requirements column
*
* Example usage:
* <code>
* $query->filterBySerializedRequirements('fooValue'); // WHERE serialized_requirements = 'fooValue'
* $query->filterBySerializedRequirements('%fooValue%'); // WHERE serialized_requirements LIKE '%fooValue%'
* </code>
*
* @param string $serializedRequirements 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 ChildTaxQuery The current query, for fluid interface
*/
public function filterBySerializedRequirements($serializedRequirements = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($serializedRequirements)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $serializedRequirements)) {
$serializedRequirements = str_replace('*', '%', $serializedRequirements);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(TaxTableMap::SERIALIZED_REQUIREMENTS, $serializedRequirements, $comparison);
}
/**

View File

@@ -49,24 +49,25 @@ class Coupon extends BaseCoupon
/**
* Constructor
* Create or Update this Coupon
*
* @param string $code Coupon Code
* @param string $title Coupon title
* @param float $amount Amount removed from the Total Checkout
* @param string $effect Coupon effect
* @param string $shortDescription Coupon short description
* @param string $description Coupon description
* @param boolean $isEnabled Enable/Disable
* @param \DateTime $expirationDate Coupon expiration date
* @param boolean $isAvailableOnSpecialOffers Is available on special offers
* @param boolean $isCumulative Is cumulative
* @param boolean $isRemovingPostage Is removing Postage
* @param int $maxUsage Coupon quantity
* @param CouponRuleCollection $rules CouponRuleInterface to add
* @param string $locale Coupon Language code ISO (ex: fr_FR)
* @param string $code Coupon Code
* @param string $title Coupon title
* @param float $amount Amount removed from the Total Checkout
* @param string $effect Coupon effect
* @param bool $isRemovingPostage Is removing Postage
* @param string $shortDescription Coupon short description
* @param string $description Coupon description
* @param boolean $isEnabled Enable/Disable
* @param \DateTime $expirationDate Coupon expiration date
* @param boolean $isAvailableOnSpecialOffers Is available on special offers
* @param boolean $isCumulative Is cumulative
* @param int $maxUsage Coupon quantity
* @param string $locale Coupon Language code ISO (ex: fr_FR)
*
* @throws \Exception
*/
function createOrUpdate($code, $title, $amount, $effect, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $rules, $locale = null)
function createOrUpdate($code, $title, $amount, $effect, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $locale = null)
{
$this->setCode($code)
->setTitle($title)
@@ -74,13 +75,13 @@ class Coupon extends BaseCoupon
->setDescription($description)
->setType($effect)
->setAmount($amount)
->setIsRemovingPostage($isRemovingPostage)
->setType($amount)
->setIsEnabled($isEnabled)
->setExpirationDate($expirationDate)
->setIsAvailableOnSpecialOffers($isAvailableOnSpecialOffers)
->setIsCumulative($isCumulative)
->setMaxUsage($maxUsage)
->setRules($rules);
->setMaxUsage($maxUsage);
// Set object language (i18n)
if (!is_null($locale)) {
@@ -99,33 +100,34 @@ class Coupon extends BaseCoupon
}
}
// /**
// * Set the value of [serialized_rules] column.
// * Convert a CouponRuleCollection into a serialized array of SerializableRule
// *
// * @param CouponRuleCollection $rules A set of Rules
// *
// * @return \Thelia\Model\Coupon The current object (for fluent API support)
// */
// public function setRules(CouponRuleCollection $rules)
// {
// $serializedRules = null;
// if ($rules !== null) {
// /** @var $rule CouponRuleInterface */
// foreach ($rules->getRules() as $rule) {
// $serializedRules[] = $rule->getSerializableRule();
// }
//
// $serializedRules = (string) base64_encode(serialize($serializedRules));
// }
//
// if ($this->serialized_rules !== $serializedRules) {
// $this->serialized_rules = $serializedRules;
// $this->modifiedColumns[] = CouponTableMap::SERIALIZED_RULES;
// }
//
// return $this;
// }
/**
* Create or Update this coupon rule
*
* @param string $serializableRules Serialized rules ready to be saved
* @param string $locale Coupon Language code ISO (ex: fr_FR)
*
* @throws \Exception
*/
function createOrUpdateRules($serializableRules, $locale)
{
$this->setSerializedRules($serializableRules);
// Set object language (i18n)
if (!is_null($locale)) {
$this->setLocale($locale);
}
$con = Propel::getWriteConnection(CouponTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
$this->save($con);
$con->commit();
} catch(\Exception $e) {
$con->rollback();
throw $e;
}
}

View File

@@ -57,7 +57,7 @@ class ProductSaleElementsTableMap extends TableMap
/**
* The total number of columns
*/
const NUM_COLUMNS = 8;
const NUM_COLUMNS = 9;
/**
* The number of lazy-loaded columns
@@ -67,7 +67,7 @@ class ProductSaleElementsTableMap extends TableMap
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 8;
const NUM_HYDRATE_COLUMNS = 9;
/**
* the column name for the ID field
@@ -79,6 +79,11 @@ class ProductSaleElementsTableMap extends TableMap
*/
const PRODUCT_ID = 'product_sale_elements.PRODUCT_ID';
/**
* the column name for the REF field
*/
const REF = 'product_sale_elements.REF';
/**
* the column name for the QUANTITY field
*/
@@ -121,12 +126,12 @@ class ProductSaleElementsTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'ProductId', 'Quantity', 'Promo', 'Newness', 'Weight', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'quantity', 'promo', 'newness', 'weight', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID, ProductSaleElementsTableMap::PRODUCT_ID, ProductSaleElementsTableMap::QUANTITY, ProductSaleElementsTableMap::PROMO, ProductSaleElementsTableMap::NEWNESS, ProductSaleElementsTableMap::WEIGHT, ProductSaleElementsTableMap::CREATED_AT, ProductSaleElementsTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'QUANTITY', 'PROMO', 'NEWNESS', 'WEIGHT', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'product_id', 'quantity', 'promo', 'newness', 'weight', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
self::TYPE_PHPNAME => array('Id', 'ProductId', 'Ref', 'Quantity', 'Promo', 'Newness', 'Weight', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'ref', 'quantity', 'promo', 'newness', 'weight', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID, ProductSaleElementsTableMap::PRODUCT_ID, ProductSaleElementsTableMap::REF, ProductSaleElementsTableMap::QUANTITY, ProductSaleElementsTableMap::PROMO, ProductSaleElementsTableMap::NEWNESS, ProductSaleElementsTableMap::WEIGHT, ProductSaleElementsTableMap::CREATED_AT, ProductSaleElementsTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'REF', 'QUANTITY', 'PROMO', 'NEWNESS', 'WEIGHT', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'product_id', 'ref', 'quantity', 'promo', 'newness', 'weight', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
);
/**
@@ -136,12 +141,12 @@ class ProductSaleElementsTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'Quantity' => 2, 'Promo' => 3, 'Newness' => 4, 'Weight' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'quantity' => 2, 'promo' => 3, 'newness' => 4, 'weight' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID => 0, ProductSaleElementsTableMap::PRODUCT_ID => 1, ProductSaleElementsTableMap::QUANTITY => 2, ProductSaleElementsTableMap::PROMO => 3, ProductSaleElementsTableMap::NEWNESS => 4, ProductSaleElementsTableMap::WEIGHT => 5, ProductSaleElementsTableMap::CREATED_AT => 6, ProductSaleElementsTableMap::UPDATED_AT => 7, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'QUANTITY' => 2, 'PROMO' => 3, 'NEWNESS' => 4, 'WEIGHT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'quantity' => 2, 'promo' => 3, 'newness' => 4, 'weight' => 5, 'created_at' => 6, 'updated_at' => 7, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'Ref' => 2, 'Quantity' => 3, 'Promo' => 4, 'Newness' => 5, 'Weight' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'createdAt' => 7, 'updatedAt' => 8, ),
self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID => 0, ProductSaleElementsTableMap::PRODUCT_ID => 1, ProductSaleElementsTableMap::REF => 2, ProductSaleElementsTableMap::QUANTITY => 3, ProductSaleElementsTableMap::PROMO => 4, ProductSaleElementsTableMap::NEWNESS => 5, ProductSaleElementsTableMap::WEIGHT => 6, ProductSaleElementsTableMap::CREATED_AT => 7, ProductSaleElementsTableMap::UPDATED_AT => 8, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'REF' => 2, 'QUANTITY' => 3, 'PROMO' => 4, 'NEWNESS' => 5, 'WEIGHT' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ),
self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'created_at' => 7, 'updated_at' => 8, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
);
/**
@@ -162,6 +167,7 @@ class ProductSaleElementsTableMap extends TableMap
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null);
$this->addColumn('REF', 'Ref', 'VARCHAR', true, 45, null);
$this->addColumn('QUANTITY', 'Quantity', 'FLOAT', true, null, null);
$this->addColumn('PROMO', 'Promo', 'TINYINT', false, null, 0);
$this->addColumn('NEWNESS', 'Newness', 'TINYINT', false, null, 0);
@@ -343,6 +349,7 @@ class ProductSaleElementsTableMap extends TableMap
if (null === $alias) {
$criteria->addSelectColumn(ProductSaleElementsTableMap::ID);
$criteria->addSelectColumn(ProductSaleElementsTableMap::PRODUCT_ID);
$criteria->addSelectColumn(ProductSaleElementsTableMap::REF);
$criteria->addSelectColumn(ProductSaleElementsTableMap::QUANTITY);
$criteria->addSelectColumn(ProductSaleElementsTableMap::PROMO);
$criteria->addSelectColumn(ProductSaleElementsTableMap::NEWNESS);
@@ -352,6 +359,7 @@ class ProductSaleElementsTableMap extends TableMap
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.PRODUCT_ID');
$criteria->addSelectColumn($alias . '.REF');
$criteria->addSelectColumn($alias . '.QUANTITY');
$criteria->addSelectColumn($alias . '.PROMO');
$criteria->addSelectColumn($alias . '.NEWNESS');

View File

@@ -57,7 +57,7 @@ class TaxTableMap extends TableMap
/**
* The total number of columns
*/
const NUM_COLUMNS = 4;
const NUM_COLUMNS = 5;
/**
* The number of lazy-loaded columns
@@ -67,7 +67,7 @@ class TaxTableMap extends TableMap
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 4;
const NUM_HYDRATE_COLUMNS = 5;
/**
* the column name for the ID field
@@ -75,9 +75,14 @@ class TaxTableMap extends TableMap
const ID = 'tax.ID';
/**
* the column name for the RATE field
* the column name for the TYPE field
*/
const RATE = 'tax.RATE';
const TYPE = 'tax.TYPE';
/**
* the column name for the SERIALIZED_REQUIREMENTS field
*/
const SERIALIZED_REQUIREMENTS = 'tax.SERIALIZED_REQUIREMENTS';
/**
* the column name for the CREATED_AT field
@@ -110,12 +115,12 @@ class TaxTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'Rate', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'rate', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(TaxTableMap::ID, TaxTableMap::RATE, TaxTableMap::CREATED_AT, TaxTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'RATE', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'rate', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, )
self::TYPE_PHPNAME => array('Id', 'Type', 'SerializedRequirements', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'type', 'serializedRequirements', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(TaxTableMap::ID, TaxTableMap::TYPE, TaxTableMap::SERIALIZED_REQUIREMENTS, TaxTableMap::CREATED_AT, TaxTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'TYPE', 'SERIALIZED_REQUIREMENTS', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'type', 'serialized_requirements', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, )
);
/**
@@ -125,12 +130,12 @@ class TaxTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'Rate' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'rate' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
self::TYPE_COLNAME => array(TaxTableMap::ID => 0, TaxTableMap::RATE => 1, TaxTableMap::CREATED_AT => 2, TaxTableMap::UPDATED_AT => 3, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'RATE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
self::TYPE_FIELDNAME => array('id' => 0, 'rate' => 1, 'created_at' => 2, 'updated_at' => 3, ),
self::TYPE_NUM => array(0, 1, 2, 3, )
self::TYPE_PHPNAME => array('Id' => 0, 'Type' => 1, 'SerializedRequirements' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'type' => 1, 'serializedRequirements' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
self::TYPE_COLNAME => array(TaxTableMap::ID => 0, TaxTableMap::TYPE => 1, TaxTableMap::SERIALIZED_REQUIREMENTS => 2, TaxTableMap::CREATED_AT => 3, TaxTableMap::UPDATED_AT => 4, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'TYPE' => 1, 'SERIALIZED_REQUIREMENTS' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
self::TYPE_FIELDNAME => array('id' => 0, 'type' => 1, 'serialized_requirements' => 2, 'created_at' => 3, 'updated_at' => 4, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, )
);
/**
@@ -150,7 +155,8 @@ class TaxTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('RATE', 'Rate', 'FLOAT', true, null, null);
$this->addColumn('TYPE', 'Type', 'VARCHAR', true, 255, null);
$this->addColumn('SERIALIZED_REQUIREMENTS', 'SerializedRequirements', 'LONGVARCHAR', true, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
@@ -327,12 +333,14 @@ class TaxTableMap extends TableMap
{
if (null === $alias) {
$criteria->addSelectColumn(TaxTableMap::ID);
$criteria->addSelectColumn(TaxTableMap::RATE);
$criteria->addSelectColumn(TaxTableMap::TYPE);
$criteria->addSelectColumn(TaxTableMap::SERIALIZED_REQUIREMENTS);
$criteria->addSelectColumn(TaxTableMap::CREATED_AT);
$criteria->addSelectColumn(TaxTableMap::UPDATED_AT);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.RATE');
$criteria->addSelectColumn($alias . '.TYPE');
$criteria->addSelectColumn($alias . '.SERIALIZED_REQUIREMENTS');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}

View File

@@ -4,6 +4,7 @@ namespace Thelia\Model;
use Thelia\Exception\TaxEngineException;
use Thelia\Model\Base\Tax as BaseTax;
use Thelia\TaxEngine\TaxType\BaseTaxType;
class Tax extends BaseTax
{
@@ -33,14 +34,37 @@ class Tax extends BaseTax
return $taxRuleCountryPosition;
}
public function getTaxRuleRateSum()
public function getTypeInstance()
{
try {
$taxRuleRateSum = $this->getVirtualColumn(TaxRuleQuery::ALIAS_FOR_TAX_RATE_SUM);
} catch(PropelException $e) {
throw new PropelException("Virtual column `" . TaxRuleQuery::ALIAS_FOR_TAX_RATE_SUM . "` does not exist in Tax::getTaxRuleRateSum");
$class = '\\Thelia\\TaxEngine\\TaxType\\' . $this->getType();
/* test type */
if(!class_exists($class)) {
throw new TaxEngineException('Recorded type `' . $class . '` does not exists', TaxEngineException::BAD_RECORDED_TYPE);
}
return $taxRuleRateSum;
$instance = new $class;
if(!$instance instanceof BaseTaxType) {
throw new TaxEngineException('Recorded type `' . $class . '` does not extends BaseTaxType', TaxEngineException::BAD_RECORDED_TYPE);
}
return $instance;
}
public function setRequirements($requirements)
{
return parent::setSerializedRequirements(base64_encode(json_encode($requirements)));
}
public function getRequirements()
{
$requirements = json_decode(base64_decode(parent::getSerializedRequirements()), true);
if(json_last_error() != JSON_ERROR_NONE || !is_array($requirements)) {
throw new TaxEngineException('BAD RECORDED REQUIREMENTS', TaxEngineException::BAD_RECORDED_REQUIREMENTS);
}
return $requirements;
}
}

View File

@@ -20,21 +20,18 @@ use Thelia\Model\Map\TaxTableMap;
class TaxRuleQuery extends BaseTaxRuleQuery
{
const ALIAS_FOR_TAX_RULE_COUNTRY_POSITION = 'taxRuleCountryPosition';
const ALIAS_FOR_TAX_RATE_SUM = 'taxRateSum';
public function getTaxCalculatorGroupedCollection(Product $product, Country $country)
public function getTaxCalculatorCollection(Product $product, Country $country)
{
$search = TaxQuery::create()
->filterByTaxRuleCountry(
TaxRuleCountryQuery::create()
->filterByCountry($country, Criteria::EQUAL)
->filterByTaxRuleId($product->getTaxRuleId())
->groupByPosition()
->orderByPosition()
->find()
)
->withColumn(TaxRuleCountryTableMap::POSITION, self::ALIAS_FOR_TAX_RULE_COUNTRY_POSITION)
->withColumn('ROUND(SUM(' . TaxTableMap::RATE . '), 2)', self::ALIAS_FOR_TAX_RATE_SUM)
;
return $search->find();