dolibarr  7.0.0-beta
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  public $error;
32 
33 
39  function __construct($db)
40  {
41  $this->db = $db;
42 
43  return 1;
44  }
45 
46 
55  function selectWebsite($selected='',$htmlname='exportmodelid',$useempty=0)
56  {
57  $out='';
58 
59  $sql = "SELECT rowid, ref";
60  $sql.= " FROM ".MAIN_DB_PREFIX."website";
61  $sql.= " WHERE 1 = 1";
62  $sql.= " ORDER BY rowid";
63  $result = $this->db->query($sql);
64  if ($result)
65  {
66  $out.='<select class="flat minwidth100" name="'.$htmlname.'" id="'.$htmlname.'">';
67  if ($useempty)
68  {
69  $out.='<option value="-1">&nbsp;</option>';
70  }
71 
72  $num = $this->db->num_rows($result);
73  $i = 0;
74  while ($i < $num)
75  {
76  $obj = $this->db->fetch_object($result);
77  if ($selected == $obj->rowid)
78  {
79  $out.='<option value="'.$obj->rowid.'" selected>';
80  }
81  else
82  {
83  $out.='<option value="'.$obj->rowid.'">';
84  }
85  $out.=$obj->ref;
86  $out.='</option>';
87  $i++;
88  }
89  $out.="</select>";
90  }
91  else {
92  dol_print_error($this->db);
93  }
94 
95  return $out;
96  }
97 
98 }
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.
__construct($db)
Constructor.
Class to manage component html for module website.