浏览代码

Merge branch 'master' of https://gogs.iprospective.fr/iProspective/erp-sync

Mathieu Moulin 1 年之前
父节点
当前提交
59276a8b87
共有 3 个文件被更改,包括 50 次插入17 次删除
  1. 35 9
      src/install/customer.inc.php
  2. 14 5
      src/repair/stock.inc.php
  3. 1 3
      web/repair.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;
+	}
 }

+ 14 - 5
src/repair/stock.inc.php

@@ -3,10 +3,13 @@
 // Stock supprimé P=>D
 
 if (isset($_GET['deleted'])) {
-	$sql = 'SELECT p.rowid k_product
+	// Produits sans lots stockables
+	$sql = 'SELECT p.rowid k_product, p.ref, p.label, p.fk_default_warehouse
 		FROM llx_product p
 		LEFT JOIN llx_product_stock s ON s.fk_product=p.rowid AND s.fk_entrepot=1
-		WHERE s.rowid IS NULL';
+		WHERE s.rowid IS NULL
+			AND p.tobatch=0
+			AND (p.fk_product_type=0 OR p.stockable_product=1)';
 	$q = DB::d_select($sql);
 	while ($row=$q->fetch_assoc()) {
 		var_dump($row);
@@ -38,15 +41,21 @@ if (isset($_GET['deleted'])) {
 						(rowid, tms, fk_product, fk_entrepot, reel, import_key)
 						VALUES
 						('.$o['d_oid'].', NOW(), '.$row['k_product'].', 1, 0, NULL)';
-					if (isset($_GET['go']))
-						DB::d_insert($sql);
+					if (isset($_GET['go'])) {
+						$ret = DB::d_insert($sql);
+						var_dump($ret);
+					}
 					else
 						echo '<p>'.$sql.'</p>';
 				}
+				else {
+					// @todo Création emplacement de stock standard depuis presta en utilisant l'emplacement de stock par defaut
+					echo '<p>Création emplacement de stock standard depuis presta ?</p>';
+				}
 			}
 		}
 		else {
-			echo '<p>ERREUR MANQUE CORRESPONDANCE LOT</p>';
+			echo '<p>ERREUR MANQUE CORRESPONDANCE LOT : '.$row['ref'].' '.$row['label'].'</p>';
 		}
 	}
 }

+ 1 - 3
web/repair.php

@@ -3,7 +3,5 @@
 require_once "bootstrap.inc.php";
 
 $inc_context = 'repair';
-$inc_options = ['supplier', 'product', 'img', 'product_lot', 'supplier_price', 'order', 'customer', 'address', 'shipping', 'invoice'];
+$inc_options = ['supplier', 'product', 'stock', 'img', 'product_lot', 'supplier_price', 'order', 'customer', 'address', 'shipping', 'invoice'];
 require_once "context_include.inc.php";
-
-$options = ['supplier', 'product', 'img', 'product_lot', 'supplier_price', 'order', 'customer', 'address', 'shipping', 'invoice'];