PageRenderTime 41ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/model/om/BaseFcdetrep.php

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