<?php


abstract class BaseTiposComision extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $tipcomi;


	
	protected $descomi;


	
	protected $observ;


	
	protected $dcomi;


	
	protected $viaticos = '0';


	
	protected $manutencion = '0';


	
	protected $taxis = '0';


	
	protected $objetos = '0';


	
	protected $destinos = '0';


	
	protected $fecha_ini = '0';


	
	protected $fecha_ant = '0';


	
	protected $cruce = '0';

	
	protected $collComisioness;

	
	protected $lastComisionesCriteria = null;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getTipcomi()
	{

		return $this->tipcomi;
	}

	
	public function getDescomi()
	{

		return $this->descomi;
	}

	
	public function getObserv()
	{

		return $this->observ;
	}

	
	public function getDcomi()
	{

		return $this->dcomi;
	}

	
	public function getViaticos()
	{

		return $this->viaticos;
	}

	
	public function getManutencion()
	{

		return $this->manutencion;
	}

	
	public function getTaxis()
	{

		return $this->taxis;
	}

	
	public function getObjetos()
	{

		return $this->objetos;
	}

	
	public function getDestinos()
	{

		return $this->destinos;
	}

	
	public function getFechaIni()
	{

		return $this->fecha_ini;
	}

	
	public function getFechaAnt()
	{

		return $this->fecha_ant;
	}

	
	public function getCruce()
	{

		return $this->cruce;
	}

	
	public function setTipcomi($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->tipcomi !== $v) {
			$this->tipcomi = $v;
			$this->modifiedColumns[] = TiposComisionPeer::TIPCOMI;
		}

	} 
	
	public function setDescomi($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->descomi !== $v) {
			$this->descomi = $v;
			$this->modifiedColumns[] = TiposComisionPeer::DESCOMI;
		}

	} 
	
	public function setObserv($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->observ !== $v) {
			$this->observ = $v;
			$this->modifiedColumns[] = TiposComisionPeer::OBSERV;
		}

	} 
	
	public function setDcomi($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->dcomi !== $v) {
			$this->dcomi = $v;
			$this->modifiedColumns[] = TiposComisionPeer::DCOMI;
		}

	} 
	
	public function setViaticos($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->viaticos !== $v || $v === '0') {
			$this->viaticos = $v;
			$this->modifiedColumns[] = TiposComisionPeer::VIATICOS;
		}

	} 
	
	public function setManutencion($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->manutencion !== $v || $v === '0') {
			$this->manutencion = $v;
			$this->modifiedColumns[] = TiposComisionPeer::MANUTENCION;
		}

	} 
	
	public function setTaxis($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->taxis !== $v || $v === '0') {
			$this->taxis = $v;
			$this->modifiedColumns[] = TiposComisionPeer::TAXIS;
		}

	} 
	
	public function setObjetos($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->objetos !== $v || $v === '0') {
			$this->objetos = $v;
			$this->modifiedColumns[] = TiposComisionPeer::OBJETOS;
		}

	} 
	
	public function setDestinos($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->destinos !== $v || $v === '0') {
			$this->destinos = $v;
			$this->modifiedColumns[] = TiposComisionPeer::DESTINOS;
		}

	} 
	
	public function setFechaIni($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->fecha_ini !== $v || $v === '0') {
			$this->fecha_ini = $v;
			$this->modifiedColumns[] = TiposComisionPeer::FECHA_INI;
		}

	} 
	
	public function setFechaAnt($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->fecha_ant !== $v || $v === '0') {
			$this->fecha_ant = $v;
			$this->modifiedColumns[] = TiposComisionPeer::FECHA_ANT;
		}

	} 
	
	public function setCruce($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cruce !== $v || $v === '0') {
			$this->cruce = $v;
			$this->modifiedColumns[] = TiposComisionPeer::CRUCE;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->tipcomi = $rs->getString($startcol + 0);

			$this->descomi = $rs->getString($startcol + 1);

			$this->observ = $rs->getString($startcol + 2);

			$this->dcomi = $rs->getString($startcol + 3);

			$this->viaticos = $rs->getString($startcol + 4);

			$this->manutencion = $rs->getString($startcol + 5);

			$this->taxis = $rs->getString($startcol + 6);

			$this->objetos = $rs->getString($startcol + 7);

			$this->destinos = $rs->getString($startcol + 8);

			$this->fecha_ini = $rs->getString($startcol + 9);

			$this->fecha_ant = $rs->getString($startcol + 10);

			$this->cruce = $rs->getString($startcol + 11);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 12; 
		} catch (Exception $e) {
			throw new PropelException("Error populating TiposComision object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(TiposComisionPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			TiposComisionPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(TiposComisionPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = TiposComisionPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setNew(false);
				} else {
					$affectedRows += TiposComisionPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			if ($this->collComisioness !== null) {
				foreach($this->collComisioness as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = TiposComisionPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}


				if ($this->collComisioness !== null) {
					foreach($this->collComisioness as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}


			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = TiposComisionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getTipcomi();
				break;
			case 1:
				return $this->getDescomi();
				break;
			case 2:
				return $this->getObserv();
				break;
			case 3:
				return $this->getDcomi();
				break;
			case 4:
				return $this->getViaticos();
				break;
			case 5:
				return $this->getManutencion();
				break;
			case 6:
				return $this->getTaxis();
				break;
			case 7:
				return $this->getObjetos();
				break;
			case 8:
				return $this->getDestinos();
				break;
			case 9:
				return $this->getFechaIni();
				break;
			case 10:
				return $this->getFechaAnt();
				break;
			case 11:
				return $this->getCruce();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = TiposComisionPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getTipcomi(),
			$keys[1] => $this->getDescomi(),
			$keys[2] => $this->getObserv(),
			$keys[3] => $this->getDcomi(),
			$keys[4] => $this->getViaticos(),
			$keys[5] => $this->getManutencion(),
			$keys[6] => $this->getTaxis(),
			$keys[7] => $this->getObjetos(),
			$keys[8] => $this->getDestinos(),
			$keys[9] => $this->getFechaIni(),
			$keys[10] => $this->getFechaAnt(),
			$keys[11] => $this->getCruce(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = TiposComisionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setTipcomi($value);
				break;
			case 1:
				$this->setDescomi($value);
				break;
			case 2:
				$this->setObserv($value);
				break;
			case 3:
				$this->setDcomi($value);
				break;
			case 4:
				$this->setViaticos($value);
				break;
			case 5:
				$this->setManutencion($value);
				break;
			case 6:
				$this->setTaxis($value);
				break;
			case 7:
				$this->setObjetos($value);
				break;
			case 8:
				$this->setDestinos($value);
				break;
			case 9:
				$this->setFechaIni($value);
				break;
			case 10:
				$this->setFechaAnt($value);
				break;
			case 11:
				$this->setCruce($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = TiposComisionPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setTipcomi($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setDescomi($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setObserv($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setDcomi($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setViaticos($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setManutencion($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setTaxis($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setObjetos($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setDestinos($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setFechaIni($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setFechaAnt($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setCruce($arr[$keys[11]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(TiposComisionPeer::DATABASE_NAME);

		if ($this->isColumnModified(TiposComisionPeer::TIPCOMI)) $criteria->add(TiposComisionPeer::TIPCOMI, $this->tipcomi);
		if ($this->isColumnModified(TiposComisionPeer::DESCOMI)) $criteria->add(TiposComisionPeer::DESCOMI, $this->descomi);
		if ($this->isColumnModified(TiposComisionPeer::OBSERV)) $criteria->add(TiposComisionPeer::OBSERV, $this->observ);
		if ($this->isColumnModified(TiposComisionPeer::DCOMI)) $criteria->add(TiposComisionPeer::DCOMI, $this->dcomi);
		if ($this->isColumnModified(TiposComisionPeer::VIATICOS)) $criteria->add(TiposComisionPeer::VIATICOS, $this->viaticos);
		if ($this->isColumnModified(TiposComisionPeer::MANUTENCION)) $criteria->add(TiposComisionPeer::MANUTENCION, $this->manutencion);
		if ($this->isColumnModified(TiposComisionPeer::TAXIS)) $criteria->add(TiposComisionPeer::TAXIS, $this->taxis);
		if ($this->isColumnModified(TiposComisionPeer::OBJETOS)) $criteria->add(TiposComisionPeer::OBJETOS, $this->objetos);
		if ($this->isColumnModified(TiposComisionPeer::DESTINOS)) $criteria->add(TiposComisionPeer::DESTINOS, $this->destinos);
		if ($this->isColumnModified(TiposComisionPeer::FECHA_INI)) $criteria->add(TiposComisionPeer::FECHA_INI, $this->fecha_ini);
		if ($this->isColumnModified(TiposComisionPeer::FECHA_ANT)) $criteria->add(TiposComisionPeer::FECHA_ANT, $this->fecha_ant);
		if ($this->isColumnModified(TiposComisionPeer::CRUCE)) $criteria->add(TiposComisionPeer::CRUCE, $this->cruce);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(TiposComisionPeer::DATABASE_NAME);

		$criteria->add(TiposComisionPeer::TIPCOMI, $this->tipcomi);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getTipcomi();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setTipcomi($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setDescomi($this->descomi);

		$copyObj->setObserv($this->observ);

		$copyObj->setDcomi($this->dcomi);

		$copyObj->setViaticos($this->viaticos);

		$copyObj->setManutencion($this->manutencion);

		$copyObj->setTaxis($this->taxis);

		$copyObj->setObjetos($this->objetos);

		$copyObj->setDestinos($this->destinos);

		$copyObj->setFechaIni($this->fecha_ini);

		$copyObj->setFechaAnt($this->fecha_ant);

		$copyObj->setCruce($this->cruce);


		if ($deepCopy) {
									$copyObj->setNew(false);

			foreach($this->getComisioness() as $relObj) {
				$copyObj->addComisiones($relObj->copy($deepCopy));
			}

		} 

		$copyObj->setNew(true);

		$copyObj->setTipcomi(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new TiposComisionPeer();
		}
		return self::$peer;
	}

	
	public function initComisioness()
	{
		if ($this->collComisioness === null) {
			$this->collComisioness = array();
		}
	}

	
	public function getComisioness($criteria = null, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collComisioness === null) {
			if ($this->isNew()) {
			   $this->collComisioness = array();
			} else {

				$criteria->add(ComisionesPeer::TIPCOMI, $this->getTipcomi());

				ComisionesPeer::addSelectColumns($criteria);
				$this->collComisioness = ComisionesPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(ComisionesPeer::TIPCOMI, $this->getTipcomi());

				ComisionesPeer::addSelectColumns($criteria);
				if (!isset($this->lastComisionesCriteria) || !$this->lastComisionesCriteria->equals($criteria)) {
					$this->collComisioness = ComisionesPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastComisionesCriteria = $criteria;
		return $this->collComisioness;
	}

	
	public function countComisioness($criteria = null, $distinct = false, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(ComisionesPeer::TIPCOMI, $this->getTipcomi());

		return ComisionesPeer::doCount($criteria, $distinct, $con);
	}

	
	public function addComisiones(Comisiones $l)
	{
		$this->collComisioness[] = $l;
		$l->setTiposComision($this);
	}


	
	public function getComisionessJoinAreas($criteria = null, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collComisioness === null) {
			if ($this->isNew()) {
				$this->collComisioness = array();
			} else {

				$criteria->add(ComisionesPeer::TIPCOMI, $this->getTipcomi());

				$this->collComisioness = ComisionesPeer::doSelectJoinAreas($criteria, $con);
			}
		} else {
									
			$criteria->add(ComisionesPeer::TIPCOMI, $this->getTipcomi());

			if (!isset($this->lastComisionesCriteria) || !$this->lastComisionesCriteria->equals($criteria)) {
				$this->collComisioness = ComisionesPeer::doSelectJoinAreas($criteria, $con);
			}
		}
		$this->lastComisionesCriteria = $criteria;

		return $this->collComisioness;
	}


	
	public function getComisionessJoinProyectos($criteria = null, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collComisioness === null) {
			if ($this->isNew()) {
				$this->collComisioness = array();
			} else {

				$criteria->add(ComisionesPeer::TIPCOMI, $this->getTipcomi());

				$this->collComisioness = ComisionesPeer::doSelectJoinProyectos($criteria, $con);
			}
		} else {
									
			$criteria->add(ComisionesPeer::TIPCOMI, $this->getTipcomi());

			if (!isset($this->lastComisionesCriteria) || !$this->lastComisionesCriteria->equals($criteria)) {
				$this->collComisioness = ComisionesPeer::doSelectJoinProyectos($criteria, $con);
			}
		}
		$this->lastComisionesCriteria = $criteria;

		return $this->collComisioness;
	}

} 