paymentsalary.class.php 19 KB

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