From 398969f6bf4b715a4d3f3552a2598f81471cdba5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 5 Aug 2010 09:12:07 +0000 Subject: [PATCH] Works on templates implementation for mutualized code --- htdocs/comm/propal.php | 135 ++---------------- htdocs/core/class/commonobject.class.php | 29 +++- htdocs/core/tpl/addfreeproductform.tpl.php | 81 +++++++++++ .../core/tpl/addpredefinedproductform.tpl.php | 85 +++++++++++ htdocs/lib/propal.lib.php | 3 +- 5 files changed, 205 insertions(+), 128 deletions(-) create mode 100644 htdocs/core/tpl/addfreeproductform.tpl.php create mode 100644 htdocs/core/tpl/addpredefinedproductform.tpl.php diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index a373479fc51..60c3cc4882b 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1447,135 +1447,20 @@ if ($id > 0 || ! empty($ref)) { $var=true; - if ($conf->milestone->enabled) - { - formAddMilestone($propal); + $propal->showAddFreeProductForm($propal); - $var=!$var; - } - - if ($conf->global->PRODUIT_USE_MARKUP) $colspan = 'colspan="2"'; - print ''; - print ''; - print ''; // ancre - print $langs->trans('AddNewLine').' - '.$langs->trans("FreeZone").''; - print ''.$langs->trans('VAT').''; - print ''.$langs->trans('PriceUHT').''; - print ''.$langs->trans('Qty').''; - print ''.$langs->trans('ReductionShort').''; - print ' '; - print "\n"; - - // Add free products/services form - print "\n".'
'; - print ''; - print ''; - print ''; - - print '\n"; - print ''; - - print $html->select_type_of_lines(isset($_POST["type"])?$_POST["type"]:-1,'type',1); - if ($conf->product->enabled && $conf->service->enabled) print '
'; - - // Editor wysiwyg - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('dp_desc',$_POST["dp_desc"],100,'dolibarr_details'); - $doleditor->Create(); - } - else - { - $nbrows=ROWS_2; - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - print ''; - } - print ''; - - print ''; - if ($societe->tva_assuj == "0") - print '0'; - else - $html->select_tva('np_tva_tx', $conf->defaulttx, $mysoc, $societe); - print "\n"; - print ''; - print ''; - print '%'; - print ''; - print ''; - - print '
'."\n"; - - // Ajout de produits/services predefinis + // Add predefined products/services if ($conf->product->enabled || $conf->service->enabled) { - if ($conf->global->PRODUIT_USE_MARKUP) - { - $colspan = 'colspan="4"'; - } - else - { - $colspan = 'colspan="3"'; - } - print ''; - print ''; - print $langs->trans("AddNewLine").' - '; - if ($conf->service->enabled) - { - print $langs->trans('RecordedProductsAndServices'); - } - else - { - print $langs->trans('RecordedProducts'); - } - print ''; - print ''.$langs->trans('Qty').''; - print ''.$langs->trans('ReductionShort').''; - print ' '; - print ''; - print "\n".'
'; - print ''; - print ''; - print ''; - $var=!$var; - - print ''; - print ''; - // multiprix - if($conf->global->PRODUIT_MULTIPRICES) - { - $html->select_produits('','idprod','',$conf->product->limit_size,$societe->price_level); - } - else - { - $html->select_produits('','idprod','',$conf->product->limit_size); - } - if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '
'; - - // Editor wysiwyg - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('np_desc',$_POST["np_desc"],100,'dolibarr_details'); - $doleditor->Create(); - } - else - { - $nbrows=ROWS_2; - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - print ''; - } - - print ''; - print ''; - print '%'; - - print ''; - print ''."\n"; - - print '
'; + $propal->showAddPredefinedProductForm($propal); + } + + // Add hook of other modules + if ($conf->milestone->enabled) + { + $var=!$var; + formAddMilestone($propal); } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d659a9883fc..16186ebc1c4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2010 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2010 Juanjo Menent * @@ -1149,9 +1149,34 @@ class CommonObject print $sql; } } + + /** + * Show add free products/services form + */ + function showAddFreeProductForm($object) + { + global $conf,$langs; + global $html,$bc,$var; + + include(DOL_DOCUMENT_ROOT.'/core/tpl/addfreeproductform.tpl.php'); + } + + /** + * Show add predefined products/services form + */ + function showAddPredefinedProductForm($object) + { + global $conf,$langs; + global $html,$bc,$var; + + include(DOL_DOCUMENT_ROOT.'/core/tpl/addpredefinedproductform.tpl.php'); + } /** - * + * Show linked object block + * @param $object + * @param $objectid + * @param $somethingshown */ function showLinkedObjectBlock($object,$objectid,$somethingshown=0) { diff --git a/htdocs/core/tpl/addfreeproductform.tpl.php b/htdocs/core/tpl/addfreeproductform.tpl.php new file mode 100644 index 00000000000..c5d3c4d189a --- /dev/null +++ b/htdocs/core/tpl/addfreeproductform.tpl.php @@ -0,0 +1,81 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ +?> + + + +global->PRODUIT_USE_MARKUP) $colspan = 'colspan="2"'; +?> + + + >trans('AddNewLine').' - '.$langs->trans("FreeZone"); ?> + trans('VAT'); ?> + trans('PriceUHT'); ?> + trans('Qty'); ?> + trans('ReductionShort'); ?> +   + + +
"> + + + +> + > + select_type_of_lines(isset($_POST["type"])?$_POST["type"]:-1,'type',1); + if ($conf->product->enabled && $conf->service->enabled) echo '
'; + + // Editor wysiwyg + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('dp_desc',$_POST["dp_desc"],100,'dolibarr_details'); + $doleditor->Create(); + } + else + { + $nbrows=ROWS_2; + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; + echo ''; + } + ?> + + + + tva_assuj == "0") + echo '0'; + else + $html->select_tva('np_tva_tx', $conf->defaulttx, $mysoc, $societe); + ?> + + + "> + % + + + +
+ + diff --git a/htdocs/core/tpl/addpredefinedproductform.tpl.php b/htdocs/core/tpl/addpredefinedproductform.tpl.php new file mode 100644 index 00000000000..d69feb9c4da --- /dev/null +++ b/htdocs/core/tpl/addpredefinedproductform.tpl.php @@ -0,0 +1,85 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ +?> + + + +global->PRODUIT_USE_MARKUP) +$colspan = 'colspan="4"'; +else +$colspan = 'colspan="3"'; +?> + + + > + trans("AddNewLine").' - '; + if ($conf->service->enabled) + echo $langs->trans('RecordedProductsAndServices'); + else + echo $langs->trans('RecordedProducts'); + ?> + + trans('Qty'); ?> + trans('ReductionShort'); ?> +   + + +
"> + + + +> + > + global->PRODUIT_MULTIPRICES) + $html->select_produits('','idprod','',$conf->product->limit_size,$societe->price_level); + else + $html->select_produits('','idprod','',$conf->product->limit_size); + + if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '
'; + + // Editor wysiwyg + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('np_desc',$_POST["np_desc"],100,'dolibarr_details'); + $doleditor->Create(); + } + else + { + $nbrows=ROWS_2; + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; + echo ''; + } + ?> + + + % + + " name="addline"> + + +
+ + diff --git a/htdocs/lib/propal.lib.php b/htdocs/lib/propal.lib.php index c85d7a6307c..4e6646104b5 100644 --- a/htdocs/lib/propal.lib.php +++ b/htdocs/lib/propal.lib.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2006-2010 Laurent Destailleur + * Copyright (C) 2005-2010 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by