aggio
This commit is contained in:
@@ -477,6 +477,59 @@ function loadArticleByIdArticle($id, $checkprevendita = false, $checkqtanegativa
|
||||
}
|
||||
}
|
||||
|
||||
function loadArticleByISBN($isbn, $checkprevendita = false, $checkqtanegativa = false)
|
||||
{
|
||||
|
||||
try {
|
||||
$articles = Article::join(DB::raw('(SELECT IdArticolo, MAX(DataOra) AS data FROM T_WEB_Articoli GROUP BY IdArticolo) b'), function ($join) {
|
||||
$join->on('T_WEB_Articoli.IdArticolo', '=', 'b.IdArticolo')
|
||||
->on('T_WEB_Articoli.DataOra', '=', 'b.data');
|
||||
})
|
||||
->leftJoin(DB::raw('(SELECT e.IdStatoProdotto, e.Descrizione as DescrizioneStatoProdotto FROM T_WEB_StatiProdotto e JOIN (SELECT IdStatoProdotto, MAX(DataOra) as data1 from T_WEB_StatiProdotto GROUP BY IdStatoProdotto) c ON e.IdStatoProdotto = c.IdStatoProdotto AND e.DataOra = c.data1 ) f'), function ($join) {
|
||||
$join->on('T_WEB_Articoli.IdStatoProdotto', '=', 'f.IdStatoProdotto');
|
||||
})
|
||||
->leftJoin(DB::raw('(SELECT o.Codice, o.QtaDisponibile FROM T_WEB_Disponibile o JOIN (SELECT Codice, MAX(DataOra) as data1 from T_WEB_Disponibile GROUP BY Codice) p ON o.Codice = p.Codice AND o.DataOra = p.data1 ) q'), function ($join) {
|
||||
$join->on('T_WEB_Articoli.IdArticolo', '=', 'q.Codice');
|
||||
})
|
||||
->where('T_WEB_Articoli.Ean13', $isbn)
|
||||
->get();
|
||||
|
||||
if ($checkprevendita) {
|
||||
foreach ($articles as $article) {
|
||||
$qtaneg = $article->QtaDisponibile < 0;
|
||||
$inprevendita = false;
|
||||
if ($article) {
|
||||
$inprevendita = ($article->DescrizioneStatoProdotto === 'In prevendita');
|
||||
if ($checkqtanegativa) {
|
||||
$inprevendita = $inprevendita && $qtaneg;
|
||||
}
|
||||
}
|
||||
if ($inprevendita) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
$ris = 'Articles ISBN ' . $isbn . ' :' . PHP_EOL;
|
||||
$ris .= getarraystr($articles); // Converte solo i dati specificati in JSON
|
||||
|
||||
try {
|
||||
$product = Product::where('sku', $isbn)->first();
|
||||
|
||||
$ris .= 'Product:' . PHP_EOL;
|
||||
$ris .= getarraystr($product);
|
||||
} catch (\Exception $e) {
|
||||
$ris .= "!!! Errore loadArticleByISBN Product: " . $e->getMessage();
|
||||
}
|
||||
|
||||
return $ris;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
return "Errore loadArticleByISBN: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function showTest()
|
||||
@@ -499,10 +552,8 @@ function showTest()
|
||||
|
||||
if (isset($product))
|
||||
$mystr .= response()->json($product);
|
||||
|
||||
}
|
||||
return $mystr;
|
||||
|
||||
}
|
||||
function showOrdini()
|
||||
{
|
||||
@@ -2073,4 +2124,3 @@ function getvalstr($mystr, $value, $separato = false)
|
||||
|
||||
return $my;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<body>
|
||||
<h1>Links</h1>
|
||||
<form id="articleForm">
|
||||
<pre>
|
||||
<pre>
|
||||
Per vedere la lista -> "LIBRI IN PREVENDITA"
|
||||
in <span style="color: green;">VERDE</span> quelli in PreOrdine
|
||||
in <span style="color: red;">ROSSO</span> quelli ancora non abilitati.
|
||||
@@ -46,6 +46,7 @@
|
||||
<input type="text" id="action" name="action" value="{{$action}}" hidden />
|
||||
<br>
|
||||
<button type="button" data-action="search">Cerca Articolo</button>
|
||||
<button type="button" data-action="search_isbn">Cerca ISBN</button>
|
||||
<button type="button" data-action="updateArtFromGM">Aggiorna Articolo da GM</button>
|
||||
<button type="button" data-action="checkPrevendita">E' in PreVendita?</button>
|
||||
<button type="button" data-action="setPreOrder">Impostalo in PreVendita!</button>
|
||||
|
||||
@@ -6350,6 +6350,9 @@ Route::get('/handle-article-action-pao/{id}/{action}', function ($id, $action) {
|
||||
if ($action == 'search') {
|
||||
// Logica di ricerca dell'articolo
|
||||
return loadArticleByIdArticle($id);
|
||||
if ($action == 'search_isbn') {
|
||||
// Logica di ricerca dell'articolo
|
||||
return loadArticleByISBN($id);
|
||||
} elseif ($action == 'updateArtFromGM') {
|
||||
return updateArticoloFromGM($id);
|
||||
} elseif ($action == 'inprevendita') {
|
||||
|
||||
Reference in New Issue
Block a user