예제 #1
0
 }
 $strLookupWhere = GetLWWhere($f, $pageType, $strTableName);
 if ($strLookupWhere) {
     $strLookupWhere = " (" . $strLookupWhere . ")  AND ";
 }
 if ($LookupType == LT_QUERY) {
     if ($gSettings->getCustomDisplay($f)) {
         $strLookupWhere .= $displayFieldName;
     } else {
         $strLookupWhere .= GetFullFieldName($displayFieldName, $lookupTable, false);
     }
 } else {
     $strLookupWhere .= $cipherer->GetFieldName($lwDisplayField, $f);
 }
 $strLookupWhere .= $cipherer->GetLikeClause($LookupType == LT_QUERY ? $displayFieldName : $f, $value);
 if ($gSettings->useCategory($f) && (postvalue("category") != '' || postvalue('editMode') != MODE_SEARCH)) {
     $cvalue = make_db_value($gSettings->getCategoryControl($f), postvalue("category"));
     $strLookupWhere .= " AND " . AddFieldWrappers($gSettings->getCategoryFilter($f)) . "=" . $cvalue;
 }
 $lookupOrderBy = $gSettings->getLookupOrderBy($f);
 if (strlen($lookupOrderBy)) {
     $lookupOrderBy = GetFullFieldName($lookupOrderBy, $lookupTable);
     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 != 4) {
예제 #2
0
function loadSelectContent($pageType, $childFieldName, $parentVal, $doCategoryFilter = true, $childVal = "", $initialLoad = true)
{
    global $conn, $LookupSQL, $strTableName;
    $pSet = new ProjectSettings($strTableName, $pageType);
    $response = array();
    $lookupType = $pSet->getLookupType($childFieldName);
    $isUnique = $pSet->isLookupUnique($childFieldName);
    if ($pSet->useCategory($childFieldName) && $doCategoryFilter) {
        if ($lookupType == LT_QUERY) {
            $lookupTable = $pSet->getLookupTable($childFieldName);
            $cipherer = new RunnerCipherer($lookupTable);
            $tempParentVal = $cipherer->MakeDBValue($pSet->getCategoryControl($childFieldName), $parentVal, "", $lookupTable, true);
        } else {
            $tempParentVal = make_db_value($childFieldName, $parentVal);
        }
        if ($tempParentVal === "null") {
            return $response;
        }
    }
    $LookupSQL = buildLookupSQL($pageType, $childFieldName, $strTableName, $parentVal, $childVal, $doCategoryFilter, $pSet->fastType($childFieldName) && $initialLoad);
    $lookupIndexes = GetLookupFieldsIndexes($pSet, $childFieldName);
    $rs = db_query($LookupSQL, $conn);
    if (!$pSet->fastType($childFieldName)) {
        while ($data = db_fetch_numarray($rs)) {
            if ($lookupType == LT_QUERY && $isUnique) {
                if (!isset($uniqueArray)) {
                    $uniqueArray = array();
                }
                if (in_array($data[$lookupIndexes["displayFieldIndex"]], $uniqueArray)) {
                    continue;
                }
                $uniqueArray[] = $data[$lookupIndexes["displayFieldIndex"]];
            }
            $response[] = $data[$lookupIndexes["linkFieldIndex"]];
            $response[] = $data[$lookupIndexes["displayFieldIndex"]];
        }
    } else {
        $data = db_fetch_numarray($rs);
        //	one record only
        if ($data && (strlen($childVal) || !db_fetch_numarray($rs))) {
            $response[] = $data[$lookupIndexes["linkFieldIndex"]];
            $response[] = $data[$lookupIndexes["displayFieldIndex"]];
        }
    }
    return $response;
}
예제 #3
0
 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 = "";
     }
 }