<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="customermodify.aspx.cs" Inherits="HySoft.BaseCallCenter.Web.customermanage.customermodify" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>编辑客户</title>
    <script src="../scripts/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../scripts/jquery/jquery.form.js"></script>
    <script type="text/javascript" src="../scripts/jquery/jquery.validate.min.js"></script>
    <script type="text/javascript" src="../scripts/jquery/messages_cn.js"></script>
    <script type="text/javascript" src="../scripts/function.js"></script>
    <link href="../scripts/ui/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <script src="../scripts/ui/json2.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/core/base.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/ligerui.min.js" type="text/javascript"></script>
    <link href="../scripts/ui/skins/Tab/css/tab.css" rel="stylesheet" type="text/css" />
    <link href="../scripts/ui/skins/Tab/css/grid.css" rel="stylesheet" type="text/css" />
    <script src="../scripts/ui/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerLayout.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerTree.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerMenu.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerTextBox.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerComboBox.js" type="text/javascript"></script>
    <link href="../scripts/ui/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <link href="../images/style.css" rel="stylesheet" type="text/css" />
    <script src="../scripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript">
        var treelist = null;
        $(function () {
            treelist = $("#drpServiceDept").ligerComboBox({
                width: 130,
                selectBoxWidth: 200,
                selectBoxHeight: 150, valueField: 'id', resize: false, treeLeafOnly: false,
                tree: {
                    url: 'ajax/customeredit.ashx?action=getservicedepttreelist',
                    width: 200,
                    height: 150,
                    checkbox: false,
                    ajaxType: 'get',
                    isExpand: false,
                    onSuccess: function (data) { SetTreeValue(); }
                },
                onSelected: function (newvalue) {
                    $("#hiddSeriveDeptId").val(newvalue);
                }
            });
            $("#drpProvince").ligerComboBox({
                url: 'ajax/customeredit.ashx?action=getregionlist',
                valueField: '_f_regionid',
                textField: '_f_regionname',
                autocomplete: true,
                onSelected: function (newvalue) {
                    $("#hiddProvinceId").val(newvalue);
                    $("#drpCity").ligerComboBox({
                        url: 'ajax/customeredit.ashx?action=getregionlist&regionpid=' + newvalue,
                        autocomplete: true,
                        valueField: '_f_regionid',
                        textField: '_f_regionname'
                    });
                }
            });
            $("#drpCity").ligerComboBox({
                data: null,
                valueField: '_f_regionid',
                textField: '_f_regionname',
                autocomplete: true,
                isMultiSelect: false,
                isShowCheckBox: false,
                onSelected: function (newvalue) {
                    $("#hiddCityId").val(newvalue);
                }
            });
            //BindData("drpProductLine", "hiddProductLineId", "CPXL");
            //BindData("drpCustomerNature", "hiddCustomerNatureId", "KHSX");
            //BindData("drpCustomerClass", "hiddCustomerClassId", "KHDJ");
            //BindData("drpCustomerIndustry", "hiddCustomerIndustryId", "SSHY");
            //BindData("drpRelationShipClass", "hiddRelationShipClassId", "GXDJ");
            //BindData("txtCustomerStatus", "hiddCustomerStatus", "KHZT");
            //$("#drpAfterSaleName").ligerComboBox({
            //    url: 'ajax/customeredit.ashx?action=getaftersalelist',
            //    valueField: '_f_userid',
            //    textField: '_f_username',
            //    autocomplete: true,
            //    onSelected: function (newvalue) {
            //        $("#hiddAfterSaleNameID").val(newvalue);
            //    }
            //});
            //$("#txtSystemStartTime").ligerDateEditor();
            //$("#txtQualityGuaranteeEndTime").ligerDateEditor();
            LoadList();
            //AddHistoryList();
            InitList();
        });
        function toDay() {
            var d = new Date();
            var str = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate();
            return str;
        }
        function BindData(objid, hiddid, param) {
            $("#" + objid).ligerComboBox({
                url: 'ajax/customeredit.ashx?action=getdictionarylist&param=' + param,
                valueField: '_f_dictionaryvalueid',
                textField: '_f_name',
                autocomplete: true,
                onSelected: function (newvalue) {
                    $("#" + hiddid).val(newvalue);
                }
            });
        }
        function SetTreeValue() {
            try {
                treelist.setValue(document.getElementById("hidSeriveDeptParentId").value);
                if (document.getElementById("hidSeriveDeptParentId").value == "" || document.getElementById("hidSeriveDeptParentId").value == "0") {
                    treelist.setText("顶级分类");
                }
            }
            catch (e) {

            }
        }
        var gridlist;
        var singleClick;
        function LoadList() {
            try {
                gridlist = $("#divDataList").ligerGrid({
                    checkbox: false,
                    height: '225',
                    columns: [
                { display: 'Id', name: '_f_manid', hide: '_f_manid', width: '3%' },
                { display: '联系人', name: '_f_name', width: '10%' },
                { display: '性别', name: '_f_sex', width: '7%' },
                { display: '职务', name: '_f_duty', width: '10%' },
                { display: '手机', name: '_f_mobile', width: '10%' },
                { display: '联系电话', name: '_f_telephone', width: '10%' },
                { display: '邮箱', name: '_f_email', width: '10%' },
                { display: 'QQ', name: '_f_qq', width: '10%' },
                { display: '传真', name: '_f_fax', width: '10%' },
                { display: '备注', name: '_f_remark', width: '20%' }
                ],
                    toolbar: {
                        items: [
                    { text: '增加', click: itemclick, icon: 'add' },
                    { line: true },
                    { text: '修改', click: itemclick, icon: 'modify' },
                    { line: true },
                    { text: '删除', click: itemclick, icon: 'delete' }
                    ]
                    },
                    url: 'ajax/person.ashx?action=getpersonlist&cId=' + $("#hiddCustomerId").val(), pageSize: 5, rownumbers: true,
                    onSelectRow: function (data, rowindex, rowobj) {
                        singleClick = data._f_manid;
                    },
                    onDblClickRow: function (data, rowindex, rowobj) {
                        var vheight = $("#form1").height();
                        var vwidth = $("#form1").width() * 0.9;
                        if (vwidth > 800) { vwidth = 800; }
                        if (singleClick == "" || singleClick == undefined) {
                            alert("请选择修改行！");
                        } else {
                            $.ligerDialog.open({
                                url: 'personmodify.aspx?actionFlag=modify&personId=' + singleClick,
                                title: '修改联系人信息', height: vheight, width: vwidth, isResize: true
                            });
                        }
                    }
                });
            }
            catch (e) {
                alert(e.Message);
            }
            gridlist.changePage('first');
        }
        function LoadedFun(e) {
            tabs('#contentTab', 1);
        }
        function itemclick(item) {
            var vheight = $("#form1").height();
            var vwidth = $("#form1").width() * 0.9;
            if (vwidth > 800) { vwidth = 800; }
            if (item.icon == "add") {
                $.ligerDialog.open({
                    url: 'personmodify.aspx?actionFlag=add&cid=' + document.getElementById("hiddCustomerId").value,
                    title: '添加客户联系人信息', height: 380, width: 650, isResize: true
                });
            }
            if (item.icon == "modify") {
                if (singleClick == "" || singleClick == undefined) {
                    alert("请选择修改行！");
                } else {
                    $.ligerDialog.open({
                        url: 'personmodify.aspx?actionFlag=modify&personId=' + singleClick,
                        title: '修改客户联系人信息', height: 380, width: 650, isResize: true
                    });
                }
            }
            if (item.icon == "delete") {
                try {
                    //获取选择的行
                    var rows = gridlist.getSelectedRows();
                    if (rows.length > 0) {
                        $.ligerDialog.confirm('确定要批量删除选择的记录吗？', function (yes) {
                            if (yes) {
                                try {
                                    var arr = new Array();
                                    var i = 0;
                                    for (var i = 0; i < rows.length; i++) {
                                        arr[i] = rows[i]._f_manid;
                                    }
                                    $.post("ajax/person.ashx?action=delete&arrid=" + arr.toString(), function (data) {
                                        if (data == "success") {
                                            $.ligerDialog.success('删除成功');
                                            LoadList();
                                        }
                                        else {
                                            $.ligerDialog.error('删除失败');
                                        }
                                    });
                                }
                                catch (e) {
                                    alert(e.Message);
                                }
                            }
                            else {
                            }
                        });
                    }
                    else {
                        $.ligerDialog.error('没有选择要删除的联系人');
                    }
                }
                catch (e) {
                    $.ligerDialog.error(e.Message);
                }
            }
        }
        function CloseThis() {
            var dialog = frameElement.dialog;
            parent.InitList();
            dialog.close();
        }
        function SaveInfo(res) {
            switch (res) {
                case 'success':
                    $.ligerDialog.success('保存成功', function (yes) { CloseThis(); });
                    break;
                case 'warn':
                    $.ligerDialog.error('保存失败，请确认数据正确性');
                    break;
                case 'error':
                    $.ligerDialog.error('系统错误，请联系开发商');
                    break;
                default:
                    break;
            }
        }
        function validate() {
            lblCustomerName.innerHTML = "*";
            lblCustomerName.style.color = "#717171";
            lblCustomerCode.innerHTML = "*";
            lblCustomerCode.style.color = "#717171";
            if (document.getElementById("txtCustomerName").value == "") {
                lblCustomerName.innerHTML = "请填写客户名";
                lblCustomerName.style.color = "red";
                return false;
            }
            else if (document.getElementById("txtCustomerCode").value == "") {
                lblCustomerCode.innerHTML = "请填写客户编号";
                lblCustomerCode.style.color = "red";
                return false;
            }
            return true;
        }
        function AddHistoryList() {
            var iframe = document.createElement('iframe');
            iframe.id = "iframe";
            iframe.src = "historyserviceinfo.aspx?customerid=" + document.getElementById("hiddCustomerId").value;
            iframe.width = "100%";
            iframe.height = "225px";
            document.getElementById("iframdiv").appendChild(iframe);
            $("#iframe").attr("frameborder", "0");
        }
    </script>
    <script type="text/javascript">
        var gridlist;
        var count = 0;
        var counts = 0;
        var arrayObj = new Array();
        function InitList() {
            count += 1;
            counts = count;
            try {
                gridlist = $("#divHistoryDataList").ligerGrid({
                    height: '225',
                    columns: [
                { display: '操作', isSort: false, width: 100, render: function (rowdata, rowindex, value) {
                    var h = "";
                    if (!rowdata._editing) {
                        h += "<a href='javascript:ShowInfo(" + rowdata._f_workorderid + ")'>详情</a> ";
                    }
                    return h;
                }
                },
                { display: '状态', name: '_f_name', width: 80 },
                { display: '来电类型', name: '_f_typename', width: 80 },
                { display: '制单人', name: '_f_username', width: 80 },
                { display: '新建时间', name: '_f_createdate', width: 150, type: 'date', format: 'yyyy-MM-dd hh:mm:ss' },
                { display: 'Id', name: '_f_workorderid', hide: 'Id', width: 1 },
                { display: '工单记录编号', name: '_f_code', width: 140 },
                { display: '客户名称', name: '_f_customername', minWidth: 120 },
                { display: '来电人', name: '_f_repairmanname', width: 80 },
                { display: '来电人联系方式', name: '_f_repairmanphone', width: 120 }
                //{ display: '客户属性', name: '_f_customernature', width: 80 },
                //{ display: '系统类型', name: '_f_systemtype', width: 120 },
                //{ display: '客户归属部门', name: '_f_servicedept', width: 120 },
                //{ display: '质保到期时间', name: '_f_qualityguaranteeendtime', width: 150, type: 'date', format: 'yyyy-MM-dd hh:mm:ss' }
                ],
                    url: 'ajax/historyserviceinfo.ashx?action=gethistoryservicelist&cid=' + document.getElementById("hiddCustomerId").value, pageSize: 5, rownumbers: true,
                    onDblClickRow: function (data, rowindex, rowobj) {
                        try {
                            if (count > 1) {
                                count -= 1;
                                return;
                            } else {
                                count = counts;
                                ShowInfo(data._f_workorderid);
                            } 
                        }
                        catch (e) {
                            alert(e.Message);
                        }
                    },
                    onSuccess: function (data, grid) {
                        if (count > 1) {
                            count -= 1;
                            return;
                        } else {
                            count = counts;
                            arrayObj = [];
                            for (var i = 0; i < 10; i++) {
                                if (data.Rows[i] != undefined) {
                                    arrayObj.push(data.Rows[i]._f_workorderid);
                                }
                            }
                        }
                    }
                });
            }
            catch (e) {
                alert(e.Message);
            }
            gridlist.changePage('first');
            $("#pageloading").hide();
        }
        function NextWorkOrderId(id, dir) {
            var length = arrayObj.length;
            for (var j = 0; j < length; j++) {
                if (arrayObj[j] == id) {
                    if (dir == "next") {
                        if (parseInt(j + 1) < length)
                            ShowInfo(arrayObj[j + 1]);
                        else
                            $.ligerDialog.warn('没有了');
                    }
                    else if (dir == "pre") {
                        if (j - 1 >= 0)
                            ShowInfo(arrayObj[j - 1]);
                        else
                            $.ligerDialog.warn('没有了');
                    }
                }
            }
        }
        function ShowInfo(id) {
            OpenWindowShow('/workordermanage/workorder/workordershow.aspx?id=' + id, '查看工单详细');
        }
        function OpenWindowShow(Url, Title) {
            var Height = $("#form1").height();
            var Width = $("#form1").width() * 0.9;
            $.ligerDialog.open({ title: Title, url: Url, height: Height, width: Width, isResize: true, modal: true, isResize: true
            });
        }
        function ReLoad() {
            gridlist.reload();
        }
    </script>
</head>
<body class="mainbody" style="margin-top: 0px;">
    <form id="form1" runat="server">
    <div id="contentTab">
        <table class="form_table">
                <col width="95px" />
                <col />
                <col width="95px" />
                <col />
                <col width="95px" />
                <col />
                <tbody>
                    <tr>
                        <th>
                            客户名称：
                        </th>
                        <td colspan="3">
                            <asp:HiddenField ID="hiddCustomerId" runat="server" />
                            <asp:TextBox ID="txtCustomerName" runat="server" CssClass="txtInput normal" Style="width: 300px;"></asp:TextBox><label
                                id="lblCustomerName" for="txtCustomerName">*</label>
                        </td>
                        <th>
                            客户编号：
                        </th>
                        <td>
                            <asp:TextBox ID="txtCustomerCode" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                            <label id="lblCustomerCode" for="txtCustomerCode">*</label>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            所属单位：
                        </th>
                        <td>
                            <div style="float:left"><asp:TextBox ID="drpServiceDept" runat="server"></asp:TextBox></div>
                            <asp:HiddenField ID="hiddSeriveDeptId" runat="server" />
                            <label id="lblServiceDept" for="drpServiceDept">*</label>
                        </td>
                        <th>
                            所属省份：
                        </th>
                        <td>
                            <asp:HiddenField ID="hiddProvinceId" runat="server" />
                            <div style="float:left"><asp:TextBox ID="drpProvince" runat="server"></asp:TextBox></div>
                            <label id="lblProvince" for="drpProvince">*</label>
                        </td>
                        <th>
                        所属市县：
                        </th>
                        <td>
                            <asp:HiddenField ID="hiddCityId" runat="server" />
                            <asp:TextBox ID="drpCity" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            联系电话1：
                        </th>
                        <td>
                            <div style="float:left"><asp:TextBox ID="drpTelephone" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox></div>
                            <asp:HiddenField ID="hiddTelephone" runat="server" />
                        </td>
                        <th>
                            联系电话2：
                        </th>
                        <td>
                            <asp:HiddenField ID="hiddMobile" runat="server" />
                            <div style="float:left"><asp:TextBox ID="drpMobile" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox></div>
                        </td>
                        <th>
                        联系电话3：
                        </th>
                        <td>
                            <asp:HiddenField ID="hiddChargeTelephone" runat="server" />
                            <asp:TextBox ID="drpChargeTelephone" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                        </td>
                    </tr>
                    <%--<tr >
                        <th>
                             产品系列：
                        </th>
                        <td>
                            <asp:HiddenField ID="hiddProductLineId" runat="server" />
                            <asp:TextBox ID="drpProductLine" runat="server"></asp:TextBox>
                        </td>
                        <th>
                           客户属性：
                        </th>
                        <td>
                            <asp:HiddenField ID="hiddCustomerNatureId" runat="server" />
                            <asp:TextBox ID="drpCustomerNature" runat="server"></asp:TextBox>
                        </td>
                        <th>
                           客户等级：
                        </th>
                        <td>
                            <asp:HiddenField ID="hiddCustomerClassId" runat="server" />
                            <asp:TextBox ID="drpCustomerClass" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <th>
                             所属行业：
                        </th>
                        <td>
                            <asp:HiddenField ID="hiddCustomerIndustryId" runat="server" />
                            <asp:TextBox ID="drpCustomerIndustry" runat="server"></asp:TextBox>
                        </td>
                        <th>
                           关系等级：
                        </th>
                        <td>
                            <asp:HiddenField ID="hiddRelationShipClassId" runat="server" />
                            <asp:TextBox ID="drpRelationShipClass" runat="server"></asp:TextBox>
                        </td>
                        <th>
                           售后负责人：
                        </th>
                        <td>
                            <asp:HiddenField ID="hiddAfterSaleNameID" runat="server" />
                            <asp:TextBox ID="drpAfterSaleName" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr style="display:none;">
                        <th>
                            客户传真：
                        </th>
                        <td>
                            <asp:TextBox ID="txtFax" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox><label
                                id="Label1" for="txtName">*</label>
                        </td>
                        <th>
                            客户邮箱：
                        </th>
                        <td>
                            <asp:TextBox ID="txtEmail" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                            <label id="Label2" for="txtUserCode">*</label>
                        </td>
                        <th>
                            办公电话：
                        </th>
                        <td>
                            <asp:TextBox ID="txtTelephone" runat="server" CssClass="txtInput normal"
                                Style="width: 120px;"></asp:TextBox><label id="Label3" for="txtOkPwd">*</label>
                        </td>
                    </tr>
                    <tr style="display:none;">
                        <th>
                            客户地址：
                        </th>
                        <td colspan="3">
                            <asp:TextBox ID="txtAddress" runat="server"  CssClass="txtInput normal"
                                Style="width: 80%;"></asp:TextBox>
                        </td>
                        <th>
                        邮政编码：
                        </th>
                        <td>
                            <asp:TextBox ID="txtPostCode" runat="server" CssClass="txtInput normal"
                                Style="width: 120px;"></asp:TextBox>
                        </td>
                    </tr>
                    <tr style="display:none;">
                        <th>
                             当前版本：
                        </th>
                        <td>
                            <asp:TextBox ID="txtCurrentVersion" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                        </td>
                        <th>
                           开通时间：
                        </th>
                        <td>
                            <asp:TextBox ID="txtSystemStartTime" runat="server" CssClass="txtInput normal" Style="width: 120px;" onfocus="WdatePicker({skin:'whyGreen'})"></asp:TextBox>
                        </td>
                        <th>
                           质保时间：
                        </th>
                        <td>
                            <asp:TextBox ID="txtQualityGuaranteeEndTime" runat="server" CssClass="txtInput normal" Style="width: 120px;" onfocus="WdatePicker({skin:'whyGreen'})"></asp:TextBox>
                        </td>
                    </tr>
                    <tr style="display:none;">
                        <th>
                             系统类型：
                        </th>
                        <td>
                            <asp:TextBox ID="txtSystemType" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                        </td>
                        <th>
                           客户状态：
                        </th>
                        <td>
                            <asp:TextBox ID="txtCustomerStatus" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                            <asp:HiddenField ID="hiddCustomerStatus" runat="server" />
                        </td>
                        <th>
                           设备总数：
                        </th>
                        <td>
                            <asp:TextBox ID="txtDeviceCount" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                        </td>
                    </tr>
                    <tr style="display:none;">
                        <th>
                            乘车方案：
                        </th>
                        <td colspan="5">
                            <textarea
                                id="txtTrackInfo" runat="server" class="txtInput normal" style="width:80%; height:60px;" cols="20" rows="3"></textarea>
                        </td>
                    </tr>--%>
                    <tr >
                        <th>
                            备注信息：
                        </th>
                        <td colspan="5">
                            <textarea
                                id="txtNotes" runat="server" class="txtInput normal" style="width:80%; height:60px;" cols="20" rows="3"></textarea>
                        </td>
                    </tr>
                </tbody>
            </table>
        <div id="divForm" style="display: block;" runat="server">
            
        </div>
        <ul class="tab_nav">
            <li class="selected"><a onclick="tabs('#contentTab',0);" href="javascript:;">联系人信息</a></li>
            <li onclick="ReLoad()"><a onclick="tabs('#contentTab',1);" href="javascript:;">历史服务记录</a></li>
        </ul>
        <div class="tab_con" style="display: block;">
            <div id="divDataList">
            </div>
        </div>
        <div class="tab_con" style="display: none;">
             <%--<div id="iframdiv">
               <iframe id="iframe" frameborder="0" style="width:100%;height:225px;"></iframe>
            </div>--%>
            <div id="divHistoryDataList">
            </div>
        </div>
        <div class="foot_btn_box">
            <asp:Button ID="btnSubmit" runat="server" Text="保&nbsp;&nbsp;存" CssClass="btnSubmit"
                OnClientClick="return validate();" OnClick="btnSubmit_Click" />
        </div>
    </div>
    </form>
</body>
</html>
