<?php


abstract class BaseControlComis extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $tipcom;


	
	protected $dias;


	
	protected $documento;


	
	protected $fecha;


	
	protected $observaciones;
        
        protected $estado;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getTipcom()
	{

		return $this->tipcom;
	}

	
	public function getDias()
	{

		return $this->dias;
	}

	
	public function getDocumento()
	{

		return $this->documento;
	}

	
	public function getFecha($format = 'Y-m-d')
	{

		if ($this->fecha === null || $this->fecha === '') {
			return null;
		} elseif (!is_int($this->fecha)) {
						$ts = strtotime($this->fecha);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [fecha] as date/time value: " . var_export($this->fecha, true));
			}
		} else {
			$ts = $this->fecha;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getObservaciones()
	{

		return $this->observaciones;
	}
        
        public function getEstado()
	{

		return $this->estado;
	}

	
	public function setId($v)
	{

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

	}

        	
	public function setTipcom($v)
	{

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

		if ($this->tipcom !== $v) {
			$this->tipcom= $v;
			$this->modifiedColumns[] = ControlComisPeer::TIPCOM;
		}

	} 
	
	public function setDias($v)
	{

						

		if ($this->dias !== $v) {
			$this->dias = $v;
			$this->modifiedColumns[] = ControlComisPeer::DIAS;
		}

	} 
	
	public function setDocumento($v)
	{
            if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}
		if ($this->documento !== $v) {
			$this->documento = $v;
			$this->modifiedColumns[] = ControlComisPeer::DOCUMENTO;
		}

	} 
	
	public function setFecha($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [fecha] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->fecha !== $ts) {
			$this->fecha = $ts;
			$this->modifiedColumns[] = ControlComisPeer::FECHA;
		}

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

		if ($this->observaciones !== $v) {
			$this->observaciones = $v;
			$this->modifiedColumns[] = ControlComisPeer::OBSERVACIONES;
		}

	} 
        
        public function setEstado($v)
	{

						

		if ($this->estado !== $v) {
			$this->estado = $v;
			$this->modifiedColumns[] = ControlComisPeer::ESTADO;
		}

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

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

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

			$this->dias = $rs->getFloat($startcol + 2);

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

			$this->fecha = $rs->getDate($startcol + 4);

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

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

                        $this->resetModified();

			$this->setNew(false);

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

		try {
			$con->begin();
			ControlComisPeer::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(ControlComisPeer::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 = ControlComisPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setNew(false);
				} else {
					$affectedRows += ControlComisPeer::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 = ControlComisPeer::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 = ControlComisPeer::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->getTipcom();
				break;
			case 2:
				return $this->getDias();
				break;
			case 3:
				return $this->getDocumento();
				break;
			case 4:
				return $this->getFecha();
				break;
			case 5:
				return $this->getObservaciones();
				break;
                        case 6:
				return $this->getEstado();
				break;    
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = ControlComisPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getTipcom(),
			$keys[2] => $this->getDias(),
			$keys[3] => $this->getDocumento(),
			$keys[4] => $this->getFecha(),
			$keys[5] => $this->getObservaciones(),
                        $keys[6] => $this->getEstado(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = ControlComisPeer::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->setTipcom($value);
				break;
			case 2:
				$this->setDias($value);
				break;
			case 3:
				$this->setDocumento($value);
				break;
			case 4:
				$this->setFecha($value);
				break;
			case 5:
				$this->setObservaciones($value);
				break;
                        case 6:
				$this->setEstado($value);
				break;    
		} 	}

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

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setTipcom($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setDias($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setDocumento($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setFecha($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setObservaciones($arr[$keys[5]]);
                if (array_key_exists($keys[6], $arr)) $this->setEstado($arr[$keys[6]]);
	}

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

		if ($this->isColumnModified(ControlComisPeer::ID)) $criteria->add(ControlComisPeer::ID, $this->id);
		if ($this->isColumnModified(ControlComisPeer::TIPCOM)) $criteria->add(ControlComisPeer::TIPCOM, $this->tipcom);
		if ($this->isColumnModified(ControlComisPeer::DIAS)) $criteria->add(ControlComisPeer::DIAS, $this->dias);
		if ($this->isColumnModified(ControlComisPeer::DOCUMENTO)) $criteria->add(ControlComisPeer::DOCUMENTO, $this->documento);
		if ($this->isColumnModified(ControlComisPeer::FECHA)) $criteria->add(ControlComisPeer::FECHA, $this->fecha);
		if ($this->isColumnModified(ControlComisPeer::OBSERVACIONES)) $criteria->add(ControlComisPeer::OBSERVACIONES, $this->observaciones);
                if ($this->isColumnModified(ControlComisPeer::ESTADO)) $criteria->add(ControlComisPeer::ESTADO, $this->estado);

		return $criteria;
	}

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

		$criteria->add(ControlComisPeer::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->setTipcom($this->tipcom);

		$copyObj->setDias($this->dias);

		$copyObj->setDocumento($this->documento);

		$copyObj->setFecha($this->fecha);

		$copyObj->setObservaciones($this->observaciones);

                $copyObj->setEstado($this->estado);

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


		} 

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

	
	

} 