opensurveysondage.class.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <?php
  2. /* Copyright (C) 2013-2014 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
  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/opensurvey/class/opensurveysondage.class.php
  20. * \ingroup opensurvey
  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 2013-03-10 00:32
  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. * Put here description of your class
  30. */
  31. class Opensurveysondage extends CommonObject
  32. {
  33. /**
  34. * @var string ID to identify managed object
  35. */
  36. public $element='opensurvey_sondage';
  37. /**
  38. * @var string Name of table without prefix where object is stored
  39. */
  40. public $table_element='opensurvey_sondage';
  41. public $picto = 'opensurvey';
  42. public $id_sondage;
  43. /**
  44. * @deprecated
  45. * @see description
  46. */
  47. public $commentaires;
  48. /**
  49. * @var string description
  50. */
  51. public $description;
  52. public $mail_admin;
  53. public $nom_admin;
  54. /**
  55. * Id of user author of the poll
  56. * @var int
  57. */
  58. public $fk_user_creat;
  59. public $titre;
  60. public $date_fin='';
  61. public $status=1;
  62. public $format;
  63. public $mailsonde;
  64. public $sujet;
  65. /**
  66. * Allow comments on this poll
  67. * @var bool
  68. */
  69. public $allow_comments;
  70. /**
  71. * Allow users see others vote
  72. * @var bool
  73. */
  74. public $allow_spy;
  75. /**
  76. * Draft status (not used)
  77. */
  78. const STATUS_DRAFT = 0;
  79. /**
  80. * Validated/Opened status
  81. */
  82. const STATUS_VALIDATED = 1;
  83. /**
  84. * Closed
  85. */
  86. const STATUS_CLOSED = 2;
  87. /**
  88. * Constructor
  89. *
  90. * @param DoliDb $db Database handler
  91. */
  92. function __construct($db)
  93. {
  94. $this->db = $db;
  95. }
  96. /**
  97. * Create object into database
  98. *
  99. * @param User $user User that creates
  100. * @param int $notrigger 0=launch triggers after, 1=disable triggers
  101. * @return int <0 if KO, Id of created object if OK
  102. */
  103. function create(User $user, $notrigger=0)
  104. {
  105. $error=0;
  106. // Clean parameters
  107. $this->cleanParameters();
  108. // Check parameters
  109. if (! $this->date_fin > 0)
  110. {
  111. $this->error='BadValueForEndDate';
  112. dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
  113. return -1;
  114. }
  115. // Insert request
  116. $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_sondage(";
  117. $sql.= "id_sondage,";
  118. $sql.= "commentaires,";
  119. $sql.= "fk_user_creat,";
  120. $sql.= "titre,";
  121. $sql.= "date_fin,";
  122. $sql.= "status,";
  123. $sql.= "format,";
  124. $sql.= "mailsonde,";
  125. $sql.= "allow_comments,";
  126. $sql.= "allow_spy,";
  127. $sql.= "sujet";
  128. $sql.= ") VALUES (";
  129. $sql.= "'".$this->db->escape($this->id_sondage)."',";
  130. $sql.= " ".(empty($this->commentaires)?'NULL':"'".$this->db->escape($this->commentaires)."'").",";
  131. $sql.= " ".$user->id.",";
  132. $sql.= " '".$this->db->escape($this->titre)."',";
  133. $sql.= " '".$this->db->idate($this->date_fin)."',";
  134. $sql.= " ".$this->status.",";
  135. $sql.= " '".$this->db->escape($this->format)."',";
  136. $sql.= " ".$this->db->escape($this->mailsonde).",";
  137. $sql.= " ".$this->db->escape($this->allow_comments).",";
  138. $sql.= " ".$this->db->escape($this->allow_spy).",";
  139. $sql.= " '".$this->db->escape($this->sujet)."'";
  140. $sql.= ")";
  141. $this->db->begin();
  142. dol_syslog(get_class($this)."::create", LOG_DEBUG);
  143. $resql=$this->db->query($sql);
  144. if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
  145. if (! $error)
  146. {
  147. if (! $notrigger)
  148. {
  149. global $langs, $conf;
  150. // Call trigger
  151. $result=$this->call_trigger('OPENSURVEY_CREATE',$user);
  152. if ($result < 0) $error++;
  153. // End call triggers
  154. }
  155. }
  156. // Commit or rollback
  157. if ($error)
  158. {
  159. foreach($this->errors as $errmsg)
  160. {
  161. dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
  162. $this->error.=($this->error?', '.$errmsg:$errmsg);
  163. }
  164. $this->db->rollback();
  165. return -1*$error;
  166. }
  167. else
  168. {
  169. $this->db->commit();
  170. return $this->id;
  171. }
  172. }
  173. /**
  174. * Load object in memory from the database
  175. *
  176. * @param int $id Id object
  177. * @param string $numsurvey Ref of survey (admin or not)
  178. * @return int <0 if KO, >0 if OK
  179. */
  180. function fetch($id, $numsurvey='')
  181. {
  182. $sql = "SELECT";
  183. $sql.= " t.id_sondage,";
  184. $sql.= " t.commentaires as description,";
  185. $sql.= " t.mail_admin,";
  186. $sql.= " t.nom_admin,";
  187. $sql.= " t.fk_user_creat,";
  188. $sql.= " t.titre,";
  189. $sql.= " t.date_fin,";
  190. $sql.= " t.status,";
  191. $sql.= " t.format,";
  192. $sql.= " t.mailsonde,";
  193. $sql.= " t.allow_comments,";
  194. $sql.= " t.allow_spy,";
  195. $sql.= " t.sujet,";
  196. $sql.= " t.tms";
  197. $sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as t";
  198. $sql.= " WHERE t.id_sondage = '".$this->db->escape($numsurvey)."'";
  199. dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
  200. $resql=$this->db->query($sql);
  201. if ($resql)
  202. {
  203. if ($this->db->num_rows($resql))
  204. {
  205. $obj = $this->db->fetch_object($resql);
  206. $this->id_sondage = $obj->id_sondage;
  207. $this->ref = $this->id_sondage; //For compatibility
  208. $this->commentaires = $obj->description; // deprecated
  209. $this->description = $obj->description;
  210. $this->mail_admin = $obj->mail_admin;
  211. $this->nom_admin = $obj->nom_admin;
  212. $this->titre = $obj->titre;
  213. $this->date_fin = $this->db->jdate($obj->date_fin);
  214. $this->status = $obj->status;
  215. $this->format = $obj->format;
  216. $this->mailsonde = $obj->mailsonde;
  217. $this->allow_comments = $obj->allow_comments;
  218. $this->allow_spy = $obj->allow_spy;
  219. $this->sujet = $obj->sujet;
  220. $this->fk_user_creat = $obj->fk_user_creat;
  221. $this->date_m = $this->db->jdate($obj->tls);
  222. $ret=1;
  223. }
  224. else
  225. {
  226. $sondage = ($id ? 'id='.$id : 'sondageid='.$numsurvey);
  227. $this->error='Fetch no poll found for '.$sondage;
  228. dol_syslog($this->error, LOG_ERR);
  229. $ret = 0;
  230. }
  231. $this->db->free($resql);
  232. }
  233. else
  234. {
  235. $this->error="Error ".$this->db->lasterror();
  236. $ret=-1;
  237. }
  238. return $ret;
  239. }
  240. /**
  241. * Update object into database
  242. *
  243. * @param User $user User that modifies
  244. * @param int $notrigger 0=launch triggers after, 1=disable triggers
  245. * @return int <0 if KO, >0 if OK
  246. */
  247. function update(User $user, $notrigger=0)
  248. {
  249. global $conf, $langs;
  250. $error=0;
  251. // Clean parameters
  252. $this->cleanParameters();
  253. // Check parameters
  254. // Put here code to add a control on parameters values
  255. // Update request
  256. $sql = "UPDATE ".MAIN_DB_PREFIX."opensurvey_sondage SET";
  257. $sql.= " id_sondage=".(isset($this->id_sondage)?"'".$this->db->escape($this->id_sondage)."'":"null").",";
  258. $sql.= " commentaires=".(isset($this->commentaires)?"'".$this->db->escape($this->commentaires)."'":"null").",";
  259. $sql.= " mail_admin=".(isset($this->mail_admin)?"'".$this->db->escape($this->mail_admin)."'":"null").",";
  260. $sql.= " nom_admin=".(isset($this->nom_admin)?"'".$this->db->escape($this->nom_admin)."'":"null").",";
  261. $sql.= " titre=".(isset($this->titre)?"'".$this->db->escape($this->titre)."'":"null").",";
  262. $sql.= " date_fin=".(dol_strlen($this->date_fin)!=0 ? "'".$this->db->idate($this->date_fin)."'" : 'null').",";
  263. $sql.= " status=".(isset($this->status)?"'".$this->db->escape($this->status)."'":"null").",";
  264. $sql.= " format=".(isset($this->format)?"'".$this->db->escape($this->format)."'":"null").",";
  265. $sql.= " mailsonde=".(isset($this->mailsonde)?$this->db->escape($this->mailsonde):"null").",";
  266. $sql.= " allow_comments=".$this->db->escape($this->allow_comments).",";
  267. $sql.= " allow_spy=".$this->db->escape($this->allow_spy);
  268. $sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'";
  269. $this->db->begin();
  270. dol_syslog(get_class($this)."::update", LOG_DEBUG);
  271. $resql = $this->db->query($sql);
  272. if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
  273. if (! $error)
  274. {
  275. if (! $notrigger)
  276. {
  277. // Call triggers
  278. include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
  279. $interface=new Interfaces($this->db);
  280. $result=$interface->run_triggers('OPENSURVEY_MODIFY',$this,$user,$langs,$conf);
  281. if ($result < 0) { $error++; $this->errors=$interface->errors; }
  282. // End call triggers
  283. }
  284. }
  285. // Commit or rollback
  286. if ($error)
  287. {
  288. foreach($this->errors as $errmsg)
  289. {
  290. dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
  291. $this->error.=($this->error?', '.$errmsg:$errmsg);
  292. }
  293. $this->db->rollback();
  294. return -1*$error;
  295. }
  296. else
  297. {
  298. $this->db->commit();
  299. return 1;
  300. }
  301. }
  302. /**
  303. * Delete object in database
  304. *
  305. * @param User $user User that deletes
  306. * @param int $notrigger 0=launch triggers after, 1=disable triggers
  307. * @param string $numsondage Num sondage admin to delete
  308. * @return int <0 if KO, >0 if OK
  309. */
  310. function delete(User $user, $notrigger, $numsondage)
  311. {
  312. global $conf, $langs;
  313. $error=0;
  314. $this->db->begin();
  315. if (! $error)
  316. {
  317. if (! $notrigger)
  318. {
  319. // Call trigger
  320. $result=$this->call_trigger('OPENSURVEY_DELETE',$user);
  321. if ($result < 0) $error++;
  322. // End call triggers
  323. }
  324. }
  325. if (! $error)
  326. {
  327. $sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$this->db->escape($numsondage)."'";
  328. dol_syslog(get_class($this)."::delete", LOG_DEBUG);
  329. $resql=$this->db->query($sql);
  330. $sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage = '".$this->db->escape($numsondage)."'";
  331. dol_syslog(get_class($this)."::delete", LOG_DEBUG);
  332. $resql=$this->db->query($sql);
  333. $sql = "DELETE FROM ".MAIN_DB_PREFIX."opensurvey_sondage";
  334. $sql.= " WHERE id_sondage = '".$this->db->escape($numsondage)."'";
  335. dol_syslog(get_class($this)."::delete", LOG_DEBUG);
  336. $resql = $this->db->query($sql);
  337. if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
  338. }
  339. // Commit or rollback
  340. if ($error)
  341. {
  342. foreach($this->errors as $errmsg)
  343. {
  344. dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
  345. $this->error.=($this->error?', '.$errmsg:$errmsg);
  346. }
  347. $this->db->rollback();
  348. return -1*$error;
  349. }
  350. else
  351. {
  352. $this->db->commit();
  353. return 1;
  354. }
  355. }
  356. /**
  357. * Return a link to the object card (with optionaly the picto)
  358. *
  359. * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
  360. * @param int $notooltip 1=Disable tooltip
  361. * @param string $morecss Add more css on link
  362. * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
  363. * @return string String with URL
  364. */
  365. function getNomUrl($withpicto=0, $notooltip=0, $morecss='', $save_lastsearch_value=-1)
  366. {
  367. global $db, $conf, $langs;
  368. global $dolibarr_main_authentication, $dolibarr_main_demo;
  369. global $menumanager;
  370. if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
  371. $result = '';
  372. $companylink = '';
  373. $label = '<u>' . $langs->trans("ShowSurvey") . '</u>';
  374. $label.= '<br>';
  375. $label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref.'<br>';
  376. $label.= '<b>' . $langs->trans('Title') . ':</b> ' . $this->title.'<br>';
  377. $url = DOL_URL_ROOT.'/opensurvey/card.php?id='.$this->id;
  378. // Add param to save lastsearch_values or not
  379. $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
  380. if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
  381. if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
  382. $linkclose='';
  383. if (empty($notooltip))
  384. {
  385. if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
  386. {
  387. $label=$langs->trans("ShowMyObject");
  388. $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
  389. }
  390. $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
  391. $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
  392. }
  393. else $linkclose = ($morecss?' class="'.$morecss.'"':'');
  394. $linkstart = '<a href="'.$url.'"';
  395. $linkstart.=$linkclose.'>';
  396. $linkend='</a>';
  397. $result .= $linkstart;
  398. 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);
  399. if ($withpicto != 2) $result.= $this->ref;
  400. $result .= $linkend;
  401. return $result;
  402. }
  403. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
  404. /**
  405. * Return array of lines
  406. *
  407. * @return int <0 if KO, >0 if OK
  408. */
  409. function fetch_lines()
  410. {
  411. // phpcs:enable
  412. $ret=array();
  413. $sql = "SELECT id_users, nom as name, reponses FROM ".MAIN_DB_PREFIX."opensurvey_user_studs";
  414. $sql.= " WHERE id_sondage = '".$this->db->escape($this->id_sondage)."'";
  415. $resql=$this->db->query($sql);
  416. if ($resql)
  417. {
  418. $num=$this->db->num_rows($resql);
  419. $i=0;
  420. while ($i < $num)
  421. {
  422. $obj=$this->db->fetch_object($resql);
  423. $tmp=array('id_users'=>$obj->id_users, 'nom'=>$obj->name, 'reponses'=>$obj->reponses);
  424. $ret[]=$tmp;
  425. $i++;
  426. }
  427. }
  428. else dol_print_error($this->db);
  429. $this->lines=$ret;
  430. return count($this->lines);
  431. }
  432. /**
  433. * Initialise object with example values
  434. * Id must be 0 if object instance is a specimen
  435. *
  436. * @return void
  437. */
  438. function initAsSpecimen()
  439. {
  440. $this->id=0;
  441. $this->id_sondage='';
  442. $this->commentaires='Comment of the specimen survey';
  443. $this->mail_admin='';
  444. $this->nom_admin='';
  445. $this->titre='This is a specimen survey';
  446. $this->date_fin=dol_now()+3600*24*10;
  447. $this->status=1;
  448. $this->format='classic';
  449. $this->mailsonde='';
  450. }
  451. /**
  452. * Returns all comments for the current opensurvey poll
  453. *
  454. * @return Object[]
  455. */
  456. public function getComments()
  457. {
  458. $comments = array();
  459. $sql = 'SELECT id_comment, usercomment, comment';
  460. $sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments';
  461. $sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'";
  462. $sql.= " ORDER BY id_comment";
  463. $resql = $this->db->query($sql);
  464. if ($resql)
  465. {
  466. $num_rows=$this->db->num_rows($resql);
  467. if ($num_rows > 0)
  468. {
  469. while ($obj = $this->db->fetch_object($resql))
  470. {
  471. $comments[] = $obj;
  472. }
  473. }
  474. }
  475. return $comments;
  476. }
  477. /**
  478. * Adds a comment to the poll
  479. *
  480. * @param string $comment Comment content
  481. * @param string $comment_user Comment author
  482. * @return boolean False in case of the query fails, true if it was successful
  483. */
  484. public function addComment($comment, $comment_user)
  485. {
  486. $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_comments (id_sondage, comment, usercomment)";
  487. $sql.= " VALUES ('".$this->db->escape($this->id_sondage)."','".$this->db->escape($comment)."','".$this->db->escape($comment_user)."')";
  488. $resql = $this->db->query($sql);
  489. if (!$resql) {
  490. return false;
  491. }
  492. return true;
  493. }
  494. /**
  495. * Deletes a comment of the poll
  496. *
  497. * @param int $id_comment Id of the comment
  498. * @return boolean False in case of the query fails, true if it was successful
  499. */
  500. public function deleteComment($id_comment)
  501. {
  502. $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_comments WHERE id_comment = '.$id_comment.' AND id_sondage = "'.$this->db->escape($this->id_sondage).'"';
  503. $resql = $this->db->query($sql);
  504. if (!$resql) {
  505. return false;
  506. }
  507. return true;
  508. }
  509. /**
  510. * Cleans all the class variables before doing an update or an insert
  511. *
  512. * @return void
  513. */
  514. private function cleanParameters()
  515. {
  516. $this->id_sondage = trim($this->id_sondage);
  517. $this->commentaires = trim($this->commentaires);
  518. $this->mail_admin = trim($this->mail_admin);
  519. $this->nom_admin = trim($this->nom_admin);
  520. $this->titre = trim($this->titre);
  521. $this->status = trim($this->status);
  522. $this->format = trim($this->format);
  523. $this->mailsonde = ($this->mailsonde ? 1 : 0);
  524. $this->allow_comments = ($this->allow_comments ? 1 : 0);
  525. $this->allow_spy = ($this->allow_spy ? 1 : 0);
  526. $this->sujet = trim($this->sujet);
  527. }
  528. /**
  529. * Return status label of Order
  530. *
  531. * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
  532. * @return string Libelle
  533. */
  534. function getLibStatut($mode)
  535. {
  536. return $this->LibStatut($this->status,$mode);
  537. }
  538. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
  539. /**
  540. * Return label of status
  541. *
  542. * @param int $status Id statut
  543. * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
  544. * @return string Label of status
  545. */
  546. function LibStatut($status,$mode)
  547. {
  548. // phpcs:enable
  549. global $langs, $conf;
  550. //print 'x'.$status.'-'.$billed;
  551. if ($mode == 0)
  552. {
  553. if ($status==self::STATUS_DRAFT) return $langs->trans('Draft');
  554. if ($status==self::STATUS_VALIDATED) return $langs->trans('Opened');
  555. if ($status==self::STATUS_CLOSED) return $langs->trans('Closed');
  556. }
  557. elseif ($mode == 1)
  558. {
  559. if ($status==self::STATUS_DRAFT) return $langs->trans('Draft');
  560. if ($status==self::STATUS_VALIDATED) return $langs->trans('Opened');
  561. if ($status==self::STATUS_CLOSED) return $langs->trans('Closed');
  562. }
  563. elseif ($mode == 2)
  564. {
  565. if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft');
  566. if ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened'),'statut1').' '.$langs->trans('Opened');
  567. if ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'),'statut6').' '.$langs->trans('Closed');
  568. }
  569. elseif ($mode == 3)
  570. {
  571. if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'),'statut0');
  572. if ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened'),'statut1');
  573. if ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'),'statut6');
  574. }
  575. elseif ($mode == 4)
  576. {
  577. if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft');
  578. if ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened').$billedtext,'statut1').' '.$langs->trans('Opened');
  579. if ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'),'statut6').' '.$langs->trans('Closed');
  580. }
  581. elseif ($mode == 5)
  582. {
  583. if ($status==self::STATUS_DRAFT) return '<span class="hideonsmartphone">'.$langs->trans('Draft').' </span>'.img_picto($langs->trans('Draft'),'statut0');
  584. if ($status==self::STATUS_VALIDATED) return '<span class="hideonsmartphone">'.$langs->trans('Opened').' </span>'.img_picto($langs->trans('Opened'),'statut1');
  585. if ($status==self::STATUS_CLOSED) return '<span class="hideonsmartphone">'.$langs->trans('Closed').' </span>'.img_picto($langs->trans('Closed'),'statut6');
  586. }
  587. }
  588. }