Qual: Reduce memory required by 2%

This commit is contained in:
Laurent Destailleur 2008-11-16 01:54:33 +00:00
parent eff8f51692
commit 21d56aa8a1
13 changed files with 1397 additions and 1333 deletions

View File

@ -18,27 +18,28 @@
*/ */
/** /**
\file htdocs/admin/company.php * \file htdocs/admin/company.php
\ingroup company * \ingroup company
\brief Page d'accueil de l'espace administration/configuration * \brief Page d'accueil de l'espace administration/configuration
\version $Id$ * \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/images.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT."/html.formcompany.class.php");
$langs->load("admin"); $langs->load("admin");
$langs->load("companies"); $langs->load("companies");
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
if ( (isset($_POST["action"]) && $_POST["action"] == 'update') if ( (isset($_POST["action"]) && $_POST["action"] == 'update')
|| (isset($_POST["action"]) && $_POST["action"] == 'updateedit') ) || (isset($_POST["action"]) && $_POST["action"] == 'updateedit') )
{ {
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM",$_POST["nom"]); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM",$_POST["nom"]);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADRESSE",$_POST["address"]); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADRESSE",$_POST["address"]);
@ -193,6 +194,8 @@ if ($_GET["action"] == 'removelogo')
llxHeader(); llxHeader();
$form = new Form($db); $form = new Form($db);
$formcompany = new FormCompany($db);
$countrynotdefined='<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>'; $countrynotdefined='<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
print_fiche_titre($langs->trans("CompanyFundation"),'','setup'); print_fiche_titre($langs->trans("CompanyFundation"),'','setup');
@ -201,7 +204,7 @@ print $langs->trans("CompanyFundationDesc")."<br>\n";
print "<br>\n"; print "<br>\n";
if ((isset($_GET["action"]) && $_GET["action"] == 'edit') if ((isset($_GET["action"]) && $_GET["action"] == 'edit')
|| (isset($_POST["action"]) && $_POST["action"] == 'updateedit') ) || (isset($_POST["action"]) && $_POST["action"] == 'updateedit') )
{ {
/** /**
* Edition des paramètres * Edition des paramètres
@ -328,7 +331,7 @@ if ((isset($_GET["action"]) && $_GET["action"] == 'edit')
print '<tr '.$bc[$var].'><td>'.$langs->trans("JuridicalStatus").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("JuridicalStatus").'</td><td>';
if ($conf->global->MAIN_INFO_SOCIETE_PAYS) if ($conf->global->MAIN_INFO_SOCIETE_PAYS)
{ {
$form->select_forme_juridique($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,$code_pays); $formcompany->select_forme_juridique($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,$code_pays);
} }
else else
{ {
@ -743,11 +746,11 @@ llxFooter('$Date$ - $Revision$');
/** /**
* \brief Retourne le nom traduit ou code+nom d'une devise * \brief Retourne le nom traduit ou code+nom d'une devise
* \param code_iso Code iso de la devise * \param code_iso Code iso de la devise
* \param withcode 1=affiche code + nom * \param withcode 1=affiche code + nom
* \return string Nom traduit de la devise * \return string Nom traduit de la devise
*/ */
function currency_name($code_iso,$withcode=0) function currency_name($code_iso,$withcode=0)
{ {
global $langs,$db; global $langs,$db;

View File

@ -28,6 +28,7 @@
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/html.formadmin.class.php"); require_once(DOL_DOCUMENT_ROOT."/html.formadmin.class.php");
require_once(DOL_DOCUMENT_ROOT."/html.formcompany.class.php");
$langs->load("other"); $langs->load("other");
$langs->load("admin"); $langs->load("admin");
@ -715,6 +716,7 @@ function fieldList($fieldlist,$obj='')
$html = new Form($db); $html = new Form($db);
$formadmin = new FormAdmin($db); $formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db);
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
@ -730,7 +732,7 @@ function fieldList($fieldlist,$obj='')
} }
elseif ($fieldlist[$field] == 'region') { elseif ($fieldlist[$field] == 'region') {
print '<td>'; print '<td>';
$html->select_region($region_id,'region'); $formcompany->select_region($region_id,'region');
print '</td>'; print '</td>';
} }
elseif ($fieldlist[$field] == 'region_id') { elseif ($fieldlist[$field] == 'region_id') {

View File

@ -448,7 +448,7 @@ if ($_GET["action"] == 'create')
} }
else else
{ {
$html->select_type_actions($actioncomm->type_code, "actioncode"); $htmlactions->select_type_actions($actioncomm->type_code, "actioncode");
} }
print '</td></tr>'; print '</td></tr>';

View File

@ -28,6 +28,7 @@
require_once("./pre.inc.php"); require_once("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/prospect.class.php"); require_once(DOL_DOCUMENT_ROOT."/prospect.class.php");
require_once(DOL_DOCUMENT_ROOT."/html.formcompany.class.php");
require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php"); require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php");
if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
@ -72,7 +73,9 @@ if ($_POST["action"] == 'setprospectlevel' && $user->rights->societe->creer)
*********************************************************************************/ *********************************************************************************/
llxHeader(); llxHeader();
$form=new Form($db); $form=new Form($db);
$formcompany=new FormCompany($db);
if ($socid > 0) if ($socid > 0)
{ {
@ -127,12 +130,12 @@ if ($socid > 0)
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($_GET['action'] == 'editlevel') if ($_GET['action'] == 'editlevel')
{ {
$form->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$societe->id,$societe->fk_prospectlevel,'prospect_level_id',1); $formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$societe->id,$societe->fk_prospectlevel,'prospect_level_id',1);
} }
else else
{ {
print $societe->getLibLevel(); print $societe->getLibLevel();
//$html->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$objsoc->id,$objsoc->mode_reglement,'none'); //$formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$objsoc->id,$objsoc->mode_reglement,'none');
} }
print "</td>"; print "</td>";
print '</tr>'; print '</tr>';

View File

@ -29,7 +29,8 @@
require('./pre.inc.php'); require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php"); require_once(DOL_DOCUMENT_ROOT."/html.formorder.class.php");
require_once(DOL_DOCUMENT_ROOT."/includes/modules/commande/modules_commande.php");
require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php'); require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php');
require_once(DOL_DOCUMENT_ROOT.'/actioncomm.class.php'); require_once(DOL_DOCUMENT_ROOT.'/actioncomm.class.php');
require_once(DOL_DOCUMENT_ROOT."/lib/order.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/order.lib.php");
@ -837,6 +838,8 @@ llxHeader('',$langs->trans('Order'),'Commande');
$html = new Form($db); $html = new Form($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
$formorder = new FormOrder($db);
/********************************************************************* /*********************************************************************
* *
@ -971,7 +974,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
} }
print '<tr><td>'.$langs->trans('Source').'</td><td colspan="2">'; print '<tr><td>'.$langs->trans('Source').'</td><td colspan="2">';
$html->selectSourcesCommande('','source_id',1); $formorder->selectSourcesCommande('','source_id',1);
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans('Model').'</td>'; print '<tr><td>'.$langs->trans('Model').'</td>';

View File

@ -32,6 +32,7 @@ require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php");
require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/contact.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/contact.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/html.formcompany.class.php");
$langs->load("companies"); $langs->load("companies");
$langs->load("users"); $langs->load("users");
@ -195,6 +196,7 @@ if ($user->rights->societe->contact->creer)
llxHeader(); llxHeader();
$form = new Form($db); $form = new Form($db);
$formcompany = new FormCompany($db);
if ($socid) if ($socid)
{ {
@ -289,7 +291,7 @@ if ($user->rights->societe->contact->creer)
// Civility // Civility
print '<tr><td width="15%">'.$langs->trans("UserTitle").'</td><td colspan="3">'; print '<tr><td width="15%">'.$langs->trans("UserTitle").'</td><td colspan="3">';
print $form->select_civilite($contact->civilite_id); print $formcompany->select_civilite($contact->civilite_id);
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("PostOrFunction").'</td><td colspan="3"><input name="poste" type="text" size="50" maxlength="80" value="'.$contact->poste.'"></td>'; print '<tr><td>'.$langs->trans("PostOrFunction").'</td><td colspan="3"><input name="poste" type="text" size="50" maxlength="80" value="'.$contact->poste.'"></td>';
@ -372,7 +374,7 @@ if ($user->rights->societe->contact->creer)
// Civility // Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
print $form->select_civilite($contact->civilite_id); print $formcompany->select_civilite($contact->civilite_id);
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("PostOrFunction" ).'</td><td colspan="3"><input name="poste" type="text" size="50" maxlength="80" value="'.$contact->poste.'"></td></tr>'; print '<tr><td>'.$langs->trans("PostOrFunction" ).'</td><td colspan="3"><input name="poste" type="text" size="50" maxlength="80" value="'.$contact->poste.'"></td></tr>';

View File

@ -24,7 +24,7 @@
\ingroup commande \ingroup commande
\brief Fiche de ventilation des commandes fournisseurs \brief Fiche de ventilation des commandes fournisseurs
\version $Id$ \version $Id$
*/ */
require('./pre.inc.php'); require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT.'/includes/modules/supplier_order/modules_commandefournisseur.php'); require_once(DOL_DOCUMENT_ROOT.'/includes/modules/supplier_order/modules_commandefournisseur.php');
@ -164,7 +164,7 @@ if ($id > 0)
print '</td><td width="50%" colspan="3">'; print '</td><td width="50%" colspan="3">';
if ($commande->methode_commande) if ($commande->methode_commande)
{ {
print "Méthode : " .$commande->methode_commande; print $langs->trans("Method")." : " .$commande->methode_commande;
} }
print "</td></tr>"; print "</td></tr>";
} }

View File

@ -28,6 +28,7 @@
require('./pre.inc.php'); require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
require_once(DOL_DOCUMENT_ROOT."/html.formorder.class.php");
require_once(DOL_DOCUMENT_ROOT.'/includes/modules/supplier_order/modules_commandefournisseur.php'); require_once(DOL_DOCUMENT_ROOT.'/includes/modules/supplier_order/modules_commandefournisseur.php');
require_once DOL_DOCUMENT_ROOT."/fourn/fournisseur.product.class.php"; require_once DOL_DOCUMENT_ROOT."/fourn/fournisseur.product.class.php";
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/project.class.php'); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/project.class.php');
@ -464,6 +465,7 @@ llxHeader('',$langs->trans("OrderCard"),"CommandeFournisseur");
$html = new Form($db); $html = new Form($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
$formorder = new FormOrder($db);
/* *************************************************************************** */ /* *************************************************************************** */
/* */ /* */
@ -1015,7 +1017,7 @@ if ($id > 0)
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("OrderMode").'</td><td>'; print '<tr><td>'.$langs->trans("OrderMode").'</td><td>';
$html->select_methodes_commande('',"methodecommande",1); $formorder->select_methodes_commande('',"methodecommande",1);
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("Comment").'</td><td><input size="30" type="text" name="commentaire"></td></tr>'; print '<tr><td>'.$langs->trans("Comment").'</td><td><input size="30" type="text" name="commentaire"></td></tr>';

View File

@ -170,207 +170,6 @@ class Form
} }
/**
* \brief Retourne la liste déroulante des départements/province/cantons tout pays confondu ou pour un pays donné.
* \remarks Dans le cas d'une liste tout pays confondus, l'affichage fait une rupture sur le pays.
* \remarks La cle de la liste est le code (il peut y avoir plusieurs entrée pour
* un code donnée mais dans ce cas, le champ pays diffère).
* Ainsi les liens avec les départements se font sur un département indépendemment de son nom.
* \param selected code forme juridique a présélectionné
* \param pays_code 0=liste tous pays confondus, sinon code du pays à afficher
*/
function select_departement($selected='',$pays_code=0)
{
global $conf,$langs,$user;
dolibarr_syslog("Form::select_departement selected=$selected, pays_code=$pays_code",LOG_DEBUG);
$langs->load("dict");
$htmlname='departement_id';
// On recherche les départements/cantons/province active d'une region et pays actif
$sql = "SELECT d.rowid, d.code_departement as code , d.nom, d.active, p.libelle as libelle_pays, p.code as code_pays FROM";
$sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_pays as p";
$sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=p.rowid";
$sql .= " AND d.active = 1 AND r.active = 1 AND p.active = 1";
if ($pays_code) $sql .= " AND p.code = '".$pays_code."'";
$sql .= " ORDER BY p.code, d.code_departement";
dolibarr_syslog("Form::select_departement sql=".$sql);
$result=$this->db->query($sql);
if ($result)
{
print '<select class="flat" name="'.$htmlname.'">';
if ($pays_code) print '<option value="0">&nbsp;</option>';
$num = $this->db->num_rows($result);
$i = 0;
dolibarr_syslog("Form::select_departement num=$num",LOG_DEBUG);
if ($num)
{
$pays='';
while ($i < $num)
{
$obj = $this->db->fetch_object($result);
if ($obj->code == '0') // Le code peut etre une chaine
{
print '<option value="0">&nbsp;</option>';
}
else {
if (! $pays || $pays != $obj->libelle_pays)
{
// Affiche la rupture si on est en mode liste multipays
if (! $pays_code && $obj->code_pays)
{
print '<option value="-1">----- '.$obj->libelle_pays." -----</option>\n";
$pays=$obj->libelle_pays;
}
}
if ($selected > 0 && $selected == $obj->rowid)
{
print '<option value="'.$obj->rowid.'" selected="true">';
}
else
{
print '<option value="'.$obj->rowid.'">';
}
// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
print $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->nom!='-'?$obj->nom:''));
print '</option>';
}
$i++;
}
}
print '</select>';
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
}
else {
dolibarr_print_error($this->db);
}
}
/**
* \brief Retourne la liste déroulante des regions actives dont le pays est actif
* \remarks La cle de la liste est le code (il peut y avoir plusieurs entrée pour
* un code donnée mais dans ce cas, le champ pays et lang diffère).
* Ainsi les liens avec les regions se font sur une region independemment
* de son nom.
*/
function select_region($selected='',$htmlname='region_id')
{
global $conf,$langs;
$langs->load("dict");
$sql = "SELECT r.rowid, r.code_region as code, r.nom as libelle, r.active, p.libelle as libelle_pays FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_pays as p";
$sql .= " WHERE r.fk_pays=p.rowid AND r.active = 1 and p.active = 1 ORDER BY libelle_pays, libelle ASC";
dolibarr_syslog("Form::select_region sql=".$sql);
if ($this->db->query($sql))
{
print '<select class="flat" name="'.$htmlname.'">';
$num = $this->db->num_rows();
$i = 0;
if ($num)
{
$pays='';
while ($i < $num)
{
$obj = $this->db->fetch_object();
if ($obj->code == 0) {
print '<option value="0">&nbsp;</option>';
}
else {
if ($pays == '' || $pays != $obj->libelle_pays)
{
// Affiche la rupture
print '<option value="-1" disabled="disabled">----- '.$obj->libelle_pays." -----</option>\n";
$pays=$obj->libelle_pays;
}
if ($selected > 0 && $selected == $obj->code)
{
print '<option value="'.$obj->code.'" selected="true">'.$obj->libelle.'</option>';
}
else
{
print '<option value="'.$obj->code.'">'.$obj->libelle.'</option>';
}
}
$i++;
}
}
print '</select>';
}
else {
dolibarr_print_error($this->db);
}
}
/**
* \brief Renvoie la liste des sources de commandes
* \param selected Id de la source pré-sélectionnée
* \param htmlname Nom de la liste deroulante
* \param addempty 0=liste sans valeur nulle, 1=ajoute valeur inconnue
* \return array Tableau des sources de commandes
*/
function selectSourcesCommande($selected='',$htmlname='source_id',$addempty=0)
{
global $conf,$langs;
print '<select class="flat" name="'.$htmlname.'" '.$htmloption.'>';
if ($addempty) print '<option value="-1" selected="true">&nbsp;</option>';
// \TODO Aller cherches les sources dans dictionnaire
print '<option value="0"'.($selected=='0'?' selected="true"':'').'>'.$langs->trans('OrderSource0').'</option>';
print '<option value="1"'.($selected=='1'?' selected="true"':'').'>'.$langs->trans('OrderSource1').'</option>';
print '<option value="2"'.($selected=='2'?' selected="true"':'').'>'.$langs->trans('OrderSource2').'</option>';
print '<option value="3"'.($selected=='3'?' selected="true"':'').'>'.$langs->trans('OrderSource3').'</option>';
print '<option value="4"'.($selected=='4'?' selected="true"':'').'>'.$langs->trans('OrderSource4').'</option>';
print '<option value="5"'.($selected=='5'?' selected="true"':'').'>'.$langs->trans('OrderSource5').'</option>';
print '<option value="6"'.($selected=='6'?' selected="true"':'').'>'.$langs->trans('OrderSource6').'</option>';
print '</select>';
}
/**
*
*
*/
function select_methodes_commande($selected='',$htmlname='source_id',$addempty=0)
{
global $conf,$langs;
$listemethodes=array();
$sql = "SELECT rowid, libelle ";
$sql.= " FROM ".MAIN_DB_PREFIX."c_methode_commande_fournisseur";
$sql.= " WHERE active = 1";
dolibarr_syslog("Form::select_methodes_commande sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
$i = 0;
$num = $this->db->num_rows($resql);
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$listemethodes[$obj->rowid] = $obj->libelle;
$i++;
}
}
else
{
dolibarr_print_error($this->db);
return -1;
}
print $this->select_array($htmlname,$listemethodes,$selected,$addempty);
return 1;
}
/** /**
* \brief Retourne la liste déroulante des pays actifs, dans la langue de l'utilisateur * \brief Retourne la liste déroulante des pays actifs, dans la langue de l'utilisateur
@ -515,27 +314,6 @@ class Form
} }
/**
* \brief Retourne la liste des types de comptes financiers
* \param selected Type pré-sélectionné
* \param htmlname Nom champ formulaire
*/
function select_type_actions($selected='',$htmlname='actioncode')
{
global $langs,$user;
require_once(DOL_DOCUMENT_ROOT."/cactioncomm.class.php");
$caction=new CActionComm($this->db);
$arraylist=$caction->liste_array(1,'code');
$arraylist[0]='&nbsp;';
asort($arraylist);
$this->select_array($htmlname, $arraylist, $selected);
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
}
/** /**
* \brief Return list of social contributions * \brief Return list of social contributions
* \param selected Preselected type * \param selected Preselected type
@ -1361,110 +1139,6 @@ class Form
} }
/**
* \brief Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre)
* \param mode 0=renvoi id+libelle, 1=renvoi code+libelle
* \return array tableau des types d'effectifs
*/
function effectif_array($mode=0)
{
$effs = array();
$sql = "SELECT id, code, libelle";
$sql .= " FROM ".MAIN_DB_PREFIX."c_effectif";
$sql.= " WHERE active = 1";
$sql .= " ORDER BY id ASC";
dolibarr_syslog('Form::effectif_array sql='.$sql,LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$objp = $this->db->fetch_object($resql);
if (! $mode) $key=$objp->id;
else $key=$objp->code;
$effs[$key] = $objp->libelle!='-'?$objp->libelle:'';
$i++;
}
$this->db->free($resql);
}
return $effs;
}
/**
* \brief Renvoie la liste des formes juridiques existantes (pas de traduction car unique au pays)
* \return array tableau des formes juridiques
*/
function forme_juridique_array()
{
$fj = array();
$sql = "SELECT code, libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_forme_juridique";
$sql.= " WHERE active = 1";
$sql.= " ORDER BY code ASC";
dolibarr_syslog('Form::forme_juridique_array sql='.$sql,LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$objp = $this->db->fetch_object($resql);
$fj[$objp->code] = $objp->libelle!='-'?$objp->libelle:'';
$i++;
}
$this->db->free($resql);
}
return $fj;
}
/**
* \brief Renvoie la liste des libelles traduits des types actifs de societes
* \param mode 0=renvoi id+libelle, 1=renvoi code+libelle
* \return array tableau des types
*/
function typent_array($mode=0)
{
global $langs;
$effs = array();
$sql = "SELECT id, code, libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_typent";
$sql.= " WHERE active = 1";
$sql.= " ORDER by id";
dolibarr_syslog('Form::typent_array sql='.$sql,LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$objp = $this->db->fetch_object($resql);
if (! $mode) $key=$objp->id;
else $key=$objp->code;
if ($langs->trans($objp->code) != $objp->code)
$effs[$key] = $langs->trans($objp->code);
else
$effs[$key] = $objp->libelle!='-'?$objp->libelle:'';
$i++;
}
$this->db->free($resql);
}
return $effs;
}
/** /**
* \brief Charge dans cache la liste des conditions de paiements possibles * \brief Charge dans cache la liste des conditions de paiements possibles
* \return int Nb lignes chargées, 0 si déjà chargées, <0 si ko * \return int Nb lignes chargées, 0 si déjà chargées, <0 si ko
@ -1791,128 +1465,6 @@ class Form
} }
/**
* \brief Retourne la liste déroulante des civilite actives
* \param selected civilite pré-sélectionnée
*/
function select_civilite($selected='')
{
global $conf,$langs,$user;
$langs->load("dict");
$sql = "SELECT rowid, code, civilite, active FROM ".MAIN_DB_PREFIX."c_civilite";
$sql .= " WHERE active = 1";
dolibarr_syslog("Form::select_civilite sql=".$sql);
if ($this->db->query($sql))
{
print '<select class="flat" name="civilite_id">';
print '<option value="">&nbsp;</option>';
$num = $this->db->num_rows();
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $this->db->fetch_object();
if ($selected == $obj->code)
{
print '<option value="'.$obj->code.'" selected="true">';
}
else
{
print '<option value="'.$obj->code.'">';
}
// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
print ($langs->trans("Civility".$obj->code)!="Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite!='-'?$obj->civilite:''));
print '</option>';
$i++;
}
}
print '</select>';
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
}
else
{
dolibarr_print_error($this->db);
}
}
/**
* \brief Retourne la liste déroulante des formes juridiques tous pays confondus ou pour un pays donné.
* \remarks Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays
* \param selected Code forme juridique a pré-sélectionné
* \param pays_code 0=liste tous pays confondus, sinon code du pays à afficher
*/
function select_forme_juridique($selected='',$pays_code=0)
{
global $conf,$langs,$user;
$langs->load("dict");
// On recherche les formes juridiques actives des pays actifs
$sql = "SELECT f.rowid, f.code as code , f.libelle as nom, f.active, p.libelle as libelle_pays, p.code as code_pays";
$sql .= " FROM llx_c_forme_juridique as f, llx_c_pays as p";
$sql .= " WHERE f.fk_pays=p.rowid";
$sql .= " AND f.active = 1 AND p.active = 1";
if ($pays_code) $sql .= " AND p.code = '".$pays_code."'";
$sql .= " ORDER BY p.code, f.code";
dolibarr_syslog("Form::select_forme_juridique sql=".$sql);
$result=$this->db->query($sql);
if ($result)
{
print '<div id="particulier2" class="visible">';
print '<select class="flat" name="forme_juridique_code">';
if ($pays_code) print '<option value="0">&nbsp;</option>';
$num = $this->db->num_rows($result);
$i = 0;
if ($num)
{
$pays='';
while ($i < $num)
{
$obj = $this->db->fetch_object($result);
if ($obj->code == 0) {
print '<option value="0">&nbsp;</option>';
}
else {
if (! $pays || $pays != $obj->libelle_pays) {
// Affiche la rupture si on est en mode liste multipays
if (! $pays_code && $obj->code_pays) {
print '<option value="0">----- '.$obj->libelle_pays." -----</option>\n";
$pays=$obj->libelle_pays;
}
}
if ($selected > 0 && $selected == $obj->code)
{
print '<option value="'.$obj->code.'" selected="true">';
}
else
{
print '<option value="'.$obj->code.'">';
}
// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
print $obj->code . ' - ';
print ($langs->trans("JuridicalStatus".$obj->code)!="JuridicalStatus".$obj->code?$langs->trans("JuridicalStatus".$obj->code):($obj->nom!='-'?$langs->convToOutputCharset($obj->nom):''));
print '</option>';
}
$i++;
}
}
print '</select>';
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
print '</div>';
}
else
{
dolibarr_print_error($this->db);
}
}
/** /**
* \brief Affiche formulaire de demande de confirmation * \brief Affiche formulaire de demande de confirmation
* \param page page * \param page page
@ -2082,38 +1634,6 @@ class Form
} }
} }
/**
* \brief Affiche formulaire de selection de l'assujétissement à la TVA
* \param page Page
* \param selected Id condition pré-sélectionnée
* \param htmlname Nom du formulaire select
*/
function form_assujetti_tva($page, $selected='', $htmlname='')
{
global $langs;
$options = array(0=>"non",1=>"oui");
if ($htmlname != "none")
{
print '<form method="post" action="'.$page.'">';
print '<input type="hidden" name="action" value="setassujtva">';
print '<table class="noborder" cellpadding="0" cellspacing="0">';
print '<tr><td>';
$this->select_assujetti_tva($selected,$htmlname);
print '</td>';
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr></table></form>';
}
else
{
if ($selected != "")
{
print $options[$selected];
} else {
print "&nbsp;";
}
}
}
/** /**
* \brief Affiche formulaire de selection des modes de reglement * \brief Affiche formulaire de selection des modes de reglement
@ -2148,58 +1668,6 @@ class Form
} }
/**
* \brief Affiche formulaire de selection des modes de reglement
* \param page Page
* \param selected Id or code preselected
* \param htmlname Nom du formulaire select
* \param empty Add empty value in list
*/
function form_prospect_level($page, $selected='', $htmlname='prospect_level_id', $empty=0)
{
global $langs;
print '<form method="post" action="'.$page.'">';
print '<input type="hidden" name="action" value="setprospectlevel">';
print '<table class="noborder" cellpadding="0" cellspacing="0">';
print '<tr><td>';
print '<select class="flat" name="'.$htmlname.'">';
if ($empty) print '<option value="">&nbsp;</option>';
dolibarr_syslog('Form::form_prospect_level',LOG_DEBUG);
$sql = "SELECT code, label";
$sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel";
$sql.= " WHERE active > 0";
$sql.= " ORDER BY sortorder";
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
print '<option value="'.$obj->code.'"';
if ($selected == $obj->code) print ' selected="true"';
print '>';
$level=$langs->trans($obj->code);
if ($level == $obj->code) $level=$langs->trans($obj->label);
print $level;
print '</option>';
$i++;
}
}
else dolibarr_print_error($this->db);
print '</select>';
print '</td>';
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr></table></form>';
}
/** /**
* \brief Affiche formulaire de selection de la remise fixe * \brief Affiche formulaire de selection de la remise fixe
* \param page Page URL where form is shown * \param page Page URL where form is shown

View File

@ -148,4 +148,27 @@ class FormActions
} }
} }
/**
* \brief Retourne la liste des types de comptes financiers
* \param selected Type pré-sélectionné
* \param htmlname Nom champ formulaire
*/
function select_type_actions($selected='',$htmlname='actioncode')
{
global $langs,$user;
require_once(DOL_DOCUMENT_ROOT."/cactioncomm.class.php");
require_once(DOL_DOCUMENT_ROOT."/html.form.class.php");
$caction=new CActionComm($this->db);
$form=new Form($this->db);
$arraylist=$caction->liste_array(1,'code');
$arraylist[0]='&nbsp;';
asort($arraylist);
$form->select_array($htmlname, $arraylist, $selected);
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
}
} }

View File

@ -0,0 +1,441 @@
<?php
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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.formcompany.class.php
* \brief Fichier de la classe des fonctions prédéfinie de composants html
* \version $Id$
*/
/**
* \class FormCompany
* \brief Classe permettant la génération de composants html
* \remarks Only common components must be here.
*/
class FormCompany
{
var $db;
var $error;
/**
* \brief Constructeur
* \param DB handler d'accès base de donnée
*/
function FormCompany($DB)
{
$this->db = $DB;
return 1;
}
/**
* \brief Renvoie la liste des libelles traduits des types actifs de societes
* \param mode 0=renvoi id+libelle, 1=renvoi code+libelle
* \return array tableau des types
*/
function typent_array($mode=0)
{
global $langs;
$effs = array();
$sql = "SELECT id, code, libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_typent";
$sql.= " WHERE active = 1";
$sql.= " ORDER by id";
dolibarr_syslog('Form::typent_array sql='.$sql,LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$objp = $this->db->fetch_object($resql);
if (! $mode) $key=$objp->id;
else $key=$objp->code;
if ($langs->trans($objp->code) != $objp->code)
$effs[$key] = $langs->trans($objp->code);
else
$effs[$key] = $objp->libelle!='-'?$objp->libelle:'';
$i++;
}
$this->db->free($resql);
}
return $effs;
}
/**
* \brief Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre)
* \param mode 0=renvoi id+libelle, 1=renvoi code+libelle
* \return array tableau des types d'effectifs
*/
function effectif_array($mode=0)
{
$effs = array();
$sql = "SELECT id, code, libelle";
$sql .= " FROM ".MAIN_DB_PREFIX."c_effectif";
$sql.= " WHERE active = 1";
$sql .= " ORDER BY id ASC";
dolibarr_syslog('Form::effectif_array sql='.$sql,LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$objp = $this->db->fetch_object($resql);
if (! $mode) $key=$objp->id;
else $key=$objp->code;
$effs[$key] = $objp->libelle!='-'?$objp->libelle:'';
$i++;
}
$this->db->free($resql);
}
return $effs;
}
/**
* \brief Affiche formulaire de selection des modes de reglement
* \param page Page
* \param selected Id or code preselected
* \param htmlname Nom du formulaire select
* \param empty Add empty value in list
*/
function form_prospect_level($page, $selected='', $htmlname='prospect_level_id', $empty=0)
{
global $langs;
print '<form method="post" action="'.$page.'">';
print '<input type="hidden" name="action" value="setprospectlevel">';
print '<table class="noborder" cellpadding="0" cellspacing="0">';
print '<tr><td>';
print '<select class="flat" name="'.$htmlname.'">';
if ($empty) print '<option value="">&nbsp;</option>';
dolibarr_syslog('Form::form_prospect_level',LOG_DEBUG);
$sql = "SELECT code, label";
$sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel";
$sql.= " WHERE active > 0";
$sql.= " ORDER BY sortorder";
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
print '<option value="'.$obj->code.'"';
if ($selected == $obj->code) print ' selected="true"';
print '>';
$level=$langs->trans($obj->code);
if ($level == $obj->code) $level=$langs->trans($obj->label);
print $level;
print '</option>';
$i++;
}
}
else dolibarr_print_error($this->db);
print '</select>';
print '</td>';
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr></table></form>';
}
/**
* \brief Retourne la liste déroulante des départements/province/cantons tout pays confondu ou pour un pays donné.
* \remarks Dans le cas d'une liste tout pays confondus, l'affichage fait une rupture sur le pays.
* \remarks La cle de la liste est le code (il peut y avoir plusieurs entrée pour
* un code donnée mais dans ce cas, le champ pays diffère).
* Ainsi les liens avec les départements se font sur un département indépendemment de son nom.
* \param selected code forme juridique a présélectionné
* \param pays_code 0=liste tous pays confondus, sinon code du pays à afficher
*/
function select_departement($selected='',$pays_code=0)
{
global $conf,$langs,$user;
dolibarr_syslog("Form::select_departement selected=$selected, pays_code=$pays_code",LOG_DEBUG);
$langs->load("dict");
$htmlname='departement_id';
// On recherche les départements/cantons/province active d'une region et pays actif
$sql = "SELECT d.rowid, d.code_departement as code , d.nom, d.active, p.libelle as libelle_pays, p.code as code_pays FROM";
$sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_pays as p";
$sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=p.rowid";
$sql .= " AND d.active = 1 AND r.active = 1 AND p.active = 1";
if ($pays_code) $sql .= " AND p.code = '".$pays_code."'";
$sql .= " ORDER BY p.code, d.code_departement";
dolibarr_syslog("Form::select_departement sql=".$sql);
$result=$this->db->query($sql);
if ($result)
{
print '<select class="flat" name="'.$htmlname.'">';
if ($pays_code) print '<option value="0">&nbsp;</option>';
$num = $this->db->num_rows($result);
$i = 0;
dolibarr_syslog("Form::select_departement num=$num",LOG_DEBUG);
if ($num)
{
$pays='';
while ($i < $num)
{
$obj = $this->db->fetch_object($result);
if ($obj->code == '0') // Le code peut etre une chaine
{
print '<option value="0">&nbsp;</option>';
}
else {
if (! $pays || $pays != $obj->libelle_pays)
{
// Affiche la rupture si on est en mode liste multipays
if (! $pays_code && $obj->code_pays)
{
print '<option value="-1">----- '.$obj->libelle_pays." -----</option>\n";
$pays=$obj->libelle_pays;
}
}
if ($selected > 0 && $selected == $obj->rowid)
{
print '<option value="'.$obj->rowid.'" selected="true">';
}
else
{
print '<option value="'.$obj->rowid.'">';
}
// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
print $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->nom!='-'?$obj->nom:''));
print '</option>';
}
$i++;
}
}
print '</select>';
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
}
else
{
dolibarr_print_error($this->db);
}
}
/**
* \brief Retourne la liste déroulante des regions actives dont le pays est actif
* \remarks La cle de la liste est le code (il peut y avoir plusieurs entrée pour
* un code donnée mais dans ce cas, le champ pays et lang diffère).
* Ainsi les liens avec les regions se font sur une region independemment
* de son nom.
*/
function select_region($selected='',$htmlname='region_id')
{
global $conf,$langs;
$langs->load("dict");
$sql = "SELECT r.rowid, r.code_region as code, r.nom as libelle, r.active, p.libelle as libelle_pays FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_pays as p";
$sql .= " WHERE r.fk_pays=p.rowid AND r.active = 1 and p.active = 1 ORDER BY libelle_pays, libelle ASC";
dolibarr_syslog("Form::select_region sql=".$sql);
if ($this->db->query($sql))
{
print '<select class="flat" name="'.$htmlname.'">';
$num = $this->db->num_rows();
$i = 0;
if ($num)
{
$pays='';
while ($i < $num)
{
$obj = $this->db->fetch_object();
if ($obj->code == 0) {
print '<option value="0">&nbsp;</option>';
}
else {
if ($pays == '' || $pays != $obj->libelle_pays)
{
// Affiche la rupture
print '<option value="-1" disabled="disabled">----- '.$obj->libelle_pays." -----</option>\n";
$pays=$obj->libelle_pays;
}
if ($selected > 0 && $selected == $obj->code)
{
print '<option value="'.$obj->code.'" selected="true">'.$obj->libelle.'</option>';
}
else
{
print '<option value="'.$obj->code.'">'.$obj->libelle.'</option>';
}
}
$i++;
}
}
print '</select>';
}
else
{
dolibarr_print_error($this->db);
}
}
/**
* \brief Retourne la liste déroulante des civilite actives
* \param selected civilite pré-sélectionnée
*/
function select_civilite($selected='')
{
global $conf,$langs,$user;
$langs->load("dict");
$sql = "SELECT rowid, code, civilite, active FROM ".MAIN_DB_PREFIX."c_civilite";
$sql .= " WHERE active = 1";
dolibarr_syslog("Form::select_civilite sql=".$sql);
if ($this->db->query($sql))
{
print '<select class="flat" name="civilite_id">';
print '<option value="">&nbsp;</option>';
$num = $this->db->num_rows();
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $this->db->fetch_object();
if ($selected == $obj->code)
{
print '<option value="'.$obj->code.'" selected="true">';
}
else
{
print '<option value="'.$obj->code.'">';
}
// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
print ($langs->trans("Civility".$obj->code)!="Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite!='-'?$obj->civilite:''));
print '</option>';
$i++;
}
}
print '</select>';
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
}
else
{
dolibarr_print_error($this->db);
}
}
/**
* \brief Retourne la liste déroulante des formes juridiques tous pays confondus ou pour un pays donné.
* \remarks Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays
* \param selected Code forme juridique a pré-sélectionné
* \param pays_code 0=liste tous pays confondus, sinon code du pays à afficher
*/
function select_forme_juridique($selected='',$pays_code=0)
{
global $conf,$langs,$user;
$langs->load("dict");
// On recherche les formes juridiques actives des pays actifs
$sql = "SELECT f.rowid, f.code as code , f.libelle as nom, f.active, p.libelle as libelle_pays, p.code as code_pays";
$sql .= " FROM llx_c_forme_juridique as f, llx_c_pays as p";
$sql .= " WHERE f.fk_pays=p.rowid";
$sql .= " AND f.active = 1 AND p.active = 1";
if ($pays_code) $sql .= " AND p.code = '".$pays_code."'";
$sql .= " ORDER BY p.code, f.code";
dolibarr_syslog("Form::select_forme_juridique sql=".$sql);
$result=$this->db->query($sql);
if ($result)
{
print '<div id="particulier2" class="visible">';
print '<select class="flat" name="forme_juridique_code">';
if ($pays_code) print '<option value="0">&nbsp;</option>';
$num = $this->db->num_rows($result);
$i = 0;
if ($num)
{
$pays='';
while ($i < $num)
{
$obj = $this->db->fetch_object($result);
if ($obj->code == 0) {
print '<option value="0">&nbsp;</option>';
}
else {
if (! $pays || $pays != $obj->libelle_pays) {
// Affiche la rupture si on est en mode liste multipays
if (! $pays_code && $obj->code_pays) {
print '<option value="0">----- '.$obj->libelle_pays." -----</option>\n";
$pays=$obj->libelle_pays;
}
}
if ($selected > 0 && $selected == $obj->code)
{
print '<option value="'.$obj->code.'" selected="true">';
}
else
{
print '<option value="'.$obj->code.'">';
}
// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
print $obj->code . ' - ';
print ($langs->trans("JuridicalStatus".$obj->code)!="JuridicalStatus".$obj->code?$langs->trans("JuridicalStatus".$obj->code):($obj->nom!='-'?$langs->convToOutputCharset($obj->nom):''));
print '</option>';
}
$i++;
}
}
print '</select>';
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
print '</div>';
}
else
{
dolibarr_print_error($this->db);
}
}
}
?>

View File

@ -0,0 +1,114 @@
<?php
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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.formorder.class.php
* \brief Fichier de la classe des fonctions prédéfinie de composants html
* \version $Id$
*/
/**
* \class FormOrder
* \brief Classe permettant la génération de composants html
* \remarks Only common components must be here.
*/
class FormOrder
{
var $db;
var $error;
/**
* \brief Constructeur
* \param DB handler d'accès base de donnée
*/
function FormOrder($DB)
{
$this->db = $DB;
return 1;
}
/**
* \brief Renvoie la liste des sources de commandes
* \param selected Id de la source pré-sélectionnée
* \param htmlname Nom de la liste deroulante
* \param addempty 0=liste sans valeur nulle, 1=ajoute valeur inconnue
* \return array Tableau des sources de commandes
*/
function selectSourcesCommande($selected='',$htmlname='source_id',$addempty=0)
{
global $conf,$langs;
print '<select class="flat" name="'.$htmlname.'" '.$htmloption.'>';
if ($addempty) print '<option value="-1" selected="true">&nbsp;</option>';
// \TODO Aller chercher les sources dans dictionnaire
print '<option value="0"'.($selected=='0'?' selected="true"':'').'>'.$langs->trans('OrderSource0').'</option>';
print '<option value="1"'.($selected=='1'?' selected="true"':'').'>'.$langs->trans('OrderSource1').'</option>';
print '<option value="2"'.($selected=='2'?' selected="true"':'').'>'.$langs->trans('OrderSource2').'</option>';
print '<option value="3"'.($selected=='3'?' selected="true"':'').'>'.$langs->trans('OrderSource3').'</option>';
print '<option value="4"'.($selected=='4'?' selected="true"':'').'>'.$langs->trans('OrderSource4').'</option>';
print '<option value="5"'.($selected=='5'?' selected="true"':'').'>'.$langs->trans('OrderSource5').'</option>';
print '<option value="6"'.($selected=='6'?' selected="true"':'').'>'.$langs->trans('OrderSource6').'</option>';
print '</select>';
}
/**
*
*
*/
function select_methodes_commande($selected='',$htmlname='source_id',$addempty=0)
{
global $conf,$langs;
$listemethodes=array();
$sql = "SELECT rowid, libelle ";
$sql.= " FROM ".MAIN_DB_PREFIX."c_methode_commande_fournisseur";
$sql.= " WHERE active = 1";
dolibarr_syslog("Form::select_methodes_commande sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
$i = 0;
$num = $this->db->num_rows($resql);
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$listemethodes[$obj->rowid] = $obj->libelle;
$i++;
}
}
else
{
dolibarr_print_error($this->db);
return -1;
}
print $this->select_array($htmlname,$listemethodes,$selected,$addempty);
return 1;
}
}
?>

View File

@ -30,6 +30,7 @@
require("pre.inc.php"); require("pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/html.formcompany.class.php");
require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
$langs->load("companies"); $langs->load("companies");
@ -266,6 +267,8 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' &&
llxHeader(); llxHeader();
$form = new Form($db); $form = new Form($db);
$formcompany = new FormCompany($db);
$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
@ -390,7 +393,7 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create')
print '<td colspan=2>&nbsp;</td></tr>'; print '<td colspan=2>&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("UserTitle").'</td><td>'; print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
print $form->select_civilite($contact->civilite_id).'</td>'; print $formcompany->select_civilite($contact->civilite_id).'</td>';
print '<td colspan=2>&nbsp;</td></tr>'; print '<td colspan=2>&nbsp;</td></tr>';
} }
@ -483,7 +486,7 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create')
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'; print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
if ($soc->pays_id) if ($soc->pays_id)
{ {
$form->select_departement($soc->departement_id,$soc->pays_code); $formcompany->select_departement($soc->departement_id,$soc->pays_code);
} }
else else
{ {
@ -546,7 +549,7 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create')
print '<td colspan="3">'; print '<td colspan="3">';
if ($soc->pays_id) if ($soc->pays_id)
{ {
$form->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); $formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code);
} }
else else
{ {
@ -555,11 +558,11 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create')
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("Type").'</td><td>'."\n"; print '<tr><td>'.$langs->trans("Type").'</td><td>'."\n";
$form->select_array("typent_id",$form->typent_array(0), $soc->typent_id); $form->select_array("typent_id",$formcompany->typent_array(0), $soc->typent_id);
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
print '</td>'; print '</td>';
print '<td>'.$langs->trans("Staff").'</td><td>'; print '<td>'.$langs->trans("Staff").'</td><td>';
$form->select_array("effectif_id",$form->effectif_array(0), $soc->effectif_id); $form->select_array("effectif_id",$formcompany->effectif_array(0), $soc->effectif_id);
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
print '</td></tr>'; print '</td></tr>';
@ -834,7 +837,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'; print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
$form->select_departement($soc->departement_id,$soc->pays_code); $formcompany->select_departement($soc->departement_id,$soc->pays_code);
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="tel" value="'.$soc->tel.'"></td>'; print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="tel" value="'.$soc->tel.'"></td>';
@ -920,15 +923,15 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
print '<tr><td>'.$langs->trans("Capital").'</td><td colspan="3"><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; print '<tr><td>'.$langs->trans("Capital").'</td><td colspan="3"><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">'; print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">';
$form->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); $formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code);
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("Type").'</td><td>'; print '<tr><td>'.$langs->trans("Type").'</td><td>';
$form->select_array("typent_id",$form->typent_array(0), $soc->typent_id); $form->select_array("typent_id",$formcompany->typent_array(0), $soc->typent_id);
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
print '</td>'; print '</td>';
print '<td>'.$langs->trans("Staff").'</td><td>'; print '<td>'.$langs->trans("Staff").'</td><td>';
$form->select_array("effectif_id",$form->effectif_array(0), $soc->effectif_id); $form->select_array("effectif_id",$formcompany->effectif_array(0), $soc->effectif_id);
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
print '</td></tr>'; print '</td></tr>';
@ -1147,7 +1150,7 @@ else
print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">'.$soc->forme_juridique.'</td></tr>'; print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">'.$soc->forme_juridique.'</td></tr>';
// Type + Staff // Type + Staff
$arr = $form->typent_array(1); $arr = $formcompany->typent_array(1);
$soc->typent= $arr[$soc->typent_code]; $soc->typent= $arr[$soc->typent_code];
print '<tr><td>'.$langs->trans("Type").'</td><td>'.$soc->typent.'</td><td>'.$langs->trans("Staff").'</td><td>'.$soc->effectif.'</td></tr>'; print '<tr><td>'.$langs->trans("Type").'</td><td>'.$soc->typent.'</td><td>'.$langs->trans("Staff").'</td><td>'.$soc->effectif.'</td></tr>';