aa
This commit is contained in:
@@ -11,6 +11,16 @@ use App\Article;
|
||||
|
||||
class ArticleController extends Controller
|
||||
{
|
||||
private function queryTest(){
|
||||
$articoli = DB::table('T_WEB_Articoli as A')
|
||||
->leftJoin(DB::raw('(SELECT CodArticoloGM, SUM(Qta) as totaleVenduti FROM T_WEB_Ordini GROUP BY CodArticoloGM) O'), 'A.IdArticolo', '=', 'O.CodArticoloGM')
|
||||
->select('A.IdArticolo', 'A.Descrizione', DB::raw('COALESCE(O.totaleVenduti, 0) as totaleVenduti'))
|
||||
->orderBy('totaleVenduti', 'desc')
|
||||
->get();
|
||||
|
||||
return $articoli;
|
||||
|
||||
}
|
||||
private function queryArticlesSales()
|
||||
{
|
||||
try {
|
||||
@@ -69,7 +79,8 @@ class ArticleController extends Controller
|
||||
)
|
||||
->where('DescrizioneStatoProdotto', 'In commercio')
|
||||
->where('DescrizioneTipologia', 'Libri')
|
||||
->orderBy('rank1Y', 'asc')
|
||||
//->orderBy('rank1Y', 'asc')
|
||||
->orderBy('totaleVenduti', 'desc')
|
||||
->get();
|
||||
|
||||
if ($articoliVenduti->isEmpty()) {
|
||||
@@ -99,6 +110,20 @@ class ArticleController extends Controller
|
||||
|
||||
}
|
||||
}
|
||||
public function showtest(Request $request)
|
||||
{
|
||||
try {
|
||||
|
||||
$articoliVenduti = $this->queryTest();
|
||||
|
||||
return view('export_articles_test', ['articoli' => $articoliVenduti]);
|
||||
|
||||
} 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 {
|
||||
|
||||
25
resources/views/export_articles_test.blade.php
Normal file
25
resources/views/export_articles_test.blade.php
Normal file
@@ -0,0 +1,25 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<h1>Totale Vendite per Articolo</h1>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID Articolo</th>
|
||||
<th>Descrizione</th>
|
||||
<th>Totale Venduti</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($articoliVenduti as $articolo)
|
||||
<tr>
|
||||
<td>{{ $articolo->IdArticolo }}</td>
|
||||
<td>{{ $articolo->Descrizione }}</td>
|
||||
<td>{{ number_format($articolo->totaleVenduti, 0, ',', '.') }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -6466,4 +6466,5 @@ 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('/view-articles-test', [ArticleController::class, 'showtest']);
|
||||
Route::get('/article-test', [ArticleController::class, 'test']);
|
||||
|
||||
Reference in New Issue
Block a user