src-wad/src/org/openbravo/wad/javasource.javaxml
author Ben Sommerville <ben.sommerville@eintel.com.au>
Tue, 27 Oct 2009 14:04:27 +1100
changeset 5328 d9f98e1761bf
parent 5308 ad129c7d1b62
child 5467 17d53b0dd1f9
child 5839 0f0482ab8635
permissions -rw-r--r--
Fixes bug 0010919: allow creation of child tab when parent has sql based auxiliar inputs defined
carlos@0
     1
<?xml version="1.0" encoding="UTF-8" ?>
carlos@0
     2
<!--
carlos@0
     3
 *************************************************************************
carlos@0
     4
 * The contents of this file are subject to the Openbravo  Public  License
carlos@0
     5
 * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
carlos@0
     6
 * Version 1.1  with a permitted attribution clause; you may not  use this
carlos@0
     7
 * file except in compliance with the License. You  may  obtain  a copy of
carlos@0
     8
 * the License at http://www.openbravo.com/legal/license.html 
carlos@0
     9
 * Software distributed under the License  is  distributed  on  an "AS IS"
carlos@0
    10
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
carlos@0
    11
 * License for the specific  language  governing  rights  and  limitations
carlos@0
    12
 * under the License. 
carlos@0
    13
 * The Original Code is Openbravo ERP. 
carlos@0
    14
 * The Initial Developer of the Original Code is Openbravo SL 
asier@2769
    15
 * All portions are Copyright (C) 2001-2009 Openbravo SL 
carlos@0
    16
 * All Rights Reserved. 
carlos@0
    17
 * Contributor(s):  ______________________________________.
carlos@0
    18
 ************************************************************************
carlos@0
    19
-->
carlos@0
    20
carlos@0
    21
carlos@0
    22
<java_TMP>
carlos@0
    23
package org.openbravo.erpWindows.<PARAMETER_TMP id="package">Window</PARAMETER_TMP>;
carlos@0
    24
carlos@0
    25
<PARAMETER_TMP id="hasAdPInstance">
carlos@0
    26
import org.openbravo.erpCommon.reference.*;
carlos@0
    27
</PARAMETER_TMP>
carlos@0
    28
<PARAMETER_TMP id="hasAdActionButton">
carlos@0
    29
import org.openbravo.erpCommon.ad_actionButton.*;
carlos@0
    30
</PARAMETER_TMP>
anthony@1867
    31
anthony@1867
    32
carlos@0
    33
import org.openbravo.erpCommon.utility.*;
carlos@0
    34
import org.openbravo.data.FieldProvider;
carlos@0
    35
import org.openbravo.utils.FormatUtilities;
asier@5303
    36
import org.openbravo.utils.Replace;
carlos@0
    37
import org.openbravo.base.secureApp.HttpSecureAppServlet;
carlos@0
    38
import org.openbravo.base.secureApp.VariablesSecureApp;
ivan@2072
    39
import org.openbravo.base.exception.OBException;
anthony@1867
    40
import org.openbravo.scheduling.ProcessBundle;
anthony@1867
    41
import org.openbravo.scheduling.ProcessRunner;
carlos@0
    42
import org.openbravo.erpCommon.businessUtility.WindowTabs;
carlos@0
    43
import org.openbravo.xmlEngine.XmlDocument;
carlos@0
    44
import java.util.Vector;
carlos@0
    45
import java.util.StringTokenizer;
carlos@0
    46
import java.io.*;
carlos@0
    47
import javax.servlet.*;
carlos@0
    48
import javax.servlet.http.*;
asier@528
    49
import java.util.*;
asier@2171
    50
import java.sql.Connection;
asier@1929
    51
import org.apache.log4j.Logger;
carlos@0
    52
carlos@0
    53
public class <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP> extends HttpSecureAppServlet {
carlos@0
    54
  private static final long serialVersionUID = 1L;
asier@1929
    55
  
stefan@3960
    56
  private static Logger log4j = Logger.getLogger(<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>.class);
asier@1929
    57
  
stefan@3960
    58
  private static final String windowId = "<PARAMETER_TMP id="windowId">Almacen</PARAMETER_TMP>";
stefan@3960
    59
  private static final String tabId = "<PARAMETER_TMP id="tabId">Almacen</PARAMETER_TMP>";
stefan@3960
    60
  private static final String defaultTabView = "<PARAMETER_TMP id="defaultView">RELATION</PARAMETER_TMP>";
stefan@3960
    61
  private static final int accesslevel = <PARAMETER_TMP id="accessLevel">xx</PARAMETER_TMP>;
stefan@3960
    62
  private static final double SUBTABS_COL_SIZE = 15;
carlos@0
    63
carlos@0
    64
  public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
asier@2769
    65
    TableSQLData tableSQL = null;
carlos@0
    66
    VariablesSecureApp vars = new VariablesSecureApp(request);
ivan@2072
    67
    Boolean saveRequest = (Boolean) request.getAttribute("autosave");
ivan@2072
    68
    
ivan@2072
    69
    if(saveRequest != null &amp;&amp; saveRequest){
asier@3199
    70
      String currentOrg = vars.getStringParameter("inpadOrgId");
asier@3199
    71
      String currentClient = vars.getStringParameter("inpadClientId");
asier@3199
    72
      boolean editableTab = (!org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)
asier@3199
    73
                            &amp;&amp; (currentOrg.equals("") || Utility.isElementInList(Utility.getContext(this, vars,"#User_Org", windowId, accesslevel), currentOrg)) 
asier@3199
    74
                            &amp;&amp; (currentClient.equals("") || Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel),currentClient)));
asier@3199
    75
    
ivan@2072
    76
        OBError myError = new OBError();
ivan@2072
    77
        String commandType = request.getParameter("inpCommandType");
ivan@2072
    78
        String str<KEY_TMP id="keyData">Almacen</KEY_TMP> = request.getParameter("inp<KEY_TMP id="keyData">Almacen</KEY_TMP>");
ivan@2072
    79
        <PARAMETER_TMP id="parent"> String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");</PARAMETER_TMP>
asier@3199
    80
        if (editableTab) {
asier@3199
    81
          int total = 0;
asier@3199
    82
          
asier@3199
    83
          if(commandType.equalsIgnoreCase("EDIT") &amp;&amp; !str<KEY_TMP id="keyData">Almacen</KEY_TMP>.equals(""))
asier@3199
    84
              total = saveRecord(vars, myError, 'U'<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);
asier@3199
    85
          else
asier@3199
    86
              total = saveRecord(vars, myError, 'I'<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);
asier@3199
    87
          
asier@3199
    88
          if (!myError.isEmpty() &amp;&amp; total == 0)     
asier@3199
    89
            throw new OBException(myError.getMessage());
asier@3199
    90
        }
ivan@2072
    91
        vars.setSessionValue(request.getParameter("mappingName") +"|hash", vars.getPostDataHash());
ivan@3796
    92
        vars.setSessionValue(tabId + "|Header.view", "EDIT");
ivan@2072
    93
        
ivan@2072
    94
        return;
ivan@2072
    95
    }
ivan@2072
    96
    
carlos@0
    97
    try {
asier@683
    98
      tableSQL = new TableSQLData(vars, this, tabId, Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel), Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "ShowAudit", windowId).equals("Y"));
carlos@0
    99
    } catch (Exception ex) {
carlos@0
   100
      ex.printStackTrace();
carlos@0
   101
    }
carlos@0
   102
carlos@0
   103
    String strOrderBy = vars.getSessionValue(tabId + "|orderby");
carlos@0
   104
    if (!strOrderBy.equals("")) {
carlos@0
   105
      vars.setSessionValue(tabId + "|newOrder", "1");
carlos@0
   106
    }
carlos@0
   107
carlos@0
   108
    if (vars.commandIn("DEFAULT")) {
carlos@0
   109
<PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>", "");
carlos@0
   110
</PARAMETER_TMP>
carlos@0
   111
      String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getGlobalVariable("inp<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>", windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", "");
carlos@0
   112
      <PARAMETER_TMP id="parent">      if (strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>.equals("")) {
carlos@0
   113
        strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = getParentID(vars, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>);
carlos@0
   114
        if (strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>.equals("")) throw new ServletException("Required parameter :" + windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");
carlos@0
   115
        vars.setSessionValue(windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>", strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>);
carlos@0
   116
<PARAMETER_TMP id="grandfather">      vars.removeSessionValue(windowId + "|<PARAMETER_TMP id="grandfatherName">xx</PARAMETER_TMP>");</PARAMETER_TMP>
carlos@0
   117
        refreshParentSession(vars, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>);
carlos@0
   118
      }
carlos@0
   119
</PARAMETER_TMP>
carlos@0
   120
carlos@0
   121
      String strView = vars.getSessionValue(tabId + "|<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>.view");
carlos@0
   122
      if (strView.equals("")) {
carlos@0
   123
        strView = defaultTabView;
carlos@0
   124
<PARAMETERS_TMP id="NothasReference">
carlos@0
   125
        if (strView.equals("EDIT")) {
asier@2769
   126
<PARAMETERS_TMP id="sectionNotIsHighVolume">          if (str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>.equals("")) str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = firstElement(vars, tableSQL);
carlos@0
   127
          if (str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>.equals("")) strView = "RELATION";</PARAMETERS_TMP>
carlos@0
   128
        }</PARAMETERS_TMP>
carlos@0
   129
      }
carlos@0
   130
      if (strView.equals("EDIT")) 
carlos@0
   131
<PARAMETERS_TMP id="NothasReference">
asier@2769
   132
        printPageEdit(response, request, vars, false, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP><PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, tableSQL);
carlos@0
   133
</PARAMETERS_TMP><PARAMETERS_TMP id="hasReference">
carlos@0
   134
        response.sendRedirect(strDireccion + "<PARAMETER_TMP id="paramEditReference">xx</PARAMETER_TMP>");
carlos@0
   135
</PARAMETERS_TMP>
asier@2769
   136
      else printPageDataSheet(response, vars<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>, tableSQL);
carlos@0
   137
    } else if (vars.commandIn("DIRECT")) {
carlos@0
   138
      String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getStringParameter("inpDirectKey");
asier@432
   139
      
asier@432
   140
      <PARAMETER_TMP id="withSecondaryKey">  
asier@432
   141
      //Double pk, inpDirectKey is useless
asier@432
   142
      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>", "");
asier@432
   143
      </PARAMETER_TMP>  
carlos@0
   144
      if (str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>.equals("")) str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getRequiredGlobalVariable("inp<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>", windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>");
carlos@0
   145
      else vars.setSessionValue(windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>);
asier@432
   146
      <PARAMETER_TMP id="parent">
asier@432
   147
      <PARAMETER_TMP id="keySequence">
asier@432
   148
      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = getParentID(vars, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>);
asier@432
   149
      </PARAMETER_TMP>
carlos@0
   150
      vars.setSessionValue(windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>", strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>);
asier@431
   151
      vars.setSessionValue("<PARENT_TMP id="parentTab">xxtabId</PARENT_TMP>|<PARAMETER_TMP id="parentTabName">xxparentTabName</PARAMETER_TMP>.view", "EDIT");
carlos@0
   152
<PARAMETER_TMP id="grandfather">      vars.removeSessionValue(windowId + "|<PARAMETER_TMP id="grandfatherName">xx</PARAMETER_TMP>");</PARAMETER_TMP>
carlos@0
   153
      refreshParentSession(vars, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>);
carlos@0
   154
</PARAMETER_TMP>
carlos@0
   155
      vars.setSessionValue(tabId + "|<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>.view", "EDIT");
carlos@0
   156
<PARAMETERS_TMP id="NothasReference">
asier@2769
   157
      printPageEdit(response, request, vars, false, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP><PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, tableSQL);
carlos@0
   158
</PARAMETERS_TMP><PARAMETERS_TMP id="hasReference">
carlos@0
   159
        response.sendRedirect(strDireccion + "<PARAMETER_TMP id="paramEditReference">xx</PARAMETER_TMP>");
carlos@0
   160
</PARAMETERS_TMP>
carlos@0
   161
    } else if (vars.commandIn("TAB")) {
asier@4881
   162
<PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParentSimple">Almacen</PARENT_TMP>", false, false, true, "");
carlos@0
   163
      vars.removeSessionValue(windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>");
asier@1186
   164
      <PARAMETER_TMP id="refreshTabParentSession">refreshParentSession(vars, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>);</PARAMETER_TMP>
carlos@0
   165
</PARAMETER_TMP>
carlos@0
   166
carlos@0
   167
      String strView = vars.getSessionValue(tabId + "|<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>.view");
carlos@0
   168
      String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = "";
carlos@0
   169
      if (strView.equals("")) {
carlos@0
   170
        strView = defaultTabView;
carlos@0
   171
        if (strView.equals("EDIT")) {
asier@2769
   172
<PARAMETERS_TMP id="sectionNotIsHighVolume">          str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = firstElement(vars, tableSQL);
carlos@0
   173
          if (str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>.equals("")) strView = "RELATION";</PARAMETERS_TMP>
carlos@0
   174
        }
carlos@0
   175
      }
carlos@0
   176
      if (strView.equals("EDIT")) {
carlos@0
   177
<PARAMETERS_TMP id="NothasReference">
asier@2769
   178
        if (str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>.equals("")) str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = firstElement(vars, tableSQL);
asier@2769
   179
        printPageEdit(response, request, vars, false, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP><PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, tableSQL);
carlos@0
   180
</PARAMETERS_TMP><PARAMETERS_TMP id="hasReference">
carlos@0
   181
        response.sendRedirect(strDireccion + "<PARAMETER_TMP id="paramEditReference">xx</PARAMETER_TMP>");
carlos@0
   182
</PARAMETERS_TMP>
asier@2769
   183
      } else printPageDataSheet(response, vars<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, "", tableSQL);
carlos@0
   184
<FIELDS_TMP id="sectionIsHighVolume4">    } else if (vars.commandIn("SEARCH")) {
carlos@0
   185
<PARAMETER_TMP id="sectionIsHighVolume5">vars.getRequestGlobalVariable("inpParam<FIELD_TMP id="searchName5">xx</FIELD_TMP>", tabId + "|param<FIELD_TMP id="searchName5">xx</FIELD_TMP>");
carlos@0
   186
</PARAMETER_TMP>
carlos@0
   187
      <PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");
carlos@0
   188
</PARAMETER_TMP>
carlos@0
   189
      
carlos@0
   190
      vars.removeSessionValue(windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>");
carlos@0
   191
      String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>="";
carlos@0
   192
carlos@0
   193
      String strView = vars.getSessionValue(tabId + "|<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>.view");
carlos@0
   194
      if (strView.equals("")) strView=defaultTabView;
carlos@0
   195
<PARAMETERS_TMP id="NothasReference">
carlos@0
   196
      if (strView.equals("EDIT")) {
asier@2769
   197
        str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = firstElement(vars, tableSQL);
stefan@2465
   198
        if (str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>.equals("")) {
stefan@2465
   199
          // filter returns empty set
stefan@2465
   200
          strView = "RELATION";
stefan@2465
   201
          // switch to grid permanently until the user changes the view again
stefan@2465
   202
          vars.setSessionValue(tabId + "|<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>.view", strView);
stefan@2465
   203
        }
carlos@0
   204
      }
carlos@0
   205
</PARAMETERS_TMP>
carlos@0
   206
      if (strView.equals("EDIT")) 
carlos@0
   207
<PARAMETERS_TMP id="NothasReference">
asier@2769
   208
        printPageEdit(response, request, vars, false, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP><PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, tableSQL);
carlos@0
   209
</PARAMETERS_TMP><PARAMETERS_TMP id="hasReference">
carlos@0
   210
        response.sendRedirect(strDireccion + "<PARAMETER_TMP id="paramEditReference">xx</PARAMETER_TMP>");
carlos@0
   211
</PARAMETERS_TMP>
asier@2769
   212
      else printPageDataSheet(response, vars<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>, tableSQL);</FIELDS_TMP>
carlos@0
   213
    } else if (vars.commandIn("RELATION")) {
carlos@0
   214
      <PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");
carlos@0
   215
      </PARAMETER_TMP>
carlos@0
   216
carlos@0
   217
      String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getGlobalVariable("inp<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>", windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", "");
carlos@0
   218
      vars.setSessionValue(tabId + "|<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>.view", "RELATION");
asier@2769
   219
      printPageDataSheet(response, vars<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>, tableSQL);
carlos@0
   220
    } else if (vars.commandIn("NEW")) {
carlos@0
   221
<PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");
carlos@0
   222
</PARAMETER_TMP>
carlos@0
   223
<PARAMETERS_TMP id="NothasReference">
asier@2769
   224
      printPageEdit(response, request, vars, true, ""<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, tableSQL);
carlos@0
   225
</PARAMETERS_TMP><PARAMETERS_TMP id="hasReference">
carlos@0
   226
      response.sendRedirect(strDireccion + "<PARAMETER_TMP id="paramEditReference">xx</PARAMETER_TMP>?Command=NEW");
carlos@0
   227
</PARAMETERS_TMP>
carlos@0
   228
    } else if (vars.commandIn("EDIT")) {
carlos@0
   229
<PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");
carlos@0
   230
</PARAMETER_TMP>
carlos@0
   231
      @SuppressWarnings("unused") // In Expense Invoice tab this variable is not used, to be fixed
carlos@0
   232
      String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getGlobalVariable("inp<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>", windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", "");
carlos@0
   233
      vars.setSessionValue(tabId + "|<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>.view", "EDIT");
carlos@0
   234
<PARAMETERS_TMP id="NothasReference">
carlos@0
   235
      setHistoryCommand(request, "EDIT");
asier@2769
   236
      printPageEdit(response, request, vars, false, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP><PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, tableSQL);
carlos@0
   237
</PARAMETERS_TMP><PARAMETERS_TMP id="hasReference">
carlos@0
   238
      response.sendRedirect(strDireccion + "<PARAMETER_TMP id="paramEditReference">xx</PARAMETER_TMP>?Command=EDIT");
carlos@0
   239
</PARAMETERS_TMP>
carlos@0
   240
    } else if (vars.commandIn("NEXT")) {
carlos@0
   241
<PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");</PARAMETER_TMP>
carlos@0
   242
      String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getRequiredStringParameter("inp<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>");
carlos@0
   243
      
asier@2769
   244
      String strNext = nextElement(vars, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>, tableSQL);
carlos@0
   245
asier@2769
   246
      printPageEdit(response, request, vars, false, strNext<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, tableSQL);
carlos@0
   247
    } else if (vars.commandIn("PREVIOUS")) {
carlos@0
   248
<PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");</PARAMETER_TMP>
carlos@0
   249
      String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getRequiredStringParameter("inp<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>");
carlos@0
   250
      
asier@2769
   251
      String strPrevious = previousElement(vars, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>, tableSQL);
carlos@0
   252
asier@2769
   253
      printPageEdit(response, request, vars, false, strPrevious<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, tableSQL);
carlos@0
   254
    } else if (vars.commandIn("FIRST_RELATION")) {
carlos@0
   255
<PARAMETER_TMP id="parent">vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");
carlos@0
   256
</PARAMETER_TMP>
carlos@0
   257
      vars.setSessionValue(tabId + "|<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>.initRecordNumber", "0");
carlos@0
   258
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
carlos@0
   259
    } else if (vars.commandIn("PREVIOUS_RELATION")) {
carlos@0
   260
<PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");
carlos@0
   261
</PARAMETER_TMP>
carlos@0
   262
      String strInitRecord = vars.getSessionValue(tabId + "|<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>.initRecordNumber");
carlos@0
   263
      String strRecordRange = Utility.getContext(this, vars, "#RecordRange", windowId);
carlos@0
   264
      int intRecordRange = strRecordRange.equals("")?0:Integer.parseInt(strRecordRange);
carlos@0
   265
      if (strInitRecord.equals("") || strInitRecord.equals("0")) {
carlos@0
   266
        vars.setSessionValue(tabId + "|<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>.initRecordNumber", "0");
carlos@0
   267
      } else {
carlos@0
   268
        int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
carlos@0
   269
        initRecord -= intRecordRange;
carlos@0
   270
        strInitRecord = ((initRecord&#60;0)?"0":Integer.toString(initRecord));
carlos@0
   271
        vars.setSessionValue(tabId + "|<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>.initRecordNumber", strInitRecord);
carlos@0
   272
      }
carlos@0
   273
      vars.removeSessionValue(windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>");
carlos@0
   274
<PARAMETER_TMP id="parent">      vars.setSessionValue(windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>", strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>);</PARAMETER_TMP>
carlos@0
   275
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
carlos@0
   276
    } else if (vars.commandIn("NEXT_RELATION")) {
carlos@0
   277
<PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");
carlos@0
   278
</PARAMETER_TMP>
carlos@0
   279
      String strInitRecord = vars.getSessionValue(tabId + "|<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>.initRecordNumber");
carlos@0
   280
      String strRecordRange = Utility.getContext(this, vars, "#RecordRange", windowId);
carlos@0
   281
      int intRecordRange = strRecordRange.equals("")?0:Integer.parseInt(strRecordRange);
carlos@0
   282
      int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord));
carlos@0
   283
      if (initRecord==0) initRecord=1;
carlos@0
   284
      initRecord += intRecordRange;
carlos@0
   285
      strInitRecord = ((initRecord&#60;0)?"0":Integer.toString(initRecord));
carlos@0
   286
      vars.setSessionValue(tabId + "|<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>.initRecordNumber", strInitRecord);
carlos@0
   287
      vars.removeSessionValue(windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>");
carlos@0
   288
<PARAMETER_TMP id="parent">      vars.setSessionValue(windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>", strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>);</PARAMETER_TMP>
carlos@0
   289
      response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
carlos@0
   290
    } else if (vars.commandIn("FIRST")) {
carlos@0
   291
<PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");</PARAMETER_TMP>
carlos@0
   292
      
asier@2769
   293
      String strFirst = firstElement(vars, tableSQL);
carlos@0
   294
asier@2769
   295
      printPageEdit(response, request, vars, false, strFirst<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, tableSQL);
carlos@0
   296
    } else if (vars.commandIn("LAST_RELATION")) {
carlos@0
   297
<PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");
carlos@0
   298
</PARAMETER_TMP>
asier@2769
   299
      String strLast = lastElement(vars, tableSQL);
asier@2769
   300
      printPageDataSheet(response, vars<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, strLast, tableSQL);
carlos@0
   301
    } else if (vars.commandIn("LAST")) {
carlos@0
   302
<PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");</PARAMETER_TMP>
carlos@0
   303
      
asier@2769
   304
      String strLast = lastElement(vars, tableSQL);
carlos@0
   305
asier@2769
   306
      printPageEdit(response, request, vars, false, strLast<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, tableSQL);
carlos@0
   307
    } else if (vars.commandIn("SAVE_NEW_RELATION", "SAVE_NEW_NEW", "SAVE_NEW_EDIT")) {
carlos@0
   308
<PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");</PARAMETER_TMP>
ivan@2072
   309
      OBError myError = new OBError();      
ivan@2072
   310
      int total = saveRecord(vars, myError, 'I'<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);      
ivan@2072
   311
      if (!myError.isEmpty()) {        
carlos@0
   312
        response.sendRedirect(strDireccion + request.getServletPath() + "?Command=NEW");
ivan@2072
   313
      } 
ivan@2072
   314
      else {
ivan@2072
   315
		if (myError.isEmpty()) {
ivan@2072
   316
		  myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsInserted");
ivan@2072
   317
		  myError.setMessage(total + " " + myError.getMessage());
ivan@2072
   318
		  vars.setMessage(tabId, myError);
ivan@2072
   319
		}        
carlos@0
   320
        if (vars.commandIn("SAVE_NEW_NEW")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=NEW");
carlos@0
   321
        else if (vars.commandIn("SAVE_NEW_EDIT")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
carlos@0
   322
        else response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
carlos@0
   323
      }
carlos@0
   324
    } else if (vars.commandIn("SAVE_EDIT_RELATION", "SAVE_EDIT_NEW", "SAVE_EDIT_EDIT", "SAVE_EDIT_NEXT")) {
carlos@0
   325
<PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");</PARAMETER_TMP>
carlos@0
   326
      String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getRequiredGlobalVariable("inp<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>", windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>");
ivan@2072
   327
      OBError myError = new OBError();
ivan@2072
   328
      int total = saveRecord(vars, myError, 'U'<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);      
ivan@2072
   329
      if (!myError.isEmpty()) {
carlos@0
   330
        response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
ivan@2072
   331
      } 
ivan@2072
   332
      else {
ivan@2072
   333
        if (myError.isEmpty()) {
carlos@0
   334
          myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsUpdated");
carlos@0
   335
          myError.setMessage(total + " " + myError.getMessage());
carlos@0
   336
          vars.setMessage(tabId, myError);
carlos@0
   337
        }
carlos@0
   338
        if (vars.commandIn("SAVE_EDIT_NEW")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=NEW");
carlos@0
   339
        else if (vars.commandIn("SAVE_EDIT_EDIT")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
carlos@0
   340
        else if (vars.commandIn("SAVE_EDIT_NEXT")) {
asier@2769
   341
          String strNext = nextElement(vars, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>, tableSQL);
carlos@0
   342
          vars.setSessionValue(windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", strNext);
carlos@0
   343
          response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
carlos@0
   344
        } else response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
carlos@0
   345
      }
carlos@0
   346
/*    } else if (vars.commandIn("DELETE_RELATION")) {
carlos@0
   347
<PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");
carlos@0
   348
</PARAMETER_TMP>
carlos@0
   349
      String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getRequiredInStringParameter("inp<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>");
carlos@0
   350
      String message = deleteRelation(vars, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP><PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);
carlos@0
   351
      if (!message.equals("")) {
asier@2749
   352
        bdError(request, response, message, vars.getLanguage());
carlos@0
   353
      } else {
carlos@0
   354
        vars.removeSessionValue(windowId + "|<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>");
carlos@0
   355
        vars.setSessionValue(tabId + "|<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>.view", "RELATION");
carlos@0
   356
        response.sendRedirect(strDireccion + request.getServletPath());
carlos@0
   357
      }*/
carlos@0
   358
    } else if (vars.commandIn("DELETE")) {
carlos@0
   359
<PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");
carlos@0
   360
</PARAMETER_TMP>
carlos@0
   361
      String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getRequiredStringParameter("inp<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>");
carlos@0
   362
      //<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data data = getEditVariables(vars<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);
carlos@0
   363
      int total = 0;
carlos@0
   364
      OBError myError = null;
asier@683
   365
      if (org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)) {
asier@683
   366
        myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
asier@683
   367
        vars.setMessage(tabId, myError);
asier@683
   368
      } else {
asier@683
   369
        try {
asier@683
   370
          total = <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data.delete(this, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP><PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP><PARAMETER_TMP id="client">, Utility.getContext(this, vars, "#User_Client", windowId, accesslevel), Utility.getContext(this, vars, "#User_Org", windowId, accesslevel)</PARAMETER_TMP>);
asier@683
   371
        } catch(ServletException ex) {
asier@683
   372
          myError = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
asier@683
   373
          if (!myError.isConnectionAvailable()) {
asier@683
   374
            bdErrorConnection(response);
asier@683
   375
            return;
asier@683
   376
          } else vars.setMessage(tabId, myError);
asier@683
   377
        }
asier@683
   378
        if (myError==null &amp;&amp; total==0) {
asier@683
   379
          myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
asier@683
   380
          vars.setMessage(tabId, myError);
asier@683
   381
        }
asier@683
   382
        vars.removeSessionValue(windowId + "|<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>");
asier@683
   383
        vars.setSessionValue(tabId + "|<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>.view", "RELATION");
carlos@0
   384
      }
carlos@0
   385
      if (myError==null) {
carlos@0
   386
        myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsDeleted");
carlos@0
   387
        myError.setMessage(total + " " + myError.getMessage());
carlos@0
   388
        vars.setMessage(tabId, myError);
carlos@0
   389
      }
carlos@0
   390
      response.sendRedirect(strDireccion + request.getServletPath());
asier@4040
   391
<FIELDS_TMP id="sectionActionButtons1">
asier@4040
   392
     } else if (vars.commandIn("BUTTON<FIELD_TMP id="ButtonRealName1">button</FIELD_TMP><FIELD_TMP id="ProcessID1">button</FIELD_TMP>")) {
asier@4040
   393
        vars.setSessionValue("button<FIELD_TMP id="ProcessID1">xx</FIELD_TMP>.str<FIELD_TMP id="ButtonName1">name</FIELD_TMP>", vars.getStringParameter("inp<FIELD_TMP id="ButtonName1">name</FIELD_TMP>"));
asier@4040
   394
        vars.setSessionValue("button<FIELD_TMP id="ProcessID1">xx</FIELD_TMP>.strProcessing", vars.getStringParameter("inpprocessing", "Y"));
asier@4040
   395
        vars.setSessionValue("button<FIELD_TMP id="ProcessID1">xx</FIELD_TMP>.strOrg", vars.getStringParameter("inpadOrgId"));
asier@4040
   396
        vars.setSessionValue("button<FIELD_TMP id="ProcessID1">xx</FIELD_TMP>.strClient", vars.getStringParameter("inpadClientId"));
asier@4048
   397
        <FIELD_TMP id="SetSession1"></FIELD_TMP>
asier@4043
   398
        
asier@4043
   399
        HashMap&lt;String, String&gt; p = new HashMap&lt;String, String&gt;();
asier@4043
   400
        <FIELD_TMP id="comboParameters1"></FIELD_TMP>
asier@4043
   401
        
asier@4043
   402
        //Save in session needed params for combos if needed
asier@4043
   403
        vars.setSessionObject("button<FIELD_TMP id="ProcessID1">xx</FIELD_TMP>.originalParams", FieldProviderFactory.getFieldProvider(p));
asier@4040
   404
        printPageButtonFS(response, vars, "<FIELD_TMP id="ProcessID1">xx</FIELD_TMP>", request.getServletPath());    
asier@4040
   405
     } else if (vars.commandIn("BUTTON<FIELD_TMP id="ProcessID1">button</FIELD_TMP>")) {
carlos@0
   406
        String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getGlobalVariable("inp<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>", windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", "");
asier@4040
   407
        String str<FIELD_TMP id="ButtonName1">name</FIELD_TMP> = vars.getSessionValue("button<FIELD_TMP id="ProcessID1">xx</FIELD_TMP>.str<FIELD_TMP id="ButtonName1">name</FIELD_TMP>");
asier@4040
   408
        String strProcessing = vars.getSessionValue("button<FIELD_TMP id="ProcessID1">xx</FIELD_TMP>.strProcessing");
asier@4040
   409
        String strOrg = vars.getSessionValue("button<FIELD_TMP id="ProcessID1">xx</FIELD_TMP>.strOrg");
asier@4040
   410
        String strClient = vars.getSessionValue("button<FIELD_TMP id="ProcessID1">xx</FIELD_TMP>.strClient");
asier@4040
   411
        
carlos@0
   412
        <FIELD_TMP id="FieldsLoad1">String strField = vars.getStringParameter("inpFields");</FIELD_TMP>
asier@683
   413
        if ((org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)) || !(Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel),strClient)  &amp;&amp; Utility.isElementInList(Utility.getContext(this, vars, "#User_Org", windowId, accesslevel),strOrg))){
asier@683
   414
          OBError myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
asier@683
   415
          vars.setMessage(tabId, myError);
asier@683
   416
          printPageClosePopUp(response, vars);
asier@683
   417
        }else{       
asier@683
   418
          printPageButton<FIELD_TMP id="ButtonRealName1">name</FIELD_TMP><FIELD_TMP id="ProcessID1">xx</FIELD_TMP>(response, vars, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>, str<FIELD_TMP id="ButtonName1">name</FIELD_TMP>, strProcessing<FIELD_TMP id="FieldsLoadName1">, strFields</FIELD_TMP>);
asier@683
   419
        }
carlos@0
   420
</FIELDS_TMP>
asier@3907
   421
<FIELDS_TMP id="sectionActionButtonsJava1">    } else if (vars.commandIn("BUTTON<FIELD_TMP id="ButtonRealName4">button</FIELD_TMP><FIELD_TMP id="ProcessID4">button</FIELD_TMP>")) {
asier@4040
   422
        vars.setSessionValue("button<FIELD_TMP id="ProcessID4">xx</FIELD_TMP>.str<FIELD_TMP id="ButtonName4">name</FIELD_TMP>", vars.getStringParameter("inp<FIELD_TMP id="ButtonName4">name</FIELD_TMP>"));
asier@4040
   423
        vars.setSessionValue("button<FIELD_TMP id="ProcessID4">xx</FIELD_TMP>.strProcessing", vars.getStringParameter("inpprocessing", "Y"));
asier@4040
   424
        vars.setSessionValue("button<FIELD_TMP id="ProcessID4">xx</FIELD_TMP>.strOrg", vars.getStringParameter("inpadOrgId"));
asier@4040
   425
        vars.setSessionValue("button<FIELD_TMP id="ProcessID4">xx</FIELD_TMP>.strClient", vars.getStringParameter("inpadClientId"));
asier@4048
   426
        <FIELD_TMP id="SetSessionJava1"></FIELD_TMP>
asier@4043
   427
        
asier@4043
   428
        HashMap&lt;String, String&gt; p = new HashMap&lt;String, String&gt;();
asier@4043
   429
        <FIELD_TMP id="comboParametersJava1"></FIELD_TMP>
asier@4043
   430
        
asier@4043
   431
        //Save in session needed params for combos if needed
asier@4048
   432
        vars.setSessionObject("button<FIELD_TMP id="ProcessID4">xx</FIELD_TMP>.originalParams", FieldProviderFactory.getFieldProvider(p));
asier@4040
   433
        printPageButtonFS(response, vars, "<FIELD_TMP id="ProcessID4">xx</FIELD_TMP>", request.getServletPath());
asier@4040
   434
      } else if (vars.commandIn("BUTTON<FIELD_TMP id="ProcessID4">button</FIELD_TMP>")) {
asier@3907
   435
        String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getGlobalVariable("inp<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>", windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", "");
asier@4040
   436
        String str<FIELD_TMP id="ButtonName4">name</FIELD_TMP> = vars.getSessionValue("button<FIELD_TMP id="ProcessID4">xx</FIELD_TMP>.str<FIELD_TMP id="ButtonName4">name</FIELD_TMP>");
asier@4040
   437
        String strProcessing = vars.getSessionValue("button<FIELD_TMP id="ProcessID4">xx</FIELD_TMP>.strProcessing");
asier@4040
   438
        String strOrg = vars.getSessionValue("button<FIELD_TMP id="ProcessID4">xx</FIELD_TMP>.strOrg");
asier@4040
   439
        String strClient = vars.getSessionValue("button<FIELD_TMP id="ProcessID4">xx</FIELD_TMP>.strClient");
asier@4040
   440
asier@3907
   441
        <FIELD_TMP id="FieldsLoad4">String strField = vars.getStringParameter("inpFields");</FIELD_TMP>
asier@3907
   442
        if ((org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)) || !(Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel),strClient)  &amp;&amp; Utility.isElementInList(Utility.getContext(this, vars, "#User_Org", windowId, accesslevel),strOrg))){
asier@3907
   443
          OBError myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
asier@3907
   444
          vars.setMessage(tabId, myError);
asier@3907
   445
          printPageClosePopUp(response, vars);
asier@3907
   446
        }else{       
asier@3907
   447
          printPageButton<FIELD_TMP id="ButtonRealName4">name</FIELD_TMP><FIELD_TMP id="ProcessID4">xx</FIELD_TMP>(response, vars, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>, str<FIELD_TMP id="ButtonName4">name</FIELD_TMP>, strProcessing<FIELD_TMP id="FieldsLoadName4">, strFields</FIELD_TMP>);
asier@3907
   448
        }
asier@3907
   449
</FIELDS_TMP>
carlos@0
   450
<FIELDS_TMP id="sectionActionButtons3">    } else if (vars.commandIn("SAVE_BUTTON<FIELD_TMP id="ButtonRealName3">button</FIELD_TMP><FIELD_TMP id="ProcessID3">button</FIELD_TMP>")) {
carlos@0
   451
        String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getGlobalVariable("inpKey", windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", "");
carlos@0
   452
        @SuppressWarnings("unused")
carlos@0
   453
        String str<FIELD_TMP id="ButtonName3">name</FIELD_TMP> = vars.getStringParameter("inp<FIELD_TMP id="ButtonName3">name</FIELD_TMP>");
carlos@0
   454
        String strProcessing = vars.getStringParameter("inpprocessing");
carlos@0
   455
        OBError myMessage = null;
carlos@0
   456
        try {
juanpablo@1605
   457
          String pinstance = SequenceIdData.getUUID();
carlos@0
   458
          PInstanceProcessData.insertPInstance(this, pinstance, "<FIELD_TMP id="ProcessID3">button</FIELD_TMP>", (("<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>".equalsIgnoreCase("AD_Language"))?"0":str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>), strProcessing, vars.getUser(), vars.getClient(), vars.getOrg());
carlos@0
   459
          <FIELD_TMP id="FieldsLoadParams3">PInstanceProcessData.insertPInstanceParam(this, pinstance, )</FIELD_TMP>
carlos@0
   460
          <FIELD_TMP id="AdditionalCode3">code</FIELD_TMP>
anthony@1867
   461
          ProcessBundle bundle = ProcessBundle.pinstance(pinstance, vars, this);
anthony@1867
   462
          new ProcessRunner(bundle).execute(this);
anthony@1867
   463
          
carlos@0
   464
          PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance);
carlos@0
   465
          myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData);
carlos@0
   466
        } catch (ServletException ex) {
carlos@0
   467
          myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
carlos@0
   468
          if (!myMessage.isConnectionAvailable()) {
carlos@0
   469
            bdErrorConnection(response);
carlos@0
   470
            return;
carlos@0
   471
          } else vars.setMessage(tabId, myMessage);
carlos@0
   472
        }
asier@3907
   473
        //close popup
asier@3907
   474
        if (myMessage!=null) {
asier@3907
   475
          if (log4j.isDebugEnabled()) log4j.debug(myMessage.getMessage());
asier@3907
   476
          vars.setMessage(tabId, myMessage);
asier@3907
   477
        }
asier@3907
   478
        printPageClosePopUp(response, vars);
asier@3907
   479
</FIELDS_TMP>
asier@3907
   480
<FIELDS_TMP id="sectionActionButtons3java">    } else if (vars.commandIn("SAVE_BUTTON<FIELD_TMP id="ButtonRealName3j">button</FIELD_TMP><FIELD_TMP id="ProcessID3j">button</FIELD_TMP>")) {
asier@3907
   481
        String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getGlobalVariable("inpKey", windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", "");
asier@3907
   482
        
ivan@4837
   483
        ProcessBundle pb = new ProcessBundle("<FIELD_TMP id="ProcessID3j"/>", vars).init(this);
asier@3907
   484
        HashMap&lt;String, Object&gt; params= new HashMap&lt;String, Object&gt;();
asier@3907
   485
       
asier@3907
   486
        params.put("<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>);
asier@3907
   487
        params.put("adOrgId", vars.getStringParameter("inpadOrgId"));
asier@3907
   488
        params.put("adClientId", vars.getStringParameter("inpadClientId"));
asier@3907
   489
        <FIELD_TMP id="FieldsLoadParams3j">PInstanceProcessData.insertPInstanceParam(this, pinstance, )</FIELD_TMP>
asier@3907
   490
        
asier@3907
   491
        pb.setParams(params);
asier@3907
   492
        OBError myMessage = null;
asier@3907
   493
        try {
ivan@4837
   494
          new ProcessRunner(pb).execute(this);
asier@3907
   495
          myMessage = (OBError) pb.getResult();
asier@3907
   496
          myMessage.setMessage(Utility.parseTranslation(this, vars, vars.getLanguage(), myMessage.getMessage()));
asier@4081
   497
          myMessage.setTitle(Utility.parseTranslation(this, vars, vars.getLanguage(), myMessage.getTitle()));
asier@3907
   498
        } catch (Exception ex) {
asier@3907
   499
          myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
asier@3907
   500
          log4j.error(ex);
asier@3907
   501
          if (!myMessage.isConnectionAvailable()) {
asier@3907
   502
            bdErrorConnection(response);
asier@3907
   503
            return;
asier@3907
   504
          } else vars.setMessage(tabId, myMessage);
asier@3907
   505
        }
asier@3907
   506
        //close popup
carlos@0
   507
        if (myMessage!=null) {
carlos@0
   508
          if (log4j.isDebugEnabled()) log4j.debug(myMessage.getMessage());
carlos@0
   509
          vars.setMessage(tabId, myMessage);
carlos@0
   510
        }
carlos@0
   511
        printPageClosePopUp(response, vars);
carlos@0
   512
</FIELDS_TMP>
carlos@0
   513
<FIELDS_TMP id="sectionCreateFrom">    } else if (vars.commandIn("BUTTONCreateFrom")) {
carlos@0
   514
        String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getGlobalVariable("inp<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>", windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", "");
carlos@0
   515
        String strTableId = "<PARAMETER_TMP id="paramTableId">xx</PARAMETER_TMP>";
carlos@0
   516
        String strProcessId = "<PARAMETER_TMP id="paramCreateFromProcessId">xx</PARAMETER_TMP>";
carlos@0
   517
        String strDateInvoiced = vars.getStringParameter("inpdateinvoiced", "");
carlos@0
   518
        String strBPartnerLocation = vars.getStringParameter("inpcBpartnerLocationId", "");
carlos@0
   519
        String strPriceList = vars.getStringParameter("inpmPricelistId", "");
carlos@0
   520
        String strBPartner = vars.getStringParameter("inpcBpartnerId", "");
carlos@0
   521
        String strBankAccount = vars.getStringParameter("inpcBankaccountId");
carlos@0
   522
        String strStatementDate = vars.getStringParameter("inpstatementdate");
carlos@0
   523
        String strOrg = vars.getStringParameter("inpadOrgId");
asier@683
   524
        String strClient = vars.getStringParameter("inpadClientId");
carlos@0
   525
        String strIsreceipt = vars.getStringParameter("inpisreceipt");
carlos@0
   526
        log4j.debug("Loading CreateFrom button in table: " + strTableId);
carlos@0
   527
        vars.setSessionValue("CreateFrom|key", str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>);
carlos@0
   528
        vars.setSessionValue("CreateFrom|tableId", strTableId);
carlos@0
   529
        vars.setSessionValue("CreateFrom|tabId", tabId);
carlos@0
   530
        vars.setSessionValue("CreateFrom|processId", strProcessId);
carlos@0
   531
        vars.setSessionValue("CreateFrom|path", strDireccion + request.getServletPath());
carlos@0
   532
        vars.setSessionValue("CreateFrom|bpartnerLocation", strBPartnerLocation);
carlos@0
   533
        vars.setSessionValue("CreateFrom|dateInvoiced", strDateInvoiced);
carlos@0
   534
        vars.setSessionValue("CreateFrom|pricelist", strPriceList);
carlos@0
   535
        vars.setSessionValue("CreateFrom|bpartner", strBPartner);
carlos@0
   536
        vars.setSessionValue("CreateFrom|windowId", windowId);
carlos@0
   537
        vars.setSessionValue("CreateFrom|bankAccount", strBankAccount);
carlos@0
   538
        vars.setSessionValue("CreateFrom|statementDate", strStatementDate);
carlos@0
   539
        vars.setSessionValue("CreateFrom|adOrgId", strOrg);
carlos@0
   540
        vars.setSessionValue("CreateFrom|isreceipt", strIsreceipt);
carlos@0
   541
        vars.setSessionValue("CreateFrom|tabName", "<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>");
asier@683
   542
        if ((org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)) || !(Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel),strClient)  &amp;&amp; Utility.isElementInList(Utility.getContext(this, vars, "#User_Org", windowId, accesslevel),strOrg))){
asier@683
   543
          OBError myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
asier@683
   544
          vars.setMessage(tabId, myError);
asier@683
   545
          printPageClosePopUp(response, vars);
asier@683
   546
        }else{       
asier@683
   547
          response.sendRedirect(strDireccion + "/ad_actionButton/CreateFrom.html");
asier@683
   548
        }
carlos@0
   549
</FIELDS_TMP>
carlos@0
   550
<FIELDS_TMP id="sectionPosted">    } else if (vars.commandIn("BUTTONPosted")) {
carlos@0
   551
        String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getGlobalVariable("inp<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>", windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", "");
carlos@0
   552
        String strTableId = "<PARAMETER_TMP id="paramTableId">xx</PARAMETER_TMP>";
carlos@0
   553
        String strPosted = vars.getStringParameter("inpposted");
carlos@0
   554
        String strProcessId = "<PARAMETER_TMP id="paramPostedProcessId">xx</PARAMETER_TMP>";
carlos@0
   555
        log4j.debug("Loading Posted button in table: " + strTableId);
asier@683
   556
        String strOrg = vars.getStringParameter("inpadOrgId");
asier@683
   557
        String strClient = vars.getStringParameter("inpadClientId");
asier@683
   558
        if ((org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)) || !(Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel),strClient)  &amp;&amp; Utility.isElementInList(Utility.getContext(this, vars, "#User_Org", windowId, accesslevel),strOrg))){
asier@683
   559
          OBError myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
asier@683
   560
          vars.setMessage(tabId, myError);
asier@683
   561
          printPageClosePopUp(response, vars);
asier@683
   562
        }else{
asier@683
   563
          vars.setSessionValue("Posted|key", str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>);
asier@683
   564
          vars.setSessionValue("Posted|tableId", strTableId);
asier@683
   565
          vars.setSessionValue("Posted|tabId", tabId);
asier@683
   566
          vars.setSessionValue("Posted|posted", strPosted);
asier@683
   567
          vars.setSessionValue("Posted|processId", strProcessId);
asier@683
   568
          vars.setSessionValue("Posted|path", strDireccion + request.getServletPath());
asier@683
   569
          vars.setSessionValue("Posted|windowId", windowId);
asier@683
   570
          vars.setSessionValue("Posted|tabName", "<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>");
asier@683
   571
          response.sendRedirect(strDireccion + "/ad_actionButton/Posted.html");
asier@683
   572
        }
carlos@0
   573
</FIELDS_TMP>
carlos@0
   574
<FIELDS_TMP id="sectionEncrypted1">    } else if (vars.commandIn("BUTTON<FIELD_TMP id="EncryptedRealName1">button</FIELD_TMP>")) {
carlos@0
   575
        String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getGlobalVariable("inp<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>", windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", "");
carlos@0
   576
        <PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");
carlos@0
   577
</PARAMETER_TMP>
asier@2749
   578
        printPageButton<FIELD_TMP id="EncryptedRealName1">name</FIELD_TMP>(request, response, vars, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP><PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);
carlos@0
   579
</FIELDS_TMP>
carlos@0
   580
<FIELDS_TMP id="sectionEncrypted3">    } else if (vars.commandIn("SAVE_BUTTON<FIELD_TMP id="EncryptedRealName3">button</FIELD_TMP>")) {
carlos@0
   581
        String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getGlobalVariable("inpKey", windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", "");
carlos@0
   582
        String str<FIELD_TMP id="EncryptedName3">name</FIELD_TMP> = FormatUtilities.<FIELD_TMP id="EncryptedMethod3">encryptDecrypt</FIELD_TMP>(vars.getStringParameter("inpValue")<FIELD_TMP id="EncryptedPostMethod3">, true</FIELD_TMP>);
carlos@0
   583
carlos@0
   584
<PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");
carlos@0
   585
</PARAMETER_TMP>
carlos@0
   586
carlos@0
   587
        OBError myError = null;
carlos@0
   588
        int count = 0;
carlos@0
   589
        try {
carlos@0
   590
          count = <PARENT_TMP id="class">Almacen</PARENT_TMP>Data.update<FIELD_TMP id="EncryptedUpdateName3">button</FIELD_TMP>(this, str<FIELD_TMP id="EncryptedName3">name</FIELD_TMP>, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP><PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);
carlos@0
   591
        } catch(ServletException ex) {
carlos@0
   592
          myError = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
carlos@0
   593
          if (!myError.isConnectionAvailable()) {
carlos@0
   594
            bdErrorConnection(response);
carlos@0
   595
            return;
carlos@0
   596
          } else vars.setMessage(tabId, myError);
carlos@0
   597
        }
carlos@0
   598
        if (myError==null) {
asier@3604
   599
          myError = new OBError();
carlos@0
   600
          if (count==0) {
asier@3604
   601
            myError.setTitle(Utility.messageBD(this, "Error", vars.getLanguage()));
asier@3604
   602
            myError.setType("Error");            
carlos@0
   603
          } else {
asier@3604
   604
            myError.setTitle(Utility.messageBD(this, "Success", vars.getLanguage()));
asier@3604
   605
            myError.setType("Success");
carlos@0
   606
          }
asier@3604
   607
          vars.setMessage(tabId, myError);
carlos@0
   608
        }
carlos@0
   609
        if (log4j.isDebugEnabled() &amp;&amp; myError!=null) log4j.debug(myError.getMessage());
carlos@0
   610
        printPageClosePopUp(response, vars);
carlos@0
   611
</FIELDS_TMP>
carlos@0
   612
    } else if (vars.getCommand().toUpperCase().startsWith("BUTTON") || vars.getCommand().toUpperCase().startsWith("SAVE_BUTTON")) {
carlos@0
   613
      pageErrorPopUp(response);
carlos@0
   614
    } else pageError(response);
carlos@0
   615
  }
carlos@0
   616
/*
carlos@0
   617
  String deleteRelation(VariablesSecureApp vars, String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP><PARAMETER_TMP id="parent">, String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>) throws IOException, ServletException {
carlos@0
   618
    log4j.debug("Deleting records");
carlos@0
   619
    Connection conn = this.getTransactionConnection();
carlos@0
   620
    try {
carlos@0
   621
      if (str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>.startsWith("(")) str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>.substring(1, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>.length()-1);
carlos@0
   622
      if (!str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>.equals("")) {
carlos@0
   623
        str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = Replace.replace(str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>, "'", "");
carlos@0
   624
        StringTokenizer st = new StringTokenizer(str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>, ",", false);
carlos@0
   625
        while (st.hasMoreTokens()) {
carlos@0
   626
          String strKey = st.nextToken();
carlos@0
   627
          if (<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data.deleteTransactional(conn, this, strKey<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>)==0) {
carlos@0
   628
            releaseRollbackConnection(conn);
carlos@0
   629
            log4j.warn("deleteRelation - key :" + strKey + " - 0 records deleted");
carlos@0
   630
          }
carlos@0
   631
        }
carlos@0
   632
      }
carlos@0
   633
      releaseCommitConnection(conn);
carlos@0
   634
    } catch (ServletException e) {
carlos@0
   635
      releaseRollbackConnection(conn);
carlos@0
   636
      e.printStackTrace();
carlos@0
   637
      log4j.error("Rollback in transaction");
carlos@0
   638
      return "ProcessRunError";
carlos@0
   639
    }
carlos@0
   640
    return "";
carlos@0
   641
  }
carlos@0
   642
*/
stefan@3960
   643
  private <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data getEditVariables(Connection con, VariablesSecureApp vars<PARAMETER_TMP id="parent">, String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>) throws IOException,ServletException {
carlos@0
   644
    <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data data = new <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data();
ivan@4810
   645
    ServletException ex = null;
ivan@2072
   646
    try {
ivan@4810
   647
<FIELDS_TMP id="sectionDetailgetEditVariables">  <FIELD_TMP id="fieldTry">claveAlmacen</FIELD_TMP>  data.<FIELD_TMP id="fieldName">claveAlmacen</FIELD_TMP> = <FIELD_TMP id="fieldEncryption">FormatUtilities.encryptDecrypt(</FIELD_TMP>vars.get<FIELD_TMP id="fieldType">StringParameter</FIELD_TMP>("inp<FIELD_TMP id="fieldName1">claveAlmacen</FIELD_TMP>"<FIELD_TMP id="fieldDefault">, "D"</FIELD_TMP>)<FIELD_TMP id="fieldEndEncryption">, true)</FIELD_TMP>; <FIELD_TMP id="fieldCatch">claveAlmacen</FIELD_TMP></FIELDS_TMP>
carlos@0
   648
      data.createdby = vars.getUser();
carlos@0
   649
      data.updatedby = vars.getUser();
asier@683
   650
      data.adUserClient = Utility.getContext(this, vars, "#User_Client", windowId, accesslevel);
asier@683
   651
      data.adOrgClient = Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel);
carlos@0
   652
asier@4402
   653
<PARAMETER_TMP id="parent">      data.<PARENT_TMP id="keyParentT">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");
carlos@0
   654
</PARAMETER_TMP>
asier@814
   655
<PARAMETER_TMP id="hasOrgKey">      data.currentAdOrgId=vars.getStringParameter("inpCurrentOrgId");</PARAMETER_TMP>
carlos@0
   656
    <LISTS_TMP id="sectionDetailParams2">      vars.getGlobalVariable("inp<LIST_TMP id="fieldInputNameParam2">Almacen</LIST_TMP>", windowId + "|<LIST_TMP id="fieldNameParam2">Almacen</LIST_TMP>", "");
carlos@0
   657
    </LISTS_TMP>
carlos@0
   658
    <LISTS_TMP id="sectionDetailDocumentsNew">     if (data.<LIST_TMP id="fieldNameDocNew">dd</LIST_TMP>.startsWith("&#60;")) data.<LIST_TMP id="fieldNameDocNew">dd</LIST_TMP> = <LIST_TMP id="fieldValueDocNew">dd</LIST_TMP>;</LISTS_TMP>
carlos@0
   659
carlos@0
   660
    <LISTS_TMP id="sectionIdentifyValues">      if (data.<LIST_TMP id="fieldIdentifyColumn">dd</LIST_TMP>.equals("")) data.<LIST_TMP id="fieldIdentifyColumn">dd</LIST_TMP> = <LIST_TMP id="fieldIdentifyValue">dd</LIST_TMP>;</LISTS_TMP>
ivan@4810
   661
    }
ivan@2072
   662
    catch(ServletException e) {
ivan@2072
   663
    	vars.setEditionData(tabId, data);
ivan@2072
   664
    	throw e;
ivan@2072
   665
    }
ivan@4810
   666
    // Behavior with exception for numeric fields is to catch last one if we have multiple ones
ivan@4810
   667
    if(ex != null) {
ivan@4810
   668
      vars.setEditionData(tabId, data);
ivan@4810
   669
      throw ex;
ivan@4810
   670
    }
carlos@0
   671
    return data;
carlos@0
   672
  }
carlos@0
   673
stefan@3960
   674
   private <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data[] getRelationData(<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data[] data) {
carlos@0
   675
    if (data!=null) {
carlos@0
   676
      for (int i=0;i&#60;data.length;i++) {<FIELDS_TMP id="sectionDetailgetRelationData">        data[i].<FIELD_TMP id="fieldRelationName">claveAlmacen</FIELD_TMP> = FormatUtilities.truncate(data[i].<FIELD_TMP id="fieldRelationName">claveAlmacen</FIELD_TMP>, <FIELD_TMP id="fieldMaxLength">35</FIELD_TMP>);</FIELDS_TMP>}
carlos@0
   677
    }
carlos@0
   678
    return data;
carlos@0
   679
  }
carlos@0
   680
stefan@3960
   681
<PARAMETER_TMP id="parent">  private void refreshParentSession(VariablesSecureApp vars, String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>) throws IOException,ServletException {
asier@5239
   682
      <PARENT_TMP id="parentClass">Almacen</PARENT_TMP>Data[] data = <PARENT_TMP id="parentClass">Almacen</PARENT_TMP>Data.selectEdit(this, vars.getSessionValue("#AD_SqlDateTimeFormat"), vars.getLanguage()<PARAMETER_TMP id="parentwhereclause"></PARAMETER_TMP><PARAMETER_TMP id="grandfather">, vars.getSessionValue(windowId + "|<PARAMETER_TMP id="grandfatherName">xx</PARAMETER_TMP>")</PARAMETER_TMP>, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>, Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel));
carlos@0
   683
      if (data==null || data.length==0) return;
carlos@0
   684
      <FIELDS_TMP id="sectionDetailParentSession">    vars.setSessionValue(windowId + "|<FIELD_TMP id="fieldRealName8">claveAlmacen</FIELD_TMP>", data[0].<FIELD_TMP id="fieldName8">claveAlmacen</FIELD_TMP>);</FIELDS_TMP>
asier@4881
   685
      vars.setSessionValue(windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>", strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>); //to ensure key parent is set for EM_* cols
ben@5328
   686
ben@5328
   687
      FieldProvider dataField = null; // Define this so that auxiliar inputs using SQL will work
ben@5328
   688
      <LISTS_TMP id="sectionDetailParentParams">
carlos@0
   689
      vars.setSessionValue(windowId + "|<LIST_TMP id="fieldParentNameParam">Almacen</LIST_TMP>", <LIST_TMP id="paramParentCode">dd</LIST_TMP>);
carlos@0
   690
      </LISTS_TMP>
carlos@0
   691
  }
carlos@0
   692
    
stefan@3960
   693
  private String getParentID(VariablesSecureApp vars, String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>) throws ServletException {
carlos@0
   694
    String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data.selectParentID(this, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>);
carlos@0
   695
    if (strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>.equals("")) {
carlos@0
   696
      log4j.error("Parent record not found for id: " + str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>);
carlos@0
   697
      throw new ServletException("Parent record not found");
carlos@0
   698
    }
carlos@0
   699
    return strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>;
carlos@0
   700
  }</PARAMETER_TMP>
carlos@0
   701
stefan@3960
   702
    private void refreshSessionEdit(VariablesSecureApp vars, FieldProvider[] data) {
carlos@0
   703
      if (data==null || data.length==0) return;
carlos@0
   704
      <FIELDS_TMP id="sectionDetailSession">    vars.setSessionValue(windowId + "|<FIELD_TMP id="fieldRealName9">claveAlmacen</FIELD_TMP>", data[0].getField("<FIELD_TMP id="fieldName9">claveAlmacen</FIELD_TMP>"));</FIELDS_TMP>
carlos@0
   705
    }
carlos@0
   706
stefan@3960
   707
    private void refreshSessionNew(VariablesSecureApp vars<PARAMETER_TMP id="parent">, String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>) throws IOException,ServletException {
asier@5239
   708
      <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data[] data = <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data.selectEdit(this, vars.getSessionValue("#AD_SqlDateTimeFormat"), vars.getLanguage()<PARAMETER_TMP id="whereClauseParams"></PARAMETER_TMP><PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, vars.getStringParameter("inp<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>", "")<PARAMETER_TMP id="client">, Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel)</PARAMETER_TMP>);
carlos@0
   709
      if (data==null || data.length==0) return;
carlos@0
   710
      refreshSessionEdit(vars, data);
carlos@0
   711
    }
carlos@0
   712
stefan@3960
   713
  private String nextElement(VariablesSecureApp vars, String strSelected, TableSQLData tableSQL) throws IOException, ServletException {
asier@2769
   714
    if (strSelected == null || strSelected.equals("")) return firstElement(vars, tableSQL);
carlos@0
   715
    if (tableSQL!=null) {
stefan@1734
   716
      String data = null;
carlos@0
   717
      try{
stefan@2126
   718
        String strSQL = ModelSQLGeneration.generateSQLonlyId(this, vars, tableSQL, (tableSQL.getTableName() + "." + tableSQL.getKeyColumn() + " AS ID"), new Vector&#60;String&#62;(), new Vector&#60;String&#62;(), 0, 0);
stefan@2126
   719
        ExecuteQuery execquery = new ExecuteQuery(this, strSQL, tableSQL.getParameterValuesOnlyId());
stefan@2165
   720
        data = execquery.selectAndSearch(ExecuteQuery.SearchType.NEXT, strSelected, tableSQL.getKeyColumn());
carlos@0
   721
      } catch (Exception e) { 
stefan@3456
   722
        log4j.error("Error getting next element", e);
carlos@0
   723
      }
carlos@0
   724
      if (data!=null) {
stefan@1734
   725
        if (data!=null) return data;
carlos@0
   726
      }
carlos@0
   727
    }
carlos@0
   728
    return strSelected;
carlos@0
   729
  }
carlos@0
   730
stefan@3960
   731
  private int getKeyPosition(VariablesSecureApp vars, String strSelected, TableSQLData tableSQL) throws IOException, ServletException {
carlos@0
   732
    if (log4j.isDebugEnabled()) log4j.debug("getKeyPosition: " + strSelected);
carlos@0
   733
    if (tableSQL!=null) {
stefan@1734
   734
      String data = null;
carlos@0
   735
      try{
stefan@2126
   736
        String strSQL = ModelSQLGeneration.generateSQLonlyId(this, vars, tableSQL, (tableSQL.getTableName() + "." + tableSQL.getKeyColumn() + " AS ID"), new Vector&#60;String&#62;(), new Vector&#60;String&#62;(),0,0);
stefan@2126
   737
        ExecuteQuery execquery = new ExecuteQuery(this, strSQL, tableSQL.getParameterValuesOnlyId());
stefan@2165
   738
        data = execquery.selectAndSearch(ExecuteQuery.SearchType.GETPOSITION, strSelected, tableSQL.getKeyColumn());
carlos@0
   739
      } catch (Exception e) { 
stefan@3456
   740
        log4j.error("Error getting key position", e);
carlos@0
   741
      }
carlos@0
   742
      if (data!=null) {
stefan@1734
   743
        if (data!=null) return Integer.valueOf(data);
carlos@0
   744
      }
carlos@0
   745
    }
carlos@0
   746
    return 0;
carlos@0
   747
  }
carlos@0
   748
stefan@3960
   749
  private String previousElement(VariablesSecureApp vars, String strSelected, TableSQLData tableSQL) throws IOException, ServletException {
asier@2769
   750
    if (strSelected == null || strSelected.equals("")) return firstElement(vars, tableSQL);
carlos@0
   751
    if (tableSQL!=null) {
stefan@1734
   752
      String data = null;
carlos@0
   753
      try{
stefan@2126
   754
        String strSQL = ModelSQLGeneration.generateSQLonlyId(this, vars, tableSQL, (tableSQL.getTableName() + "." + tableSQL.getKeyColumn() + " AS ID"), new Vector&#60;String&#62;(), new Vector&#60;String&#62;(),0,0);
stefan@2126
   755
        ExecuteQuery execquery = new ExecuteQuery(this, strSQL, tableSQL.getParameterValuesOnlyId());
stefan@2165
   756
        data = execquery.selectAndSearch(ExecuteQuery.SearchType.PREVIOUS, strSelected, tableSQL.getKeyColumn());
carlos@0
   757
      } catch (Exception e) { 
stefan@3456
   758
        log4j.error("Error getting previous element", e);
carlos@0
   759
      }
carlos@0
   760
      if (data!=null) {
stefan@1734
   761
        return data;
carlos@0
   762
      }
carlos@0
   763
    }
carlos@0
   764
    return strSelected;
carlos@0
   765
  }
carlos@0
   766
stefan@3960
   767
  private String firstElement(VariablesSecureApp vars, TableSQLData tableSQL) throws IOException, ServletException {
carlos@0
   768
    if (tableSQL!=null) {
stefan@1734
   769
      String data = null;
carlos@0
   770
      try{
stefan@2126
   771
        String strSQL = ModelSQLGeneration.generateSQLonlyId(this, vars, tableSQL, (tableSQL.getTableName() + "." + tableSQL.getKeyColumn() + " AS ID"), new Vector&#60;String&#62;(), new Vector&#60;String&#62;(),0,1);
stefan@2126
   772
        ExecuteQuery execquery = new ExecuteQuery(this, strSQL, tableSQL.getParameterValuesOnlyId());
stefan@2165
   773
        data = execquery.selectAndSearch(ExecuteQuery.SearchType.FIRST, "", tableSQL.getKeyColumn());
stefan@1734
   774
carlos@0
   775
      } catch (Exception e) { 
stefan@3456
   776
        log4j.debug("Error getting first element", e);
carlos@0
   777
      }
stefan@1734
   778
      if (data!=null) return data;
carlos@0
   779
    }
carlos@0
   780
    return "";
carlos@0
   781
  }
carlos@0
   782
stefan@3960
   783
  private String lastElement(VariablesSecureApp vars, TableSQLData tableSQL) throws IOException, ServletException {
carlos@0
   784
    if (tableSQL!=null) {
stefan@1734
   785
      String data = null;
carlos@0
   786
      try{
stefan@2126
   787
        String strSQL = ModelSQLGeneration.generateSQLonlyId(this, vars, tableSQL, (tableSQL.getTableName() + "." + tableSQL.getKeyColumn() + " AS ID"), new Vector&#60;String&#62;(), new Vector&#60;String&#62;(),0,0);
stefan@2126
   788
        ExecuteQuery execquery = new ExecuteQuery(this, strSQL, tableSQL.getParameterValuesOnlyId());
stefan@2165
   789
        data = execquery.selectAndSearch(ExecuteQuery.SearchType.LAST, "", tableSQL.getKeyColumn());
carlos@0
   790
      } catch (Exception e) { 
stefan@3456
   791
        log4j.error("Error getting last element", e);
carlos@0
   792
      }
stefan@1734
   793
      if (data!=null) return data;
carlos@0
   794
    }
carlos@0
   795
    return "";
carlos@0
   796
  }
carlos@0
   797
stefan@3960
   798
  private void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars<PARAMETER_TMP id="parent">, String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>, TableSQLData tableSQL)
carlos@0
   799
    throws IOException, ServletException {
carlos@0
   800
    if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
carlos@0
   801
carlos@0
   802
    <PARAMETER_TMP id="paramSearchVariables">xx</PARAMETER_TMP>
carlos@0
   803
    boolean hasSearchCondition=false;
carlos@0
   804
    vars.removeEditionData(tabId);
carlos@0
   805
    <FIELDS_TMP id="sectionIsHighVolume4">if (!(<PARAMETER_TMP id="paramSearchName">xx</PARAMETER_TMP>)) hasSearchCondition=true;</FIELDS_TMP>
carlos@0
   806
    String strOffset = vars.getSessionValue(tabId + "|offset");
carlos@0
   807
    String selectedRow = "0";
carlos@0
   808
    if (!str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>.equals("")) {
asier@2769
   809
      selectedRow = Integer.toString(getKeyPosition(vars, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>, tableSQL));
carlos@0
   810
    }
carlos@0
   811
carlos@0
   812
    String[] discard={"isNotFiltered","isNotTest"};
carlos@0
   813
    if (hasSearchCondition) discard[0] = new String("isFiltered");
carlos@0
   814
    if (vars.getSessionValue("#ShowTest", "N").equals("Y")) discard[1] = new String("isTest");
asier@1929
   815
    XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpWindows/<PARAMETER_TMP id="path">Window</PARAMETER_TMP>/<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>_Relation", discard).createXmlDocument();
carlos@0
   816
asier@1929
   817
    ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>", false, "document.frmMain.inp<FIELD_TMP id="keyData">Clave</FIELD_TMP>", "grid", "..<PARAMETER_TMP id="paramReportPDF">xx</PARAMETER_TMP>", "<PARAMETER_TMP id="paramReportDirectPrint">xx</PARAMETER_TMP>".equals("Y"), "<PARAMETER_TMP id="windowName">Window</PARAMETER_TMP>", strReplaceWith, false);
asier@4257
   818
    toolbar.prepareRelationTemplate<PARAMETER_TMP id="sameParent">NoSearch</PARAMETER_TMP>("<PARAMETER_TMP id="paramHasTree">hasTree</PARAMETER_TMP>".equals("Y"), hasSearchCondition, !vars.getSessionValue("#ShowTest", "N").equals("Y"), <PARAMETER_TMP id="paramIsReadOnly">readonly</PARAMETER_TMP>, Utility.getContext(this, vars, "ShowAudit", windowId).equals("Y"));
carlos@0
   819
    xmlDocument.setParameter("toolbar", toolbar.toString());
carlos@0
   820
carlos@0
   821
<PARAMETER_TMP id="parent">    xmlDocument.setParameter("keyParent", strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>);</PARAMETER_TMP>
carlos@0
   822
carlos@0
   823
    StringBuffer orderByArray = new StringBuffer();
carlos@0
   824
      vars.setSessionValue(tabId + "|newOrder", "1");
carlos@0
   825
      String positions = vars.getSessionValue(tabId + "|orderbyPositions");
carlos@0
   826
      orderByArray.append("var orderByPositions = new Array(\n");
carlos@0
   827
      if (!positions.equals("")) {
carlos@0
   828
        StringTokenizer tokens=new StringTokenizer(positions, ",");
carlos@0
   829
        boolean firstOrder = true;
carlos@0
   830
        while(tokens.hasMoreTokens()){
carlos@0
   831
          if (!firstOrder) orderByArray.append(",\n");
carlos@0
   832
          orderByArray.append("\"").append(tokens.nextToken()).append("\"");
carlos@0
   833
          firstOrder = false;
carlos@0
   834
        }
carlos@0
   835
      }
carlos@0
   836
      orderByArray.append(");\n");
carlos@0
   837
      String directions = vars.getSessionValue(tabId + "|orderbyDirections");
carlos@0
   838
      orderByArray.append("var orderByDirections = new Array(\n");
carlos@0
   839
      if (!positions.equals("")) {
carlos@0
   840
        StringTokenizer tokens=new StringTokenizer(directions, ",");
carlos@0
   841
        boolean firstOrder = true;
carlos@0
   842
        while(tokens.hasMoreTokens()){
carlos@0
   843
          if (!firstOrder) orderByArray.append(",\n");
carlos@0
   844
          orderByArray.append("\"").append(tokens.nextToken()).append("\"");
carlos@0
   845
          firstOrder = false;
carlos@0
   846
        }
carlos@0
   847
      }
carlos@0
   848
      orderByArray.append(");\n");
carlos@0
   849
//    }
carlos@0
   850
carlos@0
   851
    xmlDocument.setParameter("selectedColumn", "\nvar selectedRow = " + selectedRow + ";\n" + orderByArray.toString());
juanpablo@1605
   852
    xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
carlos@0
   853
    xmlDocument.setParameter("windowId", windowId);
carlos@0
   854
    xmlDocument.setParameter("KeyName", "<FIELD_TMP id="keyData">Clave</FIELD_TMP>");
juanpablo@1605
   855
    xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
carlos@0
   856
    xmlDocument.setParameter("theme", vars.getTheme());
carlos@0
   857
    //xmlDocument.setParameter("buttonReference", Utility.messageBD(this, "Reference", vars.getLanguage()));
carlos@0
   858
    try {
gorka@1296
   859
      WindowTabs tabs = new WindowTabs(this, vars, tabId, windowId, false);
carlos@0
   860
      xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
carlos@0
   861
      xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
carlos@0
   862
      xmlDocument.setParameter("childTabContainer", tabs.childTabs());
asier@1929
   863
      NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>_Relation.html", "<PARAMETER_TMP id="windowName">Window</PARAMETER_TMP>", "W", strReplaceWith, tabs.breadcrumb());
carlos@0
   864
      xmlDocument.setParameter("navigationBar", nav.toString());
carlos@0
   865
      LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>_Relation.html", strReplaceWith);
carlos@0
   866
      xmlDocument.setParameter("leftTabs", lBar.relationTemplate());
carlos@0
   867
    } catch (Exception ex) {
carlos@0
   868
      throw new ServletException(ex);
carlos@0
   869
    }
carlos@0
   870
    {
carlos@0
   871
      OBError myMessage = vars.getMessage(tabId);
carlos@0
   872
      vars.removeMessage(tabId);
carlos@0
   873
      if (myMessage!=null) {
carlos@0
   874
        xmlDocument.setParameter("messageType", myMessage.getType());
carlos@0
   875
        xmlDocument.setParameter("messageTitle", myMessage.getTitle());
carlos@0
   876
        xmlDocument.setParameter("messageMessage", myMessage.getMessage());
carlos@0
   877
      }
carlos@0
   878
    }
carlos@0
   879
<PARAMETER_TMP id="parent">    if (vars.getLanguage().equals("en_US")) xmlDocument.setParameter("parent", <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data.selectParent(this<FIELD_TMP id="language">, vars.getLanguage()</FIELD_TMP>, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>));
carlos@0
   880
    else xmlDocument.setParameter("parent", <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data.selectParentTrl(this<FIELD_TMP id="language">, vars.getLanguage()</FIELD_TMP>, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>));</PARAMETER_TMP>
carlos@0
   881
carlos@0
   882
    <PARAMETER_TMP id="relationControl"></PARAMETER_TMP>
carlos@0
   883
carlos@0
   884
    response.setContentType("text/html; charset=UTF-8");
carlos@0
   885
    PrintWriter out = response.getWriter();
carlos@0
   886
    out.println(xmlDocument.print());
carlos@0
   887
    out.close();
carlos@0
   888
  }
carlos@0
   889
stefan@3960
   890
  private void printPageEdit(HttpServletResponse response, HttpServletRequest request, VariablesSecureApp vars,boolean boolNew, String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP><PARAMETER_TMP id="parent">, String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, TableSQLData tableSQL)
carlos@0
   891
    throws IOException, ServletException {
carlos@0
   892
    if (log4j.isDebugEnabled()) log4j.debug("Output: edit");
asier@528
   893
    
asier@2770
   894
    HashMap&#60;String, String&#62; usedButtonShortCuts;
asier@2770
   895
  <PARAMETER_TMP id="buttonFixed">
asier@2770
   896
    HashMap&#60;String, String&#62; reservedButtonShortCuts;
asier@2770
   897
  </PARAMETER_TMP>
asier@528
   898
    usedButtonShortCuts = new HashMap&#60;String, String&#62;();
asier@528
   899
    <PARAMETER_TMP id="buttonFixed">
asier@528
   900
    reservedButtonShortCuts = new HashMap&#60;String, String&#62;();
asier@528
   901
    </PARAMETER_TMP>
asier@528
   902
    <PARAMETERS_TMP id="sectionButtonShorcuts">
asier@528
   903
    reservedButtonShortCuts.put("<FIELD_TMP id="fieldButtonSCName"/>","");
asier@528
   904
    </PARAMETERS_TMP>
asier@528
   905
    
carlos@0
   906
    String strOrderByFilter = vars.getSessionValue(tabId + "|orderby");
carlos@0
   907
    String orderClause = "<PARAMETER_TMP id="order">orderByClause</PARAMETER_TMP>";
carlos@0
   908
    if (strOrderByFilter==null || strOrderByFilter.equals("")) strOrderByFilter = orderClause;
carlos@0
   909
    /*{
carlos@0
   910
      if (!strOrderByFilter.equals("") &amp;&amp; !orderClause.equals("")) strOrderByFilter += ", ";
carlos@0
   911
      strOrderByFilter += orderClause;
carlos@0
   912
    }*/
asier@1929
   913
    
asier@1929
   914
    
carlos@0
   915
    String strCommand = null;
carlos@0
   916
    <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data[] data=null;
carlos@0
   917
    XmlDocument xmlDocument=null;
carlos@0
   918
    FieldProvider dataField = vars.getEditionData(tabId);
carlos@0
   919
    vars.removeEditionData(tabId);
carlos@0
   920
    <PARAMETER_TMP id="paramSearchVariables">xx</PARAMETER_TMP>
carlos@0
   921
    boolean hasSearchCondition=false;
carlos@0
   922
    <FIELDS_TMP id="sectionIsHighVolume4">if (!(<PARAMETER_TMP id="paramSearchName">xx</PARAMETER_TMP>)) hasSearchCondition=true;</FIELDS_TMP>
carlos@0
   923
carlos@0
   924
<PARAMETER_TMP id="sectionIsHighVolume4">       String strParamSessionDate = vars.getGlobalVariable("inpParamSessionDate", Utility.getTransactionalDate(this, vars, windowId), "");</PARAMETER_TMP>
carlos@0
   925
      String buscador = "";
carlos@0
   926
      String[] discard = {"", "isNotTest"};
carlos@0
   927
      
carlos@0
   928
      if (vars.getSessionValue("#ShowTest", "N").equals("Y")) discard[1] = new String("isTest");
carlos@0
   929
    if (dataField==null) {
carlos@0
   930
      if (!boolNew) {
carlos@0
   931
        discard[0] = new String("newDiscard");
carlos@0
   932
        <PARAMETER_TMP id="sectionIsHighVolume"><FIELDS_TMP id="sectionIsHighVolume4">
carlos@0
   933
        if (<PARAMETER_TMP id="paramSearchName">xx</PARAMETER_TMP> &amp;&amp; str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>.equals("")) {
asier@1929
   934
          buscador = "openSearchWindow('../businessUtility/Buscador.html', 'BUSCADOR', " + tabId + ", '<PARAMETER_TMP id="windowName">Window</PARAMETER_TMP>/<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>_Relation.html', " + windowId + ");";
carlos@0
   935
        } else if (str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>.equals("")) {
asier@683
   936
          <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data[] data1 = <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data.select(this, vars.getLanguage()<PARAMETER_TMP id="whereClauseParams"></PARAMETER_TMP><FIELDS_TMP id="isTransactional">, strParamTransaccional</FIELDS_TMP><FIELDS_TMP id="sectionFilter">, strParamFilter</FIELDS_TMP><PARAMETER_TMP id="sectionIsHighVolume2Edit">, strParam<PARAMETER_TMP id="searchName2Edit">xx</PARAMETER_TMP></PARAMETER_TMP><PARAMETER_TMP id="sectionIsHighVolume4">, strParamSessionDate, vars.getUser()</PARAMETER_TMP><PARAMETER_TMP id="client">, Utility.getContext(this, vars, "#User_Client", windowId, accesslevel)</PARAMETER_TMP><PARAMETER_TMP id="org">, Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel)</PARAMETER_TMP><PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, strOrderByFilter);
asier@1000
   937
          data = new <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data[1];
carlos@0
   938
          if (data1!=null &#38;&#38; data1.length!=0) data[0] = data1[0];
asier@5239
   939
        } else </FIELDS_TMP></PARAMETER_TMP>data = <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data.selectEdit(this, vars.getSessionValue("#AD_SqlDateTimeFormat"), vars.getLanguage()<PARAMETER_TMP id="whereClauseParams"></PARAMETER_TMP><PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP><PARAMETER_TMP id="client">, Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel)</PARAMETER_TMP>);
carlos@0
   940
  
asier@3527
   941
        if (!str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>.equals("") &amp;&amp; (data == null || data.length==0)) {
asier@3527
   942
          response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
asier@3527
   943
          return;
asier@3527
   944
        }
carlos@0
   945
        refreshSessionEdit(vars, data);
carlos@0
   946
        strCommand = "EDIT";
carlos@0
   947
      }
carlos@0
   948
<FIELDS_TMP id="sectionReadOnly">
carlos@0
   949
      if (data==null || data.length==0) {
asier@2769
   950
        str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = firstElement(vars, tableSQL);
carlos@0
   951
        if (str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>.equals("")) {
carlos@0
   952
          response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
carlos@0
   953
          return;
carlos@0
   954
        } else {
asier@5239
   955
          data = <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data.selectEdit(this, vars.getSessionValue("#AD_SqlDateTimeFormat"), vars.getLanguage()<PARAMETER_TMP id="whereClauseParams"></PARAMETER_TMP><PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP><PARAMETER_TMP id="client">, Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel)</PARAMETER_TMP>);
carlos@0
   956
        }
carlos@0
   957
      }
carlos@0
   958
</FIELDS_TMP>
carlos@0
   959
      if (boolNew || data==null || data.length==0) {
carlos@0
   960
        discard[0] = new String ("editDiscard");
carlos@0
   961
        strCommand = "NEW";
carlos@0
   962
        data = new <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data[0];
carlos@0
   963
      } else {
carlos@0
   964
        discard[0] = new String ("newDiscard");
carlos@0
   965
      }
carlos@0
   966
    } else {
ivan@2072
   967
      if (dataField.getField("<KEY_TMP id="keyData">Almacen</KEY_TMP>") == null || dataField.getField("<KEY_TMP id="keyData">Almacen</KEY_TMP>").equals("")) {
carlos@0
   968
        discard[0] = new String ("editDiscard");
carlos@0
   969
        strCommand = "NEW";
carlos@0
   970
        boolNew = true;
carlos@0
   971
      } else {
carlos@0
   972
        discard[0] = new String ("newDiscard");
carlos@0
   973
        strCommand = "EDIT";
carlos@0
   974
      }
carlos@0
   975
    }
asier@999
   976
    
asier@999
   977
    <LISTS_TMP id="sectionDetailParamsPrevious">    String str<LIST_TMP id="paramNamePrevious">dd</LIST_TMP> = <LIST_TMP id="paramCodePrevious">dd</LIST_TMP>;
asier@999
   978
    vars.setSessionValue(windowId + "|<LIST_TMP id="fieldNameParamPrevious">Almacen</LIST_TMP>", str<LIST_TMP id="paramNamePrevious">dd</LIST_TMP>);
asier@999
   979
    </LISTS_TMP>
asier@3178
   980
    
asier@3178
   981
    if (dataField==null) {
asier@683
   982
      if (boolNew || data==null || data.length==0) {
asier@683
   983
        refreshSessionNew(vars<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);
asier@683
   984
        data = <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data.set(<PARAMETER_TMP id="parent">strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP><PARAMETER_DEFAULT_TMP id="defaultValues">defaults</PARAMETER_DEFAULT_TMP>);
asier@683
   985
        <LISTS_TMP id="sectionDetailDocuments">     data[0].<LIST_TMP id="fieldNameDoc">dd</LIST_TMP> = "&#60;" + <LIST_TMP id="fieldValueDoc">dd</LIST_TMP> + "&#62;";</LISTS_TMP>
asier@683
   986
      }
asier@3178
   987
     }
ivan@2072
   988
      
asier@936
   989
    <PARAMETER_TMP id="parent">String currentPOrg=<PARENT_TMP id="parentClass">Almacen</PARENT_TMP>Data.selectOrg(this, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>);</PARAMETER_TMP>
asier@683
   990
    String currentOrg = (boolNew?"":(dataField!=null?dataField.getField("adOrgId"):data[0].getField("adOrgId")));
juanpablo@1605
   991
    if (!currentOrg.equals("") &amp;&amp; !currentOrg.startsWith("'")) currentOrg = "'"+currentOrg+"'";
asier@683
   992
    String currentClient = (boolNew?"":(dataField!=null?dataField.getField("adClientId"):data[0].getField("adClientId")));
juanpablo@1605
   993
    if (!currentClient.equals("") &amp;&amp; !currentClient.startsWith("'")) currentClient = "'"+currentClient+"'";
asier@683
   994
    
juanpablo@1605
   995
    boolean editableTab = (!org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId) &amp;&amp; (currentOrg.equals("") || Utility.isElementInList(Utility.getContext(this, vars, "#User_Org", windowId, accesslevel),currentOrg)) &amp;&amp; (currentClient.equals("") || Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel), currentClient)));
asier@823
   996
    if (editableTab)
asier@1929
   997
      xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpWindows/<PARAMETER_TMP id="path">Window</PARAMETER_TMP>/<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>_Edition",discard).createXmlDocument();
asier@683
   998
    else
asier@1929
   999
      xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpWindows/<PARAMETER_TMP id="path">Window</PARAMETER_TMP>/<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>_NonEditable",discard).createXmlDocument();
carlos@0
  1000
asier@1929
  1001
    xmlDocument.setParameter("tabId", tabId);
asier@1929
  1002
    ToolBar toolbar = new ToolBar(this, editableTab, vars.getLanguage(), "<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>", (strCommand.equals("NEW") || boolNew || (dataField==null &amp;&amp; (data==null || data.length==0))), "document.frmMain.inp<FIELD_TMP id="keyData">Clave</FIELD_TMP>", "", "..<PARAMETER_TMP id="paramReportPDF">xx</PARAMETER_TMP>", "<PARAMETER_TMP id="paramReportDirectPrint">xx</PARAMETER_TMP>".equals("Y"), "<PARAMETER_TMP id="windowName">Window</PARAMETER_TMP>", strReplaceWith, true, false, false, Utility.hasTabAttachments(this, vars, tabId, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>));
asier@4257
  1003
    toolbar.prepareEditionTemplate<PARAMETER_TMP id="sameParent">NoSearch</PARAMETER_TMP>("<PARAMETER_TMP id="paramHasTree">hasTree</PARAMETER_TMP>".equals("Y"), hasSearchCondition, vars.getSessionValue("#ShowTest", "N").equals("Y"), "<PARAMETER_TMP id="paramUIPattern">readonly</PARAMETER_TMP>", Utility.getContext(this, vars, "ShowAudit", windowId).equals("Y"));
asier@857
  1004
    xmlDocument.setParameter("toolbar", toolbar.toString());
carlos@0
  1005
asier@5302
  1006
    // set updated timestamp to manage locking mechanism
asier@5302
  1007
    if (!boolNew) {
asier@5302
  1008
      xmlDocument.setParameter("updatedTimestamp", (dataField != null ? dataField
asier@5302
  1009
          .getField("updatedTimeStamp") : data[0].getField("updatedTimeStamp")));
asier@5302
  1010
    }
asier@5307
  1011
    
asier@5307
  1012
    boolean concurrentSave = vars.getSessionValue(tabId + "|concurrentSave").equals("true");
asier@5307
  1013
    if (concurrentSave) {
asier@5307
  1014
      //after concurrent save error, force autosave
asier@5307
  1015
      xmlDocument.setParameter("autosave", "Y");
asier@5307
  1016
    } else {
asier@5307
  1017
      xmlDocument.setParameter("autosave", "N");
asier@5307
  1018
    }
asier@5307
  1019
    vars.removeSessionValue(tabId + "|concurrentSave");
asier@5302
  1020
carlos@0
  1021
    try {
ivan@3493
  1022
      WindowTabs tabs = new WindowTabs(this, vars, tabId, windowId, true, (strCommand.equalsIgnoreCase("NEW")));
carlos@0
  1023
      xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
carlos@0
  1024
      xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
ivan@2072
  1025
      // if (!str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>.equals("")) xmlDocument.setParameter("childTabContainer", tabs.childTabs(false));
ivan@2072
  1026
	  // else xmlDocument.setParameter("childTabContainer", tabs.childTabs(true));
ivan@2072
  1027
	  xmlDocument.setParameter("childTabContainer", tabs.childTabs(false));
asier@5307
  1028
      NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>_Relation.html", "<PARAMETER_TMP id="windowName">Window</PARAMETER_TMP>", "W", strReplaceWith, tabs.breadcrumb(), false, !concurrentSave);
carlos@0
  1029
      xmlDocument.setParameter("navigationBar", nav.toString());
carlos@0
  1030
      LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>_Relation.html", strReplaceWith);
asier@892
  1031
      xmlDocument.setParameter("leftTabs", lBar.editionTemplate(strCommand.equals("NEW")));
carlos@0
  1032
    } catch (Exception ex) {
carlos@0
  1033
      throw new ServletException(ex);
carlos@0
  1034
    }
asier@1929
  1035
		
carlos@0
  1036
    <LISTS_TMP id="sectionDetailParams">    xmlDocument.setParameter("<LIST_TMP id="paramName">dd</LIST_TMP>", str<LIST_TMP id="paramName">dd</LIST_TMP>);
carlos@0
  1037
    </LISTS_TMP>
asier@1251
  1038
    <PARAMETER_TMP id="parent">xmlDocument.setParameter("parentOrg", currentPOrg);</PARAMETER_TMP>
carlos@0
  1039
    xmlDocument.setParameter("commandType", strCommand);
carlos@0
  1040
    xmlDocument.setParameter("buscador",buscador);
carlos@0
  1041
    xmlDocument.setParameter("windowId", windowId);
ivan@2072
  1042
    xmlDocument.setParameter("changed", "");
juanpablo@1605
  1043
    xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
carlos@0
  1044
    xmlDocument.setParameter("theme", vars.getTheme());
ivan@3493
  1045
    final String strMappingName = UtilityData.selectObjectMapping(this, tabId);
ivan@3493
  1046
    xmlDocument.setParameter("mappingName", strMappingName);
ivan@2072
  1047
    xmlDocument.setParameter("confirmOnChanges", Utility.getJSConfirmOnChanges(vars, windowId));
carlos@0
  1048
    //xmlDocument.setParameter("buttonReference", Utility.messageBD(this, "Reference", vars.getLanguage()));
carlos@0
  1049
carlos@0
  1050
<PARAMETER_TMP id="sectionIsHighVolume4">    xmlDocument.setParameter("paramSessionDate", strParamSessionDate);</PARAMETER_TMP>
carlos@0
  1051
juanpablo@1605
  1052
    xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
asier@1242
  1053
    OBError myMessage = vars.getMessage(tabId);
asier@1242
  1054
    vars.removeMessage(tabId);
asier@1242
  1055
    if (myMessage!=null) {
asier@1242
  1056
      xmlDocument.setParameter("messageType", myMessage.getType());
asier@1242
  1057
      xmlDocument.setParameter("messageTitle", myMessage.getTitle());
asier@1242
  1058
      xmlDocument.setParameter("messageMessage", myMessage.getMessage());
carlos@0
  1059
    }
asier@853
  1060
    <FIELDS_TMP id="selDisplayLogic">xmlDocument.setParameter("displayLogic", getDisplayLogicContext(vars, boolNew));</FIELDS_TMP>
carlos@0
  1061
    <FIELDS_TMP id="encryptionsFields">
carlos@0
  1062
    //Encrypted fields
carlos@0
  1063
    if (data!=null &amp;&amp; data.length&#62;0) {
carlos@0
  1064
      <FIELDS_TMP id="sectionEncryption">data[0].<FIELD_TMP id="fieldEncryptionName">campo</FIELD_TMP>="";</FIELDS_TMP>
carlos@0
  1065
    }
carlos@0
  1066
    </FIELDS_TMP>
ivan@2072
  1067
    
asier@3178
  1068
     if (dataField==null) {
asier@814
  1069
      xmlDocument.setData("structure1",data);
asier@3178
  1070
      
asier@3178
  1071
    } else {
asier@3178
  1072
      
asier@3178
  1073
        FieldProvider[] dataAux = new FieldProvider[1];
asier@3178
  1074
        dataAux[0] = dataField;
asier@3178
  1075
        
asier@3178
  1076
        xmlDocument.setData("structure1",dataAux);
asier@3178
  1077
      
asier@3178
  1078
    }
asier@3178
  1079
    
asier@814
  1080
      <PARAMETER_TMP id="hasOrgKey">xmlDocument.setParameter("paramCurrentOrgId",data[0].getField("adOrgId"));</PARAMETER_TMP>
ivan@2072
  1081
   
carlos@0
  1082
<PARAMATER_TMP id="fieldControlsJavaCode"></PARAMATER_TMP>
asier@2770
  1083
    xmlDocument.setParameter("scriptOnLoad", getShortcutScript(usedButtonShortCuts<PARAMETER_TMP id="buttonFixed">, reservedButtonShortCuts</PARAMETER_TMP>));
asier@528
  1084
    
ivan@2072
  1085
    final String refererURL = vars.getSessionValue(tabId + "|requestURL");
ivan@2072
  1086
    vars.removeSessionValue(tabId + "|requestURL");
ivan@2072
  1087
    if(!refererURL.equals("")) {
ivan@2072
  1088
    	final Boolean failedAutosave = (Boolean) vars.getSessionObject(tabId + "|failedAutosave");
ivan@2072
  1089
		vars.removeSessionValue(tabId + "|failedAutosave");
ivan@2072
  1090
    	if(failedAutosave != null &amp;&amp; failedAutosave) {
ivan@2072
  1091
    		final String jsFunction = "continueUserAction('"+refererURL+"');";
ivan@2072
  1092
    		xmlDocument.setParameter("failedAutosave", jsFunction);
ivan@2072
  1093
    	}
ivan@2072
  1094
    }
ivan@3493
  1095
ivan@3493
  1096
    if (strCommand.equalsIgnoreCase("NEW")) {
ivan@3493
  1097
      vars.removeSessionValue(strMappingName + "|hash");
ivan@3493
  1098
    }
ivan@3493
  1099
carlos@0
  1100
    response.setContentType("text/html; charset=UTF-8");
carlos@0
  1101
    PrintWriter out = response.getWriter();
carlos@0
  1102
    out.println(xmlDocument.print());
carlos@0
  1103
    out.close();
carlos@0
  1104
  }
carlos@0
  1105
asier@4040
  1106
  void printPageButtonFS(HttpServletResponse response, VariablesSecureApp vars, String strProcessId, String path) throws IOException, ServletException {
asier@4040
  1107
    log4j.debug("Output: Frames action button");
asier@4040
  1108
    response.setContentType("text/html; charset=UTF-8");
asier@4040
  1109
    PrintWriter out = response.getWriter();
asier@4040
  1110
    XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
asier@4040
  1111
        "org/openbravo/erpCommon/ad_actionButton/ActionButtonDefaultFrames").createXmlDocument();
asier@4040
  1112
    xmlDocument.setParameter("processId", strProcessId);
asier@4040
  1113
    xmlDocument.setParameter("trlFormType", "PROCESS");
asier@4040
  1114
    xmlDocument.setParameter("language", "defaultLang = \"" + vars.getLanguage() + "\";\n");
asier@4040
  1115
    xmlDocument.setParameter("type", strDireccion + path);
asier@4040
  1116
    out.println(xmlDocument.print());
asier@4040
  1117
    out.close();
asier@4040
  1118
  }
asier@4040
  1119
carlos@0
  1120
<FIELDS_TMP id="sectionActionButtons2">    void printPageButton<FIELD_TMP id="ButtonRealName2">name</FIELD_TMP><FIELD_TMP id="ProcessID2">xx</FIELD_TMP>(HttpServletResponse response, VariablesSecureApp vars, String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>, String str<FIELD_TMP id="ButtonName2">name</FIELD_TMP>, String strProcessing<FIELD_TMP id="FieldsLoadName2">, strFields</FIELD_TMP>)
carlos@0
  1121
    throws IOException, ServletException {
carlos@0
  1122
      log4j.debug("Output: Button process <FIELD_TMP id="ProcessID2">xx</FIELD_TMP>");
carlos@0
  1123
      String[] discard = {"newDiscard"};
carlos@0
  1124
      response.setContentType("text/html; charset=UTF-8");
carlos@0
  1125
      PrintWriter out = response.getWriter();
carlos@0
  1126
      XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/<FIELD_TMP id="ButtonRealName2">name</FIELD_TMP><FIELD_TMP id="ButtonProcessId2">name</FIELD_TMP>", discard).createXmlDocument();
carlos@0
  1127
      xmlDocument.setParameter("key", str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>);
carlos@0
  1128
      xmlDocument.setParameter("processing", strProcessing);
carlos@0
  1129
      xmlDocument.setParameter("form", "<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>_Edition.html");
carlos@0
  1130
      xmlDocument.setParameter("window", windowId);
carlos@0
  1131
      xmlDocument.setParameter("css", vars.getTheme());
juanpablo@1605
  1132
      xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
juanpablo@1605
  1133
      xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
asier@1929
  1134
      xmlDocument.setParameter("processId", "<FIELD_TMP id="ProcessID2">xx</FIELD_TMP>");
carlos@0
  1135
      xmlDocument.setParameter("cancel", Utility.messageBD(this, "Cancel", vars.getLanguage()));
carlos@0
  1136
      xmlDocument.setParameter("ok", Utility.messageBD(this, "OK", vars.getLanguage()));
carlos@0
  1137
      
carlos@0
  1138
      {
carlos@0
  1139
        OBError myMessage = vars.getMessage("<FIELD_TMP id="ProcessID2">xx</FIELD_TMP>");
carlos@0
  1140
        vars.removeMessage("<FIELD_TMP id="ProcessID2">xx</FIELD_TMP>");
carlos@0
  1141
        if (myMessage!=null) {
carlos@0
  1142
          xmlDocument.setParameter("messageType", myMessage.getType());
carlos@0
  1143
          xmlDocument.setParameter("messageTitle", myMessage.getTitle());
carlos@0
  1144
          xmlDocument.setParameter("messageMessage", myMessage.getMessage());
carlos@0
  1145
        }
carlos@0
  1146
      }
carlos@0
  1147
carlos@0
  1148
      <FIELD_TMP id="JavaCode2">javaCode</FIELD_TMP>
asier@528
  1149
      
carlos@0
  1150
      out.println(xmlDocument.print());
carlos@0
  1151
      out.close();
carlos@0
  1152
    }
carlos@0
  1153
</FIELDS_TMP>
carlos@0
  1154
asier@3907
  1155
<FIELDS_TMP id="sectionActionButtons2java">    void printPageButton<FIELD_TMP id="ButtonRealName2j">name</FIELD_TMP><FIELD_TMP id="ProcessID2j">xx</FIELD_TMP>(HttpServletResponse response, VariablesSecureApp vars, String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>, String str<FIELD_TMP id="ButtonName2j">name</FIELD_TMP>, String strProcessing<FIELD_TMP id="FieldsLoadName2j">, strFields</FIELD_TMP>)
asier@3907
  1156
    throws IOException, ServletException {
asier@3907
  1157
      log4j.debug("Output: Button process <FIELD_TMP id="ProcessID2j">xx</FIELD_TMP>");
asier@3907
  1158
      String[] discard = {"newDiscard"};
asier@3907
  1159
      response.setContentType("text/html; charset=UTF-8");
asier@3907
  1160
      PrintWriter out = response.getWriter();
asier@3907
  1161
      XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/<FIELD_TMP id="ButtonRealName2j">name</FIELD_TMP><FIELD_TMP id="ButtonProcessId2j">name</FIELD_TMP>", discard).createXmlDocument();
asier@3907
  1162
      xmlDocument.setParameter("key", str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>);
asier@3907
  1163
      xmlDocument.setParameter("processing", strProcessing);
asier@3907
  1164
      xmlDocument.setParameter("form", "<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>_Edition.html");
asier@3907
  1165
      xmlDocument.setParameter("window", windowId);
asier@3907
  1166
      xmlDocument.setParameter("css", vars.getTheme());
asier@3907
  1167
      xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
asier@3907
  1168
      xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
asier@3907
  1169
      xmlDocument.setParameter("processId", "<FIELD_TMP id="ProcessID2j">xx</FIELD_TMP>");
asier@3907
  1170
      xmlDocument.setParameter("cancel", Utility.messageBD(this, "Cancel", vars.getLanguage()));
asier@3907
  1171
      xmlDocument.setParameter("ok", Utility.messageBD(this, "OK", vars.getLanguage()));
asier@3907
  1172
      
asier@3907
  1173
      {
asier@3907
  1174
        OBError myMessage = vars.getMessage("<FIELD_TMP id="ProcessID2j">xx</FIELD_TMP>");
asier@3907
  1175
        vars.removeMessage("<FIELD_TMP id="ProcessID2j">xx</FIELD_TMP>");
asier@3907
  1176
        if (myMessage!=null) {
asier@3907
  1177
          xmlDocument.setParameter("messageType", myMessage.getType());
asier@3907
  1178
          xmlDocument.setParameter("messageTitle", myMessage.getTitle());
asier@3907
  1179
          xmlDocument.setParameter("messageMessage", myMessage.getMessage());
asier@3907
  1180
        }
asier@3907
  1181
      }
asier@3907
  1182
asier@3907
  1183
      <FIELD_TMP id="JavaCode2j">javaCode</FIELD_TMP>
asier@3907
  1184
      
asier@3907
  1185
      out.println(xmlDocument.print());
asier@3907
  1186
      out.close();
asier@3907
  1187
    }
asier@3907
  1188
</FIELDS_TMP>
asier@3907
  1189
stefan@3960
  1190
<FIELDS_TMP id="selDisplayLogic">    private String getDisplayLogicContext(VariablesSecureApp vars, boolean isNew) throws IOException, ServletException {
carlos@0
  1191
      log4j.debug("Output: Display logic context fields");
carlos@0
  1192
      String result = "<PARAMETER_TMP id="paramDisplayLogic">xx</PARAMETER_TMP>";
carlos@0
  1193
      return result;
carlos@0
  1194
    }
carlos@0
  1195
</FIELDS_TMP>
carlos@0
  1196
stefan@3960
  1197
<FIELDS_TMP id="selReadOnlyLogic">    private String getReadOnlyLogicContext(VariablesSecureApp vars) throws IOException, ServletException {
asier@227
  1198
      log4j.debug("Output: Read Only logic context fields");
asier@227
  1199
      String result = "<PARAMETER_TMP id="paramReadOnlyLogic">xx</PARAMETER_TMP>";
asier@227
  1200
      return result;
asier@227
  1201
    }
asier@227
  1202
</FIELDS_TMP>
asier@227
  1203
asier@2749
  1204
<FIELDS_TMP id="sectionEncrypted2">    void printPageButton<FIELD_TMP id="EncryptedRealName2">name</FIELD_TMP>(HttpServletRequest request, HttpServletResponse response, VariablesSecureApp vars, String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP><PARAMETER_TMP id="parent">, String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>)
carlos@0
  1205
    throws IOException, ServletException {
carlos@0
  1206
      log4j.debug("Output: Button Encrypted <FIELD_TMP id="EncryptedRealName2">xx</FIELD_TMP>");
carlos@0
  1207
      response.setContentType("text/html; charset=UTF-8");
carlos@0
  1208
      PrintWriter out = response.getWriter();
carlos@0
  1209
      XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/EncryptedButtons").createXmlDocument();
carlos@0
  1210
asier@3984
  1211
      if (<PARENT_TMP id="class">Almacen</PARENT_TMP>Data.check<FIELD_TMP id="EncryptedUpdateName2">button</FIELD_TMP>(this, str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>).equals("0")) {
asier@2749
  1212
        bdErrorGeneralPopUp(request, response,Utility.messageBD(this,"Error", vars.getLanguage()),Utility.messageBD(this,"SaveAndTry", vars.getLanguage()));
asier@433
  1213
      } else {
asier@433
  1214
        xmlDocument.setParameter("theme", vars.getTheme());
asier@433
  1215
        xmlDocument.setParameter("realName", "<FIELD_TMP id="EncryptedName2">name</FIELD_TMP>");
asier@433
  1216
        xmlDocument.setParameter("key", str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>);
asier@433
  1217
        xmlDocument.setParameter("keyName", "<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>");
asier@433
  1218
        xmlDocument.setParameter("form", "<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>_Edition.html");
asier@433
  1219
        xmlDocument.setParameter("fieldId", "<FIELD_TMP id="EncryptedFieldID2">Almacen</FIELD_TMP>");
asier@433
  1220
        xmlDocument.setParameter("fieldLabel", Utility.messageBD(this, "<FIELD_TMP id="EncryptedName2">Almacen</FIELD_TMP>", vars.getLanguage()));
asier@433
  1221
        xmlDocument.setParameter("fieldColumnName", "<FIELD_TMP id="EncryptedName2">Almacen</FIELD_TMP>");
asier@433
  1222
        <PARAMETER_TMP id="parent">      xmlDocument.setParameter("parentKey", strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>);
asier@433
  1223
        xmlDocument.setParameter("parentKeyName", "<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");
asier@433
  1224
        </PARAMETER_TMP>
juanpablo@1605
  1225
        xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
juanpablo@1605
  1226
        xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
asier@433
  1227
        xmlDocument.setParameter("cancel", Utility.messageBD(this, "Cancel", vars.getLanguage()));
asier@433
  1228
        xmlDocument.setParameter("ok", Utility.messageBD(this, "OK", vars.getLanguage()));
asier@433
  1229
  
asier@433
  1230
        out.println(xmlDocument.print());
asier@433
  1231
      }
carlos@0
  1232
      out.close();
carlos@0
  1233
    }
carlos@0
  1234
</FIELDS_TMP>
carlos@0
  1235
asier@528
  1236
 
asier@2770
  1237
  private String getShortcutScript( HashMap&#60;String, String&#62; usedButtonShortCuts<PARAMETER_TMP id="buttonFixed">, HashMap&#60;String, String&#62; reservedButtonShortCuts</PARAMETER_TMP>){
asier@528
  1238
    StringBuffer shortcuts = new StringBuffer();
asier@528
  1239
    shortcuts.append(" function buttonListShorcuts() {\n");
asier@528
  1240
    Iterator&lt;String&gt; ik = usedButtonShortCuts.keySet().iterator();
asier@528
  1241
    Iterator&lt;String&gt; iv = usedButtonShortCuts.values().iterator();
asier@528
  1242
    while(ik.hasNext() &amp;&amp; iv.hasNext()){
asier@528
  1243
      shortcuts.append("  keyArray[keyArray.length] = new keyArrayItem(\"").append(ik.next()).append("\", \"").append(iv.next()).append("\", null, \"altKey\", false, \"onkeydown\");\n");
asier@528
  1244
    }
asier@528
  1245
    shortcuts.append(" return true;\n}");
asier@528
  1246
    return shortcuts.toString();
asier@528
  1247
  }
ivan@2072
  1248
  
ivan@2072
  1249
  private int saveRecord(VariablesSecureApp vars, OBError myError, char type<PARAMETER_TMP id="parent">, String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>) throws IOException, ServletException {
ivan@2072
  1250
    <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data data = null;
ivan@2072
  1251
    int total = 0;
ivan@2072
  1252
    if (org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)) {
ivan@2072
  1253
        OBError newError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
ivan@2072
  1254
        myError.setError(newError);
ivan@2072
  1255
        vars.setMessage(tabId, myError);
ivan@2072
  1256
    }
ivan@2072
  1257
    else {
asier@2171
  1258
        Connection con = null;
ivan@2072
  1259
        try {
asier@2171
  1260
            con = this.getTransactionConnection();
asier@5241
  1261
            data = getEditVariables(con, vars<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);
asier@5241
  1262
            data.dateTimeFormat = vars.getSessionValue("#AD_SqlDateTimeFormat");            
ivan@2072
  1263
            String strSequence = "";
ivan@2072
  1264
            if(type == 'I') {                
ivan@2072
  1265
<PARAMETER_TMP id="keySequence">        strSequence = SequenceIdData.getUUID();
ivan@2072
  1266
                if(log4j.isDebugEnabled()) log4j.debug("Sequence: " + strSequence);
ivan@2072
  1267
                data.<KEY_TMP id="keyData">Almacen</KEY_TMP> = strSequence;</PARAMETER_TMP>  
ivan@2072
  1268
            }
ivan@2072
  1269
            <PARAMETER_TMP id="client">if (Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel),data.adClientId) <FIELDS_TMP id="sectionOrganizationCheck"> &amp;&amp; Utility.isElementInList(Utility.getContext(this, vars, "#User_Org", windowId, accesslevel),data.adOrgId)</FIELDS_TMP>){</PARAMETER_TMP>
asier@5303
  1270
		     if(type == 'I') {
asier@5303
  1271
		       total = data.insert(con, this);
asier@5303
  1272
		     } else {
asier@5303
  1273
		       //Check the version of the record we are saving is the one in DB
asier@5303
  1274
		       if (<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data.getCurrentDBTimestamp(this, data.<KEY_TMP id="keyData">Almacen</KEY_TMP>).equals(
asier@5303
  1275
                vars.getStringParameter("updatedTimestamp"))) {
asier@5303
  1276
                total = data.update(con, this);
asier@5303
  1277
               } else {
asier@5303
  1278
                 myError.setMessage(Replace.replace(Replace.replace(Utility.messageBD(this,
asier@5303
  1279
                    "SavingModifiedRecord", vars.getLanguage()), "\\n", "&lt;br/&gt;"), "&amp;quot;", "\""));
asier@5303
  1280
                 myError.setType("Error");
asier@5307
  1281
                 vars.setSessionValue(tabId + "|concurrentSave", "true");
asier@5303
  1282
               } 
asier@5303
  1283
		     }		            
ivan@2072
  1284
          <PARAMETER_TMP id="client">
ivan@2072
  1285
            }
ivan@2072
  1286
                else {
ivan@2072
  1287
            OBError newError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
ivan@2072
  1288
            myError.setError(newError);            
ivan@2072
  1289
          }</PARAMETER_TMP>
asier@2171
  1290
          releaseCommitConnection(con);
asier@2171
  1291
        } catch(Exception ex) {
ivan@2072
  1292
            OBError newError = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
asier@2171
  1293
            myError.setError(newError);   
asier@2171
  1294
            try {
asier@2171
  1295
              releaseRollbackConnection(con);
asier@2171
  1296
            } catch (final Exception e) { //do nothing 
asier@2171
  1297
            }           
ivan@2072
  1298
        }
ivan@2072
  1299
            
ivan@2072
  1300
        if (myError.isEmpty() &amp;&amp; total == 0) {
ivan@2072
  1301
            OBError newError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=DBExecuteError");
ivan@2072
  1302
            myError.setError(newError);
ivan@2072
  1303
        }
ivan@2072
  1304
        vars.setMessage(tabId, myError);
ivan@2072
  1305
            
ivan@2072
  1306
        if(!myError.isEmpty()){
ivan@2072
  1307
            if(data != null ) {
ivan@2072
  1308
                if(type == 'I') {            			
ivan@2072
  1309
                    data.<KEY_TMP id="keyData">Almacen</KEY_TMP> = "";
ivan@2072
  1310
                }
ivan@2072
  1311
                else {                    
ivan@2072
  1312
                    <PARAMETERS_TMP id="sectionButtonText">
ivan@2072
  1313
                        //BUTTON TEXT FILLING
ivan@2072
  1314
                    data.<FIELD_TMP id="fieldButtonText"/> = ActionButtonDefaultData.getText(this, vars.getLanguage(), "<FIELD_TMP id="fieldButtonListID"/>", data.getField("<FIELD_TMP id="fieldButtonID"/>"));
ivan@2072
  1315
                    </PARAMETERS_TMP>
ivan@2072
  1316
                }
ivan@2072
  1317
                vars.setEditionData(tabId, data);
ivan@2072
  1318
            }            	
ivan@2072
  1319
        }
ivan@2072
  1320
        else {
ivan@2072
  1321
            vars.setSessionValue(windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", data.<KEY_TMP id="keyData">Almacen</KEY_TMP>);
ivan@2072
  1322
        }
ivan@2072
  1323
    }
ivan@2072
  1324
    return total;
ivan@2072
  1325
  }
asier@528
  1326
carlos@0
  1327
  public String getServletInfo() {
carlos@0
  1328
    return "Servlet <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>. This Servlet was made by Wad constructor";
carlos@0
  1329
  } // End of getServletInfo() method
carlos@0
  1330
}
carlos@0
  1331
</java_TMP>