Qual: Uniformize code

This commit is contained in:
Laurent Destailleur 2009-10-29 01:46:01 +00:00
parent 0f4b911f54
commit def839941f
3 changed files with 125 additions and 119 deletions

View File

@ -1273,6 +1273,10 @@ if ($_GET["action"] == '')
print "\n</div><br>\n"; print "\n</div><br>\n";
/*
* All the "Add to" areas
*/
if ($_GET["id"] && $_GET["action"] == '' && $product->status) if ($_GET["id"] && $_GET["action"] == '' && $product->status)
{ {
$propal = New Propal($db); $propal = New Propal($db);
@ -1315,7 +1319,9 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
{ {
$var=true; $var=true;
$num = $db->num_rows($result); $num = $db->num_rows($result);
print '<table class="noborder" width="100%">'; print '<form method="POST" action="fiche.php?id='.$product->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="nobordernopadding" width="100%">';
if ($num) if ($num)
{ {
$i = 0; $i = 0;
@ -1323,8 +1329,6 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$var=!$var; $var=!$var;
print '<form method="POST" action="fiche.php?id='.$product->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print "<td nowrap>"; print "<td nowrap>";
print '<input type="hidden" name="action" value="addinpropal">'; print '<input type="hidden" name="action" value="addinpropal">';
@ -1339,7 +1343,6 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '</form>';
$i++; $i++;
} }
} }
@ -1349,6 +1352,7 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
print "</td></tr>"; print "</td></tr>";
} }
print "</table>"; print "</table>";
print '</form>';
$db->free($result); $db->free($result);
} }
@ -1361,13 +1365,12 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
$var=true; $var=true;
$otherprop = $propal->liste_array(1, ' <> '.$user->id); $otherprop = $propal->liste_array(1, ' <> '.$user->id);
print '<table class="noborder" width="100%">'; print '<form method="POST" action="fiche.php?id='.$product->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="nobordernopadding" width="100%">';
if (is_array($otherprop) && sizeof($otherprop)) if (is_array($otherprop) && sizeof($otherprop))
{ {
$var=!$var; $var=!$var;
print '<form method="POST" action="fiche.php?id='.$product->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr '.$bc[$var].'><td colspan="3">'; print '<tr '.$bc[$var].'><td colspan="3">';
print '<input type="hidden" name="action" value="addinpropal">'; print '<input type="hidden" name="action" value="addinpropal">';
print $langs->trans("OtherPropals").'</td><td>'; print $langs->trans("OtherPropals").'</td><td>';
@ -1379,7 +1382,6 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
print '</td><td align="right">'; print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
print '</td></tr>'; print '</td></tr>';
print '</form>';
} }
else else
{ {
@ -1388,6 +1390,7 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
print '</td></tr>'; print '</td></tr>';
} }
print '</table>'; print '</table>';
print '</form>';
print '</td>'; print '</td>';
} }
@ -1434,7 +1437,9 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
{ {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$var=true; $var=true;
print '<table class="noborder" width="100%">'; print '<form method="POST" action="fiche.php?id='.$product->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="nobordernopadding" width="100%">';
if ($num) if ($num)
{ {
$i = 0; $i = 0;
@ -1442,8 +1447,6 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
{ {
$objc = $db->fetch_object($result); $objc = $db->fetch_object($result);
$var=!$var; $var=!$var;
print '<form method="POST" action="fiche.php?id='.$product->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print "<td nowrap>"; print "<td nowrap>";
print '<input type="hidden" name="action" value="addincommande">'; print '<input type="hidden" name="action" value="addincommande">';
@ -1458,7 +1461,6 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '</form>';
$i++; $i++;
} }
} }
@ -1469,6 +1471,7 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
print '</td></tr>'; print '</td></tr>';
} }
print "</table>"; print "</table>";
print '</form>';
$db->free($result); $db->free($result);
} }
@ -1481,12 +1484,12 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
$var=true; $var=true;
$othercom = $commande->liste_array(1, ' <> '.$user->id); $othercom = $commande->liste_array(1, ' <> '.$user->id);
print '<table class="noborder" width="100%">'; print '<form method="POST" action="fiche.php?id='.$product->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="nobordernopadding" width="100%">';
if (is_array($othercom) && sizeof($othercom)) if (is_array($othercom) && sizeof($othercom))
{ {
$var=!$var; $var=!$var;
print '<form method="POST" action="fiche.php?id='.$product->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr '.$bc[$var].'><td colspan="3">'; print '<tr '.$bc[$var].'><td colspan="3">';
print '<input type="hidden" name="action" value="addincommande">'; print '<input type="hidden" name="action" value="addincommande">';
print $langs->trans("OtherOrders").'</td><td>'; print $langs->trans("OtherOrders").'</td><td>';
@ -1498,7 +1501,6 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
print '</td><td align="right">'; print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
print '</td></tr>'; print '</td></tr>';
print '</form>';
} }
else else
{ {
@ -1507,6 +1509,7 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
print '</td></tr>'; print '</td></tr>';
} }
print '</table>'; print '</table>';
print '</form>';
} }
print '</td>'; print '</td>';
@ -1516,8 +1519,6 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
// Factures // Factures
if($conf->facture->enabled && $user->rights->facture->creer) if($conf->facture->enabled && $user->rights->facture->creer)
{ {
print '<tr class="liste_titre"><td width="50%" valign="top" class="liste_titre">'; print '<tr class="liste_titre"><td width="50%" valign="top" class="liste_titre">';
print $langs->trans("AddToMyBills").'</td>'; print $langs->trans("AddToMyBills").'</td>';
@ -1547,109 +1548,109 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
$result=$db->query($sql); $result=$db->query($sql);
if ($result) if ($result)
{ {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$var=true; $var=true;
print '<table class="noborder" width="100%">'; print '<form method="POST" action="fiche.php?id='.$product->id.'">';
if ($num) print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
{ print '<table class="nobordernopadding" width="100%">';
$i = 0; if ($num)
while ($i < $num) {
{ $i = 0;
$objp = $db->fetch_object($result); while ($i < $num)
$var=!$var; {
print '<form method="POST" action="fiche.php?id='.$product->id.'">'; $objp = $db->fetch_object($result);
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; $var=!$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print "<td nowrap>"; print "<td nowrap>";
print '<input type="hidden" name="action" value="addinfacture">'; print '<input type="hidden" name="action" value="addinfacture">';
print "<a href=\"../compta/facture.php?facid=".$objp->factureid."\">".img_object($langs->trans("ShowBills"),"bill")." ".$objp->facnumber."</a></td>\n"; print "<a href=\"../compta/facture.php?facid=".$objp->factureid."\">".img_object($langs->trans("ShowBills"),"bill")." ".$objp->facnumber."</a></td>\n";
print "<td><a href=\"../comm/fiche.php?socid=".$objp->socid."\">".dol_trunc($objp->nom,18)."</a></td>\n"; print "<td><a href=\"../comm/fiche.php?socid=".$objp->socid."\">".dol_trunc($objp->nom,18)."</a></td>\n";
print "<td nowrap=\"nowrap\">".dol_print_date($objp->df,"%d %b")."</td>\n"; print "<td nowrap=\"nowrap\">".dol_print_date($objp->df,"%d %b")."</td>\n";
print '<td><input type="hidden" name="factureid" value="'.$objp->factureid.'">'; print '<td><input type="hidden" name="factureid" value="'.$objp->factureid.'">';
print '<input type="text" class="flat" name="qty" size="1" value="1"></td><td nowrap>'.$langs->trans("ReductionShort"); print '<input type="text" class="flat" name="qty" size="1" value="1"></td><td nowrap>'.$langs->trans("ReductionShort");
print '<input type="text" class="flat" name="remise_percent" size="1" value="0">%'; print '<input type="text" class="flat" name="remise_percent" size="1" value="0">%';
print '</td><td align="right">'; print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '</form>'; $i++;
$i++; }
} }
} else {
else { print "<tr ".$bc[!$var]."><td>";
print "<tr ".$bc[!$var]."><td>"; print $langs->trans("NoDraftBills");
print $langs->trans("NoDraftBills"); print '</td></tr>';
print '</td></tr>'; }
} print "</table>";
print "</table>"; print '</form>';
$db->free($result); $db->free($result);
} }
else else
{ {
dol_print_error($db); dol_print_error($db);
} }
print '</td>'; print '</td>';
if ($user->rights->societe->client->voir) if ($user->rights->societe->client->voir)
{ {
print '<td width="50%" valign="top">'; print '<td width="50%" valign="top">';
// Liste de Autres factures // Liste de Autres factures
$var=true; $var=true;
$sql = "SELECT s.nom, s.rowid as socid, f.rowid as factureid, f.facnumber,".$db->pdate("f.datef")." as df"; $sql = "SELECT s.nom, s.rowid as socid, f.rowid as factureid, f.facnumber,".$db->pdate("f.datef")." as df";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f";
$sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.entity = ".$conf->entity;
$sql.= " AND f.fk_statut = 0"; $sql.= " AND f.fk_statut = 0";
$sql.= " AND f.fk_user_author <> ".$user->id; $sql.= " AND f.fk_user_author <> ".$user->id;
$sql.= " ORDER BY f.datec DESC, f.rowid DESC"; $sql.= " ORDER BY f.datec DESC, f.rowid DESC";
$result=$db->query($sql); $result=$db->query($sql);
if ($result) if ($result)
{ {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$var=true; $var=true;
print '<table class="noborder" width="100%">'; print '<form method="POST" action="fiche.php?id='.$product->id.'">';
if ($num) { print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$i = 0; print '<table class="nobordernopadding" width="100%">';
while ($i < $num) if ($num) {
{ $i = 0;
$objp = $db->fetch_object($result); while ($i < $num)
{
$objp = $db->fetch_object($result);
$var=!$var; $var=!$var;
print '<form method="POST" action="fiche.php?id='.$product->id.'">'; print "<tr $bc[$var]>";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print "<td><a href=\"../compta/facture.php?facid=".$objp->factureid."\">$objp->facnumber</a></td>\n";
print "<tr $bc[$var]>"; print "<td><a href=\"../comm/fiche.php?socid=".$objp->socid."\">".dol_trunc($objp->nom,24)."</a></td>\n";
print "<td><a href=\"../compta/facture.php?facid=".$objp->factureid."\">$objp->facnumber</a></td>\n"; print "<td colspan=\"2\">".$langs->trans("Qty");
print "<td><a href=\"../comm/fiche.php?socid=".$objp->socid."\">".dol_trunc($objp->nom,24)."</a></td>\n"; print '<input type="hidden" name="action" value="addinfacture">';
print "<td colspan=\"2\">".$langs->trans("Qty"); print "</td>";
print '<input type="hidden" name="action" value="addinfacture">'; print '<td><input type="hidden" name="factureid" value="'.$objp->factureid.'">';
print "</td>"; print '<input type="text" class="flat" name="qty" size="1" value="1"></td><td nowrap>'.$langs->trans("ReductionShort");
print '<td><input type="hidden" name="factureid" value="'.$objp->factureid.'">'; print '<input type="text" class="flat" name="remise_percent" size="1" value="0">%';
print '<input type="text" class="flat" name="qty" size="1" value="1"></td><td nowrap>'.$langs->trans("ReductionShort"); print '</td><td align="right">';
print '<input type="text" class="flat" name="remise_percent" size="1" value="0">%'; print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
print '</td><td align="right">'; print '</td>';
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; print '</tr>';
print '</td>'; $i++;
print '</tr>'; }
print '</form>'; }
$i++; else {
} print "<tr ".$bc[!$var]."><td>";
} print $langs->trans("NoOtherDraftBills");
else { print '</td></tr>';
print "<tr ".$bc[!$var]."><td>"; }
print $langs->trans("NoOtherDraftBills"); print "</table>";
print '</td></tr>'; print '</form>';
} $db->free($result);
print "</table>"; }
$db->free($result); else
} {
else dol_print_error($db);
{ }
dol_print_error($db);
}
} }
print '</td></tr>'; print '</td></tr>';
@ -1661,6 +1662,7 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
} }
$db->close(); $db->close();
llxFooter('$Date$ - $Revision$'); llxFooter('$Date$ - $Revision$');

View File

@ -28,6 +28,7 @@
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/html.formadmin.class.php");
$langs->load("products"); $langs->load("products");
$langs->load("bills"); $langs->load("bills");
@ -136,6 +137,7 @@ if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
llxHeader("","",$langs->trans("Translation")); llxHeader("","",$langs->trans("Translation"));
$html = new Form($db); $html = new Form($db);
$formadmin=new FormAdmin($db);
$head=product_prepare_head($product, $user); $head=product_prepare_head($product, $user);
$titre=$langs->trans("CardProduct".$product->type); $titre=$langs->trans("CardProduct".$product->type);
@ -243,7 +245,8 @@ if ($_GET["action"] == 'add' || ($user->rights->produit->creer || $user->rights-
$langs_available = $langs->get_available_languages(); $langs_available = $langs->get_available_languages();
$current_lang = $langs->getDefaultLang(); $current_lang = $langs->getDefaultLang();
// on construit la liste des traduction qui n'existe pas deja
// on construit la liste des traduction qui n'existe pas deja
$select = '<select class="flat" name="lang">'; $select = '<select class="flat" name="lang">';
foreach ($langs_available as $value) foreach ($langs_available as $value)
if ( !array_key_exists($value, $product->multilangs) ) // si la traduction n'existe pas if ( !array_key_exists($value, $product->multilangs) ) // si la traduction n'existe pas
@ -256,7 +259,9 @@ if ($_GET["action"] == 'add' || ($user->rights->produit->creer || $user->rights-
print '<input type="hidden" name="action" value="vadd">'; print '<input type="hidden" name="action" value="vadd">';
print '<input type="hidden" name="id" value="'.$_GET["id"].'">'; print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td valign="top" width="15%">'.$langs->trans('Translation').'</td><td>'.$select.'</td></tr>'; print '<tr><td valign="top" width="15%">'.$langs->trans('Translation').'</td><td>';
$formadmin->select_lang($fuser->conf->MAIN_LANG_DEFAULT,'lang',0);
print '</td></tr>';
print '<tr><td valign="top" width="15%">'.$langs->trans('Label').'</td><td><input name="libelle" size="40"></td></tr>'; print '<tr><td valign="top" width="15%">'.$langs->trans('Label').'</td><td><input name="libelle" size="40"></td></tr>';
print '<tr><td valign="top" width="15%">'.$langs->trans('Description').'</td><td><textarea name="desc" rows="3" cols="80"></textarea></td></tr>'; print '<tr><td valign="top" width="15%">'.$langs->trans('Description').'</td><td><textarea name="desc" rows="3" cols="80"></textarea></td></tr>';
print '<tr><td valign="top" width="15%">'.$langs->trans('Note').'</td><td><textarea name="note" rows="3" cols="80"></textarea></td></tr>'; print '<tr><td valign="top" width="15%">'.$langs->trans('Note').'</td><td><textarea name="note" rows="3" cols="80"></textarea></td></tr>';

View File

@ -169,7 +169,6 @@ if ($_GET["action"] == 'edit')
print ! empty($dolibarr_main_demo)?' disabled="true"':''; // Disabled for demo print ! empty($dolibarr_main_demo)?' disabled="true"':''; // Disabled for demo
print '> '.$langs->trans("UsePersonalValue").'</td>'; print '> '.$langs->trans("UsePersonalValue").'</td>';
print '<td>'; print '<td>';
$html=new Form($db);
$formadmin->select_lang($fuser->conf->MAIN_LANG_DEFAULT,'main_lang_default',1); $formadmin->select_lang($fuser->conf->MAIN_LANG_DEFAULT,'main_lang_default',1);
print '</td></tr>'; print '</td></tr>';