diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 2a7243652fc..1e90a5bcfc0 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -26,7 +26,7 @@ * \file htdocs/comm/propal.php * \ingroup propale * \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"); @@ -865,7 +865,7 @@ if ($action == 'builddoc' && $user->rights->propale->creer) $outputlangs = new Translate("",$conf); $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) { 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=$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 $formconfirm; @@ -1926,6 +1926,6 @@ else } $db->close(); -llxFooter('$Date: 2011/08/10 10:55:40 $ - $Revision: 1.616 $'); +llxFooter('$Date: 2011/08/10 17:40:46 $ - $Revision: 1.617 $'); ?> diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 74af53ff2c7..73e97061f5e 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -25,7 +25,7 @@ * \file htdocs/commande/fiche.php * \ingroup commande * \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"); @@ -64,40 +64,17 @@ $object = new Commande($db); if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'commande',$id,''); -// Instantiate hooks of thirdparty module -if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules)) -{ - $object->callHooks('ordercard'); -} +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); +$hookmanager=new HookManager($db); +$hookmanager->callHooks(array('ordercard')); /******************************************************************************/ /* Actions */ /******************************************************************************/ -// Hook of actions -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'; - } - } - } - } - } -} +$reshook=$hookmanager->executeHooks('doActions',$action,$object,$socid); // Note that $action and $object may have been modified by some hooks // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes') @@ -317,6 +294,9 @@ if ($action == 'add' && $user->rights->commande->creer) } // 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)) { foreach($object->hooks as $hook) @@ -333,7 +313,7 @@ if ($action == 'add' && $user->rights->commande->creer) } } } - } + }*/ } else { @@ -910,7 +890,7 @@ if ($action == 'builddoc') // In get or post $outputlangs = new Translate("",$conf); $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) { dol_print_error($db,$result); @@ -1535,21 +1515,8 @@ else // Paiement incomplet. On demande si motif = escompte ou autre $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 (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); - } - } - } - } + + if (! $formconfirm) $formconfirm=$hookmanager->executeHooks('formconfirm',$action,$object,$lineid); // Note that $action and $object may have been modified by hook // Print form confirm print $formconfirm; @@ -1869,7 +1836,7 @@ else print ''; // 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 @@ -1880,33 +1847,16 @@ else { $var=true; - $object->formAddFreeProduct(1,$mysoc,$soc); + $object->formAddFreeProduct(1,$mysoc,$soc,$hookmanager); // Add predefined products/services if ($conf->product->enabled || $conf->service->enabled) { $var=!$var; - $object->formAddPredefinedProduct(1,$mysoc,$soc); - } - - // Hook for external modules - 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); - } - } - } - } + $object->formAddPredefinedProduct(1,$mysoc,$soc,$hookmanager); } + + $reshook=$hookmanager->executeHooks('formAddObject',$action,$object); // Note that $action and $object may have been modified by hook } } print '
'; @@ -2051,7 +2001,7 @@ else $genallowed=$user->rights->commande->creer; $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 @@ -2131,5 +2081,5 @@ else $db->close(); -llxFooter('$Date: 2011/08/08 12:00:13 $ - $Revision: 1.528 $'); +llxFooter('$Date: 2011/08/10 17:40:46 $ - $Revision: 1.529 $'); ?> diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e1e9031aa82..b273f1d74f6 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -21,7 +21,7 @@ * \file htdocs/core/class/commonobject.class.php * \ingroup core * \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 $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; @@ -1704,15 +1704,6 @@ class CommonObject { $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 - /* - 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 diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index e5bf5a208d4..4e97c547c43 100755 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -21,7 +21,7 @@ * \file htdocs/core/class/hookmanager.class.php * \ingroup core * \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. * $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; @@ -191,13 +191,14 @@ class HookManager // Hook generic 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); } } } } - if ($method == 'doActions' || $method == 'showInputField' || $method == 'showOutputFields') return $resaction; + if ($method == 'doActions' || $method == 'showInputFields' || $method == 'showOutputFields') return $resaction; return $resprint; } diff --git a/htdocs/includes/modules/commande/modules_commande.php b/htdocs/includes/modules/commande/modules_commande.php index ce72e32e5ca..f06bee6d752 100644 --- a/htdocs/includes/modules/commande/modules_commande.php +++ b/htdocs/includes/modules/commande/modules_commande.php @@ -25,7 +25,7 @@ * \ingroup commande * \brief Fichier contenant la classe mere de generation des commandes en PDF * 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'); @@ -143,7 +143,7 @@ class ModeleNumRefCommandes * @param hideref Hide ref * @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; $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 // output format that does not support UTF8. $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; // on supprime l'image correspondant au preview diff --git a/htdocs/includes/modules/commande/pdf_edison.modules.php b/htdocs/includes/modules/commande/pdf_edison.modules.php index 019231e34c5..4d9d364e85d 100644 --- a/htdocs/includes/modules/commande/pdf_edison.modules.php +++ b/htdocs/includes/modules/commande/pdf_edison.modules.php @@ -23,7 +23,7 @@ * \file htdocs/includes/modules/commande/pdf_edison.modules.php * \ingroup commande * \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"); @@ -95,7 +95,7 @@ class pdf_edison extends ModelePDFCommandes * @param hideref Do not show ref * @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; @@ -192,29 +192,29 @@ class pdf_edison extends ModelePDFCommandes $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page // 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->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $nexY = $pdf->GetY(); - $ref = pdf_getlineref($object, $i, $outputlangs); + $ref = pdf_getlineref($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY (10, $curY); $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->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->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->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->MultiCell(26, 3, $total_excl_tax, 0, 'R', 0); diff --git a/htdocs/includes/modules/commande/pdf_einstein.modules.php b/htdocs/includes/modules/commande/pdf_einstein.modules.php index 316e66a000a..49ca9f87f6f 100644 --- a/htdocs/includes/modules/commande/pdf_einstein.modules.php +++ b/htdocs/includes/modules/commande/pdf_einstein.modules.php @@ -24,7 +24,7 @@ * \ingroup commande * \brief Fichier de la classe permettant de generer les commandes au modele Einstein * \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"); @@ -110,7 +110,7 @@ class pdf_einstein extends ModelePDFCommandes * @param hideref Do not show ref * @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; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -240,7 +240,7 @@ class pdf_einstein extends ModelePDFCommandes // Description of product line $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 $nexY = $pdf->GetY(); @@ -248,18 +248,18 @@ class pdf_einstein extends ModelePDFCommandes // TVA 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->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); } // 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->MultiCell($this->posxqty-$this->posxup-1, 3, $up_excl_tax, 0, 'R', 0); // Quantity - $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); + $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY ($this->posxqty, $curY); $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); 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'); } // 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->MultiCell(26, 3, $total_excl_tax, 0, 'R', 0); diff --git a/htdocs/includes/modules/propale/modules_propale.php b/htdocs/includes/modules/propale/modules_propale.php index 972db7bd3e8..b9777804f7c 100644 --- a/htdocs/includes/modules/propale/modules_propale.php +++ b/htdocs/includes/modules/propale/modules_propale.php @@ -1,7 +1,7 @@ - * Copyright (C) 2004-2008 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005-2011 Regis Houssin * * 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 @@ -23,7 +23,7 @@ * \ingroup propale * \brief Fichier contenant la classe mere de generation des propales en PDF * 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'); @@ -140,7 +140,7 @@ class ModeleNumRefPropales * @param hideref Hide ref * @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; $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 // output format that does not support UTF8. $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; // on supprime l'image correspondant au preview diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php index f0803e92621..afc8e881366 100644 --- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php @@ -24,7 +24,7 @@ * \ingroup propale * \brief Fichier de la classe permettant de generer les propales au modele Azur * \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."/product/class/product.class.php"); @@ -109,7 +109,7 @@ class pdf_propale_azur extends ModelePDFPropales * @param hideref Do not show ref * @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; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -242,7 +242,7 @@ class pdf_propale_azur extends ModelePDFPropales // Description de la ligne produit $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 $nexY = $pdf->GetY(); @@ -250,18 +250,18 @@ class pdf_propale_azur extends ModelePDFPropales // TVA 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->MultiCell($this->posxup-$this->posxtva-1, 4, $vat_rate, 0, 'R'); } // 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->MultiCell($this->posxqty-$this->posxup-1, 4, $up_excl_tax, 0, 'R', 0); // Quantity - $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); + $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY ($this->posxqty, $curY); $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); 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'); } // 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->MultiCell(26, 4, $total_excl_tax, 0, 'R', 0); diff --git a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php index 4014979dae0..5e68c469b95 100644 --- a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php @@ -23,7 +23,7 @@ * \file htdocs/includes/modules/propale/pdf_propale_jaune.modules.php * \ingroup propale * \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"); @@ -85,7 +85,7 @@ class pdf_propale_jaune extends ModelePDFPropales * @param hideref Do not show ref * @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; $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 // 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 $nexY = $pdf->GetY(); - $ref = pdf_getlineref($object, $i, $outputlangs); + $ref = pdf_getlineref($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY (10, $curY ); $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->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->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->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->MultiCell(24, 4, $total_excl_tax, 0, 'R', 0); diff --git a/htdocs/lib/pdf.lib.php b/htdocs/lib/pdf.lib.php index d6205f4fe99..1a7b6254983 100644 --- a/htdocs/lib/pdf.lib.php +++ b/htdocs/lib/pdf.lib.php @@ -24,7 +24,7 @@ * \file htdocs/lib/pdf.lib.php * \brief Set of functions used for PDF generation * \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 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; - 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; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - foreach($object->hooks as $hook) - { - 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); - } + $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 } else { @@ -816,7 +814,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl * @param $i Current line number * @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) ) ) { @@ -837,7 +835,7 @@ function pdf_getlinenum($object,$i,$outputlangs) * @param $i Current line number * @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) ) ) { @@ -857,7 +855,7 @@ function pdf_getlineref($object,$i,$outputlangs) * @param i Current line number * @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) ) ) { @@ -881,16 +879,14 @@ function pdf_getlineref_supplier($object,$i,$outputlangs) * 1 = yes * 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; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - foreach($object->hooks as $hook) - { - if (method_exists($hook['modules'][$special_code],'pdf_getlinevatrate')) return $hook['modules'][$special_code]->pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails); - } + $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 } else { @@ -908,16 +904,14 @@ function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0) * 1 = yes * 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; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - foreach($object->hooks as $hook) - { - if (method_exists($hook['modules'][$special_code],'pdf_getlineupexcltax')) return $hook['modules'][$special_code]->pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails); - } + $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 } else { @@ -935,18 +929,16 @@ function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0) * 1 = yes * 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 (! 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; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - foreach($object->hooks as $hook) - { - if (method_exists($hook['modules'][$special_code],'pdf_getlineqty')) return $hook['modules'][$special_code]->pdf_getlineqty($object,$i,$outputlangs,$hidedetails); - } + $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 } else { @@ -965,18 +957,16 @@ function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0) * 1 = yes * 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 (! 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; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - foreach($object->hooks as $hook) - { - if (method_exists($hook['modules'][$special_code],'pdf_getlineqty_asked')) return $hook['modules'][$special_code]->pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails); - } + $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 } else { @@ -995,18 +985,16 @@ function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0) * 1 = yes * 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 (! 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; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - foreach($object->hooks as $hook) - { - if (method_exists($hook['modules'][$special_code],'pdf_getlineqty_shipped')) return $hook['modules'][$special_code]->pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails); - } + $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 } else { @@ -1025,18 +1013,16 @@ function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0) * 1 = yes * 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 (! 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; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - foreach($object->hooks as $hook) - { - if (method_exists($hook['modules'][$special_code],'pdf_getlineqty_keeptoship')) return $hook['modules'][$special_code]->pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails); - } + $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 } else { @@ -1055,20 +1041,18 @@ function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0) * 1 = yes * 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"); 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; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - foreach($object->hooks as $hook) - { - if (method_exists($hook['modules'][$special_code],'pdf_getlineremisepercent')) return $hook['modules'][$special_code]->pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails); - } + $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 } else { @@ -1087,7 +1071,7 @@ function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0) * 1 = yes * 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) { @@ -1095,14 +1079,12 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0) } 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; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - foreach($object->hooks as $hook) - { - if (method_exists($hook['modules'][$special_code],'pdf_getlinetotalexcltax')) return $hook['modules'][$special_code]->pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails); - } + $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 } 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 outputlangs Object langs for output */ -function pdf_getTotalQty($object,$type='',$outputlangs) +function pdf_getTotalQty($object,$type='',$outputlangs,$hookmanager=false) { $total=0; $nblignes=sizeof($object->lines);