From 6cb0685b6f158d21e2794480eae2a8d0a79ecca1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Feb 2012 17:18:19 +0100 Subject: [PATCH] Qual: Uniformize hook names. All hooks to add information on create/update/view cards are called fomrObjectOptions instead of sometine formObjectOptions, sometimes showInputFields, sometimes showOutputFields. --- htdocs/adherents/fiche.php | 22 ++++---- htdocs/comm/addpropal.php | 23 +++++--- htdocs/comm/propal.php | 22 +++++--- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/commande/class/commande.class.php | 52 +++++++++---------- htdocs/commande/fiche.php | 40 ++++++++++---- htdocs/compta/facture.php | 32 +++++++++--- htdocs/compta/facture/class/facture.class.php | 4 +- htdocs/core/class/hookmanager.class.php | 33 ++++-------- htdocs/product/fiche.php | 45 +++++++++++++++- htdocs/societe/soc.php | 18 +++---- 11 files changed, 189 insertions(+), 104 deletions(-) diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 950967b4eb4..a5992410f0b 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -770,19 +770,19 @@ if ($action == 'create') // Other attributes $parameters=array(); - $reshook=$hookmanager->executeHooks('showInputFields',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { foreach($extrafields->attribute_label as $key=>$label) { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:''); - print "".$label.''; + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print ''.$label.''; print $extrafields->showInputField($key,$value); print ''."\n"; } } -/* + /* // Third party Dolibarr if ($conf->societe->enabled) { @@ -795,7 +795,8 @@ if ($action == 'create') print ''.$langs->trans("LinkedToDolibarrUser").''; print $form->select_users($object->user_id,'userid',1); print ''; -*/ + */ + print "\n"; print '
'; @@ -848,8 +849,7 @@ if ($action == 'edit') dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); dol_htmloutput_errors($errmsg,$errmsgs); - - if ($mesg) print '
'.$mesg.'
'; + dol_htmloutput_mesg($mesg); if ($conf->use_javascript_ajax) { @@ -991,15 +991,15 @@ if ($action == 'edit') // Other attributes $parameters=array(); - $reshook=$hookmanager->executeHooks('showInputFields',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { foreach($extrafields->attribute_label as $key=>$label) { - $value=(isset($_POST["options_$key"])?$_POST["options_$key"]:$object->array_options["options_$key"]); - print "".$label.""; + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print ''.$label.''; print $extrafields->showInputField($key,$value); - print "\n"; + print ''."\n"; } } diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php index 62dcde615bf..0f124265ee0 100644 --- a/htdocs/comm/addpropal.php +++ b/htdocs/comm/addpropal.php @@ -80,7 +80,7 @@ if ($action == 'create') exit; } - $propal = new Propal($db); + $object = new Propal($db); $numpr=''; $obj = $conf->global->PROPALE_ADDON; @@ -90,7 +90,7 @@ if ($action == 'create') { require_once(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"); $modPropale = new $obj; - $numpr = $modPropale->getNextValue($soc,$propal); + $numpr = $modPropale->getNextValue($soc,$object); } } @@ -175,12 +175,12 @@ if ($action == 'create') // What trigger creation print ''.$langs->trans('Source').''; - $form->select_demand_reason($propal->demand_reason,'demand_reason_id',"SRC_PROP",1); + $form->select_demand_reason($object->demand_reason,'demand_reason_id',"SRC_PROP",1); print ''; // Delivery delay print ''.$langs->trans('AvailabilityPeriod').''; - $form->select_availability($propal->availability,'availability_id','',1); + $form->select_availability($object->availability,'availability_id','',1); print ''; // Delivery date (or manufacturing) @@ -240,10 +240,19 @@ if ($action == 'create') print ''; } - // Insert hooks - $parameters=array('socid'=>$socid); - $object=new Propal($db); + // Other attributes + $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print "".$label.''; + print $extrafields->showInputField($key,$value); + print ''."\n"; + } + } print ""; print '
'; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index e1a50e5e6fa..041fbadaead 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -745,7 +745,7 @@ else if ($action == "addline" && $user->rights->propale->creer) $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); } } - + // Define output language if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { @@ -758,7 +758,7 @@ else if ($action == "addline" && $user->rights->propale->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - + $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description; } else @@ -1144,7 +1144,7 @@ if ($id > 0 || ! empty($ref)) if (! $formconfirm) { $parameters=array('lineid'=>$lineid); - $formconfirm=$hookmanager->executeHooks('formconfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + $formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook } // Print form confirm @@ -1468,9 +1468,19 @@ if ($id > 0 || ! empty($ref)) print ''; } - // Insert hooks - $parameters=array('colspan'=>' colspan="3"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + // Other attributes + $parameters=array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print "".$label.''; + print $extrafields->showInputField($key,$value); + print ''."\n"; + } + } // Amount HT print ''.$langs->trans('AmountHT').''; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 9d11f05ca25..9180774d38f 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -917,7 +917,7 @@ class Propal extends CommonObject { $parameters=array('objFrom'=>$objFrom); $action=''; - $reshook=$hookmanager->executeHooks('createfrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 4bb4e56a16a..9854f2c8093 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -112,8 +112,8 @@ class Commande extends CommonObject $this->products = array(); } - - /** + + /** * Returns the reference to the following non used Order depending on the active numbering module * defined into COMMANDE_ADDON * @@ -448,7 +448,7 @@ class Commande extends CommonObject /** * Close order - * + * * @param User $user Objet user that close * @return int <0 if KO, >0 if OK */ @@ -504,7 +504,7 @@ class Commande extends CommonObject /** * Cancel an order * If stock is decremented on order validation, we must reincrement it - * + * * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, >0 if OK */ @@ -531,7 +531,7 @@ class Commande extends CommonObject { require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"); $langs->load("agenda"); - + $num=count($this->lines); for ($i = 0; $i < $num; $i++) { @@ -581,7 +581,7 @@ class Commande extends CommonObject /** * Create order * Note that this->ref can be set or empty. If empty, we will use "(PROV)" - * + * * @param User $user Objet user that make creation * @param int notrigger Disable all triggers * @return int <0 if KO, >0 if OK @@ -825,7 +825,7 @@ class Commande extends CommonObject { $parameters=array('objFrom'=>$objFrom); $action=''; - $reshook=$hookmanager->executeHooks('createfrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; } @@ -921,7 +921,7 @@ class Commande extends CommonObject $parameters=array('objFrom'=>$object); $action=''; - $reshook=$hookmanager->executeHooks('createfrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; if (! $error) @@ -944,7 +944,7 @@ class Commande extends CommonObject /** * Add an order line into database (linked to product/service or not) - * + * * @param int $commandeid Id of line * @param string $desc Description of line * @param double $pu_ht Unit price (without tax) @@ -1112,7 +1112,7 @@ class Commande extends CommonObject * @param timestamp $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) * @param timestamp $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) * @return void - * + * * TODO Remplacer les appels a cette fonction par generation objet Ligne * insere dans tableau $this->products */ @@ -1316,7 +1316,7 @@ class Commande extends CommonObject /** * Adding line of fixed discount in the order in DB - * + * * @param int $idremise Id de la remise fixe * @return int >0 si ok, <0 si ko */ @@ -1392,7 +1392,7 @@ class Commande extends CommonObject /** * Load array lines - * + * * @param int $only_product Return only physical products * @return int <0 if KO, >0 if OK */ @@ -1494,10 +1494,10 @@ class Commande extends CommonObject /** * Load array this->expeditions of nb of products sent by line in order - * + * * @param int $filtre_statut Filter on status * @return int <0 if KO, Nb of lines found if OK - * + * * TODO deprecated, move to Shipping class */ function loadExpeditions($filtre_statut=-1) @@ -1544,7 +1544,7 @@ class Commande extends CommonObject /** * Returns a array with expeditions lines number - * + * * TODO deprecated, move to Shipping class */ function nb_expedition() @@ -1567,7 +1567,7 @@ class Commande extends CommonObject /** * Return a array with sendings by line - * + * * @param int $filtre_statut Filtre sur statut * @return int 0 si OK, <0 si KO * @@ -1582,10 +1582,10 @@ class Commande extends CommonObject /** * Return a array with the pending stock by product - * + * * @param int $filtre_statut Filtre sur statut * @return int 0 si OK, <0 si KO - * + * * TODO FONCTION NON FINIE A FINIR */ function stock_array($filtre_statut=-1) @@ -1594,7 +1594,7 @@ class Commande extends CommonObject // Tableau des id de produit de la commande $array_of_product=array(); - + // Recherche total en stock pour chaque produit if (count($array_of_product)) @@ -1622,7 +1622,7 @@ class Commande extends CommonObject /** * Delete an order line - * + * * @param int $lineid Id of line to delete * @return int >0 if OK, 0 if nothing to do, <0 if KO */ @@ -2038,7 +2038,7 @@ class Commande extends CommonObject /** * Change le delai de livraison - * + * * @param int $availability_id Id du nouveau mode * @return int >0 if OK, <0 if KO */ @@ -2403,7 +2403,7 @@ class Commande extends CommonObject /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) - * + * * @param User $user Object user * @return int <0 if KO, >0 if OK */ @@ -2756,7 +2756,7 @@ class Commande extends CommonObject /** * Return an array of order lines - * + * * @return array Lines of order */ function getLinesArray() @@ -2960,7 +2960,7 @@ class OrderLine global $conf, $user, $langs; $error=0; - + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid='".$this->rowid."';"; dol_syslog("OrderLine::delete sql=".$sql); @@ -2995,7 +2995,7 @@ class OrderLine global $langs, $conf, $user; $error=0; - + dol_syslog("OrderLine::insert rang=".$this->rang); // Clean parameters @@ -3095,7 +3095,7 @@ class OrderLine global $conf,$langs,$user; $error=0; - + // Clean parameters if (empty($this->tva_tx)) $this->tva_tx=0; if (empty($this->localtax1_tx)) $this->localtax1_tx=0; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 69ed314b433..04edb4bcc1f 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -303,7 +303,7 @@ if ($action == 'add' && $user->rights->commande->creer) // Hooks $parameters=array('objFrom'=>$srcobject); - $reshook=$hookmanager->executeHooks('createfrom',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('createFrom',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if ($reshook < 0) $error++; } else @@ -552,7 +552,7 @@ if ($action == 'addline' && $user->rights->commande->creer) $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); } } - + // Define output language if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { @@ -565,7 +565,7 @@ if ($action == 'addline' && $user->rights->commande->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - + $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description; } else @@ -1366,13 +1366,23 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } - // Insert hooks - $parameters=array(); + // Other attributes + $parameters=array('colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print "".$label.''; + print $extrafields->showInputField($key,$value); + print ''."\n"; + } + } + // Template to use by default print ''.$langs->trans('Model').''; print ''; - // pdf include_once(DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'); $liste=ModelePDFCommandes::liste_modeles($db); print $form->selectarray('model',$liste,$conf->global->COMMANDE_ADDON_PDF); @@ -1643,7 +1653,7 @@ else if (! $formconfirm) { $parameters=array('lineid'=>$lineid); - $formconfirm=$hookmanager->executeHooks('formconfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + $formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook } // Print form confirm @@ -1908,11 +1918,19 @@ else print ''; } - // Insert hooks - $parameters=array('colspan'=>' colspan="2"'); + // Other attributes + $parameters=array('colspan' => ' colspan="2"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - - // Lignes de 3 colonnes + if (empty($reshook)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print ''.$label.''; + print $extrafields->showInputField($key,$value); + print ''."\n"; + } + } // Total HT print ''.$langs->trans('AmountHT').''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index e19cc5deaed..36c3b49cb60 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -856,7 +856,7 @@ if ($action == 'add' && $user->rights->facture->creer) // Hooks $parameters=array('objFrom'=>$srcobject); - $reshook=$hookmanager->executeHooks('createfrom',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('createFrom',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if ($reshook < 0) $error++; } else @@ -1801,9 +1801,19 @@ if ($action == 'create') print ''; } - // Insert hooks - $parameters=array(); + // Other attributes + $parameters=array('colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print ''.$label.''; + print $extrafields->showInputField($key,$value); + print ''."\n"; + } + } // Modele PDF print ''.$langs->trans('Model').''; @@ -2197,7 +2207,7 @@ else if (! $formconfirm) { $parameters=array('lineid'=>$lineid); - $formconfirm=$hookmanager->executeHooks('formconfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + $formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook } // Print form confirm @@ -2700,9 +2710,19 @@ else print ''; } - // Insert hooks - $parameters=array('colspan'=>' colspan="3"'); + // Other attributes + $parameters=array('colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print ''.$label.''; + print $extrafields->showInputField($key,$value); + print ''."\n"; + } + } print '
'; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3554c11305d..ad5624f8a3f 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -557,7 +557,7 @@ class Facture extends CommonObject { $parameters=array('objFrom'=>$objFrom); $action=''; - $reshook=$hookmanager->executeHooks('createfrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; } @@ -653,7 +653,7 @@ class Facture extends CommonObject $parameters=array('objFrom'=>$object); $action=''; - $reshook=$hookmanager->executeHooks('createfrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; if (! $error) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index e1386d44b3e..3babbc8aeee 100755 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -124,8 +124,8 @@ class HookManager * @param array $parameters Array of parameters * @param Object &$object Object to use hooks on * @param string &$action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) - * @return mixed For doActions,showInputField,showOutputField: Return 0 if we want to keep standard actions, >0 if if want to stop standard actions, <0 means KO. - * For printSearchForm,printLeftBlock: Return HTML string. + * @return mixed For doActions,formObjectOptions: Return 0 if we want to keep standard actions, >0 if if want to stop standard actions, <0 means KO. + * For printSearchForm,printLeftBlock: Return HTML string. * $this->error or this->errors are also defined by class called by this function if error. */ function executeHooks($method, $parameters=false, &$object='', &$action='') @@ -148,30 +148,17 @@ class HookManager $var=!$var; // Hooks that return int - if ($method == 'doActions' && method_exists($actioninstance,$method)) + if (($method == 'doActions' || $method='formObjectOptions') && method_exists($actioninstance,$method)) { - $resaction+=$actioninstance->doActions($parameters, $object, $action); // action can be changed by method (to go back to other action for example), socid can be changed/set by method (during creation for example) - if ($resaction < 0 || ! empty($actioninstance->error) || (! empty($actioninstance->errors) && count($actioninstance->errors) > 0)) - { - $this->error=$actioninstance->error; $this->errors=$actioninstance->errors; - if ($action=='add') $action='create'; // TODO this change must be inside the doActions - if ($action=='update') $action='edit'; // TODO this change must be inside the doActions - } - } - else if ($method == 'showInputFields' && method_exists($actioninstance,$method)) - { - $resaction+=$actioninstance->showInputFields($parameters, $object, $action); // action can be changed by method (to go back to other action for example), socid can be changed/set by method (during creation for example) - if ($resaction < 0 || ! empty($actioninstance->error) || (! empty($actioninstance->errors) && count($actioninstance->errors) > 0)) - { - $this->error=$actioninstance->error; $this->errors=$actioninstance->errors; - } - } - else if ($method == 'showOutputFields' && method_exists($actioninstance,$method)) - { - $resaction+=$actioninstance->showOutputFields($parameters, $object, $action); // action can be changed by method (to go back to other action for example), socid can be changed/set by method (during creation for example) + $resaction+=$actioninstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example) if ($resaction < 0 || ! empty($actioninstance->error) || (! empty($actioninstance->errors) && count($actioninstance->errors) > 0)) { $this->error=$actioninstance->error; $this->errors=$actioninstance->errors; + if ($method == 'doActions') + { + if ($action=='add') $action='create'; // TODO this change must be inside the doActions + if ($action=='update') $action='edit'; // TODO this change must be inside the doActions + } } } // Generic hooks that return a string (printSearchForm, printLeftBlock, formBuilddocOptions, ...) @@ -184,7 +171,7 @@ class HookManager } } - if ($method == 'doActions' || $method == 'showInputFields' || $method == 'showOutputFields') return $resaction; + if ($method == 'doActions' || $method == 'formObjectOptions') return $resaction; return $resprint; } diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 79ec4d6f9ce..70a549c8df8 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2006 Andre Cianfarani @@ -780,7 +780,21 @@ else if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''; - // Note (invisible sur facture, propales...) + // Other attributes + $parameters=array('colspan' => ' colspan="2"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print ''.$label.''; + print $extrafields->showInputField($key,$value); + print ''."\n"; + } + } + + // Note (private, no output on invoices, propales...) print ''.$langs->trans("NoteNotVisibleOnBill").''; require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); $doleditor=new DolEditor('note',$_POST["note"],'',180,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,8,70); @@ -970,6 +984,20 @@ else if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''; + // Other attributes + $parameters=array('colspan' => ' colspan="2"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print ''.$label.''; + print $extrafields->showInputField($key,$value); + print ''."\n"; + } + } + // Note print ''.$langs->trans("NoteNotVisibleOnBill").''; require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); @@ -1183,6 +1211,19 @@ else // Origin country code print ''.$langs->trans("CountryOrigin").''.getCountry($object->country_id,0,$db).''; + // Other attributes + $parameters=array('colspan' => ' colspan="2"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print ''.$label.''; + print $extrafields->showInputField($key,$value); + print ''."\n"; + } + } // Note print ''.$langs->trans("Note").''.(dol_textishtml($object->note)?$object->note:dol_nl2br($object->note,1,true)).''; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 6060fc0f06a..3fd17d21210 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -940,13 +940,13 @@ else // Other attributes $parameters=array('colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('showInputFields',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { foreach($extrafields->attribute_label as $key=>$label) { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:''); - print "".$label.''; + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print ''.$label.''; print $extrafields->showInputField($key,$value); print ''."\n"; } @@ -1368,13 +1368,13 @@ else // Other attributes $parameters=array('colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('showInputFields',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { foreach($extrafields->attribute_label as $key=>$label) { - $value=(isset($_POST["options_$key"])?$_POST["options_$key"]:$object->array_options["options_$key"]); - print "".$label.""; + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print ''.$label.''; print $extrafields->showInputField($key,$value); print "\n"; } @@ -1717,13 +1717,13 @@ else // Other attributes $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('showOutputFields',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { foreach($extrafields->attribute_label as $key=>$label) { - $value=$object->array_options["options_$key"]; - print "".$label.''; + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print ''.$label.''; print $extrafields->showOutputField($key,$value); print "\n"; }