paymentdonation.class.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. <?php
  2. /* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/don/class/paymentdonation.class.php
  19. * \ingroup Donation
  20. * \brief File of class to manage payment of donations
  21. */
  22. require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
  23. /**
  24. * Class to manage payments of donations
  25. */
  26. class PaymentDonation extends CommonObject
  27. {
  28. /**
  29. * @var string ID to identify managed object
  30. */
  31. public $element = 'payment_donation';
  32. /**
  33. * @var string Name of table without prefix where object is stored
  34. */
  35. public $table_element = 'payment_donation';
  36. /**
  37. * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
  38. */
  39. public $picto = 'payment';
  40. /**
  41. * @var int ID
  42. */
  43. public $rowid;
  44. /**
  45. * @var int ID
  46. */
  47. public $fk_donation;
  48. public $datec = '';
  49. public $tms = '';
  50. public $datep = '';
  51. public $amount; // Total amount of payment
  52. public $amounts = array(); // Array of amounts
  53. public $fk_typepayment; // Payment mode ID
  54. public $paymenttype; // Payment mode ID or Code. TODO Use only the code in this field.
  55. public $num_payment;
  56. /**
  57. * @var int ID
  58. */
  59. public $fk_bank;
  60. /**
  61. * @var int ID
  62. */
  63. public $fk_user_creat;
  64. /**
  65. * @var int ID
  66. */
  67. public $fk_user_modif;
  68. /**
  69. * @deprecated
  70. * @see $amount, $amounts
  71. */
  72. public $total;
  73. public $type_code;
  74. public $type_label;
  75. /**
  76. * @var string Id of external payment mode
  77. */
  78. public $ext_payment_id;
  79. /**
  80. * @var string Name of external payment mode
  81. */
  82. public $ext_payment_site;
  83. /**
  84. * Constructor
  85. *
  86. * @param DoliDB $db Database handler
  87. */
  88. public function __construct($db)
  89. {
  90. $this->db = $db;
  91. }
  92. /**
  93. * Create payment of donation into database.
  94. * Use this->amounts to have list of lines for the payment
  95. *
  96. * @param User $user User making payment
  97. * @param bool $notrigger false=launch triggers after, true=disable triggers
  98. * @return int <0 if KO, id of payment if OK
  99. */
  100. public function create($user, $notrigger = false)
  101. {
  102. global $conf, $langs;
  103. $error = 0;
  104. $now = dol_now();
  105. // Validate parameters
  106. if (!$this->datepaid) {
  107. $this->error = 'ErrorBadValueForParameterCreatePaymentDonation';
  108. return -1;
  109. }
  110. // Clean parameters
  111. if (isset($this->chid)) {
  112. $this->chid = (int) $this->chid;
  113. } elseif (isset($this->fk_donation)) {
  114. // NOTE : The property used in INSERT for fk_donation is not fk_donation but chid
  115. // (keep priority to chid property)
  116. $this->chid = (int) $this->fk_donation;
  117. }
  118. if (isset($this->fk_donation)) {
  119. $this->fk_donation = (int) $this->fk_donation;
  120. }
  121. if (isset($this->amount)) {
  122. $this->amount = trim($this->amount);
  123. }
  124. if (isset($this->fk_typepayment)) {
  125. $this->fk_typepayment = trim($this->fk_typepayment);
  126. }
  127. if (isset($this->num_payment)) {
  128. $this->num_payment = trim($this->num_payment);
  129. }
  130. if (isset($this->note_public)) {
  131. $this->note_public = trim($this->note_public);
  132. }
  133. if (isset($this->fk_bank)) {
  134. $this->fk_bank = (int) $this->fk_bank;
  135. }
  136. if (isset($this->fk_user_creat)) {
  137. $this->fk_user_creat = (int) $this->fk_user_creat;
  138. }
  139. if (isset($this->fk_user_modif)) {
  140. $this->fk_user_modif = (int) $this->fk_user_modif;
  141. }
  142. $totalamount = 0;
  143. foreach ($this->amounts as $key => $value) { // How payment is dispatch
  144. $newvalue = price2num($value, 'MT');
  145. $this->amounts[$key] = $newvalue;
  146. $totalamount += $newvalue;
  147. }
  148. $totalamount = price2num($totalamount);
  149. // Check parameters
  150. if ($totalamount == 0) {
  151. return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null
  152. }
  153. $this->db->begin();
  154. if ($totalamount != 0) {
  155. $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_donation (fk_donation, datec, datep, amount,";
  156. $sql .= " fk_typepayment, num_payment, note, ext_payment_id, ext_payment_site,";
  157. $sql .= " fk_user_creat, fk_bank)";
  158. $sql .= " VALUES (".((int) $this->chid).", '".$this->db->idate($now)."',";
  159. $sql .= " '".$this->db->idate($this->datepaid)."',";
  160. $sql .= " ".((float) price2num($totalamount)).",";
  161. $sql .= " ".((int) $this->paymenttype).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_public)."', ";
  162. $sql .= " ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").",";
  163. $sql .= " ".((int) $user->id).", 0)";
  164. dol_syslog(get_class($this)."::create", LOG_DEBUG);
  165. $resql = $this->db->query($sql);
  166. if ($resql) {
  167. $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_donation");
  168. $this->ref = $this->id;
  169. } else {
  170. $error++;
  171. }
  172. }
  173. if (!$error && !$notrigger) {
  174. // Call triggers
  175. $result = $this->call_trigger('DONATION_PAYMENT_CREATE', $user);
  176. if ($result < 0) {
  177. $error++;
  178. }
  179. // End call triggers
  180. }
  181. if ($totalamount != 0 && !$error) {
  182. $this->amount = $totalamount;
  183. $this->total = $totalamount; // deprecated
  184. $this->db->commit();
  185. return $this->id;
  186. } else {
  187. $this->error = $this->db->error();
  188. $this->db->rollback();
  189. return -1;
  190. }
  191. }
  192. /**
  193. * Load object in memory from database
  194. *
  195. * @param int $id Id object
  196. * @return int <0 if KO, >0 if OK
  197. */
  198. public function fetch($id)
  199. {
  200. global $langs;
  201. $sql = "SELECT";
  202. $sql .= " t.rowid,";
  203. $sql .= " t.fk_donation,";
  204. $sql .= " t.datec,";
  205. $sql .= " t.tms,";
  206. $sql .= " t.datep,";
  207. $sql .= " t.amount,";
  208. $sql .= " t.fk_typepayment,";
  209. $sql .= " t.num_payment,";
  210. $sql .= " t.note as note_public,";
  211. $sql .= " t.fk_bank,";
  212. $sql .= " t.fk_user_creat,";
  213. $sql .= " t.fk_user_modif,";
  214. $sql .= " pt.code as type_code, pt.libelle as type_label,";
  215. $sql .= ' b.fk_account';
  216. $sql .= " FROM ".MAIN_DB_PREFIX."payment_donation as t";
  217. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id";
  218. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid';
  219. $sql .= " WHERE t.rowid = ".((int) $id);
  220. dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
  221. $resql = $this->db->query($sql);
  222. if ($resql) {
  223. if ($this->db->num_rows($resql)) {
  224. $obj = $this->db->fetch_object($resql);
  225. $this->id = $obj->rowid;
  226. $this->ref = $obj->rowid;
  227. $this->fk_donation = $obj->fk_donation;
  228. $this->datec = $this->db->jdate($obj->datec);
  229. $this->tms = $this->db->jdate($obj->tms);
  230. $this->datep = $this->db->jdate($obj->datep);
  231. $this->amount = $obj->amount;
  232. $this->fk_typepayment = $obj->fk_typepayment; // Id on type of payent
  233. $this->paymenttype = $obj->fk_typepayment; // Id on type of payment. We should store the code into paymenttype.
  234. $this->num_payment = $obj->num_payment;
  235. $this->note_public = $obj->note_public;
  236. $this->fk_bank = $obj->fk_bank;
  237. $this->fk_user_creat = $obj->fk_user_creat;
  238. $this->fk_user_modif = $obj->fk_user_modif;
  239. $this->type_code = $obj->type_code;
  240. $this->type_label = $obj->type_label;
  241. $this->bank_account = $obj->fk_account;
  242. $this->bank_line = $obj->fk_bank;
  243. }
  244. $this->db->free($resql);
  245. return 1;
  246. } else {
  247. $this->error = "Error ".$this->db->lasterror();
  248. return -1;
  249. }
  250. }
  251. /**
  252. * Update database
  253. *
  254. * @param User $user User that modify
  255. * @param int $notrigger 0=launch triggers after, 1=disable triggers
  256. * @return int <0 if KO, >0 if OK
  257. */
  258. public function update($user, $notrigger = 0)
  259. {
  260. global $conf, $langs;
  261. $error = 0;
  262. // Clean parameters
  263. if (isset($this->fk_donation)) {
  264. $this->fk_donation = (int) $this->fk_donation;
  265. }
  266. if (isset($this->amount)) {
  267. $this->amount = trim($this->amount);
  268. }
  269. if (isset($this->fk_typepayment)) {
  270. $this->fk_typepayment = trim($this->fk_typepayment);
  271. }
  272. if (isset($this->num_payment)) {
  273. $this->num_payment = trim($this->num_payment);
  274. }
  275. if (isset($this->note_public)) {
  276. $this->note_public = trim($this->note_public);
  277. }
  278. if (isset($this->fk_bank)) {
  279. $this->fk_bank = (int) $this->fk_bank;
  280. }
  281. if (isset($this->fk_user_creat)) {
  282. $this->fk_user_creat = (int) $this->fk_user_creat;
  283. }
  284. if (isset($this->fk_user_modif)) {
  285. $this->fk_user_modif = (int) $this->fk_user_modif;
  286. }
  287. // Check parameters
  288. // Put here code to add control on parameters values
  289. // Update request
  290. $sql = "UPDATE ".MAIN_DB_PREFIX."payment_donation SET";
  291. $sql .= " fk_donation=".(isset($this->fk_donation) ? $this->fk_donation : "null").",";
  292. $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
  293. $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
  294. $sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').",";
  295. $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").",";
  296. $sql .= " fk_typepayment=".(isset($this->fk_typepayment) ? $this->fk_typepayment : "null").",";
  297. $sql .= " num_payment=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").",";
  298. $sql .= " note=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").",";
  299. $sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").",";
  300. $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").",";
  301. $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null")."";
  302. $sql .= " WHERE rowid=".(int) $this->id;
  303. $this->db->begin();
  304. dol_syslog(get_class($this)."::update", LOG_DEBUG);
  305. $resql = $this->db->query($sql);
  306. if (!$resql) {
  307. $error++;
  308. $this->errors[] = "Error ".$this->db->lasterror();
  309. }
  310. if (!$error) {
  311. if (!$notrigger) {
  312. if (!$error && !$notrigger) {
  313. // Call triggers
  314. $result = $this->call_trigger('DONATION_PAYMENT_MODIFY', $user);
  315. if ($result < 0) {
  316. $error++;
  317. }
  318. // End call triggers
  319. }
  320. }
  321. }
  322. // Commit or rollback
  323. if ($error) {
  324. foreach ($this->errors as $errmsg) {
  325. dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
  326. $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
  327. }
  328. $this->db->rollback();
  329. return -1 * $error;
  330. } else {
  331. $this->db->commit();
  332. return 1;
  333. }
  334. }
  335. /**
  336. * Delete object in database
  337. *
  338. * @param User $user User that delete
  339. * @param int $notrigger 0=launch triggers after, 1=disable triggers
  340. * @return int <0 if KO, >0 if OK
  341. */
  342. public function delete($user, $notrigger = 0)
  343. {
  344. global $conf, $langs;
  345. $error = 0;
  346. $this->db->begin();
  347. if (!$error) {
  348. $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url";
  349. $sql .= " WHERE type='payment_donation' AND url_id=".(int) $this->id;
  350. dol_syslog(get_class($this)."::delete", LOG_DEBUG);
  351. $resql = $this->db->query($sql);
  352. if (!$resql) {
  353. $error++; $this->errors[] = "Error ".$this->db->lasterror();
  354. }
  355. }
  356. if (!$error) {
  357. $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_donation";
  358. $sql .= " WHERE rowid=".((int) $this->id);
  359. dol_syslog(get_class($this)."::delete", LOG_DEBUG);
  360. $resql = $this->db->query($sql);
  361. if (!$resql) {
  362. $error++;
  363. $this->errors[] = "Error ".$this->db->lasterror();
  364. }
  365. }
  366. if (!$error) {
  367. if (!$notrigger) {
  368. if (!$error && !$notrigger) {
  369. // Call triggers
  370. $result = $this->call_trigger('DONATION_PAYMENT_DELETE', $user);
  371. if ($result < 0) {
  372. $error++;
  373. }
  374. // End call triggers
  375. }
  376. }
  377. }
  378. // Commit or rollback
  379. if ($error) {
  380. foreach ($this->errors as $errmsg) {
  381. dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
  382. $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
  383. }
  384. $this->db->rollback();
  385. return -1 * $error;
  386. } else {
  387. $this->db->commit();
  388. return 1;
  389. }
  390. }
  391. /**
  392. * Load an object from its id and create a new one in database
  393. *
  394. * @param User $user User making the clone
  395. * @param int $fromid Id of object to clone
  396. * @return int New id of clone
  397. */
  398. public function createFromClone(User $user, $fromid)
  399. {
  400. $error = 0;
  401. $object = new PaymentDonation($this->db);
  402. $this->db->begin();
  403. // Load source object
  404. $object->fetch($fromid);
  405. $object->id = 0;
  406. $object->statut = 0;
  407. // Clear fields
  408. // ...
  409. // Create clone
  410. $object->context['createfromclone'] = 'createfromclone';
  411. $result = $object->create($user);
  412. // Other options
  413. if ($result < 0) {
  414. $this->error = $object->error;
  415. $error++;
  416. }
  417. if (!$error) {
  418. }
  419. unset($object->context['createfromclone']);
  420. // End
  421. if (!$error) {
  422. $this->db->commit();
  423. return $object->id;
  424. } else {
  425. $this->db->rollback();
  426. return -1;
  427. }
  428. }
  429. /**
  430. * Retourne le libelle du statut d'un don (brouillon, validee, abandonnee, payee)
  431. *
  432. * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long
  433. * @return string Libelle
  434. */
  435. public function getLibStatut($mode = 0)
  436. {
  437. return '';
  438. }
  439. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  440. /**
  441. * Renvoi le libelle d'un statut donne
  442. *
  443. * @param int $status Id status
  444. * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
  445. * @return string Libelle du statut
  446. */
  447. public function LibStatut($status, $mode = 0)
  448. {
  449. // phpcs:enable
  450. global $langs;
  451. return '';
  452. }
  453. /**
  454. * Initialise an instance with random values.
  455. * Used to build previews or test instances.
  456. * id must be 0 if object instance is a specimen.
  457. *
  458. * @return void
  459. */
  460. public function initAsSpecimen()
  461. {
  462. $this->id = 0;
  463. $this->fk_donation = '';
  464. $this->datec = '';
  465. $this->tms = '';
  466. $this->datep = '';
  467. $this->amount = '';
  468. $this->fk_typepayment = '';
  469. $this->paymenttype = '';
  470. $this->num_payment = '';
  471. $this->note_public = '';
  472. $this->fk_bank = '';
  473. $this->fk_user_creat = '';
  474. $this->fk_user_modif = '';
  475. }
  476. /**
  477. * Add record into bank for payment with links between this bank record and invoices of payment.
  478. * All payment properties must have been set first like after a call to create().
  479. *
  480. * @param User $user Object of user making payment
  481. * @param string $mode 'payment_donation'
  482. * @param string $label Label to use in bank record
  483. * @param int $accountid Id of bank account to do link with
  484. * @param string $emetteur_nom Name of transmitter
  485. * @param string $emetteur_banque Name of bank
  486. * @return int <0 if KO, >0 if OK
  487. */
  488. public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
  489. {
  490. global $conf;
  491. $error = 0;
  492. if (isModEnabled("banque")) {
  493. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  494. $acc = new Account($this->db);
  495. $acc->fetch($accountid);
  496. $total = $this->total;
  497. if ($mode == 'payment_donation') {
  498. $amount = $total;
  499. }
  500. // Insert payment into llx_bank
  501. $bank_line_id = $acc->addline(
  502. $this->datepaid,
  503. $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example")
  504. $label,
  505. $amount,
  506. $this->num_payment,
  507. '',
  508. $user,
  509. $emetteur_nom,
  510. $emetteur_banque
  511. );
  512. // Update fk_bank in llx_paiement.
  513. // On connait ainsi le paiement qui a genere l'ecriture bancaire
  514. if ($bank_line_id > 0) {
  515. $result = $this->update_fk_bank($bank_line_id);
  516. if ($result <= 0) {
  517. $error++;
  518. dol_print_error($this->db);
  519. }
  520. // Add link 'payment', 'payment_supplier', 'payment_donation' in bank_url between payment and bank transaction
  521. $url = '';
  522. if ($mode == 'payment_donation') {
  523. $url = DOL_URL_ROOT.'/don/payment/card.php?rowid=';
  524. }
  525. if ($url) {
  526. $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
  527. if ($result <= 0) {
  528. $error++;
  529. dol_print_error($this->db);
  530. }
  531. }
  532. } else {
  533. $this->error = $acc->error;
  534. $error++;
  535. }
  536. }
  537. if (!$error) {
  538. return 1;
  539. } else {
  540. return -1;
  541. }
  542. }
  543. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  544. /**
  545. * Update link between the donation payment and the generated line in llx_bank
  546. *
  547. * @param int $id_bank Id if bank
  548. * @return int >0 if OK, <=0 if KO
  549. */
  550. public function update_fk_bank($id_bank)
  551. {
  552. // phpcs:enable
  553. $sql = "UPDATE ".MAIN_DB_PREFIX."payment_donation SET fk_bank = ".(int) $id_bank." WHERE rowid = ".(int) $this->id;
  554. dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
  555. $result = $this->db->query($sql);
  556. if ($result) {
  557. return 1;
  558. } else {
  559. $this->error = $this->db->error();
  560. return 0;
  561. }
  562. }
  563. /**
  564. * Return clicable name (with picto eventually)
  565. *
  566. * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
  567. * @param int $maxlen Max length
  568. * @return string String with URL
  569. */
  570. public function getNomUrl($withpicto = 0, $maxlen = 0)
  571. {
  572. global $langs, $hookmanager;
  573. $result = '';
  574. $label = '<u>'.$langs->trans("DonationPayment").'</u>';
  575. $label .= '<br>';
  576. $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
  577. if (!empty($this->id)) {
  578. $link = '<a href="'.DOL_URL_ROOT.'/don/payment/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
  579. $linkend = '</a>';
  580. if ($withpicto) {
  581. $result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' ');
  582. }
  583. if ($withpicto && $withpicto != 2) {
  584. $result .= ' ';
  585. }
  586. if ($withpicto != 2) {
  587. $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend;
  588. }
  589. }
  590. global $action;
  591. $hookmanager->initHooks(array($this->element . 'dao'));
  592. $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
  593. $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
  594. if ($reshook > 0) {
  595. $result = $hookmanager->resPrint;
  596. } else {
  597. $result .= $hookmanager->resPrint;
  598. }
  599. return $result;
  600. }
  601. }