box_lastlogin.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /* Copyright (C) 2012 Charles-François BENKE <charles.fr@benke.fr>
  3. * Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2014-2020 Frederic France <frederic.france@netlogic.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/core/boxes/box_lastlogin.php
  21. * \ingroup core
  22. * \brief Module to show box of bills, orders & propal of the current year
  23. */
  24. include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
  25. /**
  26. * Class to manage the box of last login
  27. */
  28. class box_lastlogin extends ModeleBoxes
  29. {
  30. public $boxcode = "lastlogin";
  31. public $boximg = "object_user";
  32. public $boxlabel = 'BoxLoginInformation';
  33. public $depends = array("user");
  34. /**
  35. * @var DoliDB Database handler.
  36. */
  37. public $db;
  38. public $param;
  39. public $enabled = 1;
  40. public $info_box_head = array();
  41. public $info_box_contents = array();
  42. /**
  43. * Constructor
  44. *
  45. * @param DoliDB $db Database handler
  46. * @param string $param More parameters
  47. */
  48. public function __construct($db, $param)
  49. {
  50. global $conf;
  51. $this->db = $db;
  52. }
  53. /**
  54. * Charge les donnees en memoire pour affichage ulterieur
  55. *
  56. * @param int $max Maximum number of records to load
  57. * @return void
  58. */
  59. public function loadBox($max = 5)
  60. {
  61. global $conf, $user, $langs;
  62. $textHead = $langs->trans("BoxLoginInformation");
  63. $this->info_box_head = array(
  64. 'text' => $textHead,
  65. 'limit'=> dol_strlen($textHead),
  66. );
  67. $line = 0;
  68. $this->info_box_contents[$line][0] = array(
  69. 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
  70. 'text' => $langs->trans("User"),
  71. );
  72. $this->info_box_contents[$line][1] = array(
  73. 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
  74. 'text' => $user->getNomUrl(-1),
  75. 'asis' => 1
  76. );
  77. $line = 1;
  78. $this->info_box_contents[$line][0] = array(
  79. 'td' => '',
  80. 'text' => $langs->trans("PreviousConnexion"),
  81. );
  82. if ($user->datepreviouslogin) {
  83. $tmp = dol_print_date($user->datepreviouslogin, "dayhour", 'tzuserrel');
  84. } else {
  85. $tmp = $langs->trans("Unknown");
  86. }
  87. $this->info_box_contents[$line][1] = array(
  88. 'td' => '',
  89. 'text' => $tmp,
  90. );
  91. }
  92. /**
  93. * Method to show box
  94. *
  95. * @param array $head Array with properties of box title
  96. * @param array $contents Array with properties of box lines
  97. * @param int $nooutput No print, only return string
  98. * @return string
  99. */
  100. public function showBox($head = null, $contents = null, $nooutput = 0)
  101. {
  102. return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
  103. }
  104. }