<div ms-controller="CbCalendar">
    <style type="text/css">
        .calendar_top {
            width: 98%;
            height: 40px;
            margin: 20px auto 0 auto;
            padding: 0;
        }

            .calendar_top ul {
                width: 250px;
                height: 40px;
                padding-left: 20px;
            }

                .calendar_top ul li {
                    float: left;
                    width: 100px;
                    background: #fff;
                    height: 39px;
                    line-height: 39px;
                    text-align: center;
                    font-family: Arial,"微软雅黑","宋体";
                    font-size: 16px;
                    cursor: pointer;
                    border-right: 1px solid #ccc;
                    border-top: 1px solid #ccc;
                    border-bottom: 1px solid #ccc;
                }

        .calendar_div {
            width: 98%;
            border: 1px solid #ccc;
            min-height: 600px;
            margin: 0px auto 30px auto;
            background: #fff;
        }

        .calendar_table {
            width: 98%;
            border: 1px solid #ccc;
            min-height: 600px;
            margin: 0px auto 30px auto;
            background: #fff;
            padding: 15px 10px 10px 10px;
        }

        .calselect {
            border-bottom: 1px solid #fff !important;
            font-weight: bold;
        }

        #calendar {
            width: 98%;
            margin: 0 auto 10px auto;
            padding: 15px 0 10px 0;
            font-size: 14px;
            font-family: Arial,"微软雅黑","宋体",Consolas,Verdana;
        }
    </style>

    <!--头部页签-->
    <div class="calendar_top" ms-visible="showCustomer">
        <ul class="calendar_ul">
            <li ms-class-calselect="tab=='cal'" tab="cal" ms-click="changeTab" style="border-left: 1px solid #ccc;">日程</li>
            <li ms-class-calselect="tab=='table'" tab="table" ms-click="changeTab">列表</li>
        </ul>
    </div>
    <!--网格日程-->
    <div class="calendar_div" ms-visible="tab=='cal'">
        <div id='calendar'></div>
    </div>
    <!--表格日程-->
    <div ms-class-calendar_table="showCustomer || action=='salesopp'" ms-visible="tab=='table'">
        <table border="0" align="center" cellpadding="0" cellspacing="0" style="width: 100%;">
            <tbody>
                <tr>
                    <td valign="top">
                        <table width="100%" border="0" cellspacing="1" cellpadding="0" id="tableList" class="tableList bottom10">
                            <thead>
                                <tr class="dobtn">
                                    <td colspan="10" bgcolor="#FFFFFF">
                                        <a href="javascript:void(0)" ms-if="ADD" class="doadd" ms-click="doadd">新增</a>
                                        <a href="javascript:void(0)" ms-if="DELETE" class="doalldel" ms-click="doalldel">批量删除</a>
                                    </td>
                                </tr>
                                <tr class="head">
                                    <td width="3%" align="center" bgcolor="#FFFFFF">
                                        <input type="checkbox" class="checkAll">
                                    </td>
                                    <td width="30%" align="center" bgcolor="#FFFFFF">日程主题
                                    </td>
                                    <td align="center" bgcolor="#FFFFFF">分类
                                    </td>
                                    <td align="center" bgcolor="#FFFFFF" ms-visible="showCustomer">客户名称
                                    </td>
                                    <td align="center" bgcolor="#FFFFFF">执行人
                                    </td>
                                    <td align="center" bgcolor="#FFFFFF">开始时间
                                    </td>
                                    <td align="center" bgcolor="#FFFFFF">结束时间
                                    </td>
                                    <td align="center" bgcolor="#FFFFFF">优先级
                                    </td>
                                    <td align="center" bgcolor="#FFFFFF">完成进度
                                    </td>
                                    <td width="7%" align="center" bgcolor="#FFFFFF">操作
                                    </td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr class="even" ms-repeat-item="pageList">
                                    <td align="center">
                                        <input type="checkbox" name="checkbox" ms-value="{{item.Id}}">
                                    </td>
                                    <td>
                                        <a href="javascript:void(0)" title="查看" ms-click="doview" ms-value="item.Id">
                                            <span style="color: #016B96;" ms-if="item.Completion==100">
                                                <img style="position: relative;" alt="完成" title="完成" src="/Content/Themes/Base/Images/ico/gou.png"><del style="padding-left: 2px;">{{item.Subject|truncate(20,"...")}}</del></span>
                                            <span style="color: #016B96; padding-left: 18px;" ms-if="item.Completion!=100">{{item.Subject|truncate(20,"...")}}</span>
                                        </a>
                                    </td>
                                    <td align="center">
                                        <div style="width: 80px; margin: 0 auto;">
                                            <div style="width: 14px; height: 14px; float: left; margin: 7px 2px 0 0; border: 1px solid #ccc;" ms-css-background="colorWithIndex(item.Color)"></div>
                                            {{item.Category}}
                                        </div>
                                    </td>
                                    <td align="left" ms-visible="showCustomer">
                                        <a href='javascript:void(0)' ms-live-click="doviews" ms-attr-path="'/Customer/DetailCustomer/'+item.CustomId">{{item.CustomName|truncate(15,'.')}}
                                        </a>
                                    </td>
                                    <td align="center">
                                        <a href="javascript:void(0);" ms-text="item.AttendeeNames" ms-widget='userCard' ms-data-userid="item.Attendees"></a>
                                    </td>
                                    <td align="center">{{item.StartTime}}
                                    </td>
                                    <td align="center">
                                        <span ms-if="item.isOver" style="color: Red;">{{item.EndTime}}</span>
                                        <span ms-if="!item.isOver">{{item.EndTime}}</span>
                                    </td>
                                    <td align="center">{{item.PriorityType}}
                                    </td>
                                    <td align="center">{{item.Completion?(item.Completion+'%'):0+'%'}}
                                    </td>
                                    <td align="center">
                                        <a href="javascript:void(0);" class="doview" title="查看" ms-click="doview" ms-value="item.Id"></a>
                                        <a href="javascript:void(0);" class="doedit" title="编辑" ms-click="doedit" ms-if="item.EDIT" ms-value="item.Id"></a>
                                        <a href="javascript:void(0);" class="noedit" title="非常抱歉，您没有编辑的权限" ms-if="!item.EDIT"></a>
                                        <a href="javascript:void(0);" class="dodel" title="删除" ms-click="dodel" ms-if="item.DELETE" ms-value="item.Id" ms-attr-index="$index"></a>
                                        <a href="javascript:void(0);" class="nodelete" title="非常抱歉，您没有删除的权限" ms-if="!item.DELETE"></a>
                                    </td>
                                </tr>
                            </tbody>
                            <tfoot>
                                <tr ms-if="grid1.gridmsg">
                                    <td colspan="10" class="gridmsg">{{grid1.gridmsg|html}}</td>
                                </tr>
                                <tr>
                                    <td colspan="10" ms-widget='paging,upaing,userpaing'></td>
                                </tr>
                            </tfoot>
                        </table>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</div>

<!--左侧两个按钮-->
<noscript type="text/avalon" id="buttonTemplate">
    <span class="fc-button fc-button-agendaDay fc-state-default fc-corner-left" ms-click="mycal">我的日程</span>
    <span class="fc-button fc-button-agendaDay fc-state-default fc-corner-right" ms-click='selectEmp()' id="empName">下属员工</span>
</noscript>

<!--表单-->
<noscript type="text/avalon" id="formTemplate">
    <table width="98%" height="390" cellspacing="0" cellpadding="0" border="0" class="commontable">
        <tbody>
            <tr>
                <th style="width: 90px;">日程主题：</th>
                <td colspan="3">
                    <input type="text" style="width: 600px;" ms-duplex="entity.Subject" />
                    <span class="must">*</span>
                </td>
            </tr>
            <tr>
                <th style="width: 90px;">客户/联系人：</th>
                <td style="width: 375px;">
                    <input type="text" style="width: 96px;" ms-duplex="entity.CustomName" readonly="readonly" ms-visible="showCustomer" />
                    <input type="text" style="width: 90px;" ms-duplex="entity.CustomMan" />
                    <select ms-duplex="contactValue" ms-visible="!showCustomer">
                        <option ms-repeat-item="contactList" ms-value="item.Id">{{item.Name}}</option>
                    </select>
                    <button class="myfbt" type="button" ms-click='selectCustomer()' ms-visible="showCustomer"><i class="customer"></i></button>
                </td>
                <th style="width: 90px;">销售机会：</th>
                <td>
                    <select ms-duplex="entity.SalesId" style="width: 150px;">
                        <option ms-repeat-item="salasList" ms-value="item.Id" ms-text="item.Title"></option>
                    </select>
                </td>
            </tr>
            <tr>
                <th>日程分类：</th>
                <td>
                    <select ms-duplex="entity.CategoryId" id="CategoryId">
                        <option value="">请选择</option>
                        <option ms-repeat-item="entityCategoryList" ms-value="item.Id">{{item.CategoryName}}</option>
                    </select>
                    <!--<button class="myfbt" type="button" id="CategoryManager"><i class="iadduser"></i></button>-->
                    <button class="tMenus" type="button" id="CategoryManager" style="width: 16px; height: 16px; margin-bottom: 5px; border: none;" title="分类管理"></button>
                </td>
                <th>全天事件：</th>
                <td>
                    <label>
                        <input type="checkbox" name="allday" ms-duplex-radio="entity.IsAllDayEvent" ms-value="entity.IsAllDayEvent" />
                        全天事件</label>
                </td>
            </tr>
            <tr>
                <th>执行人：</th>
                <td>
                    <input type="text" readonly="readonly" ms-duplex="entity.AttendeeNames" />
                    <button class="myfbt" type="button" ms-click='selectBelongTo()'><i class="customer"></i></button>
                </td>
                <th>开始时间：</th>
                <td>
                    <input type="text" readonly="readonly" ms-duplex="entity.StartTime" ms-widget='date,birthday,birthdayOpts' style="width: 120px" /></td>
            </tr>
            <tr>
                <th>执行伙伴：</th>
                <td>
                    <input type="text" readonly="readonly" ms-duplex="entity.OtherAttendeeNames" />
                    <button class="myfbt" type="button" ms-click='selectPartner()'><i class="customer"></i></button>
                </td>
                <th>结束时间：</th>
                <td>
                    <input type="text" readonly="readonly" ms-duplex="entity.EndTime" ms-widget='date,birthday,birthdayOpts2' style="width: 120px" /></td>
            </tr>
            <tr>
                <th>优先级：</th>
                <td>
                    <select ms-each-item="youxian" ms-duplex="entity.PriorityType">
                        <option ms-value="item">{{item}}</option>
                    </select>
                </td>
                <th>完成进度：</th>
                <td ms-widget='processbar,hotprocessbar,hotOpts' id="hotOpts"></td>
            </tr>
            <tr>
                <th>描述：</th>
                <td colspan="3">
                    <textarea rows="4" style="width: 600px" ms-duplex="entity.Description"></textarea>
                </td>
            </tr>
            <tr ms-if="showMobile">
                <td>地理位置：</td>
                <td>
                    <a ms-visible="(entity.Latitude && entity.Longitude && entity.Latitude!=0 && entity.Longitude!=0)"
                        href="javascript:void(0);" class="openmap" ms-click="showMap"></a>
                    <span>{{Address}}</span>
                </td>
                <td>行动图片：</td>
                <td>
                    <span ms-visible="!entity.ActionImage">暂无图片</span>
                    <a ms-visible="entity.ActionImage" href="javascript:void(0);" ms-click="openimage" ms-attr-path="entity.ActionImage" class="openimage">点击查看</a>
                </td>
            </tr>
            <tr>
                <th>
                    <span>创建人：</span>
                </th>
                <td width="*" align="left">{{entity.AddBy.FullName}}
                </td>
                <th>
                    <span>创建时间：</span>
                </th>
                <td width="*" align="left">{{entity.AddTime}}
                </td>
            </tr>
    </table>

    <div class="warpCategory" id="warpCategory" style="top: 182px; left: 122px;">
        <!--分类列表-->
        <div class="listCategory" ms-visible="!showAdd">
            <table border="0" cellpadding="0" cellspacing="0" style="margin: 0">
                <thead>
                    <tr style="background: #f6f6f6; height: 28px;">
                        <td colspan="2" style="padding-left: 4px;">
                            <a href="javascript:void(0);" class="doadd" style="background-position: -500px -510px;" ms-click="categoryChange">新增分类</a>
                        </td>
                    </tr>
                    <tr class="trBg">
                        <th style="height: 25px; width: 80%">分类名称</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody ms-each-item="entityCategoryList">
                    <tr>
                        <td style="height: 22px; padding-left: 4px;">
                            <div class="colordiv" ms-css-background="colorWithIndex(item.CategoryColor)"></div>
                            <a href="javascript:void(0);" ms-click="categorySelect" ms-value="item.Id">{{item.CategoryName}}</a>
                        </td>
                        <td style="text-align: center;">
                            <a ms-if="item.Id!=2326142257878887" href="javascript:void(0);" class="doedit" title="编辑" ms-value="item.Id" ms-click="categoryDetail"></a>
                            <a ms-if="item.Id!=2326142257878887" href="javascript:void(0);" class="dodel" title="删除" ms-value="item.Id" ms-attr-index="$index" ms-click="categoryDel"></a>
                            <a ms-if="item.Id==2326142257878887" href="javascript:void(0);" class="noedit" title="系统内置，不得编辑。"></a>
                            <a ms-if="item.Id==2326142257878887" href="javascript:void(0);" class="nodel" title="系统内置，不得删除."></a>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <!--分类表单-->
        <div class="formCategory" ms-visible="showAdd">
            <table border="0" cellpadding="0" cellspacing="0" style="margin: 0; width: 100%;" class="commontable">
                <tbody>
                    <tr class="trBg">
                        <td style="height: 30px; padding-left: 4px;" colspan="2">分类管理</td>
                    </tr>
                    <tr>
                        <th style="height: 50px">分类名称：</th>
                        <td>
                            <input id="categoryName" type="text" ms-duplex="entityCategory.CategoryName" style="width: 180px;">
                            <input id="Hidden1" type="hidden">
                        </td>
                    </tr>
                    <tr>
                        <th style="height: 40px">分类颜色：</th>
                        <td>
                            <div id="colorLayer" class="z"></div>
                            <input id="colorValue" type="hidden" value="" ms-duplex="entityCategory.CategoryColor" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" style="height: 50px; text-align: center;">
                            <input type="button" class="myfbt" value="提交" ms-click="categorySubmit">
                            <input type="button" class="myfbt" value="返回" ms-click="categoryBack">
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" style="text-align: center;"><span id="spanMessage"></span></td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</noscript>

<!--查看-->
<noscript type="text/avalon" id="viewTemplate">
    <table cellspacing="1" cellpadding="0" width="98%" border="0" class="tablecInfo">
        <tr>
            <td width="80px">日程主题：</td>
            <td colspan="3">{{entity.Subject}}</td>
        </tr>
        <tr>
            <td>
                <span>客户/联系人：</span>
            </td>
            <td width="38%" align="left">{{entity.CustomName}} {{entity.CustomMan}}
            </td>
            <td width="80px">
                <span>销售机会：</span>
            </td>
            <td width="*" align="left">{{entity.SalesTitle}}
            </td>
        </tr>
        <tr>
            <td>
                <span>日程分类：</span>
            </td>
            <td width="*" align="left">{{entity.Category}}
            </td>
            <td>
                <span>执行人：</span>
            </td>
            <td width="*" align="left">{{entity.AttendeeNames}}
            </td>
        </tr>
        <tr>
            <td>
                <span>开始时间：</span>
            </td>
            <td width="*" align="left">{{entity.StartTime}}
            </td>
            <td>
                <span>结束时间：</span>
            </td>
            <td width="*" align="left">{{entity.EndTime}}
            </td>
        </tr>
        <tr>
            <td>
                <span>执行伙伴：</span>
            </td>
            <td width="*" align="left" colspan="3">{{entity.OtherAttendeeNames}}
            </td>
        </tr>
        <tr>
            <td>
                <span>优先级：</span>
            </td>
            <td width="*" align="left">{{entity.PriorityType}}
            </td>
            <td>
                <span>完成进度：</span>
            </td>
            <td width="*" align="left">{{entity.Completion}}%
            </td>
        </tr>
        <tr valign="top">
            <td>
                <span>日程描述：</span>
            </td>
            <td width="*" align="left" colspan="3" style="height: 100px;">{{entity.Description}}
            </td>
        </tr>
        <tr ms-if="showMobile">
            <td>地理位置：</td>
            <td>
                <a ms-visible="(entity.Latitude && entity.Longitude && entity.Latitude!=0 && entity.Longitude!=0)"
                    href="javascript:void(0);" class="openmap" ms-click="showMap"></a>
                <span>{{entity.Location}}</span>
            </td>
            <td>行动图片：</td>
            <td>
                <span ms-visible="!entity.ActionImage">暂无图片</span>
                <a ms-visible="entity.ActionImage" class="fancybox openimage" data-fancybox-group="gallery" ms-attr-href="entity.ActionImage">点击查看</a>
            </td>
        </tr>
        <tr>
            <td>
                <span>创建人：</span>
            </td>
            <td width="*" align="left">{{entity.AddBy.FullName}}
            </td>
            <td>
                <span>创建时间：</span>
            </td>
            <td width="*" align="left">{{entity.AddTime}}
            </td>
        </tr>
    </table>
</noscript>
