fournisseur.commande.dispatch.class.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. <?php
  2. /* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file fourn/class/fournisseur.commande.dispatch.class.php
  20. * \ingroup fournisseur stock
  21. * \brief This file is an example for a CRUD class file (Create/Read/Update/Delete)
  22. * Initialy built by build_class_from_table on 2015-02-24 10:38
  23. */
  24. // Put here all includes required by your class file
  25. require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php";
  26. //require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
  27. //require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
  28. /**
  29. * Class to manage table commandefournisseurdispatch
  30. */
  31. class CommandeFournisseurDispatch extends CommonObject
  32. {
  33. /**
  34. * @var DoliDB Database handler.
  35. */
  36. public $db;
  37. /**
  38. * @var string Error code (or message)
  39. */
  40. public $error;
  41. /**
  42. * @var string[] Error codes (or messages)
  43. */
  44. public $errors = array();
  45. /**
  46. * @var string ID to identify managed object
  47. */
  48. public $element='commandefournisseurdispatch';
  49. /**
  50. * @var string Name of table without prefix where object is stored
  51. */
  52. public $table_element='commande_fournisseur_dispatch'; //!< Name of table without prefix where object is stored
  53. public $lines=array();
  54. /**
  55. * @var int ID
  56. */
  57. public $id;
  58. public $fk_commande;
  59. public $fk_product;
  60. public $fk_commandefourndet;
  61. public $qty;
  62. public $fk_entrepot;
  63. /**
  64. * @var int User ID
  65. */
  66. public $fk_user;
  67. public $datec='';
  68. public $comment;
  69. public $status;
  70. public $tms='';
  71. public $batch;
  72. public $eatby='';
  73. public $sellby='';
  74. /**
  75. * Constructor
  76. *
  77. * @param DoliDb $db Database handler
  78. */
  79. function __construct($db)
  80. {
  81. $this->db = $db;
  82. // List of language codes for status
  83. $this->statuts[0] = 'Received';
  84. $this->statuts[1] = 'Verified';
  85. $this->statuts[2] = 'Denied';
  86. $this->statutshort[0] = 'Received';
  87. $this->statutshort[1] = 'Verified';
  88. $this->statutshort[2] = 'Denied';
  89. }
  90. /**
  91. * Create object into database
  92. *
  93. * @param User $user User that creates
  94. * @param int $notrigger 0=launch triggers after, 1=disable triggers
  95. * @return int <0 if KO, Id of created object if OK
  96. */
  97. function create($user, $notrigger=0)
  98. {
  99. global $conf, $langs;
  100. $error=0;
  101. // Clean parameters
  102. if (isset($this->fk_commande)) $this->fk_commande=trim($this->fk_commande);
  103. if (isset($this->fk_product)) $this->fk_product=trim($this->fk_product);
  104. if (isset($this->fk_commandefourndet)) $this->fk_commandefourndet=trim($this->fk_commandefourndet);
  105. if (isset($this->qty)) $this->qty=trim($this->qty);
  106. if (isset($this->fk_entrepot)) $this->fk_entrepot=trim($this->fk_entrepot);
  107. if (isset($this->fk_user)) $this->fk_user=trim($this->fk_user);
  108. if (isset($this->comment)) $this->comment=trim($this->comment);
  109. if (isset($this->status)) $this->status=trim($this->status);
  110. if (isset($this->batch)) $this->batch=trim($this->batch);
  111. // Check parameters
  112. // Put here code to add control on parameters values
  113. // Insert request
  114. $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."(";
  115. $sql.= "fk_commande,";
  116. $sql.= "fk_product,";
  117. $sql.= "fk_commandefourndet,";
  118. $sql.= "qty,";
  119. $sql.= "fk_entrepot,";
  120. $sql.= "fk_user,";
  121. $sql.= "datec,";
  122. $sql.= "comment,";
  123. $sql.= "status,";
  124. $sql.= "batch,";
  125. $sql.= "eatby,";
  126. $sql.= "sellby";
  127. $sql.= ") VALUES (";
  128. $sql.= " ".(! isset($this->fk_commande)?'NULL':"'".$this->db->escape($this->fk_commande)."'").",";
  129. $sql.= " ".(! isset($this->fk_product)?'NULL':"'".$this->db->escape($this->fk_product)."'").",";
  130. $sql.= " ".(! isset($this->fk_commandefourndet)?'NULL':"'".$this->db->escape($this->fk_commandefourndet)."'").",";
  131. $sql.= " ".(! isset($this->qty)?'NULL':"'".$this->db->escape($this->qty)."'").",";
  132. $sql.= " ".(! isset($this->fk_entrepot)?'NULL':"'".$this->db->escape($this->fk_entrepot)."'").",";
  133. $sql.= " ".(! isset($this->fk_user)?'NULL':"'".$this->db->escape($this->fk_user)."'").",";
  134. $sql.= " ".(! isset($this->datec) || dol_strlen($this->datec)==0?'NULL':"'".$this->db->idate($this->datec)."'").",";
  135. $sql.= " ".(! isset($this->comment)?'NULL':"'".$this->db->escape($this->comment)."'").",";
  136. $sql.= " ".(! isset($this->status)?'NULL':"'".$this->db->escape($this->status)."'").",";
  137. $sql.= " ".(! isset($this->batch)?'NULL':"'".$this->db->escape($this->batch)."'").",";
  138. $sql.= " ".(! isset($this->eatby) || dol_strlen($this->eatby)==0?'NULL':"'".$this->db->idate($this->eatby)."'").",";
  139. $sql.= " ".(! isset($this->sellby) || dol_strlen($this->sellby)==0?'NULL':"'".$this->db->idate($this->sellby)."'")."";
  140. $sql.= ")";
  141. $this->db->begin();
  142. dol_syslog(__METHOD__, LOG_DEBUG);
  143. $resql=$this->db->query($sql);
  144. if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
  145. if (! $error)
  146. {
  147. $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
  148. if (! $notrigger)
  149. {
  150. // Uncomment this and change MYOBJECT to your own tag if you
  151. // want this action calls a trigger.
  152. //// Call triggers
  153. //$result=$this->call_trigger('MYOBJECT_CREATE',$user);
  154. //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
  155. //// End call triggers
  156. }
  157. }
  158. // Commit or rollback
  159. if ($error)
  160. {
  161. foreach($this->errors as $errmsg)
  162. {
  163. dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
  164. $this->error.=($this->error?', '.$errmsg:$errmsg);
  165. }
  166. $this->db->rollback();
  167. return -1*$error;
  168. }
  169. else
  170. {
  171. $this->db->commit();
  172. return $this->id;
  173. }
  174. }
  175. /**
  176. * Load object in memory from the database
  177. *
  178. * @param int $id Id object
  179. * @param string $ref Ref
  180. * @return int <0 if KO, >0 if OK
  181. */
  182. function fetch($id,$ref='')
  183. {
  184. global $langs;
  185. $sql = "SELECT";
  186. $sql.= " t.rowid,";
  187. $sql.= " t.fk_commande,";
  188. $sql.= " t.fk_product,";
  189. $sql.= " t.fk_commandefourndet,";
  190. $sql.= " t.qty,";
  191. $sql.= " t.fk_entrepot,";
  192. $sql.= " t.fk_user,";
  193. $sql.= " t.datec,";
  194. $sql.= " t.comment,";
  195. $sql.= " t.status,";
  196. $sql.= " t.tms,";
  197. $sql.= " t.batch,";
  198. $sql.= " t.eatby,";
  199. $sql.= " t.sellby";
  200. $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
  201. if ($ref) $sql.= " WHERE t.ref = '".$ref."'";
  202. else $sql.= " WHERE t.rowid = ".$id;
  203. dol_syslog(get_class($this)."::fetch");
  204. $resql=$this->db->query($sql);
  205. if ($resql)
  206. {
  207. if ($this->db->num_rows($resql))
  208. {
  209. $obj = $this->db->fetch_object($resql);
  210. $this->id = $obj->rowid;
  211. $this->fk_commande = $obj->fk_commande;
  212. $this->fk_product = $obj->fk_product;
  213. $this->fk_commandefourndet = $obj->fk_commandefourndet;
  214. $this->qty = $obj->qty;
  215. $this->fk_entrepot = $obj->fk_entrepot;
  216. $this->fk_user = $obj->fk_user;
  217. $this->datec = $this->db->jdate($obj->datec);
  218. $this->comment = $obj->comment;
  219. $this->status = $obj->status;
  220. $this->tms = $this->db->jdate($obj->tms);
  221. $this->batch = $obj->batch;
  222. $this->eatby = $this->db->jdate($obj->eatby);
  223. $this->sellby = $this->db->jdate($obj->sellby);
  224. }
  225. $this->db->free($resql);
  226. return 1;
  227. }
  228. else
  229. {
  230. $this->error="Error ".$this->db->lasterror();
  231. return -1;
  232. }
  233. }
  234. /**
  235. * Update object into database
  236. *
  237. * @param User $user User that modifies
  238. * @param int $notrigger 0=launch triggers after, 1=disable triggers
  239. * @return int <0 if KO, >0 if OK
  240. */
  241. function update($user, $notrigger=0)
  242. {
  243. global $conf, $langs;
  244. $error=0;
  245. // Clean parameters
  246. if (isset($this->fk_commande)) $this->fk_commande=trim($this->fk_commande);
  247. if (isset($this->fk_product)) $this->fk_product=trim($this->fk_product);
  248. if (isset($this->fk_commandefourndet)) $this->fk_commandefourndet=trim($this->fk_commandefourndet);
  249. if (isset($this->qty)) $this->qty=trim($this->qty);
  250. if (isset($this->fk_entrepot)) $this->fk_entrepot=trim($this->fk_entrepot);
  251. if (isset($this->fk_user)) $this->fk_user=trim($this->fk_user);
  252. if (isset($this->comment)) $this->comment=trim($this->comment);
  253. if (isset($this->status)) $this->status=trim($this->status);
  254. if (isset($this->batch)) $this->batch=trim($this->batch);
  255. // Check parameters
  256. // Put here code to add a control on parameters values
  257. // Update request
  258. $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
  259. $sql.= " fk_commande=".(isset($this->fk_commande)?$this->fk_commande:"null").",";
  260. $sql.= " fk_product=".(isset($this->fk_product)?$this->fk_product:"null").",";
  261. $sql.= " fk_commandefourndet=".(isset($this->fk_commandefourndet)?$this->fk_commandefourndet:"null").",";
  262. $sql.= " qty=".(isset($this->qty)?$this->qty:"null").",";
  263. $sql.= " fk_entrepot=".(isset($this->fk_entrepot)?$this->fk_entrepot:"null").",";
  264. $sql.= " fk_user=".(isset($this->fk_user)?$this->fk_user:"null").",";
  265. $sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
  266. $sql.= " comment=".(isset($this->comment)?"'".$this->db->escape($this->comment)."'":"null").",";
  267. $sql.= " status=".(isset($this->status)?$this->status:"null").",";
  268. $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
  269. $sql.= " batch=".(isset($this->batch)?"'".$this->db->escape($this->batch)."'":"null").",";
  270. $sql.= " eatby=".(dol_strlen($this->eatby)!=0 ? "'".$this->db->idate($this->eatby)."'" : 'null').",";
  271. $sql.= " sellby=".(dol_strlen($this->sellby)!=0 ? "'".$this->db->idate($this->sellby)."'" : 'null')."";
  272. $sql.= " WHERE rowid=".$this->id;
  273. $this->db->begin();
  274. dol_syslog(__METHOD__);
  275. $resql = $this->db->query($sql);
  276. if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
  277. if (! $error)
  278. {
  279. if (! $notrigger)
  280. {
  281. // Uncomment this and change MYOBJECT to your own tag if you
  282. // want this action calls a trigger.
  283. //// Call triggers
  284. //$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
  285. //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
  286. //// End call triggers
  287. }
  288. }
  289. // Commit or rollback
  290. if ($error)
  291. {
  292. foreach($this->errors as $errmsg)
  293. {
  294. dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
  295. $this->error.=($this->error?', '.$errmsg:$errmsg);
  296. }
  297. $this->db->rollback();
  298. return -1*$error;
  299. }
  300. else
  301. {
  302. $this->db->commit();
  303. return 1;
  304. }
  305. }
  306. /**
  307. * Delete object in database
  308. *
  309. * @param User $user User that deletes
  310. * @param int $notrigger 0=launch triggers after, 1=disable triggers
  311. * @return int <0 if KO, >0 if OK
  312. */
  313. function delete($user, $notrigger=0)
  314. {
  315. global $conf, $langs;
  316. $error=0;
  317. $this->db->begin();
  318. if (! $error)
  319. {
  320. if (! $notrigger)
  321. {
  322. // Uncomment this and change MYOBJECT to your own tag if you
  323. // want this action calls a trigger.
  324. //// Call triggers
  325. //$result=$this->call_trigger('MYOBJECT_DELETE',$user);
  326. //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
  327. //// End call triggers
  328. }
  329. }
  330. if (! $error)
  331. {
  332. $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
  333. $sql.= " WHERE rowid=".$this->id;
  334. dol_syslog(__METHOD__);
  335. $resql = $this->db->query($sql);
  336. if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
  337. }
  338. // Commit or rollback
  339. if ($error)
  340. {
  341. foreach($this->errors as $errmsg)
  342. {
  343. dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
  344. $this->error.=($this->error?', '.$errmsg:$errmsg);
  345. }
  346. $this->db->rollback();
  347. return -1*$error;
  348. }
  349. else
  350. {
  351. $this->db->commit();
  352. return 1;
  353. }
  354. }
  355. /**
  356. * Load an object from its id and create a new one in database
  357. *
  358. * @param int $fromid Id of object to clone
  359. * @return int New id of clone
  360. */
  361. function createFromClone($fromid)
  362. {
  363. global $user,$langs;
  364. $error=0;
  365. $object=new Commandefournisseurdispatch($this->db);
  366. $this->db->begin();
  367. // Load source object
  368. $object->fetch($fromid);
  369. $object->id=0;
  370. $object->statut=0;
  371. // Clear fields
  372. // ...
  373. // Create clone
  374. $result=$object->create($user);
  375. // Other options
  376. if ($result < 0)
  377. {
  378. $this->error=$object->error;
  379. $error++;
  380. }
  381. if (! $error)
  382. {
  383. }
  384. // End
  385. if (! $error)
  386. {
  387. $this->db->commit();
  388. return $object->id;
  389. }
  390. else
  391. {
  392. $this->db->rollback();
  393. return -1;
  394. }
  395. }
  396. /**
  397. * Return label of the status of object
  398. *
  399. * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto
  400. * @return string Label
  401. */
  402. function getLibStatut($mode=0)
  403. {
  404. return $this->LibStatut($this->status,$mode);
  405. }
  406. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
  407. /**
  408. * Return label of a status
  409. *
  410. * @param int $statut Id statut
  411. * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto
  412. * @return string Label of status
  413. */
  414. function LibStatut($statut,$mode=0)
  415. {
  416. // phpcs:enable
  417. global $langs;
  418. $langs->load('orders');
  419. if ($mode == 0)
  420. {
  421. return $langs->trans($this->statuts[$statut]);
  422. }
  423. elseif ($mode == 1)
  424. {
  425. return $langs->trans($this->statutshort[$statut]);
  426. }
  427. elseif ($mode == 2)
  428. {
  429. return $langs->trans($this->statuts[$statut]);
  430. }
  431. elseif ($mode == 3)
  432. {
  433. if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0');
  434. if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4');
  435. if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut8');
  436. }
  437. elseif ($mode == 4)
  438. {
  439. if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]);
  440. if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]);
  441. if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut8').' '.$langs->trans($this->statuts[$statut]);
  442. }
  443. elseif ($mode == 5)
  444. {
  445. if ($statut==0) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut0');
  446. if ($statut==1) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut4');
  447. if ($statut==2) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut8');
  448. }
  449. }
  450. /**
  451. * Initialise object with example values
  452. * Id must be 0 if object instance is a specimen
  453. *
  454. * @return void
  455. */
  456. function initAsSpecimen()
  457. {
  458. $this->id=0;
  459. $this->fk_commande='';
  460. $this->fk_product='';
  461. $this->fk_commandefourndet='';
  462. $this->qty='';
  463. $this->fk_entrepot='';
  464. $this->fk_user='';
  465. $this->datec='';
  466. $this->comment='';
  467. $this->status='';
  468. $this->tms='';
  469. $this->batch='';
  470. $this->eatby='';
  471. $this->sellby='';
  472. }
  473. /**
  474. * Load object in memory from the database
  475. *
  476. * @param string $sortorder Sort Order
  477. * @param string $sortfield Sort field
  478. * @param int $limit offset limit
  479. * @param int $offset offset limit
  480. * @param array $filter filter array
  481. * @param string $filtermode filter mode (AND or OR)
  482. *
  483. * @return int <0 if KO, >0 if OK
  484. */
  485. public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
  486. {
  487. dol_syslog(__METHOD__, LOG_DEBUG);
  488. $sql = "SELECT";
  489. $sql.= " t.rowid,";
  490. $sql.= " t.fk_commande,";
  491. $sql.= " t.fk_product,";
  492. $sql.= " t.fk_commandefourndet,";
  493. $sql.= " t.qty,";
  494. $sql.= " t.fk_entrepot,";
  495. $sql.= " t.fk_user,";
  496. $sql.= " t.datec,";
  497. $sql.= " t.comment,";
  498. $sql.= " t.status,";
  499. $sql.= " t.tms,";
  500. $sql.= " t.batch,";
  501. $sql.= " t.eatby,";
  502. $sql.= " t.sellby";
  503. $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
  504. // Manage filter
  505. $sqlwhere = array();
  506. if (count($filter) > 0) {
  507. foreach ($filter as $key => $value) {
  508. if ($key=='t.comment') {
  509. $sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
  510. } elseif ($key=='t.datec' || $key=='t.tms' || $key=='t.eatby' || $key=='t.sellby' || $key=='t.batch') {
  511. $sqlwhere [] = $key . ' = \'' . $this->db->escape($value) . '\'';
  512. } else {
  513. $sqlwhere [] = $key . ' = ' . $this->db->escape($value);
  514. }
  515. }
  516. }
  517. if (count($sqlwhere) > 0) {
  518. $sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere);
  519. }
  520. if (!empty($sortfield)) {
  521. $sql .= $this->db->order($sortfield,$sortorder);
  522. }
  523. if (!empty($limit)) {
  524. $sql .= ' ' . $this->db->plimit($limit, $offset);
  525. }
  526. $this->lines = array();
  527. $resql = $this->db->query($sql);
  528. if ($resql) {
  529. $num = $this->db->num_rows($resql);
  530. while ($obj = $this->db->fetch_object($resql)) {
  531. $line = new self($this->db);
  532. $line->id = $obj->rowid;
  533. $line->fk_commande = $obj->fk_commande;
  534. $line->fk_product = $obj->fk_product;
  535. $line->fk_commandefourndet = $obj->fk_commandefourndet;
  536. $line->qty = $obj->qty;
  537. $line->fk_entrepot = $obj->fk_entrepot;
  538. $line->fk_user = $obj->fk_user;
  539. $line->datec = $this->db->jdate($obj->datec);
  540. $line->comment = $obj->comment;
  541. $line->status = $obj->status;
  542. $line->tms = $this->db->jdate($obj->tms);
  543. $line->batch = $obj->batch;
  544. $line->eatby = $this->db->jdate($obj->eatby);
  545. $line->sellby = $this->db->jdate($obj->sellby);
  546. $this->lines[$line->id] = $line;
  547. }
  548. $this->db->free($resql);
  549. return $num;
  550. } else {
  551. $this->errors[] = 'Error ' . $this->db->lasterror();
  552. dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
  553. return - 1;
  554. }
  555. }
  556. }