| 
                                                        @@ -87,7 +87,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    87
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    87
                                                                                                                                                                                                 | 
                                                             		'contratdet' => array('name' => 'Contract', 'parent' => 'contrat', 'parentkey' => 'fk_contrat'), | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    88
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    88
                                                                                                                                                                                                 | 
                                                             		'facture_fourn_det' => array('name' => 'SupplierInvoice', 'parent' => 'facture_fourn', 'parentkey' => 'fk_facture_fourn'), | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    89
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    89
                                                                                                                                                                                                 | 
                                                             		'commande_fournisseurdet' => array('name' => 'SupplierOrder', 'parent' => 'commande_fournisseur', 'parentkey' => 'fk_commande'), | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    90
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -		'mrp_production' => array('name' => 'Mo', 'parent' => 'mrp_mo', 'parentkey' => 'fk_mo' ), | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    90
                                                                                                                                                                                                 | 
                                                            +		'mrp_production' => array('name' => 'Mo', 'parent' => 'mrp_mo', 'parentkey' => 'fk_mo'), | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    91
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    91
                                                                                                                                                                                                 | 
                                                             		'bom_bom' => array('name' => 'BOM'), | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    92
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    92
                                                                                                                                                                                                 | 
                                                             		'bom_bomline' => array('name' => 'BOMLine', 'parent' => 'bom_bom', 'parentkey' => 'fk_bom'), | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    93
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    93
                                                                                                                                                                                                 | 
                                                             	);  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -155,7 +155,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    155
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    155
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    156
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    156
                                                                                                                                                                                                 | 
                                                             	 * @var string  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    157
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    157
                                                                                                                                                                                                 | 
                                                             	 */  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    158
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -	public $price_formated;			// used by takepos/ajax/ajax.php  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    158
                                                                                                                                                                                                 | 
                                                            +	public $price_formated; // used by takepos/ajax/ajax.php  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    159
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    159
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    160
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    160
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    161
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    161
                                                                                                                                                                                                 | 
                                                             	 * Selling price with tax  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -167,7 +167,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    167
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    167
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    168
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    168
                                                                                                                                                                                                 | 
                                                             	 * @var string  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    169
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    169
                                                                                                                                                                                                 | 
                                                             	 */  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    170
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -	public $price_ttc_formated;		// used by takepos/ajax/ajax.php  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    170
                                                                                                                                                                                                 | 
                                                            +	public $price_ttc_formated; // used by takepos/ajax/ajax.php  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    171
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    171
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    172
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    172
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    173
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    173
                                                                                                                                                                                                 | 
                                                             	 * Minimum price net  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -519,7 +519,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    519
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    519
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    520
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    520
                                                                                                                                                                                                 | 
                                                             	 * @var int|string  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    521
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    521
                                                                                                                                                                                                 | 
                                                             	 */  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    522
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -	public $weight_units;	// scale -3, 0, 3, 6  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    522
                                                                                                                                                                                                 | 
                                                            +	public $weight_units; // scale -3, 0, 3, 6  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    523
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    523
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    524
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    524
                                                                                                                                                                                                 | 
                                                             	 * @var float|string  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    525
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    525
                                                                                                                                                                                                 | 
                                                             	 */  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -527,7 +527,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    527
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    527
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    528
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    528
                                                                                                                                                                                                 | 
                                                             	 * @var int|string  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    529
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    529
                                                                                                                                                                                                 | 
                                                             	 */  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    530
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -	public $length_units;	// scale -3, 0, 3, 6  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    530
                                                                                                                                                                                                 | 
                                                            +	public $length_units; // scale -3, 0, 3, 6  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    531
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    531
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    532
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    532
                                                                                                                                                                                                 | 
                                                             	 * @var float|string  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    533
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    533
                                                                                                                                                                                                 | 
                                                             	 */  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -535,7 +535,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    535
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    535
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    536
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    536
                                                                                                                                                                                                 | 
                                                             	 * @var int|string  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    537
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    537
                                                                                                                                                                                                 | 
                                                             	 */  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    538
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -	public $width_units;	// scale -3, 0, 3, 6  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    538
                                                                                                                                                                                                 | 
                                                            +	public $width_units; // scale -3, 0, 3, 6  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    539
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    539
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    540
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    540
                                                                                                                                                                                                 | 
                                                             	 * @var float|string|null  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    541
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    541
                                                                                                                                                                                                 | 
                                                             	 */  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -543,7 +543,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    543
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    543
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    544
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    544
                                                                                                                                                                                                 | 
                                                             	 * @var int|string|null  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    545
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    545
                                                                                                                                                                                                 | 
                                                             	 */  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    546
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -	public $height_units;	// scale -3, 0, 3, 6  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    546
                                                                                                                                                                                                 | 
                                                            +	public $height_units; // scale -3, 0, 3, 6  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    547
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    547
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    548
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    548
                                                                                                                                                                                                 | 
                                                             	 * @var float|string|null  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    549
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    549
                                                                                                                                                                                                 | 
                                                             	 */  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -551,7 +551,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    551
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    551
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    552
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    552
                                                                                                                                                                                                 | 
                                                             	 * @var int|string|null  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    553
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    553
                                                                                                                                                                                                 | 
                                                             	 */  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    554
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -	public $surface_units;	// scale -3, 0, 3, 6  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    554
                                                                                                                                                                                                 | 
                                                            +	public $surface_units; // scale -3, 0, 3, 6  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    555
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    555
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    556
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    556
                                                                                                                                                                                                 | 
                                                             	 * @var float|string|null  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    557
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    557
                                                                                                                                                                                                 | 
                                                             	 */  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -559,7 +559,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    559
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    559
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    560
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    560
                                                                                                                                                                                                 | 
                                                             	 * @var int|string|null  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    561
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    561
                                                                                                                                                                                                 | 
                                                             	 */  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    562
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -	public $volume_units;	// scale -3, 0, 3, 6  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    562
                                                                                                                                                                                                 | 
                                                            +	public $volume_units; // scale -3, 0, 3, 6  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    563
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    563
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    564
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    564
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    565
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    565
                                                                                                                                                                                                 | 
                                                             	 * @var float|string|null  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -568,7 +568,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    568
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    568
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    569
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    569
                                                                                                                                                                                                 | 
                                                             	 * @var ?string  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    570
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    570
                                                                                                                                                                                                 | 
                                                             	 */  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    571
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -	public $net_measure_units;	// scale -3, 0, 3, 6  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    571
                                                                                                                                                                                                 | 
                                                            +	public $net_measure_units; // scale -3, 0, 3, 6  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    572
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    572
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    573
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    573
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    574
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    574
                                                                                                                                                                                                 | 
                                                             	 * @var string  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -824,7 +824,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    824
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    824
                                                                                                                                                                                                 | 
                                                             		'import_key'    => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'notnull' => -1, 'index' => 0, 'position' => 1000), | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    825
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    825
                                                                                                                                                                                                 | 
                                                             		//'tosell'       =>array('type'=>'integer',      'label'=>'Status',           'enabled'=>1, 'visible'=>1,  'notnull'=>1, 'default'=>'0', 'index'=>1,  'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    826
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    826
                                                                                                                                                                                                 | 
                                                             		//'tobuy'        =>array('type'=>'integer',      'label'=>'Status',           'enabled'=>1, 'visible'=>1,  'notnull'=>1, 'default'=>'0', 'index'=>1,  'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    827
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -		'mandatory_period' => array('type' => 'integer', 'label' => 'mandatoryperiod', 'enabled' => 1, 'visible' => -1,  'notnull' => 1, 'default' => '0', 'index' => 1,  'position' => 1000), | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    827
                                                                                                                                                                                                 | 
                                                            +		'mandatory_period' => array('type' => 'integer', 'label' => 'mandatoryperiod', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'default' => '0', 'index' => 1, 'position' => 1000), | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    828
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    828
                                                                                                                                                                                                 | 
                                                             	);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    829
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    829
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    830
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    830
                                                                                                                                                                                                 | 
                                                             	/**  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -1128,9 +1128,9 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    1128
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1128
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1129
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1129
                                                                                                                                                                                                 | 
                                                             							// update accountancy for this entity  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1130
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1130
                                                                                                                                                                                                 | 
                                                             							if (!$error && getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1131
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								$this->db->query("DELETE FROM " . $this->db->prefix() . "product_perentity WHERE fk_product = " .((int) $this->id) . " AND entity = " . ((int) $conf->entity)); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1131
                                                                                                                                                                                                 | 
                                                            +								$this->db->query("DELETE FROM ".$this->db->prefix()."product_perentity WHERE fk_product = ".((int) $this->id)." AND entity = ".((int) $conf->entity)); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1132
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1132
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1133
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								$sql = "INSERT INTO " . $this->db->prefix() . "product_perentity ("; | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1133
                                                                                                                                                                                                 | 
                                                            +								$sql = "INSERT INTO ".$this->db->prefix()."product_perentity ("; | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1134
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1134
                                                                                                                                                                                                 | 
                                                             								$sql .= " fk_product";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1135
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1135
                                                                                                                                                                                                 | 
                                                             								$sql .= ", entity";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1136
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1136
                                                                                                                                                                                                 | 
                                                             								$sql .= ", accountancy_code_buy";  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -1141,13 +1141,13 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    1141
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1141
                                                                                                                                                                                                 | 
                                                             								$sql .= ", accountancy_code_sell_export";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1142
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1142
                                                                                                                                                                                                 | 
                                                             								$sql .= ") VALUES ("; | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1143
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1143
                                                                                                                                                                                                 | 
                                                             								$sql .= $this->id;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1144
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								$sql .= ", " . ((int) $conf->entity);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1145
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								$sql .= ", '" . $this->db->escape($this->accountancy_code_buy) . "'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1146
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								$sql .= ", '" . $this->db->escape($this->accountancy_code_buy_intra) . "'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1147
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								$sql .= ", '" . $this->db->escape($this->accountancy_code_buy_export) . "'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1148
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								$sql .= ", '" . $this->db->escape($this->accountancy_code_sell) . "'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1149
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								$sql .= ", '" . $this->db->escape($this->accountancy_code_sell_intra) . "'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1150
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								$sql .= ", '" . $this->db->escape($this->accountancy_code_sell_export) . "'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1144
                                                                                                                                                                                                 | 
                                                            +								$sql .= ", ".((int) $conf->entity);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1145
                                                                                                                                                                                                 | 
                                                            +								$sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1146
                                                                                                                                                                                                 | 
                                                            +								$sql .= ", '".$this->db->escape($this->accountancy_code_buy_intra)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1147
                                                                                                                                                                                                 | 
                                                            +								$sql .= ", '".$this->db->escape($this->accountancy_code_buy_export)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1148
                                                                                                                                                                                                 | 
                                                            +								$sql .= ", '".$this->db->escape($this->accountancy_code_sell)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1149
                                                                                                                                                                                                 | 
                                                            +								$sql .= ", '".$this->db->escape($this->accountancy_code_sell_intra)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1150
                                                                                                                                                                                                 | 
                                                            +								$sql .= ", '".$this->db->escape($this->accountancy_code_sell_export)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1151
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1151
                                                                                                                                                                                                 | 
                                                             								$sql .= ")";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1152
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1152
                                                                                                                                                                                                 | 
                                                             								$result = $this->db->query($sql);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1153
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1153
                                                                                                                                                                                                 | 
                                                             								if (!$result) { | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -1528,12 +1528,12 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    1528
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1528
                                                                                                                                                                                                 | 
                                                             			$sql .= ", note_public = ".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : 'null');  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1529
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1529
                                                                                                                                                                                                 | 
                                                             			$sql .= ", duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1530
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1530
                                                                                                                                                                                                 | 
                                                             			if (!getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1531
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				$sql .= ", accountancy_code_buy = '" . $this->db->escape($this->accountancy_code_buy) . "'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1532
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				$sql .= ", accountancy_code_buy_intra = '" . $this->db->escape($this->accountancy_code_buy_intra) . "'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1533
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				$sql .= ", accountancy_code_buy_export = '" . $this->db->escape($this->accountancy_code_buy_export) . "'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1534
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				$sql .= ", accountancy_code_sell= '" . $this->db->escape($this->accountancy_code_sell) . "'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1535
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				$sql .= ", accountancy_code_sell_intra= '" . $this->db->escape($this->accountancy_code_sell_intra) . "'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1536
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				$sql .= ", accountancy_code_sell_export= '" . $this->db->escape($this->accountancy_code_sell_export) . "'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1531
                                                                                                                                                                                                 | 
                                                            +				$sql .= ", accountancy_code_buy = '".$this->db->escape($this->accountancy_code_buy)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1532
                                                                                                                                                                                                 | 
                                                            +				$sql .= ", accountancy_code_buy_intra = '".$this->db->escape($this->accountancy_code_buy_intra)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1533
                                                                                                                                                                                                 | 
                                                            +				$sql .= ", accountancy_code_buy_export = '".$this->db->escape($this->accountancy_code_buy_export)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1534
                                                                                                                                                                                                 | 
                                                            +				$sql .= ", accountancy_code_sell= '".$this->db->escape($this->accountancy_code_sell)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1535
                                                                                                                                                                                                 | 
                                                            +				$sql .= ", accountancy_code_sell_intra= '".$this->db->escape($this->accountancy_code_sell_intra)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1536
                                                                                                                                                                                                 | 
                                                            +				$sql .= ", accountancy_code_sell_export= '".$this->db->escape($this->accountancy_code_sell_export)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1537
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1537
                                                                                                                                                                                                 | 
                                                             			}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1538
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1538
                                                                                                                                                                                                 | 
                                                             			$sql .= ", desiredstock = ".((isset($this->desiredstock) && is_numeric($this->desiredstock)) ? (float) $this->desiredstock : "null");  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1539
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1539
                                                                                                                                                                                                 | 
                                                             			$sql .= ", cost_price = ".($this->cost_price != '' ? $this->db->escape($this->cost_price) : 'null');  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -1563,9 +1563,9 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    1563
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1563
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1564
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1564
                                                                                                                                                                                                 | 
                                                             				// update accountancy for this entity  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1565
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1565
                                                                                                                                                                                                 | 
                                                             				if (!$error && getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1566
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -					$this->db->query("DELETE FROM " . $this->db->prefix() . "product_perentity WHERE fk_product = " . ((int) $this->id) . " AND entity = " . ((int) $conf->entity)); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1566
                                                                                                                                                                                                 | 
                                                            +					$this->db->query("DELETE FROM ".$this->db->prefix()."product_perentity WHERE fk_product = ".((int) $this->id)." AND entity = ".((int) $conf->entity)); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1567
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1567
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1568
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -					$sql = "INSERT INTO " . $this->db->prefix() . "product_perentity ("; | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1568
                                                                                                                                                                                                 | 
                                                            +					$sql = "INSERT INTO ".$this->db->prefix()."product_perentity ("; | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1569
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1569
                                                                                                                                                                                                 | 
                                                             					$sql .= " fk_product";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1570
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1570
                                                                                                                                                                                                 | 
                                                             					$sql .= ", entity";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1571
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1571
                                                                                                                                                                                                 | 
                                                             					$sql .= ", accountancy_code_buy";  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -1576,13 +1576,13 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    1576
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1576
                                                                                                                                                                                                 | 
                                                             					$sql .= ", accountancy_code_sell_export";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1577
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1577
                                                                                                                                                                                                 | 
                                                             					$sql .= ") VALUES ("; | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1578
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1578
                                                                                                                                                                                                 | 
                                                             					$sql .= ((int) $this->id);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1579
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -					$sql .= ", " . ((int) $conf->entity);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1580
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -					$sql .= ", '" . $this->db->escape($this->accountancy_code_buy) . "'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1581
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -					$sql .= ", '" . $this->db->escape($this->accountancy_code_buy_intra) . "'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1582
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -					$sql .= ", '" . $this->db->escape($this->accountancy_code_buy_export) . "'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1583
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -					$sql .= ", '" . $this->db->escape($this->accountancy_code_sell) . "'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1584
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -					$sql .= ", '" . $this->db->escape($this->accountancy_code_sell_intra) . "'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1585
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -					$sql .= ", '" . $this->db->escape($this->accountancy_code_sell_export) . "'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1579
                                                                                                                                                                                                 | 
                                                            +					$sql .= ", ".((int) $conf->entity);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1580
                                                                                                                                                                                                 | 
                                                            +					$sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1581
                                                                                                                                                                                                 | 
                                                            +					$sql .= ", '".$this->db->escape($this->accountancy_code_buy_intra)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1582
                                                                                                                                                                                                 | 
                                                            +					$sql .= ", '".$this->db->escape($this->accountancy_code_buy_export)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1583
                                                                                                                                                                                                 | 
                                                            +					$sql .= ", '".$this->db->escape($this->accountancy_code_sell)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1584
                                                                                                                                                                                                 | 
                                                            +					$sql .= ", '".$this->db->escape($this->accountancy_code_sell_intra)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1585
                                                                                                                                                                                                 | 
                                                            +					$sql .= ", '".$this->db->escape($this->accountancy_code_sell_export)."'";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1586
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1586
                                                                                                                                                                                                 | 
                                                             					$sql .= ")";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1587
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1587
                                                                                                                                                                                                 | 
                                                             					$result = $this->db->query($sql);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1588
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1588
                                                                                                                                                                                                 | 
                                                             					if (!$result) { | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -1660,7 +1660,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    1660
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1660
                                                                                                                                                                                                 | 
                                                             								$error++;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1661
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1661
                                                                                                                                                                                                 | 
                                                             							} else { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1662
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1662
                                                                                                                                                                                                 | 
                                                             								// to keep old entries with the new dir  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1663
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								require_once DOL_DOCUMENT_ROOT . '/ecm/class/ecmfiles.class.php';  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1663
                                                                                                                                                                                                 | 
                                                            +								require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1664
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1664
                                                                                                                                                                                                 | 
                                                             								$ecmfiles = new EcmFiles($this->db);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1665
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1665
                                                                                                                                                                                                 | 
                                                             								$ecmfiles->updateAfterRename("produit/".dol_sanitizeFileName($this->oldcopy->ref), "produit/".dol_sanitizeFileName($this->ref)); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1666
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1666
                                                                                                                                                                                                 | 
                                                             							}  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -1958,7 +1958,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    1958
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1958
                                                                                                                                                                                                 | 
                                                             				}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1959
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1959
                                                                                                                                                                                                 | 
                                                             			} elseif (isset($this->multilangs[$key])) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1960
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1960
                                                                                                                                                                                                 | 
                                                             				if (empty($this->multilangs[$key]["label"])) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1961
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -					$this->errors[] = $key . ' : ' . $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1961
                                                                                                                                                                                                 | 
                                                            +					$this->errors[] = $key.' : '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1962
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1962
                                                                                                                                                                                                 | 
                                                             					return -1;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1963
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1963
                                                                                                                                                                                                 | 
                                                             				}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    1964
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    1964
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -2155,7 +2155,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    2155
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2155
                                                                                                                                                                                                 | 
                                                             	 */  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2156
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2156
                                                                                                                                                                                                 | 
                                                             	private function getArrayForPriceCompare($level = 0)  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2157
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2157
                                                                                                                                                                                                 | 
                                                             	{ | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2158
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -		$testExit = array('multiprices','multiprices_ttc','multiprices_base_type','multiprices_min','multiprices_min_ttc','multiprices_tva_tx','multiprices_recuperableonly'); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    2158
                                                                                                                                                                                                 | 
                                                            +		$testExit = array('multiprices', 'multiprices_ttc', 'multiprices_base_type', 'multiprices_min', 'multiprices_min_ttc', 'multiprices_tva_tx', 'multiprices_recuperableonly'); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2159
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2159
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2160
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2160
                                                                                                                                                                                                 | 
                                                             		foreach ($testExit as $field) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2161
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2161
                                                                                                                                                                                                 | 
                                                             			if (!isset($this->$field)) { | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -2845,12 +2845,12 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    2845
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2845
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2846
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2846
                                                                                                                                                                                                 | 
                                                             		//For MultiCompany  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2847
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2847
                                                                                                                                                                                                 | 
                                                             		//PMP per entity & Stocks Sharings stock_reel includes only stocks shared with this entity  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2848
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -		$separatedEntityPMP = false;	// Set to true to get the AWP from table llx_product_perentity instead of field 'pmp' into llx_product.  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2849
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -		$separatedStock = false;		// Set to true will count stock from subtable llx_product_stock. It is slower than using denormalized field 'stock', but it is required when using multientity and shared warehouses.  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    2848
                                                                                                                                                                                                 | 
                                                            +		$separatedEntityPMP = false; // Set to true to get the AWP from table llx_product_perentity instead of field 'pmp' into llx_product.  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    2849
                                                                                                                                                                                                 | 
                                                            +		$separatedStock = false; // Set to true will count stock from subtable llx_product_stock. It is slower than using denormalized field 'stock', but it is required when using multientity and shared warehouses.  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2850
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2850
                                                                                                                                                                                                 | 
                                                             		$visibleWarehousesEntities = $conf->entity;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2851
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2851
                                                                                                                                                                                                 | 
                                                             		if (getDolGlobalString('MULTICOMPANY_PRODUCT_SHARING_ENABLED')) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2852
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2852
                                                                                                                                                                                                 | 
                                                             			if (getDolGlobalString('MULTICOMPANY_PMP_PER_ENTITY_ENABLED')) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2853
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				$checkPMPPerEntity = $this->db->query("SELECT pmp FROM " . $this->db->prefix() . "product_perentity WHERE fk_product = ".((int) $id)." AND entity = ".(int) $conf->entity); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    2853
                                                                                                                                                                                                 | 
                                                            +				$checkPMPPerEntity = $this->db->query("SELECT pmp FROM ".$this->db->prefix()."product_perentity WHERE fk_product = ".((int) $id)." AND entity = ".(int) $conf->entity); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2854
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2854
                                                                                                                                                                                                 | 
                                                             				if ($this->db->num_rows($checkPMPPerEntity) > 0) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2855
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2855
                                                                                                                                                                                                 | 
                                                             					$separatedEntityPMP = true;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2856
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2856
                                                                                                                                                                                                 | 
                                                             				}  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -2858,7 +2858,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    2858
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2858
                                                                                                                                                                                                 | 
                                                             			global $mc;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2859
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2859
                                                                                                                                                                                                 | 
                                                             			$separatedStock = true;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2860
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2860
                                                                                                                                                                                                 | 
                                                             			if (isset($mc->sharings['stock']) && !empty($mc->sharings['stock'])) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2861
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				$visibleWarehousesEntities .= "," . implode(",", $mc->sharings['stock']); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    2861
                                                                                                                                                                                                 | 
                                                            +				$visibleWarehousesEntities .= ",".implode(",", $mc->sharings['stock']); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2862
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2862
                                                                                                                                                                                                 | 
                                                             			}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2863
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2863
                                                                                                                                                                                                 | 
                                                             		}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2864
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2864
                                                                                                                                                                                                 | 
                                                             		if ($separatedEntityPMP) { | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -2876,10 +2876,10 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    2876
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2876
                                                                                                                                                                                                 | 
                                                             		}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2877
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2877
                                                                                                                                                                                                 | 
                                                             		$sql .= " FROM ".$this->db->prefix()."product as p";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2878
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2878
                                                                                                                                                                                                 | 
                                                             		if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED') || $separatedEntityPMP) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2879
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -			$sql .= " LEFT JOIN " . $this->db->prefix() . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    2879
                                                                                                                                                                                                 | 
                                                            +			$sql .= " LEFT JOIN ".$this->db->prefix()."product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = ".((int) $conf->entity);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2880
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2880
                                                                                                                                                                                                 | 
                                                             		}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2881
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2881
                                                                                                                                                                                                 | 
                                                             		if ($separatedStock) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2882
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -			$sql .= " LEFT JOIN " . $this->db->prefix() . "product_stock as sp ON sp.fk_product = p.rowid AND sp.fk_entrepot IN (SELECT rowid FROM ".$this->db->prefix()."entrepot WHERE entity IN (".$this->db->sanitize($visibleWarehousesEntities)."))"; | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    2882
                                                                                                                                                                                                 | 
                                                            +			$sql .= " LEFT JOIN ".$this->db->prefix()."product_stock as sp ON sp.fk_product = p.rowid AND sp.fk_entrepot IN (SELECT rowid FROM ".$this->db->prefix()."entrepot WHERE entity IN (".$this->db->sanitize($visibleWarehousesEntities)."))"; | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2883
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2883
                                                                                                                                                                                                 | 
                                                             		}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2884
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2884
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2885
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2885
                                                                                                                                                                                                 | 
                                                             		if ($id) { | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -3039,15 +3039,15 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    3039
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3039
                                                                                                                                                                                                 | 
                                                             						$sql .= " WHERE entity IN (".getEntity('productprice').")"; | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3040
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3040
                                                                                                                                                                                                 | 
                                                             						$sql .= " AND price_level=".((int) $i);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3041
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3041
                                                                                                                                                                                                 | 
                                                             						$sql .= " AND fk_product = ".((int) $this->id);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3042
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -						$sql .= " ORDER BY date_price DESC, rowid DESC";	// Get the most recent line  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3043
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -						$sql .= " LIMIT 1";									// Only the first one  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    3042
                                                                                                                                                                                                 | 
                                                            +						$sql .= " ORDER BY date_price DESC, rowid DESC"; // Get the most recent line  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    3043
                                                                                                                                                                                                 | 
                                                            +						$sql .= " LIMIT 1"; // Only the first one  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3044
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3044
                                                                                                                                                                                                 | 
                                                             						$resql = $this->db->query($sql);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3045
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3045
                                                                                                                                                                                                 | 
                                                             						if ($resql) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3046
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3046
                                                                                                                                                                                                 | 
                                                             							$result = $this->db->fetch_array($resql);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3047
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3047
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3048
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3048
                                                                                                                                                                                                 | 
                                                             							$this->multiprices[$i] = $result ? $result["price"] : null;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3049
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3049
                                                                                                                                                                                                 | 
                                                             							$this->multiprices_ttc[$i] = $result ? $result["price_ttc"] : null;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3050
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -							$this->multiprices_min[$i] =  $result ? $result["price_min"] : null;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    3050
                                                                                                                                                                                                 | 
                                                            +							$this->multiprices_min[$i] = $result ? $result["price_min"] : null;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3051
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3051
                                                                                                                                                                                                 | 
                                                             							$this->multiprices_min_ttc[$i] = $result ? $result["price_min_ttc"] : null;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3052
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3052
                                                                                                                                                                                                 | 
                                                             							$this->multiprices_base_type[$i] = $result ? $result["price_base_type"] : null;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3053
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3053
                                                                                                                                                                                                 | 
                                                             							// Next two fields are used only if PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL is on  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -3272,7 +3272,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    3272
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3272
                                                                                                                                                                                                 | 
                                                             				$obj = $this->db->fetch_object($result);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3273
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3273
                                                                                                                                                                                                 | 
                                                             				$this->stats_mo['customers_'.$role] = $obj->nb_customers ? $obj->nb_customers : 0;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3274
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3274
                                                                                                                                                                                                 | 
                                                             				$this->stats_mo['nb_'.$role] = $obj->nb ? $obj->nb : 0;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3275
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				$this->stats_mo['qty_'.$role] = $obj->qty ? price2num($obj->qty, 'MS') : 0;		// qty may be a float due to the SUM()  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    3275
                                                                                                                                                                                                 | 
                                                            +				$this->stats_mo['qty_'.$role] = $obj->qty ? price2num($obj->qty, 'MS') : 0; // qty may be a float due to the SUM()  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3276
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3276
                                                                                                                                                                                                 | 
                                                             			} else { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3277
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3277
                                                                                                                                                                                                 | 
                                                             				$this->error = $this->db->error();  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3278
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3278
                                                                                                                                                                                                 | 
                                                             				$error++;  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -4775,7 +4775,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    4775
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    4775
                                                                                                                                                                                                 | 
                                                             				//Addition of a product with the highest rank +1  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    4776
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    4776
                                                                                                                                                                                                 | 
                                                             				$sql = "INSERT INTO ".$this->db->prefix()."product_association(fk_product_pere,fk_product_fils,qty,incdec,rang)";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    4777
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    4777
                                                                                                                                                                                                 | 
                                                             				$sql .= " VALUES (".((int) $id_pere).", ".((int) $id_fils).", ".price2num($qty, 'MS').", ".((int) $incdec).", ".((int) $rank).")"; | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    4778
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				if (! $this->db->query($sql)) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    4778
                                                                                                                                                                                                 | 
                                                            +				if (!$this->db->query($sql)) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    4779
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    4779
                                                                                                                                                                                                 | 
                                                             					dol_print_error($this->db);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    4780
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    4780
                                                                                                                                                                                                 | 
                                                             					return -1;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    4781
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    4781
                                                                                                                                                                                                 | 
                                                             				} else { | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -4896,7 +4896,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    4896
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    4896
                                                                                                                                                                                                 | 
                                                             				$sql = "UPDATE ".$this->db->prefix()."product_association";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    4897
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    4897
                                                                                                                                                                                                 | 
                                                             				$sql .= " SET rang = ".((int) $cpt);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    4898
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    4898
                                                                                                                                                                                                 | 
                                                             				$sql .= " WHERE rowid = ".((int) $objrank->rowid);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    4899
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				if (! $this->db->query($sql)) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    4899
                                                                                                                                                                                                 | 
                                                            +				if (!$this->db->query($sql)) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    4900
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    4900
                                                                                                                                                                                                 | 
                                                             					dol_print_error($this->db);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    4901
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    4901
                                                                                                                                                                                                 | 
                                                             					return -1;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    4902
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    4902
                                                                                                                                                                                                 | 
                                                             				}  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -5331,7 +5331,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    5331
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5331
                                                                                                                                                                                                 | 
                                                             		if (isset($this->sousprods) && is_array($this->sousprods)) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5332
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5332
                                                                                                                                                                                                 | 
                                                             			foreach ($this->sousprods as $prod_name => $desc_product) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5333
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5333
                                                                                                                                                                                                 | 
                                                             				if (is_array($desc_product)) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5334
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -					$this->fetch_prod_arbo($desc_product, "", $multiply, 1, $this->id, $ignore_stock_load);	// This set $this->res  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    5334
                                                                                                                                                                                                 | 
                                                            +					$this->fetch_prod_arbo($desc_product, "", $multiply, 1, $this->id, $ignore_stock_load); // This set $this->res  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5335
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5335
                                                                                                                                                                                                 | 
                                                             				}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5336
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5336
                                                                                                                                                                                                 | 
                                                             			}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5337
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5337
                                                                                                                                                                                                 | 
                                                             		}  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -5487,7 +5487,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    5487
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5487
                                                                                                                                                                                                 | 
                                                             		$sql .= " AND pa.fk_product_fils <> ".((int) $id); // This should not happens, it is to avoid infinite loop if it happens  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5488
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5488
                                                                                                                                                                                                 | 
                                                             		$sql .= " ORDER BY pa.rang";  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5489
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5489
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5490
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -		dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level. ' parents='.(is_array($parents) ? implode(',', $parents) : $parents), LOG_DEBUG); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    5490
                                                                                                                                                                                                 | 
                                                            +		dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level.' parents='.(is_array($parents) ? implode(',', $parents) : $parents), LOG_DEBUG); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5491
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5491
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5492
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5492
                                                                                                                                                                                                 | 
                                                             		if ($level == 1) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5493
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5493
                                                                                                                                                                                                 | 
                                                             			$alreadyfound = array($id => 1); // We init array of found object to start of tree, so if we found it later (should not happened), we stop immediately  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -5552,7 +5552,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    5552
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5552
                                                                                                                                                                                                 | 
                                                             			$parent[$this->label][$keyChild] = $valueChild;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5553
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5553
                                                                                                                                                                                                 | 
                                                             		}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5554
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5554
                                                                                                                                                                                                 | 
                                                             		foreach ($parent as $key => $value) {        // key=label, value is array of children | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5555
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -			$this->sousprods[$key] = $value;  // @phan-suppress-current-line PhanTypeMismatchProperty  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    5555
                                                                                                                                                                                                 | 
                                                            +			$this->sousprods[$key] = $value; // @phan-suppress-current-line PhanTypeMismatchProperty  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5556
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5556
                                                                                                                                                                                                 | 
                                                             		}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5557
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5557
                                                                                                                                                                                                 | 
                                                             	}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5558
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5558
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -5588,7 +5588,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    5588
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5588
                                                                                                                                                                                                 | 
                                                             		if (!empty($this->entity) && $permissiontoreadproduct) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5589
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5589
                                                                                                                                                                                                 | 
                                                             			$tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80, 0, 0, 0, 0, '1'); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5590
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5590
                                                                                                                                                                                                 | 
                                                             			if ($this->nbphoto > 0) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5591
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				$datas['photo'] = '<div class="photointooltip floatright">'."\n" . $tmpphoto . '</div>';  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    5591
                                                                                                                                                                                                 | 
                                                            +				$datas['photo'] = '<div class="photointooltip floatright">'."\n".$tmpphoto.'</div>';  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5592
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5592
                                                                                                                                                                                                 | 
                                                             			}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5593
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5593
                                                                                                                                                                                                 | 
                                                             		}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5594
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5594
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -5598,7 +5598,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    5598
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5598
                                                                                                                                                                                                 | 
                                                             			$datas['picto'] = img_picto('', 'service').' <u class="paddingrightonly">'.$langs->trans("Service").'</u>'; | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5599
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5599
                                                                                                                                                                                                 | 
                                                             		}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5600
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5600
                                                                                                                                                                                                 | 
                                                             		if (isset($this->status) && isset($this->status_buy)) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5601
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -			$datas['status'] = ' '.$this->getLibStatut(5, 0) . ' '.$this->getLibStatut(5, 1);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    5601
                                                                                                                                                                                                 | 
                                                            +			$datas['status'] = ' '.$this->getLibStatut(5, 0).' '.$this->getLibStatut(5, 1);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5602
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5602
                                                                                                                                                                                                 | 
                                                             		}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5603
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5603
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5604
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5604
                                                                                                                                                                                                 | 
                                                             		if (!empty($this->ref)) { | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -5648,7 +5648,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    5648
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5648
                                                                                                                                                                                                 | 
                                                             					$labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."<b>".$langs->trans("Volume").'</b>: '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5649
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5649
                                                                                                                                                                                                 | 
                                                             				}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5650
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5650
                                                                                                                                                                                                 | 
                                                             				if ($labelsurfacevolume) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5651
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -					$datas['surface'] = "<br>" . $labelsurfacevolume;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    5651
                                                                                                                                                                                                 | 
                                                            +					$datas['surface'] = "<br>".$labelsurfacevolume;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5652
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5652
                                                                                                                                                                                                 | 
                                                             				}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5653
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5653
                                                                                                                                                                                                 | 
                                                             			}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5654
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5654
                                                                                                                                                                                                 | 
                                                             			if ($this->isService() && !empty($this->duration_value)) { | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -5690,9 +5690,9 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    5690
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5690
                                                                                                                                                                                                 | 
                                                             			}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5691
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5691
                                                                                                                                                                                                 | 
                                                             			// show categories for this record only in ajax to not overload lists  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5692
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5692
                                                                                                                                                                                                 | 
                                                             			if (isModEnabled('category') && !$nofetch) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5693
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    5693
                                                                                                                                                                                                 | 
                                                            +				require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5694
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5694
                                                                                                                                                                                                 | 
                                                             				$form = new Form($this->db);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5695
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				$datas['categories'] = '<br>' . $form->showCategories($this->id, Categorie::TYPE_PRODUCT, 1);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    5695
                                                                                                                                                                                                 | 
                                                            +				$datas['categories'] = '<br>'.$form->showCategories($this->id, Categorie::TYPE_PRODUCT, 1);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5696
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5696
                                                                                                                                                                                                 | 
                                                             			}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5697
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5697
                                                                                                                                                                                                 | 
                                                             		}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5698
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    5698
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -6215,7 +6215,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    6215
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    6215
                                                                                                                                                                                                 | 
                                                             		if (isModEnabled("supplier_order")) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    6216
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    6216
                                                                                                                                                                                                 | 
                                                             			$filterStatus = getDolGlobalString('SUPPLIER_ORDER_STATUS_FOR_VIRTUAL_STOCK', '3,4'); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    6217
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    6217
                                                                                                                                                                                                 | 
                                                             			if (isset($includedraftpoforvirtual)) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    6218
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				$filterStatus = '0,1,2,'.$filterStatus;	// 1,2 may have already been inside $filterStatus but it is better to have twice than missing $filterStatus does not include them  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    6218
                                                                                                                                                                                                 | 
                                                            +				$filterStatus = '0,1,2,'.$filterStatus; // 1,2 may have already been inside $filterStatus but it is better to have twice than missing $filterStatus does not include them  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    6219
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    6219
                                                                                                                                                                                                 | 
                                                             			}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    6220
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    6220
                                                                                                                                                                                                 | 
                                                             			$result = $this->load_stats_commande_fournisseur(0, $filterStatus, 1, $dateofvirtualstock);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    6221
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    6221
                                                                                                                                                                                                 | 
                                                             			if ($result < 0) { | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -6632,7 +6632,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    6632
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    6632
                                                                                                                                                                                                 | 
                                                             		if (getDolGlobalString('BARCODE_PRODUCT_ADDON_NUM')) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    6633
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    6633
                                                                                                                                                                                                 | 
                                                             			$dirsociete = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    6634
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    6634
                                                                                                                                                                                                 | 
                                                             			foreach ($dirsociete as $dirroot) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    6635
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				$res = dol_include_once($dirroot . getDolGlobalString('BARCODE_PRODUCT_ADDON_NUM').'.php'); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    6635
                                                                                                                                                                                                 | 
                                                            +				$res = dol_include_once($dirroot.getDolGlobalString('BARCODE_PRODUCT_ADDON_NUM').'.php'); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    6636
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    6636
                                                                                                                                                                                                 | 
                                                             				if ($res) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    6637
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    6637
                                                                                                                                                                                                 | 
                                                             					break;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    6638
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    6638
                                                                                                                                                                                                 | 
                                                             				}  |