Browse Source

Config, Debug no display, Product declianison combination no sync

Mathieu Moulin 3 years ago
parent
commit
3402ae2304

+ 1 - 0
.gitignore

@@ -1,3 +1,4 @@
+config/config.inc.php
 tmp/
 var/cache/
 var/log/

+ 0 - 0
config/.gitkeep


+ 2 - 0
config/.htaccess

@@ -0,0 +1,2 @@
+order deny,allow
+deny from all

+ 14 - 0
config/config.inc.php.dist

@@ -0,0 +1,14 @@
+<?php
+
+define("DB_HOST", "localhost");
+define("DB_USER", "");
+define("DB_PASS", "");
+define("DB_BASE", "");
+
+define("PATH_ROOT", realpath(dirname(__FILE__)."/.."));
+
+define("PATH_INCLUDE", PATH_ROOT."/include");
+define("PATH_TEMPLATE", PATH_ROOT."/include/template");
+
+#error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
+

+ 42 - 0
config/config_defaults.inc.php

@@ -0,0 +1,42 @@
+<?php
+
+// PATH
+
+define('VAR_PATH', ROOT_PATH.'/var');
+define('VENDOR_PATH', ROOT_PATH.'/vendor');
+
+define('CLASS_PATH', SRC_PATH.'/class');
+define('VIEWMODEL_PATH', SRC_PATH.'/viewmodel');
+define('TEMPLATE_PATH', SRC_PATH.'/template');
+define('TABLE_PATH', SRC_PATH.'/table');
+define('ORM_PATH', SRC_PATH.'/orm');
+define('MODEL_PATH', SRC_PATH.'/model');
+define('CONTROLLER_PATH', SRC_PATH.'/controller');
+define('SYNC_PATH', SRC_PATH.'/sync');
+
+// DB
+
+if (!defined("DB_HOST"))
+	die('Please configure DB');
+if (!defined("DB_P_HOST"))
+	die('Please configure DB');
+if (!defined("DB_D_HOST"))
+	die('Please configure DB');
+
+// DEBUG
+
+if (!defined('DEBUG_AFF'))
+	define('DEBUG_AFF', false);
+if (!defined('DEBUG_ALL'))
+	define('DEBUG_ALL', true);
+if (!defined('DEBUG_SQL'))
+	define('DEBUG_SQL', DEBUG_ALL);
+if (!defined('DEBUG_SYNCHRO'))
+	define('DEBUG_SYNCHRO', DEBUG_ALL);
+if (!defined('DEBUG_WS'))
+	define('DEBUG_WS', DEBUG_ALL);
+
+// New system
+
+if (!defined('NEWSYNC_ENABLE'))
+	define('NEWSYNC_ENABLE', false);

+ 38 - 19
src/db.inc.php

@@ -23,21 +23,24 @@ public static function o_query($sql)
 {
 	global $db;
 	$q = $db->query($sql);
-	echo '<p>'.htmlentities($sql).' : '.$db->affected_rows.' / '.$db->insert_id.' / '.$db->error.'</p>';
+	if (DEBUG_AFF)
+		echo '<p>'.htmlentities($sql).' : '.$db->affected_rows.' / '.$db->insert_id.' / '.$db->error.'</p>';
 	return $q;
 }
 public static function o_select($sql)
 {
 	global $db;
 	$q = $db->query($sql);
-	echo '<p>'.htmlentities($sql).' : '.$q->num_rows.' / '.$db->error.'</p>';
+	if (DEBUG_AFF)
+		echo '<p>'.htmlentities($sql).' : '.$q->num_rows.' / '.$db->error.'</p>';
 	return $q;
 }
 public static function o_count($sql)
 {
 	global $db;
 	$q = $db->query($sql);
-	echo '<p>'.htmlentities($sql).' : '.$q->num_rows.' / '.$db->error.'</p>';
+	if (DEBUG_AFF)
+		echo '<p>'.htmlentities($sql).' : '.$q->num_rows.' / '.$db->error.'</p>';
 	list($nb) = $q->fetch_row();
 	return $nb;
 }
@@ -45,7 +48,8 @@ public static function o_insert($sql)
 {
 	global $db;
 	$q = $db->query($sql);
-	echo '<p>'.htmlentities($sql).' : '.$db->insert_id.' / '.$db->error.'</p>';
+	if (DEBUG_AFF)
+		echo '<p>'.htmlentities($sql).' : '.$db->insert_id.' / '.$db->error.'</p>';
 	if ($q)
 		return $db->insert_id;
 }
@@ -53,7 +57,8 @@ public static function o_update($sql)
 {
 	global $db;
 	$q = $db->query($sql);
-	echo '<p>'.htmlentities($sql).' : '.$db->affected_rows.' / '.$db->error.'</p>';
+	if (DEBUG_AFF)
+		echo '<p>'.htmlentities($sql).' : '.$db->affected_rows.' / '.$db->error.'</p>';
 	if ($q)
 		return $db->affected_rows;
 }
@@ -61,7 +66,8 @@ public static function o_delete($sql)
 {
 	global $db;
 	$q = $db->query($sql);
-	echo '<p>'.htmlentities($sql).' : '.$db->affected_rows.' / '.$db->error.'</p>';
+	if (DEBUG_AFF)
+		echo '<p>'.htmlentities($sql).' : '.$db->affected_rows.' / '.$db->error.'</p>';
 	if ($q)
 		return $db->affected_rows;
 }
@@ -74,7 +80,8 @@ public static function d_query($sql)
 
 	$q = $db_d->query($sql);
 
-	echo '<p>'.htmlentities($sql).' : '.$db_d->affected_rows.' / '.$db_d->insert_id.' / '.$db_d->error.'</p>';
+	if (DEBUG_AFF)
+		echo '<p>'.htmlentities($sql).' : '.$db_d->affected_rows.' / '.$db_d->insert_id.' / '.$db_d->error.'</p>';
 	return $q;
 }
 public static function d_select($sql)
@@ -83,14 +90,16 @@ public static function d_select($sql)
 
 	$q = $db_d->query($sql);
 
-	echo '<p>'.htmlentities($sql).' : '.$q->num_rows.' / '.$db_d->error.'</p>';
+	if (DEBUG_AFF)
+		echo '<p>'.htmlentities($sql).' : '.$q->num_rows.' / '.$db_d->error.'</p>';
 	return $q;
 }
 public static function d_count($sql)
 {
 	global $db_d;
 	$q = $db_d->query($sql);
-	echo '<p>'.htmlentities($sql).' : '.$q->num_rows.' / '.$db_d->error.'</p>';
+	if (DEBUG_AFF)
+		echo '<p>'.htmlentities($sql).' : '.$q->num_rows.' / '.$db_d->error.'</p>';
 	list($nb) = $q->fetch_row();
 	return $nb;
 }
@@ -99,8 +108,10 @@ public static function d_insert($sql)
 	global $db_d;
 
 	$q = $db_d->query($sql);
-	var_dump($q);
-	echo '<p>'.htmlentities($sql).' : '.$db_d->insert_id.' / '.$db_d->error.'</p>';
+	if (DEBUG_AFF)
+		var_dump($q);
+	if (DEBUG_AFF)
+		echo '<p>'.htmlentities($sql).' : '.$db_d->insert_id.' / '.$db_d->error.'</p>';
 	if ($q)
 		return $db_d->insert_id;
 }
@@ -108,7 +119,8 @@ public static function d_update($sql)
 {
 	global $db_d;
 	$q = $db_d->query($sql);
-	echo '<p>'.htmlentities($sql).' : '.$db_d->affected_rows.' / '.$db_d->error.'</p>';
+	if (DEBUG_AFF)
+		echo '<p>'.htmlentities($sql).' : '.$db_d->affected_rows.' / '.$db_d->error.'</p>';
 	if ($q)
 		return $db_d->affected_rows;
 }
@@ -116,7 +128,8 @@ public static function d_delete($sql)
 {
 	global $db_d;
 	$q = $db_d->query($sql);
-	echo '<p>'.htmlentities($sql).' : '.$db_d->affected_rows.' / '.$db_d->error.'</p>';
+	if (DEBUG_AFF)
+		echo '<p>'.htmlentities($sql).' : '.$db_d->affected_rows.' / '.$db_d->error.'</p>';
 	if ($q)
 		return $db_d->affected_rows;
 }
@@ -278,7 +291,8 @@ public static function p_query($sql)
 
 	$q = $db_p->query($sql);
 
-	echo '<p>'.htmlentities($sql).' : '.$db_p->affected_rows.' / '.$db_p->insert_id.' / '.$db_p->error.'</p>';
+	if (DEBUG_AFF)
+		echo '<p>'.htmlentities($sql).' : '.$db_p->affected_rows.' / '.$db_p->insert_id.' / '.$db_p->error.'</p>';
 	return $q;
 }
 public static function p_select($sql)
@@ -287,14 +301,16 @@ public static function p_select($sql)
 
 	$q = $db_p->query($sql);
 
-	echo '<p>'.htmlentities($sql).' : '.$q->num_rows.' / '.$db_p->error.'</p>';
+	if (DEBUG_AFF)
+		echo '<p>'.htmlentities($sql).' : '.$q->num_rows.' / '.$db_p->error.'</p>';
 	return $q;
 }
 public static function p_count($sql)
 {
 	global $db_p;
 	$q = $db_p->query($sql);
-	echo '<p>'.htmlentities($sql).' : '.$q->num_rows.' / '.$db_p->error.'</p>';
+	if (DEBUG_AFF)
+		echo '<p>'.htmlentities($sql).' : '.$q->num_rows.' / '.$db_p->error.'</p>';
 	list($nb) = $q->fetch_row();
 	return $nb;
 }
@@ -304,7 +320,8 @@ public static function p_insert($sql)
 
 	$q = $db_p->query($sql);
 
-	echo '<p>'.htmlentities($sql).' : '.$db_p->insert_id.' / '.$db_p->error.'</p>';
+	if (DEBUG_AFF)
+		echo '<p>'.htmlentities($sql).' : '.$db_p->insert_id.' / '.$db_p->error.'</p>';
 	if ($q)
 		return $db_p->insert_id;
 }
@@ -314,7 +331,8 @@ public static function p_update($sql)
 
 	$q = $db_p->query($sql);
 
-	echo '<p>'.htmlentities($sql).' : '.$db_p->affected_rows.' / '.$db_p->error.'</p>';
+	if (DEBUG_AFF)
+		echo '<p>'.htmlentities($sql).' : '.$db_p->affected_rows.' / '.$db_p->error.'</p>';
 	if ($q)
 		return $db_p->affected_rows;
 }
@@ -324,7 +342,8 @@ public static function p_delete($sql)
 
 	$q = $db_p->query($sql);
 
-	echo '<p>'.htmlentities($sql).' : '.$db_p->affected_rows.' / '.$db_p->error.'</p>';
+	if (DEBUG_AFF)
+		echo '<p>'.htmlentities($sql).' : '.$db_p->affected_rows.' / '.$db_p->error.'</p>';
 	if ($q)
 		return $db_p->affected_rows;
 }

+ 16 - 0
src/sync/product/common.inc.php

@@ -99,4 +99,20 @@ function p_data($otype, $oid)
 	return $data;
 }
 
+public function p_product_check_combi($oid)
+{
+	// Check simple ou combi
+	$sql = 'SELECT id_product_attribute
+		FROM ps_product_attribute
+		WHERE id_product='.$oid.'
+		LIMIT 1';
+	$q = DB::p_select($sql);
+
+	if ($q->num_rows) {
+		if (DEBUG_AFF)
+			var_dump('COMBI ! ACHTUNG !');
+		return true;
+	}
+}
+
 }

+ 18 - 5
src/sync/product/dp.inc.php

@@ -37,12 +37,19 @@ public function dp_insert_simple_more(&$o, &$p_data_map, &$d_data)
 
 public function osync($o)
 {
+	// Si produit maître avec déclinaisons, on stoppe la synchro pour pas foutre le border
+	if ($o['p_tref']=='product' && $this->p_product_check_combi($o['p_oid']))
+		return;
+	
 	return $this->dp_osync($o);
 }
 
 public function dp_update_more(&$o, &$p_data_map, &$p_data_map_create, &$p_data, &$d_data)
 {
-	var_dump('dp_update_more()'); var_dump($o);
+	if (DEBUG_AFF)
+		var_dump('dp_update_more()');
+	if (DEBUG_AFF)
+		var_dump($o);
 	// Produit simple
 	if ($o['p_tref']=='product')
 		return $this->dp_update_simple_more($o, $p_data_map, $p_data_map_create, $p_data, $d_data);
@@ -109,9 +116,12 @@ public function dp_update_simple_more(&$o, &$p_data_map, &$p_data_map_create, &$
 				$p_assoc_delete[] = [$row['id_product_item'], $row['id_product_attribute_item']];
 		}
 
-		var_dump($p_assoc_insert);
-		var_dump($p_assoc_update);
-		var_dump($p_assoc_delete);
+		if (DEBUG_AFF)
+			var_dump($p_assoc_insert);
+		if (DEBUG_AFF)
+			var_dump($p_assoc_update);
+		if (DEBUG_AFF)
+			var_dump($p_assoc_delete);
 		//die();
 
 		// DB actions
@@ -278,7 +288,10 @@ public function map_create_simple(&$o, &$d_data)
 
 public function dp_map_update(&$o, &$d_data, &$p_data=[])
 {
-	var_dump('dp_map_update()'); var_dump($o);
+	if (DEBUG_AFF)
+		var_dump('dp_map_update()');
+	if (DEBUG_AFF)
+		var_dump($o);
 	if ($o['p_tref']=='product')
 		return $this->map_update_simple($o, $d_data, $p_data);
 	elseif ($o['p_tref']=='product_attribute')

+ 23 - 24
src/sync/product/pd.inc.php

@@ -7,34 +7,26 @@ class sync_product_pd extends sync_product
 
 public function execute_osync($otype, $oid)
 {
+	// Si produit maître avec déclinaisons, on synchronise toutes les déclinaisons
+	if ($otype=='product' && $this->p_product_check_combi($oid)) {
+		$this->pd_osync_decl($oid);
+		return;
+	}
+	
 	return $this->pd_execute_osync($otype, $oid);
 }
 
 public function execute_create($otype, $oid)
 {
 	// Si produit maître avec déclinaisons, on synchronise toutes les déclinaisons
-	if ($otype=='product' && $this->check_combi($oid)) {
+	if ($otype=='product' && $this->p_product_check_combi($oid)) {
 		$this->pd_osync_decl($oid);
+		return;
 	}
 	
 	return $this->pd_create($otype, $oid);
 }
 
-public function check_combi($oid)
-{
-	// Check simple ou combi
-	$sql = 'SELECT id_product_attribute
-		FROM ps_product_attribute
-		WHERE id_product='.$oid.'
-		LIMIT 1';
-	$q = DB::p_select($sql);
-
-	if ($q->num_rows) {
-		var_dump('COMBI ! ACHTUNG !');
-		return true;
-	}
-}
-
 // -- SUB ACTIONS --
 
 public function pd_insert_more(&$o, &$d_data_map, &$p_data)
@@ -156,9 +148,12 @@ public function pd_update_more(&$o, &$d_data_map, &$d_data_map_create, &$d_data,
 				$d_assoc_delete[] = $row['rowid'];
 		}
 
-		var_dump($d_assoc_insert);
-		var_dump($d_assoc_update);
-		var_dump($d_assoc_delete);
+		if (DEBUG_AFF)
+			var_dump($d_assoc_insert);
+		if (DEBUG_AFF)
+			var_dump($d_assoc_update);
+		if (DEBUG_AFF)
+			var_dump($d_assoc_delete);
 		
 		// DB actions
 		foreach($d_assoc_insert as $row)
@@ -238,10 +233,12 @@ public function image_sync(&$p_data, $i_id)
 	$n = strlen($i_id);
 	for($i=0; $i<$n; $i++)
 		$p_folder .= '/'.substr($i_id, $i, 1);
+	
+	$p_f = $p_folder.'/'.$p_filename;
+	if (DEBUG_AFF)
+		var_dump($p_f);
 
-	var_dump($p_f=$p_folder.'/'.$p_filename);
-
-	if (file_exists($p_f=$p_folder.'/'.$p_filename)) {
+	if (file_exists($p_f)) {
 		//var_dump($p_f);
 		if (!empty($p_data['product_attribute']))
 			$ref = $p_data['product_attribute']['reference'];
@@ -255,14 +252,16 @@ public function image_sync(&$p_data, $i_id)
 		if (!file_exists($d_folder))
 			mkdir($d_folder);
 		$d_f = $d_folder.'/'.$d_filename;
-		var_dump($d_f);
+		if (DEBUG_AFF)
+			var_dump($d_f);
 		exec("rsync -a \"$p_f\" \"$d_f\"");
 
 		// Suppression ancienne image
 		$fp = opendir($d_folder);
 		while($filename=readdir($fp)) {
 			if (!in_array($filename, ['.', '..', $d_filename])) {
-				var_dump('DELETE : '.$filename);
+				if (DEBUG_AFF)
+					var_dump('DELETE : '.$filename);
 				unlink($d_folder.'/'.$filename);
 			}
 		}

+ 2 - 1
src/sync/supplier_price/pd.inc.php

@@ -29,7 +29,8 @@ public function osync($o)
 
 public function pd_update_more(&$o, &$d_data_map, &$d_data_map_create, &$d_data, &$p_data)
 {
-	var_dump($d_data_map);
+	if (DEBUG_AFF)
+		var_dump($d_data_map);
 }
 
 // -- MAPPING --

+ 56 - 25
src/sync/sync.inc.php

@@ -159,10 +159,12 @@ public static function _class($type, $sens)
 	try {
 		require_once(SYNC_PATH.'/'.$type.'/common.inc.php');
 	} catch(Throwable $e) {
-		var_dump($e);
+		if (DEBUG_AFF)
+			var_dump($e);
 		sync_error("Could not load common sync class for type ".$type, $e);
 	} catch(Exception $e) {
-		var_dump($e);
+		if (DEBUG_AFF)
+			var_dump($e);
 		sync_error("Could not load common sync class for type ".$type, $e);
 	}
 	
@@ -170,10 +172,12 @@ public static function _class($type, $sens)
 	try {
 		require_once(SYNC_PATH.'/'.$type.'/'.$sens.'.inc.php');
 	} catch(Throwable $e) {
-		var_dump($e);
+		if (DEBUG_AFF)
+			var_dump($e);
 		sync_error("Could not load controller sync class for type ".$type.', sens '.$sens, $e);
 	} catch(Exception $e) {
-		var_dump($e);
+		if (DEBUG_AFF)
+			var_dump($e);
 		sync_error("Could not load controller sync class for type ".$type.', sens '.$sens, $e);
 	}
 	
@@ -190,8 +194,12 @@ public static function _action($type, $sens, $action, $otype, $oid)
 		$method = 'execute_'.$action;
 		$r = $controller->$method($otype, $oid);
 	} catch(Throwable $e) {
+		if (DEBUG_AFF)
+			var_dump($e);
 		sync_error('Error executing controller '.$classname.'::'.$method.'('.$otype.','.$oid.')', $e);
 	} catch(Exception $e) {
+		if (DEBUG_AFF)
+			var_dump($e);
 		sync_error('Error executing controller '.$classname.'::'.$method.'('.$otype.','.$oid.')', $e);
 	}
 	
@@ -334,7 +342,8 @@ public static function _d_ref_nb($tablename, $fieldname, $str, $length=6, $date_
 		$nb = 0;
 	}
 
-	var_dump($nb);
+	if (DEBUG_AFF)
+		var_dump(nb);
 	return $nb;
 }
 public static function d_ref_nb()
@@ -372,7 +381,8 @@ public static function _dp_map_fk($modelname, $tablename, $id)
 	if (!($o = static::d_o_oid($modelname, $tablename, $id))) {
 		$o = static::_action($modelname, 'dp', 'create', $tablename, $id);
 	}
-	var_dump($o);
+	if (DEBUG_AFF)
+		var_dump($o);
 	if (empty($o))
 		return;
 	return $o['p_oid'];
@@ -385,7 +395,8 @@ public static function _pd_map_fk($modelname, $tablename, $id)
 	if (!($o = static::p_o_oid($modelname, $tablename, $id))) {
 		$o = static::_action($modelname, 'pd', 'create', $tablename, $id);
 	}
-	var_dump($o);
+	if (DEBUG_AFF)
+		var_dump($o);
 	if (empty($o))
 		return;
 	return $o['d_oid'];
@@ -414,7 +425,8 @@ public function pd_execute_osync($otype, $oid)
 	// Vérif lien existant
 	// Récupère lien
 	$o = $this->p_o_oid(static::MODEL_NAME, $otype, $oid);
-	var_dump($o);
+	if (DEBUG_AFF)
+		var_dump($o);
 
 	//die();
 
@@ -430,7 +442,8 @@ public function dp_execute_osync($otype, $oid)
 	// Vérif lien existant
 	// Récupère lien
 	$o = $this->d_o_oid(static::MODEL_NAME, $otype, $oid);
-	var_dump($o);
+	if (DEBUG_AFF)
+		var_dump($o);
 
 	//die();
 
@@ -454,7 +467,8 @@ public function pd_create($otype, $oid)
 
 	// Récupère données source
 	$p_data = $this->p_data($otype, $oid);
-	var_dump($p_data);
+	if (DEBUG_AFF)
+		var_dump($p_data);
 	if (empty($p_data[$otype])) {
 		sync_error("ERROR ".__METHOD__."($otype, $oid) : Source data does not exists");
 		return;
@@ -467,9 +481,11 @@ public function pd_create($otype, $oid)
 	}
 	$d_data_map_update = $this->pd_map_update($o, $p_data);
 	static::_array_merge_recursive($d_data_map, $d_data_map_update);
-	var_dump($d_data_map);
+	if (DEBUG_AFF)
+		var_dump($d_data_map);
 	
-	echo '<p>CREATION OBJETS</p>';
+	if (DEBUG_AFF)
+		echo '<p>CREATION OBJETS</p>';
 	
 	// insert main row
 	if (!($id = DB::d_insert_row($o['d_tref'], $d_data_map[$o['d_tref']]))) {
@@ -512,11 +528,13 @@ public function dp_create($otype, $oid)
 		'd_tref'=>$otype,
 		'd_oid'=>$oid,
 	];
-	var_dump($o);
+	if (DEBUG_AFF)
+		var_dump($o);
 
 	// Récupère données source
 	$d_data = $this->d_data($otype, $oid);
-	var_dump($d_data);
+	if (DEBUG_AFF)
+		var_dump($d_data);
 	if (empty($d_data[$otype])) {
 		sync_error("ERROR ".__METHOD__."($otype, $oid) : Source data does not exists");
 		return;
@@ -527,11 +545,13 @@ public function dp_create($otype, $oid)
 		sync_error("ERROR ".__METHOD__."($otype, $oid) : map_create()");
 	$p_data_map_update = $this->dp_map_update($o, $d_data);
 	static::_array_merge_recursive($p_data_map, $p_data_map_update);
-	var_dump($p_data_map);
+	if (DEBUG_AFF)
+		var_dump($p_data_map);
 
 	//die();
 
-	echo '<p>CREATION OBJETS</p>';
+	if (DEBUG_AFF)
+		echo '<p>CREATION OBJETS</p>';
 
 	// insert main row
 	if (!($id = DB::p_insert_row($o['p_tref'], $p_data_map[$o['p_tref']]))) {
@@ -570,11 +590,13 @@ public function dp_map_create(&$o, &$d_data)
 // OSYNC
 public function pd_osync($o)
 {
-	var_dump($o);
+	if (DEBUG_AFF)
+		var_dump($o);
 	
 	// Récupère données source
 	$p_data = $this->p_data($o['p_tref'], $o['p_oid']);
-	var_dump($p_data);
+	if (DEBUG_AFF)
+		var_dump($p_data);
 	if (empty($p_data[$o['p_tref']])) {
 		sync_error("ERROR ".__METHOD__."($o[p_tref], $o[p_oid]) : Source data does not exists");
 		return;
@@ -582,13 +604,15 @@ public function pd_osync($o)
 	
 	// Récupère données actuelles en comparaison
 	$d_data = $this->d_data($o['d_tref'], $o['d_oid']);
-	var_dump($d_data);
+	if (DEBUG_AFF)
+		var_dump($d_data);
 	
 	//die();
 
 	// Construit update
 	$d_data_map = $this->pd_map_update($o, $p_data, $d_data);
-	var_dump($d_data_map);
+	if (DEBUG_AFF)
+		var_dump($d_data_map);
 	
 	// Construit create
 	$d_data_map_create = $this->pd_map_create($o, $p_data);
@@ -614,11 +638,13 @@ public function pd_map_update(&$o, &$p_data, &$d_data=[])
 
 public function dp_osync($o)
 {
-	var_dump($o);
+	if (DEBUG_AFF)
+		var_dump($o);
 	
 	// Récupère données source
 	$d_data = $this->d_data($o['d_tref'], $o['d_oid']);
-	var_dump($d_data);
+	if (DEBUG_AFF)
+		var_dump($d_data);
 	if (empty($d_data[static::D_TABLE_MAIN])) {
 		sync_error("ERROR ".__METHOD__."($o[d_tref], $o[d_oid]) : Source data does not exists");
 		return;
@@ -626,20 +652,25 @@ public function dp_osync($o)
 
 	// Récupère données actuelles en comparaison
 	$p_data = $this->p_data($o['p_tref'], $o['p_oid']);
-	var_dump($p_data);
+	if (DEBUG_AFF)
+		var_dump($p_data);
 	
 	//die();
 	//var_dump('dp_osync()'); var_dump($o);
 	
 	// Construit update
 	$p_data_map = $this->dp_map_update($o, $d_data, $p_data);
-	var_dump($p_data_map);
+	if (DEBUG_AFF)
+		var_dump($p_data_map);
 	
 	// Construit create
 	$p_data_map_create = $this->dp_map_create($o, $d_data);
 
 	// Update base
-	var_dump('before base sync::p_update_row()'); var_dump($o);
+	if (DEBUG_AFF)
+		var_dump('before base sync::p_update_row()');
+	if (DEBUG_AFF)
+		var_dump($o);
 	static::p_update_row($o['p_tref'], [static::P_TABLE_ID[$o['p_tref']]=>$o['p_oid']], $p_data_map, $p_data_map_create, $p_data);
 
 	// Update more