<%@ page import="weaver.general.*" %>
<%@page import="weaver.conn.RecordSet"%>
<%@ page import="weaver.hrm.User" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="org.apache.commons.lang3.StringUtils" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>

<%
    User user = HrmUserVarify.getUser(request , response) ;
    int userid = user.getUID();
    RecordSet rs = new RecordSet();
    BaseBean bb = new BaseBean();
    String specialUser = getUfPropValue("specialUser");
    String billid = Util.null2String(request.getParameter("billid"));
    String type = Util.null2String(request.getParameter("type"));
    String xm = Util.null2String(request.getParameter("xm"));

    String status = "0" ;
    String smxsmb = "" ;
    String smbjmb = "" ;
    String pfxsmb = "" ;
    String pfbjmb = "" ;
    String fkxsmb = "" ;
    String fkbjmb = "" ;
    String sfqy = "" ;

    String qs = "" ;
    if(StringUtils.isNotEmpty(billid))
    {
        String sql = " select qs from uf_cjxmjljskh where id = ?";
        rs.executeQuery(sql,new Object[]{billid});
        if(rs.next()){
            qs = Util.null2String(rs.getString("qs"));
        }
    }
    if(StringUtils.isNotEmpty(qs))
    {
        String sql = " select sfqy,smxsmb,smbjmb,pfxsmb,pfbjmb,fkxsmb,fkbjmb from uf_xmjlkhqs where id = ?";
        rs.executeQuery(sql,new Object[]{qs});
        if(rs.next()){
            smxsmb = Util.null2String(rs.getString("smxsmb"));
            smbjmb = Util.null2String(rs.getString("smbjmb"));
            pfxsmb = Util.null2String(rs.getString("pfxsmb"));
            pfbjmb = Util.null2String(rs.getString("pfbjmb"));
            fkxsmb = Util.null2String(rs.getString("fkxsmb"));
            fkbjmb = Util.null2String(rs.getString("fkbjmb"));
            sfqy = Util.null2String(rs.getString("sfqy"));
        }
    }

    if((","+specialUser+",").contains(","+userid+",")){
        status = "1";
    }else{
        if("0".equals(sfqy)){
            if("pf".equals(type)){
                if(xm.equals(userid+"")){
                    status = "0";
                }else{
                    status = "1";
                }
            }else{
                status = "1";
            }
        }else{

        }
    }

    String formid = getUfPropValue("mode.xmjljskh.formid");
    String modeid = getUfPropValue("mode.xmjljskh.modeid");
    String url = "/spa/cube/index.html#/main/cube/card?modeId="+modeid+"&formId="+formid+"&billid="+billid ;

    if("1".equals(status)){
        if("sm".equals(type)){
            url += "&type=2&layoutid="+smbjmb;
        }else if("fk".equals(type)){
            url += "&type=2&layoutid="+fkbjmb;
        }else if("pf".equals(type)){
            url += "&type=2&layoutid="+pfbjmb;
        }
    }else{
        if("sm".equals(type)){
            url += "&type=0&layoutid="+smxsmb;
        }else if("fk".equals(type)){
            url += "&type=0&layoutid="+fkxsmb;
        }else if("pf".equals(type)){
            url += "&type=0&layoutid="+pfxsmb;
        }
    }
    bb.writeLog("url:"+url);
%>

<script type="text/javascript" src="/cloudstore/resource/pc/jquery/jquery.min.js"></script>
<script type="text/javascript">
    jQuery(document).ready(function(){
        var url = "<%=url %>";
        window.location.href = url;
    });
</script>

<%!
    public String getUfPropValue(String pkey) {
        RecordSet rs = new RecordSet();
        BaseBean bb = new BaseBean();

        if (org.apache.commons.lang3.StringUtils.isEmpty(pkey)) {
            return "";
        }
        String value = "";
        String active = bb.getPropValue("developProp", "active");
        if (org.apache.commons.lang3.StringUtils.isNotEmpty(active)) {
            String sql = " select devvalue,prodvalue from uf_hr_prop where pkey = ?";
            rs.executeQuery(sql, new Object[]{pkey});
            if (rs.next()) {
                value = Util.null2String(rs.getString(active + "value"));
            }
        }
        return value;
    }
%>



