
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8" %>
<%@ include file="header.jsp" %>

<link rel="stylesheet" type="text/css" href="<%=webpath%>/css/printOut.css"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/css/addDialog.css"/>
<script type="text/javascript" src="<%=webpath%>/js/business/enterprise.js"></script>
<script type="text/javascript" src="<%=webpath%>/js/business/supplier.js"></script>
<script type="text/javascript" src="<%=webpath%>/js/DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="<%=webpath%>/js/jquery.jqprint-0.3.js"></script>
<script src="http://www.jq22.com/jquery/jquery-migrate-1.2.1.min.js"></script>
<!--media=print 这个属性说明可以在打印时有效-->
<!--希望打印时不显示的内容设置class="Noprint"样式-->
<!--希望人为设置分页的位置设置class="PageNext"样式-->
<style>
    table.searchTable td:nth-last-child(1) {
        width: auto;
    }

    table.searchTable td {
        width: auto;
    }
    .search{
        margin:15px 55px 10px 18px;
    }
</style>
<style media="print">
    .Noprint {
        display: none;
    }

    .PageNext {
        page-break-after: always;
    }
    table.searchTable td:nth-last-child(1){
        width:40%;
    }
</style>
<style>
    .dialog_con .datagrid .panel-body {
        border-bottom:1px solid #D3D3D3;
        height:400px;
    }
</style>
<script type="text/javascript">
    function queryess(){
        var queryParams = {};
        var name = $("#name").val();
        var id=$("#userID").val();
        queryParams['name'] = name;
        queryParams['id'] = id;
        var url="/supplier/getContractInfo.do";
        queryCouponRechargehistoryList(url,queryParams);
    }
    function search(){
        var queryParams = {};
        var names = $("#names").val();
        var userIDs=$("#userIDs").val();
        queryParams['id'] = userIDs;
        queryParams['name'] = names;
        var url="/supplier/getDestination.do";
        queryDestinationList(url,queryParams);
    }
    function get(){
        var queryParams = {};
        var names = $("#enterpriseName").val();
        var id = $("#user").val();
        queryParams['name'] = names;
        queryParams['id'] = id;
        var url="/supplier/getEnterpriseInfo.do";
        querySupplierList
        (url,queryParams);
    }
    function querys() {
        var queryParams = {};
        var frame_code = $("#frame_code").val();
        var caseCode = $("#caseCode").val();
        var role = $("#rescueState").val();
        var username = $("#username").val();
        var state = parseInt(${state});
        queryParams['state'] = state;
        queryParams['phone'] = frame_code;
        queryParams['name'] = caseCode;
        queryParams['role'] = role;
        queryParams['username'] = username;
        queryCouponList("<%=path%>/user/getUserInfo.do", queryParams,
            "<%=path%>/casesInfo/caseDetailList.do?state=" + state + "&code=", state);;

    }
    function query() {
        var queryParams = {};
        var frame_code = $("#frame_code").val();
        var caseCode = $("#caseCode").val();
        var role = $("#rescueState").val();
        var username = $("#username").val();
        if((username == null || username == '') && (frame_code == null || frame_code == '') && (caseCode == null || caseCode == '') &&  role == ''){
            alert("查询条件不能为空");
            return;
        }
        var state = parseInt(${state});
        queryParams['state'] = state;
        queryParams['phone'] = frame_code;
        queryParams['name'] = caseCode;
        queryParams['role'] = role;
        queryParams['username'] = username;
        queryCouponList("<%=path%>/user/getUserInfo.do", queryParams,
            "<%=path%>/casesInfo/caseDetailList.do?state=" + state + "&code=", state);;

    }
    function clearVal() {
        $("#frame_code").val("");
        $("#username").val("");
        $("#caseCode").val("");
        $("#rescueState").val("");
    }

    function clearValState1() {
        $("#name").val("");
    }
    function clearValState2() {
        $("#names").val("");
    }
    function clearValState3() {
        $("#enterpriseName").val("");
    }
    function cancel(){
        $("#consume_dialog").hide();
    }
    function cancels(){
        $("#consumes_dialog").hide();
    }
    function off(){
        $("#wrap_dialog").hide();
    }
    $(window).ready(function () {
        $("#cc").attr('value',"--请查看--");
        $("#enterprise").attr('value',"--请查看--");
        $("#destination").attr('value',"--请查看--");
        var frame_code = $("#frame_code").val();
        var caseCode = $("#caseCode").val();
        var username = $("#username").val();
        var role = $("#rescueState").val();
        var queryParams = {};
        queryParams['phone'] = frame_code;
        queryParams['name'] = caseCode;
        queryParams['role'] = role;
        queryParams['username'] = username;
        var state = parseInt(${state});
        queryCouponList("<%=path%>/user/getUserInfo.do", queryParams,
                "<%=path%>/casesInfo/caseDetailList.do?state=" + state + "&code=", state);

    })
    function submit() {
           var userID=$("#userID").val();
           var checkeds=$('#datatable2').datagrid("getChecked");
           if(checkeds.length>0) {
               var ids = [];
               for (var i = 0; i < checkeds.length; i++) {
                   ids.push(checkeds[i].ID);
               }
            }else{
               alert("未指定合同");
               return;
           }
            $.ajax({
            cache: true,
            type: "POST",
            url:"/supplier/insertContract.do?ids="+ids+"&id="+userID,
            async: false,
            error: function (request) {
                alert("Connection error");
            },
            success: function (data) {
                if (data.flag == 1) {
                    $("#consume_dialog").hide();
                } else {
                    alert(data.msg);
                }
            }
        });
    }
    function save() {
        var userID=$("#userIDs").val();
        var checkeds=$('#datatable3').datagrid("getChecked");
        if(checkeds.length>0) {
            var ids = [];
            for (var i = 0; i < checkeds.length; i++) {
                ids.push(checkeds[i].ID);
            }
        }else{
            alert("未指定目的地");
            return;
        }
        $.ajax({
            cache: true,
            type: "POST",
            url:"/supplier/insertDestination.do?ids="+ids+"&id="+userID,
            async: false,
            error: function (request) {
                alert("Connection error");
            },
            success: function (data) {
                if (data.flag == 1) {
                    $("#consumes_dialog").hide();
                } else {
                    alert(data.msg);
                }
            }
        });
    }
    function saves() {
        var userID=$("#user").val();
        var checkeds=$('#datatable4').datagrid("getChecked");
        if(checkeds.length>0) {
            var ids = [];
            for (var i = 0; i < checkeds.length; i++) {
                ids.push(checkeds[i].ID);
            }
        }else{
            alert("未选择服务商");
            return;
        }
        $.ajax({
            cache: true,
            type: "POST",
            url:"/supplier/insertEnterprise.do?ids="+ids+"&id="+userID,
            async: false,
            error: function (request) {
                alert("Connection error");
            },
            success: function (data) {
                if (data.flag == 1) {
                    $("#wrap_dialog").hide();
                } else {
                    alert(data.msg);
                }
            }
        });
    }
    function remove() {
        var userID=$("#user").val();
        var checked = $('#enterprise').combobox('getValues');
        var ids=[];
        for(var i=0;i<checked.length;i++){
           if(i != 0){
               ids.push(checked[i]);
           }
        }
        $.ajax({
            cache: true,
            type: "POST",
            url:"/supplier/deleteEnterprise.do?ids="+ids+"&id="+userID,
            async: false,
            error: function (request) {
                alert("Connection error");
            },
            success: function (data) {
                if (data.flag == 1) {
                    $("#wrap_dialog").hide();
                } else {
                    alert(data.msg);
                }
            }
        });
    }
    function removes() {
        var userID=$("#userIDs").val();
        var checked = $('#destination').combobox('getValues');
        var ids=[];
        for(var i=0;i<checked.length;i++){
            if(i != 0){
                ids.push(checked[i]);
            }
        }
        $.ajax({
            cache: true,
            type: "POST",
            url:"/supplier/deleteDestination.do?ids="+ids+"&id="+userID,
            async: false,
            error: function (request) {
                alert("Connection error");
            },
            success: function (data) {
                if (data.flag == 1) {
                    $("#consumes_dialog").hide();
                } else {
                    alert(data.msg);
                }
            }
        });
    }
    function removees() {
        var userID=$("#userID").val();
        var checked = $('#cc').combobox('getValues');
        var ids=[];
        for(var i=0;i<checked.length;i++){
            if(i != 0){
                ids.push(checked[i]);
            }
        }
        $.ajax({
            cache: true,
            type: "POST",
            url:"/supplier/deleteContract.do?ids="+ids+"&id="+userID,
            async: false,
            error: function (request) {
                alert("Connection error");
            },
            success: function (data) {
                if (data.flag == 1) {
                    $("#consume_dialog").hide();
                } else {
                    alert(data.msg);
                }
            }
        });
    }
</script>
<input type="hidden" id="paths" value="<%=path%>"/>
<!--希望打印时不显示的内容设置class="Noprint"样式-->
<!--IE内置打印控件IEWebBrowser-->
<OBJECT id="wb" height="0" width="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" name="wb"></OBJECT>
<div id="main" class="Noprint">
    <div class="search">
            <table class="searchTable">
                <tbody>
                <tr>
                    <td style="position:relative;">
                        <span class="inputTitle"> 姓名:</span>
                        <span id="input34Wrap">
                    <input id="caseCode" name="endSubmitDate"
                           type="text" value=""
                           class="mc-ipt-text hasDatepicker"
                           style=""/><span class="mc-ipt"
                                           style="width:90%;"><span
                                id="input33Tip" class="mc-ipt-tip-query"
                                style="font-size: 11px; line-height: 40px; height: 40px;"></span></span></span></td>
                    <td style="position:relative;">
                        <span class="inputTitle"> 登录名:</span>
                        <span id="input34Wrap">
                    <input id="username" name="endSubmitDate"
                           type="text" value=""
                           class="mc-ipt-text hasDatepicker"
                           style=""/><span class="mc-ipt"
                                           style="width:90%;"><span
                                id="input33Tip" class="mc-ipt-tip-query"
                                style="font-size: 11px; line-height: 40px; height: 40px;"></span></span></span></td>
                    <!-- <td><b><font><font>VIN码</font></font></b></td> -->
                    <td style="position:relative;">
                        <span class="inputTitle"> 手机号: </span>
                        <span id="input34Wrap">
                    <input id="frame_code" name="endSubmitDate"
                           type="text" value=""
                           class="mc-ipt-text hasDatepicker"
                           style=""/><span class="mc-ipt"
                                           s tyle="width:90%;"><span
                                id="input33Tip" class="mc-ipt-tip-query"
                                style="font-size: 11px; line-height: 40px; height: 40px;"></span></span></span></td>
                    <td style="position:relative;">
                        <span class="inputTitle"> 角色: </span>
                        <span id="input34Wrap">
                     <select id="rescueState" style="width:183px"
                             class="selector" tabindex="-1" aria-hidden="true">
                                    <option value="" selected="selected" >---请选择---</option>
                                     <c:forEach items="${roles}" var="r">
                                         <option value="${r.id}">${r.name}</option>
                                     </c:forEach>
                            </select><span style="width:90%;"><span
                                id="input33Tip" class="mc-ipt-tip-query"
                                style="font-size: 11px; line-height: 40px; height: 40px;"></span></span></span></td>

                    <!-- <td><b><font><font>车牌号</font></font></b></td> -->
                    <td>
                        <button class="t-button searchBtn" id="CaseInfoList2btnCtClear" type="button"
                                onclick="clearVal();"><img class="searchIcon" src="../images/clear.png">清空
                        </button>
                        <button class="t-button searchBtn" style="margin-right:10px;" id="CaseInfoList2btnCtSearch"
                                type="button" onclick="query();"><img class="searchIcon" src="../images/search.png">搜索
                        </button>
                        <!--
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <button class="t-button" id="CaseInfoList2btnCtSearch" type="button" onclick="query();">
                                <font><font>
                                    &nbsp;&nbsp;搜 索&nbsp;&nbsp;</font></font></button> -->
                    </td>

                </tr>
                </tbody>
            </table>
    </div>
    <table id="datatable"></table>
</div>
<div class="order_undo"  id="consume_dialog" style="display: none;" >
    <div class="dialog_default">
        <div class="dialog_title">
            合同信息
        </div>
        <div class="dialog_con">
            <div class="clearfix" style="width:100%">
                <div class="search">
                    <table class="searchTable">
                        <tbody>
                        <tr>
                            <td style="position:relative;">名称: <span id="inputnameWrap">
							<input id="name" name="endSubmitDate" type="text" value=""
                                   class="mc-ipt-text hasDatepicker" style="width:156px"/> <span
                                    class="mc-ipt" style="width:215px;"> <span id="input33Tip"
                                                                               class="mc-ipt-tip-query"
                                                                               style="font-size: 11px; line-height: 20px; height: 20px;">
									<font></td>
                            <td style="position:relative;">
                                <span class="inputTitle"> 已指定合同: </span>
                                <span id="input34Wrap">
                            <input id="cc" name="id" style="width:200px;height:32px">
                                        </span></span></span></td>
                            <td>
                                <button class="t-button searchBtn" id="CaseInfoList2btnCtClear" type="button"
                                        onclick="clearValState1();"><img class="searchIcon" src="../images/clear.png">清空
                                </button>
                                <button class="t-button searchBtn" style="margin-right:10px;" id="CaseInfoList2btnCtSearch"
                                        type="button" onclick="queryess();"><img class="searchIcon" src="../images/search.png">搜索
                                </button>
                                <button class="t-button searchBtn" id="CaseInfoList2btnCtClear" type="button"
                                        onclick="removees();"><img class="searchIcon">删除已指定合同
                                </button>
                            </td>

                        </tr>
                        </tbody>
                    </table>
                </div>
                <input id="userID"  type="hidden"/>
                <table id="datatable2"></table>
            </div>
            <div class="confirm_cancel clearfix">
                <a href="javascript:void(0);" class="btn2"
                   style="margin-right:20px;margin-left:40px;margin-bottom: 20px" onclick="submit();">提&nbsp;&nbsp;交</a>
                <a href="javascript:void(0);" class="btn2"
                   style="margin-right:20px;margin-left:40px" onclick="cancel()">取&nbsp;&nbsp;消</a>
            </div>
        </div>
    </div>
</div>
<div class="order_undo"  id="consumes_dialog" style="display: none;" >
    <div class="dialog_default">
        <div class="dialog_title">
            目的地信息
        </div>
        <div class="dialog_con">
            <div class="clearfix" style="width:100%">
                <div class="search">
                    <table class="searchTable">
                        <tbody>
                        <tr>
                            <td style="position:relative;">名称: <span id="inputnameWrap">
							<input id="names" name="endSubmitDate" type="text" value=""
                                   class="mc-ipt-text hasDatepicker" style="width:156px"/> <span
                                    class="mc-ipt" style="width:215px;"> <span id="input33Tip"
                                                                               class="mc-ipt-tip-query"
                                                                               style="font-size: 11px; line-height: 20px; height: 20px;">
									<font></td>
                            <td style="position:relative;">
                                 已指定目的地:
                                <span id="input34Wrap">
                            <input id="destination" name="id" style="width:200px;height:32px">
                                        </span></span></span></td>
                            <td>
                                <button class="t-button searchBtn" id="CaseInfoList2btnCtClear" type="button"
                                        onclick="clearValState2();"><img class="searchIcon" src="../images/clear.png">清空
                                </button>
                                <button class="t-button searchBtn" style="margin-right:10px;" id="CaseInfoList2btnCtSearch"
                                        type="button" onclick="search();"><img class="searchIcon" src="../images/search.png">搜索
                                </button>
                                <button class="t-button searchBtn" id="CaseInfoList2btnCtClear" type="button"
                                        onclick="removes();"><img class="searchIcon">删除已指定目的地
                                </button>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
                <input id="userIDs"  type="hidden"/>
                <table id="datatable3"></table>
            </div>
            <div class="confirm_cancel clearfix">
                <a href="javascript:void(0);" class="btn2"
                   style="margin-right:20px;margin-left:40px;margin-bottom: 20px" onclick="save();">提&nbsp;&nbsp;交</a>
                <a href="javascript:void(0);" class="btn2"
                   style="margin-right:20px;margin-left:40px" onclick="cancels()">取&nbsp;&nbsp;消</a>
            </div>
        </div>
    </div>
</div>
<div class="order_undo"  id="wrap_dialog" style="display: none;" >
    <div class="dialog_default">
        <div class="dialog_title">
            供应商信息
        </div>
        <div class="dialog_con">
            <div class="clearfix" style="width:100%">
                <div class="search">
                    <table class="searchTable">
                        <tbody>
                        <tr>
                            <td style="position:relative;">名称: <span id="inputnameWrap">
							<input id="enterpriseName" name="endSubmitDate" type="text" value=""
                                   class="mc-ipt-text hasDatepicker" style="width:156px"/> <span
                                    class="mc-ipt" style="width:215px;"> <span id="input33Tip"
                                                                               class="mc-ipt-tip-query"
                                                                               style="font-size: 11px; line-height: 20px; height: 20px;">
									<font></td>
                            <td style="position:relative;">
                                 已指定供应商:
                                <span id="input34Wrap">
                            <input id="enterprise" name="id" style="width:200px;height:32px"/>
                                        </span></span></span></td>
                            <td>
                                <button class="t-button searchBtn" id="CaseInfoList2btnCtClear" type="button"
                                        onclick="clearValState3();"><img class="searchIcon" src="../images/clear.png">清空
                                </button>
                                <button class="t-button searchBtn" style="margin-right:10px;" id="CaseInfoList2btnCtSearch"
                                        type="button" onclick="get();"><img class="searchIcon" src="../images/search.png">搜索
                                </button>
                                <button class="t-button searchBtn" id="CaseInfoList2btnCtClear" type="button"
                                        onclick="remove();"><img class="searchIcon">删除已指定供应商
                                </button>
                            </td>

                        </tr>
                        </tbody>
                    </table>
                </div>
                <input id="user"  type="hidden"/>
                <table id="datatable4"></table>
            </div>
            <div class="confirm_cancel clearfix">
                <a href="javascript:void(0);" class="btn2"
                   style="margin-right:20px;margin-left:40px;margin-bottom: 20px" onclick="saves();">提&nbsp;&nbsp;交</a>
                <a href="javascript:void(0);" class="btn2"
                   style="margin-right:20px;margin-left:40px" onclick="off()">取&nbsp;&nbsp;消</a>
            </div>
        </div>
    </div>
</div>
<%@ include file="footer.jsp" %>