/** * Count FormQuestions * by FormQuestionTypeId Index(es) * @param integer $intFormQuestionTypeId * @return int */ public static function CountByFormQuestionTypeId($intFormQuestionTypeId, $objOptionalClauses = null) { // Call FormQuestion::QueryCount to perform the CountByFormQuestionTypeId query return FormQuestion::QueryCount(QQ::Equal(QQN::FormQuestion()->FormQuestionTypeId, $intFormQuestionTypeId), $objOptionalClauses); }
public function MoveDown() { $blnFound = false; foreach (FormQuestion::LoadArrayBySignupFormId($this->intSignupFormId, QQ::OrderBy(QQN::FormQuestion()->OrderNumber)) as $objFormQuestion) { if ($blnFound) { break; } if ($objFormQuestion->Id == $this->Id) { $blnFound = true; } } $this->OrderNumber++; $this->Save(); if ($objFormQuestion) { $objFormQuestion->OrderNumber--; $objFormQuestion->Save(); } self::RefreshOrderNumber($this->intSignupFormId); }
protected function dtgFormQuestions_Bind() { $this->dtgFormQuestions->DataSource = $this->objSignupForm->GetFormQuestionArray(QQ::OrderBy(QQN::FormQuestion()->OrderNumber)); }
} $objSignupForm = SignupForm::Load(QApplication::PathInfo(0)); if (!$objSignupForm) { QApplication::Redirect('/events/'); } if (!$objSignupForm->IsLoginCanView(QApplication::$Login)) { QApplication::Redirect('/events/'); } // Disable strict no-cache for IE due to IE issues with downloading no-cache items if (QApplication::IsBrowser(QBrowserType::InternetExplorer)) { header("Pragma:"); header("Expires:"); } header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename=' . $objSignupForm->CsvFilename); $objFormQuestionArray = $objSignupForm->GetFormQuestionArray(QQ::OrderBy(QQN::FormQuestion()->OrderNumber)); // Get Column Titles print "First Name,Last Name"; foreach ($objFormQuestionArray as $objFormQuestion) { if ($objFormQuestion->FormQuestionTypeId == FormQuestionType::Address) { print ", Street"; print ", City"; print ", State And Zip Code"; } else { print "," . EscapeCsv($objFormQuestion->ShortDescription); } } if ($objSignupForm->CountFormProducts() > 0) { foreach ($objSignupForm->GetFormProductArray(QQ::OrderBy(QQN::FormProduct()->FormProductTypeId, QQN::FormProduct()->OrderNumber)) as $objFormProduct) { if ($objFormProduct->ViewFlag) { print ",";
/** * Creates all the controls for each "question" in the form. * Note: For any fields that are looked up from the user's profile (e.g. address, phone, etc.) -- a drop down is available for quick access. * However, if they select "other", we save the data and do NOT link it to any records! * (e.g. if an "other" phone is used, that data is not stored anywhere else) */ protected function CreateFormItemControls() { /** * @var Person */ $objPerson = $this->objSignupEntry->Person; if ($objPerson != null) { // First, set up for the Person Name label $lblPersonName = new QLabel($this, 'lblPersonName'); $lblPersonName->Name = 'Name'; $lblPersonName->Required = true; $lblPersonName->Text = $objPerson->Name; $lblPersonName->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lblPersonName; } else { // else if not logged in, prompt for First and Last Name. Always. $txtFirstName = new QTextBox($this); $txtFirstName->Name = 'First Name'; $txtFirstName->Required = true; $txtFirstName->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtFirstName; $txtLastName = new QTextBox($this); $txtLastName->Name = 'Last Name'; $txtLastName->Required = true; $txtLastName->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtLastName; } // Go through all the other fields foreach ($this->objSignupForm->GetFormQuestionArray(QQ::OrderBy(QQN::FormQuestion()->OrderNumber)) as $objFormQuestion) { // Only display if this is NOT "InternalFlag" if ($objFormQuestion->InternalFlag) { continue; } $strControlId = 'fq' . $objFormQuestion->Id; $objFormAnswer = FormAnswer::LoadBySignupEntryIdFormQuestionId($this->objSignupEntry->Id, $objFormQuestion->Id); switch ($objFormQuestion->FormQuestionTypeId) { case FormQuestionType::SpouseName: if ($objPerson != null) { if (($objMarriage = $objPerson->GetMostRecentMarriage()) && $objMarriage->MarriedToPerson) { $lstSpouse = new QListBox($this, $strControlId . 'id'); $lstSpouse->ActionParameter = $strControlId . 'nm'; if (!$objFormQuestion->RequiredFlag) { $lstSpouse->AddItem('- Select One -', null); } $lstSpouse->AddItem($objMarriage->MarriedToPerson->Name, $objMarriage->MarriedToPerson->Id, true); $lstSpouse->AddItem('- Other... -', false); $lstSpouse->AddAction(new QChangeEvent(), new QAjaxAction('lst_ToggleOther')); $lstSpouse->Name = $objFormQuestion->Question; if ($objFormQuestion->RequiredFlag) { $lstSpouse->Required = true; } $lstSpouse->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lstSpouse; $txtName = new QTextBox($this, $strControlId . 'nm'); $txtName->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtName; $txtName->Visible = false; $txtName->Required = false; if ($objFormAnswer && strlen($objFormAnswer->TextValue)) { if ($lstSpouse->SelectedName != $objFormAnswer->TextValue) { $lstSpouse->SelectedIndex = count($lstSpouse->GetAllItems()) - 1; $txtName->Text = $objFormAnswer->TextValue; $this->lst_ToggleOther(null, $lstSpouse->ControlId, $lstSpouse->ActionParameter); } } } else { $lstSpouse = new QListBox($this, $strControlId . 'id'); $lstSpouse->Visible = false; if ($objFormQuestion->RequiredFlag) { $lstSpouse->Required = true; } $lstSpouse->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lstSpouse; $txtName = new QTextBox($this, $strControlId . 'nm'); $txtName->Name = $objFormQuestion->Question; $txtName->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtName; $txtName->Visible = true; $txtName->Required = $objFormQuestion->RequiredFlag; if ($objFormAnswer && strlen($objFormAnswer->TextValue)) { $txtName->Text = $objFormAnswer->TextValue; } } } else { $txtName = new QTextBox($this, $strControlId . 'nm'); $txtName->Name = $objFormQuestion->Question; $txtName->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtName; $txtName->Visible = true; $txtName->Required = $objFormQuestion->RequiredFlag; if ($objFormAnswer && strlen($objFormAnswer->TextValue)) { $txtName->Text = $objFormAnswer->TextValue; } } break; case FormQuestionType::Address: if ($objPerson != null) { $objHouseholdArray = Household::LoadArrayBySharedHouseholds($objPerson, $this->objSignupEntry->SignupByPerson); if (count($objHouseholdArray) > 1) { // TODO: Implement! throw new Exception('TODO: Not Implemented'); } else { if (count($objHouseholdArray) == 1) { $objAddress = $objHouseholdArray[0]->GetCurrentAddress(); $rblAddress = new QRadioButtonList($this, $strControlId . 'switch'); $rblAddress->Name = $objFormQuestion->Question; $rblAddress->RenderMethod = 'RenderWithName'; $rblAddress->AddItem('Use Home Address Below', $objAddress->Id, true); $rblAddress->AddItem('Edit Home Address', false, false); $rblAddress->RepeatColumns = 2; $rblAddress->AddAction(new QClickEvent(), new QAjaxAction('rblAddress_Change')); $this->objFormQuestionControlArray[] = $rblAddress; } else { $objAddress = new Address(); $rblAddress = null; } } } $txtAddress1 = new QTextBox($this, $strControlId . 'address1'); $txtAddress1->Name = 'Address 1'; $txtAddress1->RenderMethod = 'RenderWithName'; $txtAddress1->Text = $objPerson != null ? $objAddress->Address1 : ''; $txtAddress2 = new QTextBox($this, $strControlId . 'address2'); $txtAddress2->Name = 'Address 2'; $txtAddress2->RenderMethod = 'RenderWithName'; $txtAddress2->Text = $objPerson != null ? $objAddress->Address2 : ''; $txtCity = new QTextBox($this, $strControlId . 'city'); $txtCity->Name = 'City, State and Zip'; $txtCity->RenderMethod = 'RenderWithName'; $txtCity->Text = $objPerson != null ? $objAddress->City : ''; $lstState = new QListBox($this, $strControlId . 'state'); $lstState->ActionParameter = '_' . $strControlId . 'city'; $lstState->Name = QApplication::Translate('State'); $lstState->RenderMethod = 'RenderWithError'; $lstState->AddItem(QApplication::Translate('- Select One -'), null); foreach (UsState::LoadAll(QQ::OrderBy(QQN::UsState()->Name)) as $objUsState) { if ($objPerson != null) { $lstState->AddItem($objUsState->Name, $objUsState->Abbreviation, $objAddress->State == $objUsState->Abbreviation); } else { $lstState->AddItem($objUsState->Name, $objUsState->Abbreviation, false); } } $txtZipCode = new QTextBox($this, $strControlId . 'zipcode'); $txtZipCode->ActionParameter = '_' . $strControlId . 'city'; $txtZipCode->Name = 'Zip Code'; $txtZipCode->RenderMethod = 'RenderWithError'; $txtZipCode->Text = $objPerson != null ? $objAddress->ZipCode : ''; $txtZipCode->Width = '80px'; if ($objFormQuestion->RequiredFlag) { $txtAddress1->Required = true; $txtCity->Required = true; $lstState->Required = true; $txtZipCode->Required = true; } $this->objFormQuestionControlArray[] = $txtAddress1; $this->objFormQuestionControlArray[] = $txtAddress2; $this->objFormQuestionControlArray[] = $txtCity; $this->objFormQuestionControlArray[] = $lstState; $this->objFormQuestionControlArray[] = $txtZipCode; // Final configuration based on whether or not we've got a household record for this person // (in which case we have defined a rblAddress) if ($objPerson != null) { if ($rblAddress) { // Check to see if the question has been answered before if ($objFormAnswer && strlen($objFormAnswer->TextValue)) { // If it $objAddress = Address::DeduceAddressFromFullLine($objFormAnswer->TextValue); if ($objFormAnswer->AddressId == $rblAddress->SelectedValue || !$objAddress) { $txtAddress1->Enabled = false; $txtAddress2->Enabled = false; $txtCity->Enabled = false; $lstState->Enabled = false; $txtZipCode->Enabled = false; } else { $txtAddress1->Text = $objAddress->Address1; $txtAddress2->Text = $objAddress->Address2; $txtCity->Text = $objAddress->City; $txtZipCode->Text = $objAddress->ZipCode; $lstState->SelectedValue = $objAddress->State; $rblAddress->SelectedIndex = 1; } // It has not -- let's default to having the address be presumed correct } else { $txtAddress1->Enabled = false; $txtAddress2->Enabled = false; $txtCity->Enabled = false; $lstState->Enabled = false; $txtZipCode->Enabled = false; } // No rblAddress - so let's update the address1 label to match the form question's question text } else { $txtAddress1->Name = $objFormQuestion->Question; } } break; case FormQuestionType::Age: $txtAge = new QIntegerTextBox($this, $strControlId . 'age'); $txtAge->Name = $objFormQuestion->Question; $txtAge->Minimum = 0; $txtAge->Maximum = 130; $txtAge->MaxLength = 3; if ($objFormAnswer && !is_null($objFormAnswer->IntegerValue)) { $txtAge->Text = $objFormAnswer->IntegerValue; } else { if ($objPerson != null) { if (!$objPerson->DobYearApproximateFlag && $objPerson->Age) { $txtAge->Text = $objPerson->Age; } } } if ($objFormQuestion->RequiredFlag) { $txtAge->Required = true; } $txtAge->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtAge; $txtAge->Width = '50px'; break; case FormQuestionType::DateofBirth: $dtxDateOfBirth = new QDateTimeTextBox($this, $strControlId . 'dob'); $dtxDateOfBirth->LabelForInvalid = 'For example, "Mar 20 1977"'; $dtxDateOfBirth->Name = $objFormQuestion->Question; if ($objFormAnswer && !is_null($objFormAnswer->DateValue)) { $dtxDateOfBirth->Text = $objFormAnswer->DateValue->ToString('MMM D YYYY'); } else { if ($objPerson != null) { if (!$objPerson->DobYearApproximateFlag && !$objPerson->DobGuessedFlag && $objPerson->DateOfBirth) { $dtxDateOfBirth->Text = $objPerson->DateOfBirth->ToString('MMM D YYYY'); } } } if ($objFormQuestion->RequiredFlag) { $dtxDateOfBirth->Required = true; } $dtxDateOfBirth->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $dtxDateOfBirth; $dtxDateOfBirth->Width = '150px'; break; case FormQuestionType::Gender: $lstGender = new QListBox($this, $strControlId . 'gender'); $lstGender->Name = $objFormQuestion->Question; $lstGender->AddItem('- Select One -', null); if ($objFormAnswer && $objFormAnswer->TextValue) { $lstGender->AddItem('Male', true, $objFormAnswer->BooleanValue); $lstGender->AddItem('Female', false, !$objFormAnswer->BooleanValue); } else { if ($objPerson != null) { $lstGender->AddItem('Male', true, $objPerson->Gender == 'M'); $lstGender->AddItem('Female', false, $objPerson->Gender == 'F'); } else { $lstGender->AddItem('Male', true, true); // just default to something $lstGender->AddItem('Female', false, false); } } if ($objFormQuestion->RequiredFlag) { $lstGender->Required = true; } $lstGender->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lstGender; break; case FormQuestionType::Phone: $objPhoneArray = array(); if ($objPerson != null) { // Add Household Numbers (if applicable) foreach ($objPerson->GetHouseholdParticipationArray() as $objHouseholdParticipation) { foreach ($objHouseholdParticipation->Household->GetCurrentAddress()->GetPhoneArray() as $objPhone) { $objPhoneArray[] = $objPhone; } } // Add Personal Numbers foreach ($objPerson->GetPhoneArray() as $objPhone) { $objPhoneArray[] = $objPhone; } if (count($objPhoneArray)) { $lstPhone = new QListBox($this, $strControlId . 'id'); $lstPhone->ActionParameter = $strControlId . 'phone'; $lstPhone->Name = $objFormQuestion->Question; $lstPhone->AddItem('- Select One -', null); rsort($objPhoneArray); foreach ($objPhoneArray as $objPhone) { $lstPhone->AddItem($objPhone->Number, $objPhone->Id, $objFormAnswer && $objFormAnswer->PhoneId == $objPhone->Id); } $lstPhone->AddItem('- Other... -', false); if ($objFormQuestion->RequiredFlag) { $lstPhone->Required = true; } $lstPhone->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lstPhone; $lstPhone->AddAction(new QChangeEvent(), new QAjaxAction('lst_ToggleOther')); } } $txtPhone = new PhoneTextBox($this, $strControlId . 'phone'); $this->objFormQuestionControlArray[] = $txtPhone; $txtPhone->RenderMethod = 'RenderWithName'; // We need to deduce whether or not we should show an explicit text-valued phone number from before if ($objPerson != null) { $blnExplicitlyTextValueOnly = $objFormAnswer && $objFormAnswer->TextValue && (!$lstPhone || !$lstPhone->SelectedValue); } else { $blnExplicitlyTextValueOnly = true; } if (count($objPhoneArray)) { if ($blnExplicitlyTextValueOnly) { $lstPhone->SelectedIndex = count($lstPhone->GetAllItems()) - 1; $txtPhone->Visible = true; $txtPhone->Required = $objFormQuestion->RequiredFlag; $txtPhone->Text = $objFormAnswer->TextValue; } else { $txtPhone->Visible = false; $txtPhone->Required = false; } } else { $txtPhone->Visible = true; $txtPhone->Required = $objFormQuestion->RequiredFlag; $txtPhone->Name = $objFormQuestion->Question; if ($blnExplicitlyTextValueOnly) { $txtPhone->Text = $objFormAnswer ? $objFormAnswer->TextValue : ''; } } break; case FormQuestionType::Email: $objEmailArray = array(); if ($objPerson != null) { // Add Personal Emails foreach ($objPerson->GetEmailArray() as $objEmail) { $objEmailArray[] = $objEmail; } if (count($objEmailArray)) { $lstEmail = new QListBox($this, $strControlId . 'id'); $lstEmail->ActionParameter = $strControlId . 'email'; $lstEmail->Name = $objFormQuestion->Question; $lstEmail->AddItem('- Select One -', null); rsort($objEmailArray); foreach ($objEmailArray as $objEmail) { $lstEmail->AddItem($objEmail->Address, $objEmail->Id, $objFormAnswer && $objFormAnswer->EmailId == $objEmail->Id); } $lstEmail->AddItem('- Other... -', false); if ($objFormQuestion->RequiredFlag) { $lstEmail->Required = true; } $lstEmail->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lstEmail; $lstEmail->AddAction(new QChangeEvent(), new QAjaxAction('lst_ToggleOther')); } } $txtEmail = new QEmailTextBox($this, $strControlId . 'email'); $this->strEmailCtrlId = $strControlId . 'email'; $this->objFormQuestionControlArray[] = $txtEmail; $txtEmail->RenderMethod = 'RenderWithName'; // We need to deduce whether or not we should show an explicit text-valued email address from before if ($objPerson != null) { $blnExplicitlyTextValueOnly = $objFormAnswer && $objFormAnswer->TextValue && (!$lstEmail || !$lstEmail->SelectedValue); } else { $blnExplicitlyTextValueOnly = true; } if (count($objEmailArray)) { if ($blnExplicitlyTextValueOnly) { $lstEmail->SelectedIndex = count($lstEmail->GetAllItems()) - 1; $txtEmail->Visible = true; $txtEmail->Required = $objFormQuestion->RequiredFlag; $txtEmail->Text = $objFormAnswer->TextValue; } else { $txtEmail->Visible = false; $txtEmail->Required = false; } } else { $txtEmail->Visible = true; $txtEmail->Required = $objFormQuestion->RequiredFlag; $txtEmail->Name = $objFormQuestion->Question; if ($blnExplicitlyTextValueOnly) { $txtEmail->Text = $objFormAnswer ? $objFormAnswer->TextValue : ''; } } break; case FormQuestionType::ShortText: $txtAnswer = new QTextBox($this, $strControlId); $txtAnswer->Name = $objFormQuestion->Question; $txtAnswer->Required = $objFormQuestion->RequiredFlag; $txtAnswer->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtAnswer; if ($objFormAnswer) { $txtAnswer->Text = $objFormAnswer->TextValue; } break; case FormQuestionType::LongText: $txtAnswer = new QTextBox($this, $strControlId); $txtAnswer->Name = $objFormQuestion->Question; $txtAnswer->Required = $objFormQuestion->RequiredFlag; $txtAnswer->RenderMethod = 'RenderWithName'; $txtAnswer->TextMode = QTextMode::MultiLine; $this->objFormQuestionControlArray[] = $txtAnswer; if ($objFormAnswer) { $txtAnswer->Text = $objFormAnswer->TextValue; } break; case FormQuestionType::Number: $txtAnswer = new QIntegerTextBox($this, $strControlId); $txtAnswer->Name = $objFormQuestion->Question; $txtAnswer->Required = $objFormQuestion->RequiredFlag; $txtAnswer->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtAnswer; $txtAnswer->Width = '50px'; $txtAnswer->MaxLength = 6; if ($objFormAnswer) { $txtAnswer->Text = $objFormAnswer->IntegerValue; } break; case FormQuestionType::YesNo: $chkAnswer = new QCheckBox($this, $strControlId); $chkAnswer->Name = $objFormQuestion->Question; $chkAnswer->Text = trim($objFormQuestion->Options); $chkAnswer->Required = $objFormQuestion->RequiredFlag; $chkAnswer->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $chkAnswer; if ($objFormAnswer) { $chkAnswer->Checked = $objFormAnswer->BooleanValue; } break; case FormQuestionType::SingleSelect: $lstAnswer = new QListBox($this, $strControlId); $lstAnswer->Name = $objFormQuestion->Question; $lstAnswer->Required = $objFormQuestion->RequiredFlag; $lstAnswer->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lstAnswer; $lstAnswer->AddItem('- Select One -', null); foreach (explode("\n", trim($objFormQuestion->Options)) as $strItem) { if (strlen($strItem = trim($strItem))) { $lstAnswer->AddItem($strItem, $strItem, $objFormAnswer && $objFormAnswer->TextValue == $strItem); } } if ($objFormQuestion->AllowOtherFlag) { $lstAnswer->ActionParameter = $strControlId . 'other'; $lstAnswer->AddAction(new QChangeEvent(), new QAjaxAction('lst_ToggleOther')); $lstAnswer->AddItem('- Other... -', false); $txtAnswer = new QTextBox($this, $strControlId . 'other'); $txtAnswer->RenderMethod = 'RenderWithName'; $txtAnswer->Required = false; $txtAnswer->Visible = false; $this->objFormQuestionControlArray[] = $txtAnswer; } if ($objFormAnswer && strlen($objFormAnswer->TextValue) && !$lstAnswer->SelectedValue) { if ($objFormQuestion->AllowOtherFlag) { $lstAnswer->SelectedIndex = count($lstAnswer->GetAllItems()) - 1; $txtAnswer->Text = $objFormAnswer->TextValue; $txtAnswer->Visible = true; } else { $lstAnswer->AddItem($objFormAnswer->TextValue, $objFormAnswer->TextValue, true); } } break; case FormQuestionType::MultipleSelect: $strAnswerArray = array(); if ($objFormAnswer) { foreach (explode("\n", trim($objFormAnswer->TextValue)) as $strAnswer) { if (strlen($strAnswer = trim($strAnswer))) { $strAnswerArray[$strAnswer] = $strAnswer; } } } // GJS - Change to check boxes instead of multi select $chkAnswer = new QCheckBoxList($this, $strControlId); $chkAnswer->Name = $objFormQuestion->Question; $chkAnswer->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $chkAnswer; foreach (explode("\n", trim($objFormQuestion->Options)) as $strItem) { if (strlen($strItem = trim($strItem))) { $chkAnswer->AddItem($strItem, $strItem, array_key_exists($strItem, $strAnswerArray)); $strAnswerArray[$strItem] = null; unset($strAnswerArray[$strItem]); } } foreach ($strAnswerArray as $strAnswer) { $chkAnswer->AddItem($strAnswer, $strAnswer, true); } if ($objFormQuestion->AllowOtherFlag) { $txtAnswer = new QTextBox($this, $strControlId . 'other'); $txtAnswer->RenderMethod = 'RenderWithName'; $txtAnswer->HtmlBefore = 'Add another option and hit <strong>Enter</strong>:<br/>'; $txtAnswer->Visible = true; $txtAnswer->ActionParameter = $strControlId; $txtAnswer->AddAction(new QEnterKeyEvent(), new QAjaxAction('txtMultipleSelectOther_Enter')); $this->objFormQuestionControlArray[] = $txtAnswer; } break; case FormQuestionType::Instructions: $lblAnswer = new QLabel($this, $strControlId); $lblAnswer->HtmlEntities = false; $lblAnswer->Text = nl2br(QApplication::HtmlEntities(trim($objFormQuestion->Options)), true); if (strlen($strLabel = trim($objFormQuestion->Question))) { $lblAnswer->Name = $strLabel; $lblAnswer->RenderMethod = 'RenderWithName'; } else { $lblAnswer->RenderMethod = 'Render'; } $this->objFormQuestionControlArray[] = $lblAnswer; break; default: throw new Exception('Invalid FormQuestionTypeId: ' . $objFormQuestion->FormQuestionTypeId); } } }
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(); } } } } } } }
public function dtgSignupEntries_SetupColumns() { $this->dtgSignupEntries->RemoveAllColumns(); $this->dtgSignupEntries->MetaAddColumn(QQN::SignupEntry()->Person->LastName, 'Name=Name', 'Html=<?= $_FORM->RenderName($_ITEM); ?>', 'HtmlEntities=false'); // $this->dtgSignupEntries->MetaAddTypeColumn('SignupEntryStatusTypeId', 'SignupEntryStatusType', 'Name=Status'); foreach ($this->objSignupForm->GetFormQuestionArray(QQ::OrderBy(QQN::FormQuestion()->OrderNumber)) as $objFormQuestion) { if ($objFormQuestion->ViewFlag) { $this->dtgSignupEntries->AddColumn(new QDataGridColumn($objFormQuestion->ShortDescription, '<?= $_FORM->RenderAnswer($_ITEM, ' . $objFormQuestion->Id . ',' . $objFormQuestion->FormQuestionTypeId . '); ?>', 'HtmlEntities=false')); } } foreach ($this->objSignupForm->GetFormProductArray(QQ::OrderBy(QQN::FormProduct()->FormProductTypeId, QQN::FormProduct()->OrderNumber)) as $objFormProduct) { if ($objFormProduct->ViewFlag) { /* $this->dtgSignupEntries->AddColumn(new QDataGridColumn($objFormProduct->Name. ' Quantity', '<?= $_FORM->RenderProductQuantity($_ITEM, ' . $objFormProduct->Id . '); ?>', 'HtmlEntities=false'));*/ $this->dtgSignupEntries->AddColumn(new QDataGridColumn($objFormProduct->Name, '<?= $_FORM->RenderProductAmount($_ITEM, ' . $objFormProduct->Id . '); ?>', 'HtmlEntities=false')); } } if ($this->objSignupForm->CountFormProducts()) { $this->dtgSignupEntries->MetaAddColumn(QQN::SignupEntry()->AmountPaid, 'Name=Paid', 'Html=<?= $_FORM->RenderAmount($_ITEM->AmountPaid); ?>'); $this->dtgSignupEntries->MetaAddColumn(QQN::SignupEntry()->AmountBalance, 'Name=Balance', 'Html=<?= $_FORM->RenderAmount($_ITEM->AmountBalance); ?>'); $this->dtgSignupEntries->AddColumn(new QDataGridColumn('Payment Type', '<?= $_FORM->RenderPaymentType($_ITEM); ?>', 'HtmlEntities=false')); } $this->dtgSignupEntries->MetaAddColumn(QQN::SignupEntry()->DateSubmitted, 'Name=Submitted', 'Html=<?= $_ITEM->DateSubmitted ? $_ITEM->DateSubmitted->ToString("MMM D YYYY") : null; ?>'); }
/** * Used internally by the Meta-based Add Column tools. * * Given a QQNode or a Text String, this will return a FormQuestion-based QQNode. * It will also verify that it is a proper FormQuestion-based QQNode, and will throw an exception otherwise. * * @param mixed $mixContent * @return QQNode */ protected function ResolveContentItem($mixContent) { if ($mixContent instanceof QQNode) { if (!$mixContent->_ParentNode) { throw new QCallerException('Content QQNode cannot be a Top Level Node'); } if ($mixContent->_RootTableName == 'form_question') { if ($mixContent instanceof QQReverseReferenceNode && !$mixContent->_PropertyName) { throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.'); } $objCurrentNode = $mixContent; while ($objCurrentNode = $objCurrentNode->_ParentNode) { if (!$objCurrentNode instanceof QQNode) { throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.'); } if ($objCurrentNode instanceof QQReverseReferenceNode && !$objCurrentNode->_PropertyName) { throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.'); } } return $mixContent; } else { throw new QCallerException('Content QQNode has a root table of "' . $mixContent->_RootTableName . '". Must be a root of "form_question".'); } } else { if (is_string($mixContent)) { switch ($mixContent) { case 'Id': return QQN::FormQuestion()->Id; case 'SignupFormId': return QQN::FormQuestion()->SignupFormId; case 'SignupForm': return QQN::FormQuestion()->SignupForm; case 'OrderNumber': return QQN::FormQuestion()->OrderNumber; case 'FormQuestionTypeId': return QQN::FormQuestion()->FormQuestionTypeId; case 'ShortDescription': return QQN::FormQuestion()->ShortDescription; case 'Question': return QQN::FormQuestion()->Question; case 'RequiredFlag': return QQN::FormQuestion()->RequiredFlag; case 'InternalFlag': return QQN::FormQuestion()->InternalFlag; case 'Options': return QQN::FormQuestion()->Options; case 'AllowOtherFlag': return QQN::FormQuestion()->AllowOtherFlag; case 'ViewFlag': return QQN::FormQuestion()->ViewFlag; default: throw new QCallerException('Simple Property not found in FormQuestionDataGrid content: ' . $mixContent); } } else { if ($mixContent instanceof QQAssociationNode) { throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.'); } else { throw new QCallerException('Invalid Content type'); } } } }