Fixed bug 13941: Initial Client Setup, several new requirements:
authorVíctor Martínez Romanos <victor.martinez@openbravo.com>
Wed, 14 Jul 2010 10:41:52 +0200
changeset 7879 76c2e9c11f32
parent 7878 4a73659a9927
child 7880 3c4b59075d62
child 7961 ffcd5a96a0e4
Fixed bug 13941: Initial Client Setup, several new requirements:
Important datasets (core) selected by default
Reference data checkbox has the following structure:
<Reference data description> - <Module name> - <Module language>
Display a confirmation in case any important dataset is not selected
src-db/database/model/functions/AD_MODULE_CHECKED.xml
src-db/database/model/functions/AD_MODULE_IDENTIFIER.xml
src-db/database/sourcedata/AD_MESSAGE.xml
src-db/database/sourcedata/AD_MODULE.xml
src/org/openbravo/erpCommon/ad_forms/InitialClientSetup.html
src/org/openbravo/erpCommon/ad_forms/InitialClientSetup.java
src/org/openbravo/erpCommon/modules/ModuleReferenceDataClientTree_data.xsql
src/org/openbravo/erpCommon/utility/GenericTree.srpt
src/org/openbravo/erpCommon/utility/GenericTree.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-db/database/model/functions/AD_MODULE_CHECKED.xml	Wed Jul 14 10:41:52 2010 +0200
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+  <database name="FUNCTION AD_MODULE_CHECKED">
+    <function name="AD_MODULE_CHECKED" type="VARCHAR">
+      <parameter name="p_module_id" type="VARCHAR" mode="in">
+        <default/>
+      </parameter>
+      <body><![CDATA[/*************************************************************************
+* The contents of this file are subject to the Openbravo  Public  License
+* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+* Version 1.1  with a permitted attribution clause; you may not  use this
+* file except in compliance with the License. You  may  obtain  a copy of
+* the License at http://www.openbravo.com/legal/license.html
+* Software distributed under the License  is  distributed  on  an "AS IS"
+* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+* License for the specific  language  governing  rights  and  limitations
+* under the License.
+* The Original Code is Openbravo ERP.
+* The Initial Developer of the Original Code is Openbravo SLU
+* All portions are Copyright (C) 2010 Openbravo SLU
+* All Rights Reserved.
+* Contributor(s):  ______________________________________.
+************************************************************************/
+/*************************************************************************
+* Title: Returns true in case the module must be checked by default in the
+* apply dataset windows (like the Initial Client/Org setup)
+************************************************************************/
+
+BEGIN
+  IF (p_module_id = null) THEN
+    RETURN 'false';
+  ELSIF (p_module_id = '0') THEN
+    RETURN 'true';
+  ELSE
+    -- TODO implement business logic when defined
+    RETURN 'false';
+  END IF;
+  
+  EXCEPTION WHEN OTHERS THEN RETURN 'false';
+END AD_MODULE_CHECKED
+]]></body>
+    </function>
+  </database>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-db/database/model/functions/AD_MODULE_IDENTIFIER.xml	Wed Jul 14 10:41:52 2010 +0200
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+  <database name="FUNCTION AD_MODULE_IDENTIFIER">
+    <function name="AD_MODULE_IDENTIFIER" type="VARCHAR">
+      <parameter name="p_module_id" type="VARCHAR" mode="in">
+        <default/>
+      </parameter>
+      <parameter name="p_language" type="VARCHAR" mode="in">
+        <default/>
+      </parameter>
+      <body><![CDATA[/*************************************************************************
+* The contents of this file are subject to the Openbravo  Public  License
+* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+* Version 1.1  with a permitted attribution clause; you may not  use this
+* file except in compliance with the License. You  may  obtain  a copy of
+* the License at http://www.openbravo.com/legal/license.html
+* Software distributed under the License  is  distributed  on  an "AS IS"
+* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+* License for the specific  language  governing  rights  and  limitations
+* under the License.
+* The Original Code is Openbravo ERP.
+* The Initial Developer of the Original Code is Openbravo SLU
+* All portions are Copyright (C) 2010 Openbravo SLU
+* All Rights Reserved.
+* Contributor(s):  ______________________________________.
+************************************************************************/
+/*************************************************************************
+* Title: Returns the identifier to be used in the Initial Client Setup
+* The identifier is:
+* <Reference data description> - <Module name> - <Module language>
+************************************************************************/
+  v_identifier VARCHAR2(2130);
+BEGIN
+  SELECT TO_CHAR(COALESCE(TO_CHAR(T.ReferenceDataInfo) ||' - ','')) || TO_CHAR(COALESCE(TO_CHAR(T.Name),'')) ||' - '||
+       COALESCE ((SELECT TO_CHAR(COALESCE(TO_CHAR(TT.Name),'')) 
+                 FROM AD_Language TT 
+                 WHERE TT.AD_Language=T.AD_Language),'')  AS COLUMN_IDENTIFIER 
+  INTO v_identifier
+  FROM (SELECT AD_LANGUAGE 
+        FROM AD_LANGUAGE WHERE AD_LANGUAGE=p_language
+      ) L, 
+     AD_Module T 
+  WHERE AD_Module_ID=p_module_id;
+
+  RETURN v_identifier;
+END AD_MODULE_IDENTIFIER
+]]></body>
+    </function>
+  </database>
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Tue Jul 13 18:14:24 2010 +0200
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Jul 14 10:41:52 2010 +0200
@@ -31559,6 +31559,17 @@
 <!--7BF4B33E022E407BB6615E106AC7A8A6-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--7BF4B33E022E407BB6615E106AC7A8A6--></AD_MESSAGE>
 
+<!--7DB7D480F58F4D3BB81F13B6BDE62AE5--><AD_MESSAGE>
+<!--7DB7D480F58F4D3BB81F13B6BDE62AE5-->  <AD_MESSAGE_ID><![CDATA[7DB7D480F58F4D3BB81F13B6BDE62AE5]]></AD_MESSAGE_ID>
+<!--7DB7D480F58F4D3BB81F13B6BDE62AE5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--7DB7D480F58F4D3BB81F13B6BDE62AE5-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--7DB7D480F58F4D3BB81F13B6BDE62AE5-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--7DB7D480F58F4D3BB81F13B6BDE62AE5-->  <VALUE><![CDATA[JS30]]></VALUE>
+<!--7DB7D480F58F4D3BB81F13B6BDE62AE5-->  <MSGTEXT><![CDATA[You have not selected important dataset(s). After your client is created, you will need to complete its configuration by either applying a dataset to one of its organization or performing the configuration manually. Do you want to continue?]]></MSGTEXT>
+<!--7DB7D480F58F4D3BB81F13B6BDE62AE5-->  <MSGTYPE><![CDATA[C]]></MSGTYPE>
+<!--7DB7D480F58F4D3BB81F13B6BDE62AE5-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--7DB7D480F58F4D3BB81F13B6BDE62AE5--></AD_MESSAGE>
+
 <!--7FD28F8FE35B492FA9200FF14D0A7749--><AD_MESSAGE>
 <!--7FD28F8FE35B492FA9200FF14D0A7749-->  <AD_MESSAGE_ID><![CDATA[7FD28F8FE35B492FA9200FF14D0A7749]]></AD_MESSAGE_ID>
 <!--7FD28F8FE35B492FA9200FF14D0A7749-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_MODULE.xml	Tue Jul 13 18:14:24 2010 +0200
+++ b/src-db/database/sourcedata/AD_MODULE.xml	Wed Jul 14 10:41:52 2010 +0200
@@ -21,6 +21,7 @@
 <!--0-->  <HASCHARTOFACCOUNTS><![CDATA[N]]></HASCHARTOFACCOUNTS>
 <!--0-->  <ISTRANSLATIONMODULE><![CDATA[N]]></ISTRANSLATIONMODULE>
 <!--0-->  <HASREFERENCEDATA><![CDATA[Y]]></HASREFERENCEDATA>
+<!--0-->  <REFERENCEDATAINFO><![CDATA[Standard document types for orders, invoices, etc. and settings]]></REFERENCEDATAINFO>
 <!--0-->  <VERSION_LABEL><![CDATA[dev]]></VERSION_LABEL>
 <!--0-->  <ISCOMMERCIAL><![CDATA[N]]></ISCOMMERCIAL>
 <!--0--></AD_MODULE>
--- a/src/org/openbravo/erpCommon/ad_forms/InitialClientSetup.html	Tue Jul 13 18:14:24 2010 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/InitialClientSetup.html	Wed Jul 14 10:41:52 2010 +0200
@@ -63,6 +63,80 @@
 }
 
 function onloadFunctions() {
+  initialCheckModules();
+  // Override gt_checkToggleNode() function used at onclick event
+  override_gt_checkToggleNode();
+}
+
+var warningModules = new Array();
+
+function initialCheckModules() {
+  var inputs = gt_getElementsByName('inpNodes','input');
+  for (var i=0; i<inputs.length; i++) {
+    if (inputs[i].getAttribute('type') == 'checkbox') {
+      if (inputs[i].getAttribute('defaultchecked') == 'true') {
+        inputs[i].checked = true;
+      } else if (inputs[i].getAttribute('defaultchecked') == 'false') {
+        inputs[i].checked = false;
+      }
+    }
+  }
+}
+
+function runInitialClientSetup(){
+   if (checkWarningModules()) {
+     setProcessingMode('window',true);
+     submitCommandForm('OK',true);
+     return false;
+   }
+}
+
+function override_gt_checkToggleNode() {
+  window['original_gt_checkToggleNode'] = window['gt_checkToggleNode'];
+
+  window['gt_checkToggleNode']= function(element, type, isClick){
+        var allowChange = true;
+        var node = gt_returnNodeObject(element, type);
+        if (typeof node != "undefined") {
+          var nodeId = node.getAttribute('id').replace('node_','');
+          var module = document.getElementById('inpNodes_' + nodeId);
+          if (module && module.getAttribute('type') == 'checkbox') {
+            var defaultChecked = module.getAttribute('defaultchecked');
+            var newChecked = module.checked;
+            if (defaultChecked == 'true') {
+              if (!newChecked) {
+                addWarningModules(module);
+              } else {
+                removeWarningModules(module);
+              }
+            }      
+            if (allowChange) {
+              original_gt_checkToggleNode(element, type, isClick);
+            }   
+          }        
+       }  
+    }
+}
+
+function addWarningModules(module) {
+  warningModules.unshift(module);
+}
+
+function removeWarningModules(module) {
+  for (var i = 0; i < warningModules.length; i++) {
+    if (warningModules[i] == module) {
+      warningModules.splice(i, 1);
+    }
+  }
+}
+
+
+function checkWarningModules() {
+  if (warningModules.length > 0) {
+    return showJSMessage('30', defaultLang, null);
+  } else {
+    return true;
+  }
 }
 </script>
 	<script language="JavaScript" type="text/javascript">
@@ -450,7 +524,7 @@
                       <button type="button" 
                         id="buttonOK" 
                         class="ButtonLink" 
-                        onclick="setProcessingMode('window',true);submitCommandForm('OK',true);return false;" 
+                        onclick="runInitialClientSetup();" 
                         onfocus="buttonEvent('onfocus', this); window.status='Accept'; return true;" 
                         onblur="buttonEvent('onblur', this);" 
                         onkeyup="buttonEvent('onkeyup', this);" 
--- a/src/org/openbravo/erpCommon/ad_forms/InitialClientSetup.java	Tue Jul 13 18:14:24 2010 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/InitialClientSetup.java	Wed Jul 14 10:41:52 2010 +0200
@@ -93,23 +93,23 @@
     } catch (Exception ex) {
       throw new ServletException(ex);
     }
-    {
-      vars.removeMessage("InitialClientSetup");
-      OBError myMessage = vars.getMessage("InitialClientSetup");
-      if (myMessage != null) {
-        xmlDocument.setParameter("messageType", myMessage.getType());
-        xmlDocument.setParameter("messageTitle", myMessage.getTitle());
-        xmlDocument.setParameter("messageMessage", myMessage.getMessage());
-      }
-      xmlDocument.setParameter("moduleTree", tree.toHtml());
-      xmlDocument.setParameter("moduleTreeDescription", tree.descriptionToHtml());
 
-      xmlDocument.setData("reportCurrency", "liststructure", MonedaComboData.select(this));
-      response.setContentType("text/html; charset=UTF-8");
-      PrintWriter out = response.getWriter();
-      out.println(xmlDocument.print());
-      out.close();
+    vars.removeMessage("InitialClientSetup");
+    OBError myMessage = vars.getMessage("InitialClientSetup");
+    if (myMessage != null) {
+      xmlDocument.setParameter("messageType", myMessage.getType());
+      xmlDocument.setParameter("messageTitle", myMessage.getTitle());
+      xmlDocument.setParameter("messageMessage", myMessage.getMessage());
     }
+    xmlDocument.setParameter("moduleTree", tree.toHtml());
+    xmlDocument.setParameter("moduleTreeDescription", tree.descriptionToHtml());
+
+    xmlDocument.setData("reportCurrency", "liststructure", MonedaComboData.select(this));
+    response.setContentType("text/html; charset=UTF-8");
+    PrintWriter out = response.getWriter();
+    out.println(xmlDocument.print());
+    out.close();
+
   }
 
   private void printPageResult(HttpServletResponse response, VariablesSecureApp vars,
--- a/src/org/openbravo/erpCommon/modules/ModuleReferenceDataClientTree_data.xsql	Tue Jul 13 18:14:24 2010 +0200
+++ b/src/org/openbravo/erpCommon/modules/ModuleReferenceDataClientTree_data.xsql	Wed Jul 14 10:41:52 2010 +0200
@@ -12,7 +12,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) 2008 Openbravo SLU
+ * All portions are Copyright (C) 2008-2010 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -24,11 +24,12 @@
    <SqlMethod name="select" type="preparedStatement" return="multiple">
       <SqlMethodComment></SqlMethodComment>
       <Sql>
-         SELECT Type, M.AD_Module_ID as Node_ID, AD_Column_Identifier('AD_Module',M.AD_Module_ID, ?) as Name,
+         SELECT Type, M.AD_Module_ID as Node_ID, RPAD(AD_MODULE_IDENTIFIER(M.AD_Module_ID, ?), 90)  as Name,
                  (SELECT CASE WHEN COUNT(*)>0 THEN 'block' ELSE 'none' END
                     FROM AD_Module_Dependency
                    WHERE AD_Module_ID = M.AD_Module_ID
                      AND IsIncluded = 'Y')                as display,
+                     AD_MODULE_CHECKED(M.AD_Module_ID)    as defaultchecked,
                      '' as linkClick,
                      '' as linkName,
                      '' as Description,
--- a/src/org/openbravo/erpCommon/utility/GenericTree.srpt	Tue Jul 13 18:14:24 2010 +0200
+++ b/src/org/openbravo/erpCommon/utility/GenericTree.srpt	Wed Jul 14 10:41:52 2010 +0200
@@ -31,7 +31,7 @@
              </FIELD_TMP>
            </div>
            <div class="Tree_Checkbox_Spots_Closed" id="folderxx">
-            <div class="Tree_Checkbox_visible"><input id="inpNodes_xx" name="inpNodes" type="checkbox" value="xx" onclick="gt_checkToggleNode('xx', 'node', true);" onfocus="this.blur();"/></div>
+            <div class="Tree_Checkbox_visible"><input id="inpNodes_xx" name="inpNodes" type="checkbox" value="xx" defaultchecked="xx" onclick="gt_checkToggleNode('xx', 'node', true);" onfocus="this.blur();"/></div>
            </div>
            <div id="icon" class="Tree_Icon_Module">
              <div id="icon2_xx" class="Tree_Icon_Update"></div>
--- a/src/org/openbravo/erpCommon/utility/GenericTree.xml	Tue Jul 13 18:14:24 2010 +0200
+++ b/src/org/openbravo/erpCommon/utility/GenericTree.xml	Wed Jul 14 10:41:52 2010 +0200
@@ -32,6 +32,7 @@
     <FIELD id="inpNodes_xx" attribute="value">nodeId</FIELD>
     <FIELD id="inpNodes_xx" attribute="id" replace="xx">nodeId</FIELD>
     <FIELD id="inpNodes_xx" attribute="onclick" replace="xx">position</FIELD>
+    <FIELD id="inpNodes_xx" attribute="defaultchecked" replace="xx">defaultchecked</FIELD>
     <FIELD id="link_xx" attribute="onclick">linkclick</FIELD>
     <FIELD id="link_xx">linkname</FIELD>
     <FIELD id="link_xx" attribute="id" replace="xx">nodeId</FIELD>