/** * Sets a vote for a person and updates the vote_count value for this issue. * If already voted OR if person is the poster, the vote will NOT count. * @param Person $objPerson the person who is voting "yes" to this issue * @param QDateTime $dttVoteDate the optional datetime value of the date (or NOW() if none specified) * @return void */ public function SetVote(Person $objPerson, QDateTime $dttVoteDate = null) { $objVote = IssueVote::LoadByIssueIdPersonId($this->intId, $objPerson->Id); if (!$objVote && $objPerson->Id != $this->PostedByPersonId) { $objVote = new IssueVote(); $objVote->Issue = $this; $objVote->Person = $objPerson; $objVote->VoteDate = $dttVoteDate ? new QDateTime($dttVoteDate) : QDateTime::Now(); $objVote->Save(); } $this->intVoteCount = IssueVote::CountByIssueId($this->intId); $this->Save(); }