first commit

This commit is contained in:
2025-08-02 16:30:27 +02:00
commit 23646bfcee
14851 changed files with 1750626 additions and 0 deletions

139
web/abra.php Normal file
View File

@@ -0,0 +1,139 @@
<?php
while (ob_get_level()) {
ob_end_flush();
}
if (!findModule('abra')) {
redirection('INDEX');
}
if (strpos(findModule('abra', 'server'), 'zeleza') !== false
|| strpos(findModule('abra', 'server'), 'naho') !== false
|| strpos(findModule('abra', 'server'), 'horava') !== false
|| findModule('abra', 'type') == 'classic'
) {
$abra = new Abra($cfg['Modules']['abra']);
} else {
$abra = new AbraElnino($cfg['Modules']['abra']);
}
if (getVal('monitoring')) {
$orders = $abra->getOrdersToSync()->select('COUNT(*)')->execute()->fetchOne();
try {
$products = $abra->getClient()->weGetChangesCount() / 1000;
} catch (\Throwable $e) {
$products = 999;
}
echo max($orders, $products);
exit;
}
?>
<!DOCTYPE PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<?php
if ($order_id = getVal('sync_order')) {
$abra->syncOrder($order_id);
exit;
}
if ($order_id = getVal('dump_order')) {
var_dump($abra->getOrder($order_id));
exit;
}
if (getVal('fix_titles')) {
$abra->fixProductsTitles();
exit;
}
if (getVal('peek')) {
$abra->getClient()->weGetChanges(0, getVal('peek', null, 500));
$abra->printTrace();
exit;
}
if (getVal('updateScheduledProducts')) {
ob_implicit_flush();
$delayedCount = 1;
$counter = 1;
while ($delayedCount > 0 && $counter <= getVal('limit', null, 100)) {
$delayedCount = sqlQueryBuilder()->select('COUNT(*)')->from('abra_delayed_update')->execute()->fetchColumn(0);
echo PHP_EOL.'<br/>'.PHP_EOL.'run # '.$counter.', rows in abra_delayed_update: '.$delayedCount.' ';
@ob_flush();
flush();
if ($delayedCount > 0) {
$abra->updateScheduledProducts();
}
echo ' [OK]'.PHP_EOL.'<br/>'.PHP_EOL;
$counter++;
}
exit;
}
if (getVal('replay')) {
$type = getVal('type', null, 'abra');
if (isset($_POST['changes'])) {
$changes = explode("\n", $_POST['changes']);
foreach ($changes as $change) {
$change = trim($change);
switch ($type) {
case 'abra':
$body = new stdClass();
$body->data = $change;
break;
case 'claims':
$body = json_decode($change);
break;
}
$abra->{"process_message_{$type}"}($body);
}
$abra->updateScheduledProducts();
} ?>
<form action="" method="post">
<label for="changes">Změny k importu</label><br>
<textarea id="changes" rows="30" cols="100" name="changes"><?php echo htmlentities($_POST['changes'] ?? ''); ?></textarea><br>
<label for="type">Typ změny</label><br>
<select id="type" name="type">
<option value="abra" <?php if ($type == 'abra') { ?>selected<?php } ?>>Abra</option>
<option value="claims" <?php if ($type == 'claims') { ?>selected<?php } ?>>Reklamace</option>
</select>
<input type="submit">
<br>
Příklady
<pre>
Elnino:
3003835857~|~StoreCard~|~Quantity~|~40314~|~0~|~1~|~all~|~all
NE-Elnino:
6355723~|~StoreCard~|~PriceWithVAT~|~QP3A000101~|~5950~|~HL-CZK
6355734~|~StoreCard~|~Quantity~|~ND0A000101~|~1~|~01
</pre>
</form>
<?php
exit;
}
if (isset($_GET['sync_translations'])) {
$abra->syncTranslations(getVal('sync_translations'), $_GET);
exit;
}
if (isset($_GET['sync_all'])) {
$abra->getAllData(getVal('sync_all'), $_GET);
} elseif (getVal('loop')) {
$abra->loopSychronization(getVal('loop'));
} else {
$abra->sync();
}