<!--#include file="../../include/jschedule/schedule.asp"-->
<%
 'jschedule/schedule/propSch.asp (Last Update 2001.05.08)
'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
'   ESMPRO/JMSS WebClient (JSchedule) Version 6.0
'   Copyright (C) NEC Corporation/NEC Soft, Ltd. 2001
'   All rights reserved
'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
'**Start Encode**
    Dim obj
    Dim obj2

    '*** ʕϐ ***
    Dim nSchID      'XPW[ID
    Dim nFreqID     '
    Dim nYear       '\N(K{)
    Dim nMonth      '\(K{)
    Dim nMode       'ҏW[h
    Dim datTmp      'tvZp
    Dim nSchDayCnt  'XPW[̐
    Dim szRet       '|bvAbvEBhE̖߂l

    nSchID = Session("nSchID")

    '*** p[^̎擾 ***
    nMode       = Request.QueryString("nMode")
    szRet       = Request.QueryString("szRet")

    nFreqID     = Request.QueryString("nFreqID")
    nYear       = Request.QueryString("nYear")
    nMonth      = Request.QueryString("nMonth")
    nDay        = Request.QueryString("nDay")
    nWDay       = Request.QueryString("nWday")
    nShiftType  = Request.QueryString("nShiftType")
    nShiftDay   = Request.QueryString("nShiftDay")
    nShiftFlag  = Request.QueryString("nShiftFlag")
    nHour       = Request.QueryString("nHour")
    nMinute     = Request.QueryString("nMinute")
    nSecond     = Request.QueryString("nSecond")
    szWeek      = Request.QueryString("szWeek")

    '*** ҏW[hɂ鏈 ***
    Select Case UCase(szRet)
        Case "OK"
            If Len(nFreqID) > 0 Then
                Set obj =Session("jsch").SchMasterData.FreqDayPage
                If Len(nWDay) > 0 Then
                    obj.DateType = 1
                Else
                    obj.DateType = 0
                End If

                obj.FreqID    = nFreqID
                obj.WDay      = nWDay
                obj.Week      = szWeek
                obj.Year      = nYear
                obj.Month     = nMonth
                obj.Day       = nDay
                obj.ShiftType = nShiftType
                obj.ShiftDay  = nShiftDay
                obj.ShiftFlag = CLng(nShiftFlag)
                obj.Hour      = nHour
                obj.Minute    = nMinute
                obj.Second    = nSecond

                If nFreqID = 0 Then
                    'ǉ
                    Session("jsch").JSchMasterFreqAdd CLng(nSchID), CLng(0), Null
                Else
                    'ύX
                    Session("jsch").JSchMasterFreqUpdate CLng(nSchID), CLng(nFreqID), Null
                End If
            End If

        Case "CANCEL"
             'Session("jsch").JSchMasterFreqCancel Session("jserver")', CLng(nSchID), CLng(nFreqID), Null
             If nFreqID = 0 Then
                 Session("jsch").JSchMasterFreqDelete CLng(nSchID), CLng(nFreqID), Null
             End If
        Case "DEL"
'            If nFreqID = 0 Then
                'LZ
'            ElseIf Len(nFreqID) > 0 Then
                '폜
                Session("jsch").JSchMasterFreqDelete CLng(nSchID), CLng(nFreqID), Null
'            End If
    End Select

    '*** So^HwH ***
    If Session("nDispMode") = 1 Then
        Set obj = Session("jsch").SchDateData.SchPage
    Else
        Set obj = Session("jsch").SchMasterData.SchPage
    End If

    '*** Ԃ̎擾 ****
    Dim nIndex
    Dim datBegin
    Dim datEnd
    Dim nBeginYear
    Dim nBeginMonth
    Dim nBeginDay
    Dim nEndYear
    Dim nEndMonth
    Dim nEndDay

    If Session("nEditMode") = 0 Then
        '[Qƃ[h]p
        If obj.Begin = 0 Then
            nBeginYear = "----"
            nBeginMonth= "--"
            nBeginDay  = "--"
        Else
            nBeginYear = Year(CDate(obj.Begin))
            nBeginMonth= Month(CDate(obj.Begin))
            nBeginDay  = Day(CDate(obj.Begin))
        End If

        If obj.End = 0 Then
            nEndYear = "----"
            nEndMonth= "--"
            nEndDay  = "--"
        Else
            nEndYear = Year(CDate(obj.End))
            nEndMonth= Month(CDate(obj.End))
            nEndDay  = Day(CDate(obj.End))
        End If
    Else
        '*** T[o̖{̔N擾 ***
         datBegin = Session("jsch").JSchServerDate(Session("jserver"))
        If obj.Begin = 0 Then
            nBeginYear = Year(CDate(datBegin))
            nBeginMonth= Month(CDate(datBegin))
            nBeginDay  = Day(CDate(datBegin))
        Else
            nBeginYear = Year(CDate(obj.Begin))
            nBeginMonth= Month(CDate(obj.Begin))
            nBeginDay  = Day(CDate(obj.Begin))
        End If

        If obj.End = 0 Then
            datEnd = DateAdd("d",364,datBegin)
            nEndYear = Year(CDate(datEnd))
            nEndMonth= Month(CDate(datEnd))
            nEndDay  = Day(CDate(datEnd))
        Else
            nEndYear = Year(CDate(obj.End))
            nEndMonth= Month(CDate(obj.End))
            nEndDay  = Day(CDate(obj.End))
        End If
    End If

    '*** J_[\EftHgN̐ݒ ***
'   datTmp = GetFitDate(nYear,nMonth)
     datTmp = Session("jsch").JSchServerDate(Session("jserver"))
    nYear  = Year(datTmp)
    nMonth = Month(datTmp)

%>
<html>

<!-- ///////////////////////// header section ////////////////////////// -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">

<title>JMSS</title>
<link rel="stylesheet" type="text/css" href="../../include/jmss.css">
<STYLE TYPE="text/css">
<!--
    A:link    {text-decoration:none; color:#000000}
    A:visited {text-decoration:none; color:#000000}
-->
</STYLE>
<script src="../../include/functions.js"></script>
<script src="../../include/jschedule/datefunc.js"></script>
<script language="javascript"><!--
// Current Calendar Year & Month
var varYear  = <% =nYear  %>;
var varMonth = <% =nMonth %>;
var varSchID = <% =Session("nSchID") %>
var varHref;
var wdayPropWin = null;
window.onerror = null;

function getReloadString(nYear,nMonth){
    return ("propSch.asp?nSchID=" + varSchID + "&nYear=" + nYear + "&nMonth=" + nMonth)
}

function popUpFreqdayProp(varFreqID,varMode,varExcDate){
    varHref = "propFreqday.asp?nSchID=" + varSchID + "&nFreqID=" + varFreqID + "&nMode=" + varMode;
    if (varExcDate != ""){
        // wꗗ̏ꍇ
        varHref = varHref + "&szExcDate=" + varExcDate;
    }

    var x=(screen.width -330)/2;
    var y=(screen.height-420)/2;

    wdayPropWin = window.open(varHref, 'wdayPropWin', "resizable=0,width=330,height=420,left=" + x + ",top=" + y);
    if (wdayPropWin != null){
        wdayPropWin.opener = self;
    }
//  wdayPropWin.focus();
}

function getSelectedValue(){
//@ȂꍇA""
    var i;

    with(document.propform){
        if (nSchDayCnt.value > 1){
            varFlg = false;
            for (i=0; i < R1.length; i++){
                if (R1[i].checked){
                    return R1[i].value;
                }
            }
        }else{
            if (R1.checked){
                return R1.value;
            }
        }
    }
    return "";
}

function onClick_Ref(){
var i;
var varRetVal;
var varFreqID;
var varExcDate;

    varRetVal = getSelectedValue();
    if (varRetVal.value != ""){
        varFreqID = varRetVal.substring(0,varRetVal.indexOf(','));
        varExcDate= varRetVal.substring(varRetVal.indexOf(',')+1,varRetVal.length);
    }

    if (varFreqID != null){
        if (varFreqID >= 0){
            popUpFreqdayProp(varFreqID,"REF",varExcDate);
        }
    }
}

function onClick_Upd(nRdoCnt){
var i;
var varRetVal;
var varFreqID;
var varExcDate;
    varRetVal = getSelectedValue();
    if (varRetVal.value != ""){
        varFreqID = varRetVal.substring(0,varRetVal.indexOf(','));
//      varExcDate= varRetVal.substring(varRetVal.indexOf(',')+1,varRetVal.length);
    }

    if (varFreqID != null){
        if (varFreqID >= 0){
            popUpFreqdayProp(varFreqID,"UPD","");
        }
    }
}

function onClick_Add(){
    popUpFreqdayProp(0,"ADD","");
}

function onClick_Del(){
var varRetVal;
var varFreqID;

    varRetVal = getSelectedValue();
    if (varRetVal.value != ""){
        varFreqID = varRetVal.substring(0,varRetVal.indexOf(','));
    }

    if (varFreqID != null){
        if (varFreqID >= 0){
            if (confirm("IĂXPW[폜܂B\n낵łH")){
                varHref = getReloadString(varYear,varMonth);
                varHref = varHref + "&nFreqID=" + varFreqID + "&szRet=DEL";
                self.document.location.href = varHref;
            }
        }
    }
}


function DisabledDate(bFlag){
var obj;
    <%
        If Session("nEditMode")=0 Then
            'Qƃ[h̏ꍇA䂵Ȃ
            Response.Write "return;" & vbCrLf
        End If
    %>
    if (!!document.all){
        obj = document.propform;
        obj.nYear.disabled=bFlag;
        obj.nMonth.disabled=bFlag;
        obj.nDay.disabled=bFlag;
        obj.nYearTo.disabled=bFlag;
        obj.nMonthTo.disabled=bFlag;
        obj.nDayTo.disabled=bFlag;
    }
}

function initDate(){
    with (document.propform){
        initYMD(nYear,nMonth,nDay,'<%=nBeginYear%>','<%=nBeginMonth%>','<%=nBeginDay%>');
        initYMD(nYearTo,nMonthTo,nDayTo,'<%=nEndYear%>','<%=nEndMonth%>','<%=nEndDay%>');
        ReMakeDays(nYear,nMonth,nDay);
        ReMakeDays(nYearTo,nMonthTo,nDayTo);
        DisabledDate(!TermFlag.checked);
    }
}
//-->
</script>
</head>

<!-- ////////////////////////////// main section ////////////////////////////// -->
<%
If Session("nEditMode") = 0 Then
    Response.Write "<body class='dialog' onUnload='javascript:if(!!wdayPropWin){wdayPropWin.close();}'>"
    Response.Write "<form name='propform'>"
Else
    Response.Write "<body class='dialog' onLoad='javascript:initDate();' onUnload='javascript:if(!!wdayPropWin){wdayPropWin.close();}'>"
    Response.Write "<form name='propform' method='post' action='propSubmit.asp' target='_self'>"
End If
%>
<!-- Hidden Parameters -->
  <input type="hidden" name="nTabIndex" value="1">
  <input type="hidden" name="nNextTabIndex" value="1">

  <table border="0" cellspacing="0" cellpadding="2">
    <tr>
        <td valign="top">
            <%
                '*** J_\ ***
                'Response.Write MakeCalTable(nYear, nMonth, Session("jsch"), datTmpDate)
            %>
            <!--<br>-->
            <table border="0">
                <tr>
                    <td valign="top" nowrap><input type="checkbox" name="TermFlag" value="1" onClick="DisabledDate(!this.checked);" <%If obj.TermFlag = 1 Then Response.Write "checked"%> <%=szMode%>></td>
                    <td nowrap>
                    <%
                        If Session("nEditMode") = 0 Then    '[Qƃ[h]
                            Response.Write "<INPUT Type='text' size='4' maxlength='4' value='" & nBeginYear  & "' " & szMode & ">/"
                            Response.Write "<INPUT Type='text' size='2' maxlength='2' value='" & nBeginMonth & "' " & szMode & ">/"
                            Response.Write "<INPUT Type='text' size='2' maxlength='2' value='" & nBeginDay   & "' " & szMode & ">"
                        Else
                            Response.Write "<SELECT Size='1' Name='nYear' onChange='ReMakeDays(document.propform.nYear,document.propform.nMonth,document.propform.nDay);' " & szMode & ">"
                            Response.Write "<SCRIPT Language='JavaScript'>" & vbCrLf
                            Response.Write "<!--" & vbCrLf
                            Response.Write "drawYearOptions();" & vbCrLf
                            Response.Write "//-->" & vbCrLf
                            Response.Write "</Script>"
                            Response.Write "</Select>"
                            Response.Write "/"

                            Response.Write "<SELECT Size='1' Name='nMonth' onChange='ReMakeDays(document.propform.nYear,document.propform.nMonth,document.propform.nDay);' " & szMode & ">"
                            Response.Write "<SCRIPT Language='JavaScript'>" & vbCrLf
                            Response.Write "<!--" & vbCrLf
                            Response.Write "drawMonthOptions();" & vbCrLf
                            Response.Write "//-->" & vbCrLf
                            Response.Write "</Script>"
                            Response.Write "</Select>"
                            Response.Write "/"

                            Response.Write "<SELECT Size='1' Name='nDay' " & szMode & ">" & vbCrLf
                            Response.Write "<SCRIPT Language='JavaScript'>" & vbCrLf
                            Response.Write "<!--" & vbCrLf
                            Response.Write "drawDayOptions();" & vbCrLf
                            Response.Write "//-->" & vbCrLf
                            Response.Write "</Script>"
                            Response.Write "</Select>"
                            Response.Write ""
                        End If

                        Response.Write "<br>"

                        If Session("nEditMode") = 0 Then    '[Qƃ[h]
                            Response.Write "<INPUT Type='text' size='4' maxlength='4' value='" & nEndYear  & "' " & szMode & ">/"
                            Response.Write "<INPUT Type='text' size='2' maxlength='2' value='" & nEndMonth & "' " & szMode & ">/"
                            Response.Write "<INPUT Type='text' size='2' maxlength='2' value='" & nEndDay   & "' " & szMode & ">܂"
                        Else
                            Response.Write "<SELECT Size='1' Name='nYearTo' onChange='ReMakeDays(document.propform.nYearTo,document.propform.nMonthTo,document.propform.nDayTo);' " & szMode & ">"
                            Response.Write "<SCRIPT Language='JavaScript'>" & vbCrLf
                            Response.Write "<!--" & vbCrLf
                            Response.Write "drawYearOptions();" & vbCrLf
                            Response.Write "//-->" & vbCrLf
                            Response.Write "</Script>"
                            Response.Write "</Select>"
                            Response.Write "/"

                            Response.Write "<SELECT Size='1' Name='nMonthTo' onChange='ReMakeDays(document.propform.nYearTo,document.propform.nMonthTo,document.propform.nDayTo);' " & szMode & ">"
                            Response.Write "<SCRIPT Language='JavaScript'>" & vbCrLf
                            Response.Write "<!--" & vbCrLf
                            Response.Write "drawMonthOptions();" & vbCrLf
                            Response.Write "//-->" & vbCrLf
                            Response.Write "</Script>"
                            Response.Write "</Select>"
                            Response.Write "/"

                            Response.Write "<SELECT Size='1' Name='nDayTo' " & szMode & ">" & vbCrLf
                            Response.Write "<SCRIPT Language='JavaScript'>" & vbCrLf
                            Response.Write "<!--" & vbCrLf
                            Response.Write "drawDayOptions();" & vbCrLf
                            Response.Write "//-->" & vbCrLf
                            Response.Write "</Script>"
                            Response.Write "</Select>"
                            Response.Write "܂"
                        End If
                    %>
                    </td>
                </tr>
                <tr>
                    <td nowrap>x~U</td>
                    <td nowrap>
                        <select size="1" name="TransferType" <%=szMode%>>
                            <option value="0"<% If obj.TransferType = 0 Then Response.Write " selected"%>>sȂ     </option>
                            <option value="1"<% If obj.TransferType = 1 Then Response.Write " selected"%>>ғɃVtg</option>
                            <option value="2"<% If obj.TransferType = 2 Then Response.Write " selected"%>>OғɃVtg</option>
                            <option value="3"<% If obj.TransferType = 3 Then Response.Write " selected"%>>s       </option>
                        </select>
                    </td>
                </tr>
            </table>
        </td>

        <td valign="top" nowrap>
            <table border="0" width="100%" cellspacing="1" cellpadding="2" bgcolor="#C0C0C0">
                <tr bgcolor="#C0C0C0">
                    <td nowrap>I</td>
                    <td nowrap>t</td>
                    <td nowrap></td>
                    <td nowrap></td>
                </tr>
                <%
                    nSchDayCnt = obj.FreqList.Count

                    If nSchDayCnt > 0 Then
                        For nIndex=0 To obj.FreqList.Count -1
                            Set obj2 =obj.FreqList.Item(CLng(nIndex),0)
                            Response.Write "<tr>"
                            Response.Write "<td bgcolor='#FFFFFF' nowrap>"
                            Response.Write "<input type='radio' name='R1' value='" & obj2.FreqID & "," & Server.URLEncode(obj2.ExcDate) & "'"
                            If nIndex > 0 Then
                                Response.Write ">"
                            Else
                                Response.Write " checked>"
                            End If
                            Response.Write "</td>"
                            Response.Write "<td bgcolor='#FFFFFF' nowrap>" & obj2.Date & "</td>"
                            Response.Write "<td bgcolor='#FFFFFF' nowrap>" & obj2.Time & "</td>"
                            Response.Write "<td bgcolor='#FFFFFF' nowrap>" & obj2.Freq & "<br></td>"
                            Response.Write "</tr>"
                        Next
                    Else
                        Response.Write "<tr>"
                        Response.Write "<td bgcolor='#FFFFFF' colspan='4' nowrap>"
                        Response.Write "LȃXPW[܂"
                        Response.Write "</td>"
                        Response.Write "</tr>"
                    End If

                    '** \f[^ꍇ̂ݕύXE폜{^t **
                    Response.Write "<TR><TD colspan='4'>"
                    If Session("nEditMode") = 0 Then    '[Qƃ[h]
                        Response.Write "<INPUT type='button' value='Q' name='Ref' onClick='javascript:onClick_Ref();'>" & "&nbsp;"
                    ElseIf Session("nEditMode") = 1 Then    '[ύX[h]
                        If nSchDayCnt < MAX_SCHECNT Then
                            Response.Write "<INPUT type='button' value='ǉ' name='Add' onClick='javascript:onClick_Add();'>" & "&nbsp;"
                        End If
                        If nSchDayCnt > 0 Then
                            Response.Write "<INPUT type='button' value='ύX' name='Upd' onClick='javascript:onClick_Upd();'>" & "&nbsp;"
                            'If nSchDayCnt > 1 Then
                                Response.Write "<INPUT type='button' value='폜' name='Del' onClick='javascript:onClick_Del();'>"
                            'End If
                        End If
                    End If
                    Response.Write "</TD></TR>"
                    '*** (L)XPW[JEg̕ێ ***
                    Response.Write "<INPUT type='hidden' name='nSchDayCnt' value='" & nSchDayCnt & "'>"

                    '*** IuWFNg̉ ***
                    Set obj2 = Nothing
                    Set obj = Nothing
                %>
            </table>
        </td>
    </tr>
</table>

</form>

</body>

</html>
