<?php


abstract class BaseObjetosGasto extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $ano_fiscal;


	
	protected $codigo;


	
	protected $descripcion;


	
	protected $abreviatura;

        protected $comision;

	protected $collComisionadosObjss;


	protected $lastComisionesComisionadosObjsCriteria = null;
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}
        public function getComision()
	{

		return $this->comision;
	}

	
	public function getAnoFiscal()
	{

		return $this->ano_fiscal;
	}

	
	public function getCodigo()
	{

		return $this->codigo;
	}

	
	public function getDescripcion()
	{

		return $this->descripcion;
	}

	
	public function getAbreviatura()
	{

		return $this->abreviatura;
	}

	
	public function setId($v)
	{

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = ObjetosGastoPeer::ID;
		}

	}

        public function setComision($v)
	{

		if ($this->comision !== $v) {
			$this->comision = $v;
			$this->modifiedColumns[] = ObjetosGastoPeer::COMISION;
		}

	}
	
	public function setAnoFiscal($v)
	{

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

		if ($this->ano_fiscal !== $v) {
			$this->ano_fiscal = $v;
			$this->modifiedColumns[] = ObjetosGastoPeer::ANO_FISCAL;
		}

	} 
	
	public function setCodigo($v)
	{

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

		if ($this->codigo !== $v) {
			$this->codigo = $v;
			$this->modifiedColumns[] = ObjetosGastoPeer::CODIGO;
		}

	} 
	
	public function setDescripcion($v)
	{

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

		if ($this->descripcion !== $v) {
			$this->descripcion = $v;
			$this->modifiedColumns[] = ObjetosGastoPeer::DESCRIPCION;
		}

	} 
	
	public function setAbreviatura($v)
	{

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

		if ($this->abreviatura !== $v) {
			$this->abreviatura = $v;
			$this->modifiedColumns[] = ObjetosGastoPeer::ABREVIATURA;
		}

	} 

        public function addComisionadosObjs(ComisionadosObjs $l)
	{
		$this->collComisionadosObjss[] = $l;
		$l->setObjetosGasto($this);
	}
	public function initComisionadosObjss()
	{
		if ($this->collComisionadosObjss === null) {
			$this->collComisionadosObjss = array();
		}
	}
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getFloat($startcol + 0);

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

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

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

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

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 5; 
		} catch (Exception $e) {
			throw new PropelException("Error populating ObjetosGasto 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(ObjetosGastoPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			ObjetosGastoPeer::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(ObjetosGastoPeer::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 = ObjetosGastoPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setNew(false);
				} else {
					$affectedRows += ObjetosGastoPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$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 = ObjetosGastoPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

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

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

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getAnoFiscal();
				break;
			case 2:
				return $this->getCodigo();
				break;
			case 3:
				return $this->getDescripcion();
				break;
			case 4:
				return $this->getAbreviatura();
				break;
                        case 5:
                                return $this->getComision();
                                break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = ObjetosGastoPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getAnoFiscal(),
			$keys[2] => $this->getCodigo(),
			$keys[3] => $this->getDescripcion(),
			$keys[4] => $this->getAbreviatura(),
                        $keys[5] => $this->getComision(),
		);
		return $result;
	}

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

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setAnoFiscal($value);
				break;
			case 2:
				$this->setCodigo($value);
				break;
			case 3:
				$this->setDescripcion($value);
				break;
			case 4:
				$this->setAbreviatura($value);
				break;
                        case 5:
				$this->setComision($value);
				break;
		} 	}

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

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setAnoFiscal($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setCodigo($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setDescripcion($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setAbreviatura($arr[$keys[4]]);
                if (array_key_exists($keys[5], $arr)) $this->setComision($arr[$keys[5]]);
	}

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

		if ($this->isColumnModified(ObjetosGastoPeer::ID)) $criteria->add(ObjetosGastoPeer::ID, $this->id);
		if ($this->isColumnModified(ObjetosGastoPeer::ANO_FISCAL)) $criteria->add(ObjetosGastoPeer::ANO_FISCAL, $this->ano_fiscal);
		if ($this->isColumnModified(ObjetosGastoPeer::CODIGO)) $criteria->add(ObjetosGastoPeer::CODIGO, $this->codigo);
		if ($this->isColumnModified(ObjetosGastoPeer::DESCRIPCION)) $criteria->add(ObjetosGastoPeer::DESCRIPCION, $this->descripcion);
		if ($this->isColumnModified(ObjetosGastoPeer::ABREVIATURA)) $criteria->add(ObjetosGastoPeer::ABREVIATURA, $this->abreviatura);
                if ($this->isColumnModified(ObjetosGastoPeer::COMISION)) $criteria->add(ObjetosGastoPeer::COMISION, $this->comision);

		return $criteria;
	}

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

		$criteria->add(ObjetosGastoPeer::ID, $this->id);

		return $criteria;
	}

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

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

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

		$copyObj->setAnoFiscal($this->ano_fiscal);

		$copyObj->setCodigo($this->codigo);

		$copyObj->setDescripcion($this->descripcion);

		$copyObj->setAbreviatura($this->abreviatura);

                $copyObj->setComision($this->comision);


		$copyObj->setNew(true);

		$copyObj->setId(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 ObjetosGastoPeer();
		}
		return self::$peer;
	}

} 