Move the top door hinge out, the bottom rear of the door should then move flush. You may also have to adjust the rear striker. Ignore the window frame at this point. Once you achieve a flush fit at the back edge of the door, tighten the door hinges and recheck the rear. Shim the front fender to get the alignment correct to the door.
To adjust the window frame place a block of wood or tightly rolled large rag at the bottom corner of the window frame and gently close the door snug against it, then push on the upper part of the frame. Repeat as needed to get your alignment correct.