IncrementOffset(); throw $objExc; } $this->objControlBlock =& $objControlBlock; $this->strShowEditPanelMethod = $strShowEditPanelMethod; $this->strCloseEditPanelMethod = $strCloseEditPanelMethod; $this->Template = __QUASI_CORE_TEMPLATES__ . '/AccountAddressListPanel.tpl.php'; $this->dtgAddresses = new AddressDataGrid($this); $this->dtgAddresses->SetDataBinder('AccountAddressDataBinder', $this); $this->dtgAddresses->CssClass = 'datagrid'; $this->dtgAddresses->AlternateRowStyle->CssClass = 'alternate'; $this->objPaginator = new QPaginator($this->dtgAddresses); $this->dtgAddresses->Paginator = $this->objPaginator; $this->dtgAddresses->ItemsPerPage = 10; // Create an Edit Column $this->pxyEdit = new QControlProxy($this); if(IndexPage::$blnAjaxOk) $this->pxyEdit->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'pxyEdit_Click')); else $this->pxyEdit->AddAction(new QClickEvent(), new QServerControlAction($this, 'pxyEdit_Click')); $this->dtgAddresses->MetaAddEditProxyColumn($this->pxyEdit, 'Edit', 'Edit'); $this->dtgAddresses->MetaAddColumn(QQN::Address()->Person); $this->dtgAddresses->MetaAddColumn('Street1'); $this->dtgAddresses->MetaAddColumn('City'); $this->dtgAddresses->MetaAddTypeColumn('ZoneId', 'ZoneType'); // $this->dtgAddresses->MetaAddColumn('ZoneId'); $this->dtgAddresses->MetaAddColumn('PostalCode'); // $this->dtgAddresses->MetaAddTypeColumn('TypeId', 'AddressType'); $this->btnCreateNew = new QButton($this); $this->btnCreateNew->Text = QApplication::Translate('Create a New') . ' ' . QApplication::Translate('Address'); if(IndexPage::$blnAjaxOk) $this->btnCreateNew->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCreateNew_Click')); else $this->btnCreateNew->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnCreateNew_Click')); } public function pxyEdit_Click($strFormId, $strControlId, $strParameter) { $strParameterArray = explode(',', $strParameter); $this->pnlAddressEditPanel = new AccountAddressEditPanel($this, $this->objControlBlock, $this->strCloseEditPanelMethod, $strParameterArray[0]); $strMethodName = $this->strShowEditPanelMethod; $this->objControlBlock->$strMethodName($this->pnlAddressEditPanel); } public function btnCreateNew_Click($strFormId, $strControlId, $strParameter) { if($this->pnlPersonEditPanel) { $this->pnlPersonEditPanel->RemoveChildControls(true); $this->pnlPersonEditPanel->Visible = false; } if($this->pnlAddressEditPanel) $this->pnlAddressEditPanel->RemoveChildControls(true); $this->pnlAddressEditPanel = new AccountAddressEditPanel($this, $this->objControlBlock, $this->strCloseEditPanelMethod, null); $this->pnlAddressEditPanel->Visible = true; $strMethodName = $this->strShowEditPanelMethod; $this->objControlBlock->$strMethodName($this->pnlAddressEditPanel); } //Callbacks .. public function btnAddPerson_Click($strFormId, $strControlId, $strParameter) { $this->pnlAddressEditPanel->RemoveChildControls(true); $this->pnlAddressEditPanel->Visible = false; $this->pnlPersonEditPanel = new AccountPersonEditPanel($this, $this, 'ClosePersonEditPanel'); $strMethodName = $this->strShowEditPanelMethod; $this->objControlBlock->$strMethodName($this->pnlPersonEditPanel); } public function ClosePersonEditPanel($blnChangesMade) { $this->pnlPersonEditPanel->RemoveChildControls(true); $this->pnlPersonEditPanel->Visible = false; $this->pnlAddressEditPanel = new AccountAddressEditPanel($this, $this->objControlBlock, $this->strCloseEditPanelMethod, null); $strMethodName = $this->strShowEditPanelMethod; $this->objControlBlock->$strMethodName($this->pnlAddressEditPanel); } /** * This binds the Datagrid data retrieval to this Person, the addresses listed in the Datagrid will be those * associated with this user in the database. The addresses loaded will be not only the addresses * specific to the user, but also those of others added by this user (eg. addresses of friends and/or * family to whom they may wish to have orders shipped.) via the Address management panel * * 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 requested in by clicking on the columns in the Datagrid. */ public function AccountAddressDataBinder() { $this->aryPersons = array(); $this->aryAddresses = array(); $aryClauses = array(); $aryPersonIds = array(); // add extra people that may be in address book .. slightly inefficient but it works for now. $this->aryPersons = Person::QueryArray( QQ::OrCondition( QQ::Equal( QQN::Person()->Id, $this->objControlBlock->Account->PersonId), QQ::Equal( QQN::Person()->OwnerPersonId, $this->objControlBlock->Account->PersonId) ) ); foreach( $this->aryPersons as $objPerson ) $aryPersonIds[] = $objPerson->Id; // If a column is selected to be sorted, and if that column has an OrderByClause // set on it, then let's add the OrderByClause to the $aryClauses array if ($objClause = $this->dtgAddresses->OrderByClause) array_push($aryClauses, $objClause); // Add the LimitClause information as well if ($objClause = $this->dtgAddresses->LimitClause) array_push($aryClauses, $objClause); $this->aryAddresses = Address::QueryArray( QQ::In( QQN::Address()->PersonId, $aryPersonIds), $aryClauses ); if ($this->objPaginator) $this->dtgAddresses->TotalItemCount = count($this->aryAddresses); // Set the DataSource to be a Query result from Address, given the clauses above $this->dtgAddresses->DataSource = $this->aryAddresses; } } } ?>