From 7ed496d7d9e64664fa502dfa8bd6072599665702 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 12 Nov 2014 17:51:26 +0100 Subject: [PATCH 1/3] FIX: copy extrafields when creating order from propale and creating invoice from order --- htdocs/commande/class/commande.class.php | 12 +++++++++++- htdocs/compta/facture/class/facture.class.php | 10 ++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7a8fd63c8f1..d1a776d3d24 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -972,7 +972,12 @@ class Commande extends CommonOrder $line->marge_tx = $marginInfos[1]; $line->marque_tx = $marginInfos[2]; - $this->lines[$i] = $line; + // get extrafields from original line + $object->lines[$i]->fetch_optionals($object->lines[$i]->rowid); + foreach($object->lines[$i]->array_options as $options_key => $value) + $line->array_options[$options_key] = $value; + + $this->lines[$i] = $line; } $this->socid = $object->socid; @@ -991,6 +996,11 @@ class Commande extends CommonOrder $this->origin = $object->element; $this->origin_id = $object->id; + // get extrafields from original line + $object->fetch_optionals($object->id); + foreach($object->array_options as $options_key => $value) + $this->array_options[$options_key] = $value; + // Possibility to add external linked objects with hooks $this->linked_objects[$this->origin] = $this->origin_id; if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects)) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 93e245746a0..0d91d7944b8 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -701,6 +701,11 @@ class Facture extends CommonInvoice $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); $line->pa_ht = $marginInfos[0]; + // get extrafields from original line + $object->lines[$i]->fetch_optionals($object->lines[$i]->rowid); + foreach($object->lines[$i]->array_options as $options_key => $value) + $line->array_options[$options_key] = $value; + $this->lines[$i] = $line; } @@ -720,6 +725,11 @@ class Facture extends CommonInvoice $this->origin = $object->element; $this->origin_id = $object->id; + // get extrafields from original line + $object->fetch_optionals($object->id); + foreach($object->array_options as $options_key => $value) + $this->array_options[$options_key] = $value; + // Possibility to add external linked objects with hooks $this->linked_objects[$this->origin] = $this->origin_id; if (! empty($object->other_linked_objects) && is_array($object->other_linked_objects)) From d0dc792b3cd829c6ef86fa555f880ed8400d3deb Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 17 Nov 2014 11:17:45 +0100 Subject: [PATCH 2/3] check extrafields before inserting in DB --- htdocs/core/class/commonobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e363eda6e4a..5af3f5a93c3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2195,7 +2195,7 @@ abstract class CommonObject { $attributeKey = substr($key,8); // Remove 'options_' prefix // Add field of attribut - if ($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate + if (isset($extrafields->attribute_type[$attributeKey]) && $extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate $sql.=",".$attributeKey; } $sql .= ") VALUES (".$this->id; @@ -2203,7 +2203,7 @@ abstract class CommonObject { $attributeKey = substr($key,8); // Remove 'options_' prefix // Add field o fattribut - if($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate) + if(isset($extrafields->attribute_type[$attributeKey]) && $extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate) { if ($this->array_options[$key] != '') { From 3dacdf4e4a5ff54dc7a57a262d95465fc4580569 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Wed, 19 Nov 2014 09:41:21 +0100 Subject: [PATCH 3/3] Fix: Conflicts and remove duplicate code --- htdocs/core/class/commonobject.class.php | 4 +--- htdocs/product/class/product.class.php | 8 +------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b5aac7adc74..72eeba4d59f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2010-2011 Juanjo Menent + * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2011-2014 Philippe Grand * Copyright (C) 2012 Marcos García @@ -611,8 +611,6 @@ abstract class CommonObject require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdparty = new Societe($this->db); $result=$thirdparty->fetch(isset($this->socid)?$this->socid:$this->fk_soc); $this->client = $thirdparty; // deprecated diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 1faa192bd0d..2987d0de8fd 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4,16 +4,10 @@ * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2007-2011 Jean Heimburger -<<<<<<< HEAD * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2013-2014 Cedric GROSS - * Copyright (C) 2013 Marcos García - * Copyright (C) 2011-2014 Alexandre Spangaro -======= - * Copyright (C) 2010-2011 Juanjo Menent - * Copyright (C) 2013 Cedric GROSS * Copyright (C) 2013-2014 Marcos García ->>>>>>> refs/remotes/origin/3.5 + * Copyright (C) 2011-2014 Alexandre Spangaro * * 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