/** * Get questions data from db * * @param int $elemId * @param int $langId * @param int $questType * * @return array */ protected function _selectQuestions($elemId, $langId = 1, $questType = null) { $oQuestion = new FormQuestion(); $oQstIndex = new FormQuestionIndex(); $oType = new FormQuestionType(); $select = $oQuestion->select()->setIntegrityCheck(false)->from(array('FQ' => $oQuestion->info('name')))->joinLeft(array('FQI' => $oQstIndex->info('name')), 'FQI_QuestionID = FQ_ID', array('FQI_Title'))->joinRight($oType->info('name'), 'FQ_TypeID = FQT_ID', array('FQT_TypeName', 'FQT_ImageLink'))->where('FQ_ElementID = ?', $elemId); if ($langId != null) { $select->where('FQI_LanguageID = ?', $langId); $select->where('FQTI_LanguageID = ?', $langId); } if ($questType != null) { $select->where('FQ_TypeID = ?', $questType); } $questions = $oQuestion->fetchAll($select)->toArray(); return $questions; }
public function cblColumns_Click() { foreach ($this->cblColumns->GetAllItems() as $objItem) { $intId = substr($objItem->Value, 1); if (substr($objItem->Value, 0, 1) == 'q') { $objQuestion = FormQuestion::Load($intId); $objQuestion->ViewFlag = $objItem->Selected; $objQuestion->Save(); } else { $objProduct = FormProduct::Load($intId); $objProduct->ViewFlag = $objItem->Selected; $objProduct->Save(); } } $this->dtgSignupEntries_SetupColumns(); $this->dtgSignupEntries->Refresh(); }
/** * Static Helper Method to Create using PK arguments * You must pass in the PK arguments on an object to load, or leave it blank to create a new one. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to * edit, or if we are also allowed to create a new one, etc. * * @param mixed $objParentObject QForm or QPanel which will be using this FormQuestionMetaControl * @param integer $intId primary key value * @param QMetaControlCreateType $intCreateType rules governing FormQuestion object creation - defaults to CreateOrEdit * @return FormQuestionMetaControl */ public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intId)) { $objFormQuestion = FormQuestion::Load($intId); // FormQuestion was found -- return it! if ($objFormQuestion) { return new FormQuestionMetaControl($objParentObject, $objFormQuestion); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a FormQuestion object with PK arguments: ' . $intId); } } // If EditOnly is specified, throw an exception } else { if ($intCreateType == QMetaControlCreateType::EditOnly) { throw new QCallerException('No PK arguments specified'); } } // If we are here, then we need to create a new record return new FormQuestionMetaControl($objParentObject, new FormQuestion()); }
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objSignupEntry) { $objObject->objSignupEntry = SignupEntry::GetSoapObjectFromObject($objObject->objSignupEntry, false); } else { if (!$blnBindRelatedObjects) { $objObject->intSignupEntryId = null; } } if ($objObject->objFormQuestion) { $objObject->objFormQuestion = FormQuestion::GetSoapObjectFromObject($objObject->objFormQuestion, false); } else { if (!$blnBindRelatedObjects) { $objObject->intFormQuestionId = null; } } if ($objObject->objAddress) { $objObject->objAddress = Address::GetSoapObjectFromObject($objObject->objAddress, false); } else { if (!$blnBindRelatedObjects) { $objObject->intAddressId = null; } } if ($objObject->objPhone) { $objObject->objPhone = Phone::GetSoapObjectFromObject($objObject->objPhone, false); } else { if (!$blnBindRelatedObjects) { $objObject->intPhoneId = null; } } if ($objObject->objEmail) { $objObject->objEmail = Email::GetSoapObjectFromObject($objObject->objEmail, false); } else { if (!$blnBindRelatedObjects) { $objObject->intEmailId = null; } } if ($objObject->dttDateValue) { $objObject->dttDateValue = $objObject->dttDateValue->__toString(QDateTime::FormatSoap); } return $objObject; }
protected function btnDelete_Click() { $this->mctQuestion->FormQuestion->DeleteAllFormAnswers(); $this->mctQuestion->DeleteFormQuestion(); FormQuestion::RefreshOrderNumber($this->objSignupForm->Id); QApplication::Redirect('/events/form.php/' . $this->objSignupForm->Id); }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, FormQuestion::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
/** * Refresh this MetaControl with Data from the local FormAnswer object. * @param boolean $blnReload reload FormAnswer from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objFormAnswer->Reload(); } if ($this->lblId) { if ($this->blnEditMode) { $this->lblId->Text = $this->objFormAnswer->Id; } } if ($this->lstSignupEntry) { $this->lstSignupEntry->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstSignupEntry->AddItem(QApplication::Translate('- Select One -'), null); } $objSignupEntryArray = SignupEntry::LoadAll(); if ($objSignupEntryArray) { foreach ($objSignupEntryArray as $objSignupEntry) { $objListItem = new QListItem($objSignupEntry->__toString(), $objSignupEntry->Id); if ($this->objFormAnswer->SignupEntry && $this->objFormAnswer->SignupEntry->Id == $objSignupEntry->Id) { $objListItem->Selected = true; } $this->lstSignupEntry->AddItem($objListItem); } } } if ($this->lblSignupEntryId) { $this->lblSignupEntryId->Text = $this->objFormAnswer->SignupEntry ? $this->objFormAnswer->SignupEntry->__toString() : null; } if ($this->lstFormQuestion) { $this->lstFormQuestion->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstFormQuestion->AddItem(QApplication::Translate('- Select One -'), null); } $objFormQuestionArray = FormQuestion::LoadAll(); if ($objFormQuestionArray) { foreach ($objFormQuestionArray as $objFormQuestion) { $objListItem = new QListItem($objFormQuestion->__toString(), $objFormQuestion->Id); if ($this->objFormAnswer->FormQuestion && $this->objFormAnswer->FormQuestion->Id == $objFormQuestion->Id) { $objListItem->Selected = true; } $this->lstFormQuestion->AddItem($objListItem); } } } if ($this->lblFormQuestionId) { $this->lblFormQuestionId->Text = $this->objFormAnswer->FormQuestion ? $this->objFormAnswer->FormQuestion->__toString() : null; } if ($this->txtTextValue) { $this->txtTextValue->Text = $this->objFormAnswer->TextValue; } if ($this->lblTextValue) { $this->lblTextValue->Text = $this->objFormAnswer->TextValue; } if ($this->lstAddress) { $this->lstAddress->RemoveAllItems(); $this->lstAddress->AddItem(QApplication::Translate('- Select One -'), null); $objAddressArray = Address::LoadAll(); if ($objAddressArray) { foreach ($objAddressArray as $objAddress) { $objListItem = new QListItem($objAddress->__toString(), $objAddress->Id); if ($this->objFormAnswer->Address && $this->objFormAnswer->Address->Id == $objAddress->Id) { $objListItem->Selected = true; } $this->lstAddress->AddItem($objListItem); } } } if ($this->lblAddressId) { $this->lblAddressId->Text = $this->objFormAnswer->Address ? $this->objFormAnswer->Address->__toString() : null; } if ($this->lstPhone) { $this->lstPhone->RemoveAllItems(); $this->lstPhone->AddItem(QApplication::Translate('- Select One -'), null); $objPhoneArray = Phone::LoadAll(); if ($objPhoneArray) { foreach ($objPhoneArray as $objPhone) { $objListItem = new QListItem($objPhone->__toString(), $objPhone->Id); if ($this->objFormAnswer->Phone && $this->objFormAnswer->Phone->Id == $objPhone->Id) { $objListItem->Selected = true; } $this->lstPhone->AddItem($objListItem); } } } if ($this->lblPhoneId) { $this->lblPhoneId->Text = $this->objFormAnswer->Phone ? $this->objFormAnswer->Phone->__toString() : null; } if ($this->lstEmail) { $this->lstEmail->RemoveAllItems(); $this->lstEmail->AddItem(QApplication::Translate('- Select One -'), null); $objEmailArray = Email::LoadAll(); if ($objEmailArray) { foreach ($objEmailArray as $objEmail) { $objListItem = new QListItem($objEmail->__toString(), $objEmail->Id); if ($this->objFormAnswer->Email && $this->objFormAnswer->Email->Id == $objEmail->Id) { $objListItem->Selected = true; } $this->lstEmail->AddItem($objListItem); } } } if ($this->lblEmailId) { $this->lblEmailId->Text = $this->objFormAnswer->Email ? $this->objFormAnswer->Email->__toString() : null; } if ($this->txtIntegerValue) { $this->txtIntegerValue->Text = $this->objFormAnswer->IntegerValue; } if ($this->lblIntegerValue) { $this->lblIntegerValue->Text = $this->objFormAnswer->IntegerValue; } if ($this->chkBooleanValue) { $this->chkBooleanValue->Checked = $this->objFormAnswer->BooleanValue; } if ($this->lblBooleanValue) { $this->lblBooleanValue->Text = $this->objFormAnswer->BooleanValue ? QApplication::Translate('Yes') : QApplication::Translate('No'); } if ($this->calDateValue) { $this->calDateValue->DateTime = $this->objFormAnswer->DateValue; } if ($this->lblDateValue) { $this->lblDateValue->Text = sprintf($this->objFormAnswer->DateValue) ? $this->objFormAnswer->__toString($this->strDateValueDateTimeFormat) : null; } }
protected function pxyEditFormQuestion_Click($strFormId, $strControlId, $strParameter) { $objFormQuestion = FormQuestion::Load($strParameter); if ($objFormQuestion->SignupFormId != $this->objSignupForm->Id) { return; } /** * @var SignupEntry */ $objSignupEntry = $this->mctSignupEntry->SignupEntry; /** * @var Person */ $objPerson = $this->mctSignupEntry->SignupEntry->Person; $this->dlgEdit->ShowDialogBox(); $this->dlgEdit->Template = dirname(__FILE__) . '/dlgEditResult_FormAnswer.tpl.php'; $this->intEditTag = self::EditTagAnswer; $this->objAnswer = FormAnswer::LoadBySignupEntryIdFormQuestionId($objSignupEntry->Id, $objFormQuestion->Id); if (!$this->objAnswer) { $this->objAnswer = new FormAnswer(); $this->objAnswer->SignupEntryId = $objSignupEntry->Id; $this->objAnswer->FormQuestionId = $objFormQuestion->Id; $this->btnDelete->Visible = false; } else { $this->btnDelete->Visible = true; } // Reset $this->ResetDialogControls(); // Setup the appropriate control switch ($objFormQuestion->FormQuestionTypeId) { case FormQuestionType::YesNo: $this->chkBoolean->Name = 'Response'; $this->chkBoolean->Checked = $this->objAnswer->BooleanValue; $this->chkBoolean->Text = $objFormQuestion->ShortDescription; break; case FormQuestionType::SpouseName: $this->txtTextbox->Name = 'Spouse\'s Name'; $this->txtTextbox->Text = $this->objAnswer->TextValue; $this->txtTextbox->Focus(); break; case FormQuestionType::Address: $objAddresses = array(); foreach ($objPerson->GetHouseholdParticipationArray() as $objHouseholdParticipation) { foreach ($objHouseholdParticipation->Household->GetAddressArray() as $objAddress) { if ($objAddress->CurrentFlag) { $objAddresses[$objAddress->Id] = $objAddress; } } } foreach (Address::LoadArrayByPersonId($objPerson->Id) as $objAddress) { if ($objAddress->CurrentFlag) { $objAddresses[$objAddress->Id] = $objAddress; } } $this->lstListbox->RemoveAllItems(); foreach ($objAddresses as $objAddress) { $this->lstListbox->AddItem(sprintf('%s (%s)', $objAddress->Label, $objAddress->AddressShortLine), $objAddress->Id, $objAddress->Id == $this->objAnswer->AddressId); } $this->lstListbox->Name = $objFormQuestion->ShortDescription; $this->lblInstructions->Text = sprintf('If you need to specify an address that is not listed, you will need to <a href="%s">Update this person\'s Contact Info</a>.', $objPerson->ContactInfoLinkUrl); break; case FormQuestionType::Gender: $this->lstListbox->RemoveAllItems(); $this->lstListbox->AddItem('Male', true, $objPerson->Gender == 'M'); $this->lstListbox->AddItem('Female', false, $objPerson->Gender == 'F'); $this->lstListbox->Name = 'Gender'; $this->lblInstructions->Text = 'Please note that updating the Gender value here will also update this person\'s record in NOAH.'; break; case FormQuestionType::Phone: $objPhones = array(); foreach ($objPerson->GetHouseholdParticipationArray() as $objHouseholdParticipation) { foreach ($objHouseholdParticipation->Household->GetAddressArray() as $objAddress) { foreach ($objAddress->GetPhoneArray() as $objPhone) { $objPhones[] = $objPhone; } } } foreach ($objPerson->GetPhoneArray() as $objPhone) { $objPhones[] = $objPhone; } $this->lstListbox->RemoveAllItems(); foreach ($objPhones as $objPhone) { $this->lstListbox->AddItem(sprintf('%s (%s)', $objPhone->Number, $objPhone->Label), $objPhone->Id, $objPhone->Id == $this->objAnswer->PhoneId); } $this->lstListbox->Name = $objFormQuestion->ShortDescription; $this->lblInstructions->Text = sprintf('If you need to specify a phone number that is not listed, you will need to <a href="%s">Update this person\'s Contact Info</a>.', $objPerson->ContactInfoLinkUrl); break; case FormQuestionType::Email: $this->lstListbox->RemoveAllItems(); foreach ($objPerson->GetEmailArray() as $objEmail) { $this->lstListbox->AddItem($objEmail->Label, $objEmail->Id, $objEmail->Id == $this->objAnswer->EmailId); } $this->lstListbox->Name = $objFormQuestion->ShortDescription; $this->lblInstructions->Text = sprintf('If you need to specify an email address that is not listed, you will need to <a href="%s">Update this person\'s Contact Info</a>.', $objPerson->ContactInfoLinkUrl); break; case FormQuestionType::ShortText: $this->txtTextbox->Text = $this->objAnswer->TextValue; $this->txtTextbox->Name = $objFormQuestion->ShortDescription; break; case FormQuestionType::LongText: $this->txtTextArea->Text = $this->objAnswer->TextValue; $this->txtTextArea->Name = $objFormQuestion->ShortDescription; break; case FormQuestionType::SingleSelect: $this->lstListbox->RemoveAllItems(); $this->lstListbox->Name = $objFormQuestion->ShortDescription; foreach (explode("\n", $objFormQuestion->Options) as $strOption) { $strOption = trim($strOption); $this->lstListbox->AddItem($strOption, $strOption, trim($this->objAnswer->TextValue) == $strOption); } if ($objFormQuestion->AllowOtherFlag) { $this->txtTextbox->Name = 'Other...'; if (!$this->lstListbox->SelectedValue && strlen(trim($this->objAnswer->TextValue))) { $blnOtherSelected = true; $this->txtTextbox->Text = trim($this->objAnswer->TextValue); } else { $blnOtherSelected = false; } $this->txtTextbox->Enabled = $blnOtherSelected; $this->lstListbox->AddItem('- Other... -', false, $blnOtherSelected); $this->lstListbox->AddAction(new QChangeEvent(), new QAjaxAction('lstListbox_Change')); $this->lstListbox_Change(); } break; case FormQuestionType::MultipleSelect: //GJS - changing to multiple check boxes $this->chkAnswer->Name = $objFormQuestion->ShortDescription; $this->chkAnswer->RemoveAllItems(); // Get the answers $strAnswerArray = $this->objAnswer->GetSelectedMultipleChoiceArray(); foreach (explode("\n", trim($objFormQuestion->Options)) as $strItem) { if (strlen($strItem = trim($strItem))) { $this->chkAnswer->AddItem($strItem, $strItem, array_key_exists($strItem, $strAnswerArray)); $strAnswerArray[$strItem] = null; unset($strAnswerArray[$strItem]); } } foreach ($strAnswerArray as $strAnswer) { $this->chkAnswer->AddItem($strAnswer, $strAnswer, true); } // Are we allowing "others"? if ($objFormQuestion->AllowOtherFlag) { $this->txtTextbox->Name = 'Other...'; $this->txtTextbox->Text = null; $this->txtTextbox->RemoveAllActions(QEnterKeyEvent::EventName); $this->txtTextbox->AddAction(new QEnterKeyEvent(), new QAjaxAction('txtTextbox_EnterKey')); $this->txtTextbox->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $this->txtTextbox->Instructions = 'Type in a value and hit <strong>return</strong> to add it to the list'; } break; case FormQuestionType::Number: $this->txtInteger->Text = $this->objAnswer->IntegerValue; $this->txtInteger->Name = $objFormQuestion->ShortDescription; break; case FormQuestionType::Age: $this->txtTextbox->Name = $objFormQuestion->ShortDescription; $this->txtTextbox->Text = $objPerson->Age; $this->txtTextbox->Enabled = false; $this->lblInstructions->Text = sprintf('If you need modify the person\'s age, you will need to <a href="%s">update this person\'s NOAH information</a>.', $objPerson->LinkUrl); break; case FormQuestionType::DateofBirth: $this->txtTextbox->Name = $objFormQuestion->ShortDescription; $this->txtTextbox->Text = $objPerson->DateOfBirth ? $objPerson->DateOfBirth->ToString('MMM D YYYY') : null; $this->txtTextbox->Enabled = false; $this->lblInstructions->Text = sprintf('If you need modify the person\'s date of birth, you will need to <a href="%s">update this person\'s NOAH information</a>.', $objPerson->LinkUrl); break; } }
function __construct() { parent::__construct(); }
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); }
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 pxyMoveUpQuestion_Click($strFormId, $strControlId, $strParameter) { $objFormQuestion = FormQuestion::Load($strParameter); $objFormQuestion->MoveUp(); $this->dtgQuestions->Refresh(); }
/** * Deletes all associated FormQuestions * @return void */ public function DeleteAllFormQuestions() { if (is_null($this->intId)) { throw new QUndefinedPrimaryKeyException('Unable to call UnassociateFormQuestion on this unsaved SignupForm.'); } // Get the Database Object for this Class $objDatabase = SignupForm::GetDatabase(); // Journaling if ($objDatabase->JournalingDatabase) { foreach (FormQuestion::LoadArrayBySignupFormId($this->intId) as $objFormQuestion) { $objFormQuestion->Journal('DELETE'); } } // Perform the SQL Query $objDatabase->NonQuery(' DELETE FROM `form_question` WHERE `signup_form_id` = ' . $objDatabase->SqlVariable($this->intId) . ' '); }
/** * Main utility method to aid with data binding. It is used by the default BindAllRows() databinder but * could and should be used by any custom databind methods that would be used for instances of this * MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause. * * If a paginator is set on this DataBinder, it will use it. If not, then no pagination will be used. * It will also perform any sorting (if applicable). * * @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself * @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query * @return void */ public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null) { // Setup input parameters to default values if none passed in if (!$objCondition) { $objCondition = QQ::All(); } $objClauses = $objOptionalClauses ? $objOptionalClauses : array(); // We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below if ($this->Paginator) { $this->TotalItemCount = FormQuestion::QueryCount($objCondition, $objClauses); } // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add // the OrderByClause to the $objClauses array if ($objClause = $this->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be a Query result from FormQuestion, given the clauses above $this->DataSource = FormQuestion::QueryArray($objCondition, $objClauses); }