/lib/model/om/BaseCobrectra.php
PHP | 526 lines | 367 code | 159 blank | 0 comment | 53 complexity | e8599ee759ed316517e6e6e375931395 MD5 | raw file
Possible License(s): LGPL-2.1
- <?php
- abstract class BaseCobrectra extends BaseObject implements Persistent {
-
- protected static $peer;
-
- protected $numtra;
-
- protected $refdoc;
-
- protected $codcli;
-
- protected $codrec;
-
- protected $fecrec;
-
- protected $monrec;
-
- protected $id;
-
- protected $alreadyInSave = false;
-
- protected $alreadyInValidation = false;
-
- public function getNumtra()
- {
- return trim($this->numtra);
- }
-
- public function getRefdoc()
- {
- return trim($this->refdoc);
- }
-
- public function getCodcli()
- {
- return trim($this->codcli);
- }
-
- public function getCodrec()
- {
- return trim($this->codrec);
- }
-
- public function getFecrec($format = 'Y-m-d')
- {
- if ($this->fecrec === null || $this->fecrec === '') {
- return null;
- } elseif (!is_int($this->fecrec)) {
- $ts = adodb_strtotime($this->fecrec);
- if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [fecrec] as date/time value: " . var_export($this->fecrec, true));
- }
- } else {
- $ts = $this->fecrec;
- }
- if ($format === null) {
- return $ts;
- } elseif (strpos($format, '%') !== false) {
- return adodb_strftime($format, $ts);
- } else {
- return @adodb_date($format, $ts);
- }
- }
-
- public function getMonrec($val=false)
- {
- if($val) return number_format($this->monrec,2,',','.');
- else return $this->monrec;
- }
-
- public function getId()
- {
- return $this->id;
- }
-
- public function setNumtra($v)
- {
- if ($this->numtra !== $v) {
- $this->numtra = $v;
- $this->modifiedColumns[] = CobrectraPeer::NUMTRA;
- }
-
- }
-
- public function setRefdoc($v)
- {
- if ($this->refdoc !== $v) {
- $this->refdoc = $v;
- $this->modifiedColumns[] = CobrectraPeer::REFDOC;
- }
-
- }
-
- public function setCodcli($v)
- {
- if ($this->codcli !== $v) {
- $this->codcli = $v;
- $this->modifiedColumns[] = CobrectraPeer::CODCLI;
- }
-
- }
-
- public function setCodrec($v)
- {
- if ($this->codrec !== $v) {
- $this->codrec = $v;
- $this->modifiedColumns[] = CobrectraPeer::CODREC;
- }
-
- }
-
- public function setFecrec($v)
- {
- if ($v !== null && !is_int($v)) {
- $ts = adodb_strtotime($v);
- if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [fecrec] from input: " . var_export($v, true));
- }
- } else {
- $ts = $v;
- }
- if ($this->fecrec !== $ts) {
- $this->fecrec = $ts;
- $this->modifiedColumns[] = CobrectraPeer::FECREC;
- }
- }
-
- public function setMonrec($v)
- {
- if ($this->monrec !== $v) {
- $this->monrec = Herramientas::toFloat($v);
- $this->modifiedColumns[] = CobrectraPeer::MONREC;
- }
-
- }
-
- public function setId($v)
- {
- if ($this->id !== $v) {
- $this->id = $v;
- $this->modifiedColumns[] = CobrectraPeer::ID;
- }
-
- }
-
- public function hydrate(ResultSet $rs, $startcol = 1)
- {
- try {
- $this->numtra = $rs->getString($startcol + 0);
- $this->refdoc = $rs->getString($startcol + 1);
- $this->codcli = $rs->getString($startcol + 2);
- $this->codrec = $rs->getString($startcol + 3);
- $this->fecrec = $rs->getDate($startcol + 4, null);
- $this->monrec = $rs->getFloat($startcol + 5);
- $this->id = $rs->getInt($startcol + 6);
- $this->resetModified();
- $this->setNew(false);
- $this->afterHydrate();
- return $startcol + 7;
- } catch (Exception $e) {
- throw new PropelException("Error populating Cobrectra object", $e);
- }
- }
- protected function afterHydrate()
- {
- }
-
-
- public function __call($m, $a)
- {
- $prefijo = substr($m,0,3);
- $metodo = strtolower(substr($m,3));
- if($prefijo=='get'){
- if(isset($this->$metodo)) return $this->$metodo;
- else return '';
- }elseif($prefijo=='set'){
- if(isset($this->$metodo)) $this->$metodo = $a[0];
- }else call_user_func_array($m, $a);
- }
-
- public function delete($con = null)
- {
- if ($this->isDeleted()) {
- throw new PropelException("This object has already been deleted.");
- }
- if ($con === null) {
- $con = Propel::getConnection(CobrectraPeer::DATABASE_NAME);
- }
- try {
- $con->begin();
- CobrectraPeer::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(CobrectraPeer::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 = CobrectraPeer::doInsert($this, $con);
- $affectedRows += 1;
- $this->setId($pk);
- $this->setNew(false);
- } else {
- $affectedRows += CobrectraPeer::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 = CobrectraPeer::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 = CobrectraPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
- return $this->getByPosition($pos);
- }
-
- public function getByPosition($pos)
- {
- switch($pos) {
- case 0:
- return $this->getNumtra();
- break;
- case 1:
- return $this->getRefdoc();
- break;
- case 2:
- return $this->getCodcli();
- break;
- case 3:
- return $this->getCodrec();
- break;
- case 4:
- return $this->getFecrec();
- break;
- case 5:
- return $this->getMonrec();
- break;
- case 6:
- return $this->getId();
- break;
- default:
- return null;
- break;
- } }
-
- public function toArray($keyType = BasePeer::TYPE_PHPNAME)
- {
- $keys = CobrectraPeer::getFieldNames($keyType);
- $result = array(
- $keys[0] => $this->getNumtra(),
- $keys[1] => $this->getRefdoc(),
- $keys[2] => $this->getCodcli(),
- $keys[3] => $this->getCodrec(),
- $keys[4] => $this->getFecrec(),
- $keys[5] => $this->getMonrec(),
- $keys[6] => $this->getId(),
- );
- return $result;
- }
-
- public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
- {
- $pos = CobrectraPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
- return $this->setByPosition($pos, $value);
- }
-
- public function setByPosition($pos, $value)
- {
- switch($pos) {
- case 0:
- $this->setNumtra($value);
- break;
- case 1:
- $this->setRefdoc($value);
- break;
- case 2:
- $this->setCodcli($value);
- break;
- case 3:
- $this->setCodrec($value);
- break;
- case 4:
- $this->setFecrec($value);
- break;
- case 5:
- $this->setMonrec($value);
- break;
- case 6:
- $this->setId($value);
- break;
- } }
-
- public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
- {
- $keys = CobrectraPeer::getFieldNames($keyType);
- if (array_key_exists($keys[0], $arr)) $this->setNumtra($arr[$keys[0]]);
- if (array_key_exists($keys[1], $arr)) $this->setRefdoc($arr[$keys[1]]);
- if (array_key_exists($keys[2], $arr)) $this->setCodcli($arr[$keys[2]]);
- if (array_key_exists($keys[3], $arr)) $this->setCodrec($arr[$keys[3]]);
- if (array_key_exists($keys[4], $arr)) $this->setFecrec($arr[$keys[4]]);
- if (array_key_exists($keys[5], $arr)) $this->setMonrec($arr[$keys[5]]);
- if (array_key_exists($keys[6], $arr)) $this->setId($arr[$keys[6]]);
- }
-
- public function buildCriteria()
- {
- $criteria = new Criteria(CobrectraPeer::DATABASE_NAME);
- if ($this->isColumnModified(CobrectraPeer::NUMTRA)) $criteria->add(CobrectraPeer::NUMTRA, $this->numtra);
- if ($this->isColumnModified(CobrectraPeer::REFDOC)) $criteria->add(CobrectraPeer::REFDOC, $this->refdoc);
- if ($this->isColumnModified(CobrectraPeer::CODCLI)) $criteria->add(CobrectraPeer::CODCLI, $this->codcli);
- if ($this->isColumnModified(CobrectraPeer::CODREC)) $criteria->add(CobrectraPeer::CODREC, $this->codrec);
- if ($this->isColumnModified(CobrectraPeer::FECREC)) $criteria->add(CobrectraPeer::FECREC, $this->fecrec);
- if ($this->isColumnModified(CobrectraPeer::MONREC)) $criteria->add(CobrectraPeer::MONREC, $this->monrec);
- if ($this->isColumnModified(CobrectraPeer::ID)) $criteria->add(CobrectraPeer::ID, $this->id);
- return $criteria;
- }
-
- public function buildPkeyCriteria()
- {
- $criteria = new Criteria(CobrectraPeer::DATABASE_NAME);
- $criteria->add(CobrectraPeer::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->setNumtra($this->numtra);
- $copyObj->setRefdoc($this->refdoc);
- $copyObj->setCodcli($this->codcli);
- $copyObj->setCodrec($this->codrec);
- $copyObj->setFecrec($this->fecrec);
- $copyObj->setMonrec($this->monrec);
- $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 CobrectraPeer();
- }
- return self::$peer;
- }
- }