<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
    String basePath = request.getContextPath();
%>
<div class="table-responsive">
    <table class="table table-striped table-bordered table-hover " >
        <thead>
        <tr>
            <th>合同名称</th>
            <th>合同编号</th>
            <th>合作方名称</th>
            <th>联系人</th>
            <th>联系信息</th>
            <th>合同金额</th>
            <th>使用期限</th>
            <th>状态</th>
            <th class="hidden-print">操 作</th>
        </tr>
        </thead>
        <tbody>
        <c:choose>
            <c:when test="${list!=null}">
                <c:forEach items="${list}" var="item" >
                    <tr>
                        <td><a href="javascript:window.location.href='<%=basePath%>/admin/contract/view.htm/${item.id}'">${item.contractName}</a></td>
                        <td>${item.contractNumber}</td>
                        <td>${item.partnerName}</td>

                            <td>${item.contact}</td>
                            <td>${item.contactInfo}</td>
                            <td>${item.contractAmount}</td>

                            <td><fmt:formatDate value="${item.effectiveTime}" pattern="yyyy-MM-dd"/>
                            -
                                <fmt:formatDate value="${item.expiredTime}" pattern="yyyy-MM-dd"/></td>
                            <td>${item.contractState}</td>
                            <td class="btn-table hidden-print">
                                <c:if test="${item.contractState eq weishengxiao}">
                                    <button  class="btn btn-sm btn-primary m-r-sm" onclick="editButton(${item.id})"><i class="fa fa-edit"></i>编辑</button>
                                    <button  class="btn btn-sm btn-danger" onclick="deleteContract(${item.id})"><i class="fa fa-trash-o"></i>删除</button>
                                </c:if>
                                <c:if test="${item.contractState eq yishengxiao}">
                                    <button  class="btn btn-sm btn-warning m-r-sm" onclick="stop(${item.id})"><i class="fa fa-edit"></i>终止</button>
                                </c:if>
                                <c:if test="${item.contractState eq yiguoqi}">--</c:if>
                            </td>
                    </tr>
                </c:forEach>
            </c:when>
            <c:otherwise>
                <tr>
                    <td colspan="4">无数据</td>
                </tr>
            </c:otherwise>
        </c:choose>
        </tbody>
    </table>
</div>
<jsp:include page="../../../common/admin/pager.jsp">
    <jsp:param name="pageNo" value="${pager.pageNo}"/>
    <jsp:param name="pageSize" value="${pager.pageSize}"/>
    <jsp:param name="total" value="${pager.total}"/>
</jsp:include>
<script type="text/javascript">
    function stop(id) {
        $.contractStop({ func: $.ajaxGetRefresh, funcArgs: { ajaxGetOptions: { url: "<%=basePath%>/admin/contract/contractStop.action/" + id } } });
    }

    function editButton(id) {
        window.location.href = "<%=basePath%>/admin/contract/edit.htm/"+id ;
    }

    function deleteContract(id) {
        $.delWithConfirm({ func: $.ajaxGetRefresh, funcArgs: { ajaxGetOptions: { url: "<%=basePath%>/admin/contract/contractDelete.action/" + id } } });
    }
</script>