<apex:page id="Page" showHeader="false" sidebar="false" Controller="OFSCalendarController" action="{!init}" applyHtmlTag="false" applyBodyTag="false">
<head>
<title>用户日历-周视图</title>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}"/>
<apex:includeScript value="{!URLFOR($Resource.OFSCalendarJs)}"/>
<apex:stylesheet value="{!URLFOR($Resource.OFSCalendarCss)}"/>
<style>
.fc-unthemed th.col_User_none,
.fc-unthemed td.col_User_none {
    width:1px;
    padding: 0;
    border-right-width:0px;
}

</style>
<script type="text/javascript">
    function changedDay(pVal) {
<apex:outputPanel layout="none">
        var baseUrl = '{!ChangeDayUrl}' + '&mk=' + pVal;
</apex:outputPanel>
<apex:outputPanel layout="none">
        var baseUrl = '{!ChangeDayUrl}' + '&md=' + pVal;
</apex:outputPanel>
        var pSearch = encodeURIComponent(j$(escapeVfId('Page:Form:searchText')).val());
        if (pSearch != '') {
            baseUrl += '&search=' + pSearch;
        }
        baseUrl = baseUrl.replace("/apex/PersonalCalendar&", "/apex/PersonalCalendar?")
        document.location.href = baseUrl;
    }
    function showDayAll(pT2) {
        var baseUrl = '';
        if (pT2.checked) {
            baseUrl = '{!ShowDayAllUrl}' + '&t2=all';
        } else {
            baseUrl = '{!ShowDayAllUrl}';
        }
        var pSearch = encodeURIComponent(j$(escapeVfId('Page:Form:searchText')).val());
        if (pSearch != '') {
            baseUrl += '&search=' + pSearch;
        }
        baseUrl = baseUrl.replace("/apex/PersonalCalendar&", "/apex/PersonalCalendar?")
        document.location.href = baseUrl;
    }

    function showFcPopover(eventA, eventStyleClass) {
        var jEvent = j$(escapeVfId(eventA));
        var parentOffset = j$('#calendar').offset();
        var eventChildren = jEvent.children()[0];
//        var jEventTime = jEvent.children('.fc-content').children('.fc-time');
        var jEventTime = j$(eventChildren.children[2]);     // time2
        var jEventTitle = j$(eventChildren.children[1]);
        var jEventTitle2 = j$(eventChildren.children[3]);   // title2
        var jEventWhatId = j$(eventChildren.children[4]);
        var jEventMainVisit = j$(eventChildren.children[5]);
        var jEventPurposeType = j$(eventChildren.children[6]);
        var jEventOpp1 = j$(eventChildren.children[7]);
        var jEventService1 = j$(eventChildren.children[8]);
        j$('#fc-popover').css("top", (jEvent.offset().top - 16 - parentOffset.top)+ 'px').css("left", (jEvent.offset().left - parentOffset.left)+ 'px');
        j$(escapeVfId('fc-popover:container')).removeClass().addClass(eventStyleClass);
        j$(escapeVfId('fc-popover:time')).html(jEventTime.html());
        if (jEventTitle2.text().length > 0) {
            j$(escapeVfId('fc-popover:title')).html(jEventTitle2.html()).show();
        } else if (jEventTitle.text().length > 0) {
            j$(escapeVfId('fc-popover:title')).html(jEventTitle.html()).show();
        } else {
            j$(escapeVfId('fc-popover:title')).hide();
        }
        if (jEventWhatId.text().length > 0) {
            j$(escapeVfId('fc-popover:whatId')).html('{!$ObjectType.Daily_Report__c.Label}：' + jEventWhatId.html()).show();
        } else {
            j$(escapeVfId('fc-popover:whatId')).hide();
        }
        if (jEventMainVisit.text().length > 0) {
            j$(escapeVfId('fc-popover:mainVisit')).html('{!$ObjectType.Event.fields.Main_Visit_Location__c.label}：' + jEventMainVisit.html()).show();
        } else {
            j$(escapeVfId('fc-popover:mainVisit')).html('');
        }
        if (jEventPurposeType.text().length > 0) {
            j$(escapeVfId('fc-popover:purposeType')).html('{!$ObjectType.Event.fields.Purpose_Type__c.label}：' + jEventPurposeType.html()).show();
        } else {
            j$(escapeVfId('fc-popover:purposeType')).html('');
        }
        if (jEventOpp1.text().length > 0) {
            j$(escapeVfId('fc-popover:opp1')).html('{!$Label.Involved}{!$Label.Opportunity}：' + jEventOpp1.html()).show();
        } else {
            j$(escapeVfId('fc-popover:opp1')).html('');
        }
        if (jEventService1.text().length > 0) {
            j$(escapeVfId('fc-popover:service1')).html('{!$Label.Involved}{!$Label.Service_Agreement}：' + jEventService1.html()).show();
        } else {
            j$(escapeVfId('fc-popover:service1')).html('');
        }
        j$('#fc-popover').show();
//    j$('#fc-scroller-container').scroll(function() {
//        j$('#fc-popover').css("top", (jEvent.offset().top - 16 - parentOffset.top)+ 'px').css("left", (jEvent.offset().left - parentOffset.left)+ 'px');
//    });
}

</script>
</head>
<body>
    <apex:form id="Form">
        <apex:outputPanel id="MessageP">
            <apex:pageMessages />
        </apex:outputPanel>
        <div class="calendarHeaderBG calendarHeader">
            <div style="font-size:18px;font-weight: bold; padding:10px 20px;">TITLE</div>
            <div class="dateText line2">
                <apex:outputText value="{0, date, yyyy/MM}">
                    <apex:param value="{!mdDay}" />
                </apex:outputText>
            </div>
            <div class="arrowIcons line2" style="padding-left:20px;">
                <!-- <a href="{!PrevUrl}" title="Prev" class="prev"><img src="/s.gif" alt="Prev" title="Prev" class="prevCalArrow"/></a>
                <a href="{!NextUrl}" title="Next" class="next"><img src="/s.gif" alt="Next" title="Next" class="nextCalArrow"/></a> -->
                <a href="{!PrevUrl}" title="Prev" style="font-weight: bold;font-size:16px;">←</a>&nbsp;&nbsp;&nbsp;
                <a href="{!NextUrl}" title="Next" style="font-weight: bold;font-size:16px;">→</a>
            </div>
        </div>
    </apex:form>
    <div style="clear:both;"></div>
    <div id="calendar" class="fc fc-ltr fc-unthemed">
	   	<apex:outputPanel styleClass="fc-view-container">
<apex:repeat value="{!weekKeyList}" var="weekKey">
	        <div class="fc-view fc-month-view fc-basic-view"><table>
	            <thead>
		            <tr>
		                <td class="fc-widget-header">
		                    <div id="fc-widget-header-div" class="fc-row fc-widget-header"><table><thead>
		                        <tr>
		                            <th class="col_User_none fc-widget-header"></th>
										<apex:variable value="{!0}" var="cnt" />
    <apex:repeat value="{!mdKeyList2Map[weekKey]}" var="md2">
										    <apex:outputPanel layout="none" rendered="{!IF(cnt == 0, false, true)}">
						                            <th class="fc-day-header fc-widget-header{!md2['mdCss']}">
						                            	<table>
						                            		<tr>
						                            			<td style="border:0">{!md2['md2']}</td>
						                            			<td style="width:10%;border:0;"><apex:outputpanel rendered="{!eventCreateFlg}">
									                            	<a style="text-decoration: none;" href="/OFSEventCreate?sub={!sub}&dt={!md2['md']}&accid={!accid}&cid={!cid}&oid={!oid}&mid={!mid}&loc={!loc}&closeFlg={!closeFlg}">+</a>
									                            </apex:outputpanel></td>
						                            		</tr>
						                            	</table>
						                            </th>
										    </apex:outputPanel>
										    <apex:variable value="{!cnt + 1}" var="cnt" />
    </apex:repeat>
		                        </tr>
		                    </thead></table></div>
		                </td>
		            </tr>
	            </thead>
	            <tbody>
					<apex:outputPanel layout="none">
	                <!-- 週 -->
	                <tr>
	                	<td class="fc-widget-content">
	                		<div class="fc-day-grid-container fc-scroller" id="fc-scroller-container">
	                		<div id="fc-scroller" class="fc-day-grid">
    
	                    			<div class="fc-row fc-week fc-widget-content fc-rigid" style="height: {!weekCalendarInfoMap[weekKey].rowspan * 31}px;">
	                        		<div class="fc-bg"><table><tbody>
	                            		<tr>
	        							<apex:variable value="{!0}" var="cnt" />
	   <apex:repeat value="{!weekCalendarInfoMap[weekKey].mdKeyList3}" var="md2">
	            						<apex:outputPanel layout="none" rendered="{!IF(cnt == 0, true, false)}">
	                                		<td class="fc-day fc-widget-content col_User_none{!md2['mdCss']}"></td>
	            						</apex:outputPanel>
	           							<apex:outputPanel layout="none" rendered="{!IF(cnt == 0, false, true)}">
	                                		<td class="fc-day fc-widget-content{!md2['mdCss']}" data-date="{!md2['md']}"></td>
	            						</apex:outputPanel>
	            						<apex:variable value="{!cnt + 1}" var="cnt" />
	   </apex:repeat>
	                            		</tr>
	                        		</tbody></table></div>
	                        		<div class="fc-content-skeleton"><table><tbody>
	        							<apex:outputPanel layout="none" rendered="{!IF(weekCalendarInfoMap[weekKey].maxTr == 0, true, false)}">
	                            			<tr>
	                                			<td class="col_User_none">
	                                			</td>
	                            			</tr>
	        							</apex:outputPanel>
	        							<apex:outputPanel layout="none" rendered="{!IF(weekCalendarInfoMap[weekKey].maxTr == 0, false, true)}">
		            						<apex:variable value="{!1}" var="line" />
	   <apex:repeat value="{!weekCalendarInfoMap[weekKey].rowInfoList}" var="rowInfo">
		                            			<tr>
		                							<apex:outputPanel layout="none" rendered="{!IF(line == 1, true, false)}">
		                                			<td class="col_User_none" rowspan="{!weekCalendarInfoMap[weekKey].rowspan}">
		                                			</td>
		                							</apex:outputPanel>
          <apex:repeat value="{!rowInfo}" var="ev">
				                                	<td class="fc-event-container">
				                    					<apex:outputPanel layout="none" rendered="{!IF(ev['isEvent'] == '1', true, false)}">
															<div class="fc-day-grid-event {!ev['at2Css']}" style="border:0;padding:0;" id="lookup{!ev['evtId']}event" onclick="showFcPopover('lookup{!ev['evtId']}event', '{!ev['at2Css']}');">
							                                    <div class="fc-content forEvtMark {!ev['at2Css']}" id="{!IF(ev['evtMarked'] != '0', 'Mark' + ev['evtMarked'], '')}" style="padding:1px 1px 0px 1px;border-radius:2px;">
							                                        <div class="fc-time" style="{!IF(ev['evtMarked'] != '0', 'background-color:yellow;color:red;', '')}"><apex:outputPanel layout="none" rendered="{!IF(ev['isScheduled'] == 'true', true, false)}"><span style="font-size:8px;">&#10003;</span></apex:outputPanel>{!ev['time']}</div>
							                                        <div class="fc-title">{!ev['title']}</div>
							                                        <div class="fc-time2" style="display:none;"><apex:outputPanel layout="none" rendered="{!IF(ev['isScheduled'] == 'true', true, false)}"><span style="font-size:8px;">&#10003;</span></apex:outputPanel>{!ev['time']}</div>
							                                        <div class="fc-title2" style="display:none;"><apex:outputPanel layout="none" rendered="{!IF(ev['accId'] == 'false', false, true)}"><a href="/{!ev['accId']}" target="WHATIDC_{!ev['accId']}">{!ev['title']}</a></apex:outputPanel></div>
							                                        <div class="fc-whatId" style="display:none;"><apex:outputPanel layout="none" rendered="{!IF(ev['whatId'] == 'false', false, true)}">日报：<a href="/{!ev['whatId']}" target="DR_{!ev['whatId']}">Link</a></apex:outputPanel></div>
							                                        <div class="fc-mainVisit" style="display:none;">{!ev['mainVisit']}</div>
							                                        <div class="fc-purposeType" style="display:none;">{!ev['purposeType']}</div>
							                                        <div class="fc-opp1Id" style="display:none;"><apex:outputPanel layout="none" rendered="{!IF(ev['opp1Id'] == 'false', false, true)}"><a href="/{!ev['opp1Id']}" target="OPP_{!ev['opp1Id']}">{!ev['opp1Name']}</a></apex:outputPanel></div>
							                                        <div class="fc-service1Id" style="display:none;"><apex:outputPanel layout="none" rendered="{!IF(ev['service1Id'] == 'false', false, true)}"><a href="/{!ev['service1Id']}" target="OPP_{!ev['service1Id']}">{!ev['service1Name']}</a></apex:outputPanel></div>
							                                        <div class="fc-searchWord" style="display:none;">{!ev['searchWord']}</div>
							                                    </div>
															</div>
				                   						</apex:outputPanel>
				                               		</td>
		  </apex:repeat>
		                           				</tr>
		                					<apex:variable value="{!line + 1}" var="line" />
        </apex:repeat>
	        							</apex:outputPanel>
	                        		</tbody></table></div>
	                   				</div><!-- /fc-row fc-week fc-widget-content fc-rigid -->

	                		</div></div></td></tr>
					</apex:outputPanel>
	            </tbody>
	        </table></div>
</apex:repeat>
	    </apex:outputPanel>
    </div>
    
<script type="text/javascript">
    window.onresize = windowResize;
    windowResize();
</script>
</body>
</apex:page>