<!--#include file="kenshu.inc"-->
<%
Dim intKenshuCode, strDateFrom, strDateTo, strDateShime, strShainCode
Dim strYearFrom, strMonthFrom, strYearTo, strMonthTo

If Request.Cookies("kenshu")("CODE") = "" then
    '---- クッキーがなければ認証エラー画面表示 ----
    Call DispError("", "")
Else
    '---- 共通ヘッダ表示 ----
    Call DispHeader("研修一覧", "1")

    '---- 検索キーの組み立て ----
    strYearFrom = Request.Form("YearFrom")
    strMonthFrom = Request.Form("MonthFrom")
    strYearTo = Request.Form("YearTo")
    strMonthTo = Request.Form("MonthTo")

    strDateFrom = EditDateFrom(strYearFrom, strMonthFrom)
    strDateTo = EditDateTo(strYearTo, strMonthTo)

    Select Case Request.Form("ShoriCode")

        Case "1" '**** 申込可能な研修一覧表示 ****

            '---- 社員コードを取得する ----
            strShainCode = GetShainCode

            '---- 検索キー表示 ----
            Call DispQueryKey1

            '---- 研修一覧表示 ----
            Call DispKenshu1


        Case "2" '**** 受講履歴表示 ****

            '---- 社員コードを取得する ----
            strShainCode = GetShainCode

            '---- 検索キー表示 ----
            Call DispQueryKey2

            '---- 研修一覧表示 ----
            If Request.Form("Disp") = "1" Then
                Call DispKenshu2
            End If

        Case "3" '**** 研修一覧表示 ****

            '---- 検索キー表示 ----
            Call DispQueryKey3

            '---- 研修の新規登録ボタン表示 ----
%>            <table bgcolor="<%=PRPL%>" cellpadding="5">
            <tr><td>
                <form action="kenshu05.asp" method="post">
                <input type="submit" value="研修の新規登録">
                <input type="hidden" name="ShoriCode" value="3">
                ・研修の新規登録・変更を行います。
                </form>
            </td></tr>
            </table>
<%
            '---- 研修一覧表示 ----
            If Request.Form("Disp") = "1" Then
                Call DispKenshu3
            End If
    End Select

    '---- メニュー画面に戻る ----
%>    <form action="../../../SQL7/prglist/odbc/kenshu01.asp.txt" method="post">
    <input type="submit" value="メニューに戻る">
    </form>
<%
    '---- 共通フッタ表示 ----
    Call DispFooter("1")

End if


'**************************************
'検索キーの組み立て(日程自)
'**************************************
Function EditDateFrom(strYear, strMonth)

    On Error Resume Next

    If IsDate(DateSerial(strYear, strMonth, 1)) = False Or IsEmpty(strYear) Then
        EditDateFrom = ""
        strYear = ""
        strMonth = ""
        Exit Function
    End If

    EditDateFrom = DateValue(DateSerial(strYear, CInt(strMonth), 1))

End Function


'**************************************
'検索キーの組み立て(日程至)
'**************************************
Function EditDateTo(strYear, strMonth)

    On Error Resume Next

    If IsDate(DateSerial(strYear, strMonth, 1)) = False Or IsEmpty(strYear) Then
        EditDateTo = ""
        strYear = ""
        strMonth = ""
        Exit Function
    End If

    EditDateTo = DateValue(DateSerial(strYear, CInt(strMonth) + 1, 1) - 1)

End Function


'**************************************
'社員番号入力欄の表示(ShoriCode="1")
'**************************************
Sub DispQueryKey1()
%>
<form name="Keyword" method="post">
<table border="0" bgcolor="<%=GRND%>">
    <tr>
        <th bgcolor="<%=GRNH%>">申込者社員コード</th>
        <td><% Call DispShainCodeText(strShainCode)%></td>
    </tr>
</table>
</form>
<hr>
<%
End Sub


'**************************************
'検索キー入力欄の表示(ShoriCode="2")
'**************************************
Sub DispQueryKey2()
%>
<form action="kenshu02.asp" name="Keyword" method="post">
<table border="0" bgcolor="<%=GRND%>">
    <tr>
        <th bgcolor="<%=GRNH%>">社員コード</td>
        <td><% Call DispShainCodeText(strShainCode)%></td>
    </tr>
    <tr>
        <th bgcolor="<%=GRNH%>">研修名称</td>
        <td><% Call DispKenshuNameText(Request.Form("KenshuName"))%></td>
    </tr>
    <tr>
        <th bgcolor="<%=GRNH%>">日程</td>
        <td><% Call DispDateText(strYearFrom, strMonthFrom, strYearTo, strMonthTo)%></td>
    </tr>
</table>
上記内容で<input type="submit" value="検索実行">
<input type="hidden" name="ShoriCode" value="<%=Request.Form("ShoriCode")%>">
<input type="hidden" name="Disp" value="1">
</form>
<hr>
<%
End Sub


'**************************************
'検索キー入力欄の表示(ShoriCode="3")
'**************************************
Sub DispQueryKey3()
%>

<form action="kenshu02.asp" name="Keyword" method="post">
<p>
<table border="0" bgcolor="<%=GRND%>">
    <tr>
        <td bgcolor="<%=GRNH%>">研修コード</td>
        <td><% Call DispKenshuCodeText(Request.Form("KenshuCode"))%></td>
    </tr>
    <tr>
        <td bgcolor="<%=GRNH%>">研修名称</td>
        <td><% Call DispKenshuNameText(Request.Form("KenshuName"))%></td>
    </tr>
    <tr>
        <td bgcolor="<%=GRNH%>">日程</td>
        <td><% Call DispDateText(strYearFrom, strMonthFrom, strYearTo, strMonthTo)%></td>
    </tr>
</table>
上記内容で<input type="submit" value="検索実行"></p>
<input type="hidden" name="ShoriCode" value="<%=Request.Form("ShoriCode")%>">
<input type="hidden" name="Disp" value="1">
</form>
<hr>
<%
End Sub


'**************************************
'研修一覧の表示(ShoriCode="1")
'**************************************
Sub DispKenshu1()

    '---- 検索クエリー ----
    strSQL = "SELECT * FROM 研修データ A, 社員マスタ B " & _
            "WHERE A.申込締切日 >= '" & Date() & "' " & _
            "AND A.講師コード = B.社員コード " & _
            "ORDER BY 申込締切日 DESC"

    objRec.Open strSQL, objDBCon

    If objRec.EOF And objRec.BOF Then
        Response.Write "該当するレコードはありませんでした。"
        objRec.Close
        Exit Sub
    End If

    '---- 研修一覧表示 ----
%>    <h3>申込受付中の研修一覧</h3>
    <table border="1" bgcolor="<%=YLWD%>">
    <tr bgcolor="<%=YLWH%>">
        <th nowrap>研修<br>コード</th>
        <th nowrap>研修名称</th>
        <th nowrap>日程</th>
        <th nowrap>時間</th>
        <th nowrap>場所</th>
        <th nowrap>定員</th>
        <th nowrap>講師</th>
        <th nowrap>申込締切日</th>
        <th nowrap>申込</th>
        <th nowrap>申込者<br>一覧</th>
    </tr>
<%
    objRec.MoveFirst
    Do While Not objRec.EOF

        intKenshuCode = objRec.Fields("研修コード").Value

        '---- 日付の変換 ----
        Call EditDispDate(objRec, strDateFrom, strDateTo, strDateShime)
%>
        <tr>
            <td><%=intKenshuCode%></td>
            <td><%=Server.HTMLEncode(objRec.Fields("研修名称").Value)%></td>
            <td><%=strDateFrom & strDateTo%></td>
            <td><%=objRec.Fields("時間").Value%></td>
            <td><%=Server.HTMLEncode(objRec.Fields("場所").Value)%></td>
            <td><%=objRec.Fields("定員")%></td>
            <td><%=Server.HTMLEncode(objRec.Fields("氏名漢字").Value)%></td>
            <td><%=strDateShime%></td>
            <td>
                <form action="kenshu03.asp" name="raw<%=intKenshuCode%>" method="post">
                <input type="hidden" name="KenshuCode" value="<%=intKenshuCode%>">
                <input type="hidden" name="ShoriCode" value="<%=Request.Form("ShoriCode")%>">
                <input type="hidden" name="ShainCode">
                <input type="button" value="申込" onClick="GetCode(this.form)">
                </form>
            </td>
            <td>
                <form action="kenshu04.asp" name="raw2<%=intKenshuCode%>" method="post">
                <input type="hidden" name="KenshuCode" value="<%=intKenshuCode%>">
                <input type="hidden" name="ShoriCode" value="<%=Request.Form("ShoriCode")%>">
                <input type="hidden" name="ShainCode">
                <input type="button" value="表示" onClick="GetCode(this.form)">
                </form>
            </td>
        </tr>
<%
        objRec.MoveNext
    Loop
    Response.Write "</TABLE>"

    objRec.Close

End Sub


'**************************************
'研修一覧の表示(ShoriCode="2")
'**************************************
Sub DispKenshu2()

    Dim intThisPage, intRowCount
    Dim strBoldStart, strBoldEnd

    '---- 検索クエリー ----
    strSQL = "SELECT * FROM 申込データ A, 研修データ B, 状態マスタ C, 社員マスタ D " & _
            "WHERE A.研修コード = B.研修コード " & _
            "AND A.状態コード = C.状態コード " & _
            "AND B.講師コード = D.社員コード " & _
            "AND A.社員コード = '" & strShainCode & "' "

    If Request.Form("KenshuName") <> "" Then
        strSQL = strSQL & "AND B.研修名称 LIKE '%" & Request.Form("KenshuName") & "%' "
    End If
    If strDateFrom <> "" Then
        strSQL = strSQL & "AND B.日程自 >= '" & strDateFrom & "' "
    End If
    If strDateTo <> "" Then
        strSQL = strSQL & "AND B.日程自 <= '" & strDateTo & "' "
    End If

    strSQL = strSQL + "ORDER BY B.日程自 DESC"
    objRec.Open strSQL, objDBCon, 3

    '---- レコードがない場合 ----
    If objRec.EOF And objRec.BOF Then
        Response.Write "該当するレコードはありませんでした。"
        objRec.Close
        Exit Sub
    End If

    '---- ページ数を設定 ----
    If IsEmpty(Request.Form("Page")) Then
        intThisPage = 1
    Else
        intThisPage = Request.Form("Page")
    End If

    objRec.PageSize = 10
    objRec.AbsolutePage = intThisPage
%>
    <form action="kenshu02.asp" method="post">
    <h3>申し込み履歴は全部で <%=objRec.RecordCount%> 件あります。
<%
    If intThisPage * 10 < objRec.RecordCount Then

        Response.Write "<INPUT type=""hidden"" name=""ShainCode"" value=""" & strShainCode & """>"
        Call Next10Button (intThisPage)
    End If
%>
    </h3>
    </form>

    <table border="1" bgcolor="<%=YLWD%>">
    <tr bgcolor="<%=YLWH%>">
        <th nowrap>研修<br>コード</th>
        <th nowrap>研修名称</th>
        <th nowrap>日程</th>
        <th nowrap>時間</th>
        <th nowrap>場所</th>
        <th nowrap>定員</th>
        <th nowrap>講師</th>
        <th nowrap>状態</th>
        <th nowrap>申込<br>変更</th>
        <th nowrap>申込者<br>一覧</th>
    </tr>
<%
    intRowCount = 0
    Do While Not objRec.EOF And intRowCount < 10

        intKenshuCode = objRec.Fields("研修コード").Value
        strBoldStart = ""
        strBoldEnd = ""

        '---- 日付の変換 ----
        Call EditDispDate(objRec, strDateFrom, strDateTo, strDateShime)

        '---- 未実施の研修は強調する ----
        If objRec.Fields("日程自").Value > Date() Then
            strBoldStart = "<B>"
            strBoldEnd = "</B>"
            strDateFrom = "<FONT color=""#FF0000"">" & strDateFrom
            strDateTo = strDateTo & "</FONT>"
        End If
%>
        <tr>
            <td><%=strBoldStart & intKenshuCode & strBoldEnd%></td>
            <td><%=strBoldStart & Server.HTMLEncode(objRec.Fields("研修名称").Value) & strBoldEnd%></td>
            <td><%=strBoldStart & strDateFrom & strDateTo & strBoldEnd%></td>
            <td><%=strBoldStart & objRec.Fields("時間").Value & strBoldEnd%></td>
            <td><%=strBoldStart & Server.HTMLEncode(objRec.Fields("場所").Value) & strBoldEnd%></td>
            <td><%=strBoldStart & objRec.Fields("定員") & strBoldEnd%></td>
            <td><%=strBoldStart & Server.HTMLEncode(objRec.Fields("氏名漢字").Value) & strBoldEnd%></td>
            <td><%=strBoldStart & Server.HTMLEncode(objRec.Fields("状態名").Value) & strBoldEnd%></td>
            <td>
<%            If objRec.Fields("日程自").Value > Date() Then
                If objRec.Fields("状態コード").Value = "01" Then
%>                     <form action="kenshu03.asp" name="raw<%=intKenshuCode%>" method="post">
                    <input type="hidden" name="KenshuCode" value="<%=intKenshuCode%>">
                    <input type="hidden" name="ShoriCode" value="<%=Request.Form("ShoriCode")%>">
                    <input type="hidden" name="ShainCode">
                    <input type="button" value="取り消し" onClick="GetCode(this.form)">
                    </form>
<%                 ElseIf objRec.Fields("状態コード").Value = "11" Then
%>                     <form action="kenshu03.asp" name="raw<%=intKenshuCode%>" method="post">
                    <input type="hidden" name="KenshuCode" value="<%=intKenshuCode%>">
                    <input type="hidden" name="ShoriCode" value="<%=Request.Form("ShoriCode")%>">
                    <input type="hidden" name="ShainCode">
                    <input type="button" value="キャンセル" onClick="GetCode(this.form)">
                    </form>
<%                 Else
                    Response.Write(" ")
                End If
            Else
                Response.Write(" ")
            End If
%>            </td>
            <td>
                <form action="kenshu04.asp" name="raw2<%=intKenshuCode%>" method="post">
                <input type="hidden" name="KenshuCode" value="<%=intKenshuCode%>">
                <input type="hidden" name="ShoriCode" value="<%=Request.Form("ShoriCode")%>">
                <input type="hidden" name="ShainCode">
                <input type="button" value="表示" onClick="GetCode(this.form)">
                </form>
            </td>
        </tr>
<%
        objRec.MoveNext
        intRowCount = intRowCount + 1
    Loop

    Response.Write "</TABLE>"
    objRec.Close

End Sub


'**************************************
'研修一覧の表示(ShoriCode="3")
'**************************************
Sub DispKenshu3()

    Dim intThisPage, intRowCount
    Dim strBoldStart, strBoldEnd

    '---- 検索クエリー ----
    strSQL = "SELECT * FROM 研修データ A, 社員マスタ B " & _
            "WHERE A.講師コード = B.社員コード "

    If Request.Form("KenshuCode") <> "" Then
        strSQL = strSQL & "AND A.研修コード LIKE '%" & Request.Form("KenshuCode") & "%' "
    End If
    If Request.Form("KenshuName") <> "" Then
        strSQL = strSQL & "AND A.研修名称 LIKE '%" & Request.Form("KenshuName") & "%' "
    End If
    If strDateFrom <> "" Then
        strSQL = strSQL & "AND A.日程自 >= '" & strDateFrom & "' "
    End If
    If strDateTo <> "" Then
        strSQL = strSQL & "AND A.日程自 <= '" & strDateTo & "' "
    End If

    strSQL = strSQL + "ORDER BY A.日程自 DESC"
    objRec.Open strSQL, objDBCon, 3

    '---- レコードがない場合 ----
    If objRec.EOF And objRec.BOF Then
        Response.Write "該当するレコードはありませんでした。"
        objRec.Close
        Exit Sub
    End If

    '---- ページ数を設定 ----
    If IsEmpty(Request.Form("Page")) Then
        intThisPage = 1
    Else
        intThisPage = Request.Form("Page")
    End If

    objRec.PageSize = 10
    objRec.AbsolutePage = intThisPage
%>
    <form action="kenshu02.asp" method="post">
    <h3>全部で <%=objRec.RecordCount%> 件あります。
<%
    If intThisPage * 10 < objRec.RecordCount Then

        Response.Write "<INPUT type=""hidden"" name=""KenshuCode"" value=""" & Request.Form("KenshuCode") & """>"
        Call Next10Button (intThisPage)
    End If
%>
    </h3>
    </form>

    <table border="1" bgcolor="<%=YLWD%>">
    <tr bgcolor="<%=YLWH%>">
        <th nowrap>研修<br>コード</th>
        <th nowrap>研修名称</th>
        <th nowrap>日程</th>
        <th nowrap>時間</th>
        <th nowrap>場所</th>
        <th nowrap>定員</th>
        <th nowrap>講師</th>
        <th nowrap>申込締切日</th>
        <th nowrap>内容<br>変更</th>
        <th nowrap>可否<br>決定</th>
    </tr>
<%
    intRowCount = 0
    Do While Not objRec.EOF And intRowCount < 10

        intKenshuCode = objRec.Fields("研修コード").Value
        strBoldStart = ""
        strBoldEnd = ""

        '---- 日付の変換 ----
        Call EditDispDate(objRec, strDateFrom, strDateTo, strDateShime)

        '---- 未実施の研修は強調する ----
        If objRec.Fields("日程自").Value > Date() Then
            strBoldStart = "<B>"
            strBoldEnd = "</B>"
            strDateShime = "<FONT color=""#FF0000"">" & strDateShime & "</FONT>"
        End If
%>
        <tr>
            <td><%=strBoldStart & intKenshuCode & strBoldEnd%></td>
            <td><%=strBoldStart & Server.HTMLEncode(objRec.Fields("研修名称").Value) & strBoldEnd%></td>
            <td><%=strBoldStart & strDateFrom & strDateTo & strBoldEnd%></td>
            <td><%=strBoldStart & objRec.Fields("時間").Value & strBoldEnd%></td>
            <td><%=strBoldStart & Server.HTMLEncode(objRec.Fields("場所").Value) & strBoldEnd%></td>
            <td><%=strBoldStart & objRec.Fields("定員") & strBoldEnd%></td>
            <td><%=strBoldStart & Server.HTMLEncode(objRec.Fields("氏名漢字").Value) & strBoldEnd%></td>
            <td><%=strBoldStart & strDateShime & strBoldEnd%></td>
            <td>
<%            If objRec.Fields("日程自").Value > Date() Then
%>                 <form action="kenshu05.asp" method="post">
                <input type="hidden" name="KenshuCode" value="<%=intKenshuCode%>">
                <input type="hidden" name="ShoriCode" value="<%=Request.Form("ShoriCode")%>">
                <input type="submit" value="変更">
                </form>
            </td>
            <td>
                <form action="kenshu04.asp" method="post">
                <input type="hidden" name="KenshuCode" value="<%=intKenshuCode%>">
                <input type="hidden" name="ShoriCode" value="<%=Request.Form("ShoriCode")%>">
                <input type="submit" value="可否">
                </form>
<%            Else
                Response.Write " </TD><TD> "
            End If
        Response.Write "</TD></TR>"
        objRec.MoveNext
        intRowCount = intRowCount + 1
    Loop

    Response.Write "</TABLE>"
    objRec.Close

End Sub


'**************************************
'次の10件ボタン
'**************************************
Sub Next10Button (intPage)
%>
    <input type="hidden" name="KenshuName" value="<%=Request.Form("KenshuName")%>">
    <input type="hidden" name="YearFrom" value="<%=Request.Form("YearFrom")%>">
    <input type="hidden" name="MonthFrom" value="<%=Request.Form("MonthFrom")%>">
    <input type="hidden" name="YearTo" value="<%=Request.Form("YearTo")%>">
    <input type="hidden" name="MonthTo" value="<%=Request.Form("MonthTo")%>">
    <input type="hidden" name="ShoriCode" value="<%=Request.Form("ShoriCode")%>">
    <input type="hidden" name="Disp" value="1">
    <input type="hidden" name="Page" value="<%=intPage + 1 %>">
    <input type="submit" value="次の10件">
<%
End Sub
%>