BaseKataoSupplierInvoiceProduct.php 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303
  1. <?php
  2. /**
  3. * Base class that represents a row from the 'katao_supplier_invoice_product' table.
  4. *
  5. *
  6. *
  7. * @package lib.model.om
  8. */
  9. abstract class BaseKataoSupplierInvoiceProduct extends BaseObject implements Persistent {
  10. /**
  11. * The Peer class.
  12. * Instance provides a convenient way of calling static methods on a class
  13. * that calling code may not be able to identify.
  14. * @var KataoSupplierInvoiceProductPeer
  15. */
  16. protected static $peer;
  17. /**
  18. * The value for the id field.
  19. * @var int
  20. */
  21. protected $id;
  22. /**
  23. * The value for the katao_supplier_invoice_id field.
  24. * @var int
  25. */
  26. protected $katao_supplier_invoice_id;
  27. /**
  28. * The value for the katao_product_id field.
  29. * @var int
  30. */
  31. protected $katao_product_id;
  32. /**
  33. * The value for the product_reference field.
  34. * @var string
  35. */
  36. protected $product_reference;
  37. /**
  38. * The value for the product_name field.
  39. * @var string
  40. */
  41. protected $product_name;
  42. /**
  43. * The value for the product_price_euro field.
  44. * @var double
  45. */
  46. protected $product_price_euro;
  47. /**
  48. * The value for the product_margin field.
  49. * @var double
  50. */
  51. protected $product_margin;
  52. /**
  53. * The value for the product_tva_rate field.
  54. * @var double
  55. */
  56. protected $product_tva_rate = 0;
  57. /**
  58. * The value for the quantity field.
  59. * @var double
  60. */
  61. protected $quantity = 1;
  62. /**
  63. * The value for the product_price_total field.
  64. * @var double
  65. */
  66. protected $product_price_total = 0;
  67. /**
  68. * The value for the created_at field.
  69. * @var int
  70. */
  71. protected $created_at;
  72. /**
  73. * The value for the updated_at field.
  74. * @var int
  75. */
  76. protected $updated_at;
  77. /**
  78. * @var KataoSupplierInvoice
  79. */
  80. protected $aKataoSupplierInvoice;
  81. /**
  82. * @var KataoProduct
  83. */
  84. protected $aKataoProduct;
  85. /**
  86. * Flag to prevent endless save loop, if this object is referenced
  87. * by another object which falls in this transaction.
  88. * @var boolean
  89. */
  90. protected $alreadyInSave = false;
  91. /**
  92. * Flag to prevent endless validation loop, if this object is referenced
  93. * by another object which falls in this transaction.
  94. * @var boolean
  95. */
  96. protected $alreadyInValidation = false;
  97. /**
  98. * Get the [id] column value.
  99. *
  100. * @return int
  101. */
  102. public function getId()
  103. {
  104. return $this->id;
  105. }
  106. /**
  107. * Get the [katao_supplier_invoice_id] column value.
  108. *
  109. * @return int
  110. */
  111. public function getKataoSupplierInvoiceId()
  112. {
  113. return $this->katao_supplier_invoice_id;
  114. }
  115. /**
  116. * Get the [katao_product_id] column value.
  117. *
  118. * @return int
  119. */
  120. public function getKataoProductId()
  121. {
  122. return $this->katao_product_id;
  123. }
  124. /**
  125. * Get the [product_reference] column value.
  126. *
  127. * @return string
  128. */
  129. public function getProductReference()
  130. {
  131. return $this->product_reference;
  132. }
  133. /**
  134. * Get the [product_name] column value.
  135. *
  136. * @return string
  137. */
  138. public function getProductName()
  139. {
  140. return $this->product_name;
  141. }
  142. /**
  143. * Get the [product_price_euro] column value.
  144. *
  145. * @return double
  146. */
  147. public function getProductPriceEuro()
  148. {
  149. return $this->product_price_euro;
  150. }
  151. /**
  152. * Get the [product_margin] column value.
  153. *
  154. * @return double
  155. */
  156. public function getProductMargin()
  157. {
  158. return $this->product_margin;
  159. }
  160. /**
  161. * Get the [product_tva_rate] column value.
  162. *
  163. * @return double
  164. */
  165. public function getProductTvaRate()
  166. {
  167. return $this->product_tva_rate;
  168. }
  169. /**
  170. * Get the [quantity] column value.
  171. *
  172. * @return double
  173. */
  174. public function getQuantity()
  175. {
  176. return $this->quantity;
  177. }
  178. /**
  179. * Get the [product_price_total] column value.
  180. *
  181. * @return double
  182. */
  183. public function getProductPriceTotal()
  184. {
  185. return $this->product_price_total;
  186. }
  187. /**
  188. * Get the [optionally formatted] [created_at] column value.
  189. *
  190. * @param string $format The date/time format string (either date()-style or strftime()-style).
  191. * If format is NULL, then the integer unix timestamp will be returned.
  192. * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL).
  193. * @throws PropelException - if unable to convert the date/time to timestamp.
  194. */
  195. public function getCreatedAt($format = 'Y-m-d H:i:s')
  196. {
  197. if ($this->created_at === null || $this->created_at === '') {
  198. return null;
  199. } elseif (!is_int($this->created_at)) {
  200. // a non-timestamp value was set externally, so we convert it
  201. $ts = strtotime($this->created_at);
  202. if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
  203. throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
  204. }
  205. } else {
  206. $ts = $this->created_at;
  207. }
  208. if ($format === null) {
  209. return $ts;
  210. } elseif (strpos($format, '%') !== false) {
  211. return strftime($format, $ts);
  212. } else {
  213. return date($format, $ts);
  214. }
  215. }
  216. /**
  217. * Get the [optionally formatted] [updated_at] column value.
  218. *
  219. * @param string $format The date/time format string (either date()-style or strftime()-style).
  220. * If format is NULL, then the integer unix timestamp will be returned.
  221. * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL).
  222. * @throws PropelException - if unable to convert the date/time to timestamp.
  223. */
  224. public function getUpdatedAt($format = 'Y-m-d H:i:s')
  225. {
  226. if ($this->updated_at === null || $this->updated_at === '') {
  227. return null;
  228. } elseif (!is_int($this->updated_at)) {
  229. // a non-timestamp value was set externally, so we convert it
  230. $ts = strtotime($this->updated_at);
  231. if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
  232. throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
  233. }
  234. } else {
  235. $ts = $this->updated_at;
  236. }
  237. if ($format === null) {
  238. return $ts;
  239. } elseif (strpos($format, '%') !== false) {
  240. return strftime($format, $ts);
  241. } else {
  242. return date($format, $ts);
  243. }
  244. }
  245. /**
  246. * Set the value of [id] column.
  247. *
  248. * @param int $v new value
  249. * @return void
  250. */
  251. public function setId($v)
  252. {
  253. // Since the native PHP type for this column is integer,
  254. // we will cast the input value to an int (if it is not).
  255. if ($v !== null && !is_int($v) && is_numeric($v)) {
  256. $v = (int) $v;
  257. }
  258. if ($this->id !== $v) {
  259. $this->id = $v;
  260. $this->modifiedColumns[] = KataoSupplierInvoiceProductPeer::ID;
  261. }
  262. } // setId()
  263. /**
  264. * Set the value of [katao_supplier_invoice_id] column.
  265. *
  266. * @param int $v new value
  267. * @return void
  268. */
  269. public function setKataoSupplierInvoiceId($v)
  270. {
  271. // Since the native PHP type for this column is integer,
  272. // we will cast the input value to an int (if it is not).
  273. if ($v !== null && !is_int($v) && is_numeric($v)) {
  274. $v = (int) $v;
  275. }
  276. if ($this->katao_supplier_invoice_id !== $v) {
  277. $this->katao_supplier_invoice_id = $v;
  278. $this->modifiedColumns[] = KataoSupplierInvoiceProductPeer::KATAO_SUPPLIER_INVOICE_ID;
  279. }
  280. if ($this->aKataoSupplierInvoice !== null && $this->aKataoSupplierInvoice->getId() !== $v) {
  281. $this->aKataoSupplierInvoice = null;
  282. }
  283. } // setKataoSupplierInvoiceId()
  284. /**
  285. * Set the value of [katao_product_id] column.
  286. *
  287. * @param int $v new value
  288. * @return void
  289. */
  290. public function setKataoProductId($v)
  291. {
  292. // Since the native PHP type for this column is integer,
  293. // we will cast the input value to an int (if it is not).
  294. if ($v !== null && !is_int($v) && is_numeric($v)) {
  295. $v = (int) $v;
  296. }
  297. if ($this->katao_product_id !== $v) {
  298. $this->katao_product_id = $v;
  299. $this->modifiedColumns[] = KataoSupplierInvoiceProductPeer::KATAO_PRODUCT_ID;
  300. }
  301. if ($this->aKataoProduct !== null && $this->aKataoProduct->getId() !== $v) {
  302. $this->aKataoProduct = null;
  303. }
  304. } // setKataoProductId()
  305. /**
  306. * Set the value of [product_reference] column.
  307. *
  308. * @param string $v new value
  309. * @return void
  310. */
  311. public function setProductReference($v)
  312. {
  313. // Since the native PHP type for this column is string,
  314. // we will cast the input to a string (if it is not).
  315. if ($v !== null && !is_string($v)) {
  316. $v = (string) $v;
  317. }
  318. if ($this->product_reference !== $v) {
  319. $this->product_reference = $v;
  320. $this->modifiedColumns[] = KataoSupplierInvoiceProductPeer::PRODUCT_REFERENCE;
  321. }
  322. } // setProductReference()
  323. /**
  324. * Set the value of [product_name] column.
  325. *
  326. * @param string $v new value
  327. * @return void
  328. */
  329. public function setProductName($v)
  330. {
  331. // Since the native PHP type for this column is string,
  332. // we will cast the input to a string (if it is not).
  333. if ($v !== null && !is_string($v)) {
  334. $v = (string) $v;
  335. }
  336. if ($this->product_name !== $v) {
  337. $this->product_name = $v;
  338. $this->modifiedColumns[] = KataoSupplierInvoiceProductPeer::PRODUCT_NAME;
  339. }
  340. } // setProductName()
  341. /**
  342. * Set the value of [product_price_euro] column.
  343. *
  344. * @param double $v new value
  345. * @return void
  346. */
  347. public function setProductPriceEuro($v)
  348. {
  349. if ($this->product_price_euro !== $v) {
  350. $this->product_price_euro = $v;
  351. $this->modifiedColumns[] = KataoSupplierInvoiceProductPeer::PRODUCT_PRICE_EURO;
  352. }
  353. } // setProductPriceEuro()
  354. /**
  355. * Set the value of [product_margin] column.
  356. *
  357. * @param double $v new value
  358. * @return void
  359. */
  360. public function setProductMargin($v)
  361. {
  362. if ($this->product_margin !== $v) {
  363. $this->product_margin = $v;
  364. $this->modifiedColumns[] = KataoSupplierInvoiceProductPeer::PRODUCT_MARGIN;
  365. }
  366. } // setProductMargin()
  367. /**
  368. * Set the value of [product_tva_rate] column.
  369. *
  370. * @param double $v new value
  371. * @return void
  372. */
  373. public function setProductTvaRate($v)
  374. {
  375. if ($this->product_tva_rate !== $v || $v === 0) {
  376. $this->product_tva_rate = $v;
  377. $this->modifiedColumns[] = KataoSupplierInvoiceProductPeer::PRODUCT_TVA_RATE;
  378. }
  379. } // setProductTvaRate()
  380. /**
  381. * Set the value of [quantity] column.
  382. *
  383. * @param double $v new value
  384. * @return void
  385. */
  386. public function setQuantity($v)
  387. {
  388. if ($this->quantity !== $v || $v === 1) {
  389. $this->quantity = $v;
  390. $this->modifiedColumns[] = KataoSupplierInvoiceProductPeer::QUANTITY;
  391. }
  392. } // setQuantity()
  393. /**
  394. * Set the value of [product_price_total] column.
  395. *
  396. * @param double $v new value
  397. * @return void
  398. */
  399. public function setProductPriceTotal($v)
  400. {
  401. if ($this->product_price_total !== $v || $v === 0) {
  402. $this->product_price_total = $v;
  403. $this->modifiedColumns[] = KataoSupplierInvoiceProductPeer::PRODUCT_PRICE_TOTAL;
  404. }
  405. } // setProductPriceTotal()
  406. /**
  407. * Set the value of [created_at] column.
  408. *
  409. * @param int $v new value
  410. * @return void
  411. */
  412. public function setCreatedAt($v)
  413. {
  414. if ($v !== null && !is_int($v)) {
  415. $ts = strtotime($v);
  416. if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
  417. throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
  418. }
  419. } else {
  420. $ts = $v;
  421. }
  422. if ($this->created_at !== $ts) {
  423. $this->created_at = $ts;
  424. $this->modifiedColumns[] = KataoSupplierInvoiceProductPeer::CREATED_AT;
  425. }
  426. } // setCreatedAt()
  427. /**
  428. * Set the value of [updated_at] column.
  429. *
  430. * @param int $v new value
  431. * @return void
  432. */
  433. public function setUpdatedAt($v)
  434. {
  435. if ($v !== null && !is_int($v)) {
  436. $ts = strtotime($v);
  437. if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
  438. throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
  439. }
  440. } else {
  441. $ts = $v;
  442. }
  443. if ($this->updated_at !== $ts) {
  444. $this->updated_at = $ts;
  445. $this->modifiedColumns[] = KataoSupplierInvoiceProductPeer::UPDATED_AT;
  446. }
  447. } // setUpdatedAt()
  448. /**
  449. * Hydrates (populates) the object variables with values from the database resultset.
  450. *
  451. * An offset (1-based "start column") is specified so that objects can be hydrated
  452. * with a subset of the columns in the resultset rows. This is needed, for example,
  453. * for results of JOIN queries where the resultset row includes columns from two or
  454. * more tables.
  455. *
  456. * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
  457. * @param int $startcol 1-based offset column which indicates which restultset column to start with.
  458. * @return int next starting column
  459. * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
  460. */
  461. public function hydrate(ResultSet $rs, $startcol = 1)
  462. {
  463. try {
  464. $this->id = $rs->getInt($startcol + 0);
  465. $this->katao_supplier_invoice_id = $rs->getInt($startcol + 1);
  466. $this->katao_product_id = $rs->getInt($startcol + 2);
  467. $this->product_reference = $rs->getString($startcol + 3);
  468. $this->product_name = $rs->getString($startcol + 4);
  469. $this->product_price_euro = $rs->getFloat($startcol + 5);
  470. $this->product_margin = $rs->getFloat($startcol + 6);
  471. $this->product_tva_rate = $rs->getFloat($startcol + 7);
  472. $this->quantity = $rs->getFloat($startcol + 8);
  473. $this->product_price_total = $rs->getFloat($startcol + 9);
  474. $this->created_at = $rs->getTimestamp($startcol + 10, null);
  475. $this->updated_at = $rs->getTimestamp($startcol + 11, null);
  476. $this->resetModified();
  477. $this->setNew(false);
  478. // FIXME - using NUM_COLUMNS may be clearer.
  479. return $startcol + 12; // 12 = KataoSupplierInvoiceProductPeer::NUM_COLUMNS - KataoSupplierInvoiceProductPeer::NUM_LAZY_LOAD_COLUMNS).
  480. } catch (Exception $e) {
  481. throw new PropelException("Error populating KataoSupplierInvoiceProduct object", $e);
  482. }
  483. }
  484. /**
  485. * Removes this object from datastore and sets delete attribute.
  486. *
  487. * @param Connection $con
  488. * @return void
  489. * @throws PropelException
  490. * @see BaseObject::setDeleted()
  491. * @see BaseObject::isDeleted()
  492. */
  493. public function delete($con = null)
  494. {
  495. foreach (sfMixer::getCallables('BaseKataoSupplierInvoiceProduct:delete:pre') as $callable)
  496. {
  497. $ret = call_user_func($callable, $this, $con);
  498. if ($ret)
  499. {
  500. return;
  501. }
  502. }
  503. if ($this->isDeleted()) {
  504. throw new PropelException("This object has already been deleted.");
  505. }
  506. if ($con === null) {
  507. $con = Propel::getConnection(KataoSupplierInvoiceProductPeer::DATABASE_NAME);
  508. }
  509. try {
  510. $con->begin();
  511. KataoSupplierInvoiceProductPeer::doDelete($this, $con);
  512. $this->setDeleted(true);
  513. $con->commit();
  514. } catch (PropelException $e) {
  515. $con->rollback();
  516. throw $e;
  517. }
  518. foreach (sfMixer::getCallables('BaseKataoSupplierInvoiceProduct:delete:post') as $callable)
  519. {
  520. call_user_func($callable, $this, $con);
  521. }
  522. }
  523. /**
  524. * Stores the object in the database. If the object is new,
  525. * it inserts it; otherwise an update is performed. This method
  526. * wraps the doSave() worker method in a transaction.
  527. *
  528. * @param Connection $con
  529. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  530. * @throws PropelException
  531. * @see doSave()
  532. */
  533. public function save($con = null)
  534. {
  535. foreach (sfMixer::getCallables('BaseKataoSupplierInvoiceProduct:save:pre') as $callable)
  536. {
  537. $affectedRows = call_user_func($callable, $this, $con);
  538. if (is_int($affectedRows))
  539. {
  540. return $affectedRows;
  541. }
  542. }
  543. if ($this->isNew() && !$this->isColumnModified(KataoSupplierInvoiceProductPeer::CREATED_AT))
  544. {
  545. $this->setCreatedAt(time());
  546. }
  547. if ($this->isModified() && !$this->isColumnModified(KataoSupplierInvoiceProductPeer::UPDATED_AT))
  548. {
  549. $this->setUpdatedAt(time());
  550. }
  551. if ($this->isDeleted()) {
  552. throw new PropelException("You cannot save an object that has been deleted.");
  553. }
  554. if ($con === null) {
  555. $con = Propel::getConnection(KataoSupplierInvoiceProductPeer::DATABASE_NAME);
  556. }
  557. try {
  558. $con->begin();
  559. $affectedRows = $this->doSave($con);
  560. $con->commit();
  561. foreach (sfMixer::getCallables('BaseKataoSupplierInvoiceProduct:save:post') as $callable)
  562. {
  563. call_user_func($callable, $this, $con, $affectedRows);
  564. }
  565. return $affectedRows;
  566. } catch (PropelException $e) {
  567. $con->rollback();
  568. throw $e;
  569. }
  570. }
  571. /**
  572. * Stores the object in the database.
  573. *
  574. * If the object is new, it inserts it; otherwise an update is performed.
  575. * All related objects are also updated in this method.
  576. *
  577. * @param Connection $con
  578. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  579. * @throws PropelException
  580. * @see save()
  581. */
  582. protected function doSave($con)
  583. {
  584. $affectedRows = 0; // initialize var to track total num of affected rows
  585. if (!$this->alreadyInSave) {
  586. $this->alreadyInSave = true;
  587. // We call the save method on the following object(s) if they
  588. // were passed to this object by their coresponding set
  589. // method. This object relates to these object(s) by a
  590. // foreign key reference.
  591. if ($this->aKataoSupplierInvoice !== null) {
  592. if ($this->aKataoSupplierInvoice->isModified()) {
  593. $affectedRows += $this->aKataoSupplierInvoice->save($con);
  594. }
  595. $this->setKataoSupplierInvoice($this->aKataoSupplierInvoice);
  596. }
  597. if ($this->aKataoProduct !== null) {
  598. if ($this->aKataoProduct->isModified()) {
  599. $affectedRows += $this->aKataoProduct->save($con);
  600. }
  601. $this->setKataoProduct($this->aKataoProduct);
  602. }
  603. // If this object has been modified, then save it to the database.
  604. if ($this->isModified()) {
  605. if ($this->isNew()) {
  606. $pk = KataoSupplierInvoiceProductPeer::doInsert($this, $con);
  607. $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
  608. // should always be true here (even though technically
  609. // BasePeer::doInsert() can insert multiple rows).
  610. $this->setId($pk); //[IMV] update autoincrement primary key
  611. $this->setNew(false);
  612. } else {
  613. $affectedRows += KataoSupplierInvoiceProductPeer::doUpdate($this, $con);
  614. }
  615. $this->resetModified(); // [HL] After being saved an object is no longer 'modified'
  616. }
  617. $this->alreadyInSave = false;
  618. }
  619. return $affectedRows;
  620. } // doSave()
  621. /**
  622. * Array of ValidationFailed objects.
  623. * @var array ValidationFailed[]
  624. */
  625. protected $validationFailures = array();
  626. /**
  627. * Gets any ValidationFailed objects that resulted from last call to validate().
  628. *
  629. *
  630. * @return array ValidationFailed[]
  631. * @see validate()
  632. */
  633. public function getValidationFailures()
  634. {
  635. return $this->validationFailures;
  636. }
  637. /**
  638. * Validates the objects modified field values and all objects related to this table.
  639. *
  640. * If $columns is either a column name or an array of column names
  641. * only those columns are validated.
  642. *
  643. * @param mixed $columns Column name or an array of column names.
  644. * @return boolean Whether all columns pass validation.
  645. * @see doValidate()
  646. * @see getValidationFailures()
  647. */
  648. public function validate($columns = null)
  649. {
  650. $res = $this->doValidate($columns);
  651. if ($res === true) {
  652. $this->validationFailures = array();
  653. return true;
  654. } else {
  655. $this->validationFailures = $res;
  656. return false;
  657. }
  658. }
  659. /**
  660. * This function performs the validation work for complex object models.
  661. *
  662. * In addition to checking the current object, all related objects will
  663. * also be validated. If all pass then <code>true</code> is returned; otherwise
  664. * an aggreagated array of ValidationFailed objects will be returned.
  665. *
  666. * @param array $columns Array of column names to validate.
  667. * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  668. */
  669. protected function doValidate($columns = null)
  670. {
  671. if (!$this->alreadyInValidation) {
  672. $this->alreadyInValidation = true;
  673. $retval = null;
  674. $failureMap = array();
  675. // We call the validate method on the following object(s) if they
  676. // were passed to this object by their coresponding set
  677. // method. This object relates to these object(s) by a
  678. // foreign key reference.
  679. if ($this->aKataoSupplierInvoice !== null) {
  680. if (!$this->aKataoSupplierInvoice->validate($columns)) {
  681. $failureMap = array_merge($failureMap, $this->aKataoSupplierInvoice->getValidationFailures());
  682. }
  683. }
  684. if ($this->aKataoProduct !== null) {
  685. if (!$this->aKataoProduct->validate($columns)) {
  686. $failureMap = array_merge($failureMap, $this->aKataoProduct->getValidationFailures());
  687. }
  688. }
  689. if (($retval = KataoSupplierInvoiceProductPeer::doValidate($this, $columns)) !== true) {
  690. $failureMap = array_merge($failureMap, $retval);
  691. }
  692. $this->alreadyInValidation = false;
  693. }
  694. return (!empty($failureMap) ? $failureMap : true);
  695. }
  696. /**
  697. * Retrieves a field from the object by name passed in as a string.
  698. *
  699. * @param string $name name
  700. * @param string $type The type of fieldname the $name is of:
  701. * one of the class type constants TYPE_PHPNAME,
  702. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  703. * @return mixed Value of field.
  704. */
  705. public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
  706. {
  707. $pos = KataoSupplierInvoiceProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  708. return $this->getByPosition($pos);
  709. }
  710. /**
  711. * Retrieves a field from the object by Position as specified in the xml schema.
  712. * Zero-based.
  713. *
  714. * @param int $pos position in xml schema
  715. * @return mixed Value of field at $pos
  716. */
  717. public function getByPosition($pos)
  718. {
  719. switch($pos) {
  720. case 0:
  721. return $this->getId();
  722. break;
  723. case 1:
  724. return $this->getKataoSupplierInvoiceId();
  725. break;
  726. case 2:
  727. return $this->getKataoProductId();
  728. break;
  729. case 3:
  730. return $this->getProductReference();
  731. break;
  732. case 4:
  733. return $this->getProductName();
  734. break;
  735. case 5:
  736. return $this->getProductPriceEuro();
  737. break;
  738. case 6:
  739. return $this->getProductMargin();
  740. break;
  741. case 7:
  742. return $this->getProductTvaRate();
  743. break;
  744. case 8:
  745. return $this->getQuantity();
  746. break;
  747. case 9:
  748. return $this->getProductPriceTotal();
  749. break;
  750. case 10:
  751. return $this->getCreatedAt();
  752. break;
  753. case 11:
  754. return $this->getUpdatedAt();
  755. break;
  756. default:
  757. return null;
  758. break;
  759. } // switch()
  760. }
  761. /**
  762. * Exports the object as an array.
  763. *
  764. * You can specify the key type of the array by passing one of the class
  765. * type constants.
  766. *
  767. * @param string $keyType One of the class type constants TYPE_PHPNAME,
  768. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  769. * @return an associative array containing the field names (as keys) and field values
  770. */
  771. public function toArray($keyType = BasePeer::TYPE_PHPNAME)
  772. {
  773. $keys = KataoSupplierInvoiceProductPeer::getFieldNames($keyType);
  774. $result = array(
  775. $keys[0] => $this->getId(),
  776. $keys[1] => $this->getKataoSupplierInvoiceId(),
  777. $keys[2] => $this->getKataoProductId(),
  778. $keys[3] => $this->getProductReference(),
  779. $keys[4] => $this->getProductName(),
  780. $keys[5] => $this->getProductPriceEuro(),
  781. $keys[6] => $this->getProductMargin(),
  782. $keys[7] => $this->getProductTvaRate(),
  783. $keys[8] => $this->getQuantity(),
  784. $keys[9] => $this->getProductPriceTotal(),
  785. $keys[10] => $this->getCreatedAt(),
  786. $keys[11] => $this->getUpdatedAt(),
  787. );
  788. return $result;
  789. }
  790. /**
  791. * Sets a field from the object by name passed in as a string.
  792. *
  793. * @param string $name peer name
  794. * @param mixed $value field value
  795. * @param string $type The type of fieldname the $name is of:
  796. * one of the class type constants TYPE_PHPNAME,
  797. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  798. * @return void
  799. */
  800. public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
  801. {
  802. $pos = KataoSupplierInvoiceProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  803. return $this->setByPosition($pos, $value);
  804. }
  805. /**
  806. * Sets a field from the object by Position as specified in the xml schema.
  807. * Zero-based.
  808. *
  809. * @param int $pos position in xml schema
  810. * @param mixed $value field value
  811. * @return void
  812. */
  813. public function setByPosition($pos, $value)
  814. {
  815. switch($pos) {
  816. case 0:
  817. $this->setId($value);
  818. break;
  819. case 1:
  820. $this->setKataoSupplierInvoiceId($value);
  821. break;
  822. case 2:
  823. $this->setKataoProductId($value);
  824. break;
  825. case 3:
  826. $this->setProductReference($value);
  827. break;
  828. case 4:
  829. $this->setProductName($value);
  830. break;
  831. case 5:
  832. $this->setProductPriceEuro($value);
  833. break;
  834. case 6:
  835. $this->setProductMargin($value);
  836. break;
  837. case 7:
  838. $this->setProductTvaRate($value);
  839. break;
  840. case 8:
  841. $this->setQuantity($value);
  842. break;
  843. case 9:
  844. $this->setProductPriceTotal($value);
  845. break;
  846. case 10:
  847. $this->setCreatedAt($value);
  848. break;
  849. case 11:
  850. $this->setUpdatedAt($value);
  851. break;
  852. } // switch()
  853. }
  854. /**
  855. * Populates the object using an array.
  856. *
  857. * This is particularly useful when populating an object from one of the
  858. * request arrays (e.g. $_POST). This method goes through the column
  859. * names, checking to see whether a matching key exists in populated
  860. * array. If so the setByName() method is called for that column.
  861. *
  862. * You can specify the key type of the array by additionally passing one
  863. * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
  864. * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
  865. *
  866. * @param array $arr An array to populate the object from.
  867. * @param string $keyType The type of keys the array uses.
  868. * @return void
  869. */
  870. public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
  871. {
  872. $keys = KataoSupplierInvoiceProductPeer::getFieldNames($keyType);
  873. if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
  874. if (array_key_exists($keys[1], $arr)) $this->setKataoSupplierInvoiceId($arr[$keys[1]]);
  875. if (array_key_exists($keys[2], $arr)) $this->setKataoProductId($arr[$keys[2]]);
  876. if (array_key_exists($keys[3], $arr)) $this->setProductReference($arr[$keys[3]]);
  877. if (array_key_exists($keys[4], $arr)) $this->setProductName($arr[$keys[4]]);
  878. if (array_key_exists($keys[5], $arr)) $this->setProductPriceEuro($arr[$keys[5]]);
  879. if (array_key_exists($keys[6], $arr)) $this->setProductMargin($arr[$keys[6]]);
  880. if (array_key_exists($keys[7], $arr)) $this->setProductTvaRate($arr[$keys[7]]);
  881. if (array_key_exists($keys[8], $arr)) $this->setQuantity($arr[$keys[8]]);
  882. if (array_key_exists($keys[9], $arr)) $this->setProductPriceTotal($arr[$keys[9]]);
  883. if (array_key_exists($keys[10], $arr)) $this->setCreatedAt($arr[$keys[10]]);
  884. if (array_key_exists($keys[11], $arr)) $this->setUpdatedAt($arr[$keys[11]]);
  885. }
  886. /**
  887. * Build a Criteria object containing the values of all modified columns in this object.
  888. *
  889. * @return Criteria The Criteria object containing all modified values.
  890. */
  891. public function buildCriteria()
  892. {
  893. $criteria = new Criteria(KataoSupplierInvoiceProductPeer::DATABASE_NAME);
  894. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::ID)) $criteria->add(KataoSupplierInvoiceProductPeer::ID, $this->id);
  895. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::KATAO_SUPPLIER_INVOICE_ID)) $criteria->add(KataoSupplierInvoiceProductPeer::KATAO_SUPPLIER_INVOICE_ID, $this->katao_supplier_invoice_id);
  896. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::KATAO_PRODUCT_ID)) $criteria->add(KataoSupplierInvoiceProductPeer::KATAO_PRODUCT_ID, $this->katao_product_id);
  897. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::PRODUCT_REFERENCE)) $criteria->add(KataoSupplierInvoiceProductPeer::PRODUCT_REFERENCE, $this->product_reference);
  898. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::PRODUCT_NAME)) $criteria->add(KataoSupplierInvoiceProductPeer::PRODUCT_NAME, $this->product_name);
  899. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::PRODUCT_PRICE_EURO)) $criteria->add(KataoSupplierInvoiceProductPeer::PRODUCT_PRICE_EURO, $this->product_price_euro);
  900. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::PRODUCT_MARGIN)) $criteria->add(KataoSupplierInvoiceProductPeer::PRODUCT_MARGIN, $this->product_margin);
  901. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::PRODUCT_TVA_RATE)) $criteria->add(KataoSupplierInvoiceProductPeer::PRODUCT_TVA_RATE, $this->product_tva_rate);
  902. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::QUANTITY)) $criteria->add(KataoSupplierInvoiceProductPeer::QUANTITY, $this->quantity);
  903. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::PRODUCT_PRICE_TOTAL)) $criteria->add(KataoSupplierInvoiceProductPeer::PRODUCT_PRICE_TOTAL, $this->product_price_total);
  904. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::CREATED_AT)) $criteria->add(KataoSupplierInvoiceProductPeer::CREATED_AT, $this->created_at);
  905. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::UPDATED_AT)) $criteria->add(KataoSupplierInvoiceProductPeer::UPDATED_AT, $this->updated_at);
  906. return $criteria;
  907. }
  908. /**
  909. * Builds a Criteria object containing the primary key for this object.
  910. *
  911. * Unlike buildCriteria() this method includes the primary key values regardless
  912. * of whether or not they have been modified.
  913. *
  914. * @return Criteria The Criteria object containing value(s) for primary key(s).
  915. */
  916. public function buildPkeyCriteria()
  917. {
  918. $criteria = new Criteria(KataoSupplierInvoiceProductPeer::DATABASE_NAME);
  919. $criteria->add(KataoSupplierInvoiceProductPeer::ID, $this->id);
  920. return $criteria;
  921. }
  922. /**
  923. * Returns the primary key for this object (row).
  924. * @return int
  925. */
  926. public function getPrimaryKey()
  927. {
  928. return $this->getId();
  929. }
  930. /**
  931. * Generic method to set the primary key (id column).
  932. *
  933. * @param int $key Primary key.
  934. * @return void
  935. */
  936. public function setPrimaryKey($key)
  937. {
  938. $this->setId($key);
  939. }
  940. /**
  941. * Sets contents of passed object to values from current object.
  942. *
  943. * If desired, this method can also make copies of all associated (fkey referrers)
  944. * objects.
  945. *
  946. * @param object $copyObj An object of KataoSupplierInvoiceProduct (or compatible) type.
  947. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  948. * @throws PropelException
  949. */
  950. public function copyInto($copyObj, $deepCopy = false)
  951. {
  952. $copyObj->setKataoSupplierInvoiceId($this->katao_supplier_invoice_id);
  953. $copyObj->setKataoProductId($this->katao_product_id);
  954. $copyObj->setProductReference($this->product_reference);
  955. $copyObj->setProductName($this->product_name);
  956. $copyObj->setProductPriceEuro($this->product_price_euro);
  957. $copyObj->setProductMargin($this->product_margin);
  958. $copyObj->setProductTvaRate($this->product_tva_rate);
  959. $copyObj->setQuantity($this->quantity);
  960. $copyObj->setProductPriceTotal($this->product_price_total);
  961. $copyObj->setCreatedAt($this->created_at);
  962. $copyObj->setUpdatedAt($this->updated_at);
  963. $copyObj->setNew(true);
  964. $copyObj->setId(NULL); // this is a pkey column, so set to default value
  965. }
  966. /**
  967. * Makes a copy of this object that will be inserted as a new row in table when saved.
  968. * It creates a new object filling in the simple attributes, but skipping any primary
  969. * keys that are defined for the table.
  970. *
  971. * If desired, this method can also make copies of all associated (fkey referrers)
  972. * objects.
  973. *
  974. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  975. * @return KataoSupplierInvoiceProduct Clone of current object.
  976. * @throws PropelException
  977. */
  978. public function copy($deepCopy = false)
  979. {
  980. // we use get_class(), because this might be a subclass
  981. $clazz = get_class($this);
  982. $copyObj = new $clazz();
  983. $this->copyInto($copyObj, $deepCopy);
  984. return $copyObj;
  985. }
  986. /**
  987. * Returns a peer instance associated with this om.
  988. *
  989. * Since Peer classes are not to have any instance attributes, this method returns the
  990. * same instance for all member of this class. The method could therefore
  991. * be static, but this would prevent one from overriding the behavior.
  992. *
  993. * @return KataoSupplierInvoiceProductPeer
  994. */
  995. public function getPeer()
  996. {
  997. if (self::$peer === null) {
  998. self::$peer = new KataoSupplierInvoiceProductPeer();
  999. }
  1000. return self::$peer;
  1001. }
  1002. /**
  1003. * Declares an association between this object and a KataoSupplierInvoice object.
  1004. *
  1005. * @param KataoSupplierInvoice $v
  1006. * @return void
  1007. * @throws PropelException
  1008. */
  1009. public function setKataoSupplierInvoice($v)
  1010. {
  1011. if ($v === null) {
  1012. $this->setKataoSupplierInvoiceId(NULL);
  1013. } else {
  1014. $this->setKataoSupplierInvoiceId($v->getId());
  1015. }
  1016. $this->aKataoSupplierInvoice = $v;
  1017. }
  1018. /**
  1019. * Get the associated KataoSupplierInvoice object
  1020. *
  1021. * @param Connection Optional Connection object.
  1022. * @return KataoSupplierInvoice The associated KataoSupplierInvoice object.
  1023. * @throws PropelException
  1024. */
  1025. public function getKataoSupplierInvoice($con = null)
  1026. {
  1027. if ($this->aKataoSupplierInvoice === null && ($this->katao_supplier_invoice_id !== null)) {
  1028. // include the related Peer class
  1029. $this->aKataoSupplierInvoice = KataoSupplierInvoicePeer::retrieveByPK($this->katao_supplier_invoice_id, $con);
  1030. /* The following can be used instead of the line above to
  1031. guarantee the related object contains a reference
  1032. to this object, but this level of coupling
  1033. may be undesirable in many circumstances.
  1034. As it can lead to a db query with many results that may
  1035. never be used.
  1036. $obj = KataoSupplierInvoicePeer::retrieveByPK($this->katao_supplier_invoice_id, $con);
  1037. $obj->addKataoSupplierInvoices($this);
  1038. */
  1039. }
  1040. return $this->aKataoSupplierInvoice;
  1041. }
  1042. /**
  1043. * Declares an association between this object and a KataoProduct object.
  1044. *
  1045. * @param KataoProduct $v
  1046. * @return void
  1047. * @throws PropelException
  1048. */
  1049. public function setKataoProduct($v)
  1050. {
  1051. if ($v === null) {
  1052. $this->setKataoProductId(NULL);
  1053. } else {
  1054. $this->setKataoProductId($v->getId());
  1055. }
  1056. $this->aKataoProduct = $v;
  1057. }
  1058. /**
  1059. * Get the associated KataoProduct object
  1060. *
  1061. * @param Connection Optional Connection object.
  1062. * @return KataoProduct The associated KataoProduct object.
  1063. * @throws PropelException
  1064. */
  1065. public function getKataoProduct($con = null)
  1066. {
  1067. if ($this->aKataoProduct === null && ($this->katao_product_id !== null)) {
  1068. // include the related Peer class
  1069. $this->aKataoProduct = KataoProductPeer::retrieveByPK($this->katao_product_id, $con);
  1070. /* The following can be used instead of the line above to
  1071. guarantee the related object contains a reference
  1072. to this object, but this level of coupling
  1073. may be undesirable in many circumstances.
  1074. As it can lead to a db query with many results that may
  1075. never be used.
  1076. $obj = KataoProductPeer::retrieveByPK($this->katao_product_id, $con);
  1077. $obj->addKataoProducts($this);
  1078. */
  1079. }
  1080. return $this->aKataoProduct;
  1081. }
  1082. public function __call($method, $arguments)
  1083. {
  1084. if (!$callable = sfMixer::getCallable('BaseKataoSupplierInvoiceProduct:'.$method))
  1085. {
  1086. throw new sfException(sprintf('Call to undefined method BaseKataoSupplierInvoiceProduct::%s', $method));
  1087. }
  1088. array_unshift($arguments, $this);
  1089. return call_user_func_array($callable, $arguments);
  1090. }
  1091. } // BaseKataoSupplierInvoiceProduct