PageRenderTime 78ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/model/presupuesto/om/BaseHisconc.php

https://github.com/cidesa/roraima-comunal
PHP | 526 lines | 367 code | 159 blank | 0 comment | 53 complexity | ebfb418258342f5d759845373ca39211 MD5 | raw file
  1. <?php
  2. abstract class BaseHisconc extends BaseObject implements Persistent {
  3. protected static $peer;
  4. protected $numcom;
  5. protected $feccom;
  6. protected $descom;
  7. protected $moncom;
  8. protected $stacom;
  9. protected $tipcom;
  10. protected $id;
  11. protected $alreadyInSave = false;
  12. protected $alreadyInValidation = false;
  13. public function getNumcom()
  14. {
  15. return trim($this->numcom);
  16. }
  17. public function getFeccom($format = 'Y-m-d')
  18. {
  19. if ($this->feccom === null || $this->feccom === '') {
  20. return null;
  21. } elseif (!is_int($this->feccom)) {
  22. $ts = adodb_strtotime($this->feccom);
  23. if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [feccom] as date/time value: " . var_export($this->feccom, true));
  24. }
  25. } else {
  26. $ts = $this->feccom;
  27. }
  28. if ($format === null) {
  29. return $ts;
  30. } elseif (strpos($format, '%') !== false) {
  31. return adodb_strftime($format, $ts);
  32. } else {
  33. return @adodb_date($format, $ts);
  34. }
  35. }
  36. public function getDescom()
  37. {
  38. return trim($this->descom);
  39. }
  40. public function getMoncom($val=false)
  41. {
  42. if($val) return number_format($this->moncom,2,',','.');
  43. else return $this->moncom;
  44. }
  45. public function getStacom()
  46. {
  47. return trim($this->stacom);
  48. }
  49. public function getTipcom()
  50. {
  51. return trim($this->tipcom);
  52. }
  53. public function getId()
  54. {
  55. return $this->id;
  56. }
  57. public function setNumcom($v)
  58. {
  59. if ($this->numcom !== $v) {
  60. $this->numcom = $v;
  61. $this->modifiedColumns[] = HisconcPeer::NUMCOM;
  62. }
  63. }
  64. public function setFeccom($v)
  65. {
  66. if ($v !== null && !is_int($v)) {
  67. $ts = adodb_strtotime($v);
  68. if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [feccom] from input: " . var_export($v, true));
  69. }
  70. } else {
  71. $ts = $v;
  72. }
  73. if ($this->feccom !== $ts) {
  74. $this->feccom = $ts;
  75. $this->modifiedColumns[] = HisconcPeer::FECCOM;
  76. }
  77. }
  78. public function setDescom($v)
  79. {
  80. if ($this->descom !== $v) {
  81. $this->descom = $v;
  82. $this->modifiedColumns[] = HisconcPeer::DESCOM;
  83. }
  84. }
  85. public function setMoncom($v)
  86. {
  87. if ($this->moncom !== $v) {
  88. $this->moncom = Herramientas::toFloat($v);
  89. $this->modifiedColumns[] = HisconcPeer::MONCOM;
  90. }
  91. }
  92. public function setStacom($v)
  93. {
  94. if ($this->stacom !== $v) {
  95. $this->stacom = $v;
  96. $this->modifiedColumns[] = HisconcPeer::STACOM;
  97. }
  98. }
  99. public function setTipcom($v)
  100. {
  101. if ($this->tipcom !== $v) {
  102. $this->tipcom = $v;
  103. $this->modifiedColumns[] = HisconcPeer::TIPCOM;
  104. }
  105. }
  106. public function setId($v)
  107. {
  108. if ($this->id !== $v) {
  109. $this->id = $v;
  110. $this->modifiedColumns[] = HisconcPeer::ID;
  111. }
  112. }
  113. public function hydrate(ResultSet $rs, $startcol = 1)
  114. {
  115. try {
  116. $this->numcom = $rs->getString($startcol + 0);
  117. $this->feccom = $rs->getDate($startcol + 1, null);
  118. $this->descom = $rs->getString($startcol + 2);
  119. $this->moncom = $rs->getFloat($startcol + 3);
  120. $this->stacom = $rs->getString($startcol + 4);
  121. $this->tipcom = $rs->getString($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 Hisconc 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(HisconcPeer::DATABASE_NAME);
  152. }
  153. try {
  154. $con->begin();
  155. HisconcPeer::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(HisconcPeer::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 = HisconcPeer::doInsert($this, $con);
  188. $affectedRows += 1;
  189. $this->setId($pk);
  190. $this->setNew(false);
  191. } else {
  192. $affectedRows += HisconcPeer::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 = HisconcPeer::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 = HisconcPeer::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->getNumcom();
  238. break;
  239. case 1:
  240. return $this->getFeccom();
  241. break;
  242. case 2:
  243. return $this->getDescom();
  244. break;
  245. case 3:
  246. return $this->getMoncom();
  247. break;
  248. case 4:
  249. return $this->getStacom();
  250. break;
  251. case 5:
  252. return $this->getTipcom();
  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 = HisconcPeer::getFieldNames($keyType);
  264. $result = array(
  265. $keys[0] => $this->getNumcom(),
  266. $keys[1] => $this->getFeccom(),
  267. $keys[2] => $this->getDescom(),
  268. $keys[3] => $this->getMoncom(),
  269. $keys[4] => $this->getStacom(),
  270. $keys[5] => $this->getTipcom(),
  271. $keys[6] => $this->getId(),
  272. );
  273. return $result;
  274. }
  275. public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
  276. {
  277. $pos = HisconcPeer::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->setNumcom($value);
  285. break;
  286. case 1:
  287. $this->setFeccom($value);
  288. break;
  289. case 2:
  290. $this->setDescom($value);
  291. break;
  292. case 3:
  293. $this->setMoncom($value);
  294. break;
  295. case 4:
  296. $this->setStacom($value);
  297. break;
  298. case 5:
  299. $this->setTipcom($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 = HisconcPeer::getFieldNames($keyType);
  308. if (array_key_exists($keys[0], $arr)) $this->setNumcom($arr[$keys[0]]);
  309. if (array_key_exists($keys[1], $arr)) $this->setFeccom($arr[$keys[1]]);
  310. if (array_key_exists($keys[2], $arr)) $this->setDescom($arr[$keys[2]]);
  311. if (array_key_exists($keys[3], $arr)) $this->setMoncom($arr[$keys[3]]);
  312. if (array_key_exists($keys[4], $arr)) $this->setStacom($arr[$keys[4]]);
  313. if (array_key_exists($keys[5], $arr)) $this->setTipcom($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(HisconcPeer::DATABASE_NAME);
  319. if ($this->isColumnModified(HisconcPeer::NUMCOM)) $criteria->add(HisconcPeer::NUMCOM, $this->numcom);
  320. if ($this->isColumnModified(HisconcPeer::FECCOM)) $criteria->add(HisconcPeer::FECCOM, $this->feccom);
  321. if ($this->isColumnModified(HisconcPeer::DESCOM)) $criteria->add(HisconcPeer::DESCOM, $this->descom);
  322. if ($this->isColumnModified(HisconcPeer::MONCOM)) $criteria->add(HisconcPeer::MONCOM, $this->moncom);
  323. if ($this->isColumnModified(HisconcPeer::STACOM)) $criteria->add(HisconcPeer::STACOM, $this->stacom);
  324. if ($this->isColumnModified(HisconcPeer::TIPCOM)) $criteria->add(HisconcPeer::TIPCOM, $this->tipcom);
  325. if ($this->isColumnModified(HisconcPeer::ID)) $criteria->add(HisconcPeer::ID, $this->id);
  326. return $criteria;
  327. }
  328. public function buildPkeyCriteria()
  329. {
  330. $criteria = new Criteria(HisconcPeer::DATABASE_NAME);
  331. $criteria->add(HisconcPeer::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->setNumcom($this->numcom);
  345. $copyObj->setFeccom($this->feccom);
  346. $copyObj->setDescom($this->descom);
  347. $copyObj->setMoncom($this->moncom);
  348. $copyObj->setStacom($this->stacom);
  349. $copyObj->setTipcom($this->tipcom);
  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 HisconcPeer();
  364. }
  365. return self::$peer;
  366. }
  367. }