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()); }
/** * Override method to perform a property "Get" * This will get the value of $strName * * @param string $strName Name of the property to get * @return mixed */ public function __get($strName) { switch ($strName) { /////////////////// // Member Variables /////////////////// case 'Id': // Gets the value for intId (Read-Only PK) // @return integer return $this->intId; case 'SignupEntryId': // Gets the value for intSignupEntryId (Not Null) // @return integer return $this->intSignupEntryId; case 'FormQuestionId': // Gets the value for intFormQuestionId (Not Null) // @return integer return $this->intFormQuestionId; case 'TextValue': // Gets the value for strTextValue // @return string return $this->strTextValue; case 'AddressId': // Gets the value for intAddressId // @return integer return $this->intAddressId; case 'PhoneId': // Gets the value for intPhoneId // @return integer return $this->intPhoneId; case 'EmailId': // Gets the value for intEmailId // @return integer return $this->intEmailId; case 'IntegerValue': // Gets the value for intIntegerValue // @return integer return $this->intIntegerValue; case 'BooleanValue': // Gets the value for blnBooleanValue // @return boolean return $this->blnBooleanValue; case 'DateValue': // Gets the value for dttDateValue // @return QDateTime return $this->dttDateValue; /////////////////// // Member Objects /////////////////// /////////////////// // Member Objects /////////////////// case 'SignupEntry': // Gets the value for the SignupEntry object referenced by intSignupEntryId (Not Null) // @return SignupEntry try { if (!$this->objSignupEntry && !is_null($this->intSignupEntryId)) { $this->objSignupEntry = SignupEntry::Load($this->intSignupEntryId); } return $this->objSignupEntry; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'FormQuestion': // Gets the value for the FormQuestion object referenced by intFormQuestionId (Not Null) // @return FormQuestion try { if (!$this->objFormQuestion && !is_null($this->intFormQuestionId)) { $this->objFormQuestion = FormQuestion::Load($this->intFormQuestionId); } return $this->objFormQuestion; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'Address': // Gets the value for the Address object referenced by intAddressId // @return Address try { if (!$this->objAddress && !is_null($this->intAddressId)) { $this->objAddress = Address::Load($this->intAddressId); } return $this->objAddress; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'Phone': // Gets the value for the Phone object referenced by intPhoneId // @return Phone try { if (!$this->objPhone && !is_null($this->intPhoneId)) { $this->objPhone = Phone::Load($this->intPhoneId); } return $this->objPhone; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'Email': // Gets the value for the Email object referenced by intEmailId // @return Email try { if (!$this->objEmail && !is_null($this->intEmailId)) { $this->objEmail = Email::Load($this->intEmailId); } return $this->objEmail; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } //////////////////////////// // Virtual Object References (Many to Many and Reverse References) // (If restored via a "Many-to" expansion) //////////////////////////// //////////////////////////// // Virtual Object References (Many to Many and Reverse References) // (If restored via a "Many-to" expansion) //////////////////////////// case '__Restored': return $this->__blnRestored; default: try { return parent::__get($strName); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } }
protected function Form_Create() { $this->objSignupForm = SignupForm::Load(QApplication::PathInfo(0)); $this->lblHeading = new QLabel($this); if (!$this->objSignupForm) { QApplication::Redirect('/events/'); } if (!$this->objSignupForm->Ministry->IsLoginCanAdminMinistry(QApplication::$Login)) { QApplication::Redirect('/events/form.php/' . $this->objSignupForm->Id); } if (QApplication::PathInfo(1)) { $objQuestion = FormQuestion::Load(QApplication::PathInfo(1)); if (!$objQuestion) { QApplication::Redirect('/events/form.php/' . $this->objSignupForm->Id); } if ($objQuestion->SignupFormId != $this->objSignupForm->Id) { QApplication::Redirect('/events/form.php/' . $this->objSignupForm->Id); } $this->strPageTitle .= 'Edit Question'; $this->lblHeading->Text = 'Edit ' . $objQuestion->Type . ' Question'; } else { if (!QApplication::PathInfo(2)) { QApplication::Redirect('/events/form.php/' . $this->objSignupForm->Id); } $objQuestion = new FormQuestion(); $objQuestion->SignupForm = $this->objSignupForm; $objQuestion->FormQuestionTypeId = QApplication::PathInfo(2); $objQuestion->OrderNumber = 100000; $this->strPageTitle .= 'Create New Question'; $this->lblHeading->Text = 'Create New ' . $objQuestion->Type . ' Question'; // Pre-setup certain fields based on type switch ($objQuestion->FormQuestionTypeId) { case FormQuestionType::SpouseName: $objQuestion->ShortDescription = 'Spouse\'s Name'; $objQuestion->Question = 'Spouse\'s Name'; break; case FormQuestionType::Address: $objQuestion->ShortDescription = 'Home Address'; $objQuestion->Question = 'Home Address'; break; case FormQuestionType::Age: $objQuestion->ShortDescription = 'Age'; $objQuestion->Question = 'Age'; break; case FormQuestionType::DateofBirth: $objQuestion->ShortDescription = 'Date of Birth'; $objQuestion->Question = 'Date of Birth'; break; case FormQuestionType::Gender: $objQuestion->ShortDescription = 'Gender'; $objQuestion->Question = 'Gender'; break; case FormQuestionType::Phone: $objQuestion->ShortDescription = 'Phone Number'; $objQuestion->Question = 'Phone Number'; break; case FormQuestionType::Email: $objQuestion->ShortDescription = 'Email Address'; $objQuestion->Question = 'Email Address'; break; } } $this->mctQuestion = new FormQuestionMetaControl($this, $objQuestion); // Fields $this->lblFormQuestionType = $this->mctQuestion->lblFormQuestionTypeId_Create(); $this->txtShortDescription = $this->mctQuestion->txtShortDescription_Create(); $this->txtShortDescription->Required = true; $this->txtShortDescription->Instructions = 'This is the label that will show up on reports and forms'; $this->chkInternalFlag = $this->mctQuestion->chkInternalFlag_Create(); $this->chkInternalFlag->Text = 'Check if this question is only for internal use, and is <strong>NOT</strong> to be displayed on the registration form'; $this->chkInternalFlag->HtmlEntities = false; $this->txtQuestion = $this->mctQuestion->txtQuestion_Create(); $this->txtQuestion->Required = true; $this->txtQuestion->Instructions = 'This is the label that will show up on the signup form online'; $this->chkRequiredFlag = $this->mctQuestion->chkRequiredFlag_Create(); $this->chkRequiredFlag->Name = 'Answer Required?'; $this->chkRequiredFlag->Text = 'Check if an answer to this question is required'; $this->txtOptions = $this->mctQuestion->txtOptions_Create(); $this->chkAllowOtherFlag = $this->mctQuestion->chkAllowOtherFlag_Create(); // Field options based on type switch ($intFormQuestionTypeId = $this->mctQuestion->FormQuestion->FormQuestionTypeId) { case FormQuestionType::SpouseName: case FormQuestionType::Address: case FormQuestionType::Age: case FormQuestionType::DateofBirth: case FormQuestionType::Gender: case FormQuestionType::Phone: case FormQuestionType::Email: case FormQuestionType::ShortText: case FormQuestionType::LongText: case FormQuestionType::Number: $this->txtOptions->Text = null; $this->txtOptions->Required = false; $this->txtOptions->Visible = false; $this->chkAllowOtherFlag->Checked = false; $this->chkAllowOtherFlag->Required = false; $this->chkAllowOtherFlag->Visible = false; break; case FormQuestionType::YesNo: $this->txtOptions->TextMode = QTextMode::SingleLine; $this->txtOptions->Name = 'Text by the Checkbox'; $this->txtOptions->Required = false; $this->txtOptions->Visible = true; $this->chkAllowOtherFlag->Checked = false; $this->chkAllowOtherFlag->Required = false; $this->chkAllowOtherFlag->Visible = false; $this->chkRequiredFlag->Text = 'Check if the registrant is <strong>REQUIRED</strong> check "yes"'; $this->chkRequiredFlag->HtmlEntities = false; break; case FormQuestionType::SingleSelect: case FormQuestionType::MultipleSelect: $this->txtOptions->Required = true; $this->txtOptions->Visible = true; $this->chkAllowOtherFlag->Required = false; $this->chkAllowOtherFlag->Visible = true; break; case FormQuestionType::Instructions: $this->txtOptions->Name = 'Instructions Text'; $this->txtOptions->Required = true; $this->txtOptions->Visible = true; $this->chkAllowOtherFlag->Checked = false; $this->chkAllowOtherFlag->Required = false; $this->chkAllowOtherFlag->Visible = false; $this->chkRequiredFlag->Visible = false; $this->txtShortDescription->Text = '(instructions)'; $this->txtShortDescription->Visible = false; $this->chkRequiredFlag->Visible = false; $this->txtQuestion->Name = 'Label'; $this->txtQuestion->Instructions = null; $this->txtQuestion->Required = false; $this->chkInternalFlag->Visible = false; break; default: throw new Exception(sprintf('Invalid intFormQuestionTypeId: %s', $intFormQuestionTypeId)); } // Buttons $this->btnSave = new QButton($this); $this->btnSave->Text = 'Save'; $this->btnSave->CssClass = 'primary'; $this->btnSave->CausesValidation = true; $this->btnSave->AddAction(new QClickEvent(), new QAjaxAction('btnSave_Click')); $this->btnCancel = new QLinkButton($this); $this->btnCancel->Text = 'Cancel'; $this->btnCancel->CssClass = 'cancel'; $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click')); // Delete? if ($this->mctQuestion->EditMode) { $this->btnDelete = new QLinkButton($this); $this->btnDelete->Text = 'Delete'; $this->btnDelete->CssClass = 'delete'; $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction('Are you SURE you want to DELETE this Signup Form? Any responsese from existing registrations will be deleted as well, and this cannot be undone.')); $this->btnDelete->AddAction(new QClickEvent(), new QAjaxAction('btnDelete_Click')); $this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction()); } }
/** * Reload this FormQuestion from the database. * @return void */ public function Reload() { // Make sure we are actually Restored from the database if (!$this->__blnRestored) { throw new QCallerException('Cannot call Reload() on a new, unsaved FormQuestion object.'); } // Reload the Object $objReloaded = FormQuestion::Load($this->intId); // Update $this's local variables to match $this->SignupFormId = $objReloaded->SignupFormId; $this->intOrderNumber = $objReloaded->intOrderNumber; $this->FormQuestionTypeId = $objReloaded->FormQuestionTypeId; $this->strShortDescription = $objReloaded->strShortDescription; $this->strQuestion = $objReloaded->strQuestion; $this->blnRequiredFlag = $objReloaded->blnRequiredFlag; $this->blnInternalFlag = $objReloaded->blnInternalFlag; $this->strOptions = $objReloaded->strOptions; $this->blnAllowOtherFlag = $objReloaded->blnAllowOtherFlag; $this->blnViewFlag = $objReloaded->blnViewFlag; }
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; } }
public function pxyMoveUpQuestion_Click($strFormId, $strControlId, $strParameter) { $objFormQuestion = FormQuestion::Load($strParameter); $objFormQuestion->MoveUp(); $this->dtgQuestions->Refresh(); }