diff --git a/app/Http/Controllers/ArticleController.php b/app/Http/Controllers/ArticleController.php index 1ac2040d..322e0d80 100755 --- a/app/Http/Controllers/ArticleController.php +++ b/app/Http/Controllers/ArticleController.php @@ -275,7 +275,7 @@ class ArticleController extends Controller DB::raw('COALESCE(u.totFat, 0) as totFat'), DB::raw('COALESCE(p.venduti3mesi, 0) as venduti3mesi'), DB::raw('COALESCE(t.fat3mesi, 0) as fat3mesi'), - DB::raw('COALESCE(t2.fat6mesi, 0) as fat6mesi'), + DB::raw('COALESCE(t.fat6mesi, 0) as fat6mesi'), DB::raw('COALESCE(p.rank3M, 0) as rank3M'), DB::raw('COALESCE(t.fatrank3M, 0) as fatrank3M'), DB::raw('COALESCE(t2.fatrank6M, 0) as fatrank6M'), @@ -298,12 +298,11 @@ class ArticleController extends Controller } catch (\Exception $e) { // Registrazione dell'errore - echo "Errore: " . $e->getMessage(); return response()->json(['error' => 'Si รจ verificato un errore durante il recupero dei dati: ' . $e->getMessage()], 500); } // Restituisci una risposta JSON con i dati - return response()->json(['data' => $articoliVenduti]); + return $articoliVenduti; } private function queryArticlesFatturati() @@ -568,44 +567,13 @@ class ArticleController extends Controller $articoliVenduti = $this->queryArticlesFatturati(); } else { $articoliVenduti = $this->queryArticlesSales(); - // ritorna response()->json(['data' => $articoliVenduti]); } - if (true) { - echo $articoliVenduti; - echo ''; - echo ''; - foreach ($articoliVenduti as $articolo) { - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - } - echo '
IdArticoloTitoloDataPubblicazioneISBNIdCollanaDescrizioneCollanaDescrArgomentoListaArgomentiPagineIdTipoFormatoMisuretotVentotFatrank3Mfatrank3Mfatrank6Mrank6M
' . htmlspecialchars($articolo->IdArticolo) . '' . htmlspecialchars($articolo->Titolo) . '' . htmlspecialchars($articolo->DataPubblicazione) . '' . htmlspecialchars($articolo->Ean13) . '' . htmlspecialchars($articolo->IdCollana) . '' . htmlspecialchars($articolo->DescrizioneCollana) . '' . htmlspecialchars($articolo->DescrArgomento) . '' . htmlspecialchars($articolo->ListaArgomenti) . '' . htmlspecialchars($articolo->Pagine) . '' . htmlspecialchars($articolo->IdTipoFormato) . '' . htmlspecialchars($articolo->Misure) . '' . htmlspecialchars($articolo->totVen) . '' . htmlspecialchars($articolo->totFat) . '' . htmlspecialchars($articolo->rank3M) . '' . htmlspecialchars($articolo->fatrank3M) . '' . htmlspecialchars($articolo->fatrank6M) . '' . htmlspecialchars($articolo->rank6M) . '
'; - } - - if ($articoliVenduti->isEmpty()) { return response()->json(['message' => 'Nessun articolo trovato.'], 404); } else { - // Mappa i risultati nella struttura JSON desiderata - $result = collect($articoliVenduti)->map(function ($articoloVenduto) { + $result = $articoliVenduti->map(function ($articoloVenduto) { return [ 'IdArticolo' => $articoloVenduto->IdArticolo, 'title' => $articoloVenduto->Titolo,