Example #1
0
 /**
  * Used by the SearchQuery Description generator
  * Enter description here ...
  * @param string $strValue
  */
 public function GetValueDescriptionForCustomValue($strValue)
 {
     switch ($this->QueryNodeTypeId) {
         case QueryNodeType::AttributeNode:
             return AttributeOption::Load($strValue)->Name;
         default:
             return $strValue;
     }
 }
 /**
  * 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 AttributeOptionMetaControl
  * @param integer $intId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing AttributeOption object creation - defaults to CreateOrEdit
  * @return AttributeOptionMetaControl
  */
 public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intId)) {
         $objAttributeOption = AttributeOption::Load($intId);
         // AttributeOption was found -- return it!
         if ($objAttributeOption) {
             return new AttributeOptionMetaControl($objParentObject, $objAttributeOption);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a AttributeOption 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 AttributeOptionMetaControl($objParentObject, new AttributeOption());
 }
 protected function lstAttributeOptionsAsMultiple_Update()
 {
     if ($this->lstAttributeOptionsAsMultiple) {
         $this->objAttributeValue->UnassociateAllAttributeOptionsAsMultiple();
         $objSelectedListItems = $this->lstAttributeOptionsAsMultiple->SelectedItems;
         if ($objSelectedListItems) {
             foreach ($objSelectedListItems as $objListItem) {
                 $this->objAttributeValue->AssociateAttributeOptionAsMultiple(AttributeOption::Load($objListItem->Value));
             }
         }
     }
 }
Example #4
0
 public function btnSave_Click($strFormId, $strControlId, $strParameter)
 {
     switch ($this->objAttributeValue->Attribute->AttributeDataTypeId) {
         case AttributeDataType::Checkbox:
             $this->objAttributeValue->BooleanValue = $this->chkValue->SelectedValue;
             $this->objAttributeValue->Save();
             break;
         case AttributeDataType::Date:
             $this->objAttributeValue->DateValue = $this->dtxValue->DateTime;
             $this->objAttributeValue->Save();
             break;
         case AttributeDataType::DateTime:
             $this->objAttributeValue->DatetimeValue = $this->dtxValue->DateTime;
             $this->objAttributeValue->Save();
             break;
         case AttributeDataType::Text:
             $this->objAttributeValue->TextValue = trim($this->txtValue->Text);
             $this->objAttributeValue->Save();
             break;
         case AttributeDataType::ImmutableSingleDropdown:
             $this->objAttributeValue->SingleAttributeOptionId = $this->lstValue->SelectedValue;
             $this->objAttributeValue->Save();
             break;
         case AttributeDataType::ImmutableMultipleDropdown:
             $this->objAttributeValue->Save();
             $this->objAttributeValue->UnassociateAllAttributeOptionsAsMultiple();
             foreach ($this->lstValue->SelectedValues as $intOptionId) {
                 $this->objAttributeValue->AssociateAttributeOptionAsMultiple(AttributeOption::Load($intOptionId));
             }
             break;
         case AttributeDataType::MutableSingleDropdown:
             if ($this->lstValue->SelectedValue == -1) {
                 $objAttributeOption = new AttributeOption();
                 $objAttributeOption->AttributeId = $this->objAttributeValue->AttributeId;
                 $objAttributeOption->Name = trim($this->txtAddItem->Text);
                 $objAttributeOption->Save();
                 $this->objAttributeValue->SingleAttributeOption = $objAttributeOption;
                 $this->objAttributeValue->Save();
             } else {
                 $this->objAttributeValue->SingleAttributeOptionId = $this->lstValue->SelectedValue;
                 $this->objAttributeValue->Save();
             }
             break;
         case AttributeDataType::MutableMultipleDropdown:
             $this->objAttributeValue->Save();
             $this->objAttributeValue->UnassociateAllAttributeOptionsAsMultiple();
             foreach ($this->lstValue->SelectedItems as $objListItem) {
                 $intOptionId = $objListItem->Value;
                 if ($intOptionId > 0) {
                     $this->objAttributeValue->AssociateAttributeOptionAsMultiple(AttributeOption::Load($intOptionId));
                 } else {
                     if ($objListItem->Selected) {
                         $objAttributeOption = new AttributeOption();
                         $objAttributeOption->AttributeId = $this->objAttributeValue->AttributeId;
                         $objAttributeOption->Name = $objListItem->Name;
                         $objAttributeOption->Save();
                         $this->objAttributeValue->AssociateAttributeOptionAsMultiple($objAttributeOption);
                     }
                 }
             }
             break;
         default:
             throw new Exception('Unhandled AttributeDataTypeId: ' . $this->objAttributeValue->Attribute->AttributeDataTypeId);
     }
     return $this->ReturnTo('#attributes');
 }
Example #5
0
File: edit.php Project: alcf/chms
 protected function btnSave_Click($strFormId, $strControlId, $strParameter)
 {
     $this->mctAttribute->SaveAttribute();
     if ($this->pnlAttributeOptions) {
         foreach ($this->pnlAttributeOptions->GetChildControls() as $txtAttributeOption) {
             if ($txtAttributeOption->ActionParameter) {
                 $objAttributeOption = AttributeOption::Load($txtAttributeOption->ActionParameter);
                 if ($objAttributeOption->AttributeId != $this->mctAttribute->Attribute->Id) {
                     throw new Exception('Unlinked Attribute Option Found');
                 }
                 if ($objAttributeOption->Name != trim($txtAttributeOption->Text)) {
                     $objAttributeOption->Name = trim($txtAttributeOption->Text);
                     $objAttributeOption->Save();
                 }
             } else {
                 if ($strOptionName = trim($txtAttributeOption->Text)) {
                     $objAttributeOption = new AttributeOption();
                     $objAttributeOption->Attribute = $this->mctAttribute->Attribute;
                     $objAttributeOption->Name = $strOptionName;
                     $objAttributeOption->Save();
                 }
             }
         }
     }
     $this->ReturnToList();
 }
Example #6
0
 /**
  * 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 'Id':
             // Gets the value for intId (Read-Only PK)
             // @return integer
             return $this->intId;
         case 'AttributeId':
             // Gets the value for intAttributeId (Not Null)
             // @return integer
             return $this->intAttributeId;
         case 'PersonId':
             // Gets the value for intPersonId (Not Null)
             // @return integer
             return $this->intPersonId;
         case 'DateValue':
             // Gets the value for dttDateValue
             // @return QDateTime
             return $this->dttDateValue;
         case 'DatetimeValue':
             // Gets the value for dttDatetimeValue
             // @return QDateTime
             return $this->dttDatetimeValue;
         case 'TextValue':
             // Gets the value for strTextValue
             // @return string
             return $this->strTextValue;
         case 'BooleanValue':
             // Gets the value for blnBooleanValue
             // @return boolean
             return $this->blnBooleanValue;
         case 'SingleAttributeOptionId':
             // Gets the value for intSingleAttributeOptionId
             // @return integer
             return $this->intSingleAttributeOptionId;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'Attribute':
             // Gets the value for the Attribute object referenced by intAttributeId (Not Null)
             // @return Attribute
             try {
                 if (!$this->objAttribute && !is_null($this->intAttributeId)) {
                     $this->objAttribute = Attribute::Load($this->intAttributeId);
                 }
                 return $this->objAttribute;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'Person':
             // Gets the value for the Person object referenced by intPersonId (Not Null)
             // @return Person
             try {
                 if (!$this->objPerson && !is_null($this->intPersonId)) {
                     $this->objPerson = Person::Load($this->intPersonId);
                 }
                 return $this->objPerson;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'SingleAttributeOption':
             // Gets the value for the AttributeOption object referenced by intSingleAttributeOptionId
             // @return AttributeOption
             try {
                 if (!$this->objSingleAttributeOption && !is_null($this->intSingleAttributeOptionId)) {
                     $this->objSingleAttributeOption = AttributeOption::Load($this->intSingleAttributeOptionId);
                 }
                 return $this->objSingleAttributeOption;
             } 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 '_AttributeOptionAsMultiple':
             // Gets the value for the private _objAttributeOptionAsMultiple (Read-Only)
             // if set due to an expansion on the attributevalue_multipleattributeoption_assn association table
             // @return AttributeOption
             return $this->_objAttributeOptionAsMultiple;
         case '_AttributeOptionAsMultipleArray':
             // Gets the value for the private _objAttributeOptionAsMultipleArray (Read-Only)
             // if set due to an ExpandAsArray on the attributevalue_multipleattributeoption_assn association table
             // @return AttributeOption[]
             return (array) $this->_objAttributeOptionAsMultipleArray;
         case '__Restored':
             return $this->__blnRestored;
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
Example #7
0
 /**
  * Reload this AttributeOption from the database.
  * @return void
  */
 public function Reload()
 {
     // Make sure we are actually Restored from the database
     if (!$this->__blnRestored) {
         throw new QCallerException('Cannot call Reload() on a new, unsaved AttributeOption object.');
     }
     // Reload the Object
     $objReloaded = AttributeOption::Load($this->intId);
     // Update $this's local variables to match
     $this->AttributeId = $objReloaded->AttributeId;
     $this->strName = $objReloaded->strName;
 }