html.formcron.class.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /*
  3. * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
  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. * or see http://www.gnu.org/
  18. */
  19. /**
  20. * \file core/class/html.formcron.class.php
  21. * \brief Fichier de la classe des fonctions predefinie de composants html cron
  22. */
  23. /**
  24. * Class to manage building of HTML components
  25. */
  26. class FormCron extends Form
  27. {
  28. /**
  29. * @var DoliDB Database handler.
  30. */
  31. public $db;
  32. /**
  33. * @var string Error code (or message)
  34. */
  35. public $error='';
  36. /**
  37. * Constructor
  38. *
  39. * @param DoliDB $db Database handler
  40. */
  41. function __construct($db)
  42. {
  43. $this->db = $db;
  44. }
  45. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
  46. /**
  47. * Display On Off selector
  48. *
  49. * @param string $htmlname Html control name
  50. * @param integer $selected selected value
  51. * @param integer $readonly Select is read only or not
  52. * @return string HTML select field
  53. */
  54. function select_typejob($htmlname,$selected=0,$readonly=0)
  55. {
  56. // phpcs:enable
  57. global $langs;
  58. $langs->load('cron@cron');
  59. if (!empty($readonly)) {
  60. if ($selected=='command') {
  61. $out= $langs->trans('CronType_command');
  62. $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>';
  63. $out.= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>';
  64. $out.='</SELECT>';
  65. } elseif ($selected=='method') {
  66. $out= $langs->trans('CronType_method');
  67. $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>';
  68. $out.= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>';
  69. $out.='</SELECT>';
  70. }
  71. }else {
  72. $out='<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />';
  73. if ($selected=='command') {
  74. $selected_attr=' selected ';
  75. } else {
  76. $selected_attr='';
  77. }
  78. $out.= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>';
  79. if ($selected=='method') {
  80. $selected_attr=' selected ';
  81. } else {
  82. $selected_attr='';
  83. }
  84. $out.= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>';
  85. $out.='</SELECT>';
  86. }
  87. return $out;
  88. }
  89. }