Ejemplo n.º 1
0
 protected function lstTramorField_Change($strFormId, $strControlId, $strParameter)
 {
     $objControl = QForm::GetControl($strControlId);
     if ($objControl->SelectedValue != null) {
         $search = strtolower($objControl->SelectedValue);
         if ($this->in_array_nocase($search, $this->arrTracmorField)) {
             $objControl->Warning = "This value has already been selected.";
             $objControl->SelectedIndex = 0;
             unset($this->arrTracmorField[substr($objControl->Name, 3)]);
         } else {
             $objControl->Warning = "";
             $txtDefault = $this->txtMapDefaultValueArray[substr($objControl->Name, 3)];
             $lstDefault = $this->lstMapDefaultValueArray[substr($objControl->Name, 3)];
             $dtpDefault = $this->dtpDateArray[substr($objControl->Name, 3)];
             $this->arrTracmorField[substr($objControl->Name, 3)] = $search;
             if (substr($objControl->SelectedValue, 0, 8) == "contact_") {
                 $objCustomField = CustomField::LoadByCustomFieldId(substr($objControl->SelectedValue, 8));
                 // type = Text or TextBox
                 if ($objCustomField->CustomFieldQtypeId != 2) {
                     $txtDefault->Required = $objCustomField->RequiredFlag;
                     // If it is a required text field, then assign the default text for a new entity only
                     if ($objCustomField->RequiredFlag && $objCustomField->DefaultCustomFieldValueId) {
                         $txtDefault->Text = $objCustomField->DefaultCustomFieldValue->ShortDescription;
                     } else {
                         $txtDefault->Text = "";
                     }
                     $txtDefault->Display = true;
                     $lstDefault->Display = false;
                     $dtpDefault->Display = false;
                 } else {
                     $lstDefault->RemoveAllItems();
                     $lstDefault->AddItem('- Select One -', null);
                     $lstDefault->Required = true;
                     $objCustomFieldValueArray = CustomFieldValue::LoadArrayByCustomFieldId(substr($objControl->SelectedValue, 8), QQ::Clause(QQ::OrderBy(QQN::CustomFieldValue()->ShortDescription)));
                     if ($objCustomFieldValueArray) {
                         foreach ($objCustomFieldValueArray as $objCustomFieldValue) {
                             $objListItem = new QListItem($objCustomFieldValue->__toString(), $objCustomFieldValue->CustomFieldValueId);
                             // If it is a required field, then select the value on new entities by default
                             if ($objCustomField->RequiredFlag && $objCustomField->DefaultCustomFieldValueId && $objCustomField->DefaultCustomFieldValueId == $objCustomFieldValue->CustomFieldValueId) {
                                 $objListItem->Selected = true;
                             }
                             $lstDefault->AddItem($objListItem);
                         }
                     }
                     $txtDefault->Display = false;
                     $lstDefault->Display = true;
                     $dtpDefault->Display = false;
                 }
             }
             $txtDefault->Display = true;
             $lstDefault->Display = false;
             $dtpDefault->Display = false;
         }
     } else {
         unset($this->arrTracmorField[substr($objControl->Name, 3)]);
     }
 }