Perry The Platypus movie

This is an episode or movie about Phineas and Ferb finding out about Perry as an secret agent. But the bad thing is Perry gets fired and Doofenshmirtz wins for the first time. The good thing is Phineas and Ferb beat Doofenshmirtz and help Agent P get rehired.