html.formcron.class.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. var $db;
  29. var $error;
  30. /**
  31. * Constructor
  32. *
  33. * @param DoliDB $db Database handler
  34. */
  35. function __construct($db)
  36. {
  37. $this->db = $db;
  38. return 1;
  39. }
  40. /**
  41. * Display On Off selector
  42. *
  43. * @param string $htmlname Html control name
  44. * @param integer $selected selected value
  45. * @param integer $readonly Select is read only or not
  46. * @return string HTML select field
  47. */
  48. function select_typejob($htmlname,$selected=0,$readonly=0)
  49. {
  50. global $langs;
  51. $langs->load('cron@cron');
  52. if (!empty($readonly)) {
  53. if ($selected=='command') {
  54. $out= $langs->trans('CronType_command');
  55. $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>';
  56. $out.= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>';
  57. $out.='</SELECT>';
  58. } elseif ($selected=='method') {
  59. $out= $langs->trans('CronType_method');
  60. $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>';
  61. $out.= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>';
  62. $out.='</SELECT>';
  63. }
  64. }else {
  65. $out='<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />';
  66. if ($selected=='command') {
  67. $selected_attr=' selected ';
  68. } else {
  69. $selected_attr='';
  70. }
  71. $out.= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>';
  72. if ($selected=='method') {
  73. $selected_attr=' selected ';
  74. } else {
  75. $selected_attr='';
  76. }
  77. $out.= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>';
  78. $out.='</SELECT>';
  79. }
  80. return $out;
  81. }
  82. }