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() function showOrdini()
{ {
try { $str = "";
$baseUrl = request()->root();
$orders = Orderdetail::with(['product' => function($query) {
$query->select('sku', 'name', 'permalink'); try {
}])
->select('Codice', 'DataOra', 'IdInternet', 'CodArticoloGM', 'PrezzoLordo', 'Qta', 'PercSconto', 'Descrizione') // $str = Schema::getColumnListing('Orderdetails');
->orderBy('DataOra', 'desc')
$orders = Orderdetail::orderBy('DataOra', 'desc')
->take(5) ->take(5)
->get(); ->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) { } catch (\Exception $e) {
return "Errore: " . $e->getMessage(); return "Errore: " . $e->getMessage();
} }
return $str;
} }
function setOrdine($idinternet, $mode) function setOrdine($idinternet, $mode)
{ {
$str = ""; $str = "";

View File

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