<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="/WEB-INF/dateformat.tld" prefix="da" %>
<%--
  ~ This file is part of DebGen Biobank Software developed by ASTRID Research.
  ~ All rights reserved. Reproduction, modification, use or disclosure
  ~ to third parties without express authority is forbidden.
  ~
  ~ Copyright ASTRID Research Inc., Hungary, 2009-2011.
  ~
  ~ ASTRID Research
  ~ Headquaters: Csapo utca 42. Debrecen H-4029 HUNGARY
  ~ Phone: +36-52-533-173        Fax: +36-52-533-174
  ~ Web: http://www.astrid.hu    E-mail: info@astrid.hu
  ~
  ~ Project name: DebGen Biobank Software project.
  ~ URLS:
  ~ Developers: Istvan Zoltan Nagy (istvan.nagy@astrid.hu)
  --%>

<script type="text/javascript">
    setWebTitle('<fmt:message key="biobankModule" />');
    autocompleteOff();


    function removeElement(divNum) {

        var root = document.getElementById('attachmentDiv');
        var olddiv = document.getElementById(divNum);
        root.removeChild(olddiv);
        controllBtns();
    }

    function addFileUploadDiv(i18nattachmentlabel, i18nremovelabel) {


        var root = document.getElementById('attachmentDiv');
        var rootChildNodeArray = document.getElementById('attachmentDiv').getElementsByTagName("div");
        var num = rootChildNodeArray.length + 1;


        var innerItemId = "fileUpload" + num;
        var newdiv = document.createElement('div');
        var divIdName = 'uploadDiv' + num;

        newdiv.setAttribute('id', divIdName);
        newdiv.innerHTML = '<label>' + i18nattachmentlabel + '</label><input type="file" name="' + innerItemId + '" id="' + innerItemId + '"/> <a href="javascript:;" onclick="removeElement(\'' + divIdName + '\')">' + i18nremovelabel + '</a>'

        //newdiv.innerHTML = '<label>Attachment: </label><div class="fileinputs"><input type="file" class="file" name="'+innerItemId+'" id="'+innerItemId+'" onchange="document.getElementById('fake'+innerItemId).value = document.getElementById('+innerItemId+').value;"/><div class="fakefile"><input id="'fake'+innerItemId"/><input class="redbutton" type="submit" value="Browse" /></div></div><a href="javascript:;" onclick="removeElement('+divIdName+')">Remove</a>'

        root.appendChild(newdiv);

        controllBtns();
    }


    function removeFileUploadDiv() {

        var root = document.getElementById('attachmentDiv');
        var rootChildNodeArray = document.getElementById('attachmentDiv').getElementsByTagName("div");
        var num = rootChildNodeArray.length;

        var removeableDiv = document.getElementById('uploadDiv' + num);
        root.removeChild(removeableDiv);

        controllBtns();

    }

    function controllBtns() {

        var attachLink = document.getElementById('attachBtn');
        var addLink = document.getElementById('addBtn');
        var removeLink = document.getElementById('removeBtn');

        var root = document.getElementById('attachmentDiv');
        var rootChildNodeArray = document.getElementById('attachmentDiv').getElementsByTagName("div");
        var num = rootChildNodeArray.length;

        if (num == 0) {
            attachLink.disabled = true;
            removeLink.disabled = true;
        }
        else {
            attachLink.disabled = false;
            removeLink.disabled = false;
        }

    }


</script>
<div class="window500">
    <div class="title"><fmt:message key="${module.objectType}Module" /></div>
    <div class="content">
        <div style="padding: 10px;">
            <table border="0" cellspacing="10" cellpadding="5">
                <tbody>
                    <tr>
                        <td class="patientheader"></td>
                        <td><fmt:message key="biobankModule" /></td>
                </tr>
                </tbody>
            </table>
            <table align="center" border="0" cellspacing="10" cellpadding="0">
                <tbody>
                    <tr>
                        <c:if test="${user.dataRecorder}">
                            <td class="button" align="center" valign="middle"
                                style="width: 100px; height: 25px; background: url('pics/buttonbgr.png');"><a class="menulink" style="display: block; width: 100px; padding-top: 4px;" href="createmodule.html?module=${module.id}"><fmt:message key="SZERKESZTÉS" /></a>
                            </td>
                        </c:if>
                        <td class="button" align="center" valign="middle"
                            style="width: 100px; height: 25px; background: url('pics/buttonbgr.png');"><a class="menulink" style="display: block; width: 100px; padding-top: 4px;" href="printmodule.html?module=${module.id}"><fmt:message key="PRINT" /></a>
                        </td>
                        <td class="button" align="center" valign="middle"
                            style="width: 100px; height: 25px; background: url('pics/buttonbgr.png');"><a class="menulink" style="display: block; width: 100px; padding-top: 4px;" href="generatepdfmodule.html?module=${module.id}"><fmt:message key="PDF" /></a>
                        </td>
                    </tr>
                </tbody>
            </table>
            <div id="line" style="width: 476px;" class="patientline">
                <fmt:message key="BIOBANK_MODULE_DATA" />
            </div>
            <%@ include file="../showembedederror.jsp" %>
            <div id="userdiv">
                <table class="formtable" border="0" width="477px" cellspacing="0" cellpadding="3">
                    <tbody>
                        <tr>
                            <td style="width: 120px;"><fmt:message key="patientCode" />:</td>
                    <td style="width: 340px;"><a href="showpatient.html?patient=${module.patient.id}">${module.patient.patientCode}</a>
                    </td>
                    </tr>
                    <c:if test="${not module.patient.named or not user.dataRecorder}">
                        <tr>
                            <td style="width: 120px;" ><fmt:message key="monogram" />:</td>
                        <td>
                            ${module.patient.anonymousData.monogram}
                        </td>
                        </tr>
                    </c:if>
                    <c:if test="${module.patient.named and user.dataRecorder}">
                        <tr>
                            <td style="width: 120px;"><fmt:message key="BETEG_NEV" />:</td>
                        <td>${module.patient.identity.patientName}</td>
                        </tr>
                        <tr>
                            <td style="width: 120px;"><fmt:message key="TAJ" />:</td>
                        <td>${module.patient.identity.tajNumber}</td>
                        </tr>
                    </c:if>
                    <tr>
                        <td style="width: 120px;"><fmt:message key="Type" />:</td>
                    <td style="width: 340px;">
                    <fmt:message key="${module.objectType}Module" />
                    </td>
                    </tr>
                    <tr>
                        <td style="width: 112px;" ><fmt:message key="requestIdChooser" />:</td>
                    <td style="width: 340px;"><c:if test="${not empty module.request}"><a href="showrequest.html?request=${module.request.id}">${module.request.createdOnForWeb} - <fmt:message key="${module.request.localizeableName}" /></a></c:if></td>
                    </tr>
                    </tbody>
                </table>
                <div class="patientline"><fmt:message key="moduleData" /></div>
                <%@ include file="../showembedederror.jsp" %>
                <div id="userdiv">
                    <div id="common">
                        <table class="formtable" border="0" width="477px" cellspacing="0" cellpadding="3">
                            <tbody>
                                <!--tr>
                                    <td style="width: 112px;"><fmt:message key="moduleType" />:</td>
                            <td style="width: 340px;"><fmt:message key="${module.objectType}Module" />
                            </td>
                            </tr-->
                                <tr>
                                    <td style="width: 112px;" ><fmt:message key="sampleOfAnalysis" />:</td>
                            <td style="width: 340px;"><fmt:message key="${module.sampleOfAnalysis}" /></td>
                            </tr>
                            <tr>
                                <td style="width: 112px;" ><fmt:message key="indicationOfAnalysis" />:</td>
                            <td style="width: 340px;">
                                ${module.indicationOfAnalysis}
                            </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <c:if test="${module.objectType eq 'citogen'}">
                        <div id="citogen" style="display: ${empty module or module.objectType eq 'citogen' ? 'block' : 'none'}">
                            <table class="formtable" border="0" width="477px" cellspacing="0" cellpadding="3">
                                <tbody>
                                    <tr>
                                        <td style="width: 112px;"><fmt:message key="tenyesztesiIdo" />:</td>
                                <td style="width: 340px;"><fmt:message key="${module.citTenyesztesiIdo}" /></td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="analysedMetaPhases" />:</td>
                                <td style="width: 340px;">${module.citAnalysedMetaPhases gt 0 ? module.citAnalysedMetaPhases : ''}</td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="countedMetaPhases" />:</td>
                                <td style="width: 340px;">${module.citCountedMetaPhases gt 0 ? module.citCountedMetaPhases : ''}</td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="trackingTechnique" />:</td>
                                <td style="width: 340px;"><fmt:message key="${module.citTrackingTechnique}" /></td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="karyotype" />:</td>
                                <td style="width: 340px;">${module.citKaryotype}</td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="resultInformation" />:</td>
                                <td style="width: 340px;">${module.citResultInformationForWeb}</td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </c:if>
                    <c:if test="${module.objectType eq 'fish'}">
                        <div id="fish" style="display: ${module.objectType eq 'fish' ? 'block' : 'none'}">
                            <table class="formtable" border="0" width="477px" cellspacing="0" cellpadding="3">
                                <tbody>
                                    <tr>
                                        <td style="width: 112px;"><fmt:message key="fishSampleTakenOn" />:</td>
                                <td style="width: 340px;">${module.objectType eq 'fish' ? module.fishSampleTakenOnForWeb : ''}</td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="fishTenyesztesiIdo" />:</td>
                                <td style="width: 340px;"><fmt:message key="${module.fishTenyesztesiIdo}" /></td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="fishUsedTest" />:</td>
                                <td style="width: 340px;">${module.objectType eq 'fish' ? module.fishUsedTest : ''}</td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="fishResult" />:</td>
                                <td style="width: 340px;">${module.objectType eq 'fish' ? module.fishResultForWeb : ''}</td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="fishOpinion" />:</td>
                                <td style="width: 340px;">${module.objectType eq 'fish' ? module.fishOpinionForWeb : ''}</td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </c:if>
                    <c:if test="${module.objectType eq 'acho'}">
                        <div id="acho" style="display: ${module.objectType eq 'acho' ? 'block' : 'none'}">
                            <table class="formtable" border="0" width="477px" cellspacing="0" cellpadding="3">
                                <tbody>
                                    <tr>
                                        <td style="width: 112px;"><fmt:message key="achoSampleTakenOn" />:</td>
                                <td style="width: 340px;">${module.objectType eq 'acho' ? module.achoSampleTakenOnForWeb : ''}</td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="achoUsedTest" />:</td>
                                <td style="width: 340px;">${module.objectType eq 'acho' ? module.achoUsedTest : ''}</td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="achoDifference" />:</td>
                                <td style="width: 340px;">${module.objectType eq 'acho' ? module.achoDifference : ''}</td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="achoResult" />:</td>
                                <td style="width: 340px;">${module.objectType eq 'acho' ? module.achoResultForWeb : ''}</td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="achoOpinion" />:</td>
                                <td style="width: 340px;">${module.objectType eq 'acho' ? module.achoOpinionForWeb : ''}</td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </c:if>
                    <c:if test="${module.objectType eq 'hypo'}">
                        <div id="hypo" style="display: ${module.objectType eq 'hypo' ? 'block' : 'none'}">
                            <table class="formtable" border="0" width="477px" cellspacing="0" cellpadding="3">
                                <tbody>
                                    <tr>
                                        <td style="width: 112px;"><fmt:message key="hypoSampleTakenOn" />:</td>
                                <td style="width: 340px;">${module.objectType eq 'hypo' ? module.hypoSampleTakenOnForWeb : ''}</td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="hypoUsedTest" />:</td>
                                <td style="width: 340px;">${module.objectType eq 'hypo' ? module.hypoUsedTest : ''}</td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="hypoDifference" />:</td>
                                <td style="width: 340px;">${module.objectType eq 'hypo' ? module.hypoDifference : ''}</td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="hypoResult" />:</td>
                                <td style="width: 340px;">${module.objectType eq 'hypo' ? module.hypoResultForWeb : ''}</td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="hypoOpinion" />:</td>
                                <td style="width: 340px;">${module.objectType eq 'hypo' ? module.hypoOpinionForWeb : ''}</td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </c:if>
                    <c:if test="${module.objectType eq 'fmr1'}">
                        <div id="fmr" style="display: ${module.objectType eq 'fmr1' ? 'block' : 'none'}">
                            <table class="formtable" border="0" width="477px" cellspacing="0" cellpadding="3">
                                <tbody>
                                    <tr>
                                        <td style="width: 112px;"><fmt:message key="fmrSampleTakenOn" />:</td>
                                <td style="width: 340px;">${module.objectType eq 'fmr1' ? module.fmrSampleTakenOnForWeb : ''}</td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="fmrUsedTest" />:</td>
                                <td style="width: 340px;">${module.objectType eq 'fmr1' ? module.fmrUsedTest : ''}</td>
                                </tr>
                                <tr>
                                    <td style="width: 112px;"><fmt:message key="fmrResult" />:</td>
                                <td style="width: 340px;">${module.objectType eq 'fmr1' ? module.fmrResultForWeb : ''}</td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </c:if>
                </div>

                <div class="patientline"><fmt:message key="attachedKariogramTitle" /></div>
                <div id="userdiv">
                	<c:if test="${empty module.kariograms}">
                		<br/>
                		<fmt:message key="noattachedkariogram" />
                		<br/>
                		<br/>
                	</c:if>

                	 <c:forEach items="${module.kariograms}" var="kariogram">
                	 	<c:url var="deletelink" value="deletekariogram.html"><c:param name="module" value="${module.id}"/><c:param name="kariogram" value="${kariogram.id}"/></c:url>
                      	<c:url var="displaylink" value="displaykariogram.html"><c:param name="module" value="${module.id}"/><c:param name="kariogram" value="${kariogram.id}"/></c:url>
                        
                      	<a style="float: left;" href="${displaylink}"><fmt:message key="kariogram" /></a>
                      	<form action="${deletelink}" method="post">
                      			<input onclick="return confirm('<fmt:message key="attachmentDetele" />');" type="submit" style="width: 17px; height: 16px; border: 0; background: url('pics/deleteicon.png');" id="deleteBtn" value=" "/>
                      	</form><br/>
                    </c:forEach>
                </div>


                <div class="patientline"><fmt:message key="attachKariogramTitle" /></div>

                 <!-- Add, Remove  btns-->
                <div id="controllerBtns">
                	<table>
                		<tr>
                			 <td class="button" align="center" valign="middle"
                                style="width: 100px; height: 25px; background: url('pics/buttonbgr.png');"><a class="menulink" style="display: block; width: 100px; padding-top: 4px;" id="addBtn" onclick="addFileUploadDiv('<fmt:message key="attachment" />','<fmt:message key="remove" />')">+</a>
                             </td>
                             <td class="button" align="center" valign="middle"
                                style="width: 100px; height: 25px; background: url('pics/buttonbgr.png');"><a class="menulink" style="display: block; width: 100px; padding-top: 4px;" id="removeBtn" onclick="removeFileUploadDiv()">-</a>
                			 </td>
                		</tr>
                	</table>
                </div>

                <form name="module" action="attachkariogrammodule.html?module=${module.id}" enctype="multipart/form-data" method="post">
                	<div id="attachmentDiv">

                		<!-- JavaScript added divs will come here! -->

                	</div>
                	<input class="button" style="width: 100px; height: 25px; background: url('pics/buttonbgr.png');" type="submit" id="attachBtn" value="<fmt:message key="attachBtn" />"/>
                </form>

            </div>
        </div>
    </div>
    <div class="copyright">
        &copy; 2009-2010 Astrid Research Inc.
    </div>
</div>
<script type="text/javascript">
	controllBtns();
</script>
