private function buildHTMLForSubform($CRLF, $TAB, $fieldName, $fieldTitle, $blankRows, $objectID) { if (!$this->displayThisObject) { return ''; } else { $this->parentForm->subformNames[] = $this->objectProperty['sob_all_name']; $this->parentForm->subformTabs[] = $this->parentForm->formTabNames[$this->objectProperty['sob_all_tab_title']]; } $format = textFormatsArray(); if ($this->objectProperty['sob_all_on_change'] != '') { $OnChange = 'onchange="' . $this->objectProperty["sob_all_on_change"] . '" '; } $this->CRLF = $CRLF; $this->TAB = $TAB; $hGap = 3; //gap between fields $vHeight = 23; //row height $vTitleHeight = $this->objectProperty['sob_subform_title_height'] * 16; //row height $vTop = 10; //row height $sfDimensions = array(); $fldDimensions = array(); $t = nuRunQuery("SELECT * FROM zzsys_object WHERE sob_zzsys_form_id = '" . $this->objectProperty['zzsys_object_id'] . "' ORDER BY sob_all_column_number, sob_all_order_number"); while ($r = db_fetch_array($t)) { $objectLength = $r['sob_' . $r['sob_all_type'] . '_length']; // eg. text objects are 'sob_text_length' if ($r['sob_all_type'] == 'lookup') { $objectLength = $r['sob_lookup_code_length']; // code length if ($r['sob_lookup_no_description'] != '1') { $objectLength = $objectLength + 0.5 + $r['sob_lookup_description_length']; // description length } } if ($r['sob_all_type'] == 'text') { if ($format[$r['sob_text_format']]->type == 'date') { $objectLength = $objectLength + 1.5; // date button length } } $fldDimensions[$r['sob_all_name']]->type = $r['sob_all_type']; $fldDimensions[$r['sob_all_name']]->columnAlign = 'left'; if ($r['sob_all_type'] == 'text') { $fldDimensions[$r['sob_all_name']]->columnAlign = $r['sob_text_align']; } if ($r['sob_all_type'] == 'display') { $fldDimensions[$r['sob_all_name']]->columnAlign = $r['sob_display_align']; } $fldDimensions[$r['sob_all_name']]->columnTitle = $r['sob_all_title']; $fldDimensions[$r['sob_all_name']]->column = $r['sob_all_column_number']; $fldDimensions[$r['sob_all_name']]->leftCoordinate = round($sfDimensions[$r['sob_all_column_number']]->columnWidth); $fldDimensions[$r['sob_all_name']]->columnWidth = $objectLength * 16 + $hGap; $sfDimensions[$r['sob_all_column_number']]->columnWidth = round($sfDimensions[$r['sob_all_column_number']]->columnWidth) + $fldDimensions[$r['sob_all_name']]->columnWidth; $colHeight = round($sfDimensions[$r['sob_all_column_number']]->columnHeight); if ($colHeight == 0) { $sfDimensions[$r['sob_all_column_number']]->columnHeight = $vHeight; $colHeight = $sfDimensions[$r['sob_all_column_number']]->columnHeight; } if ($r['sob_all_type'] == 'textarea' and $colHeight < $r['sob_textarea_height'] * 16) { $sfDimensions[$r['sob_all_column_number']]->columnHeight = $r['sob_textarea_height'] * 16; } } $longest = ''; foreach ($sfDimensions as $key => $value) { // get longest row if ($value->columnWidth > $longest) { $longest = $value->columnWidth; } $rowHeight = $rowHeight + $value->columnHeight; } $prntCheckBox = $this->objectProperty['sob_subform_delete_box'] == '1' and $this->objectProperty['sob_subform_read_only'] != '1'; if ($prntCheckBox) { //add room for the delete tick box $longest = $longest + $vHeight; } else { $longest = $longest + 20; } //add scroll bar $sfWidth = $longest + 20; $sfLeft = $this->objectProperty['sob_subform_left']; //add height of subform title + column title(s) to overall height $sfHeight = $this->objectProperty['sob_subform_height'] * 16 - $this->objectProperty['sob_subform_title_height'] * 16 - 100; $sfTop = $this->objectProperty['sob_subform_top']; if ($this->objectProperty['sob_subform_width'] == 0) { $scsfWidth = $sfWidth + 10; } else { $scsfWidth = $this->objectProperty['sob_subform_width']; } $scsfHeight = $sfHeight - 20; $scsfHeight = $sfHeight - 16; //changed from -10 to -16 $s = "<div name='sf_title{$fieldName}' id='sf_title{$fieldName}' class='selected' style='text-align:left;position:absolute;height:20;top:{$sfTop};left:{$sfLeft};width:{$sfWidth};'>{$fieldTitle}</div>{$CRLF}"; $sfTop = $sfTop + 20; $s = $s . "{$TAB}<div name='{$fieldName}' id='{$fieldName}' class='selected' style='position:absolute;overflow:auto;width:{$scsfWidth};height:{$scsfHeight};top:{$sfTop};left:{$sfLeft};'>{$CRLF}"; $s = $s . "{$TAB} <div name='title{$fieldName}' id='title{$fieldName}' style='position:absolute;top:0;left:0;background:#6D7B8D'>{$CRLF}"; // build subform column titles $columnTop = 0; $columnNumber = ''; foreach ($fldDimensions as $key => $value) { if ($columnNumber != $value->column) { if ($columnNumber == '') { $columnNumber = $value->column; } } if ($columnTop == 0) { // only print headings for the first row (sob_subform_column_order) if ($columnNumber == $value->column) { $width = $value->columnWidth; $dbc = ''; if ($this->parentForm->zzsys_user_id == 'globeadmin' and $this->form->sys_setup != '1') { $dbc = " ondblclick=\"openBrowse('object', '{$objectID}', '', '" . $this->parentForm->session . "', '')\""; } $s = $s . "{$TAB} <div {$dbc} class='unselected' style='vertical-align:top;font-size:x-small;font-family:tahoma;font-weight:bold;top:0;left:{$value->leftCoordinate};width:{$width};height:{$vTitleHeight};overflow:hidden;position:absolute;text-align:" . align($value->columnAlign) . ";'>{$CRLF}"; $s = $s . "{$TAB} {$value->columnTitle}{$CRLF}"; $s = $s . "{$TAB} </div>{$CRLF}"; $nextLeft = $value->leftCoordinate + $value->columnWidth; } } } $sfHeight = $sfHeight - $columnTop - $vHeight; // adjusting for scrollng div $this->objectName = $this->objectProperty['sob_all_name']; // set subform name //add room for the delete tick box if ($this->objectProperty['sob_subform_read_only'] != '1') { $s = $s . "{$TAB} <div class='unselected' style='top:0;left:{$nextLeft};width:50;height:{$vTitleHeight};overflow:hidden;position:absolute;align:left;'>{$CRLF}"; //align:left removed if ($prntCheckBox) { $s = $s . "{$TAB} <font style='vertical-align:top;font-size:xx-small;font-family:tahoma;font-weight:bold;'> Delete </font>{$CRLF}"; } $s = $s . "{$TAB} </div>{$CRLF}"; } //end of subform column titles //start scrolling div $sfHeight = $sfHeight - $vTitleHeight; // adjust a bit to see all of scroll bar $columnTop = $columnTop + $vTitleHeight; //added by nick 10-06-09 $grey needs to be defined before it can be used //vvvvv $grey = iif($grey == $this->objectProperty['sob_subform_odd_background_color'], $this->objectProperty['sob_subform_even_background_color'], $this->objectProperty['sob_subform_odd_background_color']); //^^^^^ $subformClass = str_replace('.', '', $this->objectProperty['sob_all_class']); $s = $s . "{$TAB} <div name='scroller{$fieldName}' class='{$subformClass}' id='scroller{$fieldName}' style='border-style:solid;border-width:2;border-color:white;position:absolute;overflow:scroll;width:{$sfWidth};height:{$sfHeight};top:{$columnTop};left:0;background:{$grey};'>{$CRLF}"; //put subform objects in an array $subformObjects = array(); $t = nuRunQuery("SELECT * FROM zzsys_object WHERE sob_zzsys_form_id = '" . $this->objectProperty['zzsys_object_id'] . "' ORDER BY sob_all_column_number, sob_all_order_number"); while ($r = db_fetch_object($t)) { $subformObjects[] = $r; } //get SQL for subform // $subformSQL = replaceVariablesInString($this->TT,$this->objectProperty['sob_subform_sql'], $this->recordID); //get SQL for subform //-- added by sc 4-feb-2009 if (is_array($this->parentForm->recordValues)) { $hVariables = arrayToHashArray($this->parentForm->recordValues); //--session values (access level and user etc. ) } $subformSQL = replaceVariablesInString($this->TT, $this->objectProperty['sob_subform_sql'], $this->recordID); if (is_array($this->parentForm->recordValues)) { $subformSQL = replaceHashVariablesWithValues($hVariables, $subformSQL); } //--------- $subformTable = nuRunQuery($subformSQL); $columnTop = $vHeight * -1 + 5; $nextTop = 0; $columnNumber = ''; //loop through subform records if ($this->parentForm->cloning == '1') { $primaryKey = ''; } else { $primaryKey = $this->objectProperty['sob_subform_primary_key']; } while ($subformRecord = mysql_fetch_array($subformTable)) { $this->recordID = $subformRecord[$this->objectProperty['sob_subform_primary_key']]; $this->nextRowNumber(); //loop through each object for this subform record $newRow = true; $grey = iif($grey == $this->objectProperty['sob_subform_odd_background_color'], $this->objectProperty['sob_subform_even_background_color'], $this->objectProperty['sob_subform_odd_background_color']); $dq = '"'; $s = $s . "{$TAB} <div id='rowdiv_{$this->subformPrefix}' onfocus='SFrowColor(this, {$dq}{$fieldName}{$dq})' style='background:{$grey};height:{$rowHeight}'>{$CRLF}"; $checkBoxDone = false; for ($i = 0; $i < count($subformObjects); $i++) { $subformFieldDiv = $fldDimensions[$subformObjects[$i]->sob_all_name]; if ($columnNumber != $subformFieldDiv->column or $i == 0) { $columnNumber = $subformFieldDiv->column; $columnTop = $nextTop; $nextTop = $columnTop + $sfDimensions[$columnNumber]->columnHeight; } //add room for the delete tick box if ($prntCheckBox and !$checkBoxDone) { $checkBoxDone = true; $s = $s . "{$TAB} <div style='position:absolute;top:{$columnTop};left:{$nextLeft}'>{$CRLF}"; $s = $s . "{$TAB} <input name='row{$this->subformPrefix}' id='row{$this->subformPrefix}' type='checkbox' {$OnChange} tabindex='-1'/>{$CRLF}"; $s = $s . "{$TAB} </div>{$CRLF}"; } $s = $s . "{$TAB} <div name='row{$this->subformPrefix}' id='row{$this->subformPrefix}' style='background:lightgray;position:absolute;top:{$columnTop};left:{$subformFieldDiv->leftCoordinate}'>{$CRLF}"; $fieldWidth = $subformFieldDiv->columnWidth - $hGap; if ($newRow) { $s = $s . "{$TAB} <input name='{$this->subformPrefix}{$primaryKey}' id='{$this->subformPrefix}{$primaryKey}' value='{$this->recordID}' type='hidden'/>{$CRLF}"; $newRow = false; } $s = $s . "{$TAB} " . $this->buildObject($subformObjects[$i], $subformRecord) . "{$CRLF}"; $s = $s . "{$TAB} </div>{$CRLF}"; } $rowNumber = $rowNumber + 1; $newRow = true; $s = $s . "{$TAB} </div>{$CRLF}"; } $sfRowTotal = $rowNumber + $blankRows; $columnNumber = ''; //loop through blank subform records for ($blankRecord = 0; $blankRecord < $blankRows; $blankRecord++) { $this->recordID = '-1'; $this->nextRowNumber(); //loop through each object for this subform record $grey = iif($grey == $this->objectProperty['sob_subform_odd_background_color'], $this->objectProperty['sob_subform_even_background_color'], $this->objectProperty['sob_subform_odd_background_color']); // $grey = iif($grey=='#E0E0E0 ','#F0F0F0','#E0E0E0 '); $s = $s . "{$TAB} <div style='background:{$grey};height:{$rowHeight}'>{$CRLF}"; $checkBoxDone = false; for ($i = 0; $i < count($subformObjects); $i++) { $subformFieldDiv = $fldDimensions[$subformObjects[$i]->sob_all_name]; if ($columnNumber != $subformFieldDiv->column) { $columnNumber = $subformFieldDiv->column; $columnTop = $nextTop; $nextTop = $columnTop + $sfDimensions[$columnNumber]->columnHeight; } //add room for the delete tick box if ($prntCheckBox and !$checkBoxDone) { $checkBoxDone = true; $s = $s . "{$TAB} <div style='position:absolute;top:{$columnTop};left:{$nextLeft}'>{$CRLF}"; $s = $s . "{$TAB} <input name='row{$this->subformPrefix}' id='row{$this->subformPrefix}' type='checkbox' {$OnChange} tabindex='-1' checked='checked'/>{$CRLF}"; $s = $s . "{$TAB} </div>{$CRLF}"; } $s = $s . "{$TAB} <div name='{$this->subformPrefix}' id='{$this->subformPrefix}' style='position:absolute;top:{$columnTop};left:{$subformFieldDiv->leftCoordinate}'>{$CRLF}"; $fieldWidth = $subformFieldDiv->columnWidth - $hGap; $s = $s . "{$TAB} " . $this->buildObject($subformObjects[$i], $subformRecord) . "{$CRLF}"; $s = $s . "{$TAB} </div>{$CRLF}"; } $rowNumber = $rowNumber + 1; $columnNumber = ''; $s = $s . "{$TAB} </div>{$CRLF}"; } $s = $s . "{$TAB} </div>{$CRLF}"; $s = $s . "{$TAB} </div>{$CRLF}"; $s = $s . "{$TAB} </div>{$CRLF}"; $s = $s . "{$TAB} <div style='position:absolute;overflow:hidden;width:0;height:0;top:0;left:10;background:blue;'>{$CRLF}"; $sfColumns = count($fldDimensions); $s = $s . "{$TAB} <input name='subformid{$fieldName}' id='subformid{$fieldName}' value='" . $this->objectProperty['zzsys_object_id'] . "' type='hidden' />{$CRLF}"; $s = $s . "{$TAB} <input name='rows{$fieldName}' id='rows{$fieldName}' value='{$sfRowTotal}' type='hidden' />{$CRLF}"; $s = $s . "{$TAB} <input name='columns{$fieldName}' id='columns{$fieldName}' value='{$sfColumns}' type='hidden' />{$CRLF}"; $s = $s . "{$TAB} <input name='table{$fieldName}' id='table{$fieldName}' value='" . $this->objectProperty['sob_subform_table'] . "' type='hidden' />{$CRLF}"; $s = $s . "{$TAB} <input name='foreignkey{$fieldName}' id='foreignkey{$fieldName}' value='" . $this->objectProperty['sob_subform_foreign_key'] . "' type='hidden' />{$CRLF}"; $s = $s . "{$TAB} <input name='primarykey{$fieldName}' id='primarykey{$fieldName}' value='" . $this->objectProperty['sob_subform_primary_key'] . "' type='hidden' />{$CRLF}"; $s = $s . "{$TAB} <input name='readonly{$fieldName}' id='readonly{$fieldName}' value='" . $this->objectProperty['sob_subform_read_only'] . "' type='hidden' />{$CRLF}"; $s = $s . "{$TAB} <input name='deletebox{$fieldName}' id='deletebox{$fieldName}' value='" . $this->objectProperty['sob_subform_delete_box'] . "' type='hidden' />{$CRLF}"; $s = $s . "{$TAB} <input name='rowColor_{$fieldName}' id='rowColor_{$fieldName}' value='" . $this->objectProperty['sob_subform_selected_row_color'] . "' type='hidden' />{$CRLF}"; $s = $s . "{$TAB} <input name='lastRow_{$fieldName}' id='lastRow_{$fieldName}' value='' type='hidden' />{$CRLF}"; $s = $s . "{$TAB} <input name='lastColor_{$fieldName}' id='lastColor_{$fieldName}' value='' type='hidden' />{$CRLF}"; $cNo = 0; foreach ($fldDimensions as $key => $value) { $s = $s . "{$TAB} <input name='{$fieldName}{$cNo}' id='{$fieldName}{$cNo}' value='{$key}' type='hidden' />{$CRLF}"; $cNo = $cNo + 1; } $s = $s . "{$TAB}</div>{$CRLF}"; return $s; }
private function buildHTMLForInarray($CRLF, $TAB, $fieldName, $fieldTitle, $fieldValue, $PREFIX) { if ($this->displayThisObject) { $inputType = 'text'; } else { $inputType = 'hidden'; $fieldTitle = ''; } if ($this->parentType == 'form') { //--not a subform $titleTableDetail = "{$TAB} <td class='selected' bgcolor='{$this->bgcolor}' style='text-align:right'>{$fieldTitle}</td>{$CRLF}"; $tr1 = "{$TAB}<tr class='selected'>{$CRLF}"; $tr2 = "{$TAB}</tr>{$CRLF}"; $td1 = "{$TAB} <td class='selected' style='text-align:left'>{$CRLF}{$TAB} "; $td2 = "{$TAB} </td>{$CRLF}"; } if ($PREFIX != '') { $untick = "untick('{$PREFIX}');"; } $style = $this->addStyle('width', $this->objectProperty['sob_inarray_length'] * 16); $style = $style . $this->addStyle('text-align', $this->objectProperty['sob_inarray_align']); $s = $titleTableDetail . $td1; $s = $s . "<input "; $s = $s . $this->addProperty('type', $inputType); $s = $s . $this->addProperty('name', $fieldName); $s = $s . $this->addProperty('id', $fieldName); $s = $s . $this->addProperty('value', $fieldValue); $s = $s . $this->addProperty('accesskey', $this->objectProperty['sob_all_access_key']); if ($inputType == 'text') { if ($this->objectProperty['sob_all_class'] == '') { $s = $s . $this->addProperty('class', 'objects'); } else { $s = $s . $this->addProperty('class', $this->objectProperty['sob_all_class']); } $s = $s . $this->addProperty('style', $style); $s = $s . $this->addProperty('onchange', $untick . "uDB(this);" . $fieldName . '_array(this);' . $this->objectProperty['sob_all_onchange']); $s = $s . $this->addProperty('onblur', $this->objectProperty['sob_all_on_blur']); $s = $s . $this->addProperty('onfocus', $this->objectProperty['sob_all_on_focus']); $s = $s . $this->addProperty('onkeypress', $this->objectProperty['sob_all_on_keypress']); $s = $s . $this->addProperty('ondblclick', $this->objectProperty['sob_all_on_doubleclick']); } if ($this->objectProperty['sob_text_read_only'] == '1') { $s = $s . " readonly='readonly' "; } $s = $s . "/>{$CRLF}"; $s = $s . $td2; //---replace any hashes with variables $sql = replaceVariablesInString($this->TT, $this->objectProperty['sob_inarray_sql'], $this->recordID); //---run sql and use the first row and colomn as the value for this field $t = nuRunQuery($sql); $fun = "function {$fieldName}" . "_array(pThis){ {$CRLF}"; $fun = $fun . " var ar = new Array();{$CRLF}"; $fun = $fun . " var found = new Boolean(false);{$CRLF}"; $counter = 0; while ($r = db_fetch_row($t)) { if ($counter == 0) { $first = $r[0]; } $last = $r[0]; $fun = $fun . " ar[{$counter}] = \"{$r['0']}\";{$CRLF}"; $counter = $counter + 1; } $dq = '"'; $fun = $fun . " {$CRLF}"; $fun = $fun . " for (i=0 ; i < ar.length ; i++){ {$CRLF}"; $fun = $fun . " if(ar[i] == pThis.value){ {$CRLF}"; $fun = $fun . " found=true;{$CRLF}"; $fun = $fun . " }{$CRLF}"; $fun = $fun . " }{$CRLF}"; $fun = $fun . " if(found==false){ {$CRLF}"; $fun = $fun . " alert('Must be between {$dq}{$first}{$dq} and {$dq}{$last}{$dq}'){$CRLF}"; $fun = $fun . " pThis.value = '';{$CRLF}"; $fun = $fun . " }{$CRLF}"; $fun = $fun . "}{$CRLF}"; $this->parentForm->appendJSfunction($fun); return $tr1 . $s . $tr2; }
function __construct($theFormID, $thePageNumber, $theOrderBy, $isDescending, $theSearchString, $subformPrefix, $objectID, $recordID) { $this->TT = TT(); //---temp table name $this->theFormID = $theFormID; $this->objectID = $objectID; $this->recordID = $recordID; $this->rowPrefix = $subformPrefix; $this->PageNo = $thePageNumber; $this->orderBy = $theOrderBy; $this->isDescending = $isDescending; $this->form = formFields($theFormID); if ($objectID == '') { $this->callingForm = formFields($theFormID); } else { $this->isLookup = true; $t = nuRunQuery("SELECT sob_lookup_zzsysform_id FROM zzsys_object WHERE zzsys_object_id = '{$objectID}'"); $r = db_fetch_row($t); $this->callingForm = formFields($r[0]); while (list($key, $va) = each($_POST)) { $uniq = uniqid('1'); $key = str_replace("'", "\\'", $key); nuRunQuery("INSERT INTO zzsys_small_form_value (zzsys_small_form_value_id, sfv_form_record, sfv_name, sfv_value) VALUES ('{$uniq}', '{$theFormID}{$this->recordID}{$ses}" . $_GET['ses'] . "', '{$key}', '{$va}')"); } } $this->searchString = $theSearchString; $this->pageLength = 10; $this->rowHeight = 20; $this->startTime = time(); $this->setup = nuSetup(); $this->getColumnInfo($this->callingForm->zzsys_form_id); $this->defaultJSfunctions(); if ($this->callingForm->sfo_sql_run_before_display != '') { $beforeDisplaySQL = replaceVariablesInString($this->TT, $this->callingForm->sfo_sql_run_before_display, ''); $sqlStatements = array(); $sqlStatements = explode(';', $beforeDisplaySQL); //---create a tempfile to be used later as object is being built. for ($i = 0; $i < count($sqlStatements); $i++) { if (trim($sqlStatements[$i]) != '') { nuRunQuery($sqlStatements[$i]); } } } $this->SQL = new sqlString(replaceVariablesInString($this->TT, $this->callingForm->sfo_sql, '')); $this->buildWhereClause($theSearchString); $this->SQL->setWhere($this->pageWhereClause); $this->SQL->setOrderBy($this->buildOrderBy()); $this->pageBody = $this->buildBody(); $this->pageHeader = $this->buildHeader(); }
$f = $_GET['f']; //-- zzsys_form_id in zzsys_form $rID = $_GET['r']; //-- lookup's selected record id $fr = $_GET['fr']; //-- form's record id $ob = $_GET['ob']; //-- zzsys_object_id in zzsys_object of selected lookup $value = $_GET['value']; //-- selected value to go back into lookup field include "../{$dir}/database.php"; include 'common.php'; $TT = TT(); $object = objectFields($ob); $browse = formFields($object->sob_lookup_zzsysform_id); $SQL = new sqlString(replaceVariablesInString($TT, $browse->sfo_sql, '')); if ($SQL->where == '') { $SQL->setWhere(" WHERE {$object->sob_lookup_id_field} = '{$rID}'"); } else { $SQL->setWhere(" {$SQL->where} AND ({$object->sob_lookup_id_field} = '{$rID}')"); } $SQL->removeAllFields(); $SQL->addField($object->sob_lookup_id_field); $fieldNames[] = $object->sob_all_name; $SQL->addField($object->sob_lookup_code_field); $fieldNames[] = 'code' . $object->sob_all_name; $SQL->addField($object->sob_lookup_description_field); $fieldNames[] = 'description' . $object->sob_all_name; $t = nuRunQuery("SELECT * FROM zzsys_lookup WHERE slo_zzsys_object_id = '{$object->zzsys_object_id}'"); while ($r = db_fetch_object($t)) { $SQL->addField($r->zzsys_slo_table_field_name);
function displayCondition_old($string, $recordID, $recordValues) { if ($string == '') { return true; } //--- replace variables in string with GLOBAL variables and/or $id $string = replaceVariablesInString('', $string, $recordID); //--- get array of other values that need replacing $hash = getArrayFromString($string, '#'); //--- loop through array replacing variables in string with values for ($i = 0; $i < count($hash); $i++) { $fieldname = $hash[$i]; $string = str_replace('#' . $hash[$i] . '#', $recordValues[$fieldname], $string); } //--- Run string as a select statement // $t = nuRunQuery('SELECT '.$string); $t = nuRunQuery($string); $answer = db_fetch_row($t); return $answer[0] == '1'; //---if answer = 1 then return True }