This commit is contained in:
paoloar77
2024-07-16 19:31:05 +02:00
parent 8240a2d659
commit b3fa2abd0f
2 changed files with 45 additions and 15 deletions

View File

@@ -472,25 +472,57 @@ function loadArticleByIdArticle($id, $checkprevendita = false, $checkqtanegativa
}
}
function showOrdini()
{
try {
$baseUrl = request()->root();
$str = "";
$orders = Orderdetail::with(['product' => function($query) {
$query->select('sku', 'name', 'permalink');
}])
->select('Codice', 'DataOra', 'IdInternet', 'CodArticoloGM', 'PrezzoLordo', 'Qta', 'PercSconto', 'Descrizione')
->orderBy('DataOra', 'desc')
try {
// $str = Schema::getColumnListing('Orderdetails');
$orders = Orderdetail::orderBy('DataOra', 'desc')
->take(5)
->get();
return view('ordini', compact('orders', 'baseUrl'))->render();
$sep = "";
$baseUrl = Request::root(); // URL di base (dominio)
// Show the fields of the orders
foreach ($orders as $order) {
$product = Product::where('sku', $order->CodArticoloGM)->first();
if ($product)
$titolo = "<a href='" . $product['permalink'] . "' target='_blank'><span style='font-weigth: bold;'>" . $product['name'] . "</span></a>";
else
$titolo = "";
$str .= getvalstr("", $order->Codice) . " ";
$str .= getvalstr("", $order->DataOra);
$str .= getvalstr("", $titolo);
$str .= getvalstr("Ordine", $order->IdInternet, true) . " ";
$str .= getvalstr("Articolo", $order->CodArticoloGM, true);
$str .= getvalstr("Prezzo", $order->PrezzoLordo);
$str .= getvalstr("Quantità", $order->Qta);
if ($order->PercSconto)
$str .= getvalstr("Sconto", $order->PercSconto);
if ($order->Descrizione)
$str .= getvalstr("Descr", $order->Descrizione);
$str .= '<a href="' . $baseUrl . 'apimacro/public/setordine/' . $order->IdInternet . '/del/" target="_blank">ELIMINA!</a>' . $sep;
// $str .= getarraystr($product) . "<br>";
// $str .= $product;
$str .= '<br>';
}
} catch (\Exception $e) {
return "Errore: " . $e->getMessage();
}
return $str;
}
function setOrdine($idinternet, $mode)
{
$str = "";

View File

@@ -3,17 +3,15 @@
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Product; // Assumi che tu abbia un modello Product personalizzato
class Orderdetail extends Model
{
//protected $connection = 'mysql_test';
protected $connection = 'sqlsrv_test';
protected $table = 'T_WOO_Ordini';
public $timestamps = false;
public function product()
{
return $this->belongsTo(Product::class, 'CodArticoloGM', 'sku');
}
}
}