Customize Screens with JavaScript |
Within Invantive Estate you can adjust screens dynamically for the local installation, without losing the changes when a new version is installed. When installing a new version you only need to check if the local adjustments still work properly.
This functionality can be used for:
•Placing a button that can be used for showing and printing the purchase order of a contract.
•Linking a house with a map of the area within a web application elsewhere.
•Placing a button that can be used to access the phone number of a relation in a phone directory.
•Placing a button that can be used to complete an online form of another web application, for example, to request additional budget.
To modify screens you need to insert HTML code in three places in the screens of Invantive Estate. This HTML code can be entered in the screen Settings. After modification you need to log off and log on again to activate the new settings for your web session.
The HTML code may call to JavaScript and may contain other valid HTML code, as long as the complete set of code is valid.
Notice! It is easy to harm the functioning of the web interface of Invantive Estate by adding incorrect or slow HTML code. For support purposes it may be asked to undo the adding of HTML code in the settings screen.
The recommended approach for the use of JavaScript:
•Create a file in the directory ‘local’ with local modifications. Name this file ‘xxNAME.js’, where ‘NAME’ will be replaced by the company name in small letters.
•Include the JavaScript functions ‘xxNAME_after_payload’and ‘xxNAME_before_payload’ (see below for an example).
•Include in ‘Local HTML Head’ the following (see also Customize Screens):
<styler LISTING>
<script language="JavaScript1.2" src="local/xxNAAM.js" type="text/javascript"></script> </style LISTING>
•Include in ‘Local HTML Header ’ the following (see also Customize Screens):
<styler LISTING>
<script language="JavaScript" type="text/javascript"> xxNAAM_before_payload(); </script> </style LISTING>
•Include in ‘Local HTML Footer’ the following (see also Customize Screens):
<styler LISTING>
<script language="JavaScript" type="text/javascript"> xxNAAM_after_payload(); </script> </style LISTING>
For example, the contents of xxNAAM.js could be something like this:
<style LISTING>
//
// $Header: http://svn.invantive.com/repos/p104/trunk/help/nl/manual/Topics/ontwikkeling-schermen-javascript.xml 21357 2013-01-29 16:40:21Z nno $ // // (C) Copyright 2004-2011 Invantive Software BV, the Netherlands. All rights reserved.
//
// JavaScript library with extensions for the default Invantive Estate forms.
//
//
// The before_payload is executed after the head section of the html and // within the body section, but before the contents of the webpage.
//
function xxNAAM_before_payload()
{
// Empty.
}
//
// The before_payload is executed after the head section of the html and // within the body section, but after the contents of the webpage.
//
function xxNAAM_after_payload()
{
//
// Disable contract number on purchase order form.
// The contract number is auto-generated using a calculated field.
//
// You may not disable the field. CodeCharge 3 then tries to set it to null within SQL.
// With CCS 4, this restriction has been lifted.
//
// You might use bubs_set_element_readonly as an alternative.
//
if (bubs_get_page() == "bubs_odt_all")
{
//
// Make field gray.
//
BUBS_OPDRACHTEN_V1.ODT_VOLGNUMMER.style.backgroundColor="#cccccc";
//
// Associate events leading to a change with a function that bails out with false and therefore
// makes the event non-operable.
//
BUBS_OPDRACHTEN_V1.ODT_VOLGNUMMER.onkeypress = function()
{
window.event.returnValue = false;
return false;
};
BUBS_OPDRACHTEN_V1.ODT_VOLGNUMMER.onkeydown = function()
{
window.event.returnValue = false;
return false;
};
}
//
// Show a button for a purchase order PDF when on the purchase order form.
//
// The button is only shown when a purchase order selected (as signalled through ODT_ID as a GET-parameter on the URL).
//
if (bubs_get_page() == "bubs_odt_all" && bubs_get_parameter("ODT_ID"))
{
document.write('<div id="customizations">');
bubs_show_hyperlink_button('bubs_custom21_pdf_rpt.do?P_ODT_ID=' + bubs_get_parameter("ODT_ID"), 'Opdrachtformulier (PDF)');
document.write('<p/>');
document.write('</div>');
}
//
// Create button on the projects page to an outside webpage.
//
// This is meant for the connection with the ERP system.
//
if (bubs_get_page() == "bubs_pjt_all" && bubs_get_parameter("PJT_ID"))
{
document.write('<div id="customizations">');
bubs_show_hyperlink_button
( 'http://my-erp-system/show-project-data?PJT_CODE='
+ bubs_get_parameter("PJT_CODE")
+ "&"
+ escape(BUBS_PROJECTEN_V1.PJT_JURIDISCHE_EENHEID.value)
, 'Open project in ERP'
);
document.write('<p/>');
document.write('</div>');
}
}
</style LISTING>