West Ham have agreed a deal in principle with Julen Lopetegui to take over from David Moyes as manager.