From b4ebd7e8529721f8f15bf869d518cb9e58fe1f21 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Nov 2012 11:36:45 +0100 Subject: [PATCH 1/7] Qual: Uniformize code and fix a regression --- .../tpl/predefinedproductline_create.tpl.php | 63 ++++++++++--------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/htdocs/core/tpl/predefinedproductline_create.tpl.php b/htdocs/core/tpl/predefinedproductline_create.tpl.php index 601f463682d..4064fb3b585 100644 --- a/htdocs/core/tpl/predefinedproductline_create.tpl.php +++ b/htdocs/core/tpl/predefinedproductline_create.tpl.php @@ -1,6 +1,6 @@ - * Copyright (C) 2010-2011 Laurent Destailleur + * Copyright (C) 2010-2012 Laurent Destailleur * Copyright (C) 2012 Christophe Battarel * * This program is free software; you can redistribute it and/or modify @@ -42,17 +42,16 @@ trans('ReductionShort'); ?> margin->enabled)) { +if (! empty($conf->margin->enabled)) +{ + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; + if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; ?> trans('BuyingPrice'); ?> -global->DISPLAY_MARGIN_RATES)) - $colspan++; - if (! empty($conf->global->DISPLAY_MARK_RATES)) - $colspan++; -} -?>   +
0) jQuery('#np_desc').focus(); }); }); @@ -97,17 +96,16 @@ jQuery(document).ready(function() { % margin->enabled)) { +if (! empty($conf->margin->enabled)) +{ + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; + if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; ?> "> global->DISPLAY_MARGIN_RATES)) - $colspan++; - if (! empty($conf->global->DISPLAY_MARK_RATES)) - $colspan++; } ?> @@ -115,18 +113,17 @@ if (! empty($conf->margin->enabled)) { -service->enabled) && $dateSelector) { -if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) - $colspan = 10; -else - $colspan = 9; -if (! empty($conf->margin->enabled)) { - $colspan++; // For the buying price - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - $colspan++; - if (! empty($conf->global->DISPLAY_MARK_RATES)) - $colspan++; -} +service->enabled) && $dateSelector) +{ + if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10; + else $colspan = 9; + if (! empty($conf->margin->enabled)) + { + $colspan++; // For the buying price + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; + if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; + } ?> > @@ -138,11 +135,15 @@ if (! empty($conf->margin->enabled)) { ?> - +
+ margin->enabled)) { +if (! empty($conf->margin->enabled)) +{ ?> - + From 4480af348c90bce718ac3f3bcef9af703afdb912 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Nov 2012 11:57:20 +0100 Subject: [PATCH 2/7] Fix: Cols at wrong place --- htdocs/core/tpl/predefinedproductline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/predefinedproductline_create.tpl.php b/htdocs/core/tpl/predefinedproductline_create.tpl.php index 4064fb3b585..6897a523b56 100644 --- a/htdocs/core/tpl/predefinedproductline_create.tpl.php +++ b/htdocs/core/tpl/predefinedproductline_create.tpl.php @@ -48,10 +48,10 @@ if (! empty($conf->margin->enabled)) if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; ?> trans('BuyingPrice'); ?> -   +  
0 if if want to stop standard actions, <0 means KO. - * For printSearchForm,printLeftBlock,printTopRightMenu,...: Return HTML string. + * For printSearchForm,printLeftBlock,printTopRightMenu,formAddObjectLine,...: Return HTML string. TODO Must always return an int and things to print into ->resprints. + * Can also return some values into an array ->results. * $this->error or this->errors are also defined by class called by this function if error. */ function executeHooks($method, $parameters=false, &$object='', &$action='') @@ -127,45 +128,58 @@ class HookManager // Loop on each hook to qualify modules that declared context $modulealreadyexecuted=array(); - $resaction=0; $resprint=''; + $resaction=0; $error=0; + $this->resPrint=''; $this->resArray=array(); foreach($this->hooks as $modules) // this->hooks is an array with context as key and value is an array of modules that handle this context { if (! empty($modules)) { foreach($modules as $module => $actionclassinstance) { - // test to avoid to run twice a hook, when a module implements several active contexts + // jump to next class if method does not exists + if (! method_exists($actionclassinstance,$method)) continue; + // test to avoid to run twice a hook, when a module implements several active contexts if (in_array($module,$modulealreadyexecuted)) continue; $modulealreadyexecuted[$module]=$module; // Hooks that return int - if (($method == 'doActions' || $method == 'formObjectOptions') && method_exists($actionclassinstance,$method)) + if (($method == 'doActions' || $method == 'formObjectOptions')) { - $resaction+=$actionclassinstance->$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($actionclassinstance->error) || (! empty($actionclassinstance->errors) && count($actionclassinstance->errors) > 0)) - { - $this->error=$actionclassinstance->error; $this->errors=array_merge($this->errors, (array) $actionclassinstance->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 - } - } + $resaction+=$actionclassinstance->$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($actionclassinstance->error) || (! empty($actionclassinstance->errors) && count($actionclassinstance->errors) > 0)) + { + $error++; + $this->error=$actionclassinstance->error; $this->errors=array_merge($this->errors, (array) $actionclassinstance->errors); + // TODO remove this. Change must be inside the method if required + if ($method == 'doActions') + { + if ($action=='add') $action='create'; + if ($action=='update') $action='edit'; + } + } } - // Generic hooks that return a string (printSearchForm, printLeftBlock, formBuilddocOptions, ...) - else if (method_exists($actionclassinstance,$method)) + // Generic hooks that return a string (printSearchForm, printLeftBlock, printTopRightMenu, formAddObjectLine, formBuilddocOptions, ...) + else { - if (is_array($parameters) && ! empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) continue; + // TODO. this should be done into the method by returning nothing + if (is_array($parameters) && ! empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) continue; + $result = $actionclassinstance->$method($parameters, $object, $action, $this); - if (is_array($result)) $this->resArray = array_merge($this->resArray, $result); - else $resprint.=$result; + + if (is_array($actionclassinstance->results)) $this->resArray =array_merge($this->resArray, $actionclassinstance->results); + if (! empty($actionclassinstance->resprints)) $this->resPrint.=$actionclassinstance->resprints; + + // TODO. remove this. array result must be set into $actionclassinstance->results + if (is_array($result)) $this->resArray = array_merge($this->resArray, $result); + // TODO. remove this. result must not be a string. we must use $actionclassinstance->resprint to return a string + if (! is_array($result) && ! is_numeric($result)) $this->resPrint.=$result; } } } } - if ($method == 'doActions' || $method == 'formObjectOptions') return $resaction; - return $resprint; + if ($method != 'doActions' && $method != 'formObjectOptions') return $this->resPrint; // TODO remove this. When there is something to print, ->resPrint is filled. + return ($error?-1:$resaction); } } From d9fb0c941bd4afe8f6cb9f01f04dd0d4a18c73e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Nov 2012 13:28:02 +0100 Subject: [PATCH 4/7] Qual: remove select to have id same with combo and ajax --- htdocs/core/class/html.form.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 2cce0fcbdfa..d2afb9a8633 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1447,7 +1447,8 @@ class Form $num = $this->db->num_rows($result); - $outselect.=''; // remove select to have id same with combo and ajax + $outselect.=''; print ''; print ''; + print ''; + $var=true; print ''; print ''; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index e4dff4117bd..648df36f946 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -1814,10 +1814,20 @@ else print ' '; print ''; + // TODO Use the predefinedproductline_create.tpl.php file print ''; print ''; print ''; print ''; + + print ''; + $var=! $var; print ''; print ''; From 3f64b533f496a664034e29c7a4c818a24ace7371 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Nov 2012 16:06:50 +0100 Subject: [PATCH 7/7] =?UTF-8?q?Fix:=20[=20bug=20#607=20]=20Nom=20de=20soci?= =?UTF-8?q?=C3=A9t=C3=A9=20avec=20guillemets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/societe/soc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index a916a7377c3..d922ea8f51d 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1121,7 +1121,7 @@ else print ''; // Name - print ''; + print ''; // Prefix if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field @@ -1130,12 +1130,12 @@ else // It does not change the prefix mode using the auto numbering prefix if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $object->prefix_comm) { - print ''; + print ''; print $object->prefix_comm; } else { - print ''; + print ''; } print ''; }
'.$langs->trans('ThirdPartyName').'
'.$langs->trans('ThirdPartyName').'