CartCreditNote instance. If
+ * obj is an instance of CartCreditNote, delegates to
+ * equals(CartCreditNote). Otherwise, returns false.
+ *
+ * @param mixed $obj The object to compare to.
+ * @return boolean Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return array_key_exists($name, $this->virtualColumns);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return mixed
+ *
+ * @throws PropelException
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return CartCreditNote The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return CartCreditNote The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+
+ return $this;
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [cart_id] column value.
+ *
+ * @return int
+ */
+ public function getCartId()
+ {
+
+ return $this->cart_id;
+ }
+
+ /**
+ * Get the [credit_note_id] column value.
+ *
+ * @return int
+ */
+ public function getCreditNoteId()
+ {
+
+ return $this->credit_note_id;
+ }
+
+ /**
+ * Get the [amount_price] column value.
+ *
+ * @return string
+ */
+ public function getAmountPrice()
+ {
+
+ return $this->amount_price;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [cart_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CartCreditNote The current object (for fluent API support)
+ */
+ public function setCartId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->cart_id !== $v) {
+ $this->cart_id = $v;
+ $this->modifiedColumns[CartCreditNoteTableMap::CART_ID] = true;
+ }
+
+ if ($this->aCart !== null && $this->aCart->getId() !== $v) {
+ $this->aCart = null;
+ }
+
+
+ return $this;
+ } // setCartId()
+
+ /**
+ * Set the value of [credit_note_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CartCreditNote The current object (for fluent API support)
+ */
+ public function setCreditNoteId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->credit_note_id !== $v) {
+ $this->credit_note_id = $v;
+ $this->modifiedColumns[CartCreditNoteTableMap::CREDIT_NOTE_ID] = true;
+ }
+
+ if ($this->aCreditNote !== null && $this->aCreditNote->getId() !== $v) {
+ $this->aCreditNote = null;
+ }
+
+
+ return $this;
+ } // setCreditNoteId()
+
+ /**
+ * Set the value of [amount_price] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CartCreditNote The current object (for fluent API support)
+ */
+ public function setAmountPrice($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->amount_price !== $v) {
+ $this->amount_price = $v;
+ $this->modifiedColumns[CartCreditNoteTableMap::AMOUNT_PRICE] = true;
+ }
+
+
+ return $this;
+ } // setAmountPrice()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CartCreditNote The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[CartCreditNoteTableMap::CREATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CartCreditNote The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[CartCreditNoteTableMap::UPDATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->amount_price !== '0.000000') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CartCreditNoteTableMap::translateFieldName('CartId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->cart_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CartCreditNoteTableMap::translateFieldName('CreditNoteId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->credit_note_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CartCreditNoteTableMap::translateFieldName('AmountPrice', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->amount_price = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CartCreditNoteTableMap::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 ? 4 + $startcol : CartCreditNoteTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = CartCreditNoteTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \CreditNote\Model\CartCreditNote object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCart !== null && $this->cart_id !== $this->aCart->getId()) {
+ $this->aCart = null;
+ }
+ if ($this->aCreditNote !== null && $this->credit_note_id !== $this->aCreditNote->getId()) {
+ $this->aCreditNote = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CartCreditNoteTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCartCreditNoteQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCart = null;
+ $this->aCreditNote = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see CartCreditNote::setDeleted()
+ * @see CartCreditNote::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CartCreditNoteTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCartCreditNoteQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see doSave()
+ */
+ public function save(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CartCreditNoteTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(CartCreditNoteTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(CartCreditNoteTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(CartCreditNoteTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CartCreditNoteTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCart !== null) {
+ if ($this->aCart->isModified() || $this->aCart->isNew()) {
+ $affectedRows += $this->aCart->save($con);
+ }
+ $this->setCart($this->aCart);
+ }
+
+ if ($this->aCreditNote !== null) {
+ if ($this->aCreditNote->isModified() || $this->aCreditNote->isNew()) {
+ $affectedRows += $this->aCreditNote->save($con);
+ }
+ $this->setCreditNote($this->aCreditNote);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CartCreditNoteTableMap::CART_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CART_ID';
+ }
+ if ($this->isColumnModified(CartCreditNoteTableMap::CREDIT_NOTE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CREDIT_NOTE_ID';
+ }
+ if ($this->isColumnModified(CartCreditNoteTableMap::AMOUNT_PRICE)) {
+ $modifiedColumns[':p' . $index++] = 'AMOUNT_PRICE';
+ }
+ if ($this->isColumnModified(CartCreditNoteTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CartCreditNoteTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO cart_credit_note (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'CART_ID':
+ $stmt->bindValue($identifier, $this->cart_id, PDO::PARAM_INT);
+ break;
+ case 'CREDIT_NOTE_ID':
+ $stmt->bindValue($identifier, $this->credit_note_id, PDO::PARAM_INT);
+ break;
+ case 'AMOUNT_PRICE':
+ $stmt->bindValue($identifier, $this->amount_price, 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);
+ 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);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CartCreditNoteTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getCartId();
+ break;
+ case 1:
+ return $this->getCreditNoteId();
+ break;
+ case 2:
+ return $this->getAmountPrice();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CartCreditNote'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CartCreditNote'][serialize($this->getPrimaryKey())] = true;
+ $keys = CartCreditNoteTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getCartId(),
+ $keys[1] => $this->getCreditNoteId(),
+ $keys[2] => $this->getAmountPrice(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach ($virtualColumns as $key => $virtualColumn) {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCart) {
+ $result['Cart'] = $this->aCart->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCreditNote) {
+ $result['CreditNote'] = $this->aCreditNote->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CartCreditNoteTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+
+ return $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setCartId($value);
+ break;
+ case 1:
+ $this->setCreditNoteId($value);
+ break;
+ case 2:
+ $this->setAmountPrice($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CartCreditNoteTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setCartId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCreditNoteId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setAmountPrice($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]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CartCreditNoteTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CartCreditNoteTableMap::CART_ID)) $criteria->add(CartCreditNoteTableMap::CART_ID, $this->cart_id);
+ if ($this->isColumnModified(CartCreditNoteTableMap::CREDIT_NOTE_ID)) $criteria->add(CartCreditNoteTableMap::CREDIT_NOTE_ID, $this->credit_note_id);
+ if ($this->isColumnModified(CartCreditNoteTableMap::AMOUNT_PRICE)) $criteria->add(CartCreditNoteTableMap::AMOUNT_PRICE, $this->amount_price);
+ if ($this->isColumnModified(CartCreditNoteTableMap::CREATED_AT)) $criteria->add(CartCreditNoteTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CartCreditNoteTableMap::UPDATED_AT)) $criteria->add(CartCreditNoteTableMap::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CartCreditNoteTableMap::DATABASE_NAME);
+ $criteria->add(CartCreditNoteTableMap::CART_ID, $this->cart_id);
+ $criteria->add(CartCreditNoteTableMap::CREDIT_NOTE_ID, $this->credit_note_id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getCartId();
+ $pks[1] = $this->getCreditNoteId();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setCartId($keys[0]);
+ $this->setCreditNoteId($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getCartId()) && (null === $this->getCreditNoteId());
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of \CreditNote\Model\CartCreditNote (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCartId($this->getCartId());
+ $copyObj->setCreditNoteId($this->getCreditNoteId());
+ $copyObj->setAmountPrice($this->getAmountPrice());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return \CreditNote\Model\CartCreditNote Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCart object.
+ *
+ * @param ChildCart $v
+ * @return \CreditNote\Model\CartCreditNote The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCart(ChildCart $v = null)
+ {
+ if ($v === null) {
+ $this->setCartId(NULL);
+ } else {
+ $this->setCartId($v->getId());
+ }
+
+ $this->aCart = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCart object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCartCreditNote($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCart object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCart The associated ChildCart object.
+ * @throws PropelException
+ */
+ public function getCart(ConnectionInterface $con = null)
+ {
+ if ($this->aCart === null && ($this->cart_id !== null)) {
+ $this->aCart = CartQuery::create()->findPk($this->cart_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCart->addCartCreditNotes($this);
+ */
+ }
+
+ return $this->aCart;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCreditNote object.
+ *
+ * @param ChildCreditNote $v
+ * @return \CreditNote\Model\CartCreditNote The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCreditNote(ChildCreditNote $v = null)
+ {
+ if ($v === null) {
+ $this->setCreditNoteId(NULL);
+ } else {
+ $this->setCreditNoteId($v->getId());
+ }
+
+ $this->aCreditNote = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCreditNote object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCartCreditNote($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCreditNote object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCreditNote The associated ChildCreditNote object.
+ * @throws PropelException
+ */
+ public function getCreditNote(ConnectionInterface $con = null)
+ {
+ if ($this->aCreditNote === null && ($this->credit_note_id !== null)) {
+ $this->aCreditNote = ChildCreditNoteQuery::create()->findPk($this->credit_note_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCreditNote->addCartCreditNotes($this);
+ */
+ }
+
+ return $this->aCreditNote;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->cart_id = null;
+ $this->credit_note_id = null;
+ $this->amount_price = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCart = null;
+ $this->aCreditNote = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CartCreditNoteTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildCartCreditNote The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[CartCreditNoteTableMap::UPDATED_AT] = true;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/local/modules/CreditNote/Model/Base/CartCreditNoteQuery.php b/local/modules/CreditNote/Model/Base/CartCreditNoteQuery.php
new file mode 100644
index 000000000..74c9f21a4
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CartCreditNoteQuery.php
@@ -0,0 +1,774 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$cart_id, $credit_note_id] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCartCreditNote|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CartCreditNoteTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CartCreditNoteTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * 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 ChildCartCreditNote A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT CART_ID, CREDIT_NOTE_ID, AMOUNT_PRICE, CREATED_AT, UPDATED_AT FROM cart_credit_note WHERE CART_ID = :p0 AND CREDIT_NOTE_ID = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], 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 ChildCartCreditNote();
+ $obj->hydrate($row);
+ CartCreditNoteTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCartCreditNote|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCartCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(CartCreditNoteTableMap::CART_ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(CartCreditNoteTableMap::CREDIT_NOTE_ID, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCartCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(CartCreditNoteTableMap::CART_ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(CartCreditNoteTableMap::CREDIT_NOTE_ID, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the cart_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCartId(1234); // WHERE cart_id = 1234
+ * $query->filterByCartId(array(12, 34)); // WHERE cart_id IN (12, 34)
+ * $query->filterByCartId(array('min' => 12)); // WHERE cart_id > 12
+ *
+ *
+ * @see filterByCart()
+ *
+ * @param mixed $cartId 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 ChildCartCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCartId($cartId = null, $comparison = null)
+ {
+ if (is_array($cartId)) {
+ $useMinMax = false;
+ if (isset($cartId['min'])) {
+ $this->addUsingAlias(CartCreditNoteTableMap::CART_ID, $cartId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($cartId['max'])) {
+ $this->addUsingAlias(CartCreditNoteTableMap::CART_ID, $cartId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CartCreditNoteTableMap::CART_ID, $cartId, $comparison);
+ }
+
+ /**
+ * Filter the query on the credit_note_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreditNoteId(1234); // WHERE credit_note_id = 1234
+ * $query->filterByCreditNoteId(array(12, 34)); // WHERE credit_note_id IN (12, 34)
+ * $query->filterByCreditNoteId(array('min' => 12)); // WHERE credit_note_id > 12
+ *
+ *
+ * @see filterByCreditNote()
+ *
+ * @param mixed $creditNoteId 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 ChildCartCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteId($creditNoteId = null, $comparison = null)
+ {
+ if (is_array($creditNoteId)) {
+ $useMinMax = false;
+ if (isset($creditNoteId['min'])) {
+ $this->addUsingAlias(CartCreditNoteTableMap::CREDIT_NOTE_ID, $creditNoteId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($creditNoteId['max'])) {
+ $this->addUsingAlias(CartCreditNoteTableMap::CREDIT_NOTE_ID, $creditNoteId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CartCreditNoteTableMap::CREDIT_NOTE_ID, $creditNoteId, $comparison);
+ }
+
+ /**
+ * Filter the query on the amount_price column
+ *
+ * Example usage:
+ *
+ * $query->filterByAmountPrice(1234); // WHERE amount_price = 1234
+ * $query->filterByAmountPrice(array(12, 34)); // WHERE amount_price IN (12, 34)
+ * $query->filterByAmountPrice(array('min' => 12)); // WHERE amount_price > 12
+ *
+ *
+ * @param mixed $amountPrice 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 ChildCartCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByAmountPrice($amountPrice = null, $comparison = null)
+ {
+ if (is_array($amountPrice)) {
+ $useMinMax = false;
+ if (isset($amountPrice['min'])) {
+ $this->addUsingAlias(CartCreditNoteTableMap::AMOUNT_PRICE, $amountPrice['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($amountPrice['max'])) {
+ $this->addUsingAlias(CartCreditNoteTableMap::AMOUNT_PRICE, $amountPrice['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CartCreditNoteTableMap::AMOUNT_PRICE, $amountPrice, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCartCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CartCreditNoteTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CartCreditNoteTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CartCreditNoteTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCartCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CartCreditNoteTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CartCreditNoteTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CartCreditNoteTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Cart object
+ *
+ * @param \Thelia\Model\Cart|ObjectCollection $cart The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCartCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCart($cart, $comparison = null)
+ {
+ if ($cart instanceof \Thelia\Model\Cart) {
+ return $this
+ ->addUsingAlias(CartCreditNoteTableMap::CART_ID, $cart->getId(), $comparison);
+ } elseif ($cart instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CartCreditNoteTableMap::CART_ID, $cart->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCart() only accepts arguments of type \Thelia\Model\Cart or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Cart relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCartCreditNoteQuery The current query, for fluid interface
+ */
+ public function joinCart($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Cart');
+
+ // 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, 'Cart');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Cart relation Cart 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\CartQuery A secondary query class using the current class as primary query
+ */
+ public function useCartQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCart($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Cart', '\Thelia\Model\CartQuery');
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNote object
+ *
+ * @param \CreditNote\Model\CreditNote|ObjectCollection $creditNote The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCartCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCreditNote($creditNote, $comparison = null)
+ {
+ if ($creditNote instanceof \CreditNote\Model\CreditNote) {
+ return $this
+ ->addUsingAlias(CartCreditNoteTableMap::CREDIT_NOTE_ID, $creditNote->getId(), $comparison);
+ } elseif ($creditNote instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CartCreditNoteTableMap::CREDIT_NOTE_ID, $creditNote->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCreditNote() only accepts arguments of type \CreditNote\Model\CreditNote or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNote relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCartCreditNoteQuery The current query, for fluid interface
+ */
+ public function joinCreditNote($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNote');
+
+ // 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, 'CreditNote');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNote relation CreditNote 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 \CreditNote\Model\CreditNoteQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCreditNote($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNote', '\CreditNote\Model\CreditNoteQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCartCreditNote $cartCreditNote Object to remove from the list of results
+ *
+ * @return ChildCartCreditNoteQuery The current query, for fluid interface
+ */
+ public function prune($cartCreditNote = null)
+ {
+ if ($cartCreditNote) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(CartCreditNoteTableMap::CART_ID), $cartCreditNote->getCartId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(CartCreditNoteTableMap::CREDIT_NOTE_ID), $cartCreditNote->getCreditNoteId(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the cart_credit_note table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CartCreditNoteTableMap::DATABASE_NAME);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CartCreditNoteTableMap::clearInstancePool();
+ CartCreditNoteTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCartCreditNote or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCartCreditNote object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CartCreditNoteTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CartCreditNoteTableMap::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+
+ CartCreditNoteTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CartCreditNoteTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildCartCreditNoteQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CartCreditNoteTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildCartCreditNoteQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CartCreditNoteTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildCartCreditNoteQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CartCreditNoteTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildCartCreditNoteQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CartCreditNoteTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildCartCreditNoteQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CartCreditNoteTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildCartCreditNoteQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CartCreditNoteTableMap::CREATED_AT);
+ }
+
+} // CartCreditNoteQuery
diff --git a/local/modules/CreditNote/Model/Base/CreditNote.php b/local/modules/CreditNote/Model/Base/CreditNote.php
new file mode 100644
index 000000000..7007d6775
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNote.php
@@ -0,0 +1,4403 @@
+total_price = '0.000000';
+ $this->total_price_with_tax = '0.000000';
+ $this->discount_without_tax = '0.000000';
+ $this->discount_with_tax = '0.000000';
+ $this->allow_partial_use = true;
+ }
+
+ /**
+ * Initializes internal state of CreditNote\Model\Base\CreditNote object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !!$this->modifiedColumns;
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return boolean true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ if (isset($this->modifiedColumns[$col])) {
+ unset($this->modifiedColumns[$col]);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another CreditNote instance. If
+ * obj is an instance of CreditNote, delegates to
+ * equals(CreditNote). Otherwise, returns false.
+ *
+ * @param mixed $obj The object to compare to.
+ * @return boolean Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return array_key_exists($name, $this->virtualColumns);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return mixed
+ *
+ * @throws PropelException
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return CreditNote The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return CreditNote The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+
+ return $this;
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [ref] column value.
+ *
+ * @return string
+ */
+ public function getRef()
+ {
+
+ return $this->ref;
+ }
+
+ /**
+ * Get the [invoice_ref] column value.
+ *
+ * @return string
+ */
+ public function getInvoiceRef()
+ {
+
+ return $this->invoice_ref;
+ }
+
+ /**
+ * Get the [invoice_address_id] column value.
+ *
+ * @return int
+ */
+ public function getInvoiceAddressId()
+ {
+
+ return $this->invoice_address_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [invoice_date] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getInvoiceDate($format = NULL)
+ {
+ if ($format === null) {
+ return $this->invoice_date;
+ } else {
+ return $this->invoice_date instanceof \DateTime ? $this->invoice_date->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [order_id] column value.
+ *
+ * @return int
+ */
+ public function getOrderId()
+ {
+
+ return $this->order_id;
+ }
+
+ /**
+ * Get the [customer_id] column value.
+ *
+ * @return int
+ */
+ public function getCustomerId()
+ {
+
+ return $this->customer_id;
+ }
+
+ /**
+ * Get the [parent_id] column value.
+ *
+ * @return int
+ */
+ public function getParentId()
+ {
+
+ return $this->parent_id;
+ }
+
+ /**
+ * Get the [type_id] column value.
+ *
+ * @return int
+ */
+ public function getTypeId()
+ {
+
+ return $this->type_id;
+ }
+
+ /**
+ * Get the [status_id] column value.
+ *
+ * @return int
+ */
+ public function getStatusId()
+ {
+
+ return $this->status_id;
+ }
+
+ /**
+ * Get the [currency_id] column value.
+ *
+ * @return int
+ */
+ public function getCurrencyId()
+ {
+
+ return $this->currency_id;
+ }
+
+ /**
+ * Get the [currency_rate] column value.
+ *
+ * @return double
+ */
+ public function getCurrencyRate()
+ {
+
+ return $this->currency_rate;
+ }
+
+ /**
+ * Get the [total_price] column value.
+ *
+ * @return string
+ */
+ public function getTotalPrice()
+ {
+
+ return $this->total_price;
+ }
+
+ /**
+ * Get the [total_price_with_tax] column value.
+ *
+ * @return string
+ */
+ public function getTotalPriceWithTax()
+ {
+
+ return $this->total_price_with_tax;
+ }
+
+ /**
+ * Get the [discount_without_tax] column value.
+ *
+ * @return string
+ */
+ public function getDiscountWithoutTax()
+ {
+
+ return $this->discount_without_tax;
+ }
+
+ /**
+ * Get the [discount_with_tax] column value.
+ *
+ * @return string
+ */
+ public function getDiscountWithTax()
+ {
+
+ return $this->discount_with_tax;
+ }
+
+ /**
+ * Get the [allow_partial_use] column value.
+ *
+ * @return boolean
+ */
+ public function getAllowPartialUse()
+ {
+
+ return $this->allow_partial_use;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[CreditNoteTableMap::ID] = true;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [ref] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNote 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[CreditNoteTableMap::REF] = true;
+ }
+
+
+ return $this;
+ } // setRef()
+
+ /**
+ * Set the value of [invoice_ref] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function setInvoiceRef($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->invoice_ref !== $v) {
+ $this->invoice_ref = $v;
+ $this->modifiedColumns[CreditNoteTableMap::INVOICE_REF] = true;
+ }
+
+
+ return $this;
+ } // setInvoiceRef()
+
+ /**
+ * Set the value of [invoice_address_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function setInvoiceAddressId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->invoice_address_id !== $v) {
+ $this->invoice_address_id = $v;
+ $this->modifiedColumns[CreditNoteTableMap::INVOICE_ADDRESS_ID] = true;
+ }
+
+ if ($this->aCreditNoteAddress !== null && $this->aCreditNoteAddress->getId() !== $v) {
+ $this->aCreditNoteAddress = null;
+ }
+
+
+ return $this;
+ } // setInvoiceAddressId()
+
+ /**
+ * Sets the value of [invoice_date] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function setInvoiceDate($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->invoice_date !== null || $dt !== null) {
+ if ($dt !== $this->invoice_date) {
+ $this->invoice_date = $dt;
+ $this->modifiedColumns[CreditNoteTableMap::INVOICE_DATE] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setInvoiceDate()
+
+ /**
+ * Set the value of [order_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function setOrderId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->order_id !== $v) {
+ $this->order_id = $v;
+ $this->modifiedColumns[CreditNoteTableMap::ORDER_ID] = true;
+ }
+
+ if ($this->aOrder !== null && $this->aOrder->getId() !== $v) {
+ $this->aOrder = null;
+ }
+
+
+ return $this;
+ } // setOrderId()
+
+ /**
+ * Set the value of [customer_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function setCustomerId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->customer_id !== $v) {
+ $this->customer_id = $v;
+ $this->modifiedColumns[CreditNoteTableMap::CUSTOMER_ID] = true;
+ }
+
+ if ($this->aCustomer !== null && $this->aCustomer->getId() !== $v) {
+ $this->aCustomer = null;
+ }
+
+
+ return $this;
+ } // setCustomerId()
+
+ /**
+ * Set the value of [parent_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function setParentId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->parent_id !== $v) {
+ $this->parent_id = $v;
+ $this->modifiedColumns[CreditNoteTableMap::PARENT_ID] = true;
+ }
+
+ if ($this->aCreditNoteRelatedByParentId !== null && $this->aCreditNoteRelatedByParentId->getId() !== $v) {
+ $this->aCreditNoteRelatedByParentId = null;
+ }
+
+
+ return $this;
+ } // setParentId()
+
+ /**
+ * Set the value of [type_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function setTypeId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->type_id !== $v) {
+ $this->type_id = $v;
+ $this->modifiedColumns[CreditNoteTableMap::TYPE_ID] = true;
+ }
+
+ if ($this->aCreditNoteType !== null && $this->aCreditNoteType->getId() !== $v) {
+ $this->aCreditNoteType = null;
+ }
+
+
+ return $this;
+ } // setTypeId()
+
+ /**
+ * Set the value of [status_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function setStatusId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->status_id !== $v) {
+ $this->status_id = $v;
+ $this->modifiedColumns[CreditNoteTableMap::STATUS_ID] = true;
+ }
+
+ if ($this->aCreditNoteStatus !== null && $this->aCreditNoteStatus->getId() !== $v) {
+ $this->aCreditNoteStatus = null;
+ }
+
+
+ return $this;
+ } // setStatusId()
+
+ /**
+ * Set the value of [currency_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function setCurrencyId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->currency_id !== $v) {
+ $this->currency_id = $v;
+ $this->modifiedColumns[CreditNoteTableMap::CURRENCY_ID] = true;
+ }
+
+ if ($this->aCurrency !== null && $this->aCurrency->getId() !== $v) {
+ $this->aCurrency = null;
+ }
+
+
+ return $this;
+ } // setCurrencyId()
+
+ /**
+ * Set the value of [currency_rate] column.
+ *
+ * @param double $v new value
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function setCurrencyRate($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->currency_rate !== $v) {
+ $this->currency_rate = $v;
+ $this->modifiedColumns[CreditNoteTableMap::CURRENCY_RATE] = true;
+ }
+
+
+ return $this;
+ } // setCurrencyRate()
+
+ /**
+ * Set the value of [total_price] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function setTotalPrice($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->total_price !== $v) {
+ $this->total_price = $v;
+ $this->modifiedColumns[CreditNoteTableMap::TOTAL_PRICE] = true;
+ }
+
+
+ return $this;
+ } // setTotalPrice()
+
+ /**
+ * Set the value of [total_price_with_tax] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function setTotalPriceWithTax($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->total_price_with_tax !== $v) {
+ $this->total_price_with_tax = $v;
+ $this->modifiedColumns[CreditNoteTableMap::TOTAL_PRICE_WITH_TAX] = true;
+ }
+
+
+ return $this;
+ } // setTotalPriceWithTax()
+
+ /**
+ * Set the value of [discount_without_tax] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function setDiscountWithoutTax($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->discount_without_tax !== $v) {
+ $this->discount_without_tax = $v;
+ $this->modifiedColumns[CreditNoteTableMap::DISCOUNT_WITHOUT_TAX] = true;
+ }
+
+
+ return $this;
+ } // setDiscountWithoutTax()
+
+ /**
+ * Set the value of [discount_with_tax] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function setDiscountWithTax($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->discount_with_tax !== $v) {
+ $this->discount_with_tax = $v;
+ $this->modifiedColumns[CreditNoteTableMap::DISCOUNT_WITH_TAX] = true;
+ }
+
+
+ return $this;
+ } // setDiscountWithTax()
+
+ /**
+ * Sets the value of the [allow_partial_use] column.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ *
+ * @param boolean|integer|string $v The new value
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function setAllowPartialUse($v)
+ {
+ if ($v !== null) {
+ if (is_string($v)) {
+ $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ } else {
+ $v = (boolean) $v;
+ }
+ }
+
+ if ($this->allow_partial_use !== $v) {
+ $this->allow_partial_use = $v;
+ $this->modifiedColumns[CreditNoteTableMap::ALLOW_PARTIAL_USE] = true;
+ }
+
+
+ return $this;
+ } // setAllowPartialUse()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[CreditNoteTableMap::CREATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[CreditNoteTableMap::UPDATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->total_price !== '0.000000') {
+ return false;
+ }
+
+ if ($this->total_price_with_tax !== '0.000000') {
+ return false;
+ }
+
+ if ($this->discount_without_tax !== '0.000000') {
+ return false;
+ }
+
+ if ($this->discount_with_tax !== '0.000000') {
+ return false;
+ }
+
+ if ($this->allow_partial_use !== true) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CreditNoteTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CreditNoteTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->ref = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CreditNoteTableMap::translateFieldName('InvoiceRef', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->invoice_ref = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CreditNoteTableMap::translateFieldName('InvoiceAddressId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->invoice_address_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CreditNoteTableMap::translateFieldName('InvoiceDate', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->invoice_date = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CreditNoteTableMap::translateFieldName('OrderId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->order_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CreditNoteTableMap::translateFieldName('CustomerId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->customer_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CreditNoteTableMap::translateFieldName('ParentId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->parent_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CreditNoteTableMap::translateFieldName('TypeId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->type_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CreditNoteTableMap::translateFieldName('StatusId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->status_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CreditNoteTableMap::translateFieldName('CurrencyId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->currency_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CreditNoteTableMap::translateFieldName('CurrencyRate', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->currency_rate = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CreditNoteTableMap::translateFieldName('TotalPrice', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->total_price = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CreditNoteTableMap::translateFieldName('TotalPriceWithTax', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->total_price_with_tax = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : CreditNoteTableMap::translateFieldName('DiscountWithoutTax', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->discount_without_tax = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : CreditNoteTableMap::translateFieldName('DiscountWithTax', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->discount_with_tax = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : CreditNoteTableMap::translateFieldName('AllowPartialUse', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->allow_partial_use = (null !== $col) ? (boolean) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : CreditNoteTableMap::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 ? 18 + $startcol : CreditNoteTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 19; // 19 = CreditNoteTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \CreditNote\Model\CreditNote object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCreditNoteAddress !== null && $this->invoice_address_id !== $this->aCreditNoteAddress->getId()) {
+ $this->aCreditNoteAddress = null;
+ }
+ if ($this->aOrder !== null && $this->order_id !== $this->aOrder->getId()) {
+ $this->aOrder = null;
+ }
+ if ($this->aCustomer !== null && $this->customer_id !== $this->aCustomer->getId()) {
+ $this->aCustomer = null;
+ }
+ if ($this->aCreditNoteRelatedByParentId !== null && $this->parent_id !== $this->aCreditNoteRelatedByParentId->getId()) {
+ $this->aCreditNoteRelatedByParentId = null;
+ }
+ if ($this->aCreditNoteType !== null && $this->type_id !== $this->aCreditNoteType->getId()) {
+ $this->aCreditNoteType = null;
+ }
+ if ($this->aCreditNoteStatus !== null && $this->status_id !== $this->aCreditNoteStatus->getId()) {
+ $this->aCreditNoteStatus = null;
+ }
+ if ($this->aCurrency !== null && $this->currency_id !== $this->aCurrency->getId()) {
+ $this->aCurrency = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCreditNoteQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aOrder = null;
+ $this->aCustomer = null;
+ $this->aCreditNoteRelatedByParentId = null;
+ $this->aCreditNoteType = null;
+ $this->aCreditNoteStatus = null;
+ $this->aCurrency = null;
+ $this->aCreditNoteAddress = null;
+ $this->collCreditNotesRelatedById = null;
+
+ $this->collOrderCreditNotes = null;
+
+ $this->collCartCreditNotes = null;
+
+ $this->collCreditNoteDetails = null;
+
+ $this->collCreditNoteComments = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see CreditNote::setDeleted()
+ * @see CreditNote::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCreditNoteQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see doSave()
+ */
+ public function save(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(CreditNoteTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(CreditNoteTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(CreditNoteTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CreditNoteTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aOrder !== null) {
+ if ($this->aOrder->isModified() || $this->aOrder->isNew()) {
+ $affectedRows += $this->aOrder->save($con);
+ }
+ $this->setOrder($this->aOrder);
+ }
+
+ if ($this->aCustomer !== null) {
+ if ($this->aCustomer->isModified() || $this->aCustomer->isNew()) {
+ $affectedRows += $this->aCustomer->save($con);
+ }
+ $this->setCustomer($this->aCustomer);
+ }
+
+ if ($this->aCreditNoteRelatedByParentId !== null) {
+ if ($this->aCreditNoteRelatedByParentId->isModified() || $this->aCreditNoteRelatedByParentId->isNew()) {
+ $affectedRows += $this->aCreditNoteRelatedByParentId->save($con);
+ }
+ $this->setCreditNoteRelatedByParentId($this->aCreditNoteRelatedByParentId);
+ }
+
+ if ($this->aCreditNoteType !== null) {
+ if ($this->aCreditNoteType->isModified() || $this->aCreditNoteType->isNew()) {
+ $affectedRows += $this->aCreditNoteType->save($con);
+ }
+ $this->setCreditNoteType($this->aCreditNoteType);
+ }
+
+ if ($this->aCreditNoteStatus !== null) {
+ if ($this->aCreditNoteStatus->isModified() || $this->aCreditNoteStatus->isNew()) {
+ $affectedRows += $this->aCreditNoteStatus->save($con);
+ }
+ $this->setCreditNoteStatus($this->aCreditNoteStatus);
+ }
+
+ if ($this->aCurrency !== null) {
+ if ($this->aCurrency->isModified() || $this->aCurrency->isNew()) {
+ $affectedRows += $this->aCurrency->save($con);
+ }
+ $this->setCurrency($this->aCurrency);
+ }
+
+ if ($this->aCreditNoteAddress !== null) {
+ if ($this->aCreditNoteAddress->isModified() || $this->aCreditNoteAddress->isNew()) {
+ $affectedRows += $this->aCreditNoteAddress->save($con);
+ }
+ $this->setCreditNoteAddress($this->aCreditNoteAddress);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->creditNotesRelatedByIdScheduledForDeletion !== null) {
+ if (!$this->creditNotesRelatedByIdScheduledForDeletion->isEmpty()) {
+ foreach ($this->creditNotesRelatedByIdScheduledForDeletion as $creditNoteRelatedById) {
+ // need to save related object because we set the relation to null
+ $creditNoteRelatedById->save($con);
+ }
+ $this->creditNotesRelatedByIdScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCreditNotesRelatedById !== null) {
+ foreach ($this->collCreditNotesRelatedById as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->orderCreditNotesScheduledForDeletion !== null) {
+ if (!$this->orderCreditNotesScheduledForDeletion->isEmpty()) {
+ \CreditNote\Model\OrderCreditNoteQuery::create()
+ ->filterByPrimaryKeys($this->orderCreditNotesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->orderCreditNotesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrderCreditNotes !== null) {
+ foreach ($this->collOrderCreditNotes as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->cartCreditNotesScheduledForDeletion !== null) {
+ if (!$this->cartCreditNotesScheduledForDeletion->isEmpty()) {
+ \CreditNote\Model\CartCreditNoteQuery::create()
+ ->filterByPrimaryKeys($this->cartCreditNotesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->cartCreditNotesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCartCreditNotes !== null) {
+ foreach ($this->collCartCreditNotes as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->creditNoteDetailsScheduledForDeletion !== null) {
+ if (!$this->creditNoteDetailsScheduledForDeletion->isEmpty()) {
+ \CreditNote\Model\CreditNoteDetailQuery::create()
+ ->filterByPrimaryKeys($this->creditNoteDetailsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->creditNoteDetailsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCreditNoteDetails !== null) {
+ foreach ($this->collCreditNoteDetails as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->creditNoteCommentsScheduledForDeletion !== null) {
+ if (!$this->creditNoteCommentsScheduledForDeletion->isEmpty()) {
+ \CreditNote\Model\CreditNoteCommentQuery::create()
+ ->filterByPrimaryKeys($this->creditNoteCommentsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->creditNoteCommentsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCreditNoteComments !== null) {
+ foreach ($this->collCreditNoteComments as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[CreditNoteTableMap::ID] = true;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CreditNoteTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CreditNoteTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CreditNoteTableMap::REF)) {
+ $modifiedColumns[':p' . $index++] = 'REF';
+ }
+ if ($this->isColumnModified(CreditNoteTableMap::INVOICE_REF)) {
+ $modifiedColumns[':p' . $index++] = 'INVOICE_REF';
+ }
+ if ($this->isColumnModified(CreditNoteTableMap::INVOICE_ADDRESS_ID)) {
+ $modifiedColumns[':p' . $index++] = 'INVOICE_ADDRESS_ID';
+ }
+ if ($this->isColumnModified(CreditNoteTableMap::INVOICE_DATE)) {
+ $modifiedColumns[':p' . $index++] = 'INVOICE_DATE';
+ }
+ if ($this->isColumnModified(CreditNoteTableMap::ORDER_ID)) {
+ $modifiedColumns[':p' . $index++] = 'ORDER_ID';
+ }
+ if ($this->isColumnModified(CreditNoteTableMap::CUSTOMER_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CUSTOMER_ID';
+ }
+ if ($this->isColumnModified(CreditNoteTableMap::PARENT_ID)) {
+ $modifiedColumns[':p' . $index++] = 'PARENT_ID';
+ }
+ if ($this->isColumnModified(CreditNoteTableMap::TYPE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'TYPE_ID';
+ }
+ if ($this->isColumnModified(CreditNoteTableMap::STATUS_ID)) {
+ $modifiedColumns[':p' . $index++] = 'STATUS_ID';
+ }
+ if ($this->isColumnModified(CreditNoteTableMap::CURRENCY_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CURRENCY_ID';
+ }
+ if ($this->isColumnModified(CreditNoteTableMap::CURRENCY_RATE)) {
+ $modifiedColumns[':p' . $index++] = 'CURRENCY_RATE';
+ }
+ if ($this->isColumnModified(CreditNoteTableMap::TOTAL_PRICE)) {
+ $modifiedColumns[':p' . $index++] = 'TOTAL_PRICE';
+ }
+ if ($this->isColumnModified(CreditNoteTableMap::TOTAL_PRICE_WITH_TAX)) {
+ $modifiedColumns[':p' . $index++] = 'TOTAL_PRICE_WITH_TAX';
+ }
+ if ($this->isColumnModified(CreditNoteTableMap::DISCOUNT_WITHOUT_TAX)) {
+ $modifiedColumns[':p' . $index++] = 'DISCOUNT_WITHOUT_TAX';
+ }
+ if ($this->isColumnModified(CreditNoteTableMap::DISCOUNT_WITH_TAX)) {
+ $modifiedColumns[':p' . $index++] = 'DISCOUNT_WITH_TAX';
+ }
+ if ($this->isColumnModified(CreditNoteTableMap::ALLOW_PARTIAL_USE)) {
+ $modifiedColumns[':p' . $index++] = 'ALLOW_PARTIAL_USE';
+ }
+ if ($this->isColumnModified(CreditNoteTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CreditNoteTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO credit_note (%s) VALUES (%s)',
+ 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 'INVOICE_REF':
+ $stmt->bindValue($identifier, $this->invoice_ref, PDO::PARAM_STR);
+ break;
+ case 'INVOICE_ADDRESS_ID':
+ $stmt->bindValue($identifier, $this->invoice_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 'ORDER_ID':
+ $stmt->bindValue($identifier, $this->order_id, PDO::PARAM_INT);
+ break;
+ case 'CUSTOMER_ID':
+ $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT);
+ break;
+ case 'PARENT_ID':
+ $stmt->bindValue($identifier, $this->parent_id, PDO::PARAM_INT);
+ break;
+ case 'TYPE_ID':
+ $stmt->bindValue($identifier, $this->type_id, PDO::PARAM_INT);
+ break;
+ case 'STATUS_ID':
+ $stmt->bindValue($identifier, $this->status_id, PDO::PARAM_INT);
+ 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 'TOTAL_PRICE':
+ $stmt->bindValue($identifier, $this->total_price, PDO::PARAM_STR);
+ break;
+ case 'TOTAL_PRICE_WITH_TAX':
+ $stmt->bindValue($identifier, $this->total_price_with_tax, PDO::PARAM_STR);
+ break;
+ case 'DISCOUNT_WITHOUT_TAX':
+ $stmt->bindValue($identifier, $this->discount_without_tax, PDO::PARAM_STR);
+ break;
+ case 'DISCOUNT_WITH_TAX':
+ $stmt->bindValue($identifier, $this->discount_with_tax, PDO::PARAM_STR);
+ break;
+ case 'ALLOW_PARTIAL_USE':
+ $stmt->bindValue($identifier, (int) $this->allow_partial_use, 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);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getRef();
+ break;
+ case 2:
+ return $this->getInvoiceRef();
+ break;
+ case 3:
+ return $this->getInvoiceAddressId();
+ break;
+ case 4:
+ return $this->getInvoiceDate();
+ break;
+ case 5:
+ return $this->getOrderId();
+ break;
+ case 6:
+ return $this->getCustomerId();
+ break;
+ case 7:
+ return $this->getParentId();
+ break;
+ case 8:
+ return $this->getTypeId();
+ break;
+ case 9:
+ return $this->getStatusId();
+ break;
+ case 10:
+ return $this->getCurrencyId();
+ break;
+ case 11:
+ return $this->getCurrencyRate();
+ break;
+ case 12:
+ return $this->getTotalPrice();
+ break;
+ case 13:
+ return $this->getTotalPriceWithTax();
+ break;
+ case 14:
+ return $this->getDiscountWithoutTax();
+ break;
+ case 15:
+ return $this->getDiscountWithTax();
+ break;
+ case 16:
+ return $this->getAllowPartialUse();
+ break;
+ case 17:
+ return $this->getCreatedAt();
+ break;
+ case 18:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CreditNote'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CreditNote'][$this->getPrimaryKey()] = true;
+ $keys = CreditNoteTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getRef(),
+ $keys[2] => $this->getInvoiceRef(),
+ $keys[3] => $this->getInvoiceAddressId(),
+ $keys[4] => $this->getInvoiceDate(),
+ $keys[5] => $this->getOrderId(),
+ $keys[6] => $this->getCustomerId(),
+ $keys[7] => $this->getParentId(),
+ $keys[8] => $this->getTypeId(),
+ $keys[9] => $this->getStatusId(),
+ $keys[10] => $this->getCurrencyId(),
+ $keys[11] => $this->getCurrencyRate(),
+ $keys[12] => $this->getTotalPrice(),
+ $keys[13] => $this->getTotalPriceWithTax(),
+ $keys[14] => $this->getDiscountWithoutTax(),
+ $keys[15] => $this->getDiscountWithTax(),
+ $keys[16] => $this->getAllowPartialUse(),
+ $keys[17] => $this->getCreatedAt(),
+ $keys[18] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach ($virtualColumns as $key => $virtualColumn) {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aOrder) {
+ $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCustomer) {
+ $result['Customer'] = $this->aCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCreditNoteRelatedByParentId) {
+ $result['CreditNoteRelatedByParentId'] = $this->aCreditNoteRelatedByParentId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCreditNoteType) {
+ $result['CreditNoteType'] = $this->aCreditNoteType->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCreditNoteStatus) {
+ $result['CreditNoteStatus'] = $this->aCreditNoteStatus->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCurrency) {
+ $result['Currency'] = $this->aCurrency->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCreditNoteAddress) {
+ $result['CreditNoteAddress'] = $this->aCreditNoteAddress->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collCreditNotesRelatedById) {
+ $result['CreditNotesRelatedById'] = $this->collCreditNotesRelatedById->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collOrderCreditNotes) {
+ $result['OrderCreditNotes'] = $this->collOrderCreditNotes->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collCartCreditNotes) {
+ $result['CartCreditNotes'] = $this->collCartCreditNotes->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collCreditNoteDetails) {
+ $result['CreditNoteDetails'] = $this->collCreditNoteDetails->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collCreditNoteComments) {
+ $result['CreditNoteComments'] = $this->collCreditNoteComments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+
+ return $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setRef($value);
+ break;
+ case 2:
+ $this->setInvoiceRef($value);
+ break;
+ case 3:
+ $this->setInvoiceAddressId($value);
+ break;
+ case 4:
+ $this->setInvoiceDate($value);
+ break;
+ case 5:
+ $this->setOrderId($value);
+ break;
+ case 6:
+ $this->setCustomerId($value);
+ break;
+ case 7:
+ $this->setParentId($value);
+ break;
+ case 8:
+ $this->setTypeId($value);
+ break;
+ case 9:
+ $this->setStatusId($value);
+ break;
+ case 10:
+ $this->setCurrencyId($value);
+ break;
+ case 11:
+ $this->setCurrencyRate($value);
+ break;
+ case 12:
+ $this->setTotalPrice($value);
+ break;
+ case 13:
+ $this->setTotalPriceWithTax($value);
+ break;
+ case 14:
+ $this->setDiscountWithoutTax($value);
+ break;
+ case 15:
+ $this->setDiscountWithTax($value);
+ break;
+ case 16:
+ $this->setAllowPartialUse($value);
+ break;
+ case 17:
+ $this->setCreatedAt($value);
+ break;
+ case 18:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CreditNoteTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setRef($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setInvoiceRef($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setInvoiceAddressId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setInvoiceDate($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setOrderId($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCustomerId($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setParentId($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setTypeId($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setStatusId($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setCurrencyId($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setCurrencyRate($arr[$keys[11]]);
+ if (array_key_exists($keys[12], $arr)) $this->setTotalPrice($arr[$keys[12]]);
+ if (array_key_exists($keys[13], $arr)) $this->setTotalPriceWithTax($arr[$keys[13]]);
+ if (array_key_exists($keys[14], $arr)) $this->setDiscountWithoutTax($arr[$keys[14]]);
+ if (array_key_exists($keys[15], $arr)) $this->setDiscountWithTax($arr[$keys[15]]);
+ if (array_key_exists($keys[16], $arr)) $this->setAllowPartialUse($arr[$keys[16]]);
+ if (array_key_exists($keys[17], $arr)) $this->setCreatedAt($arr[$keys[17]]);
+ if (array_key_exists($keys[18], $arr)) $this->setUpdatedAt($arr[$keys[18]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CreditNoteTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CreditNoteTableMap::ID)) $criteria->add(CreditNoteTableMap::ID, $this->id);
+ if ($this->isColumnModified(CreditNoteTableMap::REF)) $criteria->add(CreditNoteTableMap::REF, $this->ref);
+ if ($this->isColumnModified(CreditNoteTableMap::INVOICE_REF)) $criteria->add(CreditNoteTableMap::INVOICE_REF, $this->invoice_ref);
+ if ($this->isColumnModified(CreditNoteTableMap::INVOICE_ADDRESS_ID)) $criteria->add(CreditNoteTableMap::INVOICE_ADDRESS_ID, $this->invoice_address_id);
+ if ($this->isColumnModified(CreditNoteTableMap::INVOICE_DATE)) $criteria->add(CreditNoteTableMap::INVOICE_DATE, $this->invoice_date);
+ if ($this->isColumnModified(CreditNoteTableMap::ORDER_ID)) $criteria->add(CreditNoteTableMap::ORDER_ID, $this->order_id);
+ if ($this->isColumnModified(CreditNoteTableMap::CUSTOMER_ID)) $criteria->add(CreditNoteTableMap::CUSTOMER_ID, $this->customer_id);
+ if ($this->isColumnModified(CreditNoteTableMap::PARENT_ID)) $criteria->add(CreditNoteTableMap::PARENT_ID, $this->parent_id);
+ if ($this->isColumnModified(CreditNoteTableMap::TYPE_ID)) $criteria->add(CreditNoteTableMap::TYPE_ID, $this->type_id);
+ if ($this->isColumnModified(CreditNoteTableMap::STATUS_ID)) $criteria->add(CreditNoteTableMap::STATUS_ID, $this->status_id);
+ if ($this->isColumnModified(CreditNoteTableMap::CURRENCY_ID)) $criteria->add(CreditNoteTableMap::CURRENCY_ID, $this->currency_id);
+ if ($this->isColumnModified(CreditNoteTableMap::CURRENCY_RATE)) $criteria->add(CreditNoteTableMap::CURRENCY_RATE, $this->currency_rate);
+ if ($this->isColumnModified(CreditNoteTableMap::TOTAL_PRICE)) $criteria->add(CreditNoteTableMap::TOTAL_PRICE, $this->total_price);
+ if ($this->isColumnModified(CreditNoteTableMap::TOTAL_PRICE_WITH_TAX)) $criteria->add(CreditNoteTableMap::TOTAL_PRICE_WITH_TAX, $this->total_price_with_tax);
+ if ($this->isColumnModified(CreditNoteTableMap::DISCOUNT_WITHOUT_TAX)) $criteria->add(CreditNoteTableMap::DISCOUNT_WITHOUT_TAX, $this->discount_without_tax);
+ if ($this->isColumnModified(CreditNoteTableMap::DISCOUNT_WITH_TAX)) $criteria->add(CreditNoteTableMap::DISCOUNT_WITH_TAX, $this->discount_with_tax);
+ if ($this->isColumnModified(CreditNoteTableMap::ALLOW_PARTIAL_USE)) $criteria->add(CreditNoteTableMap::ALLOW_PARTIAL_USE, $this->allow_partial_use);
+ if ($this->isColumnModified(CreditNoteTableMap::CREATED_AT)) $criteria->add(CreditNoteTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CreditNoteTableMap::UPDATED_AT)) $criteria->add(CreditNoteTableMap::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CreditNoteTableMap::DATABASE_NAME);
+ $criteria->add(CreditNoteTableMap::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of \CreditNote\Model\CreditNote (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setRef($this->getRef());
+ $copyObj->setInvoiceRef($this->getInvoiceRef());
+ $copyObj->setInvoiceAddressId($this->getInvoiceAddressId());
+ $copyObj->setInvoiceDate($this->getInvoiceDate());
+ $copyObj->setOrderId($this->getOrderId());
+ $copyObj->setCustomerId($this->getCustomerId());
+ $copyObj->setParentId($this->getParentId());
+ $copyObj->setTypeId($this->getTypeId());
+ $copyObj->setStatusId($this->getStatusId());
+ $copyObj->setCurrencyId($this->getCurrencyId());
+ $copyObj->setCurrencyRate($this->getCurrencyRate());
+ $copyObj->setTotalPrice($this->getTotalPrice());
+ $copyObj->setTotalPriceWithTax($this->getTotalPriceWithTax());
+ $copyObj->setDiscountWithoutTax($this->getDiscountWithoutTax());
+ $copyObj->setDiscountWithTax($this->getDiscountWithTax());
+ $copyObj->setAllowPartialUse($this->getAllowPartialUse());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+
+ foreach ($this->getCreditNotesRelatedById() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCreditNoteRelatedById($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getOrderCreditNotes() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrderCreditNote($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getCartCreditNotes() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCartCreditNote($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getCreditNoteDetails() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCreditNoteDetail($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getCreditNoteComments() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCreditNoteComment($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return \CreditNote\Model\CreditNote Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Declares an association between this object and a ChildOrder object.
+ *
+ * @param ChildOrder $v
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setOrder(ChildOrder $v = null)
+ {
+ if ($v === null) {
+ $this->setOrderId(NULL);
+ } else {
+ $this->setOrderId($v->getId());
+ }
+
+ $this->aOrder = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildOrder object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNote($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildOrder object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildOrder The associated ChildOrder object.
+ * @throws PropelException
+ */
+ public function getOrder(ConnectionInterface $con = null)
+ {
+ if ($this->aOrder === null && ($this->order_id !== null)) {
+ $this->aOrder = OrderQuery::create()->findPk($this->order_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aOrder->addCreditNotes($this);
+ */
+ }
+
+ return $this->aOrder;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCustomer object.
+ *
+ * @param ChildCustomer $v
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCustomer(ChildCustomer $v = null)
+ {
+ if ($v === null) {
+ $this->setCustomerId(NULL);
+ } else {
+ $this->setCustomerId($v->getId());
+ }
+
+ $this->aCustomer = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCustomer object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNote($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCustomer object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCustomer The associated ChildCustomer object.
+ * @throws PropelException
+ */
+ public function getCustomer(ConnectionInterface $con = null)
+ {
+ if ($this->aCustomer === null && ($this->customer_id !== null)) {
+ $this->aCustomer = CustomerQuery::create()->findPk($this->customer_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCustomer->addCreditNotes($this);
+ */
+ }
+
+ return $this->aCustomer;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCreditNote object.
+ *
+ * @param ChildCreditNote $v
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCreditNoteRelatedByParentId(ChildCreditNote $v = null)
+ {
+ if ($v === null) {
+ $this->setParentId(NULL);
+ } else {
+ $this->setParentId($v->getId());
+ }
+
+ $this->aCreditNoteRelatedByParentId = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCreditNote object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNoteRelatedById($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCreditNote object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCreditNote The associated ChildCreditNote object.
+ * @throws PropelException
+ */
+ public function getCreditNoteRelatedByParentId(ConnectionInterface $con = null)
+ {
+ if ($this->aCreditNoteRelatedByParentId === null && ($this->parent_id !== null)) {
+ $this->aCreditNoteRelatedByParentId = ChildCreditNoteQuery::create()->findPk($this->parent_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCreditNoteRelatedByParentId->addCreditNotesRelatedById($this);
+ */
+ }
+
+ return $this->aCreditNoteRelatedByParentId;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCreditNoteType object.
+ *
+ * @param ChildCreditNoteType $v
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCreditNoteType(ChildCreditNoteType $v = null)
+ {
+ if ($v === null) {
+ $this->setTypeId(NULL);
+ } else {
+ $this->setTypeId($v->getId());
+ }
+
+ $this->aCreditNoteType = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCreditNoteType object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNote($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCreditNoteType object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCreditNoteType The associated ChildCreditNoteType object.
+ * @throws PropelException
+ */
+ public function getCreditNoteType(ConnectionInterface $con = null)
+ {
+ if ($this->aCreditNoteType === null && ($this->type_id !== null)) {
+ $this->aCreditNoteType = ChildCreditNoteTypeQuery::create()->findPk($this->type_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCreditNoteType->addCreditNotes($this);
+ */
+ }
+
+ return $this->aCreditNoteType;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCreditNoteStatus object.
+ *
+ * @param ChildCreditNoteStatus $v
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCreditNoteStatus(ChildCreditNoteStatus $v = null)
+ {
+ if ($v === null) {
+ $this->setStatusId(NULL);
+ } else {
+ $this->setStatusId($v->getId());
+ }
+
+ $this->aCreditNoteStatus = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCreditNoteStatus object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNote($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCreditNoteStatus object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCreditNoteStatus The associated ChildCreditNoteStatus object.
+ * @throws PropelException
+ */
+ public function getCreditNoteStatus(ConnectionInterface $con = null)
+ {
+ if ($this->aCreditNoteStatus === null && ($this->status_id !== null)) {
+ $this->aCreditNoteStatus = ChildCreditNoteStatusQuery::create()->findPk($this->status_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCreditNoteStatus->addCreditNotes($this);
+ */
+ }
+
+ return $this->aCreditNoteStatus;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCurrency object.
+ *
+ * @param ChildCurrency $v
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCurrency(ChildCurrency $v = null)
+ {
+ if ($v === null) {
+ $this->setCurrencyId(NULL);
+ } else {
+ $this->setCurrencyId($v->getId());
+ }
+
+ $this->aCurrency = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCurrency object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNote($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCurrency object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCurrency The associated ChildCurrency object.
+ * @throws PropelException
+ */
+ public function getCurrency(ConnectionInterface $con = null)
+ {
+ if ($this->aCurrency === null && ($this->currency_id !== null)) {
+ $this->aCurrency = CurrencyQuery::create()->findPk($this->currency_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCurrency->addCreditNotes($this);
+ */
+ }
+
+ return $this->aCurrency;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCreditNoteAddress object.
+ *
+ * @param ChildCreditNoteAddress $v
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCreditNoteAddress(ChildCreditNoteAddress $v = null)
+ {
+ if ($v === null) {
+ $this->setInvoiceAddressId(NULL);
+ } else {
+ $this->setInvoiceAddressId($v->getId());
+ }
+
+ $this->aCreditNoteAddress = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCreditNoteAddress object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNote($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCreditNoteAddress object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCreditNoteAddress The associated ChildCreditNoteAddress object.
+ * @throws PropelException
+ */
+ public function getCreditNoteAddress(ConnectionInterface $con = null)
+ {
+ if ($this->aCreditNoteAddress === null && ($this->invoice_address_id !== null)) {
+ $this->aCreditNoteAddress = ChildCreditNoteAddressQuery::create()->findPk($this->invoice_address_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCreditNoteAddress->addCreditNotes($this);
+ */
+ }
+
+ return $this->aCreditNoteAddress;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('CreditNoteRelatedById' == $relationName) {
+ return $this->initCreditNotesRelatedById();
+ }
+ if ('OrderCreditNote' == $relationName) {
+ return $this->initOrderCreditNotes();
+ }
+ if ('CartCreditNote' == $relationName) {
+ return $this->initCartCreditNotes();
+ }
+ if ('CreditNoteDetail' == $relationName) {
+ return $this->initCreditNoteDetails();
+ }
+ if ('CreditNoteComment' == $relationName) {
+ return $this->initCreditNoteComments();
+ }
+ }
+
+ /**
+ * Clears out the collCreditNotesRelatedById collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCreditNotesRelatedById()
+ */
+ public function clearCreditNotesRelatedById()
+ {
+ $this->collCreditNotesRelatedById = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCreditNotesRelatedById collection loaded partially.
+ */
+ public function resetPartialCreditNotesRelatedById($v = true)
+ {
+ $this->collCreditNotesRelatedByIdPartial = $v;
+ }
+
+ /**
+ * Initializes the collCreditNotesRelatedById collection.
+ *
+ * By default this just sets the collCreditNotesRelatedById collection to an empty array (like clearcollCreditNotesRelatedById());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCreditNotesRelatedById($overrideExisting = true)
+ {
+ if (null !== $this->collCreditNotesRelatedById && !$overrideExisting) {
+ return;
+ }
+ $this->collCreditNotesRelatedById = new ObjectCollection();
+ $this->collCreditNotesRelatedById->setModel('\CreditNote\Model\CreditNote');
+ }
+
+ /**
+ * Gets an array of ChildCreditNote objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCreditNote is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ * @throws PropelException
+ */
+ public function getCreditNotesRelatedById($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNotesRelatedByIdPartial && !$this->isNew();
+ if (null === $this->collCreditNotesRelatedById || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNotesRelatedById) {
+ // return empty collection
+ $this->initCreditNotesRelatedById();
+ } else {
+ $collCreditNotesRelatedById = ChildCreditNoteQuery::create(null, $criteria)
+ ->filterByCreditNoteRelatedByParentId($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCreditNotesRelatedByIdPartial && count($collCreditNotesRelatedById)) {
+ $this->initCreditNotesRelatedById(false);
+
+ foreach ($collCreditNotesRelatedById as $obj) {
+ if (false == $this->collCreditNotesRelatedById->contains($obj)) {
+ $this->collCreditNotesRelatedById->append($obj);
+ }
+ }
+
+ $this->collCreditNotesRelatedByIdPartial = true;
+ }
+
+ reset($collCreditNotesRelatedById);
+
+ return $collCreditNotesRelatedById;
+ }
+
+ if ($partial && $this->collCreditNotesRelatedById) {
+ foreach ($this->collCreditNotesRelatedById as $obj) {
+ if ($obj->isNew()) {
+ $collCreditNotesRelatedById[] = $obj;
+ }
+ }
+ }
+
+ $this->collCreditNotesRelatedById = $collCreditNotesRelatedById;
+ $this->collCreditNotesRelatedByIdPartial = false;
+ }
+ }
+
+ return $this->collCreditNotesRelatedById;
+ }
+
+ /**
+ * Sets a collection of CreditNoteRelatedById objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $creditNotesRelatedById A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCreditNote The current object (for fluent API support)
+ */
+ public function setCreditNotesRelatedById(Collection $creditNotesRelatedById, ConnectionInterface $con = null)
+ {
+ $creditNotesRelatedByIdToDelete = $this->getCreditNotesRelatedById(new Criteria(), $con)->diff($creditNotesRelatedById);
+
+
+ $this->creditNotesRelatedByIdScheduledForDeletion = $creditNotesRelatedByIdToDelete;
+
+ foreach ($creditNotesRelatedByIdToDelete as $creditNoteRelatedByIdRemoved) {
+ $creditNoteRelatedByIdRemoved->setCreditNoteRelatedByParentId(null);
+ }
+
+ $this->collCreditNotesRelatedById = null;
+ foreach ($creditNotesRelatedById as $creditNoteRelatedById) {
+ $this->addCreditNoteRelatedById($creditNoteRelatedById);
+ }
+
+ $this->collCreditNotesRelatedById = $creditNotesRelatedById;
+ $this->collCreditNotesRelatedByIdPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CreditNote objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related CreditNote objects.
+ * @throws PropelException
+ */
+ public function countCreditNotesRelatedById(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNotesRelatedByIdPartial && !$this->isNew();
+ if (null === $this->collCreditNotesRelatedById || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNotesRelatedById) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCreditNotesRelatedById());
+ }
+
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCreditNoteRelatedByParentId($this)
+ ->count($con);
+ }
+
+ return count($this->collCreditNotesRelatedById);
+ }
+
+ /**
+ * Method called to associate a ChildCreditNote object to this object
+ * through the ChildCreditNote foreign key attribute.
+ *
+ * @param ChildCreditNote $l ChildCreditNote
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function addCreditNoteRelatedById(ChildCreditNote $l)
+ {
+ if ($this->collCreditNotesRelatedById === null) {
+ $this->initCreditNotesRelatedById();
+ $this->collCreditNotesRelatedByIdPartial = true;
+ }
+
+ if (!in_array($l, $this->collCreditNotesRelatedById->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCreditNoteRelatedById($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CreditNoteRelatedById $creditNoteRelatedById The creditNoteRelatedById object to add.
+ */
+ protected function doAddCreditNoteRelatedById($creditNoteRelatedById)
+ {
+ $this->collCreditNotesRelatedById[]= $creditNoteRelatedById;
+ $creditNoteRelatedById->setCreditNoteRelatedByParentId($this);
+ }
+
+ /**
+ * @param CreditNoteRelatedById $creditNoteRelatedById The creditNoteRelatedById object to remove.
+ * @return ChildCreditNote The current object (for fluent API support)
+ */
+ public function removeCreditNoteRelatedById($creditNoteRelatedById)
+ {
+ if ($this->getCreditNotesRelatedById()->contains($creditNoteRelatedById)) {
+ $this->collCreditNotesRelatedById->remove($this->collCreditNotesRelatedById->search($creditNoteRelatedById));
+ if (null === $this->creditNotesRelatedByIdScheduledForDeletion) {
+ $this->creditNotesRelatedByIdScheduledForDeletion = clone $this->collCreditNotesRelatedById;
+ $this->creditNotesRelatedByIdScheduledForDeletion->clear();
+ }
+ $this->creditNotesRelatedByIdScheduledForDeletion[]= $creditNoteRelatedById;
+ $creditNoteRelatedById->setCreditNoteRelatedByParentId(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNote is new, it will return
+ * an empty collection; or if this CreditNote has previously
+ * been saved, it will retrieve related CreditNotesRelatedById from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNote.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesRelatedByIdJoinOrder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('Order', $joinBehavior);
+
+ return $this->getCreditNotesRelatedById($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNote is new, it will return
+ * an empty collection; or if this CreditNote has previously
+ * been saved, it will retrieve related CreditNotesRelatedById from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNote.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesRelatedByIdJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('Customer', $joinBehavior);
+
+ return $this->getCreditNotesRelatedById($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNote is new, it will return
+ * an empty collection; or if this CreditNote has previously
+ * been saved, it will retrieve related CreditNotesRelatedById from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNote.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesRelatedByIdJoinCreditNoteType($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('CreditNoteType', $joinBehavior);
+
+ return $this->getCreditNotesRelatedById($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNote is new, it will return
+ * an empty collection; or if this CreditNote has previously
+ * been saved, it will retrieve related CreditNotesRelatedById from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNote.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesRelatedByIdJoinCreditNoteStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('CreditNoteStatus', $joinBehavior);
+
+ return $this->getCreditNotesRelatedById($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNote is new, it will return
+ * an empty collection; or if this CreditNote has previously
+ * been saved, it will retrieve related CreditNotesRelatedById from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNote.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesRelatedByIdJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('Currency', $joinBehavior);
+
+ return $this->getCreditNotesRelatedById($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNote is new, it will return
+ * an empty collection; or if this CreditNote has previously
+ * been saved, it will retrieve related CreditNotesRelatedById from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNote.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesRelatedByIdJoinCreditNoteAddress($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('CreditNoteAddress', $joinBehavior);
+
+ return $this->getCreditNotesRelatedById($query, $con);
+ }
+
+ /**
+ * Clears out the collOrderCreditNotes collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addOrderCreditNotes()
+ */
+ public function clearOrderCreditNotes()
+ {
+ $this->collOrderCreditNotes = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collOrderCreditNotes collection loaded partially.
+ */
+ public function resetPartialOrderCreditNotes($v = true)
+ {
+ $this->collOrderCreditNotesPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrderCreditNotes collection.
+ *
+ * By default this just sets the collOrderCreditNotes collection to an empty array (like clearcollOrderCreditNotes());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initOrderCreditNotes($overrideExisting = true)
+ {
+ if (null !== $this->collOrderCreditNotes && !$overrideExisting) {
+ return;
+ }
+ $this->collOrderCreditNotes = new ObjectCollection();
+ $this->collOrderCreditNotes->setModel('\CreditNote\Model\OrderCreditNote');
+ }
+
+ /**
+ * Gets an array of ChildOrderCreditNote objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCreditNote is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildOrderCreditNote[] List of ChildOrderCreditNote objects
+ * @throws PropelException
+ */
+ public function getOrderCreditNotes($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrderCreditNotesPartial && !$this->isNew();
+ if (null === $this->collOrderCreditNotes || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderCreditNotes) {
+ // return empty collection
+ $this->initOrderCreditNotes();
+ } else {
+ $collOrderCreditNotes = ChildOrderCreditNoteQuery::create(null, $criteria)
+ ->filterByCreditNote($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collOrderCreditNotesPartial && count($collOrderCreditNotes)) {
+ $this->initOrderCreditNotes(false);
+
+ foreach ($collOrderCreditNotes as $obj) {
+ if (false == $this->collOrderCreditNotes->contains($obj)) {
+ $this->collOrderCreditNotes->append($obj);
+ }
+ }
+
+ $this->collOrderCreditNotesPartial = true;
+ }
+
+ reset($collOrderCreditNotes);
+
+ return $collOrderCreditNotes;
+ }
+
+ if ($partial && $this->collOrderCreditNotes) {
+ foreach ($this->collOrderCreditNotes as $obj) {
+ if ($obj->isNew()) {
+ $collOrderCreditNotes[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrderCreditNotes = $collOrderCreditNotes;
+ $this->collOrderCreditNotesPartial = false;
+ }
+ }
+
+ return $this->collOrderCreditNotes;
+ }
+
+ /**
+ * Sets a collection of OrderCreditNote objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $orderCreditNotes A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCreditNote The current object (for fluent API support)
+ */
+ public function setOrderCreditNotes(Collection $orderCreditNotes, ConnectionInterface $con = null)
+ {
+ $orderCreditNotesToDelete = $this->getOrderCreditNotes(new Criteria(), $con)->diff($orderCreditNotes);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->orderCreditNotesScheduledForDeletion = clone $orderCreditNotesToDelete;
+
+ foreach ($orderCreditNotesToDelete as $orderCreditNoteRemoved) {
+ $orderCreditNoteRemoved->setCreditNote(null);
+ }
+
+ $this->collOrderCreditNotes = null;
+ foreach ($orderCreditNotes as $orderCreditNote) {
+ $this->addOrderCreditNote($orderCreditNote);
+ }
+
+ $this->collOrderCreditNotes = $orderCreditNotes;
+ $this->collOrderCreditNotesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related OrderCreditNote objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related OrderCreditNote objects.
+ * @throws PropelException
+ */
+ public function countOrderCreditNotes(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrderCreditNotesPartial && !$this->isNew();
+ if (null === $this->collOrderCreditNotes || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderCreditNotes) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getOrderCreditNotes());
+ }
+
+ $query = ChildOrderCreditNoteQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCreditNote($this)
+ ->count($con);
+ }
+
+ return count($this->collOrderCreditNotes);
+ }
+
+ /**
+ * Method called to associate a ChildOrderCreditNote object to this object
+ * through the ChildOrderCreditNote foreign key attribute.
+ *
+ * @param ChildOrderCreditNote $l ChildOrderCreditNote
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function addOrderCreditNote(ChildOrderCreditNote $l)
+ {
+ if ($this->collOrderCreditNotes === null) {
+ $this->initOrderCreditNotes();
+ $this->collOrderCreditNotesPartial = true;
+ }
+
+ if (!in_array($l, $this->collOrderCreditNotes->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddOrderCreditNote($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param OrderCreditNote $orderCreditNote The orderCreditNote object to add.
+ */
+ protected function doAddOrderCreditNote($orderCreditNote)
+ {
+ $this->collOrderCreditNotes[]= $orderCreditNote;
+ $orderCreditNote->setCreditNote($this);
+ }
+
+ /**
+ * @param OrderCreditNote $orderCreditNote The orderCreditNote object to remove.
+ * @return ChildCreditNote The current object (for fluent API support)
+ */
+ public function removeOrderCreditNote($orderCreditNote)
+ {
+ if ($this->getOrderCreditNotes()->contains($orderCreditNote)) {
+ $this->collOrderCreditNotes->remove($this->collOrderCreditNotes->search($orderCreditNote));
+ if (null === $this->orderCreditNotesScheduledForDeletion) {
+ $this->orderCreditNotesScheduledForDeletion = clone $this->collOrderCreditNotes;
+ $this->orderCreditNotesScheduledForDeletion->clear();
+ }
+ $this->orderCreditNotesScheduledForDeletion[]= clone $orderCreditNote;
+ $orderCreditNote->setCreditNote(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNote is new, it will return
+ * an empty collection; or if this CreditNote has previously
+ * been saved, it will retrieve related OrderCreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNote.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrderCreditNote[] List of ChildOrderCreditNote objects
+ */
+ public function getOrderCreditNotesJoinOrder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('Order', $joinBehavior);
+
+ return $this->getOrderCreditNotes($query, $con);
+ }
+
+ /**
+ * Clears out the collCartCreditNotes collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCartCreditNotes()
+ */
+ public function clearCartCreditNotes()
+ {
+ $this->collCartCreditNotes = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCartCreditNotes collection loaded partially.
+ */
+ public function resetPartialCartCreditNotes($v = true)
+ {
+ $this->collCartCreditNotesPartial = $v;
+ }
+
+ /**
+ * Initializes the collCartCreditNotes collection.
+ *
+ * By default this just sets the collCartCreditNotes collection to an empty array (like clearcollCartCreditNotes());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCartCreditNotes($overrideExisting = true)
+ {
+ if (null !== $this->collCartCreditNotes && !$overrideExisting) {
+ return;
+ }
+ $this->collCartCreditNotes = new ObjectCollection();
+ $this->collCartCreditNotes->setModel('\CreditNote\Model\CartCreditNote');
+ }
+
+ /**
+ * Gets an array of ChildCartCreditNote objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCreditNote is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCartCreditNote[] List of ChildCartCreditNote objects
+ * @throws PropelException
+ */
+ public function getCartCreditNotes($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCartCreditNotesPartial && !$this->isNew();
+ if (null === $this->collCartCreditNotes || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCartCreditNotes) {
+ // return empty collection
+ $this->initCartCreditNotes();
+ } else {
+ $collCartCreditNotes = ChildCartCreditNoteQuery::create(null, $criteria)
+ ->filterByCreditNote($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCartCreditNotesPartial && count($collCartCreditNotes)) {
+ $this->initCartCreditNotes(false);
+
+ foreach ($collCartCreditNotes as $obj) {
+ if (false == $this->collCartCreditNotes->contains($obj)) {
+ $this->collCartCreditNotes->append($obj);
+ }
+ }
+
+ $this->collCartCreditNotesPartial = true;
+ }
+
+ reset($collCartCreditNotes);
+
+ return $collCartCreditNotes;
+ }
+
+ if ($partial && $this->collCartCreditNotes) {
+ foreach ($this->collCartCreditNotes as $obj) {
+ if ($obj->isNew()) {
+ $collCartCreditNotes[] = $obj;
+ }
+ }
+ }
+
+ $this->collCartCreditNotes = $collCartCreditNotes;
+ $this->collCartCreditNotesPartial = false;
+ }
+ }
+
+ return $this->collCartCreditNotes;
+ }
+
+ /**
+ * Sets a collection of CartCreditNote objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $cartCreditNotes A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCreditNote The current object (for fluent API support)
+ */
+ public function setCartCreditNotes(Collection $cartCreditNotes, ConnectionInterface $con = null)
+ {
+ $cartCreditNotesToDelete = $this->getCartCreditNotes(new Criteria(), $con)->diff($cartCreditNotes);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->cartCreditNotesScheduledForDeletion = clone $cartCreditNotesToDelete;
+
+ foreach ($cartCreditNotesToDelete as $cartCreditNoteRemoved) {
+ $cartCreditNoteRemoved->setCreditNote(null);
+ }
+
+ $this->collCartCreditNotes = null;
+ foreach ($cartCreditNotes as $cartCreditNote) {
+ $this->addCartCreditNote($cartCreditNote);
+ }
+
+ $this->collCartCreditNotes = $cartCreditNotes;
+ $this->collCartCreditNotesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CartCreditNote objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related CartCreditNote objects.
+ * @throws PropelException
+ */
+ public function countCartCreditNotes(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCartCreditNotesPartial && !$this->isNew();
+ if (null === $this->collCartCreditNotes || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCartCreditNotes) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCartCreditNotes());
+ }
+
+ $query = ChildCartCreditNoteQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCreditNote($this)
+ ->count($con);
+ }
+
+ return count($this->collCartCreditNotes);
+ }
+
+ /**
+ * Method called to associate a ChildCartCreditNote object to this object
+ * through the ChildCartCreditNote foreign key attribute.
+ *
+ * @param ChildCartCreditNote $l ChildCartCreditNote
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function addCartCreditNote(ChildCartCreditNote $l)
+ {
+ if ($this->collCartCreditNotes === null) {
+ $this->initCartCreditNotes();
+ $this->collCartCreditNotesPartial = true;
+ }
+
+ if (!in_array($l, $this->collCartCreditNotes->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCartCreditNote($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CartCreditNote $cartCreditNote The cartCreditNote object to add.
+ */
+ protected function doAddCartCreditNote($cartCreditNote)
+ {
+ $this->collCartCreditNotes[]= $cartCreditNote;
+ $cartCreditNote->setCreditNote($this);
+ }
+
+ /**
+ * @param CartCreditNote $cartCreditNote The cartCreditNote object to remove.
+ * @return ChildCreditNote The current object (for fluent API support)
+ */
+ public function removeCartCreditNote($cartCreditNote)
+ {
+ if ($this->getCartCreditNotes()->contains($cartCreditNote)) {
+ $this->collCartCreditNotes->remove($this->collCartCreditNotes->search($cartCreditNote));
+ if (null === $this->cartCreditNotesScheduledForDeletion) {
+ $this->cartCreditNotesScheduledForDeletion = clone $this->collCartCreditNotes;
+ $this->cartCreditNotesScheduledForDeletion->clear();
+ }
+ $this->cartCreditNotesScheduledForDeletion[]= clone $cartCreditNote;
+ $cartCreditNote->setCreditNote(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNote is new, it will return
+ * an empty collection; or if this CreditNote has previously
+ * been saved, it will retrieve related CartCreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNote.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCartCreditNote[] List of ChildCartCreditNote objects
+ */
+ public function getCartCreditNotesJoinCart($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCartCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('Cart', $joinBehavior);
+
+ return $this->getCartCreditNotes($query, $con);
+ }
+
+ /**
+ * Clears out the collCreditNoteDetails collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCreditNoteDetails()
+ */
+ public function clearCreditNoteDetails()
+ {
+ $this->collCreditNoteDetails = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCreditNoteDetails collection loaded partially.
+ */
+ public function resetPartialCreditNoteDetails($v = true)
+ {
+ $this->collCreditNoteDetailsPartial = $v;
+ }
+
+ /**
+ * Initializes the collCreditNoteDetails collection.
+ *
+ * By default this just sets the collCreditNoteDetails collection to an empty array (like clearcollCreditNoteDetails());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCreditNoteDetails($overrideExisting = true)
+ {
+ if (null !== $this->collCreditNoteDetails && !$overrideExisting) {
+ return;
+ }
+ $this->collCreditNoteDetails = new ObjectCollection();
+ $this->collCreditNoteDetails->setModel('\CreditNote\Model\CreditNoteDetail');
+ }
+
+ /**
+ * Gets an array of ChildCreditNoteDetail objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCreditNote is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCreditNoteDetail[] List of ChildCreditNoteDetail objects
+ * @throws PropelException
+ */
+ public function getCreditNoteDetails($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNoteDetailsPartial && !$this->isNew();
+ if (null === $this->collCreditNoteDetails || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNoteDetails) {
+ // return empty collection
+ $this->initCreditNoteDetails();
+ } else {
+ $collCreditNoteDetails = ChildCreditNoteDetailQuery::create(null, $criteria)
+ ->filterByCreditNote($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCreditNoteDetailsPartial && count($collCreditNoteDetails)) {
+ $this->initCreditNoteDetails(false);
+
+ foreach ($collCreditNoteDetails as $obj) {
+ if (false == $this->collCreditNoteDetails->contains($obj)) {
+ $this->collCreditNoteDetails->append($obj);
+ }
+ }
+
+ $this->collCreditNoteDetailsPartial = true;
+ }
+
+ reset($collCreditNoteDetails);
+
+ return $collCreditNoteDetails;
+ }
+
+ if ($partial && $this->collCreditNoteDetails) {
+ foreach ($this->collCreditNoteDetails as $obj) {
+ if ($obj->isNew()) {
+ $collCreditNoteDetails[] = $obj;
+ }
+ }
+ }
+
+ $this->collCreditNoteDetails = $collCreditNoteDetails;
+ $this->collCreditNoteDetailsPartial = false;
+ }
+ }
+
+ return $this->collCreditNoteDetails;
+ }
+
+ /**
+ * Sets a collection of CreditNoteDetail objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $creditNoteDetails A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCreditNote The current object (for fluent API support)
+ */
+ public function setCreditNoteDetails(Collection $creditNoteDetails, ConnectionInterface $con = null)
+ {
+ $creditNoteDetailsToDelete = $this->getCreditNoteDetails(new Criteria(), $con)->diff($creditNoteDetails);
+
+
+ $this->creditNoteDetailsScheduledForDeletion = $creditNoteDetailsToDelete;
+
+ foreach ($creditNoteDetailsToDelete as $creditNoteDetailRemoved) {
+ $creditNoteDetailRemoved->setCreditNote(null);
+ }
+
+ $this->collCreditNoteDetails = null;
+ foreach ($creditNoteDetails as $creditNoteDetail) {
+ $this->addCreditNoteDetail($creditNoteDetail);
+ }
+
+ $this->collCreditNoteDetails = $creditNoteDetails;
+ $this->collCreditNoteDetailsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CreditNoteDetail objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related CreditNoteDetail objects.
+ * @throws PropelException
+ */
+ public function countCreditNoteDetails(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNoteDetailsPartial && !$this->isNew();
+ if (null === $this->collCreditNoteDetails || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNoteDetails) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCreditNoteDetails());
+ }
+
+ $query = ChildCreditNoteDetailQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCreditNote($this)
+ ->count($con);
+ }
+
+ return count($this->collCreditNoteDetails);
+ }
+
+ /**
+ * Method called to associate a ChildCreditNoteDetail object to this object
+ * through the ChildCreditNoteDetail foreign key attribute.
+ *
+ * @param ChildCreditNoteDetail $l ChildCreditNoteDetail
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function addCreditNoteDetail(ChildCreditNoteDetail $l)
+ {
+ if ($this->collCreditNoteDetails === null) {
+ $this->initCreditNoteDetails();
+ $this->collCreditNoteDetailsPartial = true;
+ }
+
+ if (!in_array($l, $this->collCreditNoteDetails->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCreditNoteDetail($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CreditNoteDetail $creditNoteDetail The creditNoteDetail object to add.
+ */
+ protected function doAddCreditNoteDetail($creditNoteDetail)
+ {
+ $this->collCreditNoteDetails[]= $creditNoteDetail;
+ $creditNoteDetail->setCreditNote($this);
+ }
+
+ /**
+ * @param CreditNoteDetail $creditNoteDetail The creditNoteDetail object to remove.
+ * @return ChildCreditNote The current object (for fluent API support)
+ */
+ public function removeCreditNoteDetail($creditNoteDetail)
+ {
+ if ($this->getCreditNoteDetails()->contains($creditNoteDetail)) {
+ $this->collCreditNoteDetails->remove($this->collCreditNoteDetails->search($creditNoteDetail));
+ if (null === $this->creditNoteDetailsScheduledForDeletion) {
+ $this->creditNoteDetailsScheduledForDeletion = clone $this->collCreditNoteDetails;
+ $this->creditNoteDetailsScheduledForDeletion->clear();
+ }
+ $this->creditNoteDetailsScheduledForDeletion[]= clone $creditNoteDetail;
+ $creditNoteDetail->setCreditNote(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNote is new, it will return
+ * an empty collection; or if this CreditNote has previously
+ * been saved, it will retrieve related CreditNoteDetails from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNote.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNoteDetail[] List of ChildCreditNoteDetail objects
+ */
+ public function getCreditNoteDetailsJoinOrderProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteDetailQuery::create(null, $criteria);
+ $query->joinWith('OrderProduct', $joinBehavior);
+
+ return $this->getCreditNoteDetails($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNote is new, it will return
+ * an empty collection; or if this CreditNote has previously
+ * been saved, it will retrieve related CreditNoteDetails from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNote.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNoteDetail[] List of ChildCreditNoteDetail objects
+ */
+ public function getCreditNoteDetailsJoinTaxRule($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteDetailQuery::create(null, $criteria);
+ $query->joinWith('TaxRule', $joinBehavior);
+
+ return $this->getCreditNoteDetails($query, $con);
+ }
+
+ /**
+ * Clears out the collCreditNoteComments collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCreditNoteComments()
+ */
+ public function clearCreditNoteComments()
+ {
+ $this->collCreditNoteComments = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCreditNoteComments collection loaded partially.
+ */
+ public function resetPartialCreditNoteComments($v = true)
+ {
+ $this->collCreditNoteCommentsPartial = $v;
+ }
+
+ /**
+ * Initializes the collCreditNoteComments collection.
+ *
+ * By default this just sets the collCreditNoteComments collection to an empty array (like clearcollCreditNoteComments());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCreditNoteComments($overrideExisting = true)
+ {
+ if (null !== $this->collCreditNoteComments && !$overrideExisting) {
+ return;
+ }
+ $this->collCreditNoteComments = new ObjectCollection();
+ $this->collCreditNoteComments->setModel('\CreditNote\Model\CreditNoteComment');
+ }
+
+ /**
+ * Gets an array of ChildCreditNoteComment objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCreditNote is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCreditNoteComment[] List of ChildCreditNoteComment objects
+ * @throws PropelException
+ */
+ public function getCreditNoteComments($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNoteCommentsPartial && !$this->isNew();
+ if (null === $this->collCreditNoteComments || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNoteComments) {
+ // return empty collection
+ $this->initCreditNoteComments();
+ } else {
+ $collCreditNoteComments = ChildCreditNoteCommentQuery::create(null, $criteria)
+ ->filterByCreditNote($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCreditNoteCommentsPartial && count($collCreditNoteComments)) {
+ $this->initCreditNoteComments(false);
+
+ foreach ($collCreditNoteComments as $obj) {
+ if (false == $this->collCreditNoteComments->contains($obj)) {
+ $this->collCreditNoteComments->append($obj);
+ }
+ }
+
+ $this->collCreditNoteCommentsPartial = true;
+ }
+
+ reset($collCreditNoteComments);
+
+ return $collCreditNoteComments;
+ }
+
+ if ($partial && $this->collCreditNoteComments) {
+ foreach ($this->collCreditNoteComments as $obj) {
+ if ($obj->isNew()) {
+ $collCreditNoteComments[] = $obj;
+ }
+ }
+ }
+
+ $this->collCreditNoteComments = $collCreditNoteComments;
+ $this->collCreditNoteCommentsPartial = false;
+ }
+ }
+
+ return $this->collCreditNoteComments;
+ }
+
+ /**
+ * Sets a collection of CreditNoteComment objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $creditNoteComments A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCreditNote The current object (for fluent API support)
+ */
+ public function setCreditNoteComments(Collection $creditNoteComments, ConnectionInterface $con = null)
+ {
+ $creditNoteCommentsToDelete = $this->getCreditNoteComments(new Criteria(), $con)->diff($creditNoteComments);
+
+
+ $this->creditNoteCommentsScheduledForDeletion = $creditNoteCommentsToDelete;
+
+ foreach ($creditNoteCommentsToDelete as $creditNoteCommentRemoved) {
+ $creditNoteCommentRemoved->setCreditNote(null);
+ }
+
+ $this->collCreditNoteComments = null;
+ foreach ($creditNoteComments as $creditNoteComment) {
+ $this->addCreditNoteComment($creditNoteComment);
+ }
+
+ $this->collCreditNoteComments = $creditNoteComments;
+ $this->collCreditNoteCommentsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CreditNoteComment objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related CreditNoteComment objects.
+ * @throws PropelException
+ */
+ public function countCreditNoteComments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNoteCommentsPartial && !$this->isNew();
+ if (null === $this->collCreditNoteComments || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNoteComments) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCreditNoteComments());
+ }
+
+ $query = ChildCreditNoteCommentQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCreditNote($this)
+ ->count($con);
+ }
+
+ return count($this->collCreditNoteComments);
+ }
+
+ /**
+ * Method called to associate a ChildCreditNoteComment object to this object
+ * through the ChildCreditNoteComment foreign key attribute.
+ *
+ * @param ChildCreditNoteComment $l ChildCreditNoteComment
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ */
+ public function addCreditNoteComment(ChildCreditNoteComment $l)
+ {
+ if ($this->collCreditNoteComments === null) {
+ $this->initCreditNoteComments();
+ $this->collCreditNoteCommentsPartial = true;
+ }
+
+ if (!in_array($l, $this->collCreditNoteComments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCreditNoteComment($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CreditNoteComment $creditNoteComment The creditNoteComment object to add.
+ */
+ protected function doAddCreditNoteComment($creditNoteComment)
+ {
+ $this->collCreditNoteComments[]= $creditNoteComment;
+ $creditNoteComment->setCreditNote($this);
+ }
+
+ /**
+ * @param CreditNoteComment $creditNoteComment The creditNoteComment object to remove.
+ * @return ChildCreditNote The current object (for fluent API support)
+ */
+ public function removeCreditNoteComment($creditNoteComment)
+ {
+ if ($this->getCreditNoteComments()->contains($creditNoteComment)) {
+ $this->collCreditNoteComments->remove($this->collCreditNoteComments->search($creditNoteComment));
+ if (null === $this->creditNoteCommentsScheduledForDeletion) {
+ $this->creditNoteCommentsScheduledForDeletion = clone $this->collCreditNoteComments;
+ $this->creditNoteCommentsScheduledForDeletion->clear();
+ }
+ $this->creditNoteCommentsScheduledForDeletion[]= clone $creditNoteComment;
+ $creditNoteComment->setCreditNote(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNote is new, it will return
+ * an empty collection; or if this CreditNote has previously
+ * been saved, it will retrieve related CreditNoteComments from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNote.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNoteComment[] List of ChildCreditNoteComment objects
+ */
+ public function getCreditNoteCommentsJoinAdmin($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteCommentQuery::create(null, $criteria);
+ $query->joinWith('Admin', $joinBehavior);
+
+ return $this->getCreditNoteComments($query, $con);
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->ref = null;
+ $this->invoice_ref = null;
+ $this->invoice_address_id = null;
+ $this->invoice_date = null;
+ $this->order_id = null;
+ $this->customer_id = null;
+ $this->parent_id = null;
+ $this->type_id = null;
+ $this->status_id = null;
+ $this->currency_id = null;
+ $this->currency_rate = null;
+ $this->total_price = null;
+ $this->total_price_with_tax = null;
+ $this->discount_without_tax = null;
+ $this->discount_with_tax = null;
+ $this->allow_partial_use = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collCreditNotesRelatedById) {
+ foreach ($this->collCreditNotesRelatedById as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collOrderCreditNotes) {
+ foreach ($this->collOrderCreditNotes as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collCartCreditNotes) {
+ foreach ($this->collCartCreditNotes as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collCreditNoteDetails) {
+ foreach ($this->collCreditNoteDetails as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collCreditNoteComments) {
+ foreach ($this->collCreditNoteComments as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ $this->collCreditNotesRelatedById = null;
+ $this->collOrderCreditNotes = null;
+ $this->collCartCreditNotes = null;
+ $this->collCreditNoteDetails = null;
+ $this->collCreditNoteComments = null;
+ $this->aOrder = null;
+ $this->aCustomer = null;
+ $this->aCreditNoteRelatedByParentId = null;
+ $this->aCreditNoteType = null;
+ $this->aCreditNoteStatus = null;
+ $this->aCurrency = null;
+ $this->aCreditNoteAddress = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CreditNoteTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildCreditNote The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[CreditNoteTableMap::UPDATED_AT] = true;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteAddress.php b/local/modules/CreditNote/Model/Base/CreditNoteAddress.php
new file mode 100644
index 000000000..756f50cdd
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteAddress.php
@@ -0,0 +1,2654 @@
+modifiedColumns;
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return boolean true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ if (isset($this->modifiedColumns[$col])) {
+ unset($this->modifiedColumns[$col]);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another CreditNoteAddress instance. If
+ * obj is an instance of CreditNoteAddress, delegates to
+ * equals(CreditNoteAddress). Otherwise, returns false.
+ *
+ * @param mixed $obj The object to compare to.
+ * @return boolean Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return array_key_exists($name, $this->virtualColumns);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return mixed
+ *
+ * @throws PropelException
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return CreditNoteAddress The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return CreditNoteAddress The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+
+ return $this;
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [customer_title_id] column value.
+ *
+ * @return int
+ */
+ public function getCustomerTitleId()
+ {
+
+ return $this->customer_title_id;
+ }
+
+ /**
+ * Get the [company] column value.
+ *
+ * @return string
+ */
+ public function getCompany()
+ {
+
+ return $this->company;
+ }
+
+ /**
+ * Get the [firstname] column value.
+ *
+ * @return string
+ */
+ public function getFirstname()
+ {
+
+ return $this->firstname;
+ }
+
+ /**
+ * Get the [lastname] column value.
+ *
+ * @return string
+ */
+ public function getLastname()
+ {
+
+ return $this->lastname;
+ }
+
+ /**
+ * Get the [address1] column value.
+ *
+ * @return string
+ */
+ public function getAddress1()
+ {
+
+ return $this->address1;
+ }
+
+ /**
+ * Get the [address2] column value.
+ *
+ * @return string
+ */
+ public function getAddress2()
+ {
+
+ return $this->address2;
+ }
+
+ /**
+ * Get the [address3] column value.
+ *
+ * @return string
+ */
+ public function getAddress3()
+ {
+
+ return $this->address3;
+ }
+
+ /**
+ * Get the [zipcode] column value.
+ *
+ * @return string
+ */
+ public function getZipcode()
+ {
+
+ return $this->zipcode;
+ }
+
+ /**
+ * Get the [city] column value.
+ *
+ * @return string
+ */
+ public function getCity()
+ {
+
+ return $this->city;
+ }
+
+ /**
+ * Get the [phone] column value.
+ *
+ * @return string
+ */
+ public function getPhone()
+ {
+
+ return $this->phone;
+ }
+
+ /**
+ * Get the [cellphone] column value.
+ *
+ * @return string
+ */
+ public function getCellphone()
+ {
+
+ return $this->cellphone;
+ }
+
+ /**
+ * Get the [country_id] column value.
+ *
+ * @return int
+ */
+ public function getCountryId()
+ {
+
+ return $this->country_id;
+ }
+
+ /**
+ * Get the [state_id] column value.
+ *
+ * @return int
+ */
+ public function getStateId()
+ {
+
+ return $this->state_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[CreditNoteAddressTableMap::ID] = true;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [customer_title_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ */
+ public function setCustomerTitleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->customer_title_id !== $v) {
+ $this->customer_title_id = $v;
+ $this->modifiedColumns[CreditNoteAddressTableMap::CUSTOMER_TITLE_ID] = true;
+ }
+
+ if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) {
+ $this->aCustomerTitle = null;
+ }
+
+
+ return $this;
+ } // setCustomerTitleId()
+
+ /**
+ * Set the value of [company] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ */
+ public function setCompany($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->company !== $v) {
+ $this->company = $v;
+ $this->modifiedColumns[CreditNoteAddressTableMap::COMPANY] = true;
+ }
+
+
+ return $this;
+ } // setCompany()
+
+ /**
+ * Set the value of [firstname] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ */
+ public function setFirstname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->firstname !== $v) {
+ $this->firstname = $v;
+ $this->modifiedColumns[CreditNoteAddressTableMap::FIRSTNAME] = true;
+ }
+
+
+ return $this;
+ } // setFirstname()
+
+ /**
+ * Set the value of [lastname] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ */
+ public function setLastname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lastname !== $v) {
+ $this->lastname = $v;
+ $this->modifiedColumns[CreditNoteAddressTableMap::LASTNAME] = true;
+ }
+
+
+ return $this;
+ } // setLastname()
+
+ /**
+ * Set the value of [address1] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ */
+ public function setAddress1($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address1 !== $v) {
+ $this->address1 = $v;
+ $this->modifiedColumns[CreditNoteAddressTableMap::ADDRESS1] = true;
+ }
+
+
+ return $this;
+ } // setAddress1()
+
+ /**
+ * Set the value of [address2] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ */
+ public function setAddress2($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address2 !== $v) {
+ $this->address2 = $v;
+ $this->modifiedColumns[CreditNoteAddressTableMap::ADDRESS2] = true;
+ }
+
+
+ return $this;
+ } // setAddress2()
+
+ /**
+ * Set the value of [address3] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ */
+ public function setAddress3($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address3 !== $v) {
+ $this->address3 = $v;
+ $this->modifiedColumns[CreditNoteAddressTableMap::ADDRESS3] = true;
+ }
+
+
+ return $this;
+ } // setAddress3()
+
+ /**
+ * Set the value of [zipcode] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ */
+ public function setZipcode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->zipcode !== $v) {
+ $this->zipcode = $v;
+ $this->modifiedColumns[CreditNoteAddressTableMap::ZIPCODE] = true;
+ }
+
+
+ return $this;
+ } // setZipcode()
+
+ /**
+ * Set the value of [city] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ */
+ public function setCity($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->city !== $v) {
+ $this->city = $v;
+ $this->modifiedColumns[CreditNoteAddressTableMap::CITY] = true;
+ }
+
+
+ return $this;
+ } // setCity()
+
+ /**
+ * Set the value of [phone] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ */
+ public function setPhone($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->phone !== $v) {
+ $this->phone = $v;
+ $this->modifiedColumns[CreditNoteAddressTableMap::PHONE] = true;
+ }
+
+
+ return $this;
+ } // setPhone()
+
+ /**
+ * Set the value of [cellphone] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ */
+ public function setCellphone($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->cellphone !== $v) {
+ $this->cellphone = $v;
+ $this->modifiedColumns[CreditNoteAddressTableMap::CELLPHONE] = true;
+ }
+
+
+ return $this;
+ } // setCellphone()
+
+ /**
+ * Set the value of [country_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ */
+ public function setCountryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->country_id !== $v) {
+ $this->country_id = $v;
+ $this->modifiedColumns[CreditNoteAddressTableMap::COUNTRY_ID] = true;
+ }
+
+ if ($this->aCountry !== null && $this->aCountry->getId() !== $v) {
+ $this->aCountry = null;
+ }
+
+
+ return $this;
+ } // setCountryId()
+
+ /**
+ * Set the value of [state_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ */
+ public function setStateId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->state_id !== $v) {
+ $this->state_id = $v;
+ $this->modifiedColumns[CreditNoteAddressTableMap::STATE_ID] = true;
+ }
+
+ if ($this->aState !== null && $this->aState->getId() !== $v) {
+ $this->aState = null;
+ }
+
+
+ return $this;
+ } // setStateId()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[CreditNoteAddressTableMap::CREATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[CreditNoteAddressTableMap::UPDATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CreditNoteAddressTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CreditNoteAddressTableMap::translateFieldName('CustomerTitleId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->customer_title_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CreditNoteAddressTableMap::translateFieldName('Company', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->company = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CreditNoteAddressTableMap::translateFieldName('Firstname', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->firstname = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CreditNoteAddressTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->lastname = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CreditNoteAddressTableMap::translateFieldName('Address1', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->address1 = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CreditNoteAddressTableMap::translateFieldName('Address2', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->address2 = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CreditNoteAddressTableMap::translateFieldName('Address3', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->address3 = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CreditNoteAddressTableMap::translateFieldName('Zipcode', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->zipcode = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CreditNoteAddressTableMap::translateFieldName('City', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->city = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CreditNoteAddressTableMap::translateFieldName('Phone', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->phone = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CreditNoteAddressTableMap::translateFieldName('Cellphone', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->cellphone = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CreditNoteAddressTableMap::translateFieldName('CountryId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->country_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CreditNoteAddressTableMap::translateFieldName('StateId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->state_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : CreditNoteAddressTableMap::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 ? 15 + $startcol : CreditNoteAddressTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 16; // 16 = CreditNoteAddressTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \CreditNote\Model\CreditNoteAddress object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCustomerTitle !== null && $this->customer_title_id !== $this->aCustomerTitle->getId()) {
+ $this->aCustomerTitle = null;
+ }
+ if ($this->aCountry !== null && $this->country_id !== $this->aCountry->getId()) {
+ $this->aCountry = null;
+ }
+ if ($this->aState !== null && $this->state_id !== $this->aState->getId()) {
+ $this->aState = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteAddressTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCreditNoteAddressQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCustomerTitle = null;
+ $this->aCountry = null;
+ $this->aState = null;
+ $this->collCreditNotes = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see CreditNoteAddress::setDeleted()
+ * @see CreditNoteAddress::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteAddressTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCreditNoteAddressQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see doSave()
+ */
+ public function save(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteAddressTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(CreditNoteAddressTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(CreditNoteAddressTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(CreditNoteAddressTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CreditNoteAddressTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCustomerTitle !== null) {
+ if ($this->aCustomerTitle->isModified() || $this->aCustomerTitle->isNew()) {
+ $affectedRows += $this->aCustomerTitle->save($con);
+ }
+ $this->setCustomerTitle($this->aCustomerTitle);
+ }
+
+ if ($this->aCountry !== null) {
+ if ($this->aCountry->isModified() || $this->aCountry->isNew()) {
+ $affectedRows += $this->aCountry->save($con);
+ }
+ $this->setCountry($this->aCountry);
+ }
+
+ if ($this->aState !== null) {
+ if ($this->aState->isModified() || $this->aState->isNew()) {
+ $affectedRows += $this->aState->save($con);
+ }
+ $this->setState($this->aState);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->creditNotesScheduledForDeletion !== null) {
+ if (!$this->creditNotesScheduledForDeletion->isEmpty()) {
+ \CreditNote\Model\CreditNoteQuery::create()
+ ->filterByPrimaryKeys($this->creditNotesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->creditNotesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCreditNotes !== null) {
+ foreach ($this->collCreditNotes as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[CreditNoteAddressTableMap::ID] = true;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CreditNoteAddressTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CreditNoteAddressTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CreditNoteAddressTableMap::CUSTOMER_TITLE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CUSTOMER_TITLE_ID';
+ }
+ if ($this->isColumnModified(CreditNoteAddressTableMap::COMPANY)) {
+ $modifiedColumns[':p' . $index++] = 'COMPANY';
+ }
+ if ($this->isColumnModified(CreditNoteAddressTableMap::FIRSTNAME)) {
+ $modifiedColumns[':p' . $index++] = 'FIRSTNAME';
+ }
+ if ($this->isColumnModified(CreditNoteAddressTableMap::LASTNAME)) {
+ $modifiedColumns[':p' . $index++] = 'LASTNAME';
+ }
+ if ($this->isColumnModified(CreditNoteAddressTableMap::ADDRESS1)) {
+ $modifiedColumns[':p' . $index++] = 'ADDRESS1';
+ }
+ if ($this->isColumnModified(CreditNoteAddressTableMap::ADDRESS2)) {
+ $modifiedColumns[':p' . $index++] = 'ADDRESS2';
+ }
+ if ($this->isColumnModified(CreditNoteAddressTableMap::ADDRESS3)) {
+ $modifiedColumns[':p' . $index++] = 'ADDRESS3';
+ }
+ if ($this->isColumnModified(CreditNoteAddressTableMap::ZIPCODE)) {
+ $modifiedColumns[':p' . $index++] = 'ZIPCODE';
+ }
+ if ($this->isColumnModified(CreditNoteAddressTableMap::CITY)) {
+ $modifiedColumns[':p' . $index++] = 'CITY';
+ }
+ if ($this->isColumnModified(CreditNoteAddressTableMap::PHONE)) {
+ $modifiedColumns[':p' . $index++] = 'PHONE';
+ }
+ if ($this->isColumnModified(CreditNoteAddressTableMap::CELLPHONE)) {
+ $modifiedColumns[':p' . $index++] = 'CELLPHONE';
+ }
+ if ($this->isColumnModified(CreditNoteAddressTableMap::COUNTRY_ID)) {
+ $modifiedColumns[':p' . $index++] = 'COUNTRY_ID';
+ }
+ if ($this->isColumnModified(CreditNoteAddressTableMap::STATE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'STATE_ID';
+ }
+ if ($this->isColumnModified(CreditNoteAddressTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CreditNoteAddressTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO credit_note_address (%s) VALUES (%s)',
+ 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 'CUSTOMER_TITLE_ID':
+ $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT);
+ break;
+ case 'COMPANY':
+ $stmt->bindValue($identifier, $this->company, PDO::PARAM_STR);
+ break;
+ case 'FIRSTNAME':
+ $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR);
+ break;
+ case 'LASTNAME':
+ $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR);
+ break;
+ case 'ADDRESS1':
+ $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR);
+ break;
+ case 'ADDRESS2':
+ $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR);
+ break;
+ case 'ADDRESS3':
+ $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR);
+ break;
+ case 'ZIPCODE':
+ $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR);
+ break;
+ case 'CITY':
+ $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR);
+ break;
+ case 'PHONE':
+ $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR);
+ break;
+ case 'CELLPHONE':
+ $stmt->bindValue($identifier, $this->cellphone, PDO::PARAM_STR);
+ break;
+ case 'COUNTRY_ID':
+ $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT);
+ break;
+ case 'STATE_ID':
+ $stmt->bindValue($identifier, $this->state_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);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteAddressTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCustomerTitleId();
+ break;
+ case 2:
+ return $this->getCompany();
+ break;
+ case 3:
+ return $this->getFirstname();
+ break;
+ case 4:
+ return $this->getLastname();
+ break;
+ case 5:
+ return $this->getAddress1();
+ break;
+ case 6:
+ return $this->getAddress2();
+ break;
+ case 7:
+ return $this->getAddress3();
+ break;
+ case 8:
+ return $this->getZipcode();
+ break;
+ case 9:
+ return $this->getCity();
+ break;
+ case 10:
+ return $this->getPhone();
+ break;
+ case 11:
+ return $this->getCellphone();
+ break;
+ case 12:
+ return $this->getCountryId();
+ break;
+ case 13:
+ return $this->getStateId();
+ break;
+ case 14:
+ return $this->getCreatedAt();
+ break;
+ case 15:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CreditNoteAddress'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CreditNoteAddress'][$this->getPrimaryKey()] = true;
+ $keys = CreditNoteAddressTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCustomerTitleId(),
+ $keys[2] => $this->getCompany(),
+ $keys[3] => $this->getFirstname(),
+ $keys[4] => $this->getLastname(),
+ $keys[5] => $this->getAddress1(),
+ $keys[6] => $this->getAddress2(),
+ $keys[7] => $this->getAddress3(),
+ $keys[8] => $this->getZipcode(),
+ $keys[9] => $this->getCity(),
+ $keys[10] => $this->getPhone(),
+ $keys[11] => $this->getCellphone(),
+ $keys[12] => $this->getCountryId(),
+ $keys[13] => $this->getStateId(),
+ $keys[14] => $this->getCreatedAt(),
+ $keys[15] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach ($virtualColumns as $key => $virtualColumn) {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCustomerTitle) {
+ $result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCountry) {
+ $result['Country'] = $this->aCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aState) {
+ $result['State'] = $this->aState->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collCreditNotes) {
+ $result['CreditNotes'] = $this->collCreditNotes->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteAddressTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+
+ return $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCustomerTitleId($value);
+ break;
+ case 2:
+ $this->setCompany($value);
+ break;
+ case 3:
+ $this->setFirstname($value);
+ break;
+ case 4:
+ $this->setLastname($value);
+ break;
+ case 5:
+ $this->setAddress1($value);
+ break;
+ case 6:
+ $this->setAddress2($value);
+ break;
+ case 7:
+ $this->setAddress3($value);
+ break;
+ case 8:
+ $this->setZipcode($value);
+ break;
+ case 9:
+ $this->setCity($value);
+ break;
+ case 10:
+ $this->setPhone($value);
+ break;
+ case 11:
+ $this->setCellphone($value);
+ break;
+ case 12:
+ $this->setCountryId($value);
+ break;
+ case 13:
+ $this->setStateId($value);
+ break;
+ case 14:
+ $this->setCreatedAt($value);
+ break;
+ case 15:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CreditNoteAddressTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCustomerTitleId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCompany($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setFirstname($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setLastname($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setAddress1($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setAddress2($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setAddress3($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setZipcode($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setCity($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setPhone($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setCellphone($arr[$keys[11]]);
+ if (array_key_exists($keys[12], $arr)) $this->setCountryId($arr[$keys[12]]);
+ if (array_key_exists($keys[13], $arr)) $this->setStateId($arr[$keys[13]]);
+ if (array_key_exists($keys[14], $arr)) $this->setCreatedAt($arr[$keys[14]]);
+ if (array_key_exists($keys[15], $arr)) $this->setUpdatedAt($arr[$keys[15]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CreditNoteAddressTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CreditNoteAddressTableMap::ID)) $criteria->add(CreditNoteAddressTableMap::ID, $this->id);
+ if ($this->isColumnModified(CreditNoteAddressTableMap::CUSTOMER_TITLE_ID)) $criteria->add(CreditNoteAddressTableMap::CUSTOMER_TITLE_ID, $this->customer_title_id);
+ if ($this->isColumnModified(CreditNoteAddressTableMap::COMPANY)) $criteria->add(CreditNoteAddressTableMap::COMPANY, $this->company);
+ if ($this->isColumnModified(CreditNoteAddressTableMap::FIRSTNAME)) $criteria->add(CreditNoteAddressTableMap::FIRSTNAME, $this->firstname);
+ if ($this->isColumnModified(CreditNoteAddressTableMap::LASTNAME)) $criteria->add(CreditNoteAddressTableMap::LASTNAME, $this->lastname);
+ if ($this->isColumnModified(CreditNoteAddressTableMap::ADDRESS1)) $criteria->add(CreditNoteAddressTableMap::ADDRESS1, $this->address1);
+ if ($this->isColumnModified(CreditNoteAddressTableMap::ADDRESS2)) $criteria->add(CreditNoteAddressTableMap::ADDRESS2, $this->address2);
+ if ($this->isColumnModified(CreditNoteAddressTableMap::ADDRESS3)) $criteria->add(CreditNoteAddressTableMap::ADDRESS3, $this->address3);
+ if ($this->isColumnModified(CreditNoteAddressTableMap::ZIPCODE)) $criteria->add(CreditNoteAddressTableMap::ZIPCODE, $this->zipcode);
+ if ($this->isColumnModified(CreditNoteAddressTableMap::CITY)) $criteria->add(CreditNoteAddressTableMap::CITY, $this->city);
+ if ($this->isColumnModified(CreditNoteAddressTableMap::PHONE)) $criteria->add(CreditNoteAddressTableMap::PHONE, $this->phone);
+ if ($this->isColumnModified(CreditNoteAddressTableMap::CELLPHONE)) $criteria->add(CreditNoteAddressTableMap::CELLPHONE, $this->cellphone);
+ if ($this->isColumnModified(CreditNoteAddressTableMap::COUNTRY_ID)) $criteria->add(CreditNoteAddressTableMap::COUNTRY_ID, $this->country_id);
+ if ($this->isColumnModified(CreditNoteAddressTableMap::STATE_ID)) $criteria->add(CreditNoteAddressTableMap::STATE_ID, $this->state_id);
+ if ($this->isColumnModified(CreditNoteAddressTableMap::CREATED_AT)) $criteria->add(CreditNoteAddressTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CreditNoteAddressTableMap::UPDATED_AT)) $criteria->add(CreditNoteAddressTableMap::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CreditNoteAddressTableMap::DATABASE_NAME);
+ $criteria->add(CreditNoteAddressTableMap::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of \CreditNote\Model\CreditNoteAddress (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCustomerTitleId($this->getCustomerTitleId());
+ $copyObj->setCompany($this->getCompany());
+ $copyObj->setFirstname($this->getFirstname());
+ $copyObj->setLastname($this->getLastname());
+ $copyObj->setAddress1($this->getAddress1());
+ $copyObj->setAddress2($this->getAddress2());
+ $copyObj->setAddress3($this->getAddress3());
+ $copyObj->setZipcode($this->getZipcode());
+ $copyObj->setCity($this->getCity());
+ $copyObj->setPhone($this->getPhone());
+ $copyObj->setCellphone($this->getCellphone());
+ $copyObj->setCountryId($this->getCountryId());
+ $copyObj->setStateId($this->getStateId());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+
+ foreach ($this->getCreditNotes() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCreditNote($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return \CreditNote\Model\CreditNoteAddress Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCustomerTitle object.
+ *
+ * @param ChildCustomerTitle $v
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCustomerTitle(ChildCustomerTitle $v = null)
+ {
+ if ($v === null) {
+ $this->setCustomerTitleId(NULL);
+ } else {
+ $this->setCustomerTitleId($v->getId());
+ }
+
+ $this->aCustomerTitle = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCustomerTitle object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNoteAddress($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCustomerTitle object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCustomerTitle The associated ChildCustomerTitle object.
+ * @throws PropelException
+ */
+ public function getCustomerTitle(ConnectionInterface $con = null)
+ {
+ if ($this->aCustomerTitle === null && ($this->customer_title_id !== null)) {
+ $this->aCustomerTitle = CustomerTitleQuery::create()->findPk($this->customer_title_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCustomerTitle->addCreditNoteAddresses($this);
+ */
+ }
+
+ return $this->aCustomerTitle;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCountry object.
+ *
+ * @param ChildCountry $v
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCountry(ChildCountry $v = null)
+ {
+ if ($v === null) {
+ $this->setCountryId(NULL);
+ } else {
+ $this->setCountryId($v->getId());
+ }
+
+ $this->aCountry = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCountry object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNoteAddress($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCountry object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCountry The associated ChildCountry object.
+ * @throws PropelException
+ */
+ public function getCountry(ConnectionInterface $con = null)
+ {
+ if ($this->aCountry === null && ($this->country_id !== null)) {
+ $this->aCountry = CountryQuery::create()->findPk($this->country_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCountry->addCreditNoteAddresses($this);
+ */
+ }
+
+ return $this->aCountry;
+ }
+
+ /**
+ * Declares an association between this object and a ChildState object.
+ *
+ * @param ChildState $v
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setState(ChildState $v = null)
+ {
+ if ($v === null) {
+ $this->setStateId(NULL);
+ } else {
+ $this->setStateId($v->getId());
+ }
+
+ $this->aState = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildState object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNoteAddress($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildState object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildState The associated ChildState object.
+ * @throws PropelException
+ */
+ public function getState(ConnectionInterface $con = null)
+ {
+ if ($this->aState === null && ($this->state_id !== null)) {
+ $this->aState = StateQuery::create()->findPk($this->state_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aState->addCreditNoteAddresses($this);
+ */
+ }
+
+ return $this->aState;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('CreditNote' == $relationName) {
+ return $this->initCreditNotes();
+ }
+ }
+
+ /**
+ * Clears out the collCreditNotes collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCreditNotes()
+ */
+ public function clearCreditNotes()
+ {
+ $this->collCreditNotes = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCreditNotes collection loaded partially.
+ */
+ public function resetPartialCreditNotes($v = true)
+ {
+ $this->collCreditNotesPartial = $v;
+ }
+
+ /**
+ * Initializes the collCreditNotes collection.
+ *
+ * By default this just sets the collCreditNotes collection to an empty array (like clearcollCreditNotes());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCreditNotes($overrideExisting = true)
+ {
+ if (null !== $this->collCreditNotes && !$overrideExisting) {
+ return;
+ }
+ $this->collCreditNotes = new ObjectCollection();
+ $this->collCreditNotes->setModel('\CreditNote\Model\CreditNote');
+ }
+
+ /**
+ * Gets an array of ChildCreditNote objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCreditNoteAddress is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ * @throws PropelException
+ */
+ public function getCreditNotes($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNotesPartial && !$this->isNew();
+ if (null === $this->collCreditNotes || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNotes) {
+ // return empty collection
+ $this->initCreditNotes();
+ } else {
+ $collCreditNotes = ChildCreditNoteQuery::create(null, $criteria)
+ ->filterByCreditNoteAddress($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCreditNotesPartial && count($collCreditNotes)) {
+ $this->initCreditNotes(false);
+
+ foreach ($collCreditNotes as $obj) {
+ if (false == $this->collCreditNotes->contains($obj)) {
+ $this->collCreditNotes->append($obj);
+ }
+ }
+
+ $this->collCreditNotesPartial = true;
+ }
+
+ reset($collCreditNotes);
+
+ return $collCreditNotes;
+ }
+
+ if ($partial && $this->collCreditNotes) {
+ foreach ($this->collCreditNotes as $obj) {
+ if ($obj->isNew()) {
+ $collCreditNotes[] = $obj;
+ }
+ }
+ }
+
+ $this->collCreditNotes = $collCreditNotes;
+ $this->collCreditNotesPartial = false;
+ }
+ }
+
+ return $this->collCreditNotes;
+ }
+
+ /**
+ * Sets a collection of CreditNote objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $creditNotes A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCreditNoteAddress The current object (for fluent API support)
+ */
+ public function setCreditNotes(Collection $creditNotes, ConnectionInterface $con = null)
+ {
+ $creditNotesToDelete = $this->getCreditNotes(new Criteria(), $con)->diff($creditNotes);
+
+
+ $this->creditNotesScheduledForDeletion = $creditNotesToDelete;
+
+ foreach ($creditNotesToDelete as $creditNoteRemoved) {
+ $creditNoteRemoved->setCreditNoteAddress(null);
+ }
+
+ $this->collCreditNotes = null;
+ foreach ($creditNotes as $creditNote) {
+ $this->addCreditNote($creditNote);
+ }
+
+ $this->collCreditNotes = $creditNotes;
+ $this->collCreditNotesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CreditNote objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related CreditNote objects.
+ * @throws PropelException
+ */
+ public function countCreditNotes(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNotesPartial && !$this->isNew();
+ if (null === $this->collCreditNotes || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNotes) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCreditNotes());
+ }
+
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCreditNoteAddress($this)
+ ->count($con);
+ }
+
+ return count($this->collCreditNotes);
+ }
+
+ /**
+ * Method called to associate a ChildCreditNote object to this object
+ * through the ChildCreditNote foreign key attribute.
+ *
+ * @param ChildCreditNote $l ChildCreditNote
+ * @return \CreditNote\Model\CreditNoteAddress The current object (for fluent API support)
+ */
+ public function addCreditNote(ChildCreditNote $l)
+ {
+ if ($this->collCreditNotes === null) {
+ $this->initCreditNotes();
+ $this->collCreditNotesPartial = true;
+ }
+
+ if (!in_array($l, $this->collCreditNotes->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCreditNote($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CreditNote $creditNote The creditNote object to add.
+ */
+ protected function doAddCreditNote($creditNote)
+ {
+ $this->collCreditNotes[]= $creditNote;
+ $creditNote->setCreditNoteAddress($this);
+ }
+
+ /**
+ * @param CreditNote $creditNote The creditNote object to remove.
+ * @return ChildCreditNoteAddress The current object (for fluent API support)
+ */
+ public function removeCreditNote($creditNote)
+ {
+ if ($this->getCreditNotes()->contains($creditNote)) {
+ $this->collCreditNotes->remove($this->collCreditNotes->search($creditNote));
+ if (null === $this->creditNotesScheduledForDeletion) {
+ $this->creditNotesScheduledForDeletion = clone $this->collCreditNotes;
+ $this->creditNotesScheduledForDeletion->clear();
+ }
+ $this->creditNotesScheduledForDeletion[]= clone $creditNote;
+ $creditNote->setCreditNoteAddress(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNoteAddress is new, it will return
+ * an empty collection; or if this CreditNoteAddress has previously
+ * been saved, it will retrieve related CreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNoteAddress.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesJoinOrder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('Order', $joinBehavior);
+
+ return $this->getCreditNotes($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNoteAddress is new, it will return
+ * an empty collection; or if this CreditNoteAddress has previously
+ * been saved, it will retrieve related CreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNoteAddress.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('Customer', $joinBehavior);
+
+ return $this->getCreditNotes($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNoteAddress is new, it will return
+ * an empty collection; or if this CreditNoteAddress has previously
+ * been saved, it will retrieve related CreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNoteAddress.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesJoinCreditNoteRelatedByParentId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('CreditNoteRelatedByParentId', $joinBehavior);
+
+ return $this->getCreditNotes($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNoteAddress is new, it will return
+ * an empty collection; or if this CreditNoteAddress has previously
+ * been saved, it will retrieve related CreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNoteAddress.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesJoinCreditNoteType($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('CreditNoteType', $joinBehavior);
+
+ return $this->getCreditNotes($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNoteAddress is new, it will return
+ * an empty collection; or if this CreditNoteAddress has previously
+ * been saved, it will retrieve related CreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNoteAddress.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesJoinCreditNoteStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('CreditNoteStatus', $joinBehavior);
+
+ return $this->getCreditNotes($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNoteAddress is new, it will return
+ * an empty collection; or if this CreditNoteAddress has previously
+ * been saved, it will retrieve related CreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNoteAddress.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('Currency', $joinBehavior);
+
+ return $this->getCreditNotes($query, $con);
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->customer_title_id = null;
+ $this->company = null;
+ $this->firstname = null;
+ $this->lastname = null;
+ $this->address1 = null;
+ $this->address2 = null;
+ $this->address3 = null;
+ $this->zipcode = null;
+ $this->city = null;
+ $this->phone = null;
+ $this->cellphone = null;
+ $this->country_id = null;
+ $this->state_id = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collCreditNotes) {
+ foreach ($this->collCreditNotes as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ $this->collCreditNotes = null;
+ $this->aCustomerTitle = null;
+ $this->aCountry = null;
+ $this->aState = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CreditNoteAddressTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildCreditNoteAddress The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[CreditNoteAddressTableMap::UPDATED_AT] = true;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteAddressQuery.php b/local/modules/CreditNote/Model/Base/CreditNoteAddressQuery.php
new file mode 100644
index 000000000..5d3275b22
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteAddressQuery.php
@@ -0,0 +1,1295 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCreditNoteAddress|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CreditNoteAddressTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteAddressTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * 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 ChildCreditNoteAddress A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, CUSTOMER_TITLE_ID, COMPANY, FIRSTNAME, LASTNAME, ADDRESS1, ADDRESS2, ADDRESS3, ZIPCODE, CITY, PHONE, CELLPHONE, COUNTRY_ID, STATE_ID, CREATED_AT, UPDATED_AT FROM credit_note_address 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 ChildCreditNoteAddress();
+ $obj->hydrate($row);
+ CreditNoteAddressTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCreditNoteAddress|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CreditNoteAddressTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CreditNoteAddressTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id 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 ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CreditNoteAddressTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CreditNoteAddressTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteAddressTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the customer_title_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCustomerTitleId(1234); // WHERE customer_title_id = 1234
+ * $query->filterByCustomerTitleId(array(12, 34)); // WHERE customer_title_id IN (12, 34)
+ * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12
+ *
+ *
+ * @see filterByCustomerTitle()
+ *
+ * @param mixed $customerTitleId 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 ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByCustomerTitleId($customerTitleId = null, $comparison = null)
+ {
+ if (is_array($customerTitleId)) {
+ $useMinMax = false;
+ if (isset($customerTitleId['min'])) {
+ $this->addUsingAlias(CreditNoteAddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($customerTitleId['max'])) {
+ $this->addUsingAlias(CreditNoteAddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteAddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId, $comparison);
+ }
+
+ /**
+ * Filter the query on the company column
+ *
+ * Example usage:
+ *
+ * $query->filterByCompany('fooValue'); // WHERE company = 'fooValue'
+ * $query->filterByCompany('%fooValue%'); // WHERE company LIKE '%fooValue%'
+ *
+ *
+ * @param string $company 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 ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByCompany($company = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($company)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $company)) {
+ $company = str_replace('*', '%', $company);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteAddressTableMap::COMPANY, $company, $comparison);
+ }
+
+ /**
+ * Filter the query on the firstname column
+ *
+ * Example usage:
+ *
+ * $query->filterByFirstname('fooValue'); // WHERE firstname = 'fooValue'
+ * $query->filterByFirstname('%fooValue%'); // WHERE firstname LIKE '%fooValue%'
+ *
+ *
+ * @param string $firstname 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 ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByFirstname($firstname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($firstname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $firstname)) {
+ $firstname = str_replace('*', '%', $firstname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteAddressTableMap::FIRSTNAME, $firstname, $comparison);
+ }
+
+ /**
+ * Filter the query on the lastname column
+ *
+ * Example usage:
+ *
+ * $query->filterByLastname('fooValue'); // WHERE lastname = 'fooValue'
+ * $query->filterByLastname('%fooValue%'); // WHERE lastname LIKE '%fooValue%'
+ *
+ *
+ * @param string $lastname 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 ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByLastname($lastname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lastname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lastname)) {
+ $lastname = str_replace('*', '%', $lastname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteAddressTableMap::LASTNAME, $lastname, $comparison);
+ }
+
+ /**
+ * Filter the query on the address1 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress1('fooValue'); // WHERE address1 = 'fooValue'
+ * $query->filterByAddress1('%fooValue%'); // WHERE address1 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address1 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 ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByAddress1($address1 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address1)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address1)) {
+ $address1 = str_replace('*', '%', $address1);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteAddressTableMap::ADDRESS1, $address1, $comparison);
+ }
+
+ /**
+ * Filter the query on the address2 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress2('fooValue'); // WHERE address2 = 'fooValue'
+ * $query->filterByAddress2('%fooValue%'); // WHERE address2 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address2 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 ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByAddress2($address2 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address2)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address2)) {
+ $address2 = str_replace('*', '%', $address2);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteAddressTableMap::ADDRESS2, $address2, $comparison);
+ }
+
+ /**
+ * Filter the query on the address3 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress3('fooValue'); // WHERE address3 = 'fooValue'
+ * $query->filterByAddress3('%fooValue%'); // WHERE address3 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address3 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 ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByAddress3($address3 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address3)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address3)) {
+ $address3 = str_replace('*', '%', $address3);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteAddressTableMap::ADDRESS3, $address3, $comparison);
+ }
+
+ /**
+ * Filter the query on the zipcode column
+ *
+ * Example usage:
+ *
+ * $query->filterByZipcode('fooValue'); // WHERE zipcode = 'fooValue'
+ * $query->filterByZipcode('%fooValue%'); // WHERE zipcode LIKE '%fooValue%'
+ *
+ *
+ * @param string $zipcode 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 ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByZipcode($zipcode = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($zipcode)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $zipcode)) {
+ $zipcode = str_replace('*', '%', $zipcode);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteAddressTableMap::ZIPCODE, $zipcode, $comparison);
+ }
+
+ /**
+ * Filter the query on the city column
+ *
+ * Example usage:
+ *
+ * $query->filterByCity('fooValue'); // WHERE city = 'fooValue'
+ * $query->filterByCity('%fooValue%'); // WHERE city LIKE '%fooValue%'
+ *
+ *
+ * @param string $city 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 ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByCity($city = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($city)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $city)) {
+ $city = str_replace('*', '%', $city);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteAddressTableMap::CITY, $city, $comparison);
+ }
+
+ /**
+ * Filter the query on the phone column
+ *
+ * Example usage:
+ *
+ * $query->filterByPhone('fooValue'); // WHERE phone = 'fooValue'
+ * $query->filterByPhone('%fooValue%'); // WHERE phone LIKE '%fooValue%'
+ *
+ *
+ * @param string $phone 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 ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByPhone($phone = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($phone)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $phone)) {
+ $phone = str_replace('*', '%', $phone);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteAddressTableMap::PHONE, $phone, $comparison);
+ }
+
+ /**
+ * Filter the query on the cellphone column
+ *
+ * Example usage:
+ *
+ * $query->filterByCellphone('fooValue'); // WHERE cellphone = 'fooValue'
+ * $query->filterByCellphone('%fooValue%'); // WHERE cellphone LIKE '%fooValue%'
+ *
+ *
+ * @param string $cellphone 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 ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByCellphone($cellphone = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($cellphone)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $cellphone)) {
+ $cellphone = str_replace('*', '%', $cellphone);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteAddressTableMap::CELLPHONE, $cellphone, $comparison);
+ }
+
+ /**
+ * Filter the query on the country_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCountryId(1234); // WHERE country_id = 1234
+ * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34)
+ * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12
+ *
+ *
+ * @see filterByCountry()
+ *
+ * @param mixed $countryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByCountryId($countryId = null, $comparison = null)
+ {
+ if (is_array($countryId)) {
+ $useMinMax = false;
+ if (isset($countryId['min'])) {
+ $this->addUsingAlias(CreditNoteAddressTableMap::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($countryId['max'])) {
+ $this->addUsingAlias(CreditNoteAddressTableMap::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteAddressTableMap::COUNTRY_ID, $countryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the state_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByStateId(1234); // WHERE state_id = 1234
+ * $query->filterByStateId(array(12, 34)); // WHERE state_id IN (12, 34)
+ * $query->filterByStateId(array('min' => 12)); // WHERE state_id > 12
+ *
+ *
+ * @see filterByState()
+ *
+ * @param mixed $stateId 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 ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByStateId($stateId = null, $comparison = null)
+ {
+ if (is_array($stateId)) {
+ $useMinMax = false;
+ if (isset($stateId['min'])) {
+ $this->addUsingAlias(CreditNoteAddressTableMap::STATE_ID, $stateId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($stateId['max'])) {
+ $this->addUsingAlias(CreditNoteAddressTableMap::STATE_ID, $stateId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteAddressTableMap::STATE_ID, $stateId, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CreditNoteAddressTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CreditNoteAddressTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteAddressTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CreditNoteAddressTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CreditNoteAddressTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteAddressTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\CustomerTitle object
+ *
+ * @param \Thelia\Model\CustomerTitle|ObjectCollection $customerTitle The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByCustomerTitle($customerTitle, $comparison = null)
+ {
+ if ($customerTitle instanceof \Thelia\Model\CustomerTitle) {
+ return $this
+ ->addUsingAlias(CreditNoteAddressTableMap::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison);
+ } elseif ($customerTitle instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteAddressTableMap::CUSTOMER_TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCustomerTitle() only accepts arguments of type \Thelia\Model\CustomerTitle or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CustomerTitle relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CustomerTitle');
+
+ // 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, 'CustomerTitle');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CustomerTitle relation CustomerTitle 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\CustomerTitleQuery A secondary query class using the current class as primary query
+ */
+ public function useCustomerTitleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCustomerTitle($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CustomerTitle', '\Thelia\Model\CustomerTitleQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Country object
+ *
+ * @param \Thelia\Model\Country|ObjectCollection $country The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByCountry($country, $comparison = null)
+ {
+ if ($country instanceof \Thelia\Model\Country) {
+ return $this
+ ->addUsingAlias(CreditNoteAddressTableMap::COUNTRY_ID, $country->getId(), $comparison);
+ } elseif ($country instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteAddressTableMap::COUNTRY_ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCountry() only accepts arguments of type \Thelia\Model\Country or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Country relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function joinCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Country');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Country');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Country relation Country object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CountryQuery A secondary query class using the current class as primary query
+ */
+ public function useCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCountry($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Country', '\Thelia\Model\CountryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\State object
+ *
+ * @param \Thelia\Model\State|ObjectCollection $state The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByState($state, $comparison = null)
+ {
+ if ($state instanceof \Thelia\Model\State) {
+ return $this
+ ->addUsingAlias(CreditNoteAddressTableMap::STATE_ID, $state->getId(), $comparison);
+ } elseif ($state instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteAddressTableMap::STATE_ID, $state->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByState() only accepts arguments of type \Thelia\Model\State or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the State relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function joinState($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('State');
+
+ // 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, 'State');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the State relation State 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\StateQuery A secondary query class using the current class as primary query
+ */
+ public function useStateQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinState($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'State', '\Thelia\Model\StateQuery');
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNote object
+ *
+ * @param \CreditNote\Model\CreditNote|ObjectCollection $creditNote the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function filterByCreditNote($creditNote, $comparison = null)
+ {
+ if ($creditNote instanceof \CreditNote\Model\CreditNote) {
+ return $this
+ ->addUsingAlias(CreditNoteAddressTableMap::ID, $creditNote->getInvoiceAddressId(), $comparison);
+ } elseif ($creditNote instanceof ObjectCollection) {
+ return $this
+ ->useCreditNoteQuery()
+ ->filterByPrimaryKeys($creditNote->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCreditNote() only accepts arguments of type \CreditNote\Model\CreditNote or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNote relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function joinCreditNote($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNote');
+
+ // 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, 'CreditNote');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNote relation CreditNote 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 \CreditNote\Model\CreditNoteQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCreditNote($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNote', '\CreditNote\Model\CreditNoteQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCreditNoteAddress $creditNoteAddress Object to remove from the list of results
+ *
+ * @return ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function prune($creditNoteAddress = null)
+ {
+ if ($creditNoteAddress) {
+ $this->addUsingAlias(CreditNoteAddressTableMap::ID, $creditNoteAddress->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the credit_note_address table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteAddressTableMap::DATABASE_NAME);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CreditNoteAddressTableMap::clearInstancePool();
+ CreditNoteAddressTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCreditNoteAddress or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCreditNoteAddress object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteAddressTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CreditNoteAddressTableMap::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+
+ CreditNoteAddressTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CreditNoteAddressTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CreditNoteAddressTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CreditNoteAddressTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CreditNoteAddressTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CreditNoteAddressTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CreditNoteAddressTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildCreditNoteAddressQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CreditNoteAddressTableMap::CREATED_AT);
+ }
+
+} // CreditNoteAddressQuery
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteComment.php b/local/modules/CreditNote/Model/Base/CreditNoteComment.php
new file mode 100644
index 000000000..71d476978
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteComment.php
@@ -0,0 +1,1556 @@
+modifiedColumns;
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return boolean true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ if (isset($this->modifiedColumns[$col])) {
+ unset($this->modifiedColumns[$col]);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another CreditNoteComment instance. If
+ * obj is an instance of CreditNoteComment, delegates to
+ * equals(CreditNoteComment). Otherwise, returns false.
+ *
+ * @param mixed $obj The object to compare to.
+ * @return boolean Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return array_key_exists($name, $this->virtualColumns);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return mixed
+ *
+ * @throws PropelException
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return CreditNoteComment The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return CreditNoteComment The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+
+ return $this;
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [credit_note_id] column value.
+ *
+ * @return int
+ */
+ public function getCreditNoteId()
+ {
+
+ return $this->credit_note_id;
+ }
+
+ /**
+ * Get the [admin_id] column value.
+ *
+ * @return int
+ */
+ public function getAdminId()
+ {
+
+ return $this->admin_id;
+ }
+
+ /**
+ * Get the [comment] column value.
+ *
+ * @return string
+ */
+ public function getComment()
+ {
+
+ return $this->comment;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteComment The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[CreditNoteCommentTableMap::ID] = true;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [credit_note_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteComment The current object (for fluent API support)
+ */
+ public function setCreditNoteId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->credit_note_id !== $v) {
+ $this->credit_note_id = $v;
+ $this->modifiedColumns[CreditNoteCommentTableMap::CREDIT_NOTE_ID] = true;
+ }
+
+ if ($this->aCreditNote !== null && $this->aCreditNote->getId() !== $v) {
+ $this->aCreditNote = null;
+ }
+
+
+ return $this;
+ } // setCreditNoteId()
+
+ /**
+ * Set the value of [admin_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteComment The current object (for fluent API support)
+ */
+ public function setAdminId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->admin_id !== $v) {
+ $this->admin_id = $v;
+ $this->modifiedColumns[CreditNoteCommentTableMap::ADMIN_ID] = true;
+ }
+
+ if ($this->aAdmin !== null && $this->aAdmin->getId() !== $v) {
+ $this->aAdmin = null;
+ }
+
+
+ return $this;
+ } // setAdminId()
+
+ /**
+ * Set the value of [comment] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteComment The current object (for fluent API support)
+ */
+ public function setComment($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->comment !== $v) {
+ $this->comment = $v;
+ $this->modifiedColumns[CreditNoteCommentTableMap::COMMENT] = true;
+ }
+
+
+ return $this;
+ } // setComment()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNoteComment The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[CreditNoteCommentTableMap::CREATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNoteComment The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[CreditNoteCommentTableMap::UPDATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CreditNoteCommentTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CreditNoteCommentTableMap::translateFieldName('CreditNoteId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->credit_note_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CreditNoteCommentTableMap::translateFieldName('AdminId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->admin_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CreditNoteCommentTableMap::translateFieldName('Comment', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->comment = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CreditNoteCommentTableMap::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 ? 5 + $startcol : CreditNoteCommentTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = CreditNoteCommentTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \CreditNote\Model\CreditNoteComment object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCreditNote !== null && $this->credit_note_id !== $this->aCreditNote->getId()) {
+ $this->aCreditNote = null;
+ }
+ if ($this->aAdmin !== null && $this->admin_id !== $this->aAdmin->getId()) {
+ $this->aAdmin = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteCommentTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCreditNoteCommentQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCreditNote = null;
+ $this->aAdmin = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see CreditNoteComment::setDeleted()
+ * @see CreditNoteComment::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteCommentTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCreditNoteCommentQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see doSave()
+ */
+ public function save(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteCommentTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(CreditNoteCommentTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(CreditNoteCommentTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(CreditNoteCommentTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CreditNoteCommentTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCreditNote !== null) {
+ if ($this->aCreditNote->isModified() || $this->aCreditNote->isNew()) {
+ $affectedRows += $this->aCreditNote->save($con);
+ }
+ $this->setCreditNote($this->aCreditNote);
+ }
+
+ if ($this->aAdmin !== null) {
+ if ($this->aAdmin->isModified() || $this->aAdmin->isNew()) {
+ $affectedRows += $this->aAdmin->save($con);
+ }
+ $this->setAdmin($this->aAdmin);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[CreditNoteCommentTableMap::ID] = true;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CreditNoteCommentTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CreditNoteCommentTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CreditNoteCommentTableMap::CREDIT_NOTE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CREDIT_NOTE_ID';
+ }
+ if ($this->isColumnModified(CreditNoteCommentTableMap::ADMIN_ID)) {
+ $modifiedColumns[':p' . $index++] = 'ADMIN_ID';
+ }
+ if ($this->isColumnModified(CreditNoteCommentTableMap::COMMENT)) {
+ $modifiedColumns[':p' . $index++] = 'COMMENT';
+ }
+ if ($this->isColumnModified(CreditNoteCommentTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CreditNoteCommentTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO credit_note_comment (%s) VALUES (%s)',
+ 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 'CREDIT_NOTE_ID':
+ $stmt->bindValue($identifier, $this->credit_note_id, PDO::PARAM_INT);
+ break;
+ case 'ADMIN_ID':
+ $stmt->bindValue($identifier, $this->admin_id, PDO::PARAM_INT);
+ break;
+ case 'COMMENT':
+ $stmt->bindValue($identifier, $this->comment, 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);
+ 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);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteCommentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCreditNoteId();
+ break;
+ case 2:
+ return $this->getAdminId();
+ break;
+ case 3:
+ return $this->getComment();
+ break;
+ case 4:
+ return $this->getCreatedAt();
+ break;
+ case 5:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CreditNoteComment'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CreditNoteComment'][$this->getPrimaryKey()] = true;
+ $keys = CreditNoteCommentTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCreditNoteId(),
+ $keys[2] => $this->getAdminId(),
+ $keys[3] => $this->getComment(),
+ $keys[4] => $this->getCreatedAt(),
+ $keys[5] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach ($virtualColumns as $key => $virtualColumn) {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCreditNote) {
+ $result['CreditNote'] = $this->aCreditNote->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aAdmin) {
+ $result['Admin'] = $this->aAdmin->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteCommentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+
+ return $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCreditNoteId($value);
+ break;
+ case 2:
+ $this->setAdminId($value);
+ break;
+ case 3:
+ $this->setComment($value);
+ break;
+ case 4:
+ $this->setCreatedAt($value);
+ break;
+ case 5:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CreditNoteCommentTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCreditNoteId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setAdminId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setComment($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CreditNoteCommentTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CreditNoteCommentTableMap::ID)) $criteria->add(CreditNoteCommentTableMap::ID, $this->id);
+ if ($this->isColumnModified(CreditNoteCommentTableMap::CREDIT_NOTE_ID)) $criteria->add(CreditNoteCommentTableMap::CREDIT_NOTE_ID, $this->credit_note_id);
+ if ($this->isColumnModified(CreditNoteCommentTableMap::ADMIN_ID)) $criteria->add(CreditNoteCommentTableMap::ADMIN_ID, $this->admin_id);
+ if ($this->isColumnModified(CreditNoteCommentTableMap::COMMENT)) $criteria->add(CreditNoteCommentTableMap::COMMENT, $this->comment);
+ if ($this->isColumnModified(CreditNoteCommentTableMap::CREATED_AT)) $criteria->add(CreditNoteCommentTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CreditNoteCommentTableMap::UPDATED_AT)) $criteria->add(CreditNoteCommentTableMap::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CreditNoteCommentTableMap::DATABASE_NAME);
+ $criteria->add(CreditNoteCommentTableMap::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of \CreditNote\Model\CreditNoteComment (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCreditNoteId($this->getCreditNoteId());
+ $copyObj->setAdminId($this->getAdminId());
+ $copyObj->setComment($this->getComment());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return \CreditNote\Model\CreditNoteComment Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCreditNote object.
+ *
+ * @param ChildCreditNote $v
+ * @return \CreditNote\Model\CreditNoteComment The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCreditNote(ChildCreditNote $v = null)
+ {
+ if ($v === null) {
+ $this->setCreditNoteId(NULL);
+ } else {
+ $this->setCreditNoteId($v->getId());
+ }
+
+ $this->aCreditNote = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCreditNote object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNoteComment($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCreditNote object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCreditNote The associated ChildCreditNote object.
+ * @throws PropelException
+ */
+ public function getCreditNote(ConnectionInterface $con = null)
+ {
+ if ($this->aCreditNote === null && ($this->credit_note_id !== null)) {
+ $this->aCreditNote = ChildCreditNoteQuery::create()->findPk($this->credit_note_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCreditNote->addCreditNoteComments($this);
+ */
+ }
+
+ return $this->aCreditNote;
+ }
+
+ /**
+ * Declares an association between this object and a ChildAdmin object.
+ *
+ * @param ChildAdmin $v
+ * @return \CreditNote\Model\CreditNoteComment The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setAdmin(ChildAdmin $v = null)
+ {
+ if ($v === null) {
+ $this->setAdminId(NULL);
+ } else {
+ $this->setAdminId($v->getId());
+ }
+
+ $this->aAdmin = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildAdmin object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNoteComment($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildAdmin object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildAdmin The associated ChildAdmin object.
+ * @throws PropelException
+ */
+ public function getAdmin(ConnectionInterface $con = null)
+ {
+ if ($this->aAdmin === null && ($this->admin_id !== null)) {
+ $this->aAdmin = AdminQuery::create()->findPk($this->admin_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aAdmin->addCreditNoteComments($this);
+ */
+ }
+
+ return $this->aAdmin;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->credit_note_id = null;
+ $this->admin_id = null;
+ $this->comment = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCreditNote = null;
+ $this->aAdmin = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CreditNoteCommentTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildCreditNoteComment The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[CreditNoteCommentTableMap::UPDATED_AT] = true;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteCommentQuery.php b/local/modules/CreditNote/Model/Base/CreditNoteCommentQuery.php
new file mode 100644
index 000000000..ce8a6e2eb
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteCommentQuery.php
@@ -0,0 +1,793 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCreditNoteComment|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CreditNoteCommentTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteCommentTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * 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 ChildCreditNoteComment A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, CREDIT_NOTE_ID, ADMIN_ID, COMMENT, CREATED_AT, UPDATED_AT FROM credit_note_comment 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 ChildCreditNoteComment();
+ $obj->hydrate($row);
+ CreditNoteCommentTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCreditNoteComment|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CreditNoteCommentTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CreditNoteCommentTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id 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 ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CreditNoteCommentTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CreditNoteCommentTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteCommentTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the credit_note_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreditNoteId(1234); // WHERE credit_note_id = 1234
+ * $query->filterByCreditNoteId(array(12, 34)); // WHERE credit_note_id IN (12, 34)
+ * $query->filterByCreditNoteId(array('min' => 12)); // WHERE credit_note_id > 12
+ *
+ *
+ * @see filterByCreditNote()
+ *
+ * @param mixed $creditNoteId 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 ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteId($creditNoteId = null, $comparison = null)
+ {
+ if (is_array($creditNoteId)) {
+ $useMinMax = false;
+ if (isset($creditNoteId['min'])) {
+ $this->addUsingAlias(CreditNoteCommentTableMap::CREDIT_NOTE_ID, $creditNoteId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($creditNoteId['max'])) {
+ $this->addUsingAlias(CreditNoteCommentTableMap::CREDIT_NOTE_ID, $creditNoteId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteCommentTableMap::CREDIT_NOTE_ID, $creditNoteId, $comparison);
+ }
+
+ /**
+ * Filter the query on the admin_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByAdminId(1234); // WHERE admin_id = 1234
+ * $query->filterByAdminId(array(12, 34)); // WHERE admin_id IN (12, 34)
+ * $query->filterByAdminId(array('min' => 12)); // WHERE admin_id > 12
+ *
+ *
+ * @see filterByAdmin()
+ *
+ * @param mixed $adminId 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 ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function filterByAdminId($adminId = null, $comparison = null)
+ {
+ if (is_array($adminId)) {
+ $useMinMax = false;
+ if (isset($adminId['min'])) {
+ $this->addUsingAlias(CreditNoteCommentTableMap::ADMIN_ID, $adminId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($adminId['max'])) {
+ $this->addUsingAlias(CreditNoteCommentTableMap::ADMIN_ID, $adminId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteCommentTableMap::ADMIN_ID, $adminId, $comparison);
+ }
+
+ /**
+ * Filter the query on the comment column
+ *
+ * Example usage:
+ *
+ * $query->filterByComment('fooValue'); // WHERE comment = 'fooValue'
+ * $query->filterByComment('%fooValue%'); // WHERE comment LIKE '%fooValue%'
+ *
+ *
+ * @param string $comment 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 ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function filterByComment($comment = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($comment)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $comment)) {
+ $comment = str_replace('*', '%', $comment);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteCommentTableMap::COMMENT, $comment, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CreditNoteCommentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CreditNoteCommentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteCommentTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CreditNoteCommentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CreditNoteCommentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteCommentTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNote object
+ *
+ * @param \CreditNote\Model\CreditNote|ObjectCollection $creditNote The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function filterByCreditNote($creditNote, $comparison = null)
+ {
+ if ($creditNote instanceof \CreditNote\Model\CreditNote) {
+ return $this
+ ->addUsingAlias(CreditNoteCommentTableMap::CREDIT_NOTE_ID, $creditNote->getId(), $comparison);
+ } elseif ($creditNote instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteCommentTableMap::CREDIT_NOTE_ID, $creditNote->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCreditNote() only accepts arguments of type \CreditNote\Model\CreditNote or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNote relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function joinCreditNote($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNote');
+
+ // 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, 'CreditNote');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNote relation CreditNote 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 \CreditNote\Model\CreditNoteQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCreditNote($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNote', '\CreditNote\Model\CreditNoteQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Admin object
+ *
+ * @param \Thelia\Model\Admin|ObjectCollection $admin The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function filterByAdmin($admin, $comparison = null)
+ {
+ if ($admin instanceof \Thelia\Model\Admin) {
+ return $this
+ ->addUsingAlias(CreditNoteCommentTableMap::ADMIN_ID, $admin->getId(), $comparison);
+ } elseif ($admin instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteCommentTableMap::ADMIN_ID, $admin->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByAdmin() only accepts arguments of type \Thelia\Model\Admin or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Admin relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function joinAdmin($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Admin');
+
+ // 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, 'Admin');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Admin relation Admin 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\AdminQuery A secondary query class using the current class as primary query
+ */
+ public function useAdminQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinAdmin($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Admin', '\Thelia\Model\AdminQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCreditNoteComment $creditNoteComment Object to remove from the list of results
+ *
+ * @return ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function prune($creditNoteComment = null)
+ {
+ if ($creditNoteComment) {
+ $this->addUsingAlias(CreditNoteCommentTableMap::ID, $creditNoteComment->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the credit_note_comment table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteCommentTableMap::DATABASE_NAME);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CreditNoteCommentTableMap::clearInstancePool();
+ CreditNoteCommentTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCreditNoteComment or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCreditNoteComment object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteCommentTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CreditNoteCommentTableMap::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+
+ CreditNoteCommentTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CreditNoteCommentTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CreditNoteCommentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CreditNoteCommentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CreditNoteCommentTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CreditNoteCommentTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CreditNoteCommentTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildCreditNoteCommentQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CreditNoteCommentTableMap::CREATED_AT);
+ }
+
+} // CreditNoteCommentQuery
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteDetail.php b/local/modules/CreditNote/Model/Base/CreditNoteDetail.php
new file mode 100644
index 000000000..9524eaad8
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteDetail.php
@@ -0,0 +1,1954 @@
+price = '0.000000';
+ $this->price_with_tax = '0.000000';
+ $this->quantity = 0;
+ }
+
+ /**
+ * Initializes internal state of CreditNote\Model\Base\CreditNoteDetail object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !!$this->modifiedColumns;
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return boolean true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ if (isset($this->modifiedColumns[$col])) {
+ unset($this->modifiedColumns[$col]);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another CreditNoteDetail instance. If
+ * obj is an instance of CreditNoteDetail, delegates to
+ * equals(CreditNoteDetail). Otherwise, returns false.
+ *
+ * @param mixed $obj The object to compare to.
+ * @return boolean Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return array_key_exists($name, $this->virtualColumns);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return mixed
+ *
+ * @throws PropelException
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return CreditNoteDetail The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return CreditNoteDetail The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+
+ return $this;
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [credit_note_id] column value.
+ *
+ * @return int
+ */
+ public function getCreditNoteId()
+ {
+
+ return $this->credit_note_id;
+ }
+
+ /**
+ * Get the [price] column value.
+ *
+ * @return string
+ */
+ public function getPrice()
+ {
+
+ return $this->price;
+ }
+
+ /**
+ * Get the [price_with_tax] column value.
+ *
+ * @return string
+ */
+ public function getPriceWithTax()
+ {
+
+ return $this->price_with_tax;
+ }
+
+ /**
+ * Get the [tax_rule_id] column value.
+ *
+ * @return int
+ */
+ public function getTaxRuleId()
+ {
+
+ return $this->tax_rule_id;
+ }
+
+ /**
+ * Get the [order_product_id] column value.
+ *
+ * @return int
+ */
+ public function getOrderProductId()
+ {
+
+ return $this->order_product_id;
+ }
+
+ /**
+ * Get the [type] column value.
+ *
+ * @return string
+ */
+ public function getType()
+ {
+
+ return $this->type;
+ }
+
+ /**
+ * Get the [quantity] column value.
+ *
+ * @return int
+ */
+ public function getQuantity()
+ {
+
+ return $this->quantity;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteDetail The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[CreditNoteDetailTableMap::ID] = true;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [credit_note_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteDetail The current object (for fluent API support)
+ */
+ public function setCreditNoteId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->credit_note_id !== $v) {
+ $this->credit_note_id = $v;
+ $this->modifiedColumns[CreditNoteDetailTableMap::CREDIT_NOTE_ID] = true;
+ }
+
+ if ($this->aCreditNote !== null && $this->aCreditNote->getId() !== $v) {
+ $this->aCreditNote = null;
+ }
+
+
+ return $this;
+ } // setCreditNoteId()
+
+ /**
+ * Set the value of [price] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteDetail The current object (for fluent API support)
+ */
+ public function setPrice($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->price !== $v) {
+ $this->price = $v;
+ $this->modifiedColumns[CreditNoteDetailTableMap::PRICE] = true;
+ }
+
+
+ return $this;
+ } // setPrice()
+
+ /**
+ * Set the value of [price_with_tax] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteDetail The current object (for fluent API support)
+ */
+ public function setPriceWithTax($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->price_with_tax !== $v) {
+ $this->price_with_tax = $v;
+ $this->modifiedColumns[CreditNoteDetailTableMap::PRICE_WITH_TAX] = true;
+ }
+
+
+ return $this;
+ } // setPriceWithTax()
+
+ /**
+ * Set the value of [tax_rule_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteDetail The current object (for fluent API support)
+ */
+ public function setTaxRuleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->tax_rule_id !== $v) {
+ $this->tax_rule_id = $v;
+ $this->modifiedColumns[CreditNoteDetailTableMap::TAX_RULE_ID] = true;
+ }
+
+ if ($this->aTaxRule !== null && $this->aTaxRule->getId() !== $v) {
+ $this->aTaxRule = null;
+ }
+
+
+ return $this;
+ } // setTaxRuleId()
+
+ /**
+ * Set the value of [order_product_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteDetail The current object (for fluent API support)
+ */
+ public function setOrderProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->order_product_id !== $v) {
+ $this->order_product_id = $v;
+ $this->modifiedColumns[CreditNoteDetailTableMap::ORDER_PRODUCT_ID] = true;
+ }
+
+ if ($this->aOrderProduct !== null && $this->aOrderProduct->getId() !== $v) {
+ $this->aOrderProduct = null;
+ }
+
+
+ return $this;
+ } // setOrderProductId()
+
+ /**
+ * Set the value of [type] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteDetail The current object (for fluent API support)
+ */
+ public function setType($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->type !== $v) {
+ $this->type = $v;
+ $this->modifiedColumns[CreditNoteDetailTableMap::TYPE] = true;
+ }
+
+
+ return $this;
+ } // setType()
+
+ /**
+ * Set the value of [quantity] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteDetail The current object (for fluent API support)
+ */
+ public function setQuantity($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->quantity !== $v) {
+ $this->quantity = $v;
+ $this->modifiedColumns[CreditNoteDetailTableMap::QUANTITY] = true;
+ }
+
+
+ return $this;
+ } // setQuantity()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteDetail The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[CreditNoteDetailTableMap::TITLE] = true;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNoteDetail The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[CreditNoteDetailTableMap::CREATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNoteDetail The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[CreditNoteDetailTableMap::UPDATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->price !== '0.000000') {
+ return false;
+ }
+
+ if ($this->price_with_tax !== '0.000000') {
+ return false;
+ }
+
+ if ($this->quantity !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CreditNoteDetailTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CreditNoteDetailTableMap::translateFieldName('CreditNoteId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->credit_note_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CreditNoteDetailTableMap::translateFieldName('Price', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->price = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CreditNoteDetailTableMap::translateFieldName('PriceWithTax', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->price_with_tax = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CreditNoteDetailTableMap::translateFieldName('TaxRuleId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->tax_rule_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CreditNoteDetailTableMap::translateFieldName('OrderProductId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->order_product_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CreditNoteDetailTableMap::translateFieldName('Type', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->type = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CreditNoteDetailTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->quantity = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CreditNoteDetailTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CreditNoteDetailTableMap::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 ? 10 + $startcol : CreditNoteDetailTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 11; // 11 = CreditNoteDetailTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \CreditNote\Model\CreditNoteDetail object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCreditNote !== null && $this->credit_note_id !== $this->aCreditNote->getId()) {
+ $this->aCreditNote = null;
+ }
+ if ($this->aTaxRule !== null && $this->tax_rule_id !== $this->aTaxRule->getId()) {
+ $this->aTaxRule = null;
+ }
+ if ($this->aOrderProduct !== null && $this->order_product_id !== $this->aOrderProduct->getId()) {
+ $this->aOrderProduct = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteDetailTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCreditNoteDetailQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCreditNote = null;
+ $this->aOrderProduct = null;
+ $this->aTaxRule = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see CreditNoteDetail::setDeleted()
+ * @see CreditNoteDetail::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteDetailTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCreditNoteDetailQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see doSave()
+ */
+ public function save(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteDetailTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(CreditNoteDetailTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(CreditNoteDetailTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(CreditNoteDetailTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CreditNoteDetailTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCreditNote !== null) {
+ if ($this->aCreditNote->isModified() || $this->aCreditNote->isNew()) {
+ $affectedRows += $this->aCreditNote->save($con);
+ }
+ $this->setCreditNote($this->aCreditNote);
+ }
+
+ if ($this->aOrderProduct !== null) {
+ if ($this->aOrderProduct->isModified() || $this->aOrderProduct->isNew()) {
+ $affectedRows += $this->aOrderProduct->save($con);
+ }
+ $this->setOrderProduct($this->aOrderProduct);
+ }
+
+ if ($this->aTaxRule !== null) {
+ if ($this->aTaxRule->isModified() || $this->aTaxRule->isNew()) {
+ $affectedRows += $this->aTaxRule->save($con);
+ }
+ $this->setTaxRule($this->aTaxRule);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[CreditNoteDetailTableMap::ID] = true;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CreditNoteDetailTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CreditNoteDetailTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CreditNoteDetailTableMap::CREDIT_NOTE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CREDIT_NOTE_ID';
+ }
+ if ($this->isColumnModified(CreditNoteDetailTableMap::PRICE)) {
+ $modifiedColumns[':p' . $index++] = 'PRICE';
+ }
+ if ($this->isColumnModified(CreditNoteDetailTableMap::PRICE_WITH_TAX)) {
+ $modifiedColumns[':p' . $index++] = 'PRICE_WITH_TAX';
+ }
+ if ($this->isColumnModified(CreditNoteDetailTableMap::TAX_RULE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'TAX_RULE_ID';
+ }
+ if ($this->isColumnModified(CreditNoteDetailTableMap::ORDER_PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = 'ORDER_PRODUCT_ID';
+ }
+ if ($this->isColumnModified(CreditNoteDetailTableMap::TYPE)) {
+ $modifiedColumns[':p' . $index++] = 'TYPE';
+ }
+ if ($this->isColumnModified(CreditNoteDetailTableMap::QUANTITY)) {
+ $modifiedColumns[':p' . $index++] = 'QUANTITY';
+ }
+ if ($this->isColumnModified(CreditNoteDetailTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(CreditNoteDetailTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CreditNoteDetailTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO credit_note_detail (%s) VALUES (%s)',
+ 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 'CREDIT_NOTE_ID':
+ $stmt->bindValue($identifier, $this->credit_note_id, PDO::PARAM_INT);
+ break;
+ case 'PRICE':
+ $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR);
+ break;
+ case 'PRICE_WITH_TAX':
+ $stmt->bindValue($identifier, $this->price_with_tax, PDO::PARAM_STR);
+ break;
+ case 'TAX_RULE_ID':
+ $stmt->bindValue($identifier, $this->tax_rule_id, PDO::PARAM_INT);
+ break;
+ case 'ORDER_PRODUCT_ID':
+ $stmt->bindValue($identifier, $this->order_product_id, PDO::PARAM_INT);
+ break;
+ case 'TYPE':
+ $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR);
+ break;
+ case 'QUANTITY':
+ $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_INT);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, 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);
+ 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);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteDetailTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCreditNoteId();
+ break;
+ case 2:
+ return $this->getPrice();
+ break;
+ case 3:
+ return $this->getPriceWithTax();
+ break;
+ case 4:
+ return $this->getTaxRuleId();
+ break;
+ case 5:
+ return $this->getOrderProductId();
+ break;
+ case 6:
+ return $this->getType();
+ break;
+ case 7:
+ return $this->getQuantity();
+ break;
+ case 8:
+ return $this->getTitle();
+ break;
+ case 9:
+ return $this->getCreatedAt();
+ break;
+ case 10:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CreditNoteDetail'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CreditNoteDetail'][$this->getPrimaryKey()] = true;
+ $keys = CreditNoteDetailTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCreditNoteId(),
+ $keys[2] => $this->getPrice(),
+ $keys[3] => $this->getPriceWithTax(),
+ $keys[4] => $this->getTaxRuleId(),
+ $keys[5] => $this->getOrderProductId(),
+ $keys[6] => $this->getType(),
+ $keys[7] => $this->getQuantity(),
+ $keys[8] => $this->getTitle(),
+ $keys[9] => $this->getCreatedAt(),
+ $keys[10] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach ($virtualColumns as $key => $virtualColumn) {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCreditNote) {
+ $result['CreditNote'] = $this->aCreditNote->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aOrderProduct) {
+ $result['OrderProduct'] = $this->aOrderProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aTaxRule) {
+ $result['TaxRule'] = $this->aTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteDetailTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+
+ return $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCreditNoteId($value);
+ break;
+ case 2:
+ $this->setPrice($value);
+ break;
+ case 3:
+ $this->setPriceWithTax($value);
+ break;
+ case 4:
+ $this->setTaxRuleId($value);
+ break;
+ case 5:
+ $this->setOrderProductId($value);
+ break;
+ case 6:
+ $this->setType($value);
+ break;
+ case 7:
+ $this->setQuantity($value);
+ break;
+ case 8:
+ $this->setTitle($value);
+ break;
+ case 9:
+ $this->setCreatedAt($value);
+ break;
+ case 10:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CreditNoteDetailTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCreditNoteId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setPrice($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setPriceWithTax($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setTaxRuleId($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setOrderProductId($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setType($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setQuantity($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setTitle($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setCreatedAt($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setUpdatedAt($arr[$keys[10]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CreditNoteDetailTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CreditNoteDetailTableMap::ID)) $criteria->add(CreditNoteDetailTableMap::ID, $this->id);
+ if ($this->isColumnModified(CreditNoteDetailTableMap::CREDIT_NOTE_ID)) $criteria->add(CreditNoteDetailTableMap::CREDIT_NOTE_ID, $this->credit_note_id);
+ if ($this->isColumnModified(CreditNoteDetailTableMap::PRICE)) $criteria->add(CreditNoteDetailTableMap::PRICE, $this->price);
+ if ($this->isColumnModified(CreditNoteDetailTableMap::PRICE_WITH_TAX)) $criteria->add(CreditNoteDetailTableMap::PRICE_WITH_TAX, $this->price_with_tax);
+ if ($this->isColumnModified(CreditNoteDetailTableMap::TAX_RULE_ID)) $criteria->add(CreditNoteDetailTableMap::TAX_RULE_ID, $this->tax_rule_id);
+ if ($this->isColumnModified(CreditNoteDetailTableMap::ORDER_PRODUCT_ID)) $criteria->add(CreditNoteDetailTableMap::ORDER_PRODUCT_ID, $this->order_product_id);
+ if ($this->isColumnModified(CreditNoteDetailTableMap::TYPE)) $criteria->add(CreditNoteDetailTableMap::TYPE, $this->type);
+ if ($this->isColumnModified(CreditNoteDetailTableMap::QUANTITY)) $criteria->add(CreditNoteDetailTableMap::QUANTITY, $this->quantity);
+ if ($this->isColumnModified(CreditNoteDetailTableMap::TITLE)) $criteria->add(CreditNoteDetailTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(CreditNoteDetailTableMap::CREATED_AT)) $criteria->add(CreditNoteDetailTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CreditNoteDetailTableMap::UPDATED_AT)) $criteria->add(CreditNoteDetailTableMap::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CreditNoteDetailTableMap::DATABASE_NAME);
+ $criteria->add(CreditNoteDetailTableMap::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of \CreditNote\Model\CreditNoteDetail (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCreditNoteId($this->getCreditNoteId());
+ $copyObj->setPrice($this->getPrice());
+ $copyObj->setPriceWithTax($this->getPriceWithTax());
+ $copyObj->setTaxRuleId($this->getTaxRuleId());
+ $copyObj->setOrderProductId($this->getOrderProductId());
+ $copyObj->setType($this->getType());
+ $copyObj->setQuantity($this->getQuantity());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return \CreditNote\Model\CreditNoteDetail Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCreditNote object.
+ *
+ * @param ChildCreditNote $v
+ * @return \CreditNote\Model\CreditNoteDetail The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCreditNote(ChildCreditNote $v = null)
+ {
+ if ($v === null) {
+ $this->setCreditNoteId(NULL);
+ } else {
+ $this->setCreditNoteId($v->getId());
+ }
+
+ $this->aCreditNote = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCreditNote object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNoteDetail($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCreditNote object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCreditNote The associated ChildCreditNote object.
+ * @throws PropelException
+ */
+ public function getCreditNote(ConnectionInterface $con = null)
+ {
+ if ($this->aCreditNote === null && ($this->credit_note_id !== null)) {
+ $this->aCreditNote = ChildCreditNoteQuery::create()->findPk($this->credit_note_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCreditNote->addCreditNoteDetails($this);
+ */
+ }
+
+ return $this->aCreditNote;
+ }
+
+ /**
+ * Declares an association between this object and a ChildOrderProduct object.
+ *
+ * @param ChildOrderProduct $v
+ * @return \CreditNote\Model\CreditNoteDetail The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setOrderProduct(ChildOrderProduct $v = null)
+ {
+ if ($v === null) {
+ $this->setOrderProductId(NULL);
+ } else {
+ $this->setOrderProductId($v->getId());
+ }
+
+ $this->aOrderProduct = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildOrderProduct object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNoteDetail($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildOrderProduct object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildOrderProduct The associated ChildOrderProduct object.
+ * @throws PropelException
+ */
+ public function getOrderProduct(ConnectionInterface $con = null)
+ {
+ if ($this->aOrderProduct === null && ($this->order_product_id !== null)) {
+ $this->aOrderProduct = OrderProductQuery::create()->findPk($this->order_product_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aOrderProduct->addCreditNoteDetails($this);
+ */
+ }
+
+ return $this->aOrderProduct;
+ }
+
+ /**
+ * Declares an association between this object and a ChildTaxRule object.
+ *
+ * @param ChildTaxRule $v
+ * @return \CreditNote\Model\CreditNoteDetail The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setTaxRule(ChildTaxRule $v = null)
+ {
+ if ($v === null) {
+ $this->setTaxRuleId(NULL);
+ } else {
+ $this->setTaxRuleId($v->getId());
+ }
+
+ $this->aTaxRule = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildTaxRule object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNoteDetail($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildTaxRule object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildTaxRule The associated ChildTaxRule object.
+ * @throws PropelException
+ */
+ public function getTaxRule(ConnectionInterface $con = null)
+ {
+ if ($this->aTaxRule === null && ($this->tax_rule_id !== null)) {
+ $this->aTaxRule = TaxRuleQuery::create()->findPk($this->tax_rule_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aTaxRule->addCreditNoteDetails($this);
+ */
+ }
+
+ return $this->aTaxRule;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->credit_note_id = null;
+ $this->price = null;
+ $this->price_with_tax = null;
+ $this->tax_rule_id = null;
+ $this->order_product_id = null;
+ $this->type = null;
+ $this->quantity = null;
+ $this->title = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCreditNote = null;
+ $this->aOrderProduct = null;
+ $this->aTaxRule = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CreditNoteDetailTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildCreditNoteDetail The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[CreditNoteDetailTableMap::UPDATED_AT] = true;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteDetailQuery.php b/local/modules/CreditNote/Model/Base/CreditNoteDetailQuery.php
new file mode 100644
index 000000000..306ac41a9
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteDetailQuery.php
@@ -0,0 +1,1088 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCreditNoteDetail|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CreditNoteDetailTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteDetailTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * 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 ChildCreditNoteDetail A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, CREDIT_NOTE_ID, PRICE, PRICE_WITH_TAX, TAX_RULE_ID, ORDER_PRODUCT_ID, TYPE, QUANTITY, TITLE, CREATED_AT, UPDATED_AT FROM credit_note_detail 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 ChildCreditNoteDetail();
+ $obj->hydrate($row);
+ CreditNoteDetailTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCreditNoteDetail|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CreditNoteDetailTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CreditNoteDetailTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id 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 ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteDetailTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the credit_note_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreditNoteId(1234); // WHERE credit_note_id = 1234
+ * $query->filterByCreditNoteId(array(12, 34)); // WHERE credit_note_id IN (12, 34)
+ * $query->filterByCreditNoteId(array('min' => 12)); // WHERE credit_note_id > 12
+ *
+ *
+ * @see filterByCreditNote()
+ *
+ * @param mixed $creditNoteId 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 ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteId($creditNoteId = null, $comparison = null)
+ {
+ if (is_array($creditNoteId)) {
+ $useMinMax = false;
+ if (isset($creditNoteId['min'])) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::CREDIT_NOTE_ID, $creditNoteId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($creditNoteId['max'])) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::CREDIT_NOTE_ID, $creditNoteId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteDetailTableMap::CREDIT_NOTE_ID, $creditNoteId, $comparison);
+ }
+
+ /**
+ * Filter the query on the price column
+ *
+ * Example usage:
+ *
+ * $query->filterByPrice(1234); // WHERE price = 1234
+ * $query->filterByPrice(array(12, 34)); // WHERE price IN (12, 34)
+ * $query->filterByPrice(array('min' => 12)); // WHERE price > 12
+ *
+ *
+ * @param mixed $price 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 ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function filterByPrice($price = null, $comparison = null)
+ {
+ if (is_array($price)) {
+ $useMinMax = false;
+ if (isset($price['min'])) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::PRICE, $price['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($price['max'])) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::PRICE, $price['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteDetailTableMap::PRICE, $price, $comparison);
+ }
+
+ /**
+ * Filter the query on the price_with_tax column
+ *
+ * Example usage:
+ *
+ * $query->filterByPriceWithTax(1234); // WHERE price_with_tax = 1234
+ * $query->filterByPriceWithTax(array(12, 34)); // WHERE price_with_tax IN (12, 34)
+ * $query->filterByPriceWithTax(array('min' => 12)); // WHERE price_with_tax > 12
+ *
+ *
+ * @param mixed $priceWithTax 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 ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function filterByPriceWithTax($priceWithTax = null, $comparison = null)
+ {
+ if (is_array($priceWithTax)) {
+ $useMinMax = false;
+ if (isset($priceWithTax['min'])) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::PRICE_WITH_TAX, $priceWithTax['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($priceWithTax['max'])) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::PRICE_WITH_TAX, $priceWithTax['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteDetailTableMap::PRICE_WITH_TAX, $priceWithTax, $comparison);
+ }
+
+ /**
+ * Filter the query on the tax_rule_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByTaxRuleId(1234); // WHERE tax_rule_id = 1234
+ * $query->filterByTaxRuleId(array(12, 34)); // WHERE tax_rule_id IN (12, 34)
+ * $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id > 12
+ *
+ *
+ * @see filterByTaxRule()
+ *
+ * @param mixed $taxRuleId 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 ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function filterByTaxRuleId($taxRuleId = null, $comparison = null)
+ {
+ if (is_array($taxRuleId)) {
+ $useMinMax = false;
+ if (isset($taxRuleId['min'])) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::TAX_RULE_ID, $taxRuleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($taxRuleId['max'])) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::TAX_RULE_ID, $taxRuleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteDetailTableMap::TAX_RULE_ID, $taxRuleId, $comparison);
+ }
+
+ /**
+ * Filter the query on the order_product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByOrderProductId(1234); // WHERE order_product_id = 1234
+ * $query->filterByOrderProductId(array(12, 34)); // WHERE order_product_id IN (12, 34)
+ * $query->filterByOrderProductId(array('min' => 12)); // WHERE order_product_id > 12
+ *
+ *
+ * @see filterByOrderProduct()
+ *
+ * @param mixed $orderProductId 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 ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function filterByOrderProductId($orderProductId = null, $comparison = null)
+ {
+ if (is_array($orderProductId)) {
+ $useMinMax = false;
+ if (isset($orderProductId['min'])) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::ORDER_PRODUCT_ID, $orderProductId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($orderProductId['max'])) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::ORDER_PRODUCT_ID, $orderProductId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteDetailTableMap::ORDER_PRODUCT_ID, $orderProductId, $comparison);
+ }
+
+ /**
+ * Filter the query on the type column
+ *
+ * Example usage:
+ *
+ * $query->filterByType('fooValue'); // WHERE type = 'fooValue'
+ * $query->filterByType('%fooValue%'); // WHERE type LIKE '%fooValue%'
+ *
+ *
+ * @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 ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function filterByType($type = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($type)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $type)) {
+ $type = str_replace('*', '%', $type);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteDetailTableMap::TYPE, $type, $comparison);
+ }
+
+ /**
+ * Filter the query on the quantity column
+ *
+ * Example usage:
+ *
+ * $query->filterByQuantity(1234); // WHERE quantity = 1234
+ * $query->filterByQuantity(array(12, 34)); // WHERE quantity IN (12, 34)
+ * $query->filterByQuantity(array('min' => 12)); // WHERE quantity > 12
+ *
+ *
+ * @param mixed $quantity 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 ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function filterByQuantity($quantity = null, $comparison = null)
+ {
+ if (is_array($quantity)) {
+ $useMinMax = false;
+ if (isset($quantity['min'])) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($quantity['max'])) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteDetailTableMap::QUANTITY, $quantity, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title 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 ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteDetailTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteDetailTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteDetailTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNote object
+ *
+ * @param \CreditNote\Model\CreditNote|ObjectCollection $creditNote The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function filterByCreditNote($creditNote, $comparison = null)
+ {
+ if ($creditNote instanceof \CreditNote\Model\CreditNote) {
+ return $this
+ ->addUsingAlias(CreditNoteDetailTableMap::CREDIT_NOTE_ID, $creditNote->getId(), $comparison);
+ } elseif ($creditNote instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteDetailTableMap::CREDIT_NOTE_ID, $creditNote->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCreditNote() only accepts arguments of type \CreditNote\Model\CreditNote or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNote relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function joinCreditNote($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNote');
+
+ // 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, 'CreditNote');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNote relation CreditNote 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 \CreditNote\Model\CreditNoteQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCreditNote($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNote', '\CreditNote\Model\CreditNoteQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\OrderProduct object
+ *
+ * @param \Thelia\Model\OrderProduct|ObjectCollection $orderProduct The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function filterByOrderProduct($orderProduct, $comparison = null)
+ {
+ if ($orderProduct instanceof \Thelia\Model\OrderProduct) {
+ return $this
+ ->addUsingAlias(CreditNoteDetailTableMap::ORDER_PRODUCT_ID, $orderProduct->getId(), $comparison);
+ } elseif ($orderProduct instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteDetailTableMap::ORDER_PRODUCT_ID, $orderProduct->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByOrderProduct() only accepts arguments of type \Thelia\Model\OrderProduct or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderProduct relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function joinOrderProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderProduct');
+
+ // 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, 'OrderProduct');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderProduct relation OrderProduct 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\OrderProductQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinOrderProduct($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderProduct', '\Thelia\Model\OrderProductQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\TaxRule object
+ *
+ * @param \Thelia\Model\TaxRule|ObjectCollection $taxRule The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function filterByTaxRule($taxRule, $comparison = null)
+ {
+ if ($taxRule instanceof \Thelia\Model\TaxRule) {
+ return $this
+ ->addUsingAlias(CreditNoteDetailTableMap::TAX_RULE_ID, $taxRule->getId(), $comparison);
+ } elseif ($taxRule instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteDetailTableMap::TAX_RULE_ID, $taxRule->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByTaxRule() only accepts arguments of type \Thelia\Model\TaxRule or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the TaxRule relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function joinTaxRule($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('TaxRule');
+
+ // 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, 'TaxRule');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the TaxRule relation TaxRule 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\TaxRuleQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxRuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinTaxRule($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'TaxRule', '\Thelia\Model\TaxRuleQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCreditNoteDetail $creditNoteDetail Object to remove from the list of results
+ *
+ * @return ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function prune($creditNoteDetail = null)
+ {
+ if ($creditNoteDetail) {
+ $this->addUsingAlias(CreditNoteDetailTableMap::ID, $creditNoteDetail->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the credit_note_detail table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteDetailTableMap::DATABASE_NAME);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CreditNoteDetailTableMap::clearInstancePool();
+ CreditNoteDetailTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCreditNoteDetail or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCreditNoteDetail object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteDetailTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CreditNoteDetailTableMap::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+
+ CreditNoteDetailTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CreditNoteDetailTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CreditNoteDetailTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CreditNoteDetailTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CreditNoteDetailTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CreditNoteDetailTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CreditNoteDetailTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildCreditNoteDetailQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CreditNoteDetailTableMap::CREATED_AT);
+ }
+
+} // CreditNoteDetailQuery
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteQuery.php b/local/modules/CreditNote/Model/Base/CreditNoteQuery.php
new file mode 100644
index 000000000..6a164c418
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteQuery.php
@@ -0,0 +1,2146 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCreditNote|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CreditNoteTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * 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 ChildCreditNote A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, REF, INVOICE_REF, INVOICE_ADDRESS_ID, INVOICE_DATE, ORDER_ID, CUSTOMER_ID, PARENT_ID, TYPE_ID, STATUS_ID, CURRENCY_ID, CURRENCY_RATE, TOTAL_PRICE, TOTAL_PRICE_WITH_TAX, DISCOUNT_WITHOUT_TAX, DISCOUNT_WITH_TAX, ALLOW_PARTIAL_USE, CREATED_AT, UPDATED_AT FROM credit_note 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 ChildCreditNote();
+ $obj->hydrate($row);
+ CreditNoteTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCreditNote|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CreditNoteTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CreditNoteTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id 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 ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CreditNoteTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CreditNoteTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the ref column
+ *
+ * Example usage:
+ *
+ * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue'
+ * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%'
+ *
+ *
+ * @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 ChildCreditNoteQuery 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(CreditNoteTableMap::REF, $ref, $comparison);
+ }
+
+ /**
+ * Filter the query on the invoice_ref column
+ *
+ * Example usage:
+ *
+ * $query->filterByInvoiceRef('fooValue'); // WHERE invoice_ref = 'fooValue'
+ * $query->filterByInvoiceRef('%fooValue%'); // WHERE invoice_ref LIKE '%fooValue%'
+ *
+ *
+ * @param string $invoiceRef 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 ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByInvoiceRef($invoiceRef = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($invoiceRef)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $invoiceRef)) {
+ $invoiceRef = str_replace('*', '%', $invoiceRef);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTableMap::INVOICE_REF, $invoiceRef, $comparison);
+ }
+
+ /**
+ * Filter the query on the invoice_address_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByInvoiceAddressId(1234); // WHERE invoice_address_id = 1234
+ * $query->filterByInvoiceAddressId(array(12, 34)); // WHERE invoice_address_id IN (12, 34)
+ * $query->filterByInvoiceAddressId(array('min' => 12)); // WHERE invoice_address_id > 12
+ *
+ *
+ * @see filterByCreditNoteAddress()
+ *
+ * @param mixed $invoiceAddressId 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 ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByInvoiceAddressId($invoiceAddressId = null, $comparison = null)
+ {
+ if (is_array($invoiceAddressId)) {
+ $useMinMax = false;
+ if (isset($invoiceAddressId['min'])) {
+ $this->addUsingAlias(CreditNoteTableMap::INVOICE_ADDRESS_ID, $invoiceAddressId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($invoiceAddressId['max'])) {
+ $this->addUsingAlias(CreditNoteTableMap::INVOICE_ADDRESS_ID, $invoiceAddressId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTableMap::INVOICE_ADDRESS_ID, $invoiceAddressId, $comparison);
+ }
+
+ /**
+ * Filter the query on the invoice_date column
+ *
+ * Example usage:
+ *
+ * $query->filterByInvoiceDate('2011-03-14'); // WHERE invoice_date = '2011-03-14'
+ * $query->filterByInvoiceDate('now'); // WHERE invoice_date = '2011-03-14'
+ * $query->filterByInvoiceDate(array('max' => 'yesterday')); // WHERE invoice_date > '2011-03-13'
+ *
+ *
+ * @param mixed $invoiceDate The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByInvoiceDate($invoiceDate = null, $comparison = null)
+ {
+ if (is_array($invoiceDate)) {
+ $useMinMax = false;
+ if (isset($invoiceDate['min'])) {
+ $this->addUsingAlias(CreditNoteTableMap::INVOICE_DATE, $invoiceDate['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($invoiceDate['max'])) {
+ $this->addUsingAlias(CreditNoteTableMap::INVOICE_DATE, $invoiceDate['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTableMap::INVOICE_DATE, $invoiceDate, $comparison);
+ }
+
+ /**
+ * Filter the query on the order_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByOrderId(1234); // WHERE order_id = 1234
+ * $query->filterByOrderId(array(12, 34)); // WHERE order_id IN (12, 34)
+ * $query->filterByOrderId(array('min' => 12)); // WHERE order_id > 12
+ *
+ *
+ * @see filterByOrder()
+ *
+ * @param mixed $orderId 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 ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByOrderId($orderId = null, $comparison = null)
+ {
+ if (is_array($orderId)) {
+ $useMinMax = false;
+ if (isset($orderId['min'])) {
+ $this->addUsingAlias(CreditNoteTableMap::ORDER_ID, $orderId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($orderId['max'])) {
+ $this->addUsingAlias(CreditNoteTableMap::ORDER_ID, $orderId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTableMap::ORDER_ID, $orderId, $comparison);
+ }
+
+ /**
+ * Filter the query on the customer_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCustomerId(1234); // WHERE customer_id = 1234
+ * $query->filterByCustomerId(array(12, 34)); // WHERE customer_id IN (12, 34)
+ * $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id > 12
+ *
+ *
+ * @see filterByCustomer()
+ *
+ * @param mixed $customerId 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 ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCustomerId($customerId = null, $comparison = null)
+ {
+ if (is_array($customerId)) {
+ $useMinMax = false;
+ if (isset($customerId['min'])) {
+ $this->addUsingAlias(CreditNoteTableMap::CUSTOMER_ID, $customerId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($customerId['max'])) {
+ $this->addUsingAlias(CreditNoteTableMap::CUSTOMER_ID, $customerId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTableMap::CUSTOMER_ID, $customerId, $comparison);
+ }
+
+ /**
+ * Filter the query on the parent_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByParentId(1234); // WHERE parent_id = 1234
+ * $query->filterByParentId(array(12, 34)); // WHERE parent_id IN (12, 34)
+ * $query->filterByParentId(array('min' => 12)); // WHERE parent_id > 12
+ *
+ *
+ * @see filterByCreditNoteRelatedByParentId()
+ *
+ * @param mixed $parentId 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 ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByParentId($parentId = null, $comparison = null)
+ {
+ if (is_array($parentId)) {
+ $useMinMax = false;
+ if (isset($parentId['min'])) {
+ $this->addUsingAlias(CreditNoteTableMap::PARENT_ID, $parentId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($parentId['max'])) {
+ $this->addUsingAlias(CreditNoteTableMap::PARENT_ID, $parentId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTableMap::PARENT_ID, $parentId, $comparison);
+ }
+
+ /**
+ * Filter the query on the type_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByTypeId(1234); // WHERE type_id = 1234
+ * $query->filterByTypeId(array(12, 34)); // WHERE type_id IN (12, 34)
+ * $query->filterByTypeId(array('min' => 12)); // WHERE type_id > 12
+ *
+ *
+ * @see filterByCreditNoteType()
+ *
+ * @param mixed $typeId 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 ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByTypeId($typeId = null, $comparison = null)
+ {
+ if (is_array($typeId)) {
+ $useMinMax = false;
+ if (isset($typeId['min'])) {
+ $this->addUsingAlias(CreditNoteTableMap::TYPE_ID, $typeId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($typeId['max'])) {
+ $this->addUsingAlias(CreditNoteTableMap::TYPE_ID, $typeId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTableMap::TYPE_ID, $typeId, $comparison);
+ }
+
+ /**
+ * Filter the query on the status_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByStatusId(1234); // WHERE status_id = 1234
+ * $query->filterByStatusId(array(12, 34)); // WHERE status_id IN (12, 34)
+ * $query->filterByStatusId(array('min' => 12)); // WHERE status_id > 12
+ *
+ *
+ * @see filterByCreditNoteStatus()
+ *
+ * @param mixed $statusId 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 ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByStatusId($statusId = null, $comparison = null)
+ {
+ if (is_array($statusId)) {
+ $useMinMax = false;
+ if (isset($statusId['min'])) {
+ $this->addUsingAlias(CreditNoteTableMap::STATUS_ID, $statusId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($statusId['max'])) {
+ $this->addUsingAlias(CreditNoteTableMap::STATUS_ID, $statusId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTableMap::STATUS_ID, $statusId, $comparison);
+ }
+
+ /**
+ * Filter the query on the currency_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCurrencyId(1234); // WHERE currency_id = 1234
+ * $query->filterByCurrencyId(array(12, 34)); // WHERE currency_id IN (12, 34)
+ * $query->filterByCurrencyId(array('min' => 12)); // WHERE currency_id > 12
+ *
+ *
+ * @see filterByCurrency()
+ *
+ * @param mixed $currencyId 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 ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCurrencyId($currencyId = null, $comparison = null)
+ {
+ if (is_array($currencyId)) {
+ $useMinMax = false;
+ if (isset($currencyId['min'])) {
+ $this->addUsingAlias(CreditNoteTableMap::CURRENCY_ID, $currencyId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($currencyId['max'])) {
+ $this->addUsingAlias(CreditNoteTableMap::CURRENCY_ID, $currencyId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTableMap::CURRENCY_ID, $currencyId, $comparison);
+ }
+
+ /**
+ * Filter the query on the currency_rate column
+ *
+ * Example usage:
+ *
+ * $query->filterByCurrencyRate(1234); // WHERE currency_rate = 1234
+ * $query->filterByCurrencyRate(array(12, 34)); // WHERE currency_rate IN (12, 34)
+ * $query->filterByCurrencyRate(array('min' => 12)); // WHERE currency_rate > 12
+ *
+ *
+ * @param mixed $currencyRate 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 ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCurrencyRate($currencyRate = null, $comparison = null)
+ {
+ if (is_array($currencyRate)) {
+ $useMinMax = false;
+ if (isset($currencyRate['min'])) {
+ $this->addUsingAlias(CreditNoteTableMap::CURRENCY_RATE, $currencyRate['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($currencyRate['max'])) {
+ $this->addUsingAlias(CreditNoteTableMap::CURRENCY_RATE, $currencyRate['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTableMap::CURRENCY_RATE, $currencyRate, $comparison);
+ }
+
+ /**
+ * Filter the query on the total_price column
+ *
+ * Example usage:
+ *
+ * $query->filterByTotalPrice(1234); // WHERE total_price = 1234
+ * $query->filterByTotalPrice(array(12, 34)); // WHERE total_price IN (12, 34)
+ * $query->filterByTotalPrice(array('min' => 12)); // WHERE total_price > 12
+ *
+ *
+ * @param mixed $totalPrice 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 ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByTotalPrice($totalPrice = null, $comparison = null)
+ {
+ if (is_array($totalPrice)) {
+ $useMinMax = false;
+ if (isset($totalPrice['min'])) {
+ $this->addUsingAlias(CreditNoteTableMap::TOTAL_PRICE, $totalPrice['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($totalPrice['max'])) {
+ $this->addUsingAlias(CreditNoteTableMap::TOTAL_PRICE, $totalPrice['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTableMap::TOTAL_PRICE, $totalPrice, $comparison);
+ }
+
+ /**
+ * Filter the query on the total_price_with_tax column
+ *
+ * Example usage:
+ *
+ * $query->filterByTotalPriceWithTax(1234); // WHERE total_price_with_tax = 1234
+ * $query->filterByTotalPriceWithTax(array(12, 34)); // WHERE total_price_with_tax IN (12, 34)
+ * $query->filterByTotalPriceWithTax(array('min' => 12)); // WHERE total_price_with_tax > 12
+ *
+ *
+ * @param mixed $totalPriceWithTax 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 ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByTotalPriceWithTax($totalPriceWithTax = null, $comparison = null)
+ {
+ if (is_array($totalPriceWithTax)) {
+ $useMinMax = false;
+ if (isset($totalPriceWithTax['min'])) {
+ $this->addUsingAlias(CreditNoteTableMap::TOTAL_PRICE_WITH_TAX, $totalPriceWithTax['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($totalPriceWithTax['max'])) {
+ $this->addUsingAlias(CreditNoteTableMap::TOTAL_PRICE_WITH_TAX, $totalPriceWithTax['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTableMap::TOTAL_PRICE_WITH_TAX, $totalPriceWithTax, $comparison);
+ }
+
+ /**
+ * Filter the query on the discount_without_tax column
+ *
+ * Example usage:
+ *
+ * $query->filterByDiscountWithoutTax(1234); // WHERE discount_without_tax = 1234
+ * $query->filterByDiscountWithoutTax(array(12, 34)); // WHERE discount_without_tax IN (12, 34)
+ * $query->filterByDiscountWithoutTax(array('min' => 12)); // WHERE discount_without_tax > 12
+ *
+ *
+ * @param mixed $discountWithoutTax 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 ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByDiscountWithoutTax($discountWithoutTax = null, $comparison = null)
+ {
+ if (is_array($discountWithoutTax)) {
+ $useMinMax = false;
+ if (isset($discountWithoutTax['min'])) {
+ $this->addUsingAlias(CreditNoteTableMap::DISCOUNT_WITHOUT_TAX, $discountWithoutTax['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($discountWithoutTax['max'])) {
+ $this->addUsingAlias(CreditNoteTableMap::DISCOUNT_WITHOUT_TAX, $discountWithoutTax['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTableMap::DISCOUNT_WITHOUT_TAX, $discountWithoutTax, $comparison);
+ }
+
+ /**
+ * Filter the query on the discount_with_tax column
+ *
+ * Example usage:
+ *
+ * $query->filterByDiscountWithTax(1234); // WHERE discount_with_tax = 1234
+ * $query->filterByDiscountWithTax(array(12, 34)); // WHERE discount_with_tax IN (12, 34)
+ * $query->filterByDiscountWithTax(array('min' => 12)); // WHERE discount_with_tax > 12
+ *
+ *
+ * @param mixed $discountWithTax 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 ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByDiscountWithTax($discountWithTax = null, $comparison = null)
+ {
+ if (is_array($discountWithTax)) {
+ $useMinMax = false;
+ if (isset($discountWithTax['min'])) {
+ $this->addUsingAlias(CreditNoteTableMap::DISCOUNT_WITH_TAX, $discountWithTax['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($discountWithTax['max'])) {
+ $this->addUsingAlias(CreditNoteTableMap::DISCOUNT_WITH_TAX, $discountWithTax['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTableMap::DISCOUNT_WITH_TAX, $discountWithTax, $comparison);
+ }
+
+ /**
+ * Filter the query on the allow_partial_use column
+ *
+ * Example usage:
+ *
+ * $query->filterByAllowPartialUse(true); // WHERE allow_partial_use = true
+ * $query->filterByAllowPartialUse('yes'); // WHERE allow_partial_use = true
+ *
+ *
+ * @param boolean|string $allowPartialUse The value to use as filter.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByAllowPartialUse($allowPartialUse = null, $comparison = null)
+ {
+ if (is_string($allowPartialUse)) {
+ $allow_partial_use = in_array(strtolower($allowPartialUse), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ }
+
+ return $this->addUsingAlias(CreditNoteTableMap::ALLOW_PARTIAL_USE, $allowPartialUse, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CreditNoteTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CreditNoteTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CreditNoteTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CreditNoteTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Order object
+ *
+ * @param \Thelia\Model\Order|ObjectCollection $order The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByOrder($order, $comparison = null)
+ {
+ if ($order instanceof \Thelia\Model\Order) {
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::ORDER_ID, $order->getId(), $comparison);
+ } elseif ($order instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByOrder() only accepts arguments of type \Thelia\Model\Order or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Order relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function joinOrder($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Order');
+
+ // 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, 'Order');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Order relation Order 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\OrderQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinOrder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Customer object
+ *
+ * @param \Thelia\Model\Customer|ObjectCollection $customer The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCustomer($customer, $comparison = null)
+ {
+ if ($customer instanceof \Thelia\Model\Customer) {
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::CUSTOMER_ID, $customer->getId(), $comparison);
+ } elseif ($customer instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::CUSTOMER_ID, $customer->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCustomer() only accepts arguments of type \Thelia\Model\Customer or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Customer relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function joinCustomer($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Customer');
+
+ // 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, 'Customer');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Customer relation Customer 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\CustomerQuery A secondary query class using the current class as primary query
+ */
+ public function useCustomerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCustomer($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Customer', '\Thelia\Model\CustomerQuery');
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNote object
+ *
+ * @param \CreditNote\Model\CreditNote|ObjectCollection $creditNote The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteRelatedByParentId($creditNote, $comparison = null)
+ {
+ if ($creditNote instanceof \CreditNote\Model\CreditNote) {
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::PARENT_ID, $creditNote->getId(), $comparison);
+ } elseif ($creditNote instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::PARENT_ID, $creditNote->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCreditNoteRelatedByParentId() only accepts arguments of type \CreditNote\Model\CreditNote or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNoteRelatedByParentId relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function joinCreditNoteRelatedByParentId($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNoteRelatedByParentId');
+
+ // 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, 'CreditNoteRelatedByParentId');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNoteRelatedByParentId relation CreditNote 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 \CreditNote\Model\CreditNoteQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteRelatedByParentIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCreditNoteRelatedByParentId($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNoteRelatedByParentId', '\CreditNote\Model\CreditNoteQuery');
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNoteType object
+ *
+ * @param \CreditNote\Model\CreditNoteType|ObjectCollection $creditNoteType The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteType($creditNoteType, $comparison = null)
+ {
+ if ($creditNoteType instanceof \CreditNote\Model\CreditNoteType) {
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::TYPE_ID, $creditNoteType->getId(), $comparison);
+ } elseif ($creditNoteType instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::TYPE_ID, $creditNoteType->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCreditNoteType() only accepts arguments of type \CreditNote\Model\CreditNoteType or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNoteType relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function joinCreditNoteType($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNoteType');
+
+ // 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, 'CreditNoteType');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNoteType relation CreditNoteType 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 \CreditNote\Model\CreditNoteTypeQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteTypeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCreditNoteType($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNoteType', '\CreditNote\Model\CreditNoteTypeQuery');
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNoteStatus object
+ *
+ * @param \CreditNote\Model\CreditNoteStatus|ObjectCollection $creditNoteStatus The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteStatus($creditNoteStatus, $comparison = null)
+ {
+ if ($creditNoteStatus instanceof \CreditNote\Model\CreditNoteStatus) {
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::STATUS_ID, $creditNoteStatus->getId(), $comparison);
+ } elseif ($creditNoteStatus instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::STATUS_ID, $creditNoteStatus->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCreditNoteStatus() only accepts arguments of type \CreditNote\Model\CreditNoteStatus or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNoteStatus relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function joinCreditNoteStatus($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNoteStatus');
+
+ // 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, 'CreditNoteStatus');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNoteStatus relation CreditNoteStatus 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 \CreditNote\Model\CreditNoteStatusQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteStatusQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCreditNoteStatus($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNoteStatus', '\CreditNote\Model\CreditNoteStatusQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Currency object
+ *
+ * @param \Thelia\Model\Currency|ObjectCollection $currency The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCurrency($currency, $comparison = null)
+ {
+ if ($currency instanceof \Thelia\Model\Currency) {
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::CURRENCY_ID, $currency->getId(), $comparison);
+ } elseif ($currency instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::CURRENCY_ID, $currency->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCurrency() only accepts arguments of type \Thelia\Model\Currency or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Currency relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function joinCurrency($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Currency');
+
+ // 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, 'Currency');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Currency relation Currency 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\CurrencyQuery A secondary query class using the current class as primary query
+ */
+ public function useCurrencyQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCurrency($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Currency', '\Thelia\Model\CurrencyQuery');
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNoteAddress object
+ *
+ * @param \CreditNote\Model\CreditNoteAddress|ObjectCollection $creditNoteAddress The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteAddress($creditNoteAddress, $comparison = null)
+ {
+ if ($creditNoteAddress instanceof \CreditNote\Model\CreditNoteAddress) {
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::INVOICE_ADDRESS_ID, $creditNoteAddress->getId(), $comparison);
+ } elseif ($creditNoteAddress instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::INVOICE_ADDRESS_ID, $creditNoteAddress->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCreditNoteAddress() only accepts arguments of type \CreditNote\Model\CreditNoteAddress or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNoteAddress relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function joinCreditNoteAddress($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNoteAddress');
+
+ // 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, 'CreditNoteAddress');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNoteAddress relation CreditNoteAddress 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 \CreditNote\Model\CreditNoteAddressQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteAddressQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCreditNoteAddress($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNoteAddress', '\CreditNote\Model\CreditNoteAddressQuery');
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNote object
+ *
+ * @param \CreditNote\Model\CreditNote|ObjectCollection $creditNote the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteRelatedById($creditNote, $comparison = null)
+ {
+ if ($creditNote instanceof \CreditNote\Model\CreditNote) {
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::ID, $creditNote->getParentId(), $comparison);
+ } elseif ($creditNote instanceof ObjectCollection) {
+ return $this
+ ->useCreditNoteRelatedByIdQuery()
+ ->filterByPrimaryKeys($creditNote->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCreditNoteRelatedById() only accepts arguments of type \CreditNote\Model\CreditNote or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNoteRelatedById relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function joinCreditNoteRelatedById($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNoteRelatedById');
+
+ // 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, 'CreditNoteRelatedById');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNoteRelatedById relation CreditNote 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 \CreditNote\Model\CreditNoteQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteRelatedByIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCreditNoteRelatedById($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNoteRelatedById', '\CreditNote\Model\CreditNoteQuery');
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\OrderCreditNote object
+ *
+ * @param \CreditNote\Model\OrderCreditNote|ObjectCollection $orderCreditNote the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByOrderCreditNote($orderCreditNote, $comparison = null)
+ {
+ if ($orderCreditNote instanceof \CreditNote\Model\OrderCreditNote) {
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::ID, $orderCreditNote->getCreditNoteId(), $comparison);
+ } elseif ($orderCreditNote instanceof ObjectCollection) {
+ return $this
+ ->useOrderCreditNoteQuery()
+ ->filterByPrimaryKeys($orderCreditNote->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrderCreditNote() only accepts arguments of type \CreditNote\Model\OrderCreditNote or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderCreditNote relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function joinOrderCreditNote($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderCreditNote');
+
+ // 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, 'OrderCreditNote');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderCreditNote relation OrderCreditNote 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 \CreditNote\Model\OrderCreditNoteQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderCreditNoteQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrderCreditNote($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderCreditNote', '\CreditNote\Model\OrderCreditNoteQuery');
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CartCreditNote object
+ *
+ * @param \CreditNote\Model\CartCreditNote|ObjectCollection $cartCreditNote the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCartCreditNote($cartCreditNote, $comparison = null)
+ {
+ if ($cartCreditNote instanceof \CreditNote\Model\CartCreditNote) {
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::ID, $cartCreditNote->getCreditNoteId(), $comparison);
+ } elseif ($cartCreditNote instanceof ObjectCollection) {
+ return $this
+ ->useCartCreditNoteQuery()
+ ->filterByPrimaryKeys($cartCreditNote->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCartCreditNote() only accepts arguments of type \CreditNote\Model\CartCreditNote or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CartCreditNote relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function joinCartCreditNote($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CartCreditNote');
+
+ // 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, 'CartCreditNote');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CartCreditNote relation CartCreditNote 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 \CreditNote\Model\CartCreditNoteQuery A secondary query class using the current class as primary query
+ */
+ public function useCartCreditNoteQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCartCreditNote($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CartCreditNote', '\CreditNote\Model\CartCreditNoteQuery');
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNoteDetail object
+ *
+ * @param \CreditNote\Model\CreditNoteDetail|ObjectCollection $creditNoteDetail the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteDetail($creditNoteDetail, $comparison = null)
+ {
+ if ($creditNoteDetail instanceof \CreditNote\Model\CreditNoteDetail) {
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::ID, $creditNoteDetail->getCreditNoteId(), $comparison);
+ } elseif ($creditNoteDetail instanceof ObjectCollection) {
+ return $this
+ ->useCreditNoteDetailQuery()
+ ->filterByPrimaryKeys($creditNoteDetail->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCreditNoteDetail() only accepts arguments of type \CreditNote\Model\CreditNoteDetail or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNoteDetail relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function joinCreditNoteDetail($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNoteDetail');
+
+ // 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, 'CreditNoteDetail');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNoteDetail relation CreditNoteDetail 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 \CreditNote\Model\CreditNoteDetailQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteDetailQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCreditNoteDetail($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNoteDetail', '\CreditNote\Model\CreditNoteDetailQuery');
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNoteComment object
+ *
+ * @param \CreditNote\Model\CreditNoteComment|ObjectCollection $creditNoteComment the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteComment($creditNoteComment, $comparison = null)
+ {
+ if ($creditNoteComment instanceof \CreditNote\Model\CreditNoteComment) {
+ return $this
+ ->addUsingAlias(CreditNoteTableMap::ID, $creditNoteComment->getCreditNoteId(), $comparison);
+ } elseif ($creditNoteComment instanceof ObjectCollection) {
+ return $this
+ ->useCreditNoteCommentQuery()
+ ->filterByPrimaryKeys($creditNoteComment->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCreditNoteComment() only accepts arguments of type \CreditNote\Model\CreditNoteComment or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNoteComment relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function joinCreditNoteComment($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNoteComment');
+
+ // 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, 'CreditNoteComment');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNoteComment relation CreditNoteComment 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 \CreditNote\Model\CreditNoteCommentQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteCommentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCreditNoteComment($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNoteComment', '\CreditNote\Model\CreditNoteCommentQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCreditNote $creditNote Object to remove from the list of results
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function prune($creditNote = null)
+ {
+ if ($creditNote) {
+ $this->addUsingAlias(CreditNoteTableMap::ID, $creditNote->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the credit_note table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTableMap::DATABASE_NAME);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CreditNoteTableMap::clearInstancePool();
+ CreditNoteTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCreditNote or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCreditNote object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CreditNoteTableMap::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+
+ CreditNoteTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CreditNoteTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CreditNoteTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CreditNoteTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CreditNoteTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CreditNoteTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CreditNoteTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildCreditNoteQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CreditNoteTableMap::CREATED_AT);
+ }
+
+} // CreditNoteQuery
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteStatus.php b/local/modules/CreditNote/Model/Base/CreditNoteStatus.php
new file mode 100644
index 000000000..8f9110e9c
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteStatus.php
@@ -0,0 +1,3020 @@
+invoiced = false;
+ $this->used = false;
+ }
+
+ /**
+ * Initializes internal state of CreditNote\Model\Base\CreditNoteStatus object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !!$this->modifiedColumns;
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return boolean true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ if (isset($this->modifiedColumns[$col])) {
+ unset($this->modifiedColumns[$col]);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another CreditNoteStatus instance. If
+ * obj is an instance of CreditNoteStatus, delegates to
+ * equals(CreditNoteStatus). Otherwise, returns false.
+ *
+ * @param mixed $obj The object to compare to.
+ * @return boolean Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return array_key_exists($name, $this->virtualColumns);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return mixed
+ *
+ * @throws PropelException
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return CreditNoteStatus The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return CreditNoteStatus The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+
+ return $this;
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+
+ return $this->code;
+ }
+
+ /**
+ * Get the [color] column value.
+ *
+ * @return string
+ */
+ public function getColor()
+ {
+
+ return $this->color;
+ }
+
+ /**
+ * Get the [invoiced] column value.
+ *
+ * @return boolean
+ */
+ public function getInvoiced()
+ {
+
+ return $this->invoiced;
+ }
+
+ /**
+ * Get the [used] column value.
+ *
+ * @return boolean
+ */
+ public function getUsed()
+ {
+
+ return $this->used;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteStatus The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[CreditNoteStatusTableMap::ID] = true;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteStatus The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[CreditNoteStatusTableMap::CODE] = true;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Set the value of [color] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteStatus The current object (for fluent API support)
+ */
+ public function setColor($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->color !== $v) {
+ $this->color = $v;
+ $this->modifiedColumns[CreditNoteStatusTableMap::COLOR] = true;
+ }
+
+
+ return $this;
+ } // setColor()
+
+ /**
+ * Sets the value of the [invoiced] column.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ *
+ * @param boolean|integer|string $v The new value
+ * @return \CreditNote\Model\CreditNoteStatus The current object (for fluent API support)
+ */
+ public function setInvoiced($v)
+ {
+ if ($v !== null) {
+ if (is_string($v)) {
+ $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ } else {
+ $v = (boolean) $v;
+ }
+ }
+
+ if ($this->invoiced !== $v) {
+ $this->invoiced = $v;
+ $this->modifiedColumns[CreditNoteStatusTableMap::INVOICED] = true;
+ }
+
+
+ return $this;
+ } // setInvoiced()
+
+ /**
+ * Sets the value of the [used] column.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ *
+ * @param boolean|integer|string $v The new value
+ * @return \CreditNote\Model\CreditNoteStatus The current object (for fluent API support)
+ */
+ public function setUsed($v)
+ {
+ if ($v !== null) {
+ if (is_string($v)) {
+ $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ } else {
+ $v = (boolean) $v;
+ }
+ }
+
+ if ($this->used !== $v) {
+ $this->used = $v;
+ $this->modifiedColumns[CreditNoteStatusTableMap::USED] = true;
+ }
+
+
+ return $this;
+ } // setUsed()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteStatus The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[CreditNoteStatusTableMap::POSITION] = true;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNoteStatus The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[CreditNoteStatusTableMap::CREATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNoteStatus The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[CreditNoteStatusTableMap::UPDATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->invoiced !== false) {
+ return false;
+ }
+
+ if ($this->used !== false) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CreditNoteStatusTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CreditNoteStatusTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->code = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CreditNoteStatusTableMap::translateFieldName('Color', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->color = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CreditNoteStatusTableMap::translateFieldName('Invoiced', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->invoiced = (null !== $col) ? (boolean) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CreditNoteStatusTableMap::translateFieldName('Used', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->used = (null !== $col) ? (boolean) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CreditNoteStatusTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CreditNoteStatusTableMap::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 : CreditNoteStatusTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = CreditNoteStatusTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \CreditNote\Model\CreditNoteStatus object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteStatusTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCreditNoteStatusQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collCreditNotes = null;
+
+ $this->collCreditNoteStatusFlowsRelatedByFromStatusId = null;
+
+ $this->collCreditNoteStatusFlowsRelatedByToStatusId = null;
+
+ $this->collCreditNoteStatusI18ns = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see CreditNoteStatus::setDeleted()
+ * @see CreditNoteStatus::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCreditNoteStatusQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see doSave()
+ */
+ public function save(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(CreditNoteStatusTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(CreditNoteStatusTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(CreditNoteStatusTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CreditNoteStatusTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->creditNotesScheduledForDeletion !== null) {
+ if (!$this->creditNotesScheduledForDeletion->isEmpty()) {
+ \CreditNote\Model\CreditNoteQuery::create()
+ ->filterByPrimaryKeys($this->creditNotesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->creditNotesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCreditNotes !== null) {
+ foreach ($this->collCreditNotes as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->creditNoteStatusFlowsRelatedByFromStatusIdScheduledForDeletion !== null) {
+ if (!$this->creditNoteStatusFlowsRelatedByFromStatusIdScheduledForDeletion->isEmpty()) {
+ \CreditNote\Model\CreditNoteStatusFlowQuery::create()
+ ->filterByPrimaryKeys($this->creditNoteStatusFlowsRelatedByFromStatusIdScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->creditNoteStatusFlowsRelatedByFromStatusIdScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCreditNoteStatusFlowsRelatedByFromStatusId !== null) {
+ foreach ($this->collCreditNoteStatusFlowsRelatedByFromStatusId as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->creditNoteStatusFlowsRelatedByToStatusIdScheduledForDeletion !== null) {
+ if (!$this->creditNoteStatusFlowsRelatedByToStatusIdScheduledForDeletion->isEmpty()) {
+ \CreditNote\Model\CreditNoteStatusFlowQuery::create()
+ ->filterByPrimaryKeys($this->creditNoteStatusFlowsRelatedByToStatusIdScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->creditNoteStatusFlowsRelatedByToStatusIdScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCreditNoteStatusFlowsRelatedByToStatusId !== null) {
+ foreach ($this->collCreditNoteStatusFlowsRelatedByToStatusId as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->creditNoteStatusI18nsScheduledForDeletion !== null) {
+ if (!$this->creditNoteStatusI18nsScheduledForDeletion->isEmpty()) {
+ \CreditNote\Model\CreditNoteStatusI18nQuery::create()
+ ->filterByPrimaryKeys($this->creditNoteStatusI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->creditNoteStatusI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCreditNoteStatusI18ns !== null) {
+ foreach ($this->collCreditNoteStatusI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[CreditNoteStatusTableMap::ID] = true;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CreditNoteStatusTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CreditNoteStatusTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CreditNoteStatusTableMap::CODE)) {
+ $modifiedColumns[':p' . $index++] = 'CODE';
+ }
+ if ($this->isColumnModified(CreditNoteStatusTableMap::COLOR)) {
+ $modifiedColumns[':p' . $index++] = 'COLOR';
+ }
+ if ($this->isColumnModified(CreditNoteStatusTableMap::INVOICED)) {
+ $modifiedColumns[':p' . $index++] = 'INVOICED';
+ }
+ if ($this->isColumnModified(CreditNoteStatusTableMap::USED)) {
+ $modifiedColumns[':p' . $index++] = 'USED';
+ }
+ if ($this->isColumnModified(CreditNoteStatusTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(CreditNoteStatusTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CreditNoteStatusTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO credit_note_status (%s) VALUES (%s)',
+ 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 'CODE':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case 'COLOR':
+ $stmt->bindValue($identifier, $this->color, PDO::PARAM_STR);
+ break;
+ case 'INVOICED':
+ $stmt->bindValue($identifier, (int) $this->invoiced, PDO::PARAM_INT);
+ break;
+ case 'USED':
+ $stmt->bindValue($identifier, (int) $this->used, PDO::PARAM_INT);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, 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);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteStatusTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCode();
+ break;
+ case 2:
+ return $this->getColor();
+ break;
+ case 3:
+ return $this->getInvoiced();
+ break;
+ case 4:
+ return $this->getUsed();
+ break;
+ case 5:
+ return $this->getPosition();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CreditNoteStatus'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CreditNoteStatus'][$this->getPrimaryKey()] = true;
+ $keys = CreditNoteStatusTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCode(),
+ $keys[2] => $this->getColor(),
+ $keys[3] => $this->getInvoiced(),
+ $keys[4] => $this->getUsed(),
+ $keys[5] => $this->getPosition(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach ($virtualColumns as $key => $virtualColumn) {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collCreditNotes) {
+ $result['CreditNotes'] = $this->collCreditNotes->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collCreditNoteStatusFlowsRelatedByFromStatusId) {
+ $result['CreditNoteStatusFlowsRelatedByFromStatusId'] = $this->collCreditNoteStatusFlowsRelatedByFromStatusId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collCreditNoteStatusFlowsRelatedByToStatusId) {
+ $result['CreditNoteStatusFlowsRelatedByToStatusId'] = $this->collCreditNoteStatusFlowsRelatedByToStatusId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collCreditNoteStatusI18ns) {
+ $result['CreditNoteStatusI18ns'] = $this->collCreditNoteStatusI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteStatusTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+
+ return $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCode($value);
+ break;
+ case 2:
+ $this->setColor($value);
+ break;
+ case 3:
+ $this->setInvoiced($value);
+ break;
+ case 4:
+ $this->setUsed($value);
+ break;
+ case 5:
+ $this->setPosition($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CreditNoteStatusTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setColor($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setInvoiced($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUsed($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPosition($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]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CreditNoteStatusTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CreditNoteStatusTableMap::ID)) $criteria->add(CreditNoteStatusTableMap::ID, $this->id);
+ if ($this->isColumnModified(CreditNoteStatusTableMap::CODE)) $criteria->add(CreditNoteStatusTableMap::CODE, $this->code);
+ if ($this->isColumnModified(CreditNoteStatusTableMap::COLOR)) $criteria->add(CreditNoteStatusTableMap::COLOR, $this->color);
+ if ($this->isColumnModified(CreditNoteStatusTableMap::INVOICED)) $criteria->add(CreditNoteStatusTableMap::INVOICED, $this->invoiced);
+ if ($this->isColumnModified(CreditNoteStatusTableMap::USED)) $criteria->add(CreditNoteStatusTableMap::USED, $this->used);
+ if ($this->isColumnModified(CreditNoteStatusTableMap::POSITION)) $criteria->add(CreditNoteStatusTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(CreditNoteStatusTableMap::CREATED_AT)) $criteria->add(CreditNoteStatusTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CreditNoteStatusTableMap::UPDATED_AT)) $criteria->add(CreditNoteStatusTableMap::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CreditNoteStatusTableMap::DATABASE_NAME);
+ $criteria->add(CreditNoteStatusTableMap::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of \CreditNote\Model\CreditNoteStatus (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCode($this->getCode());
+ $copyObj->setColor($this->getColor());
+ $copyObj->setInvoiced($this->getInvoiced());
+ $copyObj->setUsed($this->getUsed());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+
+ foreach ($this->getCreditNotes() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCreditNote($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getCreditNoteStatusFlowsRelatedByFromStatusId() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCreditNoteStatusFlowRelatedByFromStatusId($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getCreditNoteStatusFlowsRelatedByToStatusId() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCreditNoteStatusFlowRelatedByToStatusId($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getCreditNoteStatusI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCreditNoteStatusI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return \CreditNote\Model\CreditNoteStatus Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('CreditNote' == $relationName) {
+ return $this->initCreditNotes();
+ }
+ if ('CreditNoteStatusFlowRelatedByFromStatusId' == $relationName) {
+ return $this->initCreditNoteStatusFlowsRelatedByFromStatusId();
+ }
+ if ('CreditNoteStatusFlowRelatedByToStatusId' == $relationName) {
+ return $this->initCreditNoteStatusFlowsRelatedByToStatusId();
+ }
+ if ('CreditNoteStatusI18n' == $relationName) {
+ return $this->initCreditNoteStatusI18ns();
+ }
+ }
+
+ /**
+ * Clears out the collCreditNotes collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCreditNotes()
+ */
+ public function clearCreditNotes()
+ {
+ $this->collCreditNotes = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCreditNotes collection loaded partially.
+ */
+ public function resetPartialCreditNotes($v = true)
+ {
+ $this->collCreditNotesPartial = $v;
+ }
+
+ /**
+ * Initializes the collCreditNotes collection.
+ *
+ * By default this just sets the collCreditNotes collection to an empty array (like clearcollCreditNotes());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCreditNotes($overrideExisting = true)
+ {
+ if (null !== $this->collCreditNotes && !$overrideExisting) {
+ return;
+ }
+ $this->collCreditNotes = new ObjectCollection();
+ $this->collCreditNotes->setModel('\CreditNote\Model\CreditNote');
+ }
+
+ /**
+ * Gets an array of ChildCreditNote objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCreditNoteStatus is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ * @throws PropelException
+ */
+ public function getCreditNotes($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNotesPartial && !$this->isNew();
+ if (null === $this->collCreditNotes || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNotes) {
+ // return empty collection
+ $this->initCreditNotes();
+ } else {
+ $collCreditNotes = ChildCreditNoteQuery::create(null, $criteria)
+ ->filterByCreditNoteStatus($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCreditNotesPartial && count($collCreditNotes)) {
+ $this->initCreditNotes(false);
+
+ foreach ($collCreditNotes as $obj) {
+ if (false == $this->collCreditNotes->contains($obj)) {
+ $this->collCreditNotes->append($obj);
+ }
+ }
+
+ $this->collCreditNotesPartial = true;
+ }
+
+ reset($collCreditNotes);
+
+ return $collCreditNotes;
+ }
+
+ if ($partial && $this->collCreditNotes) {
+ foreach ($this->collCreditNotes as $obj) {
+ if ($obj->isNew()) {
+ $collCreditNotes[] = $obj;
+ }
+ }
+ }
+
+ $this->collCreditNotes = $collCreditNotes;
+ $this->collCreditNotesPartial = false;
+ }
+ }
+
+ return $this->collCreditNotes;
+ }
+
+ /**
+ * Sets a collection of CreditNote objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $creditNotes A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCreditNoteStatus The current object (for fluent API support)
+ */
+ public function setCreditNotes(Collection $creditNotes, ConnectionInterface $con = null)
+ {
+ $creditNotesToDelete = $this->getCreditNotes(new Criteria(), $con)->diff($creditNotes);
+
+
+ $this->creditNotesScheduledForDeletion = $creditNotesToDelete;
+
+ foreach ($creditNotesToDelete as $creditNoteRemoved) {
+ $creditNoteRemoved->setCreditNoteStatus(null);
+ }
+
+ $this->collCreditNotes = null;
+ foreach ($creditNotes as $creditNote) {
+ $this->addCreditNote($creditNote);
+ }
+
+ $this->collCreditNotes = $creditNotes;
+ $this->collCreditNotesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CreditNote objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related CreditNote objects.
+ * @throws PropelException
+ */
+ public function countCreditNotes(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNotesPartial && !$this->isNew();
+ if (null === $this->collCreditNotes || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNotes) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCreditNotes());
+ }
+
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCreditNoteStatus($this)
+ ->count($con);
+ }
+
+ return count($this->collCreditNotes);
+ }
+
+ /**
+ * Method called to associate a ChildCreditNote object to this object
+ * through the ChildCreditNote foreign key attribute.
+ *
+ * @param ChildCreditNote $l ChildCreditNote
+ * @return \CreditNote\Model\CreditNoteStatus The current object (for fluent API support)
+ */
+ public function addCreditNote(ChildCreditNote $l)
+ {
+ if ($this->collCreditNotes === null) {
+ $this->initCreditNotes();
+ $this->collCreditNotesPartial = true;
+ }
+
+ if (!in_array($l, $this->collCreditNotes->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCreditNote($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CreditNote $creditNote The creditNote object to add.
+ */
+ protected function doAddCreditNote($creditNote)
+ {
+ $this->collCreditNotes[]= $creditNote;
+ $creditNote->setCreditNoteStatus($this);
+ }
+
+ /**
+ * @param CreditNote $creditNote The creditNote object to remove.
+ * @return ChildCreditNoteStatus The current object (for fluent API support)
+ */
+ public function removeCreditNote($creditNote)
+ {
+ if ($this->getCreditNotes()->contains($creditNote)) {
+ $this->collCreditNotes->remove($this->collCreditNotes->search($creditNote));
+ if (null === $this->creditNotesScheduledForDeletion) {
+ $this->creditNotesScheduledForDeletion = clone $this->collCreditNotes;
+ $this->creditNotesScheduledForDeletion->clear();
+ }
+ $this->creditNotesScheduledForDeletion[]= clone $creditNote;
+ $creditNote->setCreditNoteStatus(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNoteStatus is new, it will return
+ * an empty collection; or if this CreditNoteStatus has previously
+ * been saved, it will retrieve related CreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNoteStatus.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesJoinOrder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('Order', $joinBehavior);
+
+ return $this->getCreditNotes($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNoteStatus is new, it will return
+ * an empty collection; or if this CreditNoteStatus has previously
+ * been saved, it will retrieve related CreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNoteStatus.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('Customer', $joinBehavior);
+
+ return $this->getCreditNotes($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNoteStatus is new, it will return
+ * an empty collection; or if this CreditNoteStatus has previously
+ * been saved, it will retrieve related CreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNoteStatus.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesJoinCreditNoteRelatedByParentId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('CreditNoteRelatedByParentId', $joinBehavior);
+
+ return $this->getCreditNotes($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNoteStatus is new, it will return
+ * an empty collection; or if this CreditNoteStatus has previously
+ * been saved, it will retrieve related CreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNoteStatus.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesJoinCreditNoteType($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('CreditNoteType', $joinBehavior);
+
+ return $this->getCreditNotes($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNoteStatus is new, it will return
+ * an empty collection; or if this CreditNoteStatus has previously
+ * been saved, it will retrieve related CreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNoteStatus.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('Currency', $joinBehavior);
+
+ return $this->getCreditNotes($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNoteStatus is new, it will return
+ * an empty collection; or if this CreditNoteStatus has previously
+ * been saved, it will retrieve related CreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNoteStatus.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesJoinCreditNoteAddress($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('CreditNoteAddress', $joinBehavior);
+
+ return $this->getCreditNotes($query, $con);
+ }
+
+ /**
+ * Clears out the collCreditNoteStatusFlowsRelatedByFromStatusId collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCreditNoteStatusFlowsRelatedByFromStatusId()
+ */
+ public function clearCreditNoteStatusFlowsRelatedByFromStatusId()
+ {
+ $this->collCreditNoteStatusFlowsRelatedByFromStatusId = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCreditNoteStatusFlowsRelatedByFromStatusId collection loaded partially.
+ */
+ public function resetPartialCreditNoteStatusFlowsRelatedByFromStatusId($v = true)
+ {
+ $this->collCreditNoteStatusFlowsRelatedByFromStatusIdPartial = $v;
+ }
+
+ /**
+ * Initializes the collCreditNoteStatusFlowsRelatedByFromStatusId collection.
+ *
+ * By default this just sets the collCreditNoteStatusFlowsRelatedByFromStatusId collection to an empty array (like clearcollCreditNoteStatusFlowsRelatedByFromStatusId());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCreditNoteStatusFlowsRelatedByFromStatusId($overrideExisting = true)
+ {
+ if (null !== $this->collCreditNoteStatusFlowsRelatedByFromStatusId && !$overrideExisting) {
+ return;
+ }
+ $this->collCreditNoteStatusFlowsRelatedByFromStatusId = new ObjectCollection();
+ $this->collCreditNoteStatusFlowsRelatedByFromStatusId->setModel('\CreditNote\Model\CreditNoteStatusFlow');
+ }
+
+ /**
+ * Gets an array of ChildCreditNoteStatusFlow objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCreditNoteStatus is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCreditNoteStatusFlow[] List of ChildCreditNoteStatusFlow objects
+ * @throws PropelException
+ */
+ public function getCreditNoteStatusFlowsRelatedByFromStatusId($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNoteStatusFlowsRelatedByFromStatusIdPartial && !$this->isNew();
+ if (null === $this->collCreditNoteStatusFlowsRelatedByFromStatusId || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNoteStatusFlowsRelatedByFromStatusId) {
+ // return empty collection
+ $this->initCreditNoteStatusFlowsRelatedByFromStatusId();
+ } else {
+ $collCreditNoteStatusFlowsRelatedByFromStatusId = ChildCreditNoteStatusFlowQuery::create(null, $criteria)
+ ->filterByCreditNoteStatusRelatedByFromStatusId($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCreditNoteStatusFlowsRelatedByFromStatusIdPartial && count($collCreditNoteStatusFlowsRelatedByFromStatusId)) {
+ $this->initCreditNoteStatusFlowsRelatedByFromStatusId(false);
+
+ foreach ($collCreditNoteStatusFlowsRelatedByFromStatusId as $obj) {
+ if (false == $this->collCreditNoteStatusFlowsRelatedByFromStatusId->contains($obj)) {
+ $this->collCreditNoteStatusFlowsRelatedByFromStatusId->append($obj);
+ }
+ }
+
+ $this->collCreditNoteStatusFlowsRelatedByFromStatusIdPartial = true;
+ }
+
+ reset($collCreditNoteStatusFlowsRelatedByFromStatusId);
+
+ return $collCreditNoteStatusFlowsRelatedByFromStatusId;
+ }
+
+ if ($partial && $this->collCreditNoteStatusFlowsRelatedByFromStatusId) {
+ foreach ($this->collCreditNoteStatusFlowsRelatedByFromStatusId as $obj) {
+ if ($obj->isNew()) {
+ $collCreditNoteStatusFlowsRelatedByFromStatusId[] = $obj;
+ }
+ }
+ }
+
+ $this->collCreditNoteStatusFlowsRelatedByFromStatusId = $collCreditNoteStatusFlowsRelatedByFromStatusId;
+ $this->collCreditNoteStatusFlowsRelatedByFromStatusIdPartial = false;
+ }
+ }
+
+ return $this->collCreditNoteStatusFlowsRelatedByFromStatusId;
+ }
+
+ /**
+ * Sets a collection of CreditNoteStatusFlowRelatedByFromStatusId objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $creditNoteStatusFlowsRelatedByFromStatusId A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCreditNoteStatus The current object (for fluent API support)
+ */
+ public function setCreditNoteStatusFlowsRelatedByFromStatusId(Collection $creditNoteStatusFlowsRelatedByFromStatusId, ConnectionInterface $con = null)
+ {
+ $creditNoteStatusFlowsRelatedByFromStatusIdToDelete = $this->getCreditNoteStatusFlowsRelatedByFromStatusId(new Criteria(), $con)->diff($creditNoteStatusFlowsRelatedByFromStatusId);
+
+
+ $this->creditNoteStatusFlowsRelatedByFromStatusIdScheduledForDeletion = $creditNoteStatusFlowsRelatedByFromStatusIdToDelete;
+
+ foreach ($creditNoteStatusFlowsRelatedByFromStatusIdToDelete as $creditNoteStatusFlowRelatedByFromStatusIdRemoved) {
+ $creditNoteStatusFlowRelatedByFromStatusIdRemoved->setCreditNoteStatusRelatedByFromStatusId(null);
+ }
+
+ $this->collCreditNoteStatusFlowsRelatedByFromStatusId = null;
+ foreach ($creditNoteStatusFlowsRelatedByFromStatusId as $creditNoteStatusFlowRelatedByFromStatusId) {
+ $this->addCreditNoteStatusFlowRelatedByFromStatusId($creditNoteStatusFlowRelatedByFromStatusId);
+ }
+
+ $this->collCreditNoteStatusFlowsRelatedByFromStatusId = $creditNoteStatusFlowsRelatedByFromStatusId;
+ $this->collCreditNoteStatusFlowsRelatedByFromStatusIdPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CreditNoteStatusFlow objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related CreditNoteStatusFlow objects.
+ * @throws PropelException
+ */
+ public function countCreditNoteStatusFlowsRelatedByFromStatusId(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNoteStatusFlowsRelatedByFromStatusIdPartial && !$this->isNew();
+ if (null === $this->collCreditNoteStatusFlowsRelatedByFromStatusId || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNoteStatusFlowsRelatedByFromStatusId) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCreditNoteStatusFlowsRelatedByFromStatusId());
+ }
+
+ $query = ChildCreditNoteStatusFlowQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCreditNoteStatusRelatedByFromStatusId($this)
+ ->count($con);
+ }
+
+ return count($this->collCreditNoteStatusFlowsRelatedByFromStatusId);
+ }
+
+ /**
+ * Method called to associate a ChildCreditNoteStatusFlow object to this object
+ * through the ChildCreditNoteStatusFlow foreign key attribute.
+ *
+ * @param ChildCreditNoteStatusFlow $l ChildCreditNoteStatusFlow
+ * @return \CreditNote\Model\CreditNoteStatus The current object (for fluent API support)
+ */
+ public function addCreditNoteStatusFlowRelatedByFromStatusId(ChildCreditNoteStatusFlow $l)
+ {
+ if ($this->collCreditNoteStatusFlowsRelatedByFromStatusId === null) {
+ $this->initCreditNoteStatusFlowsRelatedByFromStatusId();
+ $this->collCreditNoteStatusFlowsRelatedByFromStatusIdPartial = true;
+ }
+
+ if (!in_array($l, $this->collCreditNoteStatusFlowsRelatedByFromStatusId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCreditNoteStatusFlowRelatedByFromStatusId($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CreditNoteStatusFlowRelatedByFromStatusId $creditNoteStatusFlowRelatedByFromStatusId The creditNoteStatusFlowRelatedByFromStatusId object to add.
+ */
+ protected function doAddCreditNoteStatusFlowRelatedByFromStatusId($creditNoteStatusFlowRelatedByFromStatusId)
+ {
+ $this->collCreditNoteStatusFlowsRelatedByFromStatusId[]= $creditNoteStatusFlowRelatedByFromStatusId;
+ $creditNoteStatusFlowRelatedByFromStatusId->setCreditNoteStatusRelatedByFromStatusId($this);
+ }
+
+ /**
+ * @param CreditNoteStatusFlowRelatedByFromStatusId $creditNoteStatusFlowRelatedByFromStatusId The creditNoteStatusFlowRelatedByFromStatusId object to remove.
+ * @return ChildCreditNoteStatus The current object (for fluent API support)
+ */
+ public function removeCreditNoteStatusFlowRelatedByFromStatusId($creditNoteStatusFlowRelatedByFromStatusId)
+ {
+ if ($this->getCreditNoteStatusFlowsRelatedByFromStatusId()->contains($creditNoteStatusFlowRelatedByFromStatusId)) {
+ $this->collCreditNoteStatusFlowsRelatedByFromStatusId->remove($this->collCreditNoteStatusFlowsRelatedByFromStatusId->search($creditNoteStatusFlowRelatedByFromStatusId));
+ if (null === $this->creditNoteStatusFlowsRelatedByFromStatusIdScheduledForDeletion) {
+ $this->creditNoteStatusFlowsRelatedByFromStatusIdScheduledForDeletion = clone $this->collCreditNoteStatusFlowsRelatedByFromStatusId;
+ $this->creditNoteStatusFlowsRelatedByFromStatusIdScheduledForDeletion->clear();
+ }
+ $this->creditNoteStatusFlowsRelatedByFromStatusIdScheduledForDeletion[]= clone $creditNoteStatusFlowRelatedByFromStatusId;
+ $creditNoteStatusFlowRelatedByFromStatusId->setCreditNoteStatusRelatedByFromStatusId(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collCreditNoteStatusFlowsRelatedByToStatusId collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCreditNoteStatusFlowsRelatedByToStatusId()
+ */
+ public function clearCreditNoteStatusFlowsRelatedByToStatusId()
+ {
+ $this->collCreditNoteStatusFlowsRelatedByToStatusId = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCreditNoteStatusFlowsRelatedByToStatusId collection loaded partially.
+ */
+ public function resetPartialCreditNoteStatusFlowsRelatedByToStatusId($v = true)
+ {
+ $this->collCreditNoteStatusFlowsRelatedByToStatusIdPartial = $v;
+ }
+
+ /**
+ * Initializes the collCreditNoteStatusFlowsRelatedByToStatusId collection.
+ *
+ * By default this just sets the collCreditNoteStatusFlowsRelatedByToStatusId collection to an empty array (like clearcollCreditNoteStatusFlowsRelatedByToStatusId());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCreditNoteStatusFlowsRelatedByToStatusId($overrideExisting = true)
+ {
+ if (null !== $this->collCreditNoteStatusFlowsRelatedByToStatusId && !$overrideExisting) {
+ return;
+ }
+ $this->collCreditNoteStatusFlowsRelatedByToStatusId = new ObjectCollection();
+ $this->collCreditNoteStatusFlowsRelatedByToStatusId->setModel('\CreditNote\Model\CreditNoteStatusFlow');
+ }
+
+ /**
+ * Gets an array of ChildCreditNoteStatusFlow objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCreditNoteStatus is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCreditNoteStatusFlow[] List of ChildCreditNoteStatusFlow objects
+ * @throws PropelException
+ */
+ public function getCreditNoteStatusFlowsRelatedByToStatusId($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNoteStatusFlowsRelatedByToStatusIdPartial && !$this->isNew();
+ if (null === $this->collCreditNoteStatusFlowsRelatedByToStatusId || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNoteStatusFlowsRelatedByToStatusId) {
+ // return empty collection
+ $this->initCreditNoteStatusFlowsRelatedByToStatusId();
+ } else {
+ $collCreditNoteStatusFlowsRelatedByToStatusId = ChildCreditNoteStatusFlowQuery::create(null, $criteria)
+ ->filterByCreditNoteStatusRelatedByToStatusId($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCreditNoteStatusFlowsRelatedByToStatusIdPartial && count($collCreditNoteStatusFlowsRelatedByToStatusId)) {
+ $this->initCreditNoteStatusFlowsRelatedByToStatusId(false);
+
+ foreach ($collCreditNoteStatusFlowsRelatedByToStatusId as $obj) {
+ if (false == $this->collCreditNoteStatusFlowsRelatedByToStatusId->contains($obj)) {
+ $this->collCreditNoteStatusFlowsRelatedByToStatusId->append($obj);
+ }
+ }
+
+ $this->collCreditNoteStatusFlowsRelatedByToStatusIdPartial = true;
+ }
+
+ reset($collCreditNoteStatusFlowsRelatedByToStatusId);
+
+ return $collCreditNoteStatusFlowsRelatedByToStatusId;
+ }
+
+ if ($partial && $this->collCreditNoteStatusFlowsRelatedByToStatusId) {
+ foreach ($this->collCreditNoteStatusFlowsRelatedByToStatusId as $obj) {
+ if ($obj->isNew()) {
+ $collCreditNoteStatusFlowsRelatedByToStatusId[] = $obj;
+ }
+ }
+ }
+
+ $this->collCreditNoteStatusFlowsRelatedByToStatusId = $collCreditNoteStatusFlowsRelatedByToStatusId;
+ $this->collCreditNoteStatusFlowsRelatedByToStatusIdPartial = false;
+ }
+ }
+
+ return $this->collCreditNoteStatusFlowsRelatedByToStatusId;
+ }
+
+ /**
+ * Sets a collection of CreditNoteStatusFlowRelatedByToStatusId objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $creditNoteStatusFlowsRelatedByToStatusId A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCreditNoteStatus The current object (for fluent API support)
+ */
+ public function setCreditNoteStatusFlowsRelatedByToStatusId(Collection $creditNoteStatusFlowsRelatedByToStatusId, ConnectionInterface $con = null)
+ {
+ $creditNoteStatusFlowsRelatedByToStatusIdToDelete = $this->getCreditNoteStatusFlowsRelatedByToStatusId(new Criteria(), $con)->diff($creditNoteStatusFlowsRelatedByToStatusId);
+
+
+ $this->creditNoteStatusFlowsRelatedByToStatusIdScheduledForDeletion = $creditNoteStatusFlowsRelatedByToStatusIdToDelete;
+
+ foreach ($creditNoteStatusFlowsRelatedByToStatusIdToDelete as $creditNoteStatusFlowRelatedByToStatusIdRemoved) {
+ $creditNoteStatusFlowRelatedByToStatusIdRemoved->setCreditNoteStatusRelatedByToStatusId(null);
+ }
+
+ $this->collCreditNoteStatusFlowsRelatedByToStatusId = null;
+ foreach ($creditNoteStatusFlowsRelatedByToStatusId as $creditNoteStatusFlowRelatedByToStatusId) {
+ $this->addCreditNoteStatusFlowRelatedByToStatusId($creditNoteStatusFlowRelatedByToStatusId);
+ }
+
+ $this->collCreditNoteStatusFlowsRelatedByToStatusId = $creditNoteStatusFlowsRelatedByToStatusId;
+ $this->collCreditNoteStatusFlowsRelatedByToStatusIdPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CreditNoteStatusFlow objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related CreditNoteStatusFlow objects.
+ * @throws PropelException
+ */
+ public function countCreditNoteStatusFlowsRelatedByToStatusId(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNoteStatusFlowsRelatedByToStatusIdPartial && !$this->isNew();
+ if (null === $this->collCreditNoteStatusFlowsRelatedByToStatusId || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNoteStatusFlowsRelatedByToStatusId) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCreditNoteStatusFlowsRelatedByToStatusId());
+ }
+
+ $query = ChildCreditNoteStatusFlowQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCreditNoteStatusRelatedByToStatusId($this)
+ ->count($con);
+ }
+
+ return count($this->collCreditNoteStatusFlowsRelatedByToStatusId);
+ }
+
+ /**
+ * Method called to associate a ChildCreditNoteStatusFlow object to this object
+ * through the ChildCreditNoteStatusFlow foreign key attribute.
+ *
+ * @param ChildCreditNoteStatusFlow $l ChildCreditNoteStatusFlow
+ * @return \CreditNote\Model\CreditNoteStatus The current object (for fluent API support)
+ */
+ public function addCreditNoteStatusFlowRelatedByToStatusId(ChildCreditNoteStatusFlow $l)
+ {
+ if ($this->collCreditNoteStatusFlowsRelatedByToStatusId === null) {
+ $this->initCreditNoteStatusFlowsRelatedByToStatusId();
+ $this->collCreditNoteStatusFlowsRelatedByToStatusIdPartial = true;
+ }
+
+ if (!in_array($l, $this->collCreditNoteStatusFlowsRelatedByToStatusId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCreditNoteStatusFlowRelatedByToStatusId($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CreditNoteStatusFlowRelatedByToStatusId $creditNoteStatusFlowRelatedByToStatusId The creditNoteStatusFlowRelatedByToStatusId object to add.
+ */
+ protected function doAddCreditNoteStatusFlowRelatedByToStatusId($creditNoteStatusFlowRelatedByToStatusId)
+ {
+ $this->collCreditNoteStatusFlowsRelatedByToStatusId[]= $creditNoteStatusFlowRelatedByToStatusId;
+ $creditNoteStatusFlowRelatedByToStatusId->setCreditNoteStatusRelatedByToStatusId($this);
+ }
+
+ /**
+ * @param CreditNoteStatusFlowRelatedByToStatusId $creditNoteStatusFlowRelatedByToStatusId The creditNoteStatusFlowRelatedByToStatusId object to remove.
+ * @return ChildCreditNoteStatus The current object (for fluent API support)
+ */
+ public function removeCreditNoteStatusFlowRelatedByToStatusId($creditNoteStatusFlowRelatedByToStatusId)
+ {
+ if ($this->getCreditNoteStatusFlowsRelatedByToStatusId()->contains($creditNoteStatusFlowRelatedByToStatusId)) {
+ $this->collCreditNoteStatusFlowsRelatedByToStatusId->remove($this->collCreditNoteStatusFlowsRelatedByToStatusId->search($creditNoteStatusFlowRelatedByToStatusId));
+ if (null === $this->creditNoteStatusFlowsRelatedByToStatusIdScheduledForDeletion) {
+ $this->creditNoteStatusFlowsRelatedByToStatusIdScheduledForDeletion = clone $this->collCreditNoteStatusFlowsRelatedByToStatusId;
+ $this->creditNoteStatusFlowsRelatedByToStatusIdScheduledForDeletion->clear();
+ }
+ $this->creditNoteStatusFlowsRelatedByToStatusIdScheduledForDeletion[]= clone $creditNoteStatusFlowRelatedByToStatusId;
+ $creditNoteStatusFlowRelatedByToStatusId->setCreditNoteStatusRelatedByToStatusId(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collCreditNoteStatusI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCreditNoteStatusI18ns()
+ */
+ public function clearCreditNoteStatusI18ns()
+ {
+ $this->collCreditNoteStatusI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCreditNoteStatusI18ns collection loaded partially.
+ */
+ public function resetPartialCreditNoteStatusI18ns($v = true)
+ {
+ $this->collCreditNoteStatusI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collCreditNoteStatusI18ns collection.
+ *
+ * By default this just sets the collCreditNoteStatusI18ns collection to an empty array (like clearcollCreditNoteStatusI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCreditNoteStatusI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collCreditNoteStatusI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collCreditNoteStatusI18ns = new ObjectCollection();
+ $this->collCreditNoteStatusI18ns->setModel('\CreditNote\Model\CreditNoteStatusI18n');
+ }
+
+ /**
+ * Gets an array of ChildCreditNoteStatusI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCreditNoteStatus is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCreditNoteStatusI18n[] List of ChildCreditNoteStatusI18n objects
+ * @throws PropelException
+ */
+ public function getCreditNoteStatusI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNoteStatusI18nsPartial && !$this->isNew();
+ if (null === $this->collCreditNoteStatusI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNoteStatusI18ns) {
+ // return empty collection
+ $this->initCreditNoteStatusI18ns();
+ } else {
+ $collCreditNoteStatusI18ns = ChildCreditNoteStatusI18nQuery::create(null, $criteria)
+ ->filterByCreditNoteStatus($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCreditNoteStatusI18nsPartial && count($collCreditNoteStatusI18ns)) {
+ $this->initCreditNoteStatusI18ns(false);
+
+ foreach ($collCreditNoteStatusI18ns as $obj) {
+ if (false == $this->collCreditNoteStatusI18ns->contains($obj)) {
+ $this->collCreditNoteStatusI18ns->append($obj);
+ }
+ }
+
+ $this->collCreditNoteStatusI18nsPartial = true;
+ }
+
+ reset($collCreditNoteStatusI18ns);
+
+ return $collCreditNoteStatusI18ns;
+ }
+
+ if ($partial && $this->collCreditNoteStatusI18ns) {
+ foreach ($this->collCreditNoteStatusI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collCreditNoteStatusI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collCreditNoteStatusI18ns = $collCreditNoteStatusI18ns;
+ $this->collCreditNoteStatusI18nsPartial = false;
+ }
+ }
+
+ return $this->collCreditNoteStatusI18ns;
+ }
+
+ /**
+ * Sets a collection of CreditNoteStatusI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $creditNoteStatusI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCreditNoteStatus The current object (for fluent API support)
+ */
+ public function setCreditNoteStatusI18ns(Collection $creditNoteStatusI18ns, ConnectionInterface $con = null)
+ {
+ $creditNoteStatusI18nsToDelete = $this->getCreditNoteStatusI18ns(new Criteria(), $con)->diff($creditNoteStatusI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->creditNoteStatusI18nsScheduledForDeletion = clone $creditNoteStatusI18nsToDelete;
+
+ foreach ($creditNoteStatusI18nsToDelete as $creditNoteStatusI18nRemoved) {
+ $creditNoteStatusI18nRemoved->setCreditNoteStatus(null);
+ }
+
+ $this->collCreditNoteStatusI18ns = null;
+ foreach ($creditNoteStatusI18ns as $creditNoteStatusI18n) {
+ $this->addCreditNoteStatusI18n($creditNoteStatusI18n);
+ }
+
+ $this->collCreditNoteStatusI18ns = $creditNoteStatusI18ns;
+ $this->collCreditNoteStatusI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CreditNoteStatusI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related CreditNoteStatusI18n objects.
+ * @throws PropelException
+ */
+ public function countCreditNoteStatusI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNoteStatusI18nsPartial && !$this->isNew();
+ if (null === $this->collCreditNoteStatusI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNoteStatusI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCreditNoteStatusI18ns());
+ }
+
+ $query = ChildCreditNoteStatusI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCreditNoteStatus($this)
+ ->count($con);
+ }
+
+ return count($this->collCreditNoteStatusI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildCreditNoteStatusI18n object to this object
+ * through the ChildCreditNoteStatusI18n foreign key attribute.
+ *
+ * @param ChildCreditNoteStatusI18n $l ChildCreditNoteStatusI18n
+ * @return \CreditNote\Model\CreditNoteStatus The current object (for fluent API support)
+ */
+ public function addCreditNoteStatusI18n(ChildCreditNoteStatusI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collCreditNoteStatusI18ns === null) {
+ $this->initCreditNoteStatusI18ns();
+ $this->collCreditNoteStatusI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collCreditNoteStatusI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCreditNoteStatusI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CreditNoteStatusI18n $creditNoteStatusI18n The creditNoteStatusI18n object to add.
+ */
+ protected function doAddCreditNoteStatusI18n($creditNoteStatusI18n)
+ {
+ $this->collCreditNoteStatusI18ns[]= $creditNoteStatusI18n;
+ $creditNoteStatusI18n->setCreditNoteStatus($this);
+ }
+
+ /**
+ * @param CreditNoteStatusI18n $creditNoteStatusI18n The creditNoteStatusI18n object to remove.
+ * @return ChildCreditNoteStatus The current object (for fluent API support)
+ */
+ public function removeCreditNoteStatusI18n($creditNoteStatusI18n)
+ {
+ if ($this->getCreditNoteStatusI18ns()->contains($creditNoteStatusI18n)) {
+ $this->collCreditNoteStatusI18ns->remove($this->collCreditNoteStatusI18ns->search($creditNoteStatusI18n));
+ if (null === $this->creditNoteStatusI18nsScheduledForDeletion) {
+ $this->creditNoteStatusI18nsScheduledForDeletion = clone $this->collCreditNoteStatusI18ns;
+ $this->creditNoteStatusI18nsScheduledForDeletion->clear();
+ }
+ $this->creditNoteStatusI18nsScheduledForDeletion[]= clone $creditNoteStatusI18n;
+ $creditNoteStatusI18n->setCreditNoteStatus(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->code = null;
+ $this->color = null;
+ $this->invoiced = null;
+ $this->used = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collCreditNotes) {
+ foreach ($this->collCreditNotes as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collCreditNoteStatusFlowsRelatedByFromStatusId) {
+ foreach ($this->collCreditNoteStatusFlowsRelatedByFromStatusId as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collCreditNoteStatusFlowsRelatedByToStatusId) {
+ foreach ($this->collCreditNoteStatusFlowsRelatedByToStatusId as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collCreditNoteStatusI18ns) {
+ foreach ($this->collCreditNoteStatusI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_US';
+ $this->currentTranslations = null;
+
+ $this->collCreditNotes = null;
+ $this->collCreditNoteStatusFlowsRelatedByFromStatusId = null;
+ $this->collCreditNoteStatusFlowsRelatedByToStatusId = null;
+ $this->collCreditNoteStatusI18ns = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CreditNoteStatusTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildCreditNoteStatus The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_US')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCreditNoteStatusI18n */
+ public function getTranslation($locale = 'en_US', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collCreditNoteStatusI18ns) {
+ foreach ($this->collCreditNoteStatusI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildCreditNoteStatusI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildCreditNoteStatusI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addCreditNoteStatusI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCreditNoteStatus The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildCreditNoteStatusI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collCreditNoteStatusI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collCreditNoteStatusI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCreditNoteStatusI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteStatusI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteStatusI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->getCurrentTranslation()->getChapo();
+ }
+
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteStatusI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ { $this->getCurrentTranslation()->setChapo($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->getCurrentTranslation()->getPostscriptum();
+ }
+
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteStatusI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ { $this->getCurrentTranslation()->setPostscriptum($v);
+
+ return $this;
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildCreditNoteStatus The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[CreditNoteStatusTableMap::UPDATED_AT] = true;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteStatusFlow.php b/local/modules/CreditNote/Model/Base/CreditNoteStatusFlow.php
new file mode 100644
index 000000000..ad7d91ae9
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteStatusFlow.php
@@ -0,0 +1,1639 @@
+root = false;
+ }
+
+ /**
+ * Initializes internal state of CreditNote\Model\Base\CreditNoteStatusFlow object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !!$this->modifiedColumns;
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return boolean true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ if (isset($this->modifiedColumns[$col])) {
+ unset($this->modifiedColumns[$col]);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another CreditNoteStatusFlow instance. If
+ * obj is an instance of CreditNoteStatusFlow, delegates to
+ * equals(CreditNoteStatusFlow). Otherwise, returns false.
+ *
+ * @param mixed $obj The object to compare to.
+ * @return boolean Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return array_key_exists($name, $this->virtualColumns);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return mixed
+ *
+ * @throws PropelException
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return CreditNoteStatusFlow The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return CreditNoteStatusFlow The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+
+ return $this;
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [from_status_id] column value.
+ *
+ * @return int
+ */
+ public function getFromStatusId()
+ {
+
+ return $this->from_status_id;
+ }
+
+ /**
+ * Get the [to_status_id] column value.
+ *
+ * @return int
+ */
+ public function getToStatusId()
+ {
+
+ return $this->to_status_id;
+ }
+
+ /**
+ * Get the [priority] column value.
+ *
+ * @return int
+ */
+ public function getPriority()
+ {
+
+ return $this->priority;
+ }
+
+ /**
+ * Get the [root] column value.
+ *
+ * @return boolean
+ */
+ public function getRoot()
+ {
+
+ return $this->root;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteStatusFlow The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[CreditNoteStatusFlowTableMap::ID] = true;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [from_status_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteStatusFlow The current object (for fluent API support)
+ */
+ public function setFromStatusId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->from_status_id !== $v) {
+ $this->from_status_id = $v;
+ $this->modifiedColumns[CreditNoteStatusFlowTableMap::FROM_STATUS_ID] = true;
+ }
+
+ if ($this->aCreditNoteStatusRelatedByFromStatusId !== null && $this->aCreditNoteStatusRelatedByFromStatusId->getId() !== $v) {
+ $this->aCreditNoteStatusRelatedByFromStatusId = null;
+ }
+
+
+ return $this;
+ } // setFromStatusId()
+
+ /**
+ * Set the value of [to_status_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteStatusFlow The current object (for fluent API support)
+ */
+ public function setToStatusId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->to_status_id !== $v) {
+ $this->to_status_id = $v;
+ $this->modifiedColumns[CreditNoteStatusFlowTableMap::TO_STATUS_ID] = true;
+ }
+
+ if ($this->aCreditNoteStatusRelatedByToStatusId !== null && $this->aCreditNoteStatusRelatedByToStatusId->getId() !== $v) {
+ $this->aCreditNoteStatusRelatedByToStatusId = null;
+ }
+
+
+ return $this;
+ } // setToStatusId()
+
+ /**
+ * Set the value of [priority] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteStatusFlow The current object (for fluent API support)
+ */
+ public function setPriority($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->priority !== $v) {
+ $this->priority = $v;
+ $this->modifiedColumns[CreditNoteStatusFlowTableMap::PRIORITY] = true;
+ }
+
+
+ return $this;
+ } // setPriority()
+
+ /**
+ * Sets the value of the [root] column.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ *
+ * @param boolean|integer|string $v The new value
+ * @return \CreditNote\Model\CreditNoteStatusFlow The current object (for fluent API support)
+ */
+ public function setRoot($v)
+ {
+ if ($v !== null) {
+ if (is_string($v)) {
+ $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ } else {
+ $v = (boolean) $v;
+ }
+ }
+
+ if ($this->root !== $v) {
+ $this->root = $v;
+ $this->modifiedColumns[CreditNoteStatusFlowTableMap::ROOT] = true;
+ }
+
+
+ return $this;
+ } // setRoot()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNoteStatusFlow The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[CreditNoteStatusFlowTableMap::CREATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNoteStatusFlow The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[CreditNoteStatusFlowTableMap::UPDATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->root !== false) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CreditNoteStatusFlowTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CreditNoteStatusFlowTableMap::translateFieldName('FromStatusId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->from_status_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CreditNoteStatusFlowTableMap::translateFieldName('ToStatusId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->to_status_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CreditNoteStatusFlowTableMap::translateFieldName('Priority', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->priority = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CreditNoteStatusFlowTableMap::translateFieldName('Root', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->root = (null !== $col) ? (boolean) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CreditNoteStatusFlowTableMap::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 ? 6 + $startcol : CreditNoteStatusFlowTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = CreditNoteStatusFlowTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \CreditNote\Model\CreditNoteStatusFlow object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCreditNoteStatusRelatedByFromStatusId !== null && $this->from_status_id !== $this->aCreditNoteStatusRelatedByFromStatusId->getId()) {
+ $this->aCreditNoteStatusRelatedByFromStatusId = null;
+ }
+ if ($this->aCreditNoteStatusRelatedByToStatusId !== null && $this->to_status_id !== $this->aCreditNoteStatusRelatedByToStatusId->getId()) {
+ $this->aCreditNoteStatusRelatedByToStatusId = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteStatusFlowTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCreditNoteStatusFlowQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCreditNoteStatusRelatedByFromStatusId = null;
+ $this->aCreditNoteStatusRelatedByToStatusId = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see CreditNoteStatusFlow::setDeleted()
+ * @see CreditNoteStatusFlow::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusFlowTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCreditNoteStatusFlowQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see doSave()
+ */
+ public function save(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusFlowTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(CreditNoteStatusFlowTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(CreditNoteStatusFlowTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(CreditNoteStatusFlowTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CreditNoteStatusFlowTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCreditNoteStatusRelatedByFromStatusId !== null) {
+ if ($this->aCreditNoteStatusRelatedByFromStatusId->isModified() || $this->aCreditNoteStatusRelatedByFromStatusId->isNew()) {
+ $affectedRows += $this->aCreditNoteStatusRelatedByFromStatusId->save($con);
+ }
+ $this->setCreditNoteStatusRelatedByFromStatusId($this->aCreditNoteStatusRelatedByFromStatusId);
+ }
+
+ if ($this->aCreditNoteStatusRelatedByToStatusId !== null) {
+ if ($this->aCreditNoteStatusRelatedByToStatusId->isModified() || $this->aCreditNoteStatusRelatedByToStatusId->isNew()) {
+ $affectedRows += $this->aCreditNoteStatusRelatedByToStatusId->save($con);
+ }
+ $this->setCreditNoteStatusRelatedByToStatusId($this->aCreditNoteStatusRelatedByToStatusId);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[CreditNoteStatusFlowTableMap::ID] = true;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CreditNoteStatusFlowTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CreditNoteStatusFlowTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CreditNoteStatusFlowTableMap::FROM_STATUS_ID)) {
+ $modifiedColumns[':p' . $index++] = 'FROM_STATUS_ID';
+ }
+ if ($this->isColumnModified(CreditNoteStatusFlowTableMap::TO_STATUS_ID)) {
+ $modifiedColumns[':p' . $index++] = 'TO_STATUS_ID';
+ }
+ if ($this->isColumnModified(CreditNoteStatusFlowTableMap::PRIORITY)) {
+ $modifiedColumns[':p' . $index++] = 'PRIORITY';
+ }
+ if ($this->isColumnModified(CreditNoteStatusFlowTableMap::ROOT)) {
+ $modifiedColumns[':p' . $index++] = 'ROOT';
+ }
+ if ($this->isColumnModified(CreditNoteStatusFlowTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CreditNoteStatusFlowTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO credit_note_status_flow (%s) VALUES (%s)',
+ 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 'FROM_STATUS_ID':
+ $stmt->bindValue($identifier, $this->from_status_id, PDO::PARAM_INT);
+ break;
+ case 'TO_STATUS_ID':
+ $stmt->bindValue($identifier, $this->to_status_id, PDO::PARAM_INT);
+ break;
+ case 'PRIORITY':
+ $stmt->bindValue($identifier, $this->priority, PDO::PARAM_INT);
+ break;
+ case 'ROOT':
+ $stmt->bindValue($identifier, (int) $this->root, 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);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteStatusFlowTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getFromStatusId();
+ break;
+ case 2:
+ return $this->getToStatusId();
+ break;
+ case 3:
+ return $this->getPriority();
+ break;
+ case 4:
+ return $this->getRoot();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CreditNoteStatusFlow'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CreditNoteStatusFlow'][$this->getPrimaryKey()] = true;
+ $keys = CreditNoteStatusFlowTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getFromStatusId(),
+ $keys[2] => $this->getToStatusId(),
+ $keys[3] => $this->getPriority(),
+ $keys[4] => $this->getRoot(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach ($virtualColumns as $key => $virtualColumn) {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCreditNoteStatusRelatedByFromStatusId) {
+ $result['CreditNoteStatusRelatedByFromStatusId'] = $this->aCreditNoteStatusRelatedByFromStatusId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCreditNoteStatusRelatedByToStatusId) {
+ $result['CreditNoteStatusRelatedByToStatusId'] = $this->aCreditNoteStatusRelatedByToStatusId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteStatusFlowTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+
+ return $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setFromStatusId($value);
+ break;
+ case 2:
+ $this->setToStatusId($value);
+ break;
+ case 3:
+ $this->setPriority($value);
+ break;
+ case 4:
+ $this->setRoot($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CreditNoteStatusFlowTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setFromStatusId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setToStatusId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setPriority($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setRoot($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CreditNoteStatusFlowTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CreditNoteStatusFlowTableMap::ID)) $criteria->add(CreditNoteStatusFlowTableMap::ID, $this->id);
+ if ($this->isColumnModified(CreditNoteStatusFlowTableMap::FROM_STATUS_ID)) $criteria->add(CreditNoteStatusFlowTableMap::FROM_STATUS_ID, $this->from_status_id);
+ if ($this->isColumnModified(CreditNoteStatusFlowTableMap::TO_STATUS_ID)) $criteria->add(CreditNoteStatusFlowTableMap::TO_STATUS_ID, $this->to_status_id);
+ if ($this->isColumnModified(CreditNoteStatusFlowTableMap::PRIORITY)) $criteria->add(CreditNoteStatusFlowTableMap::PRIORITY, $this->priority);
+ if ($this->isColumnModified(CreditNoteStatusFlowTableMap::ROOT)) $criteria->add(CreditNoteStatusFlowTableMap::ROOT, $this->root);
+ if ($this->isColumnModified(CreditNoteStatusFlowTableMap::CREATED_AT)) $criteria->add(CreditNoteStatusFlowTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CreditNoteStatusFlowTableMap::UPDATED_AT)) $criteria->add(CreditNoteStatusFlowTableMap::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CreditNoteStatusFlowTableMap::DATABASE_NAME);
+ $criteria->add(CreditNoteStatusFlowTableMap::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of \CreditNote\Model\CreditNoteStatusFlow (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setFromStatusId($this->getFromStatusId());
+ $copyObj->setToStatusId($this->getToStatusId());
+ $copyObj->setPriority($this->getPriority());
+ $copyObj->setRoot($this->getRoot());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return \CreditNote\Model\CreditNoteStatusFlow Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCreditNoteStatus object.
+ *
+ * @param ChildCreditNoteStatus $v
+ * @return \CreditNote\Model\CreditNoteStatusFlow The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCreditNoteStatusRelatedByFromStatusId(ChildCreditNoteStatus $v = null)
+ {
+ if ($v === null) {
+ $this->setFromStatusId(NULL);
+ } else {
+ $this->setFromStatusId($v->getId());
+ }
+
+ $this->aCreditNoteStatusRelatedByFromStatusId = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCreditNoteStatus object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNoteStatusFlowRelatedByFromStatusId($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCreditNoteStatus object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCreditNoteStatus The associated ChildCreditNoteStatus object.
+ * @throws PropelException
+ */
+ public function getCreditNoteStatusRelatedByFromStatusId(ConnectionInterface $con = null)
+ {
+ if ($this->aCreditNoteStatusRelatedByFromStatusId === null && ($this->from_status_id !== null)) {
+ $this->aCreditNoteStatusRelatedByFromStatusId = ChildCreditNoteStatusQuery::create()->findPk($this->from_status_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCreditNoteStatusRelatedByFromStatusId->addCreditNoteStatusFlowsRelatedByFromStatusId($this);
+ */
+ }
+
+ return $this->aCreditNoteStatusRelatedByFromStatusId;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCreditNoteStatus object.
+ *
+ * @param ChildCreditNoteStatus $v
+ * @return \CreditNote\Model\CreditNoteStatusFlow The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCreditNoteStatusRelatedByToStatusId(ChildCreditNoteStatus $v = null)
+ {
+ if ($v === null) {
+ $this->setToStatusId(NULL);
+ } else {
+ $this->setToStatusId($v->getId());
+ }
+
+ $this->aCreditNoteStatusRelatedByToStatusId = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCreditNoteStatus object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNoteStatusFlowRelatedByToStatusId($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCreditNoteStatus object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCreditNoteStatus The associated ChildCreditNoteStatus object.
+ * @throws PropelException
+ */
+ public function getCreditNoteStatusRelatedByToStatusId(ConnectionInterface $con = null)
+ {
+ if ($this->aCreditNoteStatusRelatedByToStatusId === null && ($this->to_status_id !== null)) {
+ $this->aCreditNoteStatusRelatedByToStatusId = ChildCreditNoteStatusQuery::create()->findPk($this->to_status_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCreditNoteStatusRelatedByToStatusId->addCreditNoteStatusFlowsRelatedByToStatusId($this);
+ */
+ }
+
+ return $this->aCreditNoteStatusRelatedByToStatusId;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->from_status_id = null;
+ $this->to_status_id = null;
+ $this->priority = null;
+ $this->root = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCreditNoteStatusRelatedByFromStatusId = null;
+ $this->aCreditNoteStatusRelatedByToStatusId = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CreditNoteStatusFlowTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildCreditNoteStatusFlow The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[CreditNoteStatusFlowTableMap::UPDATED_AT] = true;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteStatusFlowQuery.php b/local/modules/CreditNote/Model/Base/CreditNoteStatusFlowQuery.php
new file mode 100644
index 000000000..047402c19
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteStatusFlowQuery.php
@@ -0,0 +1,835 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCreditNoteStatusFlow|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CreditNoteStatusFlowTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteStatusFlowTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * 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 ChildCreditNoteStatusFlow A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, FROM_STATUS_ID, TO_STATUS_ID, PRIORITY, ROOT, CREATED_AT, UPDATED_AT FROM credit_note_status_flow 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 ChildCreditNoteStatusFlow();
+ $obj->hydrate($row);
+ CreditNoteStatusFlowTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCreditNoteStatusFlow|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CreditNoteStatusFlowTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CreditNoteStatusFlowTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id 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 ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CreditNoteStatusFlowTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CreditNoteStatusFlowTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusFlowTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the from_status_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFromStatusId(1234); // WHERE from_status_id = 1234
+ * $query->filterByFromStatusId(array(12, 34)); // WHERE from_status_id IN (12, 34)
+ * $query->filterByFromStatusId(array('min' => 12)); // WHERE from_status_id > 12
+ *
+ *
+ * @see filterByCreditNoteStatusRelatedByFromStatusId()
+ *
+ * @param mixed $fromStatusId 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 ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function filterByFromStatusId($fromStatusId = null, $comparison = null)
+ {
+ if (is_array($fromStatusId)) {
+ $useMinMax = false;
+ if (isset($fromStatusId['min'])) {
+ $this->addUsingAlias(CreditNoteStatusFlowTableMap::FROM_STATUS_ID, $fromStatusId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($fromStatusId['max'])) {
+ $this->addUsingAlias(CreditNoteStatusFlowTableMap::FROM_STATUS_ID, $fromStatusId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusFlowTableMap::FROM_STATUS_ID, $fromStatusId, $comparison);
+ }
+
+ /**
+ * Filter the query on the to_status_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByToStatusId(1234); // WHERE to_status_id = 1234
+ * $query->filterByToStatusId(array(12, 34)); // WHERE to_status_id IN (12, 34)
+ * $query->filterByToStatusId(array('min' => 12)); // WHERE to_status_id > 12
+ *
+ *
+ * @see filterByCreditNoteStatusRelatedByToStatusId()
+ *
+ * @param mixed $toStatusId 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 ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function filterByToStatusId($toStatusId = null, $comparison = null)
+ {
+ if (is_array($toStatusId)) {
+ $useMinMax = false;
+ if (isset($toStatusId['min'])) {
+ $this->addUsingAlias(CreditNoteStatusFlowTableMap::TO_STATUS_ID, $toStatusId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($toStatusId['max'])) {
+ $this->addUsingAlias(CreditNoteStatusFlowTableMap::TO_STATUS_ID, $toStatusId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusFlowTableMap::TO_STATUS_ID, $toStatusId, $comparison);
+ }
+
+ /**
+ * Filter the query on the priority column
+ *
+ * Example usage:
+ *
+ * $query->filterByPriority(1234); // WHERE priority = 1234
+ * $query->filterByPriority(array(12, 34)); // WHERE priority IN (12, 34)
+ * $query->filterByPriority(array('min' => 12)); // WHERE priority > 12
+ *
+ *
+ * @param mixed $priority 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 ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function filterByPriority($priority = null, $comparison = null)
+ {
+ if (is_array($priority)) {
+ $useMinMax = false;
+ if (isset($priority['min'])) {
+ $this->addUsingAlias(CreditNoteStatusFlowTableMap::PRIORITY, $priority['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($priority['max'])) {
+ $this->addUsingAlias(CreditNoteStatusFlowTableMap::PRIORITY, $priority['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusFlowTableMap::PRIORITY, $priority, $comparison);
+ }
+
+ /**
+ * Filter the query on the root column
+ *
+ * Example usage:
+ *
+ * $query->filterByRoot(true); // WHERE root = true
+ * $query->filterByRoot('yes'); // WHERE root = true
+ *
+ *
+ * @param boolean|string $root The value to use as filter.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function filterByRoot($root = null, $comparison = null)
+ {
+ if (is_string($root)) {
+ $root = in_array(strtolower($root), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusFlowTableMap::ROOT, $root, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CreditNoteStatusFlowTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CreditNoteStatusFlowTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusFlowTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CreditNoteStatusFlowTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CreditNoteStatusFlowTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusFlowTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNoteStatus object
+ *
+ * @param \CreditNote\Model\CreditNoteStatus|ObjectCollection $creditNoteStatus The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteStatusRelatedByFromStatusId($creditNoteStatus, $comparison = null)
+ {
+ if ($creditNoteStatus instanceof \CreditNote\Model\CreditNoteStatus) {
+ return $this
+ ->addUsingAlias(CreditNoteStatusFlowTableMap::FROM_STATUS_ID, $creditNoteStatus->getId(), $comparison);
+ } elseif ($creditNoteStatus instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteStatusFlowTableMap::FROM_STATUS_ID, $creditNoteStatus->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCreditNoteStatusRelatedByFromStatusId() only accepts arguments of type \CreditNote\Model\CreditNoteStatus or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNoteStatusRelatedByFromStatusId relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function joinCreditNoteStatusRelatedByFromStatusId($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNoteStatusRelatedByFromStatusId');
+
+ // 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, 'CreditNoteStatusRelatedByFromStatusId');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNoteStatusRelatedByFromStatusId relation CreditNoteStatus 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 \CreditNote\Model\CreditNoteStatusQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteStatusRelatedByFromStatusIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCreditNoteStatusRelatedByFromStatusId($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNoteStatusRelatedByFromStatusId', '\CreditNote\Model\CreditNoteStatusQuery');
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNoteStatus object
+ *
+ * @param \CreditNote\Model\CreditNoteStatus|ObjectCollection $creditNoteStatus The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteStatusRelatedByToStatusId($creditNoteStatus, $comparison = null)
+ {
+ if ($creditNoteStatus instanceof \CreditNote\Model\CreditNoteStatus) {
+ return $this
+ ->addUsingAlias(CreditNoteStatusFlowTableMap::TO_STATUS_ID, $creditNoteStatus->getId(), $comparison);
+ } elseif ($creditNoteStatus instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteStatusFlowTableMap::TO_STATUS_ID, $creditNoteStatus->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCreditNoteStatusRelatedByToStatusId() only accepts arguments of type \CreditNote\Model\CreditNoteStatus or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNoteStatusRelatedByToStatusId relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function joinCreditNoteStatusRelatedByToStatusId($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNoteStatusRelatedByToStatusId');
+
+ // 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, 'CreditNoteStatusRelatedByToStatusId');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNoteStatusRelatedByToStatusId relation CreditNoteStatus 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 \CreditNote\Model\CreditNoteStatusQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteStatusRelatedByToStatusIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCreditNoteStatusRelatedByToStatusId($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNoteStatusRelatedByToStatusId', '\CreditNote\Model\CreditNoteStatusQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCreditNoteStatusFlow $creditNoteStatusFlow Object to remove from the list of results
+ *
+ * @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function prune($creditNoteStatusFlow = null)
+ {
+ if ($creditNoteStatusFlow) {
+ $this->addUsingAlias(CreditNoteStatusFlowTableMap::ID, $creditNoteStatusFlow->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the credit_note_status_flow table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusFlowTableMap::DATABASE_NAME);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CreditNoteStatusFlowTableMap::clearInstancePool();
+ CreditNoteStatusFlowTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCreditNoteStatusFlow or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCreditNoteStatusFlow object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusFlowTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CreditNoteStatusFlowTableMap::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+
+ CreditNoteStatusFlowTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CreditNoteStatusFlowTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CreditNoteStatusFlowTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CreditNoteStatusFlowTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CreditNoteStatusFlowTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CreditNoteStatusFlowTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CreditNoteStatusFlowTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CreditNoteStatusFlowTableMap::CREATED_AT);
+ }
+
+} // CreditNoteStatusFlowQuery
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteStatusI18n.php b/local/modules/CreditNote/Model/Base/CreditNoteStatusI18n.php
new file mode 100644
index 000000000..392fd6f04
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteStatusI18n.php
@@ -0,0 +1,1442 @@
+locale = 'en_US';
+ }
+
+ /**
+ * Initializes internal state of CreditNote\Model\Base\CreditNoteStatusI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !!$this->modifiedColumns;
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return boolean true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ if (isset($this->modifiedColumns[$col])) {
+ unset($this->modifiedColumns[$col]);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another CreditNoteStatusI18n instance. If
+ * obj is an instance of CreditNoteStatusI18n, delegates to
+ * equals(CreditNoteStatusI18n). Otherwise, returns false.
+ *
+ * @param mixed $obj The object to compare to.
+ * @return boolean Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return array_key_exists($name, $this->virtualColumns);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return mixed
+ *
+ * @throws PropelException
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return CreditNoteStatusI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return CreditNoteStatusI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+
+ return $this;
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+
+ return $this->postscriptum;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteStatusI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[CreditNoteStatusI18nTableMap::ID] = true;
+ }
+
+ if ($this->aCreditNoteStatus !== null && $this->aCreditNoteStatus->getId() !== $v) {
+ $this->aCreditNoteStatus = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteStatusI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[CreditNoteStatusI18nTableMap::LOCALE] = true;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteStatusI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[CreditNoteStatusI18nTableMap::TITLE] = true;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteStatusI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[CreditNoteStatusI18nTableMap::DESCRIPTION] = true;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteStatusI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[CreditNoteStatusI18nTableMap::CHAPO] = true;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteStatusI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[CreditNoteStatusI18nTableMap::POSTSCRIPTUM] = true;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_US') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CreditNoteStatusI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CreditNoteStatusI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CreditNoteStatusI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CreditNoteStatusI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CreditNoteStatusI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CreditNoteStatusI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postscriptum = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = CreditNoteStatusI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \CreditNote\Model\CreditNoteStatusI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCreditNoteStatus !== null && $this->id !== $this->aCreditNoteStatus->getId()) {
+ $this->aCreditNoteStatus = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteStatusI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCreditNoteStatusI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCreditNoteStatus = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see CreditNoteStatusI18n::setDeleted()
+ * @see CreditNoteStatusI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCreditNoteStatusI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see doSave()
+ */
+ public function save(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CreditNoteStatusI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCreditNoteStatus !== null) {
+ if ($this->aCreditNoteStatus->isModified() || $this->aCreditNoteStatus->isNew()) {
+ $affectedRows += $this->aCreditNoteStatus->save($con);
+ }
+ $this->setCreditNoteStatus($this->aCreditNoteStatus);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CreditNoteStatusI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CreditNoteStatusI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(CreditNoteStatusI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(CreditNoteStatusI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(CreditNoteStatusI18nTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(CreditNoteStatusI18nTableMap::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO credit_note_status_i18n (%s) VALUES (%s)',
+ 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 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'POSTSCRIPTUM':
+ $stmt->bindValue($identifier, $this->postscriptum, 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);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteStatusI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getPostscriptum();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CreditNoteStatusI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CreditNoteStatusI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = CreditNoteStatusI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getPostscriptum(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach ($virtualColumns as $key => $virtualColumn) {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCreditNoteStatus) {
+ $result['CreditNoteStatus'] = $this->aCreditNoteStatus->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteStatusI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+
+ return $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setPostscriptum($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CreditNoteStatusI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CreditNoteStatusI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CreditNoteStatusI18nTableMap::ID)) $criteria->add(CreditNoteStatusI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(CreditNoteStatusI18nTableMap::LOCALE)) $criteria->add(CreditNoteStatusI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(CreditNoteStatusI18nTableMap::TITLE)) $criteria->add(CreditNoteStatusI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(CreditNoteStatusI18nTableMap::DESCRIPTION)) $criteria->add(CreditNoteStatusI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(CreditNoteStatusI18nTableMap::CHAPO)) $criteria->add(CreditNoteStatusI18nTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(CreditNoteStatusI18nTableMap::POSTSCRIPTUM)) $criteria->add(CreditNoteStatusI18nTableMap::POSTSCRIPTUM, $this->postscriptum);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CreditNoteStatusI18nTableMap::DATABASE_NAME);
+ $criteria->add(CreditNoteStatusI18nTableMap::ID, $this->id);
+ $criteria->add(CreditNoteStatusI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of \CreditNote\Model\CreditNoteStatusI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return \CreditNote\Model\CreditNoteStatusI18n Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCreditNoteStatus object.
+ *
+ * @param ChildCreditNoteStatus $v
+ * @return \CreditNote\Model\CreditNoteStatusI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCreditNoteStatus(ChildCreditNoteStatus $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aCreditNoteStatus = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCreditNoteStatus object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNoteStatusI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCreditNoteStatus object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCreditNoteStatus The associated ChildCreditNoteStatus object.
+ * @throws PropelException
+ */
+ public function getCreditNoteStatus(ConnectionInterface $con = null)
+ {
+ if ($this->aCreditNoteStatus === null && ($this->id !== null)) {
+ $this->aCreditNoteStatus = ChildCreditNoteStatusQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCreditNoteStatus->addCreditNoteStatusI18ns($this);
+ */
+ }
+
+ return $this->aCreditNoteStatus;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCreditNoteStatus = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CreditNoteStatusI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteStatusI18nQuery.php b/local/modules/CreditNote/Model/Base/CreditNoteStatusI18nQuery.php
new file mode 100644
index 000000000..7bcb56362
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteStatusI18nQuery.php
@@ -0,0 +1,607 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCreditNoteStatusI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CreditNoteStatusI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteStatusI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * 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 ChildCreditNoteStatusI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM credit_note_status_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $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 ChildCreditNoteStatusI18n();
+ $obj->hydrate($row);
+ CreditNoteStatusI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCreditNoteStatusI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCreditNoteStatusI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(CreditNoteStatusI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(CreditNoteStatusI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCreditNoteStatusI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(CreditNoteStatusI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(CreditNoteStatusI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByCreditNoteStatus()
+ *
+ * @param mixed $id 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 ChildCreditNoteStatusI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CreditNoteStatusI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CreditNoteStatusI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale 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 ChildCreditNoteStatusI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title 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 ChildCreditNoteStatusI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description 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 ChildCreditNoteStatusI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusI18nTableMap::DESCRIPTION, $description, $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 ChildCreditNoteStatusI18nQuery 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(CreditNoteStatusI18nTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @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 ChildCreditNoteStatusI18nQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNoteStatus object
+ *
+ * @param \CreditNote\Model\CreditNoteStatus|ObjectCollection $creditNoteStatus The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteStatusI18nQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteStatus($creditNoteStatus, $comparison = null)
+ {
+ if ($creditNoteStatus instanceof \CreditNote\Model\CreditNoteStatus) {
+ return $this
+ ->addUsingAlias(CreditNoteStatusI18nTableMap::ID, $creditNoteStatus->getId(), $comparison);
+ } elseif ($creditNoteStatus instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteStatusI18nTableMap::ID, $creditNoteStatus->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCreditNoteStatus() only accepts arguments of type \CreditNote\Model\CreditNoteStatus or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNoteStatus relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteStatusI18nQuery The current query, for fluid interface
+ */
+ public function joinCreditNoteStatus($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNoteStatus');
+
+ // 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, 'CreditNoteStatus');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNoteStatus relation CreditNoteStatus 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 \CreditNote\Model\CreditNoteStatusQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteStatusQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinCreditNoteStatus($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNoteStatus', '\CreditNote\Model\CreditNoteStatusQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCreditNoteStatusI18n $creditNoteStatusI18n Object to remove from the list of results
+ *
+ * @return ChildCreditNoteStatusI18nQuery The current query, for fluid interface
+ */
+ public function prune($creditNoteStatusI18n = null)
+ {
+ if ($creditNoteStatusI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(CreditNoteStatusI18nTableMap::ID), $creditNoteStatusI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(CreditNoteStatusI18nTableMap::LOCALE), $creditNoteStatusI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the credit_note_status_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusI18nTableMap::DATABASE_NAME);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CreditNoteStatusI18nTableMap::clearInstancePool();
+ CreditNoteStatusI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCreditNoteStatusI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCreditNoteStatusI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CreditNoteStatusI18nTableMap::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+
+ CreditNoteStatusI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CreditNoteStatusI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // CreditNoteStatusI18nQuery
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteStatusQuery.php b/local/modules/CreditNote/Model/Base/CreditNoteStatusQuery.php
new file mode 100644
index 000000000..30f4e66e4
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteStatusQuery.php
@@ -0,0 +1,1046 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCreditNoteStatus|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CreditNoteStatusTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteStatusTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * 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 ChildCreditNoteStatus A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, CODE, COLOR, INVOICED, USED, POSITION, CREATED_AT, UPDATED_AT FROM credit_note_status 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 ChildCreditNoteStatus();
+ $obj->hydrate($row);
+ CreditNoteStatusTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCreditNoteStatus|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CreditNoteStatusTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CreditNoteStatusTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id 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 ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CreditNoteStatusTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CreditNoteStatusTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code 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 ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusTableMap::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the color column
+ *
+ * Example usage:
+ *
+ * $query->filterByColor('fooValue'); // WHERE color = 'fooValue'
+ * $query->filterByColor('%fooValue%'); // WHERE color LIKE '%fooValue%'
+ *
+ *
+ * @param string $color 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 ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function filterByColor($color = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($color)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $color)) {
+ $color = str_replace('*', '%', $color);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusTableMap::COLOR, $color, $comparison);
+ }
+
+ /**
+ * Filter the query on the invoiced column
+ *
+ * Example usage:
+ *
+ * $query->filterByInvoiced(true); // WHERE invoiced = true
+ * $query->filterByInvoiced('yes'); // WHERE invoiced = true
+ *
+ *
+ * @param boolean|string $invoiced The value to use as filter.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function filterByInvoiced($invoiced = null, $comparison = null)
+ {
+ if (is_string($invoiced)) {
+ $invoiced = in_array(strtolower($invoiced), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusTableMap::INVOICED, $invoiced, $comparison);
+ }
+
+ /**
+ * Filter the query on the used column
+ *
+ * Example usage:
+ *
+ * $query->filterByUsed(true); // WHERE used = true
+ * $query->filterByUsed('yes'); // WHERE used = true
+ *
+ *
+ * @param boolean|string $used The value to use as filter.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function filterByUsed($used = null, $comparison = null)
+ {
+ if (is_string($used)) {
+ $used = in_array(strtolower($used), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusTableMap::USED, $used, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position 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 ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(CreditNoteStatusTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(CreditNoteStatusTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CreditNoteStatusTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CreditNoteStatusTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CreditNoteStatusTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CreditNoteStatusTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteStatusTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNote object
+ *
+ * @param \CreditNote\Model\CreditNote|ObjectCollection $creditNote the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function filterByCreditNote($creditNote, $comparison = null)
+ {
+ if ($creditNote instanceof \CreditNote\Model\CreditNote) {
+ return $this
+ ->addUsingAlias(CreditNoteStatusTableMap::ID, $creditNote->getStatusId(), $comparison);
+ } elseif ($creditNote instanceof ObjectCollection) {
+ return $this
+ ->useCreditNoteQuery()
+ ->filterByPrimaryKeys($creditNote->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCreditNote() only accepts arguments of type \CreditNote\Model\CreditNote or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNote relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function joinCreditNote($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNote');
+
+ // 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, 'CreditNote');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNote relation CreditNote 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 \CreditNote\Model\CreditNoteQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCreditNote($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNote', '\CreditNote\Model\CreditNoteQuery');
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNoteStatusFlow object
+ *
+ * @param \CreditNote\Model\CreditNoteStatusFlow|ObjectCollection $creditNoteStatusFlow the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteStatusFlowRelatedByFromStatusId($creditNoteStatusFlow, $comparison = null)
+ {
+ if ($creditNoteStatusFlow instanceof \CreditNote\Model\CreditNoteStatusFlow) {
+ return $this
+ ->addUsingAlias(CreditNoteStatusTableMap::ID, $creditNoteStatusFlow->getFromStatusId(), $comparison);
+ } elseif ($creditNoteStatusFlow instanceof ObjectCollection) {
+ return $this
+ ->useCreditNoteStatusFlowRelatedByFromStatusIdQuery()
+ ->filterByPrimaryKeys($creditNoteStatusFlow->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCreditNoteStatusFlowRelatedByFromStatusId() only accepts arguments of type \CreditNote\Model\CreditNoteStatusFlow or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNoteStatusFlowRelatedByFromStatusId relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function joinCreditNoteStatusFlowRelatedByFromStatusId($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNoteStatusFlowRelatedByFromStatusId');
+
+ // 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, 'CreditNoteStatusFlowRelatedByFromStatusId');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNoteStatusFlowRelatedByFromStatusId relation CreditNoteStatusFlow 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 \CreditNote\Model\CreditNoteStatusFlowQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteStatusFlowRelatedByFromStatusIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCreditNoteStatusFlowRelatedByFromStatusId($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNoteStatusFlowRelatedByFromStatusId', '\CreditNote\Model\CreditNoteStatusFlowQuery');
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNoteStatusFlow object
+ *
+ * @param \CreditNote\Model\CreditNoteStatusFlow|ObjectCollection $creditNoteStatusFlow the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteStatusFlowRelatedByToStatusId($creditNoteStatusFlow, $comparison = null)
+ {
+ if ($creditNoteStatusFlow instanceof \CreditNote\Model\CreditNoteStatusFlow) {
+ return $this
+ ->addUsingAlias(CreditNoteStatusTableMap::ID, $creditNoteStatusFlow->getToStatusId(), $comparison);
+ } elseif ($creditNoteStatusFlow instanceof ObjectCollection) {
+ return $this
+ ->useCreditNoteStatusFlowRelatedByToStatusIdQuery()
+ ->filterByPrimaryKeys($creditNoteStatusFlow->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCreditNoteStatusFlowRelatedByToStatusId() only accepts arguments of type \CreditNote\Model\CreditNoteStatusFlow or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNoteStatusFlowRelatedByToStatusId relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function joinCreditNoteStatusFlowRelatedByToStatusId($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNoteStatusFlowRelatedByToStatusId');
+
+ // 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, 'CreditNoteStatusFlowRelatedByToStatusId');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNoteStatusFlowRelatedByToStatusId relation CreditNoteStatusFlow 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 \CreditNote\Model\CreditNoteStatusFlowQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteStatusFlowRelatedByToStatusIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCreditNoteStatusFlowRelatedByToStatusId($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNoteStatusFlowRelatedByToStatusId', '\CreditNote\Model\CreditNoteStatusFlowQuery');
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNoteStatusI18n object
+ *
+ * @param \CreditNote\Model\CreditNoteStatusI18n|ObjectCollection $creditNoteStatusI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteStatusI18n($creditNoteStatusI18n, $comparison = null)
+ {
+ if ($creditNoteStatusI18n instanceof \CreditNote\Model\CreditNoteStatusI18n) {
+ return $this
+ ->addUsingAlias(CreditNoteStatusTableMap::ID, $creditNoteStatusI18n->getId(), $comparison);
+ } elseif ($creditNoteStatusI18n instanceof ObjectCollection) {
+ return $this
+ ->useCreditNoteStatusI18nQuery()
+ ->filterByPrimaryKeys($creditNoteStatusI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCreditNoteStatusI18n() only accepts arguments of type \CreditNote\Model\CreditNoteStatusI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNoteStatusI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function joinCreditNoteStatusI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNoteStatusI18n');
+
+ // 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, 'CreditNoteStatusI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNoteStatusI18n relation CreditNoteStatusI18n 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 \CreditNote\Model\CreditNoteStatusI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteStatusI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinCreditNoteStatusI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNoteStatusI18n', '\CreditNote\Model\CreditNoteStatusI18nQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCreditNoteStatus $creditNoteStatus Object to remove from the list of results
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function prune($creditNoteStatus = null)
+ {
+ if ($creditNoteStatus) {
+ $this->addUsingAlias(CreditNoteStatusTableMap::ID, $creditNoteStatus->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the credit_note_status table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusTableMap::DATABASE_NAME);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CreditNoteStatusTableMap::clearInstancePool();
+ CreditNoteStatusTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCreditNoteStatus or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCreditNoteStatus object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CreditNoteStatusTableMap::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+
+ CreditNoteStatusTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CreditNoteStatusTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'CreditNoteStatusI18n';
+
+ return $this
+ ->joinCreditNoteStatusI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('CreditNoteStatusI18n');
+ $this->with['CreditNoteStatusI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildCreditNoteStatusI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNoteStatusI18n', '\CreditNote\Model\CreditNoteStatusI18nQuery');
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CreditNoteStatusTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CreditNoteStatusTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CreditNoteStatusTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CreditNoteStatusTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CreditNoteStatusTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildCreditNoteStatusQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CreditNoteStatusTableMap::CREATED_AT);
+ }
+
+} // CreditNoteStatusQuery
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteType.php b/local/modules/CreditNote/Model/Base/CreditNoteType.php
new file mode 100644
index 000000000..2bed29737
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteType.php
@@ -0,0 +1,2412 @@
+required_order = false;
+ }
+
+ /**
+ * Initializes internal state of CreditNote\Model\Base\CreditNoteType object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !!$this->modifiedColumns;
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return boolean true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ if (isset($this->modifiedColumns[$col])) {
+ unset($this->modifiedColumns[$col]);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another CreditNoteType instance. If
+ * obj is an instance of CreditNoteType, delegates to
+ * equals(CreditNoteType). Otherwise, returns false.
+ *
+ * @param mixed $obj The object to compare to.
+ * @return boolean Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return array_key_exists($name, $this->virtualColumns);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return mixed
+ *
+ * @throws PropelException
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return CreditNoteType The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return CreditNoteType The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+
+ return $this;
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+
+ return $this->code;
+ }
+
+ /**
+ * Get the [color] column value.
+ *
+ * @return string
+ */
+ public function getColor()
+ {
+
+ return $this->color;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [required_order] column value.
+ *
+ * @return boolean
+ */
+ public function getRequiredOrder()
+ {
+
+ return $this->required_order;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteType The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[CreditNoteTypeTableMap::ID] = true;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteType The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[CreditNoteTypeTableMap::CODE] = true;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Set the value of [color] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteType The current object (for fluent API support)
+ */
+ public function setColor($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->color !== $v) {
+ $this->color = $v;
+ $this->modifiedColumns[CreditNoteTypeTableMap::COLOR] = true;
+ }
+
+
+ return $this;
+ } // setColor()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteType The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[CreditNoteTypeTableMap::POSITION] = true;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of the [required_order] column.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ *
+ * @param boolean|integer|string $v The new value
+ * @return \CreditNote\Model\CreditNoteType The current object (for fluent API support)
+ */
+ public function setRequiredOrder($v)
+ {
+ if ($v !== null) {
+ if (is_string($v)) {
+ $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ } else {
+ $v = (boolean) $v;
+ }
+ }
+
+ if ($this->required_order !== $v) {
+ $this->required_order = $v;
+ $this->modifiedColumns[CreditNoteTypeTableMap::REQUIRED_ORDER] = true;
+ }
+
+
+ return $this;
+ } // setRequiredOrder()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNoteType The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[CreditNoteTypeTableMap::CREATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNoteType The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[CreditNoteTypeTableMap::UPDATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->required_order !== false) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CreditNoteTypeTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CreditNoteTypeTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->code = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CreditNoteTypeTableMap::translateFieldName('Color', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->color = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CreditNoteTypeTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CreditNoteTypeTableMap::translateFieldName('RequiredOrder', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->required_order = (null !== $col) ? (boolean) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CreditNoteTypeTableMap::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 ? 6 + $startcol : CreditNoteTypeTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = CreditNoteTypeTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \CreditNote\Model\CreditNoteType object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteTypeTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCreditNoteTypeQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collCreditNotes = null;
+
+ $this->collCreditNoteTypeI18ns = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see CreditNoteType::setDeleted()
+ * @see CreditNoteType::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCreditNoteTypeQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see doSave()
+ */
+ public function save(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(CreditNoteTypeTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(CreditNoteTypeTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(CreditNoteTypeTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CreditNoteTypeTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->creditNotesScheduledForDeletion !== null) {
+ if (!$this->creditNotesScheduledForDeletion->isEmpty()) {
+ \CreditNote\Model\CreditNoteQuery::create()
+ ->filterByPrimaryKeys($this->creditNotesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->creditNotesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCreditNotes !== null) {
+ foreach ($this->collCreditNotes as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->creditNoteTypeI18nsScheduledForDeletion !== null) {
+ if (!$this->creditNoteTypeI18nsScheduledForDeletion->isEmpty()) {
+ \CreditNote\Model\CreditNoteTypeI18nQuery::create()
+ ->filterByPrimaryKeys($this->creditNoteTypeI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->creditNoteTypeI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCreditNoteTypeI18ns !== null) {
+ foreach ($this->collCreditNoteTypeI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[CreditNoteTypeTableMap::ID] = true;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CreditNoteTypeTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CreditNoteTypeTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CreditNoteTypeTableMap::CODE)) {
+ $modifiedColumns[':p' . $index++] = 'CODE';
+ }
+ if ($this->isColumnModified(CreditNoteTypeTableMap::COLOR)) {
+ $modifiedColumns[':p' . $index++] = 'COLOR';
+ }
+ if ($this->isColumnModified(CreditNoteTypeTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(CreditNoteTypeTableMap::REQUIRED_ORDER)) {
+ $modifiedColumns[':p' . $index++] = 'REQUIRED_ORDER';
+ }
+ if ($this->isColumnModified(CreditNoteTypeTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CreditNoteTypeTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO credit_note_type (%s) VALUES (%s)',
+ 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 'CODE':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case 'COLOR':
+ $stmt->bindValue($identifier, $this->color, PDO::PARAM_STR);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case 'REQUIRED_ORDER':
+ $stmt->bindValue($identifier, (int) $this->required_order, 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);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteTypeTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCode();
+ break;
+ case 2:
+ return $this->getColor();
+ break;
+ case 3:
+ return $this->getPosition();
+ break;
+ case 4:
+ return $this->getRequiredOrder();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CreditNoteType'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CreditNoteType'][$this->getPrimaryKey()] = true;
+ $keys = CreditNoteTypeTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCode(),
+ $keys[2] => $this->getColor(),
+ $keys[3] => $this->getPosition(),
+ $keys[4] => $this->getRequiredOrder(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach ($virtualColumns as $key => $virtualColumn) {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collCreditNotes) {
+ $result['CreditNotes'] = $this->collCreditNotes->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collCreditNoteTypeI18ns) {
+ $result['CreditNoteTypeI18ns'] = $this->collCreditNoteTypeI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteTypeTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+
+ return $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCode($value);
+ break;
+ case 2:
+ $this->setColor($value);
+ break;
+ case 3:
+ $this->setPosition($value);
+ break;
+ case 4:
+ $this->setRequiredOrder($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CreditNoteTypeTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setColor($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setRequiredOrder($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CreditNoteTypeTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CreditNoteTypeTableMap::ID)) $criteria->add(CreditNoteTypeTableMap::ID, $this->id);
+ if ($this->isColumnModified(CreditNoteTypeTableMap::CODE)) $criteria->add(CreditNoteTypeTableMap::CODE, $this->code);
+ if ($this->isColumnModified(CreditNoteTypeTableMap::COLOR)) $criteria->add(CreditNoteTypeTableMap::COLOR, $this->color);
+ if ($this->isColumnModified(CreditNoteTypeTableMap::POSITION)) $criteria->add(CreditNoteTypeTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(CreditNoteTypeTableMap::REQUIRED_ORDER)) $criteria->add(CreditNoteTypeTableMap::REQUIRED_ORDER, $this->required_order);
+ if ($this->isColumnModified(CreditNoteTypeTableMap::CREATED_AT)) $criteria->add(CreditNoteTypeTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CreditNoteTypeTableMap::UPDATED_AT)) $criteria->add(CreditNoteTypeTableMap::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CreditNoteTypeTableMap::DATABASE_NAME);
+ $criteria->add(CreditNoteTypeTableMap::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of \CreditNote\Model\CreditNoteType (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCode($this->getCode());
+ $copyObj->setColor($this->getColor());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setRequiredOrder($this->getRequiredOrder());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+
+ foreach ($this->getCreditNotes() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCreditNote($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getCreditNoteTypeI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCreditNoteTypeI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return \CreditNote\Model\CreditNoteType Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('CreditNote' == $relationName) {
+ return $this->initCreditNotes();
+ }
+ if ('CreditNoteTypeI18n' == $relationName) {
+ return $this->initCreditNoteTypeI18ns();
+ }
+ }
+
+ /**
+ * Clears out the collCreditNotes collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCreditNotes()
+ */
+ public function clearCreditNotes()
+ {
+ $this->collCreditNotes = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCreditNotes collection loaded partially.
+ */
+ public function resetPartialCreditNotes($v = true)
+ {
+ $this->collCreditNotesPartial = $v;
+ }
+
+ /**
+ * Initializes the collCreditNotes collection.
+ *
+ * By default this just sets the collCreditNotes collection to an empty array (like clearcollCreditNotes());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCreditNotes($overrideExisting = true)
+ {
+ if (null !== $this->collCreditNotes && !$overrideExisting) {
+ return;
+ }
+ $this->collCreditNotes = new ObjectCollection();
+ $this->collCreditNotes->setModel('\CreditNote\Model\CreditNote');
+ }
+
+ /**
+ * Gets an array of ChildCreditNote objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCreditNoteType is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ * @throws PropelException
+ */
+ public function getCreditNotes($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNotesPartial && !$this->isNew();
+ if (null === $this->collCreditNotes || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNotes) {
+ // return empty collection
+ $this->initCreditNotes();
+ } else {
+ $collCreditNotes = ChildCreditNoteQuery::create(null, $criteria)
+ ->filterByCreditNoteType($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCreditNotesPartial && count($collCreditNotes)) {
+ $this->initCreditNotes(false);
+
+ foreach ($collCreditNotes as $obj) {
+ if (false == $this->collCreditNotes->contains($obj)) {
+ $this->collCreditNotes->append($obj);
+ }
+ }
+
+ $this->collCreditNotesPartial = true;
+ }
+
+ reset($collCreditNotes);
+
+ return $collCreditNotes;
+ }
+
+ if ($partial && $this->collCreditNotes) {
+ foreach ($this->collCreditNotes as $obj) {
+ if ($obj->isNew()) {
+ $collCreditNotes[] = $obj;
+ }
+ }
+ }
+
+ $this->collCreditNotes = $collCreditNotes;
+ $this->collCreditNotesPartial = false;
+ }
+ }
+
+ return $this->collCreditNotes;
+ }
+
+ /**
+ * Sets a collection of CreditNote objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $creditNotes A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCreditNoteType The current object (for fluent API support)
+ */
+ public function setCreditNotes(Collection $creditNotes, ConnectionInterface $con = null)
+ {
+ $creditNotesToDelete = $this->getCreditNotes(new Criteria(), $con)->diff($creditNotes);
+
+
+ $this->creditNotesScheduledForDeletion = $creditNotesToDelete;
+
+ foreach ($creditNotesToDelete as $creditNoteRemoved) {
+ $creditNoteRemoved->setCreditNoteType(null);
+ }
+
+ $this->collCreditNotes = null;
+ foreach ($creditNotes as $creditNote) {
+ $this->addCreditNote($creditNote);
+ }
+
+ $this->collCreditNotes = $creditNotes;
+ $this->collCreditNotesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CreditNote objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related CreditNote objects.
+ * @throws PropelException
+ */
+ public function countCreditNotes(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNotesPartial && !$this->isNew();
+ if (null === $this->collCreditNotes || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNotes) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCreditNotes());
+ }
+
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCreditNoteType($this)
+ ->count($con);
+ }
+
+ return count($this->collCreditNotes);
+ }
+
+ /**
+ * Method called to associate a ChildCreditNote object to this object
+ * through the ChildCreditNote foreign key attribute.
+ *
+ * @param ChildCreditNote $l ChildCreditNote
+ * @return \CreditNote\Model\CreditNoteType The current object (for fluent API support)
+ */
+ public function addCreditNote(ChildCreditNote $l)
+ {
+ if ($this->collCreditNotes === null) {
+ $this->initCreditNotes();
+ $this->collCreditNotesPartial = true;
+ }
+
+ if (!in_array($l, $this->collCreditNotes->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCreditNote($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CreditNote $creditNote The creditNote object to add.
+ */
+ protected function doAddCreditNote($creditNote)
+ {
+ $this->collCreditNotes[]= $creditNote;
+ $creditNote->setCreditNoteType($this);
+ }
+
+ /**
+ * @param CreditNote $creditNote The creditNote object to remove.
+ * @return ChildCreditNoteType The current object (for fluent API support)
+ */
+ public function removeCreditNote($creditNote)
+ {
+ if ($this->getCreditNotes()->contains($creditNote)) {
+ $this->collCreditNotes->remove($this->collCreditNotes->search($creditNote));
+ if (null === $this->creditNotesScheduledForDeletion) {
+ $this->creditNotesScheduledForDeletion = clone $this->collCreditNotes;
+ $this->creditNotesScheduledForDeletion->clear();
+ }
+ $this->creditNotesScheduledForDeletion[]= clone $creditNote;
+ $creditNote->setCreditNoteType(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNoteType is new, it will return
+ * an empty collection; or if this CreditNoteType has previously
+ * been saved, it will retrieve related CreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNoteType.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesJoinOrder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('Order', $joinBehavior);
+
+ return $this->getCreditNotes($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNoteType is new, it will return
+ * an empty collection; or if this CreditNoteType has previously
+ * been saved, it will retrieve related CreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNoteType.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('Customer', $joinBehavior);
+
+ return $this->getCreditNotes($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNoteType is new, it will return
+ * an empty collection; or if this CreditNoteType has previously
+ * been saved, it will retrieve related CreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNoteType.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesJoinCreditNoteRelatedByParentId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('CreditNoteRelatedByParentId', $joinBehavior);
+
+ return $this->getCreditNotes($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNoteType is new, it will return
+ * an empty collection; or if this CreditNoteType has previously
+ * been saved, it will retrieve related CreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNoteType.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesJoinCreditNoteStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('CreditNoteStatus', $joinBehavior);
+
+ return $this->getCreditNotes($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNoteType is new, it will return
+ * an empty collection; or if this CreditNoteType has previously
+ * been saved, it will retrieve related CreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNoteType.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('Currency', $joinBehavior);
+
+ return $this->getCreditNotes($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CreditNoteType is new, it will return
+ * an empty collection; or if this CreditNoteType has previously
+ * been saved, it will retrieve related CreditNotes from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in CreditNoteType.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildCreditNote[] List of ChildCreditNote objects
+ */
+ public function getCreditNotesJoinCreditNoteAddress($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildCreditNoteQuery::create(null, $criteria);
+ $query->joinWith('CreditNoteAddress', $joinBehavior);
+
+ return $this->getCreditNotes($query, $con);
+ }
+
+ /**
+ * Clears out the collCreditNoteTypeI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCreditNoteTypeI18ns()
+ */
+ public function clearCreditNoteTypeI18ns()
+ {
+ $this->collCreditNoteTypeI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCreditNoteTypeI18ns collection loaded partially.
+ */
+ public function resetPartialCreditNoteTypeI18ns($v = true)
+ {
+ $this->collCreditNoteTypeI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collCreditNoteTypeI18ns collection.
+ *
+ * By default this just sets the collCreditNoteTypeI18ns collection to an empty array (like clearcollCreditNoteTypeI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCreditNoteTypeI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collCreditNoteTypeI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collCreditNoteTypeI18ns = new ObjectCollection();
+ $this->collCreditNoteTypeI18ns->setModel('\CreditNote\Model\CreditNoteTypeI18n');
+ }
+
+ /**
+ * Gets an array of ChildCreditNoteTypeI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCreditNoteType is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCreditNoteTypeI18n[] List of ChildCreditNoteTypeI18n objects
+ * @throws PropelException
+ */
+ public function getCreditNoteTypeI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNoteTypeI18nsPartial && !$this->isNew();
+ if (null === $this->collCreditNoteTypeI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNoteTypeI18ns) {
+ // return empty collection
+ $this->initCreditNoteTypeI18ns();
+ } else {
+ $collCreditNoteTypeI18ns = ChildCreditNoteTypeI18nQuery::create(null, $criteria)
+ ->filterByCreditNoteType($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCreditNoteTypeI18nsPartial && count($collCreditNoteTypeI18ns)) {
+ $this->initCreditNoteTypeI18ns(false);
+
+ foreach ($collCreditNoteTypeI18ns as $obj) {
+ if (false == $this->collCreditNoteTypeI18ns->contains($obj)) {
+ $this->collCreditNoteTypeI18ns->append($obj);
+ }
+ }
+
+ $this->collCreditNoteTypeI18nsPartial = true;
+ }
+
+ reset($collCreditNoteTypeI18ns);
+
+ return $collCreditNoteTypeI18ns;
+ }
+
+ if ($partial && $this->collCreditNoteTypeI18ns) {
+ foreach ($this->collCreditNoteTypeI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collCreditNoteTypeI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collCreditNoteTypeI18ns = $collCreditNoteTypeI18ns;
+ $this->collCreditNoteTypeI18nsPartial = false;
+ }
+ }
+
+ return $this->collCreditNoteTypeI18ns;
+ }
+
+ /**
+ * Sets a collection of CreditNoteTypeI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $creditNoteTypeI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCreditNoteType The current object (for fluent API support)
+ */
+ public function setCreditNoteTypeI18ns(Collection $creditNoteTypeI18ns, ConnectionInterface $con = null)
+ {
+ $creditNoteTypeI18nsToDelete = $this->getCreditNoteTypeI18ns(new Criteria(), $con)->diff($creditNoteTypeI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->creditNoteTypeI18nsScheduledForDeletion = clone $creditNoteTypeI18nsToDelete;
+
+ foreach ($creditNoteTypeI18nsToDelete as $creditNoteTypeI18nRemoved) {
+ $creditNoteTypeI18nRemoved->setCreditNoteType(null);
+ }
+
+ $this->collCreditNoteTypeI18ns = null;
+ foreach ($creditNoteTypeI18ns as $creditNoteTypeI18n) {
+ $this->addCreditNoteTypeI18n($creditNoteTypeI18n);
+ }
+
+ $this->collCreditNoteTypeI18ns = $creditNoteTypeI18ns;
+ $this->collCreditNoteTypeI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CreditNoteTypeI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related CreditNoteTypeI18n objects.
+ * @throws PropelException
+ */
+ public function countCreditNoteTypeI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCreditNoteTypeI18nsPartial && !$this->isNew();
+ if (null === $this->collCreditNoteTypeI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCreditNoteTypeI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCreditNoteTypeI18ns());
+ }
+
+ $query = ChildCreditNoteTypeI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCreditNoteType($this)
+ ->count($con);
+ }
+
+ return count($this->collCreditNoteTypeI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildCreditNoteTypeI18n object to this object
+ * through the ChildCreditNoteTypeI18n foreign key attribute.
+ *
+ * @param ChildCreditNoteTypeI18n $l ChildCreditNoteTypeI18n
+ * @return \CreditNote\Model\CreditNoteType The current object (for fluent API support)
+ */
+ public function addCreditNoteTypeI18n(ChildCreditNoteTypeI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collCreditNoteTypeI18ns === null) {
+ $this->initCreditNoteTypeI18ns();
+ $this->collCreditNoteTypeI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collCreditNoteTypeI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCreditNoteTypeI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CreditNoteTypeI18n $creditNoteTypeI18n The creditNoteTypeI18n object to add.
+ */
+ protected function doAddCreditNoteTypeI18n($creditNoteTypeI18n)
+ {
+ $this->collCreditNoteTypeI18ns[]= $creditNoteTypeI18n;
+ $creditNoteTypeI18n->setCreditNoteType($this);
+ }
+
+ /**
+ * @param CreditNoteTypeI18n $creditNoteTypeI18n The creditNoteTypeI18n object to remove.
+ * @return ChildCreditNoteType The current object (for fluent API support)
+ */
+ public function removeCreditNoteTypeI18n($creditNoteTypeI18n)
+ {
+ if ($this->getCreditNoteTypeI18ns()->contains($creditNoteTypeI18n)) {
+ $this->collCreditNoteTypeI18ns->remove($this->collCreditNoteTypeI18ns->search($creditNoteTypeI18n));
+ if (null === $this->creditNoteTypeI18nsScheduledForDeletion) {
+ $this->creditNoteTypeI18nsScheduledForDeletion = clone $this->collCreditNoteTypeI18ns;
+ $this->creditNoteTypeI18nsScheduledForDeletion->clear();
+ }
+ $this->creditNoteTypeI18nsScheduledForDeletion[]= clone $creditNoteTypeI18n;
+ $creditNoteTypeI18n->setCreditNoteType(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->code = null;
+ $this->color = null;
+ $this->position = null;
+ $this->required_order = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collCreditNotes) {
+ foreach ($this->collCreditNotes as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collCreditNoteTypeI18ns) {
+ foreach ($this->collCreditNoteTypeI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_US';
+ $this->currentTranslations = null;
+
+ $this->collCreditNotes = null;
+ $this->collCreditNoteTypeI18ns = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CreditNoteTypeTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildCreditNoteType The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_US')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCreditNoteTypeI18n */
+ public function getTranslation($locale = 'en_US', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collCreditNoteTypeI18ns) {
+ foreach ($this->collCreditNoteTypeI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildCreditNoteTypeI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildCreditNoteTypeI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addCreditNoteTypeI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCreditNoteType The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildCreditNoteTypeI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collCreditNoteTypeI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collCreditNoteTypeI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCreditNoteTypeI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteTypeI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteTypeI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->getCurrentTranslation()->getChapo();
+ }
+
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteTypeI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ { $this->getCurrentTranslation()->setChapo($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->getCurrentTranslation()->getPostscriptum();
+ }
+
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteTypeI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ { $this->getCurrentTranslation()->setPostscriptum($v);
+
+ return $this;
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildCreditNoteType The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[CreditNoteTypeTableMap::UPDATED_AT] = true;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteTypeI18n.php b/local/modules/CreditNote/Model/Base/CreditNoteTypeI18n.php
new file mode 100644
index 000000000..b2cd7bdc5
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteTypeI18n.php
@@ -0,0 +1,1442 @@
+locale = 'en_US';
+ }
+
+ /**
+ * Initializes internal state of CreditNote\Model\Base\CreditNoteTypeI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !!$this->modifiedColumns;
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return boolean true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ if (isset($this->modifiedColumns[$col])) {
+ unset($this->modifiedColumns[$col]);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another CreditNoteTypeI18n instance. If
+ * obj is an instance of CreditNoteTypeI18n, delegates to
+ * equals(CreditNoteTypeI18n). Otherwise, returns false.
+ *
+ * @param mixed $obj The object to compare to.
+ * @return boolean Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return array_key_exists($name, $this->virtualColumns);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return mixed
+ *
+ * @throws PropelException
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return CreditNoteTypeI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return CreditNoteTypeI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+
+ return $this;
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+
+ return $this->postscriptum;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteTypeI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[CreditNoteTypeI18nTableMap::ID] = true;
+ }
+
+ if ($this->aCreditNoteType !== null && $this->aCreditNoteType->getId() !== $v) {
+ $this->aCreditNoteType = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteTypeI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[CreditNoteTypeI18nTableMap::LOCALE] = true;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteTypeI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[CreditNoteTypeI18nTableMap::TITLE] = true;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteTypeI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[CreditNoteTypeI18nTableMap::DESCRIPTION] = true;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteTypeI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[CreditNoteTypeI18nTableMap::CHAPO] = true;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteTypeI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[CreditNoteTypeI18nTableMap::POSTSCRIPTUM] = true;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_US') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CreditNoteTypeI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CreditNoteTypeI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CreditNoteTypeI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CreditNoteTypeI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CreditNoteTypeI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CreditNoteTypeI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postscriptum = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = CreditNoteTypeI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \CreditNote\Model\CreditNoteTypeI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCreditNoteType !== null && $this->id !== $this->aCreditNoteType->getId()) {
+ $this->aCreditNoteType = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteTypeI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCreditNoteTypeI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCreditNoteType = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see CreditNoteTypeI18n::setDeleted()
+ * @see CreditNoteTypeI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCreditNoteTypeI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see doSave()
+ */
+ public function save(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CreditNoteTypeI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCreditNoteType !== null) {
+ if ($this->aCreditNoteType->isModified() || $this->aCreditNoteType->isNew()) {
+ $affectedRows += $this->aCreditNoteType->save($con);
+ }
+ $this->setCreditNoteType($this->aCreditNoteType);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CreditNoteTypeI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CreditNoteTypeI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(CreditNoteTypeI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(CreditNoteTypeI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(CreditNoteTypeI18nTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(CreditNoteTypeI18nTableMap::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO credit_note_type_i18n (%s) VALUES (%s)',
+ 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 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'POSTSCRIPTUM':
+ $stmt->bindValue($identifier, $this->postscriptum, 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);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteTypeI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getPostscriptum();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CreditNoteTypeI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CreditNoteTypeI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = CreditNoteTypeI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getPostscriptum(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach ($virtualColumns as $key => $virtualColumn) {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCreditNoteType) {
+ $result['CreditNoteType'] = $this->aCreditNoteType->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteTypeI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+
+ return $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setPostscriptum($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CreditNoteTypeI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CreditNoteTypeI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CreditNoteTypeI18nTableMap::ID)) $criteria->add(CreditNoteTypeI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(CreditNoteTypeI18nTableMap::LOCALE)) $criteria->add(CreditNoteTypeI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(CreditNoteTypeI18nTableMap::TITLE)) $criteria->add(CreditNoteTypeI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(CreditNoteTypeI18nTableMap::DESCRIPTION)) $criteria->add(CreditNoteTypeI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(CreditNoteTypeI18nTableMap::CHAPO)) $criteria->add(CreditNoteTypeI18nTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(CreditNoteTypeI18nTableMap::POSTSCRIPTUM)) $criteria->add(CreditNoteTypeI18nTableMap::POSTSCRIPTUM, $this->postscriptum);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CreditNoteTypeI18nTableMap::DATABASE_NAME);
+ $criteria->add(CreditNoteTypeI18nTableMap::ID, $this->id);
+ $criteria->add(CreditNoteTypeI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of \CreditNote\Model\CreditNoteTypeI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return \CreditNote\Model\CreditNoteTypeI18n Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCreditNoteType object.
+ *
+ * @param ChildCreditNoteType $v
+ * @return \CreditNote\Model\CreditNoteTypeI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCreditNoteType(ChildCreditNoteType $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aCreditNoteType = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCreditNoteType object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNoteTypeI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCreditNoteType object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCreditNoteType The associated ChildCreditNoteType object.
+ * @throws PropelException
+ */
+ public function getCreditNoteType(ConnectionInterface $con = null)
+ {
+ if ($this->aCreditNoteType === null && ($this->id !== null)) {
+ $this->aCreditNoteType = ChildCreditNoteTypeQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCreditNoteType->addCreditNoteTypeI18ns($this);
+ */
+ }
+
+ return $this->aCreditNoteType;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCreditNoteType = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CreditNoteTypeI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteTypeI18nQuery.php b/local/modules/CreditNote/Model/Base/CreditNoteTypeI18nQuery.php
new file mode 100644
index 000000000..b0676533d
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteTypeI18nQuery.php
@@ -0,0 +1,607 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCreditNoteTypeI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CreditNoteTypeI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteTypeI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * 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 ChildCreditNoteTypeI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM credit_note_type_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $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 ChildCreditNoteTypeI18n();
+ $obj->hydrate($row);
+ CreditNoteTypeI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCreditNoteTypeI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCreditNoteTypeI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(CreditNoteTypeI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(CreditNoteTypeI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCreditNoteTypeI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(CreditNoteTypeI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(CreditNoteTypeI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByCreditNoteType()
+ *
+ * @param mixed $id 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 ChildCreditNoteTypeI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CreditNoteTypeI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CreditNoteTypeI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTypeI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale 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 ChildCreditNoteTypeI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTypeI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title 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 ChildCreditNoteTypeI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTypeI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description 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 ChildCreditNoteTypeI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTypeI18nTableMap::DESCRIPTION, $description, $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 ChildCreditNoteTypeI18nQuery 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(CreditNoteTypeI18nTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @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 ChildCreditNoteTypeI18nQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTypeI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNoteType object
+ *
+ * @param \CreditNote\Model\CreditNoteType|ObjectCollection $creditNoteType The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteTypeI18nQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteType($creditNoteType, $comparison = null)
+ {
+ if ($creditNoteType instanceof \CreditNote\Model\CreditNoteType) {
+ return $this
+ ->addUsingAlias(CreditNoteTypeI18nTableMap::ID, $creditNoteType->getId(), $comparison);
+ } elseif ($creditNoteType instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteTypeI18nTableMap::ID, $creditNoteType->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCreditNoteType() only accepts arguments of type \CreditNote\Model\CreditNoteType or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNoteType relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteTypeI18nQuery The current query, for fluid interface
+ */
+ public function joinCreditNoteType($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNoteType');
+
+ // 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, 'CreditNoteType');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNoteType relation CreditNoteType 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 \CreditNote\Model\CreditNoteTypeQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteTypeQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinCreditNoteType($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNoteType', '\CreditNote\Model\CreditNoteTypeQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCreditNoteTypeI18n $creditNoteTypeI18n Object to remove from the list of results
+ *
+ * @return ChildCreditNoteTypeI18nQuery The current query, for fluid interface
+ */
+ public function prune($creditNoteTypeI18n = null)
+ {
+ if ($creditNoteTypeI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(CreditNoteTypeI18nTableMap::ID), $creditNoteTypeI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(CreditNoteTypeI18nTableMap::LOCALE), $creditNoteTypeI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the credit_note_type_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeI18nTableMap::DATABASE_NAME);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CreditNoteTypeI18nTableMap::clearInstancePool();
+ CreditNoteTypeI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCreditNoteTypeI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCreditNoteTypeI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CreditNoteTypeI18nTableMap::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+
+ CreditNoteTypeI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CreditNoteTypeI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // CreditNoteTypeI18nQuery
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteTypeQuery.php b/local/modules/CreditNote/Model/Base/CreditNoteTypeQuery.php
new file mode 100644
index 000000000..7629600a7
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteTypeQuery.php
@@ -0,0 +1,861 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCreditNoteType|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CreditNoteTypeTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteTypeTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * 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 ChildCreditNoteType A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, CODE, COLOR, POSITION, REQUIRED_ORDER, CREATED_AT, UPDATED_AT FROM credit_note_type 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 ChildCreditNoteType();
+ $obj->hydrate($row);
+ CreditNoteTypeTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCreditNoteType|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CreditNoteTypeTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CreditNoteTypeTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id 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 ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CreditNoteTypeTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CreditNoteTypeTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTypeTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code 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 ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTypeTableMap::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the color column
+ *
+ * Example usage:
+ *
+ * $query->filterByColor('fooValue'); // WHERE color = 'fooValue'
+ * $query->filterByColor('%fooValue%'); // WHERE color LIKE '%fooValue%'
+ *
+ *
+ * @param string $color 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 ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function filterByColor($color = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($color)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $color)) {
+ $color = str_replace('*', '%', $color);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTypeTableMap::COLOR, $color, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position 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 ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(CreditNoteTypeTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(CreditNoteTypeTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTypeTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the required_order column
+ *
+ * Example usage:
+ *
+ * $query->filterByRequiredOrder(true); // WHERE required_order = true
+ * $query->filterByRequiredOrder('yes'); // WHERE required_order = true
+ *
+ *
+ * @param boolean|string $requiredOrder The value to use as filter.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function filterByRequiredOrder($requiredOrder = null, $comparison = null)
+ {
+ if (is_string($requiredOrder)) {
+ $required_order = in_array(strtolower($requiredOrder), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ }
+
+ return $this->addUsingAlias(CreditNoteTypeTableMap::REQUIRED_ORDER, $requiredOrder, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CreditNoteTypeTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CreditNoteTypeTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTypeTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CreditNoteTypeTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CreditNoteTypeTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteTypeTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNote object
+ *
+ * @param \CreditNote\Model\CreditNote|ObjectCollection $creditNote the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function filterByCreditNote($creditNote, $comparison = null)
+ {
+ if ($creditNote instanceof \CreditNote\Model\CreditNote) {
+ return $this
+ ->addUsingAlias(CreditNoteTypeTableMap::ID, $creditNote->getTypeId(), $comparison);
+ } elseif ($creditNote instanceof ObjectCollection) {
+ return $this
+ ->useCreditNoteQuery()
+ ->filterByPrimaryKeys($creditNote->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCreditNote() only accepts arguments of type \CreditNote\Model\CreditNote or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNote relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function joinCreditNote($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNote');
+
+ // 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, 'CreditNote');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNote relation CreditNote 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 \CreditNote\Model\CreditNoteQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCreditNote($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNote', '\CreditNote\Model\CreditNoteQuery');
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNoteTypeI18n object
+ *
+ * @param \CreditNote\Model\CreditNoteTypeI18n|ObjectCollection $creditNoteTypeI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteTypeI18n($creditNoteTypeI18n, $comparison = null)
+ {
+ if ($creditNoteTypeI18n instanceof \CreditNote\Model\CreditNoteTypeI18n) {
+ return $this
+ ->addUsingAlias(CreditNoteTypeTableMap::ID, $creditNoteTypeI18n->getId(), $comparison);
+ } elseif ($creditNoteTypeI18n instanceof ObjectCollection) {
+ return $this
+ ->useCreditNoteTypeI18nQuery()
+ ->filterByPrimaryKeys($creditNoteTypeI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCreditNoteTypeI18n() only accepts arguments of type \CreditNote\Model\CreditNoteTypeI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNoteTypeI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function joinCreditNoteTypeI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNoteTypeI18n');
+
+ // 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, 'CreditNoteTypeI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNoteTypeI18n relation CreditNoteTypeI18n 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 \CreditNote\Model\CreditNoteTypeI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteTypeI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinCreditNoteTypeI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNoteTypeI18n', '\CreditNote\Model\CreditNoteTypeI18nQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCreditNoteType $creditNoteType Object to remove from the list of results
+ *
+ * @return ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function prune($creditNoteType = null)
+ {
+ if ($creditNoteType) {
+ $this->addUsingAlias(CreditNoteTypeTableMap::ID, $creditNoteType->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the credit_note_type table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeTableMap::DATABASE_NAME);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CreditNoteTypeTableMap::clearInstancePool();
+ CreditNoteTypeTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCreditNoteType or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCreditNoteType object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CreditNoteTypeTableMap::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+
+ CreditNoteTypeTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CreditNoteTypeTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'CreditNoteTypeI18n';
+
+ return $this
+ ->joinCreditNoteTypeI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('CreditNoteTypeI18n');
+ $this->with['CreditNoteTypeI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildCreditNoteTypeI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNoteTypeI18n', '\CreditNote\Model\CreditNoteTypeI18nQuery');
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CreditNoteTypeTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CreditNoteTypeTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CreditNoteTypeTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CreditNoteTypeTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CreditNoteTypeTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildCreditNoteTypeQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CreditNoteTypeTableMap::CREATED_AT);
+ }
+
+} // CreditNoteTypeQuery
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteVersion.php b/local/modules/CreditNote/Model/Base/CreditNoteVersion.php
new file mode 100644
index 000000000..266f8ce46
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteVersion.php
@@ -0,0 +1,2890 @@
+total_price = '0.000000';
+ $this->total_price_with_tax = '0.000000';
+ $this->discount_without_tax = '0.000000';
+ $this->discount_with_tax = '0.000000';
+ $this->allow_partial_use = true;
+ $this->version = 0;
+ $this->order_id_version = 0;
+ $this->customer_id_version = 0;
+ $this->parent_id_version = 0;
+ }
+
+ /**
+ * Initializes internal state of CreditNote\Model\Base\CreditNoteVersion object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !!$this->modifiedColumns;
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return boolean true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ if (isset($this->modifiedColumns[$col])) {
+ unset($this->modifiedColumns[$col]);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another CreditNoteVersion instance. If
+ * obj is an instance of CreditNoteVersion, delegates to
+ * equals(CreditNoteVersion). Otherwise, returns false.
+ *
+ * @param mixed $obj The object to compare to.
+ * @return boolean Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return array_key_exists($name, $this->virtualColumns);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return mixed
+ *
+ * @throws PropelException
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return CreditNoteVersion The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return CreditNoteVersion The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+
+ return $this;
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [ref] column value.
+ *
+ * @return string
+ */
+ public function getRef()
+ {
+
+ return $this->ref;
+ }
+
+ /**
+ * Get the [invoice_ref] column value.
+ *
+ * @return string
+ */
+ public function getInvoiceRef()
+ {
+
+ return $this->invoice_ref;
+ }
+
+ /**
+ * Get the [invoice_address_id] column value.
+ *
+ * @return int
+ */
+ public function getInvoiceAddressId()
+ {
+
+ return $this->invoice_address_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [invoice_date] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getInvoiceDate($format = NULL)
+ {
+ if ($format === null) {
+ return $this->invoice_date;
+ } else {
+ return $this->invoice_date instanceof \DateTime ? $this->invoice_date->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [order_id] column value.
+ *
+ * @return int
+ */
+ public function getOrderId()
+ {
+
+ return $this->order_id;
+ }
+
+ /**
+ * Get the [customer_id] column value.
+ *
+ * @return int
+ */
+ public function getCustomerId()
+ {
+
+ return $this->customer_id;
+ }
+
+ /**
+ * Get the [parent_id] column value.
+ *
+ * @return int
+ */
+ public function getParentId()
+ {
+
+ return $this->parent_id;
+ }
+
+ /**
+ * Get the [type_id] column value.
+ *
+ * @return int
+ */
+ public function getTypeId()
+ {
+
+ return $this->type_id;
+ }
+
+ /**
+ * Get the [status_id] column value.
+ *
+ * @return int
+ */
+ public function getStatusId()
+ {
+
+ return $this->status_id;
+ }
+
+ /**
+ * Get the [currency_id] column value.
+ *
+ * @return int
+ */
+ public function getCurrencyId()
+ {
+
+ return $this->currency_id;
+ }
+
+ /**
+ * Get the [currency_rate] column value.
+ *
+ * @return double
+ */
+ public function getCurrencyRate()
+ {
+
+ return $this->currency_rate;
+ }
+
+ /**
+ * Get the [total_price] column value.
+ *
+ * @return string
+ */
+ public function getTotalPrice()
+ {
+
+ return $this->total_price;
+ }
+
+ /**
+ * Get the [total_price_with_tax] column value.
+ *
+ * @return string
+ */
+ public function getTotalPriceWithTax()
+ {
+
+ return $this->total_price_with_tax;
+ }
+
+ /**
+ * Get the [discount_without_tax] column value.
+ *
+ * @return string
+ */
+ public function getDiscountWithoutTax()
+ {
+
+ return $this->discount_without_tax;
+ }
+
+ /**
+ * Get the [discount_with_tax] column value.
+ *
+ * @return string
+ */
+ public function getDiscountWithTax()
+ {
+
+ return $this->discount_with_tax;
+ }
+
+ /**
+ * Get the [allow_partial_use] column value.
+ *
+ * @return boolean
+ */
+ public function getAllowPartialUse()
+ {
+
+ return $this->allow_partial_use;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getVersionCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->version_created_at;
+ } else {
+ return $this->version_created_at instanceof \DateTime ? $this->version_created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+
+ return $this->version_created_by;
+ }
+
+ /**
+ * Get the [order_id_version] column value.
+ *
+ * @return int
+ */
+ public function getOrderIdVersion()
+ {
+
+ return $this->order_id_version;
+ }
+
+ /**
+ * Get the [customer_id_version] column value.
+ *
+ * @return int
+ */
+ public function getCustomerIdVersion()
+ {
+
+ return $this->customer_id_version;
+ }
+
+ /**
+ * Get the [parent_id_version] column value.
+ *
+ * @return int
+ */
+ public function getParentIdVersion()
+ {
+
+ return $this->parent_id_version;
+ }
+
+ /**
+ * Get the [credit_note_ids] column value.
+ *
+ * @return array
+ */
+ public function getCreditNoteIds()
+ {
+ if (null === $this->credit_note_ids_unserialized) {
+ $this->credit_note_ids_unserialized = array();
+ }
+ if (!$this->credit_note_ids_unserialized && null !== $this->credit_note_ids) {
+ $credit_note_ids_unserialized = substr($this->credit_note_ids, 2, -2);
+ $this->credit_note_ids_unserialized = $credit_note_ids_unserialized ? explode(' | ', $credit_note_ids_unserialized) : array();
+ }
+
+ return $this->credit_note_ids_unserialized;
+ }
+
+ /**
+ * Test the presence of a value in the [credit_note_ids] array column value.
+ * @param mixed $value
+ *
+ * @return boolean
+ */
+ public function hasCreditNoteId($value)
+ {
+ return in_array($value, $this->getCreditNoteIds());
+ } // hasCreditNoteId()
+
+ /**
+ * Get the [credit_note_versions] column value.
+ *
+ * @return array
+ */
+ public function getCreditNoteVersions()
+ {
+ if (null === $this->credit_note_versions_unserialized) {
+ $this->credit_note_versions_unserialized = array();
+ }
+ if (!$this->credit_note_versions_unserialized && null !== $this->credit_note_versions) {
+ $credit_note_versions_unserialized = substr($this->credit_note_versions, 2, -2);
+ $this->credit_note_versions_unserialized = $credit_note_versions_unserialized ? explode(' | ', $credit_note_versions_unserialized) : array();
+ }
+
+ return $this->credit_note_versions_unserialized;
+ }
+
+ /**
+ * Test the presence of a value in the [credit_note_versions] array column value.
+ * @param mixed $value
+ *
+ * @return boolean
+ */
+ public function hasCreditNoteVersion($value)
+ {
+ return in_array($value, $this->getCreditNoteVersions());
+ } // hasCreditNoteVersion()
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::ID] = true;
+ }
+
+ if ($this->aCreditNote !== null && $this->aCreditNote->getId() !== $v) {
+ $this->aCreditNote = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [ref] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteVersion 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[CreditNoteVersionTableMap::REF] = true;
+ }
+
+
+ return $this;
+ } // setRef()
+
+ /**
+ * Set the value of [invoice_ref] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setInvoiceRef($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->invoice_ref !== $v) {
+ $this->invoice_ref = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::INVOICE_REF] = true;
+ }
+
+
+ return $this;
+ } // setInvoiceRef()
+
+ /**
+ * Set the value of [invoice_address_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setInvoiceAddressId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->invoice_address_id !== $v) {
+ $this->invoice_address_id = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::INVOICE_ADDRESS_ID] = true;
+ }
+
+
+ return $this;
+ } // setInvoiceAddressId()
+
+ /**
+ * Sets the value of [invoice_date] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setInvoiceDate($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->invoice_date !== null || $dt !== null) {
+ if ($dt !== $this->invoice_date) {
+ $this->invoice_date = $dt;
+ $this->modifiedColumns[CreditNoteVersionTableMap::INVOICE_DATE] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setInvoiceDate()
+
+ /**
+ * Set the value of [order_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setOrderId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->order_id !== $v) {
+ $this->order_id = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::ORDER_ID] = true;
+ }
+
+
+ return $this;
+ } // setOrderId()
+
+ /**
+ * Set the value of [customer_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setCustomerId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->customer_id !== $v) {
+ $this->customer_id = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::CUSTOMER_ID] = true;
+ }
+
+
+ return $this;
+ } // setCustomerId()
+
+ /**
+ * Set the value of [parent_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setParentId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->parent_id !== $v) {
+ $this->parent_id = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::PARENT_ID] = true;
+ }
+
+
+ return $this;
+ } // setParentId()
+
+ /**
+ * Set the value of [type_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setTypeId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->type_id !== $v) {
+ $this->type_id = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::TYPE_ID] = true;
+ }
+
+
+ return $this;
+ } // setTypeId()
+
+ /**
+ * Set the value of [status_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setStatusId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->status_id !== $v) {
+ $this->status_id = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::STATUS_ID] = true;
+ }
+
+
+ return $this;
+ } // setStatusId()
+
+ /**
+ * Set the value of [currency_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setCurrencyId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->currency_id !== $v) {
+ $this->currency_id = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::CURRENCY_ID] = true;
+ }
+
+
+ return $this;
+ } // setCurrencyId()
+
+ /**
+ * Set the value of [currency_rate] column.
+ *
+ * @param double $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setCurrencyRate($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->currency_rate !== $v) {
+ $this->currency_rate = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::CURRENCY_RATE] = true;
+ }
+
+
+ return $this;
+ } // setCurrencyRate()
+
+ /**
+ * Set the value of [total_price] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setTotalPrice($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->total_price !== $v) {
+ $this->total_price = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::TOTAL_PRICE] = true;
+ }
+
+
+ return $this;
+ } // setTotalPrice()
+
+ /**
+ * Set the value of [total_price_with_tax] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setTotalPriceWithTax($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->total_price_with_tax !== $v) {
+ $this->total_price_with_tax = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::TOTAL_PRICE_WITH_TAX] = true;
+ }
+
+
+ return $this;
+ } // setTotalPriceWithTax()
+
+ /**
+ * Set the value of [discount_without_tax] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setDiscountWithoutTax($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->discount_without_tax !== $v) {
+ $this->discount_without_tax = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::DISCOUNT_WITHOUT_TAX] = true;
+ }
+
+
+ return $this;
+ } // setDiscountWithoutTax()
+
+ /**
+ * Set the value of [discount_with_tax] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setDiscountWithTax($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->discount_with_tax !== $v) {
+ $this->discount_with_tax = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::DISCOUNT_WITH_TAX] = true;
+ }
+
+
+ return $this;
+ } // setDiscountWithTax()
+
+ /**
+ * Sets the value of the [allow_partial_use] column.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ *
+ * @param boolean|integer|string $v The new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setAllowPartialUse($v)
+ {
+ if ($v !== null) {
+ if (is_string($v)) {
+ $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ } else {
+ $v = (boolean) $v;
+ }
+ }
+
+ if ($this->allow_partial_use !== $v) {
+ $this->allow_partial_use = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::ALLOW_PARTIAL_USE] = true;
+ }
+
+
+ return $this;
+ } // setAllowPartialUse()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[CreditNoteVersionTableMap::CREATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[CreditNoteVersionTableMap::UPDATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::VERSION] = true;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ if ($dt !== $this->version_created_at) {
+ $this->version_created_at = $dt;
+ $this->modifiedColumns[CreditNoteVersionTableMap::VERSION_CREATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::VERSION_CREATED_BY] = true;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
+ /**
+ * Set the value of [order_id_version] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setOrderIdVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->order_id_version !== $v) {
+ $this->order_id_version = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::ORDER_ID_VERSION] = true;
+ }
+
+
+ return $this;
+ } // setOrderIdVersion()
+
+ /**
+ * Set the value of [customer_id_version] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setCustomerIdVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->customer_id_version !== $v) {
+ $this->customer_id_version = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::CUSTOMER_ID_VERSION] = true;
+ }
+
+
+ return $this;
+ } // setCustomerIdVersion()
+
+ /**
+ * Set the value of [parent_id_version] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setParentIdVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->parent_id_version !== $v) {
+ $this->parent_id_version = $v;
+ $this->modifiedColumns[CreditNoteVersionTableMap::PARENT_ID_VERSION] = true;
+ }
+
+
+ return $this;
+ } // setParentIdVersion()
+
+ /**
+ * Set the value of [credit_note_ids] column.
+ *
+ * @param array $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setCreditNoteIds($v)
+ {
+ if ($this->credit_note_ids_unserialized !== $v) {
+ $this->credit_note_ids_unserialized = $v;
+ $this->credit_note_ids = '| ' . implode(' | ', $v) . ' |';
+ $this->modifiedColumns[CreditNoteVersionTableMap::CREDIT_NOTE_IDS] = true;
+ }
+
+
+ return $this;
+ } // setCreditNoteIds()
+
+ /**
+ * Adds a value to the [credit_note_ids] array column value.
+ * @param mixed $value
+ *
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function addCreditNoteId($value)
+ {
+ $currentArray = $this->getCreditNoteIds();
+ $currentArray []= $value;
+ $this->setCreditNoteIds($currentArray);
+
+ return $this;
+ } // addCreditNoteId()
+
+ /**
+ * Removes a value from the [credit_note_ids] array column value.
+ * @param mixed $value
+ *
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function removeCreditNoteId($value)
+ {
+ $targetArray = array();
+ foreach ($this->getCreditNoteIds() as $element) {
+ if ($element != $value) {
+ $targetArray []= $element;
+ }
+ }
+ $this->setCreditNoteIds($targetArray);
+
+ return $this;
+ } // removeCreditNoteId()
+
+ /**
+ * Set the value of [credit_note_versions] column.
+ *
+ * @param array $v new value
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function setCreditNoteVersions($v)
+ {
+ if ($this->credit_note_versions_unserialized !== $v) {
+ $this->credit_note_versions_unserialized = $v;
+ $this->credit_note_versions = '| ' . implode(' | ', $v) . ' |';
+ $this->modifiedColumns[CreditNoteVersionTableMap::CREDIT_NOTE_VERSIONS] = true;
+ }
+
+
+ return $this;
+ } // setCreditNoteVersions()
+
+ /**
+ * Adds a value to the [credit_note_versions] array column value.
+ * @param mixed $value
+ *
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function addCreditNoteVersion($value)
+ {
+ $currentArray = $this->getCreditNoteVersions();
+ $currentArray []= $value;
+ $this->setCreditNoteVersions($currentArray);
+
+ return $this;
+ } // addCreditNoteVersion()
+
+ /**
+ * Removes a value from the [credit_note_versions] array column value.
+ * @param mixed $value
+ *
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ */
+ public function removeCreditNoteVersion($value)
+ {
+ $targetArray = array();
+ foreach ($this->getCreditNoteVersions() as $element) {
+ if ($element != $value) {
+ $targetArray []= $element;
+ }
+ }
+ $this->setCreditNoteVersions($targetArray);
+
+ return $this;
+ } // removeCreditNoteVersion()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->total_price !== '0.000000') {
+ return false;
+ }
+
+ if ($this->total_price_with_tax !== '0.000000') {
+ return false;
+ }
+
+ if ($this->discount_without_tax !== '0.000000') {
+ return false;
+ }
+
+ if ($this->discount_with_tax !== '0.000000') {
+ return false;
+ }
+
+ if ($this->allow_partial_use !== true) {
+ return false;
+ }
+
+ if ($this->version !== 0) {
+ return false;
+ }
+
+ if ($this->order_id_version !== 0) {
+ return false;
+ }
+
+ if ($this->customer_id_version !== 0) {
+ return false;
+ }
+
+ if ($this->parent_id_version !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CreditNoteVersionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CreditNoteVersionTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->ref = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CreditNoteVersionTableMap::translateFieldName('InvoiceRef', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->invoice_ref = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CreditNoteVersionTableMap::translateFieldName('InvoiceAddressId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->invoice_address_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CreditNoteVersionTableMap::translateFieldName('InvoiceDate', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->invoice_date = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CreditNoteVersionTableMap::translateFieldName('OrderId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->order_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CreditNoteVersionTableMap::translateFieldName('CustomerId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->customer_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CreditNoteVersionTableMap::translateFieldName('ParentId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->parent_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CreditNoteVersionTableMap::translateFieldName('TypeId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->type_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CreditNoteVersionTableMap::translateFieldName('StatusId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->status_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CreditNoteVersionTableMap::translateFieldName('CurrencyId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->currency_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CreditNoteVersionTableMap::translateFieldName('CurrencyRate', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->currency_rate = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CreditNoteVersionTableMap::translateFieldName('TotalPrice', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->total_price = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CreditNoteVersionTableMap::translateFieldName('TotalPriceWithTax', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->total_price_with_tax = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : CreditNoteVersionTableMap::translateFieldName('DiscountWithoutTax', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->discount_without_tax = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : CreditNoteVersionTableMap::translateFieldName('DiscountWithTax', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->discount_with_tax = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : CreditNoteVersionTableMap::translateFieldName('AllowPartialUse', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->allow_partial_use = (null !== $col) ? (boolean) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : CreditNoteVersionTableMap::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 ? 18 + $startcol : CreditNoteVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 19 + $startcol : CreditNoteVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 20 + $startcol : CreditNoteVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 21 + $startcol : CreditNoteVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version_created_by = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 22 + $startcol : CreditNoteVersionTableMap::translateFieldName('OrderIdVersion', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->order_id_version = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 23 + $startcol : CreditNoteVersionTableMap::translateFieldName('CustomerIdVersion', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->customer_id_version = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 24 + $startcol : CreditNoteVersionTableMap::translateFieldName('ParentIdVersion', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->parent_id_version = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 25 + $startcol : CreditNoteVersionTableMap::translateFieldName('CreditNoteIds', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->credit_note_ids = $col;
+ $this->credit_note_ids_unserialized = null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 26 + $startcol : CreditNoteVersionTableMap::translateFieldName('CreditNoteVersions', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->credit_note_versions = $col;
+ $this->credit_note_versions_unserialized = null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 27; // 27 = CreditNoteVersionTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \CreditNote\Model\CreditNoteVersion object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCreditNote !== null && $this->id !== $this->aCreditNote->getId()) {
+ $this->aCreditNote = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteVersionTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCreditNoteVersionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCreditNote = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see CreditNoteVersion::setDeleted()
+ * @see CreditNoteVersion::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteVersionTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCreditNoteVersionQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see doSave()
+ */
+ public function save(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteVersionTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CreditNoteVersionTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCreditNote !== null) {
+ if ($this->aCreditNote->isModified() || $this->aCreditNote->isNew()) {
+ $affectedRows += $this->aCreditNote->save($con);
+ }
+ $this->setCreditNote($this->aCreditNote);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CreditNoteVersionTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::REF)) {
+ $modifiedColumns[':p' . $index++] = 'REF';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::INVOICE_REF)) {
+ $modifiedColumns[':p' . $index++] = 'INVOICE_REF';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::INVOICE_ADDRESS_ID)) {
+ $modifiedColumns[':p' . $index++] = 'INVOICE_ADDRESS_ID';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::INVOICE_DATE)) {
+ $modifiedColumns[':p' . $index++] = 'INVOICE_DATE';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::ORDER_ID)) {
+ $modifiedColumns[':p' . $index++] = 'ORDER_ID';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::CUSTOMER_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CUSTOMER_ID';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::PARENT_ID)) {
+ $modifiedColumns[':p' . $index++] = 'PARENT_ID';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::TYPE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'TYPE_ID';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::STATUS_ID)) {
+ $modifiedColumns[':p' . $index++] = 'STATUS_ID';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::CURRENCY_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CURRENCY_ID';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::CURRENCY_RATE)) {
+ $modifiedColumns[':p' . $index++] = 'CURRENCY_RATE';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::TOTAL_PRICE)) {
+ $modifiedColumns[':p' . $index++] = 'TOTAL_PRICE';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::TOTAL_PRICE_WITH_TAX)) {
+ $modifiedColumns[':p' . $index++] = 'TOTAL_PRICE_WITH_TAX';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::DISCOUNT_WITHOUT_TAX)) {
+ $modifiedColumns[':p' . $index++] = 'DISCOUNT_WITHOUT_TAX';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::DISCOUNT_WITH_TAX)) {
+ $modifiedColumns[':p' . $index++] = 'DISCOUNT_WITH_TAX';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::ALLOW_PARTIAL_USE)) {
+ $modifiedColumns[':p' . $index++] = 'ALLOW_PARTIAL_USE';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::VERSION)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_BY';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::ORDER_ID_VERSION)) {
+ $modifiedColumns[':p' . $index++] = 'ORDER_ID_VERSION';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::CUSTOMER_ID_VERSION)) {
+ $modifiedColumns[':p' . $index++] = 'CUSTOMER_ID_VERSION';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::PARENT_ID_VERSION)) {
+ $modifiedColumns[':p' . $index++] = 'PARENT_ID_VERSION';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::CREDIT_NOTE_IDS)) {
+ $modifiedColumns[':p' . $index++] = 'CREDIT_NOTE_IDS';
+ }
+ if ($this->isColumnModified(CreditNoteVersionTableMap::CREDIT_NOTE_VERSIONS)) {
+ $modifiedColumns[':p' . $index++] = 'CREDIT_NOTE_VERSIONS';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO credit_note_version (%s) VALUES (%s)',
+ 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 'INVOICE_REF':
+ $stmt->bindValue($identifier, $this->invoice_ref, PDO::PARAM_STR);
+ break;
+ case 'INVOICE_ADDRESS_ID':
+ $stmt->bindValue($identifier, $this->invoice_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 'ORDER_ID':
+ $stmt->bindValue($identifier, $this->order_id, PDO::PARAM_INT);
+ break;
+ case 'CUSTOMER_ID':
+ $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT);
+ break;
+ case 'PARENT_ID':
+ $stmt->bindValue($identifier, $this->parent_id, PDO::PARAM_INT);
+ break;
+ case 'TYPE_ID':
+ $stmt->bindValue($identifier, $this->type_id, PDO::PARAM_INT);
+ break;
+ case 'STATUS_ID':
+ $stmt->bindValue($identifier, $this->status_id, PDO::PARAM_INT);
+ 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 'TOTAL_PRICE':
+ $stmt->bindValue($identifier, $this->total_price, PDO::PARAM_STR);
+ break;
+ case 'TOTAL_PRICE_WITH_TAX':
+ $stmt->bindValue($identifier, $this->total_price_with_tax, PDO::PARAM_STR);
+ break;
+ case 'DISCOUNT_WITHOUT_TAX':
+ $stmt->bindValue($identifier, $this->discount_without_tax, PDO::PARAM_STR);
+ break;
+ case 'DISCOUNT_WITH_TAX':
+ $stmt->bindValue($identifier, $this->discount_with_tax, PDO::PARAM_STR);
+ break;
+ case 'ALLOW_PARTIAL_USE':
+ $stmt->bindValue($identifier, (int) $this->allow_partial_use, 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;
+ case 'VERSION':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case 'VERSION_CREATED_AT':
+ $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION_CREATED_BY':
+ $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
+ break;
+ case 'ORDER_ID_VERSION':
+ $stmt->bindValue($identifier, $this->order_id_version, PDO::PARAM_INT);
+ break;
+ case 'CUSTOMER_ID_VERSION':
+ $stmt->bindValue($identifier, $this->customer_id_version, PDO::PARAM_INT);
+ break;
+ case 'PARENT_ID_VERSION':
+ $stmt->bindValue($identifier, $this->parent_id_version, PDO::PARAM_INT);
+ break;
+ case 'CREDIT_NOTE_IDS':
+ $stmt->bindValue($identifier, $this->credit_note_ids, PDO::PARAM_STR);
+ break;
+ case 'CREDIT_NOTE_VERSIONS':
+ $stmt->bindValue($identifier, $this->credit_note_versions, 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);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteVersionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getRef();
+ break;
+ case 2:
+ return $this->getInvoiceRef();
+ break;
+ case 3:
+ return $this->getInvoiceAddressId();
+ break;
+ case 4:
+ return $this->getInvoiceDate();
+ break;
+ case 5:
+ return $this->getOrderId();
+ break;
+ case 6:
+ return $this->getCustomerId();
+ break;
+ case 7:
+ return $this->getParentId();
+ break;
+ case 8:
+ return $this->getTypeId();
+ break;
+ case 9:
+ return $this->getStatusId();
+ break;
+ case 10:
+ return $this->getCurrencyId();
+ break;
+ case 11:
+ return $this->getCurrencyRate();
+ break;
+ case 12:
+ return $this->getTotalPrice();
+ break;
+ case 13:
+ return $this->getTotalPriceWithTax();
+ break;
+ case 14:
+ return $this->getDiscountWithoutTax();
+ break;
+ case 15:
+ return $this->getDiscountWithTax();
+ break;
+ case 16:
+ return $this->getAllowPartialUse();
+ break;
+ case 17:
+ return $this->getCreatedAt();
+ break;
+ case 18:
+ return $this->getUpdatedAt();
+ break;
+ case 19:
+ return $this->getVersion();
+ break;
+ case 20:
+ return $this->getVersionCreatedAt();
+ break;
+ case 21:
+ return $this->getVersionCreatedBy();
+ break;
+ case 22:
+ return $this->getOrderIdVersion();
+ break;
+ case 23:
+ return $this->getCustomerIdVersion();
+ break;
+ case 24:
+ return $this->getParentIdVersion();
+ break;
+ case 25:
+ return $this->getCreditNoteIds();
+ break;
+ case 26:
+ return $this->getCreditNoteVersions();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CreditNoteVersion'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CreditNoteVersion'][serialize($this->getPrimaryKey())] = true;
+ $keys = CreditNoteVersionTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getRef(),
+ $keys[2] => $this->getInvoiceRef(),
+ $keys[3] => $this->getInvoiceAddressId(),
+ $keys[4] => $this->getInvoiceDate(),
+ $keys[5] => $this->getOrderId(),
+ $keys[6] => $this->getCustomerId(),
+ $keys[7] => $this->getParentId(),
+ $keys[8] => $this->getTypeId(),
+ $keys[9] => $this->getStatusId(),
+ $keys[10] => $this->getCurrencyId(),
+ $keys[11] => $this->getCurrencyRate(),
+ $keys[12] => $this->getTotalPrice(),
+ $keys[13] => $this->getTotalPriceWithTax(),
+ $keys[14] => $this->getDiscountWithoutTax(),
+ $keys[15] => $this->getDiscountWithTax(),
+ $keys[16] => $this->getAllowPartialUse(),
+ $keys[17] => $this->getCreatedAt(),
+ $keys[18] => $this->getUpdatedAt(),
+ $keys[19] => $this->getVersion(),
+ $keys[20] => $this->getVersionCreatedAt(),
+ $keys[21] => $this->getVersionCreatedBy(),
+ $keys[22] => $this->getOrderIdVersion(),
+ $keys[23] => $this->getCustomerIdVersion(),
+ $keys[24] => $this->getParentIdVersion(),
+ $keys[25] => $this->getCreditNoteIds(),
+ $keys[26] => $this->getCreditNoteVersions(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach ($virtualColumns as $key => $virtualColumn) {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCreditNote) {
+ $result['CreditNote'] = $this->aCreditNote->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CreditNoteVersionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+
+ return $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setRef($value);
+ break;
+ case 2:
+ $this->setInvoiceRef($value);
+ break;
+ case 3:
+ $this->setInvoiceAddressId($value);
+ break;
+ case 4:
+ $this->setInvoiceDate($value);
+ break;
+ case 5:
+ $this->setOrderId($value);
+ break;
+ case 6:
+ $this->setCustomerId($value);
+ break;
+ case 7:
+ $this->setParentId($value);
+ break;
+ case 8:
+ $this->setTypeId($value);
+ break;
+ case 9:
+ $this->setStatusId($value);
+ break;
+ case 10:
+ $this->setCurrencyId($value);
+ break;
+ case 11:
+ $this->setCurrencyRate($value);
+ break;
+ case 12:
+ $this->setTotalPrice($value);
+ break;
+ case 13:
+ $this->setTotalPriceWithTax($value);
+ break;
+ case 14:
+ $this->setDiscountWithoutTax($value);
+ break;
+ case 15:
+ $this->setDiscountWithTax($value);
+ break;
+ case 16:
+ $this->setAllowPartialUse($value);
+ break;
+ case 17:
+ $this->setCreatedAt($value);
+ break;
+ case 18:
+ $this->setUpdatedAt($value);
+ break;
+ case 19:
+ $this->setVersion($value);
+ break;
+ case 20:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 21:
+ $this->setVersionCreatedBy($value);
+ break;
+ case 22:
+ $this->setOrderIdVersion($value);
+ break;
+ case 23:
+ $this->setCustomerIdVersion($value);
+ break;
+ case 24:
+ $this->setParentIdVersion($value);
+ break;
+ case 25:
+ if (!is_array($value)) {
+ $v = trim(substr($value, 2, -2));
+ $value = $v ? explode(' | ', $v) : array();
+ }
+ $this->setCreditNoteIds($value);
+ break;
+ case 26:
+ if (!is_array($value)) {
+ $v = trim(substr($value, 2, -2));
+ $value = $v ? explode(' | ', $v) : array();
+ }
+ $this->setCreditNoteVersions($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CreditNoteVersionTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setRef($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setInvoiceRef($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setInvoiceAddressId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setInvoiceDate($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setOrderId($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCustomerId($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setParentId($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setTypeId($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setStatusId($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setCurrencyId($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setCurrencyRate($arr[$keys[11]]);
+ if (array_key_exists($keys[12], $arr)) $this->setTotalPrice($arr[$keys[12]]);
+ if (array_key_exists($keys[13], $arr)) $this->setTotalPriceWithTax($arr[$keys[13]]);
+ if (array_key_exists($keys[14], $arr)) $this->setDiscountWithoutTax($arr[$keys[14]]);
+ if (array_key_exists($keys[15], $arr)) $this->setDiscountWithTax($arr[$keys[15]]);
+ if (array_key_exists($keys[16], $arr)) $this->setAllowPartialUse($arr[$keys[16]]);
+ if (array_key_exists($keys[17], $arr)) $this->setCreatedAt($arr[$keys[17]]);
+ if (array_key_exists($keys[18], $arr)) $this->setUpdatedAt($arr[$keys[18]]);
+ if (array_key_exists($keys[19], $arr)) $this->setVersion($arr[$keys[19]]);
+ if (array_key_exists($keys[20], $arr)) $this->setVersionCreatedAt($arr[$keys[20]]);
+ if (array_key_exists($keys[21], $arr)) $this->setVersionCreatedBy($arr[$keys[21]]);
+ if (array_key_exists($keys[22], $arr)) $this->setOrderIdVersion($arr[$keys[22]]);
+ if (array_key_exists($keys[23], $arr)) $this->setCustomerIdVersion($arr[$keys[23]]);
+ if (array_key_exists($keys[24], $arr)) $this->setParentIdVersion($arr[$keys[24]]);
+ if (array_key_exists($keys[25], $arr)) $this->setCreditNoteIds($arr[$keys[25]]);
+ if (array_key_exists($keys[26], $arr)) $this->setCreditNoteVersions($arr[$keys[26]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CreditNoteVersionTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CreditNoteVersionTableMap::ID)) $criteria->add(CreditNoteVersionTableMap::ID, $this->id);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::REF)) $criteria->add(CreditNoteVersionTableMap::REF, $this->ref);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::INVOICE_REF)) $criteria->add(CreditNoteVersionTableMap::INVOICE_REF, $this->invoice_ref);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::INVOICE_ADDRESS_ID)) $criteria->add(CreditNoteVersionTableMap::INVOICE_ADDRESS_ID, $this->invoice_address_id);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::INVOICE_DATE)) $criteria->add(CreditNoteVersionTableMap::INVOICE_DATE, $this->invoice_date);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::ORDER_ID)) $criteria->add(CreditNoteVersionTableMap::ORDER_ID, $this->order_id);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::CUSTOMER_ID)) $criteria->add(CreditNoteVersionTableMap::CUSTOMER_ID, $this->customer_id);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::PARENT_ID)) $criteria->add(CreditNoteVersionTableMap::PARENT_ID, $this->parent_id);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::TYPE_ID)) $criteria->add(CreditNoteVersionTableMap::TYPE_ID, $this->type_id);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::STATUS_ID)) $criteria->add(CreditNoteVersionTableMap::STATUS_ID, $this->status_id);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::CURRENCY_ID)) $criteria->add(CreditNoteVersionTableMap::CURRENCY_ID, $this->currency_id);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::CURRENCY_RATE)) $criteria->add(CreditNoteVersionTableMap::CURRENCY_RATE, $this->currency_rate);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::TOTAL_PRICE)) $criteria->add(CreditNoteVersionTableMap::TOTAL_PRICE, $this->total_price);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::TOTAL_PRICE_WITH_TAX)) $criteria->add(CreditNoteVersionTableMap::TOTAL_PRICE_WITH_TAX, $this->total_price_with_tax);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::DISCOUNT_WITHOUT_TAX)) $criteria->add(CreditNoteVersionTableMap::DISCOUNT_WITHOUT_TAX, $this->discount_without_tax);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::DISCOUNT_WITH_TAX)) $criteria->add(CreditNoteVersionTableMap::DISCOUNT_WITH_TAX, $this->discount_with_tax);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::ALLOW_PARTIAL_USE)) $criteria->add(CreditNoteVersionTableMap::ALLOW_PARTIAL_USE, $this->allow_partial_use);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::CREATED_AT)) $criteria->add(CreditNoteVersionTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::UPDATED_AT)) $criteria->add(CreditNoteVersionTableMap::UPDATED_AT, $this->updated_at);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::VERSION)) $criteria->add(CreditNoteVersionTableMap::VERSION, $this->version);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::VERSION_CREATED_AT)) $criteria->add(CreditNoteVersionTableMap::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::VERSION_CREATED_BY)) $criteria->add(CreditNoteVersionTableMap::VERSION_CREATED_BY, $this->version_created_by);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::ORDER_ID_VERSION)) $criteria->add(CreditNoteVersionTableMap::ORDER_ID_VERSION, $this->order_id_version);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::CUSTOMER_ID_VERSION)) $criteria->add(CreditNoteVersionTableMap::CUSTOMER_ID_VERSION, $this->customer_id_version);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::PARENT_ID_VERSION)) $criteria->add(CreditNoteVersionTableMap::PARENT_ID_VERSION, $this->parent_id_version);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::CREDIT_NOTE_IDS)) $criteria->add(CreditNoteVersionTableMap::CREDIT_NOTE_IDS, $this->credit_note_ids);
+ if ($this->isColumnModified(CreditNoteVersionTableMap::CREDIT_NOTE_VERSIONS)) $criteria->add(CreditNoteVersionTableMap::CREDIT_NOTE_VERSIONS, $this->credit_note_versions);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CreditNoteVersionTableMap::DATABASE_NAME);
+ $criteria->add(CreditNoteVersionTableMap::ID, $this->id);
+ $criteria->add(CreditNoteVersionTableMap::VERSION, $this->version);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getVersion();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setVersion($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getVersion());
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of \CreditNote\Model\CreditNoteVersion (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setRef($this->getRef());
+ $copyObj->setInvoiceRef($this->getInvoiceRef());
+ $copyObj->setInvoiceAddressId($this->getInvoiceAddressId());
+ $copyObj->setInvoiceDate($this->getInvoiceDate());
+ $copyObj->setOrderId($this->getOrderId());
+ $copyObj->setCustomerId($this->getCustomerId());
+ $copyObj->setParentId($this->getParentId());
+ $copyObj->setTypeId($this->getTypeId());
+ $copyObj->setStatusId($this->getStatusId());
+ $copyObj->setCurrencyId($this->getCurrencyId());
+ $copyObj->setCurrencyRate($this->getCurrencyRate());
+ $copyObj->setTotalPrice($this->getTotalPrice());
+ $copyObj->setTotalPriceWithTax($this->getTotalPriceWithTax());
+ $copyObj->setDiscountWithoutTax($this->getDiscountWithoutTax());
+ $copyObj->setDiscountWithTax($this->getDiscountWithTax());
+ $copyObj->setAllowPartialUse($this->getAllowPartialUse());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
+ $copyObj->setOrderIdVersion($this->getOrderIdVersion());
+ $copyObj->setCustomerIdVersion($this->getCustomerIdVersion());
+ $copyObj->setParentIdVersion($this->getParentIdVersion());
+ $copyObj->setCreditNoteIds($this->getCreditNoteIds());
+ $copyObj->setCreditNoteVersions($this->getCreditNoteVersions());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return \CreditNote\Model\CreditNoteVersion Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCreditNote object.
+ *
+ * @param ChildCreditNote $v
+ * @return \CreditNote\Model\CreditNoteVersion The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCreditNote(ChildCreditNote $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aCreditNote = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCreditNote object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCreditNoteVersion($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCreditNote object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCreditNote The associated ChildCreditNote object.
+ * @throws PropelException
+ */
+ public function getCreditNote(ConnectionInterface $con = null)
+ {
+ if ($this->aCreditNote === null && ($this->id !== null)) {
+ $this->aCreditNote = ChildCreditNoteQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCreditNote->addCreditNoteVersions($this);
+ */
+ }
+
+ return $this->aCreditNote;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->ref = null;
+ $this->invoice_ref = null;
+ $this->invoice_address_id = null;
+ $this->invoice_date = null;
+ $this->order_id = null;
+ $this->customer_id = null;
+ $this->parent_id = null;
+ $this->type_id = null;
+ $this->status_id = null;
+ $this->currency_id = null;
+ $this->currency_rate = null;
+ $this->total_price = null;
+ $this->total_price_with_tax = null;
+ $this->discount_without_tax = null;
+ $this->discount_with_tax = null;
+ $this->allow_partial_use = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = null;
+ $this->order_id_version = null;
+ $this->customer_id_version = null;
+ $this->parent_id_version = null;
+ $this->credit_note_ids = null;
+ $this->credit_note_ids_unserialized = null;
+ $this->credit_note_versions = null;
+ $this->credit_note_versions_unserialized = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCreditNote = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CreditNoteVersionTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/local/modules/CreditNote/Model/Base/CreditNoteVersionQuery.php b/local/modules/CreditNote/Model/Base/CreditNoteVersionQuery.php
new file mode 100644
index 000000000..70a5d7f88
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/CreditNoteVersionQuery.php
@@ -0,0 +1,1650 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $version] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCreditNoteVersion|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CreditNoteVersionTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CreditNoteVersionTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * 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 ChildCreditNoteVersion A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, REF, INVOICE_REF, INVOICE_ADDRESS_ID, INVOICE_DATE, ORDER_ID, CUSTOMER_ID, PARENT_ID, TYPE_ID, STATUS_ID, CURRENCY_ID, CURRENCY_RATE, TOTAL_PRICE, TOTAL_PRICE_WITH_TAX, DISCOUNT_WITHOUT_TAX, DISCOUNT_WITH_TAX, ALLOW_PARTIAL_USE, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY, ORDER_ID_VERSION, CUSTOMER_ID_VERSION, PARENT_ID_VERSION, CREDIT_NOTE_IDS, CREDIT_NOTE_VERSIONS FROM credit_note_version WHERE ID = :p0 AND VERSION = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], 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 ChildCreditNoteVersion();
+ $obj->hydrate($row);
+ CreditNoteVersionTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCreditNoteVersion|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(CreditNoteVersionTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(CreditNoteVersionTableMap::VERSION, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(CreditNoteVersionTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(CreditNoteVersionTableMap::VERSION, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByCreditNote()
+ *
+ * @param mixed $id 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the ref column
+ *
+ * Example usage:
+ *
+ * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue'
+ * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%'
+ *
+ *
+ * @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 ChildCreditNoteVersionQuery 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(CreditNoteVersionTableMap::REF, $ref, $comparison);
+ }
+
+ /**
+ * Filter the query on the invoice_ref column
+ *
+ * Example usage:
+ *
+ * $query->filterByInvoiceRef('fooValue'); // WHERE invoice_ref = 'fooValue'
+ * $query->filterByInvoiceRef('%fooValue%'); // WHERE invoice_ref LIKE '%fooValue%'
+ *
+ *
+ * @param string $invoiceRef 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByInvoiceRef($invoiceRef = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($invoiceRef)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $invoiceRef)) {
+ $invoiceRef = str_replace('*', '%', $invoiceRef);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::INVOICE_REF, $invoiceRef, $comparison);
+ }
+
+ /**
+ * Filter the query on the invoice_address_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByInvoiceAddressId(1234); // WHERE invoice_address_id = 1234
+ * $query->filterByInvoiceAddressId(array(12, 34)); // WHERE invoice_address_id IN (12, 34)
+ * $query->filterByInvoiceAddressId(array('min' => 12)); // WHERE invoice_address_id > 12
+ *
+ *
+ * @param mixed $invoiceAddressId 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByInvoiceAddressId($invoiceAddressId = null, $comparison = null)
+ {
+ if (is_array($invoiceAddressId)) {
+ $useMinMax = false;
+ if (isset($invoiceAddressId['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::INVOICE_ADDRESS_ID, $invoiceAddressId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($invoiceAddressId['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::INVOICE_ADDRESS_ID, $invoiceAddressId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::INVOICE_ADDRESS_ID, $invoiceAddressId, $comparison);
+ }
+
+ /**
+ * Filter the query on the invoice_date column
+ *
+ * Example usage:
+ *
+ * $query->filterByInvoiceDate('2011-03-14'); // WHERE invoice_date = '2011-03-14'
+ * $query->filterByInvoiceDate('now'); // WHERE invoice_date = '2011-03-14'
+ * $query->filterByInvoiceDate(array('max' => 'yesterday')); // WHERE invoice_date > '2011-03-13'
+ *
+ *
+ * @param mixed $invoiceDate The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByInvoiceDate($invoiceDate = null, $comparison = null)
+ {
+ if (is_array($invoiceDate)) {
+ $useMinMax = false;
+ if (isset($invoiceDate['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::INVOICE_DATE, $invoiceDate['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($invoiceDate['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::INVOICE_DATE, $invoiceDate['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::INVOICE_DATE, $invoiceDate, $comparison);
+ }
+
+ /**
+ * Filter the query on the order_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByOrderId(1234); // WHERE order_id = 1234
+ * $query->filterByOrderId(array(12, 34)); // WHERE order_id IN (12, 34)
+ * $query->filterByOrderId(array('min' => 12)); // WHERE order_id > 12
+ *
+ *
+ * @param mixed $orderId 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByOrderId($orderId = null, $comparison = null)
+ {
+ if (is_array($orderId)) {
+ $useMinMax = false;
+ if (isset($orderId['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::ORDER_ID, $orderId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($orderId['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::ORDER_ID, $orderId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::ORDER_ID, $orderId, $comparison);
+ }
+
+ /**
+ * Filter the query on the customer_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCustomerId(1234); // WHERE customer_id = 1234
+ * $query->filterByCustomerId(array(12, 34)); // WHERE customer_id IN (12, 34)
+ * $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id > 12
+ *
+ *
+ * @param mixed $customerId 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByCustomerId($customerId = null, $comparison = null)
+ {
+ if (is_array($customerId)) {
+ $useMinMax = false;
+ if (isset($customerId['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::CUSTOMER_ID, $customerId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($customerId['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::CUSTOMER_ID, $customerId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::CUSTOMER_ID, $customerId, $comparison);
+ }
+
+ /**
+ * Filter the query on the parent_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByParentId(1234); // WHERE parent_id = 1234
+ * $query->filterByParentId(array(12, 34)); // WHERE parent_id IN (12, 34)
+ * $query->filterByParentId(array('min' => 12)); // WHERE parent_id > 12
+ *
+ *
+ * @param mixed $parentId 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByParentId($parentId = null, $comparison = null)
+ {
+ if (is_array($parentId)) {
+ $useMinMax = false;
+ if (isset($parentId['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::PARENT_ID, $parentId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($parentId['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::PARENT_ID, $parentId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::PARENT_ID, $parentId, $comparison);
+ }
+
+ /**
+ * Filter the query on the type_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByTypeId(1234); // WHERE type_id = 1234
+ * $query->filterByTypeId(array(12, 34)); // WHERE type_id IN (12, 34)
+ * $query->filterByTypeId(array('min' => 12)); // WHERE type_id > 12
+ *
+ *
+ * @param mixed $typeId 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByTypeId($typeId = null, $comparison = null)
+ {
+ if (is_array($typeId)) {
+ $useMinMax = false;
+ if (isset($typeId['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::TYPE_ID, $typeId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($typeId['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::TYPE_ID, $typeId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::TYPE_ID, $typeId, $comparison);
+ }
+
+ /**
+ * Filter the query on the status_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByStatusId(1234); // WHERE status_id = 1234
+ * $query->filterByStatusId(array(12, 34)); // WHERE status_id IN (12, 34)
+ * $query->filterByStatusId(array('min' => 12)); // WHERE status_id > 12
+ *
+ *
+ * @param mixed $statusId 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByStatusId($statusId = null, $comparison = null)
+ {
+ if (is_array($statusId)) {
+ $useMinMax = false;
+ if (isset($statusId['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::STATUS_ID, $statusId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($statusId['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::STATUS_ID, $statusId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::STATUS_ID, $statusId, $comparison);
+ }
+
+ /**
+ * Filter the query on the currency_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCurrencyId(1234); // WHERE currency_id = 1234
+ * $query->filterByCurrencyId(array(12, 34)); // WHERE currency_id IN (12, 34)
+ * $query->filterByCurrencyId(array('min' => 12)); // WHERE currency_id > 12
+ *
+ *
+ * @param mixed $currencyId 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByCurrencyId($currencyId = null, $comparison = null)
+ {
+ if (is_array($currencyId)) {
+ $useMinMax = false;
+ if (isset($currencyId['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::CURRENCY_ID, $currencyId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($currencyId['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::CURRENCY_ID, $currencyId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::CURRENCY_ID, $currencyId, $comparison);
+ }
+
+ /**
+ * Filter the query on the currency_rate column
+ *
+ * Example usage:
+ *
+ * $query->filterByCurrencyRate(1234); // WHERE currency_rate = 1234
+ * $query->filterByCurrencyRate(array(12, 34)); // WHERE currency_rate IN (12, 34)
+ * $query->filterByCurrencyRate(array('min' => 12)); // WHERE currency_rate > 12
+ *
+ *
+ * @param mixed $currencyRate 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByCurrencyRate($currencyRate = null, $comparison = null)
+ {
+ if (is_array($currencyRate)) {
+ $useMinMax = false;
+ if (isset($currencyRate['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::CURRENCY_RATE, $currencyRate['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($currencyRate['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::CURRENCY_RATE, $currencyRate['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::CURRENCY_RATE, $currencyRate, $comparison);
+ }
+
+ /**
+ * Filter the query on the total_price column
+ *
+ * Example usage:
+ *
+ * $query->filterByTotalPrice(1234); // WHERE total_price = 1234
+ * $query->filterByTotalPrice(array(12, 34)); // WHERE total_price IN (12, 34)
+ * $query->filterByTotalPrice(array('min' => 12)); // WHERE total_price > 12
+ *
+ *
+ * @param mixed $totalPrice 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByTotalPrice($totalPrice = null, $comparison = null)
+ {
+ if (is_array($totalPrice)) {
+ $useMinMax = false;
+ if (isset($totalPrice['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::TOTAL_PRICE, $totalPrice['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($totalPrice['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::TOTAL_PRICE, $totalPrice['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::TOTAL_PRICE, $totalPrice, $comparison);
+ }
+
+ /**
+ * Filter the query on the total_price_with_tax column
+ *
+ * Example usage:
+ *
+ * $query->filterByTotalPriceWithTax(1234); // WHERE total_price_with_tax = 1234
+ * $query->filterByTotalPriceWithTax(array(12, 34)); // WHERE total_price_with_tax IN (12, 34)
+ * $query->filterByTotalPriceWithTax(array('min' => 12)); // WHERE total_price_with_tax > 12
+ *
+ *
+ * @param mixed $totalPriceWithTax 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByTotalPriceWithTax($totalPriceWithTax = null, $comparison = null)
+ {
+ if (is_array($totalPriceWithTax)) {
+ $useMinMax = false;
+ if (isset($totalPriceWithTax['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::TOTAL_PRICE_WITH_TAX, $totalPriceWithTax['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($totalPriceWithTax['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::TOTAL_PRICE_WITH_TAX, $totalPriceWithTax['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::TOTAL_PRICE_WITH_TAX, $totalPriceWithTax, $comparison);
+ }
+
+ /**
+ * Filter the query on the discount_without_tax column
+ *
+ * Example usage:
+ *
+ * $query->filterByDiscountWithoutTax(1234); // WHERE discount_without_tax = 1234
+ * $query->filterByDiscountWithoutTax(array(12, 34)); // WHERE discount_without_tax IN (12, 34)
+ * $query->filterByDiscountWithoutTax(array('min' => 12)); // WHERE discount_without_tax > 12
+ *
+ *
+ * @param mixed $discountWithoutTax 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByDiscountWithoutTax($discountWithoutTax = null, $comparison = null)
+ {
+ if (is_array($discountWithoutTax)) {
+ $useMinMax = false;
+ if (isset($discountWithoutTax['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::DISCOUNT_WITHOUT_TAX, $discountWithoutTax['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($discountWithoutTax['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::DISCOUNT_WITHOUT_TAX, $discountWithoutTax['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::DISCOUNT_WITHOUT_TAX, $discountWithoutTax, $comparison);
+ }
+
+ /**
+ * Filter the query on the discount_with_tax column
+ *
+ * Example usage:
+ *
+ * $query->filterByDiscountWithTax(1234); // WHERE discount_with_tax = 1234
+ * $query->filterByDiscountWithTax(array(12, 34)); // WHERE discount_with_tax IN (12, 34)
+ * $query->filterByDiscountWithTax(array('min' => 12)); // WHERE discount_with_tax > 12
+ *
+ *
+ * @param mixed $discountWithTax 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByDiscountWithTax($discountWithTax = null, $comparison = null)
+ {
+ if (is_array($discountWithTax)) {
+ $useMinMax = false;
+ if (isset($discountWithTax['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::DISCOUNT_WITH_TAX, $discountWithTax['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($discountWithTax['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::DISCOUNT_WITH_TAX, $discountWithTax['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::DISCOUNT_WITH_TAX, $discountWithTax, $comparison);
+ }
+
+ /**
+ * Filter the query on the allow_partial_use column
+ *
+ * Example usage:
+ *
+ * $query->filterByAllowPartialUse(true); // WHERE allow_partial_use = true
+ * $query->filterByAllowPartialUse('yes'); // WHERE allow_partial_use = true
+ *
+ *
+ * @param boolean|string $allowPartialUse The value to use as filter.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByAllowPartialUse($allowPartialUse = null, $comparison = null)
+ {
+ if (is_string($allowPartialUse)) {
+ $allow_partial_use = in_array(strtolower($allowPartialUse), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::ALLOW_PARTIAL_USE, $allowPartialUse, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version)) {
+ $useMinMax = false;
+ if (isset($version['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($version['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
+ }
+
+ /**
+ * Filter the query on the order_id_version column
+ *
+ * Example usage:
+ *
+ * $query->filterByOrderIdVersion(1234); // WHERE order_id_version = 1234
+ * $query->filterByOrderIdVersion(array(12, 34)); // WHERE order_id_version IN (12, 34)
+ * $query->filterByOrderIdVersion(array('min' => 12)); // WHERE order_id_version > 12
+ *
+ *
+ * @param mixed $orderIdVersion 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByOrderIdVersion($orderIdVersion = null, $comparison = null)
+ {
+ if (is_array($orderIdVersion)) {
+ $useMinMax = false;
+ if (isset($orderIdVersion['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::ORDER_ID_VERSION, $orderIdVersion['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($orderIdVersion['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::ORDER_ID_VERSION, $orderIdVersion['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::ORDER_ID_VERSION, $orderIdVersion, $comparison);
+ }
+
+ /**
+ * Filter the query on the customer_id_version column
+ *
+ * Example usage:
+ *
+ * $query->filterByCustomerIdVersion(1234); // WHERE customer_id_version = 1234
+ * $query->filterByCustomerIdVersion(array(12, 34)); // WHERE customer_id_version IN (12, 34)
+ * $query->filterByCustomerIdVersion(array('min' => 12)); // WHERE customer_id_version > 12
+ *
+ *
+ * @param mixed $customerIdVersion 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByCustomerIdVersion($customerIdVersion = null, $comparison = null)
+ {
+ if (is_array($customerIdVersion)) {
+ $useMinMax = false;
+ if (isset($customerIdVersion['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::CUSTOMER_ID_VERSION, $customerIdVersion['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($customerIdVersion['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::CUSTOMER_ID_VERSION, $customerIdVersion['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::CUSTOMER_ID_VERSION, $customerIdVersion, $comparison);
+ }
+
+ /**
+ * Filter the query on the parent_id_version column
+ *
+ * Example usage:
+ *
+ * $query->filterByParentIdVersion(1234); // WHERE parent_id_version = 1234
+ * $query->filterByParentIdVersion(array(12, 34)); // WHERE parent_id_version IN (12, 34)
+ * $query->filterByParentIdVersion(array('min' => 12)); // WHERE parent_id_version > 12
+ *
+ *
+ * @param mixed $parentIdVersion 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 ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByParentIdVersion($parentIdVersion = null, $comparison = null)
+ {
+ if (is_array($parentIdVersion)) {
+ $useMinMax = false;
+ if (isset($parentIdVersion['min'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::PARENT_ID_VERSION, $parentIdVersion['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($parentIdVersion['max'])) {
+ $this->addUsingAlias(CreditNoteVersionTableMap::PARENT_ID_VERSION, $parentIdVersion['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::PARENT_ID_VERSION, $parentIdVersion, $comparison);
+ }
+
+ /**
+ * Filter the query on the credit_note_ids column
+ *
+ * @param array $creditNoteIds The values to use as filter.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteIds($creditNoteIds = null, $comparison = null)
+ {
+ $key = $this->getAliasedColName(CreditNoteVersionTableMap::CREDIT_NOTE_IDS);
+ if (null === $comparison || $comparison == Criteria::CONTAINS_ALL) {
+ foreach ($creditNoteIds as $value) {
+ $value = '%| ' . $value . ' |%';
+ if ($this->containsKey($key)) {
+ $this->addAnd($key, $value, Criteria::LIKE);
+ } else {
+ $this->add($key, $value, Criteria::LIKE);
+ }
+ }
+
+ return $this;
+ } elseif ($comparison == Criteria::CONTAINS_SOME) {
+ foreach ($creditNoteIds as $value) {
+ $value = '%| ' . $value . ' |%';
+ if ($this->containsKey($key)) {
+ $this->addOr($key, $value, Criteria::LIKE);
+ } else {
+ $this->add($key, $value, Criteria::LIKE);
+ }
+ }
+
+ return $this;
+ } elseif ($comparison == Criteria::CONTAINS_NONE) {
+ foreach ($creditNoteIds as $value) {
+ $value = '%| ' . $value . ' |%';
+ if ($this->containsKey($key)) {
+ $this->addAnd($key, $value, Criteria::NOT_LIKE);
+ } else {
+ $this->add($key, $value, Criteria::NOT_LIKE);
+ }
+ }
+ $this->addOr($key, null, Criteria::ISNULL);
+
+ return $this;
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::CREDIT_NOTE_IDS, $creditNoteIds, $comparison);
+ }
+
+ /**
+ * Filter the query on the credit_note_ids column
+ * @param mixed $creditNoteIds The value to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::CONTAINS_ALL
+ *
+ * @return ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteId($creditNoteIds = null, $comparison = null)
+ {
+ if (null === $comparison || $comparison == Criteria::CONTAINS_ALL) {
+ if (is_scalar($creditNoteIds)) {
+ $creditNoteIds = '%| ' . $creditNoteIds . ' |%';
+ $comparison = Criteria::LIKE;
+ }
+ } elseif ($comparison == Criteria::CONTAINS_NONE) {
+ $creditNoteIds = '%| ' . $creditNoteIds . ' |%';
+ $comparison = Criteria::NOT_LIKE;
+ $key = $this->getAliasedColName(CreditNoteVersionTableMap::CREDIT_NOTE_IDS);
+ if ($this->containsKey($key)) {
+ $this->addAnd($key, $creditNoteIds, $comparison);
+ } else {
+ $this->addAnd($key, $creditNoteIds, $comparison);
+ }
+ $this->addOr($key, null, Criteria::ISNULL);
+
+ return $this;
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::CREDIT_NOTE_IDS, $creditNoteIds, $comparison);
+ }
+
+ /**
+ * Filter the query on the credit_note_versions column
+ *
+ * @param array $creditNoteVersions The values to use as filter.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteVersions($creditNoteVersions = null, $comparison = null)
+ {
+ $key = $this->getAliasedColName(CreditNoteVersionTableMap::CREDIT_NOTE_VERSIONS);
+ if (null === $comparison || $comparison == Criteria::CONTAINS_ALL) {
+ foreach ($creditNoteVersions as $value) {
+ $value = '%| ' . $value . ' |%';
+ if ($this->containsKey($key)) {
+ $this->addAnd($key, $value, Criteria::LIKE);
+ } else {
+ $this->add($key, $value, Criteria::LIKE);
+ }
+ }
+
+ return $this;
+ } elseif ($comparison == Criteria::CONTAINS_SOME) {
+ foreach ($creditNoteVersions as $value) {
+ $value = '%| ' . $value . ' |%';
+ if ($this->containsKey($key)) {
+ $this->addOr($key, $value, Criteria::LIKE);
+ } else {
+ $this->add($key, $value, Criteria::LIKE);
+ }
+ }
+
+ return $this;
+ } elseif ($comparison == Criteria::CONTAINS_NONE) {
+ foreach ($creditNoteVersions as $value) {
+ $value = '%| ' . $value . ' |%';
+ if ($this->containsKey($key)) {
+ $this->addAnd($key, $value, Criteria::NOT_LIKE);
+ } else {
+ $this->add($key, $value, Criteria::NOT_LIKE);
+ }
+ }
+ $this->addOr($key, null, Criteria::ISNULL);
+
+ return $this;
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::CREDIT_NOTE_VERSIONS, $creditNoteVersions, $comparison);
+ }
+
+ /**
+ * Filter the query on the credit_note_versions column
+ * @param mixed $creditNoteVersions The value to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::CONTAINS_ALL
+ *
+ * @return ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteVersion($creditNoteVersions = null, $comparison = null)
+ {
+ if (null === $comparison || $comparison == Criteria::CONTAINS_ALL) {
+ if (is_scalar($creditNoteVersions)) {
+ $creditNoteVersions = '%| ' . $creditNoteVersions . ' |%';
+ $comparison = Criteria::LIKE;
+ }
+ } elseif ($comparison == Criteria::CONTAINS_NONE) {
+ $creditNoteVersions = '%| ' . $creditNoteVersions . ' |%';
+ $comparison = Criteria::NOT_LIKE;
+ $key = $this->getAliasedColName(CreditNoteVersionTableMap::CREDIT_NOTE_VERSIONS);
+ if ($this->containsKey($key)) {
+ $this->addAnd($key, $creditNoteVersions, $comparison);
+ } else {
+ $this->addAnd($key, $creditNoteVersions, $comparison);
+ }
+ $this->addOr($key, null, Criteria::ISNULL);
+
+ return $this;
+ }
+
+ return $this->addUsingAlias(CreditNoteVersionTableMap::CREDIT_NOTE_VERSIONS, $creditNoteVersions, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNote object
+ *
+ * @param \CreditNote\Model\CreditNote|ObjectCollection $creditNote The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function filterByCreditNote($creditNote, $comparison = null)
+ {
+ if ($creditNote instanceof \CreditNote\Model\CreditNote) {
+ return $this
+ ->addUsingAlias(CreditNoteVersionTableMap::ID, $creditNote->getId(), $comparison);
+ } elseif ($creditNote instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CreditNoteVersionTableMap::ID, $creditNote->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCreditNote() only accepts arguments of type \CreditNote\Model\CreditNote or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNote relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function joinCreditNote($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNote');
+
+ // 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, 'CreditNote');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNote relation CreditNote 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 \CreditNote\Model\CreditNoteQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCreditNote($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNote', '\CreditNote\Model\CreditNoteQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCreditNoteVersion $creditNoteVersion Object to remove from the list of results
+ *
+ * @return ChildCreditNoteVersionQuery The current query, for fluid interface
+ */
+ public function prune($creditNoteVersion = null)
+ {
+ if ($creditNoteVersion) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(CreditNoteVersionTableMap::ID), $creditNoteVersion->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(CreditNoteVersionTableMap::VERSION), $creditNoteVersion->getVersion(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the credit_note_version table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteVersionTableMap::DATABASE_NAME);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CreditNoteVersionTableMap::clearInstancePool();
+ CreditNoteVersionTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCreditNoteVersion or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCreditNoteVersion object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteVersionTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CreditNoteVersionTableMap::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+
+ CreditNoteVersionTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CreditNoteVersionTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // CreditNoteVersionQuery
diff --git a/local/modules/CreditNote/Model/Base/OrderCreditNote.php b/local/modules/CreditNote/Model/Base/OrderCreditNote.php
new file mode 100644
index 000000000..e0c7f730c
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/OrderCreditNote.php
@@ -0,0 +1,1513 @@
+amount_price = '0.000000';
+ }
+
+ /**
+ * Initializes internal state of CreditNote\Model\Base\OrderCreditNote object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !!$this->modifiedColumns;
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return boolean true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ if (isset($this->modifiedColumns[$col])) {
+ unset($this->modifiedColumns[$col]);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another OrderCreditNote instance. If
+ * obj is an instance of OrderCreditNote, delegates to
+ * equals(OrderCreditNote). Otherwise, returns false.
+ *
+ * @param mixed $obj The object to compare to.
+ * @return boolean Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return array_key_exists($name, $this->virtualColumns);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return mixed
+ *
+ * @throws PropelException
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return OrderCreditNote The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return OrderCreditNote The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+
+ return $this;
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [order_id] column value.
+ *
+ * @return int
+ */
+ public function getOrderId()
+ {
+
+ return $this->order_id;
+ }
+
+ /**
+ * Get the [credit_note_id] column value.
+ *
+ * @return int
+ */
+ public function getCreditNoteId()
+ {
+
+ return $this->credit_note_id;
+ }
+
+ /**
+ * Get the [amount_price] column value.
+ *
+ * @return string
+ */
+ public function getAmountPrice()
+ {
+
+ return $this->amount_price;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [order_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\OrderCreditNote The current object (for fluent API support)
+ */
+ public function setOrderId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->order_id !== $v) {
+ $this->order_id = $v;
+ $this->modifiedColumns[OrderCreditNoteTableMap::ORDER_ID] = true;
+ }
+
+ if ($this->aOrder !== null && $this->aOrder->getId() !== $v) {
+ $this->aOrder = null;
+ }
+
+
+ return $this;
+ } // setOrderId()
+
+ /**
+ * Set the value of [credit_note_id] column.
+ *
+ * @param int $v new value
+ * @return \CreditNote\Model\OrderCreditNote The current object (for fluent API support)
+ */
+ public function setCreditNoteId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->credit_note_id !== $v) {
+ $this->credit_note_id = $v;
+ $this->modifiedColumns[OrderCreditNoteTableMap::CREDIT_NOTE_ID] = true;
+ }
+
+ if ($this->aCreditNote !== null && $this->aCreditNote->getId() !== $v) {
+ $this->aCreditNote = null;
+ }
+
+
+ return $this;
+ } // setCreditNoteId()
+
+ /**
+ * Set the value of [amount_price] column.
+ *
+ * @param string $v new value
+ * @return \CreditNote\Model\OrderCreditNote The current object (for fluent API support)
+ */
+ public function setAmountPrice($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->amount_price !== $v) {
+ $this->amount_price = $v;
+ $this->modifiedColumns[OrderCreditNoteTableMap::AMOUNT_PRICE] = true;
+ }
+
+
+ return $this;
+ } // setAmountPrice()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\OrderCreditNote The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[OrderCreditNoteTableMap::CREATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \CreditNote\Model\OrderCreditNote The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[OrderCreditNoteTableMap::UPDATED_AT] = true;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->amount_price !== '0.000000') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderCreditNoteTableMap::translateFieldName('OrderId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->order_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderCreditNoteTableMap::translateFieldName('CreditNoteId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->credit_note_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderCreditNoteTableMap::translateFieldName('AmountPrice', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->amount_price = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderCreditNoteTableMap::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 ? 4 + $startcol : OrderCreditNoteTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = OrderCreditNoteTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \CreditNote\Model\OrderCreditNote object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aOrder !== null && $this->order_id !== $this->aOrder->getId()) {
+ $this->aOrder = null;
+ }
+ if ($this->aCreditNote !== null && $this->credit_note_id !== $this->aCreditNote->getId()) {
+ $this->aCreditNote = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(OrderCreditNoteTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildOrderCreditNoteQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aOrder = null;
+ $this->aCreditNote = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see OrderCreditNote::setDeleted()
+ * @see OrderCreditNote::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderCreditNoteTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildOrderCreditNoteQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see doSave()
+ */
+ public function save(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderCreditNoteTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(OrderCreditNoteTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(OrderCreditNoteTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(OrderCreditNoteTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ OrderCreditNoteTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aOrder !== null) {
+ if ($this->aOrder->isModified() || $this->aOrder->isNew()) {
+ $affectedRows += $this->aOrder->save($con);
+ }
+ $this->setOrder($this->aOrder);
+ }
+
+ if ($this->aCreditNote !== null) {
+ if ($this->aCreditNote->isModified() || $this->aCreditNote->isNew()) {
+ $affectedRows += $this->aCreditNote->save($con);
+ }
+ $this->setCreditNote($this->aCreditNote);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(OrderCreditNoteTableMap::ORDER_ID)) {
+ $modifiedColumns[':p' . $index++] = 'ORDER_ID';
+ }
+ if ($this->isColumnModified(OrderCreditNoteTableMap::CREDIT_NOTE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CREDIT_NOTE_ID';
+ }
+ if ($this->isColumnModified(OrderCreditNoteTableMap::AMOUNT_PRICE)) {
+ $modifiedColumns[':p' . $index++] = 'AMOUNT_PRICE';
+ }
+ if ($this->isColumnModified(OrderCreditNoteTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(OrderCreditNoteTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO order_credit_note (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ORDER_ID':
+ $stmt->bindValue($identifier, $this->order_id, PDO::PARAM_INT);
+ break;
+ case 'CREDIT_NOTE_ID':
+ $stmt->bindValue($identifier, $this->credit_note_id, PDO::PARAM_INT);
+ break;
+ case 'AMOUNT_PRICE':
+ $stmt->bindValue($identifier, $this->amount_price, 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);
+ 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);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = OrderCreditNoteTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getOrderId();
+ break;
+ case 1:
+ return $this->getCreditNoteId();
+ break;
+ case 2:
+ return $this->getAmountPrice();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['OrderCreditNote'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['OrderCreditNote'][serialize($this->getPrimaryKey())] = true;
+ $keys = OrderCreditNoteTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getOrderId(),
+ $keys[1] => $this->getCreditNoteId(),
+ $keys[2] => $this->getAmountPrice(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach ($virtualColumns as $key => $virtualColumn) {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aOrder) {
+ $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCreditNote) {
+ $result['CreditNote'] = $this->aCreditNote->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = OrderCreditNoteTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+
+ return $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setOrderId($value);
+ break;
+ case 1:
+ $this->setCreditNoteId($value);
+ break;
+ case 2:
+ $this->setAmountPrice($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
+ {
+ $keys = OrderCreditNoteTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setOrderId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCreditNoteId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setAmountPrice($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]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(OrderCreditNoteTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(OrderCreditNoteTableMap::ORDER_ID)) $criteria->add(OrderCreditNoteTableMap::ORDER_ID, $this->order_id);
+ if ($this->isColumnModified(OrderCreditNoteTableMap::CREDIT_NOTE_ID)) $criteria->add(OrderCreditNoteTableMap::CREDIT_NOTE_ID, $this->credit_note_id);
+ if ($this->isColumnModified(OrderCreditNoteTableMap::AMOUNT_PRICE)) $criteria->add(OrderCreditNoteTableMap::AMOUNT_PRICE, $this->amount_price);
+ if ($this->isColumnModified(OrderCreditNoteTableMap::CREATED_AT)) $criteria->add(OrderCreditNoteTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(OrderCreditNoteTableMap::UPDATED_AT)) $criteria->add(OrderCreditNoteTableMap::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(OrderCreditNoteTableMap::DATABASE_NAME);
+ $criteria->add(OrderCreditNoteTableMap::ORDER_ID, $this->order_id);
+ $criteria->add(OrderCreditNoteTableMap::CREDIT_NOTE_ID, $this->credit_note_id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getOrderId();
+ $pks[1] = $this->getCreditNoteId();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setOrderId($keys[0]);
+ $this->setCreditNoteId($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getOrderId()) && (null === $this->getCreditNoteId());
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of \CreditNote\Model\OrderCreditNote (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setOrderId($this->getOrderId());
+ $copyObj->setCreditNoteId($this->getCreditNoteId());
+ $copyObj->setAmountPrice($this->getAmountPrice());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return \CreditNote\Model\OrderCreditNote Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Declares an association between this object and a ChildOrder object.
+ *
+ * @param ChildOrder $v
+ * @return \CreditNote\Model\OrderCreditNote The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setOrder(ChildOrder $v = null)
+ {
+ if ($v === null) {
+ $this->setOrderId(NULL);
+ } else {
+ $this->setOrderId($v->getId());
+ }
+
+ $this->aOrder = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildOrder object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrderCreditNote($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildOrder object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildOrder The associated ChildOrder object.
+ * @throws PropelException
+ */
+ public function getOrder(ConnectionInterface $con = null)
+ {
+ if ($this->aOrder === null && ($this->order_id !== null)) {
+ $this->aOrder = OrderQuery::create()->findPk($this->order_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aOrder->addOrderCreditNotes($this);
+ */
+ }
+
+ return $this->aOrder;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCreditNote object.
+ *
+ * @param ChildCreditNote $v
+ * @return \CreditNote\Model\OrderCreditNote The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCreditNote(ChildCreditNote $v = null)
+ {
+ if ($v === null) {
+ $this->setCreditNoteId(NULL);
+ } else {
+ $this->setCreditNoteId($v->getId());
+ }
+
+ $this->aCreditNote = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCreditNote object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrderCreditNote($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCreditNote object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCreditNote The associated ChildCreditNote object.
+ * @throws PropelException
+ */
+ public function getCreditNote(ConnectionInterface $con = null)
+ {
+ if ($this->aCreditNote === null && ($this->credit_note_id !== null)) {
+ $this->aCreditNote = ChildCreditNoteQuery::create()->findPk($this->credit_note_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCreditNote->addOrderCreditNotes($this);
+ */
+ }
+
+ return $this->aCreditNote;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->order_id = null;
+ $this->credit_note_id = null;
+ $this->amount_price = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aOrder = null;
+ $this->aCreditNote = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(OrderCreditNoteTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildOrderCreditNote The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[OrderCreditNoteTableMap::UPDATED_AT] = true;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/local/modules/CreditNote/Model/Base/OrderCreditNoteQuery.php b/local/modules/CreditNote/Model/Base/OrderCreditNoteQuery.php
new file mode 100644
index 000000000..93bf8f6b6
--- /dev/null
+++ b/local/modules/CreditNote/Model/Base/OrderCreditNoteQuery.php
@@ -0,0 +1,774 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$order_id, $credit_note_id] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildOrderCreditNote|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = OrderCreditNoteTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(OrderCreditNoteTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * 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 ChildOrderCreditNote A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ORDER_ID, CREDIT_NOTE_ID, AMOUNT_PRICE, CREATED_AT, UPDATED_AT FROM order_credit_note WHERE ORDER_ID = :p0 AND CREDIT_NOTE_ID = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], 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 ChildOrderCreditNote();
+ $obj->hydrate($row);
+ OrderCreditNoteTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildOrderCreditNote|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildOrderCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(OrderCreditNoteTableMap::ORDER_ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(OrderCreditNoteTableMap::CREDIT_NOTE_ID, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildOrderCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(OrderCreditNoteTableMap::ORDER_ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(OrderCreditNoteTableMap::CREDIT_NOTE_ID, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the order_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByOrderId(1234); // WHERE order_id = 1234
+ * $query->filterByOrderId(array(12, 34)); // WHERE order_id IN (12, 34)
+ * $query->filterByOrderId(array('min' => 12)); // WHERE order_id > 12
+ *
+ *
+ * @see filterByOrder()
+ *
+ * @param mixed $orderId 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 ChildOrderCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByOrderId($orderId = null, $comparison = null)
+ {
+ if (is_array($orderId)) {
+ $useMinMax = false;
+ if (isset($orderId['min'])) {
+ $this->addUsingAlias(OrderCreditNoteTableMap::ORDER_ID, $orderId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($orderId['max'])) {
+ $this->addUsingAlias(OrderCreditNoteTableMap::ORDER_ID, $orderId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderCreditNoteTableMap::ORDER_ID, $orderId, $comparison);
+ }
+
+ /**
+ * Filter the query on the credit_note_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreditNoteId(1234); // WHERE credit_note_id = 1234
+ * $query->filterByCreditNoteId(array(12, 34)); // WHERE credit_note_id IN (12, 34)
+ * $query->filterByCreditNoteId(array('min' => 12)); // WHERE credit_note_id > 12
+ *
+ *
+ * @see filterByCreditNote()
+ *
+ * @param mixed $creditNoteId 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 ChildOrderCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCreditNoteId($creditNoteId = null, $comparison = null)
+ {
+ if (is_array($creditNoteId)) {
+ $useMinMax = false;
+ if (isset($creditNoteId['min'])) {
+ $this->addUsingAlias(OrderCreditNoteTableMap::CREDIT_NOTE_ID, $creditNoteId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($creditNoteId['max'])) {
+ $this->addUsingAlias(OrderCreditNoteTableMap::CREDIT_NOTE_ID, $creditNoteId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderCreditNoteTableMap::CREDIT_NOTE_ID, $creditNoteId, $comparison);
+ }
+
+ /**
+ * Filter the query on the amount_price column
+ *
+ * Example usage:
+ *
+ * $query->filterByAmountPrice(1234); // WHERE amount_price = 1234
+ * $query->filterByAmountPrice(array(12, 34)); // WHERE amount_price IN (12, 34)
+ * $query->filterByAmountPrice(array('min' => 12)); // WHERE amount_price > 12
+ *
+ *
+ * @param mixed $amountPrice 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 ChildOrderCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByAmountPrice($amountPrice = null, $comparison = null)
+ {
+ if (is_array($amountPrice)) {
+ $useMinMax = false;
+ if (isset($amountPrice['min'])) {
+ $this->addUsingAlias(OrderCreditNoteTableMap::AMOUNT_PRICE, $amountPrice['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($amountPrice['max'])) {
+ $this->addUsingAlias(OrderCreditNoteTableMap::AMOUNT_PRICE, $amountPrice['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderCreditNoteTableMap::AMOUNT_PRICE, $amountPrice, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildOrderCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(OrderCreditNoteTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(OrderCreditNoteTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderCreditNoteTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ChildOrderCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(OrderCreditNoteTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(OrderCreditNoteTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderCreditNoteTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Order object
+ *
+ * @param \Thelia\Model\Order|ObjectCollection $order The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByOrder($order, $comparison = null)
+ {
+ if ($order instanceof \Thelia\Model\Order) {
+ return $this
+ ->addUsingAlias(OrderCreditNoteTableMap::ORDER_ID, $order->getId(), $comparison);
+ } elseif ($order instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderCreditNoteTableMap::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByOrder() only accepts arguments of type \Thelia\Model\Order or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Order relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderCreditNoteQuery The current query, for fluid interface
+ */
+ public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Order');
+
+ // 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, 'Order');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Order relation Order 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\OrderQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
+ }
+
+ /**
+ * Filter the query by a related \CreditNote\Model\CreditNote object
+ *
+ * @param \CreditNote\Model\CreditNote|ObjectCollection $creditNote The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderCreditNoteQuery The current query, for fluid interface
+ */
+ public function filterByCreditNote($creditNote, $comparison = null)
+ {
+ if ($creditNote instanceof \CreditNote\Model\CreditNote) {
+ return $this
+ ->addUsingAlias(OrderCreditNoteTableMap::CREDIT_NOTE_ID, $creditNote->getId(), $comparison);
+ } elseif ($creditNote instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderCreditNoteTableMap::CREDIT_NOTE_ID, $creditNote->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCreditNote() only accepts arguments of type \CreditNote\Model\CreditNote or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CreditNote relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderCreditNoteQuery The current query, for fluid interface
+ */
+ public function joinCreditNote($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CreditNote');
+
+ // 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, 'CreditNote');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CreditNote relation CreditNote 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 \CreditNote\Model\CreditNoteQuery A secondary query class using the current class as primary query
+ */
+ public function useCreditNoteQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCreditNote($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CreditNote', '\CreditNote\Model\CreditNoteQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildOrderCreditNote $orderCreditNote Object to remove from the list of results
+ *
+ * @return ChildOrderCreditNoteQuery The current query, for fluid interface
+ */
+ public function prune($orderCreditNote = null)
+ {
+ if ($orderCreditNote) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(OrderCreditNoteTableMap::ORDER_ID), $orderCreditNote->getOrderId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(OrderCreditNoteTableMap::CREDIT_NOTE_ID), $orderCreditNote->getCreditNoteId(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the order_credit_note table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderCreditNoteTableMap::DATABASE_NAME);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ OrderCreditNoteTableMap::clearInstancePool();
+ OrderCreditNoteTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildOrderCreditNote or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildOrderCreditNote object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderCreditNoteTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderCreditNoteTableMap::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+
+ OrderCreditNoteTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ OrderCreditNoteTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildOrderCreditNoteQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(OrderCreditNoteTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildOrderCreditNoteQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(OrderCreditNoteTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildOrderCreditNoteQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(OrderCreditNoteTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildOrderCreditNoteQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(OrderCreditNoteTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildOrderCreditNoteQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(OrderCreditNoteTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildOrderCreditNoteQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(OrderCreditNoteTableMap::CREATED_AT);
+ }
+
+} // OrderCreditNoteQuery
diff --git a/local/modules/CreditNote/Model/CartCreditNote.php b/local/modules/CreditNote/Model/CartCreditNote.php
new file mode 100644
index 000000000..f670e3a0a
--- /dev/null
+++ b/local/modules/CreditNote/Model/CartCreditNote.php
@@ -0,0 +1,10 @@
+setOrderId(null);
+ } else {
+ $this->setOrderId($v->getId());
+ }
+
+ $this->aOrder = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCustomer object, it will not be re-added.
+ if (method_exists($v, 'addCreditNote') && $v !== null) {
+ $v->addCreditNote($this);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCurrency object.
+ *
+ * @param Currency $v
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCurrency(Currency $v = null)
+ {
+ if ($v === null) {
+ $this->setCurrencyId(null);
+ } else {
+ $this->setCurrencyId($v->getId());
+ }
+
+ $this->aCurrency = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCustomer object, it will not be re-added.
+ if (method_exists($v, 'addCreditNote') && $v !== null) {
+ $v->addCreditNote($this);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCustomer object.
+ *
+ * @param Customer $v
+ * @return \CreditNote\Model\CreditNote The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCustomer(Customer $v = null)
+ {
+ if ($v === null) {
+ $this->setCustomerId(null);
+ } else {
+ $this->setCustomerId($v->getId());
+ }
+
+ $this->aCustomer = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCustomer object, it will not be re-added.
+ if (method_exists($v, 'addCreditNote') && $v !== null) {
+ $v->addCreditNote($this);
+ }
+
+ return $this;
+ }
+
+ public function setStatusId($v)
+ {
+ // check status flow
+ if (null !== $this->getStatusId() && (int) $v !== (int) $this->getStatusId()) {
+ if (!CreditNoteStatusFlowQuery::create()
+ ->filterByFromStatusId($this->getStatusId())
+ ->filterByToStatusId($v)
+ ->findOne()) {
+ throw new \Exception('You do not respect the status flow');
+ }
+ }
+
+ return parent::setStatusId($v);
+ }
+
+ public function setCreditNoteStatus(ChildCreditNoteStatus $v = null)
+ {
+ // check status flow
+ if (null !== $v && null !== $this->getCreditNoteStatus() && (int) $v->getId() !== (int) $this->getCreditNoteStatus()->getId()) {
+ if (!CreditNoteStatusFlowQuery::create()
+ ->filterByFromStatusId($this->getCreditNoteStatus()->getId())
+ ->filterByToStatusId($v->getId())
+ ->findOne()) {
+ throw new \Exception('You do not respect the status flow');
+ }
+ }
+
+ return parent::setCreditNoteStatus($v);
+ }
+}
diff --git a/local/modules/CreditNote/Model/CreditNoteAddress.php b/local/modules/CreditNote/Model/CreditNoteAddress.php
new file mode 100644
index 000000000..8a3be921d
--- /dev/null
+++ b/local/modules/CreditNote/Model/CreditNoteAddress.php
@@ -0,0 +1,10 @@
+setOrderProductId(null);
+ } else {
+ $this->setOrderProductId($v->getId());
+ }
+
+ $this->aOrderProduct = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCustomer object, it will not be re-added.
+ if (method_exists($v, 'addCreditNote') && $v !== null) {
+ $v->addCreditNote($this);
+ }
+
+ return $this;
+ }
+}
diff --git a/local/modules/CreditNote/Model/CreditNoteDetailQuery.php b/local/modules/CreditNote/Model/CreditNoteDetailQuery.php
new file mode 100644
index 000000000..f2fbe5381
--- /dev/null
+++ b/local/modules/CreditNote/Model/CreditNoteDetailQuery.php
@@ -0,0 +1,21 @@
+filterByFromStatusId($creditNoteStatus->getId())
+ ->orderByPriority(Criteria::ASC)
+ ->useCreditNoteStatusRelatedByToStatusIdQuery()
+ ->filterByUsed(true)
+ ->endUse()
+ ->findOne();
+
+ if (null === $statusFlow) {
+ return null;
+ }
+
+ return $statusFlow->getCreditNoteStatusRelatedByToStatusId();
+ }
+
+ /**
+ * @param CreditNoteStatus $creditNoteStatus
+ * @return CreditNoteStatus|null
+ */
+ public static function findNextCreditNoteStatus(CreditNoteStatus $creditNoteStatus)
+ {
+ /** @var CreditNoteStatusFlow $statusFlow */
+ $statusFlow = CreditNoteStatusFlowQuery::create()
+ ->filterByFromStatusId($creditNoteStatus->getId())
+ ->orderByPriority(Criteria::ASC)
+ ->useCreditNoteStatusRelatedByToStatusIdQuery()
+ ->filterByUsed($creditNoteStatus->getUsed())
+ ->endUse()
+ ->findOne();
+
+ if (null === $statusFlow) {
+ return null;
+ }
+
+ return $statusFlow->getCreditNoteStatusRelatedByToStatusId();
+ }
+}
diff --git a/local/modules/CreditNote/Model/CreditNoteType.php b/local/modules/CreditNote/Model/CreditNoteType.php
new file mode 100644
index 000000000..8b5d41b02
--- /dev/null
+++ b/local/modules/CreditNote/Model/CreditNoteType.php
@@ -0,0 +1,10 @@
+ array('CartId', 'CreditNoteId', 'AmountPrice', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('cartId', 'creditNoteId', 'amountPrice', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(CartCreditNoteTableMap::CART_ID, CartCreditNoteTableMap::CREDIT_NOTE_ID, CartCreditNoteTableMap::AMOUNT_PRICE, CartCreditNoteTableMap::CREATED_AT, CartCreditNoteTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('CART_ID', 'CREDIT_NOTE_ID', 'AMOUNT_PRICE', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('cart_id', 'credit_note_id', 'amount_price', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('CartId' => 0, 'CreditNoteId' => 1, 'AmountPrice' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ self::TYPE_STUDLYPHPNAME => array('cartId' => 0, 'creditNoteId' => 1, 'amountPrice' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ self::TYPE_COLNAME => array(CartCreditNoteTableMap::CART_ID => 0, CartCreditNoteTableMap::CREDIT_NOTE_ID => 1, CartCreditNoteTableMap::AMOUNT_PRICE => 2, CartCreditNoteTableMap::CREATED_AT => 3, CartCreditNoteTableMap::UPDATED_AT => 4, ),
+ self::TYPE_RAW_COLNAME => array('CART_ID' => 0, 'CREDIT_NOTE_ID' => 1, 'AMOUNT_PRICE' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ self::TYPE_FIELDNAME => array('cart_id' => 0, 'credit_note_id' => 1, 'amount_price' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('cart_credit_note');
+ $this->setPhpName('CartCreditNote');
+ $this->setClassName('\\CreditNote\\Model\\CartCreditNote');
+ $this->setPackage('CreditNote.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('CART_ID', 'CartId', 'INTEGER' , 'cart', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('CREDIT_NOTE_ID', 'CreditNoteId', 'INTEGER' , 'credit_note', 'ID', true, null, null);
+ $this->addColumn('AMOUNT_PRICE', 'AmountPrice', 'DECIMAL', false, 16, 0);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Cart', '\\Thelia\\Model\\Cart', RelationMap::MANY_TO_ONE, array('cart_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('CreditNote', '\\CreditNote\\Model\\CreditNote', RelationMap::MANY_TO_ONE, array('credit_note_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \CreditNote\Model\CartCreditNote $obj A \CreditNote\Model\CartCreditNote object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getCartId(), (string) $obj->getCreditNoteId()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \CreditNote\Model\CartCreditNote object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \CreditNote\Model\CartCreditNote) {
+ $key = serialize(array((string) $value->getCartId(), (string) $value->getCreditNoteId()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \CreditNote\Model\CartCreditNote object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('CartId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CreditNoteId', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('CartId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CreditNoteId', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CartCreditNoteTableMap::CLASS_DEFAULT : CartCreditNoteTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CartCreditNote object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CartCreditNoteTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CartCreditNoteTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CartCreditNoteTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CartCreditNoteTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CartCreditNoteTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CartCreditNoteTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CartCreditNoteTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CartCreditNoteTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CartCreditNoteTableMap::CART_ID);
+ $criteria->addSelectColumn(CartCreditNoteTableMap::CREDIT_NOTE_ID);
+ $criteria->addSelectColumn(CartCreditNoteTableMap::AMOUNT_PRICE);
+ $criteria->addSelectColumn(CartCreditNoteTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CartCreditNoteTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.CART_ID');
+ $criteria->addSelectColumn($alias . '.CREDIT_NOTE_ID');
+ $criteria->addSelectColumn($alias . '.AMOUNT_PRICE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getServiceContainer()->getDatabaseMap(CartCreditNoteTableMap::DATABASE_NAME)->getTable(CartCreditNoteTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CartCreditNoteTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CartCreditNoteTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CartCreditNoteTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CartCreditNote or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CartCreditNote object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CartCreditNoteTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \CreditNote\Model\CartCreditNote) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CartCreditNoteTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(CartCreditNoteTableMap::CART_ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(CartCreditNoteTableMap::CREDIT_NOTE_ID, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = CartCreditNoteQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CartCreditNoteTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CartCreditNoteTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the cart_credit_note table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CartCreditNoteQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CartCreditNote or Criteria object.
+ *
+ * @param mixed $criteria Criteria or CartCreditNote object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CartCreditNoteTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from CartCreditNote object
+ }
+
+
+ // Set the correct dbName
+ $query = CartCreditNoteQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CartCreditNoteTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CartCreditNoteTableMap::buildTableMap();
diff --git a/local/modules/CreditNote/Model/Map/CreditNoteAddressTableMap.php b/local/modules/CreditNote/Model/Map/CreditNoteAddressTableMap.php
new file mode 100644
index 000000000..156f1b028
--- /dev/null
+++ b/local/modules/CreditNote/Model/Map/CreditNoteAddressTableMap.php
@@ -0,0 +1,539 @@
+ array('Id', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'Phone', 'Cellphone', 'CountryId', 'StateId', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'phone', 'cellphone', 'countryId', 'stateId', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(CreditNoteAddressTableMap::ID, CreditNoteAddressTableMap::CUSTOMER_TITLE_ID, CreditNoteAddressTableMap::COMPANY, CreditNoteAddressTableMap::FIRSTNAME, CreditNoteAddressTableMap::LASTNAME, CreditNoteAddressTableMap::ADDRESS1, CreditNoteAddressTableMap::ADDRESS2, CreditNoteAddressTableMap::ADDRESS3, CreditNoteAddressTableMap::ZIPCODE, CreditNoteAddressTableMap::CITY, CreditNoteAddressTableMap::PHONE, CreditNoteAddressTableMap::CELLPHONE, CreditNoteAddressTableMap::COUNTRY_ID, CreditNoteAddressTableMap::STATE_ID, CreditNoteAddressTableMap::CREATED_AT, CreditNoteAddressTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'PHONE', 'CELLPHONE', 'COUNTRY_ID', 'STATE_ID', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'phone', 'cellphone', 'country_id', 'state_id', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'CustomerTitleId' => 1, 'Company' => 2, 'Firstname' => 3, 'Lastname' => 4, 'Address1' => 5, 'Address2' => 6, 'Address3' => 7, 'Zipcode' => 8, 'City' => 9, 'Phone' => 10, 'Cellphone' => 11, 'CountryId' => 12, 'StateId' => 13, 'CreatedAt' => 14, 'UpdatedAt' => 15, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'customerTitleId' => 1, 'company' => 2, 'firstname' => 3, 'lastname' => 4, 'address1' => 5, 'address2' => 6, 'address3' => 7, 'zipcode' => 8, 'city' => 9, 'phone' => 10, 'cellphone' => 11, 'countryId' => 12, 'stateId' => 13, 'createdAt' => 14, 'updatedAt' => 15, ),
+ self::TYPE_COLNAME => array(CreditNoteAddressTableMap::ID => 0, CreditNoteAddressTableMap::CUSTOMER_TITLE_ID => 1, CreditNoteAddressTableMap::COMPANY => 2, CreditNoteAddressTableMap::FIRSTNAME => 3, CreditNoteAddressTableMap::LASTNAME => 4, CreditNoteAddressTableMap::ADDRESS1 => 5, CreditNoteAddressTableMap::ADDRESS2 => 6, CreditNoteAddressTableMap::ADDRESS3 => 7, CreditNoteAddressTableMap::ZIPCODE => 8, CreditNoteAddressTableMap::CITY => 9, CreditNoteAddressTableMap::PHONE => 10, CreditNoteAddressTableMap::CELLPHONE => 11, CreditNoteAddressTableMap::COUNTRY_ID => 12, CreditNoteAddressTableMap::STATE_ID => 13, CreditNoteAddressTableMap::CREATED_AT => 14, CreditNoteAddressTableMap::UPDATED_AT => 15, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CUSTOMER_TITLE_ID' => 1, 'COMPANY' => 2, 'FIRSTNAME' => 3, 'LASTNAME' => 4, 'ADDRESS1' => 5, 'ADDRESS2' => 6, 'ADDRESS3' => 7, 'ZIPCODE' => 8, 'CITY' => 9, 'PHONE' => 10, 'CELLPHONE' => 11, 'COUNTRY_ID' => 12, 'STATE_ID' => 13, 'CREATED_AT' => 14, 'UPDATED_AT' => 15, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'customer_title_id' => 1, 'company' => 2, 'firstname' => 3, 'lastname' => 4, 'address1' => 5, 'address2' => 6, 'address3' => 7, 'zipcode' => 8, 'city' => 9, 'phone' => 10, 'cellphone' => 11, 'country_id' => 12, 'state_id' => 13, 'created_at' => 14, 'updated_at' => 15, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('credit_note_address');
+ $this->setPhpName('CreditNoteAddress');
+ $this->setClassName('\\CreditNote\\Model\\CreditNoteAddress');
+ $this->setPackage('CreditNote.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', 'customer_title', 'ID', false, null, null);
+ $this->addColumn('COMPANY', 'Company', 'VARCHAR', false, 255, null);
+ $this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null);
+ $this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null);
+ $this->addColumn('ADDRESS1', 'Address1', 'VARCHAR', true, 255, null);
+ $this->addColumn('ADDRESS2', 'Address2', 'VARCHAR', false, 255, null);
+ $this->addColumn('ADDRESS3', 'Address3', 'VARCHAR', false, 255, null);
+ $this->addColumn('ZIPCODE', 'Zipcode', 'VARCHAR', true, 10, null);
+ $this->addColumn('CITY', 'City', 'VARCHAR', true, 255, null);
+ $this->addColumn('PHONE', 'Phone', 'VARCHAR', false, 20, null);
+ $this->addColumn('CELLPHONE', 'Cellphone', 'VARCHAR', false, 20, null);
+ $this->addForeignKey('COUNTRY_ID', 'CountryId', 'INTEGER', 'country', 'ID', true, null, null);
+ $this->addForeignKey('STATE_ID', 'StateId', 'INTEGER', 'state', 'ID', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('CustomerTitle', '\\Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), 'RESTRICT', 'RESTRICT');
+ $this->addRelation('Country', '\\Thelia\\Model\\Country', RelationMap::MANY_TO_ONE, array('country_id' => 'id', ), 'RESTRICT', 'RESTRICT');
+ $this->addRelation('State', '\\Thelia\\Model\\State', RelationMap::MANY_TO_ONE, array('state_id' => 'id', ), 'RESTRICT', 'RESTRICT');
+ $this->addRelation('CreditNote', '\\CreditNote\\Model\\CreditNote', RelationMap::ONE_TO_MANY, array('id' => 'invoice_address_id', ), 'RESTRICT', 'RESTRICT', 'CreditNotes');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CreditNoteAddressTableMap::CLASS_DEFAULT : CreditNoteAddressTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CreditNoteAddress object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CreditNoteAddressTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CreditNoteAddressTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CreditNoteAddressTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CreditNoteAddressTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CreditNoteAddressTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CreditNoteAddressTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CreditNoteAddressTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CreditNoteAddressTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CreditNoteAddressTableMap::ID);
+ $criteria->addSelectColumn(CreditNoteAddressTableMap::CUSTOMER_TITLE_ID);
+ $criteria->addSelectColumn(CreditNoteAddressTableMap::COMPANY);
+ $criteria->addSelectColumn(CreditNoteAddressTableMap::FIRSTNAME);
+ $criteria->addSelectColumn(CreditNoteAddressTableMap::LASTNAME);
+ $criteria->addSelectColumn(CreditNoteAddressTableMap::ADDRESS1);
+ $criteria->addSelectColumn(CreditNoteAddressTableMap::ADDRESS2);
+ $criteria->addSelectColumn(CreditNoteAddressTableMap::ADDRESS3);
+ $criteria->addSelectColumn(CreditNoteAddressTableMap::ZIPCODE);
+ $criteria->addSelectColumn(CreditNoteAddressTableMap::CITY);
+ $criteria->addSelectColumn(CreditNoteAddressTableMap::PHONE);
+ $criteria->addSelectColumn(CreditNoteAddressTableMap::CELLPHONE);
+ $criteria->addSelectColumn(CreditNoteAddressTableMap::COUNTRY_ID);
+ $criteria->addSelectColumn(CreditNoteAddressTableMap::STATE_ID);
+ $criteria->addSelectColumn(CreditNoteAddressTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CreditNoteAddressTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CUSTOMER_TITLE_ID');
+ $criteria->addSelectColumn($alias . '.COMPANY');
+ $criteria->addSelectColumn($alias . '.FIRSTNAME');
+ $criteria->addSelectColumn($alias . '.LASTNAME');
+ $criteria->addSelectColumn($alias . '.ADDRESS1');
+ $criteria->addSelectColumn($alias . '.ADDRESS2');
+ $criteria->addSelectColumn($alias . '.ADDRESS3');
+ $criteria->addSelectColumn($alias . '.ZIPCODE');
+ $criteria->addSelectColumn($alias . '.CITY');
+ $criteria->addSelectColumn($alias . '.PHONE');
+ $criteria->addSelectColumn($alias . '.CELLPHONE');
+ $criteria->addSelectColumn($alias . '.COUNTRY_ID');
+ $criteria->addSelectColumn($alias . '.STATE_ID');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getServiceContainer()->getDatabaseMap(CreditNoteAddressTableMap::DATABASE_NAME)->getTable(CreditNoteAddressTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteAddressTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CreditNoteAddressTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CreditNoteAddressTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CreditNoteAddress or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CreditNoteAddress object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteAddressTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \CreditNote\Model\CreditNoteAddress) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CreditNoteAddressTableMap::DATABASE_NAME);
+ $criteria->add(CreditNoteAddressTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = CreditNoteAddressQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CreditNoteAddressTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CreditNoteAddressTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the credit_note_address table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CreditNoteAddressQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CreditNoteAddress or Criteria object.
+ *
+ * @param mixed $criteria Criteria or CreditNoteAddress object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteAddressTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from CreditNoteAddress object
+ }
+
+ if ($criteria->containsKey(CreditNoteAddressTableMap::ID) && $criteria->keyContainsValue(CreditNoteAddressTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CreditNoteAddressTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = CreditNoteAddressQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CreditNoteAddressTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CreditNoteAddressTableMap::buildTableMap();
diff --git a/local/modules/CreditNote/Model/Map/CreditNoteCommentTableMap.php b/local/modules/CreditNote/Model/Map/CreditNoteCommentTableMap.php
new file mode 100644
index 000000000..987d30cb0
--- /dev/null
+++ b/local/modules/CreditNote/Model/Map/CreditNoteCommentTableMap.php
@@ -0,0 +1,457 @@
+ array('Id', 'CreditNoteId', 'AdminId', 'Comment', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'creditNoteId', 'adminId', 'comment', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(CreditNoteCommentTableMap::ID, CreditNoteCommentTableMap::CREDIT_NOTE_ID, CreditNoteCommentTableMap::ADMIN_ID, CreditNoteCommentTableMap::COMMENT, CreditNoteCommentTableMap::CREATED_AT, CreditNoteCommentTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CREDIT_NOTE_ID', 'ADMIN_ID', 'COMMENT', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'credit_note_id', 'admin_id', 'comment', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'CreditNoteId' => 1, 'AdminId' => 2, 'Comment' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'creditNoteId' => 1, 'adminId' => 2, 'comment' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
+ self::TYPE_COLNAME => array(CreditNoteCommentTableMap::ID => 0, CreditNoteCommentTableMap::CREDIT_NOTE_ID => 1, CreditNoteCommentTableMap::ADMIN_ID => 2, CreditNoteCommentTableMap::COMMENT => 3, CreditNoteCommentTableMap::CREATED_AT => 4, CreditNoteCommentTableMap::UPDATED_AT => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CREDIT_NOTE_ID' => 1, 'ADMIN_ID' => 2, 'COMMENT' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'credit_note_id' => 1, 'admin_id' => 2, 'comment' => 3, 'created_at' => 4, 'updated_at' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('credit_note_comment');
+ $this->setPhpName('CreditNoteComment');
+ $this->setClassName('\\CreditNote\\Model\\CreditNoteComment');
+ $this->setPackage('CreditNote.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('CREDIT_NOTE_ID', 'CreditNoteId', 'INTEGER', 'credit_note', 'ID', true, null, null);
+ $this->addForeignKey('ADMIN_ID', 'AdminId', 'INTEGER', 'admin', 'ID', false, null, null);
+ $this->addColumn('COMMENT', 'Comment', 'CLOB', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('CreditNote', '\\CreditNote\\Model\\CreditNote', RelationMap::MANY_TO_ONE, array('credit_note_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Admin', '\\Thelia\\Model\\Admin', RelationMap::MANY_TO_ONE, array('admin_id' => 'id', ), 'SET NULL', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CreditNoteCommentTableMap::CLASS_DEFAULT : CreditNoteCommentTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CreditNoteComment object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CreditNoteCommentTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CreditNoteCommentTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CreditNoteCommentTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CreditNoteCommentTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CreditNoteCommentTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CreditNoteCommentTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CreditNoteCommentTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CreditNoteCommentTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CreditNoteCommentTableMap::ID);
+ $criteria->addSelectColumn(CreditNoteCommentTableMap::CREDIT_NOTE_ID);
+ $criteria->addSelectColumn(CreditNoteCommentTableMap::ADMIN_ID);
+ $criteria->addSelectColumn(CreditNoteCommentTableMap::COMMENT);
+ $criteria->addSelectColumn(CreditNoteCommentTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CreditNoteCommentTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CREDIT_NOTE_ID');
+ $criteria->addSelectColumn($alias . '.ADMIN_ID');
+ $criteria->addSelectColumn($alias . '.COMMENT');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getServiceContainer()->getDatabaseMap(CreditNoteCommentTableMap::DATABASE_NAME)->getTable(CreditNoteCommentTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteCommentTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CreditNoteCommentTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CreditNoteCommentTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CreditNoteComment or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CreditNoteComment object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteCommentTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \CreditNote\Model\CreditNoteComment) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CreditNoteCommentTableMap::DATABASE_NAME);
+ $criteria->add(CreditNoteCommentTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = CreditNoteCommentQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CreditNoteCommentTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CreditNoteCommentTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the credit_note_comment table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CreditNoteCommentQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CreditNoteComment or Criteria object.
+ *
+ * @param mixed $criteria Criteria or CreditNoteComment object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteCommentTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from CreditNoteComment object
+ }
+
+ if ($criteria->containsKey(CreditNoteCommentTableMap::ID) && $criteria->keyContainsValue(CreditNoteCommentTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CreditNoteCommentTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = CreditNoteCommentQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CreditNoteCommentTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CreditNoteCommentTableMap::buildTableMap();
diff --git a/local/modules/CreditNote/Model/Map/CreditNoteDetailTableMap.php b/local/modules/CreditNote/Model/Map/CreditNoteDetailTableMap.php
new file mode 100644
index 000000000..c30263cfc
--- /dev/null
+++ b/local/modules/CreditNote/Model/Map/CreditNoteDetailTableMap.php
@@ -0,0 +1,498 @@
+ array('Id', 'CreditNoteId', 'Price', 'PriceWithTax', 'TaxRuleId', 'OrderProductId', 'Type', 'Quantity', 'Title', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'creditNoteId', 'price', 'priceWithTax', 'taxRuleId', 'orderProductId', 'type', 'quantity', 'title', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(CreditNoteDetailTableMap::ID, CreditNoteDetailTableMap::CREDIT_NOTE_ID, CreditNoteDetailTableMap::PRICE, CreditNoteDetailTableMap::PRICE_WITH_TAX, CreditNoteDetailTableMap::TAX_RULE_ID, CreditNoteDetailTableMap::ORDER_PRODUCT_ID, CreditNoteDetailTableMap::TYPE, CreditNoteDetailTableMap::QUANTITY, CreditNoteDetailTableMap::TITLE, CreditNoteDetailTableMap::CREATED_AT, CreditNoteDetailTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CREDIT_NOTE_ID', 'PRICE', 'PRICE_WITH_TAX', 'TAX_RULE_ID', 'ORDER_PRODUCT_ID', 'TYPE', 'QUANTITY', 'TITLE', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'credit_note_id', 'price', 'price_with_tax', 'tax_rule_id', 'order_product_id', 'type', 'quantity', 'title', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'CreditNoteId' => 1, 'Price' => 2, 'PriceWithTax' => 3, 'TaxRuleId' => 4, 'OrderProductId' => 5, 'Type' => 6, 'Quantity' => 7, 'Title' => 8, 'CreatedAt' => 9, 'UpdatedAt' => 10, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'creditNoteId' => 1, 'price' => 2, 'priceWithTax' => 3, 'taxRuleId' => 4, 'orderProductId' => 5, 'type' => 6, 'quantity' => 7, 'title' => 8, 'createdAt' => 9, 'updatedAt' => 10, ),
+ self::TYPE_COLNAME => array(CreditNoteDetailTableMap::ID => 0, CreditNoteDetailTableMap::CREDIT_NOTE_ID => 1, CreditNoteDetailTableMap::PRICE => 2, CreditNoteDetailTableMap::PRICE_WITH_TAX => 3, CreditNoteDetailTableMap::TAX_RULE_ID => 4, CreditNoteDetailTableMap::ORDER_PRODUCT_ID => 5, CreditNoteDetailTableMap::TYPE => 6, CreditNoteDetailTableMap::QUANTITY => 7, CreditNoteDetailTableMap::TITLE => 8, CreditNoteDetailTableMap::CREATED_AT => 9, CreditNoteDetailTableMap::UPDATED_AT => 10, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CREDIT_NOTE_ID' => 1, 'PRICE' => 2, 'PRICE_WITH_TAX' => 3, 'TAX_RULE_ID' => 4, 'ORDER_PRODUCT_ID' => 5, 'TYPE' => 6, 'QUANTITY' => 7, 'TITLE' => 8, 'CREATED_AT' => 9, 'UPDATED_AT' => 10, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'credit_note_id' => 1, 'price' => 2, 'price_with_tax' => 3, 'tax_rule_id' => 4, 'order_product_id' => 5, 'type' => 6, 'quantity' => 7, 'title' => 8, 'created_at' => 9, 'updated_at' => 10, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('credit_note_detail');
+ $this->setPhpName('CreditNoteDetail');
+ $this->setClassName('\\CreditNote\\Model\\CreditNoteDetail');
+ $this->setPackage('CreditNote.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('CREDIT_NOTE_ID', 'CreditNoteId', 'INTEGER', 'credit_note', 'ID', true, null, null);
+ $this->addColumn('PRICE', 'Price', 'DECIMAL', false, 16, 0);
+ $this->addColumn('PRICE_WITH_TAX', 'PriceWithTax', 'DECIMAL', false, 16, 0);
+ $this->addForeignKey('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', 'tax_rule', 'ID', false, null, null);
+ $this->addForeignKey('ORDER_PRODUCT_ID', 'OrderProductId', 'INTEGER', 'order_product', 'ID', false, null, null);
+ $this->addColumn('TYPE', 'Type', 'VARCHAR', false, 55, null);
+ $this->addColumn('QUANTITY', 'Quantity', 'INTEGER', true, null, 0);
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('CreditNote', '\\CreditNote\\Model\\CreditNote', RelationMap::MANY_TO_ONE, array('credit_note_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('OrderProduct', '\\Thelia\\Model\\OrderProduct', RelationMap::MANY_TO_ONE, array('order_product_id' => 'id', ), 'RESTRICT', 'RESTRICT');
+ $this->addRelation('TaxRule', '\\Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'RESTRICT', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CreditNoteDetailTableMap::CLASS_DEFAULT : CreditNoteDetailTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CreditNoteDetail object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CreditNoteDetailTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CreditNoteDetailTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CreditNoteDetailTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CreditNoteDetailTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CreditNoteDetailTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CreditNoteDetailTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CreditNoteDetailTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CreditNoteDetailTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CreditNoteDetailTableMap::ID);
+ $criteria->addSelectColumn(CreditNoteDetailTableMap::CREDIT_NOTE_ID);
+ $criteria->addSelectColumn(CreditNoteDetailTableMap::PRICE);
+ $criteria->addSelectColumn(CreditNoteDetailTableMap::PRICE_WITH_TAX);
+ $criteria->addSelectColumn(CreditNoteDetailTableMap::TAX_RULE_ID);
+ $criteria->addSelectColumn(CreditNoteDetailTableMap::ORDER_PRODUCT_ID);
+ $criteria->addSelectColumn(CreditNoteDetailTableMap::TYPE);
+ $criteria->addSelectColumn(CreditNoteDetailTableMap::QUANTITY);
+ $criteria->addSelectColumn(CreditNoteDetailTableMap::TITLE);
+ $criteria->addSelectColumn(CreditNoteDetailTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CreditNoteDetailTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CREDIT_NOTE_ID');
+ $criteria->addSelectColumn($alias . '.PRICE');
+ $criteria->addSelectColumn($alias . '.PRICE_WITH_TAX');
+ $criteria->addSelectColumn($alias . '.TAX_RULE_ID');
+ $criteria->addSelectColumn($alias . '.ORDER_PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.TYPE');
+ $criteria->addSelectColumn($alias . '.QUANTITY');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getServiceContainer()->getDatabaseMap(CreditNoteDetailTableMap::DATABASE_NAME)->getTable(CreditNoteDetailTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteDetailTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CreditNoteDetailTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CreditNoteDetailTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CreditNoteDetail or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CreditNoteDetail object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteDetailTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \CreditNote\Model\CreditNoteDetail) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CreditNoteDetailTableMap::DATABASE_NAME);
+ $criteria->add(CreditNoteDetailTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = CreditNoteDetailQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CreditNoteDetailTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CreditNoteDetailTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the credit_note_detail table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CreditNoteDetailQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CreditNoteDetail or Criteria object.
+ *
+ * @param mixed $criteria Criteria or CreditNoteDetail object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteDetailTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from CreditNoteDetail object
+ }
+
+ if ($criteria->containsKey(CreditNoteDetailTableMap::ID) && $criteria->keyContainsValue(CreditNoteDetailTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CreditNoteDetailTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = CreditNoteDetailQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CreditNoteDetailTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CreditNoteDetailTableMap::buildTableMap();
diff --git a/local/modules/CreditNote/Model/Map/CreditNoteStatusFlowTableMap.php b/local/modules/CreditNote/Model/Map/CreditNoteStatusFlowTableMap.php
new file mode 100644
index 000000000..6e345e9a7
--- /dev/null
+++ b/local/modules/CreditNote/Model/Map/CreditNoteStatusFlowTableMap.php
@@ -0,0 +1,465 @@
+ array('Id', 'FromStatusId', 'ToStatusId', 'Priority', 'Root', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'fromStatusId', 'toStatusId', 'priority', 'root', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(CreditNoteStatusFlowTableMap::ID, CreditNoteStatusFlowTableMap::FROM_STATUS_ID, CreditNoteStatusFlowTableMap::TO_STATUS_ID, CreditNoteStatusFlowTableMap::PRIORITY, CreditNoteStatusFlowTableMap::ROOT, CreditNoteStatusFlowTableMap::CREATED_AT, CreditNoteStatusFlowTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'FROM_STATUS_ID', 'TO_STATUS_ID', 'PRIORITY', 'ROOT', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'from_status_id', 'to_status_id', 'priority', 'root', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'FromStatusId' => 1, 'ToStatusId' => 2, 'Priority' => 3, 'Root' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'fromStatusId' => 1, 'toStatusId' => 2, 'priority' => 3, 'root' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ self::TYPE_COLNAME => array(CreditNoteStatusFlowTableMap::ID => 0, CreditNoteStatusFlowTableMap::FROM_STATUS_ID => 1, CreditNoteStatusFlowTableMap::TO_STATUS_ID => 2, CreditNoteStatusFlowTableMap::PRIORITY => 3, CreditNoteStatusFlowTableMap::ROOT => 4, CreditNoteStatusFlowTableMap::CREATED_AT => 5, CreditNoteStatusFlowTableMap::UPDATED_AT => 6, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'FROM_STATUS_ID' => 1, 'TO_STATUS_ID' => 2, 'PRIORITY' => 3, 'ROOT' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'from_status_id' => 1, 'to_status_id' => 2, 'priority' => 3, 'root' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('credit_note_status_flow');
+ $this->setPhpName('CreditNoteStatusFlow');
+ $this->setClassName('\\CreditNote\\Model\\CreditNoteStatusFlow');
+ $this->setPackage('CreditNote.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('FROM_STATUS_ID', 'FromStatusId', 'INTEGER', 'credit_note_status', 'ID', true, null, null);
+ $this->addForeignKey('TO_STATUS_ID', 'ToStatusId', 'INTEGER', 'credit_note_status', 'ID', true, null, null);
+ $this->addColumn('PRIORITY', 'Priority', 'INTEGER', false, 11, null);
+ $this->addColumn('ROOT', 'Root', 'BOOLEAN', true, 1, false);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('CreditNoteStatusRelatedByFromStatusId', '\\CreditNote\\Model\\CreditNoteStatus', RelationMap::MANY_TO_ONE, array('from_status_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('CreditNoteStatusRelatedByToStatusId', '\\CreditNote\\Model\\CreditNoteStatus', RelationMap::MANY_TO_ONE, array('to_status_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CreditNoteStatusFlowTableMap::CLASS_DEFAULT : CreditNoteStatusFlowTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CreditNoteStatusFlow object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CreditNoteStatusFlowTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CreditNoteStatusFlowTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CreditNoteStatusFlowTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CreditNoteStatusFlowTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CreditNoteStatusFlowTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CreditNoteStatusFlowTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CreditNoteStatusFlowTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CreditNoteStatusFlowTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CreditNoteStatusFlowTableMap::ID);
+ $criteria->addSelectColumn(CreditNoteStatusFlowTableMap::FROM_STATUS_ID);
+ $criteria->addSelectColumn(CreditNoteStatusFlowTableMap::TO_STATUS_ID);
+ $criteria->addSelectColumn(CreditNoteStatusFlowTableMap::PRIORITY);
+ $criteria->addSelectColumn(CreditNoteStatusFlowTableMap::ROOT);
+ $criteria->addSelectColumn(CreditNoteStatusFlowTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CreditNoteStatusFlowTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.FROM_STATUS_ID');
+ $criteria->addSelectColumn($alias . '.TO_STATUS_ID');
+ $criteria->addSelectColumn($alias . '.PRIORITY');
+ $criteria->addSelectColumn($alias . '.ROOT');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getServiceContainer()->getDatabaseMap(CreditNoteStatusFlowTableMap::DATABASE_NAME)->getTable(CreditNoteStatusFlowTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteStatusFlowTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CreditNoteStatusFlowTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CreditNoteStatusFlowTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CreditNoteStatusFlow or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CreditNoteStatusFlow object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusFlowTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \CreditNote\Model\CreditNoteStatusFlow) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CreditNoteStatusFlowTableMap::DATABASE_NAME);
+ $criteria->add(CreditNoteStatusFlowTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = CreditNoteStatusFlowQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CreditNoteStatusFlowTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CreditNoteStatusFlowTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the credit_note_status_flow table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CreditNoteStatusFlowQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CreditNoteStatusFlow or Criteria object.
+ *
+ * @param mixed $criteria Criteria or CreditNoteStatusFlow object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusFlowTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from CreditNoteStatusFlow object
+ }
+
+ if ($criteria->containsKey(CreditNoteStatusFlowTableMap::ID) && $criteria->keyContainsValue(CreditNoteStatusFlowTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CreditNoteStatusFlowTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = CreditNoteStatusFlowQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CreditNoteStatusFlowTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CreditNoteStatusFlowTableMap::buildTableMap();
diff --git a/local/modules/CreditNote/Model/Map/CreditNoteStatusI18nTableMap.php b/local/modules/CreditNote/Model/Map/CreditNoteStatusI18nTableMap.php
new file mode 100644
index 000000000..e2ca04313
--- /dev/null
+++ b/local/modules/CreditNote/Model/Map/CreditNoteStatusI18nTableMap.php
@@ -0,0 +1,498 @@
+ array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_COLNAME => array(CreditNoteStatusI18nTableMap::ID, CreditNoteStatusI18nTableMap::LOCALE, CreditNoteStatusI18nTableMap::TITLE, CreditNoteStatusI18nTableMap::DESCRIPTION, CreditNoteStatusI18nTableMap::CHAPO, CreditNoteStatusI18nTableMap::POSTSCRIPTUM, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_COLNAME => array(CreditNoteStatusI18nTableMap::ID => 0, CreditNoteStatusI18nTableMap::LOCALE => 1, CreditNoteStatusI18nTableMap::TITLE => 2, CreditNoteStatusI18nTableMap::DESCRIPTION => 3, CreditNoteStatusI18nTableMap::CHAPO => 4, CreditNoteStatusI18nTableMap::POSTSCRIPTUM => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('credit_note_status_i18n');
+ $this->setPhpName('CreditNoteStatusI18n');
+ $this->setClassName('\\CreditNote\\Model\\CreditNoteStatusI18n');
+ $this->setPackage('CreditNote.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'credit_note_status', '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', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('CreditNoteStatus', '\\CreditNote\\Model\\CreditNoteStatus', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \CreditNote\Model\CreditNoteStatusI18n $obj A \CreditNote\Model\CreditNoteStatusI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \CreditNote\Model\CreditNoteStatusI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \CreditNote\Model\CreditNoteStatusI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \CreditNote\Model\CreditNoteStatusI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CreditNoteStatusI18nTableMap::CLASS_DEFAULT : CreditNoteStatusI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CreditNoteStatusI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CreditNoteStatusI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CreditNoteStatusI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CreditNoteStatusI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CreditNoteStatusI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CreditNoteStatusI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CreditNoteStatusI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CreditNoteStatusI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CreditNoteStatusI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CreditNoteStatusI18nTableMap::ID);
+ $criteria->addSelectColumn(CreditNoteStatusI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(CreditNoteStatusI18nTableMap::TITLE);
+ $criteria->addSelectColumn(CreditNoteStatusI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(CreditNoteStatusI18nTableMap::CHAPO);
+ $criteria->addSelectColumn(CreditNoteStatusI18nTableMap::POSTSCRIPTUM);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getServiceContainer()->getDatabaseMap(CreditNoteStatusI18nTableMap::DATABASE_NAME)->getTable(CreditNoteStatusI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteStatusI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CreditNoteStatusI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CreditNoteStatusI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CreditNoteStatusI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CreditNoteStatusI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \CreditNote\Model\CreditNoteStatusI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CreditNoteStatusI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(CreditNoteStatusI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(CreditNoteStatusI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = CreditNoteStatusI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CreditNoteStatusI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CreditNoteStatusI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the credit_note_status_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CreditNoteStatusI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CreditNoteStatusI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or CreditNoteStatusI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from CreditNoteStatusI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = CreditNoteStatusI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CreditNoteStatusI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CreditNoteStatusI18nTableMap::buildTableMap();
diff --git a/local/modules/CreditNote/Model/Map/CreditNoteStatusTableMap.php b/local/modules/CreditNote/Model/Map/CreditNoteStatusTableMap.php
new file mode 100644
index 000000000..def4bd81c
--- /dev/null
+++ b/local/modules/CreditNote/Model/Map/CreditNoteStatusTableMap.php
@@ -0,0 +1,495 @@
+ array('Id', 'Code', 'Color', 'Invoiced', 'Used', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'code', 'color', 'invoiced', 'used', 'position', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(CreditNoteStatusTableMap::ID, CreditNoteStatusTableMap::CODE, CreditNoteStatusTableMap::COLOR, CreditNoteStatusTableMap::INVOICED, CreditNoteStatusTableMap::USED, CreditNoteStatusTableMap::POSITION, CreditNoteStatusTableMap::CREATED_AT, CreditNoteStatusTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'COLOR', 'INVOICED', 'USED', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'code', 'color', 'invoiced', 'used', 'position', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Color' => 2, 'Invoiced' => 3, 'Used' => 4, 'Position' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'color' => 2, 'invoiced' => 3, 'used' => 4, 'position' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ self::TYPE_COLNAME => array(CreditNoteStatusTableMap::ID => 0, CreditNoteStatusTableMap::CODE => 1, CreditNoteStatusTableMap::COLOR => 2, CreditNoteStatusTableMap::INVOICED => 3, CreditNoteStatusTableMap::USED => 4, CreditNoteStatusTableMap::POSITION => 5, CreditNoteStatusTableMap::CREATED_AT => 6, CreditNoteStatusTableMap::UPDATED_AT => 7, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'COLOR' => 2, 'INVOICED' => 3, 'USED' => 4, 'POSITION' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'color' => 2, 'invoiced' => 3, 'used' => 4, 'position' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('credit_note_status');
+ $this->setPhpName('CreditNoteStatus');
+ $this->setClassName('\\CreditNote\\Model\\CreditNoteStatus');
+ $this->setPackage('CreditNote.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null);
+ $this->addColumn('COLOR', 'Color', 'CHAR', false, 7, null);
+ $this->addColumn('INVOICED', 'Invoiced', 'BOOLEAN', true, 1, false);
+ $this->addColumn('USED', 'Used', 'BOOLEAN', true, 1, false);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, 11, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('CreditNote', '\\CreditNote\\Model\\CreditNote', RelationMap::ONE_TO_MANY, array('id' => 'status_id', ), 'RESTRICT', 'RESTRICT', 'CreditNotes');
+ $this->addRelation('CreditNoteStatusFlowRelatedByFromStatusId', '\\CreditNote\\Model\\CreditNoteStatusFlow', RelationMap::ONE_TO_MANY, array('id' => 'from_status_id', ), 'CASCADE', 'RESTRICT', 'CreditNoteStatusFlowsRelatedByFromStatusId');
+ $this->addRelation('CreditNoteStatusFlowRelatedByToStatusId', '\\CreditNote\\Model\\CreditNoteStatusFlow', RelationMap::ONE_TO_MANY, array('id' => 'to_status_id', ), 'CASCADE', 'RESTRICT', 'CreditNoteStatusFlowsRelatedByToStatusId');
+ $this->addRelation('CreditNoteStatusI18n', '\\CreditNote\\Model\\CreditNoteStatusI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CreditNoteStatusI18ns');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to credit_note_status * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ CreditNoteStatusFlowTableMap::clearInstancePool();
+ CreditNoteStatusI18nTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CreditNoteStatusTableMap::CLASS_DEFAULT : CreditNoteStatusTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CreditNoteStatus object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CreditNoteStatusTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CreditNoteStatusTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CreditNoteStatusTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CreditNoteStatusTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CreditNoteStatusTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CreditNoteStatusTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CreditNoteStatusTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CreditNoteStatusTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CreditNoteStatusTableMap::ID);
+ $criteria->addSelectColumn(CreditNoteStatusTableMap::CODE);
+ $criteria->addSelectColumn(CreditNoteStatusTableMap::COLOR);
+ $criteria->addSelectColumn(CreditNoteStatusTableMap::INVOICED);
+ $criteria->addSelectColumn(CreditNoteStatusTableMap::USED);
+ $criteria->addSelectColumn(CreditNoteStatusTableMap::POSITION);
+ $criteria->addSelectColumn(CreditNoteStatusTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CreditNoteStatusTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.COLOR');
+ $criteria->addSelectColumn($alias . '.INVOICED');
+ $criteria->addSelectColumn($alias . '.USED');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getServiceContainer()->getDatabaseMap(CreditNoteStatusTableMap::DATABASE_NAME)->getTable(CreditNoteStatusTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteStatusTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CreditNoteStatusTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CreditNoteStatusTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CreditNoteStatus or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CreditNoteStatus object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \CreditNote\Model\CreditNoteStatus) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CreditNoteStatusTableMap::DATABASE_NAME);
+ $criteria->add(CreditNoteStatusTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = CreditNoteStatusQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CreditNoteStatusTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CreditNoteStatusTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the credit_note_status table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CreditNoteStatusQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CreditNoteStatus or Criteria object.
+ *
+ * @param mixed $criteria Criteria or CreditNoteStatus object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from CreditNoteStatus object
+ }
+
+ if ($criteria->containsKey(CreditNoteStatusTableMap::ID) && $criteria->keyContainsValue(CreditNoteStatusTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CreditNoteStatusTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = CreditNoteStatusQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CreditNoteStatusTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CreditNoteStatusTableMap::buildTableMap();
diff --git a/local/modules/CreditNote/Model/Map/CreditNoteTableMap.php b/local/modules/CreditNote/Model/Map/CreditNoteTableMap.php
new file mode 100644
index 000000000..0a0d0632e
--- /dev/null
+++ b/local/modules/CreditNote/Model/Map/CreditNoteTableMap.php
@@ -0,0 +1,583 @@
+ array('Id', 'Ref', 'InvoiceRef', 'InvoiceAddressId', 'InvoiceDate', 'OrderId', 'CustomerId', 'ParentId', 'TypeId', 'StatusId', 'CurrencyId', 'CurrencyRate', 'TotalPrice', 'TotalPriceWithTax', 'DiscountWithoutTax', 'DiscountWithTax', 'AllowPartialUse', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'invoiceRef', 'invoiceAddressId', 'invoiceDate', 'orderId', 'customerId', 'parentId', 'typeId', 'statusId', 'currencyId', 'currencyRate', 'totalPrice', 'totalPriceWithTax', 'discountWithoutTax', 'discountWithTax', 'allowPartialUse', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(CreditNoteTableMap::ID, CreditNoteTableMap::REF, CreditNoteTableMap::INVOICE_REF, CreditNoteTableMap::INVOICE_ADDRESS_ID, CreditNoteTableMap::INVOICE_DATE, CreditNoteTableMap::ORDER_ID, CreditNoteTableMap::CUSTOMER_ID, CreditNoteTableMap::PARENT_ID, CreditNoteTableMap::TYPE_ID, CreditNoteTableMap::STATUS_ID, CreditNoteTableMap::CURRENCY_ID, CreditNoteTableMap::CURRENCY_RATE, CreditNoteTableMap::TOTAL_PRICE, CreditNoteTableMap::TOTAL_PRICE_WITH_TAX, CreditNoteTableMap::DISCOUNT_WITHOUT_TAX, CreditNoteTableMap::DISCOUNT_WITH_TAX, CreditNoteTableMap::ALLOW_PARTIAL_USE, CreditNoteTableMap::CREATED_AT, CreditNoteTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'REF', 'INVOICE_REF', 'INVOICE_ADDRESS_ID', 'INVOICE_DATE', 'ORDER_ID', 'CUSTOMER_ID', 'PARENT_ID', 'TYPE_ID', 'STATUS_ID', 'CURRENCY_ID', 'CURRENCY_RATE', 'TOTAL_PRICE', 'TOTAL_PRICE_WITH_TAX', 'DISCOUNT_WITHOUT_TAX', 'DISCOUNT_WITH_TAX', 'ALLOW_PARTIAL_USE', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'ref', 'invoice_ref', 'invoice_address_id', 'invoice_date', 'order_id', 'customer_id', 'parent_id', 'type_id', 'status_id', 'currency_id', 'currency_rate', 'total_price', 'total_price_with_tax', 'discount_without_tax', 'discount_with_tax', 'allow_partial_use', '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, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'InvoiceRef' => 2, 'InvoiceAddressId' => 3, 'InvoiceDate' => 4, 'OrderId' => 5, 'CustomerId' => 6, 'ParentId' => 7, 'TypeId' => 8, 'StatusId' => 9, 'CurrencyId' => 10, 'CurrencyRate' => 11, 'TotalPrice' => 12, 'TotalPriceWithTax' => 13, 'DiscountWithoutTax' => 14, 'DiscountWithTax' => 15, 'AllowPartialUse' => 16, 'CreatedAt' => 17, 'UpdatedAt' => 18, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'invoiceRef' => 2, 'invoiceAddressId' => 3, 'invoiceDate' => 4, 'orderId' => 5, 'customerId' => 6, 'parentId' => 7, 'typeId' => 8, 'statusId' => 9, 'currencyId' => 10, 'currencyRate' => 11, 'totalPrice' => 12, 'totalPriceWithTax' => 13, 'discountWithoutTax' => 14, 'discountWithTax' => 15, 'allowPartialUse' => 16, 'createdAt' => 17, 'updatedAt' => 18, ),
+ self::TYPE_COLNAME => array(CreditNoteTableMap::ID => 0, CreditNoteTableMap::REF => 1, CreditNoteTableMap::INVOICE_REF => 2, CreditNoteTableMap::INVOICE_ADDRESS_ID => 3, CreditNoteTableMap::INVOICE_DATE => 4, CreditNoteTableMap::ORDER_ID => 5, CreditNoteTableMap::CUSTOMER_ID => 6, CreditNoteTableMap::PARENT_ID => 7, CreditNoteTableMap::TYPE_ID => 8, CreditNoteTableMap::STATUS_ID => 9, CreditNoteTableMap::CURRENCY_ID => 10, CreditNoteTableMap::CURRENCY_RATE => 11, CreditNoteTableMap::TOTAL_PRICE => 12, CreditNoteTableMap::TOTAL_PRICE_WITH_TAX => 13, CreditNoteTableMap::DISCOUNT_WITHOUT_TAX => 14, CreditNoteTableMap::DISCOUNT_WITH_TAX => 15, CreditNoteTableMap::ALLOW_PARTIAL_USE => 16, CreditNoteTableMap::CREATED_AT => 17, CreditNoteTableMap::UPDATED_AT => 18, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'INVOICE_REF' => 2, 'INVOICE_ADDRESS_ID' => 3, 'INVOICE_DATE' => 4, 'ORDER_ID' => 5, 'CUSTOMER_ID' => 6, 'PARENT_ID' => 7, 'TYPE_ID' => 8, 'STATUS_ID' => 9, 'CURRENCY_ID' => 10, 'CURRENCY_RATE' => 11, 'TOTAL_PRICE' => 12, 'TOTAL_PRICE_WITH_TAX' => 13, 'DISCOUNT_WITHOUT_TAX' => 14, 'DISCOUNT_WITH_TAX' => 15, 'ALLOW_PARTIAL_USE' => 16, 'CREATED_AT' => 17, 'UPDATED_AT' => 18, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'invoice_ref' => 2, 'invoice_address_id' => 3, 'invoice_date' => 4, 'order_id' => 5, 'customer_id' => 6, 'parent_id' => 7, 'type_id' => 8, 'status_id' => 9, 'currency_id' => 10, 'currency_rate' => 11, 'total_price' => 12, 'total_price_with_tax' => 13, 'discount_without_tax' => 14, 'discount_with_tax' => 15, 'allow_partial_use' => 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, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('credit_note');
+ $this->setPhpName('CreditNote');
+ $this->setClassName('\\CreditNote\\Model\\CreditNote');
+ $this->setPackage('CreditNote.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('REF', 'Ref', 'VARCHAR', false, 45, null);
+ $this->addColumn('INVOICE_REF', 'InvoiceRef', 'VARCHAR', false, 45, null);
+ $this->addForeignKey('INVOICE_ADDRESS_ID', 'InvoiceAddressId', 'INTEGER', 'credit_note_address', 'ID', true, null, null);
+ $this->addColumn('INVOICE_DATE', 'InvoiceDate', 'TIMESTAMP', false, null, null);
+ $this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', false, null, null);
+ $this->addForeignKey('CUSTOMER_ID', 'CustomerId', 'INTEGER', 'customer', 'ID', true, null, null);
+ $this->addForeignKey('PARENT_ID', 'ParentId', 'INTEGER', 'credit_note', 'ID', false, null, null);
+ $this->addForeignKey('TYPE_ID', 'TypeId', 'INTEGER', 'credit_note_type', 'ID', true, null, null);
+ $this->addForeignKey('STATUS_ID', 'StatusId', 'INTEGER', 'credit_note_status', 'ID', true, null, null);
+ $this->addForeignKey('CURRENCY_ID', 'CurrencyId', 'INTEGER', 'currency', 'ID', true, null, null);
+ $this->addColumn('CURRENCY_RATE', 'CurrencyRate', 'FLOAT', false, null, null);
+ $this->addColumn('TOTAL_PRICE', 'TotalPrice', 'DECIMAL', false, 16, 0);
+ $this->addColumn('TOTAL_PRICE_WITH_TAX', 'TotalPriceWithTax', 'DECIMAL', false, 16, 0);
+ $this->addColumn('DISCOUNT_WITHOUT_TAX', 'DiscountWithoutTax', 'DECIMAL', false, 16, 0);
+ $this->addColumn('DISCOUNT_WITH_TAX', 'DiscountWithTax', 'DECIMAL', false, 16, 0);
+ $this->addColumn('ALLOW_PARTIAL_USE', 'AllowPartialUse', 'BOOLEAN', false, 1, true);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'RESTRICT', 'RESTRICT');
+ $this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'RESTRICT', 'RESTRICT');
+ $this->addRelation('CreditNoteRelatedByParentId', '\\CreditNote\\Model\\CreditNote', RelationMap::MANY_TO_ONE, array('parent_id' => 'id', ), 'RESTRICT', 'RESTRICT');
+ $this->addRelation('CreditNoteType', '\\CreditNote\\Model\\CreditNoteType', RelationMap::MANY_TO_ONE, array('type_id' => 'id', ), 'RESTRICT', 'RESTRICT');
+ $this->addRelation('CreditNoteStatus', '\\CreditNote\\Model\\CreditNoteStatus', RelationMap::MANY_TO_ONE, array('status_id' => 'id', ), 'RESTRICT', 'RESTRICT');
+ $this->addRelation('Currency', '\\Thelia\\Model\\Currency', RelationMap::MANY_TO_ONE, array('currency_id' => 'id', ), 'RESTRICT', 'RESTRICT');
+ $this->addRelation('CreditNoteAddress', '\\CreditNote\\Model\\CreditNoteAddress', RelationMap::MANY_TO_ONE, array('invoice_address_id' => 'id', ), 'RESTRICT', 'RESTRICT');
+ $this->addRelation('CreditNoteRelatedById', '\\CreditNote\\Model\\CreditNote', RelationMap::ONE_TO_MANY, array('id' => 'parent_id', ), 'RESTRICT', 'RESTRICT', 'CreditNotesRelatedById');
+ $this->addRelation('OrderCreditNote', '\\CreditNote\\Model\\OrderCreditNote', RelationMap::ONE_TO_MANY, array('id' => 'credit_note_id', ), 'CASCADE', 'RESTRICT', 'OrderCreditNotes');
+ $this->addRelation('CartCreditNote', '\\CreditNote\\Model\\CartCreditNote', RelationMap::ONE_TO_MANY, array('id' => 'credit_note_id', ), 'CASCADE', 'RESTRICT', 'CartCreditNotes');
+ $this->addRelation('CreditNoteDetail', '\\CreditNote\\Model\\CreditNoteDetail', RelationMap::ONE_TO_MANY, array('id' => 'credit_note_id', ), 'CASCADE', 'RESTRICT', 'CreditNoteDetails');
+ $this->addRelation('CreditNoteComment', '\\CreditNote\\Model\\CreditNoteComment', RelationMap::ONE_TO_MANY, array('id' => 'credit_note_id', ), 'CASCADE', 'RESTRICT', 'CreditNoteComments');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to credit_note * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ OrderCreditNoteTableMap::clearInstancePool();
+ CartCreditNoteTableMap::clearInstancePool();
+ CreditNoteDetailTableMap::clearInstancePool();
+ CreditNoteCommentTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CreditNoteTableMap::CLASS_DEFAULT : CreditNoteTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CreditNote object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CreditNoteTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CreditNoteTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CreditNoteTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CreditNoteTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CreditNoteTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CreditNoteTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CreditNoteTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CreditNoteTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CreditNoteTableMap::ID);
+ $criteria->addSelectColumn(CreditNoteTableMap::REF);
+ $criteria->addSelectColumn(CreditNoteTableMap::INVOICE_REF);
+ $criteria->addSelectColumn(CreditNoteTableMap::INVOICE_ADDRESS_ID);
+ $criteria->addSelectColumn(CreditNoteTableMap::INVOICE_DATE);
+ $criteria->addSelectColumn(CreditNoteTableMap::ORDER_ID);
+ $criteria->addSelectColumn(CreditNoteTableMap::CUSTOMER_ID);
+ $criteria->addSelectColumn(CreditNoteTableMap::PARENT_ID);
+ $criteria->addSelectColumn(CreditNoteTableMap::TYPE_ID);
+ $criteria->addSelectColumn(CreditNoteTableMap::STATUS_ID);
+ $criteria->addSelectColumn(CreditNoteTableMap::CURRENCY_ID);
+ $criteria->addSelectColumn(CreditNoteTableMap::CURRENCY_RATE);
+ $criteria->addSelectColumn(CreditNoteTableMap::TOTAL_PRICE);
+ $criteria->addSelectColumn(CreditNoteTableMap::TOTAL_PRICE_WITH_TAX);
+ $criteria->addSelectColumn(CreditNoteTableMap::DISCOUNT_WITHOUT_TAX);
+ $criteria->addSelectColumn(CreditNoteTableMap::DISCOUNT_WITH_TAX);
+ $criteria->addSelectColumn(CreditNoteTableMap::ALLOW_PARTIAL_USE);
+ $criteria->addSelectColumn(CreditNoteTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CreditNoteTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.REF');
+ $criteria->addSelectColumn($alias . '.INVOICE_REF');
+ $criteria->addSelectColumn($alias . '.INVOICE_ADDRESS_ID');
+ $criteria->addSelectColumn($alias . '.INVOICE_DATE');
+ $criteria->addSelectColumn($alias . '.ORDER_ID');
+ $criteria->addSelectColumn($alias . '.CUSTOMER_ID');
+ $criteria->addSelectColumn($alias . '.PARENT_ID');
+ $criteria->addSelectColumn($alias . '.TYPE_ID');
+ $criteria->addSelectColumn($alias . '.STATUS_ID');
+ $criteria->addSelectColumn($alias . '.CURRENCY_ID');
+ $criteria->addSelectColumn($alias . '.CURRENCY_RATE');
+ $criteria->addSelectColumn($alias . '.TOTAL_PRICE');
+ $criteria->addSelectColumn($alias . '.TOTAL_PRICE_WITH_TAX');
+ $criteria->addSelectColumn($alias . '.DISCOUNT_WITHOUT_TAX');
+ $criteria->addSelectColumn($alias . '.DISCOUNT_WITH_TAX');
+ $criteria->addSelectColumn($alias . '.ALLOW_PARTIAL_USE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getServiceContainer()->getDatabaseMap(CreditNoteTableMap::DATABASE_NAME)->getTable(CreditNoteTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CreditNoteTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CreditNoteTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CreditNote or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CreditNote object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \CreditNote\Model\CreditNote) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CreditNoteTableMap::DATABASE_NAME);
+ $criteria->add(CreditNoteTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = CreditNoteQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CreditNoteTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CreditNoteTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the credit_note table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CreditNoteQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CreditNote or Criteria object.
+ *
+ * @param mixed $criteria Criteria or CreditNote object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from CreditNote object
+ }
+
+ if ($criteria->containsKey(CreditNoteTableMap::ID) && $criteria->keyContainsValue(CreditNoteTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CreditNoteTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = CreditNoteQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CreditNoteTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CreditNoteTableMap::buildTableMap();
diff --git a/local/modules/CreditNote/Model/Map/CreditNoteTypeI18nTableMap.php b/local/modules/CreditNote/Model/Map/CreditNoteTypeI18nTableMap.php
new file mode 100644
index 000000000..bdac74922
--- /dev/null
+++ b/local/modules/CreditNote/Model/Map/CreditNoteTypeI18nTableMap.php
@@ -0,0 +1,498 @@
+ array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_COLNAME => array(CreditNoteTypeI18nTableMap::ID, CreditNoteTypeI18nTableMap::LOCALE, CreditNoteTypeI18nTableMap::TITLE, CreditNoteTypeI18nTableMap::DESCRIPTION, CreditNoteTypeI18nTableMap::CHAPO, CreditNoteTypeI18nTableMap::POSTSCRIPTUM, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_COLNAME => array(CreditNoteTypeI18nTableMap::ID => 0, CreditNoteTypeI18nTableMap::LOCALE => 1, CreditNoteTypeI18nTableMap::TITLE => 2, CreditNoteTypeI18nTableMap::DESCRIPTION => 3, CreditNoteTypeI18nTableMap::CHAPO => 4, CreditNoteTypeI18nTableMap::POSTSCRIPTUM => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('credit_note_type_i18n');
+ $this->setPhpName('CreditNoteTypeI18n');
+ $this->setClassName('\\CreditNote\\Model\\CreditNoteTypeI18n');
+ $this->setPackage('CreditNote.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'credit_note_type', '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', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('CreditNoteType', '\\CreditNote\\Model\\CreditNoteType', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \CreditNote\Model\CreditNoteTypeI18n $obj A \CreditNote\Model\CreditNoteTypeI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \CreditNote\Model\CreditNoteTypeI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \CreditNote\Model\CreditNoteTypeI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \CreditNote\Model\CreditNoteTypeI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CreditNoteTypeI18nTableMap::CLASS_DEFAULT : CreditNoteTypeI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CreditNoteTypeI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CreditNoteTypeI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CreditNoteTypeI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CreditNoteTypeI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CreditNoteTypeI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CreditNoteTypeI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CreditNoteTypeI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CreditNoteTypeI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CreditNoteTypeI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CreditNoteTypeI18nTableMap::ID);
+ $criteria->addSelectColumn(CreditNoteTypeI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(CreditNoteTypeI18nTableMap::TITLE);
+ $criteria->addSelectColumn(CreditNoteTypeI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(CreditNoteTypeI18nTableMap::CHAPO);
+ $criteria->addSelectColumn(CreditNoteTypeI18nTableMap::POSTSCRIPTUM);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getServiceContainer()->getDatabaseMap(CreditNoteTypeI18nTableMap::DATABASE_NAME)->getTable(CreditNoteTypeI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteTypeI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CreditNoteTypeI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CreditNoteTypeI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CreditNoteTypeI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CreditNoteTypeI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \CreditNote\Model\CreditNoteTypeI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CreditNoteTypeI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(CreditNoteTypeI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(CreditNoteTypeI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = CreditNoteTypeI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CreditNoteTypeI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CreditNoteTypeI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the credit_note_type_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CreditNoteTypeI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CreditNoteTypeI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or CreditNoteTypeI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from CreditNoteTypeI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = CreditNoteTypeI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CreditNoteTypeI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CreditNoteTypeI18nTableMap::buildTableMap();
diff --git a/local/modules/CreditNote/Model/Map/CreditNoteTypeTableMap.php b/local/modules/CreditNote/Model/Map/CreditNoteTypeTableMap.php
new file mode 100644
index 000000000..6cff2460f
--- /dev/null
+++ b/local/modules/CreditNote/Model/Map/CreditNoteTypeTableMap.php
@@ -0,0 +1,484 @@
+ array('Id', 'Code', 'Color', 'Position', 'RequiredOrder', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'code', 'color', 'position', 'requiredOrder', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(CreditNoteTypeTableMap::ID, CreditNoteTypeTableMap::CODE, CreditNoteTypeTableMap::COLOR, CreditNoteTypeTableMap::POSITION, CreditNoteTypeTableMap::REQUIRED_ORDER, CreditNoteTypeTableMap::CREATED_AT, CreditNoteTypeTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'COLOR', 'POSITION', 'REQUIRED_ORDER', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'code', 'color', 'position', 'required_order', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Color' => 2, 'Position' => 3, 'RequiredOrder' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'color' => 2, 'position' => 3, 'requiredOrder' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ self::TYPE_COLNAME => array(CreditNoteTypeTableMap::ID => 0, CreditNoteTypeTableMap::CODE => 1, CreditNoteTypeTableMap::COLOR => 2, CreditNoteTypeTableMap::POSITION => 3, CreditNoteTypeTableMap::REQUIRED_ORDER => 4, CreditNoteTypeTableMap::CREATED_AT => 5, CreditNoteTypeTableMap::UPDATED_AT => 6, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'COLOR' => 2, 'POSITION' => 3, 'REQUIRED_ORDER' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'color' => 2, 'position' => 3, 'required_order' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('credit_note_type');
+ $this->setPhpName('CreditNoteType');
+ $this->setClassName('\\CreditNote\\Model\\CreditNoteType');
+ $this->setPackage('CreditNote.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null);
+ $this->addColumn('COLOR', 'Color', 'CHAR', false, 7, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, 11, null);
+ $this->addColumn('REQUIRED_ORDER', 'RequiredOrder', 'BOOLEAN', true, 1, false);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('CreditNote', '\\CreditNote\\Model\\CreditNote', RelationMap::ONE_TO_MANY, array('id' => 'type_id', ), 'RESTRICT', 'RESTRICT', 'CreditNotes');
+ $this->addRelation('CreditNoteTypeI18n', '\\CreditNote\\Model\\CreditNoteTypeI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CreditNoteTypeI18ns');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to credit_note_type * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ CreditNoteTypeI18nTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CreditNoteTypeTableMap::CLASS_DEFAULT : CreditNoteTypeTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CreditNoteType object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CreditNoteTypeTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CreditNoteTypeTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CreditNoteTypeTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CreditNoteTypeTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CreditNoteTypeTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CreditNoteTypeTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CreditNoteTypeTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CreditNoteTypeTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CreditNoteTypeTableMap::ID);
+ $criteria->addSelectColumn(CreditNoteTypeTableMap::CODE);
+ $criteria->addSelectColumn(CreditNoteTypeTableMap::COLOR);
+ $criteria->addSelectColumn(CreditNoteTypeTableMap::POSITION);
+ $criteria->addSelectColumn(CreditNoteTypeTableMap::REQUIRED_ORDER);
+ $criteria->addSelectColumn(CreditNoteTypeTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CreditNoteTypeTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.COLOR');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.REQUIRED_ORDER');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getServiceContainer()->getDatabaseMap(CreditNoteTypeTableMap::DATABASE_NAME)->getTable(CreditNoteTypeTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteTypeTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CreditNoteTypeTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CreditNoteTypeTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CreditNoteType or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CreditNoteType object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \CreditNote\Model\CreditNoteType) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CreditNoteTypeTableMap::DATABASE_NAME);
+ $criteria->add(CreditNoteTypeTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = CreditNoteTypeQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CreditNoteTypeTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CreditNoteTypeTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the credit_note_type table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CreditNoteTypeQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CreditNoteType or Criteria object.
+ *
+ * @param mixed $criteria Criteria or CreditNoteType object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from CreditNoteType object
+ }
+
+ if ($criteria->containsKey(CreditNoteTypeTableMap::ID) && $criteria->keyContainsValue(CreditNoteTypeTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CreditNoteTypeTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = CreditNoteTypeQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CreditNoteTypeTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CreditNoteTypeTableMap::buildTableMap();
diff --git a/local/modules/CreditNote/Model/Map/CreditNoteVersionTableMap.php b/local/modules/CreditNote/Model/Map/CreditNoteVersionTableMap.php
new file mode 100644
index 000000000..ffd3d1e8f
--- /dev/null
+++ b/local/modules/CreditNote/Model/Map/CreditNoteVersionTableMap.php
@@ -0,0 +1,666 @@
+ array('Id', 'Ref', 'InvoiceRef', 'InvoiceAddressId', 'InvoiceDate', 'OrderId', 'CustomerId', 'ParentId', 'TypeId', 'StatusId', 'CurrencyId', 'CurrencyRate', 'TotalPrice', 'TotalPriceWithTax', 'DiscountWithoutTax', 'DiscountWithTax', 'AllowPartialUse', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', 'OrderIdVersion', 'CustomerIdVersion', 'ParentIdVersion', 'CreditNoteIds', 'CreditNoteVersions', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'invoiceRef', 'invoiceAddressId', 'invoiceDate', 'orderId', 'customerId', 'parentId', 'typeId', 'statusId', 'currencyId', 'currencyRate', 'totalPrice', 'totalPriceWithTax', 'discountWithoutTax', 'discountWithTax', 'allowPartialUse', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', 'orderIdVersion', 'customerIdVersion', 'parentIdVersion', 'creditNoteIds', 'creditNoteVersions', ),
+ self::TYPE_COLNAME => array(CreditNoteVersionTableMap::ID, CreditNoteVersionTableMap::REF, CreditNoteVersionTableMap::INVOICE_REF, CreditNoteVersionTableMap::INVOICE_ADDRESS_ID, CreditNoteVersionTableMap::INVOICE_DATE, CreditNoteVersionTableMap::ORDER_ID, CreditNoteVersionTableMap::CUSTOMER_ID, CreditNoteVersionTableMap::PARENT_ID, CreditNoteVersionTableMap::TYPE_ID, CreditNoteVersionTableMap::STATUS_ID, CreditNoteVersionTableMap::CURRENCY_ID, CreditNoteVersionTableMap::CURRENCY_RATE, CreditNoteVersionTableMap::TOTAL_PRICE, CreditNoteVersionTableMap::TOTAL_PRICE_WITH_TAX, CreditNoteVersionTableMap::DISCOUNT_WITHOUT_TAX, CreditNoteVersionTableMap::DISCOUNT_WITH_TAX, CreditNoteVersionTableMap::ALLOW_PARTIAL_USE, CreditNoteVersionTableMap::CREATED_AT, CreditNoteVersionTableMap::UPDATED_AT, CreditNoteVersionTableMap::VERSION, CreditNoteVersionTableMap::VERSION_CREATED_AT, CreditNoteVersionTableMap::VERSION_CREATED_BY, CreditNoteVersionTableMap::ORDER_ID_VERSION, CreditNoteVersionTableMap::CUSTOMER_ID_VERSION, CreditNoteVersionTableMap::PARENT_ID_VERSION, CreditNoteVersionTableMap::CREDIT_NOTE_IDS, CreditNoteVersionTableMap::CREDIT_NOTE_VERSIONS, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'REF', 'INVOICE_REF', 'INVOICE_ADDRESS_ID', 'INVOICE_DATE', 'ORDER_ID', 'CUSTOMER_ID', 'PARENT_ID', 'TYPE_ID', 'STATUS_ID', 'CURRENCY_ID', 'CURRENCY_RATE', 'TOTAL_PRICE', 'TOTAL_PRICE_WITH_TAX', 'DISCOUNT_WITHOUT_TAX', 'DISCOUNT_WITH_TAX', 'ALLOW_PARTIAL_USE', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', 'ORDER_ID_VERSION', 'CUSTOMER_ID_VERSION', 'PARENT_ID_VERSION', 'CREDIT_NOTE_IDS', 'CREDIT_NOTE_VERSIONS', ),
+ self::TYPE_FIELDNAME => array('id', 'ref', 'invoice_ref', 'invoice_address_id', 'invoice_date', 'order_id', 'customer_id', 'parent_id', 'type_id', 'status_id', 'currency_id', 'currency_rate', 'total_price', 'total_price_with_tax', 'discount_without_tax', 'discount_with_tax', 'allow_partial_use', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', 'order_id_version', 'customer_id_version', 'parent_id_version', 'credit_note_ids', 'credit_note_versions', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'InvoiceRef' => 2, 'InvoiceAddressId' => 3, 'InvoiceDate' => 4, 'OrderId' => 5, 'CustomerId' => 6, 'ParentId' => 7, 'TypeId' => 8, 'StatusId' => 9, 'CurrencyId' => 10, 'CurrencyRate' => 11, 'TotalPrice' => 12, 'TotalPriceWithTax' => 13, 'DiscountWithoutTax' => 14, 'DiscountWithTax' => 15, 'AllowPartialUse' => 16, 'CreatedAt' => 17, 'UpdatedAt' => 18, 'Version' => 19, 'VersionCreatedAt' => 20, 'VersionCreatedBy' => 21, 'OrderIdVersion' => 22, 'CustomerIdVersion' => 23, 'ParentIdVersion' => 24, 'CreditNoteIds' => 25, 'CreditNoteVersions' => 26, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'invoiceRef' => 2, 'invoiceAddressId' => 3, 'invoiceDate' => 4, 'orderId' => 5, 'customerId' => 6, 'parentId' => 7, 'typeId' => 8, 'statusId' => 9, 'currencyId' => 10, 'currencyRate' => 11, 'totalPrice' => 12, 'totalPriceWithTax' => 13, 'discountWithoutTax' => 14, 'discountWithTax' => 15, 'allowPartialUse' => 16, 'createdAt' => 17, 'updatedAt' => 18, 'version' => 19, 'versionCreatedAt' => 20, 'versionCreatedBy' => 21, 'orderIdVersion' => 22, 'customerIdVersion' => 23, 'parentIdVersion' => 24, 'creditNoteIds' => 25, 'creditNoteVersions' => 26, ),
+ self::TYPE_COLNAME => array(CreditNoteVersionTableMap::ID => 0, CreditNoteVersionTableMap::REF => 1, CreditNoteVersionTableMap::INVOICE_REF => 2, CreditNoteVersionTableMap::INVOICE_ADDRESS_ID => 3, CreditNoteVersionTableMap::INVOICE_DATE => 4, CreditNoteVersionTableMap::ORDER_ID => 5, CreditNoteVersionTableMap::CUSTOMER_ID => 6, CreditNoteVersionTableMap::PARENT_ID => 7, CreditNoteVersionTableMap::TYPE_ID => 8, CreditNoteVersionTableMap::STATUS_ID => 9, CreditNoteVersionTableMap::CURRENCY_ID => 10, CreditNoteVersionTableMap::CURRENCY_RATE => 11, CreditNoteVersionTableMap::TOTAL_PRICE => 12, CreditNoteVersionTableMap::TOTAL_PRICE_WITH_TAX => 13, CreditNoteVersionTableMap::DISCOUNT_WITHOUT_TAX => 14, CreditNoteVersionTableMap::DISCOUNT_WITH_TAX => 15, CreditNoteVersionTableMap::ALLOW_PARTIAL_USE => 16, CreditNoteVersionTableMap::CREATED_AT => 17, CreditNoteVersionTableMap::UPDATED_AT => 18, CreditNoteVersionTableMap::VERSION => 19, CreditNoteVersionTableMap::VERSION_CREATED_AT => 20, CreditNoteVersionTableMap::VERSION_CREATED_BY => 21, CreditNoteVersionTableMap::ORDER_ID_VERSION => 22, CreditNoteVersionTableMap::CUSTOMER_ID_VERSION => 23, CreditNoteVersionTableMap::PARENT_ID_VERSION => 24, CreditNoteVersionTableMap::CREDIT_NOTE_IDS => 25, CreditNoteVersionTableMap::CREDIT_NOTE_VERSIONS => 26, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'INVOICE_REF' => 2, 'INVOICE_ADDRESS_ID' => 3, 'INVOICE_DATE' => 4, 'ORDER_ID' => 5, 'CUSTOMER_ID' => 6, 'PARENT_ID' => 7, 'TYPE_ID' => 8, 'STATUS_ID' => 9, 'CURRENCY_ID' => 10, 'CURRENCY_RATE' => 11, 'TOTAL_PRICE' => 12, 'TOTAL_PRICE_WITH_TAX' => 13, 'DISCOUNT_WITHOUT_TAX' => 14, 'DISCOUNT_WITH_TAX' => 15, 'ALLOW_PARTIAL_USE' => 16, 'CREATED_AT' => 17, 'UPDATED_AT' => 18, 'VERSION' => 19, 'VERSION_CREATED_AT' => 20, 'VERSION_CREATED_BY' => 21, 'ORDER_ID_VERSION' => 22, 'CUSTOMER_ID_VERSION' => 23, 'PARENT_ID_VERSION' => 24, 'CREDIT_NOTE_IDS' => 25, 'CREDIT_NOTE_VERSIONS' => 26, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'invoice_ref' => 2, 'invoice_address_id' => 3, 'invoice_date' => 4, 'order_id' => 5, 'customer_id' => 6, 'parent_id' => 7, 'type_id' => 8, 'status_id' => 9, 'currency_id' => 10, 'currency_rate' => 11, 'total_price' => 12, 'total_price_with_tax' => 13, 'discount_without_tax' => 14, 'discount_with_tax' => 15, 'allow_partial_use' => 16, 'created_at' => 17, 'updated_at' => 18, 'version' => 19, 'version_created_at' => 20, 'version_created_by' => 21, 'order_id_version' => 22, 'customer_id_version' => 23, 'parent_id_version' => 24, 'credit_note_ids' => 25, 'credit_note_versions' => 26, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('credit_note_version');
+ $this->setPhpName('CreditNoteVersion');
+ $this->setClassName('\\CreditNote\\Model\\CreditNoteVersion');
+ $this->setPackage('CreditNote.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'credit_note', 'ID', true, null, null);
+ $this->addColumn('REF', 'Ref', 'VARCHAR', false, 45, null);
+ $this->addColumn('INVOICE_REF', 'InvoiceRef', 'VARCHAR', false, 45, null);
+ $this->addColumn('INVOICE_ADDRESS_ID', 'InvoiceAddressId', 'INTEGER', true, null, null);
+ $this->addColumn('INVOICE_DATE', 'InvoiceDate', 'TIMESTAMP', false, null, null);
+ $this->addColumn('ORDER_ID', 'OrderId', 'INTEGER', false, null, null);
+ $this->addColumn('CUSTOMER_ID', 'CustomerId', 'INTEGER', true, null, null);
+ $this->addColumn('PARENT_ID', 'ParentId', 'INTEGER', false, null, null);
+ $this->addColumn('TYPE_ID', 'TypeId', 'INTEGER', true, null, null);
+ $this->addColumn('STATUS_ID', 'StatusId', 'INTEGER', true, null, null);
+ $this->addColumn('CURRENCY_ID', 'CurrencyId', 'INTEGER', true, null, null);
+ $this->addColumn('CURRENCY_RATE', 'CurrencyRate', 'FLOAT', false, null, null);
+ $this->addColumn('TOTAL_PRICE', 'TotalPrice', 'DECIMAL', false, 16, 0);
+ $this->addColumn('TOTAL_PRICE_WITH_TAX', 'TotalPriceWithTax', 'DECIMAL', false, 16, 0);
+ $this->addColumn('DISCOUNT_WITHOUT_TAX', 'DiscountWithoutTax', 'DECIMAL', false, 16, 0);
+ $this->addColumn('DISCOUNT_WITH_TAX', 'DiscountWithTax', 'DECIMAL', false, 16, 0);
+ $this->addColumn('ALLOW_PARTIAL_USE', 'AllowPartialUse', 'BOOLEAN', false, 1, true);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
+ $this->addColumn('ORDER_ID_VERSION', 'OrderIdVersion', 'INTEGER', false, null, 0);
+ $this->addColumn('CUSTOMER_ID_VERSION', 'CustomerIdVersion', 'INTEGER', false, null, 0);
+ $this->addColumn('PARENT_ID_VERSION', 'ParentIdVersion', 'INTEGER', false, null, 0);
+ $this->addColumn('CREDIT_NOTE_IDS', 'CreditNoteIds', 'ARRAY', false, null, null);
+ $this->addColumn('CREDIT_NOTE_VERSIONS', 'CreditNoteVersions', 'ARRAY', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('CreditNote', '\\CreditNote\\Model\\CreditNote', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \CreditNote\Model\CreditNoteVersion $obj A \CreditNote\Model\CreditNoteVersion object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getVersion()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \CreditNote\Model\CreditNoteVersion object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \CreditNote\Model\CreditNoteVersion) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getVersion()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \CreditNote\Model\CreditNoteVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 19 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 19 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CreditNoteVersionTableMap::CLASS_DEFAULT : CreditNoteVersionTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CreditNoteVersion object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CreditNoteVersionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CreditNoteVersionTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CreditNoteVersionTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CreditNoteVersionTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CreditNoteVersionTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CreditNoteVersionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CreditNoteVersionTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CreditNoteVersionTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::ID);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::REF);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::INVOICE_REF);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::INVOICE_ADDRESS_ID);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::INVOICE_DATE);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::ORDER_ID);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::CUSTOMER_ID);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::PARENT_ID);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::TYPE_ID);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::STATUS_ID);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::CURRENCY_ID);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::CURRENCY_RATE);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::TOTAL_PRICE);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::TOTAL_PRICE_WITH_TAX);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::DISCOUNT_WITHOUT_TAX);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::DISCOUNT_WITH_TAX);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::ALLOW_PARTIAL_USE);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::UPDATED_AT);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::VERSION);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::VERSION_CREATED_BY);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::ORDER_ID_VERSION);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::CUSTOMER_ID_VERSION);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::PARENT_ID_VERSION);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::CREDIT_NOTE_IDS);
+ $criteria->addSelectColumn(CreditNoteVersionTableMap::CREDIT_NOTE_VERSIONS);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.REF');
+ $criteria->addSelectColumn($alias . '.INVOICE_REF');
+ $criteria->addSelectColumn($alias . '.INVOICE_ADDRESS_ID');
+ $criteria->addSelectColumn($alias . '.INVOICE_DATE');
+ $criteria->addSelectColumn($alias . '.ORDER_ID');
+ $criteria->addSelectColumn($alias . '.CUSTOMER_ID');
+ $criteria->addSelectColumn($alias . '.PARENT_ID');
+ $criteria->addSelectColumn($alias . '.TYPE_ID');
+ $criteria->addSelectColumn($alias . '.STATUS_ID');
+ $criteria->addSelectColumn($alias . '.CURRENCY_ID');
+ $criteria->addSelectColumn($alias . '.CURRENCY_RATE');
+ $criteria->addSelectColumn($alias . '.TOTAL_PRICE');
+ $criteria->addSelectColumn($alias . '.TOTAL_PRICE_WITH_TAX');
+ $criteria->addSelectColumn($alias . '.DISCOUNT_WITHOUT_TAX');
+ $criteria->addSelectColumn($alias . '.DISCOUNT_WITH_TAX');
+ $criteria->addSelectColumn($alias . '.ALLOW_PARTIAL_USE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
+ $criteria->addSelectColumn($alias . '.ORDER_ID_VERSION');
+ $criteria->addSelectColumn($alias . '.CUSTOMER_ID_VERSION');
+ $criteria->addSelectColumn($alias . '.PARENT_ID_VERSION');
+ $criteria->addSelectColumn($alias . '.CREDIT_NOTE_IDS');
+ $criteria->addSelectColumn($alias . '.CREDIT_NOTE_VERSIONS');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getServiceContainer()->getDatabaseMap(CreditNoteVersionTableMap::DATABASE_NAME)->getTable(CreditNoteVersionTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteVersionTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CreditNoteVersionTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CreditNoteVersionTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CreditNoteVersion or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CreditNoteVersion object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteVersionTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \CreditNote\Model\CreditNoteVersion) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CreditNoteVersionTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(CreditNoteVersionTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(CreditNoteVersionTableMap::VERSION, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = CreditNoteVersionQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CreditNoteVersionTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CreditNoteVersionTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the credit_note_version table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CreditNoteVersionQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CreditNoteVersion or Criteria object.
+ *
+ * @param mixed $criteria Criteria or CreditNoteVersion object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CreditNoteVersionTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from CreditNoteVersion object
+ }
+
+
+ // Set the correct dbName
+ $query = CreditNoteVersionQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CreditNoteVersionTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CreditNoteVersionTableMap::buildTableMap();
diff --git a/local/modules/CreditNote/Model/Map/OrderCreditNoteTableMap.php b/local/modules/CreditNote/Model/Map/OrderCreditNoteTableMap.php
new file mode 100644
index 000000000..4efdedbbe
--- /dev/null
+++ b/local/modules/CreditNote/Model/Map/OrderCreditNoteTableMap.php
@@ -0,0 +1,504 @@
+ array('OrderId', 'CreditNoteId', 'AmountPrice', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('orderId', 'creditNoteId', 'amountPrice', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(OrderCreditNoteTableMap::ORDER_ID, OrderCreditNoteTableMap::CREDIT_NOTE_ID, OrderCreditNoteTableMap::AMOUNT_PRICE, OrderCreditNoteTableMap::CREATED_AT, OrderCreditNoteTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ORDER_ID', 'CREDIT_NOTE_ID', 'AMOUNT_PRICE', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('order_id', 'credit_note_id', 'amount_price', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('OrderId' => 0, 'CreditNoteId' => 1, 'AmountPrice' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ self::TYPE_STUDLYPHPNAME => array('orderId' => 0, 'creditNoteId' => 1, 'amountPrice' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ self::TYPE_COLNAME => array(OrderCreditNoteTableMap::ORDER_ID => 0, OrderCreditNoteTableMap::CREDIT_NOTE_ID => 1, OrderCreditNoteTableMap::AMOUNT_PRICE => 2, OrderCreditNoteTableMap::CREATED_AT => 3, OrderCreditNoteTableMap::UPDATED_AT => 4, ),
+ self::TYPE_RAW_COLNAME => array('ORDER_ID' => 0, 'CREDIT_NOTE_ID' => 1, 'AMOUNT_PRICE' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ self::TYPE_FIELDNAME => array('order_id' => 0, 'credit_note_id' => 1, 'amount_price' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('order_credit_note');
+ $this->setPhpName('OrderCreditNote');
+ $this->setClassName('\\CreditNote\\Model\\OrderCreditNote');
+ $this->setPackage('CreditNote.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ORDER_ID', 'OrderId', 'INTEGER' , 'order', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('CREDIT_NOTE_ID', 'CreditNoteId', 'INTEGER' , 'credit_note', 'ID', true, null, null);
+ $this->addColumn('AMOUNT_PRICE', 'AmountPrice', 'DECIMAL', false, 16, 0);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('CreditNote', '\\CreditNote\\Model\\CreditNote', RelationMap::MANY_TO_ONE, array('credit_note_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \CreditNote\Model\OrderCreditNote $obj A \CreditNote\Model\OrderCreditNote object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getOrderId(), (string) $obj->getCreditNoteId()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \CreditNote\Model\OrderCreditNote object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \CreditNote\Model\OrderCreditNote) {
+ $key = serialize(array((string) $value->getOrderId(), (string) $value->getCreditNoteId()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \CreditNote\Model\OrderCreditNote object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('OrderId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CreditNoteId', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('OrderId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CreditNoteId', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? OrderCreditNoteTableMap::CLASS_DEFAULT : OrderCreditNoteTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (OrderCreditNote object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = OrderCreditNoteTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = OrderCreditNoteTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + OrderCreditNoteTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = OrderCreditNoteTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ OrderCreditNoteTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = OrderCreditNoteTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = OrderCreditNoteTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ OrderCreditNoteTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(OrderCreditNoteTableMap::ORDER_ID);
+ $criteria->addSelectColumn(OrderCreditNoteTableMap::CREDIT_NOTE_ID);
+ $criteria->addSelectColumn(OrderCreditNoteTableMap::AMOUNT_PRICE);
+ $criteria->addSelectColumn(OrderCreditNoteTableMap::CREATED_AT);
+ $criteria->addSelectColumn(OrderCreditNoteTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ORDER_ID');
+ $criteria->addSelectColumn($alias . '.CREDIT_NOTE_ID');
+ $criteria->addSelectColumn($alias . '.AMOUNT_PRICE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getServiceContainer()->getDatabaseMap(OrderCreditNoteTableMap::DATABASE_NAME)->getTable(OrderCreditNoteTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderCreditNoteTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(OrderCreditNoteTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new OrderCreditNoteTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a OrderCreditNote or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or OrderCreditNote object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderCreditNoteTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \CreditNote\Model\OrderCreditNote) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(OrderCreditNoteTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(OrderCreditNoteTableMap::ORDER_ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(OrderCreditNoteTableMap::CREDIT_NOTE_ID, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = OrderCreditNoteQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { OrderCreditNoteTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { OrderCreditNoteTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the order_credit_note table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return OrderCreditNoteQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a OrderCreditNote or Criteria object.
+ *
+ * @param mixed $criteria Criteria or OrderCreditNote object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderCreditNoteTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from OrderCreditNote object
+ }
+
+
+ // Set the correct dbName
+ $query = OrderCreditNoteQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // OrderCreditNoteTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+OrderCreditNoteTableMap::buildTableMap();
diff --git a/local/modules/CreditNote/Model/OrderCreditNote.php b/local/modules/CreditNote/Model/OrderCreditNote.php
new file mode 100644
index 000000000..cd8af1b97
--- /dev/null
+++ b/local/modules/CreditNote/Model/OrderCreditNote.php
@@ -0,0 +1,10 @@
+gilles.bourgeat@gmail.com>
+ */
+trait ModelEventDispatcherTrait
+{
+ use TheliaModelEventDispatcherTrait;
+
+ protected function getTableName()
+ {
+ $tableMapClass = self::TABLE_MAP;
+ return $tableMapClass::TABLE_NAME;
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ parent::preInsert($con);
+
+ if ($this->getDispatcher() !== null) {
+ /** @var ActiveRecordInterface $this */
+ $event = new PropelEvent($this);
+ /** @var ModelEventDispatcherTrait $this */
+ $this->getDispatcher()->dispatch(CreditNoteEvents::PROPEL_PRE_INSERT . $this->getTableName(), $event);
+
+ if ($event->isPropagationStopped()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+ parent::postInsert($con);
+
+ if ($this->getDispatcher() !== null) {
+ /** @var ActiveRecordInterface $this */
+ $event = new PropelEvent($this);
+ /** @var ModelEventDispatcherTrait $this */
+ $this->getDispatcher()->dispatch(CreditNoteEvents::PROPEL_POST_INSERT . $this->getTableName(), $event);
+ }
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ parent::preUpdate($con);
+
+ if ($this->getDispatcher() !== null) {
+ /** @var ActiveRecordInterface $this */
+ $event = new PropelEvent($this);
+ /** @var ModelEventDispatcherTrait $this */
+ $this->getDispatcher()->dispatch(CreditNoteEvents::PROPEL_PRE_UPDATE . $this->getTableName(), $event);
+
+ if ($event->isPropagationStopped()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+ parent::postUpdate($con);
+
+ if ($this->getDispatcher() !== null) {
+ /** @var ActiveRecordInterface $this */
+ $event = new PropelEvent($this);
+ /** @var ModelEventDispatcherTrait $this */
+ $this->getDispatcher()->dispatch(CreditNoteEvents::PROPEL_POST_UPDATE . $this->getTableName(), $event);
+ }
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ parent::preDelete($con);
+
+ if ($this->getDispatcher() !== null) {
+ /** @var ActiveRecordInterface $this */
+ $event = new PropelEvent($this);
+ /** @var ModelEventDispatcherTrait $this */
+ $this->getDispatcher()->dispatch(CreditNoteEvents::PROPEL_PRE_DELETE . $this->getTableName(), $event);
+
+ if ($event->isPropagationStopped()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+ parent::postDelete($con);
+
+ if ($this->getDispatcher() !== null) {
+ /** @var ActiveRecordInterface $this */
+ $event = new PropelEvent($this);
+ /** @var ModelEventDispatcherTrait $this */
+ $this->getDispatcher()->dispatch(CreditNoteEvents::PROPEL_POST_DELETE . $this->getTableName(), $event);
+ }
+ }
+}
diff --git a/local/modules/CreditNote/Readme.md b/local/modules/CreditNote/Readme.md
new file mode 100644
index 000000000..0b24e5802
--- /dev/null
+++ b/local/modules/CreditNote/Readme.md
@@ -0,0 +1,24 @@
+# Credit Note
+
+Author: Gilles Bourgeat