<%
'include/jschedule/cal-functions.asp (Last Update 2001.02.19)
'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
'   ESMPRO/JMSS WebClient (JSchedule) Version 6.0
'   Copyright (C) NEC Corporation/NEC Soft, Ltd. 2001
'   All rights reserved
'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
'**Start Encode**

    aryWeekDayName  = Array(WeekDayName(1,True),WeekDayName(2,True),WeekDayName(3,True),WeekDayName(4,True),WeekDayName(5,True),WeekDayName(6,True),WeekDayName(7,True))
    aryMonthDays    = Array(31,28,31,30,31,30,31,31,30,31,30,31)

    '********************************************************************
    '@́FGetFitDate(nYear,nMonth)
    '@@\FKꂽN̎擾
    '@FnYear,nMonth
    '@ߒlFKꂽDate^t
    '@lF2000.1-2019.12 ̊Ԃ݂̂̕\
    '@@@FsȏꍇAKꂽt܂̓T[o̓tԂ
    '@@@Ft1ɕԂ
    '********************************************************************
    Function GetFitDate(nYear,nMonth)

        Dim datTmp

        If Len(nYear) = 0 Or Len(nMonth) = 0 Then
            '*** T[ot̎擾 ***
            datTmp = Session("jsch").JSchServerDate(Session("jserver"))
            nYear  = Year(datTmp)
            nMonth = Month(datTmp)
        End If

        If nYear >= 2019 And nMonth > 12 Then
            'Nߑ
            nYear = 2019
            nMonth= 12
        ElseIf nYear =< 2000 And nMonth =< 0 Then
            'Nߏ
            nYear = 2000
            nMonth= 1
        End If

        GetFitDate = DateSerial(nYear,nMonth,1)

    End Function


    '********************************************************************
    '@́FMakeYearMonthList(nYear,nMonth)
    '@@\FNhbv_EXg̍쐬(J_[p)
    '@FnYear(N), nMonthi茎j
    '@ߒlFHTMLhbv_EXg "<TABLE>`</TABLE>"
    '@lFiNj̃`FbN͍sĂȂ
    '@@@F͈́F2000.01 - 2019.12
    '********************************************************************
    Function MakeYearMonthList(nYear,nMonth)

        strBuff = ""

        '*** N ***
        strBuff = "<SELECT size=1 name=nSelYear OnChange='javascript:onChange_YM();'>"
        For i=2000 To 2019
            strBuff = strBuff & "<OPTION value=" & Cstr(i)
            If i = nYear Then
                strBuff = strBuff & " selected"
            End If
            strBuff = strBuff & ">"
            strBuff = strBuff & Cstr(i)
        Next
        strBuff = strBuff & "</SELECT>N "

        '***  ***
        strBuff = strBuff & "<SELECT size=1 name=nSelMonth OnChange='javascript:onChange_YM();'>"
        For i=1 To 12
            strBuff = strBuff & "<OPTION value=" & Cstr(i)
            If i = nMonth Then
                strBuff = strBuff & " selected"
            End If
            strBuff = strBuff & ">"
            strBuff = strBuff & Cstr(i)
        Next
        strBuff = strBuff & "</SELECT>"

        MakeYearMonthList = strBuff

    End Function


    '********************************************************************
    '@́FMakeCalTable(nYear, nMonth, objJsch, datServerDate)
    '@@\FJ_[̍쐬
    '@FnYear          \Niintj
    '@@@FnMonth         \iintj
    '@@@FobjJsch        jschedule IuWFNg
    '@@@FdatServerDate  T[oݓiDatej
    '@ߒlFHTMLe[u "<TABLE>`</TABLE>"
    '@lF
    '@@@FtNbNJavaScript:popUpDateProp()
    '********************************************************************
    Function MakeCalTable(nYear,nMonth,objJsch,datServerDate)

        '*** l ***
        bFuture         = False 'tOiȂׂDate^̌vZj
        strBuff         = ""
        nFirstDayOfWeek = WeekDay(DateSerial(nYear,nMonth,1)) -1
        'u[NvH
        If ( ((nYear Mod 4 = 0) And (nYear Mod 100 <> 0)) Or (nYear Mod 400 = 0) ) Then
            aryMonthDays(1) = 29
        End If

        '*** table header (year and month) ***
        strBuff = "<TABLE border='0' align=center cellspacing='1' cellpadding='1'>" & _
                  "<TR align=center>" & _
                  "<TD colspan=7 align=center nowrap>" & _
                  "<INPUT type='button' value='&lt;' name='prevMonth' onClick='javascript:onClick_prevMonth()'> "
        '* DropDownList *
        strBuff = strBuff & MakeYearMonthList(nYear,nMonth)

        '* [<][>] bottuns *
        strBuff = strBuff & " <INPUT type='button' value='&gt;' name='nextMonth' onClick='javascript:onClick_nextMonth()'>" & _
                  "</TD></TR>"

        '*** j\(T̋x~擾͌ݕs) ***
        strBuff = strBuff & "<TR>"
        For i = 0 To 6
            strBuff = strBuff & "<TD nowrap align='center' valign='center' bgcolor='#FFCC99' width='22'>"
            strBuff = strBuff & "<A href='javascript:popUpWdayProp(" & Cstr(i) & ");'>"
            strBuff = strBuff & CStr(aryWeekDayName(i))
            strBuff = strBuff &  "</A></TD>"
        Next
        strBuff = strBuff & "</TR>"

        '*** \ ***
        For nStart = 1 - nFirstDayOfWeek To 30 Step 7

            strBuff = strBuff & vbCrLF & "<TR align=center>"

            For i = nStart To nStart + 6 Step 1

                If ((i > 0) And (i <= aryMonthDays(nMonth -1))) Then

                    If bFuture = False Then
                        '*** 擾( nDiff>0AnDiff<0ߋAnDiff=0) ***
                        nDiff = DateDiff("d", CDate(datServerDate), DateSerial(nYear,nMonth,i))
                    End If

                    '*** wiF̌ ***
                    strBuff = strBuff & "<TD ALIGN='right' BGCOLOR='#"
                    If nDiff > 0 Then
                        strBuff = strBuff & "FFFFCC" '
                    ElseIf nDiff < 0 Then
                        strBuff = strBuff & "C0C0C0" 'ߋ
                    Else
                        strBuff = strBuff & "00FFFF" '
                    End If
                    strBuff = strBuff & "'>"

                    '*** Nwb_(݈ȍ~) ***
                    If nDiff >= 0 Then
                        strBuff = strBuff & "<A href='javascript:popUpDateProp(" & CStr(i) & ");'>"
                    End If

                    '*** x~擾 ***
                    If objJsch.JSchIsHoliday(CLng(nYear), CLng(nMonth), CLng(i)) = 1 Then
                        'x~
                        strBuff = strBuff & "<FONT color='#FF0000'>" & CStr(i) & "</FONT>"
                    Else
                        'ʏ
                        strBuff = strBuff & CStr(i)
                    End If

                    '*** Ntb_(݈ȍ~) ***
                    If nDiff >= 0 Then
                        strBuff = strBuff & "</A>"
                        bFuture = True
                        nDiff = 1
                    End If
                Else
                    '(tȂ)
                    strBuff = strBuff & "<TD bgcolor='#CCCCCC'><BR>"
                End If
                strBuff = strBuff & "</TD>"
            Next
            strBuff = strBuff & "</TR>"
        Next

        strBuff = strBuff & "</TABLE>"

        MakeCalTable = strBuff

    End Function
%>
