public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'InfoCardPdfView.php');
     PHPWS_Core::initModClass('hms', 'InfoCard.php');
     PHPWS_Core::initModClass('hms', 'CheckinFactory.php');
     $checkinId = $context->get('checkinId');
     $checkin = CheckinFactory::getCheckinById($checkinId);
     $infoCard = new InfoCard($checkin);
     $view = new InfoCardPdfView();
     $view->addInfoCard($infoCard);
     $view->getPdf()->output();
     exit;
 }
 public function execute(CommandContext $context)
 {
     $term = Term::getSelectedTerm();
     $checkins = CheckinFactory::getCheckinsOrderedByRoom($term);
     if (!isset($checkins) || count($checkins) <= 0) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'No check-ins were found for the selected term.');
         $cmd = CommandFactory::getCommand('ShowAdminMaintenanceMenu');
         $cmd->redirect();
     }
     $view = new InfoCardPdfView();
     foreach ($checkins as $checkin) {
         $infoCard = new InfoCard($checkin);
         $view->addInfoCard($infoCard);
     }
     $view->getPdf()->output();
     exit;
 }
示例#3
0
 public static function sendCheckinConfirmation(Student $student, InfoCard $infoCard, InfoCardPdfView $infoCardView)
 {
     $tags = array();
     $tags['NAME'] = $student->getName();
     $tags['HALL_NAME'] = $infoCard->getHall()->getHallName();
     $tags['ASSIGNMENT'] = $infoCard->getRoom()->where_am_i();
     $content = PHPWS_Template::process($tags, 'hms', 'email/checkinConfirmation.tpl');
     $htmlContent = Markdown::defaultTransform($content);
     $message = Swift_Message::newInstance();
     $message->setSubject('Check-in Confirmation');
     $message->setFrom(array(FROM_ADDRESS => SYSTEM_NAME));
     $message->setTo(array($student->getUsername() . TO_DOMAIN => $student->getName()));
     $message->setBody($content);
     $message->addPart($htmlContent, 'text/html');
     // Attach info card
     $attachment = Swift_Attachment::newInstance($infoCardView->getPdf()->output('my-pdf-file.pdf', 'S'), 'ResidentInfoCard.pdf', 'application/pdf');
     $message->attach($attachment);
     if (EMAIL_TEST_FLAG) {
         self::logSwiftmailMessageLong($message);
         return;
     }
     $transport = Swift_SmtpTransport::newInstance('localhost');
     $mailer = Swift_Mailer::newInstance($transport);
     $mailer->send($message);
 }