details: /erp/devel/pi/rev/e65622833f44
changeset: 9967:e65622833f44
user: Asier Lostalé <asier.lostale <at> openbravo.com>
date: Wed Jan 19 10:48:44 2011 +0100
summary: [print] Show print toolbar button in tabs where print is defined
details: /erp/devel/pi/rev/be0c44bcb34d
changeset: 9968:be0c44bcb34d
user: Asier Lostalé <asier.lostale <at> openbravo.com>
date: Wed Jan 19 15:52:58 2011 +0100
summary: [print] Added standard columns to tab
details: /erp/devel/pi/rev/fdcc95ea9e66
changeset: 9969:fdcc95ea9e66
user: Asier Lostalé <asier.lostale <at> openbravo.com>
date: Thu Jan 20 08:17:05 2011 +0100
summary: [print] Sample print implemntation for printing invoices
details: /erp/devel/pi/rev/109de0c65230
changeset: 9970:109de0c65230
user: Asier Lostalé <asier.lostale <at> openbravo.com>
date: Thu Jan 20 08:17:50 2011 +0100
summary: [print] Properly show print popup
diffstat:
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl
| 17 ++
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
| 85 +++++++++-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
| 35 +++-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
| 45 +++++
src/org/openbravo/erpCommon/businessUtility/PrinterReports.html
| 16 +-
src/org/openbravo/erpCommon/utility/reporting/printing/PrintOptions.html
| 11 +-
6 files changed, 197 insertions(+), 12 deletions(-)
diffs (truncated from 353 to 300 lines):
diff -r bf4b4623fef7 -r 109de0c65230
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl
Thu Jan 20 09:19:30 2011 +0100
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl
Thu Jan 20 08:17:50 2011 +0100
@@ -33,6 +33,14 @@
defaultEditMode: ${tabComponent.defaultEditMode},
+ standardProperties:{
+ inpTabId: '${tabComponent.tabId}',
+ inpwindowId: '${tabComponent.windowId}',
+ inpTableId: '${tabComponent.tableId?js_string}',
+ inpkeyColumnId: '${tabComponent.keyColumnId?js_string}',
+ inpKeyName: '${tabComponent.keyName?js_string}'
+ },
+
propertyToColumns:[
<#list tabComponent.allFields as field>
{
@@ -59,6 +67,15 @@
}<#if field_has_next>,</#if>
</#list>],
+ iconToolbarButtons: [
+ <#list tabComponent.iconButtons as button>
+ {
+ action: function(){ ${button.action} },
+ buttonType: '${button.type?js_string}',
+ prompt: '${button.label?js_string}'
+ }<#if button_has_next>,</#if>
+ </#list>],
+
<#if tabComponent.childTabs?size > 0>
hasChildTabs: true,
</#if>
diff -r bf4b4623fef7 -r 109de0c65230
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
Thu Jan 20 09:19:30 2011 +0100
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
Thu Jan 20 08:17:50 2011 +0100
@@ -59,6 +59,8 @@
private OBViewTab parentTabComponent;
private String parentProperty = null;
private List<ButtonField> buttonFields = null;
+ private List<IconButton> iconButtons = null;
+ private Field keyField;
protected Template getComponentTemplate() {
return OBDal.getInstance().get(Template.class, TEMPLATE_ID);
@@ -91,6 +93,20 @@
return buttonFields;
}
+ public List<IconButton> getIconButtons() {
+ if (iconButtons != null) {
+ return iconButtons;
+ }
+
+ iconButtons = new ArrayList<IconButton>();
+
+ // Print button
+ if (tab.getProcess() != null) {
+ iconButtons.add(new PrintButton());
+ }
+ return iconButtons;
+ }
+
public String getParentProperty() {
if (parentTabComponent == null) {
return "";
@@ -199,7 +215,6 @@
public List<FieldProperty> getAllFields() {
List<FieldProperty> fields = new ArrayList<FieldProperty>();
- Field keyField = null;
for (Field field : tab.getADFieldList()) {
if (field.getColumn().isKeyColumn()) {
keyField = field;
@@ -217,15 +232,56 @@
fields.add(fp);
}
+ // Standard hidden fields shown in all 2.50 windows
+ FieldProperty fp = new FieldProperty(keyField);
+ fp.columnName = keyField.getColumn().getDBColumnName();
+ fields.add(fp);
+
return fields;
}
+ private Field getKeyField() {
+ if (keyField != null) {
+ return keyField;
+ }
+
+ for (Field field : tab.getADFieldList()) {
+ if (field.getColumn().isKeyColumn()) {
+ keyField = field;
+ }
+ }
+ return keyField;
+ }
+
+ public String getTableId() {
+ return tab.getTable().getId();
+ }
+
+ public String getKeyColumnId() {
+ return getKeyField().getColumn().getDBColumnName();
+ }
+
+ public String getKeyName() {
+ return "inp" +
Sqlc.TransformaNombreColumna(getKeyField().getColumn().getDBColumnName());
+ }
+
+ public String getWindowId() {
+ return tab.getWindow().getId();
+ }
+
public class FieldProperty {
private String columnName;
private String dbColumnName;
private String propertyName;
private boolean session;
+ public FieldProperty() {
+ session = false;
+ propertyName = "";
+ columnName = "";
+ dbColumnName = "";
+ }
+
public FieldProperty(Field field) {
Column col = field.getColumn();
columnName = "inp" + Sqlc.TransformaNombreColumna(col.getDBColumnName());
@@ -377,4 +433,31 @@
}
}
}
+
+ public class IconButton {
+ protected String action;
+ protected String type;
+ protected String label;
+
+ public String getAction() {
+ return action;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+ }
+
+ public class PrintButton extends IconButton {
+ public PrintButton() {
+ type = "print";
+ action = "OB.ToolbarUtils.print(this.view);";
+ label = "testing...";
+ }
+
+ }
}
diff -r bf4b4623fef7 -r 109de0c65230
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
Thu Jan 20 09:19:30 2011 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
Thu Jan 20 08:17:50 2011 +0100
@@ -179,21 +179,36 @@
OB.TestRegistry.register('org.openbravo.client.application.ViewForm_' +
this.tabId, this.viewForm);
var rightMemberButtons = [];
+ var leftMemberButtons = [];
+ var i;
if (this.actionToolbarButtons) {
- for (var i = 0; i < this.actionToolbarButtons.length; i++) {
+ for (i = 0; i < this.actionToolbarButtons.length; i++) {
rightMemberButtons.push(isc.OBToolbarActionButton.create(this.actionToolbarButtons[i]));
}
}
+ // These are the icon toolbar buttons shown in all the tabs
+ leftMemberButtons =
[isc.OBToolbarIconButton.create(isc.OBToolbar.NEW_BUTTON_PROPERTIES),
+
isc.OBToolbarIconButton.create(isc.OBToolbar.SAVE_BUTTON_PROPERTIES),
+
isc.OBToolbarIconButton.create(isc.OBToolbar.UNDO_BUTTON_PROPERTIES),
+
isc.OBToolbarIconButton.create(isc.OBToolbar.DELETE_BUTTON_PROPERTIES),
+
isc.OBToolbarIconButton.create(isc.OBToolbar.REFRESH_BUTTON_PROPERTIES)];
+
+ // Look for specific toolabr buttons for this tab
+ if (this.iconToolbarButtons) {
+ for (i = 0; i < this.iconToolbarButtons.length; i++) {
+
leftMemberButtons.push(isc.OBToolbarIconButton.create(this.iconToolbarButtons[i]));
+ }
+ }
+
this.toolBar = isc.OBToolbar.create({
view: this,
visibility: 'hidden',
- leftMembers:
[isc.OBToolbarIconButton.create(isc.OBToolbar.NEW_BUTTON_PROPERTIES),
isc.OBToolbarIconButton.create(isc.OBToolbar.SAVE_BUTTON_PROPERTIES),
isc.OBToolbarIconButton.create(isc.OBToolbar.UNDO_BUTTON_PROPERTIES),
isc.OBToolbarIconButton.create(isc.OBToolbar.DELETE_BUTTON_PROPERTIES),
isc.OBToolbarIconButton.create(isc.OBToolbar.REFRESH_BUTTON_PROPERTIES)],
+ leftMembers: leftMemberButtons,
rightMembers: rightMemberButtons
});
-
var ret = this.Super('initWidget', arguments);
this.setToolBarButtonState();
@@ -1378,6 +1393,20 @@
}
}
}
+
+ if (!onlySessionProperties){
+ for (var p in this.standardProperties){
+ if (this.standardProperties.hasOwnProperty(p)){
+ if (classicMode) {
+ contextInfo[p] = this.standardProperties[p];
+ } else {
+ // surround the property name with @ symbols to make them
different
+ // from filter criteria and such
+ contextInfo['@' + this.entity + '.' + p + '@'] =
this.standardProperties[p];
+ }
+ }
+ }
+ }
}
if (this.isShowingForm) {
isc.addProperties(contextInfo, this.viewForm.auxInputs);
diff -r bf4b4623fef7 -r 109de0c65230
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
Thu Jan 20 09:19:30 2011 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
Thu Jan 20 08:17:50 2011 +0100
@@ -642,3 +642,48 @@
alert(this.title);
}
});
+
+OB.ToolbarUtils = {};
+
+OB.ToolbarUtils.print = function(view){
+ var popupParams = {
+ viewId : 'print',
+ obManualURL : '/businessUtility/PrinterReports.html',
+ processId : '1',
+ id : '1',
+ tabTitle : 'a',
+ command: 'DEFAULT'
+ };
+
+ var allProperties = view.getContextInfo(false, true);
+ var sessionProperties = view.getContextInfo(true, true);
+
+ for ( var param in allProperties) {
+ if (allProperties.hasOwnProperty(param)) {
+ var value = allProperties[param];
+
+ if (typeof value === 'boolean') {
+ value = value?'Y':'N';
+ }
+
+ popupParams.command += '&' + param + '=' + value;
+ }
+ }
+
+ popupParams.command += '&inppdfpath=../invoices/print.html';
+ popupParams.command += '&inphiddenkey=inpcInvoiceId';
+
+ var selectedIds = '';
+ for (var i=0; i<view.viewGrid.getSelectedRecords().length; i++){
+ selectedIds += (i>0?',':'')+view.viewGrid.getSelectedRecords()[i].id;
+ }
+
+ popupParams.command += '&inphiddenvalue='+selectedIds;
+
+ view.setContextInfo(sessionProperties, function() {
+ // OB.Layout.ViewManager.openView('OBPopupClassicWindow', popupParams);
+
+ OB.Layout.ClassicOBCompatibility.Popup.open('print', 0, 0,
OB.Application.contextUrl +
'/businessUtility/PrinterReports.html?Command='+popupParams.command, '',
window, false, false, true);
+ });
+
+};
\ No newline at end of file
diff -r bf4b4623fef7 -r 109de0c65230
src/org/openbravo/erpCommon/businessUtility/PrinterReports.html
--- a/src/org/openbravo/erpCommon/businessUtility/PrinterReports.html Thu Jan
20 09:19:30 2011 +0100
+++ b/src/org/openbravo/erpCommon/businessUtility/PrinterReports.html Thu Jan
20 08:17:50 2011 +0100
@@ -11,7 +11,7 @@
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2001-2010 Openbravo SLU
+ * All portions are Copyright (C) 2001-2011 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -21,14 +21,19 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Report print</title>
<link rel="shortcut icon" href="../../../../../web/images/favicon.ico"
type="image/x-icon" />
-<script language="JavaScript" type="text/javascript" id="paramDirectory">
var baseDirectory = "localhost";</script>
+<script language="JavaScript" type="text/javascript" id="paramDirectory">
var baseDirectory = "localhost";</script>
<script language="JavaScript" src="../../../../../web/js/utils.js"
type="text/javascript"></script>
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits