Example #1
0
 /**
  * Skip an optional page
  *
  */
 public function do_skip()
 {
     if (count($this->getAnswers())) {
         $this->_controller->addMessage('error', 'You must delete your existing answers before you can skip this page.');
         return false;
     }
     if (!$this->_applicationPage->isRequired()) {
         $answer = new \Jazzee\Entity\Answer();
         $answer->setPage($this->_applicationPage->getPage());
         $this->_applicant->addAnswer($answer);
         $answer->setPageStatus(self::SKIPPED);
         $this->_controller->getEntityManager()->persist($answer);
     }
 }
Example #2
0
 public function newAnswer($input)
 {
     if (is_null($this->_applicationPage->getMax()) or count($this->getAnswers()) < $this->_applicationPage->getMax()) {
         $answer = new \Jazzee\Entity\Answer();
         $answer->setPage($this->_applicationPage->getPage());
         $this->_applicant->addAnswer($answer);
         foreach ($this->_applicationPage->getPage()->getElements() as $element) {
             $element->getJazzeeElement()->setController($this->_controller);
             foreach ($element->getJazzeeElement()->getElementAnswers($input->get('el' . $element->getId())) as $elementAnswer) {
                 $answer->addElementAnswer($elementAnswer);
             }
         }
         $this->getForm()->applyDefaultValues();
         $this->_controller->getEntityManager()->persist($answer);
         $this->_controller->addMessage('success', 'Answer Saved Successfully');
         //flush here so the answerId will be correct when we view
         $this->_controller->getEntityManager()->flush();
     }
 }
Example #3
0
 /**
  * Parse the transaction results sent from Authorize.net Direct Post
  * @param \TransactionController $controller
  */
 public static function transaction($controller)
 {
     $matches = array();
     preg_match('#page/(\\d{1,})/?#', $_POST['redirect_url'], $matches);
     if (!isset($matches[1])) {
         throw new \Jazzee\Exception("No page id match found in redirect_url: '{$_POST['redirect_url']}");
     }
     $applicationPage = $controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\ApplicationPage')->find($matches[1]);
     if (!$applicationPage) {
         throw new \Jazzee\Exception("{$matches[1]} is not a valid applicationPage id");
     }
     if (!empty($_POST['x_cust_id'])) {
         $applicant = $controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\Applicant')->find($_POST['x_cust_id']);
         if (!$applicant) {
             throw new \Jazzee\Exception("{$_POST['x_cust_id']} is not a valid applicant id.  Anet post: " . var_export($_POST, true));
         }
         $answer = new \Jazzee\Entity\Answer();
         $answer->setPage($applicationPage->getPage());
         $applicant->addAnswer($answer);
         $payment = new \Jazzee\Entity\Payment();
         $payment->setType($controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\PaymentType')->find($_POST['paymentType']));
         $answer->setPayment($payment);
         $fakeInput = new \Foundation\Form\Input(array());
         if ($payment->getType()->getJazzeePaymentType($controller)->pendingPayment($payment, $fakeInput)) {
             $controller->getEntityManager()->persist($applicant);
             $controller->getEntityManager()->persist($answer);
             $controller->getEntityManager()->persist($payment);
             foreach ($payment->getVariables() as $var) {
                 $controller->getEntityManager()->persist($var);
             }
             $controller->getEntityManager()->flush();
             print \AuthorizeNetDPM::getRelayResponseSnippet($_POST['redirect_url']);
         }
     }
 }
Example #4
0
 /**
  * Change the school for an answer
  * @param integer $answerID
  * @param array $input
  */
 public function do_changeSchool($answerId, array $input)
 {
     if ($answer = $this->_applicant->findAnswerById($answerId)) {
         $this->_form = $this->makeForm();
         if (!array_key_exists('level', $input)) {
             $input['level'] = null;
         }
         switch ($input['level']) {
             case 'search':
                 if ($input = $this->getForm()->processInput($input)) {
                     $choices = array();
                     $searchTerms = $input->get('schoolSearch');
                     $resultsCount = $this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\School')->getSearchCount($searchTerms);
                     if ($resultsCount > 50) {
                         $this->_form->getElementByName('schoolSearch')->addMessage('Your search returned too many results, please try again with more detail.');
                     } else {
                         if ($resultsCount == 0) {
                             $this->_controller->addMessage('info', 'We were not able to find any schools that matched your search, you can search again or add a new school to our system.');
                         } else {
                             $schools = $this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\School')->search($searchTerms);
                             foreach ($schools as $school) {
                                 $choices[$school->getId()] = $school->getName();
                             }
                         }
                         $this->pickSchoolForm($choices);
                     }
                 } else {
                     $this->_controller->addMessage('error', self::ERROR_MESSAGE);
                 }
                 break;
             case 'pick':
                 if (!empty($input['pickSchoolId']) and $selectedSchool = $this->getSchoolById($input['pickSchoolId'])) {
                     $answer->setSchool($selectedSchool);
                     foreach ($answer->getChildren() as $childAnswer) {
                         $this->_controller->getEntityManager()->remove($childAnswer);
                         $answer->getChildren()->removeElement($childAnswer);
                     }
                     $this->_controller->getEntityManager()->persist($answer);
                     $this->_controller->addMessage('success', 'Answer Saved Successfully');
                     $this->_controller->redirectUrl($this->_controller->getActionPath());
                 } else {
                     $this->newSchoolForm();
                     $this->_form->getElementByName('submit')->setValue('Save');
                     if ($child = $answer->getChildren()->first()) {
                         foreach ($child->getPage()->getElements() as $element) {
                             $element->getJazzeeElement()->setController($this->_controller);
                             $value = $element->getJazzeeElement()->formValue($child);
                             if ($value) {
                                 $this->_form->getElementByName('el' . $element->getId())->setValue($value);
                             }
                         }
                     }
                 }
                 break;
             case 'new':
                 $this->newSchoolForm();
                 if ($filteredInput = $this->getForm()->processInput($input)) {
                     $answer->removeSchool();
                     $childPage = $this->_applicationPage->getPage()->getChildByFixedId(self::PAGE_FID_NEWSCHOOL);
                     if ($childAnswer = $answer->getChildren()->first()) {
                         foreach ($childAnswer->getElementAnswers() as $ea) {
                             $this->_controller->getEntityManager()->remove($ea);
                             $childAnswer->getElementAnswers()->removeElement($ea);
                         }
                     } else {
                         $childAnswer = new \Jazzee\Entity\Answer();
                         $childAnswer->setPage($childPage);
                         $answer->addChild($childAnswer);
                     }
                     foreach ($childPage->getElements() as $element) {
                         foreach ($element->getJazzeeElement()->getElementAnswers($filteredInput->get('el' . $element->getId())) as $elementAnswer) {
                             $childAnswer->addElementAnswer($elementAnswer);
                         }
                     }
                     $this->_controller->getEntityManager()->persist($childAnswer);
                     $this->_controller->addMessage('success', 'Answer Saved Successfully');
                     $this->_controller->redirectUrl($this->_controller->getActionPath());
                 } else {
                     $this->_controller->addMessage('error', self::ERROR_MESSAGE);
                 }
                 break;
         }
         $this->_form->setAction($this->_controller->getActionPath() . "/do/changeSchool/{$answerId}");
     }
 }
Example #5
0
 /**
  * Parse the transaction results sent from cashnet
  * @param \TransactionController $controller
  */
 public static function transaction($controller)
 {
     if (empty($_POST['ref1val1']) or empty($_POST['ref2val1'])) {
         throw new \Jazzee\Exception("refval1 or refval2 not set by cashnet.  Cashnet post: " . var_export($_POST, true));
     }
     $matches = array();
     preg_match('#page/(\\d{1,})/?#', $_POST['ref2val1'], $matches);
     if (!isset($matches[1])) {
         throw new \Jazzee\Exception("No page id match found in ref2val1: '{$_POST['ref2val1']}'");
     }
     $applicationPage = $controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\ApplicationPage')->find($matches[1]);
     if (!$applicationPage) {
         throw new \Jazzee\Exception("{$matches[1]} is not a valid applicationPage id");
     }
     $applicant = $controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\Applicant')->find($_POST['ref1val1']);
     if (!$applicant) {
         throw new \Jazzee\Exception("{$_POST['ref1val1']} is not a valid applicant id.  Cashnet post: " . var_export($_POST, true));
     }
     $answer = new \Jazzee\Entity\Answer();
     $answer->setPage($applicationPage->getPage());
     $applicant->addAnswer($answer);
     $payment = new \Jazzee\Entity\Payment();
     $payment->setType($controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\PaymentType')->findOneBy(array('class' => get_called_class())));
     $answer->setPayment($payment);
     $input = new \Foundation\Form\Input($_POST);
     if ($payment->getType()->getJazzeePaymentType($controller)->pendingPayment($payment, $input)) {
         $controller->getEntityManager()->persist($applicant);
         $controller->getEntityManager()->persist($answer);
         $controller->getEntityManager()->persist($payment);
         foreach ($payment->getVariables() as $var) {
             $controller->getEntityManager()->persist($var);
         }
         $controller->getEntityManager()->flush();
         header('Location: ' . $_POST['ref2val1']);
         die;
     }
     throw new \Jazzee\Exception("We were unable to record this payment.  Cashnet post: " . var_export($_POST, true));
 }
Example #6
0
 /**
  * Only process payments if there is not already a pending payment
  * @param array $input
  * @return type
  */
 public function newAnswer($input)
 {
     if ($this->getStatus() == self::INCOMPLETE) {
         $answer = new \Jazzee\Entity\Answer();
         $answer->setPage($this->_applicationPage->getPage());
         $this->_applicant->addAnswer($answer);
         $payment = new \Jazzee\Entity\Payment();
         $payment->setType($this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\PaymentType')->find($input->get('paymentType')));
         $answer->setPayment($payment);
         $result = $payment->getType()->getJazzeePaymentType($this->_controller)->pendingPayment($payment, $input);
         if ($result) {
             $this->_controller->addMessage('success', 'Your payment has been recorded.');
             $this->_form = null;
         } else {
             $this->_controller->addMessage('error', 'There was a problem processing your payment.');
         }
         $this->_controller->getEntityManager()->persist($answer);
         $this->_controller->getEntityManager()->persist($payment);
         foreach ($payment->getVariables() as $var) {
             $this->_controller->getEntityManager()->persist($var);
         }
         return $result;
     }
 }
Example #7
0
 public function newLorAnswer(\Foundation\Form\Input $input, \Jazzee\Entity\Answer $parent)
 {
     if ($parent->getChildren()->count() == 0) {
         $page = $parent->getPage()->getChildren()->first();
         $child = new \Jazzee\Entity\Answer();
         $parent->addChild($child);
         $child->setPage($page);
         $branch = new \Jazzee\Entity\Answer();
         $branch->setPage($page->getChildById($input->get('branching')));
         $child->addChild($branch);
         foreach ($branch->getPage()->getElements() as $element) {
             foreach ($element->getJazzeeElement()->getElementAnswers($input->get('el' . $element->getId())) as $elementAnswer) {
                 $branch->addElementAnswer($elementAnswer);
             }
         }
         $this->_form->applyDefaultValues();
         $this->_controller->getEntityManager()->persist($child);
         $this->_controller->getEntityManager()->persist($branch);
         //flush here so the answerId will be correct when we view
         $this->_controller->getEntityManager()->flush();
     }
 }