function initLookupParams() { global $cman; $this->parId = postvalue("parId"); $this->firstTime = postvalue("firsttime"); $this->mainField = postvalue("field"); $this->lookupControl = postvalue("control"); $this->lookupCategory = postvalue("category"); $this->mainTable = postvalue("table"); // convert into an array as parent ctrl can have multiple values if (!is_array($this->lookupCategory)) { $this->lookupCategory = strlen($this->lookupCategory) != 0 ? splitvalues($this->lookupCategory) : array(); } $arrCategory = array(); foreach ($this->lookupCategory as $categValue) { $arrCategory[] = "category[]=" . $categValue; } $lookCategory = implode("&", $arrCategory); if ($lookCategory) { $lookCategory = "&" . $lookCategory; } $this->lookupParams = "mode=lookup&id=" . $this->id . "&parId=" . $this->parId . "&field=" . rawurlencode($this->mainField) . "&control=" . rawurlencode($this->lookupControl) . $lookCategory . "&table=" . rawurlencode($this->mainTable) . "&editMode=" . postvalue('editMode'); $pageType = postvalue("pageType"); if ($pageType != PAGE_ADD && $pageType != PAGE_EDIT) { $pageType = PAGE_SEARCH; } $this->mainPSet = new ProjectSettings($this->mainTable, $pageType); $this->linkField = $this->mainPSet->getLinkField($this->mainField); $this->dispField = $this->mainPSet->getDisplayField($this->mainField); if ($this->mainPSet->getCustomDisplay($this->mainField)) { $this->dispFieldAlias = GetGlobalData("dispFieldAlias", "rrdf1"); $this->pSet->getSQLQuery()->AddCustomExpression($this->mainPSet->getDisplayField($this->mainField), $this->pSet, $this->mainTable, $this->mainField, $this->dispFieldAlias); $this->customField = $this->linkField; } $this->outputFieldValue($this->linkField, 2); $this->outputFieldValue($this->dispField, 2); if ($this->mainPSet->useCategory($this->mainField)) { $this->categoryField = $this->mainPSet->getCategoryFilter($this->mainField); } $this->strLookupWhere = GetLWWhere($this->mainField, $pageType, $this->mainTable); if ($this->dispFieldAlias && $this->pSet->appearOnListPage($this->dispField)) { $this->lookupSelectField = $this->dispField; } elseif ($this->pSet->appearOnListPage($this->dispField)) { $this->lookupSelectField = $this->dispField; } else { $this->lookupSelectField = $this->listFields[0]['fName']; } if (!$this->categoryField) { $this->lookupCategory = array(); } $orderByField = $this->mainPSet->getLookupOrderBy($this->mainField); if (strlen($orderByField)) { // adjust the ORDER BY clause according to the main lookup settings $this->gstrOrderBy = " ORDER BY " . $this->connection->addTableWrappers($this->tName) . "." . $this->connection->addFieldWrappers($orderByField); if ($this->mainPSet->isLookupDesc($this->mainField)) { $this->gstrOrderBy .= ' DESC'; } } }
if ($gSettings->isLookupDesc($f)) { $lookupOrderBy .= ' DESC'; } } if ($LookupType == LT_QUERY) { $LookupSQL = $lookupQueryObj->toSql(whereAdd($lookupQueryObj->m_where->toSql($lookupQueryObj), $strLookupWhere), strlen($lookupOrderBy) ? ' ORDER BY ' . $lookupOrderBy : null); } else { $LookupSQL = $LookupSQLTable . " where " . $strLookupWhere; if (!$gSettings->isLookupUnique($f) || nDATABASE_Access != $lookupConnection->dbType) { if ($lookupOrderBy) { $LookupSQL .= " ORDER BY " . $lookupOrderBy; } } } } if (strlen(GetLWWhere($f, $pageType, $strTableName))) { $hasWhere = true; } break; } $lookupIndexes = GetLookupFieldsIndexes($gSettings, $lookupField); $linkFieldIndex = $lookupIndexes["linkFieldIndex"]; $displayFieldIndex = $lookupIndexes["displayFieldIndex"]; if ($lookupConnection) { $qResult = $lookupConnection->query($LookupSQL); while ($data = $qResult->fetchNumeric()) { if ($LookupType == LT_QUERY && $gSettings->isLookupUnique($lookupField)) { if (!isset($uniqueArray)) { $uniqueArray = array(); } if (in_array($data[$displayFieldIndex], $uniqueArray)) {
function buildLookupSQL($pageType, $field, $table, $parentVal, $childVal = "", $doCategoryFilter = true, $doValueFilter = false, $addCategoryField = false, $doWhereFilter = true, $oneRecordMode = false, $doValueFilterByLinkField = false) { global $strTableName; if (!strlen($table)) { $table = $strTableName; } $pSet = new ProjectSettings($table, $pageType); // read settings $nLookupType = $pSet->getLookupType($field); if ($nLookupType != LT_LOOKUPTABLE && $nLookupType != LT_QUERY) { return ""; } $lookupTable = $pSet->getLookupTable($field); $displayFieldName = $pSet->getDisplayField($field); $linkFieldName = $pSet->getLinkField($field); $linkAndDisplaySame = $displayFieldName == $linkFieldName; $bUnique = $pSet->isLookupUnique($field); $strLookupWhere = GetLWWhere($field, $pageType, $table); $strOrderBy = $pSet->getLookupOrderBy($field); if (strlen($strOrderBy)) { $strOrderBy = GetFullFieldName($strOrderBy, $lookupTable); if ($pSet->isLookupDesc($field)) { $strOrderBy .= ' DESC'; } } $bDesc = $pSet->isLookupDesc($field); $strCategoryFilter = $pSet->getCategoryFilter($field); if ($nLookupType == LT_QUERY) { $lookupPSet = new ProjectSettings($lookupTable, $pageType); $cipherer = new RunnerCipherer($lookupTable, $lookupPSet); } else { $cipherer = new RunnerCipherer($table, $pSet); } if ($doCategoryFilter) { if ($nLookupType == LT_QUERY) { $parentVal = $cipherer->MakeDBValue($strCategoryFilter, $parentVal, "", $lookupTable, true); } else { $parentVal = make_db_value($pSet->getCategoryControl($field), $parentVal, '', '', $table); } } if ($doValueFilter) { if ($pageType != PAGE_SEARCH || $doValueFilterByLinkField) { if ($nLookupType == LT_QUERY) { $childWhereField = $pSet->getLWLinkField($field, false); } else { $childWhereField = $pSet->getLWLinkField($field, true); } } else { if ($nLookupType == LT_QUERY) { $childWhereField = $pSet->getLWDisplayField($field, false); } else { $childWhereField = $pSet->getLWDisplayField($field, true); } } if ($nLookupType == LT_QUERY) { $childVal = $cipherer->MakeDBValue($childWhereField, $childVal, "", $lookupTable, true); } else { if ($linkAndDisplaySame) { $childVal = make_db_value($field, $childVal, '', '', $table); } else { $childVal = add_db_quotes($field, $childVal, $table, 200); } } } // build Where clause $categoryWhere = ""; $childWhere = ""; if ($pSet->useCategory($field) && $doCategoryFilter) { $condition = "=" . $parentVal; if ($parentVal === "null") { $condition = " is null"; } if ($nLookupType == LT_QUERY) { $categoryWhere = $cipherer->GetFieldName(AddFieldWrappers($strCategoryFilter), $strCategoryFilter) . $condition; } else { $categoryWhere = AddFieldWrappers($strCategoryFilter) . $condition; } } if ($doValueFilter) { $condition = "=" . $childVal; if ($childVal === "null") { $condition = " is null"; } if ($nLookupType == LT_QUERY) { if ($pageType != PAGE_SEARCH || $pSet->lookupControlType($field) == LCT_LIST || $doValueFilterByLinkField) { $childWhere = GetFullFieldName($pSet->getLinkField($field), $lookupTable, false) . $condition; } else { if (!$pSet->getCustomDisplay($field)) { $childWhere = $cipherer->GetFieldName($lookupPSet->getFullNameField($displayFieldName), $field) . $condition; } else { $childWhere = $pSet->getDisplayField($field) . $condition; } } } else { if ($pageType != PAGE_SEARCH || $doValueFilterByLinkField) { $childWhere = $pSet->getLWLinkField($field, true) . $condition; } else { $childWhere = $pSet->getLWDisplayField($field, true) . $condition; } } } $strWhere = ""; if ($doWhereFilter && strlen($strLookupWhere)) { $strWhere = "(" . $strLookupWhere . ")"; } if (strlen($categoryWhere)) { if (strlen($strWhere)) { $strWhere .= " AND "; } $strWhere .= $categoryWhere; } if (strlen($childWhere)) { if (strlen($strWhere)) { $strWhere .= " AND "; } $strWhere .= $childWhere; } // build SQL string if ($nLookupType == LT_QUERY) { $lookupQueryObj = $lookupPSet->getSQLQuery(); if ($pSet->getCustomDisplay($field)) { $lookupQueryObj->AddCustomExpression($displayFieldName, $lookupPSet, $table, $field); } $lookupQueryObj->ReplaceFieldsWithDummies($lookupPSet->getBinaryFieldsIndices()); $strWhere = whereAdd($lookupQueryObj->m_where->toSql($lookupQueryObj), $strWhere); $LookupSQL = $lookupQueryObj->toSql($strWhere, strlen($strOrderBy) ? ' ORDER BY ' . $strOrderBy : null, null, $oneRecordMode); } else { $LookupSQL = "SELECT "; if ($bUnique && !$oneRecordMode) { $LookupSQL .= "DISTINCT "; } $LookupSQL .= $pSet->getLWLinkField($field); if (!$linkAndDisplaySame) { $LookupSQL .= "," . $pSet->getLWDisplayField($field); } if ($addCategoryField && strlen($strCategoryFilter)) { $LookupSQL .= "," . AddFieldWrappers($strCategoryFilter); } $LookupSQL .= " FROM " . AddTableWrappers($lookupTable); if (strlen($strWhere)) { $LookupSQL .= " WHERE " . $strWhere; } // order by clause if (strlen($strOrderBy)) { $LookupSQL .= " ORDER BY " . AddTableWrappers($lookupTable) . "." . $strOrderBy; } if ($oneRecordMode) { $LookupSQL .= " limit 1"; } } return $LookupSQL; }
function update_report_totals() { $root =& $_SESSION["webreports"]; // ensure all fields in reports are listed in the tables $tables = getReportTablesList(); if (is_wr_custom()) { $fields = WRGetFieldsList(''); } $arr_unset = array(); foreach ($root["totals"] as $idx => $fld) { if (array_search($fld["table"], $tables) !== false || is_null($fld["table"]) && is_wr_custom()) { if (!is_wr_custom()) { $fields = WRGetFieldsList($fld["table"]); } if (array_search($fld["name"], $fields) !== false) { continue; } } // remove $total if found $arr_unset[] = $idx; } foreach ($arr_unset as $idx => $fld) { unset($root["totals"][$fld]); } // ensure all fields appear in the totals $all_fields = array(); foreach ($tables as $t) { $fields = WRGetFieldsList($t); foreach ($fields as $f) { if (is_wr_db()) { $all_fields[] = $t . "." . $f; } else { $all_fields[] = $f; } } } // ensure all series fields appear in the totals foreach ($all_fields as $fieldItem) { $f = $fieldItem; $table = ""; $fld = ""; if (is_wr_db()) { WRSplitFieldName($f, $table, $fld); } else { $table = $tables[0]; $fld = $f; $f = $table . "_" . $f; } if (array_key_exists(GoodFieldName($f), $root["totals"])) { continue; } $pSet = new ProjectSettings($table, PAGE_LIST); $root['totals'][GoodFieldName($f)] = array(); $root['totals'][GoodFieldName($f)]["name"] = $fld; $root['totals'][GoodFieldName($f)]["table"] = $table; $root['totals'][GoodFieldName($f)]["label"] = $pSet->label($fld); $root['totals'][GoodFieldName($f)]["show"] = "true"; $root['totals'][GoodFieldName($f)]["min"] = "false"; $root['totals'][GoodFieldName($f)]["max"] = "false"; $root['totals'][GoodFieldName($f)]["sum"] = "false"; $root['totals'][GoodFieldName($f)]["avg"] = "false"; $root['totals'][GoodFieldName($f)]["curr"] = "false"; $root['totals'][GoodFieldName($f)]["search"] = ""; $root['totals'][GoodFieldName($f)]["view_format"] = GetGenericViewFormat($table, $fld); $root['totals'][GoodFieldName($f)]["edit_format"] = GetGenericEditFormat($table, $fld); $root['totals'][GoodFieldName($f)]["display_field"] = $pSet->getDisplayField($fld); $root['totals'][GoodFieldName($f)]["linkfield"] = $pSet->getLinkField($fld); $root['totals'][GoodFieldName($f)]["show_thumbnail"] = $pSet->showThumbnail($fld); $root['totals'][GoodFieldName($f)]["need_encode"] = $pSet->NeedEncode($fld); $root['totals'][GoodFieldName($f)]["thumbnail"] = $pSet->getStrThumbnail($fld); $root['totals'][GoodFieldName($f)]["listformatobj_imgwidth"] = $pSet->getImageWidth($fld); $root['totals'][GoodFieldName($f)]["listformatobj_imgheight"] = $pSet->getImageHeight($fld); $root['totals'][GoodFieldName($f)]["hlprefix"] = $pSet->getLinkPrefix($fld); $root['totals'][GoodFieldName($f)]["listformatobj_filename"] = $pSet->getFilenameField($fld); $root['totals'][GoodFieldName($f)]["lookupobj_lookuptype"] = $pSet->getLookupType($fld); $root['totals'][GoodFieldName($f)]["editformatobj_lookupobj_customdispaly"] = $pSet->getDisplayField($fld); $root['totals'][GoodFieldName($f)]["editformatobj_lookupobj_table"] = $pSet->getLookupTable($fld); $root['totals'][GoodFieldName($f)]["editformatobj_lookupobj_where"] = GetLWWhere($fld, PAGE_REPORT); } $_SESSION["webreports"] = $root; }
/** * Get a Lookup Wizard Where expression * @return String */ protected function getLookupWhere() { $lookupWhere = GetLWWhere($this->field, $this->lookupPageType, $this->tName); if ($this->lookupType == LT_QUERY) { if ($this->lookupPSet->getAdvancedSecurityType() == ADVSECURITY_VIEW_OWN) { $lookupWhere = whereAdd($lookupWhere, SecuritySQL("Search", $this->lookupTable)); } } return $lookupWhere; }
function comlete_report_session_default_values($isedit = "") { $root =& $_SESSION["webreports"]; $table = $root['tables'][0]; $arr_fields = WRGetNBFieldsList($table); $arr_fields_all = WRGetFieldsList($table); $gfield = $arr_fields[0]; if (is_wr_db()) { $gfield = $table . "." . $arr_fields[0]; } $garrfield = array("name" => $gfield, "int_type" => "0", "ss" => "true", "group_order" => "1", "color1" => "FF0000", "color2" => "CC0000"); $garrSummary = array(); $garrSummary["name"] = "Summary"; $garrSummary["crosstable"] = "false"; $garrSummary["sps"] = "true"; $garrSummary["sds"] = "true"; $garrSummary["sgs"] = "true"; $garrSummary["sum_x"] = "true"; $garrSummary["sum_y"] = "true"; $garrSummary["sum_total"] = "true"; $root['group_fields'] = array($garrfield, $garrSummary); $root['totals'] = array(); $pSet = new ProjectSettings($table); foreach ($arr_fields_all as $fld) { $root['totals'][GoodFieldName($table . "." . $fld)] = array(); $root['totals'][GoodFieldName($table . "." . $fld)]["name"] = $fld; $root['totals'][GoodFieldName($table . "." . $fld)]["table"] = $table; $root['totals'][GoodFieldName($table . "." . $fld)]["label"] = $pSet->label($fld); $root['totals'][GoodFieldName($table . "." . $fld)]["show"] = "true"; $root['totals'][GoodFieldName($table . "." . $fld)]["min"] = "false"; $root['totals'][GoodFieldName($table . "." . $fld)]["max"] = "false"; $root['totals'][GoodFieldName($table . "." . $fld)]["sum"] = "false"; $root['totals'][GoodFieldName($table . "." . $fld)]["avg"] = "false"; $root['totals'][GoodFieldName($table . "." . $fld)]["curr"] = "false"; $root['totals'][GoodFieldName($table . "." . $fld)]["search"] = ""; $root['totals'][GoodFieldName($table . "." . $fld)]["view_format"] = GetGenericViewFormat($table, $fld); $root['totals'][GoodFieldName($table . "." . $fld)]["edit_format"] = GetGenericEditFormat($table, $fld); $root['totals'][GoodFieldName($table . "." . $fld)]["display_field"] = $pSet->getDisplayField($fld); if (is_wr_project()) { $root['totals'][GoodFieldName($table . "." . $fld)]["linkfield"] = $pSet->getLinkField($fld); } else { $root['totals'][GoodFieldName($table . "." . $fld)]["linkfield"] = ""; } $root['totals'][GoodFieldName($table . "." . $fld)]["show_thumbnail"] = $pSet->showThumbnail($fld); $root['totals'][GoodFieldName($table . "." . $fld)]["need_encode"] = $pSet->NeedEncode($fld); $root['totals'][GoodFieldName($table . "." . $fld)]["thumbnail"] = $pSet->getStrThumbnail($fld); $root['totals'][GoodFieldName($table . "." . $fld)]["listformatobj_imgwidth"] = $pSet->getImageWidth($fld); $root['totals'][GoodFieldName($table . "." . $fld)]["listformatobj_imgheight"] = $pSet->getImageHeight($fld); $root['totals'][GoodFieldName($table . "." . $fld)]["hlprefix"] = $pSet->getLinkPrefix($fld); $root['totals'][GoodFieldName($table . "." . $fld)]["listformatobj_filename"] = $pSet->getFilenameField($fld); $root['totals'][GoodFieldName($table . "." . $fld)]["lookupobj_lookuptype"] = $pSet->getLookupType($fld); $root['totals'][GoodFieldName($table . "." . $fld)]["editformatobj_lookupobj_customdispaly"] = $pSet->getDisplayField($fld); $root['totals'][GoodFieldName($table . "." . $fld)]["editformatobj_lookupobj_table"] = $pSet->getLookupTable($fld); $root['totals'][GoodFieldName($table . "." . $fld)]["editformatobj_lookupobj_where"] = GetLWWhere($fld, PAGE_REPORT); } $root['sort_fields'] = array(array("name" => $gfield, "desc" => "false")); if (!$isedit) { $root['miscellaneous'] = array("type" => "stepped", "print_friendly" => "true", "lines_num" => "30"); $root['settings'] = array("name" => GoodFieldName($root['tables'][0]) . '_' . CheckLastID('report'), "title" => $root['tables'][0] . ' Report ' . CheckLastID('report'), "status" => "private"); $_SESSION["webobject"]["name"] = GoodFieldName($root['tables'][0]) . '_' . CheckLastID('report'); $root['owner'] = $_SESSION["UserID"]; $_SESSION['webreports']['tmp_active'] = "x"; } $root['table_name'] = $root['tables'][0]; $root['short_table_name'] = GetTableURL($root['tables'][0]); }
function buildControl($value, $mode, $fieldNum = 0, $validate, $additionalCtrlParams, $data) { parent::buildControl($value, $mode, $fieldNum, $validate, $additionalCtrlParams, $data); global $conn; $this->conn = $conn; // read control settings $this->alt = ""; if (($mode == MODE_INLINE_EDIT || $mode == MODE_INLINE_ADD) && $this->is508) { $this->alt = ' alt="' . htmlspecialchars($this->strLabel) . '" '; } $this->cfield = "value_" . GoodFieldName($this->field) . "_" . $this->id; $this->clookupfield = "display_value" . ($fieldNum ? $fieldNum : '') . "_" . GoodFieldName($this->field) . "_" . $this->id; $this->openlookup = "open_lookup_" . GoodFieldName($this->field) . "_" . $this->id; $this->ctype = "type_" . GoodFieldName($this->field) . "_" . $this->id; if ($fieldNum) { $this->cfield = "value" . $fieldNum . "_" . GoodFieldName($this->field) . "_" . $this->id; $this->ctype = "type" . $fieldNum . "_" . GoodFieldName($this->field) . "_" . $this->id; } $this->addnewitem = false; $advancedadd = false; //$this->strCategoryControl = $this->pageObject->pSetEdit->getCategoryControl($this->field); $this->categoryFieldId = GoodFieldName($this->pageObject->pSetEdit->getCategoryControl($this->field)); $this->bUseCategory = $this->pageObject->pSetEdit->useCategory($this->field); $dependentLookups = $this->pageObject->pSetEdit->getDependentLookups($this->field); $this->isLinkFieldEncrypted = $this->ciphererLink->isFieldPHPEncrypted($this->field); $this->horizontalLookup = $this->pageObject->pSetEdit->isHorizontalLookup($this->field); //$this->inputStyle = ($additionalCtrlParams['style'] ? 'style="'.$additionalCtrlParams['style'].'"' : ''); $this->strLookupWhere = GetLWWhere($this->field, $this->lookupPageType, $this->pageObject->tName); $this->lookupSize = $this->pageObject->pSetEdit->selectSize($this->field); if ($this->LCType == LCT_CBLIST) { $this->lookupSize = 2; } // simply > 1 for CBLIST $add_page = GetTableURL($this->lookupTable) . "_add.php"; $list_page = GetTableURL($this->lookupTable) . "_list.php"; $strPerm = GetUserPermissions($this->lookupTable); // alter "add on the fly" settings if (strpos($strPerm, "A") !== false) { $this->addnewitem = $this->pageObject->pSetEdit->isAllowToAdd($this->field); $advancedadd = !$this->pageObject->pSetEdit->isSimpleAdd($this->field); if (!$advancedadd) { $this->addnewitem = false; } } // alter lookuptype settings if ($this->LCType == LCT_LIST && strpos($strPerm, "S") === false) { $this->LCType = LCT_DROPDOWN; } if ($this->LCType == LCT_LIST) { $this->addnewitem = false; } if ($mode == MODE_SEARCH) { $this->addnewitem = false; } // prepare multi-select attributes $this->multiple = ""; $this->postfix = ""; if ($this->lookupSize > 1) { $avalue = splitvalues($value); $this->multiple = " multiple"; $this->postfix = "[]"; } else { $avalue = array((string) $value); } // prepare JS code $className = "DropDownLookup"; if ($this->LCType == LCT_AJAX) { $className = "EditBoxLookup"; } elseif ($this->LCType == LCT_LIST) { $className = "ListPageLookup"; } elseif ($this->LCType == LCT_CBLIST) { $className = "CheckBoxLookup"; } // build the control /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // list of values /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if ($this->lookupType == LT_LISTOFVALUES) { $this->buildListOfValues($avalue, $value, $mode); } else { // build table-based lookup $this->isDisplayFieldEncrypted = ($this->lookupType == LT_QUERY || $this->linkAndDisplaySame) && $this->ciphererDisplay->isFieldPHPEncrypted($this->lookupType == LT_QUERY ? $this->displayFieldName : $this->field); //////////////////////////////////////////////////////////////////////////////////////////// // table-based ajax-lookup control //////////////////////////////////////////////////////////////////////////////////////////// if ($this->LCType == LCT_AJAX || $this->LCType == LCT_LIST) { $this->buildAJAXLookup($value, $mode); } else { $this->buildClassicLookup($avalue, $value, $mode); } } $this->buildControlEnd($validate); }
function DisplayLookupWizard($field, $value, $data, $keylink, $mode) { global $conn, $strTableName; if (!strlen($value)) { return ""; } $LookupSQL = "SELECT "; $LookupSQL .= GetLWDisplayField($field); $LookupSQL .= " FROM " . AddTableWrappers(GetLookupTable($field)) . " WHERE "; $where = ""; $lookupvalue = $value; $iquery = "field=" . htmlspecialchars(rawurlencode($field)) . $keylink; $out = ""; if (Multiselect($field)) { $arr = splitvalues($value); $numeric = true; $type = GetLWLinkFieldType($field); if (!$type) { foreach ($arr as $val) { if (strlen($val) && !is_numeric($val)) { $numeric = false; break; } } } else { $numeric = !NeedQuotes($type); } $in = ""; foreach ($arr as $val) { if ($numeric && !strlen($val)) { continue; } if (strlen($in)) { $in .= ","; } if ($numeric) { $in .= $val + 0; } else { $in .= db_prepare_string($val); } } if (strlen($in)) { $LookupSQL .= GetLWLinkField($field) . " in (" . $in . ")"; $where = GetLWWhere($field); if (strlen($where)) { $LookupSQL .= " and (" . $where . ")"; } LogInfo($LookupSQL); $rsLookup = db_query($LookupSQL, $conn); $found = false; while ($lookuprow = db_fetch_numarray($rsLookup)) { $lookupvalue = $lookuprow[0]; if ($found) { $out .= ","; } $found = true; $out .= GetDataInt($lookupvalue, $data, $field, ViewFormat($field)); } if ($found) { if (NeedEncode($field) && $mode != MODE_EXPORT) { return ProcessLargeText($out, $iquery, "", $mode, GetEditFormat($field)); } else { return $out; } } } } else { $strdata = make_db_value($field, $value); $LookupSQL .= GetLWLinkField($field) . " = " . $strdata; $where = GetLWWhere($field); if (strlen($where)) { $LookupSQL .= " and (" . $where . ")"; } LogInfo($LookupSQL); $rsLookup = db_query($LookupSQL, $conn); if ($lookuprow = db_fetch_numarray($rsLookup)) { $lookupvalue = $lookuprow[0]; } } if (!$out) { $out = GetDataInt($lookupvalue, $data, $field, ViewFormat($field)); } if (NeedEncode($field) && $mode != MODE_EXPORT) { $value = ProcessLargeText($out, $iquery, "", $mode, GetEditFormat($field)); } else { $value = $out; } return $value; }
/** * Get a Lookup Wizard Where expression * @return String */ protected function getLookupWhere() { $lookupWhere = GetLWWhere($this->field, $this->lookupPageType, $this->tName); return $lookupWhere; }
/** * @param String value * @return String */ protected function getNotMultiselectLookupResolvingSQL($value) { if ($this->pSet->multiSelect($this->field)) { return ""; } $where = GetLWWhere($this->field, $this->pSet->getEditPageType()); $strdata = $this->cipherer->MakeDBValue($this->nLookupType == LT_QUERY ? $this->linkFieldName : $this->field, $value, "", true); if ($this->nLookupType == LT_QUERY) { $strWhere = GetFullFieldName($this->linkFieldName, $this->lookupTable, false) . " = " . $strdata; if (strlen($where)) { $strWhere .= " and (" . $where . ")"; } $LookupSQL = $this->lookupQueryObj->toSql(whereAdd($this->lookupQueryObj->m_where->toSql($this->lookupQueryObj), $strWhere)); } else { $strWhere = $this->lookupConnection->addFieldWrappers($this->pSet->getLinkField($this->field)) . " = " . $strdata; if (strlen($where)) { $strWhere .= " and (" . $where . ")"; } $LookupSQL = $this->LookupSQL . $strWhere; } return $LookupSQL; }
<td style="display:none;"> <input type="text" id="vf' . $cnt . '" name="vf' . $cnt . '" value="' . $vf . '" > <input type="text" id="ef' . $cnt . '" name="ef' . $cnt . '" value="' . GetGenericEditFormat( $arr['table'], $arr['field'] ) . '" > <input type="text" id="display_field_' . $cnt . '" name="display_field_' . $cnt . '" value="' . $pSet->getLWDisplayField( $arr['field'] ) . '" > <input type="text" id="linkfield_' . $cnt . '" name="linkfield_' . $cnt . '" value="' . $pSet->getLWLinkField( $arr['field'] ) . '" > <input type="text" id="show_thumbnail_' . $cnt . '" name="show_thumbnail_' . $cnt . '" value="' . $pSet->showThumbnail( $arr['field'] ) . '" > <input type="text" id="need_encode_' . $cnt . '" name="need_encode_' . $cnt . '" value="' . $pSet->NeedEncode($arr['field']) . '" > <input type="text" id="thumbnail_' . $cnt . '" name="thumbnail_' . $cnt . '" value="' . $pSet->getStrThumbnail( $arr['field'] ) . '" > <input type="text" id="listformatobj_imgwidth_' . $cnt . '" name="listformatobj_imgwidth_' . $cnt . '" value="' . $pSet->getImageWidth( $arr['field'] ) . '" > <input type="text" id="listformatobj_imgheight_' . $cnt . '" name="listformatobj_imgheight_' . $cnt . '" value="' . $pSet->getImageHeight( $arr['field'] ) . '" > <input type="text" id="hlprefix_' . $cnt . '" name="hlprefix_' . $cnt . '" value="' . $pSet->getLinkPrefix($arr['field']) . '" > <input type="text" id="listformatobj_filename_' . $cnt . '" name="listformatobj_filename_' . $cnt . '" value="' . $pSet->getFilenameField( $arr['field']) . '" > <input type="text" id="lookupobj_lookuptype_' . $cnt . '" name="lookupobj_lookuptype_' . $cnt . '" value="' . $pSet->getLookupType( $arr['field'] ) . '" > <input type="text" id="editformatobj_lookupobj_customdispaly_' . $cnt . '" name="editformatobj_lookupobj_customdispaly_' . $cnt . '" value="' . $pSet->getLWDisplayField( $arr['field'] ) . '" > <input type="text" id="editformatobj_lookupobj_table_' . $cnt . '" name="editformatobj_lookupobj_table_' . $cnt . '" value="' . $pSet->getLookupTable( $arr['field'] ) . '" > <input type="text" id="editformatobj_lookupobj_where_' . $cnt . '" name="editformatobj_lookupobj_where_' . $cnt . '" value="' . GetLWWhere($arr['field'],PAGE_REPORT) . '" > </td> </tr>'; } $arr = $_SESSION['webreports']['totals']; if ( !empty( $arr ) ) { $b_includes .= '<script type="text/javascript"> $(document).ready(function(){'."\n"; foreach ($arr as $id => $totals) { if(!is_wr_custom()) $b_includes .= "$('tr[id=".$id."]', '#trt').find('td').eq(1).text('" . jsreplace($totals["table"].".".$totals["name"]) . "');"."\n"; $b_includes .= "$('tr[id=".$id."]', '#trt').find('td').eq(2).find('input').val('" . jsreplace($totals["label"]) . "');"."\n";
function initLookupParams() { $this->parId = postvalue("parId"); $this->firstTime = postvalue("firsttime"); $this->mainField = postvalue("field"); $this->lookupControl = postvalue("control"); $this->lookupCategory = postvalue("category"); $this->mainTable = postvalue("table"); global $tables_data; include_once getabspath('include/' . GetTableURL($this->mainTable) . '_settings.php'); $this->pSet = new ProjectSettings($this->tName, PAGE_SEARCH); $this->lookupParams = "mode=lookup&id=" . $this->id . "&parId=" . $this->parId . "&field=" . rawurlencode($this->mainField) . "&control=" . rawurlencode($this->lookupControl) . "&category=" . rawurlencode($this->lookupCategory) . "&table=" . rawurlencode($this->mainTable) . "&editMode=" . postvalue('editMode'); $this->sessionPrefix = $this->tName . "_lookup_" . $this->mainTable . '_' . $this->mainField; $pageType = postvalue("pageType"); if ($pageType != PAGE_ADD && $pageType != PAGE_EDIT) { $pageType = PAGE_SEARCH; } $lookupPSet = new ProjectSettings($this->mainTable, $pageType); $this->linkField = $lookupPSet->getLWLinkField($this->mainField, false); $this->dispField = $lookupPSet->getLWDisplayField($this->mainField, false); if ($lookupPSet->getCustomDisplay($this->mainField)) { $this->dispFieldAlias = GetGlobalData("dispFieldAlias", "rrdf1"); $this->pSet->getSQLQuery()->AddCustomExpression($lookupPSet->getDisplayField($this->mainField), $this->pSet, $this->mainTable, $this->mainField, $this->dispFieldAlias); $this->customField = $this->linkField; } $this->outputFieldValue($this->linkField, 2); $this->outputFieldValue($this->dispField, 2); if ($lookupPSet->useCategory($this->mainField)) { $this->categoryField = $lookupPSet->getCategoryFilter($this->mainField); } $this->strLookupWhere = GetLWWhere($this->mainField, $this->pageType, $this->mainTable); if ($this->dispFieldAlias && $this->pSet->appearOnListPage($this->dispField)) { $this->lookupSelectField = $this->dispField; } elseif ($this->pSet->appearOnListPage($this->dispField)) { $this->lookupSelectField = $this->dispField; } else { $this->lookupSelectField = $this->listFields[0]['fName']; } if ($this->categoryField) { if (!strlen(GetFullFieldName($this->categoryField))) { $this->categoryField = ""; } } if (!$this->categoryField) { $this->lookupCategory = ""; } }
public function showDBValue(&$data, $keylink) { global $conn, $strTableName; $value = $data[$this->field]; if (!strlen($value)) { return ""; } $where = ""; $out = ""; $lookupvalue = $value; $iquery = "field=" . htmlspecialchars(rawurlencode($this->field)) . $keylink; $where = GetLWWhere($this->field, $this->container->pageType); if ($this->pSet->multiSelect($this->field)) { $arr = splitvalues($value); $numeric = true; $type = $this->pSet->getLWLinkFieldType($this->field); if (!$type) { foreach ($arr as $val) { if (strlen($val) && !is_numeric($val)) { $numeric = false; break; } } } else { $numeric = !NeedQuotes($type); } $in = ""; foreach ($arr as $val) { if ($numeric && !strlen($val)) { continue; } if (strlen($in)) { $in .= ","; } if ($numeric) { $in .= $val + 0; } else { $in .= db_prepare_string($this->cipherer->EncryptField($this->nLookupType == LT_QUERY ? $this->linkFieldName : $this->field, $val)); } } if (strlen($in)) { if ($this->nLookupType == LT_QUERY) { $inWhere = GetFullFieldName($this->linkFieldName, $this->lookupTable, false) . " in (" . $in . ")"; if (strlen($where)) { $inWhere .= " and (" . $where . ")"; } $LookupSQL = $this->lookupQueryObj->toSql(whereAdd($this->lookupQueryObj->m_where->toSql($this->lookupQueryObj), $inWhere)); } else { $LookupSQL = $this->LookupSQL . $this->pSet->getLWLinkField($this->field) . " in (" . $in . ")"; if (strlen($where)) { $LookupSQL .= " and (" . $where . ")"; } } LogInfo($LookupSQL); $rsLookup = db_query($LookupSQL, $conn); $found = false; $lookupArrTmp = array(); $lookupArr = array(); while ($lookuprow = db_fetch_numarray($rsLookup)) { $lookupArrTmp[] = $lookuprow[$this->displayFieldIndex]; } $lookupArr = array_unique($lookupArrTmp); $localData = $data; foreach ($lookupArr as $lookupvalue) { if ($found) { $out .= ","; } $found = true; if ($this->pSet->getViewFormat($this->field) != "Custom") { $localData[$this->field] = $lookupvalue; } $outVal = $this->localControlsContainer->showDBValue($this->field, $localData, $keylink, $lookupvalue); $out .= $this->nLookupType == LT_QUERY || $this->linkAndDisplaySame ? $this->cipherer->DecryptField($this->nLookupType == LT_QUERY ? $this->displayFieldName : $this->field, $outVal) : $outVal; } return $out; } } else { $found = false; $strdata = $this->cipherer->MakeDBValue($this->nLookupType == LT_QUERY ? $this->linkFieldName : $this->field, $value, "", "", true); if ($this->nLookupType == LT_QUERY) { $strWhere = GetFullFieldName($this->linkFieldName, $this->lookupTable, false) . " = " . $strdata; if (strlen($where)) { $strWhere .= " and (" . $where . ")"; } $LookupSQL = $this->lookupQueryObj->toSql(whereAdd($this->lookupQueryObj->m_where->toSql($this->lookupQueryObj), $strWhere)); } else { $strWhere = $this->pSet->getLWLinkField($this->field) . " = " . $strdata; if (strlen($where)) { $strWhere .= " and (" . $where . ")"; } $LookupSQL = $this->LookupSQL . $strWhere; } LogInfo($LookupSQL); $rsLookup = db_query($LookupSQL, $conn); if ($lookuprow = db_fetch_numarray($rsLookup)) { $lookupvalue = $lookuprow[$this->displayFieldIndex]; $found = true; } } if (!$out) { if ($found && ($this->nLookupType == LT_QUERY || $this->linkAndDisplaySame)) { $lookupvalue = $this->cipherer->DecryptField($this->nLookupType == LT_QUERY ? $this->displayFieldName : $this->field, $lookupvalue); } $localData = $data; if ($this->pSet->getViewFormat($this->field) != "Custom") { $localData[$this->field] = $lookupvalue; } $out = $this->localControlsContainer->showDBValue($this->field, $localData, $keylink, $lookupvalue); } return $out; }