From 9f0bde74b68dd9628c234afd4846f40003f47245 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 5 Aug 2010 09:45:59 +0000 Subject: [PATCH] Works on templates implementation for mutualized code --- htdocs/comm/propal.php | 4 +- htdocs/commande/fiche.php | 138 +----------------- htdocs/core/class/commonobject.class.php | 4 +- htdocs/core/tpl/addfreeproductform.tpl.php | 17 ++- .../core/tpl/addpredefinedproductform.tpl.php | 17 ++- 5 files changed, 39 insertions(+), 141 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 60c3cc4882b..e2613e235ae 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1447,13 +1447,13 @@ if ($id > 0 || ! empty($ref)) { $var=true; - $propal->showAddFreeProductForm($propal); + $propal->showAddFreeProductForm(); // Add predefined products/services if ($conf->product->enabled || $conf->service->enabled) { $var=!$var; - $propal->showAddPredefinedProductForm($propal); + $propal->showAddPredefinedProductForm(); } // Add hook of other modules diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index f8f09e42dee..9f6d13a1c42 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1936,143 +1936,15 @@ else */ if ($commande->statut == 0 && $user->rights->commande->creer && $_GET["action"] <> 'editline') { - 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 ''; - - // Add free products/services form - print '
'; - print ''; - print ''; - print ''; - $var=true; - print ''; - 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($soc->tva_assuj == "0") - print '0'; - else - print $html->select_tva('tva_tx',$conf->defaulttx,$mysoc,$soc); - print ''; - print ''; - print ''; - print '%'; - print ''; - print ''; - - if ($conf->service->enabled) - { - // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) - // Start and end dates selector - print ''; - print ''.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - print $html->select_date('','date_start',$usehm,$usehm,1,"addline"); - print ' '.$langs->trans('to').' '; - print $html->select_date('','date_end',$usehm,$usehm,1,"addline"); - print ''; - print ''; - } - print '
'; - - // Ajout de produits/services predefinis + + $commande->showAddFreeProductForm(1); + + // Add predefined products/services if ($conf->product->enabled || $conf->service->enabled) { - 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 '
'; - print ''; - print ''; - print ''; - $var=!$var; - print ''; - print ''; - // multiprix - if($conf->global->PRODUIT_MULTIPRICES) - { - $html->select_produits('','idprod','',$conf->product->limit_size,$soc->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 ''; - - if ($conf->service->enabled) - { - // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) - // Start and end dates selector - print ''; - print ''.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - print $html->select_date('','date_start_prod',$usehm,$usehm,1,"addline"); - print ' '.$langs->trans('to').' '; - print $html->select_date('','date_end_prod',$usehm,$usehm,1,"addline"); - print ''; - print ''; - } - print '
'; + $commande->showAddPredefinedProductForm(1); } } print ''; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 16186ebc1c4..5540a6c4909 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1153,7 +1153,7 @@ class CommonObject /** * Show add free products/services form */ - function showAddFreeProductForm($object) + function showAddFreeProductForm($dateSelector=0) { global $conf,$langs; global $html,$bc,$var; @@ -1164,7 +1164,7 @@ class CommonObject /** * Show add predefined products/services form */ - function showAddPredefinedProductForm($object) + function showAddPredefinedProductForm($dateSelector=0) { global $conf,$langs; global $html,$bc,$var; diff --git a/htdocs/core/tpl/addfreeproductform.tpl.php b/htdocs/core/tpl/addfreeproductform.tpl.php index c5d3c4d189a..34f57ecb034 100644 --- a/htdocs/core/tpl/addfreeproductform.tpl.php +++ b/htdocs/core/tpl/addfreeproductform.tpl.php @@ -35,10 +35,10 @@ if ($conf->global->PRODUIT_USE_MARKUP) $colspan = 'colspan="2"';   -
"> - + > > @@ -76,6 +76,19 @@ if ($conf->global->PRODUIT_USE_MARKUP) $colspan = 'colspan="2"'; +service->enabled && $dateSelector) {?> +> + + trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; + echo $html->select_date('','date_start',$usehm,$usehm,1,"addline"); + echo ' '.$langs->trans('to').' '; + echo $html->select_date('','date_end',$usehm,$usehm,1,"addline"); + ?> + + + +
diff --git a/htdocs/core/tpl/addpredefinedproductform.tpl.php b/htdocs/core/tpl/addpredefinedproductform.tpl.php index d69feb9c4da..13d2c39bb16 100644 --- a/htdocs/core/tpl/addpredefinedproductform.tpl.php +++ b/htdocs/core/tpl/addpredefinedproductform.tpl.php @@ -43,10 +43,10 @@ $colspan = 'colspan="3"';   -
"> - + > > @@ -80,6 +80,19 @@ $colspan = 'colspan="3"'; " name="addline"> +service->enabled && $dateSelector) {?> +> + + trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; + echo $html->select_date('','date_start',$usehm,$usehm,1,"addline"); + echo ' '.$langs->trans('to').' '; + echo $html->select_date('','date_end',$usehm,$usehm,1,"addline"); + ?> + + + +