diff --git a/app/CustomFuncPao.php b/app/CustomFuncPao.php
index f1546ec6..3d83fe3b 100644
--- a/app/CustomFuncPao.php
+++ b/app/CustomFuncPao.php
@@ -527,20 +527,24 @@ function setOrdine($idinternet, $mode)
{
try {
$str = "setOrdine";
- $ordine = Orderdetail::where('IdInternet', $idinternet)->get();
+ $ordini = Orderdetail::where('IdInternet', $idinternet)->get();
- if ($ordine)
- $str .= getarraystr($ordine) . "
";
+ if (!$ordini->isEmpty()) {
+ $ordine = $ordini[0];
- $prodotto = Product::where('sku', $ordine["CodArticoloGM"])->first();
+ if ($ordine)
+ $str .= getarraystr($ordine) . "
";
- if ($prodotto)
- $str .= getarraystr($prodotto) . "
";
+ $prodotto = Product::where('sku', $ordine["CodArticoloGM"])->first();
- if ($mode === 'AAAdel' && $ordine) {
- // delete record $ordine
- $deletedCount = Orderdetail::where('IdInternet', $idinternet)->delete();
- $str .= "
Numero di record eliminati: " . $deletedCount . "";
+ if ($prodotto)
+ $str .= getarraystr($prodotto) . "
";
+
+ if ($mode === 'AAAdel' && $ordine) {
+ // delete record $ordine
+ $deletedCount = Orderdetail::where('IdInternet', $idinternet)->delete();
+ $str .= "
Numero di record eliminati: " . $deletedCount . "";
+ }
}
} catch (\Exception $e) {
$str .= "Errore: " . $e->getMessage();