X-ray diffraction from partially disordered layer structures: General case