function getCtrlSearchTypeOptions($fName, $selOpt, $not)
 {
     $options = parent::getCtrlSearchTypeOptions($fName, $selOpt, $not);
     if (strlen($fName)) {
         $fType = GetEditFormat($fName, $this->tName);
     } else {
         $fType = EDIT_FORMAT_TEXT_FIELD;
     }
     if ($fType == EDIT_FORMAT_DATE || $fType == EDIT_FORMAT_TIME) {
         $options .= "<option value=\"NOT Equals\" " . ($selOpt == "Equals" && $not ? "selected" : "") . ">" . mlang_message("SEARCH_NOT_EQUALS") . "</option>";
         $options .= "<option value=\"NOT More than\" " . ($selOpt == "More than" && $not ? "selected" : "") . ">" . mlang_message("SEARCH_NOT_MORE_THAN") . "</option>";
         $options .= "<option value=\"NOT Less than\" " . ($selOpt == "Less than" && $not ? "selected" : "") . ">" . mlang_message("SEARCH_NOT_LESS_THAN") . "</option>";
         $options .= "<option value=\"NOT Between\" " . ($selOpt == "Between" && $not ? "selected" : "") . ">" . mlang_message("SEARCH_NOT_BETWEEN") . "</option>";
         $options .= "<option value=\"NOT Empty\" " . ($selOpt == "Empty" && $not ? "selected" : "") . ">" . mlang_message("SEARCH_NOT_EMPTY") . "</option>";
     } elseif ($fType == EDIT_FORMAT_LOOKUP_WIZARD) {
         if (Multiselect($fName, $this->tName)) {
             $options .= "<OPTION value=\"NOT Contains\" " . ($selOpt == "Contains" && $not ? "selected" : "") . ">" . mlang_message("SEARCH_NOT_CONTAINS") . "</option>";
         } else {
             $options .= "<OPTION value=\"NOT Equals\" " . ($selOpt == "Equals" && $not ? "selected" : "") . ">" . mlang_message("SEARCH_NOT_EQUALS") . "</option>";
         }
     } elseif ($fType == EDIT_FORMAT_TEXT_FIELD || $fType == EDIT_FORMAT_TEXT_AREA || $fType == EDIT_FORMAT_PASSWORD || $fType == EDIT_FORMAT_HIDDEN || $fType == EDIT_FORMAT_READONLY) {
         $options .= "<option value=\"NOT Contains\" " . ($selOpt == "Contains" && $not ? "selected" : "") . ">" . mlang_message("SEARCH_NOT_CONTAINS") . "</option>";
         $options .= "<option value=\"NOT Equals\" " . ($selOpt == "Equals" && $not ? "selected" : "") . ">" . mlang_message("SEARCH_NOT_EQUALS") . "</option>";
         $options .= "<option value=\"NOT Starts with\" " . ($selOpt == "Starts with" && $not ? "selected" : "") . ">" . mlang_message("SEARCH_NOT_STARTS_WITH") . "</option>";
         $options .= "<option value=\"NOT More than\" " . ($selOpt == "More than" && $not ? "selected" : "") . ">" . mlang_message("SEARCH_NOT_MORE_THAN") . "</option>";
         $options .= "<option value=\"NOT Less than\" " . ($selOpt == "Less than" && $not ? "selected" : "") . ">" . mlang_message("SEARCH_NOT_LESS_THAN") . "</option>";
         $options .= "<option value=\"NOT Between\" " . ($selOpt == "Between" && $not ? "selected" : "") . ">" . mlang_message("SEARCH_NOT_BETWEEN") . "</option>";
         $options .= "<option value=\"NOT Empty\" " . ($selOpt == "Empty" && $not ? "selected" : "") . ">" . mlang_message("SEARCH_NOT_EMPTY") . "</option>";
     } else {
         $options .= "<option value=\"NOT Equals\" " . ($selOpt == "Equals" && $not ? "selected" : "") . ">" . mlang_message("SEARCH_NOT_EQUALS") . "</option>";
     }
     return $options;
 }
    $preload = $pageObject->fillPreload($fName, $vals);
    if ($preload !== false) {
        $controls["controls"]['preloadData'] = $preload;
    }
    $pageObject->fillControlsMap($controls);
    //fill field tool tips
    $pageObject->fillFieldToolTips($fName);
    // fill special settings for timepicker
    if (GetEditFormat($fName) == 'Time') {
        $pageObject->fillTimePickSettings($fName, $data[$fName]);
    }
    if (ViewFormat($fName) == FORMAT_MAP) {
        $pageObject->googleMapCfg['isUseGoogleMap'] = true;
    }
    if ($detailKeys && in_array($fName, $detailKeys) && array_key_exists($fName, $data)) {
        if ((GetEditFormat($fName) == EDIT_FORMAT_LOOKUP_WIZARD || GetEditFormat($fName) == EDIT_FORMAT_RADIO) && GetpLookupType($fName) == LT_LOOKUPTABLE) {
            $value = DisplayLookupWizard($fName, $data[$fName], $data, "", MODE_VIEW);
        } elseif (NeedEncode($fName)) {
            $value = ProcessLargeText(GetData($data, $fName, ViewFormat($fName)), "field=" . rawurlencode(htmlspecialchars($fName)), "", MODE_VIEW);
        } else {
            $value = GetData($data, $fName, ViewFormat($fName));
        }
        $xt->assign($gfName . "_editcontrol", $value);
    }
}
//fill tab groups name and sections name to controls
$pageObject->fillCntrlTabGroups();
$pageObject->jsSettings['tableSettings'][$strTableName]["keys"] = $keys;
$pageObject->jsSettings['tableSettings'][$strTableName]["prevKeys"] = $prev;
$pageObject->jsSettings['tableSettings'][$strTableName]["nextKeys"] = $next;
if ($pageObject->lockingObj) {
 /**
  * Return JS for preload dependent ctrl for search fields
  *
  * @param string $fName - field name
  * @param string $fval - value of field
  * @return array
  */
 function getSearchPreloadArr($fName, $fval)
 {
     // if no parent in project settings
     if (GetEditFormat($fName) != EDIT_FORMAT_LOOKUP_WIZARD && !UseCategory($fName, $this->tName)) {
         return false;
     }
     // if parent exist in settings
     $parentFieldName = CategoryControl($fName, $this->tName);
     $parentVal = $this->getParentVal($fName);
     $doFilter = true;
     // if no filter f parent doesn't exist or it's value is empty
     if ($parentVal === false || $parentVal === '') {
         $doFilter = false;
     }
     $output = loadSelectContent($fName, $parentVal, $doFilter, $fval[$fName]);
     return array('vals' => $output, "fVal" => $fval[$fName]);
 }
function GetInputElementId($field, $id)
{
    $format = GetEditFormat($field);
    if ($format == EDIT_FORMAT_DATE) {
        $type = DateEditType($field);
        if ($type == EDIT_DATE_DD || $type == EDIT_DATE_DD_DP) {
            return "dayvalue_" . GoodFieldName($field) . "_" . $id;
        } else {
            return "value_" . GoodFieldName($field) . "_" . $id;
        }
    } else {
        if ($format == EDIT_FORMAT_RADIO) {
            return "radio_" . GoodFieldName($field) . "_" . $id . "_0";
        } else {
            if ($format == EDIT_FORMAT_LOOKUP_WIZARD) {
                $lookuptype = LookupControlType($field);
                if ($lookuptype == LCT_AJAX || $lookuptype == LCT_LIST) {
                    return "display_value_" . GoodFieldName($field) . "_" . $id;
                } else {
                    return "value_" . GoodFieldName($field) . "_" . $id;
                }
            } else {
                return "value_" . GoodFieldName($field) . "_" . $id;
            }
        }
    }
}
function xt_buildeditcontrol(&$params)
{
    $field = $params["field"];
    if ($params["mode"] == "edit") {
        $mode = MODE_EDIT;
    } else {
        if ($params["mode"] == "add") {
            $mode = MODE_ADD;
        } else {
            if ($params["mode"] == "inline_edit") {
                $mode = MODE_INLINE_EDIT;
            } else {
                if ($params["mode"] == "inline_add") {
                    $mode = MODE_INLINE_ADD;
                } else {
                    $mode = MODE_SEARCH;
                }
            }
        }
    }
    $fieldNum = 0;
    if (@$params["fieldNum"]) {
        $fieldNum = $params["fieldNum"];
    }
    $id = "";
    if (@$params["id"] !== "") {
        $id = $params["id"];
    }
    $format = GetEditFormat($field);
    if (@$params["format"] != "") {
        $format = $params["format"];
    }
    $append = "";
    if (($mode == MODE_EDIT || $mode == MODE_ADD || $mode == MODE_INLINE_EDIT || $mode == MODE_INLINE_ADD) && $format == EDIT_FORMAT_READONLY) {
        global $readonlyfields;
        echo $readonlyfields[$field];
    }
    if ($mode == MODE_SEARCH) {
        $format = @$params["format"];
    }
    $validate = array();
    if (count(@$params["validate"])) {
        $validate = @$params["validate"];
    }
    $additionalCtrlParams = array();
    if (count(@$params["additionalCtrlParams"])) {
        $additionalCtrlParams = @$params["additionalCtrlParams"];
    }
    $pageObj = isset($params["pageObj"]) ? $params["pageObj"] : null;
    BuildEditControl($field, @$params["value"], $format, $mode, $fieldNum, $id, $validate, $additionalCtrlParams, $pageObj);
}
function ExportToExcel()
{
    global $rs, $nPageSize, $strTableName, $conn, $eventObj;
    if ($eventObj->exists("ListFetchArray")) {
        $row = $eventObj->ListFetchArray($rs);
    } else {
        $row = db_fetch_array($rs);
    }
    //	if(!$row)
    //		return;
    $arrLabel = array();
    $arrColumnWidth = array();
    $arrTotal = array();
    $arrTotalMessage = array();
    $totals = array();
    $arrFields = array();
    $arrTmpTotal = array();
    $arrFields = GetFieldsList($strTableName);
    $arrTmpTotal = GetTableData($strTableName, ".totalsFields", array());
    foreach ($arrFields as $value) {
        $arrLabel[$value] = label($value, $strTableName);
        $arrColumnWidth[$value] = 10;
        $totals[$value] = 0;
        $totalsType = "";
        foreach ($arrTmpTotal as $tvalue) {
            if ($tvalue["fName"] == $value) {
                $totalsType = $tvalue["totalsType"];
            }
        }
        $totalsFields[] = array('fName' => $value, 'totalsType' => $totalsType, 'viewFormat' => ViewFormat($value, $strTableName));
    }
    // write data rows
    $iNumberOfRows = 0;
    $objPHPExcel = ExportExcelInit($arrLabel, $arrColumnWidth);
    while ((!$nPageSize || $iNumberOfRows < $nPageSize) && $row) {
        countTotals($totals, $totalsFields, $row);
        $values = array();
        $arrData = array();
        $arrDataType = array();
        foreach ($arrFields as $value) {
            if (GetEditFormat($value, $strTableName) == EDIT_FORMAT_LOOKUP_WIZARD || GetEditFormat($value, $strTableName) == EDIT_FORMAT_RADIO) {
                $values[$value] = "";
                if (strlen($row[$value])) {
                    $values[$value] = DisplayLookupWizard($value, $row[$value], $row, "", MODE_EXPORT);
                }
            } elseif (IsBinaryType(GetFieldType($value, $strTableName))) {
                $values[$value] = $row[$value];
            } else {
                if (ViewFormat($value, $strTableName) != FORMAT_FILE_IMAGE && ViewFormat($value, $strTableName) != FORMAT_FILE && ViewFormat($value, $strTableName) != FORMAT_HYPERLINK && ViewFormat($value, $strTableName) != FORMAT_EMAILHYPERLINK && ViewFormat($value, $strTableName) != FORMAT_CHECKBOX) {
                    $format = ViewFormat($value, $strTableName);
                } else {
                    $format = FORMAT_NONE;
                }
                $values[$value] = GetData($row, $value, $format);
            }
        }
        $eventRes = true;
        if ($eventObj->exists('BeforeOut')) {
            $eventRes = $eventObj->BeforeOut($row, $values, $arrColumnWidth, $iNumberOfRows + 1, $objPHPExcel);
        }
        if ($eventRes) {
            $iNumberOfRows++;
            $i = 0;
            foreach ($arrFields as $value) {
                if (IsBinaryType(GetFieldType($value, $strTableName))) {
                    $arrDataType[$value] = "binary";
                } elseif (ViewFormat($value, $strTableName) == FORMAT_FILE_IMAGE) {
                    $arrDataType[$value] = "file";
                } elseif (ViewFormat($value, $strTableName) == FORMAT_DATE_SHORT || ViewFormat($value, $strTableName) == FORMAT_DATE_LONG || ViewFormat($value, $strTableName) == FORMAT_DATE_TIME) {
                    $arrDataType[$value] = "date";
                } else {
                    $arrDataType[$value] = "";
                }
                $arrData[$value] = $values[$value];
            }
            ExportExcelRecord($arrData, $arrDataType, $iNumberOfRows, $objPHPExcel);
        }
        if ($eventObj->exists("ListFetchArray")) {
            $row = $eventObj->ListFetchArray($rs);
        } else {
            $row = db_fetch_array($rs);
        }
    }
    if (count($arrTmpTotal)) {
        foreach ($arrFields as $fName) {
            $value = array();
            foreach ($arrTmpTotal as $tvalue) {
                if ($tvalue["fName"] == $fName) {
                    $value = $tvalue;
                }
            }
            $total = "";
            $totalMess = "";
            if ($value["totalsType"]) {
                if ($value["totalsType"] == "COUNT") {
                    $totalMess = "Count" . ": ";
                } elseif ($value["totalsType"] == "TOTAL") {
                    $totalMess = "Total" . ": ";
                } elseif ($value["totalsType"] == "AVERAGE") {
                    $totalMess = "Average" . ": ";
                }
                $total = GetTotals($fName, $totals[$fName], $value["totalsType"], $iNumberOfRows, $value["viewFormat"]);
            }
            $arrTotal[$fName] = $total;
            $arrTotalMessage[$fName] = $totalMess;
        }
    }
    ExportExcelTotals($arrTotal, $arrTotalMessage, ++$iNumberOfRows, $objPHPExcel);
    $formatExcel = "Excel2007";
    $extExcel = ".xlsx";
    if (@$_REQUEST["type"] == "excel5") {
        $formatExcel = "Excel5";
        $extExcel = ".xls";
    }
    ExportExcelSave(GoodFieldName($strTableName) . $extExcel, $formatExcel, $objPHPExcel);
}