Thailand PM faces court ruling that could cost him his job