Fix: works on repair broken features (in progress)

This commit is contained in:
Regis Houssin 2011-08-10 17:56:02 +00:00
parent fb09ae37d9
commit fc93513607
5 changed files with 39 additions and 126 deletions

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.529 2011/08/10 17:40:46 hregis Exp $ * \version $Id: fiche.php,v 1.530 2011/08/10 17:56:18 hregis Exp $
*/ */
require("../main.inc.php"); require("../main.inc.php");
@ -296,24 +296,6 @@ 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 $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 ($reshook < 0) $error++;
/*
if (! empty($object->hooks))
{
foreach($object->hooks as $hook)
{
if (! empty($hook['modules']))
{
foreach($hook['modules'] as $module)
{
if (method_exists($module,'createfrom'))
{
$res = $module->createfrom($srcobject,$object_id,$object->element);
if ($res < 0) $error++;
}
}
}
}
}*/
} }
else else
{ {
@ -2081,5 +2063,5 @@ else
$db->close(); $db->close();
llxFooter('$Date: 2011/08/10 17:40:46 $ - $Revision: 1.529 $'); llxFooter('$Date: 2011/08/10 17:56:18 $ - $Revision: 1.530 $');
?> ?>

View File

@ -25,7 +25,7 @@
* \file htdocs/compta/facture.php * \file htdocs/compta/facture.php
* \ingroup facture * \ingroup facture
* \brief Page to create/see an invoice * \brief Page to create/see an invoice
* \version $Id: facture.php,v 1.850 2011/08/03 00:46:23 eldy Exp $ * \version $Id: facture.php,v 1.851 2011/08/10 17:56:13 hregis Exp $
*/ */
require('../main.inc.php'); require('../main.inc.php');
@ -74,41 +74,17 @@ $usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE;
$object=new Facture($db); $object=new Facture($db);
// 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('invoicecard'); $hookmanager->callHooks(array('invoicecard'));
}
/******************************************************************************/ /******************************************************************************/
/* 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')
@ -805,23 +781,8 @@ if ($action == 'add' && $user->rights->facture->creer)
} }
// Hooks // Hooks
if (! empty($object->hooks)) $reshook=$hookmanager->executeHooks('createfrom',$action,$srcobject,$id,$object->element); // Note that $action and $object may have been modified by hook
{ if ($reshook < 0) $error++;
foreach($object->hooks as $hook)
{
if (! empty($hook['modules']))
{
foreach($hook['modules'] as $module)
{
if (method_exists($module,'createfrom'))
{
$res = $module->createfrom($srcobject,$id,$object->element);
if ($res < 0) $error++;
}
}
}
}
}
} }
else else
{ {
@ -1415,7 +1376,7 @@ if (GETPOST('action') == 'builddoc') // En get ou en post
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
$result=facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); $result=facture_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);
@ -2071,21 +2032,8 @@ else
// Paiement incomplet. On demande si motif = escompte ou autre // Paiement incomplet. On demande si motif = escompte ou autre
$formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('CloneInvoice'),$langs->trans('ConfirmCloneInvoice',$object->ref),'confirm_clone',$formquestion,'yes',1); $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('CloneInvoice'),$langs->trans('ConfirmCloneInvoice',$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;
@ -2603,7 +2551,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
@ -2612,33 +2560,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
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);
}
}
}
}
} }
$reshook=$hookmanager->executeHooks('formAddObject',$action,$object); // Note that $action and $object may have been modified by hook
} }
print "</table>\n"; print "</table>\n";
@ -2874,7 +2805,7 @@ else
$delallowed=$user->rights->facture->supprimer; $delallowed=$user->rights->facture->supprimer;
print '<br>'; print '<br>';
$somethingshown=$formfile->show_documents('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang,$object->hooks); $somethingshown=$formfile->show_documents('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang,$hookmanager);
/* /*
* Linked object block * Linked object block
@ -3247,5 +3178,5 @@ else
$db->close(); $db->close();
llxFooter('$Date: 2011/08/03 00:46:23 $ - $Revision: 1.850 $'); llxFooter('$Date: 2011/08/10 17:56:13 $ - $Revision: 1.851 $');
?> ?>

View File

@ -24,7 +24,7 @@
* \ingroup facture * \ingroup facture
* \brief File of class to generate invoices from crab model * \brief File of class to generate invoices from crab model
* \author Laurent Destailleur * \author Laurent Destailleur
* \version $Id: pdf_crabe.modules.php,v 1.12 2011/07/31 23:28:15 eldy Exp $ * \version $Id: pdf_crabe.modules.php,v 1.13 2011/08/10 17:56:11 hregis Exp $
*/ */
require_once(DOL_DOCUMENT_ROOT."/includes/modules/facture/modules_facture.php"); require_once(DOL_DOCUMENT_ROOT."/includes/modules/facture/modules_facture.php");
@ -115,7 +115,7 @@ class pdf_crabe extends ModelePDFFactures
* @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;
@ -247,7 +247,7 @@ class pdf_crabe extends ModelePDFFactures
// Description of product line // Description of product line
$pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
$curX = $this->posxdesc-1; $curX = $this->posxdesc-1;
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$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();
@ -255,18 +255,18 @@ class pdf_crabe extends ModelePDFFactures
// VAT Rate // VAT Rate
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'); // Enough for 6 chars $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $qty, 0, 'R'); // Enough for 6 chars
@ -274,12 +274,12 @@ class pdf_crabe extends ModelePDFFactures
if ($object->lines[$i]->remise_percent) if ($object->lines[$i]->remise_percent)
{ {
$pdf->SetXY ($this->posxdiscount-2, $curY); $pdf->SetXY ($this->posxdiscount-2, $curY);
$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R'); $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 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

@ -25,7 +25,7 @@
* \ingroup facture * \ingroup facture
* \brief Fichier de la classe permettant de generer les factures au modele oursin * \brief Fichier de la classe permettant de generer les factures au modele oursin
* \author Sylvain SCATTOLINI base sur un modele de Laurent Destailleur * \author Sylvain SCATTOLINI base sur un modele de Laurent Destailleur
* \version $Id: pdf_oursin.modules.php,v 1.11 2011/07/31 23:28:15 eldy Exp $ * \version $Id: pdf_oursin.modules.php,v 1.12 2011/08/10 17:56:10 hregis Exp $
*/ */
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
@ -114,7 +114,7 @@ class pdf_oursin extends ModelePDFFactures
* @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;
@ -211,7 +211,7 @@ class pdf_oursin extends ModelePDFFactures
$curY = $nexY; $curY = $nexY;
// Description of product line // Description of product line
pdf_writelinedesc($pdf,$object,$i,$outputlangs,108,3,$this->posxdesc-1,$curY+1,$hideref,$hidedesc); pdf_writelinedesc($pdf,$object,$i,$outputlangs,108,3,$this->posxdesc-1,$curY+1,$hideref,$hidedesc,0,$hookmanager);
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
@ -220,31 +220,31 @@ class pdf_oursin extends ModelePDFFactures
{ {
if ($this->franchise!=1) if ($this->franchise!=1)
{ {
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY ($this->marges['g']+118, $curY); $pdf->SetXY ($this->marges['g']+118, $curY);
$pdf->MultiCell(12, 3, $vat_rate, 0, 'R'); $pdf->MultiCell(12, 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->marges['g']+132, $curY); $pdf->SetXY ($this->marges['g']+132, $curY);
$pdf->MultiCell(16, 3, $up_excl_tax, 0, 'R', 0); $pdf->MultiCell(16, 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->marges['g']+150, $curY); $pdf->SetXY ($this->marges['g']+150, $curY);
$pdf->MultiCell(10, 3, $qty, 0, 'R'); $pdf->MultiCell(10, 3, $qty, 0, 'R');
// Remise sur ligne // Remise sur ligne
$pdf->SetXY ($this->marges['g']+160, $curY); $pdf->SetXY ($this->marges['g']+160, $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(14, 3, $remise_percent, 0, 'R'); $pdf->MultiCell(14, 3, $remise_percent, 0, 'R');
} }
// Total HT // Total HT
$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY ($this->marges['g']+168, $curY); $pdf->SetXY ($this->marges['g']+168, $curY);
$pdf->MultiCell(21, 3, $total_excl_tax, 0, 'R', 0); $pdf->MultiCell(21, 3, $total_excl_tax, 0, 'R', 0);

View File

@ -24,7 +24,7 @@
* \ingroup facture * \ingroup facture
* \brief Fichier contenant la classe mere de generation des factures en PDF * \brief Fichier contenant la classe mere de generation des factures en PDF
* et la classe mere de numerotation des factures * et la classe mere de numerotation des factures
* \version $Id: modules_facture.php,v 1.93 2011/07/31 23:28:16 eldy Exp $ * \version $Id: modules_facture.php,v 1.94 2011/08/10 17:56:02 hregis Exp $
*/ */
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
@ -144,7 +144,7 @@ class ModeleNumRefFactures
* @param hideref Hide ref * @param hideref Hide ref
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function facture_pdf_create($db, $object, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) function facture_pdf_create($db, $object, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
@ -210,7 +210,7 @@ function facture_pdf_create($db, $object, $message, $modele, $outputlangs, $hide
// 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)
{ {
// Success in building document. We build meta file. // Success in building document. We build meta file.
facture_meta_create($db, $object->id); facture_meta_create($db, $object->id);