diff --git a/app/CustomFuncPao.php b/app/CustomFuncPao.php index 1e101360..b3d49ada 100644 --- a/app/CustomFuncPao.php +++ b/app/CustomFuncPao.php @@ -472,57 +472,25 @@ function loadArticleByIdArticle($id, $checkprevendita = false, $checkqtanegativa } } + function showOrdini() { - $str = ""; - - try { + $baseUrl = request()->root(); - // $str = Schema::getColumnListing('Orderdetails'); - - $orders = Orderdetail::orderBy('DataOra', 'desc') + $orders = Orderdetail::with(['product' => function($query) { + $query->select('sku', 'name', 'permalink'); + }]) + ->select('Codice', 'DataOra', 'IdInternet', 'CodArticoloGM', 'PrezzoLordo', 'Qta', 'PercSconto', 'Descrizione') + ->orderBy('DataOra', 'desc') ->take(5) ->get(); - $sep = ""; - - $baseUrl = Request::root(); // URL di base (dominio) - - // Show the fields of the orders - foreach ($orders as $order) { - $product = Product::where('sku', $order->CodArticoloGM)->first(); - - if ($product) - $titolo = "" . $product['name'] . ""; - else - $titolo = ""; - - $str .= getvalstr("", $order->Codice) . " "; - $str .= getvalstr("", $order->DataOra); - $str .= getvalstr("", $titolo); - $str .= getvalstr("Ordine", $order->IdInternet, true) . " "; - $str .= getvalstr("Articolo", $order->CodArticoloGM, true); - $str .= getvalstr("Prezzo", $order->PrezzoLordo); - $str .= getvalstr("Quantità", $order->Qta); - if ($order->PercSconto) - $str .= getvalstr("Sconto", $order->PercSconto); - if ($order->Descrizione) - $str .= getvalstr("Descr", $order->Descrizione); - - $str .= 'ELIMINA!' . $sep; - - // $str .= getarraystr($product) . "
"; - // $str .= $product; - $str .= '
'; - } + return view('ordini', compact('orders', 'baseUrl'))->render(); } catch (\Exception $e) { return "Errore: " . $e->getMessage(); } - - return $str; } - function setOrdine($idinternet, $mode) { $str = ""; diff --git a/resources/views/ordini.blade.php b/resources/views/ordini.blade.php new file mode 100644 index 00000000..95163523 --- /dev/null +++ b/resources/views/ordini.blade.php @@ -0,0 +1,25 @@ +@foreach($orders as $order) + @php + $product = $order->product; + $titolo = $product + ? "{$product->name}" + : ""; + @endphp + + {{ getvalstr("", $order->Codice) }} + {{ getvalstr("", $order->DataOra) }} + {{ getvalstr("", $titolo) }} + {{ getvalstr("Ordine", $order->IdInternet, true) }} + {{ getvalstr("Articolo", $order->CodArticoloGM, true) }} + {{ getvalstr("Prezzo", $order->PrezzoLordo) }} + {{ getvalstr("Quantità", $order->Qta) }} + @if($order->PercSconto) + {{ getvalstr("Sconto", $order->PercSconto) }} + @endif + @if($order->Descrizione) + {{ getvalstr("Descr", $order->Descrizione) }} + @endif + + ELIMINA! +
+@endforeach \ No newline at end of file