This commit is contained in:
paoloar77
2024-11-28 17:14:50 +01:00
parent da4f48b83c
commit ce709a9836
3 changed files with 69 additions and 0 deletions

View File

@@ -70,6 +70,20 @@ class ArticleController extends Controller
}
}
public function test(Request $request)
{
try {
$articoli = $this->queryTest();
return view('article_test', ['articoli' => $$articoli]);
} catch (\Exception $e) {
// Potresti considerare di registrare l'errore per debugging
return new Response('Error exporting articles: ' . $e->getMessage(), 500);
}
}
public function exportArticlesSales(Request $request): Response
{
try {
@@ -133,4 +147,19 @@ class ArticleController extends Controller
return new Response('Error exporting articles: ' . $e->getMessage(), 500);
}
}
private function queryTest(): \Response
{
try {
$duplicati = DB::table('T_WEB_Articoli')
->select('idArticolo', 'Titolo', 'DataPubblicazione', 'Ean13', DB::raw('count(*) as total'))
->groupBy('idArticolo', 'Titolo', 'DataPubblicazione', 'Ean13')
->having('total', '>', 1) // Cerca solo i duplicati
->get();
$response->setContent($duplicati);
return $response;
} catch (\Exception $e) {
return new Response('Error exporting articles: ' . $e->getMessage(), 500);
}
}

View File

@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Articoli </title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div class="container mt-4">
<h1 class="mb-4">Articoli </h1>
<table class="table table-bordered">
<tbody>
<!--<pre>{{ print_r($articoliVenduti, true) }}</pre>-->
@if ($articoliVenduti->isEmpty())
<tr>
<td colspan="6" class="text-center">Nessun articolo trovato.</td>
</tr>
@else
@foreach ($articoli as $articolo)
@if (isset($articolo->idArticolo))
<tr>
<td>{{ $articolo->idArticolo }}</td>
<td>{{ $articolo->Titolo }}</td>
<td>{{ \Carbon\Carbon::parse($articolo->DataPubblicazione)->format('d/m/Y') }}</td>
<td>{{ $articolo->totaleVenduto }}</td>
</tr>
@endif
@endforeach
@endif
</tbody>
</table>
</div>
</body>
</html>

View File

@@ -6407,3 +6407,4 @@ Route::get('/export-articles-sales', [ArticleController::class, 'exportArticlesS
Route::get('/export-articles-sales-json', [ArticleController::class, 'exportArticlesSalesByJSON']);
Route::get('/view-articles-sales', [ArticleController::class, 'showArticlesSales']);
Route::get('/article-test', [ArticleController::class, 'test']);