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>';
@ -1549,7 +1550,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;
@ -1557,8 +1560,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="addinfacture">'; print '<input type="hidden" name="action" value="addinfacture">';
@ -1572,7 +1573,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++;
} }
} }
@ -1582,6 +1582,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);
} }
else else
@ -1611,7 +1612,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;
while ($i < $num) while ($i < $num)
@ -1619,8 +1622,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><a href=\"../compta/facture.php?facid=".$objp->factureid."\">$objp->facnumber</a></td>\n"; print "<td><a href=\"../compta/facture.php?facid=".$objp->factureid."\">$objp->facnumber</a></td>\n";
print "<td><a href=\"../comm/fiche.php?socid=".$objp->socid."\">".dol_trunc($objp->nom,24)."</a></td>\n"; print "<td><a href=\"../comm/fiche.php?socid=".$objp->socid."\">".dol_trunc($objp->nom,24)."</a></td>\n";
@ -1634,7 +1635,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++;
} }
} }
@ -1644,6 +1644,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);
} }
else else
@ -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,6 +245,7 @@ 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)
@ -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>';