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();
 }
예제 #2
0
 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());
 }
예제 #3
0
 /**
  * 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);
 }