ArticoliFatturati

This commit is contained in:
paoloar77
2024-12-18 08:20:00 +01:00
parent 755abea3be
commit ceacf59278
4 changed files with 86 additions and 2 deletions

16
app/ArticoliFatturati.php Executable file
View File

@@ -0,0 +1,16 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class ArticoliFatturati extends Model
{
protected $connection = 'sqlsrv_test';
protected $table = 'T_WEB_ArticoliFatturati';
public $timestamps = false;
}

View File

@@ -620,8 +620,6 @@ function showOrdiniWeb()
try {
// $str = Schema::getColumnListing('Orderdetails');
$orders = OrderdetailWeb::orderBy('DataOra', 'desc')
->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 = "<a href='" . $product['permalink'] . "' target='_blank'>";
$finelink = "</a>";
} else {
$mylink = "";
$finelink = "";
}
if ($product && isset($product['name']))
$titolo = $mylink . "<span style='font-weigth: bold;'>" . $product['name'] . "</span>" . $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 .= ' <a href="' . $baseUrl . '/setordine/' . $order->IdInternet . '/idsito/" target="_blank">IMPOSTA IDSITO FDV</a>' . $sep;
$str .= '<br>';
}
} catch (\Exception $e) {
return "Errore: " . $e->getMessage();
}
return $str;
}
function getStructTable($tableName)
{
$str = '';
@@ -929,6 +985,7 @@ function getRigaArticoloByArt($article, $ind, $sep)
'<a href="' . $article->permalink . '?id=' . $article->IdArticolo . '" target="_blank">' . $article->IdArticolo . '</a>' . $sep .
'<a href="' . $permalink . '" target="_blank"><span style="color:' . $colore . '; font-weight: bold;"> ' . $article->Titolo . '</span></a>' . $sep .
' Pubb:' . formatDateToItalian($article->DataPubblicazione) . $sep .
$article->DescrizioneCollana . $sep .
$article->DescrizioneStatoProdotto . ' (' . $article->DescrizioneFormato . ')' . $sep .
'[Qta = <span style="">' . $article->QtaDisponibile . '</span>]' . $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)

View File

@@ -61,11 +61,17 @@
<button type="button" data-action="riviste">Riviste</button>
<button type="button" data-action="showOrdini">Mostra Ordini</button>
<button type="button" data-action="showOrdiniWeb">Mostra Ordini Web</button>
<button type="button" data-action="showArticoliFatturatiWeb">Mostra Fatturati</button>
<button type="button" data-action="Vendite">Vendite</button>
<button type="button" data-action="showDettOrdini">Dettaglio Ordini</button>
<button type="button" data-action="showDettOrdiniWeb">Dettaglio Ordini Web</button>
</form>
<div>
<a href="http://vps-88271abb.vps.ovh.net/apimacro/public/view-articles-sales" target="_blank">Articoli
Venduti</a><br>
</div>
<div id="result"></div>
<div id="loading"></div>

View File

@@ -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') {