Works on hook integration in pdf

This commit is contained in:
Regis Houssin 2010-09-09 15:24:06 +00:00
parent 683fcb75c4
commit 015f32dd0d
2 changed files with 66 additions and 58 deletions

View File

@ -959,7 +959,7 @@ class Propal extends CommonObject
$line->subprice = $objp->subprice; $line->subprice = $objp->subprice;
$line->fk_remise_except = $objp->fk_remise_except; $line->fk_remise_except = $objp->fk_remise_except;
$line->remise_percent = $objp->remise_percent; $line->remise_percent = $objp->remise_percent;
$line->price = $objp->price; // deprecated $line->price = $objp->price; // TODO deprecated
$line->info_bits = $objp->info_bits; $line->info_bits = $objp->info_bits;
$line->total_ht = $objp->total_ht; $line->total_ht = $objp->total_ht;

View File

@ -405,80 +405,87 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
$ref_supplier=$object->lines[$i]->ref_supplier; if (empty($ref_supplier)) $ref_supplier=$object->lines[$i]->ref_fourn; // TODO Not yeld saved for supplier invoices, only supplier orders $ref_supplier=$object->lines[$i]->ref_supplier; if (empty($ref_supplier)) $ref_supplier=$object->lines[$i]->ref_fourn; // TODO Not yeld saved for supplier invoices, only supplier orders
$note=$object->lines[$i]->note; $note=$object->lines[$i]->note;
if ($issupplierline) $prodser = new ProductFournisseur($db); if (!empty($object->hooks) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code))
else $prodser = new Product($db);
if ($idprod)
{ {
$prodser->fetch($idprod); $libelleproduitservice = $object->hooks[$object->lines[$i]->special_code]->pdf_getlinedesc($object,$i,$outputlangs);
// If a predefined product and multilang and on other lang, we renamed label with label translated
if ($conf->global->MAIN_MULTILANGS && ($outputlangs->defaultlang != $langs->defaultlang))
{
if (! empty($prodser->multilangs[$outputlangs->defaultlang]["libelle"])) $label=$prodser->multilangs[$outputlangs->defaultlang]["libelle"];
if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"])) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"];
if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"])) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"];
}
} }
else
// Description short of product line
$libelleproduitservice=$label;
// Description long of product line
if ($desc && ($desc != $label))
{ {
if ($libelleproduitservice && !$hidedesc) $libelleproduitservice.="\n"; if ($issupplierline) $prodser = new ProductFournisseur($db);
else $prodser = new Product($db);
if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) if ($idprod)
{ {
$discount=new DiscountAbsolute($db); $prodser->fetch($idprod);
$discount->fetch($object->lines[$i]->fk_remise_except); // If a predefined product and multilang and on other lang, we renamed label with label translated
$libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$discount->ref_facture_source); if ($conf->global->MAIN_MULTILANGS && ($outputlangs->defaultlang != $langs->defaultlang))
}
else
{
if ($idprod)
{ {
if (!$hidedesc) $libelleproduitservice.=$desc; if (! empty($prodser->multilangs[$outputlangs->defaultlang]["libelle"])) $label=$prodser->multilangs[$outputlangs->defaultlang]["libelle"];
if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"])) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"];
if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"])) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"];
}
}
// Description short of product line
$libelleproduitservice=$label;
// Description long of product line
if ($desc && ($desc != $label))
{
if ($libelleproduitservice && !$hidedesc) $libelleproduitservice.="\n";
if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except)
{
$discount=new DiscountAbsolute($db);
$discount->fetch($object->lines[$i]->fk_remise_except);
$libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$discount->ref_facture_source);
} }
else else
{ {
$libelleproduitservice.=$desc; if ($idprod)
}
}
}
// If line linked to a product
if ($idprod)
{
// On ajoute la ref
if ($prodser->ref)
{
$prefix_prodserv = "";
$ref_prodserv = "";
if ($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS) // In standard mode, we do not show this
{
if($prodser->isservice())
{ {
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." "; if (!$hidedesc) $libelleproduitservice.=$desc;
} }
else else
{ {
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." "; $libelleproduitservice.=$desc;
} }
} }
}
if (!$hideref) // If line linked to a product
if ($idprod)
{
// On ajoute la ref
if ($prodser->ref)
{ {
if ($issupplierline) $ref_prodserv = $prodser->ref.' ('.$outputlangs->trans("SupplierRef").' '.$ref_supplier.')'; // Show local ref and supplier ref $prefix_prodserv = "";
else $ref_prodserv = $prodser->ref; // Show local ref only $ref_prodserv = "";
if ($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS) // In standard mode, we do not show this
{
if($prodser->isservice())
{
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." ";
}
else
{
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." ";
}
}
$ref_prodserv .= " - "; if (!$hideref)
{
if ($issupplierline) $ref_prodserv = $prodser->ref.' ('.$outputlangs->trans("SupplierRef").' '.$ref_supplier.')'; // Show local ref and supplier ref
else $ref_prodserv = $prodser->ref; // Show local ref only
$ref_prodserv .= " - ";
}
$libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice;
} }
$libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice;
} }
} }
$libelleproduitservice=dol_htmlentitiesbr($libelleproduitservice,1); $libelleproduitservice=dol_htmlentitiesbr($libelleproduitservice,1);
if ($object->lines[$i]->date_start || $object->lines[$i]->date_end) if ($object->lines[$i]->date_start || $object->lines[$i]->date_end)
@ -500,6 +507,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
$libelleproduitservice.="<br>".dol_htmlentitiesbr($period,1); $libelleproduitservice.="<br>".dol_htmlentitiesbr($period,1);
//print $libelleproduitservice; //print $libelleproduitservice;
} }
return $libelleproduitservice; return $libelleproduitservice;
} }