$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Peak Power";
$arr['viewFormat'] = ViewFormat("Peak Power", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Date Time";
$arr['viewFormat'] = ViewFormat("Date Time", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "IsSync";
$arr['viewFormat'] = ViewFormat("IsSync", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Currunt Readings";
$arr['viewFormat'] = ViewFormat("Currunt Readings", $strTableName);
$fieldsArr[] = $arr;
$mainTableOwnerID = GetTableData($strTableName, ".mainTableOwnerID", '');
$ownerIdValue = "";
$pageObject->setGoogleMapsParams($fieldsArr);
while ($data) {
    $xt->assign("show_key1", htmlspecialchars(GetData($data, "Record ID", "")));
    $keylink = "";
    $keylink .= "&key1=" . htmlspecialchars(rawurlencode(@$data["Record ID"]));
    ////////////////////////////////////////////
    //Record ID -
    $value = "";
    $value = ProcessLargeText(GetData($data, "Record ID", ""), "", "", MODE_VIEW);
    if ($mainTableOwnerID == "Record ID") {
        $ownerIdValue = $value;
    }
$fieldsArr = array();
$arr = array();
$arr['fName'] = "UserID";
$arr['viewFormat'] = ViewFormat("UserID", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Password";
$arr['viewFormat'] = ViewFormat("Password", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "User Name";
$arr['viewFormat'] = ViewFormat("User Name", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Role";
$arr['viewFormat'] = ViewFormat("Role", $strTableName);
$fieldsArr[] = $arr;
$pageObject->setGoogleMapsParams($fieldsArr);
$colsonpage = 1;
if ($colsonpage > $recordsonpage) {
    $colsonpage = $recordsonpage;
}
if ($colsonpage < 1) {
    $colsonpage = 1;
}
//	fill $rowinfo array
$pages = array();
$rowinfo = array();
$rowinfo["data"] = array();
if ($eventObj->exists("ListFetchArray")) {
    $data = $eventObj->ListFetchArray($rs);
    //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) {
    $pageObject->jsSettings['tableSettings'][$strTableName]["sKeys"] = $skeys;
    $pageObject->jsSettings['tableSettings'][$strTableName]["enableCtrls"] = $enableCtrlsForEditing;
    $pageObject->jsSettings['tableSettings'][$strTableName]["confirmTime"] = $pageObject->lockingObj->ConfirmTime;
}
/////////////////////////////////////////////////////////////
}
$data = db_fetch_array($rs);
if ($eventObj->exists("ProcessValuesView")) {
    $eventObj->ProcessValuesView($data);
}
$out = "";
$first = true;
$templatefile = "";
$fieldsArr = array();
$arr = array();
$arr['fName'] = "Units";
$arr['viewFormat'] = ViewFormat("Units", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "PerUnit Price";
$arr['viewFormat'] = ViewFormat("PerUnit Price", $strTableName);
$fieldsArr[] = $arr;
$mainTableOwnerID = GetTableData($strTableName, ".mainTableOwnerID", '');
$ownerIdValue = "";
$pageObject->setGoogleMapsParams($fieldsArr);
while ($data) {
    $xt->assign("show_key1", htmlspecialchars(GetData($data, "Units", "")));
    $keylink = "";
    $keylink .= "&key1=" . htmlspecialchars(rawurlencode(@$data["Units"]));
    ////////////////////////////////////////////
    //Units -
    $value = "";
    $value = ProcessLargeText(GetData($data, "Units", ""), "", "", MODE_VIEW);
    if ($mainTableOwnerID == "Units") {
        $ownerIdValue = $value;
    }
        $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, @$defvalues[$fName]);
    }
    if (($detailKeys && in_array($fName, $detailKeys) || $fName == postvalue("category")) && array_key_exists($fName, $defvalues)) {
        if ((GetEditFormat($fName) == EDIT_FORMAT_LOOKUP_WIZARD || GetEditFormat($fName) == EDIT_FORMAT_RADIO) && GetpLookupType($fName) == LT_LOOKUPTABLE) {
            $value = DisplayLookupWizard($fName, $defvalues[$fName], $defvalues, "", MODE_VIEW);
        } elseif (NeedEncode($fName)) {
            $value = ProcessLargeText(GetData($defvalues, $fName, ViewFormat($fName)), "field=" . rawurlencode(htmlspecialchars($fName)), "", MODE_VIEW);
        } else {
            $value = GetData($defvalues, $fName, ViewFormat($fName));
        }
        $xt->assign($gfName . "_editcontrol", $value);
    }
}
//fill tab groups name and sections name to controls
$pageObject->fillCntrlTabGroups();
/////////////////////////////////////////////////////////////
if ($pageObject->isShowDetailTables && ($inlineadd == ADD_SIMPLE || $inlineadd == ADD_POPUP) && !isMobile()) {
    if (count($dpParams['ids'])) {
        $xt->assign("detail_tables", true);
        include 'classes/listpage.php';
        include 'classes/listpage_embed.php';
        include 'classes/listpage_dpinline.php';
        include "classes/searchclause.php";
    }
    } else {
        $rs = db_query($strSQL, $conn);
    }
    $recordsonpage = $numrows;
    $maxpages = ceil($recordsonpage / 30);
    $xt->assign("page_number", true);
    $xt->assign("maxpages", $maxpages);
}
$fieldsArr = array();
$arr = array();
$arr['fName'] = "Code";
$arr['viewFormat'] = ViewFormat("Code", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Tamper Type";
$arr['viewFormat'] = ViewFormat("Tamper Type", $strTableName);
$fieldsArr[] = $arr;
$pageObject->setGoogleMapsParams($fieldsArr);
$colsonpage = 1;
if ($colsonpage > $recordsonpage) {
    $colsonpage = $recordsonpage;
}
if ($colsonpage < 1) {
    $colsonpage = 1;
}
//	fill $rowinfo array
$pages = array();
$rowinfo = array();
$rowinfo["data"] = array();
if ($eventObj->exists("ListFetchArray")) {
    $data = $eventObj->ListFetchArray($rs);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Currunt Readings";
$arr['viewFormat'] = ViewFormat("Currunt Readings", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Unit Consumed";
$arr['viewFormat'] = ViewFormat("Unit Consumed", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Bill Amount";
$arr['viewFormat'] = ViewFormat("Bill Amount", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Due Date";
$arr['viewFormat'] = ViewFormat("Due Date", $strTableName);
$fieldsArr[] = $arr;
$pageObject->setGoogleMapsParams($fieldsArr);
$colsonpage = 1;
if ($colsonpage > $recordsonpage) {
    $colsonpage = $recordsonpage;
}
if ($colsonpage < 1) {
    $colsonpage = 1;
}
//	fill $rowinfo array
$pages = array();
$rowinfo = array();
$rowinfo["data"] = array();
if ($eventObj->exists("ListFetchArray")) {
    $data = $eventObj->ListFetchArray($rs);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Address";
$arr['viewFormat'] = ViewFormat("Address", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Contact";
$arr['viewFormat'] = ViewFormat("Contact", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Location";
$arr['viewFormat'] = ViewFormat("Location", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Customer Type";
$arr['viewFormat'] = ViewFormat("Customer Type", $strTableName);
$fieldsArr[] = $arr;
$pageObject->setGoogleMapsParams($fieldsArr);
$colsonpage = 1;
if ($colsonpage > $recordsonpage) {
    $colsonpage = $recordsonpage;
}
if ($colsonpage < 1) {
    $colsonpage = 1;
}
//	fill $rowinfo array
$pages = array();
$rowinfo = array();
$rowinfo["data"] = array();
if ($eventObj->exists("ListFetchArray")) {
    $data = $eventObj->ListFetchArray($rs);
    } else {
        $rs = db_query($strSQL, $conn);
    }
    $recordsonpage = $numrows;
    $maxpages = ceil($recordsonpage / 30);
    $xt->assign("page_number", true);
    $xt->assign("maxpages", $maxpages);
}
$fieldsArr = array();
$arr = array();
$arr['fName'] = "Code";
$arr['viewFormat'] = ViewFormat("Code", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Action";
$arr['viewFormat'] = ViewFormat("Action", $strTableName);
$fieldsArr[] = $arr;
$pageObject->setGoogleMapsParams($fieldsArr);
$colsonpage = 1;
if ($colsonpage > $recordsonpage) {
    $colsonpage = $recordsonpage;
}
if ($colsonpage < 1) {
    $colsonpage = 1;
}
//	fill $rowinfo array
$pages = array();
$rowinfo = array();
$rowinfo["data"] = array();
if ($eventObj->exists("ListFetchArray")) {
    $data = $eventObj->ListFetchArray($rs);
    $maxpages = ceil($recordsonpage / 30);
    $xt->assign("page_number", true);
    $xt->assign("maxpages", $maxpages);
}
$fieldsArr = array();
$arr = array();
$arr['fName'] = "ID";
$arr['viewFormat'] = ViewFormat("ID", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Customer ID";
$arr['viewFormat'] = ViewFormat("Customer ID", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Module ID";
$arr['viewFormat'] = ViewFormat("Module ID", $strTableName);
$fieldsArr[] = $arr;
$pageObject->setGoogleMapsParams($fieldsArr);
$colsonpage = 1;
if ($colsonpage > $recordsonpage) {
    $colsonpage = $recordsonpage;
}
if ($colsonpage < 1) {
    $colsonpage = 1;
}
//	fill $rowinfo array
$pages = array();
$rowinfo = array();
$rowinfo["data"] = array();
if ($eventObj->exists("ListFetchArray")) {
    $data = $eventObj->ListFetchArray($rs);
    } else {
        $rs = db_query($strSQL, $conn);
    }
    $recordsonpage = $numrows;
    $maxpages = ceil($recordsonpage / 30);
    $xt->assign("page_number", true);
    $xt->assign("maxpages", $maxpages);
}
$fieldsArr = array();
$arr = array();
$arr['fName'] = "Code";
$arr['viewFormat'] = ViewFormat("Code", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Status";
$arr['viewFormat'] = ViewFormat("Status", $strTableName);
$fieldsArr[] = $arr;
$pageObject->setGoogleMapsParams($fieldsArr);
$colsonpage = 1;
if ($colsonpage > $recordsonpage) {
    $colsonpage = $recordsonpage;
}
if ($colsonpage < 1) {
    $colsonpage = 1;
}
//	fill $rowinfo array
$pages = array();
$rowinfo = array();
$rowinfo["data"] = array();
if ($eventObj->exists("ListFetchArray")) {
    $data = $eventObj->ListFetchArray($rs);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Module Status";
$arr['viewFormat'] = ViewFormat("Module Status", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Module Condition";
$arr['viewFormat'] = ViewFormat("Module Condition", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Serial Num";
$arr['viewFormat'] = ViewFormat("Serial Num", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Entry Date";
$arr['viewFormat'] = ViewFormat("Entry Date", $strTableName);
$fieldsArr[] = $arr;
$pageObject->setGoogleMapsParams($fieldsArr);
$colsonpage = 1;
if ($colsonpage > $recordsonpage) {
    $colsonpage = $recordsonpage;
}
if ($colsonpage < 1) {
    $colsonpage = 1;
}
//	fill $rowinfo array
$pages = array();
$rowinfo = array();
$rowinfo["data"] = array();
if ($eventObj->exists("ListFetchArray")) {
    $data = $eventObj->ListFetchArray($rs);
function BuildEditControl($field, $value, $format, $edit, $fieldNum = 0, $id = "", $validate, $additionalCtrlParams, &$pageObj)
{
    global $rs, $data, $strTableName, $filenamelist, $keys, $locale_info, $jscode;
    $inputStyle = 'style="';
    $inputStyle .= $additionalCtrlParams['style'] ? $additionalCtrlParams['style'] : '';
    //$inputStyle .= ($additionalCtrlParams['hidden'] ? 'display: none;' : '');
    $inputStyle .= '"';
    $cfieldname = GoodFieldName($field) . "_" . $id;
    $cfield = "value_" . GoodFieldName($field) . "_" . $id;
    $ctype = "type_" . GoodFieldName($field) . "_" . $id;
    $is508 = isEnableSection508();
    $strLabel = Label($field);
    if ($fieldNum) {
        $cfield = "value" . $fieldNum . "_" . GoodFieldName($field) . "_" . $id;
        $ctype = "type" . $fieldNum . "_" . GoodFieldName($field) . "_" . $id;
    }
    $type = GetFieldType($field);
    $arr = "";
    $iquery = "field=" . rawurlencode($field);
    $keylink = "";
    $arrKeys = GetTableKeys($strTableName);
    for ($j = 0; $j < count($arrKeys); $j++) {
        $keylink .= "&key" . ($j + 1) . "=" . rawurlencode($data[$arrKeys[$j]]);
    }
    $iquery .= $keylink;
    $isHidden = isset($additionalCtrlParams['hidden']) && $additionalCtrlParams['hidden'];
    echo '<span id="edit' . $id . '_' . GoodFieldName($field) . '_' . $fieldNum . '" class="runner-nowrap"' . ($isHidden ? ' style="display:none"' : '') . '">';
    if ($format == EDIT_FORMAT_FILE && $edit == MODE_SEARCH) {
        $format = "";
    }
    if ($format == EDIT_FORMAT_TEXT_FIELD) {
        if (IsDateFieldType($type)) {
            echo '<input id="' . $ctype . '" type="hidden" name="' . $ctype . '" value="date' . EDIT_DATE_SIMPLE . '">' . GetDateEdit($field, $value, 0, $fieldNum, $edit, $id, $pageObj);
        } else {
            if ($edit == MODE_SEARCH) {
                echo '<input id="' . $cfield . '" ' . $inputStyle . ' type="text" autocomplete="off" ' . (($edit == MODE_INLINE_EDIT || $edit == MODE_INLINE_ADD) && $is508 == true ? 'alt="' . $strLabel . '" ' : '') . 'name="' . $cfield . '" ' . GetEditParams($field) . ' value="' . htmlspecialchars($value) . '">';
            } else {
                echo '<input id="' . $cfield . '" ' . $inputStyle . ' type="text" ' . (($edit == MODE_INLINE_EDIT || $edit == MODE_INLINE_ADD) && $is508 == true ? 'alt="' . $strLabel . '" ' : '') . 'name="' . $cfield . '" ' . GetEditParams($field) . ' value="' . htmlspecialchars($value) . '">';
            }
        }
    } else {
        if ($format == EDIT_FORMAT_TIME) {
            echo '<input id="' . $ctype . '" ' . $inputStyle . ' type="hidden" name="' . $ctype . '" value="time">';
            $arr_number = parsenumbers((string) $value);
            if (count($arr_number) == 6) {
                $value = mysprintf("%d:%02d:%02d", array($arr_number[3], $arr_number[4], $arr_number[5]));
            }
            $timeAttrs = GetFieldData($strTableName, $field, "FormatTimeAttrs", array());
            if (count($timeAttrs)) {
                if ($timeAttrs["useTimePicker"]) {
                    $convention = $timeAttrs["hours"];
                    $loc = getLacaleAmPmForTimePicker($convention, true);
                    $tpVal = getValForTimePicker($type, $value, $loc['locale']);
                    echo '<input type="text" ' . $inputStyle . ' name="' . $cfield . '" ' . (($edit == MODE_INLINE_EDIT || $edit == MODE_INLINE_ADD) && $is508 == true ? 'alt="' . $strLabel . '" ' : '') . 'id="' . $cfield . '" ' . GetEditParams($field) . ' value="' . htmlspecialchars($tpVal['val']) . '">';
                    echo '&nbsp;';
                    echo '<img class="runner-imgclock" src="images/clock.gif" alt="Time" border="0" style="margin:4px 0 0 6px; visibility: hidden;" id="trigger-test-' . $cfield . '" />';
                } else {
                    echo '<input id="' . $cfield . '" ' . $inputStyle . ' type="text" ' . (($edit == MODE_INLINE_EDIT || $edit == MODE_INLINE_ADD) && $is508 == true ? 'alt="' . $strLabel . '" ' : '') . 'name="' . $cfield . '" ' . GetEditParams($field) . ' value="' . htmlspecialchars($value) . '">';
                }
            }
        } else {
            if ($format == EDIT_FORMAT_TEXT_AREA) {
                $nWidth = GetNCols($field);
                $nHeight = GetNRows($field);
                if (UseRTE($field)) {
                    $value = RTESafe($value);
                } else {
                    echo '<textarea id="' . $cfield . '" ' . (($edit == MODE_INLINE_EDIT || $edit == MODE_INLINE_ADD) && $is508 == true ? 'alt="' . $strLabel . '" ' : '') . 'name="' . $cfield . '" style="';
                    if (!isMobile()) {
                        echo "width: " . $nWidth . "px;";
                    }
                    echo 'height: ' . $nHeight . 'px;">' . htmlspecialchars($value) . '</textarea>';
                }
            } else {
                if ($format == EDIT_FORMAT_PASSWORD) {
                    echo '<input ' . $inputStyle . ' id="' . $cfield . '" type="Password" ' . (($edit == MODE_INLINE_EDIT || $edit == MODE_INLINE_ADD) && $is508 == true ? 'alt="' . $strLabel . '" ' : '') . 'name="' . $cfield . '" ' . GetEditParams($field) . ' value="' . htmlspecialchars($value) . '">';
                } else {
                    if ($format == EDIT_FORMAT_DATE) {
                        echo '<input id="' . $ctype . '" type="hidden" name="' . $ctype . '" value="date' . DateEditType($field) . '">' . GetDateEdit($field, $value, DateEditType($field), $fieldNum, $edit, $id, $pageObj);
                    } else {
                        if ($format == EDIT_FORMAT_RADIO) {
                            BuildRadioControl($field, $value, $fieldNum, $id, $edit);
                        } else {
                            if ($format == EDIT_FORMAT_CHECKBOX) {
                                if ($edit == MODE_ADD || $edit == MODE_INLINE_ADD || $edit == MODE_EDIT || $edit == MODE_INLINE_EDIT) {
                                    $checked = "";
                                    if ($value && $value != 0) {
                                        $checked = " checked";
                                    }
                                    echo '<input id="' . $ctype . '" type="hidden" name="' . $ctype . '" value="checkbox">';
                                    echo '<input id="' . $cfield . '" type="Checkbox" ' . (($edit == MODE_INLINE_EDIT || $edit == MODE_INLINE_ADD) && $is508 == true ? 'alt="' . $strLabel . '" ' : '') . 'name="' . $cfield . '" ' . $checked . '>';
                                } else {
                                    echo '<input id="' . $ctype . '" type="hidden" name="' . $ctype . '" value="checkbox">';
                                    echo '<select id="' . $cfield . '" ' . (($edit == MODE_INLINE_EDIT || $edit == MODE_INLINE_ADD) && $is508 == true ? 'alt="' . $strLabel . '" ' : '') . 'name="' . $cfield . '">';
                                    $val = array("", "on", "off");
                                    $show = array("", "True", "False");
                                    foreach ($val as $i => $v) {
                                        $sel = "";
                                        if ($value === $v) {
                                            $sel = " selected";
                                        }
                                        echo '<option value="' . $v . '"' . $sel . '>' . $show[$i] . '</option>';
                                    }
                                    echo "</select>";
                                }
                            } else {
                                if ($format == EDIT_FORMAT_DATABASE_IMAGE || $format == EDIT_FORMAT_DATABASE_FILE) {
                                    $disp = "";
                                    $strfilename = "";
                                    //$onchangefile="";
                                    if ($edit == MODE_EDIT || $edit == MODE_INLINE_EDIT) {
                                        $value = db_stripslashesbinary($value);
                                        $itype = SupposeImageType($value);
                                        $thumbnailed = false;
                                        $thumbfield = "";
                                        if ($itype) {
                                            if ($thumbnailed) {
                                                $disp = "<a ";
                                                if (IsUseiBox($field, $strTableName)) {
                                                    $disp .= " rel='ibox'";
                                                } else {
                                                    $disp .= " target=_blank";
                                                }
                                                $disp .= " href=\"imager.php?table=" . GetTableURL($strTableName) . "&" . $iquery . "&rndVal=" . rand(0, 32768) . "\">";
                                                $disp .= "<img id=\"image_" . GoodFieldName($field) . "_" . $id . "\" name=\"" . $cfield . "\" border=0";
                                                if (isEnableSection508()) {
                                                    $disp .= " alt=\"Image from DB\"";
                                                }
                                                $disp .= " src=\"imager.php?table=" . GetTableURL($strTableName) . "&field=" . rawurlencode($thumbfield) . "&alt=" . rawurlencode($field) . $keylink . "&rndVal=" . rand(0, 32768) . "\">";
                                                $disp .= "</a>";
                                            } else {
                                                $disp = '<img id="image_' . GoodFieldName($field) . '_' . $id . '" name="' . $cfield . '"';
                                                if (isEnableSection508()) {
                                                    $disp .= ' alt="Image from DB"';
                                                }
                                                $disp .= ' border=0 src="imager.php?table=' . GetTableURL($strTableName) . '&' . $iquery . "&rndVal=" . rand(0, 32768) . '">';
                                            }
                                        } else {
                                            if (strlen($value)) {
                                                $disp = '<img id="image_' . GoodFieldName($field) . '_' . $id . '" name="' . $cfield . '" border=0 ';
                                                if (isEnableSection508()) {
                                                    $disp .= ' alt="file"';
                                                }
                                                $disp .= ' src="images/file.gif">';
                                            } else {
                                                $disp = '<img id="image_' . GoodFieldName($field) . '_' . $id . '" name="' . $cfield . '" border="0"';
                                                if (isEnableSection508()) {
                                                    $disp .= ' alt=" "';
                                                }
                                                $disp .= ' src="images/no_image.gif">';
                                            }
                                        }
                                        //	filename
                                        if ($format == EDIT_FORMAT_DATABASE_FILE && !$itype && strlen($value)) {
                                            if (!($filename = @$data[GetFilenameField($field)])) {
                                                $filename = "file.bin";
                                            }
                                            $disp = '<a href="getfile.php?table=' . GetTableURL($strTableName) . '&filename=' . htmlspecialchars($filename) . '&' . $iquery . '".>' . $disp . '</a>';
                                        }
                                        //	filename edit
                                        if ($format == EDIT_FORMAT_DATABASE_FILE && GetFilenameField($field)) {
                                            if (!($filename = @$data[GetFilenameField($field)])) {
                                                $filename = "";
                                            }
                                            if ($edit == MODE_INLINE_EDIT) {
                                                $strfilename = '<br><label for="filename_' . $cfieldname . '">' . mlang_message("FILENAME") . '</label>&nbsp;&nbsp;<input type="text" ' . $inputStyle . ' id="filename_' . $cfieldname . '" name="filename_' . $cfieldname . '" size="20" maxlength="50" value="' . htmlspecialchars($filename) . '">';
                                            } else {
                                                $strfilename = '<br><label for="filename_' . $cfieldname . '">' . mlang_message("FILENAME") . '</label>&nbsp;&nbsp;<input type="text" ' . $inputStyle . ' id="filename_' . $cfieldname . '" name="filename_' . $cfieldname . '" size="20" maxlength="50" value="' . htmlspecialchars($filename) . '">';
                                            }
                                        }
                                        $strtype = '<br><input id="' . $ctype . '_keep" type="Radio" name="' . $ctype . '" value="file0" checked>' . mlang_message("KEEP");
                                        if ((strlen($value) || $edit == MODE_INLINE_EDIT) && !IsRequired($field)) {
                                            $strtype .= '<input id="' . $ctype . '_delete" type="Radio" name="' . $ctype . '" value="file1">' . mlang_message("DELETE");
                                        }
                                        $strtype .= '<input id="' . $ctype . '_update" type="Radio" name="' . $ctype . '" value="file2">' . mlang_message("UPDATE");
                                    } else {
                                        //	if Add mode
                                        $strtype = '<input id="' . $ctype . '" type="hidden" name="' . $ctype . '" value="file2">';
                                        if ($format == EDIT_FORMAT_DATABASE_FILE && GetFilenameField($field)) {
                                            $strfilename = '<br><label for="filename_' . $cfieldname . '">' . mlang_message("FILENAME") . '</label>&nbsp;&nbsp;<input type="text" ' . $inputStyle . ' id="filename_' . $cfieldname . '" name="filename_' . $cfieldname . '" size="20" maxlength="50">';
                                        }
                                    }
                                    if ($edit == MODE_INLINE_EDIT && $format == EDIT_FORMAT_DATABASE_FILE) {
                                        $disp = "";
                                    }
                                    echo $disp . $strtype;
                                    if ($edit == MODE_EDIT || $edit == MODE_INLINE_EDIT) {
                                        echo '<br>';
                                    }
                                    echo '<input type="File" ' . $inputStyle . ' id="' . $cfield . '" ' . (($edit == MODE_INLINE_EDIT || $edit == MODE_INLINE_ADD) && $is508 == true ? 'alt="' . $strLabel . '" ' : '') . ' name="' . $cfield . '" >' . $strfilename;
                                    echo '<input type="Hidden" id="notempty_' . $cfieldname . '" value="' . (strlen($value) ? 1 : 0) . '">';
                                } else {
                                    if ($format == EDIT_FORMAT_LOOKUP_WIZARD) {
                                        BuildSelectControl($field, $value, $fieldNum, $edit, $id, $additionalCtrlParams, $pageObj);
                                    } else {
                                        if ($format == EDIT_FORMAT_HIDDEN) {
                                            echo '<input id="' . $cfield . '" type="Hidden" name="' . $cfield . '" value="' . htmlspecialchars($value) . '">';
                                        } else {
                                            if ($format == EDIT_FORMAT_READONLY) {
                                                echo '<input id="' . $cfield . '" type="Hidden" name="' . $cfield . '" value="' . htmlspecialchars($value) . '">';
                                            } else {
                                                if ($format == EDIT_FORMAT_FILE) {
                                                    $disp = "";
                                                    $strfilename = "";
                                                    $function = "";
                                                    if ($edit == MODE_EDIT || $edit == MODE_INLINE_EDIT) {
                                                        //	show current file
                                                        if (ViewFormat($field) == FORMAT_FILE || ViewFormat($field) == FORMAT_FILE_IMAGE) {
                                                            $disp = GetData($data, $field, ViewFormat($field)) . "<br>";
                                                        }
                                                        $filename = $value;
                                                        //	filename edit
                                                        $filename_size = 30;
                                                        if (UseTimestamp($field)) {
                                                            $filename_size = 50;
                                                        }
                                                        $strfilename = '<input type=hidden name="filenameHidden_' . $cfieldname . '" value="' . htmlspecialchars($filename) . '"><br>' . mlang_message("FILENAME") . '&nbsp;&nbsp;<input type="text" style="background-color:gainsboro" disabled id="filename_' . $cfieldname . '" name="filename_' . $cfieldname . '" size="' . $filename_size . '" maxlength="100" value="' . htmlspecialchars($filename) . '">';
                                                        if ($edit == MODE_INLINE_EDIT) {
                                                            $strtype = '<br><input id="' . $ctype . '_keep" type="Radio" name="' . $ctype . '" value="upload0" checked class="runner-uploadtype">' . mlang_message("KEEP");
                                                        } else {
                                                            $strtype = '<br><input id="' . $ctype . '_keep" type="Radio" name="' . $ctype . '" value="upload0" checked class="runner-uploadtype">' . mlang_message("KEEP");
                                                        }
                                                        if ((strlen($value) || $edit == MODE_INLINE_EDIT) && !IsRequired($field)) {
                                                            $strtype .= '<input id="' . $ctype . '_delete" type="Radio" name="' . $ctype . '" value="upload1" class="runner-uploadtype">' . mlang_message("DELETE");
                                                        }
                                                        $strtype .= '<input id="' . $ctype . '_update" type="Radio" name="' . $ctype . '" value="upload2" class="runner-uploadtype">' . mlang_message("UPDATE");
                                                    } else {
                                                        //	if Adding record
                                                        $filename_size = 30;
                                                        if (UseTimestamp($field)) {
                                                            $filename_size = 50;
                                                        }
                                                        $strtype = '<input id="' . $ctype . '" type="hidden" name="' . $ctype . '" value="upload2">';
                                                        $strfilename = '<br>' . mlang_message("FILENAME") . '&nbsp;&nbsp;<input type="text" id="filename_' . $cfieldname . '" name="filename_' . $cfieldname . '" size="' . $filename_size . '" maxlength="100">';
                                                    }
                                                    echo $disp . $strtype . $function;
                                                    if ($edit == MODE_EDIT || $edit == MODE_INLINE_EDIT) {
                                                        echo '<br>';
                                                    }
                                                    echo '<input type="File" id="' . $cfield . '" ' . (($edit == MODE_INLINE_EDIT || $edit == MODE_INLINE_ADD) && $is508 == true ? 'alt="' . $strLabel . '" ' : '') . ' name="' . $cfield . '" >' . $strfilename;
                                                    echo '<input type="Hidden" id="notempty_' . $cfieldname . '" value="' . (strlen($value) ? 1 : 0) . '">';
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if (count($validate['basicValidate']) && array_search('IsRequired', $validate['basicValidate']) !== false) {
        echo '&nbsp;<font color="red">*</font></span>';
    } else {
        echo '</span>';
    }
}
}
$data = db_fetch_array($rs);
if ($eventObj->exists("ProcessValuesView")) {
    $eventObj->ProcessValuesView($data);
}
$out = "";
$first = true;
$templatefile = "";
$fieldsArr = array();
$arr = array();
$arr['fName'] = "Code";
$arr['viewFormat'] = ViewFormat("Code", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Condition";
$arr['viewFormat'] = ViewFormat("Condition", $strTableName);
$fieldsArr[] = $arr;
$mainTableOwnerID = GetTableData($strTableName, ".mainTableOwnerID", '');
$ownerIdValue = "";
$pageObject->setGoogleMapsParams($fieldsArr);
while ($data) {
    $xt->assign("show_key1", htmlspecialchars(GetData($data, "Code", "")));
    $keylink = "";
    $keylink .= "&key1=" . htmlspecialchars(rawurlencode(@$data["Code"]));
    ////////////////////////////////////////////
    //Code -
    $value = "";
    $value = ProcessLargeText(GetData($data, "Code", ""), "", "", MODE_VIEW);
    if ($mainTableOwnerID == "Code") {
        $ownerIdValue = $value;
    }
 /**
  * Proccess record values
  *
  * @param array $record
  * @param array $data
  * @param string $keylink
  */
 function proccessRecordValue(&$data, &$keylink, $listFieldInfo)
 {
     $value = "";
     if ($listFieldInfo['viewFormat'] == FORMAT_DATABASE_IMAGE) {
         if (ShowThumbnail($listFieldInfo['fName'], $this->tName)) {
             $thumbPref = GetThumbnailPrefix($listFieldInfo['fName'], $this->tName);
             $value .= "<a";
             if (IsUseiBox($listFieldInfo['fName'], $this->tName)) {
                 $value .= " rel='ibox'";
             } else {
                 $value .= " target=_blank";
             }
             $value .= " href='imager.php?table=" . $this->shortTableName . "&field=" . rawurlencode($listFieldInfo['fName']) . $keylink . "'>";
             $value .= "<img border=0";
             if ($this->is508) {
                 $value .= " alt=\"Image from DB\"";
             }
             $value .= " src='imager.php?table=" . $this->shortTableName . "&field=" . rawurlencode($thumbPref) . "&alt=" . rawurlencode($listFieldInfo['fName']) . $keylink . "'>";
             $value .= "</a>";
         } else {
             $value = "<img";
             if ($this->is508) {
                 $value .= " alt=\"Image from DB\"";
             }
             $imgWidth = GetImageWidth($listFieldInfo['fName'], $this->tName);
             $value .= $imgWidth ? " width=" . $imgWidth : "";
             $imgHeight = GetImageHeight($listFieldInfo['fName'], $this->tName);
             $value .= $imgHeight ? " height=" . $imgHeight : "";
             $value .= " border=0";
             $value .= " src='imager.php?table=" . $this->shortTableName . "&field=" . rawurlencode($listFieldInfo['fName']) . $keylink . "'>";
         }
     } else {
         if ($listFieldInfo['viewFormat'] == FORMAT_FILE_IMAGE) {
             if (CheckImageExtension($data[$listFieldInfo['fName']])) {
                 if (ShowThumbnail($listFieldInfo['fName'], $this->tName)) {
                     // show thumbnail
                     $thumbPref = GetThumbnailPrefix($listFieldInfo['fName'], $this->tName);
                     $thumbname = $thumbPref . $data[$listFieldInfo['fName']];
                     if (substr(GetLinkPrefix($listFieldInfo['fName'], $this->tName), 0, 7) != "http://" && !myfile_exists(GetUploadFolder($listFieldInfo['fName']) . $thumbname)) {
                         $thumbname = $data[$listFieldInfo['fName']];
                     }
                     $value = "<a";
                     if (IsUseiBox($listFieldInfo['fName'], $this->tName)) {
                         $value .= " rel='ibox'";
                     } else {
                         $value .= " target=_blank";
                     }
                     $value .= " href=\"" . htmlspecialchars(AddLinkPrefix($listFieldInfo['fName'], $data[$listFieldInfo['fName']])) . "\">";
                     $value .= "<img";
                     if ($thumbname == $data[$listFieldInfo['fName']]) {
                         $imgWidth = GetImageWidth($listFieldInfo['fName'], $this->tName);
                         $value .= $imgWidth ? " width=" . $imgWidth : "";
                         $imgHeight = GetImageHeight($listFieldInfo['fName'], $this->tName);
                         $value .= $imgHeight ? " height=" . $imgHeight : "";
                     }
                     $value .= " border=0";
                     if ($this->is508) {
                         $value .= " alt=\"" . htmlspecialchars($data[$listFieldInfo['fName']]) . "\"";
                     }
                     $value .= " src=\"" . htmlspecialchars(AddLinkPrefix($listFieldInfo['fName'], $thumbname)) . "\"></a>";
                 } else {
                     $value = "<img";
                     $imgWidth = GetImageWidth($listFieldInfo['fName'], $this->tName);
                     $value .= $imgWidth ? " width=" . $imgWidth : "";
                     $imgHeight = GetImageHeight($listFieldInfo['fName'], $this->tName);
                     $value .= $imgHeight ? " height=" . $imgHeight : "";
                     $value .= " border=0";
                     if ($this->is508) {
                         $value .= " alt=\"" . htmlspecialchars($data[$listFieldInfo['fName']]) . "\"";
                     }
                     $value .= " src=\"" . htmlspecialchars(AddLinkPrefix($listFieldInfo['fName'], $data[$listFieldInfo['fName']])) . "\">";
                 }
             }
         } else {
             if ($listFieldInfo['viewFormat'] == FORMAT_DATABASE_FILE) {
                 $fileNameF = GetFilenameField($listFieldInfo['fName'], $this->tName);
                 if ($fileNameF) {
                     $fileName = $data[$fileNameF];
                     if (!$fileName) {
                         $fileName = "file.bin";
                     }
                 } else {
                     $fileName = "file.bin";
                 }
                 if (strlen($data[$listFieldInfo['fName']])) {
                     $value = "<a href='getfile.php?table=" . $this->shortTableName . "&filename=" . rawurlencode($fileName) . "&field=" . rawurlencode($listFieldInfo['fName']) . $keylink . "'>";
                     $value .= htmlspecialchars($fileName);
                     $value .= "</a>";
                 }
             } else {
                 if ($listFieldInfo['viewFormat'] == FORMAT_AUDIO) {
                     $fileName = GetData($data, $listFieldInfo['fName'], FORMAT_NONE);
                     $fieldIsUrl = GetFieldData($this->tName, $listFieldInfo['fName'], "fieldIsVideoUrl", false);
                     if (strlen($fileName)) {
                         $absFileName = "";
                         if (!$fieldIsUrl && GetFieldData($this->tName, $listFieldInfo['fName'], "Absolute", false)) {
                             $absFileName = GetUploadFolder($listFieldInfo['fName']) . $fileName;
                         } elseif (!$fieldIsUrl) {
                             $absFileName = getabspath(GetUploadFolder($listFieldInfo['fName']) . $fileName);
                         }
                         // if file
                         if ($fieldIsUrl || file_exists($absFileName)) {
                             $titleField = GetFieldData($this->tName, $listFieldInfo['fName'], 'audioTitleField', "");
                             $title = "";
                             if ($titleField) {
                                 $title = htmlspecialchars(GetData($data, $titleField, ViewFormat($titleField, $titleField)));
                             }
                             if ($fieldIsUrl) {
                                 $href = $fileName;
                             } else {
                                 $href = 'download.php?table=' . $this->shortTableName . '&field=' . rawurlencode($listFieldInfo['fName']) . $keylink;
                             }
                             $value = '<a class="htrack" type="audio/mpeg" title="' . $title . '" href="' . $href . '">' . $title . '</a>';
                         }
                     }
                 } else {
                     if ($listFieldInfo['viewFormat'] == FORMAT_DATABASE_AUDIO) {
                         $titleField = GetFieldData($this->tName, $listFieldInfo['fName'], 'audioTitleField', "");
                         $title = "";
                         if ($titleField) {
                             $title = htmlspecialchars(GetData($data, $titleField, ViewFormat($titleField, $titleField)));
                         }
                         if (@$data[$listFieldInfo['fName']] != NULL) {
                             $value = '<a class="htrack" type="audio/mpeg" title="' . $title . '" href="getfile.php?table=' . $this->shortTableName . '&field=' . rawurlencode($listFieldInfo['fName']) . $keylink . '">' . $title . '</a>';
                         } else {
                             $value = $title;
                         }
                     } else {
                         if ($listFieldInfo['viewFormat'] == FORMAT_VIDEO) {
                             $value = "";
                             $fieldIsUrl = GetFieldData($this->tName, $listFieldInfo['fName'], "fieldIsVideoUrl", false);
                             $fileName = GetData($data, $listFieldInfo['fName'], FORMAT_NONE);
                             if (strlen($fileName)) {
                                 $absFileName = "";
                                 if (!$fieldIsUrl && GetFieldData($this->tName, $listFieldInfo['fName'], "Absolute", false)) {
                                     $absFileName = GetUploadFolder($listFieldInfo['fName']) . $fileName;
                                 } elseif (!$fieldIsUrl) {
                                     $absFileName = getabspath(GetUploadFolder($listFieldInfo['fName']) . $fileName);
                                 }
                                 // if file
                                 if ($fieldIsUrl || file_exists($absFileName)) {
                                     $videoId = 'video_' . GoodFieldName(htmlspecialchars($listFieldInfo['fName'])) . '_' . $this->recId;
                                     if ($fieldIsUrl) {
                                         $href = $fileName;
                                     } else {
                                         $href = 'download.php?table=' . $this->shortTableName . '&field=' . rawurlencode($listFieldInfo['fName']) . $keylink;
                                     }
                                     $value = '<a href="' . $href . '" style="display:block;width:' . GetFieldData($this->tName, $listFieldInfo['fName'], 'videoWidth', "") . 'px;height:' . GetFieldData($this->tName, $listFieldInfo['fName'], 'videoHeight', "") . 'px;" id="' . $videoId . '"></a>';
                                     $this->controlsMap['video'][] = $videoId;
                                 }
                             }
                         } else {
                             if ($listFieldInfo['viewFormat'] == FORMAT_DATABASE_VIDEO) {
                                 if (@$data[$listFieldInfo['fName']] != NULL) {
                                     $videoId = 'video_' . GoodFieldName(htmlspecialchars($listFieldInfo['fName'])) . '_' . $this->recId;
                                     $value = '<a href="getfile.php?table=' . $this->shortTableName . '&field=' . rawurlencode($listFieldInfo['fName']) . $keylink . '" style="display:block;width:' . GetFieldData($this->tName, $listFieldInfo['fName'], 'videoWidth', 0) . 'px;height:' . GetFieldData($this->tName, $listFieldInfo['fName'], 'videoHeight', 0) . 'px;" id="' . $videoId . '"></a>';
                                     $this->controlsMap['video'][] = $videoId;
                                 }
                             } else {
                                 if ($listFieldInfo['viewFormat'] == FORMAT_MAP) {
                                     $value = '<div id="littleMap_' . GoodFieldName($listFieldInfo['fName']) . '_' . $this->recId . '" style="width: ' . $this->googleMapCfg['fieldsAsMap'][$listFieldInfo['fName']]['width'] . 'px; height: ' . $this->googleMapCfg['fieldsAsMap'][$listFieldInfo['fName']]['height'] . 'px;"></div>';
                                 } else {
                                     if (($listFieldInfo['editFormat'] == EDIT_FORMAT_LOOKUP_WIZARD || $listFieldInfo['editFormat'] == EDIT_FORMAT_RADIO) && GetLookupType($listFieldInfo['fName'], $this->tName) == LT_LOOKUPTABLE && GetLWLinkField($listFieldInfo['fName'], $this->tName) != GetLWDisplayField($listFieldInfo['fName'], $this->tName)) {
                                         $value = DisplayLookupWizard($listFieldInfo['fName'], $data[$listFieldInfo['fName']], $data, $keylink, MODE_LIST);
                                     } else {
                                         if (NeedEncode($listFieldInfo['fName'], $this->tName)) {
                                             $value = ProcessLargeText(GetData($data, $listFieldInfo['fName'], $listFieldInfo['viewFormat']), "field=" . rawurlencode($listFieldInfo['fName']) . $keylink, "", MODE_LIST);
                                         } else {
                                             $value = GetData($data, $listFieldInfo['fName'], $listFieldInfo['viewFormat']);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // create address field as center link
     $value = $this->addCenterLink($value, $listFieldInfo['fName']);
     return $value;
 }
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);
}