protected function SetupPanel()
 {
     // Get and Validate the Address Object
     $this->mctAddress = AddressMetaControl::Create($this, $this->strUrlHashArgument, QMetaControlCreateType::CreateOnRecordNotFound);
     // Dialog Message
     $this->dlgMessage = new MessageDialog($this);
     $this->dlgMessage_Reset();
     $this->btnSave->RemoveAllActions(QClickEvent::EventName);
     $this->btnSave->AddAction(new QClickEvent(), new QShowDialogBox($this->dlgMessage));
     $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
     if (!$this->mctAddress->EditMode) {
         // Trying to create a NEW address
         $this->mctAddress->Address->Person = $this->objPerson;
         $this->btnSave->Text = 'Create';
     } else {
         // Ensure the Address object belongs to the person
         if ($this->mctAddress->Address->PersonId != $this->objPerson->Id) {
             return $this->ReturnTo('#contact');
         }
         $this->btnSave->Text = 'Update';
         $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 permenantly DELETE this record?'));
         $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
         $this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction());
     }
     // Create Controls
     $this->lstAddressType = $this->mctAddress->lstAddressType_Create();
     $this->calDateUntilWhen = $this->mctAddress->calDateUntilWhen_Create();
     $this->calDateUntilWhen->MinimumYear = 2000;
     $this->calDateUntilWhen->MaximumYear = date('Y') + 10;
     $this->chkCurrentFlag = $this->mctAddress->chkCurrentFlag_Create();
     // Fixup "Address Type"
     $this->lstAddressType->GetItem(0)->Name = 'Previous Home';
     if (!$this->mctAddress->EditMode) {
         $this->lstAddressType->AddSelectOneOption();
     }
     $this->chkInvalidFlag = $this->mctAddress->chkInvalidFlag_Create();
     $this->txtAddress1 = $this->mctAddress->txtAddress1_Create();
     $this->txtAddress2 = $this->mctAddress->txtAddress2_Create();
     $this->txtAddress3 = $this->mctAddress->txtAddress3_Create();
     $this->txtCity = $this->mctAddress->txtCity_Create();
     $this->lstState = $this->mctAddress->lstState_Create();
     $this->txtZipCode = $this->mctAddress->txtZipCode_Create();
     $this->txtCountry = $this->mctAddress->txtCountry_Create();
     $this->txtInternationalState = $this->mctAddress->txtState_Create();
     $this->txtInternationalState->Visible = false;
     $this->chkInternationalFlag = $this->mctAddress->chkInternationalFlag_Create();
     $this->chkInternationalFlag->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'chkInternationalFlag_Click'));
     $this->chkInternationalFlag_Click();
     // Add Actions
     $this->lstAddressType->AddAction(new QChangeEvent(), new QAjaxControlAction($this, 'lstAddressType_Change'));
     // Setup Controls
     $this->lstAddressType_Change();
 }
 public function __construct($objParentObject, Person $objPerson, $strControlId = null)
 {
     // Call the Parent
     try {
         parent::__construct($objParentObject, $strControlId);
         // Setup the Template
         $this->Template = 'AddressListPanel.tpl.php';
         // Setting local the Master QDataGrid to refresh on
         // Saves on the Child DataGrid..
         $this->objPerson = $objPerson;
         // Instantiate the Meta DataGrid
         $this->dtgAddresses = new QDataGrid($this);
         // Bind him, the normal...
         $this->dtgAddresses->SetDataBinder('dtgAddresses_Bind', $this);
         $this->dtgAddresses->AddColumn(new QDataGridColumn('Address', '<?= $_CONTROL->ParentControl->render_StreetColumn($_CONTROL, $_ITEM ) ?>', 'HtmlEntities=false', 'Name=Street'));
         $this->dtgAddresses->AddColumn(new QDataGridColumn('City', '<?= $_CONTROL->ParentControl->render_CityColumn($_CONTROL, $_ITEM ) ?>', 'HtmlEntities=false', 'Name=City'));
         $this->dtgAddresses->AddColumn(new QDataGridColumn('Id', '<?= $_CONTROL->ParentControl->render_AddressIdColumn($_CONTROL, $_ITEM ) ?>', 'HtmlEntities=false', 'Name=address_id'));
         $this->dtgAddresses->AddColumn(new QDataGridColumn('PersonId', '<?= $_CONTROL->ParentControl->render_PersonIdColumn($_CONTROL, $_ITEM ) ?>', 'HtmlEntities=false', 'Name=person_id'));
         // edit button
         $this->dtgAddresses->AddColumn(new QDataGridColumn('', '<?= $_CONTROL->ParentControl->render_btnRecordEdit($_CONTROL, $_ITEM) ?>', 'HtmlEntities=false', 'Width=1px', 'Wrap=false'));
         // delete button
         $this->dtgAddresses->AddColumn(new QDataGridColumn('', '<?= $_CONTROL->ParentControl->render_btnRecordDelete($_CONTROL, $_ITEM) ?>', 'HtmlEntities=false', 'Width=1px'));
         $this->metaAddress = AddressMetaControl::CreateFromPathInfo($this->dtgAddresses);
         $this->lblId = $this->metaAddress->lblId_Create();
         $this->lblId->AddAction(new QEscapeKeyEvent(), new QAjaxControlAction($this, 'btnCancel_Click', $this->dtgAddresses->WaitIcon));
         $this->lblId->AddAction(new QEscapeKeyEvent(), new QTerminateAction());
         $this->lblPersonId = $this->metaAddress->lblPersonId_Create();
         $this->lblPersonId->AddAction(new QEscapeKeyEvent(), new QAjaxControlAction($this, 'btnCancel_Click', $this->dtgAddresses->WaitIcon));
         $this->lblPersonId->AddAction(new QEscapeKeyEvent(), new QTerminateAction());
         $this->txtStreet = $this->metaAddress->txtStreet_Create();
         $this->txtStreet->AddAction(new QEscapeKeyEvent(), new QAjaxControlAction($this, 'btnCancel_Click', $this->dtgAddresses->WaitIcon));
         $this->txtStreet->AddAction(new QEscapeKeyEvent(), new QTerminateAction());
         $this->txtCity = $this->metaAddress->txtCity_Create();
         $this->txtCity->AddAction(new QEscapeKeyEvent(), new QAjaxControlAction($this, 'btnCancel_Click', $this->dtgAddresses->WaitIcon));
         $this->txtCity->AddAction(new QEscapeKeyEvent(), new QTerminateAction());
         $this->btnSave = new QButton($this->dtgAddresses);
         $this->btnSave->Text = QApplication::Translate('Save');
         $this->btnSave->CssClass = 'inputbutton';
         $this->btnSave->PrimaryButton = true;
         $this->btnSave->CausesValidation = QCausesValidation::SiblingsOnly;
         $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click', $this->dtgAddresses->WaitIcon));
         $this->btnCancel = new QButton($this->dtgAddresses);
         $this->btnCancel->Text = QApplication::Translate('Cancel');
         $this->btnCancel->CssClass = 'inputbutton';
         $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click', $this->dtgAddresses->WaitIcon));
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
 }
 public function __construct(QPanel $pnlContent, $strReturnUrl, $intAddressId, $blnDisplayButtons = true)
 {
     $this->pnlContent = $pnlContent;
     $this->pnlContent->Template = dirname(__FILE__) . '/EditHomeAddressDelegate.tpl.php';
     $this->strReturnUrl = $strReturnUrl;
     $this->blnDisplayButtons = $blnDisplayButtons;
     $this->dlgMessage = new MessageDialog($pnlContent);
     $this->dlgMessage_Reset();
     // Get and Validate the Address Object
     $this->mctAddress = AddressMetaControl::Create($this->pnlContent, $intAddressId, QMetaControlCreateType::CreateOnRecordNotFound);
     if (!$this->mctAddress->EditMode) {
         $this->mctAddress->Address->AddressTypeId = AddressType::Home;
         $this->mctAddress->Address->CurrentFlag = true;
         $this->pnlContent->btnSave->Text = 'Create';
         // Create Phone Numbers
         $this->arrPhones = array();
         $this->AddPhoneNumberField();
         $this->AddPhoneNumberField();
         $this->AddPhoneNumberField();
     } else {
         // Ensure the Address object belongs to the household
         if ($this->mctAddress->Address->HouseholdId != $this->pnlContent->Form->objHousehold->Id) {
             return $this->pnlContent->ReturnTo($this->strReturnUrl);
         }
         $this->pnlContent->btnSave->Text = 'Update';
         // Create DELETE Button for non-Current
         if (!$this->mctAddress->Address->CurrentFlag) {
             $this->btnDelete = new QLinkButton($this->pnlContent);
             $this->btnDelete->Text = 'Delete';
             $this->btnDelete->CssClass = 'delete';
             $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction('Are you SURE you want to permenantly DELETE this record?'));
             $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this->pnlContent, 'btnDelete_Click'));
             $this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction());
         }
         // Get Phone Numbers
         $this->arrPhones = $this->mctAddress->Address->GetPhoneArray();
         // Add one additional
         if (count($this->arrPhones) < 3) {
             while (count($this->arrPhones) < 3) {
                 $this->AddPhoneNumberField();
             }
         } else {
             $this->AddPhoneNumberField();
         }
     }
     // Create Controls
     $this->chkInvalidFlag = $this->mctAddress->chkInvalidFlag_Create();
     $this->txtAddress1 = $this->mctAddress->txtAddress1_Create();
     $this->txtAddress2 = $this->mctAddress->txtAddress2_Create();
     $this->txtAddress3 = $this->mctAddress->txtAddress3_Create();
     $this->txtCity = $this->mctAddress->txtCity_Create();
     $this->lstState = $this->mctAddress->lstState_Create();
     $this->txtZipCode = $this->mctAddress->txtZipCode_Create();
     $this->txtCountry = $this->mctAddress->txtCountry_Create();
     $this->txtInternationalState = $this->mctAddress->txtState_Create();
     $this->txtInternationalState->Visible = false;
     $this->chkInternationalFlag = $this->mctAddress->chkInternationalFlag_Create();
     $this->chkInternationalFlag->AddAction(new QClickEvent(), new QAjaxControlAction($this->pnlContent, 'chkInternationalFlag_Click'));
     $this->chkInternationalFlag_Click();
     // PHone Numbers
     $this->dtrPhones = new QDataRepeater($this->pnlContent);
     $this->dtrPhones->Template = dirname(__FILE__) . '/dtrPhones.tpl.php';
     $this->dtrPhones->SetDataBinder('dtrPhones_Bind', $this);
     $this->pxyAddPhone = new QControlProxy($this->pnlContent);
     $this->pxyAddPhone->AddAction(new QClickEvent(), new QAjaxControlAction($this->pnlContent, 'pxyAddPhone_Click'));
     $this->pxyAddPhone->AddAction(new QClickEvent(), new QTerminateAction());
 }
 /**
  * Static Helper Method to Create using QueryString arguments
  *
  * @param mixed $objParentObject QForm or QPanel which will be using this AddressMetaControl
  * @param QMetaControlCreateType $intCreateType rules governing Address object creation - defaults to CreateOrEdit
  * @return AddressMetaControl
  */
 public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     $intId = QApplication::QueryString('intId');
     return AddressMetaControl::Create($objParentObject, $intId, $intCreateType);
 }