fix bug24035: la valeur de remise ne peut pas etre negative

This commit is contained in:
raphael_bertrand 2008-08-11 13:29:23 +00:00
parent ae6ec592ac
commit 7132585be1
4 changed files with 7787 additions and 7707 deletions

View File

@ -5,6 +5,7 @@
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -189,7 +190,10 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer)
$propal->duree_validite = $_POST['duree_validite']; $propal->duree_validite = $_POST['duree_validite'];
$propal->cond_reglement_id = $_POST['cond_reglement_id']; $propal->cond_reglement_id = $_POST['cond_reglement_id'];
$propal->mode_reglement_id = $_POST['mode_reglement_id']; $propal->mode_reglement_id = $_POST['mode_reglement_id'];
if($_POST['remise_percent']>0)
$propal->remise_percent = $_POST['remise_percent']; $propal->remise_percent = $_POST['remise_percent'];
else
$propal->remise_percent = 0;
$propal->remise_absolue = $_POST['remise_absolue']; $propal->remise_absolue = $_POST['remise_absolue'];
$propal->socid = $_POST['socid']; $propal->socid = $_POST['socid'];
$propal->contactid = $_POST['contactidp']; $propal->contactid = $_POST['contactidp'];
@ -615,6 +619,12 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
$info_bits=0; $info_bits=0;
if ($tva_npr) $info_bits |= 0x01; if ($tva_npr) $info_bits |= 0x01;
// Define remise_percent
if ($_POST['remise_percent']>0)
$remise_percent=$_POST['remise_percent'];
else
$remise_percent=0;
// Insert line // Insert line
$result=$propal->addline( $result=$propal->addline(
$_POST['propalid'], $_POST['propalid'],
@ -623,7 +633,7 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
$_POST['qty'], $_POST['qty'],
$tva_tx, $tva_tx,
$_POST['idprod'], $_POST['idprod'],
$_POST['remise_percent'], $remise_percent,
$price_base_type, $price_base_type,
$pu_ttc, $pu_ttc,
$info_bits $info_bits
@ -662,10 +672,17 @@ if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST
$vat_rate=$_POST['tva_tx']; $vat_rate=$_POST['tva_tx'];
$vat_rate=eregi_replace('\*','',$vat_rate); $vat_rate=eregi_replace('\*','',$vat_rate);
// Define remise_percent
if ($_POST['remise_percent']>0)
$remise_percent=$_POST['remise_percent'];
else
$remise_percent=0;
$result = $propal->updateline($_POST['lineid'], $result = $propal->updateline($_POST['lineid'],
$_POST['subprice'], $_POST['subprice'],
$_POST['qty'], $_POST['qty'],
$_POST['remise_percent'], $remise_percent,
$vat_rate, $vat_rate,
$_POST['desc'], $_POST['desc'],
'HT', 'HT',
@ -727,9 +744,15 @@ if ($_POST["action"] == 'setconditions')
if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->propale->creer) if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->propale->creer)
{ {
// Define remise_percent
if ($_POST['remise_percent']>0)
$remise_percent=$_POST['remise_percent'];
else
$remise_percent=0;
$propal = new Propal($db); $propal = new Propal($db);
$propal->fetch($_REQUEST['propalid']); $propal->fetch($_REQUEST['propalid']);
$result = $propal->set_remise_percent($user, $_POST['remise_percent']); $result = $propal->set_remise_percent($user, $remise_percent);
$_GET['propalid']=$_REQUEST['propalid']; $_GET['propalid']=$_REQUEST['propalid'];
} }

View File

@ -1,6 +1,7 @@
<?PHP <?PHP
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -38,9 +39,16 @@ $langs->load("bills");
if ($_POST["action"] == 'setremise') if ($_POST["action"] == 'setremise')
{ {
// Define remise
if ($_POST['remise']>0)
$remise=$_POST['remise'];
else
$remise=0;
$soc = New Societe($db); $soc = New Societe($db);
$soc->fetch($_GET["id"]); $soc->fetch($_GET["id"]);
$result=$soc->set_remise_client($_POST["remise"],$_POST["note"],$user); $result=$soc->set_remise_client($remise,$_POST["note"],$user);
if ($result > 0) if ($result > 0)
{ {

View File

@ -4,6 +4,7 @@
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -274,9 +275,15 @@ if ($_POST['action'] == 'setconditions' && $user->rights->commande->creer)
if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->facture->creer) if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->facture->creer)
{ {
// Define remise_percent
if ($_POST['remise_percent']>0)
$remise_percent=$_POST['remise_percent'];
else
$remise_percent=0;
$commande = new Commande($db); $commande = new Commande($db);
$commande->fetch($_REQUEST['id']); $commande->fetch($_REQUEST['id']);
$result = $commande->set_remise($user, $_POST['remise_percent']); $result = $commande->set_remise($user, $remise_percent);
$_GET['id']=$_REQUEST['id']; $_GET['id']=$_REQUEST['id'];
} }
@ -360,6 +367,12 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
$info_bits=0; $info_bits=0;
if ($tva_npr) $info_bits |= 0x01; if ($tva_npr) $info_bits |= 0x01;
// Define remise_percent
if ($_POST['remise_percent']>0)
$remise_percent=$_POST['remise_percent'];
else
$remise_percent=0;
// Insert line // Insert line
$result = $commande->addline( $result = $commande->addline(
$_POST['id'], $_POST['id'],
@ -368,7 +381,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
$_POST['qty'], $_POST['qty'],
$tva_tx, $tva_tx,
$_POST['idprod'], $_POST['idprod'],
$_POST['remise_percent'], $remise_percent,
$info_bits, $info_bits,
'', '',
$price_base_type, $price_base_type,
@ -407,11 +420,17 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS
$vat_rate=$_POST['tva_tx']; $vat_rate=$_POST['tva_tx'];
$vat_rate=eregi_replace('\*','',$vat_rate); $vat_rate=eregi_replace('\*','',$vat_rate);
// Define elremise_percent
if ($_POST['elremise_percent']>0)
$elremise_percent=$_POST['elremise_percent'];
else
$elremise_percent=0;
$result = $commande->updateline($_POST['elrowid'], $result = $commande->updateline($_POST['elrowid'],
$_POST['eldesc'], $_POST['eldesc'],
$_POST['pu'], $_POST['pu'],
$_POST['qty'], $_POST['qty'],
$_POST['elremise_percent'], $elremise_percent,
$vat_rate, $vat_rate,
'HT', 'HT',
$info_bits $info_bits

View File

@ -5,6 +5,7 @@
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -203,9 +204,15 @@ if ($_POST['action'] == 'setconditions')
if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->facture->creer) if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->facture->creer)
{ {
// Define remise_percent
if ($_POST['remise_percent']>0)
$remise_percent=$_POST['remise_percent'];
else
$remise_percent=0;
$fac = new Facture($db); $fac = new Facture($db);
$fac->fetch($_REQUEST['facid']); $fac->fetch($_REQUEST['facid']);
$result = $fac->set_remise($user, $_POST['remise_percent']); $result = $fac->set_remise($user, $remise_percent);
$_GET['facid']=$_REQUEST['facid']; $_GET['facid']=$_REQUEST['facid'];
} }
@ -438,6 +445,12 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$facture->socid=$_POST['socid']; $facture->socid=$_POST['socid'];
$facture->fetch_client(); $facture->fetch_client();
// Define remise_percent
if ($_POST['remise_percent']>0)
$remise_percent=$_POST['remise_percent'];
else
$remise_percent=0;
$db->begin(); $db->begin();
// Facture remplacement // Facture remplacement
@ -471,7 +484,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$facture->cond_reglement_id = $_POST['cond_reglement_id']; $facture->cond_reglement_id = $_POST['cond_reglement_id'];
$facture->mode_reglement_id = $_POST['mode_reglement_id']; $facture->mode_reglement_id = $_POST['mode_reglement_id'];
$facture->remise_absolue = $_POST['remise_absolue']; $facture->remise_absolue = $_POST['remise_absolue'];
$facture->remise_percent = $_POST['remise_percent']; $facture->remise_percent = $remise_percent;
// Propriétés particulieres a facture de remplacement // Propriétés particulieres a facture de remplacement
$facture->fk_facture_source = $_POST['fac_replacement']; $facture->fk_facture_source = $_POST['fac_replacement'];
@ -515,7 +528,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$facture->cond_reglement_id = 0; $facture->cond_reglement_id = 0;
$facture->mode_reglement_id = $_POST['mode_reglement_id']; $facture->mode_reglement_id = $_POST['mode_reglement_id'];
$facture->remise_absolue = $_POST['remise_absolue']; $facture->remise_absolue = $_POST['remise_absolue'];
$facture->remise_percent = $_POST['remise_percent']; $facture->remise_percent = $remise_percent;
// Propriétés particulieres a facture avoir // Propriétés particulieres a facture avoir
$facture->fk_facture_source = $_POST['fac_avoir']; $facture->fk_facture_source = $_POST['fac_avoir'];
@ -572,7 +585,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$facture->mode_reglement_id = $_POST['mode_reglement_id']; $facture->mode_reglement_id = $_POST['mode_reglement_id'];
$facture->amount = $_POST['amount']; $facture->amount = $_POST['amount'];
$facture->remise_absolue = $_POST['remise_absolue']; $facture->remise_absolue = $_POST['remise_absolue'];
$facture->remise_percent = $_POST['remise_percent']; $facture->remise_percent = $remise_percent;
if (! $_POST['propalid'] && ! $_POST['commandeid'] && ! $_POST['contratid']) if (! $_POST['propalid'] && ! $_POST['commandeid'] && ! $_POST['contratid'])
{ {
@ -588,7 +601,12 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
if ($_POST['date_end'.$i.'year'] && $_POST['date_end'.$i.'month'] && $_POST['date_end'.$i.'day']) { if ($_POST['date_end'.$i.'year'] && $_POST['date_end'.$i.'month'] && $_POST['date_end'.$i.'day']) {
$endday=$_POST['date_end'.$i.'year'].'-'.$_POST['date_end'.$i.'month'].'-'.$_POST['date_end'.$i.'day']; $endday=$_POST['date_end'.$i.'year'].'-'.$_POST['date_end'.$i.'month'].'-'.$_POST['date_end'.$i.'day'];
} }
$facture->add_product($_POST['idprod'.$i],$_POST['qty'.$i],$_POST['remise_percent'.$i],$startday,$endday); // Define remise_percent
if ($_POST['remise_percent'.$i]>0)
$remise_percent_i=$_POST['remise_percent'.$i];
else
$remise_percent_i=0;
$facture->add_product($_POST['idprod'.$i],$_POST['qty'.$i],$remise_percent_i,$startday,$endday);
} }
} }
@ -877,6 +895,12 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') &&
$info_bits=0; $info_bits=0;
if ($tva_npr) $info_bits |= 0x01; if ($tva_npr) $info_bits |= 0x01;
// Define remise_percent
if ($_POST['remise_percent']>0)
$remise_percent=$_POST['remise_percent'];
else
$remise_percent=0;
// Insert line // Insert line
$result = $fac->addline( $result = $fac->addline(
$_POST['facid'], $_POST['facid'],
@ -885,7 +909,7 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') &&
$_POST['qty'], $_POST['qty'],
$tva_tx, $tva_tx,
$_POST['idprod'], $_POST['idprod'],
$_POST['remise_percent'], $remise_percent,
$date_start, $date_start,
$date_end, $date_end,
0, 0,
@ -935,11 +959,17 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
$vat_rate=$_POST['tva_tx']; $vat_rate=$_POST['tva_tx'];
$vat_rate=eregi_replace('\*','',$vat_rate); $vat_rate=eregi_replace('\*','',$vat_rate);
// Define remise_percent
if ($_POST['remise_percent']>0)
$remise_percent=$_POST['remise_percent'];
else
$remise_percent=0;
$result = $fac->updateline($_POST['rowid'], $result = $fac->updateline($_POST['rowid'],
$_POST['desc'], $_POST['desc'],
$_POST['price'], $_POST['price'],
$_POST['qty'], $_POST['qty'],
$_POST['remise_percent'], $remise_percent,
$date_start, $date_start,
$date_end, $date_end,
$vat_rate, $vat_rate,