diff --git a/app/CustomFuncPao.php b/app/CustomFuncPao.php index b3d49ada..1e101360 100644 --- a/app/CustomFuncPao.php +++ b/app/CustomFuncPao.php @@ -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 = "" . $product['name'] . ""; + 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 .= 'ELIMINA!' . $sep; + + // $str .= getarraystr($product) . "
"; + // $str .= $product; + $str .= '
'; + } } catch (\Exception $e) { return "Errore: " . $e->getMessage(); } + + return $str; } + function setOrdine($idinternet, $mode) { $str = ""; diff --git a/app/Orderdetail.php b/app/Orderdetail.php index 745c39d1..f22e0a2a 100644 --- a/app/Orderdetail.php +++ b/app/Orderdetail.php @@ -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'); - } -} \ No newline at end of file + + +}