The episode is "The Unfortunate Problem of a Missing Zipper" — Season 7, Episode 11 (original air date: January 11, 2010).
Alan Harper (Jon Cryer) falls from a ladder while trying to fix a garage door spring, leading to a hospital stay and painkiller-induced antics.