1 /* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=javascript: */
3 * Copyright (C) 2007 Sergey Yanovich <ynvich@gmail.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 const nsCI = Components.interfaces;
23 const treeViewContract = "@aasii.org/view/tree-transcript;1";
24 const reportContract = "@aasii.org/report/transcript;1";
31 Components.classes['@mozilla.org/consoleservice;1']
32 .getService(Components.interfaces.nsIConsoleService)
33 .logStringMessage(str);
39 for (var prop in obj) {
41 dump(prop + ": " + obj[prop] + "\n");
43 dump(prop + ": error: " + e.message + "\n");
50 return document.defaultView.QueryInterface(nsCI.nsIInterfaceRequestor)
51 .getInterface(nsCI.nsIWebNavigation)
52 .sessionHistory.QueryInterface(nsCI.aaISession);
57 document.defaultView.QueryInterface(nsCI.nsIInterfaceRequestor)
58 .getInterface(nsCI.nsIWebNavigation)
59 .loadURI(uri,nsCI.nsIWebNavigation.LOAD_FLAGS_NONE,null,null,null);
62 function transcriptPageLoad()
64 document.getElementById("filter.dateFrom").addEventListener("change", dateFromChange, false);
65 document.getElementById("header.dateFrom").value = document.
66 getElementById("filter.dateFrom").value;
67 document.getElementById("header.dateTo").value = document.
68 getElementById("filter.dateTo").value;
69 gTree = document.getElementById("transcript.tree");
70 gTree.view = Components.classes[treeViewContract]
71 .createInstance(nsCI.nsITreeView);
72 gReport = session().createQuery(reportContract).
73 QueryInterface(nsCI.aaITranscript);
74 gTree.view.QueryInterface(nsCI.aaIDataTreeView).dataSet = gReport;
77 addEventListener("resize", transcriptResize, true);
81 function transcriptResize()
86 function alignLabels()
88 var width = gTree.columns[3].width;
89 document.getElementById("header.sumCreditFrom").setAttribute('width',width);
90 document.getElementById("header.sumCreditTo").setAttribute('width',width);
95 if (document.getElementById("viewMode").hasAttribute("disabled")) {
96 session().beginQuery();
97 addEventListener("pageshow", choosenFlow, true);
99 loadURI("chrome://abstract/content/flow.xul");
102 function choosenFlow()
104 removeEventListener("pageshow", choosenFlow, true);
105 var buffer = session().queryBuffer;
106 session().queryBuffer = null;
107 gReport.flow = buffer
108 ? buffer.QueryInterface(nsCI.aaIFlow) : null;
110 updateFlowLink("filter");
113 function dateFromChange(event)
117 function dateToChange(event)
121 function transcriptLoad()
123 gReport.start = (document.getElementById("filter.dateFrom").dateValue
124 .getTime() - 1000 * 60 * 60 * 24) * 1000;
125 gReport.end = document.getElementById("filter.dateTo").dateValue
128 gTree.view.QueryInterface(nsCI.aaIDataTreeView).update();
129 updateFlowLink("header");
131 var startDate = new Date();
132 var endDate = new Date();
133 startDate.setTime(gReport.start/1000 + 1000 * 60 * 60 * 24);
134 endDate.setTime(gReport.end/1000);
136 document.getElementById("filter.dateFrom").dateValue = startDate;
137 document.getElementById("header.dateFrom").value =
138 startDate.toLocaleFormat('%Y-%m-%d');
139 document.getElementById("filter.dateTo").dateValue = endDate;
140 document.getElementById("header.dateTo").value =
141 endDate.toLocaleFormat('%Y-%m-%d');
143 document.getElementById("header.sumDebitFrom").value = gReport.opening &&
144 gReport.opening.side ? gReport.opening.value.toFixed(2) : "0.00" ;
145 document.getElementById("header.sumCreditFrom").value = gReport.opening &&
146 ! gReport.opening.side ? gReport.opening.value.toFixed(2) : "0.00" ;
147 document.getElementById("header.sumDebitTo").value = gReport.closing &&
148 gReport.closing.side ? gReport.closing.value.toFixed(2) : "0.00";
149 document.getElementById("header.sumCreditTo").value = gReport.closing &&
150 ! gReport.closing.side ? gReport.closing.value.toFixed(2) : "0.00";
155 function updateFlowLink(part)
157 if (gReport && gReport.flow)
158 document.getElementById(part + ".flow").value = gReport.flow.tag;
160 document.getElementById(part + ".flow").value = document.
161 getElementById("bundle_abstract").getString("link.choose");
164 function setMode(isChange)
166 var newMode, oldMode;
169 newMode = document.getElementById("changeMode");
170 oldMode = document.getElementById("viewMode");
172 updateFlowLink("filter");
174 newMode = document.getElementById("viewMode");
175 oldMode = document.getElementById("changeMode");
178 oldMode.setAttribute("disabled","true");
179 oldMode.setAttribute("collapsed","true");
181 newMode.removeAttribute("disabled");
182 newMode.removeAttribute("collapsed");
185 function filterChange()
190 function filterReset()