Exemplo n.º 1
0
 protected function Form_Create()
 {
     // Attempt to load by Token and then by ID
     $this->objSignupForm = SignupForm::LoadByToken(QApplication::PathInfo(0));
     if (!$this->objSignupForm) {
         $this->objSignupForm = SignupForm::Load(QApplication::PathInfo(0));
     }
     // Ensure it is the correct type and it exists
     if (!$this->objSignupForm) {
         $this->strHtmlIncludeFilePath = '_notfound.tpl.php';
         return;
     }
     $this->strPageTitle = $this->objSignupForm->Name . ' - Confirmation';
     // Ensure it is Active
     if (!$this->objSignupForm->ActiveFlag) {
         $this->strHtmlIncludeFilePath = '_notactive.tpl.php';
         return;
     }
     // Get the SignupEntry
     $this->objSignupEntry = SignupEntry::Load(QApplication::PathInfo(1));
     // Ensure it is correct for the form and the signup person
     if ($this->objSignupEntry->SignupByPersonId) {
         if (!$this->objSignupEntry || $this->objSignupEntry->SignupFormId != $this->objSignupForm->Id || $this->objSignupEntry->SignupByPersonId != QApplication::$PublicLogin->PersonId || $this->objSignupEntry->SignupEntryStatusTypeId != SignupEntryStatusType::Complete) {
             $this->strHtmlIncludeFilePath = '_notfound.tpl.php';
             return;
         }
     } else {
         if (!$this->objSignupEntry || $this->objSignupEntry->SignupFormId != $this->objSignupForm->Id || !$this->objSignupEntry->CommunicationsEntryId || $this->objSignupEntry->SignupEntryStatusTypeId != SignupEntryStatusType::Complete) {
             $this->strHtmlIncludeFilePath = '_notfound.tpl.php';
             return;
         }
     }
 }
Exemplo n.º 2
0
 protected function Form_Create()
 {
     // Attempt to load by Token and then by ID
     $this->objSignupForm = SignupForm::LoadByToken(QApplication::PathInfo(0));
     if (!$this->objSignupForm) {
         $this->objSignupForm = SignupForm::Load(QApplication::PathInfo(0));
     }
     // Ensure it is the correct type and it exists
     if (!$this->objSignupForm) {
         $this->strHtmlIncludeFilePath = '_notfound.tpl.php';
         return;
     }
     $this->strPageTitle = $this->objSignupForm->Name . ' - Payment';
     // Ensure it is Active
     if (!$this->objSignupForm->ActiveFlag) {
         $this->strHtmlIncludeFilePath = '_notactive.tpl.php';
         return;
     }
     // Ensure we have Products that require some kind of payment
     if (!$this->objSignupForm->CountFormProducts()) {
         $this->strHtmlIncludeFilePath = '_notfound.tpl.php';
         return;
     }
     // Get the SignupEntry
     $this->objSignupEntry = SignupEntry::Load(QApplication::PathInfo(1));
     // Ensure it is correct for the form and the signup person
     if (!$this->objSignupEntry || $this->objSignupEntry->SignupFormId != $this->objSignupForm->Id || $this->objSignupEntry->SignupByPersonId != QApplication::$PublicLogin->PersonId || $this->objSignupEntry->SignupEntryStatusTypeId != SignupEntryStatusType::Incomplete) {
         $this->strHtmlIncludeFilePath = '_notfound.tpl.php';
         return;
     }
     switch ($this->objSignupForm->SignupFormTypeId) {
         case SignupFormType::Event:
             $this->objChild = $this->objSignupForm->EventSignupForm;
             break;
         case SignupFormType::Course:
             $this->objChild = $this->objSignupForm->ClassMeeting;
             break;
     }
     $this->dtgProducts = new QDataGrid($this);
     $this->dtgProducts->AddColumn(new QDataGridColumn('Product / Item', '<?= $_FORM->RenderProduct($_ITEM); ?>', 'HtmlEntities=false', 'Width=550px'));
     $this->dtgProducts->AddColumn(new QDataGridColumn('Quantity', '<?= $_FORM->RenderQuantity($_ITEM); ?>', 'HtmlEntities=false', 'Width=100px'));
     $this->dtgProducts->AddColumn(new QDataGridColumn('Cost', '<?= $_FORM->RenderCost($_ITEM); ?>', 'HtmlEntities=false', 'Width=100px'));
     $this->dtgProducts->AddColumn(new QDataGridColumn('Total', '<?= $_FORM->RenderTotal($_ITEM); ?>', 'HtmlEntities=false', 'Width=100px'));
     $this->dtgProducts->SetDataBinder('dtgProducts_Bind');
     // Remove All Product Selections
     $this->objSignupEntry->DeleteAllSignupProducts();
     // Add Required Products
     foreach ($this->objSignupForm->GetFormProductArrayByType(FormProductType::Required, QQ::OrderBy(QQN::FormProduct()->OrderNumber)) as $objProduct) {
         if ($objProduct->IsAvailableRightNow()) {
             $objSignupProduct = SignupProduct::LoadBySignupEntryIdFormProductId($this->objSignupEntry->Id, $objProduct->Id);
             if (!$objSignupProduct) {
                 $this->objSignupEntry->AddProduct($objProduct);
             }
         }
     }
     // Deposit vs. Full Amount Choice
     $this->rblDeposit = new QRadioButtonList($this);
     $this->rblDeposit->Name = 'Payment Option';
     $this->rblDeposit->AddItem('Pay in Full', 1);
     $this->rblDeposit->AddItem('Deposit', 2);
     $this->rblDeposit->AddAction(new QClickEvent(), new QAjaxAction('rblDeposit_Click'));
     $this->btnRegister = new QButton($this);
     $this->btnRegister->CssClass = 'primary';
     $this->btnRegister->Text = 'Submit Registration';
     $this->btnRegister->AddAction(new QClickEvent(), new QAjaxAction('btnRegister_Click'));
     $this->btnRegister->CausesValidation = true;
     // Figure out which address to use
     $objAddress = $this->objSignupEntry->RetrieveAnyValidAddressObject();
     if (!$objAddress) {
         $objAddress = QApplication::$PublicLogin->Person->DeducePrimaryAddress();
     }
     // Create the Payment Panel
     $this->pnlPayment = new PaymentPanel($this, null, $objAddress, QApplication::$PublicLogin->Person->FirstName, QApplication::$PublicLogin->Person->LastName);
     $this->pnlPayment->SetButtonText('Submit Payment');
     $this->objSignupEntry->RefreshAmounts();
     $this->RefreshForm();
 }
Exemplo n.º 3
0
Arquivo: edit.php Projeto: alcf/chms
 public function btnSave_Click()
 {
     // Check for unique token
     $strToken = QApplication::Tokenize($this->txtToken->Text);
     if (strlen($strToken)) {
         if (is_numeric($strToken)) {
             $this->txtToken->Warning = 'URL must have more than just numbers';
         }
         if (($objTest = SignupForm::LoadByToken($strToken)) && $objTest->Id != $this->mctSignupForm->SignupForm->Id) {
             $this->txtToken->Warning = 'URL is already taken';
         }
         if ($this->txtToken->Warning) {
             $this->txtToken->Blink();
             $this->txtToken->Focus();
             return;
         }
         $this->txtToken->Text = $strToken;
     } else {
         $this->txtToken->Text = null;
     }
     $this->mctSignupForm->SaveSignupForm();
     // Add Child
     switch ($this->mctSignupForm->SignupForm->SignupFormTypeId) {
         case SignupFormType::Event:
             if (!$this->mctSignupChild->EventSignupForm->SignupForm) {
                 $this->mctSignupChild->EventSignupForm->SignupForm = $this->mctSignupForm->SignupForm;
             }
             $this->mctSignupChild->SaveEventSignupForm();
             break;
         case SignupFormType::Course:
             if (!$this->mctSignupChild->ClassMeeting->SignupForm) {
                 $this->mctSignupChild->ClassMeeting->SignupForm = $this->mctSignupForm->SignupForm;
             }
             $this->mctSignupChild->SaveClassMeeting();
             break;
         default:
             throw new Exception('Invalid SignupFormTypeId: ' . $objSignupForm->SignupFormTypeId);
     }
     // Redirect to View Page
     QApplication::Redirect('/events/form.php/' . $this->mctSignupForm->SignupForm->Id);
 }
Exemplo n.º 4
0
 protected function Form_Create()
 {
     // Attempt to load by Token and then by ID
     $this->objSignupForm = SignupForm::LoadByToken(QApplication::PathInfo(0));
     if (!$this->objSignupForm) {
         $this->objSignupForm = SignupForm::Load(QApplication::PathInfo(0));
     }
     // Ensure it is the correct type and it exists
     if (!$this->objSignupForm) {
         $this->strHtmlIncludeFilePath = '_notfound.tpl.php';
         $this->blnFormErrorFlag = true;
         return;
     }
     $this->strPageTitle = $this->objSignupForm->Name . ' - Signup';
     // Ensure it is Active
     if (!$this->objSignupForm->ActiveFlag) {
         $this->strHtmlIncludeFilePath = '_notactive.tpl.php';
         $this->blnFormErrorFlag = true;
         return;
     }
     // Ensure that the funding stuff is a-okay
     if ($this->objSignupForm->IsStewardshipFundMissing()) {
         $this->strHtmlIncludeFilePath = '_notactive.tpl.php';
         $this->blnFormErrorFlag = true;
         return;
     }
     // Ensure we are not double registering where not allowed.
     // Only need to check if user is logged in.
     if (QApplication::$PublicLogin) {
         if (!$this->objSignupForm->AllowMultipleFlag && count(SignupEntry::LoadArrayBySignupFormIdPersonIdSignupEntryStatusTypeId($this->objSignupForm->Id, QApplication::$PublicLogin->PersonId, SignupEntryStatusType::Complete))) {
             $this->strHtmlIncludeFilePath = '_registered.tpl.php';
             $this->blnFormErrorFlag = true;
             return;
         }
     }
     // Ensure capacity limits
     if (!$this->objSignupForm->IsWithinCapacity()) {
         $this->strHtmlIncludeFilePath = '_capacity.tpl.php';
         $this->blnFormErrorFlag = true;
         return;
     }
     if (QApplication::$PublicLogin) {
         $objSignupEntryArray = SignupEntry::LoadArrayBySignupFormIdPersonIdSignupEntryStatusTypeId($this->objSignupForm->Id, QApplication::$PublicLogin->PersonId, SignupEntryStatusType::Incomplete);
         if (count($objSignupEntryArray)) {
             $this->objSignupEntry = $objSignupEntryArray[0];
         }
     }
     // Create the Entry object if doesn't yet exists
     if (!$this->objSignupEntry) {
         $this->objSignupEntry = new SignupEntry();
         $this->objSignupEntry->SignupForm = $this->objSignupForm;
         if (QApplication::$PublicLogin) {
             $this->objSignupEntry->Person = QApplication::$PublicLogin->Person;
             $this->objSignupEntry->SignupByPerson = QApplication::$PublicLogin->Person;
         }
         $this->objSignupEntry->SignupEntryStatusTypeId = SignupEntryStatusType::Incomplete;
         $this->objSignupEntry->DateCreated = QDateTime::Now();
     }
     $this->btnSubmit = new QButton($this);
     $this->btnSubmit->CausesValidation = true;
     $this->btnSubmit->CssClass = 'primary';
     if ($this->objSignupForm->CountFormProducts()) {
         $this->btnSubmit->Text = 'Next';
     } else {
         $this->btnSubmit->Text = 'Submit Registration';
     }
     $this->btnSubmit->AddAction(new QClickEvent(), new QAjaxAction('btnSubmit_Click'));
 }
Exemplo n.º 5
0
 public static function GenerateFormInMinistry(Ministry $objMinistry)
 {
     $objSignupForm = new SignupForm();
     $objSignupForm->SignupFormTypeId = SignupFormType::Event;
     $objSignupForm->Ministry = $objMinistry;
     $objSignupForm->Name = self::GenerateTitle(3, 8);
     if (rand(0, 2)) {
         $strToken = strtolower($objSignupForm->Name);
         $strToken = str_replace(' ', '_', $strToken);
         if (!SignupForm::LoadByToken($strToken)) {
             $objSignupForm->Token = $strToken;
         }
     }
     $objSignupForm->ActiveFlag = rand(0, 10);
     $objSignupForm->Description = self::GenerateContent(rand(1, 3), 8, 20);
     $objSignupForm->InformationUrl = 'http://www.yahoo.com/';
     $objSignupForm->EmailNotification = rand(0, 1) ? 'mike@michaelho.com, mike.ho@alcf.net' : null;
     $objSignupForm->AllowOtherFlag = rand(0, 1);
     $objSignupForm->AllowMultipleFlag = rand(0, 1);
     switch (rand(0, 5)) {
         case 1:
             $objSignupForm->SignupLimit = 50;
             break;
         case 2:
             $objSignupForm->SignupMaleLimit = 50;
             $objSignupForm->SignupFemaleLimit = 50;
             break;
     }
     $objSignupForm->DateCreated = self::GenerateDateTime(self::$SystemStartDate, QDateTime::Now());
     $objSignupForm->Save();
     $objEventSignupForm = new EventSignupForm();
     $objEventSignupForm->SignupForm = $objSignupForm;
     $objEventSignupForm->DateStart = new QDateTime('2011-06-27 17:00');
     $objEventSignupForm->DateEnd = new QDateTime('2011-06-30 12:00');
     $objEventSignupForm->Location = 'Camp Hammer, Boulder Creek, CA';
     $objEventSignupForm->Save();
     // Add form products information
     // 1: Required Product
     $intOrderNumber = 1;
     if (rand(0, 1)) {
         $objFormProduct = new FormProduct();
         $objFormProduct->SignupForm = $objSignupForm;
         $objFormProduct->FormProductTypeId = FormProductType::Required;
         $objFormProduct->FormPaymentTypeId = self::GenerateFromArray(array_keys(FormPaymentType::$NameArray));
         $objFormProduct->Name = 'Main Registration Fee';
         switch ($objFormProduct->FormPaymentTypeId) {
             case FormPaymentType::DepositRequired:
                 $objFormProduct->Cost = rand(1, 10) * 10;
                 $objFormProduct->Deposit = $objFormProduct->Cost / 2;
                 break;
             case FormPaymentType::PayInFull:
                 $objFormProduct->Cost = rand(1, 10) * 10;
                 break;
             case FormPaymentType::Donation:
                 $objFormProduct->FormPaymentTypeId = FormPaymentType::PayInFull;
                 $objFormProduct->Cost = rand(1, 10) * 10;
                 break;
         }
         $objFormProduct->OrderNumber = $intOrderNumber;
         $intOrderNumber++;
         $objFormProduct->ViewFlag = true;
         $objFormProduct->MinimumQuantity = 1;
         $objFormProduct->MaximumQuantity = 1;
         $objFormProduct->Save();
     }
     // 2: Required w/ Choice Product
     if (rand(0, 1)) {
         $arrProduct = array('100' => 'Standard Accommodation', '150' => 'Deluxe Accommodation');
         foreach ($arrProduct as $fltAmount => $strName) {
             $objFormProduct = new FormProduct();
             $objFormProduct->SignupForm = $objSignupForm;
             $objFormProduct->FormProductTypeId = FormProductType::RequiredWithChoice;
             $objFormProduct->FormPaymentTypeId = FormPaymentType::PayInFull;
             $objFormProduct->Name = $strName;
             $objFormProduct->Description = self::GenerateContent(1, 3, 10);
             $objFormProduct->Cost = $fltAmount;
             $objFormProduct->OrderNumber = $intOrderNumber;
             $objFormProduct->MinimumQuantity = 1;
             $objFormProduct->MaximumQuantity = 1;
             $intOrderNumber++;
             $objFormProduct->ViewFlag = true;
             $objFormProduct->Save();
         }
     }
     // 3: Optional Product(s)
     $intProductCount = rand(0, 3);
     for ($i = 0; $i < $intProductCount; $i++) {
         $objFormProduct = new FormProduct();
         $objFormProduct->SignupForm = $objSignupForm;
         $objFormProduct->FormProductTypeId = FormProductType::Optional;
         $objFormProduct->FormPaymentTypeId = FormPaymentType::PayInFull;
         $objFormProduct->Name = self::GenerateTitle(2, 5);
         $objFormProduct->Description = self::GenerateContent(1, 3, 10);
         $objFormProduct->MinimumQuantity = 1;
         $objFormProduct->MaximumQuantity = rand(1, 3);
         $objFormProduct->Cost = rand(1, 10) * 5;
         $objFormProduct->OrderNumber = $intOrderNumber;
         $intOrderNumber++;
         $objFormProduct->ViewFlag = true;
         $objFormProduct->Save();
     }
     // 4: Otpional Donation
     if (rand(0, 1)) {
         $objFormProduct = new FormProduct();
         $objFormProduct->SignupForm = $objSignupForm;
         $objFormProduct->FormProductTypeId = FormProductType::Optional;
         $objFormProduct->FormPaymentTypeId = FormPaymentType::Donation;
         $objFormProduct->Name = 'Donation';
         $objFormProduct->Description = self::GenerateContent(1, 3, 10);
         $objFormProduct->MinimumQuantity = 1;
         $objFormProduct->MaximumQuantity = 1;
         $objFormProduct->OrderNumber = $intOrderNumber;
         $intOrderNumber++;
         $objFormProduct->ViewFlag = true;
         $objFormProduct->Save();
     }
     // Add Form Questions
     $intOrderNumber = 1;
     foreach (FormQuestionType::$NameArray as $intFormQuestionTypeId => $strName) {
         if (rand(0, 1)) {
             $objFormQuestion = null;
         } else {
             $objFormQuestion = new FormQuestion();
             $objFormQuestion->SignupForm = $objSignupForm;
             $objFormQuestion->OrderNumber = $intOrderNumber;
             $objFormQuestion->FormQuestionTypeId = $intFormQuestionTypeId;
             $objFormQuestion->RequiredFlag = rand(0, 1);
             $objFormQuestion->ViewFlag = rand(0, 1);
             switch ($intFormQuestionTypeId) {
                 case FormQuestionType::SpouseName:
                     $objFormQuestion->ShortDescription = 'Spouse\'s Name';
                     $objFormQuestion->Question = 'What is your spouse\'s name?';
                     break;
                 case FormQuestionType::Address:
                     $objFormQuestion->ShortDescription = 'Home Address';
                     $objFormQuestion->Question = 'What is your address?';
                     break;
                 case FormQuestionType::Age:
                     $objFormQuestion->ShortDescription = 'Age';
                     $objFormQuestion->Question = 'How old are you?';
                     break;
                 case FormQuestionType::DateofBirth:
                     $objFormQuestion->ShortDescription = 'Date of Birth';
                     $objFormQuestion->Question = 'When were you born';
                     break;
                 case FormQuestionType::Gender:
                     $objFormQuestion->ShortDescription = 'Gender';
                     $objFormQuestion->Question = 'What is your gender?';
                     break;
                 case FormQuestionType::Phone:
                     $objFormQuestion->ShortDescription = 'Phone';
                     $objFormQuestion->Question = 'What is your phone number?';
                     break;
                 case FormQuestionType::Email:
                     $objFormQuestion->ShortDescription = 'Email';
                     $objFormQuestion->Question = 'What is your email address?';
                     break;
                 case FormQuestionType::ShortText:
                     $objFormQuestion->ShortDescription = 'Foo Bar';
                     $objFormQuestion->Question = 'What is your foo bar?';
                     break;
                 case FormQuestionType::LongText:
                     $objFormQuestion->ShortDescription = 'Foo Bar Long';
                     $objFormQuestion->Question = 'What is your foo bar long?';
                     break;
                 case FormQuestionType::Number:
                     $objFormQuestion->ShortDescription = 'Number of Baz';
                     $objFormQuestion->Question = 'How many baz?';
                     break;
                 case FormQuestionType::YesNo:
                     $objFormQuestion->ShortDescription = 'Blue Color';
                     $objFormQuestion->Question = 'Is it blue?';
                     break;
                 case FormQuestionType::SingleSelect:
                     $objFormQuestion->ShortDescription = 'One Item';
                     $objFormQuestion->Question = 'Which is it?';
                     $objFormQuestion->Options = "Option One\nOption Two\nOption Three";
                     break;
                 case FormQuestionType::MultipleSelect:
                     $objFormQuestion->ShortDescription = 'Multiple Item';
                     $objFormQuestion->Question = 'What are they?';
                     $objFormQuestion->Options = "Option One\nOption Two\nOption Three";
                     break;
                 default:
                     throw new QCallerException(sprintf('Invalid intFormQuestionTypeId: %s', $intFormQuestionTypeId));
             }
             $objFormQuestion->Save();
             $intPersonCount = rand(self::SignupsPerFormMinimum, self::SignupsPerFormMaximum);
             for ($i = 0; $i < $intPersonCount; $i++) {
                 $objPerson = null;
                 while (!$objPerson) {
                     $objPerson = Person::Load(rand(1, self::$MaximumPersonId));
                     if ($objPerson && !$objSignupForm->AllowMultipleFlag && $objSignupForm->IsPersonRegistered($objPerson)) {
                         $objPerson = null;
                     }
                 }
                 $objSignup = new SignupEntry();
                 $objSignup->SignupForm = $objSignupForm;
                 $objSignup->Person = $objPerson;
                 $objSignup->SignupByPerson = $objPerson;
                 $objSignup->DateCreated = self::GenerateDateTime($objSignupForm->DateCreated, QDateTime::Now());
                 $objSignup->SignupEntryStatusTypeId = SignupEntryStatusType::Incomplete;
                 $objSignup->InternalNotes = !rand(0, 2) ? self::GenerateContent(1, 5, 10) : null;
                 $objSignup->Save();
                 // Rqeuired Products
                 foreach ($objSignupForm->GetFormProductArrayByType(FormProductType::Required) as $objFormProduct) {
                     $objSignup->AddProduct($objFormProduct);
                 }
                 // Required with Choice
                 $objArray = $objSignupForm->GetFormProductArrayByType(FormProductType::RequiredWithChoice);
                 if (count($objArray)) {
                     $objSignup->AddProduct(self::GenerateFromArray($objArray));
                 }
                 // Optionals (including donations)
                 foreach ($objSignupForm->GetFormProductArrayByType(FormProductType::Optional) as $objFormProduct) {
                     if (rand(0, 1)) {
                         if ($objFormProduct->FormPaymentTypeId == FormPaymentType::Donation) {
                             $objSignup->AddProduct($objFormProduct, rand($objFormProduct->MinimumQuantity, $objFormProduct->MaximumQuantity), rand(1, 10) * 10);
                         } else {
                             $objSignup->AddProduct($objFormProduct, rand($objFormProduct->MinimumQuantity, $objFormProduct->MaximumQuantity));
                         }
                     }
                 }
                 // Payments
                 if (rand(0, 14)) {
                     $objSignup->SignupEntryStatusTypeId = SignupEntryStatusType::Complete;
                     $objSignup->DateSubmitted = new QDateTime($objSignup->DateCreated);
                     $objSignup->DateSubmitted->Minute += 1;
                     $objSignup->Save();
                     $fltAmount = rand(0, 1) ? $objSignup->AmountTotal : $objSignup->CalculateMinimumDeposit();
                     $objSignup->AddPayment(SignupPaymentType::CreditCard, $fltAmount, 'DATAGEN1234', new QDateTime($objSignup->DateSubmitted));
                 }
                 // Create the form answers for each question
                 foreach ($objSignupForm->GetFormQuestionArray(QQ::OrderBy(QQN::FormQuestion()->OrderNumber)) as $objFormQuestion) {
                     if ($objFormQuestion->RequiredFlag || rand(0, 1)) {
                         $objFormAnswer = new FormAnswer();
                         $objFormAnswer->SignupEntry = $objSignup;
                         $objFormAnswer->FormQuestion = $objFormQuestion;
                         switch ($objFormQuestion->FormQuestionTypeId) {
                             case FormQuestionType::SpouseName:
                                 $objFormAnswer->TextValue = 'Spouse Name';
                                 break;
                             case FormQuestionType::Address:
                                 $objFormAnswer->TextValue = $objPerson->PrimaryAddressText . ', ' . $objPerson->PrimaryCityText;
                                 $objArray = $objPerson->GetHouseholdParticipationArray();
                                 if (count($objArray)) {
                                     $objAddress = $objArray[0]->Household->GetCurrentAddress();
                                     if ($objAddress) {
                                         $objFormAnswer->AddressId = $objAddress->Id;
                                     } else {
                                         $objFormAnswer = null;
                                     }
                                 } else {
                                     $objArray = $objPerson->GetAddressArray();
                                     if (count($objArray)) {
                                         $objFormAnswer->AddressId = $objArray[0]->Id;
                                     } else {
                                         $objFormAnswer = null;
                                     }
                                 }
                                 break;
                             case FormQuestionType::Age:
                                 $objFormAnswer->IntegerValue = $objPerson->Age;
                                 break;
                             case FormQuestionType::DateofBirth:
                                 if ($objPerson->DateOfBirth) {
                                     $objFormAnswer->DateValue = $objPerson->DateOfBirth;
                                 }
                                 break;
                             case FormQuestionType::Gender:
                                 switch ($objPerson->Gender) {
                                     case 'M':
                                         $objFormAnswer->BooleanValue = true;
                                         $objFormAnswer->TextValue = 'Male';
                                         break;
                                     case 'F':
                                         $objFormAnswer->BooleanValue = false;
                                         $objFormAnswer->TextValue = 'Female';
                                         break;
                                     default:
                                         $objFormAnswer = null;
                                         break;
                                 }
                                 break;
                             case FormQuestionType::Phone:
                                 if (count($objArray = $objPerson->GetPhoneArray())) {
                                     $objFormAnswer->TextValue = $objArray[0]->Number;
                                     $objFormAnswer->PhoneId = $objArray[0]->Id;
                                 }
                                 break;
                             case FormQuestionType::Email:
                                 if (count($objArray = $objPerson->GetEmailArray())) {
                                     $objFormAnswer->TextValue = $objArray[0]->Address;
                                     $objFormAnswer->EmailId = $objArray[0]->Id;
                                 }
                                 break;
                             case FormQuestionType::ShortText:
                                 $objFormAnswer->TextValue = 'Foo Bar';
                                 break;
                             case FormQuestionType::LongText:
                                 $objFormAnswer->TextValue = 'The quick brown fox jumps over the lazy dog.';
                                 break;
                             case FormQuestionType::Number:
                                 $objFormAnswer->IntegerValue = 28;
                                 break;
                             case FormQuestionType::YesNo:
                                 $objFormAnswer->BooleanValue = rand(0, 1);
                                 break;
                             case FormQuestionType::SingleSelect:
                                 $objFormAnswer->TextValue = "Option Two";
                                 break;
                             case FormQuestionType::MultipleSelect:
                                 $objFormAnswer->TextValue = "Option One\nOption Three";
                                 break;
                         }
                         if ($objFormAnswer) {
                             $objFormAnswer->Save();
                         }
                     }
                 }
             }
         }
     }
 }