Commit a02b4288 authored by vkadam's avatar vkadam

JS component for view attachments of Bank Guarantee.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98556 ce508802-f39f-4f6c-b175-0d175dae99d5
parent f0a39d3e
var tranEditorId = "TRANID" + Math.floor((Math.random()*100000)+1);
var docIds = [];
var documents = "";
var highlightDiv;
function viewAttachmentsOnLoad()
{
var divHeight = 300;
if ( parent.document.getElementById('splitterBottomPane') != null )
{
divHeight = +(parent.document.getElementById('splitterBottomPane').clientHeight);
}
divHeight = Math.floor(+divHeight - 4);
if ( document.getElementById("attachDetailSrc") != null && document.getElementById("attachDetailSrc") != undefined )
{
document.getElementById("attachDetailSrc").setAttribute("style", "overflow: auto; height:"+ divHeight +"px");
document.getElementById("attachFeed").setAttribute("style", "height:"+ divHeight +"px");
}
if ( document.getElementsByName( "document" ) != null && document.getElementsByName( "document" ) != undefined )
{
var rows = document.getElementsByName( "document" ).length;
for ( var i = 0; i < rows; i++)
{
if ( document.getElementsByName( "document" )[i] != null && document.getElementsByName( "document" )[i] != undefined )
{
var doc = document.getElementsByName( "document" )[i].value;
if ( doc != "" && doc.length > 1 )
{
doc = doc.substring( 1, doc.length-1 )
var docId = doc.split("~")[0];
docIds.push( docId );
}
}
}
viewAttachDocument();
}
if ( document.getElementById('attachList0') != null && document.getElementById('attachList0') != undefined )
{
document.getElementById('attachList0').setAttribute("class", "viewdata-Link");
highlightDiv = document.getElementById('attachList0');
}
}
function viewAttachDocument()
{
var divHeight = 300;
if ( parent.document.getElementById('splitterBottomPane') != null )
{
divHeight = +(parent.document.getElementById('splitterBottomPane').clientHeight);
}
iframeHeight = Math.floor(+divHeight - 45);
documents = "";
$.ajax({
async : false,
url : "/ibase/SSCEditorServlet?ACTION=GET_DOCUMENT&DOC_ID="+ docIds,
dataType : 'text',
type : 'POST',
success : function(result) {
documents = result;
}
});
var mainattachmentContainer = document.getElementById("fileViewer");
var docNames = documents.split(",");
for (var inc = 0; inc < docNames.length; inc++ )
{
var iFrame = "<div id='viewerHeader" + inc + "' class='viewerHeader' >" +
"<div style='float: left; margin-top: 5px;' id='viewerHeaderText" + inc + "' class='headerText'></div>" +
"<iframe class='att-iframe' id='att-iframe" + inc + "' name ='att-iframe" + inc + "' src='' style='height: "+ iframeHeight +"px;' frameborder='0' scrolling='no' ></iframe>" +
"</div>";
mainattachmentContainer.innerHTML += iFrame;
document.getElementById("att-iframe"+inc).src = "../../PayAuthAttachments/"+ docNames[inc]; //Added by Prasad on 22/05/15 [for source to iframe]
var attachedFile = document.getElementById("viewerHeaderText"+inc);
attachedFile.innerHTML = "&nbsp;&nbsp;" + (inc + 1) + "&nbsp;-&nbsp;"+ docNames[inc];
var docType = docNames[inc].split(".")[1];
if ( docType != null && docType != undefined && ( docType.trim() == 'ods' || docType.trim() == 'log' || docType.trim() == 'sql') )
{
document.getElementById("att-iframe"+inc).srcdoc = "<p>You cannot view this file on browser.</p>";
}
}
viewAttachloading( false );
}
function downloadDoc( docRefId, inc )
{
var docRefIdArr = docRefId.split("~");
var docId = docRefIdArr[0];
var docType = docRefIdArr[1];
var attDocId = docId;
var attDocName = document.getElementById(docId).title;
var refId = document.getElementById("DB_ID").value;
if (refId == null)
{
refId = "";
}
if (refId.substring(refId.length - 1, refId.length) == ":")
{
refId = refId.substring(0, refId.length - 1);
}
if (refId == "" || refId == ":")
{
refId = tranEditorId;
}
var divHeight = 300;
if ( parent.document.getElementById('splitterBottomPane') != null )
{
divHeight = +(parent.document.getElementById('splitterBottomPane').clientHeight);
}
iframeHeight = Math.floor(+divHeight - 45);
var url = "/ibase/WebITMDocumentHandlerServlet?OBJ_NAME=" + objName
+ "&REF_ID=" + refId
+ "&ACTION=GET_DOCUMENT&CLIENT=WEB1&DOC_ID=" + docId
+ "&DOC_TYPE=" + docType;
var iFrame = "<div id='viewerHeader" + inc + "' class='viewerHeader' onmouseover='onMouseOverDiv("+ inc +")'>" +
"<div style='float: left; margin-top: 5px;' id='viewerHeaderText" + inc + "' class='headerText'></div>" +
"<iframe class='att-iframe' id='att-iframe" + inc + "' name ='att-iframe" + inc + "' src='" + url + "' style='height: "+ iframeHeight +"px;' ></iframe>" +
"</div>";
var mainattachmentContainer = document.getElementById("fileViewer");
mainattachmentContainer.innerHTML += iFrame;
var attachedFile = document.getElementById("viewerHeaderText"+inc);
attachedFile.innerHTML = "&nbsp;&nbsp;" + (inc + 1) + "&nbsp;-&nbsp;" + attDocName;
if (docType.trim() == 'ods' || docType.trim() == 'log' || docType.trim() == 'sql')
{
document.getElementById("att-iframe"+inc).srcdoc = "<p>You cannot view this file on browser.</p>";
}
}
function downloadAttach( docRefId )
{
docRefId = docRefId.substring(9, docRefId.length);
var docRefIdArr = docRefId.split("~");
var docId = docRefIdArr[0];
var docType = docRefIdArr[1];
var refId = document.getElementById("DB_ID").value;
if (refId == null)
{
refId = "";
}
if (refId.substring(refId.length - 1, refId.length) == ":")
{
refId = refId.substring(0, refId.length - 1);
}
if (refId == "" || refId == ":")
{
refId = tranEditorId;
}
var url = "/ibase/WebITMDocumentHandlerServlet?OBJ_NAME=" + objName
+ "&REF_ID=" + refId
+ "&ACTION=GET_DOCUMENT&CLIENT=WEB1&DOC_ID=" + docId
+ "&DOC_TYPE=" + docType;
window.open(url);
}
function deleteAttach(refId)
{
var isConfirm = confirm("Do you want to delete file ?");
if ( isConfirm )
{
var objName = "voucher";
var vochNo = document.getElementById("DB_ID").value;
if (refId != "")
{
var url="AttachmentView.jsp?ACTION=REMOVE&OBJ_NAME="+ objName +"&REF_ID="+ refId;
var fullwidth = eval(screen.width) / 2 + 130;
var fullheight = screen.height - 70;
parent.document.getElementById("attachSrc").src = url;
}
}
}
function getDivFocus( index )
{
window.location.hash = '#viewerHeader'+index;
scrollAttachDiv();
}
function onMouseOverDiv( index )
{
if ( document.getElementsByName( "document" ) != null && document.getElementsByName( "document" ) != undefined )
{
var rows = document.getElementsByName( "document" ).length;
for ( var i = 0; i < rows; i++)
{
if ( i == index )
{
document.getElementById('attachList'+i).style.backgroundColor = "gray";
document.getElementById('attachList'+i).style.color = "#FFF";
}
else
{
document.getElementById('attachList'+i).style.backgroundColor = "";
document.getElementById('attachList'+i).style.color = "";
}
}
}
}
function HighlightNScrollDiv()
{
if ( document.getElementsByName( "document" ) != null && document.getElementsByName( "document" ) != undefined )
{
var attachCnt = document.getElementsByName( "document" ).length;
var outerDivHt = document.getElementById('attachDetailSrc').scrollHeight;
var outerDivST = document.getElementById('attachDetailSrc').scrollTop;
var scrollHt = outerDivHt / attachCnt;
var scrollPos = (outerDivST - scrollHt) / scrollHt;
for ( var i = 0; i < attachCnt; i++)
{
if ( i == Math.round(scrollPos) + 1 )
{
document.getElementById('attachList'+i).setAttribute("class", "viewdata-Link");
if ( highlightDiv != document.getElementsByClassName("viewdata-Link")[0] )
{
scrollAttachDiv();
highlightDiv = document.getElementsByClassName("viewdata-Link")[0];
}
}
else
{
document.getElementById('attachList'+i).setAttribute("class", "attachLinkDiv");
}
}
}
}
function scrollAttachDiv()
{
if ( document.getElementsByClassName("viewdata-Link")[0] != null && document.getElementsByClassName("viewdata-Link")[0] != undefined )
{
var divPosition = document.getElementsByClassName("viewdata-Link")[0].getBoundingClientRect();
document.getElementById('attachFeed').scrollTop = divPosition.top;
}
}
function resizeWindow()
{
window.scrollTo(0,0);
var divHeight = 300;
if ( parent.document.getElementById('splitterBottomPane') != null && parent.document.getElementById('splitterBottomPane') != undefined )
{
divHeight = +(parent.document.getElementById('splitterBottomPane').clientHeight);
}
divHeight = Math.floor(+divHeight - 4);
if ( document.getElementById("attachDetailSrc") != null && document.getElementById("attachDetailSrc") != undefined )
{
document.getElementById("attachDetailSrc").setAttribute("style", "overflow: auto; height:"+ divHeight +"px");
document.getElementById("attachFeed").setAttribute("style", "height:"+ divHeight +"px");
}
}
function selectedRowsHighlight( index )
{
if(document.getElementById('Details') != null && document.getElementById('Details') != undefined)
{
var rows = document.getElementsByName('Details-tab').length;
for(var i = 0; i < rows; i++)
{
document.getElementById("Details-"+i).setAttribute("class", "");
}
if (document.getElementById(index) != null && document.getElementById(index) != undefined )
{
document.getElementById(index).setAttribute("class", "highlight-selected");
}
}
}
function viewAttachments(refId)
{
var objName = "voucher";
var vochNo = refId;
viewAttachloading( true );
if (refId != "")
{
var url = "AttachmentView.jsp?ACTION=LOAD&VIEWFROM=PayAuth&OBJ_NAME=" + objName + "&REF_ID="+ vochNo;
document.getElementById("attachSrc").src = url;
}
}
function viewReport(refId)
{
var count = 0;
var url = "", objName = "";
viewReportloading( true );
if (refId != "")
{
$.ajax({
async : false,
url : "/ibase/SSCEditorServlet?ACTION=GET_REPORT_TYPE&VOUCHER_NO="+refId,
dataType : 'text',
type : 'POST',
success : function(result) {
count = result;
}
});
if ( count > 0 )
{
objName = "d_voucher_summary_tran";
url = "/ibase/webitm/jasprerportria/CustomReportJasp.jsp?OBJ_NAME=" + objName + "&as_tran_id=" + refId;
}
else
{
objName = "d_misc_voucher_sum_tran";
url = "/ibase/webitm/jasprerportria/CustomReportJasp.jsp?OBJ_NAME=" + objName + "&frmtranid=" + refId;
}
document.getElementById("reportSrc").src = url;
viewReportloading( false );
}
}
function viewMiscReport(refId)
{
var objName = "d_misc_voucher_sum_tran";
if (refId != "")
{
var url = "/ibase/webitm/jasprerportria/CustomReportJasp.jsp?OBJ_NAME=" + objName + "&frmtranid=" + refId;
var fullwidth = eval(screen.width) / 2 + 130;
var fullheight = screen.height - 70;
window.open(url, "", "toolbar=no,status=yes,resizable=no,scrollbars=no,left=250,top=0,width=" + fullwidth + ",height=" + fullheight);
}
}
function viewReportloading( flag )
{
if ( parent.document.getElementById("loadingReportDiv") != null )
{
if ( flag )
{
parent.document.getElementById("loadingReportDiv").style.height = "100%";
parent.document.getElementById("loadingReportDiv").style.width = "100%";
parent.document.getElementById("loadingReportDiv").style.visibility = "visible";
}
else
{
parent.document.getElementById("loadingReportDiv").style.height = "0%";
parent.document.getElementById("loadingReportDiv").style.width = "0%";
parent.document.getElementById("loadingReportDiv").style.visibility = "hidden";
}
}
}
//for Attachment
function viewAttachloading( flag )
{
if ( parent.document.getElementById("loadingAttachDiv") != null )
{
if ( flag )
{
parent.document.getElementById("loadingAttachDiv").style.height = "100%";
parent.document.getElementById("loadingAttachDiv").style.width = "100%";
parent.document.getElementById("loadingAttachDiv").style.visibility = "visible";
}
else
{
parent.document.getElementById("loadingAttachDiv").style.height = "0%";
parent.document.getElementById("loadingAttachDiv").style.width = "0%";
parent.document.getElementById("loadingAttachDiv").style.visibility = "hidden";
}
}
}
scrollStep=240;
function toLeft()
{
document.getElementById("dataDivID").scrollLeft = 0;
}
function scrollDivLeft()
{
document.getElementById("dataDivID").scrollLeft -= scrollStep;
}
function scrollDivRight()
{
document.getElementById("dataDivID").scrollLeft += scrollStep;
}
function toRight()
{
document.getElementById("dataDivID").scrollLeft = document.getElementById("dataDivID").scrollWidth;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment