From 530e321a3e52f5885c6cbd143f9fdb620e4a9e75 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 8 Sep 2010 16:09:59 +0000 Subject: [PATCH] Works on module hook integration --- htdocs/core/class/commonobject.class.php | 144 +----------------- ...tpl.php => freeproductline_create.tpl.php} | 4 +- htdocs/core/tpl/freeproductline_edit.tpl.php | 26 ++++ htdocs/core/tpl/freeproductline_view.tpl.php | 105 +++++++++++++ ...p => predefinedproductline_create.tpl.php} | 4 +- .../tpl/predefinedproductline_edit.tpl.php | 26 ++++ .../tpl/predefinedproductline_view.tpl.php | 106 +++++++++++++ 7 files changed, 273 insertions(+), 142 deletions(-) rename htdocs/core/tpl/{addfreeproductform.tpl.php => freeproductline_create.tpl.php} (96%) create mode 100644 htdocs/core/tpl/freeproductline_edit.tpl.php create mode 100644 htdocs/core/tpl/freeproductline_view.tpl.php rename htdocs/core/tpl/{addpredefinedproductform.tpl.php => predefinedproductline_create.tpl.php} (96%) create mode 100644 htdocs/core/tpl/predefinedproductline_edit.tpl.php create mode 100644 htdocs/core/tpl/predefinedproductline_view.tpl.php diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 768b9279689..946fb6f9f71 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1288,7 +1288,7 @@ class CommonObject global $conf,$langs; global $html,$bc,$var; - include(DOL_DOCUMENT_ROOT.'/core/tpl/addpredefinedproductform.tpl.php'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_create.tpl.php'); } /** @@ -1300,7 +1300,7 @@ class CommonObject global $conf,$langs; global $html,$bc,$var; - include(DOL_DOCUMENT_ROOT.'/core/tpl/addfreeproductform.tpl.php'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_create.tpl.php'); } /** @@ -1400,152 +1400,20 @@ class CommonObject if (! empty($line->date_end)) $type=1; // Ligne en mode visu + // TODO simplifier les templates if ($_GET['action'] != 'editline' || $_GET['lineid'] != $line->id) { - print ''; - // Produit if ($line->fk_product > 0) { $product_static = new Product($db); - - print ''; - print ''; // ancre pour retourner sur la ligne; - - // Show product and description - $product_static->type=$line->fk_product_type; - $product_static->id=$line->fk_product; - $product_static->ref=$line->ref; - $product_static->libelle=$line->product_label; - $text=$product_static->getNomUrl(1); - $text.= ' - '.$line->product_label; - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description)); - print $html->textwithtooltip($text,$description,3,'','',$i); - - // Show range - print_date_range($line->date_start, $line->date_end); - - // Add description in form - if ($conf->global->PRODUIT_DESC_IN_FORM) - { - print ($line->description && $line->description!=$line->product_label)?'
'.dol_htmlentitiesbr($line->description):''; - } - - print ''; + + include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_view.tpl.php'); } else { - print ''; - print ''; // ancre pour retourner sur la ligne - if (($line->info_bits & 2) == 2) - { - print ''; - print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount"); - print ''; - if ($line->description) - { - if ($line->description == '(CREDIT_NOTE)') - { - $discount=new DiscountAbsolute($this->db); - $discount->fetch($line->fk_remise_except); - print ' - '.$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0)); - } - else - { - print ' - '.nl2br($line->description); - } - } - } - else - { - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - print $text.' '.nl2br($line->description); - // Show range - print_date_range($line->date_start,$line->date_end); - } - print "\n"; + include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_view.tpl.php'); } - - // VAT Rate - print ''.vatrate($line->tva_tx,'%',$line->info_bits).''; - - // U.P HT - print ''.price($line->subprice)."\n"; - - // Qty - print ''; - if ((($line->info_bits & 2) != 2) && $line->special_code != 3) - { - print $line->qty; - } - else print ' '; - print ''; - - // Remise percent (negative or positive) - if (!empty($line->remise_percent) && $line->special_code != 3) - { - print ''.dol_print_reduction($line->remise_percent,$langs)."\n"; - } - else - { - print ' '; - } - - // Montant total HT - if ($line->special_code == 3) - { - // Si ligne en option - print ''.$langs->trans('Option').''; - } - else - { - print ''.price($line->total_ht)."\n"; - } - - // Icone d'edition et suppression - if ($this->statut == 0 && $user->rights->$element->creer) - { - print ''; - if (($line->info_bits & 2) == 2) - { - // Ligne remise predefinie, on permet pas modif - } - else - { - print 'id.'#'.$line->id.'">'; - print img_edit(); - print ''; - } - print ''; - print ''; - print 'id.'">'; - print img_delete(); - print ''; - if ($num > 1) - { - print ''; - if ($i > 0) - { - print 'id.'">'; - print img_up(); - print ''; - } - if ($i < $num-1) - { - print 'id.'">'; - print img_down(); - print ''; - } - print ''; - } - } - else - { - print ' '; - } - - print ''; } // Ligne en mode update diff --git a/htdocs/core/tpl/addfreeproductform.tpl.php b/htdocs/core/tpl/freeproductline_create.tpl.php similarity index 96% rename from htdocs/core/tpl/addfreeproductform.tpl.php rename to htdocs/core/tpl/freeproductline_create.tpl.php index c4475aa3b35..a77ab4dd20f 100644 --- a/htdocs/core/tpl/addfreeproductform.tpl.php +++ b/htdocs/core/tpl/freeproductline_create.tpl.php @@ -19,7 +19,7 @@ */ ?> - + global->PRODUIT_USE_MARKUP) $colspan = 'colspan="2"'; - + diff --git a/htdocs/core/tpl/freeproductline_edit.tpl.php b/htdocs/core/tpl/freeproductline_edit.tpl.php new file mode 100644 index 00000000000..62c9fe7ed01 --- /dev/null +++ b/htdocs/core/tpl/freeproductline_edit.tpl.php @@ -0,0 +1,26 @@ + + * + * 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$ + */ +?> + + + + + + diff --git a/htdocs/core/tpl/freeproductline_view.tpl.php b/htdocs/core/tpl/freeproductline_view.tpl.php new file mode 100644 index 00000000000..48a606526ad --- /dev/null +++ b/htdocs/core/tpl/freeproductline_view.tpl.php @@ -0,0 +1,105 @@ + + * + * 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$ + */ +?> + + + +> + + info_bits & 2) == 2) { ?> + + trans("ShowReduc"),'reduc').' '.$langs->trans("Discount"); ?> + + description) { + if ($line->description == '(CREDIT_NOTE)') { + $discount=new DiscountAbsolute($this->db); + $discount->fetch($line->fk_remise_except); + echo ' - '.$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0)); + } else { + echo ' - '.nl2br($line->description); + } + } + } else { + if ($type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + echo $text.' '.nl2br($line->description); + // Show range + print_date_range($line->date_start,$line->date_end); + } ?> + + + tva_tx,'%',$line->info_bits); ?> + + subprice); ?> + + + info_bits & 2) != 2) && $line->special_code != 3) echo $line->qty; + else echo ' '; ?> + + + remise_percent) && $line->special_code != 3) { ?> + remise_percent,$langs); ?> + +   + + + special_code == 3) { ?> + trans('Option'); ?> + + total_ht); ?> + + + statut == 0 && $user->rights->$element->creer) { ?> + + info_bits & 2) == 2) { ?> + + id.'#'.$line->id; ?>"> + + + + + + + id; ?>"> + + + + + 1) { ?> + + 0) { ?> + id; ?>"> + + + + + id; ?>"> + + + + + + +   + + + + + diff --git a/htdocs/core/tpl/addpredefinedproductform.tpl.php b/htdocs/core/tpl/predefinedproductline_create.tpl.php similarity index 96% rename from htdocs/core/tpl/addpredefinedproductform.tpl.php rename to htdocs/core/tpl/predefinedproductline_create.tpl.php index c28a87664aa..c3ea739fd50 100644 --- a/htdocs/core/tpl/addpredefinedproductform.tpl.php +++ b/htdocs/core/tpl/predefinedproductline_create.tpl.php @@ -19,7 +19,7 @@ */ ?> - + global->PRODUIT_USE_MARKUP) @@ -88,4 +88,4 @@ $colspan = 'colspan="3"'; - + diff --git a/htdocs/core/tpl/predefinedproductline_edit.tpl.php b/htdocs/core/tpl/predefinedproductline_edit.tpl.php new file mode 100644 index 00000000000..a26145ef494 --- /dev/null +++ b/htdocs/core/tpl/predefinedproductline_edit.tpl.php @@ -0,0 +1,26 @@ + + * + * 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$ + */ +?> + + + + + + diff --git a/htdocs/core/tpl/predefinedproductline_view.tpl.php b/htdocs/core/tpl/predefinedproductline_view.tpl.php new file mode 100644 index 00000000000..bb085dad6eb --- /dev/null +++ b/htdocs/core/tpl/predefinedproductline_view.tpl.php @@ -0,0 +1,106 @@ + + * + * 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$ + */ +?> + + + +> + + + type=$line->fk_product_type; + $product_static->id=$line->fk_product; + $product_static->ref=$line->ref; + $product_static->libelle=$line->product_label; + $text=$product_static->getNomUrl(1); + $text.= ' - '.$line->product_label; + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description)); + echo $html->textwithtooltip($text,$description,3,'','',$i); + + // Show range + print_date_range($line->date_start, $line->date_end); + + // Add description in form + if ($conf->global->PRODUIT_DESC_IN_FORM) + { + print ($line->description && $line->description!=$line->product_label)?'
'.dol_htmlentitiesbr($line->description):''; + } + ?> + + + tva_tx,'%',$line->info_bits); ?> + + subprice); ?> + + + info_bits & 2) != 2) && $line->special_code != 3) echo $line->qty; + else echo ' '; ?> + + + remise_percent) && $line->special_code != 3) { ?> + remise_percent,$langs); ?> + +   + + + special_code == 3) { ?> + trans('Option'); ?> + + total_ht); ?> + + + statut == 0 && $user->rights->$element->creer) { ?> + + info_bits & 2) == 2) { ?> + + id.'#'.$line->id; ?>"> + + + + + + + id; ?>"> + + + + + 1) { ?> + + 0) { ?> + id; ?>"> + + + + + id; ?>"> + + + + + + +   + + + + +