From ceacf59278a59f103297efa332363ca8e1698f98 Mon Sep 17 00:00:00 2001 From: paoloar77 Date: Wed, 18 Dec 2024 08:20:00 +0100 Subject: [PATCH] ArticoliFatturati --- app/ArticoliFatturati.php | 16 +++++++ app/CustomFuncPao.php | 64 +++++++++++++++++++++++++++- resources/views/mylinkspao.blade.php | 6 +++ routes/web.php | 2 + 4 files changed, 86 insertions(+), 2 deletions(-) create mode 100755 app/ArticoliFatturati.php diff --git a/app/ArticoliFatturati.php b/app/ArticoliFatturati.php new file mode 100755 index 00000000..bb64b770 --- /dev/null +++ b/app/ArticoliFatturati.php @@ -0,0 +1,16 @@ +take(5) ->get(); @@ -676,6 +674,64 @@ function showOrdiniWeb() return $str; } +function showArticoliFatturatiWeb() +{ + $str = ""; + + try { + + $orders = ArticoliFatturati::orderBy('DataOra', 'desc') + ->take(10) + ->get(); + + $sep = ""; + + $baseUrl = Request::root(); // URL di base (dominio) + + // Show the fields of the orders + foreach ($orders as $order) { + $product = Product::where('sku', $order->CodArticolo)->first(); + + if (isset($product['permalink'])) { + $mylink = ""; + $finelink = ""; + } else { + $mylink = ""; + $finelink = ""; + } + + if ($product && isset($product['name'])) + $titolo = $mylink . "" . $product['name'] . "" . $finelink; + else + $titolo = ""; + + $str .= getvalstr("", $order->Codice) . " "; + $str .= getvalstr("", $order->AnnoDoc) . " "; + $str .= getvalstr("", $order->NumeroDoc) . " "; + $str .= getvalstr("", $order->TipoDoc) . " "; + $str .= getvalstr("Articolo", $order->CodArticolo, true); + $str .= getvalstr("Quantità", $order->Qta); + $str .= getvalstr("", $order->DataOra); + $str .= getvalstr("", $order->Stato); + $str .= getvalstr("", $order->Note); + $str .= getvalstr("", $titolo); + $str .= getvalstr("Ordine", $order->IdInternet, true) . " "; + if ($order->PercSconto) + $str .= getvalstr("Sconto", $order->PercSconto); + if ($order->Descrizione) + $str .= getvalstr("Descr", $order->Descrizione); + + // $str .= ' IMPOSTA IDSITO FDV' . $sep; + + $str .= '
'; + } + } catch (\Exception $e) { + return "Errore: " . $e->getMessage(); + } + + return $str; +} + function getStructTable($tableName) { $str = ''; @@ -929,6 +985,7 @@ function getRigaArticoloByArt($article, $ind, $sep) '' . $article->IdArticolo . '' . $sep . ' ' . $article->Titolo . '' . $sep . ' Pubb:' . formatDateToItalian($article->DataPubblicazione) . $sep . + $article->DescrizioneCollana . $sep . $article->DescrizioneStatoProdotto . ' (' . $article->DescrizioneFormato . ')' . $sep . '[Qta = ' . $article->QtaDisponibile . ']' . $sep . ' [' . showprice($prezzo) . ' ]' . $sep . @@ -1029,6 +1086,9 @@ function libriInPrevendita() ->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'); }) + ->leftJoin(DB::raw('(SELECT r.IdCollana, r.Descrizione as DescrizioneCollana FROM T_WEB_Collana r JOIN (SELECT IdCollana, MAX(DataOra) as data1 from T_WEB_Collana GROUP BY IdCollana) c ON r.IdCollana = c.IdCollana AND e.DataOra = c.data1 ) s'), function ($join) { + $join->on('T_WEB_Articoli.IdCollana', '=', 's.IdCollana'); + }) ->where('DescrizioneStatoProdotto', 'In prevendita') ->where(DB::raw('CONVERT(INT, QtaDisponibile)'), '<', 0) diff --git a/resources/views/mylinkspao.blade.php b/resources/views/mylinkspao.blade.php index aeff6196..7613c95f 100644 --- a/resources/views/mylinkspao.blade.php +++ b/resources/views/mylinkspao.blade.php @@ -61,11 +61,17 @@ + +
+ Articoli + Venduti
+ +
diff --git a/routes/web.php b/routes/web.php index 1ae7ca69..c4c53090 100644 --- a/routes/web.php +++ b/routes/web.php @@ -6430,6 +6430,8 @@ Route::get('/handle-article-action-pao/{id}/{action}', function ($id, $action) { return showTest(); } elseif ($action == 'showOrdiniWeb') { return showOrdiniWeb(); + } elseif ($action == 'showArticoliFatturatiWeb') { + return showArticoliFatturatiWeb(); } elseif ($action == 'setOrdine') { return setOrdine($id, ''); } elseif ($action == 'showDettOrdini') {