*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
\n";
$retm=$objectstatic->updatePrice($newprice, $price_base_type, $user, $newvat, $newminprice, $newlevel, $newnpr);
if ($retm < 0)
{
$error++;
break;
}
if ($newlevel == 1) $updatelevel1=true;
}
// Update single price
$price_base_type = $objectstatic->price_base_type; // Get price_base_type of product/service to keep the same for update
if ($price_base_type == 'TTC')
{
$newprice=price2num($objectstatic->price_ttc,'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals)
$newminprice=$objectstatic->price_min_ttc;
}
else
{
$newprice=price2num($objectstatic->price,'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals)
$newminprice=$objectstatic->price_min;
}
if ($newminprice > $newprice) $newminprice=$newprice;
$newvat=str_replace('*','',$newvatrate);
$newnpr=$objectstatic->recuperableonly;
$newlevel=0;
if (! empty($price_base_type) && ! $updatelevel1)
{
//print "$objectstatic->id $newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr
\n";
$ret=$objectstatic->updatePrice($newprice, $price_base_type, $user, $newvat, $newminprice, $newlevel, $newnpr);
}
if ($ret < 0 || $retm < 0) $error++;
else $nbrecordsmodified++;
}
$i++;
}
if (! $error)
{
if ($nbrecordsmodified > 0) setEventMessage($langs->trans("RecordsModified",$nbrecordsmodified));
else setEventMessage($langs->trans("NoRecordFound"),'warnings');
$db->commit();
}
else
{
setEventMessage($langs->trans("Error"),'errors');
$db->rollback();
}
}
}
}
/*
* View
*/
$form=new Form($db);
$title = $langs->trans('ModulesSystemTools');
llxHeader('',$title);
print_fiche_titre($title,'','setup');
print $langs->trans("ProductVatMassChangeDesc").'
';
if (empty($mysoc->country_code))
{
$langs->load("errors");
$warnpicto=img_error($langs->trans("WarningMandatorySetupNotComplete"));
print '
'.$warnpicto.' '.$langs->trans("WarningMandatorySetupNotComplete").'';
}
else
{
$var=true;
print '