Exemple #1
0
function markread_record_newai($mode = 'makeread', $element = '')
{
    global $db, $tablename;
    global $_POST, $_GET, $columns, $primarykey, $primarykey_index;
    global $SUNSHINE_USER_NAME_VAR, $SUNSHINE_USER_ID_VAR, $_SESSION;
    global $return_sql_line, $isrechecked;
    $user_value = $_SESSION[$SUNSHINE_USER_NAME_VAR];
    //$user_value='122';
    $mark_array = explode('_', $_GET['action']);
    switch ($mode) {
        case 'makeread':
            $SQL = $return_sql_line['markread_sql'];
            //print $SQL;//exit;
            $result = $db->Execute($SQL);
            break;
        case 'makeadd':
            $SQL = $return_sql_line['markadd_sql'];
            //print $SQL;//exit;
            $result = $db->Execute($SQL);
            break;
        case 'addusername':
            $index_key = $_GET[(string) $columns[$primarykey]];
            //print $index_key;
            checkread_username($mode = 'addusername', $element[markread], $index_key);
            return;
            break;
    }
    //print $SQL;exit;
    if ($result->EOF) {
        return false;
    } else {
        return true;
    }
}
function newaiinit_value($fields)
{
    global $common_html, $html_etc;
    global $return_sql_line, $db;
    global $_POST, $_GET, $ROWS_PAGE;
    global $action_add, $action_model, $mark;
    global $read_type, $email_filter, $returnmodel;
    global $sms_filter, $nullshow, $columns;
    global $primarykey_index;
    global $systemorder;
    global $tablename;
    //print $systemorder;
    $systemorderArray = explode(',', $systemorder);
    //echo '<br>';//by cwf
    //var_dump($systemorderArray);//by cwf ='0:desc'
    //var_dump($columns);//by cwf
    for ($xx = 0; $xx < sizeof($systemorderArray); $xx++) {
        $KeyOrderSqlIndexArray = explode(':', $systemorderArray[$xx]);
        //{0,desc} by cwf
        $KeyOrderSqlIndexName = $KeyOrderSqlIndexArray[0];
        // 0
        $KeyOrderSqlIndexOrderDesc = $KeyOrderSqlIndexArray[1];
        //desc
        $OrderSQLARRAY[$xx] = $columns[$KeyOrderSqlIndexName] . " " . $KeyOrderSqlIndexOrderDesc;
        //id desc
    }
    $OrderSQLText = join(' , ', $OrderSQLARRAY);
    //将数组转化成字符串,以,隔开。 =id desc
    if (TRIM($OrderSQLARRAY[0]) != "") {
        //判断移除特殊字符后的变量是否为空
        $systemorderText = $OrderSQLText;
        //id desc
    } else {
        if ($systemorder != "") {
            $systemorder1 = "asc";
        } else {
            $systemorder1 = "desc";
        }
        $systemorderText = $primarykey_index . " {$systemorder1}";
    }
    //print $systemorderText;
    switch ($db->databaseType) {
        case 'mssql':
            if (isset($_GET[ordername]) && in_array($_GET[ordername], $columns)) {
                if ($_GET[doubletime] % 2 == 0) {
                    $addsql = "order by [" . $_GET[ordername] . "] asc";
                } else {
                    $addsql = "order by [" . $_GET[ordername] . "] desc";
                }
            } else {
                $addsql = "order by [" . $primarykey_index . "] {$systemorder1}";
            }
            break;
        case 'mysql':
        default:
            if (isset($_GET[ordername]) && in_array($_GET[ordername], $columns)) {
                if ($_GET[doubletime] % 2 == 0) {
                    $addsql = "order by " . $_GET[ordername] . " asc";
                } else {
                    $addsql = "order by " . $_GET[ordername] . " desc";
                }
            } else {
                $addsql = "order by {$systemorderText}";
            }
            break;
    }
    //end switch
    //判断是否进行搜索设定
    if ($action_add == 'search') {
        $SQL = $return_sql_line['uniquekey_sql_search'] . " " . $addsql;
        $SQL_NUM = $return_sql_line['uniquekey_sql_num_search'];
        $SQL_SUM = $return_sql_line['uniquekey_sql_sum_search'];
    } else {
        $SQL = $return_sql_line['uniquekey_sql'] . " " . $addsql;
        $SQL_NUM = $return_sql_line['uniquekey_sql_num_get'];
        $SQL_SUM = $return_sql_line['uniquekey_sql_sum_get'];
    }
    global $NEWAIINIT_VALUE_SYSTEM;
    global $NEWAIINIT_VALUE_SYSTEM_NUM;
    global $NEWAIINIT_VALUE_SYSTEM_SUM;
    if (strlen($NEWAIINIT_VALUE_SYSTEM) > 10) {
        $SQL = $NEWAIINIT_VALUE_SYSTEM;
        $SQL_NUM = $NEWAIINIT_VALUE_SYSTEM_NUM;
        $SQL_SUM = $NEWAIINIT_VALUE_SYSTEM_SUM;
    }
    global $SYSTEM_MODE, $SYSTEM_PRINT_SQL;
    //print_R($SYSTEM_MODE);
    //print_R($return_sql_line);exit;
    //print_R($return_sql_line);
    if ($SYSTEM_PRINT_SQL) {
        $SYSTEM_PRINT_SQL = $SQL;
        print_R($SQL);
        print "<HR>";
        print_R($_GET);
        print "<HR>";
        //print_R($_SESSION);
        //print "<HR>";
    }
    //print_R($SQL_SUM);EXIT;
    global $rc;
    $rs =& $db->CacheExecute(5, $SQL_NUM);
    $rs_a = $rs->GetArray();
    $rc = $rs_a[0]['num'];
    if ($rc == '') {
        $rc = $rs_a[0]['NUM'];
    }
    //求和开始 2011-01-31日支持数组
    global $UserSumFunction;
    //print $UserSumFunction;exit;
    $UserSumFunctionArray = explode(',', $UserSumFunction);
    $SQL_SUM_原始 = $SQL_SUM;
    for ($ixx = 0; $ixx < sizeof($UserSumFunctionArray); $ixx++) {
        $UserSumFunctionTEMP = $UserSumFunctionArray[$ixx];
        if ($UserSumFunctionTEMP != "") {
            $UserSumFunctionTEMP = $columns[$UserSumFunctionTEMP];
            //有些字段职员看不到汇总
            if ($fields['INPUT_TEXT'][$UserSumFunctionTEMP] == "private") {
                $grade = str_split($fields['inputsize'][$UserSumFunctionTEMP]);
                if (!in_array($_SESSION['LOGIN_USER_PRIV'], $grade)) {
                    continue;
                }
            }
            $SQL_SUM = eregi_replace("___", $UserSumFunctionTEMP, $SQL_SUM_原始);
            //print $SQL_SUM;//exit;
            $rs_sum =& $db->CacheExecute(15, $SQL_SUM);
            $sum_number = $rs_sum->fields['sum'];
            $UserSumFunctionTEMP = $html_etc[$fields['tablename']][$UserSumFunctionTEMP];
            $fields['other']['sum_number'][$UserSumFunctionTEMP] = is_float($sum_number + 0) ? number_format($sum_number, 2, '.', ',') : $sum_number;
        }
    }
    //求和结束
    if ($rc == 0 && $nullshow != 1) {
        $return = "location='?action=init_" . $mark . "'";
        $showtext = $common_html['common_html']['norecord'];
        $location_title = 'sunshine_inside';
        $action_array_temp = explode('_', $_GET['action']);
        if ($action_array_temp[1] == 'customer') {
        } else {
            if ($email_filter != '') {
                $return = isset($returnmodel) ? "location='?action=" . $returnmodel . "'" : "history.back();";
                $showtext = $common_html['common_html']["nomail" . $mark];
            } else {
                if ($sms_filter != '') {
                    $return = isset($returnmodel) ? "location='?action=" . $returnmodel . "'" : "history.back();";
                    $showtext = $common_html['common_html']["nosms" . $mark];
                } else {
                    //page_css('system');
                    //$action_model='add_default:new:n';
                    //show_new_element($action_model);
                }
            }
        }
        print_infor($showtext, 'trip', "{$return}");
        exit;
    }
    if ($ROWS_PAGE <= 0) {
        $pagenums = 0;
    } else {
        $pagenums = ceil($rc / $ROWS_PAGE);
        $pageid = $_GET['pageid'];
    }
    if ($pageid == "" || empty($pageid)) {
        $pageid = 1;
    }
    if ($pageid > $pagenums) {
        $pageid = $pagenums;
    }
    $from = ($pageid - 1) * $ROWS_PAGE;
    //print $SQL;print $SQL_NUM;
    global $SYSTEM_SQL;
    $SYSTEM_SQL = $SQL;
    //print_r($SQL);
    $rsl = $db->SelectLimit($SQL, $ROWS_PAGE, $from);
    $rsa = $rsl->GetArray();
    //print_R($rsa[0]);
    @($fields['header'] = array_keys($rsa[0]));
    $fields['sql']['SQL'] = $SQL;
    $fields['sql']['SQL_NUM'] = $SQL_NUM;
    $fields['value'] = $rsa;
    //print_R(array_keys($rsa[0]));
    //print_R($fields['value']);
    $counter = 0;
    //行数增加
    //是否引入图片放大脚本
    $ifincludemaginfier = false;
    //2011-06-21初始化编辑与删除权限的值
    $fields['view_priv'][$counter] = 0;
    $fields['edit_priv'][$counter] = 0;
    $fields['delete_priv'][$counter] = 0;
    $fields['value2'] = $fields['value'];
    foreach ($fields['value'] as $list) {
        //print_R($list);exit;
        //print $tablename;
        $i = 0;
        //
        global $showlistfieldstopedit;
        $showlistfieldstopeditArray = explode(',', $showlistfieldstopedit);
        global $showlistfieldstopdelete;
        $showlistfieldstopdeleteArray = explode(',', $showlistfieldstopdelete);
        foreach ($fields['name'] as $list_index) {
            $mode = $fields['filter'][$i];
            //在此判断是否在专业科科长权限,如果是,则不显示USER_DEFINE字段
            if ($_SESSION['SUNSHINE_BANJI_LIST'] != "") {
                if ($mode == 'userdefine') {
                    $mode = 'input';
                    //设置为INPUT则不会显示增加操作的连接
                }
            }
            //2011-06-20 处理针对行的编辑和删除按钮的禁用权限处理,兼容用户自定义部分的权限控制
            //用户权限定义部分
            //得到X列Y行的值
            $filtervalue = $fields['value'][$counter][$list_index];
            $showlistfieldstopeditArrayCheckArray = explode(':', $showlistfieldstopeditArray[$i]);
            //print_R($showlistfieldstopeditArrayCheckArray);
            if (in_array($filtervalue, $showlistfieldstopeditArrayCheckArray) && $filtervalue != "") {
                $fields['edit_priv'][$counter] = 1;
            } else {
                //兼容旧的返回结果
                //$fields['edit_priv'][$counter] = 0;
            }
            $filtervalue = $fields['value'][$counter][$list_index];
            $showlistfieldstopdeleteArrayCheckArray = explode(':', $showlistfieldstopdeleteArray[$i]);
            if (in_array($filtervalue, $showlistfieldstopdeleteArrayCheckArray) && $filtervalue != "") {
                $fields['delete_priv'][$counter] = 1;
            } else {
                //兼容旧的返回结果
                //$fields['delete_priv'][$counter] = 0;
            }
            $i++;
            //列数增加
            //exit($mode);
            if (stristr($mode, 'color')) {
                $hascolor = true;
            } else {
                $hascolor = false;
            }
            switch ($mode) {
                case '':
                case 'input':
                case 'autoincrement':
                case 'autoincrementdate':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    break;
                case 'number':
                    $filtervalue = "<div align=right>" . $fields['value'][$counter][$list_index] . "</div>";
                    break;
                case 'money':
                    $filtervalue = "<div align=right>" . number_format(floatval($fields['value'][$counter][$list_index]), 2) . "</div>";
                    break;
                case 'password':
                    $filtervalue = "******";
                    break;
                case 'password_simple':
                    $filtervalue = "******";
                    break;
                case 'ajaxinput':
                    global $sessionkey;
                    $INPUT_TEXT = $fields['INPUT_TEXT'][$list_index];
                    if ($INPUT_TEXT == "") {
                        $INPUT_SIZE = 15;
                    } else {
                        $INPUT_SIZE = $INPUT_TEXT;
                    }
                    //print $sessionkey;
                    $filtervalue = $fields['value'][$counter][$list_index];
                    $AjaxID = $fields['value'][$counter][$primarykey_index];
                    $openDir = "sessionkey={$sessionkey}&action=jiyun512&tablename={$tablename}&primarykey={$primarykey_index}&IDValue={$AjaxID}&FieldName={$list_index}";
                    if (is_file("newai_ajax.php")) {
                        $TempDirPath = "./";
                    } else {
                        if (is_file("../../Framework/newai_ajax.php")) {
                            $TempDirPath = "../../Framework/";
                        } else {
                            $TempDirPath = '';
                        }
                    }
                    $openDir = $TempDirPath . "newai_ajax.php?" . base64_encode($openDir);
                    $filtervalue = "<input type=\"text\" class=\"SmallInput\" size=\"{$INPUT_SIZE}\"  value=\"" . $filtervalue . "\"\n\t\t\t\tonBlur=\"GetResult('" . $openDir . "&FieldValue='+this.value);\"\n\t\t\t\tonkeypress=\"GetResult('" . $openDir . "&FieldValue='+this.value);\"\n\t\t\t\tonchange=\"GetResult('" . $openDir . "&FieldValue='+this.value);\"\n\t\t\t\t>";
                    $filtervalue = $filtervalue;
                    break;
                case 'ajaxinputhidden':
                    global $sessionkey;
                    $INPUT_TEXT = $fields['INPUT_TEXT'][$list_index];
                    if ($INPUT_TEXT == "") {
                        $INPUT_SIZE = 15;
                    } else {
                        $INPUT_SIZE = $INPUT_TEXT;
                    }
                    //print $sessionkey;
                    $filtervalue = $fields['value'][$counter][$list_index];
                    $AjaxID = $fields['value'][$counter][$primarykey_index];
                    $openDir = "sessionkey={$sessionkey}&action=jiyun512&tablename={$tablename}&primarykey={$primarykey_index}&IDValue={$AjaxID}&FieldName={$list_index}";
                    if (is_file("newai_ajax.php")) {
                        $TempDirPath = "./";
                    } else {
                        if (is_file("../../Framework/newai_ajax.php")) {
                            $TempDirPath = "../../Framework/";
                        } else {
                            $TempDirPath = '';
                        }
                    }
                    $openDir = $TempDirPath . "newai_ajax.php?" . base64_encode($openDir);
                    //$filtervalue="<input type=\"text\" class=\"SmallInput\" size=\"$INPUT_SIZE\"  value=\"".$filtervalue."\" onkeyup=\"GetResult('".$openDir."&FieldValue='+this.value);\">";
                    if (TRIM($filtervalue) != "") {
                        $SpanInputText = "";
                    } else {
                        $SpanInputText = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                    }
                    $filtervalue = "<SPAN onclick=\"listTable_edit(this,'{$list_index}',{$AjaxID},'{$sessionkey}','{$tablename}','{$primarykey_index}','{$AjaxID}','{$list_index}','{$openDir}')\">" . $filtervalue . $SpanInputText . "</SPAN>";
                    break;
                case 'ajaxboolean':
                    global $sessionkey;
                    $INPUT_TEXT = $fields['INPUT_TEXT'][$list_index];
                    if ($INPUT_TEXT == "") {
                        $INPUT_SIZE = 15;
                    } else {
                        $INPUT_SIZE = $INPUT_TEXT;
                    }
                    //print $sessionkey;
                    $filtervalue = $fields['value'][$counter][$list_index];
                    $AjaxID = $fields['value'][$counter][$primarykey_index];
                    $openDir = "action=jiyun512&tablename={$tablename}&primarykey={$primarykey_index}&IDValue={$AjaxID}&sessionkey={$sessionkey}&FieldName={$list_index}";
                    if (is_file("newai_ajax.php")) {
                        $TempDirPath = "./";
                    } else {
                        if (is_file("../../newai_ajax.php")) {
                            $TempDirPath = "../../Framework/";
                        } else {
                            $TempDirPath = '';
                        }
                    }
                    if (is_file("images/error.gif")) {
                        $PicDirPath = "./";
                    } else {
                        $PicDirPath = "../../Framework/";
                    }
                    $openDir = $TempDirPath . "newai_ajax.php?" . base64_encode($openDir);
                    //$filtervalue="<input type=\"text\" class=\"SmallInput\" size=\"$INPUT_SIZE\"  value=\"".$filtervalue."\" onkeyup=\"GetResult('".$openDir."&FieldValue='+this.value);\">";
                    if ($filtervalue == "1") {
                        $filtervalue = "<img onclick=\"listTable_boolean(this,'{$list_index}',{$AjaxID},'{$sessionkey}','{$tablename}','{$primarykey_index}','{$AjaxID}','{$list_index}','{$openDir}')\" src=\"" . $PicDirPath . "images/right.gif\" border=0>";
                    } else {
                        $filtervalue = "<img onclick=\"listTable_boolean(this,'{$list_index}',{$AjaxID},'{$sessionkey}','{$tablename}','{$primarykey_index}','{$AjaxID}','{$list_index}','{$openDir}')\" src=\"" . $PicDirPath . "images/error.gif\" border=0>";
                    }
                    break;
                case 'avatar':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    $filepath = "images/avatar/{$filtervalue}.gif";
                    if (is_file($filepath)) {
                        $filtervalue = "<img src=\"{$filepath}\" border=0>";
                    } else {
                        $filtervalue = "<img src=\"images/avatar/9.gif\" border=0>";
                    }
                    break;
                case 'textarea':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    $filtervalue = strip_tags(htmlspecialchars_decode($filtervalue));
                    if (cutStr($filtervalue, 25) != $filtervalue) {
                        $filtervalue = "<font title='{$filtervalue}'>" . cutStr($filtervalue, 25) . "</font>" . "...";
                    }
                    break;
                case 'textareabr':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    $filtervaluetext = addslashes($filtervalue);
                    if (cutStr($filtervalue, 25) != $filtervalue) {
                        $filtervalue = "<font title='{$filtervaluetext}'>" . cutStr($filtervalue, 25) . "</font>" . "...";
                    }
                    //if(strlen($filtervalue)>50)	$filtervalue=substr($filtervalue,0,50)."...";
                    break;
                case 'readonlytextarea':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    $filtervaluetext = addslashes($filtervalue);
                    if (cutStr($filtervalue, 25) != $filtervalue) {
                        $filtervalue = "<font title='{$filtervaluetext}'>" . cutStr($filtervalue, 25) . "</font>" . "...";
                    }
                    break;
                case 'idtoname_user':
                    $filtervalue = idtoname($fields['value'][$counter][$list_index], $mode = 'user');
                    break;
                case 'idtoname_course':
                    $filtervalue = idtoname($fields['value'][$counter][$list_index], $mode = 'course');
                    break;
                case 'idtoname_YuanXi':
                    $filtervalue = idtoname($fields['value'][$counter][$list_index], $mode = 'YuanXi');
                    break;
                case 'idtoname_dept':
                    $filtervalue = idtoname($fields['value'][$counter][$list_index], $mode = 'dept');
                    //$filtervalue=$fields['value'][$counter][$list_index];
                    break;
                case 'colorselect':
                    $filtervalue = "<div  style=\"border:1px double #000000;width:16px;height:16px;background-color:{$filtervalue};overflow:hidden;\"></div>";
                    break;
                case 'date':
                case 'date1':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    break;
                case 'dateonly':
                    $filtervalue_Array = explode(' ', $fields['value'][$counter][$list_index]);
                    $filtervalue = $filtervalue_Array[0];
                    break;
                case 'timeonly':
                    $filtervalue_Array = explode(' ', $fields['value'][$counter][$list_index]);
                    $filtervalue = $filtervalue_Array[1];
                    break;
                case 'datetime':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    break;
                case 'url':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    $urlfield = $fields['INPUT_TEXT'][$list_index];
                    $urlid = $fields['inputsize'][$list_index];
                    if ($filtervalue != '' && $urlid != '') {
                        $filtervalue = $filtervalue . "-" . $fields['value'][$counter][$urlid];
                    }
                    $url = $fields['value'][$counter][$urlfield];
                    $urlarray = explode("?", $url);
                    $urlarray[1] = str_ireplace("&amp;", "&", $urlarray[1]);
                    $url = $urlarray[0] . "?" . base64_encode($urlarray[1]);
                    $filtervalue = "<a href=\"{$url}\" target=_blank >{$filtervalue}</a>";
                    break;
                case 'mulcheckbox':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    $subtablename = $fields['INPUT_TEXT'][$list_index];
                    $subkey = $fields['inputsize'][$list_index];
                    $subval = $fields['inputother'][$list_index];
                    $subcolums = returntablecolumn($subtablename);
                    $subkey = $subcolums[$subkey];
                    $subval = $subcolums[$subval];
                    $fieldValueArray = explode(",", $filtervalue);
                    array_pop($fieldValueArray);
                    $fieldValueArrayTEXT = join("','", $fieldValueArray);
                    $sql = "select {$subval} from {$subtablename} where {$subkey} in ('{$fieldValueArrayTEXT}')";
                    $rsxx = $db->CacheExecute(5, $sql);
                    $rsxxA = $rsxx->GetArray();
                    $fieldValueNameText = '';
                    for ($iD = 0; $iD < sizeof($rsxxA); $iD++) {
                        $fieldValueNameText .= $rsxxA[$iD][$subval] . ",";
                    }
                    //for($iD=0;$iD<sizeof($fieldValueArray);$iD++)			{
                    //	$fieldValueArrayValue = $fieldValueArray[$iD];
                    //	if($fieldValueArrayValue!="")
                    //		$fieldValueNameText .= returntablefield("user","USER_ID",$fieldValueArrayValue,"USER_NAME").",";
                    //}
                    $filtervalue = $fieldValueNameText;
                    break;
                case 'file':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    $filtervalue_file = explode('=', $filtervalue);
                    $filtervalue_sizeof = sizeof($filtervalue_file) - 1;
                    $filename = $filtervalue_file[$filtervalue_sizeof];
                    $filtervalue = "<a href=\"{$filtervalue}\">{$filename}</a>";
                    break;
                case 'singlefile':
                case 'picturefile':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    $var_value = ereg_replace("&amp;", "&", $filtervalue);
                    //print $filtervalue;
                    $parse_url = parse_url($var_value);
                    $query = $parse_url['query'];
                    parse_str($query, $output);
                    //print_R($output);
                    $attachmentid = $output['attachmentid'];
                    $attachmentname = $output['attachmentname'];
                    $filtervalue_file = explode('=', $filtervalue);
                    $filtervalue_sizeof = sizeof($filtervalue_file) - 1;
                    $filename = $filtervalue_file[$filtervalue_sizeof];
                    $filename_newfile = "../../attachment/{$attachmentid}/{$attachmentname}";
                    $filename_newfile2 = "../../Framework/attachment/{$attachmentid}/{$attachmentname}";
                    //print $filename_newfile;
                    //print_R(is_file($filename_newfile));
                    if (is_file($filename_newfile) || is_file($filename_newfile2)) {
                        $filtervalue = trim($fields['value'][$counter][$list_index]);
                        $filtervalue_file = explode('=', $filtervalue);
                        $filtervalue_sizeof = sizeof($filtervalue_file) - 1;
                        $filename = $filtervalue_file[$filtervalue_sizeof];
                        //$filtervalue = "<a href='".$filtervalue."'>$filename</a>";
                        if (!$ifincludemaginfier) {
                            print "<script type=\"text/javascript\" language=\"javascript\" src=\"" . ROOT_DIR . "general/ERP/Enginee/jquery/jquery.js\"></script>";
                            print "<script type=\"text/javascript\" language=\"javascript\" src=\"" . ROOT_DIR . "general/ERP/Enginee/jquery/jquery.magnifier.js\"></script>";
                            $ifincludemaginfier = true;
                        }
                        $image = "<img src='" . $filtervalue . "' height=25  class=\"magnify\"  data-magnifyto=\"500\" onmouseover=\"this.style.cursor='pointer';this.style.cursor='hand'\" onmouseout=\"this.style.cursor='default'\">";
                        //$filtervalue = "<a href='".$filtervalue."'>$image</a>";
                        $filtervalue = $image;
                    } else {
                        $filtervalue = "";
                    }
                    break;
                case 'tdoafile':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    $var_value_array = explode('||', $filtervalue);
                    $ATTACHMENT_ID = $var_value_array[1];
                    $ATTACHMENT_NAME = $var_value_array[0];
                    $ATTACHMENT_ID_ARRAY = explode(",", $ATTACHMENT_ID);
                    $ATTACHMENT_NAME_ARRAY = explode("*", $ATTACHMENT_NAME);
                    $ATTACH_LINK = '';
                    require_once 'lib/utility_file.php';
                    $MODULE = attach_sub_dir();
                    for ($IX = 0; $IX < count($ATTACHMENT_ID_ARRAY); $IX++) {
                        if ($ATTACHMENT_ID_ARRAY[$IX] != "") {
                            $ATTACH_IMAGE = image_mimetype($ATTACHMENT_NAME_ARRAY[$IX]);
                            //print $ATTACH_IMAGE;
                            $ATTACHMENT_ID = $ATTACHMENT_ID_ARRAY[$IX];
                            //print_R($ATTACHMENT_ID);
                            $ATTACHMENT_ID_ARRAY2 = explode('_', $ATTACHMENT_ID);
                            $YM = $ATTACHMENT_ID_ARRAY2[0];
                            $ATTACHMENT_ID = $ATTACHMENT_ID_ARRAY2[1];
                            $SIGN_KEY = "";
                            //$SIGN_KEY = substr( $ATTACHMENT_ID, strpos( $ATTACHMENT_ID, "." ) + 1 );
                            //$ATTACHMENT_ID = substr( $ATTACHMENT_ID, 0, strpos( $ATTACHMENT_ID, "." ) );
                            //print_R($ATTACHMENT_ID);
                            $ATTACHMENT_ID_ENCODED = attach_id_encode($ATTACHMENT_ID, $ATTACHMENT_NAME_ARRAY[$IX]);
                            $ATTACH_SIZE = attach_size($ATTACHMENT_ID_ARRAY[$IX], $ATTACHMENT_NAME_ARRAY[$IX], $MODULE);
                            if (0 < floor($ATTACH_SIZE / 1024 / 1024)) {
                                $ATTACH_SIZE = round($ATTACH_SIZE / 1024 / 1024, 2) . "MB";
                            } else {
                                if (0 < floor($ATTACH_SIZE / 1024)) {
                                    $ATTACH_SIZE = round($ATTACH_SIZE / 1024, 2) . "KB";
                                } else {
                                    $ATTACH_SIZE .= "字节";
                                }
                            }
                            $ATTACH_LINK .= "<img src=\"../../Framework/images/attach/" . $ATTACH_IMAGE . "\" align=\"absmiddle\"\n\t\t\t\t\t\t\ttitle='" . urldecode($ATTACHMENT_NAME_ARRAY[$IX]) . " 大小:{$ATTACH_SIZE}'><a href=\"../../Enginee/lib/attach.php?MODULE=" . $MODULE . "&YM=" . $YM . "&ATTACHMENT_ID=" . $ATTACHMENT_ID_ENCODED . "&ATTACHMENT_NAME=" . urlencode($ATTACHMENT_NAME_ARRAY[$IX]) . "\" " . ($ATTACH_OFFICE_OPEN_IN_IE ? " target=\"_blank\"" : "") . "\n\t\t\t\t\t\t\ttitle='" . urldecode($ATTACHMENT_NAME_ARRAY[$IX]) . " 大小:{$ATTACH_SIZE}'\n\t\t\t\t\t\t\t>" . urldecode($ATTACHMENT_NAME_ARRAY[$IX]) . "</a>\n";
                        }
                    }
                    $filtervalue = $ATTACH_LINK;
                    break;
                case 'binaryfile':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    $filtervalue_file = explode('=', $filtervalue);
                    $filtervalue_sizeof = sizeof($filtervalue_file) - 1;
                    $filename = $filtervalue_file[$filtervalue_sizeof];
                    $filtervalue = "<a href=\"{$filtervalue}\">{$filename}</a>";
                    break;
                case 'sex':
                    $filtervalue = returnsexcolor($fields['value'][$counter][$list_index]);
                    break;
                case 'select_sex':
                    $filtervalue = returnsexcolor($fields['value'][$counter][$list_index]);
                    break;
                case 'boolean':
                    $filtervalue = returnboolean_gif($fields['value'][$counter][$list_index]);
                    break;
                case 'checkbox':
                    $filtervalue = returncheckbox($fields['value'][$counter][$list_index]);
                    break;
                case 'select_sms':
                    $filtervalue = return_select_filter('select_sms', $fields['value'][$counter][$list_index]);
                    break;
                case 'select_education':
                    $filtervalue = return_select_filter('select_education', $fields['value'][$counter][$list_index]);
                    break;
                case 'select_marriage':
                    $filtervalue = return_select_filter('select_marriage', $fields['value'][$counter][$list_index]);
                    break;
                case 'select_politics':
                    $filtervalue = return_select_filter('select_politics', $fields['value'][$counter][$list_index]);
                    break;
                case 'sms_self_status':
                    $filtervalue = return_select_filter('sms_self_status', $fields['value'][$counter][$list_index]);
                    break;
                case 'sms_delete_status':
                    $filtervalue = return_select_filter('sms_delete_status', $fields['value'][$counter][$list_index]);
                    break;
                case 'select_worklog':
                    $filtervalue = return_select_filter('select_worklog', $fields['value'][$counter][$list_index]);
                    break;
                case 'email_read_status_inbox':
                    $filtervalue = return_select_filter('email_read_status_inbox', $fields['value'][$counter][$list_index]);
                    break;
                case 'email_read_status_outbox':
                    $filtervalue = return_select_filter('email_read_status_outbox', $fields['value'][$counter][$list_index]);
                    break;
                case 'email_delete_status_outbox':
                    $filtervalue = return_select_filter('email_delete_status_outbox', $fields['value'][$counter][$list_index]);
                    break;
                case 'ajax':
                    $filtervalue = ajaxtablefield($fields['select'][$i - 1]['tablename'], $fields['select'][$i - 1]['value'], $fields['value'][$counter][$list_index], $fields['select'][$i - 1]['field'], $counter, $fields['tablename'], $fields['name'][$i - 1], $primarykey_index, $fields['value'][$counter][$primarykey_index]);
                    break;
                case 'select':
                    $filtervalue = returntablefield($fields['select'][$i - 1]['tablename'], $fields['select'][$i - 1]['value'], $fields['value'][$counter][$list_index], $fields['select'][$i - 1]['field']);
                    break;
                case 'radio':
                    $filtervalue = returntablefield($fields['select'][$i - 1]['tablename'], $fields['select'][$i - 1]['value'], $fields['value'][$counter][$list_index], $fields['select'][$i - 1]['field']);
                    //print_R($fields['select'][$i-1]);;
                    break;
                case 'radiogroup':
                    $filtervalue = returntablefieldColorFilterGray($fields['select'][$i - 1]['tablename'], $fields['select'][$i - 1]['value'], $fields['value'][$counter][$list_index], $fields['select'][$i - 1]['field'], $fields['select'][$i - 1]['groupfield'], $fields['select'][$i - 1]['groupvalue'], '', '', '', $hascolor);
                    break;
                case 'selectcolor':
                    $filtervalue = returntablefieldColorFilterGray($fields['select'][$i - 1]['tablename'], $fields['select'][$i - 1]['value'], $fields['value'][$counter][$list_index], $fields['select'][$i - 1]['field'], '', '', '', $hascolor);
                    break;
                case 'select_input':
                    $value = $fields['value'][$counter][$list_index];
                    $filtervalue = returntablefield($fields['select'][$i - 1]['tablename'], $fields['select'][$i - 1]['value'], $fields['value'][$counter][$list_index], $fields['select'][$i - 1]['field']);
                    break;
                case 'select_textarea':
                    $value = $fields['value'][$counter][$list_index];
                    $filtervalue = idtoname($value, $mode = 'dept');
                    //returntablefield($fields['select'][$i-1]['tablename'],$fields['select'][$i-1]['value'],$fields['value'][$counter][$list_index],$fields['select'][$i-1]['field']);
                    break;
                case 'checkread':
                    $index_key = $fields['table']['primarykeyindex'];
                    $index_key = $fields['value'][$counter][$index_key];
                    $in_array = checkread_username('checkread', $fields['checkread'][$i - 1]['field'], $index_key);
                    $in_array = $in_array == 1 ? 1 : 0;
                    $filtervalue = return_select_filter('notify_read_status', $in_array);
                    break;
                case 'usertonamelist':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    $fieldValueArray = explode(",", $filtervalue);
                    array_pop($fieldValueArray);
                    $fieldValueArrayTEXT = join("','", $fieldValueArray);
                    $sql = "select UID,USER_NAME from user where USER_ID in ('{$fieldValueArrayTEXT}') order by USER_NAME";
                    $rsxx = $db->CacheExecute(5, $sql);
                    $rsxxA = $rsxx->GetArray();
                    $fieldValueNameText = '';
                    for ($iD = 0; $iD < sizeof($rsxxA); $iD++) {
                        $fieldValueNameText .= "<a target='_blank' href='../Framework/user_newai.php?action=view_default&UID=" . $rsxxA[$iD]['UID'] . "'>" . $rsxxA[$iD]['USER_NAME'] . "</a>,";
                    }
                    //for($iD=0;$iD<sizeof($fieldValueArray);$iD++)			{
                    //	$fieldValueArrayValue = $fieldValueArray[$iD];
                    //	if($fieldValueArrayValue!="")
                    //		$fieldValueNameText .= returntablefield("user","USER_ID",$fieldValueArrayValue,"USER_NAME").",";
                    //}
                    $filtervalue = $fieldValueNameText;
                    //$filtervalue="<font title='$fieldValueNameText'>".$fieldValueNameText."</font>"."...";
                    break;
                case 'link':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    $url = $fields['link'][$i - 1]['url'];
                    $target = $fields['link'][$i - 1]['target'];
                    $filename = $fields['link'][$i - 1]['filename'];
                    $index_key = $fields['table']['primarykeyindex'];
                    $filtervalue = "<a href='{$filename}?" . base64_encode("action={$url}&{$index_key}=" . $fields['value'][$counter][$index_key]) . "' target={$target}>{$filtervalue}</a>";
                    //$filtervalue="<a href='$filename?action=$url&$list_index=$filtervalue&$index_key=".$fields['value'][$counter][$index_key]."' target=$target>$filtervalue</a>";
                    break;
                case 'mobile':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    $regex = "/1[34568]+\\d{9}/";
                    preg_match_all($regex, $filtervalue, $phones);
                    if (strlen($phones[0][0]) == 11) {
                        $filtervalue = "<a href='../JXC/sms_sendlist_newai.php?" . base64_encode("action=add_default&sendlist=" . $phones[0][0]) . "' target='_blank'>{$filtervalue}</a>";
                    }
                    break;
                case 'qq':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    $filtervalue = !empty($filtervalue) ? "<a target=\"_blank\" href=\"http://wpa.qq.com/msgrd?v=3&amp;uin=" . $filtervalue . "&amp;site=qq&amp;menu=yes\"><img border=\"0\" src=\"http://wpa.qq.com/pa?p=2:" . $filtervalue . ":45\" title=\"点击这里发消息\" onerror=\"this.src='" . ROOT_DIR . "general/ERP/Framework/images/help3.gif';this.title='此QQ号码可能不存在'\">" . $filtervalue . "</a>" : '';
                    break;
                case 'email':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    if ($fields['tablename'] == 'linkman') {
                        $fromsrc = 'customer';
                        $linkman = gettablefield($fields['tablename'], 'email', 'rowid', $filtervalue);
                    } else {
                        if ($fields['tablename'] == 'supplylinkman') {
                            $fromsrc = 'supply';
                            $linkman = gettablefield($fields['tablename'], 'email', 'rowid', $filtervalue);
                        } else {
                            $linkman = $filtervalue;
                            $fromsrc = '';
                        }
                    }
                    $filtervalue = "<a href='../CRM/email_newai.php?" . base64_encode("action=add_default&sendlist=" . $linkman . "&fromsrc=" . $fromsrc) . "' target='_blank' >" . $filtervalue . "</a>";
                    break;
                case 'userdefine':
                    $filtervalue = $fields['value'][$counter][$list_index];
                    $functionName = $fields['userdefine'][$i - 1];
                    $fileName = $functionName . ".php";
                    $fileName0 = "userdefine/{$fileName}";
                    $fileName = "../../Enginee/userdefine/{$fileName}";
                    if (file_exists($fileName0)) {
                        require_once $fileName0;
                        $functionName = $functionName . "_Value";
                        if (function_exists($functionName)) {
                            $filtervalue = $functionName($fields['value'][$counter][$list_index], $fields, $counter);
                        }
                    } else {
                        if (file_exists($fileName)) {
                            require_once $fileName;
                            $functionName = $functionName . "_Value";
                            if (function_exists($functionName)) {
                                $filtervalue = $functionName($fields['value'][$counter][$list_index], $fields, $counter);
                            } else {
                                print "函数名称[{$functionName}]不存在!";
                            }
                        } else {
                            print "没有相应文件,文件名:{$fileName}";
                        }
                    }
                    //用户权限定义部分
                    //print_R($functionName."_PRIV");print_R("<BR>");
                    if (function_exists($functionName . "_PRIV")) {
                        $NewFunctionNamePriv = $functionName . "_PRIV";
                        $userdefine_priv_Infor = $NewFunctionNamePriv($fields['value'][$counter][$list_index], $fields, $counter);
                        if ($userdefine_priv_Infor['view_priv'] == 1) {
                            $fields['view_priv'][$counter] = 1;
                        }
                        if ($userdefine_priv_Infor['edit_priv'] == 1) {
                            $fields['edit_priv'][$counter] = 1;
                        }
                        if ($userdefine_priv_Infor['delete_priv'] == 1) {
                            $fields['delete_priv'][$counter] = 1;
                        }
                        if ($userdefine_priv_Infor['shenhe_priv'] == 1) {
                            $fields['shenhe_priv'][$counter] = 1;
                        }
                        if ($userdefine_priv_Infor['flow_priv'] == 1) {
                            $fields['flow_priv'][$counter] = 1;
                        }
                        if ($userdefine_priv_Infor['next_priv'] == 1) {
                            $fields['next_priv'][$counter] = 1;
                        }
                        if ($userdefine_priv_Infor == 1) {
                            $fields['view_priv'][$counter] = 1;
                            $fields['edit_priv'][$counter] = 1;
                            $fields['delete_priv'][$counter] = 1;
                            $fields['shenhe_priv'][$counter] = 1;
                            $fields['flow_priv'][$counter] = 1;
                            $fields['next_priv'][$counter] = 1;
                        }
                        //print_R($fields['delete_priv']);
                    }
                    break;
            }
            global $limitEditDelUser;
            global $limitEditDelCust;
            if ($limitEditDelUser != '') {
                //限制上级的编辑和删除权限
                if ($_SESSION['limitEditDel'] == '0' && $fields['value2'][$counter][$limitEditDelUser] != $_SESSION['LOGIN_USER_ID'] && $_SESSION['LOGIN_USER_ID'] != 'admin' && $fields['value2'][$counter]['datascope'] != '1') {
                    $fields['edit_priv'][$counter] = 1;
                    $fields['delete_priv'][$counter] = 1;
                }
                //限制公共客户的编辑和删除权限
                if ($fields['value2'][$counter]['datascope'] == '1' && !ifHasRoleUser($fields['value2'][$counter][$limitEditDelUser])) {
                    $fields['edit_priv'][$counter] = 1;
                    $fields['delete_priv'][$counter] = 1;
                }
            }
            if ($limitEditDelCust != '') {
                $guanlianSysuser = returntablefield("customer", "rowid", $fields['value2'][$counter][$limitEditDelCust], "sysuser,datascope");
                ////限制上级的编辑和删除权限
                if ($_SESSION['limitEditDel'] == '0' && $guanlianSysuser['sysuser'] != $_SESSION['LOGIN_USER_ID'] && $_SESSION['LOGIN_USER_ID'] != 'admin' && $guanlianSysuser['datascope'] != '1') {
                    $fields['edit_priv'][$counter] = 1;
                    $fields['delete_priv'][$counter] = 1;
                }
                //限制公共客户的编辑和删除权限
                if ($guanlianSysuser['datascope'] == '1' && !ifHasRoleUser($guanlianSysuser['sysuser'])) {
                    $fields['edit_priv'][$counter] = 1;
                    $fields['delete_priv'][$counter] = 1;
                }
            }
            $fields['elementlink'][$counter][$list_index] = $fields['value'][$counter][$list_index];
            $fields['value'][$counter][$list_index] = $filtervalue;
        }
        $counter++;
    }
    $fields['other']['pageid'] = $pageid;
    $fields['other']['pagenums'] = $pagenums;
    $fields['other']['rc'] = $rc;
    //print_r($fields['delete_priv']);print_r($fields['edit_priv']);exit;
    return $fields;
}