2
0
forked from Wavyzz/dolibarr

Fix: works on repair broken features (in progress)

This commit is contained in:
Regis Houssin
2011-08-10 17:40:42 +00:00
parent 8dea0afa74
commit fb09ae37d9
11 changed files with 111 additions and 187 deletions

View File

@@ -26,7 +26,7 @@
* \file htdocs/comm/propal.php * \file htdocs/comm/propal.php
* \ingroup propale * \ingroup propale
* \brief Page of commercial proposals card and list * \brief Page of commercial proposals card and list
* \version $Id: propal.php,v 1.616 2011/08/10 10:55:40 hregis Exp $ * \version $Id: propal.php,v 1.617 2011/08/10 17:40:46 hregis Exp $
*/ */
require("../main.inc.php"); require("../main.inc.php");
@@ -865,7 +865,7 @@ if ($action == 'builddoc' && $user->rights->propale->creer)
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
$result=propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); $result=propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
if ($result <= 0) if ($result <= 0)
{ {
dol_print_error($db,$result); dol_print_error($db,$result);
@@ -1072,7 +1072,7 @@ if ($id > 0 || ! empty($ref))
$formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate','',0,1); $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate','',0,1);
} }
$formconfirm=$hookmanager->executeHooks('formconfirm',$action,$object,$lineid); // Note that $action and $object may have been modified by hook if (! $formconfirm) $formconfirm=$hookmanager->executeHooks('formconfirm',$action,$object,$lineid); // Note that $action and $object may have been modified by hook
// Print form confirm // Print form confirm
print $formconfirm; print $formconfirm;
@@ -1926,6 +1926,6 @@ else
} }
$db->close(); $db->close();
llxFooter('$Date: 2011/08/10 10:55:40 $ - $Revision: 1.616 $'); llxFooter('$Date: 2011/08/10 17:40:46 $ - $Revision: 1.617 $');
?> ?>

View File

@@ -25,7 +25,7 @@
* \file htdocs/commande/fiche.php * \file htdocs/commande/fiche.php
* \ingroup commande * \ingroup commande
* \brief Page to show customer order * \brief Page to show customer order
* \version $Id: fiche.php,v 1.528 2011/08/08 12:00:13 eldy Exp $ * \version $Id: fiche.php,v 1.529 2011/08/10 17:40:46 hregis Exp $
*/ */
require("../main.inc.php"); require("../main.inc.php");
@@ -64,40 +64,17 @@ $object = new Commande($db);
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'commande',$id,''); $result=restrictedArea($user,'commande',$id,'');
// Instantiate hooks of thirdparty module // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules)) include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
{ $hookmanager=new HookManager($db);
$object->callHooks('ordercard'); $hookmanager->callHooks(array('ordercard'));
}
/******************************************************************************/ /******************************************************************************/
/* Actions */ /* Actions */
/******************************************************************************/ /******************************************************************************/
// Hook of actions $reshook=$hookmanager->executeHooks('doActions',$action,$object,$socid); // Note that $action and $object may have been modified by some hooks
if (! empty($object->hooks))
{
foreach($object->hooks as $hook)
{
if (! empty($hook['modules']))
{
foreach($hook['modules'] as $module)
{
if (method_exists($module,'doActions'))
{
$reshook+=$module->doActions($object);
if (! empty($module->error) || (! empty($module->errors) && sizeof($module->errors) > 0))
{
$mesg=$module->error; $mesgs=$module->errors;
if ($action=='add') $action='create';
if ($action=='update') $action='edit';
}
}
}
}
}
}
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes') if ($action == 'confirm_clone' && $confirm == 'yes')
@@ -317,6 +294,9 @@ if ($action == 'add' && $user->rights->commande->creer)
} }
// Hooks // Hooks
$reshook=$hookmanager->executeHooks('createfrom',$action,$srcobject,$object_id,$object->element); // Note that $action and $object may have been modified by hook
if ($reshook < 0) $error++;
/*
if (! empty($object->hooks)) if (! empty($object->hooks))
{ {
foreach($object->hooks as $hook) foreach($object->hooks as $hook)
@@ -333,7 +313,7 @@ if ($action == 'add' && $user->rights->commande->creer)
} }
} }
} }
} }*/
} }
else else
{ {
@@ -910,7 +890,7 @@ if ($action == 'builddoc') // In get or post
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
$result=commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); $result=commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
if ($result <= 0) if ($result <= 0)
{ {
dol_print_error($db,$result); dol_print_error($db,$result);
@@ -1536,20 +1516,7 @@ else
$formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneOrder'),$langs->trans('ConfirmCloneOrder',$object->ref),'confirm_clone',$formquestion,'yes',1); $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneOrder'),$langs->trans('ConfirmCloneOrder',$object->ref),'confirm_clone',$formquestion,'yes',1);
} }
// Hook for external modules if (! $formconfirm) $formconfirm=$hookmanager->executeHooks('formconfirm',$action,$object,$lineid); // Note that $action and $object may have been modified by hook
if (empty($formconfirm) && ! empty($object->hooks))
{
foreach($object->hooks as $hook)
{
if (! empty($hook['modules']))
{
foreach($hook['modules'] as $module)
{
if (empty($formconfirm) && method_exists($module,'formconfirm')) $formconfirm = $module->formconfirm($action,$object,$lineid);
}
}
}
}
// Print form confirm // Print form confirm
print $formconfirm; print $formconfirm;
@@ -1869,7 +1836,7 @@ else
print '<table id="tablelines" class="noborder" width="100%">'; print '<table id="tablelines" class="noborder" width="100%">';
// Show object lines // Show object lines
if (! empty($object->lines)) $object->printObjectLines($action,$mysoc,$soc,$lineid,1); if (! empty($object->lines)) $object->printObjectLines($action,$mysoc,$soc,$lineid,1,$hookmanager);
/* /*
* Form to add new line * Form to add new line
@@ -1880,33 +1847,16 @@ else
{ {
$var=true; $var=true;
$object->formAddFreeProduct(1,$mysoc,$soc); $object->formAddFreeProduct(1,$mysoc,$soc,$hookmanager);
// Add predefined products/services // Add predefined products/services
if ($conf->product->enabled || $conf->service->enabled) if ($conf->product->enabled || $conf->service->enabled)
{ {
$var=!$var; $var=!$var;
$object->formAddPredefinedProduct(1,$mysoc,$soc); $object->formAddPredefinedProduct(1,$mysoc,$soc,$hookmanager);
} }
// Hook for external modules $reshook=$hookmanager->executeHooks('formAddObject',$action,$object); // Note that $action and $object may have been modified by hook
if (! empty($object->hooks))
{
foreach($object->hooks as $hook)
{
if (! empty($hook['modules']))
{
foreach($hook['modules'] as $module)
{
if (method_exists($module,'formAddObject'))
{
$var=!$var;
$module->formAddObject($object);
}
}
}
}
}
} }
} }
print '</table>'; print '</table>';
@@ -2051,7 +2001,7 @@ else
$genallowed=$user->rights->commande->creer; $genallowed=$user->rights->commande->creer;
$delallowed=$user->rights->commande->supprimer; $delallowed=$user->rights->commande->supprimer;
$somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang,$object->hooks); $somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang,$hookmanager);
/* /*
* Linked object block * Linked object block
@@ -2131,5 +2081,5 @@ else
$db->close(); $db->close();
llxFooter('$Date: 2011/08/08 12:00:13 $ - $Revision: 1.528 $'); llxFooter('$Date: 2011/08/10 17:40:46 $ - $Revision: 1.529 $');
?> ?>

View File

@@ -21,7 +21,7 @@
* \file htdocs/core/class/commonobject.class.php * \file htdocs/core/class/commonobject.class.php
* \ingroup core * \ingroup core
* \brief File of parent class of all other business classes (invoices, contracts, proposals, orders, ...) * \brief File of parent class of all other business classes (invoices, contracts, proposals, orders, ...)
* \version $Id: commonobject.class.php,v 1.152 2011/08/10 10:55:37 hregis Exp $ * \version $Id: commonobject.class.php,v 1.153 2011/08/10 17:40:46 hregis Exp $
*/ */
@@ -1655,7 +1655,7 @@ class CommonObject
* @param $selected Object line selected * @param $selected Object line selected
* @param $dateSelector 1=Show also date range input fields * @param $dateSelector 1=Show also date range input fields
*/ */
function printObjectLines($action='viewline',$seller,$buyer,$selected=0,$dateSelector=0,$hookmanager='') function printObjectLines($action='viewline',$seller,$buyer,$selected=0,$dateSelector=0,$hookmanager=false)
{ {
global $conf,$langs; global $conf,$langs;
@@ -1704,15 +1704,6 @@ class CommonObject
{ {
$parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected); $parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected);
$reshook=$hookmanager->executeHooks('printObjectLine',$action,$this,'',$parameters); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('printObjectLine',$action,$this,'',$parameters); // Note that $action and $object may have been modified by some hooks
/*
foreach($this->hooks as $hook)
{
if (method_exists($hook['modules'][$line->special_code],'printObjectLine'))
{
$hook['modules'][$line->special_code]->printObjectLine($action,$this,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected);
}
}
*/
} }
} }
else else

View File

@@ -21,7 +21,7 @@
* \file htdocs/core/class/hookmanager.class.php * \file htdocs/core/class/hookmanager.class.php
* \ingroup core * \ingroup core
* \brief File of class to manage hooks * \brief File of class to manage hooks
* \version $Id: hookmanager.class.php,v 1.2 2011/08/10 10:55:36 hregis Exp $ * \version $Id: hookmanager.class.php,v 1.3 2011/08/10 17:40:45 hregis Exp $
*/ */
@@ -120,7 +120,7 @@ class HookManager
* For printSearchForm,printLeftBlock: Return HTML string. * For printSearchForm,printLeftBlock: Return HTML string.
* $this->error or this->errors are also defined with hooks errors. * $this->error or this->errors are also defined with hooks errors.
*/ */
function executeHooks($method, &$action='', &$object='', $id='', $parameters=false) function executeHooks($method, $action='', &$object='', $id='', $parameters=false)
{ {
global $var; global $var;
@@ -191,13 +191,14 @@ class HookManager
// Hook generic // Hook generic
else if (method_exists($module,$method)) else if (method_exists($module,$method))
{ {
if (is_array($parameters) && $parameters['special_code'] > 3 && $parameters['special_code'] != $module->module_number) continue;
$resprint.=$module->$method($object, $action, $id, $parameters, $this); $resprint.=$module->$method($object, $action, $id, $parameters, $this);
} }
} }
} }
} }
if ($method == 'doActions' || $method == 'showInputField' || $method == 'showOutputFields') return $resaction; if ($method == 'doActions' || $method == 'showInputFields' || $method == 'showOutputFields') return $resaction;
return $resprint; return $resprint;
} }

View File

@@ -25,7 +25,7 @@
* \ingroup commande * \ingroup commande
* \brief Fichier contenant la classe mere de generation des commandes en PDF * \brief Fichier contenant la classe mere de generation des commandes en PDF
* et la classe mere de numerotation des commandes * et la classe mere de numerotation des commandes
* \version $Id: modules_commande.php,v 1.48 2011/07/31 23:28:13 eldy Exp $ * \version $Id: modules_commande.php,v 1.49 2011/08/10 17:40:45 hregis Exp $
*/ */
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
@@ -143,7 +143,7 @@ class ModeleNumRefCommandes
* @param hideref Hide ref * @param hideref Hide ref
* @return int 0 if KO, 1 if OK * @return int 0 if KO, 1 if OK
*/ */
function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
$langs->load("orders"); $langs->load("orders");
@@ -192,7 +192,7 @@ function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0
// We save charset_output to restore it because write_file can change it if needed for // We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8. // output format that does not support UTF8.
$sav_charset_output=$outputlangs->charset_output; $sav_charset_output=$outputlangs->charset_output;
if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc) > 0) if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0)
{ {
$outputlangs->charset_output=$sav_charset_output; $outputlangs->charset_output=$sav_charset_output;
// on supprime l'image correspondant au preview // on supprime l'image correspondant au preview

View File

@@ -23,7 +23,7 @@
* \file htdocs/includes/modules/commande/pdf_edison.modules.php * \file htdocs/includes/modules/commande/pdf_edison.modules.php
* \ingroup commande * \ingroup commande
* \brief Fichier de la classe permettant de generer les commandes au modele Edison * \brief Fichier de la classe permettant de generer les commandes au modele Edison
* \version $Id: pdf_edison.modules.php,v 1.89 2011/07/31 23:28:13 eldy Exp $ * \version $Id: pdf_edison.modules.php,v 1.90 2011/08/10 17:40:45 hregis Exp $
*/ */
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php"); require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php");
@@ -95,7 +95,7 @@ class pdf_edison extends ModelePDFCommandes
* @param hideref Do not show ref * @param hideref Do not show ref
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
{ {
global $user,$conf,$langs,$mysoc; global $user,$conf,$langs,$mysoc;
@@ -192,29 +192,29 @@ class pdf_edison extends ModelePDFCommandes
$pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page
// Description de la ligne produit // Description de la ligne produit
pdf_writelinedesc($pdf,$object,$i,$outputlangs,100,3,30,$curY,1,$hidedesc); pdf_writelinedesc($pdf,$object,$i,$outputlangs,100,3,30,$curY,1,$hidedesc,0,$hookmanager);
//$pdf->writeHTMLCell(100, 3, 30, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1); //$pdf->writeHTMLCell(100, 3, 30, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1);
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$ref = pdf_getlineref($object, $i, $outputlangs); $ref = pdf_getlineref($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY (10, $curY); $pdf->SetXY (10, $curY);
$pdf->MultiCell(20, 3, $ref, 0, 'C'); $pdf->MultiCell(20, 3, $ref, 0, 'C');
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY (133, $curY); $pdf->SetXY (133, $curY);
$pdf->MultiCell(12, 3, $vat_rate, 0, 'C'); $pdf->MultiCell(12, 3, $vat_rate, 0, 'C');
$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY (145, $curY); $pdf->SetXY (145, $curY);
$pdf->MultiCell(10, 3, $qty, 0, 'C'); $pdf->MultiCell(10, 3, $qty, 0, 'C');
$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY (156, $curY); $pdf->SetXY (156, $curY);
$pdf->MultiCell(18, 3, $up_excl_tax, 0, 'R', 0); $pdf->MultiCell(18, 3, $up_excl_tax, 0, 'R', 0);
$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY (174, $curY); $pdf->SetXY (174, $curY);
$pdf->MultiCell(26, 3, $total_excl_tax, 0, 'R', 0); $pdf->MultiCell(26, 3, $total_excl_tax, 0, 'R', 0);

View File

@@ -24,7 +24,7 @@
* \ingroup commande * \ingroup commande
* \brief Fichier de la classe permettant de generer les commandes au modele Einstein * \brief Fichier de la classe permettant de generer les commandes au modele Einstein
* \author Laurent Destailleur * \author Laurent Destailleur
* \version $Id: pdf_einstein.modules.php,v 1.163 2011/07/31 23:28:13 eldy Exp $ * \version $Id: pdf_einstein.modules.php,v 1.164 2011/08/10 17:40:45 hregis Exp $
*/ */
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php"); require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php");
@@ -110,7 +110,7 @@ class pdf_einstein extends ModelePDFCommandes
* @param hideref Do not show ref * @param hideref Do not show ref
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
{ {
global $user,$langs,$conf; global $user,$langs,$conf;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -240,7 +240,7 @@ class pdf_einstein extends ModelePDFCommandes
// Description of product line // Description of product line
$curX = $this->posxdesc-1; $curX = $this->posxdesc-1;
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
@@ -248,18 +248,18 @@ class pdf_einstein extends ModelePDFCommandes
// TVA // TVA
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{ {
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY ($this->posxtva, $curY); $pdf->SetXY ($this->posxtva, $curY);
$pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R');
} }
// Prix unitaire HT avant remise // Prix unitaire HT avant remise
$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY ($this->posxup, $curY); $pdf->SetXY ($this->posxup, $curY);
$pdf->MultiCell($this->posxqty-$this->posxup-1, 3, $up_excl_tax, 0, 'R', 0); $pdf->MultiCell($this->posxqty-$this->posxup-1, 3, $up_excl_tax, 0, 'R', 0);
// Quantity // Quantity
$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY ($this->posxqty, $curY); $pdf->SetXY ($this->posxqty, $curY);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $qty, 0, 'R'); $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $qty, 0, 'R');
@@ -267,12 +267,12 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetXY ($this->posxdiscount, $curY); $pdf->SetXY ($this->posxdiscount, $curY);
if ($object->lines[$i]->remise_percent) if ($object->lines[$i]->remise_percent)
{ {
$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent, 0, 'R'); $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent, 0, 'R');
} }
// Total HT ligne // Total HT ligne
$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY ($this->postotalht, $curY); $pdf->SetXY ($this->postotalht, $curY);
$pdf->MultiCell(26, 3, $total_excl_tax, 0, 'R', 0); $pdf->MultiCell(26, 3, $total_excl_tax, 0, 'R', 0);

View File

@@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.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
@@ -23,7 +23,7 @@
* \ingroup propale * \ingroup propale
* \brief Fichier contenant la classe mere de generation des propales en PDF * \brief Fichier contenant la classe mere de generation des propales en PDF
* et la classe mere de numerotation des propales * et la classe mere de numerotation des propales
* \version $Id: modules_propale.php,v 1.63 2011/07/31 23:28:16 eldy Exp $ * \version $Id: modules_propale.php,v 1.64 2011/08/10 17:40:44 hregis Exp $
*/ */
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
@@ -140,7 +140,7 @@ class ModeleNumRefPropales
* @param hideref Hide ref * @param hideref Hide ref
* @return int 0 if KO, 1 if OK * @return int 0 if KO, 1 if OK
*/ */
function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
$langs->load("propale"); $langs->load("propale");
@@ -191,7 +191,7 @@ function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0,
// We save charset_output to restore it because write_file can change it if needed for // We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8. // output format that does not support UTF8.
$sav_charset_output=$outputlangs->charset_output; $sav_charset_output=$outputlangs->charset_output;
if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc) > 0) if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0)
{ {
$outputlangs->charset_output=$sav_charset_output; $outputlangs->charset_output=$sav_charset_output;
// on supprime l'image correspondant au preview // on supprime l'image correspondant au preview

View File

@@ -24,7 +24,7 @@
* \ingroup propale * \ingroup propale
* \brief Fichier de la classe permettant de generer les propales au modele Azur * \brief Fichier de la classe permettant de generer les propales au modele Azur
* \author Laurent Destailleur * \author Laurent Destailleur
* \version $Id: pdf_propale_azur.modules.php,v 1.243 2011/07/31 23:28:16 eldy Exp $ * \version $Id: pdf_propale_azur.modules.php,v 1.244 2011/08/10 17:40:42 hregis Exp $
*/ */
require_once(DOL_DOCUMENT_ROOT."/includes/modules/propale/modules_propale.php"); require_once(DOL_DOCUMENT_ROOT."/includes/modules/propale/modules_propale.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
@@ -109,7 +109,7 @@ class pdf_propale_azur extends ModelePDFPropales
* @param hideref Do not show ref * @param hideref Do not show ref
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
{ {
global $user,$langs,$conf; global $user,$langs,$conf;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -242,7 +242,7 @@ class pdf_propale_azur extends ModelePDFPropales
// Description de la ligne produit // Description de la ligne produit
$curX = $this->posxdesc-1; $curX = $this->posxdesc-1;
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
@@ -250,18 +250,18 @@ class pdf_propale_azur extends ModelePDFPropales
// TVA // TVA
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{ {
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY ($this->posxtva, $curY); $pdf->SetXY ($this->posxtva, $curY);
$pdf->MultiCell($this->posxup-$this->posxtva-1, 4, $vat_rate, 0, 'R'); $pdf->MultiCell($this->posxup-$this->posxtva-1, 4, $vat_rate, 0, 'R');
} }
// Prix unitaire HT avant remise // Prix unitaire HT avant remise
$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY ($this->posxup, $curY); $pdf->SetXY ($this->posxup, $curY);
$pdf->MultiCell($this->posxqty-$this->posxup-1, 4, $up_excl_tax, 0, 'R', 0); $pdf->MultiCell($this->posxqty-$this->posxup-1, 4, $up_excl_tax, 0, 'R', 0);
// Quantity // Quantity
$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY ($this->posxqty, $curY); $pdf->SetXY ($this->posxqty, $curY);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 4, $qty, 0, 'R'); $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 4, $qty, 0, 'R');
@@ -269,12 +269,12 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->SetXY ($this->posxdiscount, $curY); $pdf->SetXY ($this->posxdiscount, $curY);
if ($object->lines[$i]->remise_percent) if ($object->lines[$i]->remise_percent)
{ {
$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 4, $remise_percent, 0, 'R'); $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 4, $remise_percent, 0, 'R');
} }
// Total HT ligne // Total HT ligne
$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY ($this->postotalht, $curY); $pdf->SetXY ($this->postotalht, $curY);
$pdf->MultiCell(26, 4, $total_excl_tax, 0, 'R', 0); $pdf->MultiCell(26, 4, $total_excl_tax, 0, 'R', 0);

View File

@@ -23,7 +23,7 @@
* \file htdocs/includes/modules/propale/pdf_propale_jaune.modules.php * \file htdocs/includes/modules/propale/pdf_propale_jaune.modules.php
* \ingroup propale * \ingroup propale
* \brief Fichier de la classe permettant de generer les propales au modele Jaune * \brief Fichier de la classe permettant de generer les propales au modele Jaune
* \version $Id: pdf_propale_jaune.modules.php,v 1.117 2011/07/31 23:28:16 eldy Exp $ * \version $Id: pdf_propale_jaune.modules.php,v 1.118 2011/08/10 17:40:44 hregis Exp $
*/ */
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php"); require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php");
@@ -85,7 +85,7 @@ class pdf_propale_jaune extends ModelePDFPropales
* @param hideref Do not show ref * @param hideref Do not show ref
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
{ {
global $user,$langs,$conf; global $user,$langs,$conf;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -181,28 +181,28 @@ class pdf_propale_jaune extends ModelePDFPropales
$pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page
// Description de la ligne produit // Description de la ligne produit
pdf_writelinedesc($pdf,$object,$i,$outputlangs,102,4,30,$curY,1,$hidedesc); pdf_writelinedesc($pdf,$object,$i,$outputlangs,102,4,30,$curY,1,$hidedesc,0,$hookmanager);
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$ref = pdf_getlineref($object, $i, $outputlangs); $ref = pdf_getlineref($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY (10, $curY ); $pdf->SetXY (10, $curY );
$pdf->MultiCell(20, 4, $ref, 0, 'L', 0); $pdf->MultiCell(20, 4, $ref, 0, 'L', 0);
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY (132, $curY ); $pdf->SetXY (132, $curY );
$pdf->MultiCell(12, 4, $vat_rate, 0, 'R'); $pdf->MultiCell(12, 4, $vat_rate, 0, 'R');
$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY (144, $curY ); $pdf->SetXY (144, $curY );
$pdf->MultiCell(10, 4, $qty, 0, 'R', 0); $pdf->MultiCell(10, 4, $qty, 0, 'R', 0);
$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY (154, $curY ); $pdf->SetXY (154, $curY );
$pdf->MultiCell(22, 4, $up_excl_tax, 0, 'R', 0); $pdf->MultiCell(22, 4, $up_excl_tax, 0, 'R', 0);
$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY (176, $curY ); $pdf->SetXY (176, $curY );
$pdf->MultiCell(24, 4, $total_excl_tax, 0, 'R', 0); $pdf->MultiCell(24, 4, $total_excl_tax, 0, 'R', 0);

View File

@@ -24,7 +24,7 @@
* \file htdocs/lib/pdf.lib.php * \file htdocs/lib/pdf.lib.php
* \brief Set of functions used for PDF generation * \brief Set of functions used for PDF generation
* \ingroup core * \ingroup core
* \version $Id: pdf.lib.php,v 1.100 2011/08/10 17:32:29 eldy Exp $ * \version $Id: pdf.lib.php,v 1.101 2011/08/10 17:40:46 hregis Exp $
*/ */
@@ -654,18 +654,16 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
* @param hidedesc Hide description * @param hidedesc Hide description
* @param issupplierline Is it a line for a supplier object ? * @param issupplierline Is it a line for a supplier object ?
*/ */
function pdf_writelinedesc(&$pdf,$object,$i,$outputlangs,$w,$h,$posx,$posy,$hideref=0,$hidedesc=0,$issupplierline=0) function pdf_writelinedesc(&$pdf,$object,$i,$outputlangs,$w,$h,$posx,$posy,$hideref=0,$hidedesc=0,$issupplierline=0,$hookmanager=false)
{ {
global $db, $conf, $langs; global $db, $conf, $langs;
if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
{ {
$special_code = $object->lines[$i]->special_code; $special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
foreach($object->hooks as $hook) $parameters = array('pdf'=>$pdf,'i'=>$i,'outputlangs'=>$outputlangs,'w'=>$w,'h'=>$h,'posx'=>$posx,'posy'=>$posy,'hideref'=>$hideref,'hidedesc'=>$hidedesc,'issupplierline'=>$issupplierline,'special_code'=>$special_code);
{ $reshook=$hookmanager->executeHooks('pdf_writelinedesc','',$object,'',$parameters); // Note that $action and $object may have been modified by some hooks
if (method_exists($hook['modules'][$special_code],'pdf_writelinedesc')) return $hook['modules'][$special_code]->pdf_writelinedesc($pdf,$object,$i,$outputlangs,$w,$h,$posx,$posy,$hideref,$hidedesc,$issupplierline);
}
} }
else else
{ {
@@ -816,7 +814,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
* @param $i Current line number * @param $i Current line number
* @param outputlangs Object langs for output * @param outputlangs Object langs for output
*/ */
function pdf_getlinenum($object,$i,$outputlangs) function pdf_getlinenum($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
{ {
if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
{ {
@@ -837,7 +835,7 @@ function pdf_getlinenum($object,$i,$outputlangs)
* @param $i Current line number * @param $i Current line number
* @param outputlang Object lang for output * @param outputlang Object lang for output
*/ */
function pdf_getlineref($object,$i,$outputlangs) function pdf_getlineref($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
{ {
if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
{ {
@@ -857,7 +855,7 @@ function pdf_getlineref($object,$i,$outputlangs)
* @param i Current line number * @param i Current line number
* @param outputlangs Object langs for output * @param outputlangs Object langs for output
*/ */
function pdf_getlineref_supplier($object,$i,$outputlangs) function pdf_getlineref_supplier($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
{ {
if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
{ {
@@ -881,16 +879,14 @@ function pdf_getlineref_supplier($object,$i,$outputlangs)
* 1 = yes * 1 = yes
* 2 = just special lines * 2 = just special lines
*/ */
function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0) function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
{ {
if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
{ {
$special_code = $object->lines[$i]->special_code; $special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
foreach($object->hooks as $hook) $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
{ return $hookmanager->executeHooks('pdf_getlinevatrate','',$object,'',$parameters); // Note that $action and $object may have been modified by some hooks
if (method_exists($hook['modules'][$special_code],'pdf_getlinevatrate')) return $hook['modules'][$special_code]->pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails);
}
} }
else else
{ {
@@ -908,16 +904,14 @@ function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0)
* 1 = yes * 1 = yes
* 2 = just special lines * 2 = just special lines
*/ */
function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0) function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
{ {
if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
{ {
$special_code = $object->lines[$i]->special_code; $special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
foreach($object->hooks as $hook) $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
{ return $hookmanager->executeHooks('pdf_getlineupexcltax','',$object,'',$parameters); // Note that $action and $object may have been modified by some hooks
if (method_exists($hook['modules'][$special_code],'pdf_getlineupexcltax')) return $hook['modules'][$special_code]->pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails);
}
} }
else else
{ {
@@ -935,18 +929,16 @@ function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0)
* 1 = yes * 1 = yes
* 2 = just special lines * 2 = just special lines
*/ */
function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0) function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
{ {
if ($object->lines[$i]->special_code != 3) if ($object->lines[$i]->special_code != 3)
{ {
if (! empty($object->hooks) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
{ {
$special_code = $object->lines[$i]->special_code; $special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
foreach($object->hooks as $hook) $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
{ return $hookmanager->executeHooks('pdf_getlineqty','',$object,'',$parameters); // Note that $action and $object may have been modified by some hooks
if (method_exists($hook['modules'][$special_code],'pdf_getlineqty')) return $hook['modules'][$special_code]->pdf_getlineqty($object,$i,$outputlangs,$hidedetails);
}
} }
else else
{ {
@@ -965,18 +957,16 @@ function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0)
* 1 = yes * 1 = yes
* 2 = just special lines * 2 = just special lines
*/ */
function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0) function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
{ {
if ($object->lines[$i]->special_code != 3) if ($object->lines[$i]->special_code != 3)
{ {
if (! empty($object->hooks) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
{ {
$special_code = $object->lines[$i]->special_code; $special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
foreach($object->hooks as $hook) $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
{ return $hookmanager->executeHooks('pdf_getlineqty_asked','',$object,'',$parameters); // Note that $action and $object may have been modified by some hooks
if (method_exists($hook['modules'][$special_code],'pdf_getlineqty_asked')) return $hook['modules'][$special_code]->pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails);
}
} }
else else
{ {
@@ -995,18 +985,16 @@ function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0)
* 1 = yes * 1 = yes
* 2 = just special lines * 2 = just special lines
*/ */
function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0) function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
{ {
if ($object->lines[$i]->special_code != 3) if ($object->lines[$i]->special_code != 3)
{ {
if (! empty($object->hooks) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
{ {
$special_code = $object->lines[$i]->special_code; $special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
foreach($object->hooks as $hook) $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
{ return $hookmanager->executeHooks('pdf_getlineqty_shipped','',$object,'',$parameters); // Note that $action and $object may have been modified by some hooks
if (method_exists($hook['modules'][$special_code],'pdf_getlineqty_shipped')) return $hook['modules'][$special_code]->pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails);
}
} }
else else
{ {
@@ -1025,18 +1013,16 @@ function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0)
* 1 = yes * 1 = yes
* 2 = just special lines * 2 = just special lines
*/ */
function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0) function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
{ {
if ($object->lines[$i]->special_code != 3) if ($object->lines[$i]->special_code != 3)
{ {
if (! empty($object->hooks) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
{ {
$special_code = $object->lines[$i]->special_code; $special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
foreach($object->hooks as $hook) $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
{ return $hookmanager->executeHooks('pdf_getlineqty_keeptoship','',$object,'',$parameters); // Note that $action and $object may have been modified by some hooks
if (method_exists($hook['modules'][$special_code],'pdf_getlineqty_keeptoship')) return $hook['modules'][$special_code]->pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails);
}
} }
else else
{ {
@@ -1055,20 +1041,18 @@ function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0)
* 1 = yes * 1 = yes
* 2 = just special lines * 2 = just special lines
*/ */
function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0) function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
{ {
include_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); include_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
if ($object->lines[$i]->special_code != 3) if ($object->lines[$i]->special_code != 3)
{ {
if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
{ {
$special_code = $object->lines[$i]->special_code; $special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
foreach($object->hooks as $hook) $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
{ return $hookmanager->executeHooks('pdf_getlineremisepercent','',$object,'',$parameters); // Note that $action and $object may have been modified by some hooks
if (method_exists($hook['modules'][$special_code],'pdf_getlineremisepercent')) return $hook['modules'][$special_code]->pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails);
}
} }
else else
{ {
@@ -1087,7 +1071,7 @@ function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0)
* 1 = yes * 1 = yes
* 2 = just special lines * 2 = just special lines
*/ */
function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0) function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
{ {
if ($object->lines[$i]->special_code == 3) if ($object->lines[$i]->special_code == 3)
{ {
@@ -1095,14 +1079,12 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0)
} }
else else
{ {
if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
{ {
$special_code = $object->lines[$i]->special_code; $special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
foreach($object->hooks as $hook) $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
{ return $hookmanager->executeHooks('pdf_getlinetotalexcltax','',$object,'',$parameters); // Note that $action and $object may have been modified by some hooks
if (method_exists($hook['modules'][$special_code],'pdf_getlinetotalexcltax')) return $hook['modules'][$special_code]->pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails);
}
} }
else else
{ {
@@ -1117,7 +1099,7 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0)
* @param type Type of line (all=all, 0=product, 1=service, 9=other) * @param type Type of line (all=all, 0=product, 1=service, 9=other)
* @param outputlangs Object langs for output * @param outputlangs Object langs for output
*/ */
function pdf_getTotalQty($object,$type='',$outputlangs) function pdf_getTotalQty($object,$type='',$outputlangs,$hookmanager=false)
{ {
$total=0; $total=0;
$nblignes=sizeof($object->lines); $nblignes=sizeof($object->lines);