From ce34c01b9e1efb69d013ea052963f03776f9b725 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Apr 2014 00:06:16 +0200 Subject: [PATCH] New: On page to enter supplier prices, if there is no supplier, add direct link to create one. Qual: 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 | 4 ++ htdocs/core/class/hookmanager.class.php | 1 + htdocs/core/class/html.form.class.php | 4 +- htdocs/langs/en_US/companies.lang | 1 + htdocs/opensurvey/results.php | 4 +- htdocs/product/fournisseurs.php | 11 +++-- htdocs/societe/soc.php | 54 ++++++++++++++++++------- 7 files changed, 59 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2a417a386dd..95314f65679 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 fc606857371..53a8f052394 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 46b0b6a2783..0943bce1e87 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 3c8ba86ec7c..55eb2dbb91f 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 7ac3dbb0d6d..48c585c0f2e 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 '
'."\n"; - print ''; + print ''; print '
'."\n"; print "

"."\n"; @@ -752,7 +752,7 @@ else print ''.dol_htmlentities($tmp[0]).''."\n"; } - print ''.img_picto('',dol_buildpath('/opensurvey/img/add-16.png',1),'',1).''."\n"; + print ''.img_picto('',dol_buildpath('/opensurvey/img/add-16.png',1),'',1).''."\n"; print ''."\n"; } diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index f696326a6f3..d8aa9b84314 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 ' - '.$langs->trans("CreateDolibarrThirdPartySupplier").''; + } } } print ''; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 3ff26dcffcd..8bb6342a2cd 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Brian Fraval - * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Patrick Raguin @@ -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 ''; print ''; + print ''; print ''; print ''; print ''; @@ -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 ''; // Ref