瀏覽代碼

Resync auto script

Mathieu Moulin 3 年之前
父節點
當前提交
1d8c14050d
共有 3 個文件被更改,包括 34 次插入2 次删除
  1. 2 1
      install/sql/_sync.sql
  2. 31 0
      src/resync/auto.inc.php
  3. 1 1
      web/resync.php

+ 2 - 1
install/sql/_sync.sql

@@ -46,7 +46,8 @@ CREATE TABLE `_sync` (
 --
 ALTER TABLE `_sync`
   ADD PRIMARY KEY (`id`),
-  ADD KEY `type` (`type`,`t_name`,`t_oid`);
+  ADD KEY `type` (`type`,`t_name`,`t_oid`),
+  ADD KEY `sync_ts` (`sync_ts`);
 
 --
 -- AUTO_INCREMENT pour les tables déchargées

+ 31 - 0
src/resync/auto.inc.php

@@ -0,0 +1,31 @@
+<?php
+
+$sql = 'SELECT s.ts, s.type, s.t_name, s.t_oid, s.action
+	FROM _sync s
+	WHERE s.sync_ts IS NULL
+		AND s.action IN ("create", "osync")
+		AND s.type NOT IN ("shipping")
+	GROUP BY s.type, s.t_name, s.t_oid, s.action
+	ORDER BY s.ts DESC';
+
+// PD
+
+echo '<h3>Presta => Doli</h3>';
+
+$q = DB::p_select($sql);
+while($row=$q->fetch_assoc()) {
+	var_dump($row);
+	if (isset($_GET['go']))
+		sync::_action($row['type'], 'pd', $row['action'], $row['t_name'], $row['t_oid']);
+}
+
+// DP
+
+echo '<h3>Doli => Presta</h3>';
+
+$q = DB::d_select($sql);
+while($row=$q->fetch_assoc()) {
+	var_dump($row);
+	if (isset($_GET['go']))
+		sync::_action($row['type'], 'dp', $row['action'], $row['t_name'], $row['t_oid']);
+}

+ 1 - 1
web/resync.php

@@ -2,7 +2,7 @@
 
 require_once "bootstrap.inc.php";
 
-$options = ['supplier', 'product', 'img', 'product_lot', 'supplier_price', 'order', 'customer', 'address', 'stock'];
+$options = ['auto', 'supplier', 'product', 'img', 'product_lot', 'supplier_price', 'order', 'customer', 'address', 'stock'];
 
 echo '<p>';
 foreach($options as $option)