From dfdc9da781fda557038b4293dda79ca10b816732 Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Tue, 3 Sep 2013 11:15:19 +0200 Subject: [PATCH 1/5] Add an additional description for the category products --- htdocs/core/lib/pdf.lib.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index a4b091347d0..621b06965e1 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1031,7 +1031,23 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl $libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice; } } - + + // Add an additional description for the category products + if ($conf->categorie->enabled) + { + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $categstatic=new Categorie($db); + // recovering the list of all the categories linked to product + $tblcateg=$categstatic->containing($idprod,0); + foreach ($tblcateg as $cate) + { + // Adding the descriptions if they are filled + $desccateg=$cate->add_description; + if ($desccateg) + $libelleproduitservice.='__N__'.$desccateg; + } + } + if (! empty($object->lines[$i]->date_start) || ! empty($object->lines[$i]->date_end)) { $format='day'; From 6d6f30725bf190a40bb20de6b565f38a5ef2b60f Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Tue, 3 Sep 2013 11:41:33 +0200 Subject: [PATCH 2/5] Add an additional description for the category products --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 621b06965e1..6be4eaf2a61 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1033,7 +1033,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl } // Add an additional description for the category products - if ($conf->categorie->enabled) + if (! empty($conf->categorie->enabled)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $categstatic=new Categorie($db); From 397d0e3b8197113400ef3f240aeb3e78b1e6af0c Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Tue, 3 Sep 2013 15:12:15 +0200 Subject: [PATCH 3/5] Add an additional description for the category products --- htdocs/categories/class/categorie.class.php | 37 +++++++++++++-------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index fddbefa8d5f..09d8f373543 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2006-2012 Regis Houssin * Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin - * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2013 Philippe Grand * * 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 @@ -44,6 +44,7 @@ class Categorie var $fk_parent; var $label; var $description; + var $add_description; // For taxes like DEEE... var $socid; var $type; // 0=Product, 1=Supplier, 2=Customer/Prospect, 3=Member var $import_key; @@ -73,7 +74,7 @@ class Categorie { global $conf; - $sql = "SELECT rowid, fk_parent, entity, label, description, fk_soc, visible, type"; + $sql = "SELECT rowid, fk_parent, entity, label, description, add_description, fk_soc, visible, type"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; if ($id) { @@ -93,14 +94,15 @@ class Categorie { $res = $this->db->fetch_array($resql); - $this->id = $res['rowid']; - $this->fk_parent = $res['fk_parent']; - $this->label = $res['label']; - $this->description = $res['description']; - $this->socid = $res['fk_soc']; - $this->visible = $res['visible']; - $this->type = $res['type']; - $this->entity = $res['entity']; + $this->id = $res['rowid']; + $this->fk_parent = $res['fk_parent']; + $this->label = $res['label']; + $this->description = $res['description']; + $this->add_description = $res['add_description']; + $this->socid = $res['fk_soc']; + $this->visible = $res['visible']; + $this->type = $res['type']; + $this->entity = $res['entity']; $this->db->free($resql); @@ -156,6 +158,7 @@ class Categorie $sql.= "fk_parent,"; $sql.= " label,"; $sql.= " description,"; + $sql.= " add_description,"; if (! empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) { $sql.= "fk_soc,"; @@ -168,6 +171,7 @@ class Categorie $sql.= $this->fk_parent.","; $sql.= "'".$this->db->escape($this->label)."',"; $sql.= "'".$this->db->escape($this->description)."',"; + $sql.= "'".$this->db->escape($this->add_description)."',"; if (! empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) { $sql.= ($this->socid != -1 ? $this->socid : 'null').","; @@ -244,7 +248,14 @@ class Categorie $sql = "UPDATE ".MAIN_DB_PREFIX."categorie"; $sql.= " SET label = '".$this->db->escape($this->label)."',"; - $sql.= " description = '".$this->db->escape($this->description)."'"; + if (! empty($this->description)) + { + $sql .= ", description = '".$this->db->escape($this->description)."'"; + } + if (! empty($this->add_description)) + { + $sql .= ", add_description = '".$this->db->escape($this->add_description)."'"; + } if (! empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) { $sql .= ", fk_soc = ".($this->socid != -1 ? $this->socid : 'null'); @@ -611,8 +622,8 @@ class Categorie $sql = "SELECT fk_parent as id_parent, rowid as id_son"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; $sql.= " WHERE fk_parent != 0"; - $sql.= " AND entity IN (".getEntity('category',1).")"; - + $sql.= " AND entity = ".$conf->entity; + dol_syslog(get_class($this)."::load_motherof sql=".$sql); $resql = $this->db->query($sql); if ($resql) From 9f01aa51a3a6498475359c19e60187b9791a1945 Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Tue, 3 Sep 2013 15:19:03 +0200 Subject: [PATCH 4/5] fix regression --- htdocs/categories/class/categorie.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 09d8f373543..b4fa020e2b3 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2006-2012 Regis Houssin * Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin + * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2013 Philippe Grand * * This program is free software; you can redistribute it and/or modify @@ -622,7 +623,7 @@ class Categorie $sql = "SELECT fk_parent as id_parent, rowid as id_son"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; $sql.= " WHERE fk_parent != 0"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " AND entity IN (".getEntity('category',1).")"; dol_syslog(get_class($this)."::load_motherof sql=".$sql); $resql = $this->db->query($sql); From 222eb18bb9450bfd2d3c5388a37602e5dfded803 Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Tue, 3 Sep 2013 17:37:22 +0200 Subject: [PATCH 5/5] fix : Fatal error: Call to undefined function dol_time_plus_duree() --- htdocs/product/index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/product/index.php b/htdocs/product/index.php index f9eb16e23de..6104702f6cd 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -25,6 +25,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $type=isset($_GET["type"])?$_GET["type"]:(isset($_POST["type"])?$_POST["type"]:''); if ($type =='' && !$user->rights->produit->lire) $type='1'; // Force global page on service page only