Browse Source

Merge remote-tracking branch 'origin/3.6' into 3.7

Conflicts:
	htdocs/comm/propal/class/propal.class.php
	htdocs/commande/class/commande.class.php
	htdocs/compta/facture/class/facture.class.php
Laurent Destailleur 10 years ago
parent
commit
c73fe965d2

+ 3 - 0
ChangeLog

@@ -466,6 +466,9 @@ Fix: [ bug #2570 ] [Contacts] Page should not process if ID is invalid
 Fix: [ bug #3268 ] SQL error when accessing thirdparty log page without a socid parameter
 Fix: [ bug #3180 ] formObjectOptions hook when editing thirdparty card does not print result
 Fix: [ bug #1791 ] Margin menu not available if any Finance module is not enabled
+Fix: [ bug #3310 ] OrderLine::fetch, FactureLigne::fetch and PropaleLigne::fetch do not return anything
+Fix: [ bug #3206 ] PropaleLigne, OrderLine and FactureLigne given to triggers through update function does not contain all the information
+Fix: [ bug #3313 ] Error enabling module with PostgreSQL database
 
 ***** ChangeLog for 3.5.6 compared to 3.5.5 *****
 Fix: Avoid missing class error for fetch_thirdparty method #1973

+ 15 - 13
htdocs/comm/propal/class/propal.class.php

@@ -547,15 +547,15 @@ class Propal extends CommonObject
                 $price = $pu - $remise;
             }
 
-            // Update line
-            $this->line=new PropaleLigne($this->db);
+            //Fetch current line from the database and then clone the object and set it in $oldline property
+            $line = new PropaleLigne($this->db);
+            $line->fetch($rowid);
 
-            $this->line->context = $this->context;
+            $staticline = clone $line;
 
-            // Stock previous line records
-            $staticline=new PropaleLigne($this->db);
-            $staticline->fetch($rowid);
-            $this->line->oldline = $staticline;
+            $line->oldline = $staticline;
+            $this->line = $line;
+            $this->line->context = $this->context;
 
             // Reorder if fk_parent_line change
             if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line)
@@ -960,9 +960,9 @@ class Propal extends CommonObject
     function createFromClone($socid=0)
     {
         global $db, $user,$langs,$conf,$hookmanager;
-		
+
 		dol_include_once('/projet/class.project.class.php');
-				
+
         $this->context['createfromclone']='createfromclone';
 
         $error=0;
@@ -987,16 +987,16 @@ class Propal extends CommonObject
                 $this->socid 				= $objsoc->id;
                 $this->cond_reglement_id	= (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
                 $this->mode_reglement_id	= (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
-				
+
 				$project = new Project($db);
-				
+
 				if($objFrom->fk_project > 0 && $project->fetch($objFrom->fk_project)) {
 					if($project->socid <= 0) $this->fk_project = $objFrom->fk_project;
 					else $this->fk_project = '';
 				} else {
 					$this->fk_project = '';
 				}
-                
+
                 $this->fk_delivery_address	= '';
             }
 
@@ -2906,10 +2906,12 @@ class PropaleLigne  extends CommonObject
             $this->date_end         = $this->db->jdate($objp->date_end);
 
 			$this->db->free($result);
+
+            return 1;
 		}
 		else
 		{
-			dol_print_error($this->db);
+			return -1;
 		}
 	}
 

+ 12 - 10
htdocs/commande/class/commande.class.php

@@ -1048,10 +1048,10 @@ class Commande extends CommonOrder
 
             // get extrafields from original line
 			$object->fetch_optionals($object->id);
-			
+
 			$e = new ExtraFields($db);
 			$element_extrafields = $e->fetch_name_optionals_label($this->element);
-			
+
 			foreach($object->array_options as $options_key => $value) {
 				if(array_key_exists(str_replace('options_', '', $options_key), $element_extrafields)){
 					$this->array_options[$options_key] = $value;
@@ -2421,15 +2421,15 @@ class Commande extends CommonOrder
                 $price = ($pu - $remise);
             }
 
-            // Update line
-            $this->line=new OrderLine($this->db);
+            //Fetch current line from the database and then clone the object and set it in $oldline property
+            $line = new OrderLine($this->db);
+            $line->fetch($rowid);
 
-            $this->line->context = $this->context;
+            $staticline = clone $line;
 
-            // Stock previous line records
-            $staticline=new OrderLine($this->db);
-            $staticline->fetch($rowid);
-            $this->line->oldline = $staticline;
+            $line->oldline = $staticline;
+            $this->line = $line;
+            $this->line->context = $this->context;
 
             // Reorder if fk_parent_line change
             if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line)
@@ -3356,10 +3356,12 @@ class OrderLine extends CommonOrderLine
             $this->date_end         = $this->db->jdate($objp->date_end);
 
             $this->db->free($result);
+
+            return 1;
         }
         else
         {
-            dol_print_error($this->db);
+            return -1;
         }
     }
 

+ 0 - 1
htdocs/compta/bank/class/account.class.php

@@ -1136,7 +1136,6 @@ class AccountLine extends CommonObject
         }
         else
         {
-            dol_print_error($this->db);
             return -1;
         }
     }

+ 20 - 8
htdocs/compta/facture/class/facture.class.php

@@ -2185,15 +2185,25 @@ class Facture extends CommonInvoice
 			$pu_tva = $tabprice[4];
 			$pu_ttc = $tabprice[5];
 
-			// Update line into database
-			$this->line=new FactureLigne($this->db);
+			// Old properties: $price, $remise (deprecated)
+			$price = $pu;
+			$remise = 0;
+			if ($remise_percent > 0)
+			{
+				$remise = round(($pu * $remise_percent / 100),2);
+				$price = ($pu - $remise);
+			}
+			$price    = price2num($price);
 
-            $this->line->context = $this->context;
+			//Fetch current line from the database and then clone the object and set it in $oldline property
+			$line = new FactureLigne($this->db);
+			$line->fetch($rowid);
 
-            // Stock previous line records
-			$staticline=new FactureLigne($this->db);
-			$staticline->fetch($rowid);
-			$this->line->oldline = $staticline;
+			$staticline = clone $line;
+
+			$line->oldline = $staticline;
+			$this->line = $line;
+            $this->line->context = $this->context;
 
 			// Reorder if fk_parent_line change
 			if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line)
@@ -3496,10 +3506,12 @@ class FactureLigne extends CommonInvoiceLine
 			$this->product_desc			= $objp->product_desc;
 
 			$this->db->free($result);
+
+			return 1;
 		}
 		else
 		{
-			dol_print_error($this->db);
+			return -1;
 		}
 	}
 

+ 0 - 3
htdocs/core/modules/DolibarrModules.class.php

@@ -1160,7 +1160,6 @@ abstract class DolibarrModules
 
         $this->db->begin();
 
-        //var_dump($this->menu); exit;
         foreach ($this->menu as $key => $value)
         {
             $menu = new Menubase($this->db);
@@ -1169,11 +1168,9 @@ abstract class DolibarrModules
             if (! $this->menu[$key]['fk_menu'])
             {
                 $menu->fk_menu=0;
-                //print 'aaa'.$this->menu[$key]['fk_menu'];
             }
             else
             {
-                //print 'xxx'.$this->menu[$key]['fk_menu'];exit;
                 $foundparent=0;
                 $fk_parent=$this->menu[$key]['fk_menu'];
                 if (preg_match('/^r=/',$fk_parent))	// old deprecated method

+ 2 - 0
htdocs/expedition/class/expedition.class.php

@@ -1140,6 +1140,8 @@ class Expedition extends CommonObject
 				$line->details_entrepot[]     = $detail_entrepot;
 
                 $line->line_id          = $obj->line_id;
+                $line->rowid            = $obj->line_id;    // TODO deprecated
+                $line->id               = $obj->line_id;
 				$line->fk_origin_line 	= $obj->fk_origin_line;
 				$line->origin_line_id 	= $obj->fk_origin_line;	    // TODO deprecated
 				$line->fk_product     	= $obj->fk_product;