Qual: Uniformize code

This commit is contained in:
Laurent Destailleur 2009-05-27 15:52:08 +00:00
parent 3d900a81e5
commit 1063772919
5 changed files with 91 additions and 33 deletions

View File

@ -601,7 +601,7 @@ if ($_POST['action'] == "setabsolutediscount" && $user->rights->propale->creer)
/*
* Ajout d'une ligne produit dans la propale
*/
if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
if ($_POST['action'] == "addline" && $user->rights->propale->creer)
{
if (isset($_POST['qty']) && (($_POST['np_price']!='' && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprod']))
{
@ -702,13 +702,18 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
propale_pdf_create($db, $propal->id, $propal->modelpdf, $outputlangs);
unset($_POST['qty']);
unset($_POST['type']);
unset($_POST['np_price']);
unset($_POST['dp_desc']);
unset($_POST['np_tva_tx']);
}
else
{
$mesg='<div class="error">'.$propal->error.'</div>';
}
}
}
}
@ -1602,7 +1607,7 @@ if ($id > 0 || ! empty($ref))
print '<form action="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'#add" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
print '<input type="hidden" name="action" value="addligne">';
print '<input type="hidden" name="action" value="addline">';
$var=true;
print '<tr '.$bc[$var].">\n";
@ -1632,7 +1637,7 @@ if ($id > 0 || ! empty($ref))
print '<td align="right"><input type="text" size="5" name="np_price"></td>';
print '<td align="right"><input type="text" size="2" name="qty" value="'.(isset($_POST["qty"])?$_POST["qty"]:1).'"></td>';
print '<td align="right" nowrap><input type="text" size="1" value="'.$societe->remise_client.'" name="remise_percent">%</td>';
print '<td align="center" valign="middle" colspan="4"><input type="submit" class="button" value="'.$langs->trans('Add').'" name="addligne"></td>';
print '<td align="center" valign="middle" colspan="4"><input type="submit" class="button" value="'.$langs->trans('Add').'" name="addline"></td>';
print '</tr>';
print '</form>';
@ -1667,7 +1672,7 @@ if ($id > 0 || ! empty($ref))
print '<form id="addpredefinedproduct" action="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'#add" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
print '<input type="hidden" name="action" value="addligne">';
print '<input type="hidden" name="action" value="addline">';
$var=!$var;
@ -1700,7 +1705,7 @@ if ($id > 0 || ! empty($ref))
print '<td align="right"><input type="text" size="2" name="qty" value="1"></td>';
print '<td align="right" nowrap><input type="text" size="1" name="remise_percent" value="'.$societe->remise_client.'">%</td>';
print '<td align="center" valign="middle" colspan="4"><input type="submit" class="button" value="'.$langs->trans("Add").'" name="addligne">';
print '<td align="center" valign="middle" colspan="4"><input type="submit" class="button" value="'.$langs->trans("Add").'" name="addline">';
print '</td></tr>'."\n";
print '</form>';

View File

@ -310,7 +310,7 @@ if ($_REQUEST['action'] == 'setremiseabsolue' && $user->rights->facture->creer)
/*
* Ajout d'une ligne produit dans la commande
*/
if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
if ($_POST['action'] == 'addline' && $user->rights->commande->creer)
{
$result=0;
@ -434,6 +434,15 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
commande_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
unset($_POST['qty']);
unset($_POST['type']);
unset($_POST['idprod']);
unset($_POST['remmise_percent']);
unset($_POST['dp_desc']);
unset($_POST['np_desc']);
unset($_POST['pu']);
unset($_POST['tva_tx']);
}
else
{
@ -1785,7 +1794,7 @@ else
print '<form action="fiche.php?id='.$id.'#add" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="action" value="addligne">';
print '<input type="hidden" name="action" value="addline">';
$var=true;
print '<tr '.$bc[$var].'>';
@ -1824,9 +1833,9 @@ else
// Start and end dates selector
print '<tr '.$bc[$var].'>';
print '<td colspan="9">'.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
print $html->select_date('','date_start',$usehm,$usehm,1,"addligne");
print $html->select_date('','date_start',$usehm,$usehm,1,"addline");
print ' '.$langs->trans('to').' ';
print $html->select_date('','date_end',$usehm,$usehm,1,"addligne");
print $html->select_date('','date_end',$usehm,$usehm,1,"addline");
print '</td>';
print '</tr>';
}
@ -1855,7 +1864,7 @@ else
print '<form id="addpredefinedproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$id.'#add" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="action" value="addligne">';
print '<input type="hidden" name="action" value="addline">';
$var=!$var;
print '<tr '.$bc[$var].'>';
@ -1896,9 +1905,9 @@ else
// Start and end dates selector
print '<tr '.$bc[$var].'>';
print '<td colspan="9">'.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
print $html->select_date('','date_start_prod',$usehm,$usehm,1,"addligne");
print $html->select_date('','date_start_prod',$usehm,$usehm,1,"addline");
print ' '.$langs->trans('to').' ';
print $html->select_date('','date_end_prod',$usehm,$usehm,1,"addligne");
print $html->select_date('','date_end_prod',$usehm,$usehm,1,"addline");
print '</td>';
print '</tr>';
}

View File

@ -842,7 +842,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
/*
* Ajout d'une ligne produit dans la facture
*/
if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') && $user->rights->facture->creer)
if (($_POST['action'] == 'addline' || $_POST['action'] == 'addline_predef') && $user->rights->facture->creer)
{
$result=0;
@ -971,6 +971,15 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') &&
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs);
unset($_POST['qty']);
unset($_POST['type']);
unset($_POST['idprod']);
unset($_POST['remmise_percent']);
unset($_POST['dp_desc']);
unset($_POST['np_desc']);
unset($_POST['pu']);
unset($_POST['tva_tx']);
}
else
{
@ -3005,10 +3014,10 @@ else
print "</tr>\n";
// Add free products/services form
print '<form name="addligne" action="'.$_SERVER['PHP_SELF'].'#add" method="post">';
print '<form name="addline" action="'.$_SERVER['PHP_SELF'].'#add" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="facid" value="'.$fac->id.'">';
print '<input type="hidden" name="action" value="addligne">';
print '<input type="hidden" name="action" value="addline">';
$var=true;
print '<tr '.$bc[$var].'>';
@ -3045,9 +3054,9 @@ else
{
print '<tr '.$bc[$var].'>';
print '<td colspan="9">'.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
print $html->select_date('','date_start',$usehm,$usehm,1,"addligne");
print $html->select_date('','date_start',$usehm,$usehm,1,"addline");
print ' '.$langs->trans('to').' ';
print $html->select_date('','date_end',$usehm,$usehm,1,"addligne");
print $html->select_date('','date_end',$usehm,$usehm,1,"addline");
print '</td>';
print '</tr>';
}
@ -3077,7 +3086,7 @@ else
print '<form id="addpredefinedproduct" action="'.$_SERVER['PHP_SELF'].'#add" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="facid" value="'.$fac->id.'">';
print '<input type="hidden" name="action" value="addligne_predef">';
print '<input type="hidden" name="action" value="addline_predef">';
$var=! $var;
print '<tr '.$bc[$var].'>';
@ -3115,9 +3124,9 @@ else
{
print '<tr '.$bc[$var].'>';
print '<td colspan="9">'.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
print $html->select_date('','date_start_predef',$usehm,$usehm,1,"addligne_predef");
print $html->select_date('','date_start_predef',$usehm,$usehm,1,"addline_predef");
print ' '.$langs->trans('to').' ';
print $html->select_date('','date_end_predef',$usehm,$usehm,1,"addligne_predef");
print $html->select_date('','date_end_predef',$usehm,$usehm,1,"addline_predef");
print '</td>';
print '</tr>';
}

View File

@ -83,7 +83,7 @@ if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->fournisseur->com
/*
* Ajout d'une ligne produit dans la commande
*/
if ($_POST['action'] == 'addligne' && $user->rights->fournisseur->commande->creer)
if ($_POST['action'] == 'addline' && $user->rights->fournisseur->commande->creer)
{
if ($_POST['qty'] && (($_POST['pu'] && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprodfournprice']))
{
@ -180,8 +180,17 @@ if ($_POST['action'] == 'addligne' && $user->rights->fournisseur->commande->cree
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
unset($_POST['qty']);
unset($_POST['type']);
unset($_POST['idprodfournprice']);
unset($_POST['remmise_percent']);
unset($_POST['dp_desc']);
unset($_POST['np_desc']);
unset($_POST['pu']);
unset($_POST['tva_tx']);
}
else
else if (empty($mesg))
{
$mesg='<div class="error">'.$commande->error.'</div>';
}
@ -848,7 +857,7 @@ if ($id > 0 || ! empty($ref))
// Add free products/services form
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'#add" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addligne">';
print '<input type="hidden" name="action" value="addline">';
print '<input type="hidden" name="id" value="'.$commande->id.'">';
$var=true;
@ -906,7 +915,7 @@ if ($id > 0 || ! empty($ref))
print '<form id="addpredefinedproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'#add" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addligne">';
print '<input type="hidden" name="action" value="addline">';
print '<input type="hidden" name="id" value="'.$commande->id.'">';
$var=!$var;

View File

@ -282,7 +282,7 @@ if ($_REQUEST['action'] == 'update_line')
}
}
if ($_GET['action'] == 'add_ligne')
if ($_GET['action'] == 'addline')
{
$facfou = new FactureFournisseur($db, '', $_GET['facid']);
$ret=$facfou->fetch($_GET['facid']);
@ -292,10 +292,10 @@ if ($_GET['action'] == 'add_ligne')
exit;
}
if ($_POST['prodfournpriceid']) // > 0 or -1
if ($_POST['idprodfournprice']) // > 0 or -1
{
$product = new ProductFournisseur($db);
$idprod=$product->get_buyprice($_POST['prodfournpriceid'], $_POST['qty']);
$idprod=$product->get_buyprice($_POST['idprodfournprice'], $_POST['qty']);
if ($idprod > 0)
{
$result=$product->fetch($idprod);
@ -337,17 +337,43 @@ if ($_GET['action'] == 'add_ligne')
$ht = price2num($_POST['amount']);
$price_base_type = 'HT';
//$desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0)
$facfou->addline($_POST['label'], $ht, $tauxtva, $_POST['qty'], 0, 0, $datestart, $dateend, 0, 0, $price_base_type, $type);
$result=$facfou->addline($_POST['label'], $ht, $tauxtva, $_POST['qty'], 0, 0, $datestart, $dateend, 0, 0, $price_base_type, $type);
}
else
{
$ttc = price2num($_POST['amountttc']);
$ht = $ttc / (1 + ($tauxtva / 100));
$price_base_type = 'HT';
$facfou->addline($_POST['label'], $ht, $tauxtva, $_POST['qty'], 0, 0, $datestart, $dateend, 0, 0, $price_base_type, $type);
$result=$facfou->addline($_POST['label'], $ht, $tauxtva, $_POST['qty'], 0, 0, $datestart, $dateend, 0, 0, $price_base_type, $type);
}
}
}
//print "xx".$tva_tx; exit;
if ($result > 0)
{
$outputlangs = $langs;
if (! empty($_REQUEST['lang_id']))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
//supplier_invoice_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
unset($_POST['qty']);
unset($_POST['type']);
unset($_POST['idprodfournprice']);
unset($_POST['remmise_percent']);
unset($_POST['dp_desc']);
unset($_POST['np_desc']);
unset($_POST['pu']);
unset($_POST['tva_tx']);
}
else if (empty($mesg))
{
$mesg='<div class="error">'.$facfou->error.'</div>';
}
$_GET['action'] = '';
}
@ -957,7 +983,7 @@ else
print '</tr>';
// Add free products/services form
print '<form action="fiche.php?facid='.$fac->id.'&amp;action=add_ligne" method="post">';
print '<form action="fiche.php?facid='.$fac->id.'&amp;action=addline" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="facid" value="'.$fac->id.'">';
print '<input type="hidden" name="socid" value="'.$societe->id.'">';
@ -1022,7 +1048,7 @@ else
print '<td colspan="4">&nbsp;</td>';
print '</tr>';
print '<form name="addligne_predef" action="fiche.php?facid='.$fac->id.'&amp;action=add_ligne" method="post">';
print '<form name="addligne_predef" action="fiche.php?facid='.$fac->id.'&amp;action=addline" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="socid" value="'. $fac->socid .'">';
print '<input type="hidden" name="facid" value="'.$fac->id.'">';
@ -1030,7 +1056,7 @@ else
$var=! $var;
print '<tr '.$bc[$var].'>';
print '<td colspan="4">';
$html->select_produits_fournisseurs($fac->socid,'','prodfournpriceid','',$filtre);
$html->select_produits_fournisseurs($fac->socid,'','idprodfournprice','',$filtre);
print '</td>';
print '<td align="right"><input type="text" name="qty" value="1" size="1"></td>';
print '<td>&nbsp;</td>';