aa
This commit is contained in:
@@ -199,21 +199,12 @@ class ArticleController extends Controller
|
|||||||
->leftJoin(DB::raw('(SELECT CodArticoloGM, SUM(Qta) as totVen FROM T_WEB_Ordini GROUP BY CodArticoloGM) o'), function ($join) {
|
->leftJoin(DB::raw('(SELECT CodArticoloGM, SUM(Qta) as totVen FROM T_WEB_Ordini GROUP BY CodArticoloGM) o'), function ($join) {
|
||||||
$join->on('T_WEB_Articoli.IdArticolo', '=', 'o.CodArticoloGM');
|
$join->on('T_WEB_Articoli.IdArticolo', '=', 'o.CodArticoloGM');
|
||||||
})
|
})
|
||||||
->leftJoin(DB::raw('(SELECT CodArticolo, SUM(TRY_CAST(Qta AS INT)) as totFat FROM T_WEB_ArticoliFatturati GROUP BY CodArticolo) u'), function ($join) {
|
|
||||||
$join->on('T_WEB_Articoli.IdArticolo', '=', 'u.CodArticolo');
|
|
||||||
})
|
|
||||||
->leftJoin(DB::raw('(SELECT CodArticoloGM, SUM(Qta) as venduti3mesi, RANK() OVER (ORDER BY SUM(Qta) DESC) as rank3M
|
->leftJoin(DB::raw('(SELECT CodArticoloGM, SUM(Qta) as venduti3mesi, RANK() OVER (ORDER BY SUM(Qta) DESC) as rank3M
|
||||||
FROM T_WEB_Ordini
|
FROM T_WEB_Ordini
|
||||||
WHERE DataOra >= DATEADD(MONTH, -3, GETDATE())
|
WHERE DataOra >= DATEADD(MONTH, -3, GETDATE())
|
||||||
GROUP BY CodArticoloGM) p'), function ($join) {
|
GROUP BY CodArticoloGM) p'), function ($join) {
|
||||||
$join->on('T_WEB_Articoli.IdArticolo', '=', 'p.CodArticoloGM');
|
$join->on('T_WEB_Articoli.IdArticolo', '=', 'p.CodArticoloGM');
|
||||||
})
|
})
|
||||||
->leftJoin(DB::raw('(SELECT CodArticolo, SUM(TRY_CAST(Qta AS INT)) as fat3mesi, RANK() OVER (ORDER BY SUM(TRY_CAST(Qta AS INT)) DESC) as fatrank3M
|
|
||||||
FROM T_WEB_ArticoliFatturati
|
|
||||||
WHERE DataOra >= DATEADD(MONTH, -3, GETDATE())
|
|
||||||
GROUP BY CodArticolo) t'), function ($join) {
|
|
||||||
$join->on('T_WEB_Articoli.IdArticolo', '=', 't.CodArticolo');
|
|
||||||
})
|
|
||||||
->leftJoin(DB::raw('(SELECT CodArticoloGM, SUM(Qta) as venduti6mesi, RANK() OVER (ORDER BY SUM(Qta) DESC) as rank6M
|
->leftJoin(DB::raw('(SELECT CodArticoloGM, SUM(Qta) as venduti6mesi, RANK() OVER (ORDER BY SUM(Qta) DESC) as rank6M
|
||||||
FROM T_WEB_Ordini
|
FROM T_WEB_Ordini
|
||||||
WHERE DataOra >= DATEADD(MONTH, -6, GETDATE())
|
WHERE DataOra >= DATEADD(MONTH, -6, GETDATE())
|
||||||
@@ -231,17 +222,26 @@ class ArticleController extends Controller
|
|||||||
GROUP BY CodArticoloGM) s'), function ($join) {
|
GROUP BY CodArticoloGM) s'), function ($join) {
|
||||||
$join->on('T_WEB_Articoli.IdArticolo', '=', 's.CodArticoloGM');
|
$join->on('T_WEB_Articoli.IdArticolo', '=', 's.CodArticoloGM');
|
||||||
})
|
})
|
||||||
|
->leftJoin(DB::raw('(SELECT CodArticolo, SUM(TRY_CAST(Qta AS INT)) as fat3mesi, RANK() OVER (ORDER BY SUM(TRY_CAST(Qta AS INT)) DESC) as fatrank3M
|
||||||
|
FROM T_WEB_ArticoliFatturati
|
||||||
|
WHERE DataOra >= DATEADD(MONTH, -3, GETDATE()) AND ISNUMERIC(Qta) = 1
|
||||||
|
GROUP BY CodArticolo) t'), function ($join) {
|
||||||
|
$join->on('T_WEB_Articoli.IdArticolo', '=', 't.CodArticolo');
|
||||||
|
})
|
||||||
|
->leftJoin(DB::raw('(SELECT CodArticolo, SUM(TRY_CAST(Qta AS INT)) as totFat FROM T_WEB_ArticoliFatturati WHERE ISNUMERIC(Qta) = 1 GROUP BY CodArticolo) u'), function ($join) {
|
||||||
|
$join->on('T_WEB_Articoli.IdArticolo', '=', 'u.CodArticolo');
|
||||||
|
})
|
||||||
->select(
|
->select(
|
||||||
'T_WEB_Articoli.*',
|
'T_WEB_Articoli.*',
|
||||||
'f.DescrizioneStatoProdotto',
|
'f.DescrizioneStatoProdotto',
|
||||||
'i.DescrizioneTipologia',
|
'i.DescrizioneTipologia',
|
||||||
'n.DescrizioneFormato',
|
'n.DescrizioneFormato',
|
||||||
DB::raw('COALESCE(o.totVen, 0) as totVen'),
|
DB::raw('COALESCE(o.totVen, 0) as totVen'),
|
||||||
DB::raw('COALESCE(o.totFat, 0) as totFat'),
|
DB::raw('COALESCE(u.totFat, 0) as totFat'),
|
||||||
DB::raw('COALESCE(p.venduti3mesi, 0) as venduti3mesi'),
|
DB::raw('COALESCE(p.venduti3mesi, 0) as venduti3mesi'),
|
||||||
DB::raw('COALESCE(t.fat3mesi, 0) as fat3mesi'),
|
DB::raw('COALESCE(t.fat3mesi, 0) as fat3mesi'),
|
||||||
DB::raw('COALESCE(t.fatrank3M, 0) as fatrank3M'),
|
|
||||||
DB::raw('COALESCE(p.rank3M, 0) as rank3M'),
|
DB::raw('COALESCE(p.rank3M, 0) as rank3M'),
|
||||||
|
DB::raw('COALESCE(t.fatrank3M, 0) as fatrank3M'),
|
||||||
DB::raw('COALESCE(q.venduti6mesi, 0) as venduti6mesi'),
|
DB::raw('COALESCE(q.venduti6mesi, 0) as venduti6mesi'),
|
||||||
DB::raw('COALESCE(q.rank6M, 0) as rank6M'),
|
DB::raw('COALESCE(q.rank6M, 0) as rank6M'),
|
||||||
DB::raw('COALESCE(r.venduti1anno, 0) as venduti1anno'),
|
DB::raw('COALESCE(r.venduti1anno, 0) as venduti1anno'),
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
<th>Ult Ordi</th>
|
<th>Ult Ordi</th>
|
||||||
<th>Tot Venduti</th>
|
<th>Tot Venduti</th>
|
||||||
<th>Ult 3 Mese</th>
|
<th>Ult 3 Mese</th>
|
||||||
|
<th>Tot Fatt</th>
|
||||||
|
<th>Fatt 3 Mesi</th>
|
||||||
<th>Ult 6 Mesi</th>
|
<th>Ult 6 Mesi</th>
|
||||||
<th>Ult Anno</th>
|
<th>Ult Anno</th>
|
||||||
|
|
||||||
@@ -90,13 +92,12 @@
|
|||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td>@if (isset($articolo->totFat))
|
<td>@if (isset($articolo->totFat))
|
||||||
<a href="/apimacro/public/view-fatturati-by-idarticolo/{{$articolo->IdArticolo}}"
|
Fatt: <a href="/apimacro/public/view-fatturati-by-idarticolo/{{$articolo->IdArticolo}}"
|
||||||
target="_blank">{{ $articolo->totFat }}</a>
|
target="_blank">{{ $articolo->totFat }}</a>
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>@if (isset($articolo->fat3mesi))
|
<td>@if (isset($articolo->fat3mesi))
|
||||||
{{ $articolo->fat3mesi }}
|
Fatt 3M: {{ $articolo->fat3mesi }}
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td>@if (isset($articolo->venduti6mesi))
|
<td>@if (isset($articolo->venduti6mesi))
|
||||||
|
|||||||
Reference in New Issue
Block a user