PageRenderTime 60ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/model/om/BaseCobdestra.php

https://github.com/cidesa/roraima
PHP | 526 lines | 367 code | 159 blank | 0 comment | 53 complexity | 2fc853ce59f4390821ad6466e07c7d24 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. abstract class BaseCobdestra extends BaseObject implements Persistent {
  3. protected static $peer;
  4. protected $numtra;
  5. protected $refdoc;
  6. protected $codcli;
  7. protected $coddes;
  8. protected $fecdes;
  9. protected $mondes;
  10. protected $id;
  11. protected $alreadyInSave = false;
  12. protected $alreadyInValidation = false;
  13. public function getNumtra()
  14. {
  15. return trim($this->numtra);
  16. }
  17. public function getRefdoc()
  18. {
  19. return trim($this->refdoc);
  20. }
  21. public function getCodcli()
  22. {
  23. return trim($this->codcli);
  24. }
  25. public function getCoddes()
  26. {
  27. return trim($this->coddes);
  28. }
  29. public function getFecdes($format = 'Y-m-d')
  30. {
  31. if ($this->fecdes === null || $this->fecdes === '') {
  32. return null;
  33. } elseif (!is_int($this->fecdes)) {
  34. $ts = adodb_strtotime($this->fecdes);
  35. if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [fecdes] as date/time value: " . var_export($this->fecdes, true));
  36. }
  37. } else {
  38. $ts = $this->fecdes;
  39. }
  40. if ($format === null) {
  41. return $ts;
  42. } elseif (strpos($format, '%') !== false) {
  43. return adodb_strftime($format, $ts);
  44. } else {
  45. return @adodb_date($format, $ts);
  46. }
  47. }
  48. public function getMondes($val=false)
  49. {
  50. if($val) return number_format($this->mondes,2,',','.');
  51. else return $this->mondes;
  52. }
  53. public function getId()
  54. {
  55. return $this->id;
  56. }
  57. public function setNumtra($v)
  58. {
  59. if ($this->numtra !== $v) {
  60. $this->numtra = $v;
  61. $this->modifiedColumns[] = CobdestraPeer::NUMTRA;
  62. }
  63. }
  64. public function setRefdoc($v)
  65. {
  66. if ($this->refdoc !== $v) {
  67. $this->refdoc = $v;
  68. $this->modifiedColumns[] = CobdestraPeer::REFDOC;
  69. }
  70. }
  71. public function setCodcli($v)
  72. {
  73. if ($this->codcli !== $v) {
  74. $this->codcli = $v;
  75. $this->modifiedColumns[] = CobdestraPeer::CODCLI;
  76. }
  77. }
  78. public function setCoddes($v)
  79. {
  80. if ($this->coddes !== $v) {
  81. $this->coddes = $v;
  82. $this->modifiedColumns[] = CobdestraPeer::CODDES;
  83. }
  84. }
  85. public function setFecdes($v)
  86. {
  87. if ($v !== null && !is_int($v)) {
  88. $ts = adodb_strtotime($v);
  89. if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [fecdes] from input: " . var_export($v, true));
  90. }
  91. } else {
  92. $ts = $v;
  93. }
  94. if ($this->fecdes !== $ts) {
  95. $this->fecdes = $ts;
  96. $this->modifiedColumns[] = CobdestraPeer::FECDES;
  97. }
  98. }
  99. public function setMondes($v)
  100. {
  101. if ($this->mondes !== $v) {
  102. $this->mondes = Herramientas::toFloat($v);
  103. $this->modifiedColumns[] = CobdestraPeer::MONDES;
  104. }
  105. }
  106. public function setId($v)
  107. {
  108. if ($this->id !== $v) {
  109. $this->id = $v;
  110. $this->modifiedColumns[] = CobdestraPeer::ID;
  111. }
  112. }
  113. public function hydrate(ResultSet $rs, $startcol = 1)
  114. {
  115. try {
  116. $this->numtra = $rs->getString($startcol + 0);
  117. $this->refdoc = $rs->getString($startcol + 1);
  118. $this->codcli = $rs->getString($startcol + 2);
  119. $this->coddes = $rs->getString($startcol + 3);
  120. $this->fecdes = $rs->getDate($startcol + 4, null);
  121. $this->mondes = $rs->getFloat($startcol + 5);
  122. $this->id = $rs->getInt($startcol + 6);
  123. $this->resetModified();
  124. $this->setNew(false);
  125. $this->afterHydrate();
  126. return $startcol + 7;
  127. } catch (Exception $e) {
  128. throw new PropelException("Error populating Cobdestra object", $e);
  129. }
  130. }
  131. protected function afterHydrate()
  132. {
  133. }
  134. public function __call($m, $a)
  135. {
  136. $prefijo = substr($m,0,3);
  137. $metodo = strtolower(substr($m,3));
  138. if($prefijo=='get'){
  139. if(isset($this->$metodo)) return $this->$metodo;
  140. else return '';
  141. }elseif($prefijo=='set'){
  142. if(isset($this->$metodo)) $this->$metodo = $a[0];
  143. }else call_user_func_array($m, $a);
  144. }
  145. public function delete($con = null)
  146. {
  147. if ($this->isDeleted()) {
  148. throw new PropelException("This object has already been deleted.");
  149. }
  150. if ($con === null) {
  151. $con = Propel::getConnection(CobdestraPeer::DATABASE_NAME);
  152. }
  153. try {
  154. $con->begin();
  155. CobdestraPeer::doDelete($this, $con);
  156. $this->setDeleted(true);
  157. $con->commit();
  158. } catch (PropelException $e) {
  159. $con->rollback();
  160. throw $e;
  161. }
  162. }
  163. public function save($con = null)
  164. {
  165. if ($this->isDeleted()) {
  166. throw new PropelException("You cannot save an object that has been deleted.");
  167. }
  168. if ($con === null) {
  169. $con = Propel::getConnection(CobdestraPeer::DATABASE_NAME);
  170. }
  171. try {
  172. $con->begin();
  173. $affectedRows = $this->doSave($con);
  174. $con->commit();
  175. return $affectedRows;
  176. } catch (PropelException $e) {
  177. $con->rollback();
  178. throw $e;
  179. }
  180. }
  181. protected function doSave($con)
  182. {
  183. $affectedRows = 0; if (!$this->alreadyInSave) {
  184. $this->alreadyInSave = true;
  185. if ($this->isModified()) {
  186. if ($this->isNew()) {
  187. $pk = CobdestraPeer::doInsert($this, $con);
  188. $affectedRows += 1;
  189. $this->setId($pk);
  190. $this->setNew(false);
  191. } else {
  192. $affectedRows += CobdestraPeer::doUpdate($this, $con);
  193. }
  194. $this->resetModified(); }
  195. $this->alreadyInSave = false;
  196. }
  197. return $affectedRows;
  198. }
  199. protected $validationFailures = array();
  200. public function getValidationFailures()
  201. {
  202. return $this->validationFailures;
  203. }
  204. public function validate($columns = null)
  205. {
  206. $res = $this->doValidate($columns);
  207. if ($res === true) {
  208. $this->validationFailures = array();
  209. return true;
  210. } else {
  211. $this->validationFailures = $res;
  212. return false;
  213. }
  214. }
  215. protected function doValidate($columns = null)
  216. {
  217. if (!$this->alreadyInValidation) {
  218. $this->alreadyInValidation = true;
  219. $retval = null;
  220. $failureMap = array();
  221. if (($retval = CobdestraPeer::doValidate($this, $columns)) !== true) {
  222. $failureMap = array_merge($failureMap, $retval);
  223. }
  224. $this->alreadyInValidation = false;
  225. }
  226. return (!empty($failureMap) ? $failureMap : true);
  227. }
  228. public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
  229. {
  230. $pos = CobdestraPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  231. return $this->getByPosition($pos);
  232. }
  233. public function getByPosition($pos)
  234. {
  235. switch($pos) {
  236. case 0:
  237. return $this->getNumtra();
  238. break;
  239. case 1:
  240. return $this->getRefdoc();
  241. break;
  242. case 2:
  243. return $this->getCodcli();
  244. break;
  245. case 3:
  246. return $this->getCoddes();
  247. break;
  248. case 4:
  249. return $this->getFecdes();
  250. break;
  251. case 5:
  252. return $this->getMondes();
  253. break;
  254. case 6:
  255. return $this->getId();
  256. break;
  257. default:
  258. return null;
  259. break;
  260. } }
  261. public function toArray($keyType = BasePeer::TYPE_PHPNAME)
  262. {
  263. $keys = CobdestraPeer::getFieldNames($keyType);
  264. $result = array(
  265. $keys[0] => $this->getNumtra(),
  266. $keys[1] => $this->getRefdoc(),
  267. $keys[2] => $this->getCodcli(),
  268. $keys[3] => $this->getCoddes(),
  269. $keys[4] => $this->getFecdes(),
  270. $keys[5] => $this->getMondes(),
  271. $keys[6] => $this->getId(),
  272. );
  273. return $result;
  274. }
  275. public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
  276. {
  277. $pos = CobdestraPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  278. return $this->setByPosition($pos, $value);
  279. }
  280. public function setByPosition($pos, $value)
  281. {
  282. switch($pos) {
  283. case 0:
  284. $this->setNumtra($value);
  285. break;
  286. case 1:
  287. $this->setRefdoc($value);
  288. break;
  289. case 2:
  290. $this->setCodcli($value);
  291. break;
  292. case 3:
  293. $this->setCoddes($value);
  294. break;
  295. case 4:
  296. $this->setFecdes($value);
  297. break;
  298. case 5:
  299. $this->setMondes($value);
  300. break;
  301. case 6:
  302. $this->setId($value);
  303. break;
  304. } }
  305. public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
  306. {
  307. $keys = CobdestraPeer::getFieldNames($keyType);
  308. if (array_key_exists($keys[0], $arr)) $this->setNumtra($arr[$keys[0]]);
  309. if (array_key_exists($keys[1], $arr)) $this->setRefdoc($arr[$keys[1]]);
  310. if (array_key_exists($keys[2], $arr)) $this->setCodcli($arr[$keys[2]]);
  311. if (array_key_exists($keys[3], $arr)) $this->setCoddes($arr[$keys[3]]);
  312. if (array_key_exists($keys[4], $arr)) $this->setFecdes($arr[$keys[4]]);
  313. if (array_key_exists($keys[5], $arr)) $this->setMondes($arr[$keys[5]]);
  314. if (array_key_exists($keys[6], $arr)) $this->setId($arr[$keys[6]]);
  315. }
  316. public function buildCriteria()
  317. {
  318. $criteria = new Criteria(CobdestraPeer::DATABASE_NAME);
  319. if ($this->isColumnModified(CobdestraPeer::NUMTRA)) $criteria->add(CobdestraPeer::NUMTRA, $this->numtra);
  320. if ($this->isColumnModified(CobdestraPeer::REFDOC)) $criteria->add(CobdestraPeer::REFDOC, $this->refdoc);
  321. if ($this->isColumnModified(CobdestraPeer::CODCLI)) $criteria->add(CobdestraPeer::CODCLI, $this->codcli);
  322. if ($this->isColumnModified(CobdestraPeer::CODDES)) $criteria->add(CobdestraPeer::CODDES, $this->coddes);
  323. if ($this->isColumnModified(CobdestraPeer::FECDES)) $criteria->add(CobdestraPeer::FECDES, $this->fecdes);
  324. if ($this->isColumnModified(CobdestraPeer::MONDES)) $criteria->add(CobdestraPeer::MONDES, $this->mondes);
  325. if ($this->isColumnModified(CobdestraPeer::ID)) $criteria->add(CobdestraPeer::ID, $this->id);
  326. return $criteria;
  327. }
  328. public function buildPkeyCriteria()
  329. {
  330. $criteria = new Criteria(CobdestraPeer::DATABASE_NAME);
  331. $criteria->add(CobdestraPeer::ID, $this->id);
  332. return $criteria;
  333. }
  334. public function getPrimaryKey()
  335. {
  336. return $this->getId();
  337. }
  338. public function setPrimaryKey($key)
  339. {
  340. $this->setId($key);
  341. }
  342. public function copyInto($copyObj, $deepCopy = false)
  343. {
  344. $copyObj->setNumtra($this->numtra);
  345. $copyObj->setRefdoc($this->refdoc);
  346. $copyObj->setCodcli($this->codcli);
  347. $copyObj->setCoddes($this->coddes);
  348. $copyObj->setFecdes($this->fecdes);
  349. $copyObj->setMondes($this->mondes);
  350. $copyObj->setNew(true);
  351. $copyObj->setId(NULL);
  352. }
  353. public function copy($deepCopy = false)
  354. {
  355. $clazz = get_class($this);
  356. $copyObj = new $clazz();
  357. $this->copyInto($copyObj, $deepCopy);
  358. return $copyObj;
  359. }
  360. public function getPeer()
  361. {
  362. if (self::$peer === null) {
  363. self::$peer = new CobdestraPeer();
  364. }
  365. return self::$peer;
  366. }
  367. }