paymentvarious.class.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. <?php
  2. /* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
  3. * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
  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 htdocs/compta/bank/class/paymentvarious.class.php
  20. * \ingroup bank
  21. * \brief Class for various payment
  22. */
  23. // Put here all includes required by your class file
  24. require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
  25. /**
  26. * Class to manage various payments
  27. */
  28. class PaymentVarious extends CommonObject
  29. {
  30. /**
  31. * @var string ID to identify managed object
  32. */
  33. public $element='variouspayment';
  34. /**
  35. * @var string Name of table without prefix where object is stored
  36. */
  37. public $table_element='payment_various';
  38. /**
  39. * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
  40. */
  41. public $picto = 'bill';
  42. /**
  43. * @var int ID
  44. */
  45. public $id;
  46. /**
  47. * @var string Ref
  48. */
  49. public $ref;
  50. public $tms;
  51. public $datep;
  52. public $datev;
  53. public $sens;
  54. public $amount;
  55. public $type_payment;
  56. public $num_payment;
  57. /**
  58. * @var string various payments label
  59. */
  60. public $label;
  61. public $accountancy_code;
  62. /**
  63. * @var int ID
  64. */
  65. public $fk_project;
  66. /**
  67. * @var int ID
  68. */
  69. public $fk_bank;
  70. /**
  71. * @var int ID
  72. */
  73. public $fk_user_author;
  74. /**
  75. * @var int ID
  76. */
  77. public $fk_user_modif;
  78. /**
  79. * Constructor
  80. *
  81. * @param DoliDB $db Database handler
  82. */
  83. function __construct($db)
  84. {
  85. $this->db = $db;
  86. $this->element = 'payment_various';
  87. $this->table_element = 'payment_various';
  88. }
  89. /**
  90. * Update database
  91. *
  92. * @param User $user User that modify
  93. * @param int $notrigger 0=no, 1=yes (no update trigger)
  94. * @return int <0 if KO, >0 if OK
  95. */
  96. function update($user = null, $notrigger = 0)
  97. {
  98. global $conf, $langs;
  99. $error=0;
  100. // Clean parameters
  101. $this->amount=trim($this->amount);
  102. $this->label=trim($this->label);
  103. $this->note=trim($this->note);
  104. $this->fk_bank = (int) $this->fk_bank;
  105. $this->fk_user_author = (int) $this->fk_user_author;
  106. $this->fk_user_modif = (int) $this->fk_user_modif;
  107. $this->db->begin();
  108. // Update request
  109. $sql = "UPDATE ".MAIN_DB_PREFIX."payment_various SET";
  110. if ($this->tms) $sql.= " tms='".$this->db->idate($this->tms)."',";
  111. $sql.= " datep='".$this->db->idate($this->datep)."',";
  112. $sql.= " datev='".$this->db->idate($this->datev)."',";
  113. $sql.= " sens=".$this->sens.",";
  114. $sql.= " amount=".price2num($this->amount).",";
  115. $sql.= " fk_typepayment=".$this->fk_typepayment."',";
  116. $sql.= " num_payment='".$this->db->escape($this->num_payment)."',";
  117. $sql.= " label='".$this->db->escape($this->label)."',";
  118. $sql.= " note='".$this->db->escape($this->note)."',";
  119. $sql.= " accountancy_code='".$this->db->escape($this->accountancy_code)."',";
  120. $sql.= " fk_projet='".$this->db->escape($this->fk_project)."',";
  121. $sql.= " fk_bank=".($this->fk_bank > 0 ? $this->fk_bank:"null").",";
  122. $sql.= " fk_user_author=".$this->fk_user_author.",";
  123. $sql.= " fk_user_modif=".$this->fk_user_modif;
  124. $sql.= " WHERE rowid=".$this->id;
  125. dol_syslog(get_class($this)."::update", LOG_DEBUG);
  126. $resql = $this->db->query($sql);
  127. if (! $resql)
  128. {
  129. $this->error="Error ".$this->db->lasterror();
  130. return -1;
  131. }
  132. if (! $notrigger)
  133. {
  134. // Call trigger
  135. $result=$this->call_trigger('PAYMENT_VARIOUS_MODIFY',$user);
  136. if ($result < 0) $error++;
  137. // End call triggers
  138. }
  139. if (! $error)
  140. {
  141. $this->db->commit();
  142. return 1;
  143. }
  144. else
  145. {
  146. $this->db->rollback();
  147. return -1;
  148. }
  149. }
  150. /**
  151. * Load object in memory from database
  152. *
  153. * @param int $id id object
  154. * @param User $user User that load
  155. * @return int <0 if KO, >0 if OK
  156. */
  157. function fetch($id, $user = null)
  158. {
  159. global $langs;
  160. $sql = "SELECT";
  161. $sql.= " v.rowid,";
  162. $sql.= " v.tms,";
  163. $sql.= " v.datep,";
  164. $sql.= " v.datev,";
  165. $sql.= " v.sens,";
  166. $sql.= " v.amount,";
  167. $sql.= " v.fk_typepayment,";
  168. $sql.= " v.num_payment,";
  169. $sql.= " v.label,";
  170. $sql.= " v.note,";
  171. $sql.= " v.accountancy_code,";
  172. $sql.= " v.fk_projet as fk_project,";
  173. $sql.= " v.fk_bank,";
  174. $sql.= " v.fk_user_author,";
  175. $sql.= " v.fk_user_modif,";
  176. $sql.= " b.fk_account,";
  177. $sql.= " b.fk_type,";
  178. $sql.= " b.rappro";
  179. $sql.= " FROM ".MAIN_DB_PREFIX."payment_various as v";
  180. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid";
  181. $sql.= " WHERE v.rowid = ".$id;
  182. dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
  183. $resql=$this->db->query($sql);
  184. if ($resql)
  185. {
  186. if ($this->db->num_rows($resql))
  187. {
  188. $obj = $this->db->fetch_object($resql);
  189. $this->id = $obj->rowid;
  190. $this->ref = $obj->rowid;
  191. $this->tms = $this->db->jdate($obj->tms);
  192. $this->datep = $this->db->jdate($obj->datep);
  193. $this->datev = $this->db->jdate($obj->datev);
  194. $this->sens = $obj->sens;
  195. $this->amount = $obj->amount;
  196. $this->type_payment = $obj->fk_typepayment;
  197. $this->num_payment = $obj->num_payment;
  198. $this->label = $obj->label;
  199. $this->note = $obj->note;
  200. $this->accountancy_code = $obj->accountancy_code;
  201. $this->fk_project = $obj->fk_project;
  202. $this->fk_bank = $obj->fk_bank;
  203. $this->fk_user_author = $obj->fk_user_author;
  204. $this->fk_user_modif = $obj->fk_user_modif;
  205. $this->fk_account = $obj->fk_account;
  206. $this->fk_type = $obj->fk_type;
  207. $this->rappro = $obj->rappro;
  208. }
  209. $this->db->free($resql);
  210. return 1;
  211. }
  212. else
  213. {
  214. $this->error="Error ".$this->db->lasterror();
  215. return -1;
  216. }
  217. }
  218. /**
  219. * Delete object in database
  220. *
  221. * @param User $user User that delete
  222. * @return int <0 if KO, >0 if OK
  223. */
  224. function delete($user)
  225. {
  226. global $conf, $langs;
  227. $error=0;
  228. // Call trigger
  229. $result=$this->call_trigger('PAYMENT_VARIOUS_DELETE',$user);
  230. if ($result < 0) return -1;
  231. // End call triggers
  232. $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_various";
  233. $sql.= " WHERE rowid=".$this->id;
  234. dol_syslog(get_class($this)."::delete", LOG_DEBUG);
  235. $resql = $this->db->query($sql);
  236. if (! $resql)
  237. {
  238. $this->error="Error ".$this->db->lasterror();
  239. return -1;
  240. }
  241. return 1;
  242. }
  243. /**
  244. * Initialise an instance with random values.
  245. * Used to build previews or test instances.
  246. * id must be 0 if object instance is a specimen.
  247. *
  248. * @return void
  249. */
  250. function initAsSpecimen()
  251. {
  252. $this->id=0;
  253. $this->tms='';
  254. $this->datep='';
  255. $this->datev='';
  256. $this->sens='';
  257. $this->amount='';
  258. $this->label='';
  259. $this->accountancy_code='';
  260. $this->note='';
  261. $this->fk_bank='';
  262. $this->fk_user_author='';
  263. $this->fk_user_modif='';
  264. }
  265. /**
  266. * Create in database
  267. *
  268. * @param User $user User that create
  269. * @return int <0 if KO, >0 if OK
  270. */
  271. function create($user)
  272. {
  273. global $conf,$langs;
  274. $error=0;
  275. $now=dol_now();
  276. // Clean parameters
  277. $this->amount=price2num(trim($this->amount));
  278. $this->label=trim($this->label);
  279. $this->note=trim($this->note);
  280. $this->fk_bank = (int) $this->fk_bank;
  281. $this->fk_user_author = (int) $this->fk_user_author;
  282. $this->fk_user_modif = (int) $this->fk_user_modif;
  283. // Check parameters
  284. if (! $this->label)
  285. {
  286. $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label"));
  287. return -3;
  288. }
  289. if ($this->amount < 0 || $this->amount == '')
  290. {
  291. $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount"));
  292. return -5;
  293. }
  294. if (! empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0))
  295. {
  296. $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Account"));
  297. return -6;
  298. }
  299. if (! empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0))
  300. {
  301. $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode"));
  302. return -7;
  303. }
  304. $this->db->begin();
  305. // Insert into llx_payment_various
  306. $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_various (";
  307. $sql.= " datep";
  308. $sql.= ", datev";
  309. $sql.= ", sens";
  310. $sql.= ", amount";
  311. $sql.= ", fk_typepayment";
  312. $sql.= ", num_payment";
  313. if ($this->note) $sql.= ", note";
  314. $sql.= ", label";
  315. $sql.= ", accountancy_code";
  316. $sql.= ", fk_projet";
  317. $sql.= ", fk_user_author";
  318. $sql.= ", datec";
  319. $sql.= ", fk_bank";
  320. $sql.= ", entity";
  321. $sql.= ")";
  322. $sql.= " VALUES (";
  323. $sql.= "'".$this->db->idate($this->datep)."'";
  324. $sql.= ", '".$this->db->idate($this->datev)."'";
  325. $sql.= ", '".$this->db->escape($this->sens)."'";
  326. $sql.= ", ".$this->amount;
  327. $sql.= ", '".$this->db->escape($this->type_payment)."'";
  328. $sql.= ", '".$this->db->escape($this->num_payment)."'";
  329. if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'";
  330. $sql.= ", '".$this->db->escape($this->label)."'";
  331. $sql.= ", '".$this->db->escape($this->accountancy_code)."'";
  332. $sql.= ", ".($this->fk_project > 0? $this->fk_project : 0);
  333. $sql.= ", ".$user->id;
  334. $sql.= ", '".$this->db->idate($now)."'";
  335. $sql.= ", NULL";
  336. $sql.= ", ".$conf->entity;
  337. $sql.= ")";
  338. dol_syslog(get_class($this)."::create", LOG_DEBUG);
  339. $result = $this->db->query($sql);
  340. if ($result)
  341. {
  342. $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_various");
  343. $this->ref = $this->id;
  344. if ($this->id > 0)
  345. {
  346. if (! empty($conf->banque->enabled) && ! empty($this->amount))
  347. {
  348. // Insert into llx_bank
  349. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  350. $acc = new Account($this->db);
  351. $result=$acc->fetch($this->accountid);
  352. if ($result <= 0) dol_print_error($this->db);
  353. // Insert payment into llx_bank
  354. // Add link 'payment_various' in bank_url between payment and bank transaction
  355. $sign=1;
  356. if ($this->sens == '0') $sign=-1;
  357. $bank_line_id = $acc->addline(
  358. $this->datep,
  359. $this->type_payment,
  360. $this->label,
  361. $sign * abs($this->amount),
  362. $this->num_payment,
  363. '',
  364. $user
  365. );
  366. // Update fk_bank into llx_paiement.
  367. // So we know the payment which has generate the banking ecriture
  368. if ($bank_line_id > 0)
  369. {
  370. $this->update_fk_bank($bank_line_id);
  371. }
  372. else
  373. {
  374. $this->error=$acc->error;
  375. $error++;
  376. }
  377. if (! $error)
  378. {
  379. // Add link 'payment_various' in bank_url between payment and bank transaction
  380. $url=DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id=';
  381. $result=$acc->add_url_line($bank_line_id, $this->id, $url, "(VariousPayment)", "payment_various");
  382. if ($result <= 0)
  383. {
  384. $this->error=$acc->error;
  385. $error++;
  386. }
  387. }
  388. if ($result <= 0)
  389. {
  390. $this->error=$acc->error;
  391. $error++;
  392. }
  393. }
  394. // Call trigger
  395. $result=$this->call_trigger('PAYMENT_VARIOUS_CREATE',$user);
  396. if ($result < 0) $error++;
  397. // End call triggers
  398. }
  399. else $error++;
  400. if (! $error)
  401. {
  402. $this->db->commit();
  403. return $this->id;
  404. }
  405. else
  406. {
  407. $this->db->rollback();
  408. return -2;
  409. }
  410. }
  411. else
  412. {
  413. $this->error=$this->db->error();
  414. $this->db->rollback();
  415. return -1;
  416. }
  417. }
  418. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
  419. /**
  420. * Update link between payment various and line generate into llx_bank
  421. *
  422. * @param int $id_bank Id bank account
  423. * @return int <0 if KO, >0 if OK
  424. */
  425. function update_fk_bank($id_bank)
  426. {
  427. // phpcs:enable
  428. $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_various SET fk_bank = '.$id_bank;
  429. $sql.= ' WHERE rowid = '.$this->id;
  430. $result = $this->db->query($sql);
  431. if ($result)
  432. {
  433. return 1;
  434. }
  435. else
  436. {
  437. dol_print_error($this->db);
  438. return -1;
  439. }
  440. }
  441. /**
  442. * Retourne le libelle du statut
  443. *
  444. * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
  445. * @return string Libelle
  446. */
  447. function getLibStatut($mode = 0)
  448. {
  449. return $this->LibStatut($this->statut,$mode);
  450. }
  451. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
  452. /**
  453. * Renvoi le libelle d'un statut donne
  454. *
  455. * @param int $statut Id status
  456. * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
  457. * @return string Libelle
  458. */
  459. function LibStatut($statut, $mode = 0)
  460. {
  461. // phpcs:enable
  462. global $langs;
  463. if ($mode == 0)
  464. {
  465. return $langs->trans($this->statuts[$statut]);
  466. }
  467. elseif ($mode == 1)
  468. {
  469. return $langs->trans($this->statuts_short[$statut]);
  470. }
  471. elseif ($mode == 2)
  472. {
  473. if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts_short[$statut]);
  474. elseif ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]);
  475. elseif ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts_short[$statut]);
  476. }
  477. elseif ($mode == 3)
  478. {
  479. if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0');
  480. elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
  481. elseif ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6');
  482. }
  483. elseif ($mode == 4)
  484. {
  485. if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]);
  486. elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]);
  487. elseif ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]);
  488. }
  489. elseif ($mode == 5)
  490. {
  491. if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut0');
  492. elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
  493. elseif ($statut==2 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6');
  494. }
  495. }
  496. /**
  497. * Send name clicable (with possibly the picto)
  498. *
  499. * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
  500. * @param string $option link option
  501. * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
  502. * @param int $notooltip 1=Disable tooltip
  503. * @return string String with URL
  504. */
  505. function getNomUrl($withpicto = 0, $option = '', $save_lastsearch_value = -1, $notooltip = 0)
  506. {
  507. global $db, $conf, $langs, $hookmanager;
  508. global $langs;
  509. if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
  510. $result='';
  511. $label='<u>'.$langs->trans("ShowVariousPayment").'</u>';
  512. $label.= '<br>';
  513. $label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
  514. $url = DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$this->id;
  515. if ($option != 'nolink')
  516. {
  517. // Add param to save lastsearch_values or not
  518. $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
  519. if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
  520. if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
  521. }
  522. $linkclose='';
  523. if (empty($notooltip))
  524. {
  525. if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
  526. {
  527. $label=$langs->trans("ShowMyObject");
  528. $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
  529. }
  530. $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
  531. $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
  532. /*
  533. $hookmanager->initHooks(array('myobjectdao'));
  534. $parameters=array('id'=>$this->id);
  535. $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
  536. if ($reshook > 0) $linkclose = $hookmanager->resPrint;
  537. */
  538. }
  539. else $linkclose = ($morecss?' class="'.$morecss.'"':'');
  540. $linkstart = '<a href="'.$url.'"';
  541. $linkstart.=$linkclose.'>';
  542. $linkend='</a>';
  543. $result .= $linkstart;
  544. if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
  545. if ($withpicto != 2) $result.= $this->ref;
  546. $result .= $linkend;
  547. //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
  548. global $action;
  549. $hookmanager->initHooks(array('variouspayment'));
  550. $parameters=array('id'=>$this->id, 'getnomurl'=>$result);
  551. $reshook=$hookmanager->executeHooks('getNomUrl',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
  552. if ($reshook > 0) $result = $hookmanager->resPrint;
  553. else $result .= $hookmanager->resPrint;
  554. return $result;
  555. }
  556. /**
  557. * Information on record
  558. *
  559. * @param int $id Id of record
  560. * @return void
  561. */
  562. function info($id)
  563. {
  564. $sql = 'SELECT v.rowid, v.datec, v.fk_user_author';
  565. $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_various as v';
  566. $sql.= ' WHERE v.rowid = '.$id;
  567. dol_syslog(get_class($this).'::info', LOG_DEBUG);
  568. $result = $this->db->query($sql);
  569. if ($result)
  570. {
  571. if ($this->db->num_rows($result))
  572. {
  573. $obj = $this->db->fetch_object($result);
  574. $this->id = $obj->rowid;
  575. if ($obj->fk_user_author)
  576. {
  577. $cuser = new User($this->db);
  578. $cuser->fetch($obj->fk_user_author);
  579. $this->user_creation = $cuser;
  580. }
  581. $this->date_creation = $this->db->jdate($obj->datec);
  582. if ($obj->fk_user_modif)
  583. {
  584. $muser = new User($this->db);
  585. $muser->fetch($obj->fk_user_modif);
  586. $this->user_modif = $muser;
  587. }
  588. $this->date_modif = $this->db->jdate($obj->tms);
  589. }
  590. $this->db->free($result);
  591. }
  592. else
  593. {
  594. dol_print_error($this->db);
  595. }
  596. }
  597. }