Anger Management

In 1978, a young Dave Buznik is about to kiss the girl of his dreams, when a local bully, Arnie Shankman, pulls down his pants and underwear, embarrassing him in front of everybody. This leaves Dave with lasting trauma about public affection, as well as repressing his emotions. Twenty five years later, Dave Buznik lives in New York, working as a secretary for Frank Head, an abusive boss who takes credit for Dave's work. His problems also extend to his private life, his girlfriend Linda's ex-boyfriend Andrew still being close friends with her and being condescending to Dave at work.
While flying to a business meeting, Dave sits next to a man named Buddy Rydell. After a series of annoyances from the flight attendant and a sky marshal cause Dave, who repeatedly wanted a headset to watch an in-flight movie suggested by Buddy, to lose his temper, the sky marshal, who also mistakes Dave for a racist, tasers him, and Dave is arrested for assaulting the flight attendant, and sentenced to anger management therapy. The therapist happens to be Buddy. Buddy's unorthodox techniques cause Dave to lose his temper, and Buddy tells Dave he recognizes his problem as passive-aggressive anger. After Dave gets into a bar fight caused by Chuck, another of Buddy's patients, Dave is sent back to court and Buddy intervenes on his behalf, choosing to move in with Dave and shadow him in his life as part of more intensive therapy. Failure to comply will result in a year of jail time for Dave. Having Buddy as an unexpected and hovering roommate irritates Dave, which prompts Buddy to offer more therapeutic advice which, in turn, irritates Dave even more. Although Dave believes Andrew is doing nothing to ruin him at work, Buddy suspects otherwise and tells him that he needs to start fighting back or nothing will change. After receiving a phone call for Buddy informing him his mother is undergoing minor surgery, Dave jokes to him about its seriousness, prompting Buddy to warn he'll get Dave back.
After seeing Buddy's mother, the two stop at a restaurant on the way back to New York. After Buddy pressures him, Dave flirts and goes home with a young lady, but rejects her amorous advances out of loyalty to Linda. Later, Dave is devastated to learn that Buddy has told Linda about the woman, but Buddy explains the woman was a former patient of his, having set up the encounter to get revenge on Dave for the "dying mother" prank, and he will explain the truth to Linda. Buddy takes a detour to a Buddhist temple, so that Dave can confront a reformed Arnie, who has become a monk. While confronting his tormentor, Arnie expresses his sincerest apologies to Dave for bullying him all his life and asserts that Dave didn't deserve the abuse, but he laughs when Dave reminds him of the kiss incident. Buddy and a hesitant Dave provoke Arnie by lying about Dave exposing himself to Arnie's mentally ill sister, and Dave and Arnie fight. Dave and Buddy tease the monks into a rage and are chased off the grounds, Dave feeling good on confronting his tormentor. Back in New York, Dave attempts to propose to Linda but loses his nerve, and Linda suggests that they take a break from their relationship. Soon after Buddy begins dating Linda, Dave (unaware this was the next step of his therapy) sees this as the last straw and loses his cool by attacking Buddy. Being called back into court, Dave is given a restraining order by the judge, who threatens to lock him up if Dave has another incident.
Called into work and yelled at by his boss, Dave finally snaps when he learns that his boss intentionally passed him and gave the promotion to Andrew. He immediately confronts both men for the way they've mistreated him in the past. Dave calls Andrew out for trying to interfere with both his promotion and relationship with Linda, revealing he wants Andrew out of their lives permanently. Andrew attempts to insult him about being too dependent on Buddy to back him up and admits he isn't good enough for Linda. Taking Buddy's advice, Dave debunks the claim and knocks him out cold. He proceeds to humiliate his boss by using a golf club to wreck his office and reminding him of all the years of his loyal services just to be denied of the promotion he wanted so much in favor of someone who didn't deserve it. Dave then tells his boss that if he gets out of jail within three years, he expects his boss to do the right thing and give him the promotion that Andrew presumably resigned from. His boss agrees and Dave leaves. Learning Buddy has taken Linda to a New York Yankees game, Dave assumes Buddy intends to steal his proposal idea and races to the stadium. Security captures him and begins to remove him from the stadium but Mayor Rudy Giuliani orders them to allow Dave to speak. After admitting that he does have an anger problem and is willing to change, Dave agrees to kiss Linda in front of the stadium in exchange for her marrying him. Linda and Buddy then reveal that the game was the final part of Dave's therapy, and explain that the tormentors and aggravations he has been put through were Buddy's doing to teach him how to unleash his anger in healthy doses to avoid it building up. The passenger, the Judge, the waitress and the flight attendant are Buddy's friends. Dave then asks about the Sky Marshall who tased him if he was involved with Buddy and Linda admits he wasn't.
The three attend a picnic with Buddy's other patients, where Dave plays a final joke on Buddy with a friend holding the group up with a water pistol, and the film ends as the friends sing "I Feel Pretty" from West Side Story together.

Question: What does the judge give Dave?
Answer: Restraining order; a restraining order