Browse Source

Install/resync customer DP

Mathieu Moulin 1 year ago
parent
commit
0ac452e8a7
1 changed files with 35 additions and 9 deletions
  1. 35 9
      src/install/customer.inc.php

+ 35 - 9
src/install/customer.inc.php

@@ -2,13 +2,39 @@
 
 echo '<h3>Synchro Customers</h3>';
 
-$sql = 'SELECT c.id_customer
-	FROM ps_customer c';
-
-$q = DB::p_select($sql);
-while ($row=$q->fetch_assoc()) {
-	var_dump($row);
-	if (isset($_GET['go']))
-		sync::_action('customer', 'pd', 'osync', 'customer', $row['id_customer']);
-	//break;
+if (empty($_GET['start']) || !is_numeric($start=$_GET['start']) || ($start<0))
+	$start = 0;
+if (empty($_GET['num']) || !is_numeric($num=$_GET['num']) || ($num<0))
+	$num = 500;
+
+if (isset($_GET['pd'])) {
+	$sql = 'SELECT c.id_customer
+		FROM ps_customer c';
+
+	$q = DB::p_select($sql);
+	while ($row=$q->fetch_assoc()) {
+		var_dump($row);
+		if (isset($_GET['go']))
+			sync::_action('customer', 'pd', 'osync', 'customer', $row['id_customer']);
+		//break;
+	}
+}
+
+if (isset($_GET['dp'])) {
+	$sql = 'SELECT s.rowid
+		FROM llx_societe s
+		WHERE s.client > 0
+		LIMIT '.$start.','.$num;
+	echo '<p>'.$sql.'</p>';
+	$q = DB::d_select($sql);
+	$n = $q->num_rows;
+	if (isset($_GET['go']) && $n>=$num) {
+		echo '<p>Suite : <a href="?t=customer&dp&start='.($start+$num).'&num='.$num.'&go">'.($start+$num).'-'.($start+2*$num).'</a></p>';
+	}
+	while ($row=$q->fetch_assoc()) {
+		var_dump($row);
+		if (isset($_GET['go']))
+			sync::_action('customer', 'dp', 'osync', 'societe', $row['rowid']);
+		//break;
+	}
 }