Ajout possibilit de modifier la description produit
This commit is contained in:
parent
7b69c5a42f
commit
20ceefc29e
@ -106,21 +106,19 @@ if ($_POST["action"] == 'addligne' && $user->rights->fournisseur->commande->cree
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["action"] == 'updateligne' && $user->rights->commande->creer)
|
||||
if ($_POST["action"] == 'updateligne' && $user->rights->commande->creer && $_POST['save'] == $langs->trans('Save'))
|
||||
{
|
||||
$commande = new CommandeFournisseur($db,"",$_GET["id"]);
|
||||
if ($commande->fetch($_GET["id"]) )
|
||||
{
|
||||
$commande = new CommandeFournisseur($db,"",$_POST["id"]);
|
||||
$commande->fetch($_POST["id"]);
|
||||
|
||||
$result = $commande->updateline($_POST["elrowid"],
|
||||
$_POST["eldesc"],
|
||||
$_POST["elprice"],
|
||||
$_POST["elqty"],
|
||||
$_POST["elremise_percent"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Erreur";
|
||||
}
|
||||
$_POST["elremise_percent"],
|
||||
$_POST["tva_tx"]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
if ($_GET["action"] == 'deleteline' && $user->rights->fournisseur->commande->creer)
|
||||
@ -490,9 +488,13 @@ if ($_GET["id"] > 0)
|
||||
print '<td> </td>';
|
||||
}
|
||||
print '<td align="right">'.price($objp->subprice)."</td>\n";
|
||||
if ($commande->statut == 0 && $user->rights->fournisseur->commande->creer && $_GET["action"] <> 'valid')
|
||||
if ($commande->statut == 0 && $user->rights->fournisseur->commande->creer && $_GET["action"] <> 'valid' && $_GET["action"] != 'editline')
|
||||
{
|
||||
print '<td> </td><td align="right"><a href="fiche.php?id='.$commande->id.'&action=deleteline&lineid='.$objp->rowid.'">';
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=editline&rowid='.$objp->rowid.'#'.$objp->rowid.'">';
|
||||
print img_edit();
|
||||
print '</a></td>';
|
||||
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=deleteline&lineid='.$objp->rowid.'">';
|
||||
print img_delete();
|
||||
print '</a></td>';
|
||||
}
|
||||
@ -507,12 +509,15 @@ if ($_GET["id"] > 0)
|
||||
print "<form action=\"fiche.php?id=$commande->id\" method=\"post\">";
|
||||
print '<input type="hidden" name="action" value="updateligne">';
|
||||
print '<input type="hidden" name="elrowid" value="'.$_GET["rowid"].'">';
|
||||
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td colspan="3"><textarea name="eldesc" cols="60" rows="2">'.stripslashes($objp->description).'</textarea></td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="center"><input size="4" type="text" name="elqty" value="'.$objp->qty.'"></td>';
|
||||
print '<td align="right"><input size="3" type="text" name="elremise_percent" value="'.$objp->remise_percent.'"> %</td>';
|
||||
print '<td align="right"><input size="8" type="text" name="elprice" value="'.price($objp->subprice).'"></td>';
|
||||
print '<td align="right" colspan="2"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td>';
|
||||
print '<td align="right" colspan="2"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
||||
print '<br /><input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'"></td>';
|
||||
print '</tr>' . "\n";
|
||||
print "</form>\n";
|
||||
}
|
||||
@ -536,7 +541,7 @@ if ($_GET["id"] > 0)
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="2">'.$langs->trans("Description").'</td>';
|
||||
print '<td> </td>';
|
||||
if ($num_lignes) print '<td> </td>';
|
||||
print '<td align="center">'.$langs->trans("VAT").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Qty").'</td>';
|
||||
print '<td align="right">'.$langs->trans("ReductionShort").'</td>';
|
||||
|
||||
@ -103,8 +103,7 @@ class CommandeFournisseur extends Commande
|
||||
|
||||
$this->db->free();
|
||||
|
||||
if ($this->statut == 0)
|
||||
$this->brouillon = 1;
|
||||
if ($this->statut == 0) $this->brouillon = 1;
|
||||
|
||||
// export pdf -----------
|
||||
|
||||
@ -1056,6 +1055,96 @@ class CommandeFournisseur extends Commande
|
||||
print $this->db->error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Mets à jour une ligne de commande
|
||||
* \param rowid Id de la ligne de facture
|
||||
* \param desc Description de la ligne
|
||||
* \param pu Prix unitaire
|
||||
* \param qty Quantité
|
||||
* \param remise_percent Pourcentage de remise de la ligne
|
||||
* \param tva_tx Taux TVA
|
||||
* \return int < 0 si erreur, > 0 si ok
|
||||
*/
|
||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $txtva)
|
||||
{
|
||||
dolibarr_syslog("CommandeFournisseur::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $txtva");
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
|
||||
if ($this->brouillon)
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
// Nettoyage paramètres
|
||||
$remise_percent=price2num($remise_percent);
|
||||
$qty=price2num($qty);
|
||||
if (! $qty) $qty=1;
|
||||
$pu = price2num($pu);
|
||||
$txtva=price2num($txtva);
|
||||
|
||||
// Calcul du total TTC et de la TVA pour la ligne a partir de
|
||||
// qty, pu, remise_percent et txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
|
||||
// Anciens indicateurs: $price, $subprice, $remise (a ne plus utiliser)
|
||||
$price = $pu;
|
||||
$subprice = $pu;
|
||||
$remise = 0;
|
||||
if ($remise_percent > 0)
|
||||
{
|
||||
$remise = round(($pu * $remise_percent / 100),2);
|
||||
$price = ($pu - $remise);
|
||||
}
|
||||
$price = price2num($price);
|
||||
$subprice = price2num($subprice);
|
||||
|
||||
// Mise a jour ligne en base
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseurdet SET";
|
||||
$sql.= " description='".addslashes($desc)."'";
|
||||
$sql.= ",price='".price2num($price)."'";
|
||||
$sql.= ",subprice='".price2num($subprice)."'";
|
||||
$sql.= ",remise='".price2num($remise)."'";
|
||||
$sql.= ",remise_percent='".price2num($remise_percent)."'";
|
||||
$sql.= ",tva_tx='".price2num($txtva)."'";
|
||||
$sql.= ",qty='".price2num($qty)."'";
|
||||
//if ($date_end) { $sql.= ",date_start='$date_end'"; }
|
||||
//else { $sql.=',date_start=null'; }
|
||||
//if ($date_end) { $sql.= ",date_end='$date_end'"; }
|
||||
//else { $sql.=',date_end=null'; }
|
||||
//$sql.= " info_bits=".$info_bits.",";
|
||||
//$sql.= ",total_ht='".price2num($total_ht)."'";
|
||||
//$sql.= ",total_tva='".price2num($total_tva)."'";
|
||||
//$sql.= ",total_ttc='".price2num($total_ttc)."'";
|
||||
$sql.= " WHERE rowid = ".$rowid;
|
||||
|
||||
$result = $this->db->query( $sql);
|
||||
if ($result > 0)
|
||||
{
|
||||
// Mise a jour info denormalisees au niveau facture
|
||||
$this->update_price($this->id);
|
||||
$this->db->commit();
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error="Commande::updateline Order status makes operation forbidden";
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CommandeFournisseurLigne extends CommandeLigne
|
||||
|
||||
Loading…
Reference in New Issue
Block a user