Qual: Some methods object->addline used a first parameter that was

object->id, some not. Of course this was not a good pratice, since
object->id is already known so no need to provide it as parameter.
All methods addline in this case were modified to match good
pratice and be uniformed with others.
This commit is contained in:
Laurent Destailleur 2013-07-10 17:29:54 +02:00
parent 1ee67bd5b9
commit 27a435994a
14 changed files with 28 additions and 33 deletions

View File

@ -48,7 +48,10 @@ For developers:
- New: Make some changes to allow usage of several alternative $dolibarr_main_url_root variables.
Fix also several bugs with old code.
WARNING: We started to clean hooks code. If your hook want to modify value of $actions, it's role
WARNING: This may create regression for some external modules, but was necessary to make
Dolibarr better:
- We started to clean hooks code. If your hook want to modify value of $actions, it's role
of your hook to modify it. Dolibarr hook code will not decide this for your module anymore.
If your action class for hook was returning a string or an array, instead your module must
set $actionclassinstance->results (to return array)
@ -57,6 +60,11 @@ to return same thing. The return value must be replaced by a "return 0";
Goal is to fix old compatibility code that does not match hook
specification: http://wiki.dolibarr.org/index.php/Hooks_system
- Some methods object->addline used a first parameter that was object->id, some not. Of course
this was not a good pratice, since object->id is already known so no need to provide it as
parameter. All methods addline in this case were modified to remove this information.
***** ChangeLog for 3.4 compared to 3.3.2 *****
For users:
- New: Can use ODS templates as document templates.

View File

@ -186,7 +186,7 @@ for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++)
$prodid = rand(1, $num_prods);
$product=new Product($db);
$result=$product->fetch($prodids[$prodid]);
$result=$com->addline($com->id, $product->description, $product->price, rand(1,5), 0, 0, 0, $prodids[$prodid], 0, 0, 0, $product->price_base_type, $product->price_ttc, '', '', $product->type);
$result=$com->addline($product->description, $product->price, rand(1,5), 0, 0, 0, $prodids[$prodid], 0, 0, 0, $product->price_base_type, $product->price_ttc, '', '', $product->type);
if ($result < 0)
{
dol_print_error($db,$propal->error);

View File

@ -112,7 +112,7 @@ while ($i < GEN_NUMBER_FACTURE && $result >= 0)
$prodid = rand(1, $num_prods);
$product=new Product($db);
$result=$product->fetch($prodids[$prodid]);
$result=$facture->addline($facture->id, $product->description, $product->price, rand(1,5), 0, 0, 0, $prodids[$prodid], 0, '', '', 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
$result=$facture->addline($product->description, $product->price, rand(1,5), 0, 0, 0, $prodids[$prodid], 0, '', '', 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
if ($result < 0)
{
dol_print_error($db,$propal->error);

View File

@ -145,7 +145,7 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0)
$prodid = rand(1, $num_prods);
$product=new Product($db);
$result=$product->fetch($prodids[$prodid]);
$result=$propal->addline($propal->id, $product->description, $product->price, rand(1,5), 0, 0, 0, $prodids[$prodid], 0);
$result=$propal->addline($product->description, $product->price, rand(1,5), 0, 0, 0, $prodids[$prodid], 0);
if ($result < 0)
{
dol_print_error($db,$propal->error);

View File

@ -368,7 +368,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && ! $
$vattouse=get_default_tva($mysoc, $mysoc, $idprodsubscription);
}
//print xx".$vattouse." - ".$mysoc." - ".$customer;exit;
$result=$invoice->addline($invoice->id,$label,0,1,$vattouse,0,0,$idprodsubscription,0,$datecotisation,$datesubend,0,0,'','TTC',$cotisation,1);
$result=$invoice->addline($label,0,1,$vattouse,0,0,$idprodsubscription,0,$datecotisation,$datesubend,0,0,'','TTC',$cotisation,1);
if ($result <= 0)
{
$errmsg=$invoice->error;
@ -538,7 +538,7 @@ if ($rowid)
// EMail
print '<tr><td>'.$langs->trans("EMail").'</td><td class="valeur">'.dol_print_email($object->email,0,$object->fk_soc,1).'</td></tr>';
// Status
print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$object->getLibStatut(4).'</td></tr>';

View File

@ -804,7 +804,6 @@ else if ($action == "addline" && $user->rights->propal->creer)
{
// Insert line
$result=$object->addline(
$id,
$desc,
$pu_ht,
GETPOST('qty'),

View File

@ -314,9 +314,9 @@ class Propal extends CommonObject
*
* @see add_product
*/
function addline($propalid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_option=0)
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_option=0)
{
global $conf;
$propalid=$this->id;
dol_syslog(get_class($this)."::addline propalid=$propalid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type");
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@ -414,7 +414,6 @@ class Propal extends CommonObject
$this->line->pa_ht = $pa_ht;
// Mise en option de la ligne
//if ($conf->global->PROPALE_USE_OPTION_LINE && !$qty) $ligne->special_code=3;
if (empty($qty) && empty($special_code)) $this->line->special_code=3;
// TODO deprecated
@ -762,7 +761,6 @@ class Propal extends CommonObject
}
$result = $this->addline(
$this->id,
$this->lines[$i]->desc,
$this->lines[$i]->subprice,
$this->lines[$i]->qty,

View File

@ -681,7 +681,6 @@ class Commande extends CommonOrder
}
$result = $this->addline(
$this->id,
$this->lines[$i]->desc,
$this->lines[$i]->subprice,
$this->lines[$i]->qty,
@ -1005,7 +1004,6 @@ class Commande extends CommonOrder
/**
* Add an order line into database (linked to product/service or not)
*
* @param int $commandeid Id of line
* @param string $desc Description of line
* @param double $pu_ht Unit price (without tax)
* @param double $qty Quantite
@ -1037,8 +1035,10 @@ class Commande extends CommonOrder
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
*/
function addline($commandeid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_option=0)
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_option=0)
{
$commandeid=$this->id;
dol_syslog(get_class($this)."::addline commandeid=$commandeid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end, type=$type", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';

View File

@ -322,7 +322,6 @@ else if ($action == 'add' && $user->rights->commande->creer)
}
$result = $object->addline(
$object_id,
$desc,
$lines[$i]->subprice,
$lines[$i]->qty,
@ -739,7 +738,6 @@ else if ($action == 'addline' && $user->rights->commande->creer)
{
// Insert line
$result = $object->addline(
$object->id,
$desc,
$pu_ht,
GETPOST('qty'),

View File

@ -269,7 +269,6 @@ if (($action == 'create' || $action == 'add') && empty($mesgs))
$fk_parent_line = 0;
}
$result = $object->addline(
$id,
$desc,
$lines[$i]->subprice,
$lines[$i]->qty,
@ -428,7 +427,7 @@ if ($action == 'create' && empty($mesgs))
if (! empty($conf->projet->enabled))
{
$formproject=new FormProjets($db);
$langs->load('projects');
print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">';
$formproject->select_projects($soc->id, $projectid, 'projectid');

View File

@ -758,7 +758,7 @@ else if ($action == 'add' && $user->rights->facture->creer)
$product->fetch($_POST['idprod'.$i]);
$startday=dol_mktime(12, 0, 0, $_POST['date_start'.$i.'month'], $_POST['date_start'.$i.'day'], $_POST['date_start'.$i.'year']);
$endday=dol_mktime(12, 0, 0, $_POST['date_end'.$i.'month'], $_POST['date_end'.$i.'day'], $_POST['date_end'.$i.'year']);
$result=$object->addline($object->id,$product->description,$product->price, $_POST['qty'.$i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod'.$i], $_POST['remise_percent'.$i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
$result=$object->addline($product->description,$product->price, $_POST['qty'.$i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod'.$i], $_POST['remise_percent'.$i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
}
}
}
@ -913,7 +913,6 @@ else if ($action == 'add' && $user->rights->facture->creer)
}
$result = $object->addline(
$object->id,
$langs->trans('Deposit'),
$amountdeposit, //subprice
1, //quantity
@ -1016,7 +1015,6 @@ else if ($action == 'add' && $user->rights->facture->creer)
}
$result = $object->addline(
$object->id,
$desc,
$lines[$i]->subprice,
$lines[$i]->qty,
@ -1093,7 +1091,7 @@ else if ($action == 'add' && $user->rights->facture->creer)
$product->fetch($_POST['idprod'.$i]);
$startday=dol_mktime(12, 0, 0, $_POST['date_start'.$i.'month'], $_POST['date_start'.$i.'day'], $_POST['date_start'.$i.'year']);
$endday=dol_mktime(12, 0, 0, $_POST['date_end'.$i.'month'], $_POST['date_end'.$i.'day'], $_POST['date_end'.$i.'year']);
$result=$object->addline($object->id,$product->description,$product->price, $_POST['qty'.$i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod'.$i], $_POST['remise_percent'.$i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
$result=$object->addline($product->description,$product->price, $_POST['qty'.$i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod'.$i], $_POST['remise_percent'.$i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
}
}
}
@ -1311,7 +1309,6 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
{
// Insert line
$result = $object->addline(
$object->id,
$desc,
$pu_ht,
GETPOST('qty'),

View File

@ -147,7 +147,6 @@ class FactureRec extends Facture
for ($i = 0; $i < $num; $i++)
{
$result_insert = $this->addline(
$this->id,
$facsrc->lines[$i]->desc,
$facsrc->lines[$i]->subprice,
$facsrc->lines[$i]->qty,
@ -399,7 +398,6 @@ class FactureRec extends Facture
/**
* Add a line to invoice
*
* @param int $facid Id de la facture
* @param string $desc Description de la ligne
* @param double $pu_ht Prix unitaire HT (> 0 even for credit note)
* @param double $qty Quantite
@ -416,8 +414,10 @@ class FactureRec extends Facture
* @param string $label Label of the line
* @return int <0 if KO, Id of line if OK
*/
function addline($facid, $desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='')
function addline($desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='')
{
$facid=$this->id;
dol_syslog("FactureRec::addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';

View File

@ -344,7 +344,6 @@ class Facture extends CommonInvoice
}
$result = $this->addline(
$this->id,
$this->lines[$i]->desc,
$this->lines[$i]->subprice,
$this->lines[$i]->qty,
@ -403,7 +402,6 @@ class Facture extends CommonInvoice
$localtax2_tx=get_localtax($tva_tx,2,$soc);
$result_insert = $this->addline(
$this->id,
$_facrec->lines[$i]->desc,
$_facrec->lines[$i]->subprice,
$_facrec->lines[$i]->qty,
@ -1943,7 +1941,6 @@ class Facture extends CommonInvoice
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
*
* @param int $facid Id de la facture
* @param string $desc Description de la ligne
* @param double $pu_ht Prix unitaire HT (> 0 even for credit note)
* @param double $qty Quantite
@ -1971,8 +1968,10 @@ class Facture extends CommonInvoice
* @param array $array_option extrafields array
* @return int <0 if KO, Id of line if OK
*/
function addline($facid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_option=0)
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_option=0)
{
$facid=$this->id;
dol_syslog(get_class($this)."::Addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';

View File

@ -450,7 +450,6 @@ if (empty($reshook))
}
$result = $propal->addline(
$propal->id,
$desc,
$pu_ht,
GETPOST('qty'),
@ -524,7 +523,6 @@ if (empty($reshook))
}
$result = $commande->addline(
$commande->id,
$desc,
$pu_ht,
GETPOST('qty'),
@ -598,7 +596,6 @@ if (empty($reshook))
}
$result = $facture->addline(
$facture->id,
$desc,
$pu_ht,
GETPOST('qty'),