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()
|
function showTest()
|
||||||
@@ -488,7 +541,7 @@ function showTest()
|
|||||||
try {
|
try {
|
||||||
// $products = WooCommerce::get('products', ['sku' => $sku]);
|
// $products = WooCommerce::get('products', ['sku' => $sku]);
|
||||||
$product = Product::where('sku', $sku)->first();
|
$product = Product::where('sku', $sku)->first();
|
||||||
|
|
||||||
// Verifica se ci sono prodotti trovati
|
// Verifica se ci sono prodotti trovati
|
||||||
$mystr .= response()->json($product); // Restituisce il primo prodotto
|
$mystr .= response()->json($product); // Restituisce il primo prodotto
|
||||||
// print_r($product);
|
// print_r($product);
|
||||||
@@ -499,10 +552,8 @@ function showTest()
|
|||||||
|
|
||||||
if (isset($product))
|
if (isset($product))
|
||||||
$mystr .= response()->json($product);
|
$mystr .= response()->json($product);
|
||||||
|
|
||||||
}
|
}
|
||||||
return $mystr;
|
return $mystr;
|
||||||
|
|
||||||
}
|
}
|
||||||
function showOrdini()
|
function showOrdini()
|
||||||
{
|
{
|
||||||
@@ -2073,4 +2124,3 @@ function getvalstr($mystr, $value, $separato = false)
|
|||||||
|
|
||||||
return $my;
|
return $my;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<h1>Links</h1>
|
<h1>Links</h1>
|
||||||
<form id="articleForm">
|
<form id="articleForm">
|
||||||
<pre>
|
<pre>
|
||||||
Per vedere la lista -> "LIBRI IN PREVENDITA"
|
Per vedere la lista -> "LIBRI IN PREVENDITA"
|
||||||
in <span style="color: green;">VERDE</span> quelli in PreOrdine
|
in <span style="color: green;">VERDE</span> quelli in PreOrdine
|
||||||
in <span style="color: red;">ROSSO</span> quelli ancora non abilitati.
|
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 />
|
<input type="text" id="action" name="action" value="{{$action}}" hidden />
|
||||||
<br>
|
<br>
|
||||||
<button type="button" data-action="search">Cerca Articolo</button>
|
<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="updateArtFromGM">Aggiorna Articolo da GM</button>
|
||||||
<button type="button" data-action="checkPrevendita">E' in PreVendita?</button>
|
<button type="button" data-action="checkPrevendita">E' in PreVendita?</button>
|
||||||
<button type="button" data-action="setPreOrder">Impostalo 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') {
|
if ($action == 'search') {
|
||||||
// Logica di ricerca dell'articolo
|
// Logica di ricerca dell'articolo
|
||||||
return loadArticleByIdArticle($id);
|
return loadArticleByIdArticle($id);
|
||||||
|
if ($action == 'search_isbn') {
|
||||||
|
// Logica di ricerca dell'articolo
|
||||||
|
return loadArticleByISBN($id);
|
||||||
} elseif ($action == 'updateArtFromGM') {
|
} elseif ($action == 'updateArtFromGM') {
|
||||||
return updateArticoloFromGM($id);
|
return updateArticoloFromGM($id);
|
||||||
} elseif ($action == 'inprevendita') {
|
} elseif ($action == 'inprevendita') {
|
||||||
|
|||||||
Reference in New Issue
Block a user