BaseKataoSupplierInvoiceProduct.php 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309
  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 int
  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 int
  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 int $v new value
  384. * @return void
  385. */
  386. public function setQuantity($v)
  387. {
  388. // Since the native PHP type for this column is integer,
  389. // we will cast the input value to an int (if it is not).
  390. if ($v !== null && !is_int($v) && is_numeric($v)) {
  391. $v = (int) $v;
  392. }
  393. if ($this->quantity !== $v || $v === 1) {
  394. $this->quantity = $v;
  395. $this->modifiedColumns[] = KataoSupplierInvoiceProductPeer::QUANTITY;
  396. }
  397. } // setQuantity()
  398. /**
  399. * Set the value of [product_price_total] column.
  400. *
  401. * @param double $v new value
  402. * @return void
  403. */
  404. public function setProductPriceTotal($v)
  405. {
  406. if ($this->product_price_total !== $v || $v === 0) {
  407. $this->product_price_total = $v;
  408. $this->modifiedColumns[] = KataoSupplierInvoiceProductPeer::PRODUCT_PRICE_TOTAL;
  409. }
  410. } // setProductPriceTotal()
  411. /**
  412. * Set the value of [created_at] column.
  413. *
  414. * @param int $v new value
  415. * @return void
  416. */
  417. public function setCreatedAt($v)
  418. {
  419. if ($v !== null && !is_int($v)) {
  420. $ts = strtotime($v);
  421. if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
  422. throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
  423. }
  424. } else {
  425. $ts = $v;
  426. }
  427. if ($this->created_at !== $ts) {
  428. $this->created_at = $ts;
  429. $this->modifiedColumns[] = KataoSupplierInvoiceProductPeer::CREATED_AT;
  430. }
  431. } // setCreatedAt()
  432. /**
  433. * Set the value of [updated_at] column.
  434. *
  435. * @param int $v new value
  436. * @return void
  437. */
  438. public function setUpdatedAt($v)
  439. {
  440. if ($v !== null && !is_int($v)) {
  441. $ts = strtotime($v);
  442. if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
  443. throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
  444. }
  445. } else {
  446. $ts = $v;
  447. }
  448. if ($this->updated_at !== $ts) {
  449. $this->updated_at = $ts;
  450. $this->modifiedColumns[] = KataoSupplierInvoiceProductPeer::UPDATED_AT;
  451. }
  452. } // setUpdatedAt()
  453. /**
  454. * Hydrates (populates) the object variables with values from the database resultset.
  455. *
  456. * An offset (1-based "start column") is specified so that objects can be hydrated
  457. * with a subset of the columns in the resultset rows. This is needed, for example,
  458. * for results of JOIN queries where the resultset row includes columns from two or
  459. * more tables.
  460. *
  461. * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
  462. * @param int $startcol 1-based offset column which indicates which restultset column to start with.
  463. * @return int next starting column
  464. * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
  465. */
  466. public function hydrate(ResultSet $rs, $startcol = 1)
  467. {
  468. try {
  469. $this->id = $rs->getInt($startcol + 0);
  470. $this->katao_supplier_invoice_id = $rs->getInt($startcol + 1);
  471. $this->katao_product_id = $rs->getInt($startcol + 2);
  472. $this->product_reference = $rs->getString($startcol + 3);
  473. $this->product_name = $rs->getString($startcol + 4);
  474. $this->product_price_euro = $rs->getFloat($startcol + 5);
  475. $this->product_margin = $rs->getFloat($startcol + 6);
  476. $this->product_tva_rate = $rs->getFloat($startcol + 7);
  477. $this->quantity = $rs->getInt($startcol + 8);
  478. $this->product_price_total = $rs->getFloat($startcol + 9);
  479. $this->created_at = $rs->getTimestamp($startcol + 10, null);
  480. $this->updated_at = $rs->getTimestamp($startcol + 11, null);
  481. $this->resetModified();
  482. $this->setNew(false);
  483. // FIXME - using NUM_COLUMNS may be clearer.
  484. return $startcol + 12; // 12 = KataoSupplierInvoiceProductPeer::NUM_COLUMNS - KataoSupplierInvoiceProductPeer::NUM_LAZY_LOAD_COLUMNS).
  485. } catch (Exception $e) {
  486. throw new PropelException("Error populating KataoSupplierInvoiceProduct object", $e);
  487. }
  488. }
  489. /**
  490. * Removes this object from datastore and sets delete attribute.
  491. *
  492. * @param Connection $con
  493. * @return void
  494. * @throws PropelException
  495. * @see BaseObject::setDeleted()
  496. * @see BaseObject::isDeleted()
  497. */
  498. public function delete($con = null)
  499. {
  500. foreach (sfMixer::getCallables('BaseKataoSupplierInvoiceProduct:delete:pre') as $callable)
  501. {
  502. $ret = call_user_func($callable, $this, $con);
  503. if ($ret)
  504. {
  505. return;
  506. }
  507. }
  508. if ($this->isDeleted()) {
  509. throw new PropelException("This object has already been deleted.");
  510. }
  511. if ($con === null) {
  512. $con = Propel::getConnection(KataoSupplierInvoiceProductPeer::DATABASE_NAME);
  513. }
  514. try {
  515. $con->begin();
  516. KataoSupplierInvoiceProductPeer::doDelete($this, $con);
  517. $this->setDeleted(true);
  518. $con->commit();
  519. } catch (PropelException $e) {
  520. $con->rollback();
  521. throw $e;
  522. }
  523. foreach (sfMixer::getCallables('BaseKataoSupplierInvoiceProduct:delete:post') as $callable)
  524. {
  525. call_user_func($callable, $this, $con);
  526. }
  527. }
  528. /**
  529. * Stores the object in the database. If the object is new,
  530. * it inserts it; otherwise an update is performed. This method
  531. * wraps the doSave() worker method in a transaction.
  532. *
  533. * @param Connection $con
  534. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  535. * @throws PropelException
  536. * @see doSave()
  537. */
  538. public function save($con = null)
  539. {
  540. foreach (sfMixer::getCallables('BaseKataoSupplierInvoiceProduct:save:pre') as $callable)
  541. {
  542. $affectedRows = call_user_func($callable, $this, $con);
  543. if (is_int($affectedRows))
  544. {
  545. return $affectedRows;
  546. }
  547. }
  548. if ($this->isNew() && !$this->isColumnModified(KataoSupplierInvoiceProductPeer::CREATED_AT))
  549. {
  550. $this->setCreatedAt(time());
  551. }
  552. if ($this->isModified() && !$this->isColumnModified(KataoSupplierInvoiceProductPeer::UPDATED_AT))
  553. {
  554. $this->setUpdatedAt(time());
  555. }
  556. if ($this->isDeleted()) {
  557. throw new PropelException("You cannot save an object that has been deleted.");
  558. }
  559. if ($con === null) {
  560. $con = Propel::getConnection(KataoSupplierInvoiceProductPeer::DATABASE_NAME);
  561. }
  562. try {
  563. $con->begin();
  564. $affectedRows = $this->doSave($con);
  565. $con->commit();
  566. foreach (sfMixer::getCallables('BaseKataoSupplierInvoiceProduct:save:post') as $callable)
  567. {
  568. call_user_func($callable, $this, $con, $affectedRows);
  569. }
  570. return $affectedRows;
  571. } catch (PropelException $e) {
  572. $con->rollback();
  573. throw $e;
  574. }
  575. }
  576. /**
  577. * Stores the object in the database.
  578. *
  579. * If the object is new, it inserts it; otherwise an update is performed.
  580. * All related objects are also updated in this method.
  581. *
  582. * @param Connection $con
  583. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  584. * @throws PropelException
  585. * @see save()
  586. */
  587. protected function doSave($con)
  588. {
  589. $affectedRows = 0; // initialize var to track total num of affected rows
  590. if (!$this->alreadyInSave) {
  591. $this->alreadyInSave = true;
  592. // We call the save method on the following object(s) if they
  593. // were passed to this object by their coresponding set
  594. // method. This object relates to these object(s) by a
  595. // foreign key reference.
  596. if ($this->aKataoSupplierInvoice !== null) {
  597. if ($this->aKataoSupplierInvoice->isModified()) {
  598. $affectedRows += $this->aKataoSupplierInvoice->save($con);
  599. }
  600. $this->setKataoSupplierInvoice($this->aKataoSupplierInvoice);
  601. }
  602. if ($this->aKataoProduct !== null) {
  603. if ($this->aKataoProduct->isModified()) {
  604. $affectedRows += $this->aKataoProduct->save($con);
  605. }
  606. $this->setKataoProduct($this->aKataoProduct);
  607. }
  608. // If this object has been modified, then save it to the database.
  609. if ($this->isModified()) {
  610. if ($this->isNew()) {
  611. $pk = KataoSupplierInvoiceProductPeer::doInsert($this, $con);
  612. $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
  613. // should always be true here (even though technically
  614. // BasePeer::doInsert() can insert multiple rows).
  615. $this->setId($pk); //[IMV] update autoincrement primary key
  616. $this->setNew(false);
  617. } else {
  618. $affectedRows += KataoSupplierInvoiceProductPeer::doUpdate($this, $con);
  619. }
  620. $this->resetModified(); // [HL] After being saved an object is no longer 'modified'
  621. }
  622. $this->alreadyInSave = false;
  623. }
  624. return $affectedRows;
  625. } // doSave()
  626. /**
  627. * Array of ValidationFailed objects.
  628. * @var array ValidationFailed[]
  629. */
  630. protected $validationFailures = array();
  631. /**
  632. * Gets any ValidationFailed objects that resulted from last call to validate().
  633. *
  634. *
  635. * @return array ValidationFailed[]
  636. * @see validate()
  637. */
  638. public function getValidationFailures()
  639. {
  640. return $this->validationFailures;
  641. }
  642. /**
  643. * Validates the objects modified field values and all objects related to this table.
  644. *
  645. * If $columns is either a column name or an array of column names
  646. * only those columns are validated.
  647. *
  648. * @param mixed $columns Column name or an array of column names.
  649. * @return boolean Whether all columns pass validation.
  650. * @see doValidate()
  651. * @see getValidationFailures()
  652. */
  653. public function validate($columns = null)
  654. {
  655. $res = $this->doValidate($columns);
  656. if ($res === true) {
  657. $this->validationFailures = array();
  658. return true;
  659. } else {
  660. $this->validationFailures = $res;
  661. return false;
  662. }
  663. }
  664. /**
  665. * This function performs the validation work for complex object models.
  666. *
  667. * In addition to checking the current object, all related objects will
  668. * also be validated. If all pass then <code>true</code> is returned; otherwise
  669. * an aggreagated array of ValidationFailed objects will be returned.
  670. *
  671. * @param array $columns Array of column names to validate.
  672. * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  673. */
  674. protected function doValidate($columns = null)
  675. {
  676. if (!$this->alreadyInValidation) {
  677. $this->alreadyInValidation = true;
  678. $retval = null;
  679. $failureMap = array();
  680. // We call the validate method on the following object(s) if they
  681. // were passed to this object by their coresponding set
  682. // method. This object relates to these object(s) by a
  683. // foreign key reference.
  684. if ($this->aKataoSupplierInvoice !== null) {
  685. if (!$this->aKataoSupplierInvoice->validate($columns)) {
  686. $failureMap = array_merge($failureMap, $this->aKataoSupplierInvoice->getValidationFailures());
  687. }
  688. }
  689. if ($this->aKataoProduct !== null) {
  690. if (!$this->aKataoProduct->validate($columns)) {
  691. $failureMap = array_merge($failureMap, $this->aKataoProduct->getValidationFailures());
  692. }
  693. }
  694. if (($retval = KataoSupplierInvoiceProductPeer::doValidate($this, $columns)) !== true) {
  695. $failureMap = array_merge($failureMap, $retval);
  696. }
  697. $this->alreadyInValidation = false;
  698. }
  699. return (!empty($failureMap) ? $failureMap : true);
  700. }
  701. /**
  702. * Retrieves a field from the object by name passed in as a string.
  703. *
  704. * @param string $name name
  705. * @param string $type The type of fieldname the $name is of:
  706. * one of the class type constants TYPE_PHPNAME,
  707. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  708. * @return mixed Value of field.
  709. */
  710. public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
  711. {
  712. $pos = KataoSupplierInvoiceProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  713. return $this->getByPosition($pos);
  714. }
  715. /**
  716. * Retrieves a field from the object by Position as specified in the xml schema.
  717. * Zero-based.
  718. *
  719. * @param int $pos position in xml schema
  720. * @return mixed Value of field at $pos
  721. */
  722. public function getByPosition($pos)
  723. {
  724. switch($pos) {
  725. case 0:
  726. return $this->getId();
  727. break;
  728. case 1:
  729. return $this->getKataoSupplierInvoiceId();
  730. break;
  731. case 2:
  732. return $this->getKataoProductId();
  733. break;
  734. case 3:
  735. return $this->getProductReference();
  736. break;
  737. case 4:
  738. return $this->getProductName();
  739. break;
  740. case 5:
  741. return $this->getProductPriceEuro();
  742. break;
  743. case 6:
  744. return $this->getProductMargin();
  745. break;
  746. case 7:
  747. return $this->getProductTvaRate();
  748. break;
  749. case 8:
  750. return $this->getQuantity();
  751. break;
  752. case 9:
  753. return $this->getProductPriceTotal();
  754. break;
  755. case 10:
  756. return $this->getCreatedAt();
  757. break;
  758. case 11:
  759. return $this->getUpdatedAt();
  760. break;
  761. default:
  762. return null;
  763. break;
  764. } // switch()
  765. }
  766. /**
  767. * Exports the object as an array.
  768. *
  769. * You can specify the key type of the array by passing one of the class
  770. * type constants.
  771. *
  772. * @param string $keyType One of the class type constants TYPE_PHPNAME,
  773. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  774. * @return an associative array containing the field names (as keys) and field values
  775. */
  776. public function toArray($keyType = BasePeer::TYPE_PHPNAME)
  777. {
  778. $keys = KataoSupplierInvoiceProductPeer::getFieldNames($keyType);
  779. $result = array(
  780. $keys[0] => $this->getId(),
  781. $keys[1] => $this->getKataoSupplierInvoiceId(),
  782. $keys[2] => $this->getKataoProductId(),
  783. $keys[3] => $this->getProductReference(),
  784. $keys[4] => $this->getProductName(),
  785. $keys[5] => $this->getProductPriceEuro(),
  786. $keys[6] => $this->getProductMargin(),
  787. $keys[7] => $this->getProductTvaRate(),
  788. $keys[8] => $this->getQuantity(),
  789. $keys[9] => $this->getProductPriceTotal(),
  790. $keys[10] => $this->getCreatedAt(),
  791. $keys[11] => $this->getUpdatedAt(),
  792. );
  793. return $result;
  794. }
  795. /**
  796. * Sets a field from the object by name passed in as a string.
  797. *
  798. * @param string $name peer name
  799. * @param mixed $value field value
  800. * @param string $type The type of fieldname the $name is of:
  801. * one of the class type constants TYPE_PHPNAME,
  802. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  803. * @return void
  804. */
  805. public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
  806. {
  807. $pos = KataoSupplierInvoiceProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  808. return $this->setByPosition($pos, $value);
  809. }
  810. /**
  811. * Sets a field from the object by Position as specified in the xml schema.
  812. * Zero-based.
  813. *
  814. * @param int $pos position in xml schema
  815. * @param mixed $value field value
  816. * @return void
  817. */
  818. public function setByPosition($pos, $value)
  819. {
  820. switch($pos) {
  821. case 0:
  822. $this->setId($value);
  823. break;
  824. case 1:
  825. $this->setKataoSupplierInvoiceId($value);
  826. break;
  827. case 2:
  828. $this->setKataoProductId($value);
  829. break;
  830. case 3:
  831. $this->setProductReference($value);
  832. break;
  833. case 4:
  834. $this->setProductName($value);
  835. break;
  836. case 5:
  837. $this->setProductPriceEuro($value);
  838. break;
  839. case 6:
  840. $this->setProductMargin($value);
  841. break;
  842. case 7:
  843. $this->setProductTvaRate($value);
  844. break;
  845. case 8:
  846. $this->setQuantity($value);
  847. break;
  848. case 9:
  849. $this->setProductPriceTotal($value);
  850. break;
  851. case 10:
  852. $this->setCreatedAt($value);
  853. break;
  854. case 11:
  855. $this->setUpdatedAt($value);
  856. break;
  857. } // switch()
  858. }
  859. /**
  860. * Populates the object using an array.
  861. *
  862. * This is particularly useful when populating an object from one of the
  863. * request arrays (e.g. $_POST). This method goes through the column
  864. * names, checking to see whether a matching key exists in populated
  865. * array. If so the setByName() method is called for that column.
  866. *
  867. * You can specify the key type of the array by additionally passing one
  868. * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
  869. * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
  870. *
  871. * @param array $arr An array to populate the object from.
  872. * @param string $keyType The type of keys the array uses.
  873. * @return void
  874. */
  875. public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
  876. {
  877. $keys = KataoSupplierInvoiceProductPeer::getFieldNames($keyType);
  878. if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
  879. if (array_key_exists($keys[1], $arr)) $this->setKataoSupplierInvoiceId($arr[$keys[1]]);
  880. if (array_key_exists($keys[2], $arr)) $this->setKataoProductId($arr[$keys[2]]);
  881. if (array_key_exists($keys[3], $arr)) $this->setProductReference($arr[$keys[3]]);
  882. if (array_key_exists($keys[4], $arr)) $this->setProductName($arr[$keys[4]]);
  883. if (array_key_exists($keys[5], $arr)) $this->setProductPriceEuro($arr[$keys[5]]);
  884. if (array_key_exists($keys[6], $arr)) $this->setProductMargin($arr[$keys[6]]);
  885. if (array_key_exists($keys[7], $arr)) $this->setProductTvaRate($arr[$keys[7]]);
  886. if (array_key_exists($keys[8], $arr)) $this->setQuantity($arr[$keys[8]]);
  887. if (array_key_exists($keys[9], $arr)) $this->setProductPriceTotal($arr[$keys[9]]);
  888. if (array_key_exists($keys[10], $arr)) $this->setCreatedAt($arr[$keys[10]]);
  889. if (array_key_exists($keys[11], $arr)) $this->setUpdatedAt($arr[$keys[11]]);
  890. }
  891. /**
  892. * Build a Criteria object containing the values of all modified columns in this object.
  893. *
  894. * @return Criteria The Criteria object containing all modified values.
  895. */
  896. public function buildCriteria()
  897. {
  898. $criteria = new Criteria(KataoSupplierInvoiceProductPeer::DATABASE_NAME);
  899. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::ID)) $criteria->add(KataoSupplierInvoiceProductPeer::ID, $this->id);
  900. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::KATAO_SUPPLIER_INVOICE_ID)) $criteria->add(KataoSupplierInvoiceProductPeer::KATAO_SUPPLIER_INVOICE_ID, $this->katao_supplier_invoice_id);
  901. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::KATAO_PRODUCT_ID)) $criteria->add(KataoSupplierInvoiceProductPeer::KATAO_PRODUCT_ID, $this->katao_product_id);
  902. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::PRODUCT_REFERENCE)) $criteria->add(KataoSupplierInvoiceProductPeer::PRODUCT_REFERENCE, $this->product_reference);
  903. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::PRODUCT_NAME)) $criteria->add(KataoSupplierInvoiceProductPeer::PRODUCT_NAME, $this->product_name);
  904. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::PRODUCT_PRICE_EURO)) $criteria->add(KataoSupplierInvoiceProductPeer::PRODUCT_PRICE_EURO, $this->product_price_euro);
  905. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::PRODUCT_MARGIN)) $criteria->add(KataoSupplierInvoiceProductPeer::PRODUCT_MARGIN, $this->product_margin);
  906. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::PRODUCT_TVA_RATE)) $criteria->add(KataoSupplierInvoiceProductPeer::PRODUCT_TVA_RATE, $this->product_tva_rate);
  907. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::QUANTITY)) $criteria->add(KataoSupplierInvoiceProductPeer::QUANTITY, $this->quantity);
  908. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::PRODUCT_PRICE_TOTAL)) $criteria->add(KataoSupplierInvoiceProductPeer::PRODUCT_PRICE_TOTAL, $this->product_price_total);
  909. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::CREATED_AT)) $criteria->add(KataoSupplierInvoiceProductPeer::CREATED_AT, $this->created_at);
  910. if ($this->isColumnModified(KataoSupplierInvoiceProductPeer::UPDATED_AT)) $criteria->add(KataoSupplierInvoiceProductPeer::UPDATED_AT, $this->updated_at);
  911. return $criteria;
  912. }
  913. /**
  914. * Builds a Criteria object containing the primary key for this object.
  915. *
  916. * Unlike buildCriteria() this method includes the primary key values regardless
  917. * of whether or not they have been modified.
  918. *
  919. * @return Criteria The Criteria object containing value(s) for primary key(s).
  920. */
  921. public function buildPkeyCriteria()
  922. {
  923. $criteria = new Criteria(KataoSupplierInvoiceProductPeer::DATABASE_NAME);
  924. $criteria->add(KataoSupplierInvoiceProductPeer::ID, $this->id);
  925. return $criteria;
  926. }
  927. /**
  928. * Returns the primary key for this object (row).
  929. * @return int
  930. */
  931. public function getPrimaryKey()
  932. {
  933. return $this->getId();
  934. }
  935. /**
  936. * Generic method to set the primary key (id column).
  937. *
  938. * @param int $key Primary key.
  939. * @return void
  940. */
  941. public function setPrimaryKey($key)
  942. {
  943. $this->setId($key);
  944. }
  945. /**
  946. * Sets contents of passed object to values from current object.
  947. *
  948. * If desired, this method can also make copies of all associated (fkey referrers)
  949. * objects.
  950. *
  951. * @param object $copyObj An object of KataoSupplierInvoiceProduct (or compatible) type.
  952. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  953. * @throws PropelException
  954. */
  955. public function copyInto($copyObj, $deepCopy = false)
  956. {
  957. $copyObj->setKataoSupplierInvoiceId($this->katao_supplier_invoice_id);
  958. $copyObj->setKataoProductId($this->katao_product_id);
  959. $copyObj->setProductReference($this->product_reference);
  960. $copyObj->setProductName($this->product_name);
  961. $copyObj->setProductPriceEuro($this->product_price_euro);
  962. $copyObj->setProductMargin($this->product_margin);
  963. $copyObj->setProductTvaRate($this->product_tva_rate);
  964. $copyObj->setQuantity($this->quantity);
  965. $copyObj->setProductPriceTotal($this->product_price_total);
  966. $copyObj->setCreatedAt($this->created_at);
  967. $copyObj->setUpdatedAt($this->updated_at);
  968. $copyObj->setNew(true);
  969. $copyObj->setId(NULL); // this is a pkey column, so set to default value
  970. }
  971. /**
  972. * Makes a copy of this object that will be inserted as a new row in table when saved.
  973. * It creates a new object filling in the simple attributes, but skipping any primary
  974. * keys that are defined for the table.
  975. *
  976. * If desired, this method can also make copies of all associated (fkey referrers)
  977. * objects.
  978. *
  979. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  980. * @return KataoSupplierInvoiceProduct Clone of current object.
  981. * @throws PropelException
  982. */
  983. public function copy($deepCopy = false)
  984. {
  985. // we use get_class(), because this might be a subclass
  986. $clazz = get_class($this);
  987. $copyObj = new $clazz();
  988. $this->copyInto($copyObj, $deepCopy);
  989. return $copyObj;
  990. }
  991. /**
  992. * Returns a peer instance associated with this om.
  993. *
  994. * Since Peer classes are not to have any instance attributes, this method returns the
  995. * same instance for all member of this class. The method could therefore
  996. * be static, but this would prevent one from overriding the behavior.
  997. *
  998. * @return KataoSupplierInvoiceProductPeer
  999. */
  1000. public function getPeer()
  1001. {
  1002. if (self::$peer === null) {
  1003. self::$peer = new KataoSupplierInvoiceProductPeer();
  1004. }
  1005. return self::$peer;
  1006. }
  1007. /**
  1008. * Declares an association between this object and a KataoSupplierInvoice object.
  1009. *
  1010. * @param KataoSupplierInvoice $v
  1011. * @return void
  1012. * @throws PropelException
  1013. */
  1014. public function setKataoSupplierInvoice($v)
  1015. {
  1016. if ($v === null) {
  1017. $this->setKataoSupplierInvoiceId(NULL);
  1018. } else {
  1019. $this->setKataoSupplierInvoiceId($v->getId());
  1020. }
  1021. $this->aKataoSupplierInvoice = $v;
  1022. }
  1023. /**
  1024. * Get the associated KataoSupplierInvoice object
  1025. *
  1026. * @param Connection Optional Connection object.
  1027. * @return KataoSupplierInvoice The associated KataoSupplierInvoice object.
  1028. * @throws PropelException
  1029. */
  1030. public function getKataoSupplierInvoice($con = null)
  1031. {
  1032. if ($this->aKataoSupplierInvoice === null && ($this->katao_supplier_invoice_id !== null)) {
  1033. // include the related Peer class
  1034. $this->aKataoSupplierInvoice = KataoSupplierInvoicePeer::retrieveByPK($this->katao_supplier_invoice_id, $con);
  1035. /* The following can be used instead of the line above to
  1036. guarantee the related object contains a reference
  1037. to this object, but this level of coupling
  1038. may be undesirable in many circumstances.
  1039. As it can lead to a db query with many results that may
  1040. never be used.
  1041. $obj = KataoSupplierInvoicePeer::retrieveByPK($this->katao_supplier_invoice_id, $con);
  1042. $obj->addKataoSupplierInvoices($this);
  1043. */
  1044. }
  1045. return $this->aKataoSupplierInvoice;
  1046. }
  1047. /**
  1048. * Declares an association between this object and a KataoProduct object.
  1049. *
  1050. * @param KataoProduct $v
  1051. * @return void
  1052. * @throws PropelException
  1053. */
  1054. public function setKataoProduct($v)
  1055. {
  1056. if ($v === null) {
  1057. $this->setKataoProductId(NULL);
  1058. } else {
  1059. $this->setKataoProductId($v->getId());
  1060. }
  1061. $this->aKataoProduct = $v;
  1062. }
  1063. /**
  1064. * Get the associated KataoProduct object
  1065. *
  1066. * @param Connection Optional Connection object.
  1067. * @return KataoProduct The associated KataoProduct object.
  1068. * @throws PropelException
  1069. */
  1070. public function getKataoProduct($con = null)
  1071. {
  1072. if ($this->aKataoProduct === null && ($this->katao_product_id !== null)) {
  1073. // include the related Peer class
  1074. $this->aKataoProduct = KataoProductPeer::retrieveByPK($this->katao_product_id, $con);
  1075. /* The following can be used instead of the line above to
  1076. guarantee the related object contains a reference
  1077. to this object, but this level of coupling
  1078. may be undesirable in many circumstances.
  1079. As it can lead to a db query with many results that may
  1080. never be used.
  1081. $obj = KataoProductPeer::retrieveByPK($this->katao_product_id, $con);
  1082. $obj->addKataoProducts($this);
  1083. */
  1084. }
  1085. return $this->aKataoProduct;
  1086. }
  1087. public function __call($method, $arguments)
  1088. {
  1089. if (!$callable = sfMixer::getCallable('BaseKataoSupplierInvoiceProduct:'.$method))
  1090. {
  1091. throw new sfException(sprintf('Call to undefined method BaseKataoSupplierInvoiceProduct::%s', $method));
  1092. }
  1093. array_unshift($arguments, $this);
  1094. return call_user_func_array($callable, $arguments);
  1095. }
  1096. } // BaseKataoSupplierInvoiceProduct