/** * Create and setup QListBox lstState * @param string $strControlId optional ControlId to use * @return QListBox */ public function lstState_Create($strControlId = null) { $this->lstState = new QListBox($this->objParentObject, $strControlId); $this->lstState->Name = QApplication::Translate('State'); $this->lstState->AddItem(QApplication::Translate('- Select One -'), null); foreach (UsState::LoadAll(QQ::OrderBy(QQN::UsState()->Name)) as $objUsState) { $this->lstState->AddItem($objUsState->Name, $objUsState->Abbreviation, $this->objAddress->State == $objUsState->Abbreviation); } return $this->lstState; }
protected function btnAddress_Click($strFormId, $strControlId, $strParameter) { if (!$this->txtHomeAddress1) { $this->txtHomeAddress1 = new QTextBox($this->dlgAddress); $this->txtHomeAddress1->Name = 'Home Address 1'; $this->txtHomeAddress1->Required = true; $this->txtHomeAddress2 = new QTextBox($this->dlgAddress); $this->txtHomeAddress2->Name = 'Home Address 2'; $this->txtHomeCity = new QTextBox($this->dlgAddress); $this->txtHomeCity->Name = 'Home City, State, Zip'; $this->txtHomeCity->Required = true; $this->lstHomeState = new QListBox($this->dlgAddress); $this->lstHomeState->AddItem(QApplication::Translate('- Select One -'), null); $this->lstHomeState->Required = true; foreach (UsState::LoadAll(QQ::OrderBy(QQN::UsState()->Name)) as $objUsState) { $this->lstHomeState->AddItem($objUsState->Name, $objUsState->Abbreviation); } $this->txtHomeZipCode = new QTextBox($this->dlgAddress); $this->txtHomeZipCode->Required = true; $this->txtHomePhone = new PhoneTextBox($this->dlgAddress); $this->txtHomePhone->Name = 'Home Phone'; $this->rblMailingAddress = new QRadioButtonList($this->dlgAddress); $this->rblMailingAddress->Name = 'Separate Mailing Address?'; $this->rblMailingAddress->AddItem('Yes, please use my separate mailing address', true); $this->rblMailingAddress->AddItem('No, I do not use a separate mailing address', false); $this->rblMailingAddress->AddAction(new QClickEvent(), new QAjaxAction('rblMailingAddress_Refresh')); $this->txtMailingAddress1 = new QTextBox($this->dlgAddress); $this->txtMailingAddress1->Name = 'Mailing Address 1'; $this->txtMailingAddress1->Required = true; $this->txtMailingAddress2 = new QTextBox($this->dlgAddress); $this->txtMailingAddress2->Name = 'Mailing Address 2'; $this->txtMailingCity = new QTextBox($this->dlgAddress); $this->txtMailingCity->Name = 'Mailing City, State, Zip'; $this->txtMailingCity->Required = true; $this->lstMailingState = new QListBox($this->dlgAddress); $this->lstMailingState->AddItem(QApplication::Translate('- Select One -'), null); $this->lstMailingState->Required = true; foreach (UsState::LoadAll(QQ::OrderBy(QQN::UsState()->Name)) as $objUsState) { $this->lstMailingState->AddItem($objUsState->Name, $objUsState->Abbreviation); } $this->txtMailingZipCode = new QTextBox($this->dlgAddress); $this->txtMailingZipCode->Required = true; } $objHouseholdArray = array(); foreach (QApplication::$PublicLogin->Person->GetHouseholdParticipationArray() as $objParticipation) { $objHouseholdArray[] = $objParticipation->Household; } if (count($objHouseholdArray) > 1) { return; } if (count($objHouseholdArray) == 1) { $objAddress = $objHouseholdArray[0]->GetCurrentAddress(); if (!$objAddress) { $objAddress = new Address(); } $this->txtHomeAddress1->Text = $objAddress->Address1; $this->txtHomeAddress2->Text = $objAddress->Address2; $this->txtHomeCity->Text = $objAddress->City; $this->lstHomeState->SelectedValue = $objAddress->State; $this->txtHomeZipCode->Text = $objAddress->ZipCode; if (count($objPhoneArray = $objAddress->GetPhoneArray())) { $this->txtHomePhone->Text = $objPhoneArray[0]->Number; } } if (QApplication::$PublicLogin->Person->MailingAddress && !QApplication::$PublicLogin->Person->MailingAddress->Household) { $this->rblMailingAddress->SelectedValue = true; $objAddress = QApplication::$PublicLogin->Person->MailingAddress; $this->txtMailingAddress1->Text = $objAddress->Address1; $this->txtMailingAddress2->Text = $objAddress->Address2; $this->txtMailingCity->Text = $objAddress->City; $this->lstMailingState->SelectedValue = $objAddress->State; $this->txtMailingZipCode->Text = $objAddress->ZipCode; } else { $this->rblMailingAddress->SelectedValue = false; } $this->btnAddressUpdate->ActionParameter = 1; $this->btnAddressCancel->ActionParameter = 1; $this->dlgAddress->ShowDialogBox(); $this->dlgAddress->Template = dirname(__FILE__) . '/dlgAddress.inc.php'; $this->rblMailingAddress_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 UsStateMetaControl * @param integer $intId primary key value * @param QMetaControlCreateType $intCreateType rules governing UsState object creation - defaults to CreateOrEdit * @return UsStateMetaControl */ public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intId)) { $objUsState = UsState::Load($intId); // UsState was found -- return it! if ($objUsState) { return new UsStateMetaControl($objParentObject, $objUsState); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a UsState 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 UsStateMetaControl($objParentObject, new UsState()); }
/** * 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 = UsState::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 UsState, given the clauses above $this->DataSource = UsState::QueryArray($objCondition, $objClauses); }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, UsState::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
protected function pnlDetailsMain_Setup() { $this->lblUsername = new QLabel($this->pnlDetailsMain); $this->lblUsername->Name = 'Username'; $this->lblUsername->Text = QApplication::$PublicLogin->Username; $this->lblName = new QLabel($this->pnlDetailsMain); $this->lblName->Name = 'Name'; $this->lblName->Text = QApplication::$PublicLogin->ProvisionalPublicLogin->FirstName . ' ' . QApplication::$PublicLogin->ProvisionalPublicLogin->LastName; $this->lblEmail = new QLabel($this->pnlDetailsMain); $this->lblEmail->Name = 'Email Address'; $this->lblEmail->Text = QApplication::$PublicLogin->ProvisionalPublicLogin->EmailAddress; $this->txtPassword = new QTextBox($this->pnlDetailsMain); $this->txtPassword->Name = 'Select a Password'; $this->txtPassword->Required = true; $this->txtPassword->TextMode = QTextMode::Password; $this->txtPassword->Instructions = 'At least 6 characters long'; $this->txtConfirmPassword = new QTextBox($this->pnlDetailsMain); $this->txtConfirmPassword->Name = 'Confirm Password'; $this->txtConfirmPassword->Instructions = 'Must match above'; $this->txtConfirmPassword->Required = true; $this->txtConfirmPassword->TextMode = QTextMode::Password; $this->lstQuestion = new QListBox($this->pnlDetailsMain); $this->lstQuestion->Name = '"Forgot Password" Question'; $this->lstQuestion->AddItem('- Select One -', null); $this->lstQuestion->AddItem('What city were you born in?', 'What city were you born in?'); $this->lstQuestion->AddItem('What is the name of your elementary school?', 'What is the name of your elementary school?'); $this->lstQuestion->AddItem('What street did you grow up on?', 'What street did you grow up on?'); $this->lstQuestion->AddItem('What is the name of your pet?', 'What is the name of your pet?'); $this->lstQuestion->AddItem('What was the make and model of your first car?', 'What was the make and model of your first car?'); $this->lstQuestion->AddItem('- Other... -', false); $this->lstQuestion->Required = true; $this->lstQuestion->AddAction(new QChangeEvent(), new QAjaxAction('lstQuestion_Refresh')); $this->txtQuestion = new QTextBox($this->pnlDetailsMain); $this->txtAnswer = new QTextBox($this->pnlDetailsMain); $this->txtAnswer->Name = 'Your Answer'; $this->txtAnswer->Required = true; $this->lstQuestion_Refresh(); $this->txtHomeAddress1 = new QTextBox($this->pnlDetailsMain); $this->txtHomeAddress1->Name = 'Home Address 1'; $this->txtHomeAddress1->Required = true; $this->txtHomeAddress2 = new QTextBox($this->pnlDetailsMain); $this->txtHomeAddress2->Name = 'Home Address 2'; $this->txtHomeCity = new QTextBox($this->pnlDetailsMain); $this->txtHomeCity->Name = 'Home City, State, Zip'; $this->txtHomeCity->Required = true; $this->lstHomeState = new QListBox($this->pnlDetailsMain); $this->lstHomeState->AddItem(QApplication::Translate('- Select One -'), null); $this->lstHomeState->Required = true; foreach (UsState::LoadAll(QQ::OrderBy(QQN::UsState()->Name)) as $objUsState) { $this->lstHomeState->AddItem($objUsState->Name, $objUsState->Abbreviation); } $this->txtHomeZipCode = new QTextBox($this->pnlDetailsMain); $this->txtHomeZipCode->Required = true; $this->rblMailingAddress = new QRadioButtonList($this->pnlDetailsMain); $this->rblMailingAddress->Name = 'Separate Mailing Address?'; $this->rblMailingAddress->AddItem('Yes, please use my separate mailing address', true); $this->rblMailingAddress->AddItem('No, I do not use a separate mailing address', false, true); $this->rblMailingAddress->AddAction(new QClickEvent(), new QAjaxAction('rblMailingAddress_Refresh')); $this->txtMailingAddress1 = new QTextBox($this->pnlDetailsMain); $this->txtMailingAddress1->Name = 'Mailing Address 1'; $this->txtMailingAddress1->Required = true; $this->txtMailingAddress2 = new QTextBox($this->pnlDetailsMain); $this->txtMailingAddress2->Name = 'Mailing Address 2'; $this->txtMailingCity = new QTextBox($this->pnlDetailsMain); $this->txtMailingCity->Name = 'Mailing City, State, Zip'; $this->txtMailingCity->Required = true; $this->lstMailingState = new QListBox($this->pnlDetailsMain); $this->lstMailingState->AddItem(QApplication::Translate('- Select One -'), null); $this->lstMailingState->Required = true; foreach (UsState::LoadAll(QQ::OrderBy(QQN::UsState()->Name)) as $objUsState) { $this->lstMailingState->AddItem($objUsState->Name, $objUsState->Abbreviation); } $this->txtMailingZipCode = new QTextBox($this->pnlDetailsMain); $this->txtMailingZipCode->Required = true; $this->rblMailingAddress_Refresh(); $this->dtxDateOfBirth = new QDateTimeTextBox($this->pnlDetailsMain); $this->dtxDateOfBirth->Name = 'Date of Birth'; $this->calDateOfBirth = new QCalendar($this->dtxDateOfBirth, $this->dtxDateOfBirth); $this->dtxDateOfBirth->RemoveAllActions(QClickEvent::EventName); $this->rblGender = new QRadioButtonList($this->pnlDetailsMain); $this->rblGender->AddItem('Male', 'M'); $this->rblGender->AddItem('Female', 'F'); $this->rblGender->Name = 'Gender'; $this->rblGender->RepeatColumns = 2; $this->chkBulkEmail = new QCheckBox($this->pnlDetailsMain); $this->chkBulkEmail->Name = 'ALCF Email Announcements'; $this->chkBulkEmail->Text = 'Check to be included on any general ALCF or church-wide email announcements'; $this->chkBulkEmail->HtmlEntities = false; $this->chkBulkEmail->Checked = true; $this->txtHomePhone = new PhoneTextBox($this->pnlDetailsMain); $this->txtHomePhone->Name = 'Home Phone'; $this->txtMobilePhone = new PhoneTextBox($this->pnlDetailsMain); $this->txtMobilePhone->Name = 'Mobile Phone'; $this->btnConfirm = new QButton($this->pnlDetailsMain); $this->btnConfirm->Text = 'Confirm Registration'; $this->btnConfirm->CausesValidation = true; $this->btnConfirm->AddAction(new QClickEvent(), new QToggleEnableAction($this->btnConfirm)); $this->btnConfirm->AddAction(new QClickEvent(), new QAjaxAction('btnConfirm_Click')); $this->btnCancel = new QLinkButton($this->pnlDetailsMain); $this->btnCancel->Text = 'Cancel'; $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click')); $this->btnCancel->AddAction(new QClickEvent(), new QTerminateAction()); }
/** * 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 function __construct($objParentObject, $strControlId = null, Address $objAddress = null, $strFirstName = null, $strLastName = null) { parent::__construct($objParentObject, $strControlId); $this->strTemplate = dirname(__FILE__) . '/PaymentPanel.tpl.php'; if (!$objAddress) { $objAddress = new Address(); } $this->txtFirstName = new QTextBox($this); $this->txtFirstName->Name = 'Cardholder Name'; $this->txtFirstName->Required = true; $this->txtFirstName->Text = $strFirstName; $this->txtFirstName->Width = '120px'; $this->txtLastName = new QTextBox($this); $this->txtLastName->Name = 'Cardholder Last Name'; $this->txtLastName->Required = true; $this->txtLastName->Text = $strLastName; $this->txtLastName->Width = '120px'; $this->txtAddress1 = new QTextBox($this); $this->txtAddress1->Name = 'Address 1'; $this->txtAddress1->Text = $objAddress->Address1; $this->txtAddress1->Required = true; $this->txtAddress2 = new QTextBox($this); $this->txtAddress2->Name = 'Address 2'; $this->txtAddress2->Text = $objAddress->Address2; $this->txtCity = new QTextBox($this); $this->txtCity->Name = 'City, State and Zip'; $this->txtCity->Text = $objAddress->City; $this->txtCity->Required = true; $this->lstState = new QListBox($this); $this->lstState->Name = QApplication::Translate('State'); $this->lstState->AddItem(QApplication::Translate('- Select One -'), null); foreach (UsState::LoadAll(QQ::OrderBy(QQN::UsState()->Name)) as $objUsState) { $this->lstState->AddItem($objUsState->Name, $objUsState->Abbreviation, $objAddress->State == $objUsState->Abbreviation); } $this->lstState->Required = true; $this->txtZipCode = new QTextBox($this); $this->txtZipCode->Name = 'Zip Code'; $this->txtZipCode->Text = $objAddress->ZipCode; $this->txtZipCode->Width = '80px'; $this->txtZipCode->Required = true; $this->lstCcType = new QListBox($this); $this->lstCcType->Name = 'Credit Card'; $this->lstCcType->Required = true; $this->lstCcType->AddItem('- Select One -'); foreach (CreditCardType::$NameArray as $intId => $strName) { $this->lstCcType->AddItem($strName, $intId); } $this->txtCcNumber = new QTextBox($this); $this->txtCcNumber->Name = 'Account Number'; $this->txtCcNumber->Required = true; $this->txtCcNumber->MaxLength = 16; $this->lstCcExpMonth = new QListBox($this); $this->lstCcExpMonth->Name = 'Expiration Date'; $this->lstCcExpMonth->Required = true; $this->lstCcExpMonth->AddItem('- Select One -'); for ($intMonth = 1; $intMonth <= 12; $intMonth++) { $strMonth = date('F', mktime(0, 0, 0, $intMonth, 1, 2000)); $this->lstCcExpMonth->AddItem(sprintf('%02s - %s', $intMonth, $strMonth), $intMonth); } $this->lstCcExpYear = new QListBox($this); $this->lstCcExpYear->Required = true; $this->lstCcExpYear->AddItem('---'); for ($intYear = 0; $intYear <= 11; $intYear++) { $intYearToUse = date('Y') + $intYear; $this->lstCcExpYear->AddItem($intYearToUse, $intYearToUse); } $this->txtCcCsc = new QTextBox($this); $this->txtCcCsc->Name = 'Security Code (CSC/CVV2)'; $this->txtCcCsc->Required = true; $this->txtCcCsc->Width = '80px'; $this->txtCcCsc->MinLength = 3; $this->txtCcCsc->MaxLength = 4; $this->dlgDialogBox = new QDialogBox($this); $this->dlgDialogBox->MatteClickable = false; $this->dlgDialogBox->Display = false; $this->dlgDialogBox->Template = dirname(__FILE__) . '/PaymentPanel_DialogBox.tpl.php'; $this->btnDialogBoxOkay = new QButton($this->dlgDialogBox); $this->btnDialogBoxOkay->Text = 'Try Again'; $this->btnDialogBoxOkay->CssClass = 'primary'; $this->btnDialogBoxOkay->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDialogBoxOkay_Click')); $this->btnDialogBoxOkay->Visible = false; $this->lblDialogBoxMessage = new QLabel($this->dlgDialogBox); $this->lblDialogBoxMessage->HtmlEntities = false; $this->lblDialogBoxMessage->Text = '<h4>Please Wait...</h4>We are processing your credit card. We appreciate your patience!<br/><br/><img src="/assets/images/cc_processing.gif"/>'; $this->btnSubmit = new QButton($this); $this->btnSubmit->CausesValidation = true; $this->btnSubmit->CssClass = 'primary'; $this->btnSubmit->Text = 'Submit'; $this->btnSubmit->AddAction(new QClickEvent(), new QConfirmAction('By proceeding, your credit card will be charged for the amount shown. Are you SURE you wish to proceed?')); $this->btnSubmit->AddAction(new QClickEvent(), new QToggleEnableAction($this->btnSubmit)); $this->btnSubmit->AddAction(new QClickEvent(), new QShowDialogBox($this->dlgDialogBox)); $this->btnSubmit->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSubmit_Click')); }
public function __construct($objParentObject, $strControlId = null, Address $objAddress = null, $strFirstName = null, $strLastName = null, RecurringPayments $objRecurringPayment = null) { parent::__construct($objParentObject, $strControlId); $this->strTemplate = dirname(__FILE__) . '/RecurringPaymentPanel.tpl.php'; if (!$objAddress) { $objAddress = new Address(); } $this->txtFirstName = new QTextBox($this); $this->txtFirstName->Name = 'Cardholder Name'; $this->txtFirstName->Required = true; $this->txtFirstName->Text = $strFirstName; $this->txtFirstName->Width = '120px'; $this->txtLastName = new QTextBox($this); $this->txtLastName->Name = 'Cardholder Last Name'; $this->txtLastName->Required = true; $this->txtLastName->Text = $strLastName; $this->txtLastName->Width = '120px'; QCryptography::$Key = CRYPTO_KEY; $objCrypto = new QCryptography(null, false); if ($objRecurringPayment) { $strOriginal = $objCrypto->Decrypt($objRecurringPayment->CardHolderName); $nameArray = explode(' ', $strOriginal); $this->txtFirstName->Text = $nameArray[0]; $this->txtLastName->Text = $nameArray[1]; } $this->txtAddress1 = new QTextBox($this); $this->txtAddress1->Name = 'Address 1'; if (!$objRecurringPayment) { $this->txtAddress1->Text = $objAddress->Address1; } else { $this->txtAddress1->Text = $objCrypto->Decrypt($objRecurringPayment->Address1); } $this->txtAddress1->Required = true; $this->txtAddress2 = new QTextBox($this); $this->txtAddress2->Name = 'Address 2'; if (!$objRecurringPayment) { $this->txtAddress2->Text = $objAddress->Address2; } else { $this->txtAddress2->Text = $objCrypto->Decrypt($objRecurringPayment->Address2); } $this->txtCity = new QTextBox($this); $this->txtCity->Name = 'City, State and Zip'; if (!$objRecurringPayment) { $this->txtCity->Text = $objAddress->City; } else { $this->txtCity->Text = $objCrypto->Decrypt($objRecurringPayment->City); } $this->txtCity->Required = true; $this->lstState = new QListBox($this); $this->lstState->Name = QApplication::Translate('State'); $this->lstState->AddItem(QApplication::Translate('- Select One -'), null); foreach (UsState::LoadAll(QQ::OrderBy(QQN::UsState()->Name)) as $objUsState) { $this->lstState->AddItem($objUsState->Name, $objUsState->Abbreviation, $objAddress->State == $objUsState->Abbreviation); } $this->lstState->Required = true; $this->txtZipCode = new QTextBox($this); $this->txtZipCode->Name = 'Zip Code'; if (!$objRecurringPayment) { $this->txtZipCode->Text = $objAddress->ZipCode; } else { $this->txtZipCode->Text = $objCrypto->Decrypt($objRecurringPayment->Zip); } $this->txtZipCode->Width = '80px'; $this->txtZipCode->Required = true; $this->lstCcType = new QListBox($this); $this->lstCcType->Name = 'Credit Card'; $this->lstCcType->Required = true; $this->lstCcType->AddItem('- Select One -'); foreach (CreditCardType::$NameArray as $intId => $strName) { if ($objRecurringPayment) { $this->lstCcType->AddItem($strName, $intId, $objRecurringPayment->CreditCardTypeId == $intId); } else { $this->lstCcType->AddItem($strName, $intId); } } $this->txtCcNumber = new QTextBox($this); $this->txtCcNumber->Name = 'Account Number'; $this->txtCcNumber->Required = true; $this->txtCcNumber->MaxLength = 16; if ($objRecurringPayment) { $this->txtCcNumber->Text = $objCrypto->Decrypt($objRecurringPayment->AccountNumber); $objExpirationDate = $objRecurringPayment->ExpirationDate; //$objCrypto->Decrypt($objRecurringPayment->ExpirationDate); $intSelectedMonth = substr($objExpirationDate, 0, 2); $intSelectedYear = substr($objExpirationDate, 2, 2); } $this->lstCcExpMonth = new QListBox($this); $this->lstCcExpMonth->Name = 'Expiration Date'; $this->lstCcExpMonth->Required = true; $this->lstCcExpMonth->AddItem('- Select One -'); for ($intMonth = 1; $intMonth <= 12; $intMonth++) { $strMonth = date('F', mktime(0, 0, 0, $intMonth, 1, 2000)); if (!$objRecurringPayment) { $this->lstCcExpMonth->AddItem(sprintf('%02s - %s', $intMonth, $strMonth), $intMonth); } else { $this->lstCcExpMonth->AddItem(sprintf('%02s - %s', $intMonth, $strMonth), $intMonth, $intSelectedMonth == $intMonth); } } $this->lstCcExpYear = new QListBox($this); $this->lstCcExpYear->Required = true; $this->lstCcExpYear->AddItem('---'); for ($intYear = 0; $intYear <= 11; $intYear++) { $intYearToUse = date('Y') + $intYear; $intCmpYear = substr($intYearToUse, 2, 2); if (!$objRecurringPayment) { $this->lstCcExpYear->AddItem($intYearToUse, $intYearToUse); } else { $this->lstCcExpYear->AddItem($intYearToUse, $intYearToUse, $intSelectedYear == $intCmpYear); } } $this->txtCcCsc = new QTextBox($this); $this->txtCcCsc->Name = 'Security Code (CSC/CVV2)'; $this->txtCcCsc->Required = true; $this->txtCcCsc->Width = '80px'; $this->txtCcCsc->MinLength = 3; $this->txtCcCsc->MaxLength = 4; if ($objRecurringPayment) { $this->txtCcCsc->Text = $objCrypto->Decrypt($objRecurringPayment->SecurityCode); } }