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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -28,6 +28,7 @@
require_once("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.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."/actioncomm.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();
$form=new Form($db);
$formcompany=new FormCompany($db);
if ($socid > 0)
{
@ -127,12 +130,12 @@ if ($socid > 0)
print '</td><td colspan="3">';
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
{
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 '</tr>';

View File

@ -29,7 +29,8 @@
require('./pre.inc.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.'/actioncomm.class.php');
require_once(DOL_DOCUMENT_ROOT."/lib/order.lib.php");
@ -837,6 +838,8 @@ llxHeader('',$langs->trans('Order'),'Commande');
$html = new Form($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">';
$html->selectSourcesCommande('','source_id',1);
$formorder->selectSourcesCommande('','source_id',1);
print '</td></tr>';
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."/lib/contact.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("users");
@ -195,6 +196,7 @@ if ($user->rights->societe->contact->creer)
llxHeader();
$form = new Form($db);
$formcompany = new FormCompany($db);
if ($socid)
{
@ -289,7 +291,7 @@ if ($user->rights->societe->contact->creer)
// Civility
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 '<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
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 '<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

@ -20,11 +20,11 @@
*/
/**
\file htdocs/fourn/commande/fiche.php
\ingroup commande
\brief Fiche de ventilation des commandes fournisseurs
\version $Id$
*/
\file htdocs/fourn/commande/fiche.php
\ingroup commande
\brief Fiche de ventilation des commandes fournisseurs
\version $Id$
*/
require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT.'/includes/modules/supplier_order/modules_commandefournisseur.php');
@ -45,15 +45,15 @@ if (!$user->rights->fournisseur->commande->lire) accessforbidden();
$socid=0;
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
$action = '';
$socid = $user->societe_id;
}
// Récupération de l'id de projet
$projetid = 0;
if ($_GET["projetid"])
{
$projetid = $_GET["projetid"];
$projetid = $_GET["projetid"];
}
$mesg='';
@ -63,23 +63,23 @@ $mesg='';
*/
if ($_POST["action"] == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
{
$commande = new CommandeFournisseur($db);
$commande->fetch($_GET["id"]);
$commande = new CommandeFournisseur($db);
$commande->fetch($_GET["id"]);
foreach($_POST as $key => $value)
{
if ( eregi('^product_([0-9]+)$', $key, $reg) )
foreach($_POST as $key => $value)
{
if ( eregi('^product_([0-9]+)$', $key, $reg) )
{
$prod = "product_".$reg[1];
$qty = "qty_".$reg[1];
$ent = "entrepot_".$reg[1];
$pu = "pu_".$reg[1];
$result = $commande->DispatchProduct($user, $_POST[$prod], $_POST[$qty], $_POST[$ent], $_POST[$pu]);
}
}
}
Header("Location: dispatch.php?id=".$_GET["id"]);
exit;
Header("Location: dispatch.php?id=".$_GET["id"]);
exit;
}
@ -96,307 +96,307 @@ $html = new Form($db);
$id = $_GET['id'];
if ($id > 0)
{
//if ($mesg) print $mesg.'<br>';
$commande = new CommandeFournisseur($db);
if ( $commande->fetch($_GET['id']) >= 0)
{
$soc = new Societe($db);
$soc->fetch($commande->socid);
$author = new User($db);
$author->id = $commande->user_author_id;
$author->fetch();
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans("OrderCard");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$commande->id;
$head[$h][1] = $langs->trans("OrderDispatch");
$a = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$commande->id;
$head[$h][1] = $langs->trans("Note");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$commande->id;
$head[$h][1] = $langs->trans("OrderFollow");
$h++;
$title=$langs->trans("SupplierOrder");
dolibarr_fiche_head($head, $a, $title);
/*
* Commande
*/
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
print '<td colspan="5">'.$commande->ref.'</td>';
print '</tr>';
// Fournisseur
print '<tr><td width="20%">'.$langs->trans("Supplier")."</td>";
print '<td colspan="5">';
print '<b><a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$soc->id.'">';
print img_object($langs->trans("ShowSupplier"),'company').' '.$soc->nom.'</a></b></td>';
print '</tr>';
// Statut
print '<tr>';
print '<td>'.$langs->trans("Status").'</td>';
print '<td width="50%" colspan="5">';
print $commande->getLibStatut(4);
print "</td></tr>";
//if ($mesg) print $mesg.'<br>';
if ($commande->methode_commande_id > 0)
$commande = new CommandeFournisseur($db);
if ( $commande->fetch($_GET['id']) >= 0)
{
print '<tr><td>'.$langs->trans("Date").'</td><td colspan="2">';
if ($commande->date_commande)
{
print dolibarr_print_date($commande->date_commande,"dayhourtext")."\n";
}
print '</td><td width="50%" colspan="3">';
if ($commande->methode_commande)
{
print "Méthode : " .$commande->methode_commande;
}
print "</td></tr>";
$soc = new Societe($db);
$soc->fetch($commande->socid);
$author = new User($db);
$author->id = $commande->user_author_id;
$author->fetch();
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans("OrderCard");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$commande->id;
$head[$h][1] = $langs->trans("OrderDispatch");
$a = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$commande->id;
$head[$h][1] = $langs->trans("Note");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$commande->id;
$head[$h][1] = $langs->trans("OrderFollow");
$h++;
$title=$langs->trans("SupplierOrder");
dolibarr_fiche_head($head, $a, $title);
/*
* Commande
*/
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
print '<td colspan="5">'.$commande->ref.'</td>';
print '</tr>';
// Fournisseur
print '<tr><td width="20%">'.$langs->trans("Supplier")."</td>";
print '<td colspan="5">';
print '<b><a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$soc->id.'">';
print img_object($langs->trans("ShowSupplier"),'company').' '.$soc->nom.'</a></b></td>';
print '</tr>';
// Statut
print '<tr>';
print '<td>'.$langs->trans("Status").'</td>';
print '<td width="50%" colspan="5">';
print $commande->getLibStatut(4);
print "</td></tr>";
if ($commande->methode_commande_id > 0)
{
print '<tr><td>'.$langs->trans("Date").'</td><td colspan="2">';
if ($commande->date_commande)
{
print dolibarr_print_date($commande->date_commande,"dayhourtext")."\n";
}
print '</td><td width="50%" colspan="3">';
if ($commande->methode_commande)
{
print $langs->trans("Method")." : " .$commande->methode_commande;
}
print "</td></tr>";
}
// Auteur
print '<tr><td>'.$langs->trans("AuthorRequest").'</td>';
print '<td colspan="2">'.$author->getNomUrl(1).'</td>';
print '<td colspan="3" width="50%">';
print "&nbsp;</td></tr>";
print "</table>";
if ($mesg) print $mesg;
else print '<br>';
/*
* Lignes de commandes
*/
if ($commande->statut == 3 || $commande->statut == 4 || $commande->statut == 5)
{
print '<form method="POST" action="dispatch.php?id='.$commande->id.'">';
print '<input type="hidden" name="action" value="dispatch">';
print '<table class="noborder" width="100%">';
$sql = "SELECT cfd.fk_product, sum(cfd.qty) as qty";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd";
$sql.= " WHERE cfd.fk_commande = ".$commande->id;
$sql.= " GROUP BY cfd.fk_product";
$resql = $db->query($sql);
if ($resql)
{
while ( $row = $db->fetch_row($resql) )
{
$products_dispatched[$row[0]] = $row[1];
}
$db->free($resql);
}
$sql = "SELECT l.ref,l.fk_product,l.description, l.subprice, sum(l.qty) as qty";
$sql.= ", l.rowid";
$sql.= ", p.label";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product=p.rowid";
$sql.= " WHERE l.fk_commande = ".$commande->id;
$sql.= " GROUP BY l.fk_product";
$sql.= " ORDER BY l.rowid";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
if ($num)
{
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="right">'.$langs->trans("QtyOrdered").'</td>';
print '<td align="right">'.$langs->trans("QtyDispatched").'</td>';
print '<td align="right">'.$langs->trans("Warehouse").'</td>';
print '<td align="right">'.$langs->trans("QtyDelivered").'</td>';
print "</tr>\n";
}
$entrepot = new Entrepot($db);
$var=true;
while ($i < $num)
{
$objp = $db->fetch_object($resql);
// On n'affiche pas les produits personnalisés
if ($objp->fk_product)
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"),'product').' '.$objp->ref.'</a>';
print ' - '.$objp->label;
if ($objp->description) print '<br>'.nl2br($objp->description);
print '<input name="product_'.$i.'" type="hidden" value="'.$objp->fk_product.'">';
print '<input name="pu_'.$i.'" type="hidden" value="'.$objp->subprice.'">';
print "</td>\n";
print '<td align="right">'.$objp->qty.'</td>';
print '<td align="right">'.$products_dispatched[$objp->fk_product].'</td>';
print '<td align="right">';
if (sizeof($user->entrepots) === 1)
{
$uentrepot = array();
$uentrepot[$user->entrepots[0]['id']] = $user->entrepots[0]['label'];
$html->select_array("entrepot_".$i, $uentrepot);
}
else
{
$html->select_array("entrepot_".$i, $entrepot->list_array());
}
print "</td>\n";
print '<td align="right"><input name="qty_'.$i.'" type="text" size="8" value="'.($objp->qty-$products_dispatched[$objp->fk_product]).'"></td>';
print "</tr>\n";
}
$i++;
}
$db->free($resql);
}
else
{
dolibarr_print_error($db);
}
print "</table>\n";
print "<br/>\n";
print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'"></center></form>';
}
print "<br/>\n";
print '<table class="noborder" width="100%">';
$sql = "SELECT p.ref,cfd.fk_product, cfd.qty";
$sql.= ", cfd.rowid";
$sql.= ", p.label, e.label as entrepot";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd";
$sql.= " , ".MAIN_DB_PREFIX."product as p ";
$sql.= " , ".MAIN_DB_PREFIX."entrepot as e ";
$sql.= " WHERE cfd.fk_commande = ".$commande->id;
$sql.= " AND cfd.fk_product = p.rowid";
$sql.= " AND cfd.fk_entrepot = e.rowid";
$sql.= " ORDER BY cfd.rowid ASC;";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
if ($num)
{
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="right">'.$langs->trans("QtyDispatched").'</td>';
print '<td align="right">'.$langs->trans("Warehouse").'</td>';
print "</tr>\n";
}
$var=false;
while ($i < $num)
{
$objp = $db->fetch_object($resql);
print "<tr $bc[$var]>";
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"),'product').' '.$objp->ref.'</a>';
print ' - '.$objp->label;
print "</td>\n";
print '<td align="right">'.$objp->qty.'</td>';
print '<td align="right">'.stripslashes($objp->entrepot).'</td>';
print "</tr>\n";
$i++;
$var=!$var;
}
$db->free($resql);
}
else
{
dolibarr_print_error($db);
}
print "</table>\n";
print '</div>';
/**
* Boutons actions
*/
if ($user->societe_id == 0 && $commande->statut < 3 && ($_GET["action"] <> 'valid' || $_GET['action'] == 'builddoc'))
{
print '<div class="tabsAction">';
if ($commande->statut == 0 && $num > 0)
{
if ($user->rights->fournisseur->commande->valider)
{
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&amp;action=valid">'.$langs->trans("Valid").'</a>';
}
}
if ($commande->statut == 1)
{
if ($user->rights->fournisseur->commande->approuver)
{
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&amp;action=approve">'.$langs->trans("ApproveOrder").'</a>';
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&amp;action=refuse">'.$langs->trans("RefuseOrder").'</a>';
}
if ($user->rights->fournisseur->commande->annuler)
{
print '<a class="butActionDelete" href="fiche.php?id='.$commande->id.'&amp;action=cancel">'.$langs->trans("CancelOrder").'</a>';
}
}
if ($commande->statut == 2)
{
if ($user->rights->fournisseur->commande->annuler)
{
print '<a class="butActionDelete" href="fiche.php?id='.$commande->id.'&amp;action=cancel">'.$langs->trans("CancelOrder").'</a>';
}
}
if ($commande->statut == 0)
{
if ($user->rights->fournisseur->commande->creer)
{
print '<a class="butActionDelete" href="fiche.php?id='.$commande->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
}
}
print "</div>";
}
/*
*
*
*/
}
// Auteur
print '<tr><td>'.$langs->trans("AuthorRequest").'</td>';
print '<td colspan="2">'.$author->getNomUrl(1).'</td>';
print '<td colspan="3" width="50%">';
print "&nbsp;</td></tr>";
print "</table>";
if ($mesg) print $mesg;
else print '<br>';
/*
* Lignes de commandes
*/
if ($commande->statut == 3 || $commande->statut == 4 || $commande->statut == 5)
else
{
print '<form method="POST" action="dispatch.php?id='.$commande->id.'">';
print '<input type="hidden" name="action" value="dispatch">';
print '<table class="noborder" width="100%">';
$sql = "SELECT cfd.fk_product, sum(cfd.qty) as qty";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd";
$sql.= " WHERE cfd.fk_commande = ".$commande->id;
$sql.= " GROUP BY cfd.fk_product";
$resql = $db->query($sql);
if ($resql)
{
while ( $row = $db->fetch_row($resql) )
{
$products_dispatched[$row[0]] = $row[1];
}
$db->free($resql);
}
$sql = "SELECT l.ref,l.fk_product,l.description, l.subprice, sum(l.qty) as qty";
$sql.= ", l.rowid";
$sql.= ", p.label";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product=p.rowid";
$sql.= " WHERE l.fk_commande = ".$commande->id;
$sql.= " GROUP BY l.fk_product";
$sql.= " ORDER BY l.rowid";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
if ($num)
{
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="right">'.$langs->trans("QtyOrdered").'</td>';
print '<td align="right">'.$langs->trans("QtyDispatched").'</td>';
print '<td align="right">'.$langs->trans("Warehouse").'</td>';
print '<td align="right">'.$langs->trans("QtyDelivered").'</td>';
print "</tr>\n";
}
$entrepot = new Entrepot($db);
$var=true;
while ($i < $num)
{
$objp = $db->fetch_object($resql);
// On n'affiche pas les produits personnalisés
if ($objp->fk_product)
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"),'product').' '.$objp->ref.'</a>';
print ' - '.$objp->label;
if ($objp->description) print '<br>'.nl2br($objp->description);
print '<input name="product_'.$i.'" type="hidden" value="'.$objp->fk_product.'">';
print '<input name="pu_'.$i.'" type="hidden" value="'.$objp->subprice.'">';
print "</td>\n";
print '<td align="right">'.$objp->qty.'</td>';
print '<td align="right">'.$products_dispatched[$objp->fk_product].'</td>';
print '<td align="right">';
if (sizeof($user->entrepots) === 1)
{
$uentrepot = array();
$uentrepot[$user->entrepots[0]['id']] = $user->entrepots[0]['label'];
$html->select_array("entrepot_".$i, $uentrepot);
}
else
{
$html->select_array("entrepot_".$i, $entrepot->list_array());
}
print "</td>\n";
print '<td align="right"><input name="qty_'.$i.'" type="text" size="8" value="'.($objp->qty-$products_dispatched[$objp->fk_product]).'"></td>';
print "</tr>\n";
}
$i++;
}
$db->free($resql);
}
else
{
dolibarr_print_error($db);
}
print "</table>\n";
print "<br/>\n";
print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'"></center></form>';
// Commande non trouvée
dolibarr_print_error($db);
}
print "<br/>\n";
print '<table class="noborder" width="100%">';
$sql = "SELECT p.ref,cfd.fk_product, cfd.qty";
$sql.= ", cfd.rowid";
$sql.= ", p.label, e.label as entrepot";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd";
$sql.= " , ".MAIN_DB_PREFIX."product as p ";
$sql.= " , ".MAIN_DB_PREFIX."entrepot as e ";
$sql.= " WHERE cfd.fk_commande = ".$commande->id;
$sql.= " AND cfd.fk_product = p.rowid";
$sql.= " AND cfd.fk_entrepot = e.rowid";
$sql.= " ORDER BY cfd.rowid ASC;";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
if ($num)
{
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="right">'.$langs->trans("QtyDispatched").'</td>';
print '<td align="right">'.$langs->trans("Warehouse").'</td>';
print "</tr>\n";
}
$var=false;
while ($i < $num)
{
$objp = $db->fetch_object($resql);
print "<tr $bc[$var]>";
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"),'product').' '.$objp->ref.'</a>';
print ' - '.$objp->label;
print "</td>\n";
print '<td align="right">'.$objp->qty.'</td>';
print '<td align="right">'.stripslashes($objp->entrepot).'</td>';
print "</tr>\n";
$i++;
$var=!$var;
}
$db->free($resql);
}
else
{
dolibarr_print_error($db);
}
print "</table>\n";
print '</div>';
/**
* Boutons actions
*/
if ($user->societe_id == 0 && $commande->statut < 3 && ($_GET["action"] <> 'valid' || $_GET['action'] == 'builddoc'))
{
print '<div class="tabsAction">';
if ($commande->statut == 0 && $num > 0)
{
if ($user->rights->fournisseur->commande->valider)
{
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&amp;action=valid">'.$langs->trans("Valid").'</a>';
}
}
if ($commande->statut == 1)
{
if ($user->rights->fournisseur->commande->approuver)
{
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&amp;action=approve">'.$langs->trans("ApproveOrder").'</a>';
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&amp;action=refuse">'.$langs->trans("RefuseOrder").'</a>';
}
if ($user->rights->fournisseur->commande->annuler)
{
print '<a class="butActionDelete" href="fiche.php?id='.$commande->id.'&amp;action=cancel">'.$langs->trans("CancelOrder").'</a>';
}
}
if ($commande->statut == 2)
{
if ($user->rights->fournisseur->commande->annuler)
{
print '<a class="butActionDelete" href="fiche.php?id='.$commande->id.'&amp;action=cancel">'.$langs->trans("CancelOrder").'</a>';
}
}
if ($commande->statut == 0)
{
if ($user->rights->fournisseur->commande->creer)
{
print '<a class="butActionDelete" href="fiche.php?id='.$commande->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
}
}
print "</div>";
}
/*
*
*
*/
}
else
{
// Commande non trouvée
dolibarr_print_error($db);
}
}
$db->close();

View File

@ -28,6 +28,7 @@
require('./pre.inc.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."/fourn/fournisseur.product.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);
$formfile = new FormFile($db);
$formorder = new FormOrder($db);
/* *************************************************************************** */
/* */
@ -1015,7 +1017,7 @@ if ($id > 0)
print '</td></tr>';
print '<tr><td>'.$langs->trans("OrderMode").'</td><td>';
$html->select_methodes_commande('',"methodecommande",1);
$formorder->select_methodes_commande('',"methodecommande",1);
print '</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
@ -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
* \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
* \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
* \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
@ -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
* \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_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");
$langs->load("companies");
@ -266,6 +267,8 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' &&
llxHeader();
$form = new Form($db);
$formcompany = new FormCompany($db);
$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 '<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>';
}
@ -483,7 +486,7 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create')
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
if ($soc->pays_id)
{
$form->select_departement($soc->departement_id,$soc->pays_code);
$formcompany->select_departement($soc->departement_id,$soc->pays_code);
}
else
{
@ -546,7 +549,7 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create')
print '<td colspan="3">';
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
{
@ -555,11 +558,11 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create')
print '</td></tr>';
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);
print '</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);
print '</td></tr>';
@ -834,7 +837,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
print '</td></tr>';
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 '<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('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 '<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);
print '</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);
print '</td></tr>';
@ -1147,7 +1150,7 @@ else
print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">'.$soc->forme_juridique.'</td></tr>';
// Type + Staff
$arr = $form->typent_array(1);
$arr = $formcompany->typent_array(1);
$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>';