/** * 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')); }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ public function create(array $data) { $nombreEmpresa = $data['email']; $name = $data['name']; $apellido = $data['apellido']; $telefono = $data['telefono']; $email = $data['email']; $ID = Sap::getId(); $client = Sap::getClientSoap(); //'name' => $nombreEmpresa $result = $client->call('AddLead', array('id' => $ID, 'name' => $nombreEmpresa, 'tel' => $telefono, 'email' => $email, 'nombreUsuario' => $name, 'apellido' => $apellido)); $sapResult = (string) $result['AddLeadResult']; //dd($sapResult); //if (preg_match("/L\d+/", $sapResult)) { $user = User::create(['nombre' => $name, 'Apellido' => $apellido, 'email' => $email, 'telefono' => $telefono, 'password' => bcrypt($data['password'])]); $user->sapResultado = $sapResult; $user->save(); return $user; //}else{ // return back()->withErrors(array('msg' => 'Ha ocurrido un error al procesar su solicitud')); //} }