Spin reorientation transition and phase diagram of ultrathin ferromagnetic films