dolibarr  9.0.0
html.formwebsite.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
29 {
30  private $db;
31 
35  public $error;
36 
37 
43  function __construct($db)
44  {
45  $this->db = $db;
46  }
47 
48 
57  function selectWebsite($selected='',$htmlname='exportmodelid',$useempty=0)
58  {
59  $out='';
60 
61  $sql = "SELECT rowid, ref";
62  $sql.= " FROM ".MAIN_DB_PREFIX."website";
63  $sql.= " WHERE 1 = 1";
64  $sql.= " ORDER BY rowid";
65  $result = $this->db->query($sql);
66  if ($result)
67  {
68  $out.='<select class="flat minwidth100" name="'.$htmlname.'" id="'.$htmlname.'">';
69  if ($useempty)
70  {
71  $out.='<option value="-1">&nbsp;</option>';
72  }
73 
74  $num = $this->db->num_rows($result);
75  $i = 0;
76  while ($i < $num)
77  {
78  $obj = $this->db->fetch_object($result);
79  if ($selected == $obj->rowid)
80  {
81  $out.='<option value="'.$obj->rowid.'" selected>';
82  }
83  else
84  {
85  $out.='<option value="'.$obj->rowid.'">';
86  }
87  $out.=$obj->ref;
88  $out.='</option>';
89  $i++;
90  }
91  $out.="</select>";
92  }
93  else {
94  dol_print_error($this->db);
95  }
96 
97  return $out;
98  }
99 
100 
110  function selectTypeOfContainer($htmlname, $selected='', $useempty=0, $moreattrib='')
111  {
112  global $langs, $conf, $user;
113 
114  $langs->load("admin");
115 
116  $sql = "SELECT rowid, code, label, entity";
117  $sql.= " FROM ".MAIN_DB_PREFIX.'c_type_container';
118  $sql.= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")";
119  $sql.= " ORDER BY label";
120 
121  dol_syslog(get_class($this)."::selectTypeOfContainer", LOG_DEBUG);
122  $result = $this->db->query($sql);
123  if ($result)
124  {
125  $num = $this->db->num_rows($result);
126  $i = 0;
127  if ($num)
128  {
129  print '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>';
130  if ($useempty == 1 || ($useempty == 2 && $num > 1))
131  {
132  print '<option value="-1">&nbsp;</option>';
133  }
134 
135  while ($i < $num)
136  {
137  $obj = $this->db->fetch_object($result);
138  if ($selected == $obj->rowid || $selected == $obj->code)
139  {
140  print '<option value="'.$obj->code.'" selected>';
141  }
142  else
143  {
144  print '<option value="'.$obj->code.'">';
145  }
146  print $obj->label;
147  print '</option>';
148  $i++;
149  }
150  print "</select>";
151  if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
152  }
153  else
154  {
155  print $langs->trans("NoTypeOfPagePleaseEditDictionary");
156  }
157  }
158  else {
159  dol_print_error($this->db);
160  }
161  }
162 
163 
173  function selectSampleOfContainer($htmlname, $selected='', $useempty=0, $moreattrib='')
174  {
175  global $langs, $conf, $user;
176 
177  $langs->load("admin");
178 
179  $arrayofsamples=array('empty'=>'EmptyPage', 'corporatehome'=>'CorporateHomePage');
180 
181  $out = '';
182  $out .= '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>';
183 
184  if ($useempty == 1 || $useempty == 2)
185  {
186  $out .= '<option value="-1">&nbsp;</option>';
187  }
188 
189  foreach($arrayofsamples as $key => $val)
190  {
191  if ($selected == $key)
192  {
193  $out .= '<option value="'.$key.'" selected>';
194  }
195  else
196  {
197  $out .= '<option value="'.$key.'">';
198  }
199  $out .= $langs->trans($val);
200  $out .= '</option>';
201  }
202  $out .= "</select>";
203 
204  return $out;
205  }
206 }
selectTypeOfContainer($htmlname, $selected='', $useempty=0, $moreattrib='')
Return a HTML select list of a dictionary.
print
Draft customers invoices.
Definition: index.php:91
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
selectWebsite($selected='', $htmlname='exportmodelid', $useempty=0)
Return HTML select list of export models.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
__construct($db)
Constructor.
selectSampleOfContainer($htmlname, $selected='', $useempty=0, $moreattrib='')
Return a HTML select list of a dictionary.
Class to manage component html for module website.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='')
Show information for admin users or standard users.