<%-- 
    Document   : CommonSearchPhotoSignatureLOV
    Created on : Jun 7, 2017, 1:53:19 PM
    Author     : 594267
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="LoginDb.DbHandler"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.io.*"%>
<%@page import="java.util.*"%>
<%@page import="java.sql.Connection"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Product Selection</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/ButtonAndText.css" />
        <script src="${pageContext.request.contextPath}/jquery-ui-1.10.4.custom/development-bundle/jquery-1.10.2.js"></script>
         <style> 
          
           * { 
			box-sizing: border-box; 
		} 
		.sig:hover { 
			-ms-transform: scale(4.6); 
			/* IE 9 */ 
			-webkit-transform: scale(1.5); 
			/* Safari 3-8 */ 
			-moz-transform:  scale(3.0); 
		} 
	</style>   
        
        
        
        <script>

            var f = 1;

            function imageExists(url){

                var ret_url = "${pageContext.request.contextPath}/img/faceDefault - Copy.jpg";
                var image = new Image();

                image.src = url;

                if (!image.complete) {
                    document.getElementById('photo').setAttribute('src',ret_url);
                }
                else if (image.height === 0) {
                    document.getElementById('photo').setAttribute('src',ret_url);
                } else
                    document.getElementById('photo').setAttribute('src',url);

                
            }

            function sigImageExists(url){
                var image = new Image();

                image.src = url;

                if (!image.complete) {
                    document.getElementById('sig').style.display = 'none';
                    document.getElementById('noSig').style.display = 'block';
                    f = 0;
                }
                else if (image.height === 0) {
                    document.getElementById('sig').style.display = 'none';
                    document.getElementById('noSig').style.display = 'block';
                    f = 0;
                } else {
                    document.getElementById('sig').style.display = 'block';
                    document.getElementById('noSig').style.display = 'none';
                    f = 1;
                }

            }

            function clickFunc(){
                opener.document.getElementById('image-holder').style.display = 'block';
                opener.document.getElementById('blah').setAttribute('src',document.getElementById('photo').getAttribute('src'));
                if(f == 1){
                    opener.document.getElementById('blahsig').setAttribute('src',document.getElementById('sig').getAttribute('src'));
                    opener.document.getElementById('noSig').style.display = 'none';
                } else if(f == 0) {
                    opener.document.getElementById('blahsig').style.display = 'none';
                    opener.document.getElementById('noSig').style.display = 'block';
                }
                self.close();
            }
        </script>

        <%
                    String searchString1 = "";
                    String screenName = "";
                    String searchString2 = "";
                    String lovKey = "";
                    String textIndex = "";
                    String tranType = "";
                    String productCode = "";
                    String searchString3 = "";


                    screenName = request.getParameter("screenName");
                    lovKey = request.getParameter("lovKey");
                    String pacsId = session.getAttribute("pacsId").toString();
                    textIndex = request.getParameter("textIndex");
                    String subPacsFlag = (String) session.getAttribute("subPacsFlag");
                    String headPacsId = (String) session.getAttribute("headPacsId").toString();

                    String headerQry = null;

                    searchString1 = request.getParameter("custNo");
                    
                    String bgColor = null;
                    int flag = 1;

        %>
        <title>Photo Signature</title>
    </head>
    <body style="background-image: url('/PacsApplication/img/download.jpg');" onload="javascript:imageExists('${pageContext.request.contextPath}/UploadedFiles/<%=searchString1 + ".jpg"%>');javascript:sigImageExists('${pageContext.request.contextPath}/UploadedFiles/<%="sig-" + searchString1 + ".jpg"%>')">
        <%
                        if (searchString1 == null || searchString1.isEmpty()) {
        %>
        <center><p>Please search a account to get the photo and signature</p>
            <input type="button" value="Close Window" onclick="self.close();">
        </center>
        <%} else {%>
        <table border="2">
            <tr><th style="background-color: #99FF99;"><b>CIF Number</b></th><th style="background-color: #99FF99;"><b>Photo</b></th><th style="background-color: #99FF99;"><b>Signature</b></th></tr>
            <% if (flag == 1) {
                                            flag = 0;
                                            bgColor = "#AFC7C7";
                                        } else {
                                            flag = 1;
                                            bgColor = "#95B9C7";
                                        }%>
            <tr>
                <td bgcolor='<%=bgColor%>' id='x' onclick="javascript:clickFunc()" style="cursor:pointer;"><%=searchString1%></td>
                <td bgcolor='<%=bgColor%>' id='y' onclick="javascript:clickFunc()"
                    style="cursor:pointer;"><img id="photo" src="${pageContext.request.contextPath}/UploadedFiles/<%=searchString1 + ".jpg"%>" height="150" width="140" border="1px"/></td>
                <td bgcolor='<%=bgColor%>' id='z' onclick="javascript:clickFunc()" style="cursor:pointer;">
                    <img id="sig" src="${pageContext.request.contextPath}/UploadedFiles/<%="sig-" + searchString1 + ".jpg"%>" height="50" width="140" border="1px"/>
                    <p id="noSig" style="display: none"><b>No Signature found</b></p>
                </td>


            </tr>

        </table>
        <%}%>
       
    </body>
</html>
