Пример #1
0
 /**
  *  Adds Messages entities for the submitted list of applicants
  */
 public function actionSendMessage()
 {
     $applicants = explode(',', $this->post['applicantIds']);
     foreach ($applicants as $id) {
         $thread = new \Jazzee\Entity\Thread();
         $thread->setSubject($this->post['subject']);
         $applicant = $this->getApplicantById($id);
         $thread->setApplicant($applicant);
         $message = new \Jazzee\Entity\Message();
         $message->setSender(\Jazzee\Entity\Message::PROGRAM);
         $message->setText($this->post['body']);
         $thread->addMessage($message);
         $this->_em->persist($thread);
         $this->_em->persist($message);
     }
     $this->addMessage('success', count($applicants) . ' messages sent successfully');
     $this->setLayoutVar('status', 'success');
     $this->setVar('result', true);
     $this->loadView('applicants_single/result');
 }
Пример #2
0
 /**
  * Final Deny applicant
  * @param integer $applicantId
  */
 public function actionFinalDeny($applicantId)
 {
     $applicant = $this->getApplicantById($applicantId);
     $form = new \Foundation\Form();
     $form->setAction($this->path("applicants/single/{$applicantId}/finalDeny"));
     $field = $form->newField();
     $field->setLegend('Deny ' . $applicant->getFirstName() . ' ' . $applicant->getLastName());
     $element = $field->newElement('SelectList', 'decisionTemplate');
     $element->setLabel('Decision Template');
     $templates = array();
     $arr = $this->_em->getRepository('Jazzee\\Entity\\Template')->findBy(array('type' => \Jazzee\Entity\Template::DECISION_DENY, 'application' => $this->_application));
     foreach ($arr as $template) {
         $element->newItem($template->getId(), $template->getTitle());
         $templates[$template->getId()] = $template;
     }
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element = $field->newElement('RadioList', 'sendMessage');
     $element->setLabel('Send the applicant a notification?');
     $element->newItem(0, 'No');
     $element->newItem(1, 'Yes');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $form->newButton('submit', 'Deny Applicant');
     if (!empty($this->post)) {
         $this->setLayoutVar('textarea', true);
         if ($input = $form->processInput($this->post)) {
             $decision = $applicant->getDecision();
             $template = $templates[$input->get('decisionTemplate')];
             $decision->finalDeny($template);
             if ($input->get('sendMessage')) {
                 $thread = new \Jazzee\Entity\Thread();
                 $thread->setSubject('Admission Decision');
                 $thread->setApplicant($applicant);
                 $message = new \Jazzee\Entity\Message();
                 $message->setSender(\Jazzee\Entity\Message::PROGRAM);
                 $text = nl2br($decision->getDecisionLetter());
                 $message->setText($text);
                 $thread->addMessage($message);
                 $this->_em->persist($thread);
                 $this->_em->persist($message);
             }
             $this->_em->persist($decision);
             $this->auditLog($applicant, 'Final Deny');
             $this->setLayoutVar('status', 'success');
         }
     }
     $this->setVar('result', array('decisions' => $this->getDecisions($applicant)));
     $this->setVar('form', $form);
     $this->loadView('applicants_single/form');
 }
Пример #3
0
 /**
  * New Message to applicant
  * @param $applicantId
  */
 public function actionNew($applicantId = false)
 {
     if ($applicantId) {
         $applicant = $this->getApplicantById($applicantId);
     }
     $form = new \Foundation\Form();
     $path = 'applicants/messages/new';
     if ($applicantId) {
         $path .= '/' . $applicantId;
     }
     $form->setAction($this->path($path));
     $field = $form->newField();
     $field->setLegend('New Message');
     if ($applicantId) {
         $element = $field->newElement('Plaintext', 'name');
         $element->setLabel('To');
         $element->setValue($applicant->getFullName());
         $element = $field->newElement('HiddenInput', 'to');
         $element->setValue($applicant->getId());
     } else {
         $element = $field->newElement('SelectList', 'to');
         $element->setLabel('To');
         foreach ($this->_em->getRepository('\\Jazzee\\Entity\\Applicant')->findApplicantsByName('%', '%', $this->_application) as $applicant) {
             $element->newItem($applicant->getId(), $applicant->getLastName() . ', ' . $applicant->getFirstName());
         }
         $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     }
     $element = $field->newElement('TextInput', 'subject');
     $element->setLabel('Subject');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addFilter(new \Foundation\Form\Filter\SafeHTML($element));
     $element = $field->newElement('Textarea', 'text');
     $element->setLabel('Message');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addFilter(new \Foundation\Form\Filter\SafeHTML($element));
     $form->newButton('submit', 'Submit');
     $this->setVar('form', $form);
     if ($input = $form->processInput($this->post)) {
         $thread = new \Jazzee\Entity\Thread();
         $thread->setSubject($input->get('subject'));
         $applicant = $this->getApplicantById($input->get('to'));
         $thread->setApplicant($applicant);
         $message = new \Jazzee\Entity\Message();
         $message->setSender(\Jazzee\Entity\Message::PROGRAM);
         $message->setText($input->get('text'));
         $thread->addMessage($message);
         $this->_em->persist($thread);
         $this->_em->persist($message);
         $this->addMessage('success', 'Your message has been sent.');
         $this->redirectPath('applicants/messages');
     }
 }
Пример #4
0
 /**
  * Deny Applicants
  */
 public function actionFinalDeny()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path('applicants/decisions/finalDeny'));
     $field = $form->newField();
     $field->setLegend('Deny Applicants');
     $element = $field->newElement('CheckboxList', 'applicants');
     $element->setLabel('Select applicants to deny');
     foreach ($this->_em->getRepository('\\Jazzee\\Entity\\Applicant')->findApplicantsByName('%', '%', $this->_application) as $applicant) {
         if ($applicant->isLocked() and $applicant->getDecision()->can('finalDeny')) {
             $element->newItem($applicant->getId(), $applicant->getLastName() . ', ' . $applicant->getFirstName());
         }
     }
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element = $field->newElement('SelectList', 'decisionTemplate');
     $element->setLabel('Decision Template');
     $templates = array();
     $arr = $this->_em->getRepository('Jazzee\\Entity\\Template')->findBy(array('type' => \Jazzee\Entity\Template::DECISION_DENY, 'application' => $this->_application));
     foreach ($arr as $template) {
         $element->newItem($template->getId(), $template->getTitle());
         $templates[$template->getId()] = $template;
     }
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element = $field->newElement('RadioList', 'sendMessage');
     $element->setLabel('Send the applicant a notification?');
     $element->newItem(0, 'No');
     $element->newItem(1, 'Yes');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $form->newButton('submit', 'Submit');
     if ($input = $form->processInput($this->post)) {
         $count = 0;
         foreach ($input->get('applicants') as $id) {
             $applicant = $this->getApplicantById($id);
             $decision = $applicant->getDecision();
             $template = $templates[$input->get('decisionTemplate')];
             $decision->finalDeny($template);
             if ($input->get('sendMessage')) {
                 $thread = new \Jazzee\Entity\Thread();
                 $thread->setSubject('Admission Decision');
                 $thread->setApplicant($applicant);
                 $message = new \Jazzee\Entity\Message();
                 $message->setSender(\Jazzee\Entity\Message::PROGRAM);
                 $text = nl2br($decision->getDecisionLetter());
                 $message->setText($text);
                 $thread->addMessage($message);
                 $this->_em->persist($thread);
                 $this->_em->persist($message);
             }
             $this->_em->persist($decision);
             $this->auditLog($applicant, 'Final Deny');
             $count++;
             if ($count > 100) {
                 $this->_em->flush();
                 $count = 0;
             }
         }
         $this->addMessage('success', count($this->post['applicants']) . ' applicant(s) denied.');
         $this->redirectPath('applicants/decisions');
     }
     $this->setVar('form', $form);
     $this->loadView('applicants_decisions/form');
 }
Пример #5
0
 /**
  * Bulk create applicants from a csv file
  */
 public function actionBulk()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path('applicants/create/bulk'));
     $field = $form->newField();
     $field->setLegend('Create Applicants From File');
     $element = $field->newElement('FileInput', 'file');
     $element->setLabel('File');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addFilter(new \Foundation\Form\Filter\CSVArray($element));
     $element = $field->newElement('TextInput', 'notificationSubject');
     $element->setLabel('Subject for Notification Email');
     $element->setValue('New Application Account');
     $element = $field->newElement('Textarea', 'notificationMessage');
     $element->setLabel('Notification Email Message');
     $element->setFormat('Leave this blank if you do not want to notify the applicant of their new account');
     $notificationMessagereplacements = array('_Applicant_Name_', '_Deadline_', '_Link_', '_Email_', '_Password_');
     $element->setInstructions('You can use these tokens in the text, they will be replaced automatically: <br />' . implode('</br />', $notificationMessagereplacements));
     $element->setValue($this->_defaultEmail);
     $element = $field->newElement('DateInput', 'deadlineExtension');
     $element->setLabel('Deadline');
     $element->setFormat('If you wish to extend this applicants deadline past the application deadline enter it here.');
     if ($this->_application->getClose()) {
         $element->addValidator(new \Foundation\Form\Validator\DateAfter($element, $this->_application->getClose()->format('c')));
     }
     $form->newButton('submit', 'Upload File and create applicants');
     if ($input = $form->processInput($this->post)) {
         $newApplicants = $input->get('file');
         $first = $newApplicants[0];
         $requiredHeaders = array('External ID', 'First Name', 'Middle Name', 'Last Name', 'Suffix', 'Email Address', 'Password');
         $error = false;
         foreach ($requiredHeaders as $value) {
             if (!in_array($value, $first)) {
                 $form->getElementByName('file')->addMessage("The uploaded file must contain a column '{$value}'");
                 $error = true;
             }
         }
         if (!$error) {
             $headers = array_shift($newApplicants);
             $byKey = array();
             foreach ($newApplicants as $newApplicant) {
                 $arr = array();
                 foreach ($headers as $key => $value) {
                     $arr[$value] = $newApplicant[$key];
                 }
                 $byKey[] = $arr;
             }
             $newApplicants = $byKey;
             $results = array();
             foreach ($newApplicants as $newApplicant) {
                 $result = array('messages' => array(), 'applicant' => null, 'plainTextPassword' => '');
                 $duplicate = $this->_em->getRepository('Jazzee\\Entity\\Applicant')->findOneByEmailAndApplication($newApplicant['Email Address'], $this->_application);
                 if ($duplicate) {
                     $result['status'] = 'duplicate';
                     $result['messages'][] = 'An applicant with that email address already exists.';
                     $result['applicant'] = $duplicate;
                 } else {
                     if (!empty($newApplicant['External ID']) and !$this->_application->validateExternalId($newApplicant['External ID'])) {
                         $result['status'] = 'badExternalId';
                         $result['messages'][] = $newApplicant['External ID'] . ' is not a valid external ID for this program';
                         $result['applicantName'] = "{$newApplicant['First Name']} {$newApplicant['Last Name']}";
                         $result['applicantEmail'] = $newApplicant['Email Address'];
                     } else {
                         $result['status'] = 'success';
                         $applicant = new \Jazzee\Entity\Applicant();
                         $applicant->setApplication($this->_application);
                         $applicant->setEmail($newApplicant['Email Address']);
                         if ($newApplicant['Password']) {
                             $applicant->setPassword($newApplicant['Password']);
                             $plainTextPassword = $newApplicant['Password'];
                         } else {
                             $plainTextPassword = $applicant->generatePassword();
                         }
                         $applicant->setFirstName($newApplicant['First Name']);
                         $applicant->setMiddleName($newApplicant['Middle Name']);
                         $applicant->setLastName($newApplicant['Last Name']);
                         $applicant->setSuffix($newApplicant['Suffix']);
                         $applicant->setExternalId($newApplicant['External ID']);
                         if ($input->get('deadlineExtension')) {
                             $applicant->setDeadlineExtension($input->get('deadlineExtension'));
                         }
                         $this->_em->persist($applicant);
                         $result['applicant'] = $applicant;
                         $result['plainTextPassword'] = $plainTextPassword;
                         $result['messages'][] = 'Applicant Created Successfully';
                         if ($input->get('notificationMessage')) {
                             $replace = array($applicant->getFullName(), $applicant->getDeadline() ? $applicant->getDeadline()->format('l F jS Y g:ia') : '', $this->absoluteApplyPath("apply/{$this->_application->getProgram()->getShortName()}/{$this->_application->getCycle()->getName()}/applicant/login"), $applicant->getEmail(), $plainTextPassword);
                             $body = str_ireplace($notificationMessagereplacements, $replace, $input->get('notificationMessage'));
                             $subject = $input->get('notificationSubject') ? $input->get('notificationSubject') : 'New Application Account';
                             $email = $this->newMailMessage();
                             $email->AddCustomHeader('X-Jazzee-Applicant-ID:' . $applicant->getId());
                             $email->AddAddress($applicant->getEmail(), $applicant->getFullName());
                             $email->setFrom($this->_application->getContactEmail(), $this->_application->getContactName());
                             $email->Subject = $subject;
                             $email->Body = $body;
                             $email->Send();
                             $thread = new \Jazzee\Entity\Thread();
                             $thread->setSubject($subject);
                             $thread->setApplicant($applicant);
                             $message = new \Jazzee\Entity\Message();
                             $message->setSender(\Jazzee\Entity\Message::PROGRAM);
                             $message->setText(nl2br($body));
                             $message->read();
                             $thread->addMessage($message);
                             $this->_em->persist($thread);
                             $this->_em->persist($message);
                             $result['messages'][] = 'New account email sent';
                         }
                     }
                 }
                 $results[] = $result;
             }
             $this->setVar('results', $results);
             $this->_em->flush();
         }
     }
     $this->setVar('form', $form);
 }
Пример #6
0
 /**
  * Reply to a message
  */
 public function actionReply()
 {
     $thread = $this->_em->getRepository('\\Jazzee\\Entity\\Thread')->findOneBy(array('id' => $this->actionParams['id'], 'applicant' => $this->_applicant->getId()));
     if (!$thread) {
         throw new \Jazzee\Exception($this->actionParams['id'] . " is not a valid thread id for applicant " . $this->_applicant->getId());
     }
     $this->setVar('thread', $thread);
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->applyPath('support/reply/' . $thread->getId()));
     $field = $form->newField();
     $field->setLegend('Reply to message');
     $element = $field->newElement('Textarea', 'text');
     $element->setLabel('Your Reply');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addFilter(new \Foundation\Form\Filter\Safe($element));
     $form->newButton('submit', 'Submit');
     $this->setVar('form', $form);
     if ($input = $form->processInput($this->post)) {
         $reply = new \Jazzee\Entity\Message();
         $reply->setSender(\Jazzee\Entity\Message::APPLICANT);
         $reply->setText($input->get('text'));
         $thread->addMessage($reply);
         $this->_em->persist($reply);
         $this->addMessage('success', 'Your reply has been sent.');
         $this->redirectApplyPath('support');
     }
 }