Attached Files | 36245.diff [^] (55,098 bytes) 2017-06-16 11:47 [Show Content] [Hide Content]# HG changeset patch
# User Armaignac <collazoandy4@gmail.com>
# Date 1497386165 14400
# Tue Jun 13 16:36:05 2017 -0400
# Node ID b08f498eba610b4b70e34355fcf2e0046a2e0f51
# Parent f2ee792f14ff145dc05f47f0a7c3c089dbcb3823
Fixes issue 36245: Prevent user to launch Journal Entries Report more than once
User is able to run Journal Entries Report several times. In case this is
done in an environment with huge amount of accounting data system will crash.
Now two new preferences were created to limit the user report runs.
The report now show an error message when the user exceeds the ReportsUserExecutionsLimit
or ReportsExecutionsLimit preference values when he runs the report.
A new message entry was created to inform the user with the error cause.
diff --git a/src-db/database/sourcedata/AD_MESSAGE.xml b/src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml
@@ -21371,6 +21371,18 @@
<!--716A7D748A9C9ED8E040007F01015931--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
<!--716A7D748A9C9ED8E040007F01015931--></AD_MESSAGE>
+<!--71755E370E6F4AB185E9AC5CB573CAB0--><AD_MESSAGE>
+<!--71755E370E6F4AB185E9AC5CB573CAB0--> <AD_MESSAGE_ID><![CDATA[71755E370E6F4AB185E9AC5CB573CAB0]]></AD_MESSAGE_ID>
+<!--71755E370E6F4AB185E9AC5CB573CAB0--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--71755E370E6F4AB185E9AC5CB573CAB0--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--71755E370E6F4AB185E9AC5CB573CAB0--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--71755E370E6F4AB185E9AC5CB573CAB0--> <VALUE><![CDATA[ReportsExecutionsLimit]]></VALUE>
+<!--71755E370E6F4AB185E9AC5CB573CAB0--> <MSGTEXT><![CDATA[Report execution limit has been exceeded]]></MSGTEXT>
+<!--71755E370E6F4AB185E9AC5CB573CAB0--> <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--71755E370E6F4AB185E9AC5CB573CAB0--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--71755E370E6F4AB185E9AC5CB573CAB0--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--71755E370E6F4AB185E9AC5CB573CAB0--></AD_MESSAGE>
+
<!--71C5D55B1EE14B2DA165D44220963D84--><AD_MESSAGE>
<!--71C5D55B1EE14B2DA165D44220963D84--> <AD_MESSAGE_ID><![CDATA[71C5D55B1EE14B2DA165D44220963D84]]></AD_MESSAGE_ID>
<!--71C5D55B1EE14B2DA165D44220963D84--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff --git a/src-db/database/sourcedata/AD_PREFERENCE.xml b/src-db/database/sourcedata/AD_PREFERENCE.xml
--- a/src-db/database/sourcedata/AD_PREFERENCE.xml
+++ b/src-db/database/sourcedata/AD_PREFERENCE.xml
@@ -24,6 +24,17 @@
<!--9B4A5EB695FDA841E040A8C0E1077381--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
<!--9B4A5EB695FDA841E040A8C0E1077381--></AD_PREFERENCE>
+<!--D8BA2E4D3073410D8ABA9CC5BEC1B7D0--><AD_PREFERENCE>
+<!--D8BA2E4D3073410D8ABA9CC5BEC1B7D0--> <AD_PREFERENCE_ID><![CDATA[D8BA2E4D3073410D8ABA9CC5BEC1B7D0]]></AD_PREFERENCE_ID>
+<!--D8BA2E4D3073410D8ABA9CC5BEC1B7D0--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--D8BA2E4D3073410D8ABA9CC5BEC1B7D0--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--D8BA2E4D3073410D8ABA9CC5BEC1B7D0--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--D8BA2E4D3073410D8ABA9CC5BEC1B7D0--> <ATTRIBUTE><![CDATA[ReportsUserExecutionsLimit]]></ATTRIBUTE>
+<!--D8BA2E4D3073410D8ABA9CC5BEC1B7D0--> <VALUE><![CDATA[1]]></VALUE>
+<!--D8BA2E4D3073410D8ABA9CC5BEC1B7D0--> <ISPROPERTYLIST><![CDATA[N]]></ISPROPERTYLIST>
+<!--D8BA2E4D3073410D8ABA9CC5BEC1B7D0--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--D8BA2E4D3073410D8ABA9CC5BEC1B7D0--></AD_PREFERENCE>
+
<!--D965E00387CB434DAD78493B417AFD37--><AD_PREFERENCE>
<!--D965E00387CB434DAD78493B417AFD37--> <AD_PREFERENCE_ID><![CDATA[D965E00387CB434DAD78493B417AFD37]]></AD_PREFERENCE_ID>
<!--D965E00387CB434DAD78493B417AFD37--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -35,4 +46,15 @@
<!--D965E00387CB434DAD78493B417AFD37--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
<!--D965E00387CB434DAD78493B417AFD37--></AD_PREFERENCE>
+<!--F44893EDBDA84C6BAF99A1F8550E5044--><AD_PREFERENCE>
+<!--F44893EDBDA84C6BAF99A1F8550E5044--> <AD_PREFERENCE_ID><![CDATA[F44893EDBDA84C6BAF99A1F8550E5044]]></AD_PREFERENCE_ID>
+<!--F44893EDBDA84C6BAF99A1F8550E5044--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F44893EDBDA84C6BAF99A1F8550E5044--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F44893EDBDA84C6BAF99A1F8550E5044--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F44893EDBDA84C6BAF99A1F8550E5044--> <ATTRIBUTE><![CDATA[ReportsExecutionsLimit]]></ATTRIBUTE>
+<!--F44893EDBDA84C6BAF99A1F8550E5044--> <VALUE><![CDATA[1]]></VALUE>
+<!--F44893EDBDA84C6BAF99A1F8550E5044--> <ISPROPERTYLIST><![CDATA[N]]></ISPROPERTYLIST>
+<!--F44893EDBDA84C6BAF99A1F8550E5044--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--F44893EDBDA84C6BAF99A1F8550E5044--></AD_PREFERENCE>
+
</data>
diff --git a/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java b/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java
--- a/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java
@@ -44,6 +44,7 @@
import org.openbravo.base.secureApp.VariablesHistory;
import org.openbravo.base.secureApp.VariablesSecureApp;
import org.openbravo.base.structure.BaseOBObject;
+import org.openbravo.client.kernel.RequestContext;
import org.openbravo.dal.core.OBContext;
import org.openbravo.dal.service.OBDal;
import org.openbravo.dal.service.OBQuery;
@@ -81,6 +82,8 @@
*/
private static final String PREVIOUS_RANGE = "ReportGeneralLedgerJournal.previousRange";
private static final String PREVIOUS_RANGE_OLD = "ReportGeneralLedgerJournal.previousRangeOld";
+ private static final Map<String, Integer> userExecutions = new HashMap<String, Integer>();
+ private static int reportExecutions = 0;
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
@@ -269,10 +272,16 @@
strcelementvalueto);
vars.setSessionValue("inpElementValueIdFrom_DES", strcelementvaluefromdes);
vars.setSessionValue("inpElementValueIdTo_DES", strcelementvaluetodes);
- printPageDataSheet(response, vars, strDateFrom, strDateTo, strDocument, strDocumentNo,
- strOrg, "", "", "", strcAcctSchemaId, strShowClosing, strShowReg, strShowOpening,
- strPageNo, strEntryNo, strShowDescription, strShowRegular, strShowDivideUp, "", "",
- strcelementvaluefrom, strcelementvalueto, strcelementvaluefromdes, strcelementvaluetodes);
+ try {
+ increaseReportUsage(vars);
+ printPageDataSheet(response, vars, strDateFrom, strDateTo, strDocument, strDocumentNo,
+ strOrg, "", "", "", strcAcctSchemaId, strShowClosing, strShowReg, strShowOpening,
+ strPageNo, strEntryNo, strShowDescription, strShowRegular, strShowDivideUp, "", "",
+ strcelementvaluefrom, strcelementvalueto, strcelementvaluefromdes,
+ strcelementvaluetodes);
+ } finally {
+ decreaseReportUsage();
+ }
} else if (vars.commandIn("PDF", "XLS")) {
if (log4j.isDebugEnabled()) {
log4j.debug("PDF");
@@ -359,10 +368,15 @@
"ReportGeneralLedgerJournal|C_ElementValue_IDFROM");
String strcelementvalueto = vars.getRequestGlobalVariable("inpcElementValueIdTo",
"ReportGeneralLedgerJournal|C_ElementValue_IDTO");
- printPagePDF(request, response, vars, strDateFrom, strDateTo, strDocument, strDocumentNo,
- strOrg, strTable, strRecord, strFactAcctGroupId, strcAcctSchemaId, strShowClosing,
- strShowReg, strShowOpening, strPageNo, strEntryNo, "Y".equals(strShowDescription) ? "Y"
- : "", strShowRegular, strShowDivideUp, strcelementvaluefrom, strcelementvalueto);
+ try {
+ increaseReportUsage(vars);
+ printPagePDF(request, response, vars, strDateFrom, strDateTo, strDocument, strDocumentNo,
+ strOrg, strTable, strRecord, strFactAcctGroupId, strcAcctSchemaId, strShowClosing,
+ strShowReg, strShowOpening, strPageNo, strEntryNo, "Y".equals(strShowDescription) ? "Y"
+ : "", strShowRegular, strShowDivideUp, strcelementvaluefrom, strcelementvalueto);
+ } finally {
+ decreaseReportUsage();
+ }
} else if (vars.commandIn("PREVIOUS_RELATION")) {
String strInitRecord = vars.getSessionValue("ReportGeneralLedgerJournal.initRecordNumber");
String strPreviousRecordRange = vars.getSessionValue(PREVIOUS_RANGE);
@@ -464,6 +478,7 @@
String oraLimit1 = null;
String oraLimit2 = null;
String pgLimit = null;
+ boolean loadReportData = vars.getMessage("ReportGeneralLedgerJournal") == null;
try {
if (vars.commandIn("FIND")
|| vars.commandIn("DEFAULT")
@@ -553,27 +568,29 @@
pgLimit = intRecordRangeUsed + " OFFSET "
+ (initRecordNumber == 0 ? initRecordNumber : initRecordNumber - 1);
}
- scrollData = ReportGeneralLedgerJournalData.select(this, rowNum, "'N'",
- Utility.getContext(this, vars, "#User_Client", "ReportGeneralLedger"),
- Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportGeneralLedger"),
- strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strDocument,
- getDocumentNo(vars.getClient(), strDocument, strDocumentNo), strcAcctSchemaId,
- strOrgFamily, strCheck, strAllaccounts, strcelementvaluefrom, strcelementvalueto,
- vars.getLanguage(), pgLimit, oraLimit1, oraLimit2);
- Vector<ReportGeneralLedgerJournalData> res = new Vector<ReportGeneralLedgerJournalData>();
- while (scrollData.next()) {
- res.add(scrollData.get());
- }
- data = new ReportGeneralLedgerJournalData[res.size()];
- res.copyInto(data);
- if (data != null && data.length > 0) {
- strPosition = ReportGeneralLedgerJournalData.selectCount(this,
+ if (loadReportData) {
+ scrollData = ReportGeneralLedgerJournalData.select(this, rowNum, "'N'",
Utility.getContext(this, vars, "#User_Client", "ReportGeneralLedger"),
Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportGeneralLedger"),
strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strDocument,
getDocumentNo(vars.getClient(), strDocument, strDocumentNo), strcAcctSchemaId,
strOrgFamily, strCheck, strAllaccounts, strcelementvaluefrom, strcelementvalueto,
- data[0].dateacct, data[0].identifier);
+ vars.getLanguage(), pgLimit, oraLimit1, oraLimit2);
+ Vector<ReportGeneralLedgerJournalData> res = new Vector<ReportGeneralLedgerJournalData>();
+ while (scrollData.next()) {
+ res.add(scrollData.get());
+ }
+ data = new ReportGeneralLedgerJournalData[res.size()];
+ res.copyInto(data);
+ if (data != null && data.length > 0) {
+ strPosition = ReportGeneralLedgerJournalData.selectCount(this,
+ Utility.getContext(this, vars, "#User_Client", "ReportGeneralLedger"),
+ Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportGeneralLedger"),
+ strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strDocument,
+ getDocumentNo(vars.getClient(), strDocument, strDocumentNo), strcAcctSchemaId,
+ strOrgFamily, strCheck, strAllaccounts, strcelementvaluefrom, strcelementvalueto,
+ data[0].dateacct, data[0].identifier);
+ }
}
} else {
if (this.myPool.getRDBMS().equalsIgnoreCase("ORACLE")) {
@@ -587,23 +604,25 @@
pgLimit = intRecordRangePredefined + " OFFSET "
+ (initRecordNumber == 0 ? initRecordNumber : initRecordNumber - 1);
}
- scrollData = ReportGeneralLedgerJournalData.selectDirect(this, rowNum,
- "Y".equals(strShowDescription) ? "'Y'" : "'N'",
- Utility.getContext(this, vars, "#User_Client", "ReportGeneralLedger"),
- Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportGeneralLedger"),
- strTable, strRecord, strcAcctSchemaId, vars.getLanguage(), pgLimit, oraLimit1,
- oraLimit2);
- Vector<ReportGeneralLedgerJournalData> res = new Vector<ReportGeneralLedgerJournalData>();
- while (scrollData.next()) {
- res.add(scrollData.get());
- }
- data = new ReportGeneralLedgerJournalData[res.size()];
- res.copyInto(data);
- if (data != null && data.length > 0)
- strPosition = ReportGeneralLedgerJournalData.selectCountDirect(this,
+ if (loadReportData) {
+ scrollData = ReportGeneralLedgerJournalData.selectDirect(this, rowNum,
+ "Y".equals(strShowDescription) ? "'Y'" : "'N'",
Utility.getContext(this, vars, "#User_Client", "ReportGeneralLedger"),
Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportGeneralLedger"),
- strTable, strRecord, strFactAcctGroupId, data[0].dateacct, data[0].identifier);
+ strTable, strRecord, strcAcctSchemaId, vars.getLanguage(), pgLimit, oraLimit1,
+ oraLimit2);
+ Vector<ReportGeneralLedgerJournalData> res = new Vector<ReportGeneralLedgerJournalData>();
+ while (scrollData.next()) {
+ res.add(scrollData.get());
+ }
+ data = new ReportGeneralLedgerJournalData[res.size()];
+ res.copyInto(data);
+ if (data != null && data.length > 0)
+ strPosition = ReportGeneralLedgerJournalData.selectCountDirect(this,
+ Utility.getContext(this, vars, "#User_Client", "ReportGeneralLedger"),
+ Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportGeneralLedger"),
+ strTable, strRecord, strFactAcctGroupId, data[0].dateacct, data[0].identifier);
+ }
}
} else if (vars.commandIn("DIRECT")) {
scrollData = ReportGeneralLedgerJournalData.selectDirect(this, rowNum,
@@ -797,6 +816,13 @@
String strTreeOrg = TreeData.getTreeOrg(this, vars.getClient());
String strOrgFamily = getFamily(strTreeOrg, strOrg);
try {
+ OBError myMessage = vars.getMessage("ReportGeneralLedgerJournal");
+ vars.removeMessage("ReportGeneralLedgerJournal");
+ if (myMessage != null) {
+ advisePopUp(request, response, myMessage.getType(), myMessage.getTitle(),
+ myMessage.getMessage());
+ return;
+ }
if (!strFactAcctGroupId.equals("")) {
scrollData = ReportGeneralLedgerJournalData.selectDirect2(this,
Utility.getContext(this, vars, "#User_Client", "ReportGeneralLedger"),
@@ -1048,4 +1074,46 @@
public String getServletInfo() {
return "Servlet ReportGeneralLedgerJournal. This Servlet was made by Pablo Sarobe modified by everybody";
} // end of getServletInfo() method
+
+ private void increaseReportUsage(VariablesSecureApp vars) {
+ String preferenceValue = Utility.getPreference(vars, "ReportsUserExecutionsLimit", "");
+ int userExecutionLimit = Integer.parseInt(StringUtils.isEmpty(preferenceValue) ? "1"
+ : preferenceValue);
+
+ preferenceValue = Utility.getPreference(vars, "ReportsExecutionsLimit", "");
+ int reportExecutionLimit = Integer.parseInt(StringUtils.isEmpty(preferenceValue) ? "1"
+ : preferenceValue);
+
+ String userId = getAuthenticatedUserId();
+ int userExecution = userExecutions.containsKey(userId) ? userExecutions.get(userId) : 0;
+
+ if (userExecution >= userExecutionLimit || reportExecutions >= reportExecutionLimit) {
+ OBError myMessage = new OBError();
+ myMessage.setType("Error");
+ myMessage.setTitle("");
+ String msgbody = Utility.messageBD(this, "ReportsExecutionsLimit", vars.getLanguage());
+ myMessage.setMessage(msgbody);
+ vars.setMessage("ReportGeneralLedgerJournal", myMessage);
+ } else {
+ reportExecutions++;
+ userExecution++;
+
+ userExecutions.put(userId, userExecution);
+ }
+ }
+
+ private String getAuthenticatedUserId() {
+ return (String) RequestContext.get().getSession().getAttribute("#Authenticated_user");
+ }
+
+ private void decreaseReportUsage() {
+ String userId = getAuthenticatedUserId();
+ if (userExecutions.containsKey(userId)) {
+ userExecutions.put(userId, userExecutions.get(userId) - 1);
+ if (userExecutions.get(userId) <= 0) {
+ userExecutions.remove(userId);
+ }
+ }
+ reportExecutions--;
+ }
}
# HG changeset patch
# User Alvaro Ferraz <alvaro.ferraz@openbravo.com>
# Date 1497530655 -7200
# Thu Jun 15 14:44:15 2017 +0200
# Node ID 1648170196fb6d589c47564e460c499c9a6b90b8
# Parent b08f498eba610b4b70e34355fcf2e0046a2e0f51
Related to issue 36245: Code review improvements
Preferences will have a value of 0 to avoid changing the default behaviour.
Improved error messages to show more information to end user.
Use advise() to show error when launching in HTML and advisePopUp when launching in PDF/XLS.
Run report only if execution limit error was not thrown.
Execution number will be increased always before checking if limits are reached and they will be decreased always after throwing the error or running the report, inside finally statement.
reportExecutions variable will be initialized again to zero in case it goes to negative by mistake.
diff --git a/src-db/database/sourcedata/AD_MESSAGE.xml b/src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml
@@ -21377,7 +21377,7 @@
<!--71755E370E6F4AB185E9AC5CB573CAB0--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
<!--71755E370E6F4AB185E9AC5CB573CAB0--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
<!--71755E370E6F4AB185E9AC5CB573CAB0--> <VALUE><![CDATA[ReportsExecutionsLimit]]></VALUE>
-<!--71755E370E6F4AB185E9AC5CB573CAB0--> <MSGTEXT><![CDATA[Report execution limit has been exceeded]]></MSGTEXT>
+<!--71755E370E6F4AB185E9AC5CB573CAB0--> <MSGTEXT><![CDATA[Report execution limit (%d) has been reached]]></MSGTEXT>
<!--71755E370E6F4AB185E9AC5CB573CAB0--> <MSGTYPE><![CDATA[E]]></MSGTYPE>
<!--71755E370E6F4AB185E9AC5CB573CAB0--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
<!--71755E370E6F4AB185E9AC5CB573CAB0--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
@@ -21576,6 +21576,18 @@
<!--750BD7EF580544768D8DEC762753A24D--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
<!--750BD7EF580544768D8DEC762753A24D--></AD_MESSAGE>
+<!--751B5CDC5E974D068360BE1AB88C0B55--><AD_MESSAGE>
+<!--751B5CDC5E974D068360BE1AB88C0B55--> <AD_MESSAGE_ID><![CDATA[751B5CDC5E974D068360BE1AB88C0B55]]></AD_MESSAGE_ID>
+<!--751B5CDC5E974D068360BE1AB88C0B55--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--751B5CDC5E974D068360BE1AB88C0B55--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--751B5CDC5E974D068360BE1AB88C0B55--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--751B5CDC5E974D068360BE1AB88C0B55--> <VALUE><![CDATA[ReportsUserExecutionsLimit]]></VALUE>
+<!--751B5CDC5E974D068360BE1AB88C0B55--> <MSGTEXT><![CDATA[Report execution limit (%d) has been reached for user %s]]></MSGTEXT>
+<!--751B5CDC5E974D068360BE1AB88C0B55--> <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--751B5CDC5E974D068360BE1AB88C0B55--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--751B5CDC5E974D068360BE1AB88C0B55--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--751B5CDC5E974D068360BE1AB88C0B55--></AD_MESSAGE>
+
<!--76044028A6A54026900ABC05910E2216--><AD_MESSAGE>
<!--76044028A6A54026900ABC05910E2216--> <AD_MESSAGE_ID><![CDATA[76044028A6A54026900ABC05910E2216]]></AD_MESSAGE_ID>
<!--76044028A6A54026900ABC05910E2216--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff --git a/src-db/database/sourcedata/AD_PREFERENCE.xml b/src-db/database/sourcedata/AD_PREFERENCE.xml
--- a/src-db/database/sourcedata/AD_PREFERENCE.xml
+++ b/src-db/database/sourcedata/AD_PREFERENCE.xml
@@ -30,7 +30,7 @@
<!--D8BA2E4D3073410D8ABA9CC5BEC1B7D0--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
<!--D8BA2E4D3073410D8ABA9CC5BEC1B7D0--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
<!--D8BA2E4D3073410D8ABA9CC5BEC1B7D0--> <ATTRIBUTE><![CDATA[ReportsUserExecutionsLimit]]></ATTRIBUTE>
-<!--D8BA2E4D3073410D8ABA9CC5BEC1B7D0--> <VALUE><![CDATA[1]]></VALUE>
+<!--D8BA2E4D3073410D8ABA9CC5BEC1B7D0--> <VALUE><![CDATA[0]]></VALUE>
<!--D8BA2E4D3073410D8ABA9CC5BEC1B7D0--> <ISPROPERTYLIST><![CDATA[N]]></ISPROPERTYLIST>
<!--D8BA2E4D3073410D8ABA9CC5BEC1B7D0--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
<!--D8BA2E4D3073410D8ABA9CC5BEC1B7D0--></AD_PREFERENCE>
@@ -52,7 +52,7 @@
<!--F44893EDBDA84C6BAF99A1F8550E5044--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
<!--F44893EDBDA84C6BAF99A1F8550E5044--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
<!--F44893EDBDA84C6BAF99A1F8550E5044--> <ATTRIBUTE><![CDATA[ReportsExecutionsLimit]]></ATTRIBUTE>
-<!--F44893EDBDA84C6BAF99A1F8550E5044--> <VALUE><![CDATA[1]]></VALUE>
+<!--F44893EDBDA84C6BAF99A1F8550E5044--> <VALUE><![CDATA[0]]></VALUE>
<!--F44893EDBDA84C6BAF99A1F8550E5044--> <ISPROPERTYLIST><![CDATA[N]]></ISPROPERTYLIST>
<!--F44893EDBDA84C6BAF99A1F8550E5044--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
<!--F44893EDBDA84C6BAF99A1F8550E5044--></AD_PREFERENCE>
diff --git a/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java b/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java
--- a/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java
@@ -60,6 +60,7 @@
import org.openbravo.erpCommon.utility.OBLedgerUtils;
import org.openbravo.erpCommon.utility.ToolBar;
import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.model.ad.access.User;
import org.openbravo.model.ad.datamodel.Table;
import org.openbravo.model.common.enterprise.DocumentType;
import org.openbravo.model.financialmgmt.accounting.coa.AcctSchema;
@@ -197,83 +198,87 @@
printPageDataSheet(response, vars, "", "", "", "", "", "", "", strFactAcctGroupId, "", "",
"", "", "1", "1", "", "Y", "", "", "", "", "", "", "");
} else if (vars.commandIn("FIND")) {
- String strcAcctSchemaId = vars.getRequestGlobalVariable("inpcAcctSchemaId",
- "ReportGeneralLedger|cAcctSchemaId");
- vars.setSessionValue("ReportGeneralLedgerJournal|cAcctSchemaId", strcAcctSchemaId);
- String strDateFrom = vars.getRequestGlobalVariable("inpDateFrom",
- "ReportGeneralLedgerJournal|DateFrom");
- String strDateTo = vars.getRequestGlobalVariable("inpDateTo",
- "ReportGeneralLedgerJournal|DateTo");
- String strDocument = vars.getRequestGlobalVariable("inpDocument",
- "ReportGeneralLedgerJournal|Document");
- String strDocumentNo = vars.getRequestGlobalVariable("inpDocumentNo",
- "ReportGeneralLedgerJournal|DocumentNo");
- String strOrg = vars.getGlobalVariable("inpOrg", "ReportGeneralLedgerJournal|Org", "0");
- String strShowClosing = vars.getRequestGlobalVariable("inpShowClosing",
- "ReportGeneralLedgerJournal|ShowClosing");
- if (strShowClosing == null || "".equals(strShowClosing))
- vars.setSessionValue("ReportGeneralLedgerJournal|ShowClosing", "N");
- String strShowDivideUp = vars.getRequestGlobalVariable("inpShowDivideUp",
- "ReportGeneralLedgerJournal|ShowDivideUp");
- if (strShowDivideUp == null || "".equals(strShowDivideUp))
- vars.setSessionValue("ReportGeneralLedgerJournal|ShowDivideUp", "N");
- String strShowRegular = vars.getRequestGlobalVariable("inpShowRegular",
- "ReportGeneralLedgerJournal|ShowRegular");
- if (strShowRegular == null || "".equals(strShowRegular))
- vars.setSessionValue("ReportGeneralLedgerJournal|ShowRegular", "N");
- String strShowReg = vars.getRequestGlobalVariable("inpShowReg",
- "ReportGeneralLedgerJournal|ShowReg");
- if (strShowReg == null || "".equals(strShowReg))
- vars.setSessionValue("ReportGeneralLedgerJournal|ShowReg", "N");
- String strShowOpening = vars.getRequestGlobalVariable("inpShowOpening",
- "ReportGeneralLedgerJournal|ShowOpening");
- if (strShowOpening == null || "".equals(strShowOpening))
- vars.setSessionValue("ReportGeneralLedgerJournal|ShowOpening", "N");
- if (!("Y".equals(strShowOpening)) && !("Y".equals(strShowReg))
- && !("Y".equals(strShowRegular)) && !("Y".equals(strShowClosing))
- && !("Y".equals(strShowDivideUp))) {
- strShowRegular = "Y";
- vars.setSessionValue("ReportGeneralLedgerJournal|ShowRegular", "Y");
- }
- String strShowClosing1 = vars.getStringParameter("inpShowClosing");
- String strShowReg1 = vars.getStringParameter("inpShowReg");
- String strShowOpening1 = vars.getStringParameter("inpShowOpening");
- String strShowDivideUp1 = vars.getStringParameter("inpShowDivideUp");
- log4j.debug("********FIND*************** strShowClosing: " + strShowClosing);
- log4j.debug("********FIND*************** strShowReg: " + strShowReg);
- log4j.debug("********FIND*************** strShowOpening: " + strShowOpening);
- log4j.debug("********FIND*************** strShowDivideUp: " + strShowDivideUp);
- log4j.debug("********FIND*************** strShowClosing1: " + strShowClosing1);
- log4j.debug("********FIND*************** strShowReg1: " + strShowReg1);
- log4j.debug("********FIND*************** strShowOpening1: " + strShowOpening1);
- log4j.debug("********FIND*************** strShowDivideUp1: " + strShowDivideUp1);
- vars.setSessionValue("ReportGeneralLedgerJournal.initRecordNumber", "0");
- vars.setSessionValue(PREVIOUS_ACCTENTRIES, "0");
- vars.setSessionValue(PREVIOUS_RANGE, "");
- setHistoryCommand(request, "DEFAULT");
- String strPageNo = vars.getRequestGlobalVariable("inpPageNo",
- "ReportGeneralLedgerJournal|PageNo");
- String strEntryNo = vars.getRequestGlobalVariable("inpEntryNo",
- "ReportGeneralLedgerJournal|EntryNo");
- String strShowDescription = vars.getRequestGlobalVariable("inpShowDescription",
- "ReportGeneralLedgerJournal|ShowDescription");
- if (strShowDescription == null || "".equals(strShowDescription))
- vars.setSessionValue("ReportGeneralLedgerJournal|ShowDescription", "N");
- String strcelementvaluefrom = vars.getRequestGlobalVariable("inpcElementValueIdFrom",
- "ReportGeneralLedgerJournal|C_ElementValue_IDFROM");
- String strcelementvalueto = vars.getRequestGlobalVariable("inpcElementValueIdTo",
- "ReportGeneralLedgerJournal|C_ElementValue_IDTO");
- String strcelementvaluefromdes = "", strcelementvaluetodes = "";
- if (!strcelementvaluefrom.equals(""))
- strcelementvaluefromdes = ReportGeneralLedgerData.selectSubaccountDescription(this,
- strcelementvaluefrom);
- if (!strcelementvalueto.equals(""))
- strcelementvaluetodes = ReportGeneralLedgerData.selectSubaccountDescription(this,
- strcelementvalueto);
- vars.setSessionValue("inpElementValueIdFrom_DES", strcelementvaluefromdes);
- vars.setSessionValue("inpElementValueIdTo_DES", strcelementvaluetodes);
try {
- increaseReportUsage(vars);
+ OBError msg = checkReportUsage(vars);
+ if (msg != null) {
+ advise(request, response, msg.getType(), msg.getTitle(), msg.getMessage());
+ return;
+ }
+ String strcAcctSchemaId = vars.getRequestGlobalVariable("inpcAcctSchemaId",
+ "ReportGeneralLedger|cAcctSchemaId");
+ vars.setSessionValue("ReportGeneralLedgerJournal|cAcctSchemaId", strcAcctSchemaId);
+ String strDateFrom = vars.getRequestGlobalVariable("inpDateFrom",
+ "ReportGeneralLedgerJournal|DateFrom");
+ String strDateTo = vars.getRequestGlobalVariable("inpDateTo",
+ "ReportGeneralLedgerJournal|DateTo");
+ String strDocument = vars.getRequestGlobalVariable("inpDocument",
+ "ReportGeneralLedgerJournal|Document");
+ String strDocumentNo = vars.getRequestGlobalVariable("inpDocumentNo",
+ "ReportGeneralLedgerJournal|DocumentNo");
+ String strOrg = vars.getGlobalVariable("inpOrg", "ReportGeneralLedgerJournal|Org", "0");
+ String strShowClosing = vars.getRequestGlobalVariable("inpShowClosing",
+ "ReportGeneralLedgerJournal|ShowClosing");
+ if (strShowClosing == null || "".equals(strShowClosing))
+ vars.setSessionValue("ReportGeneralLedgerJournal|ShowClosing", "N");
+ String strShowDivideUp = vars.getRequestGlobalVariable("inpShowDivideUp",
+ "ReportGeneralLedgerJournal|ShowDivideUp");
+ if (strShowDivideUp == null || "".equals(strShowDivideUp))
+ vars.setSessionValue("ReportGeneralLedgerJournal|ShowDivideUp", "N");
+ String strShowRegular = vars.getRequestGlobalVariable("inpShowRegular",
+ "ReportGeneralLedgerJournal|ShowRegular");
+ if (strShowRegular == null || "".equals(strShowRegular))
+ vars.setSessionValue("ReportGeneralLedgerJournal|ShowRegular", "N");
+ String strShowReg = vars.getRequestGlobalVariable("inpShowReg",
+ "ReportGeneralLedgerJournal|ShowReg");
+ if (strShowReg == null || "".equals(strShowReg))
+ vars.setSessionValue("ReportGeneralLedgerJournal|ShowReg", "N");
+ String strShowOpening = vars.getRequestGlobalVariable("inpShowOpening",
+ "ReportGeneralLedgerJournal|ShowOpening");
+ if (strShowOpening == null || "".equals(strShowOpening))
+ vars.setSessionValue("ReportGeneralLedgerJournal|ShowOpening", "N");
+ if (!("Y".equals(strShowOpening)) && !("Y".equals(strShowReg))
+ && !("Y".equals(strShowRegular)) && !("Y".equals(strShowClosing))
+ && !("Y".equals(strShowDivideUp))) {
+ strShowRegular = "Y";
+ vars.setSessionValue("ReportGeneralLedgerJournal|ShowRegular", "Y");
+ }
+ String strShowClosing1 = vars.getStringParameter("inpShowClosing");
+ String strShowReg1 = vars.getStringParameter("inpShowReg");
+ String strShowOpening1 = vars.getStringParameter("inpShowOpening");
+ String strShowDivideUp1 = vars.getStringParameter("inpShowDivideUp");
+ log4j.debug("********FIND*************** strShowClosing: " + strShowClosing);
+ log4j.debug("********FIND*************** strShowReg: " + strShowReg);
+ log4j.debug("********FIND*************** strShowOpening: " + strShowOpening);
+ log4j.debug("********FIND*************** strShowDivideUp: " + strShowDivideUp);
+ log4j.debug("********FIND*************** strShowClosing1: " + strShowClosing1);
+ log4j.debug("********FIND*************** strShowReg1: " + strShowReg1);
+ log4j.debug("********FIND*************** strShowOpening1: " + strShowOpening1);
+ log4j.debug("********FIND*************** strShowDivideUp1: " + strShowDivideUp1);
+ vars.setSessionValue("ReportGeneralLedgerJournal.initRecordNumber", "0");
+ vars.setSessionValue(PREVIOUS_ACCTENTRIES, "0");
+ vars.setSessionValue(PREVIOUS_RANGE, "");
+ setHistoryCommand(request, "DEFAULT");
+ String strPageNo = vars.getRequestGlobalVariable("inpPageNo",
+ "ReportGeneralLedgerJournal|PageNo");
+ String strEntryNo = vars.getRequestGlobalVariable("inpEntryNo",
+ "ReportGeneralLedgerJournal|EntryNo");
+ String strShowDescription = vars.getRequestGlobalVariable("inpShowDescription",
+ "ReportGeneralLedgerJournal|ShowDescription");
+ if (strShowDescription == null || "".equals(strShowDescription))
+ vars.setSessionValue("ReportGeneralLedgerJournal|ShowDescription", "N");
+ String strcelementvaluefrom = vars.getRequestGlobalVariable("inpcElementValueIdFrom",
+ "ReportGeneralLedgerJournal|C_ElementValue_IDFROM");
+ String strcelementvalueto = vars.getRequestGlobalVariable("inpcElementValueIdTo",
+ "ReportGeneralLedgerJournal|C_ElementValue_IDTO");
+ String strcelementvaluefromdes = "", strcelementvaluetodes = "";
+ if (!strcelementvaluefrom.equals(""))
+ strcelementvaluefromdes = ReportGeneralLedgerData.selectSubaccountDescription(this,
+ strcelementvaluefrom);
+ if (!strcelementvalueto.equals(""))
+ strcelementvaluetodes = ReportGeneralLedgerData.selectSubaccountDescription(this,
+ strcelementvalueto);
+ vars.setSessionValue("inpElementValueIdFrom_DES", strcelementvaluefromdes);
+ vars.setSessionValue("inpElementValueIdTo_DES", strcelementvaluetodes);
printPageDataSheet(response, vars, strDateFrom, strDateTo, strDocument, strDocumentNo,
strOrg, "", "", "", strcAcctSchemaId, strShowClosing, strShowReg, strShowOpening,
strPageNo, strEntryNo, strShowDescription, strShowRegular, strShowDivideUp, "", "",
@@ -283,93 +288,97 @@
decreaseReportUsage();
}
} else if (vars.commandIn("PDF", "XLS")) {
- if (log4j.isDebugEnabled()) {
- log4j.debug("PDF");
- }
- String strcAcctSchemaId = vars.getRequestGlobalVariable("inpcAcctSchemaId",
- "ReportGeneralLedger|cAcctSchemaId");
- String strDateFrom = vars.getRequestGlobalVariable("inpDateFrom",
- "ReportGeneralLedgerJournal|DateFrom");
- String strDateTo = vars.getRequestGlobalVariable("inpDateTo",
- "ReportGeneralLedgerJournal|DateTo");
- String strDocument = vars.getRequestGlobalVariable("inpDocument",
- "ReportGeneralLedgerJournal|Document");
- String strDocumentNo = vars.getRequestGlobalVariable("inpDocumentNo",
- "ReportGeneralLedgerJournal|DocumentNo");
- String strOrg = vars.getGlobalVariable("inpOrg", "ReportGeneralLedgerJournal|Org", "0");
- String strShowClosing = vars.getRequestGlobalVariable("inpShowClosing",
- "ReportGeneralLedgerJournal|ShowClosing");
- if (strShowClosing == null || "".equals(strShowClosing))
- vars.setSessionValue("ReportGeneralLedgerJournal|ShowClosing", "N");
- String strShowRegular = vars.getRequestGlobalVariable("inpShowRegular",
- "ReportGeneralLedgerJournal|ShowRegular");
- if (strShowRegular == null || "".equals(strShowRegular))
- vars.setSessionValue("ReportGeneralLedgerJournal|ShowRegular", "N");
- String strShowReg = vars.getRequestGlobalVariable("inpShowReg",
- "ReportGeneralLedgerJournal|ShowReg");
- if (strShowReg == null || "".equals(strShowReg))
- vars.setSessionValue("ReportGeneralLedgerJournal|ShowReg", "N");
- String strShowOpening = vars.getRequestGlobalVariable("inpShowOpening",
- "ReportGeneralLedgerJournal|ShowOpening");
- if (strShowOpening == null || "".equals(strShowOpening))
- vars.setSessionValue("ReportGeneralLedgerJournal|ShowOpening", "N");
- String strShowDivideUp = vars.getRequestGlobalVariable("inpShowDivideUp",
- "ReportGeneralLedgerJournal|ShowDivideUp");
- if (strShowDivideUp == null || "".equals(strShowDivideUp))
- vars.setSessionValue("ReportGeneralLedgerJournal|ShowDivideUp", "N");
- // In case all flags "Type" are deactivated, the "Regular" one is activated by default
- if (!("Y".equals(strShowOpening)) && !("Y".equals(strShowReg))
- && !("Y".equals(strShowRegular)) && !("Y".equals(strShowClosing))
- && !("Y".equals(strShowDivideUp))) {
- strShowRegular = "Y";
- vars.setSessionValue("ReportGeneralLedgerJournal|ShowRegular", "Y");
- }
+ try {
+ if (log4j.isDebugEnabled()) {
+ log4j.debug("PDF");
+ }
+ OBError msg = checkReportUsage(vars);
+ if (msg != null) {
+ advisePopUp(request, response, msg.getType(), msg.getTitle(), msg.getMessage());
+ return;
+ }
+ String strcAcctSchemaId = vars.getRequestGlobalVariable("inpcAcctSchemaId",
+ "ReportGeneralLedger|cAcctSchemaId");
+ String strDateFrom = vars.getRequestGlobalVariable("inpDateFrom",
+ "ReportGeneralLedgerJournal|DateFrom");
+ String strDateTo = vars.getRequestGlobalVariable("inpDateTo",
+ "ReportGeneralLedgerJournal|DateTo");
+ String strDocument = vars.getRequestGlobalVariable("inpDocument",
+ "ReportGeneralLedgerJournal|Document");
+ String strDocumentNo = vars.getRequestGlobalVariable("inpDocumentNo",
+ "ReportGeneralLedgerJournal|DocumentNo");
+ String strOrg = vars.getGlobalVariable("inpOrg", "ReportGeneralLedgerJournal|Org", "0");
+ String strShowClosing = vars.getRequestGlobalVariable("inpShowClosing",
+ "ReportGeneralLedgerJournal|ShowClosing");
+ if (strShowClosing == null || "".equals(strShowClosing))
+ vars.setSessionValue("ReportGeneralLedgerJournal|ShowClosing", "N");
+ String strShowRegular = vars.getRequestGlobalVariable("inpShowRegular",
+ "ReportGeneralLedgerJournal|ShowRegular");
+ if (strShowRegular == null || "".equals(strShowRegular))
+ vars.setSessionValue("ReportGeneralLedgerJournal|ShowRegular", "N");
+ String strShowReg = vars.getRequestGlobalVariable("inpShowReg",
+ "ReportGeneralLedgerJournal|ShowReg");
+ if (strShowReg == null || "".equals(strShowReg))
+ vars.setSessionValue("ReportGeneralLedgerJournal|ShowReg", "N");
+ String strShowOpening = vars.getRequestGlobalVariable("inpShowOpening",
+ "ReportGeneralLedgerJournal|ShowOpening");
+ if (strShowOpening == null || "".equals(strShowOpening))
+ vars.setSessionValue("ReportGeneralLedgerJournal|ShowOpening", "N");
+ String strShowDivideUp = vars.getRequestGlobalVariable("inpShowDivideUp",
+ "ReportGeneralLedgerJournal|ShowDivideUp");
+ if (strShowDivideUp == null || "".equals(strShowDivideUp))
+ vars.setSessionValue("ReportGeneralLedgerJournal|ShowDivideUp", "N");
+ // In case all flags "Type" are deactivated, the "Regular" one is activated by default
+ if (!("Y".equals(strShowOpening)) && !("Y".equals(strShowReg))
+ && !("Y".equals(strShowRegular)) && !("Y".equals(strShowClosing))
+ && !("Y".equals(strShowDivideUp))) {
+ strShowRegular = "Y";
+ vars.setSessionValue("ReportGeneralLedgerJournal|ShowRegular", "Y");
+ }
- // String strRecord = vars.getGlobalVariable("inpRecord",
- // "ReportGeneralLedgerJournal|Record");
- // String strTable = vars.getGlobalVariable("inpTable",
- // "ReportGeneralLedgerJournal|Table");
- String strTable = vars.getStringParameter("inpTable");
- String strRecord = vars.getStringParameter("inpRecord");
- String strPageNo = vars.getGlobalVariable("inpPageNo", "ReportGeneralLedgerJournal|PageNo",
- "1");
- String strEntryNo = vars.getGlobalVariable("inpEntryNo",
- "ReportGeneralLedgerJournal|EntryNo", "1");
- String strShowDescription = vars.getRequestGlobalVariable("inpShowDescription",
- "ReportGeneralLedgerJournal|ShowDescription");
- if (strShowDescription == null || "".equals(strShowDescription))
- vars.setSessionValue("ReportGeneralLedgerJournal|ShowDescription", "N");
- /*
- * Scenario 1: We will have FactAcctGroupId while the request redirect from
- * ReportGeneralLedger Report. Otherwise we don't need to use FactAcctGroupId for PDF or Excel
- * report. So we have to check the immediate history command has DIRECT2 (It means previous
- * request from ReportGeneralLedger Report) Scenario 2: If we print once in PDF, it will reset
- * the history of COMMAND with DEFAULT, so same record of redirect wont print more than one
- * time. It will consider as default in second time.Scenario 3: If user change the filter
- * criteria, however he has come from ReportGeneralLedger Report(DIRECT2) We don't take
- * strFactAcctGroupId(will take care of criteria from current screen)
- */
- String strFactAcctGroupId = "";
- if (strcAcctSchemaId.equals("") && strDateFrom.equals("") && strDocument.equals("")
- && strOrg.equals("0") && strShowClosing.equals("") && strShowReg.equals("")
- && strShowOpening.equals("") && strRecord.equals("")) {
+ // String strRecord = vars.getGlobalVariable("inpRecord",
+ // "ReportGeneralLedgerJournal|Record");
+ // String strTable = vars.getGlobalVariable("inpTable",
+ // "ReportGeneralLedgerJournal|Table");
+ String strTable = vars.getStringParameter("inpTable");
+ String strRecord = vars.getStringParameter("inpRecord");
+ String strPageNo = vars.getGlobalVariable("inpPageNo", "ReportGeneralLedgerJournal|PageNo",
+ "1");
+ String strEntryNo = vars.getGlobalVariable("inpEntryNo",
+ "ReportGeneralLedgerJournal|EntryNo", "1");
+ String strShowDescription = vars.getRequestGlobalVariable("inpShowDescription",
+ "ReportGeneralLedgerJournal|ShowDescription");
+ if (strShowDescription == null || "".equals(strShowDescription))
+ vars.setSessionValue("ReportGeneralLedgerJournal|ShowDescription", "N");
+ /*
+ * Scenario 1: We will have FactAcctGroupId while the request redirect from
+ * ReportGeneralLedger Report. Otherwise we don't need to use FactAcctGroupId for PDF or
+ * Excel report. So we have to check the immediate history command has DIRECT2 (It means
+ * previous request from ReportGeneralLedger Report) Scenario 2: If we print once in PDF, it
+ * will reset the history of COMMAND with DEFAULT, so same record of redirect wont print
+ * more than one time. It will consider as default in second time.Scenario 3: If user change
+ * the filter criteria, however he has come from ReportGeneralLedger Report(DIRECT2) We
+ * don't take strFactAcctGroupId(will take care of criteria from current screen)
+ */
+ String strFactAcctGroupId = "";
+ if (strcAcctSchemaId.equals("") && strDateFrom.equals("") && strDocument.equals("")
+ && strOrg.equals("0") && strShowClosing.equals("") && strShowReg.equals("")
+ && strShowOpening.equals("") && strRecord.equals("")) {
- int currentHistoryIndex = new Integer(
- new VariablesHistory(request).getCurrentHistoryIndex()).intValue();
- String currentCommand = vars.getSessionValue("reqHistory.command" + currentHistoryIndex);
- if (currentCommand.equals("DIRECT2")) {
- strFactAcctGroupId = vars.getGlobalVariable("inpFactAcctGroupId",
- "ReportGeneralLedgerJournal|FactAcctGroupId");
+ int currentHistoryIndex = new Integer(
+ new VariablesHistory(request).getCurrentHistoryIndex()).intValue();
+ String currentCommand = vars.getSessionValue("reqHistory.command" + currentHistoryIndex);
+ if (currentCommand.equals("DIRECT2")) {
+ strFactAcctGroupId = vars.getGlobalVariable("inpFactAcctGroupId",
+ "ReportGeneralLedgerJournal|FactAcctGroupId");
+ }
}
- }
- // vars.setSessionValue("ReportGeneralLedgerJournal.initRecordNumber", "0");
- setHistoryCommand(request, "DEFAULT");
- String strcelementvaluefrom = vars.getRequestGlobalVariable("inpcElementValueIdFrom",
- "ReportGeneralLedgerJournal|C_ElementValue_IDFROM");
- String strcelementvalueto = vars.getRequestGlobalVariable("inpcElementValueIdTo",
- "ReportGeneralLedgerJournal|C_ElementValue_IDTO");
- try {
- increaseReportUsage(vars);
+ // vars.setSessionValue("ReportGeneralLedgerJournal.initRecordNumber", "0");
+ setHistoryCommand(request, "DEFAULT");
+ String strcelementvaluefrom = vars.getRequestGlobalVariable("inpcElementValueIdFrom",
+ "ReportGeneralLedgerJournal|C_ElementValue_IDFROM");
+ String strcelementvalueto = vars.getRequestGlobalVariable("inpcElementValueIdTo",
+ "ReportGeneralLedgerJournal|C_ElementValue_IDTO");
printPagePDF(request, response, vars, strDateFrom, strDateTo, strDocument, strDocumentNo,
strOrg, strTable, strRecord, strFactAcctGroupId, strcAcctSchemaId, strShowClosing,
strShowReg, strShowOpening, strPageNo, strEntryNo, "Y".equals(strShowDescription) ? "Y"
@@ -478,7 +487,6 @@
String oraLimit1 = null;
String oraLimit2 = null;
String pgLimit = null;
- boolean loadReportData = vars.getMessage("ReportGeneralLedgerJournal") == null;
try {
if (vars.commandIn("FIND")
|| vars.commandIn("DEFAULT")
@@ -568,29 +576,27 @@
pgLimit = intRecordRangeUsed + " OFFSET "
+ (initRecordNumber == 0 ? initRecordNumber : initRecordNumber - 1);
}
- if (loadReportData) {
- scrollData = ReportGeneralLedgerJournalData.select(this, rowNum, "'N'",
+ scrollData = ReportGeneralLedgerJournalData.select(this, rowNum, "'N'",
+ Utility.getContext(this, vars, "#User_Client", "ReportGeneralLedger"),
+ Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportGeneralLedger"),
+ strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strDocument,
+ getDocumentNo(vars.getClient(), strDocument, strDocumentNo), strcAcctSchemaId,
+ strOrgFamily, strCheck, strAllaccounts, strcelementvaluefrom, strcelementvalueto,
+ vars.getLanguage(), pgLimit, oraLimit1, oraLimit2);
+ Vector<ReportGeneralLedgerJournalData> res = new Vector<ReportGeneralLedgerJournalData>();
+ while (scrollData.next()) {
+ res.add(scrollData.get());
+ }
+ data = new ReportGeneralLedgerJournalData[res.size()];
+ res.copyInto(data);
+ if (data != null && data.length > 0) {
+ strPosition = ReportGeneralLedgerJournalData.selectCount(this,
Utility.getContext(this, vars, "#User_Client", "ReportGeneralLedger"),
Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportGeneralLedger"),
strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strDocument,
getDocumentNo(vars.getClient(), strDocument, strDocumentNo), strcAcctSchemaId,
strOrgFamily, strCheck, strAllaccounts, strcelementvaluefrom, strcelementvalueto,
- vars.getLanguage(), pgLimit, oraLimit1, oraLimit2);
- Vector<ReportGeneralLedgerJournalData> res = new Vector<ReportGeneralLedgerJournalData>();
- while (scrollData.next()) {
- res.add(scrollData.get());
- }
- data = new ReportGeneralLedgerJournalData[res.size()];
- res.copyInto(data);
- if (data != null && data.length > 0) {
- strPosition = ReportGeneralLedgerJournalData.selectCount(this,
- Utility.getContext(this, vars, "#User_Client", "ReportGeneralLedger"),
- Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportGeneralLedger"),
- strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strDocument,
- getDocumentNo(vars.getClient(), strDocument, strDocumentNo), strcAcctSchemaId,
- strOrgFamily, strCheck, strAllaccounts, strcelementvaluefrom, strcelementvalueto,
- data[0].dateacct, data[0].identifier);
- }
+ data[0].dateacct, data[0].identifier);
}
} else {
if (this.myPool.getRDBMS().equalsIgnoreCase("ORACLE")) {
@@ -604,25 +610,23 @@
pgLimit = intRecordRangePredefined + " OFFSET "
+ (initRecordNumber == 0 ? initRecordNumber : initRecordNumber - 1);
}
- if (loadReportData) {
- scrollData = ReportGeneralLedgerJournalData.selectDirect(this, rowNum,
- "Y".equals(strShowDescription) ? "'Y'" : "'N'",
+ scrollData = ReportGeneralLedgerJournalData.selectDirect(this, rowNum,
+ "Y".equals(strShowDescription) ? "'Y'" : "'N'",
+ Utility.getContext(this, vars, "#User_Client", "ReportGeneralLedger"),
+ Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportGeneralLedger"),
+ strTable, strRecord, strcAcctSchemaId, vars.getLanguage(), pgLimit, oraLimit1,
+ oraLimit2);
+ Vector<ReportGeneralLedgerJournalData> res = new Vector<ReportGeneralLedgerJournalData>();
+ while (scrollData.next()) {
+ res.add(scrollData.get());
+ }
+ data = new ReportGeneralLedgerJournalData[res.size()];
+ res.copyInto(data);
+ if (data != null && data.length > 0)
+ strPosition = ReportGeneralLedgerJournalData.selectCountDirect(this,
Utility.getContext(this, vars, "#User_Client", "ReportGeneralLedger"),
Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportGeneralLedger"),
- strTable, strRecord, strcAcctSchemaId, vars.getLanguage(), pgLimit, oraLimit1,
- oraLimit2);
- Vector<ReportGeneralLedgerJournalData> res = new Vector<ReportGeneralLedgerJournalData>();
- while (scrollData.next()) {
- res.add(scrollData.get());
- }
- data = new ReportGeneralLedgerJournalData[res.size()];
- res.copyInto(data);
- if (data != null && data.length > 0)
- strPosition = ReportGeneralLedgerJournalData.selectCountDirect(this,
- Utility.getContext(this, vars, "#User_Client", "ReportGeneralLedger"),
- Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportGeneralLedger"),
- strTable, strRecord, strFactAcctGroupId, data[0].dateacct, data[0].identifier);
- }
+ strTable, strRecord, strFactAcctGroupId, data[0].dateacct, data[0].identifier);
}
} else if (vars.commandIn("DIRECT")) {
scrollData = ReportGeneralLedgerJournalData.selectDirect(this, rowNum,
@@ -816,13 +820,6 @@
String strTreeOrg = TreeData.getTreeOrg(this, vars.getClient());
String strOrgFamily = getFamily(strTreeOrg, strOrg);
try {
- OBError myMessage = vars.getMessage("ReportGeneralLedgerJournal");
- vars.removeMessage("ReportGeneralLedgerJournal");
- if (myMessage != null) {
- advisePopUp(request, response, myMessage.getType(), myMessage.getTitle(),
- myMessage.getMessage());
- return;
- }
if (!strFactAcctGroupId.equals("")) {
scrollData = ReportGeneralLedgerJournalData.selectDirect2(this,
Utility.getContext(this, vars, "#User_Client", "ReportGeneralLedger"),
@@ -1075,39 +1072,50 @@
return "Servlet ReportGeneralLedgerJournal. This Servlet was made by Pablo Sarobe modified by everybody";
} // end of getServletInfo() method
- private void increaseReportUsage(VariablesSecureApp vars) {
- String preferenceValue = Utility.getPreference(vars, "ReportsUserExecutionsLimit", "");
- int userExecutionLimit = Integer.parseInt(StringUtils.isEmpty(preferenceValue) ? "1"
- : preferenceValue);
-
- preferenceValue = Utility.getPreference(vars, "ReportsExecutionsLimit", "");
- int reportExecutionLimit = Integer.parseInt(StringUtils.isEmpty(preferenceValue) ? "1"
- : preferenceValue);
-
- String userId = getAuthenticatedUserId();
- int userExecution = userExecutions.containsKey(userId) ? userExecutions.get(userId) : 0;
-
- if (userExecution >= userExecutionLimit || reportExecutions >= reportExecutionLimit) {
- OBError myMessage = new OBError();
- myMessage.setType("Error");
- myMessage.setTitle("");
- String msgbody = Utility.messageBD(this, "ReportsExecutionsLimit", vars.getLanguage());
- myMessage.setMessage(msgbody);
- vars.setMessage("ReportGeneralLedgerJournal", myMessage);
- } else {
- reportExecutions++;
- userExecution++;
-
- userExecutions.put(userId, userExecution);
- }
- }
-
- private String getAuthenticatedUserId() {
+ private String getUser() {
return (String) RequestContext.get().getSession().getAttribute("#Authenticated_user");
}
+ private OBError checkReportUsage(VariablesSecureApp vars) {
+ String userId = getUser();
+ int userExecution = userExecutions.containsKey(userId) ? userExecutions.get(userId) : 0;
+ userExecution++;
+ userExecutions.put(userId, userExecution);
+ reportExecutions++;
+
+ String userExecutionPreference = Utility.getPreference(vars, "ReportsUserExecutionsLimit", "");
+ int userExecutionLimit = Integer.parseInt(StringUtils.isEmpty(userExecutionPreference) ? "0"
+ : userExecutionPreference);
+ String reportExecutionPreference = Utility.getPreference(vars, "ReportsExecutionsLimit", "");
+ int reportExecutionLimit = Integer
+ .parseInt(StringUtils.isEmpty(reportExecutionPreference) ? "0" : reportExecutionPreference);
+
+ if (userExecutionLimit > 0 && userExecution > userExecutionLimit) {
+ OBError myMessage = new OBError();
+ myMessage.setType("Error");
+ myMessage.setTitle(Utility.messageBD(this, "Error", vars.getLanguage()));
+ String msgbody = Utility.messageBD(this, "ReportsUserExecutionsLimit", vars.getLanguage());
+ String userName = OBDal.getInstance().get(User.class, userId).getName();
+ msgbody = String.format(msgbody, userExecutionLimit, userName);
+ myMessage.setMessage(msgbody);
+ return myMessage;
+ }
+
+ else if (reportExecutionLimit > 0 && reportExecutions > reportExecutionLimit) {
+ OBError myMessage = new OBError();
+ myMessage.setType("Error");
+ myMessage.setTitle(Utility.messageBD(this, "Error", vars.getLanguage()));
+ String msgbody = Utility.messageBD(this, "ReportsExecutionsLimit", vars.getLanguage());
+ msgbody = String.format(msgbody, reportExecutionLimit);
+ myMessage.setMessage(msgbody);
+ return myMessage;
+ }
+
+ return null;
+ }
+
private void decreaseReportUsage() {
- String userId = getAuthenticatedUserId();
+ String userId = getUser();
if (userExecutions.containsKey(userId)) {
userExecutions.put(userId, userExecutions.get(userId) - 1);
if (userExecutions.get(userId) <= 0) {
@@ -1115,5 +1123,8 @@
}
}
reportExecutions--;
+ if (reportExecutions < 0) {
+ reportExecutions = 0;
+ }
}
}
|