Subversion Repositories Applications.bazar

Compare Revisions

Ignore whitespace Rev 67 → Rev 68

/trunk/bibliotheque/bazar.fonct.formulaire.php
19,7 → 19,7
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.fonct.formulaire.php,v 1.12 2006-01-05 16:28:24 alexandre_tb Exp $
// CVS : $Id: bazar.fonct.formulaire.php,v 1.13 2006-01-13 14:12:51 florian Exp $
/**
* Formulaire
*
31,7 → 31,7
//Autres auteurs :
*@author Aleandre GRANIER <alexandre@tela-botanica.org>
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.12 $ $Date: 2006-01-05 16:28:24 $
*@version $Revision: 1.13 $ $Date: 2006-01-13 14:12:51 $
// +------------------------------------------------------------------------------------------------------+
*/
 
42,7 → 42,7
/** liste() - Ajoute un élément de type liste au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param string nom du champs dans la table bazar_fiche dans la base de donnée
* @param int identifiant de la liste sur bazar_liste
* @param string label à afficher dans le formulaire
* @param string première restriction de la taille des champs du formulaire
* @param string deuxième restriction de la taille des champs du formulaire
51,29 → 51,27
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function liste(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire) {
$requete = 'select * from '.$source;
function liste(&$formtemplate, $id_liste , $label, $limite1, $limite2, $defaut, $source, $obligatoire) {
//TODO: trouver la variable générique papyrus pour les langues
$requete = 'SELECT * FROM bazar_liste_valeurs WHERE blv_ce_liste='.$id_liste.' AND blv_ce_i18n="fr-FR"';
$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ;
if (DB::isError ($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
while ($ligne = $resultat->fetchRow()) {
$select[$ligne[0]] = $ligne[1] ;
$select[$ligne[1]] = $ligne[2] ;
}
$option=array('style'=>'width: '.$limite1.'px;');
require_once 'HTML/QuickForm/select.php';
$select= new HTML_QuickForm_select($nom_bdd, constant($label), $select, $option);
$select= new HTML_QuickForm_select('liste'.$id_liste, constant($label), $select, $option);
$select->setSize($limite2);
$select->setMultiple(0);
$select->setSelected($defaut);
$formtemplate->addElement($select) ;
//gestion des champs obligatoire
//$formtemplate->registerRule('saisir_liste','function','liste_choisir');
//$formtemplate->addRule($nom_bdd, BAZ_CHOISIR_OBLIGATOIRE , 'saisir_liste');
 
if (isset($obligatoire)and($obligatoire==1)) {
$formtemplate->addRule($nom_bdd, BAZ_CHOISIR_OBLIGATOIRE.' '.constant($label) , 'nonzero', '', 'client') ;
$formtemplate->addRule($nom_bdd, constant($label.'_REQUIS'), 'required', '', 'client') ;}
$formtemplate->addRule('liste'.$id_liste, BAZ_CHOISIR_OBLIGATOIRE.' '.constant($label) , 'nonzero', '', 'client') ;
$formtemplate->addRule('liste'.$id_liste, constant($label.'_REQUIS'), 'required', '', 'client') ;}
}
 
 
80,7 → 78,7
/** checkbox() - Ajoute un élément de type checkbox au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param string nom du champs dans la table bazar_fiche dans la base de donnée
* @param int identifiant de la liste sur bazar_liste
* @param string label à afficher dans le formulaire
* @param string première restriction de la taille des champs du formulaire
* @param string deuxième restriction de la taille des champs du formulaire
89,26 → 87,24
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function checkbox(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire) {
$requete = 'SELECT * FROM '.$source;
function checkbox(&$formtemplate, $id_liste , $label, $limite1, $limite2, $defaut, $source, $obligatoire) {
//TODO: trouver la variable générique papyrus pour les langues
$requete = 'SELECT * FROM bazar_liste_valeurs WHERE blv_ce_liste='.$id_liste.' AND blv_ce_i18n="fr-FR"';
$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ;
if (DB::isError ($resultat)) {
die ($GLOBALS['_BAZAR_']['db']->getMessage().$GLOBALS['_BAZAR_']['db']->getDebugInfo()) ;
}
$tableau_info_jointure = explode (',', $nom_bdd) ;
$nom_table_jointure = $tableau_info_jointure[0] ;
require_once 'HTML/QuickForm/advcheckbox.php' ;
$i=0;
while ($ligne = $resultat->fetchRow()) {
//$chkbox[$ligne[0]] = $ligne[1] ;
if ($i==0) $labelchkbox=constant($label) ; else $labelchkbox='&nbsp;' ;
$checkbox[]= & HTML_Quickform::createElement('checkbox', '', $labelchkbox, $ligne[1],
$checkbox[]= & HTML_Quickform::createElement('checkbox', $ligne[1], $labelchkbox, $ligne[2],
array ('style'=>'display:inline;margin-left:2px;')) ;
$i++;
}
 
$formtemplate->addGroup($checkbox, $nom_table_jointure, constant($label), '<br />'."\n");
$formtemplate->addGroup($checkbox, 'checkbox'.$id_liste, constant($label), '<br />'."\n");
}
 
 
215,7 → 211,7
*/
function labelhtml(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire) {
require_once 'HTML/QuickForm/html.php';
$formhtml= new HTML_QuickForm_html('<li>'.constant($label).'</li>'."\n");
$formhtml= new HTML_QuickForm_html('<tr>'."\n".'<td colspan="2">'."\n".constant($label)."\n".'</td>'."\n".'</tr>'."\n");
$formtemplate->addElement($formhtml) ;
}
 
222,6 → 218,9
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.12 2006/01/05 16:28:24 alexandre_tb
* prise en chage des checkbox, reste la mise à jour à gérer
*
* Revision 1.11 2006/01/02 13:24:07 alexandre_tb
* correction de bug d'un mauvais retour en erreur
*