/** * Display detall of a product selected * * @return product */ public function datos($categoria, $valor) { $producto = Articulos::firstOrNew(['ItemCode' => $valor]); $detalle = Detalles::where('ItemCode', $valor)->get(); $relacionados = DB::select('select * from producto where visto !=0 ORDER BY rand() limit 3'); $ID = null; $client = null; if (Auth::check()) { $ID = Session::get('UserId'); $client = Session::get('Client'); // $ID = Sap::getId(); ////$client = Sap::getClientSoap(); } else { $ID = Sap::getId(); $client = Sap::getClientSoap(); } $CurrencyRate = $client->call('getCurrencyRate', array('tipo' => 'USD', 'SID' => $ID)); $currency = $CurrencyRate['getCurrencyRateResult']; /* funcion para sacar el detalle de un producto Session::put('UserId', Sap::getId()); Session::put('Client', */ $ItemList = $client->call('GetDetalle', array('SID' => $ID, 'producto' => $valor)); $productos = (string) $ItemList['GetDetalleResult']; $datos = utf8_encode($productos); $BOM = new \SimpleXMLElement($datos); //datos a mostrar en la interfaz if ($BOM->BO->Items_Prices->row[1]->Currency == "MXP") { $numero = $BOM->BO->Items_Prices->row[1]->Price; $numero = number_format($numero, 2, '.', ','); $precio = $numero; } else { $number = (double) $BOM->BO->Items_Prices->row[1]->Price; $number = number_format($number, 2, '.', ','); $numero = $number * $currency; $numero = number_format($numero, 2, '.', ','); $precio = $numero; } $stock = $BOM->BO->Items->row->QuantityOnStock * 1; return view('detalle_producto')->with(compact('precio', 'stock', 'producto', 'detalle', 'relacionados')); }