dolibarr  17.0.4
html.formcron.class.php
Go to the documentation of this file.
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 <https://www.gnu.org/licenses/>.
17  * or see https://www.gnu.org/
18  */
19 
29 class FormCron extends Form
30 {
34  public $db;
35 
39  public $error = '';
40 
46  public function __construct($db)
47  {
48  $this->db = $db;
49  }
50 
51 
52  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
61  public function select_typejob($htmlname, $selected = 0, $readonly = 0)
62  {
63  // phpcs:enable
64  global $langs;
65 
66  $langs->load('cron@cron');
67  $out = '';
68  if (!empty($readonly)) {
69  if ($selected == 'command') {
70  $out = $langs->trans('CronType_command');
71  $out .= '<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>';
72  $out .= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>';
73  $out .= '</SELECT>';
74  } elseif ($selected == 'method') {
75  $out = $langs->trans('CronType_method');
76  $out .= '<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>';
77  $out .= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>';
78  $out .= '</SELECT>';
79  }
80  } else {
81  $out = '<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />';
82 
83  if ($selected == 'command') {
84  $selected_attr = ' selected ';
85  } else {
86  $selected_attr = '';
87  }
88  $out .= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>';
89 
90  if ($selected == 'method') {
91  $selected_attr = ' selected ';
92  } else {
93  $selected_attr = '';
94  }
95  $out .= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>';
96 
97  $out .= '</SELECT>';
98  }
99  if (empty($readonly)) {
100  $out .= ajax_combobox($htmlname);
101  }
102 
103  return $out;
104  }
105 }
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:449
Class to manage building of HTML components.
__construct($db)
Constructor.
select_typejob($htmlname, $selected=0, $readonly=0)
Display On Off selector.
Class to manage generation of HTML components Only common components must be here.
$conf db
API class for accounts.
Definition: inc.php:41