<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<% try {
%>


<!DOCTYPE html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="img/favicon.ico?pacs=<%=((new java.util.Date()).getTime())%>" type="image/x-icon" />
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&family=Rubik:ital,wght@0,300..900;1,300..900&display=swap" rel="stylesheet">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Lexend:wght@100..900&family=Montserrat:ital,wght@0,100..900;1,100..900&family=Rubik:ital,wght@0,300..900;1,300..900&display=swap" rel="stylesheet">
    <title>Integrated PACS Kisan Solution</title>

<!--        <link type="text/css" rel="stylesheet" href="/PacsApplication/css/loginpage.css?pacs=<%=((new java.util.Date()).getTime())%>"/>
   <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">-->

    <script type="text/javascript" src="${pageContext.request.contextPath}/js/CapsLock.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
    <script src="${pageContext.request.contextPath}/js/iFrame_killer.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>

    <%
        String changePasswordFlag = null; // initializatoin changed to null for SAST
        Object display = request.getAttribute("changePasswordFlag");
        if (display != null) {
            changePasswordFlag = display.toString();
        }
    %>

    <% String otp_flag = (String) request.getAttribute("otp_flag");
        //otp_flag = "valid";
    %>

    <style>
        body {
            font-family: "Montserrat", sans-serif;
            margin: 0;
        }
        #logo {
            height: 200px;
            width: 200px;
        }

        #sign_in{
            font-family: Rubik, sans-serif;
            font-size: 1.5em;
            font-weight: normal;
            color: rgb(0, 140, 70);
        }

        #otp_entry{
            font-family: Rubik, sans-serif;
            font-size: 1.5em;
            font-weight: normal;
            color: rgb(0, 140, 70);
        }

        .container {
            display: flex;
            height: 100vh;
        }

        .left-section {
            flex: 0.8;
            background-color: #B1E1B3;
            /* Light gray background */
            text-align: center;
            color: #008C46;
            font-size: 25px;
            padding-top: 45px;

        }

        .right-section {
            flex: 1;
            background-color: #fff;
            /* White background */
            padding: 30px;
            text-align: center;
            font-size: 35px;
            padding-top: 60px;
        }

        .header img {
            width: 100px;
            height: auto;
        }

        /* .header h1 {
            font-size: 45px;
            margin-top: 10px;
            color: #008C46;
        } */

        form {
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-group label {
            display: block;
            margin-bottom: 5px;
        }

        input[type="text"],
        input[type="password"] {
            width: 100%;
            padding: 10px;
            border: 2px solid #a0a0a0;
            border-radius: 20px;
            width: 400px;
            margin-left: 26px;
            font-size: 16px;
            font-family: Rubik, sans-serif;

        }

        #loginbtn {
            background-color: #008C46;
            font-family: 'Rubik', sans-serif;
            color: #fff;
            padding: 10px 20px;
            border: none;
            border-radius: 100px;
            cursor: pointer;
            font-size: 20px;
            font-weight: 500;
            width: 448px;
            height: 50px;
            margin-left: 10px;
            transition: 0.15s linear;

        }
        #resetbtn {
            background-color: #ffffff;
            font-family: 'Rubik', sans-serif;
            color: #008C46;
            padding: 10px 20px;
            border: 2px solid #008C46;
            border-radius: 100px;
            cursor: pointer;
            font-size: 20px;
            font-weight: 500;
            width: 448px;
            height: 50px;
            margin-left: 10px;

        }

        #resetbtn:hover {
            background-color: #008C46;
            color: #fff;
        }

        #loginbtn:hover {
            background-color: #fff;
            color: #008C46;
            border: 2px solid #008C46;
        }

        .copyright {
            margin-top: 30px;
            font-size: 12px;
            color: gray;
        }

        .footer {
            font-family: Lexend, sans-serif;
            font-weight: 600;
            position: fixed;
            left: 0;
            bottom: 0;
            width: 40%;
            color: #008C46;
            text-align: left;
            font-size: 12px;
            margin-left: 5px;
        }

        .button-container {
            display: flex;
            /* padding: 20px; */
            border: none;
            border-radius: 3px;
            cursor: pointer;
            font-size: 300px;
            gap: 16px;
            margin-top: 10px;
            width: 448px;
            height: 50px;
            margin-left: 10px;

        }
        /*added on 13/2/24*/

        #submitbtn {
            background-color: #008C46;
            font-family: 'Rubik', sans-serif;
            color: #fff;
            padding: 10px 20px;
            border: none;
            border-radius: 100px;
            cursor: pointer;
            font-size: 20px;
            font-weight: 500;
            width: 448px;
            height: 50px;
            margin-left: 10px;
            transition: 0.15s linear;

        }
        #resendbtn {
            background-color: #ffffff;
            font-family: 'Rubik', sans-serif;
            color: #008C46;
            padding: 10px 20px;
            border: 2px solid #008C46;
            border-radius: 100px;
            cursor: pointer;
            font-size: 20px;
            font-weight: 500;
            width: 448px;
            height: 50px;
            margin-left: 10px;

        }

        #resendbtn:hover {
            background-color: #008C46;
            color: #fff;
        }

        #submitbtn:hover {
            background-color: #fff;
            color: #008C46;
            border: 2px solid #008C46;
        }

        .error-msg {
            padding-top: 3px;
            padding-bottom: 5px;

        }
        /*added on 5/2/24 instead of style="width: 435px; height: 46px; margin-left: 21px;"*/
        select {
            margin-bottom: 10px;
            margin-top: 10px;
            width: 425px;
            padding: 10px;
            border: 2px solid #a0a0a0;
            border-radius: 20px;
            font-size: 16px;
            margin-left: 26px;
            color: #979797;

        }

    </style>
</head>

<body onLoad="ChangePassword(<%=changePasswordFlag%>); do_Load();">


    <%
        String error_msg = "";
        Object error = request.getAttribute("error");
        if (error != null) {
            error_msg = error.toString();
        }
    %>

    <script language="JavaScript" type="text/javascript">

        function ChangePassword(changePasswordFlag) {
            if (changePasswordFlag != undefined) {
                if (changePasswordFlag != 0)
                {
                    alert("Your Password has been changed successfully.Try login with the new credential.");
                } else
                {
                    alert("Password change unsuccesful.Please try again.");
                }
            }
        }

        var inAttempt = 0;
        rnumber = rnumber = null;
        function submitform(formT)
        {
            re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
            if (document.forms[0].UID.value != "") {
                if (!re.test(document.forms[0].UID.value))
                {
                    alert("User ID could only contain numbers.");
                    document.forms[0].UID.focus();
                    return false;
                }
            }
            re = /^(?=.*\d)\d*(?:\.\d*)?$/; //this checks whether field contains digits
            if (document.forms[0].PACSID.value != "") {
                if (!re.test(document.forms[0].PACSID.value))
                {
                    alert("PACS ID could only contain numbers.");
                    document.forms[0].PACSID.focus();
                    return false;
                }
            }

            if (validateForm(formT))
            {
                if (inAttempt == 0)
                {
                    formT.target = "_top";
                    formT.submit();
                } else
                    alert("Already submited.");
                inAttempt++;
            }

        }
        function ShowParent()
        {
            document.forms[0].action = "/PacsApplication/Login.jsp";
            document.forms[0].submit();
        }

        function resenOtp()
        {
            document.forms[0].action = "/PacsApplication/OtpResendServlet";
            document.forms[0].submit();
        }

        function validateForm()
        {

            if (!checkText("User ID", document.form1.UID)) {
                document.form1.UID.focus();

                return false;
            }

            if (!checkText("Password", document.form1.PWD))
            {
                document.form1.PWD.focus();

                return false;
            }

            if (!checkText("PACSID", document.form1.PACSID))
            {
                document.form1.PACSID.focus();

                return false;
            }

            if (!checkText("MODULE NAME", document.form1.moduleName))
            {
                document.form1.moduleName.focus();

                return false;
            }

            return true;

        }


        function checkText(ale, alfanumeric)
        {
            if (isBlank(alfanumeric.value))
            {
                alert(ale + "  cannot be blank. Enter " + ale);
                alfanumeric.focus();
                alfanumeric.select();
                return false;
            }
            return true;
        }

        history.pushState(null, null, location.href);
        window.addEventListener('popstate', function (event) {
            history.pushState(null, null, location.href);
        });

        function checkNumberAlone(ale, amt)
        {
            var len = amt.value.length;
            if (isBlank(amt.value))
            {
                alert(ale + " cannot be blank. Enter " + ale);
                return false;
            }
            for (i = 0; i < len; i++)
            {
                if (amt.value.charAt(i) < '0' || amt.value.charAt(i) > '9')
                {
                    alert(ale + " cannot contain characters other than Numbers.");
                    return false;
                }
            }
            return true;
        }

        function isBlank(s)
        {

            var len = s.length;
            var i;
            if (len == 0)
                return true;

            for (i = 0; i < len; ++i)
            {
                if (s.charAt(i) != " ")
                    return false;
            }
            return true;
        }

        function showtip2(current, e, text)
        {
            if (document.all && document.readyState == "complete")
            {
                document.all.tooltip2.innerHTML = '<font color="BLACK"><b>' + text + '</b></font>'
                document.all.tooltip2.style.pixelLeft = event.clientX + document.body.scrollLeft + 0
                document.all.tooltip2.style.pixelTop = event.clientY + document.body.scrollTop + 20
                document.all.tooltip2.style.visibility = "visible"
            } else if (document.layers)
            {
                document.tooltip2.document.nstip.document.write('<font color="BLACK"><b>' + text + '</b></font>')
                document.tooltip2.document.nstip.document.close()
                document.tooltip2.document.nstip.left = 0
                document.tooltip2.left = e.pageX + 10
                document.tooltip2.top = e.pageY + 10
                document.tooltip2.visibility = "show"
            }
        }
        function hidetip2()
        {
            if (document.all)
                document.all.tooltip2.style.visibility = "hidden"
            else if (document.layers)
            {
                clearInterval(currentscroll)
                document.tooltip2.visibility = "hidden"
            }
        }
        function checkCapsLock(e)
        {

            if (CapsLock.isOn()) {


            }

            CapsLock.addListener(
                    function (status) {
                        if (status)
                            alert("Caps Lock is on");
                    });

        }

        function add(a)
        {
            document.all.btClear.disabled = false;
            document.form1.pwd.value += a.value.substring(1, 2);
        }

    </script>

    <script language="javascript" type="text/javascript">
        window.history.forward();
        function add(a)
        {
            document.all.btClear.disabled = false;
            document.form1.pwd.value += a.value.substring(1, 2);
        }

        function toggle(fRef)
        {
            capsLock = !capsLock;
            if (capsLock)
            {
                fRef.caps.value = ' SHIFT ';

                fRef.n1.value = ' ! ';
                fRef.n2.value = ' @ ';
                fRef.n3.value = ' # ';
                fRef.n4.value = ' $ ';
                fRef.n5.value = ' % ';
                fRef.n6.value = ' ^ ';
                fRef.n7.value = ' & ';
                fRef.n8.value = ' * ';
                fRef.n9.value = ' ( ';
                fRef.n0.value = ' ) ';
                fRef.s0.value = ' ~ ';
                fRef.s1.value = ' _ ';
                fRef.s2.value = ' + ';
                fRef.s3.value = ' { ';
                fRef.s4.value = ' } ';
                fRef.s5.value = ' | ';
                fRef.s6.value = ' : ';
                fRef.s7.value = ' " ';
                fRef.s8.value = ' < ';
                fRef.s9.value = ' > ';
                fRef.s10.value = ' ? ';

                for (var i = 0; i < letters.length; i++)
                {
                    var letter = letters.substring(i, i + 1)
                    fRef[letter].value = ' ' + letter.toUpperCase() + ' ';
                }
            } else
            {
                fRef.caps.value = ' Shift ';

                fRef.n1.value = ' 1 ';
                fRef.n2.value = ' 2 ';
                fRef.n3.value = ' 3 ';
                fRef.n4.value = ' 4 ';
                fRef.n5.value = ' 5 ';
                fRef.n6.value = ' 6 ';
                fRef.n7.value = ' 7 ';
                fRef.n8.value = ' 8 ';
                fRef.n9.value = ' 9 ';
                fRef.n0.value = ' 0 ';
                fRef.s0.value = ' ` ';
                fRef.s1.value = ' - ';
                fRef.s2.value = ' = ';
                fRef.s3.value = ' [ ';
                fRef.s4.value = ' ] ';
                fRef.s5.value = ' \\ ';
                fRef.s6.value = ' ; ';
                fRef.s7.value = " ' ";
                fRef.s8.value = ' , ';
                fRef.s9.value = ' . ';
                fRef.s10.value = ' / ';

                for (var i = 0; i < letters.length; i++)
                {
                    var letter = letters.substring(i, i + 1)
                    fRef[letter].value = ' ' + letter + ' ';
                    alert(fRef[letter].value);
                }
            }

        }

        function noBack()
        {
            window.history.forward();
        }

        function do_Load()
        {
            noBack();
            document.form1.UID.value = "";
            if (document.form1.UID.value == "")
            {
                document.form1.UID.focus();
            } else
            {
                document.form1.PWD.focus();

            }
        }

        function del()
        {
            var input = document.form1.PWD.value;
            if (input.length > 0)
                document.form1.PWD.value = input.substring(0, input.length - 1);
        }

        function clearform(dumForm)
        {
            dumForm.reset();
        }

        function gotoProductsandServices()
        {
            document.form2.HandleID.value = "I_LOGPROD";

        }
    </script>

    <script>
        window.onload = function () {
            setTimeout(function () {
                document.getElementById('resendbtn').disabled = false;
            }, 60000);  // 30000 milliseconds = 30 seconds

            var countdownElement = document.getElementById('countdown');
            var resetButton = document.getElementById('resetButton');
            var countdown = 60; // this is the countdown starting time(seconds)

            countdownElement.innerText = countdown;

            var intervalId = setInterval(function () {
                countdown--;
                countdownElement.innerText = countdown;
                if (countdown <= 0) {
                    clearInterval(intervalId);
                    resetButton.disabled = false;
                    document.getElementById('timer').innerText = 'You can now reset.';
                }
            }, 1000);  // this updates countdown every second

        };
    </script>


    <div class="container">
        <div class="left-section">
            <img id="logo" src="/PacsApplication/img/logo.png" alt="Logo" draggable="false">
            <h1 onselectstart="return false">Integrated <br>PACS Kisan<br>Solution<br>(IPKS)</h1>
        </div>
        <div class="footer">
            <p onselectstart="return false">Copyright © 2023 Tata Consultancy Services, All rights reserved.</p>
        </div>
        <div class="right-section">

            <%if (otp_flag == null) {%>
            <div class="header">
                <h1 id="sign_in" onselectstart="return false">Sign In</h1>
            </div>
            <%} else {%>
            <div class="header">
                <br><br>
                <h1 id="otp_entry" onselectstart="return false">Enter OTP</h1>
            </div>
            <%}%>

            <!--<div id="tooltip2" style="VISIBILITY: hidden; WIDTH: 120px; CLIP: rect(0px 150px 50px 0px); POSITION: absolute; BACKGROUND-COLOR: #FFFFFF" ></div>-->

            <%if (otp_flag == null) {%>
            <form form id="form1" name="form1" method="post" action="/PacsApplication/LoginServlet">
                <div class="form-group">
                    <input type="text" id="username" maxlength="6" name="UID" id="UID" placeholder="Login ID" required size=43 onkeypress='return event.charCode >= 48 && event.charCode <= 57' style="height: 24px;">
                </div>

                <div class="form-group">
                    <input type="password" autocomplete="off" placeholder="Password" onkeypress="checkCapsLock(event)" id="PWD" name="PWD" required size=43 style="height: 24px;">
                </div>

                <div class="form-group">
                    <input type="text" maxlength="5" id="PACSID" placeholder="PACS ID/Bank ID" name="PACSID" required size=43 onkeypress='return event.charCode >= 48 && event.charCode <= 57' style="height: 24px;" >
                </div>

                <div class="form-group">
                    <select name="moduleName" id="moduleName" placeholder="MODULE">

                        <option value=""> --Select-- </option>
                        <option value="kcc">KCC Module</option>
                        <option value="trading">Trading Module</option>
                        <option value="asset">Asset Module</option>
                        <option value="shg">Self Help Group Module</option>
                        <option value="dashboard">MIS & Dashboard Module</option>
                        <option value="Deposit">Deposit Module</option>
                        <option value="Loan">Loan Module</option>
                        <option value="share">Share Module</option>
                        <option value="dds">DDS Module</option>
                        <option value="payroll">Payroll Module</option>

                    </select>
                </div>
                <div class="error-msg">
                    <font color="red" size="3px" ><b><%= error_msg%></b></font>
                </div>
                <div class="button-container">
                    <button id = "loginbtn" type="submit" onclick="javascript:submitform(form1)">Login</button>
                    <button id= "resetbtn" type="" onclick="ShowParent();">Reset</button>
                </div>
            </form>
            <!--xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-->
            <%} else {%>
            <form form id="otpform" name="otpform" method="post" action="/PacsApplication/OtpVerificationServlet">

                <div class="form-group">
                    <input type="password" autocomplete="off" placeholder="OTP" maxlength="4" onkeypress='return event.charCode >= 48 && event.charCode <= 57' id="otp" name="otp" required size=4 style="height: 24px;">
                </div>
                <div class="error-msg">
                    <font color="red" size="3px" ><b><%= error_msg%></b></font>
                </div>
                <div class="button-container">
                    <button id = "submitbtn" type="submit" onclick="javascript:submitform(otpform)">Submit</button>
                    <button id= "resendbtn" type="" disabled onclick="resenOtp();">Resend</button>
                </div>
            </form>

            <p id="timer" color="red" style="font-family: Rubik;font-size: 16px; color:red">You can resend OTP after <span id="countdown">60</span> seconds.</p>

            <%}%>
            <!--<p class="copyright">Copyright © 2023 Tata Consultancy Services, All rights reserved.</p>-->
        </div>
    </div>


    <!--    <script src="script1.js"></script>
        <script src="script2.js"></script>-->



</body>

</html>













<% 	} catch (Exception e) {
        System.out.println("EX in " + e);
    }
%>