public function validateRequest(Qurbani $qurbani) { $errors = []; if ($qurbani->getSheep() < 0) { $errors[] = "Invalid Number of Sheep"; } if ($qurbani->getCows() < 0) { $errors[] = "Invalid Number of Cows"; } if ($qurbani->getCamels() < 0) { $errors[] = "Invalid Number of Camels"; } if ($qurbani->getSheep() + $qurbani->getCows() + $qurbani->getCamels() <= 0) { $errors[] = "At least one animal is required"; } if (($qurbani->getDonationid() != null || $qurbani->getQurbanikey() == null) && !$qurbani->getIsvoid()) { $sheep = $qurbani->getSheep(); $cows = $qurbani->getCows(); $camels = $qurbani->getCamels(); if ($qurbani->getQurbanikey() != null) { $current = $this->qurbaniRepo->fetch($qurbani->getQurbanikey()); if ($current == null) { $errors[] = "Could not find Qurbani Donation"; } else { if ($current->getQurbanimonth() != $this->details->qurbanimonth) { $errors[] = "Invalid Qurbani Month"; } if ($current->getDonationid() != null && !$current->getIsvoid()) { $sheep -= $current->getSheep(); $cows -= $current->getCows(); $camels -= $current->getCamels(); } } } $sheepLeft = $this->details->totalsheep - $this->getPurchasedSheep(); $cowsLeft = $this->details->totalcows - $this->getPurchasedCows(); $camelsLeft = $this->details->totalcamels - $this->getPurchasedCamels(); if ($sheep > $sheepLeft) { $errors[] = "Only {$sheepLeft} Sheep left"; } if ($cows > $cowsLeft) { $errors[] = "Only {$cowsLeft} Cows left"; } if ($camels > $camelsLeft) { $errors[] = "Only {$camelsLeft} Camels left"; } } return $errors; }
public function qurbaniCompleteAlert(Qurbani $qurbani) { if (!$qurbani->getIscomplete()) { $subject = "Your Qurbani has been done"; $htmlBody = "\r\n <html>\r\n <head></head>\r\n <body>\r\n <p>\r\n Salam Aleikum,<br/>\r\n This is to confirm that your qurbani as follows has been done:\r\n <ul>\r\n <li><strong>Sheep:</strong> " . $qurbani->getSheep() . "</li>\r\n <li><strong>Cows:</strong> " . $qurbani->getCows() . "</li>\r\n <li><strong>Camels:</strong> " . $qurbani->getCamels() . "</li>" . ($qurbani->getInstructions() == null ? "" : "<li><strong>On Behalf of:</strong> <br/>" . nl2br($qurbani->getInstructions()) . "</li>") . "</ul>\r\n <br/>\r\n We would like to take this opportunity to thank you for your donation. May Allah accept it from you. Amin.<br/>\r\n <br/>\r\n Shukran<br/>\r\n The Projects Team, EKDA<br/>\r\n 11B Sunnybank Road<br/>\r\n Aberdeen, United Kingdom<br/>\r\n AB24 3NJ<br/>\r\n www.ekda.org<br/>\r\n Scottish Charity Reg No: SC041294<br/>\r\n </p>\r\n </body>\r\n </html>\r\n "; $recipients = $this->isNotProduction ? $this->supportEmail : $qurbani->getEmail(); $this->emailRepository->sendMail($this->defaultSender, $recipients, $subject, null, $htmlBody); } }
public function __construct(Qurbani $qurbani = null) { if ($qurbani != null) { $this->qurbanikey = $qurbani->getQurbanikey(); $this->qurbanimonth = $qurbani->getQurbanimonth(); $this->sheep = $qurbani->getSheep(); $this->cows = $qurbani->getCows(); $this->camels = $qurbani->getCamels(); $this->total = $qurbani->getTotal(); $this->fullname = $qurbani->getFullname(); $this->email = $qurbani->getEmail(); $this->mobile = $qurbani->getMobile(); $this->instructions = $qurbani->getInstructions(); $this->donationid = $qurbani->getDonationid(); $this->isvoid = $qurbani->getIsvoid(); $this->iscomplete = $qurbani->getIscomplete(); $this->createddate = $qurbani->getCreateddate(); } }