mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2025-01-13 23:31:13 +01:00
class.remote.php sendlist changed to work on arrays
This commit is contained in:
parent
d0d9c4150b
commit
01561960ec
@ -1935,10 +1935,10 @@ class Remote {
|
|||||||
// Bulk transfer (new 2024-06-28)
|
// Bulk transfer (new 2024-06-28)
|
||||||
$result = null;
|
$result = null;
|
||||||
if (!empty($lagerexport)) {
|
if (!empty($lagerexport)) {
|
||||||
$result = $this->sendlistlager($i, $id, $data);
|
$result = $this->sendlistlager($id, $data);
|
||||||
}
|
}
|
||||||
if (!empty($artikelexport) && !$nurlager) {
|
if (!empty($artikelexport) && !$nurlager) {
|
||||||
$result = $this->sendlist($i, $id, $data, true);
|
$result = $this->sendlist($id, $data, true);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@ -2061,10 +2061,10 @@ class Remote {
|
|||||||
// Bulk transfer (new 2024-06-28)
|
// Bulk transfer (new 2024-06-28)
|
||||||
$result = null;
|
$result = null;
|
||||||
if (!empty($lagerexport)) {
|
if (!empty($lagerexport)) {
|
||||||
$result = $this->sendlistlager($i, $id, $data);
|
$result = $this->sendlistlager($id, $data);
|
||||||
}
|
}
|
||||||
if (!empty($artikelexport) && !$nurlager) {
|
if (!empty($artikelexport) && !$nurlager) {
|
||||||
$result = $this->sendlist($i, $id, $data, true);
|
$result = $this->sendlist($id, $data, true);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@ -2085,33 +2085,27 @@ class Remote {
|
|||||||
return $this->app->DB->SelectArr($query);
|
return $this->app->DB->SelectArr($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function sendlistlager($i, $id, $data) {
|
protected function sendlistlager(int $shop_id, array $data) {
|
||||||
$data2 = $data;
|
$result = $this->RemoteCommand($shop_id, 'sendlistlager', $data);
|
||||||
foreach ($data2 as $key => $value) {
|
|
||||||
$data2[$key]['artikel'] = $value['artikelid'];
|
|
||||||
}
|
|
||||||
$result = $this->RemoteCommand($id, 'sendlistlager', $data2);
|
|
||||||
$this->app->DB->Update(
|
|
||||||
sprintf(
|
|
||||||
'UPDATE artikel_onlineshops SET last_storage_transfer = NOW() WHERE artikel = %d AND shop = %d',
|
|
||||||
$data2[$i]['artikel'], $id
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function sendlist($i, $id, $data, $isLagerExported) {
|
protected function sendlist(int $shop_id, array $data, $isLagerExported) {
|
||||||
|
|
||||||
|
// See description of return format in function RemoteSendArticleList()
|
||||||
|
$result = $this->RemoteCommand($shop_id, 'sendlist', $data);
|
||||||
|
|
||||||
|
if (!empty($result) && is_array($result)) {
|
||||||
|
foreach ($result['articles'] as $artikelid) {
|
||||||
/** @var Shopexport $objShopexport */
|
/** @var Shopexport $objShopexport */
|
||||||
$objShopexport = $this->app->loadModule('shopexport');
|
$objShopexport = $this->app->loadModule('shopexport');
|
||||||
$changedHash = $objShopexport->hasArticleHashChanged($data[0]['artikel'], $id);
|
$changedHash = $objShopexport->hasArticleHashChanged($artikelid, $shop_id);
|
||||||
$hash = $changedHash['hash'];
|
$hash = $changedHash['hash'];
|
||||||
//$changedHash = $changedHash['changed'];
|
|
||||||
|
|
||||||
$result = $this->RemoteCommand($id, 'sendlist', $data);
|
|
||||||
$checkAo = $this->app->DB->Select(
|
$checkAo = $this->app->DB->Select(
|
||||||
sprintf(
|
sprintf(
|
||||||
'SELECT id FROM artikel_onlineshops WHERE artikel = %d AND shop=%d LIMIT 1',
|
'SELECT id FROM artikel_onlineshops WHERE artikel = %d AND shop=%d LIMIT 1',
|
||||||
$data[0]['artikel'], $id
|
$artikelid, $shop_id
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if (empty($checkAo)) {
|
if (empty($checkAo)) {
|
||||||
@ -2119,7 +2113,7 @@ class Remote {
|
|||||||
sprintf(
|
sprintf(
|
||||||
'INSERT INTO artikel_onlineshops (artikel, shop, aktiv, ausartikel)
|
'INSERT INTO artikel_onlineshops (artikel, shop, aktiv, ausartikel)
|
||||||
VALUES (%d, %d, 1, 1) ',
|
VALUES (%d, %d, 1, 1) ',
|
||||||
$data[0]['artikel'], $id
|
$artikelid, $shop_id
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -2128,23 +2122,24 @@ class Remote {
|
|||||||
"UPDATE artikel_onlineshops
|
"UPDATE artikel_onlineshops
|
||||||
SET last_article_transfer = NOW(), last_article_hash = '%s'
|
SET last_article_transfer = NOW(), last_article_hash = '%s'
|
||||||
WHERE artikel = %d AND shop = %d",
|
WHERE artikel = %d AND shop = %d",
|
||||||
$this->app->DB->real_escape_string($hash), $data[0]['artikel'], $id
|
$this->app->DB->real_escape_string($hash), $artikelid, $shop_id
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// See description of return format in function RemoteSendArticleList()
|
if (!empty($result) && is_array($result)) {
|
||||||
if (!empty($result) && is_array($result) && !empty($result['new'])) {
|
|
||||||
foreach ($result['new'] as $artikelid => $fremdnummer) {
|
foreach ($result['new'] as $artikelid => $fremdnummer) {
|
||||||
$artikelid = (int) $artikelid;
|
$artikelid = (int) $artikelid;
|
||||||
$artikelnummer = $this->app->DB->Select("SELECT nummer FROM artikel WHERE id = '$artikelid' LIMIT 1");
|
$artikelnummer = $this->app->DB->Select("SELECT nummer FROM artikel WHERE id = '$artikelid' LIMIT 1");
|
||||||
if ($artikelid > 0 && $artikelnummer != trim($fremdnummer) &&
|
if ($artikelid > 0 && $artikelnummer != trim($fremdnummer) &&
|
||||||
($this->app->DB->Select("SELECT id FROM artikel WHERE id = '$artikelid' AND (shop = '$id' OR shop2 = '$id' OR shop3 = '$id') LIMIT 1") ||
|
($this->app->DB->Select("SELECT id FROM artikel WHERE id = '$artikelid' AND (shop = '$shop_id' OR shop2 = '$shop_id' OR shop3 = '$shop_id') LIMIT 1") ||
|
||||||
$this->app->DB->Select("SELECT id FROM artikel_onlineshops WHERE artikel = '$artikelid' AND aktiv = 1")
|
$this->app->DB->Select("SELECT id FROM artikel_onlineshops WHERE artikel = '$artikelid' AND aktiv = 1")
|
||||||
) && trim($fremdnummer) !== '') {
|
) && trim($fremdnummer) !== '') {
|
||||||
//Nur falls Artikel zum Shop passt und keine aktive Fremdnummer exisitert.
|
//Nur falls Artikel zum Shop passt und keine aktive Fremdnummer exisitert.
|
||||||
if (!$this->app->DB->Select("SELECT id FROM `artikelnummer_fremdnummern` WHERE artikel = '$artikelid' AND shopid = '$id' AND nummer <> '' AND (aktiv = 1 OR nummer = '" . trim($this->app->DB->real_escape_string($fremdnummer)) . "') LIMIT 1 ")) {
|
if (!$this->app->DB->Select("SELECT id FROM `artikelnummer_fremdnummern` WHERE artikel = '$artikelid' AND shopid = '$shop_id' AND nummer <> '' AND (aktiv = 1 OR nummer = '" . trim($this->app->DB->real_escape_string($fremdnummer)) . "') LIMIT 1 ")) {
|
||||||
$this->app->DB->Insert("INSERT INTO `artikelnummer_fremdnummern` (artikel, bezeichnung, nummer, shopid, bearbeiter, zeitstempel, aktiv)
|
$this->app->DB->Insert("INSERT INTO `artikelnummer_fremdnummern` (artikel, bezeichnung, nummer, shopid, bearbeiter, zeitstempel, aktiv)
|
||||||
VALUES ('$artikelid','Erstellt durch Artikelexport','" . trim($this->app->DB->real_escape_string($fremdnummer)) . "','$id','" . ((isset($this->app->User) && method_exists($this->app->User, 'GetName')) ? $this->app->DB->real_escape_string($this->app->User->GetName()) : 'Cronjob') . "',now(),0)
|
VALUES ('$artikelid','Erstellt durch Artikelexport','" . trim($this->app->DB->real_escape_string($fremdnummer)) . "','$shop_id','" . ((isset($this->app->User) && method_exists($this->app->User, 'GetName')) ? $this->app->DB->real_escape_string($this->app->User->GetName()) : 'Cronjob') . "',now(),0)
|
||||||
");
|
");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2153,8 +2148,9 @@ class Remote {
|
|||||||
$result['count'] = $result['anzahl'];
|
$result['count'] = $result['anzahl'];
|
||||||
}//Altes Verhalten
|
}//Altes Verhalten
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$isLagerExported) {
|
if (!$isLagerExported) {
|
||||||
$this->sendlistlager($i, $id, $data);
|
$this->sendlistlager($shop_id, $data);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user