diff --git a/ChangeLog b/ChangeLog index 2a417a386ddf9b2b50b2822f8503ef7db900279e..95314f656791a05534fd895c35e10c988c717a9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -78,6 +78,10 @@ removed. You must now use the 6 parameters way. See file modMyModule.class.php f - Properties "dictionnaries" into module descriptor files has been renamed into "dictionaries". - Method form->select_currency() has been removed. Use instead print form->selectCurrency(). - Method form->select_methodes_commande() has been renamed into english name selectInputMethod(). +- The following hooks are now 'addreplace' hooks: "formCreateThirdpartyOptions" + So check that return value is 0 to keep default standard behaviour after hook or 1 to disable + default standard behaviour. + ***** ChangeLog for 3.5.2 compared to 3.5.1 ***** diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index fc606857371412f7d66adef611ce55e230abf31e..53a8f05239434a5fcabc07bc5739621e771fd473 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -137,6 +137,7 @@ class HookManager 'addMoreActionsButtons', 'addStatisticLine', 'doActions', + 'formCreateThirdpartyOptions', 'formObjectOptions', 'formattachOptions', 'formBuilddocLineOptions', diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 46b0b6a27838c831652c0b9be86166ccaa248501..0943bce1e87a984612bdad2949fa45ac97913751 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -757,7 +757,7 @@ class Form { global $conf,$user,$langs; - $out=''; + $out=''; $num=0; $outarray=array(); // On recherche les societes @@ -859,6 +859,8 @@ class Form dol_print_error($this->db); } + $this->result=array('nbofthirdparties'=>$num); + if ($outputmode) return $outarray; return $out; } diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 3c8ba86ec7c6da4bb7cc7437f8126871a74fdd8c..55eb2dbb91fd702ef36ca5cf5277757704dd5acd 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -18,6 +18,7 @@ NewCompany=New company (prospect, customer, supplier) NewThirdParty=New third party (prospect, customer, supplier) NewSocGroup=New company group NewPrivateIndividual=New private individual (prospect, customer, supplier) +CreateDolibarrThirdPartySupplier=Create a third party (supplier) ProspectionArea=Prospection area SocGroup=Group of companies IdThirdParty=Id third party diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index 7ac3dbb0d6d4f4cba8d9be2aed1b0ab454bcfd3f..48c585c0f2e80ffe2589f6cf6e1a3532593f0e9c 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -511,7 +511,7 @@ if (GETPOST('ajoutsujet')) if (!$user->rights->opensurvey->write) accessforbidden(); print '<form name="formulaire" action="" method="POST">'."\n"; - print '<input type="hidden" name="backtourl" value="'.GETPOST('backtourl').'">'; + print '<input type="hidden" name="backtopage" value="'.GETPOST('backtopage').'">'; print '<div class="center">'."\n"; print "<br><br>"."\n"; @@ -752,7 +752,7 @@ else print '<td class="sujet">'.dol_htmlentities($tmp[0]).'</td>'."\n"; } - print '<td class="sujet"><a href="'.$_SERVER["PHP_SELF"].'?id='.$numsondage.'&ajoutsujet=1&backtourl='.urlencode($_SERVER["PHP_SELF"]).'">'.img_picto('',dol_buildpath('/opensurvey/img/add-16.png',1),'',1).'</a></td>'."\n"; + print '<td class="sujet"><a href="'.$_SERVER["PHP_SELF"].'?id='.$numsondage.'&ajoutsujet=1&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_picto('',dol_buildpath('/opensurvey/img/add-16.png',1),'',1).'</a></td>'."\n"; print '</tr>'."\n"; } diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index f696326a6f37208ff2aef2fcaa05419b952d6d84..d8aa9b8431498a616693b81e7b4ff09cb846aa24 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -42,6 +42,7 @@ $ref = GETPOST('ref', 'alpha'); $rowid=GETPOST('rowid','int'); $action=GETPOST('action', 'alpha'); $socid=GETPOST('socid', 'int'); +$backtopage=GETPOST('backtopage','alpha'); $error=0; $mesg = ''; // If socid provided by ajax company selector @@ -304,10 +305,14 @@ if ($id || $ref) $events[]=array('method' => 'getVatRates', 'url' => dol_buildpath('/core/ajax/vatrates.php',1), 'htmlname' => 'tva_tx', 'params' => array()); print $form->select_company(GETPOST("id_fourn"),'id_fourn','fournisseur=1',1,0,0,$events); - if (is_object($hookmanager)) + $parameters=array('filtre'=>"fournisseur=1",'html_name'=>'id_fourn','selected'=>GETPOST("id_fourn"),'showempty'=>1,'prod_id'=>$product->id); + $reshook=$hookmanager->executeHooks('formCreateThirdpartyOptions',$parameters,$object,$action); + if (empty($reshook)) { - $parameters=array('filtre'=>"fournisseur=1",'html_name'=>'id_fourn','selected'=>GETPOST("id_fourn"),'showempty'=>1,'prod_id'=>$product->id); - $reshook=$hookmanager->executeHooks('formCreateThirdpartyOptions',$parameters,$object,$action); + if (empty($form->result)) + { + print ' - <a href="'.DOL_URL_ROOT.'/societe/soc.php?action=create&type=f&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$product->id.'&action='.$action).'">'.$langs->trans("CreateDolibarrThirdPartySupplier").'</a>'; + } } } print '</td></tr>'; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 3ff26dcffcd49ed23ec83721582477d309d66e16..8bb6342a2cd4fda20347e5d4fa8037a95be5f3e1 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1,7 +1,7 @@ <?php /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2003 Brian Fraval <brian@fraval.org> - * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net> @@ -49,6 +49,7 @@ if (! empty($conf->notification->enabled)) $langs->load("mails"); $mesg=''; $error=0; $errors=array(); $action = (GETPOST('action') ? GETPOST('action') : 'view'); +$backtopage = GETPOST('backtopage','alpha'); $confirm = GETPOST('confirm'); $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; @@ -182,7 +183,7 @@ if (empty($reshook)) else if (! empty($_FILES['photo']['name'])) $object->logo = dol_sanitizeFileName($_FILES['photo']['name']); // Check parameters - if (empty($_POST["cancel"])) + if (! GETPOST("cancel")) { if (! empty($object->email) && ! isValidEMail($object->email)) { @@ -317,11 +318,20 @@ if (empty($reshook)) { $db->commit(); - $url=$_SERVER["PHP_SELF"]."?socid=".$object->id; - if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url=DOL_URL_ROOT."/comm/fiche.php?socid=".$object->id; - else if ($object->fournisseur == 1) $url=DOL_URL_ROOT."/fourn/fiche.php?socid=".$object->id; - header("Location: ".$url); - exit; + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + else + { + $url=$_SERVER["PHP_SELF"]."?socid=".$object->id; + if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url=DOL_URL_ROOT."/comm/fiche.php?socid=".$object->id; + else if ($object->fournisseur == 1) $url=DOL_URL_ROOT."/fourn/fiche.php?socid=".$object->id; + + header("Location: ".$url); + exit; + } } else { @@ -332,10 +342,18 @@ if (empty($reshook)) if ($action == 'update') { - if ($_POST["cancel"]) + if (GETPOST("cancel")) { - header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); - exit; + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + else + { + header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); + exit; + } } // To not set code if third party is not concerned. But if it had values, we keep them. @@ -425,9 +443,16 @@ if (empty($reshook)) if (! $error && ! count($errors)) { - - header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); - exit; + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + else + { + header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); + exit; + } } else { @@ -739,6 +764,7 @@ else print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">'; print '<input type="hidden" name="action" value="add">'; + print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="private" value='.$object->particulier.'>'; print '<input type="hidden" name="type" value='.GETPOST("type").'>'; @@ -1478,7 +1504,7 @@ else $showlogo=$object->logo; $showbarcode=empty($conf->barcode->enabled)?0:1; if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; - + print '<table class="border" width="100%">'; // Ref