/** * 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 = ContactCustomFieldHelper::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 ContactCustomFieldHelper, given the clauses above $this->DataSource = ContactCustomFieldHelper::QueryArray($objCondition, $objClauses); }
/** * This will save this object's Contact instance, * updating only the fields which have had a control created for it. */ public function SaveContact() { try { // Update any fields for controls that have been created if ($this->lstCompany) { $this->objContact->CompanyId = $this->lstCompany->SelectedValue; } if ($this->lstAddress) { $this->objContact->AddressId = $this->lstAddress->SelectedValue; } if ($this->txtFirstName) { $this->objContact->FirstName = $this->txtFirstName->Text; } if ($this->txtLastName) { $this->objContact->LastName = $this->txtLastName->Text; } if ($this->txtTitle) { $this->objContact->Title = $this->txtTitle->Text; } if ($this->txtEmail) { $this->objContact->Email = $this->txtEmail->Text; } if ($this->txtPhoneOffice) { $this->objContact->PhoneOffice = $this->txtPhoneOffice->Text; } if ($this->txtPhoneHome) { $this->objContact->PhoneHome = $this->txtPhoneHome->Text; } if ($this->txtPhoneMobile) { $this->objContact->PhoneMobile = $this->txtPhoneMobile->Text; } if ($this->txtFax) { $this->objContact->Fax = $this->txtFax->Text; } if ($this->txtDescription) { $this->objContact->Description = $this->txtDescription->Text; } if ($this->lstCreatedByObject) { $this->objContact->CreatedBy = $this->lstCreatedByObject->SelectedValue; } if ($this->calCreationDate) { $this->objContact->CreationDate = $this->calCreationDate->DateTime; } if ($this->lstModifiedByObject) { $this->objContact->ModifiedBy = $this->lstModifiedByObject->SelectedValue; } // Update any UniqueReverseReferences (if any) for controls that have been created for it if ($this->lstContactCustomFieldHelper) { $this->objContact->ContactCustomFieldHelper = ContactCustomFieldHelper::Load($this->lstContactCustomFieldHelper->SelectedValue); } // Save the Contact object $this->objContact->Save(); // Finally, update any ManyToManyReferences (if any) } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } }
/** * 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 'ContactId': // Gets the value for intContactId (Read-Only PK) // @return integer return $this->intContactId; case 'CompanyId': // Gets the value for intCompanyId (Not Null) // @return integer return $this->intCompanyId; case 'AddressId': // Gets the value for intAddressId // @return integer return $this->intAddressId; case 'FirstName': // Gets the value for strFirstName // @return string return $this->strFirstName; case 'LastName': // Gets the value for strLastName (Not Null) // @return string return $this->strLastName; case 'Title': // Gets the value for strTitle // @return string return $this->strTitle; case 'Email': // Gets the value for strEmail // @return string return $this->strEmail; case 'PhoneOffice': // Gets the value for strPhoneOffice // @return string return $this->strPhoneOffice; case 'PhoneHome': // Gets the value for strPhoneHome // @return string return $this->strPhoneHome; case 'PhoneMobile': // Gets the value for strPhoneMobile // @return string return $this->strPhoneMobile; case 'Fax': // Gets the value for strFax // @return string return $this->strFax; case 'Description': // Gets the value for strDescription // @return string return $this->strDescription; case 'CreatedBy': // Gets the value for intCreatedBy // @return integer return $this->intCreatedBy; case 'CreationDate': // Gets the value for dttCreationDate // @return QDateTime return $this->dttCreationDate; case 'ModifiedBy': // Gets the value for intModifiedBy // @return integer return $this->intModifiedBy; case 'ModifiedDate': // Gets the value for strModifiedDate (Read-Only Timestamp) // @return string return $this->strModifiedDate; /////////////////// // Member Objects /////////////////// /////////////////// // Member Objects /////////////////// case 'Company': // Gets the value for the Company object referenced by intCompanyId (Not Null) // @return Company try { if (!$this->objCompany && !is_null($this->intCompanyId)) { $this->objCompany = Company::Load($this->intCompanyId); } return $this->objCompany; } 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 'CreatedByObject': // Gets the value for the UserAccount object referenced by intCreatedBy // @return UserAccount try { if (!$this->objCreatedByObject && !is_null($this->intCreatedBy)) { $this->objCreatedByObject = UserAccount::Load($this->intCreatedBy); } return $this->objCreatedByObject; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'ModifiedByObject': // Gets the value for the UserAccount object referenced by intModifiedBy // @return UserAccount try { if (!$this->objModifiedByObject && !is_null($this->intModifiedBy)) { $this->objModifiedByObject = UserAccount::Load($this->intModifiedBy); } return $this->objModifiedByObject; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'ContactCustomFieldHelper': // Gets the value for the ContactCustomFieldHelper object that uniquely references this Contact // by objContactCustomFieldHelper (Unique) // @return ContactCustomFieldHelper try { if ($this->objContactCustomFieldHelper === false) { // We've attempted early binding -- and the reverse reference object does not exist return null; } if (!$this->objContactCustomFieldHelper) { $this->objContactCustomFieldHelper = ContactCustomFieldHelper::LoadByContactId($this->intContactId); } return $this->objContactCustomFieldHelper; } 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 '_AssetTransactionCheckoutAsTo': // Gets the value for the private _objAssetTransactionCheckoutAsTo (Read-Only) // if set due to an expansion on the asset_transaction_checkout.to_contact_id reverse relationship // @return AssetTransactionCheckout return $this->_objAssetTransactionCheckoutAsTo; case '_AssetTransactionCheckoutAsToArray': // Gets the value for the private _objAssetTransactionCheckoutAsToArray (Read-Only) // if set due to an ExpandAsArray on the asset_transaction_checkout.to_contact_id reverse relationship // @return AssetTransactionCheckout[] return (array) $this->_objAssetTransactionCheckoutAsToArray; case '_ReceiptAsFrom': // Gets the value for the private _objReceiptAsFrom (Read-Only) // if set due to an expansion on the receipt.from_contact_id reverse relationship // @return Receipt return $this->_objReceiptAsFrom; case '_ReceiptAsFromArray': // Gets the value for the private _objReceiptAsFromArray (Read-Only) // if set due to an ExpandAsArray on the receipt.from_contact_id reverse relationship // @return Receipt[] return (array) $this->_objReceiptAsFromArray; case '_ReceiptAsTo': // Gets the value for the private _objReceiptAsTo (Read-Only) // if set due to an expansion on the receipt.to_contact_id reverse relationship // @return Receipt return $this->_objReceiptAsTo; case '_ReceiptAsToArray': // Gets the value for the private _objReceiptAsToArray (Read-Only) // if set due to an ExpandAsArray on the receipt.to_contact_id reverse relationship // @return Receipt[] return (array) $this->_objReceiptAsToArray; case '_ShipmentAsFrom': // Gets the value for the private _objShipmentAsFrom (Read-Only) // if set due to an expansion on the shipment.from_contact_id reverse relationship // @return Shipment return $this->_objShipmentAsFrom; case '_ShipmentAsFromArray': // Gets the value for the private _objShipmentAsFromArray (Read-Only) // if set due to an ExpandAsArray on the shipment.from_contact_id reverse relationship // @return Shipment[] return (array) $this->_objShipmentAsFromArray; case '_ShipmentAsTo': // Gets the value for the private _objShipmentAsTo (Read-Only) // if set due to an expansion on the shipment.to_contact_id reverse relationship // @return Shipment return $this->_objShipmentAsTo; case '_ShipmentAsToArray': // Gets the value for the private _objShipmentAsToArray (Read-Only) // if set due to an ExpandAsArray on the shipment.to_contact_id reverse relationship // @return Shipment[] return (array) $this->_objShipmentAsToArray; case '__Restored': return $this->__blnRestored; default: try { return parent::__get($strName); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } }
protected function UpdateContactFields() { $this->objContact->CompanyId = $this->lstCompany->SelectedValue; $this->objContact->AddressId = $this->lstAddress->SelectedValue; $this->objContact->FirstName = $this->txtFirstName->Text; $this->objContact->LastName = $this->txtLastName->Text; $this->objContact->Title = $this->txtTitle->Text; $this->objContact->Email = $this->txtEmail->Text; $this->objContact->PhoneOffice = $this->txtPhoneOffice->Text; $this->objContact->PhoneHome = $this->txtPhoneHome->Text; $this->objContact->PhoneMobile = $this->txtPhoneMobile->Text; $this->objContact->Fax = $this->txtFax->Text; $this->objContact->Description = $this->txtDescription->Text; $this->objContact->CreatedBy = $this->lstCreatedByObject->SelectedValue; $this->objContact->CreationDate = $this->calCreationDate->DateTime; $this->objContact->ModifiedBy = $this->lstModifiedByObject->SelectedValue; $this->objContact->ContactCustomFieldHelper = ContactCustomFieldHelper::Load($this->lstContactCustomFieldHelper->SelectedValue); }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, ContactCustomFieldHelper::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
/** * 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 ContactCustomFieldHelperMetaControl * @param integer $intContactId primary key value * @param QMetaControlCreateType $intCreateType rules governing ContactCustomFieldHelper object creation - defaults to CreateOrEdit * @return ContactCustomFieldHelperMetaControl */ public static function Create($objParentObject, $intContactId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intContactId)) { $objContactCustomFieldHelper = ContactCustomFieldHelper::Load($intContactId); // ContactCustomFieldHelper was found -- return it! if ($objContactCustomFieldHelper) { return new ContactCustomFieldHelperMetaControl($objParentObject, $objContactCustomFieldHelper); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a ContactCustomFieldHelper object with PK arguments: ' . $intContactId); } } // 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 ContactCustomFieldHelperMetaControl($objParentObject, new ContactCustomFieldHelper()); }