<%-- 
    Document   : CropLoanDisbursementVidyasagar
    Created on : 23-May-2023, 6:31:49 PM
    Author     : 1815522
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Crop Loan Disbursement Vidyasagar</title>
        <link rel="shortcut icon" href="${pageContext.request.contextPath}/img/favicon.ico" type="image/x-icon" />
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/TableCSSCode.css" />
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/styles.css?pacs=<%=((new java.util.Date()).getTime())%>"/>
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/ButtonAndText.css?pacs=<%=((new java.util.Date()).getTime())%>" />
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/info.css?pacs=<%=((new java.util.Date()).getTime())%>" />
        <script src="${pageContext.request.contextPath}/js/Calendar.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <script type="text/javascript" src="${pageContext.request.contextPath}/jquery-ui-1.10.4.custom/development-bundle/jquery-1.10.2.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <script type="text/javascript" src="/PacsApplication/chromejs/chrome.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <script type="text/javascript" src="/PacsApplication/js/iFrame_killer.js"></script>

    </head>
    <script>
        function sendFileToServer()
        {
            var fileName = document.getElementById("fileChooser").value;
            var fileNameSplit = fileName.split('.');
            var fileNameSplit1 = fileNameSplit[0].substring(fileNameSplit[0].lastIndexOf('\\') + 1);
            fileNameSplit1 = fileNameSplit1.split('_');

            if ((fileNameSplit[1] == "txt") && (fileNameSplit1[0] == "SAL") && !(isNaN(fileNameSplit1[1])) && !(isNaN(fileNameSplit1[2])) && !(isNaN(fileNameSplit1[3])) && !(isNaN(fileNameSplit1[4])) && !(isNaN(fileNameSplit1[5]))) {
                document.SALFileIdUpload.actionTag.value = "UPLOAD";
                document.SALFileIdUpload.action = '/PacsApplication/CropLoanDisbursementServlet';
                document.SALFileIdUpload.submit();
            }
            //SAL_00001_29052023_050400_29052023_165.txt
            else {
                alert("please choose text file only with below format, SAL_xxxx_ddmmyyyy_xxxxxx_ddmmyyyy_xxx.txt");
                return;
            }
        }

        function refreshOriginalPage()
        {
            window.location.href = 'CropLoanDisbursementVidyasagar.jsp';
            //document.getElementById("successMessageTag").innerHTML = "xxx";
        }
    </script>

    <body>
        <jsp:include page="MenuHead.jsp" flush="true" />
        <br>
        <fieldset style="background-image: url('/PacsApplication/img/download.jpg'); border-color: black; border-width: 3px">
            <legend style="padding: 8px; border-radius: 20px; background-color: #006600; color: white">Crop Loan Disbursement</legend>

            <div id="UploadDiv" style="display:block">
                <form name="SALFileIdUpload" id="SALFileIdUpload" method="post" enctype="multipart/form-data">
                    <center>
                        Select file to upload:
                        <input type="file" name="dataFile" id="fileChooser"/><br/><br/>
                        <input type="hidden" id="actionTag" name="actionTag">
                        <input type="button" value="Upload" id ="FileTypeIdUpload" name="FileType" onclick="sendFileToServer()"/>
                        <input type="button" value="Refresh" id ="RefreshId" name="RefreshIdButton" onclick="refreshOriginalPage()"/>
                    </center>
                </form>              
            </div>

            <div id="errorMessageTag" style="color: #FF0000;">${errorMessageSAL}</div>
            <div id="successMessageTag" style="color: #0000FF;">${successMessageSAL}</div>
        </fieldset>
    </body>
</html>
