2
0
forked from Wavyzz/dolibarr
Files
dolibarr-fork/htdocs/html.formother.class.php
Laurent Destailleur 211be07fb1 Reduce amount of memory.
2008-10-25 17:27:15 +00:00

159 lines
4.5 KiB
PHP

<?php
/* Copyright (c) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2006 Marc Barilley/Ocebo <marc@ocebo.com>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerker@telenet.be>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* \file htdocs/html.formother.class.php
* \brief Fichier de la classe des fonctions prédéfinie de composants html autre
* \version $Id$
*/
/**
* \class FormOther
* \brief Classe permettant la génération de composants html autre
* \remarks Only common components must be here.
*/
class FormOther
{
var $db;
var $error;
/**
* \brief Constructeur
* \param DB handler d'accès base de donnée
*/
function FormOther($DB)
{
$this->db = $DB;
return 1;
}
/**
* \brief Retourne la liste des modèles d'export
* \param selected Id modèle pré-sélectionné
* \param htmlname Nom de la zone select
* \param type Type des modèles recherchés
* \param useempty Affiche valeur vide dans liste
*/
function select_export_model($selected='',$htmlname='exportmodelid',$type='',$useempty=0)
{
$sql = "SELECT rowid, label";
$sql.= " FROM ".MAIN_DB_PREFIX."export_model";
$sql.= " WHERE type = '".$type."'";
$sql.= " ORDER BY rowid";
$result = $this->db->query($sql);
if ($result)
{
print '<select class="flat" name="'.$htmlname.'">';
if ($useempty)
{
print '<option value="-1">&nbsp;</option>';
}
$num = $this->db->num_rows($result);
$i = 0;
while ($i < $num)
{
$obj = $this->db->fetch_object($result);
if ($selected == $obj->rowid)
{
print '<option value="'.$obj->rowid.'" selected="true">';
}
else
{
print '<option value="'.$obj->rowid.'">';
}
print $obj->label;
print '</option>';
$i++;
}
print "</select>";
}
else {
dolibarr_print_error($this->db);
}
}
/**
* \brief Retourne la liste des ecotaxes avec tooltip sur le libelle
* \param selected code ecotaxes pre-selectionne
* \param htmlname nom de la liste deroulante
*/
function select_ecotaxes($selected='',$htmlname='ecotaxe_id')
{
global $langs;
$sql = "SELECT e.rowid, e.code, e.libelle, e.price, e.organization,";
$sql.= " p.libelle as pays";
$sql.= " FROM ".MAIN_DB_PREFIX."c_ecotaxe as e,".MAIN_DB_PREFIX."c_pays as p";
$sql.= " WHERE e.active = 1 AND e.fk_pays = p.rowid";
$sql.= " ORDER BY pays, e.organization ASC, e.code ASC";
if ($this->db->query($sql))
{
print '<select class="flat" name="'.$htmlname.'">';
$num = $this->db->num_rows();
$i = 0;
print '<option value="-1">&nbsp;</option>'."\n";
if ($num)
{
while ($i < $num)
{
$obj = $this->db->fetch_object();
if ($selected && $selected == $obj->rowid)
{
print '<option value="'.$obj->rowid.'" selected="true">';
}
else
{
print '<option value="'.$obj->rowid.'">';
//print '<option onmouseover="showtip(\''.$obj->libelle.'\')" onMouseout="hidetip()" value="'.$obj->rowid.'">';
}
$selectOptionValue = $obj->code.' : '.price($obj->price).' '.$langs->trans("HT").' ('.$obj->organization.')';
print $selectOptionValue;
print '</option>';
$i++;
}
}
print '</select>';
return 0;
}
else
{
dolibarr_print_error($this->db);
return 1;
}
}
}
?>