Skip to content

Commit

Permalink
Fix: works on repair broken features (in progress)
Browse files Browse the repository at this point in the history
  • Loading branch information
hregis committed Aug 10, 2011
1 parent 57ac43c commit 302070b
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 187 deletions.
8 changes: 4 additions & 4 deletions htdocs/comm/propal.php
Expand Up @@ -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");
Expand Down Expand Up @@ -865,7 +865,7 @@
$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);
Expand Down Expand Up @@ -1072,7 +1072,7 @@
$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;
Expand Down Expand Up @@ -1926,6 +1926,6 @@
}
$db->close();

llxFooter('$Date: 2011/08/10 10:55:40 $ - $Revision: 1.616 $');
llxFooter('$Date: 2011/08/10 17:40:46 $ - $Revision: 1.617 $');

?>
90 changes: 20 additions & 70 deletions htdocs/commande/fiche.php
Expand Up @@ -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");
Expand Down Expand Up @@ -64,40 +64,17 @@
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')
Expand Down Expand Up @@ -317,6 +294,9 @@
}

// 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)
Expand All @@ -333,7 +313,7 @@
}
}
}
}
}*/
}
else
{
Expand Down Expand Up @@ -910,7 +890,7 @@
$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);
Expand Down Expand Up @@ -1535,21 +1515,8 @@
// 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;
Expand Down Expand Up @@ -1869,7 +1836,7 @@
print '<table id="tablelines" class="noborder" width="100%">';

// 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
Expand All @@ -1880,33 +1847,16 @@
{
$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 '</table>';
Expand Down Expand Up @@ -2051,7 +2001,7 @@
$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
Expand Down Expand Up @@ -2131,5 +2081,5 @@

$db->close();

llxFooter('$Date: 2011/08/08 12:00:13 $ - $Revision: 1.528 $');
llxFooter('$Date: 2011/08/10 17:40:46 $ - $Revision: 1.529 $');
?>
13 changes: 2 additions & 11 deletions htdocs/core/class/commonobject.class.php
Expand Up @@ -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 $
*/


Expand Down Expand Up @@ -1655,7 +1655,7 @@ function formAddFreeProduct($dateSelector,$seller,$buyer,$hookmanager=false)
* @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;

Expand Down Expand Up @@ -1704,15 +1704,6 @@ function printObjectLines($action='viewline',$seller,$buyer,$selected=0,$dateSel
{
$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
Expand Down
7 changes: 4 additions & 3 deletions htdocs/core/class/hookmanager.class.php
Expand Up @@ -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 $
*/


Expand Down Expand Up @@ -120,7 +120,7 @@ function callHooks($arraytype)
* 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;

Expand Down Expand Up @@ -191,13 +191,14 @@ function executeHooks($method, &$action='', &$object='', $id='', $parameters=fal
// 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;
}

Expand Down
6 changes: 3 additions & 3 deletions htdocs/includes/modules/commande/modules_commande.php
Expand Up @@ -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');
Expand Down Expand Up @@ -143,7 +143,7 @@ function getVersion()
* @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");
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions htdocs/includes/modules/commande/pdf_edison.modules.php
Expand Up @@ -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");
Expand Down Expand Up @@ -95,7 +95,7 @@ function pdf_edison($db=0)
* @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;

Expand Down Expand Up @@ -192,29 +192,29 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$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);

Expand Down

0 comments on commit 302070b

Please sign in to comment.