Fix: Can not edit line for free product lines. Also type was lost.

This commit is contained in:
Laurent Destailleur 2010-10-16 13:10:24 +00:00
parent 54ff2328be
commit f30061ca0c
3 changed files with 31 additions and 34 deletions

View File

@ -966,24 +966,24 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
// Define info_bits
$info_bits=0;
if (preg_match('/\*/',$_POST['np_tva_tx'])) $info_bits |= 0x01;
if (preg_match('/\*/',$_POST['tva_tx'])) $info_bits |= 0x01;
// Define vat_rate
$vat_rate=$_POST['np_tva_tx'];
$vat_rate=$_POST['tva_tx'];
$vat_rate=str_replace('*','',$vat_rate);
$localtax1_rate=get_localtax($vat_rate,1,$object->client);
$localtax2_rate=get_localtax($vat_rate,2,$object->client);
// Check parameters
if (empty($_POST['productid']) && $_POST["type"] < 0)
if (! GETPOST('productid') && GETPOST("type") < 0)
{
$mesg = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>';
$result = -1 ;
}
// Check minimum price
if(! empty($_POST['productid']))
if (GETPOST('productid'))
{
$productid = $_POST['productid'];
$productid = GETPOST('productid');
$product = new Product($db);
$product->fetch($productid);
$type=$product->type;
@ -995,23 +995,17 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
}
// Define params
if (! empty($_POST['productid']))
{
$type=$product->type;
}
else
{
$type=$_POST["type"];
}
if (GETPOST('productid')) $type=$product->type;
else $type=GETPOST("type");
// Update line
if ($result >= 0)
{
$result = $object->updateline($_POST['rowid'],
$result = $object->updateline(GETPOST('lineid'),
$description,
$_POST['price'],
$_POST['qty'],
$_POST['remise_percent'],
GETPOST('subprice'),
GETPOST('qty'),
GETPOST('remise_percent'),
$date_start,
$date_end,
$vat_rate,
@ -1025,7 +1019,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{

View File

@ -1794,21 +1794,21 @@ class Facture extends CommonObject
}
/**
* \brief Update line
* \param rowid Id of line to update
* \param desc Description of line
* \param pu Prix unitaire (HT ou TTC selon price_base_type)
* \param qty Quantity
* \param remise_percent Pourcentage de remise de la ligne
* \param date_start Date de debut de validite du service
* \param date_end Date de fin de validite du service
* \param tva_tx VAT Rate
* \param txlocaltax1 Local tax 1 rate
* \param txlocaltax2 Local tax 2 rate
* \param price_base_type HT or TTC
* \param info_bits Miscellanous informations
* \param type Type of line (0=product, 1=service)
* \return int < 0 si erreur, > 0 si ok
* Update a detail line
* @param rowid Id of line to update
* @param desc Description of line
* @param pu Prix unitaire (HT ou TTC selon price_base_type)
* @param qty Quantity
* @param remise_percent Pourcentage de remise de la ligne
* @param date_start Date de debut de validite du service
* @param date_end Date de fin de validite du service
* @param tva_tx VAT Rate
* @param txlocaltax1 Local tax 1 rate
* @param txlocaltax2 Local tax 2 rate
* @param price_base_type HT or TTC
* @param info_bits Miscellanous informations
* @param type Type of line (0=product, 1=service)
* @return int < 0 si erreur, > 0 si ok
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0,$price_base_type='HT', $info_bits=0, $type=0)
{

View File

@ -17,6 +17,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
*
* Need to have object $this (invoice, order, ...) and $line defined
*/
?>
@ -25,7 +27,8 @@
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
<input type="hidden" name="action" value="updateligne">
<input type="hidden" name="id" value="<?php echo $this->id; ?>">
<input type="hidden" name="lineid" value="<?php echo $_GET["lineid"]; ?>">
<input type="hidden" name="lineid" value="<?php echo $line->id; ?>">
<input type="hidden" name="type" value="<?php echo $line->product_type; ?>">
<tr <?php echo $bc[$var]; ?>>
<td>