Пример #1
0
print "   }\n";
if (hasDeleteBox($object->sob_zzsys_form_id)) {
    print "   window.parent.frames[0].document.forms[0]['row{$prefix}'].checked = false;\n";
}
if ($o == 'id') {
    //--set focus to back to code fielde
    print "   window.parent.frames[0].document.forms[0][document.forms[0].elements[1].name].focus();\n";
}
print "   {$object->sob_lookup_javascript};\n";
print "}\n";
print setFormatArray();
print "/* ]]> */ \n";
print "</script>\n<!-- End Of Form Functions -->\n\n";
$old_sql_string = $form->sfo_sql;
$new_sql_string = replaceHashVariablesWithValues($arrayOfHashVariables, $old_sql_string);
$SQL = new sqlString($new_sql_string);
if ($SQL->where == '') {
    $SQL->setWhere("WHERE {$lookIn} = '{$newID}'");
} else {
    $SQL->setWhere("{$SQL->where} AND ({$lookIn} = '{$newID}')");
}
$SQL->removeAllFields();
$SQL->addField($object->sob_lookup_id_field);
$fieldNames[] = $prefix . $object->sob_all_name;
$SQL->addField($object->sob_lookup_code_field);
$fieldNames[] = 'code' . $prefix . $object->sob_all_name;
if ($object->sob_lookup_no_description != '1' and $object->sob_lookup_description_field != '') {
    $fieldNames[] = 'description' . $prefix . $object->sob_all_name;
    $SQL->addField($object->sob_lookup_description_field);
}
$t = nuRunQuery("SELECT * FROM zzsys_lookup WHERE slo_zzsys_object_id = '{$object->zzsys_object_id}'");
Пример #2
0
 public function setValue($pRecordID, $pClone, $pValue)
 {
     $type = $this->objectProperty['sob_all_type'];
     $this->objectType = $this->objectProperty['sob_all_type'];
     if ($type == 'display') {
         //---replace any hashes with variables
         $sql = replaceVariablesInString($this->TT, $this->objectProperty['sob_display_sql'], $this->recordID);
         //---run sql and use the first row and colomn as the value for this field
         if (trim($sql) == '') {
             return '';
         }
         $t = nuRunQuery($sql);
         $r = db_fetch_row($t);
         return formatTextValue($r[0], $this->objectProperty['sob_display_format']);
     }
     if ($type == 'dropdown') {
         if ($this->activity or $pRecordID == '-1' or $pClone and $this->objectProperty['sob_all_clone'] != '1') {
             //---get default value from sob_text_default_value_sql
             if ($this->objectProperty['sob_dropdown_default_value_sql'] == '') {
                 return '';
             }
             //---replace any hashes with variables
             $sql = replaceVariablesInString($this->TT, $this->objectProperty['sob_dropdown_default_value_sql'], $this->recordID);
             //---run sql and use the first row and colomn as the default value for this field
             $t = nuRunQuery($sql);
             $r = db_fetch_row($t);
             return $r[0];
         }
         return $pValue;
         //---return value already in record
     }
     if ($type == 'lookup') {
         if ($pValue == '' or $this->activity or $pRecordID == '-1' or $pClone and $this->objectProperty['sob_all_clone'] != '1') {
             //---get default value from sob_text_default_value_sql
             if ($this->objectProperty['sob_lookup_default_value_sql'] == '') {
                 $this->lookupArray['id'] = '';
                 $this->lookupArray['code'] = '';
                 $this->lookupArray['description'] = '';
                 return '';
             }
             $defaultValueSQL = replaceVariablesInString('', $this->objectProperty['sob_lookup_default_value_sql'], '');
             $T = nuRunQuery($defaultValueSQL);
             $R = db_fetch_row($T);
             $pValue = $R[0];
         }
         //--get sql from lookup form
         if ($this->objectProperty['sob_lookup_load_zzsysform_id'] == '') {
             $lookupFormID = $this->objectProperty['sob_lookup_zzsysform_id'];
         } else {
             $lookupFormID = $this->objectProperty['sob_lookup_load_zzsysform_id'];
         }
         $t = nuRunQuery("SELECT * FROM zzsys_form WHERE zzsys_form_id = '{$lookupFormID}'");
         $r = db_fetch_object($t);
         $browseTable = $this->TT;
         $TT = $this->TT;
         $this->parentForm->arrayOfHashVariables['#formSessionID#'] = $this->parentForm->formsessionID;
         $this->parentForm->arrayOfHashVariables['#browseTable#'] = $this->TT;
         $this->parentForm->arrayOfHashVariables['#TT#'] = $this->TT;
         eval(replaceHashVariablesWithValues($this->parentForm->arrayOfHashVariables, $r->sfo_custom_code_run_before_browse));
         //--replace hash variables then run code
         $r->sfo_sql = replaceHashVariablesWithValues($this->parentForm->arrayOfHashVariables, $r->sfo_sql);
         //--replace hash variables
         $SQL = new sqlString($r->sfo_sql);
         if ($SQL->getWhere() == '') {
             $SQL->setWhere("WHERE " . $this->objectProperty['sob_lookup_id_field'] . " = '{$pValue}'");
         } else {
             $SQL->setWhere($SQL->getWhere() . " AND (" . $this->objectProperty['sob_lookup_id_field'] . " = '{$pValue}')");
         }
         $SQL->removeAllFields();
         $SQL->addField($this->objectProperty['sob_lookup_id_field']);
         $SQL->addField($this->objectProperty['sob_lookup_code_field']);
         if ($this->objectProperty['sob_lookup_description_field'] == '') {
             $SQL->addField("''");
         } else {
             $SQL->addField($this->objectProperty['sob_lookup_description_field']);
         }
         if ($_GET['debug'] != '') {
             tofile('SQL lookup hash variables : debug value:' . $_GET['debug']);
             tofile(print_r($this->parentForm->arrayOfHashVariables, true));
             tofile($SQL->SQL);
         }
         $T = nuRunQuery($SQL->SQL);
         /*            $lookupform                         = formFields($this->objectProperty['sob_lookup_zzsysform_id']);
         
         		    $fld1                               = $this->objectProperty['sob_lookup_id_field'];
         		    $fld2                               = $this->objectProperty['sob_lookup_code_field'];
         	    	if($this->objectProperty['sob_lookup_description_field']==''){
             		    $fld3                           = '"" AS desc ';
             		}else{
             		    $fld3                           = $this->objectProperty['sob_lookup_description_field'];
         		    }
             		$T = nuRunQuery("SELECT $fld1, $fld2, $fld3 FROM $lookupform->sfo_table WHERE $lookupform->sfo_primary_key = '$pValue'");
         */
         $R = db_fetch_row($T);
         $this->lookupArray['id'] = $R[0];
         $this->lookupArray['code'] = $R[1];
         $this->lookupArray['description'] = $R[2];
         //		    if($browseTable!=''){nuRunQuery("DROP TABLE IF EXISTS `$this->TT`");}
         return $pValue;
         //---return value already in record
     }
     if ($type == 'inarray') {
         if ($this->activity or $pRecordID == '-1' or $pClone and $this->objectProperty['sob_all_clone'] != '1') {
             //---get default value from sob_text_default_value_sql
             if ($this->objectProperty['sob_inarray_default_value_sql'] == '') {
                 return '';
             }
             //---replace any hashes with variables
             $sql = replaceVariablesInString($this->TT, $this->objectProperty['sob_inarray_default_value_sql'], $this->recordID);
             //---run sql and use the first row and column as the default value for this field
             $t = nuRunQuery($sql);
             $r = db_fetch_row($t);
             return $r[0];
         }
         return $pValue;
         //---return value already in record
     }
     if ($type == 'password') {
         return $pValue;
     }
     if ($type == 'text') {
         if ($this->activity or $pRecordID == '-1' or $pClone and $this->objectProperty['sob_all_clone'] != '1') {
             //---get default value from sob_text_default_value_sql
             if ($this->objectProperty['sob_text_default_value_sql'] == '') {
                 return formatTextValue('', $this->objectProperty['sob_text_format']);
             }
             //---replace any hashes with variables
             $sql = replaceVariablesInString($this->TT, $this->objectProperty['sob_text_default_value_sql'], $this->recordID);
             //---run sql and use the first row and colomn as the default value for this field
             $t = nuRunQuery($sql);
             $r = db_fetch_row($t);
             return formatTextValue($r[0], $this->objectProperty['sob_text_format']);
         }
         return formatTextValue($pValue, $this->objectProperty['sob_text_format']);
         //---return value already in record
     }
     if ($type == 'textarea') {
         if ($this->activity or $pRecordID == '-1' or $pClone and $this->objectProperty['sob_all_clone'] != '1') {
             //---get default value from sob_text_default_value_sql
             if ($this->objectProperty['sob_textarea_default_value_sql'] == '') {
                 return '';
             }
             //---replace any hashes with variables
             $sql = replaceVariablesInString($this->TT, $this->objectProperty['sob_textarea_default_value_sql'], $this->recordID);
             //---run sql and use the first row and colomn as the default value for this field
             $t = nuRunQuery($sql);
             $r = db_fetch_row($t);
             return $r[0];
         }
         return $pValue;
         //---return value already in record
     }
 }
Пример #3
0
 public function setValue($pRecordID, $pClone, $pValue)
 {
     $type = $this->objectProperty['sob_all_type'];
     if ($type == 'display') {
         //---replace any hashes with variables
         $sql = replaceVariablesInString($this->TT, $this->objectProperty['sob_display_sql'], $this->recordID);
         //---run sql and use the first row and colomn as the value for this field
         $t = nuRunQuery($sql);
         $r = db_fetch_row($t);
         return formatTextValue($r[0], $this->objectProperty['sob_display_format']);
     }
     if ($type == 'dropdown') {
         if ($pRecordID == '-1' or $pClone and $this->objectProperty['sob_all_clone'] != '1') {
             //---get default value from sob_text_default_value_sql
             if ($this->objectProperty['sob_dropdown_default_value_sql'] == '') {
                 return '';
             }
             //---replace any hashes with variables
             $sql = replaceVariablesInString($this->TT, $this->objectProperty['sob_dropdown_default_value_sql'], $this->recordID);
             //---run sql and use the first row and colomn as the default value for this field
             $t = nuRunQuery($sql);
             $r = db_fetch_row($t);
             return $r[0];
         }
         return $pValue;
         //---return value already in record
     }
     if ($type == 'lookup') {
         if ($pRecordID == '-1' or $pClone and $this->objectProperty['sob_all_clone'] != '1') {
             //---get default value from sob_text_default_value_sql
             if ($this->objectProperty['sob_lookup_default_value_sql'] == '') {
                 $this->lookupArray['id'] = '';
                 $this->lookupArray['code'] = '';
                 $this->lookupArray['description'] = '';
                 return '';
             }
             $defaultValueSQL = replaceVariablesInString('', $this->objectProperty['sob_lookup_default_value_sql'], '');
             $T = nuRunQuery($defaultValueSQL);
             $R = db_fetch_row($T);
             $pValue = $R[0];
         }
         //-------
         //--get sql from lookup form
         $lookupFormID = $this->objectProperty['sob_lookup_zzsysform_id'];
         $t = nuRunQuery("SELECT * FROM zzsys_form WHERE zzsys_form_id = '{$lookupFormID}'");
         $r = db_fetch_object($t);
         $TT = $this->TT;
         $browseTable = $TT;
         eval($r->sfo_custom_code_run_before_browse);
         $SQLwithGlobalValues = replaceVariablesInString($this->TT, $r->sfo_sql, '');
         $SQLwithRecordValues = getSqlRecordValues($SQLwithGlobalValues, $this->parentForm->recordAndFieldValues);
         $SQL = new sqlString($SQLwithRecordValues);
         //-------
         //			$SQL                                = new sqlString(replaceVariablesInString($this->TT,$this->objectProperty['sob_lookup_sql'], ''));
         tofile('sql step 1==' . $this->objectProperty['sob_lookup_sql']);
         $SQL->setWhere("WHERE " . $this->objectProperty['sob_lookup_id_field'] . " = '{$pValue}'");
         $SQL->removeAllFields();
         $SQL->addField($this->objectProperty['sob_lookup_id_field']);
         $SQL->addField($this->objectProperty['sob_lookup_code_field']);
         $SQL->addField($this->objectProperty['sob_lookup_description_field']);
         $T = nuRunQuery($SQL->SQL);
         tofile('step 111');
         $R = db_fetch_row($T);
         $this->lookupArray['id'] = $R[0];
         $this->lookupArray['code'] = $R[1];
         $this->lookupArray['description'] = $R[2];
         return $pValue;
         //---return value already in record
     }
     if ($type == 'inarray') {
         if ($pRecordID == '-1' or $pClone and $this->objectProperty['sob_all_clone'] != '1') {
             //---get default value from sob_text_default_value_sql
             if ($this->objectProperty['sob_inarray_default_value_sql'] == '') {
                 return '';
             }
             //---replace any hashes with variables
             $sql = replaceVariablesInString($this->TT, $this->objectProperty['sob_inarray_default_value_sql'], $this->recordID);
             //---run sql and use the first row and column as the default value for this field
             $t = nuRunQuery($sql);
             $r = db_fetch_row($t);
             return $r[0];
         }
         return $pValue;
         //---return value already in record
     }
     if ($type == 'password') {
         return $pValue;
     }
     if ($type == 'text') {
         if ($pRecordID == '-1' or $pClone and $this->objectProperty['sob_all_clone'] != '1') {
             //---get default value from sob_text_default_value_sql
             if ($this->objectProperty['sob_text_default_value_sql'] == '') {
                 return formatTextValue('', $this->objectProperty['sob_text_format']);
             }
             //---replace any hashes with variables
             $sql = replaceVariablesInString($this->TT, $this->objectProperty['sob_text_default_value_sql'], $this->recordID);
             //---run sql and use the first row and colomn as the default value for this field
             $t = nuRunQuery($sql);
             $r = db_fetch_row($t);
             return formatTextValue($r[0], $this->objectProperty['sob_text_format']);
         }
         return formatTextValue($pValue, $this->objectProperty['sob_text_format']);
         //---return value already in record
     }
     if ($type == 'textarea') {
         if ($pRecordID == '-1' or $pClone and $this->objectProperty['sob_all_clone'] != '1') {
             //---get default value from sob_text_default_value_sql
             if ($this->objectProperty['sob_textarea_default_value_sql'] == '') {
                 return '';
             }
             //---replace any hashes with variables
             $sql = replaceVariablesInString($this->TT, $this->objectProperty['sob_textarea_default_value_sql'], $this->recordID);
             //---run sql and use the first row and colomn as the default value for this field
             $t = nuRunQuery($sql);
             $r = db_fetch_row($t);
             return $r[0];
         }
         return $pValue;
         //---return value already in record
     }
 }