// t21lib.js ///* //************************************************************************* //** * //** Copyright (C) 2002-2015 Trans-Mit Pty. Ltd. Melbourne Australia * //** This software may not be loaned, resold, changed or copied * //** in any way without the express written permission of author * //** and Trans-Mit Pty. Ltd., Australia. * //** * //************************************************************************* //** //** $Header: $ //** $Author: $ //** $Date: $ //** $Locker: $ //** //************************************************************************* //*/ //**Start Encode** // Browser check userAgernt_arr = navigator.userAgent.split(";"); msie_ver = userAgernt_arr[1].substring(1); msie_ver_arr = userAgernt_arr[1].split(" "); msie_ver_id = msie_ver_arr[1]; msie_ver_no = parseFloat(msie_ver_arr[2]); if ( msie_ver_id != "MSIE" || msie_ver_no < 5.5 ) { alert("Your Browser Must be Internet Explorer 5.5 or greater"); self.close(); } //------------------------------------------------------------------ //---------------------------------------------------------------------- // taken from jsolait init.js (see copyright below) // rjs 24/02/2005 - modified to allow GET/POST, sync/async-callback // coppied from jsoget.js 18/11/2012 /** Creates an HTTP request object for retreiving files. @return HTTP request object. */ var libgetHTTP=function() { var obj; // rjsol // try{ //to get the mozilla httprequest object // obj = new XMLHttpRequest(); // }catch(e){ try{ //to get MS HTTP request object obj=new ActiveXObject("Msxml2.XMLHTTP.4.0"); }catch(e){ try{ //to get MS HTTP request object obj=new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{// to get the old MS HTTP request object obj = new ActiveXObject("microsoft.XMLHTTP"); }catch(e){ //throw new Exception(thisMod, "Unable to get an HTTP request object."); alert("Unable to get an HTTP request object."); } } } // } return obj; } /** Retrieves a file given its URL. @param url The url to load. @param headers=[] The headers to use. @return The content of the file. */ var libgetFile=function(url, headers, get_post, callback, cbid, errcallback) { //if callback is defined then the operation is done async //alert("getFile(" + url + "," + headers + "," + get_post + "," + callback + "," + cbid +")") headers = (headers != null) ? headers : []; get_post = (get_post != null) ? get_post : "GET"; var async_mode = false //setup the request try { var xmlhttp= libgetHTTP(); if ( callback != null ) { async_mode = true } xmlhttp.open(get_post, url, async_mode); xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); // avoid browser cache for(var i=0;i< headers.length;i++) { xmlhttp.setRequestHeader(headers[i][0], headers[i][1]); } if ( async_mode == true ) { var a_url = url var a_callback = callback var a_errcallback = errcallback var a_cbid = (cbid == null) ? 0 : cbid xmlhttp.onreadystatechange = function () { if ( xmlhttp.readyState == 4 ) { if (xmlhttp.status != 200 && xmlhttp.status != 0 ) { //throw new Exception(thisMod, "File not loaded: '%s'.".format(a_url)); if ( a_errcallback != null ) { a_errcallback(a_cbid, a_url, xmlhttp.statusText); } else { alert("File not loaded: '" + url + "'"); callback(a_cbid, a_url, ""); } return "" } callback(a_cbid, a_url, xmlhttp.responseText); return "" } } } xmlhttp.send(""); if ( async_mode == true ) { //while ( xmlhttp.readyState != 4) { // ??? xml 3 ??? xmlhttp.waitForResponse(1000) //} return "" } }catch(e){ //throw new Exception(thisMod,"Unable to load URL: '%s'.".format(url)); if ( a_errcallback != null ) { a_errcallback(a_cbid, a_url, xmlhttp.statusText); } else { alert("Unable to load URL: '" + url + "'"); callback(a_cbid, a_url, ""); } } if( xmlhttp.status == 200 || xmlhttp.status == 0 ) { return xmlhttp.responseText; }else{ //throw new Exception(thisMod,"File not loaded: '%s'.".format(url)); if ( errcallback != null ) { errcallback(cbid, url, xmlhttp.statusText); } else { alert("File not loaded: '" + url + "'"); } return "" } } //---------------------------------------------------------------------- //------------------------------------------------------------------ // wbt_auth if ( is_web_login(0) ) { try { var wbt_auth_me_allow = false; var wbt_auth_access_list = { // login/navigation/user reports - allow all to access // cgi "wbt_login.cgi" : "NAV", "wbt_telmax21.cgi" : "NAV", "wbt_topdat.cgi" : "NAV", "wbt_cashpay.cgi" : "NAV", // cashier Payment form // html "T21Enquiry.htm" : "NAV", "abc.html" : "NAV", "acccodedet.htm" : "NAV", "acccodeextsum.htm" : "NAV", "calendar.html" : "NAV", "cdr.htm" : "NAV", "centre.htm" : "NAV", "cg.htm" : "NAV", "distid.htm" : "NAV", "distidV2.htm" : "NAV", "edr.htm" : "NAV", "index.html" : "NAV", "m11cdr.htm" : "NAV", "mainframes.html" : "NAV", "mcallbV2.htm" : "NAV", "mchargebV2.htm" : "NAV", "miscdr.htm" : "NAV", "mngmain.htm" : "NAV", "mngreps.htm" : "NAV", "mobile.htm" : "NAV", "mpureviewV2.htm" : "NAV", "o_cdr.htm" : "NAV", "o_cg.htm" : "NAV", "o_edr.htm" : "NAV", "o_miscdr.htm" : "NAV", "o_ovhdr.htm" : "NAV", "o_service1.htm" : "NAV", "o_service2.htm" : "NAV", "o_service3.htm" : "NAV", "o_service4.htm" : "NAV", "ovhdr.htm" : "NAV", "reportgroupx.htm" : "NAV", "service1.htm" : "NAV", "service10.htm" : "NAV", "service10V2.htm" : "NAV", "service2.htm" : "NAV", "service3.htm" : "NAV", "service3000000.htm" : "NAV", "service4.htm" : "NAV", "service5.htm" : "NAV", "swbdet.htm" : "NAV", "swbextnsum.htm" : "NAV", "t21index.html" : "NAV", "topmenu.html" : "NAV", "topreport.html" : "NAV", "vmldet.htm" : "NAV", "vmlextnsum.htm" : "NAV", "wbt.htm" : "NAV", "wbtdoacccodereps.html" : "NAV", "wbthelp.html" : "NAV", "wbtmainhome.html" : "NAV", // ADMIN only // cgi "wbt_ACCM.cgi" : "ADMIN", "wbt_MAINT_dataplan.cgi" : "ADMIN", "wbt_SIDMAINT.cgi" : "ADMIN", "wbt_SIDMAINT_DIRENQ.cgi" : "ADMIN", "wbt_SIDMAINT_acccode.cgi" : "ADMIN", "wbt_SIDMAINT_mobile_phones.cgi" : "ADMIN", "wbt_SIDMAINT_mobile_phones_servercontrol.cgi" : "ADMIN", "wbt_SIDMAINT_picklist.cgi" : "ADMIN", "wbt_T21Enquiry_audittrail.cgi" : "ADMIN", "wbt_WBDM.cgi" : "ADMIN", "wbt_acccodedata.cgi" : "ADMIN", "wbt_admin.cgi" : "ADMIN", "wbt_dataplans.cgi" : "ADMIN", "wbt_dorelease.cgi" : "ADMIN", "wbt_dosave_didyouknow.cgi" : "ADMIN", "wbt_dosql.cgi" : "ADMIN", "wbt_gethier.cgi" : "ADMIN", "wbt_release.cgi" : "ADMIN", "wbt_picklists.cgi" : "ADMIN", "wbt_upfile2.cgi" : "ADMIN", "wbt_upfile2delete.cgi" : "ADMIN", "wbt_upfile2list.cgi" : "ADMIN", "wbt_upfile2upload.cgi" : "ADMIN", "wbt_upfile2verify.cgi" : "ADMIN", // html "wbtadmin.html" : "ADMIN", "wbtrelease.html" : "ADMIN", "wbtupfile2.html" : "ADMIN", "wbtACCM.html" : "ADMIN", "wbtMAINT_dataplan.html" : "ADMIN", "wbtSIDMAINT.html" : "ADMIN", "wbtSIDMAINT_CUSTOM.html" : "ADMIN", "wbtSIDMAINT_DIRENQ.html" : "ADMIN", "wbtSIDMAINT_acccode.html" : "ADMIN", "wbtSIDMAINT_auto.html" : "ADMIN", "wbtSIDMAINT_mobile_phones.html" : "ADMIN", "wbtSIDMAINT_picklist.html" : "ADMIN", "wbtSIDMAINT_tst.html" : "ADMIN", "wbtWBDM.html" : "ADMIN", "wbtgrphier.html" : "ADMIN", //// download invoice PDF //// - allow access if wbdconf.wbt_type is INVOICE_PDF //replaced by distid .pdf file //"wbt_dnldinvoicepdf.cgi" : "INVOICE_PDF", // returns dynamic report csv data // (see wbt_stdcgiheader stdcgi_auth) // 0 ) wbt_auth_me_src = wbt_auth_me_arr[wbt_auth_me_arr.length-1].split(/[#?&]/)[0]; //var wbt_auth_me_hash = window.location.hash; //var wbt_auth_me_search = window.location.search; //wbt_auth_me_arg_arr = wbt_auth_me_search.split(/[&]/); //wbt_auth_me_arg_arr[0] = wbt_auth_me_arg_arr[0].substr(1); var wbt_auth_me_access = wbt_auth_access_list[wbt_auth_me_src]; var wbt_auth_me_appmode = getCookie("remuserappmode"); var wbt_auth_me_remuser = getCookie("remuser"); var wbt_common_path = wbt_auth_me_href.replace(/\/common\/.*$/,"") + "/common"; if ( wbt_auth_me_remuser != null && wbt_auth_me_remuser != "" ) { // test remuserappmode for cookie hacking var url = wbt_common_path + "/wbt_getuseraccess.cgi"; var j_src = ""; j_src = libgetFile(url,'',"POST",null,null); var getuseraccess_appmode = eval(j_src); //alert("j_src=[" + j_src + "]" + " wbt_auth_me_appmode=[" + wbt_auth_me_appmode + "]" + " getuseraccess_appmode=[" + getuseraccess_appmode + "]"); if ( wbt_auth_me_appmode != getuseraccess_appmode ) wbt_auth_me_access = "DENY"; } switch ( wbt_auth_me_access ) { case "NAV": wbt_auth_me_allow = true; break; case "ADMIN": if ( wbt_auth_me_appmode == wbt_auth_me_access ) wbt_auth_me_allow = true; break; case "INVOICE_PDF": if ( wbt_auth_me_appmode == "INVOICE_PDF" || wbt_auth_me_appmode == "ADMIN" ) wbt_auth_me_allow = true; break; case "TEST": if ( testing ) wbt_auth_me_allow = true; break; case "DENY": default: wbt_auth_me_allow = false; break; } dbgmsg = "wbt_auth_me_src=[" + wbt_auth_me_src + "]" + "\n" + "wbt_auth_me_access=[" + wbt_auth_me_access + "]" + "\n" + "wbt_auth_me_appmode=[" + wbt_auth_me_appmode + "]" + "\n" + "wbt_auth_me_allow=[" + wbt_auth_me_allow + "]" + "\n" + ""; //alert(dbgmsg); //dbgwindow(dbgmsg); if ( !wbt_auth_me_allow ) throw "wbt_auth: access denied."; } catch (e) { // deny alert("Error (" + e + ")"); window.location = ""; // move away from page } } //------------------------------------------------------------------ // global version wb_version = 2 var wb_version_store if ( (wb_version_store = getCookie("WB_VERSION")) != null ) wb_version = parseInt(wb_version_store) if ( wb_version != 1 && wb_version != 2 ) wb_version = 2 // ------------------------------------- function w(str) { document.writeln(str); } function dumpobj(obj1) { for (prop in obj1) { if ( ! window.confirm("The property '" + prop + "' is " + obj1[prop]) ) break; } } //---------------------------------------------------------------------- function globalstyle() { var outp = ''; outp += 'A.srtA { color: black; text-decoration: none; }'; outp += 'A.srtA:hover { color: pink; text-decoration: underline; }'; outp += 'A.drillA { color: black; text-decoration: none;'; outp += ' font-family : Arial;'; outp += ' font-weight : normal;'; outp += ' }'; outp += 'A.drillA:hover { color: blue; text-decoration: underline; }'; outp += 'A.nodrillA { color: pink; text-decoration: none;'; outp += ' font-family : Arial;'; outp += ' font-weight : normal;'; outp += ' }'; outp += 'A.nodrillA:hover { color: red; text-decoration:none; }'; outp += 'A.totinfoA { text-decoration: none; }'; outp += 'A.totinfoA:hover { color: pink; text-decoration: underline; }'; outp += 'A.CAPTION.totinfoA { color: #005A74; }'; outp += 'A.filtA { color: black; text-decoration: none;'; outp += ' font-family : Arial;'; outp += ' font-weight : normal;'; outp += ' }'; outp += 'A.filtA:hover { color: pink; text-decoration: underline; }'; outp += 'LABEL.filt_in {'; outp += ' background : white;'; outp += ' color : black;'; outp += ' text-decoration : none;'; outp += ' font-size : 9pt;'; outp += ' font-family : Arial;'; outp += ' font-weight : normal;'; outp += ' }'; outp += 'INPUT.but_filt_in {'; outp += ' color : #005A74;'; outp += ' text-decoration : underline;'; outp += ' font-size : 8pt;'; outp += ' font-family : Arial;'; outp += ' font-weight : normal;'; outp += ' }'; outp += 'INPUT.filt_in {'; outp += ' background : #C1B6A2;'; outp += ' color : #005A74;'; outp += ' text-decoration : none;'; outp += ' font-size : 8pt;'; outp += ' font-family : Arial;'; outp += ' font-weight : normal;'; outp += ' }'; outp += 'SELECT.filt_in {'; outp += ' background : #C1B6A2;'; outp += ' color : #005A74;'; outp += ' text-decoration : none;'; outp += ' font-size : 8pt;'; outp += ' font-family : Arial;'; outp += ' font-weight : normal;'; outp += ' }'; outp += 'TEXTAREA.filt_in {'; outp += ' background : #C1B6A2;'; outp += ' color : #E5352C;'; outp += ' width : 500px;'; outp += ' text-decoration : none;'; outp += ' font-size : 10pt;'; outp += ' font-family : Arial;'; outp += ' font-weight : normal;'; outp += ' padding : 10;'; outp += ' border : 2 dotted #005A74;'; outp += ' }'; return outp; } // -------------------------------------------------------------------- // window open/close replacement (Re:- IE* default to open in new TAB function window_open(url, title, props) { //return window.open(url, title, props); return popwindow(url, title, props); //return new popwindow(url, title, props); } var popwindows = []; var popwindows_baseurl = []; function popwindow(url, title, props) { // exists? var baseurl_arr = url.split("?"); var baseurl = baseurl_arr[0] if ( popwindows_baseurl[baseurl] != null ) { var winid = popwindows_baseurl[baseurl] // set new url popwindows[winid].iframe1.src = url; return popwindows[winid].iframe1.contentWindow; } var title_h = 18; var myprops = props.replace(/\,/g,"\;").replace(/\=/g,"\:"); var winid = popwindows.length; //popwin = document.createElement("
"); popwin = document.createElement(""); popwindows[winid] = popwin; popwindows_baseurl[baseurl] = winid; popwin.baseurl = baseurl; //popwin.id = "my_" + title; popwin.id = "popwin_" + winid; popwin.style.z_index = 1; //popwin.style.display = "none"; //popwin.style.filter = 'alpha(opacity=0)'; popwin.style.position = "absolute"; popwin.style.border = "4"; popwin.style.borderStyle = "outset"; var frame_h = parseInt(popwin.style.height.replace(/px/,"")); var frame_w = parseInt(popwin.style.width.replace(/px/,"")); popwin.style.height = (title_h + frame_h) + "px"; var outp = ""; outp += "
"; outp += ""; outp += ""; outp += ""; outp += ""; outp += "
"; outp += title; outp += ""; //outp += "        " //outp += "        " //outp += "        " //outp += "        " //outp += " X " + "'>Close" + ""; //outp += ""; outp += "
"; outp += "
"; var frame1name = "frame1"; //outp = "" //outp += ""); iframe1.id = frame1name; iframe1.name = frame1name; iframe1.style.height = frame_h + "px"; //iframe1.style.width = frame_w + "px"; iframe1.style.width = "100%"; //iframe1.src = url; iframe1.popwin = popwin; popwin.iframe1 = iframe1; popwin.appendChild(iframe1); document.body.appendChild(popwin); // methods popwin.close = function () { //alert("popwin.close()"); popwin.removeNode(true); popwindows[popwin.winid] = null; popwindows_baseurl[popwin.baseurl] = null; } iframe1.close = function () { //alert("frame1.close()"); iframe1.popwin.close(); } iframe1.attachEvent("onload", function() { //alert("frame1 loaded"); //alert("b iframe1.contentWindow.close = " + iframe1.contentWindow.close); //iframe1.contentWindow.nativeclose = iframe1.contentWindow.closel; iframe1.contentWindow.close = function () { //iframe1.contentWindow.nativeclose(); //alert("frame1.contentWindow.close()"); iframe1.close(); } //alert("a iframe1.contentWindow.close = " + iframe1.contentWindow.close); }); //iframe1.attachEvent("onbeforeunload", function() { // alert("frame1 before unload"); // iframe1.close(); // }); //this.close = this.popwin.close; //this.focus = this.popwin.focus; //this.blur = this.popwin.blur; //this.toggle = function () { this.popwin.style.visibility = this.popwin.style.visibility == 'visible' ? 'hidden' : 'visible'; } //alert("here 0 popwin.id = [" + popwin.id + "]" + " HTML = " + popwin.outerHTML); //alert("iframe1.contentWindow = " + iframe1.contentWindow); ////iframe1.contentWindow.opener = window; // load url iframe1.src = url; //var popwinel = document.getElementById(popwin.id); //alert("here 1 id=" + popwinel.id); //popwinel.frame1.setAttribute('src', url); //frame1.src = url; //alert("here 2"); //popwin.style.visibility = 'hidden'; //alert("here 3"); popwin.style.visibility = 'visible'; //return popwin; //return iframe1; return iframe1.contentWindow; } //function window_close(x) //{ // alert("window_close(" + x + ")"); // if ( typeof(x) == "object" ) // x.removeNode(true); // else // eval(x + ".removeNode(true)"); //} // -------------------------------------------------------------------- // return URL to data file function settdf(datfile, contenttype, contentdisposition) { //return = "../../" + datfile; if ( is_web_login(1) ) { //var distid = getCookie("WB_distid"); //alert("settdf() WB_distid is " + "[" + distid + "]") ////setCookie("WB_distid", distid) ////top.t21main.setCookie("WB_distid", distid) var uri = '../wbt_topdat.cgi?tdf="' + datfile + '"'; if ( contenttype != null ) { uri = uri + '&contenttype="' + contenttype + '"'; if ( contentdisposition != null ) { uri = uri + '&contentdisposition="' + contentdisposition + '"'; } } return encodeURI(uri); } else { return '../../' + datfile; } } // -------------------------------------------------------------------- function is_web_login(a) { //var remuser = getCookie("remuser"); //var remuserpwdes = getCookie("remuserpwdes"); //var WB_userid = getCookie("WB_userid"); //alert("a=" + a + " remuser=[" + remuser + "]" + " remuserpwdes=[" + remuserpwdes + "]" + " WB_userid=[" + WB_userid + "]" + "\n>>>>> document.cookie=[" + document.cookie + "]"); // return true if web login return ((getCookie("remuser") != null) && (getCookie("remuserpwdes") != null) && (getCookie("WB_userid") != null) ) // could also validate getCookie("remuserpwdes") // against actual value in wbdconf table } // -------------------------------------------------------------------- function setPersistentData(name, value, expires, path, domain, secure) { //return setCookie(name, value, expires, path, domain, secure) try { if ( typeof(top.opener) == "undefined" ) // called from top var uStore_div = Bilmax21_userData_div else var uStore_div = top.opener.Bilmax21_userData_div // add attribute to user data store div var val = "" if ( typeof(value) != "undefined" ) val = value //if ( typeof(val.toString()) != "undefined" ) // val = val.toString uStore_div.setAttribute(name, val) } catch (errcode) { alert("catch setPersistentData(" + name + "," + value + ")" + " val=[" + val + "]" + " errcode=" + errcode) } } function getPersistentData(name) { //return getCookie(name) if ( typeof(top.opener) == "undefined" ) // called from top var uStore_div = Bilmax21_userData_div else var uStore_div = top.opener.Bilmax21_userData_div //alert("uStore_div.getAttribute(" + name + ") = [" + uStore_div.getAttribute(name) + "]") return uStore_div.getAttribute(name) } function deletePersistentData(name, path, domain) { //return deleteCookie(name, path, domain) if ( typeof(top.opener) == "undefined" ) // called from top var uStore_div = Bilmax21_userData_div else var uStore_div = top.opener.Bilmax21_userData_div // remove user data store attribute uStore_div.removeAttribute(name) } function savePersistentData(expires) { if ( typeof(top.opener) == "undefined" ) // called from top var uStore_div = Bilmax21_userData_div else var uStore_div = top.opener.Bilmax21_userData_div // save user data store ////uStore_div.expires = expires var now = new Date() fixDate(now) ////now.setHours(now.getHours() + 12) now.setMinutes(now.getMinutes() + 10) uStore_div.expires = now.toUTCString() uStore_div.save("Bilmax21_userData") //alert("SAVED :\n" + uStore_div.xmlDocument.xml) } function loadPersistentData() { if ( typeof(top.opener) == "undefined" ) // called from top var uStore_div = Bilmax21_userData_div else var uStore_div = top.opener.Bilmax21_userData_div // load user data store uStore_div.load("Bilmax21_userData") //alert("LOADED :\n" + uStore_div.xmlDocument.xml) } // ------------------------------------- function setCookie(name, value, expires, path, domain, secure) { path = "/"; if ( value == null ) value = ''; //if ( value == null || value == "" ) // value = "_NULL_"; //if ( name == "remuser" ) { // alert("setCookie: name=[" + name + "]" + " value=[" + value + "]" + " BEFORE document.cookie = " + document.cookie); //} var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + (typeof(expires) == "string" ? expires : expires.toGMTString()) : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); //if ( name == "remuser" ) { // alert("setCookie: set curCookie=[" + curCookie + "]"); //} //var curCookie = name + "=" + escape(value); // // only 20 cookies max - so make sure we don't loose these ones // // oldest cookie is is deleted if 20 exceeded // refreshCookie("WB_centre"); // refreshCookie("WB_centre_filter"); // refreshCookie("WB_project"); // refreshCookie("WB_project_filter"); // refreshCookie("WB_serviectypeid"); // refreshCookie("WB_serviectypeid_filter"); // refreshCookie("WB_monthtag"); // //refreshCookie("WB_distiddesc"); // refreshCookie("WB_distid"); // refreshCookie("WB_distidmtags"); // refreshCookie("WB_wbd_method"); // refreshCookie("WB_wbd_type"); // refreshCookie("WB_VERSION"); // refreshCookie("WB_userid"); // refreshCookie("WB_recordno"); // //refreshCookie("WB_WBDM"); // refreshCookie("remuser"); // refreshCookie("remuserpwdes"); // refreshCookie("remuserappmode"); //document.cookie = curCookie; if ( typeof(top.opener) == "object" ) top.opener.document.cookie = curCookie; else document.cookie = curCookie; //if ( name == "remuser" ) { // alert("setCookie: name=[" + name + "]" + " value=[" + value + "]" + " AFTER document.cookie = " + document.cookie); //} } function refreshCookie(name) { var tv1 = ''; if ( (tv1 = getCookie(name)) != null ) { //if ( tv1 == null || tv1 == "" ) // tv1 = "_NULL_";; var curCookie = name + "=" + escape(tv1); //document.cookie = curCookie; if ( typeof(top.opener) == "object" ) top.opener.document.cookie = curCookie; else document.cookie = curCookie; } } function getCookie(name) { //if ( name == "WB_distid" ) { // alert("getCookie(" + name + "): document.cookie = " + document.cookie); // if ( typeof(top.opener) == "object" ) { // alert("HERE> top.opener.document.location.href=[" + top.opener.document.location.href + "] top.opener.document.cookie=[" + top.opener.document.cookie + "]"); // } //} //alert("getCookie: document.cookie = " + document.cookie); var myCookies = document.cookie; if ( typeof(top.opener) == "object" ) myCookies = top.opener.document.cookie; var value = null; //var prefix = name + "="; //var cookieStartIndex = myCookies.indexOf(prefix); //if (cookieStartIndex >= 0 ) { // var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length); // if (cookieEndIndex == -1) // cookieEndIndex = document.cookie.length; // value = unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex)); //} var i,x,y; var ARRcookies = myCookies.split(";"); //for (i=0; i=0; --i) { x = ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); y = ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); x = x.replace(/^\s+|\s+$/g,""); if (x == name) { value = unescape(y); break; } } //if ( value == "_NULL_" ) // value = null; //if ( name == "remuser" ) { // alert("getCookie: name=[" + name + "]" + " value=[" + value + "]"); //} return value; } function deleteCookie(name, path, domain) { path = "/"; //alert("deleteCookie: name=[" + name + "]" + " path=[" + path + "]" + " domain=[" + domain + "]"); if ( getCookie(name) ) { //if ( name == "remuser" ) { // var tst_remuser = getCookie("remuser"); // alert("before clear tst_remuser=[" + tst_remuser + "]" + " document.cookie = " + document.cookie); //} //document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; var expires = "Thu, 01-Jan-70 00:00:01 GMT"; setCookie(name, null, expires, path); //if ( name == "remuser" ) { // var tst_remuser = getCookie("remuser"); // alert("after clear tst_remuser=[" + tst_remuser + "]" + " document.cookie = " + document.cookie); //} } return true } function fixDate(date) { var base = new Date(0); var skew = base.getTime(); if (skew > 0) date.setTime(date.getTime() - skew); } //---------------------------------------- function monthtag_to_exbillperiod(monthtag) { var mntharr = new Array(); mntharr["Jan"] = "January"; mntharr["Feb"] = "February"; mntharr["Mar"] = "March"; mntharr["Apr"] = "April"; mntharr["May"] = "May"; mntharr["Jun"] = "June"; mntharr["Jul"] = "July"; mntharr["Aug"] = "August"; mntharr["Sep"] = "September"; mntharr["Oct"] = "October"; mntharr["Nov"] = "November"; mntharr["Dec"] = "December"; var billMMM = monthtag.substr(0,3); var billyyyy = monthtag.substr(4,4); var exbillperiod = mntharr[billMMM] + " " + billyyyy; return exbillperiod; } //------------------------------------------------------------- var page_header_htm = "" function wb_page_header(distid, distiddesc, exbillperiod, reportdesc) { var outp = ""; var customer = getPersistentData("WB_customer"); if ( customer == null ) customer = ""; var customerdesc = getPersistentData("WB_customerdesc"); if ( customerdesc == null ) customerdesc = ""; ; var group = getPersistentData("WB_group"); if ( group == null ) group = ""; var groupdesc = getPersistentData("WB_groupdesc") if ( groupdesc == null ) groupdesc = ""; outp += ''; } if ( do_aro ) outp += '  ' + aro + '  '; outp += ''; //outp += ''; outp += "'; outp += ''; //outp += ''; outp += "'; } if ( do_distid && distid != "" ) { if ( do_aro ) outp += '  ' + aro + '  '; outp += ''; //outp += ''; outp += "'; outp += ''; //outp += ''; outp += "'; outp += ''; //outp += ''; outp += "'; outp += ''; //outp += ''; outp += "'; } if ( do_distid && distid != "" ) { if ( do_aro ) outp += '  ' + aro + '  '; outp += ''; //outp += ''; outp += "'; outp += ''; //outp += ''; outp += "'; outp += ''; //outp += ''; outp += "'; outp += ''; //outp += ''; outp += "= 1000000 ) { var nmillion = Math.floor(dollars / 1000000) var remdollars = dollars - (nmillion * 1000000) var ngrand = Math.floor(remdollars / 1000) var nhundred = Math.floor(remdollars - (ngrand * 1000)) dollars_str = nmillion + "," dollars_str += ngrand < 100 ? "0" : "" dollars_str += ngrand < 10 ? "0" : "" dollars_str += ngrand + "," dollars_str += nhundred < 100 ? "0" : "" dollars_str += nhundred < 10 ? "0" : "" dollars_str += nhundred } else if ( dollars >= 1000 ) { var remdollars = dollars var ngrand = Math.floor(remdollars / 1000) var nhundred = Math.floor(remdollars - (ngrand * 1000)) dollars_str+= ngrand + "," dollars_str += nhundred < 100 ? "0" : "" dollars_str += nhundred < 10 ? "0" : "" dollars_str += nhundred } else { dollars_str = dollars } var str = (isneg ? "-" : "") + "$" + dollars_str + "."; if ( cents < 10 ) str = str + "0" + cents; else str = str + cents; return str; } function fmt_duration(val, show0) { var i = 0; var isneg = 0; if (val != null && val != "") i = Math.floor(parseFloat(val)) if ( i < 0 ) { isneg = 1 i = i * -1 } var hours = Math.floor(i / 3600); var rem = i - (hours * 3600); var minutes = Math.floor(rem / 60); var seconds = rem - (minutes * 60); if ( hours == 0 && minutes == 0 && seconds == 0 ) { if ( show0 ) return "0:00:00" //"000:00:00" else return "" } var hours_str = "" var minutes_str = "" //if ( hours != 0 ) { //hours_str += hours < 100 ? "0" : "" //hours_str += hours < 10 ? "0" : "" hours_str += parseFloat(hours) hours_str += ":" minutes_str += minutes < 10 ? "0" : "" minutes_str += parseFloat(minutes) //} //else { // minutes_str += parseFloat(minutes) //} minutes_str += ":" var seconds_str = "" seconds_str += seconds < 10 ? "0" : "" seconds_str += seconds var str = hours_str + minutes_str + seconds_str return str } function fmt_count(val, show0) { if ( val == 0 ) { if ( show0 ) return "0" else return "" } return Math.round(val).toString() } function fmt_value(val,fmt,show0) { switch (fmt) { default: case 0: // count return fmt_count(val,show0) break; case 1: // duration return fmt_duration(val,show0) break; case 2: // cost return fmt_cost(val,show0) break } } //---------------------------------------- function duration_to_seconds(durstr) { var hhh = parseFloat(durstr.substr(0,3)) var mm = parseFloat(durstr.substr(4,2)) var ss = parseFloat(durstr.substr(7,2)) var dursecs = (hhh * 3600) + (mm * 60) + ss return dursecs } //================================================================ var selected_invoiceno = "" var selected_sundry = "" var selected_supplier = "" function store_inv_sundry_supplier(REPID,invoiceno,sundry,supplier) { var i = 0; //alert("store_inv_sundry_supplier(" + REPID + "," + invoiceno + "," + sundry + "," + supplier + ")"); // create unique invoiceno list for (i=0; i < ninvoicenos ; i++) { if ( invoiceno == invoicenolist[i]) break; }; if ( i >= ninvoicenos ) { // new //invoicenolist[ninvoicenos++] = invoiceno; // added sort code below // insert alphabetically for (i = ninvoicenos; i > 0; --i) { // List/All always first if ( invoicenolist[i-1] == "List" || invoicenolist[i-1] == "All" ) break; if ( invoiceno >= invoicenolist[i-1] ) break; // shuffle up one invoicenolist[i] = invoicenolist[i-1]; } if ( i == -1 ) // empty list i = 0; invoicenolist[i] = invoiceno; ++ninvoicenos; } // set starting invoiceno index if ( eval("invoiceno == this_" + REPID + "invoiceno") ) curinvoiceno = i; // create unique sundry list for (i=0; i < nsundrys ; i++) { if ( sundry == sundrylist[i]) break; } if ( i >= nsundrys ) { // new //sundrylist[nsundrys++] = sundry; // added sort code below // insert alphabetically for (i = nsundrys; i > 0; --i) { // List/All always first if ( sundrylist[i-1] == "List" || sundrylist[i-1] == "All" ) break; if ( sundry >= sundrylist[i-1] ) break; // shuffle up one sundrylist[i] = sundrylist[i-1]; } if ( i == -1 ) // empty list i = 0; sundrylist[i] = sundry; ++nsundrys; } // set starting sundry index if ( eval("sundry == this_" + REPID + "sundry") ) cursundry = i; // create unique supplier list for (i=0; i < nsuppliers ; i++) { if ( supplier == supplierlist[i] ) break; } if ( i >= nsuppliers ) { // new //supplierlist[nsuppliers++] = supplier; // added sort code below // insert alphabetically for (i = nsuppliers; i > 0; --i) { // List/All always first if ( supplierlist[i-1] == "List" || supplierlist[i-1] == "All" ) break; if ( supplier >= supplierlist[i-1] ) break; // shuffle up one supplierlist[i] = supplierlist[i-1]; } if ( i == -1 ) // empty list i = 0; supplierlist[i] = supplier; ++nsuppliers; } // set starting supplier index if ( eval("supplier == this_" + REPID + "supplier") ) cursupplier = i; // creat unique list of invoiceno|sundry|supplier combinations var sunsup = invoiceno + "|" + sundry + "|" + supplier; for (i=0; i < nsunsups ; i++) { if ( sunsup == sunsuplist[i] ) break; } if ( i >= nsunsups ) sunsuplist[nsunsups++] = sunsup; selected_invoiceno = invoicenolist[curinvoiceno]; selected_sundry = sundrylist[cursundry]; selected_supplier = supplierlist[cursupplier]; } function in_sunsuplist(invoiceno,sundry,supplier) { var i = 0; //alert("in_sunsuplist(" + invoiceno + "," + sundry + "," + supplier + ")") // scan unique list of sundry|supplier combinations var sunsup = invoiceno + "|" + sundry + "|" + supplier for (i=0; i < nsunsups ; i++) { if ( sunsup == sunsuplist[i] ) { cursunsup = i return 1 } } cursunsup = -1 return 0 } function show_supplier_invoiceno_sundry_input(REPID,repbill) { supplier_invoiceno_sundry_input.innerHTML = supplier_invoiceno_sundry_selection(REPID,repbill) } function supplier_invoiceno_sundry_selection(REPID,repbill) { var outp = ""; var sstr = ""; var i = 0; // supplier select if ( nsuppliers == 2 ) { // List,single - so select single cursupplier = 1 //eval("this_" + REPID + "supplier = supplierlist[cursupplier]") //eval("setPersistentData(\"WB_" + REPID + "supplier\", this_" + REPID + "supplier)") } outp += "\n"; outp += "