Exemplo n.º 1
0
  private void init() {
    CPanel panel = new CPanel();
    panel.setLayout(new MigLayout());
    getContentPane().add(panel);

    panel.add(new CLabel(Msg.translate(posPanel.getCtx(), "SalesRep_ID")));

    username =
        new PosTextField(
            Msg.translate(posPanel.getCtx(), "SalesRep_ID"),
            posPanel,
            posPanel.p_pos.getOSK_KeyLayout_ID());

    panel.add(username, "wrap");

    panel.add(new CLabel(Msg.translate(posPanel.getCtx(), "UserPIN")));

    pin =
        new PosTextField(
            Msg.translate(posPanel.getCtx(), "UserPIN"),
            posPanel,
            posPanel.p_pos.getOSNP_KeyLayout_ID());

    panel.add(pin, "");

    AppsAction act = new AppsAction("Ok", KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), false);
    act.setDelegate(this);
    bProcess = (CButton) act.getButton();
    bProcess.setFocusable(false);
    panel.add(bProcess, "h 50!, w 50!");

    pack();
  }
  /** Dynamic Init. - Create GridController & Panel - AD_Column_ID from C_Order */
  public void dynInit() throws Exception {
    // Order Distribution
    MLookup orderL =
        MLookupFactory.get(
            Env.getCtx(),
            m_WindowNo,
            0,
            MColumn.getColumn_ID(MDDOrder.Table_Name, MDDOrder.COLUMNNAME_DD_Order_ID),
            DisplayType.Search);
    fOrder = new VLookup(MDDOrder.COLUMNNAME_DD_Order_ID, true, false, true, orderL);
    lOrder.setText(Msg.translate(Env.getCtx(), MDDOrder.COLUMNNAME_DD_Order_ID));
    fOrder.addVetoableChangeListener(this);
    lOrder.setVisible(false);
    fOrder.setVisible(false);

    MLookup llocator = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, 53950, DisplayType.TableDir);
    fLocator = new VLookup(MLocator.COLUMNNAME_M_Locator_ID, true, false, true, llocator);
    lLocator.setText(Msg.translate(Env.getCtx(), "M_Locator_ID"));
    fLocator.addVetoableChangeListener(this);
    m_M_Locator_ID = fLocator.getValue();

    MLookup llocatorto =
        MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, 53949, DisplayType.TableDir);
    fLocatorTo = new VLookup("M_LocatorTo_ID", false, false, true, llocatorto);
    lLocatorTo.setText(Msg.translate(Env.getCtx(), "M_LocatorTo_ID"));
    fLocatorTo.addVetoableChangeListener(this);
    m_M_LocatorTo_ID = fLocatorTo.getValue();

    //	C_Order.C_BPartner_ID
    MLookup bpL = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, 2762, DisplayType.Search);
    fBPartner = new VLookup("C_BPartner_ID", false, false, true, bpL);
    lBPartner.setText(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
    fBPartner.addVetoableChangeListener(this);
    panel.getStatusBar().setStatusLine(Msg.getMsg(Env.getCtx(), "InventoryMoveGenerateSel"));
  } //	dynInit
Exemplo n.º 3
0
  @Override
  protected void afterAction() {

    super.afterAction();

    if (isIgnoreChange()) {

      SwingTool.setCursorsFromParent(window, false);
      return;
    }

    if (successful()) {

      ADialog.info(
          Env.getWindowNo(getWindow()),
          getWindow(),
          Msg.translate(Env.getCtx(), "Success"),
          getSuccessMsg());
    } else {

      ADialog.error(
          Env.getWindowNo(getWindow()),
          getWindow(),
          Msg.translate(Env.getCtx(), "Error"),
          getErrorMsg());
    }

    SwingTool.setCursorsFromParent(window, false);
  }
  /**
   * Initialize Lookups
   *
   * @return true if OK
   */
  private boolean initLookups() {
    try {
      int AD_Column_ID = COLUMN_S_RESOURCE_S_RESOURCETYPE_ID; // 	S_Resource.S_ResourceType_ID

      fieldResourceType =
          new WSearchEditor(
              MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir),
              Msg.translate(Env.getCtx(), "S_ResourceType_ID"),
              "",
              false,
              false,
              true);

      AD_Column_ID =
          COLUMN_S_RESOURCEASSIGNMENT_S_RESOURCE_ID; //	S_ResourceAssignment.S_Resource_ID

      fieldResource =
          new WSearchEditor(
              MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir),
              Msg.translate(Env.getCtx(), "S_Resource_ID"),
              "",
              false,
              false,
              true);
    } catch (Exception e) {
      log.log(Level.SEVERE, "InfoAssignment.initLookup");
      return false;
    }

    bNew.setImage(ThemeManager.getThemeResource("images/New16.png"));

    return true;
  } // initLookups
Exemplo n.º 5
0
  private boolean dynInit(WButtonEditor button) throws Exception {
    // 获取海外入库单产生的异常
    Vector<Vector> data = getBExceptionData();
    if (data.size() <= 0) {
      // 当卖家海外仓入库单内所有单品状态都变更为"海外仓上架完成"时,将卖家海外仓入库单状态更新为"海外仓入库完成"
      if (m_mTab.getAD_Table_ID() == MOrder.Table_ID) {
        MOrder order = new MOrder(Env.getCtx(), m_mTab.getRecord_ID(), null);
        order.setStatus(MOrder.STATUS_ForeignWarehouseInboundCompleted);
        order.saveEx();
      } else if (m_mTab.getAD_Table_ID() == MWorkOrder.Table_ID) {
        MWorkOrder order = new MWorkOrder(Env.getCtx(), m_mTab.getRecord_ID(), null);
        order.setStatus(MWorkOrder.STATUS_Completed);
        order.saveEx();
      }

      // 不显示业务异常提示窗口
      return false;
    }

    ColumnInfo[] layout =
        new ColumnInfo[] {
          new ColumnInfo(Msg.translate(Env.getCtx(), "WT_ExceptionType"), ".", String.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "WT_ExceptionID"), ".", String.class)
        };
    xTable.prepareTable(layout, "", "", false, "");
    xTable.loadTable(data);
    // 显示业务异常提示窗口
    return true;
  } // dynInit
Exemplo n.º 6
0
 public ChangeVO updateRow(
     int windowNo,
     int AD_Tab_ID,
     int queryResultID,
     int relRowNo,
     Map<String, String> context,
     boolean force) {
   if (context == null || context.size() == 0)
     return new ChangeVO(true, Msg.translate(m_context, "NoContext"));
   ArrayList<String[]> data = m_results.get(queryResultID);
   if (data == null || data.size() == 0)
     return new ChangeVO(true, Msg.translate(m_context, "CachedDataNotFound"));
   UITab tab = getTab(AD_Tab_ID);
   if (tab == null) {
     log.config("Not found AD_Tab_ID=" + AD_Tab_ID);
     return new ChangeVO(true, Msg.translate(m_context, "@NotFound@ @AD_Tab_ID@=" + AD_Tab_ID));
   }
   CContext ctx = new CContext(m_context.entrySet());
   ctx.addWindow(windowNo, context);
   ChangeVO retValue;
   if (force) retValue = tab.saveRow(ctx, windowNo, false, null);
   else retValue = tab.saveRow(ctx, windowNo, false, data.get(relRowNo));
   if (retValue.hasError()) return retValue;
   // Update Results
   String[] dataRow = retValue.rowData.clone();
   data.set(relRowNo, dataRow);
   postProcessChangeVO(retValue, windowNo, context, dataRow, tab);
   retValue.trxInfo = GridTab.getTrxInfo(tab.getTableName(), ctx, windowNo, tab.getTabNo());
   if (retValue.isRefreshAll()) {}
   return retValue;
 }
  private void jbInit() {
    setLayout(new BorderLayout(10, 10));

    JTabbedPane tabbedPane = new JTabbedPane();

    tabbedPane.addTab(
        Msg.translate(Env.getCtx(), "Installed Plugins"), generateInstalledSoftPanel());
    tabbedPane.addTab(
        Msg.translate(Env.getCtx(), "Install new Plugins"), generateRepositoriesPanel());

    add(tabbedPane);
  }
  /**
   * Static Init.
   *
   * <pre>
   *  mainPanel
   *      northPanel
   *      centerPanel
   *          xMatched
   *          xPanel
   *          xMathedTo
   *      southPanel
   *  </pre>
   *
   * @throws Exception
   */
  private void jbInit() throws Exception {
    mainPanel.setLayout(mainLayout);
    northPanel.setLayout(northLayout);

    southPanel.setLayout(southLayout);
    generate.setText(Msg.translate(Env.getCtx(), "XX_PrintSelectedLabels"));
    generate.setEnabled(true);

    markall.setText(Msg.translate(Env.getCtx(), "XX_CheckAll"));
    markall.setEnabled(true);

    centerPanel.setLayout(centerLayout);
    xProductScrollPane.setBorder(xProductBorder);
    xProductScrollPane.setPreferredSize(new Dimension(1024, 350));

    xPanel.setLayout(xLayout);

    mainPanel.add(northPanel, BorderLayout.NORTH);
    mainPanel.add(southPanel, BorderLayout.SOUTH);
    mainPanel.add(centerPanel, BorderLayout.CENTER);
    centerPanel.add(xProductScrollPane, BorderLayout.CENTER);
    xProductScrollPane.getViewport().add(xProductTable, null);

    southPanel.add(
        markall,
        new GridBagConstraints(
            6,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 12, 5, 12),
            0,
            0));
    southPanel.add(
        generate,
        new GridBagConstraints(
            8,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 12, 5, 12),
            0,
            0));
  } //  jbInit*/
Exemplo n.º 9
0
 /**
  * Get Table Name
  *
  * @param ctx context
  * @return table name
  */
 public String getTableName(Properties ctx) {
   if (m_tableName == null) {
     String sql = "SELECT TableName FROM AD_Table WHERE AD_Table_ID=?";
     PreparedStatement pstmt = null;
     try {
       pstmt = DB.prepareStatement(sql, null);
       pstmt.setInt(1, getAD_Table_ID());
       ResultSet rs = pstmt.executeQuery();
       if (rs.next()) {
         m_tableName = rs.getString(1);
       }
       rs.close();
       pstmt.close();
       pstmt = null;
     } catch (Exception e) {
       log.error(sql, e);
     }
     try {
       if (pstmt != null) pstmt.close();
       pstmt = null;
     } catch (Exception e) {
       pstmt = null;
     }
     //	Get Clear Text
     String realName = Msg.translate(ctx, m_tableName + "_ID");
     if (!realName.equals(m_tableName + "_ID")) m_tableName = realName;
   }
   return m_tableName;
 } //	getTableName
Exemplo n.º 10
0
  public static ElementBean getMsg(Properties ctx, String text) {
    String language = Env.getContext(ctx, UdiConstants.LANGUAGE_CTX_PARAM);

    if (language == null || language.trim().length() == 0) {
      language = Language.AD_Language_en_US;
    }

    String msg = Msg.getElement(language, text, true);

    if (msg == null || msg == "") {
      msg = Msg.translate(language, text);
    }

    if (msg == null || msg == "") {
      msg = text;
    }

    int ind = msg.indexOf(Env.NL);
    if (ind != -1) msg = msg.substring(0, ind);

    ElementBean elementBean = new ElementBean();
    elementBean.setColumnName(text);
    elementBean.setDescription(msg);
    elementBean.setHelp(msg);
    elementBean.setName(msg);
    elementBean.setPrintName(msg);

    return elementBean;
  }
Exemplo n.º 11
0
  /** Esta función asocia un medio de publicación existente o nuevo a una acción de mercadeo. */
  protected String doIt() throws Exception {

    X_XX_VMA_MediaType medio = new X_XX_VMA_MediaType(Env.getCtx(), 0, null);
    // X_XX_VMA_MarketingActivity accion = new
    // X_XX_VMA_MarketingActivity(getCtx(),p_XX_VMA_MarketingActivity_ID,null);
    // X_C_Channel canal = new X_C_Channel(getCtx(),Medio,null);
    boolean bool = false;
    // String lista = accion.getXX_VMA_MediaList();
    // System.out.println("el medio es el número "+Medio);
    medio.setXX_VMA_MarketingActivity_ID(p_XX_VMA_MarketingActivity_ID);
    // si no se eligió un medio existente o se introdujo uno nuevo, fracasa el proceso
    // de asociación
    if (Medio == 0 && MedioValue == null) {
      ADialog.error(Env.WINDOW_INFO, null, "Error", Msg.translate(Env.getCtx(), "XX_Media"));
      throw new Exception(Msg.translate(Env.getCtx(), "XX_MediaNot"));
    } // si se eligió un medio existente se asocia a la acción de mercadeo
    else if (Medio != 0 && MedioValue == null) {
      medio.setC_Channel_ID(Medio);
      bool = medio.save();
      if (bool) {
        return Msg.translate(Env.getCtx(), "XX_PubliMedia");
      } else {
        ADialog.error(Env.WINDOW_INFO, null, Msg.translate(Env.getCtx(), "XX_MediaActivity"));
        throw new Exception(Msg.translate(Env.getCtx(), "XX_MediaNot"));
      }
      // si no se eligió un medio existente y se coloco uno nuevo, este se crea
      // primero como un canal de publicación y luego se asocia a la acción de mercadeo
    } else if (Medio == 0 && MedioValue != null) {
      // creación del nuevo medio de publicación
      X_C_Channel canal = new X_C_Channel(Env.getCtx(), 0, null);
      canal.setName(MedioValue);
      canal.save();
      // se asocia el medio de publicación a la acción de mercadeo
      medio.setC_Channel_ID(canal.getC_Channel_ID());
      bool = medio.save();
      if (bool) return Msg.translate(Env.getCtx(), "XX_PubliMedia");
      else {
        ADialog.error(
            Env.WINDOW_INFO, null, "Error", Msg.translate(Env.getCtx(), "XX_MediaActivity"));
        throw new Exception(Msg.translate(Env.getCtx(), "XX_MediaNot"));
      }
    } else {
      ADialog.error(
          Env.WINDOW_INFO, null, "Error", Msg.translate(Env.getCtx(), "XX_ChooseChannel"));
      throw new Exception(Msg.translate(Env.getCtx(), "XX_MediaNot"));
    }
  } // Fin doIt
 public InstallForm(Properties ctx) {
   this.ctx = ctx;
   setTitle(Msg.translate(Env.getCtx(), "Manage Plugins"));
   jbInit();
   load();
   setMinimumSize(new Dimension(600, 400));
   pack();
 }
Exemplo n.º 13
0
  public void initComponents() {
    lblDocumentNo = new Label(Util.cleanAmp(Msg.translate(Env.getCtx(), "DocumentNo")));
    lblDescription = new Label(Msg.translate(Env.getCtx(), "Description"));
    lblDateOrdered = new Label(Msg.translate(Env.getCtx(), "DateOrdered"));
    lblOrderRef = new Label(Msg.translate(Env.getCtx(), "POReference"));
    lblGrandTotal = new Label(Msg.translate(Env.getCtx(), "GrandTotal"));

    txtDocumentNo = new Textbox();
    txtDescription = new Textbox();
    txtOrderRef = new Textbox();

    dateFrom = new Datebox();
    dateTo = new Datebox();

    amountFrom = new NumberBox(false);
    amountTo = new NumberBox(false);

    isSoTrx = new Checkbox();
    isSoTrx.setLabel(Msg.translate(Env.getCtx(), "IsSOTrx"));
    isSoTrx.setChecked(!"N".equals(Env.getContext(Env.getCtx(), p_WindowNo, "IsSOTrx")));
    MLookup lookupBP = MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, 3499, DisplayType.Search);
    editorBPartner =
        new WSearchEditor(
            lookupBP, Msg.translate(Env.getCtx(), "C_BPartner_ID"), "", true, false, true);
    editorBPartner.addValueChangeListener(this);
  }
Exemplo n.º 14
0
  /**
   * Static Init
   *
   * @throws Exception
   */
  private void jbInit() throws Exception {
    Charset[] charsets = Ini.getAvailableCharsets();

    for (int i = 0; i < charsets.length; i++)
      fCharset.appendItem(charsets[i].displayName(), charsets[i]);

    bFile.setLabel(Msg.getMsg(Env.getCtx(), "FileImportFile"));
    bFile.setTooltiptext(Msg.getMsg(Env.getCtx(), "FileImportFileInfo"));
    bFile.addEventListener(Events.ON_CLICK, this);

    fCharset.setMold("select");
    fCharset.setRows(0);
    fCharset.setTooltiptext(Msg.getMsg(Env.getCtx(), "Charset", false));

    info.setValue("   ");

    labelFormat.setValue(Msg.translate(Env.getCtx(), "AD_ImpFormat_ID"));

    pickFormat.setMold("select");
    pickFormat.setRows(0);

    bNext.setTooltiptext(Msg.getMsg(Env.getCtx(), "Next"));
    bNext.setLabel(">");
    bNext.addEventListener(Events.ON_CLICK, this);

    record.setValue("------");

    bPrevious.setTooltiptext(Msg.getMsg(Env.getCtx(), "Previous"));
    bPrevious.setLabel("<");
    bPrevious.addEventListener(Events.ON_CLICK, this);

    northPanel.appendChild(bFile);
    northPanel.appendChild(fCharset);
    northPanel.appendChild(info);
    northPanel.appendChild(labelFormat);
    northPanel.appendChild(pickFormat);
    northPanel.appendChild(bPrevious);
    northPanel.appendChild(record);
    northPanel.appendChild(bNext);

    rawData.setWidth("100%");
    rawData.setCols(80);
    rawData.setRows(MAX_SHOWN_LINES);
    rawData.setHeight("40%");

    previewPanel.setWidth("100%");
    previewPanel.setHeight("58%");
    previewPanel.setStyle("overflow: auto");

    centerPanel.setWidth("100%"); // Elaine 2008/11/07 - fix text area is not expanded in IE7
    centerPanel.setHeight("100%");
    centerPanel.appendChild(rawData);
    centerPanel.appendChild(new Separator());
    centerPanel.appendChild(previewPanel);

    confirmPanel.addActionListener(Events.ON_CLICK, this);
  }
Exemplo n.º 15
0
 public void updateUI() {
   int total = noOfNotice + noOfRequest + noOfWorkflow + noOfUnprocessed;
   windowContainer.setTabTitle(
       0,
       Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Home")) + " (" + total + ")",
       Msg.translate(Env.getCtx(), "AD_Note_ID")
           + " : "
           + noOfNotice
           + ", "
           + Msg.translate(Env.getCtx(), "R_Request_ID")
           + " : "
           + noOfRequest
           + ", "
           + Util.cleanAmp(Msg.getMsg(Env.getCtx(), "WorkflowActivities"))
           + " : "
           + noOfWorkflow
           + (noOfUnprocessed > 0
               ? ", " + Msg.getMsg(Env.getCtx(), "UnprocessedDocs") + " : " + noOfUnprocessed
               : ""));
 }
Exemplo n.º 16
0
  @Override
  protected String doIt() throws Exception {

    String msg = "";
    if (archivo == null) {
      msg = Msg.translate(getCtx(), "File Not Loaded");
    } else {

      if (!archivo.substring(archivo.length() - 4, archivo.length()).equals(".xls")) {
        if (archivo.substring(archivo.length() - 5, archivo.length()).equals(".xlsx")) {
          msg = Msg.translate(getCtx(), "Excel Earlier Format");
          ;
        } else {
          msg = Msg.translate(getCtx(), "Not Excel");
        }
      } else {
        getAllStores();
        msg = readFile();
      }
    }
    return msg;
  }
Exemplo n.º 17
0
  public Vector<String> getStudentColumnNames() {
    Vector<String> columnNames = new Vector<String>();
    columnNames.add(Msg.translate(Env.getCtx(), "IsPaid"));
    columnNames.add(Msg.translate(Env.getCtx(), "Value"));
    columnNames.add(Msg.translate(Env.getCtx(), "Name"));
    columnNames.add(Msg.translate(Env.getCtx(), "Grade"));
    columnNames.add(Msg.translate(Env.getCtx(), "Modality"));
    columnNames.add(Msg.translate(Env.getCtx(), "TransportCode"));
    columnNames.add(Msg.translate(Env.getCtx(), "ChildNo"));

    return columnNames;
  }
Exemplo n.º 18
0
 /**
  * Extended String Representation
  *
  * @param ctx context
  * @return extended info
  */
 public String toStringX(Properties ctx) {
   String in = Msg.getMsg(ctx, "Include");
   String ex = Msg.getMsg(ctx, "Exclude");
   StringBuffer sb = new StringBuffer();
   sb.append(Msg.translate(ctx, "AD_Table_ID"))
       .append("=")
       .append(getTableName(ctx))
       .append(", ")
       .append(Msg.translate(ctx, "Record_ID"))
       .append("=")
       .append(getRecord_ID())
       .append(" - ")
       .append(Msg.translate(ctx, "IsDependentEntities"))
       .append("=")
       .append(isDependentEntities())
       .append(" (")
       .append(Msg.translate(ctx, "IsReadOnly"))
       .append("=")
       .append(super.isReadOnly())
       .append(") - ")
       .append(isExclude() ? ex : in);
   return sb.toString();
 } //	toStringX
Exemplo n.º 19
0
  protected void initForm() {
    loadActivities();

    fAnswerList.setMold("select");

    bZoom.setImage("/images/Zoom16.png");
    bOK.setImage("/images/Ok24.png");

    MLookup lookup = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, 10443, DisplayType.Search);
    fForward =
        new WSearchEditor(lookup, Msg.translate(Env.getCtx(), "AD_User_ID"), "", true, false, true);

    init();
    display(-1);
  }
Exemplo n.º 20
0
 /**
  * *********************************************************************** Get Summary
  *
  * @return Summary of Document
  */
 @Override
 public String getSummary() {
   final StringBuilder sb = new StringBuilder();
   sb.append(getDocumentNo());
   //	: Total Lines = 123.00 (#1)
   sb.append(": ")
       .append(Msg.translate(getCtx(), "ApprovalAmt"))
       .append("=")
       .append(getApprovalAmt())
       .append(" (#")
       .append(getLines(false).length)
       .append(")");
   //	 - Description
   if (getDescription() != null && getDescription().length() > 0)
     sb.append(" - ").append(getDescription());
   return sb.toString();
 } //	getSummary
Exemplo n.º 21
0
  public void onEvent(Event event) throws Exception {
    if (Events.ON_CLICK.equalsIgnoreCase(event.getName())) {
      //	Warehouse/Product
      int only_Warehouse_ID = getOnly_Warehouse_ID();
      int only_Product_ID = getOnly_Product_ID();

      log.config("Only Warehouse_ID=" + only_Warehouse_ID + ", Product_ID=" + only_Product_ID);

      //	Text Entry ok

      if (event.getTarget() == getComponent() && actionText(only_Warehouse_ID, only_Product_ID))
        return;

      //	 Button - Start Dialog

      int M_Locator_ID = 0;

      if (m_value instanceof Integer) M_Locator_ID = ((Integer) m_value).intValue();

      m_mLocator.setOnly_Warehouse_ID(only_Warehouse_ID);
      m_mLocator.setOnly_Product_ID(getOnly_Product_ID());

      WLocatorDialog ld =
          new WLocatorDialog(
              Msg.translate(Env.getCtx(), getColumnName()),
              m_mLocator,
              M_Locator_ID,
              isMandatory(),
              only_Warehouse_ID,
              this.m_WindowNo);

      //	display
      ld.setVisible(true);
      AEnv.showWindow(ld);

      m_mLocator.setOnly_Warehouse_ID(0);

      //	redisplay

      if (!ld.isChanged()) return;
      setValue(ld.getValue(), true);
    }
  }
Exemplo n.º 22
0
  /** Dynamic Init for Price Tab */
  private boolean dynInit() {
    //	Header
    Vector<String> columnNames = new Vector<String>();
    columnNames.add(
        Msg.translate(Env.getCtx(), m_C_BPartner_ID == 0 ? "C_BPartner_ID" : "M_Product_ID"));
    columnNames.add(Msg.translate(Env.getCtx(), "PriceActual"));
    columnNames.add(Msg.translate(Env.getCtx(), "C_Currency_ID"));
    columnNames.add(Msg.translate(Env.getCtx(), "QtyInvoiced"));
    columnNames.add(Msg.translate(Env.getCtx(), "Discount"));
    columnNames.add(Msg.translate(Env.getCtx(), "DocumentNo"));
    columnNames.add(Msg.translate(Env.getCtx(), "DateInvoiced"));
    columnNames.add(Msg.translate(Env.getCtx(), "AD_Org_ID"));

    //	Fill Data
    Vector<Vector<Object>> data = null;
    if (m_C_BPartner_ID == 0) data = queryBPartner(); // 	BPartner of Product
    else data = queryProduct(); // 	Product of BPartner

    //  Table
    m_modelPrice = new ListModelTable(data);
    m_tablePrice.setData(m_modelPrice, columnNames);
    //
    m_tablePrice.setColumnClass(0, String.class, true); //  Product/Partner
    m_tablePrice.setColumnClass(1, Double.class, true); //  Price
    m_tablePrice.setColumnClass(2, String.class, true); //  Currency
    m_tablePrice.setColumnClass(3, Double.class, true); //  Quantity
    m_tablePrice.setColumnClass(4, BigDecimal.class, true); //  Discount (%) to limit precision
    m_tablePrice.setColumnClass(5, String.class, true); //  DocNo
    m_tablePrice.setColumnClass(6, Timestamp.class, true); //  Date
    m_tablePrice.setColumnClass(7, String.class, true); //  Org
    //
    m_tablePrice.autoSize();
    //

    return data.size() != 0;
  } //	dynInit
Exemplo n.º 23
0
 public void configureMiniTable(IMiniTable miniTable) {
   //  create Columns
   miniTable.addColumn("C_Order_ID");
   miniTable.addColumn("AD_Org_ID");
   miniTable.addColumn("C_DocType_ID");
   miniTable.addColumn("DocumentNo");
   miniTable.addColumn("C_BPartner_ID");
   miniTable.addColumn("DateOrdered");
   miniTable.addColumn("TotalLines");
   //
   miniTable.setMultiSelection(true);
   //  set details
   miniTable.setColumnClass(0, IDColumn.class, false, " ");
   miniTable.setColumnClass(1, String.class, true, Msg.translate(Env.getCtx(), "AD_Org_ID"));
   miniTable.setColumnClass(2, String.class, true, Msg.translate(Env.getCtx(), "C_DocType_ID"));
   miniTable.setColumnClass(3, String.class, true, Msg.translate(Env.getCtx(), "DocumentNo"));
   miniTable.setColumnClass(4, String.class, true, Msg.translate(Env.getCtx(), "C_BPartner_ID"));
   miniTable.setColumnClass(5, Timestamp.class, true, Msg.translate(Env.getCtx(), "DateOrdered"));
   miniTable.setColumnClass(6, BigDecimal.class, true, Msg.translate(Env.getCtx(), "TotalLines"));
   //
   miniTable.autoSize();
 }
Exemplo n.º 24
0
  /**
   * Process Alert
   *
   * @param alert alert
   * @return true if processed
   */
  private boolean processAlert(MAlert alert) {
    if (!alert.isValid()) return false;
    log.info("" + alert);

    StringBuffer message = new StringBuffer(alert.getAlertMessage()).append(Env.NL);
    //
    boolean valid = true;
    boolean processed = false;
    ArrayList<File> attachments = new ArrayList<File>();
    MAlertRule[] rules = alert.getRules(false);
    for (int i = 0; i < rules.length; i++) {
      if (i > 0) message.append(Env.NL);
      String trxName = null; // 	assume r/o

      MAlertRule rule = rules[i];
      if (!rule.isValid()) continue;
      log.fine("" + rule);

      //	Pre
      String sql = rule.getPreProcessing();
      if (sql != null && sql.length() > 0) {
        int no = DB.executeUpdate(sql, false, trxName);
        if (no == -1) {
          ValueNamePair error = CLogger.retrieveError();
          rule.setErrorMsg("Pre=" + error.getName());
          m_errors.append("Pre=" + error.getName());
          rule.setIsValid(false);
          rule.save();
          valid = false;
          break;
        }
      } //	Pre

      //	The processing
      sql = rule.getSql(true);
      try {
        String text = null;
        if (MSysConfig.getBooleanValue(
            "ALERT_SEND_ATTACHMENT_AS_XLS", true, Env.getAD_Client_ID(getCtx())))
          text = getExcelReport(rule, sql, trxName, attachments);
        else text = getPlainTextReport(rule, sql, trxName, attachments);
        if (text != null && text.length() > 0) {
          message.append(text);
          processed = true;
        }
      } catch (Exception e) {
        rule.setErrorMsg("Select=" + e.getLocalizedMessage());
        m_errors.append("Select=" + e.getLocalizedMessage());
        rule.setIsValid(false);
        rule.save();
        valid = false;
        break;
      }

      //	Post
      sql = rule.getPostProcessing();
      if (sql != null && sql.length() > 0) {
        int no = DB.executeUpdate(sql, false, trxName);
        if (no == -1) {
          ValueNamePair error = CLogger.retrieveError();
          rule.setErrorMsg("Post=" + error.getName());
          m_errors.append("Post=" + error.getName());
          rule.setIsValid(false);
          rule.save();
          valid = false;
          break;
        }
      } //	Post

      /** Trx */
      if (trxName != null) {
        Trx trx = Trx.get(trxName, false);
        if (trx != null) {
          trx.commit();
          trx.close();
        }
      }
    } //	 for all rules

    //	Update header if error
    if (!valid) {
      alert.setIsValid(false);
      alert.save();
      return false;
    }

    //	Nothing to report
    if (!processed) {
      m_summary.append(alert.getName()).append("=No Result - ");
      return true;
    }

    //
    // Report footer - Date Generated
    DateFormat df = DisplayType.getDateFormat(DisplayType.DateTime);
    message.append("\n\n");
    message
        .append(Msg.translate(getCtx(), "Date"))
        .append(" : ")
        .append(df.format(new Timestamp(System.currentTimeMillis())));

    Collection<Integer> users = alert.getRecipientUsers();
    int countMail = notifyUsers(users, alert.getAlertSubject(), message.toString(), attachments);

    m_summary.append(alert.getName()).append(" (EMails+Notes=").append(countMail).append(") - ");
    return valid;
  } //	processAlert
Exemplo n.º 25
0
/**
 * Based on InfoAssignment written by Jorg Janke
 *
 * @author Niraj Sohun Aug 06, 2007
 *     <p>Zk Port
 * @author Elaine
 * @version InfoAssignment.java Adempiere Swing UI 3.4.1
 */
@Deprecated // replaced with InfoAssignmentWindow IDEMPIERE-325
public class InfoAssignmentPanel extends InfoPanel
    implements EventListener<Event>, ValueChangeListener {
  /** */
  private static final long serialVersionUID = -935642651768066799L;

  private WEditor fieldResourceType;
  private WEditor fieldResource;

  private Button bNew = new Button();

  private Datebox fieldFrom = new Datebox();
  private Datebox fieldTo = new Datebox();

  private Label labelFrom = new Label(Msg.translate(Env.getCtx(), "DateFrom"));
  private Label labelTo = new Label(Msg.translate(Env.getCtx(), "DateTo"));
  private Borderlayout layout;
  private Vbox southBody;

  /** From Clause */
  private static String s_assignmentFROM =
      "S_ResourceAssignment ra, S_ResourceType rt, S_Resource r, C_UOM uom";

  private static String s_assignmentWHERE =
      "ra.IsActive='Y' AND ra.S_Resource_ID=r.S_Resource_ID "
          + "AND r.S_ResourceType_ID=rt.S_ResourceType_ID AND rt.C_UOM_ID=uom.C_UOM_ID";

  /** Array of Column Info */
  private static ColumnInfo[] s_assignmentLayout = {
    new ColumnInfo(" ", "ra.S_ResourceAssignment_ID", IDColumn.class),
    new ColumnInfo(Msg.translate(Env.getCtx(), "S_ResourceType_ID"), "rt.Name", String.class),
    new ColumnInfo(Msg.translate(Env.getCtx(), "S_Resource_ID"), "r.Name", String.class),
    new ColumnInfo(
        Msg.translate(Env.getCtx(), "AssignDateFrom"), "ra.AssignDateFrom", Timestamp.class),
    new ColumnInfo(Msg.translate(Env.getCtx(), "Qty"), "ra.Qty", Double.class),
    new ColumnInfo(Msg.translate(Env.getCtx(), "C_UOM_ID"), "uom.UOMSymbol", String.class),
    new ColumnInfo(Msg.translate(Env.getCtx(), "AssignDateTo"), "ra.AssignDateTo", Timestamp.class),
    new ColumnInfo(Msg.translate(Env.getCtx(), "IsConfirmed"), "ra.IsConfirmed", Boolean.class)
  };

  /**
   * Constructor
   *
   * @param WindowNo WindowNo
   * @param value Query value Name or Value if contains numbers
   * @param multiSelection multiple selection
   * @param whereClause where clause
   */
  public InfoAssignmentPanel(
      int WindowNo, String value, boolean multiSelection, String whereClause) {
    this(WindowNo, value, multiSelection, whereClause, true);
  }

  /**
   * Constructor
   *
   * @param WindowNo WindowNo
   * @param value Query value Name or Value if contains numbers
   * @param multiSelection multiple selection
   * @param whereClause where clause
   */
  public InfoAssignmentPanel(
      int WindowNo, String value, boolean multiSelection, String whereClause, boolean lookup) {
    super(WindowNo, "ra", "S_ResourceAssignment_ID", multiSelection, whereClause, lookup);
    log.info(value);
    setTitle(Msg.getMsg(Env.getCtx(), "InfoAssignment"));

    if (!initLookups()) return;

    statInit();
    initInfo(value, whereClause);

    int no = contentPanel.getRowCount();
    setStatusLine(
        Integer.toString(no) + " " + Msg.getMsg(Env.getCtx(), "SearchRows_EnterQuery"), false);
    setStatusDB(Integer.toString(no));

    p_loadedOK = true;
  } // InfoAssignmentPanel

  /**
   * Initialize Lookups
   *
   * @return true if OK
   */
  private boolean initLookups() {
    try {
      int AD_Column_ID = COLUMN_S_RESOURCE_S_RESOURCETYPE_ID; // 	S_Resource.S_ResourceType_ID

      fieldResourceType =
          new WSearchEditor(
              MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir),
              Msg.translate(Env.getCtx(), "S_ResourceType_ID"),
              "",
              false,
              false,
              true);

      AD_Column_ID =
          COLUMN_S_RESOURCEASSIGNMENT_S_RESOURCE_ID; //	S_ResourceAssignment.S_Resource_ID

      fieldResource =
          new WSearchEditor(
              MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir),
              Msg.translate(Env.getCtx(), "S_Resource_ID"),
              "",
              false,
              false,
              true);
    } catch (Exception e) {
      log.log(Level.SEVERE, "InfoAssignment.initLookup");
      return false;
    }

    bNew.setImage(ThemeManager.getThemeResource("images/New16.png"));

    return true;
  } // initLookups

  /**
   * Static Setup - add fields to parameterPanel.
   *
   * <pre>
   * 		ResourceType	Resource	DateTimeFrom	DateTimeTo	New
   *  </pre>
   */
  private void statInit() {
    fieldFrom.setWidth("180px");
    fieldTo.setWidth("180px");

    bNew.addEventListener(Events.ON_CLICK, this);

    Grid grid = GridFactory.newGridLayout();

    Rows rows = new Rows();
    grid.appendChild(rows);

    Row row = new Row();
    rows.appendChild(row);
    row.appendChild(fieldResourceType.getLabel().rightAlign());
    row.appendChild(fieldResource.getLabel().rightAlign());
    row.appendChild(labelFrom.rightAlign());
    row.appendChild(labelTo.rightAlign());
    row.appendChild(new Label());

    row = new Row();
    rows.appendChild(row);
    row.appendChild(fieldResourceType.getComponent());
    row.appendChild(fieldResource.getComponent());
    Div div = new Div();
    div.setStyle("text-align: right;");
    div.appendChild(fieldFrom);
    row.appendChild(div);
    div = new Div();
    div.setStyle("text-align: right;");
    div.appendChild(fieldTo);
    row.appendChild(div);
    row.appendChild(bNew);

    layout = new Borderlayout();
    layout.setWidth("100%");
    layout.setHeight("100%");
    if (!isLookup()) {
      layout.setStyle("position: absolute");
    }
    this.appendChild(layout);

    North north = new North();
    layout.appendChild(north);
    north.appendChild(grid);

    Center center = new Center();
    layout.appendChild(center);
    div = new Div();
    div.appendChild(contentPanel);
    if (isLookup()) contentPanel.setWidth("99%");
    else contentPanel.setStyle("width: 99%; margin: 0px auto;");
    contentPanel.setVflex(true);
    div.setStyle("width :100%; height: 100%");
    center.appendChild(div);
    div.setVflex("1");
    div.setHflex("1");

    South south = new South();
    layout.appendChild(south);
    southBody = new Vbox();
    southBody.setWidth("100%");
    south.appendChild(southBody);
    southBody.appendChild(confirmPanel);
    southBody.appendChild(new Separator());
    southBody.appendChild(statusBar);
  }

  /**
   * Dynamic Init
   *
   * @param value value
   * @param whereClause where clause
   */
  private void initInfo(String value, String whereClause) {
    //  C_BPartner bp, AD_User c, C_BPartner_Location l, C_Location a

    //	Create Grid

    StringBuilder where = new StringBuilder(s_assignmentWHERE);

    if (whereClause != null && whereClause.length() > 0) where.append(" AND ").append(whereClause);

    prepareTable(
        s_assignmentLayout, s_assignmentFROM, where.toString(), "rt.Name,r.Name,ra.AssignDateFrom");
  } // initInfo

  /** ********************************************************************** */

  /**
   * Event Listener
   *
   * @param e event
   */
  public void onEvent(Event e) {
    //  don't requery if fieldValue and fieldName are empty
    //	return;

    super.onEvent(e);
  } // onEvent

  /** ********************************************************************** */

  /**
   * Get dynamic WHERE part of SQL To be overwritten by concrete classes
   *
   * @return WHERE clause
   */
  protected String getSQLWhere() {
    StringBuilder sql = new StringBuilder();

    Integer S_ResourceType_ID = (Integer) fieldResourceType.getValue();

    if (S_ResourceType_ID != null)
      sql.append(" AND rt.S_ResourceType_ID=").append(S_ResourceType_ID.intValue());

    Integer S_Resource_ID = (Integer) fieldResource.getValue();

    if (S_Resource_ID != null) sql.append(" AND r.S_Resource_ID=").append(S_Resource_ID.intValue());

    Date f = fieldFrom.getValue();
    Timestamp ts = f != null ? new Timestamp(f.getTime()) : null;

    if (ts != null) sql.append(" AND TRUNC(ra.AssignDateFrom)>=").append(DB.TO_DATE(ts, false));

    Date t = fieldTo.getValue();
    ts = t != null ? new Timestamp(t.getTime()) : null;

    if (ts != null) sql.append(" AND TRUNC(ra.AssignDateTo)<=").append(DB.TO_DATE(ts, false));

    return sql.toString();
  } // getSQLWhere

  /**
   * Set Parameters for Query To be overwritten by concrete classes
   *
   * @param pstmt pstmt
   * @param forCount for counting records
   * @throws SQLException
   */
  protected void setParameters(PreparedStatement pstmt, boolean forCount) throws SQLException {}

  /** History dialog To be overwritten by concrete classes */
  protected void showHistory() {}

  /**
   * Has History (false) To be overwritten by concrete classes
   *
   * @return true if it has history (default false)
   */
  protected boolean hasHistory() {
    return false;
  }

  /** Customize dialog To be overwritten by concrete classes */
  protected void customize() {}

  /**
   * Has Customize (false) To be overwritten by concrete classes
   *
   * @return true if it has customize (default false)
   */
  protected boolean hasCustomize() {
    return false;
  }

  /** Zoom action To be overwritten by concrete classes */
  public void zoom() {
    if (getSelectedRowKey() != null && getSelectedRowKey() > 0) {
      MQuery zoomQuery = new MQuery(); //  ColumnName might be changed in MTab.validateQuery
      String column = getKeyColumn();
      // strip off table name, fully qualify name doesn't work when zoom into detail tab
      if (column.indexOf(".") > 0) column = column.substring(column.indexOf(".") + 1);
      zoomQuery.addRestriction(column, MQuery.EQUAL, getSelectedRowKey());
      zoomQuery.setRecordCount(1);
      zoomQuery.setTableName(column.substring(0, column.length() - 3));

      AEnv.zoom(236, zoomQuery);
    }
  }

  /**
   * Has Zoom (false) To be overwritten by concrete classes
   *
   * @return true if it has zoom (default false)
   */
  protected boolean hasZoom() {
    return true;
  }

  /** Save Selection Details To be overwritten by concrete classes */
  protected void saveSelectionDetail() {}

  public void valueChange(ValueChangeEvent evt) {}

  public void tableChanged(WTableModelEvent event) {}

  @Override
  protected void insertPagingComponent() {
    southBody.insertBefore(paging, southBody.getFirstChild());
    layout.invalidate();
  }
}
Exemplo n.º 26
0
  /**
   * Static Init
   *
   * @throws Exception
   */
  private void zkInit() throws Exception {
    //
    form.appendChild(mainPanel);
    mainPanel.appendChild(mainLayout);
    mainPanel.setStyle("width: 100%; height: 100%; padding: 0; margin: 0");
    mainLayout.setHeight("100%");
    mainLayout.setWidth("99%");
    parameterPanel.appendChild(parameterLayout);
    //
    labelBankAccount.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID"));
    fieldBankAccount.addActionListener(this);
    labelBPartner.setText(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
    fieldBPartner.addActionListener(this);
    bRefresh.addActionListener(this);
    labelPayDate.setText(Msg.translate(Env.getCtx(), "PayDate"));
    labelPaymentRule.setText(Msg.translate(Env.getCtx(), "PaymentRule"));
    fieldPaymentRule.addActionListener(this);
    labelDtype.setText(Msg.translate(Env.getCtx(), "C_DocType_ID"));
    fieldDtype.addActionListener(this);
    //
    labelBankBalance.setText(Msg.translate(Env.getCtx(), "CurrentBalance"));
    labelBalance.setText("0");
    onlyDue.setText(Msg.getMsg(Env.getCtx(), "OnlyDue"));
    dataStatus.setText(" ");
    dataStatus.setPre(true);
    //
    bGenerate.addActionListener(this);
    bCancel.addActionListener(this);
    //
    North north = new North();
    north.setStyle("border: none");
    mainLayout.appendChild(north);
    north.appendChild(parameterPanel);

    Rows rows = parameterLayout.newRows();
    Row row = rows.newRow();
    row.appendChild(labelBankAccount.rightAlign());
    row.appendChild(fieldBankAccount);
    row.appendChild(labelBankBalance.rightAlign());
    Panel balancePanel = new Panel();
    balancePanel.appendChild(labelCurrency);
    balancePanel.appendChild(labelBalance);
    row.appendChild(balancePanel);
    row.appendChild(new Space());

    row = rows.newRow();
    row.appendChild(labelBPartner.rightAlign());
    row.appendChild(fieldBPartner);
    row.appendChild(new Space());
    row.appendChild(onlyDue);
    row.appendChild(new Space());

    row = rows.newRow();
    row.appendChild(labelDtype.rightAlign());
    row.appendChild(fieldDtype);
    row.appendChild(new Space());
    row.appendChild(new Space());
    row.appendChild(new Space());

    row = rows.newRow();
    row.appendChild(labelPayDate.rightAlign());
    row.appendChild(fieldPayDate.getComponent());
    row.appendChild(labelPaymentRule.rightAlign());
    row.appendChild(fieldPaymentRule);
    row.appendChild(bRefresh);

    South south = new South();
    south.setStyle("border: none");
    mainLayout.appendChild(south);
    southPanel = new Panel();
    southPanel.appendChild(dataStatus);
    south.appendChild(southPanel);
    Center center = new Center();
    mainLayout.appendChild(center);
    center.appendChild(miniTable);
    //
    commandPanel.addButton(bGenerate);
    commandPanel.getButton(ConfirmPanel.A_OK).setVisible(false);
  } //  jbInit
Exemplo n.º 27
0
  /** Create/Save Account */
  private void action_Save() {
    log.info("");
    /** Check completeness (mandatory fields) ... and for duplicates */
    StringBuffer sb = new StringBuffer();
    StringBuffer sql =
        new StringBuffer("SELECT C_ValidCombination_ID, Alias FROM C_ValidCombination WHERE ");
    Object value = null;
    if (s_AcctSchema.isHasAlias()) {
      value = f_Alias.getValue().toString();
      if (value == null) sb.append(Msg.translate(Env.getCtx(), "Alias")).append(", ");
    }
    MAcctSchemaElement[] elements = s_AcctSchema.getAcctSchemaElements();
    for (int i = 0; i < elements.length; i++) {
      MAcctSchemaElement ase = elements[i];
      String type = ase.getElementType();
      //
      if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Organization)) {
        value = f_AD_Org_ID.getValue();
        sql.append("AD_Org_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Account)) {
        value = f_Account_ID.getValue();
        sql.append("Account_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SubAccount)) {
        value = f_SubAcct_ID.getValue();
        sql.append("C_SubAcct_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Product)) {
        value = f_M_Product_ID.getValue();
        sql.append("M_Product_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_BPartner)) {
        value = f_C_BPartner_ID.getValue();
        sql.append("C_BPartner_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Campaign)) {
        value = f_C_Campaign_ID.getValue();
        sql.append("C_Campaign_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationFrom)) {
        value = f_C_LocFrom_ID.getValue();
        sql.append("C_LocFrom_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationTo)) {
        value = f_C_LocTo_ID.getValue();
        sql.append("C_LocTo_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Project)) {
        value = f_C_Project_ID.getValue();
        sql.append("C_Project_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SalesRegion)) {
        value = f_C_SalesRegion_ID.getValue();
        sql.append("C_SalesRegion_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_OrgTrx)) {
        value = f_AD_OrgTrx_ID.getValue();
        sql.append("AD_OrgTrx_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Activity)) {
        value = f_C_Activity_ID.getValue();
        sql.append("C_Activity_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList1)) {
        value = f_User1_ID.getValue();
        sql.append("User1_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList2)) {
        value = f_User2_ID.getValue();
        sql.append("User2_ID");
        if (value == null) sql.append(" IS NULL AND ");
        else sql.append("=").append(value).append(" AND ");
      }
      //
      if (ase.isMandatory() && value == null) sb.append(ase.getName()).append(", ");
    } //	Fields in Element Order

    if (sb.length() != 0) {
      ADialog.error(m_WindowNo, this, "FillMandatory", sb.substring(0, sb.length() - 2));
      return;
    }
    if (f_AD_Org_ID == null || f_AD_Org_ID.getValue() == null) {
      ADialog.error(m_WindowNo, this, "FillMandatory", Msg.getElement(Env.getCtx(), "AD_Org_ID"));
      return;
    }
    if (f_Account_ID == null || f_Account_ID.getValue() == null) {
      ADialog.error(m_WindowNo, this, "FillMandatory", Msg.getElement(Env.getCtx(), "Account_ID"));
      return;
    }

    /** Check if already exists */
    sql.append("AD_Client_ID=? AND C_AcctSchema_ID=?");
    log.fine("Check = " + sql.toString());
    int IDvalue = 0;
    String Alias = null;
    try {
      PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
      pstmt.setInt(1, m_AD_Client_ID);
      pstmt.setInt(2, s_AcctSchema.getC_AcctSchema_ID());
      ResultSet rs = pstmt.executeQuery();
      if (rs.next()) {
        IDvalue = rs.getInt(1);
        Alias = rs.getString(2);
      }
      rs.close();
      pstmt.close();
    } catch (SQLException e) {
      log.log(Level.SEVERE, sql.toString(), e);
      IDvalue = 0;
    }
    log.fine("ID=" + IDvalue + ", Alias=" + Alias);

    if (Alias == null) Alias = "";

    //	We have an account like this already - check alias
    if (IDvalue != 0 && s_AcctSchema.isHasAlias() && !f_Alias.getValue().toString().equals(Alias)) {
      sql = new StringBuffer("UPDATE C_ValidCombination SET Alias=");
      if (f_Alias.getValue().toString().length() == 0) sql.append("NULL");
      else sql.append("'").append(f_Alias.getValue()).append("'");
      sql.append(" WHERE C_ValidCombination_ID=").append(IDvalue);
      int i = 0;
      try {
        java.sql.PreparedStatement stmt =
            DB.prepareStatement(
                sql.toString(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE, null);
        i = stmt.executeUpdate();
        stmt.close();
      } catch (SQLException e) {
        log.log(Level.SEVERE, sql.toString(), e);
      }
      if (i == 0) ADialog.error(m_WindowNo, this, "AccountNotUpdated");
    }

    //	load and display
    if (IDvalue != 0) {
      loadInfo(IDvalue, s_AcctSchema.getC_AcctSchema_ID());
      action_Find(false);
      return;
    }

    log.config("New");
    Alias = null;
    if (f_Alias != null) Alias = f_Alias.getValue().toString();
    int C_SubAcct_ID = 0;
    if (f_SubAcct_ID != null && f_SubAcct_ID.getValue() != null)
      C_SubAcct_ID = ((Integer) f_SubAcct_ID.getValue()).intValue();
    int M_Product_ID = 0;
    if (f_M_Product_ID != null && f_M_Product_ID.getValue() != null)
      M_Product_ID = ((Integer) f_M_Product_ID.getValue()).intValue();
    int C_BPartner_ID = 0;
    if (f_C_BPartner_ID != null && f_C_BPartner_ID.getValue() != null)
      C_BPartner_ID = ((Integer) f_C_BPartner_ID.getValue()).intValue();
    int AD_OrgTrx_ID = 0;
    if (f_AD_OrgTrx_ID != null && f_AD_OrgTrx_ID.getValue() != null)
      AD_OrgTrx_ID = ((Integer) f_AD_OrgTrx_ID.getValue()).intValue();
    int C_LocFrom_ID = 0;
    if (f_C_LocFrom_ID != null && f_C_LocFrom_ID.getValue() != null)
      C_LocFrom_ID = ((Integer) f_C_LocFrom_ID.getValue()).intValue();
    int C_LocTo_ID = 0;
    if (f_C_LocTo_ID != null && f_C_LocTo_ID.getValue() != null)
      C_LocTo_ID = ((Integer) f_C_LocTo_ID.getValue()).intValue();
    int C_SRegion_ID = 0;
    if (f_C_SalesRegion_ID != null && f_C_SalesRegion_ID.getValue() != null)
      C_SRegion_ID = ((Integer) f_C_SalesRegion_ID.getValue()).intValue();
    int C_Project_ID = 0;
    if (f_C_Project_ID != null && f_C_Project_ID.getValue() != null)
      C_Project_ID = ((Integer) f_C_Project_ID.getValue()).intValue();
    int C_Campaign_ID = 0;
    if (f_C_Campaign_ID != null && f_C_Campaign_ID.getValue() != null)
      C_Campaign_ID = ((Integer) f_C_Campaign_ID.getValue()).intValue();
    int C_Activity_ID = 0;
    if (f_C_Activity_ID != null && f_C_Activity_ID.getValue() != null)
      C_Activity_ID = ((Integer) f_C_Activity_ID.getValue()).intValue();
    int User1_ID = 0;
    if (f_User1_ID != null && f_User1_ID.getValue() != null)
      User1_ID = ((Integer) f_User1_ID.getValue()).intValue();
    int User2_ID = 0;
    if (f_User2_ID != null && f_User2_ID.getValue() != null)
      User2_ID = ((Integer) f_User2_ID.getValue()).intValue();

    MAccount acct =
        MAccount.get(
            Env.getCtx(),
            m_AD_Client_ID,
            ((Integer) f_AD_Org_ID.getValue()).intValue(),
            s_AcctSchema.getC_AcctSchema_ID(),
            ((Integer) f_Account_ID.getValue()).intValue(),
            C_SubAcct_ID,
            M_Product_ID,
            C_BPartner_ID,
            AD_OrgTrx_ID,
            C_LocFrom_ID,
            C_LocTo_ID,
            C_SRegion_ID,
            C_Project_ID,
            C_Campaign_ID,
            C_Activity_ID,
            User1_ID,
            User2_ID,
            0,
            0);
    if (acct != null && acct.get_ID() == 0) acct.save();

    //  Show Info
    if (acct == null || acct.get_ID() == 0) loadInfo(0, 0);
    else {
      //	Update Account with optional Alias
      if (Alias != null && Alias.length() > 0) {
        acct.setAlias(Alias);
        acct.save();
      }
      loadInfo(acct.get_ID(), s_AcctSchema.getC_AcctSchema_ID());
    }
    action_Find(false);
  } //	action_Save
Exemplo n.º 28
0
 /**
  * Get Product Layout
  *
  * @return array of Column_Info
  */
 protected Info_Column[] getProductLayout() {
   if (s_productLayout != null) return s_productLayout;
   //
   if (s_productLayout == null) {
     ArrayList<Info_Column> list = new ArrayList<Info_Column>();
     list.add(new Info_Column(" ", "p.M_Product_ID", IDColumn.class, !p_multiSelection));
     list.add(
         new Info_Column(
             Msg.translate(Env.getCtx(), "Discontinued").substring(0, 1),
             "p.Discontinued",
             Boolean.class));
     list.add(new Info_Column(Msg.translate(Env.getCtx(), "Value"), "p.Value", String.class));
     list.add(new Info_Column(Msg.translate(Env.getCtx(), "Name"), "p.Name", String.class));
     list.add(
         new Info_Column(
             Msg.translate(Env.getCtx(), "QtyAvailable"),
             "case when p.IsBOM='N' and (p.ProductType!='I' OR p.IsStocked='N') then to_number(get_Sysconfig('QTY_TO_SHOW_FOR_SERVICES', '99999', p.ad_client_id, 0), '99999999999') else bomQtyAvailable(p.M_Product_ID,?,0) end AS QtyAvailable",
             Double.class,
             true,
             true,
             null));
     list.add(
         new Info_Column(
             Msg.translate(Env.getCtx(), "PriceList"),
             "bomPriceList(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceList",
             BigDecimal.class));
     list.add(
         new Info_Column(
             Msg.translate(Env.getCtx(), "PriceStd"),
             "bomPriceStd(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceStd",
             BigDecimal.class));
     list.add(
         new Info_Column(
             Msg.translate(Env.getCtx(), "QtyOnHand"),
             "case when p.IsBOM='N' and (p.ProductType!='I' OR p.IsStocked='N') then to_number(get_Sysconfig('QTY_TO_SHOW_FOR_SERVICES', '99999', p.ad_client_id, 0), '99999999999') else bomQtyOnHand(p.M_Product_ID,?,0) end AS QtyOnHand",
             Double.class));
     list.add(
         new Info_Column(
             Msg.translate(Env.getCtx(), "QtyReserved"),
             "bomQtyReserved(p.M_Product_ID,?,0) AS QtyReserved",
             Double.class));
     list.add(
         new Info_Column(
             Msg.translate(Env.getCtx(), "QtyOrdered"),
             "bomQtyOrdered(p.M_Product_ID,?,0) AS QtyOrdered",
             Double.class));
     if (isUnconfirmed()) {
       list.add(
           new Info_Column(
               Msg.translate(Env.getCtx(), "QtyUnconfirmed"),
               "(SELECT SUM(c.TargetQty) FROM M_InOutLineConfirm c INNER JOIN M_InOutLine il ON (c.M_InOutLine_ID=il.M_InOutLine_ID) INNER JOIN M_InOut i ON (il.M_InOut_ID=i.M_InOut_ID) WHERE c.Processed='N' AND i.M_Warehouse_ID=? AND il.M_Product_ID=p.M_Product_ID) AS QtyUnconfirmed",
               Double.class));
       list.add(
           new Info_Column(
               Msg.translate(Env.getCtx(), "QtyUnconfirmedMove"),
               "(SELECT SUM(c.TargetQty) FROM M_MovementLineConfirm c INNER JOIN M_MovementLine ml ON (c.M_MovementLine_ID=ml.M_MovementLine_ID) INNER JOIN M_Locator l ON (ml.M_LocatorTo_ID=l.M_Locator_ID) WHERE c.Processed='N' AND l.M_Warehouse_ID=? AND ml.M_Product_ID=p.M_Product_ID) AS QtyUnconfirmedMove",
               Double.class));
     }
     list.add(
         new Info_Column(
             Msg.translate(Env.getCtx(), "Margin"),
             "bomPriceStd(p.M_Product_ID, pr.M_PriceList_Version_ID)-bomPriceLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS Margin",
             BigDecimal.class));
     list.add(new Info_Column(Msg.translate(Env.getCtx(), "Vendor"), "bp.Name", String.class));
     list.add(
         new Info_Column(
             Msg.translate(Env.getCtx(), "PriceLimit"),
             "bomPriceLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceLimit",
             BigDecimal.class));
     list.add(
         new Info_Column(
             Msg.translate(Env.getCtx(), "IsInstanceAttribute"),
             "pa.IsInstanceAttribute",
             Boolean.class));
     s_productLayout = new Info_Column[list.size()];
     list.toArray(s_productLayout);
     INDEX_NAME = 3;
     INDEX_PATTRIBUTE = s_productLayout.length - 1; // 	last item
   }
   return s_productLayout;
 } //  getProductLayout
Exemplo n.º 29
0
  /** Static Setup - add fields to parameterPanel */
  private void statInit() {
    labelValue.setText(Msg.getMsg(Env.getCtx(), "Value"));
    fieldValue.setBackground(AdempierePLAF.getInfoBackground());
    fieldValue.addActionListener(this);

    labelName.setText(Msg.getMsg(Env.getCtx(), "Name"));
    fieldName.setBackground(AdempierePLAF.getInfoBackground());
    fieldName.addActionListener(this);

    labelUPC.setText(Msg.translate(Env.getCtx(), "UPC"));
    fieldUPC.setBackground(AdempierePLAF.getInfoBackground());
    fieldUPC.addActionListener(this);

    labelSKU.setText(Msg.translate(Env.getCtx(), "SKU"));
    fieldSKU.setBackground(AdempierePLAF.getInfoBackground());
    fieldSKU.addActionListener(this);

    labelWarehouse.setText(Msg.getMsg(Env.getCtx(), "Warehouse"));
    pickWarehouse.setBackground(AdempierePLAF.getInfoBackground());

    labelPriceList.setText(Msg.getMsg(Env.getCtx(), "PriceListVersion"));
    pickPriceList.setBackground(AdempierePLAF.getInfoBackground());

    labelProductCategory.setText(Msg.translate(Env.getCtx(), "M_Product_Category_ID"));
    pickProductCategory.setBackground(AdempierePLAF.getInfoBackground());

    // @Trifon
    labelAS.setText(Msg.translate(Env.getCtx(), "M_AttributeSet_ID"));
    pickAS.setBackground(AdempierePLAF.getInfoBackground());

    m_InfoPAttributeButton.setMargin(new Insets(2, 2, 2, 2));
    m_InfoPAttributeButton.setToolTipText(Msg.getMsg(Env.getCtx(), "InfoPAttribute"));
    m_InfoPAttributeButton.addActionListener(this);

    labelVendor.setText(Msg.translate(Env.getCtx(), "Vendor"));
    fieldVendor.setBackground(AdempierePLAF.getInfoBackground());
    fieldVendor.addActionListener(this);

    //	Line 1
    parameterPanel.setLayout(new ALayout());
    parameterPanel.add(labelValue, new ALayoutConstraint(0, 0));
    parameterPanel.add(fieldValue, null);
    parameterPanel.add(labelUPC, null);
    parameterPanel.add(fieldUPC, null);
    parameterPanel.add(labelWarehouse, null);
    parameterPanel.add(pickWarehouse, null);
    parameterPanel.add(m_InfoPAttributeButton);
    //	Line 2
    parameterPanel.add(labelName, new ALayoutConstraint(1, 0));
    parameterPanel.add(fieldName, null);
    parameterPanel.add(labelSKU, null);
    parameterPanel.add(fieldSKU, null);
    parameterPanel.add(labelVendor, null);
    parameterPanel.add(fieldVendor, null);

    // Line 3
    parameterPanel.add(labelPriceList, new ALayoutConstraint(2, 0));
    parameterPanel.add(pickPriceList, null);
    parameterPanel.add(labelProductCategory, null);
    parameterPanel.add(pickProductCategory, null);
    parameterPanel.add(labelAS, null); // @Trifon
    parameterPanel.add(pickAS, null); // @Trifon

    //	Product Attribute Instance
    m_PAttributeButton = ConfirmPanel.createPAttributeButton(true);
    confirmPanel.addButton(m_PAttributeButton);
    m_PAttributeButton.addActionListener(this);
    m_PAttributeButton.setEnabled(false);

    // Begin - fer_luck @ centuryon
    // add taskpane
    fieldDescription.setBackground(AdempierePLAF.getInfoBackground());
    fieldDescription.setEditable(false);
    fieldDescription.setPreferredSize(new Dimension(INFO_WIDTH - 100, 100));

    warehouseStockPanel.setTitle(Msg.translate(Env.getCtx(), "WarehouseStock"));
    warehouseStockPanel.setUI(new AdempiereTaskPaneUI());
    warehouseStockPanel.getContentPane().setBackground(new ColorUIResource(251, 248, 241));
    warehouseStockPanel.getContentPane().setForeground(new ColorUIResource(251, 0, 0));

    ColumnInfo[] s_layoutWarehouse =
        new ColumnInfo[] {
          new ColumnInfo(Msg.translate(Env.getCtx(), "Warehouse"), "Warehouse", String.class),
          new ColumnInfo(
              Msg.translate(Env.getCtx(), "QtyAvailable"), "sum(QtyAvailable)", Double.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "sum(QtyOnHand)", Double.class),
          new ColumnInfo(
              Msg.translate(Env.getCtx(), "QtyReserved"), "sum(QtyReserved)", Double.class),
          new ColumnInfo(
              Msg.translate(Env.getCtx(), "QtyAllocated"), "sum(QtyAllocated)", Double.class)
        };
    /** From Clause */
    String s_sqlFrom = " M_PRODUCT_STOCK_V ";
    /** Where Clause */
    String s_sqlWhere = "Value = ?";
    m_sqlWarehouse =
        warehouseTbl.prepareTable(
            s_layoutWarehouse, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_STOCK_V");
    m_sqlWarehouse += " Group By Warehouse, documentnote ";
    warehouseTbl.setRowSelectionAllowed(true);
    warehouseTbl.setMultiSelection(false);
    warehouseTbl.addMouseListener(this);
    warehouseTbl.getSelectionModel().addListSelectionListener(this);
    warehouseTbl.setShowTotals(true);
    warehouseTbl.autoSize();

    ColumnInfo[] s_layoutSubstitute =
        new ColumnInfo[] {
          new ColumnInfo(Msg.translate(Env.getCtx(), "Warehouse"), "orgname", String.class),
          new ColumnInfo(
              Msg.translate(Env.getCtx(), "Value"),
              "(Select Value from M_Product p where p.M_Product_ID=M_PRODUCT_SUBSTITUTERELATED_V.Substitute_ID)",
              String.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "QtyAvailable", Double.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "QtyOnHand", Double.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "QtyReserved", Double.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "PriceStd"), "PriceStd", Double.class)
        };
    s_sqlFrom = "M_PRODUCT_SUBSTITUTERELATED_V";
    s_sqlWhere = "M_Product_ID = ? AND M_PriceList_Version_ID = ? and RowType = 'S'";
    m_sqlSubstitute =
        substituteTbl.prepareTable(
            s_layoutSubstitute, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_SUBSTITUTERELATED_V");
    substituteTbl.setRowSelectionAllowed(false);
    substituteTbl.setMultiSelection(false);
    substituteTbl.addMouseListener(this);
    substituteTbl.getSelectionModel().addListSelectionListener(this);
    substituteTbl.autoSize();

    ColumnInfo[] s_layoutRelated =
        new ColumnInfo[] {
          new ColumnInfo(Msg.translate(Env.getCtx(), "Warehouse"), "orgname", String.class),
          new ColumnInfo(
              Msg.translate(Env.getCtx(), "Value"),
              "(Select Value from M_Product p where p.M_Product_ID=M_PRODUCT_SUBSTITUTERELATED_V.Substitute_ID)",
              String.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "QtyAvailable", Double.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "QtyOnHand", Double.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "QtyReserved", Double.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "PriceStd"), "PriceStd", Double.class)
        };
    s_sqlFrom = "M_PRODUCT_SUBSTITUTERELATED_V";
    s_sqlWhere = "M_Product_ID = ? AND M_PriceList_Version_ID = ? and RowType = 'R'";
    m_sqlRelated =
        relatedTbl.prepareTable(
            s_layoutRelated, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_SUBSTITUTERELATED_V");
    relatedTbl.setRowSelectionAllowed(false);
    relatedTbl.setMultiSelection(false);
    relatedTbl.addMouseListener(this);
    relatedTbl.getSelectionModel().addListSelectionListener(this);
    relatedTbl.autoSize();

    // Available to Promise Tab
    m_tableAtp.setRowSelectionAllowed(false);
    m_tableAtp.setMultiSelection(false);

    CTabbedPane jTab = new CTabbedPane();
    jTab.addTab(Msg.translate(Env.getCtx(), "Warehouse"), new JScrollPane(warehouseTbl));
    jTab.setPreferredSize(new Dimension(INFO_WIDTH, SCREEN_HEIGHT > 600 ? 250 : 105));
    jTab.addTab(Msg.translate(Env.getCtx(), "Description"), new JScrollPane(fieldDescription));
    jTab.addTab(Msg.translate(Env.getCtx(), "Substitute_ID"), new JScrollPane(substituteTbl));
    jTab.addTab(Msg.translate(Env.getCtx(), "RelatedProduct_ID"), new JScrollPane(relatedTbl));
    jTab.addTab(Msg.getMsg(Env.getCtx(), "ATP"), new JScrollPane(m_tableAtp));
    jTab.addChangeListener(this);
    tablePanel.setPreferredSize(new Dimension(INFO_WIDTH, SCREEN_HEIGHT > 600 ? 255 : 110));
    tablePanel.add(jTab);

    warehouseStockPanel.setCollapsed(true);
    warehouseStockPanel.add(tablePanel);
    this.addonPanel.add(warehouseStockPanel);

    this.p_table.addKeyListener(
        new KeyAdapter() {
          public void keyReleased(KeyEvent ke) {
            int row = ((MiniTable) ke.getSource()).getSelectedRow();
            refresh(
                ((MiniTable) ke.getSource()).getValueAt(row, 2),
                new BigDecimal(pickWarehouse.getValue().toString()).intValue(),
                new BigDecimal(pickPriceList.getValue().toString()).intValue());
            warehouseStockPanel.setCollapsed(false);
          }
        });

    this.p_table.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent me) {
            int row = ((MiniTable) me.getSource()).getSelectedRow();
            refresh(
                ((MiniTable) me.getSource()).getValueAt(row, 2),
                new BigDecimal(pickWarehouse.getValue().toString()).intValue(),
                new BigDecimal(pickPriceList.getValue().toString()).intValue());
            warehouseStockPanel.setCollapsed(false);
          }
        });
    // End - fer_luck @ centuryon
  } //	statInit
Exemplo n.º 30
0
  /** Query ATP */
  private void initAtpTab(int m_M_Warehouse_ID) {

    //	Header
    Vector<String> columnNames = new Vector<String>();
    columnNames.add(Msg.translate(Env.getCtx(), "Date"));
    columnNames.add(Msg.translate(Env.getCtx(), "QtyOnHand"));
    columnNames.add(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
    columnNames.add(Msg.translate(Env.getCtx(), "QtyOrdered"));
    columnNames.add(Msg.translate(Env.getCtx(), "QtyReserved"));
    columnNames.add(Msg.translate(Env.getCtx(), "M_Locator_ID"));
    columnNames.add(Msg.translate(Env.getCtx(), "M_AttributeSetInstance_ID"));
    columnNames.add(Msg.translate(Env.getCtx(), "DocumentNo"));
    columnNames.add(Msg.translate(Env.getCtx(), "M_Warehouse_ID"));

    //	Fill Storage Data
    boolean showDetail = CLogMgt.isLevelFine();
    String sql =
        "SELECT s.QtyOnHand, s.QtyReserved, s.QtyOrdered,"
            + " productAttribute(s.M_AttributeSetInstance_ID), s.M_AttributeSetInstance_ID,";
    if (!showDetail)
      sql =
          "SELECT SUM(s.QtyOnHand), SUM(s.QtyReserved), SUM(s.QtyOrdered),"
              + " productAttribute(s.M_AttributeSetInstance_ID), 0,";
    sql +=
        " w.Name, l.Value "
            + "FROM M_Storage s"
            + " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)"
            + " INNER JOIN M_Warehouse w ON (l.M_Warehouse_ID=w.M_Warehouse_ID) "
            + "WHERE M_Product_ID=?";
    if (m_M_Warehouse_ID != 0) sql += " AND l.M_Warehouse_ID=?";
    if (m_M_AttributeSetInstance_ID > 0) sql += " AND s.M_AttributeSetInstance_ID=?";
    sql += " AND (s.QtyOnHand<>0 OR s.QtyReserved<>0 OR s.QtyOrdered<>0)";
    if (!showDetail)
      sql += " GROUP BY productAttribute(s.M_AttributeSetInstance_ID), w.Name, l.Value";
    sql += " ORDER BY l.Value";

    Vector<Vector<Object>> data = new Vector<Vector<Object>>();
    double qty = 0;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = DB.prepareStatement(sql, null);
      pstmt.setInt(1, m_M_Product_ID);
      if (m_M_Warehouse_ID != 0) pstmt.setInt(2, m_M_Warehouse_ID);
      if (m_M_AttributeSetInstance_ID > 0) pstmt.setInt(3, m_M_AttributeSetInstance_ID);
      rs = pstmt.executeQuery();
      while (rs.next()) {
        Vector<Object> line = new Vector<Object>(9);
        line.add(null); //  Date
        double qtyOnHand = rs.getDouble(1);
        qty += qtyOnHand;
        line.add(new Double(qtyOnHand)); //  Qty
        line.add(null); //  BPartner
        line.add(new Double(rs.getDouble(3))); //  QtyOrdered
        line.add(new Double(rs.getDouble(2))); //  QtyReserved
        line.add(rs.getString(7)); //  Locator
        String asi = rs.getString(4);
        if (showDetail && (asi == null || asi.length() == 0)) asi = "{" + rs.getInt(5) + "}";
        line.add(asi); //  ASI
        line.add(null); //  DocumentNo
        line.add(rs.getString(6)); // 	Warehouse
        data.add(line);
      }
    } catch (SQLException e) {
      log.log(Level.SEVERE, sql, e);
    } finally {
      DB.close(rs, pstmt);
      rs = null;
      pstmt = null;
    }

    //	Orders
    sql =
        "SELECT ol.DatePromised, ol.QtyReserved,"
            + " productAttribute(ol.M_AttributeSetInstance_ID), ol.M_AttributeSetInstance_ID,"
            + " dt.DocBaseType, bp.Name,"
            + " dt.PrintName || ' ' || o.DocumentNo As DocumentNo, w.Name "
            + "FROM C_Order o"
            + " INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID)"
            + " INNER JOIN C_DocType dt ON (o.C_DocType_ID=dt.C_DocType_ID)"
            + " INNER JOIN M_Warehouse w ON (ol.M_Warehouse_ID=w.M_Warehouse_ID)"
            + " INNER JOIN C_BPartner bp  ON (o.C_BPartner_ID=bp.C_BPartner_ID) "
            + "WHERE ol.QtyReserved<>0"
            + " AND ol.M_Product_ID=?";
    if (m_M_Warehouse_ID != 0) sql += " AND ol.M_Warehouse_ID=?";
    if (m_M_AttributeSetInstance_ID > 0) sql += " AND ol.M_AttributeSetInstance_ID=?";
    sql += " ORDER BY o.DatePromised";
    try {
      pstmt = DB.prepareStatement(sql, null);
      pstmt.setInt(1, m_M_Product_ID);
      if (m_M_Warehouse_ID != 0) pstmt.setInt(2, m_M_Warehouse_ID);
      if (m_M_AttributeSetInstance_ID > 0) pstmt.setInt(3, m_M_AttributeSetInstance_ID);
      rs = pstmt.executeQuery();
      while (rs.next()) {
        Vector<Object> line = new Vector<Object>(9);
        line.add(rs.getTimestamp(1)); //  Date
        double oq = rs.getDouble(2);
        String DocBaseType = rs.getString(5);
        Double qtyReserved = null;
        Double qtyOrdered = null;
        if (MDocType.DOCBASETYPE_PurchaseOrder.equals(DocBaseType)) {
          qtyOrdered = new Double(oq);
          qty += oq;
        } else {
          qtyReserved = new Double(oq);
          qty -= oq;
        }
        line.add(new Double(qty)); //  Qty
        line.add(rs.getString(6)); //  BPartner
        line.add(qtyOrdered); //  QtyOrdered
        line.add(qtyReserved); //  QtyReserved
        line.add(null); //  Locator
        String asi = rs.getString(3);
        if (showDetail && (asi == null || asi.length() == 0)) asi = "{" + rs.getInt(4) + "}";
        line.add(asi); //  ASI
        line.add(rs.getString(7)); //  DocumentNo
        line.add(rs.getString(8)); // 	Warehouse
        data.add(line);
      }
    } catch (SQLException e) {
      log.log(Level.SEVERE, sql, e);
    } finally {
      DB.close(rs, pstmt);
      rs = null;
      pstmt = null;
    }

    //  Table
    MiniTable table = null;
    m_modelAtp = new DefaultTableModel(data, columnNames);
    m_tableAtp.setModel(m_modelAtp);
    table = m_tableAtp;
    //
    table.setColumnClass(0, Timestamp.class, true); //  Date
    table.setColumnClass(1, Double.class, true); //  Quantity
    table.setColumnClass(2, String.class, true); //  Partner
    table.setColumnClass(3, Double.class, true); //  Quantity
    table.setColumnClass(4, Double.class, true); //  Quantity
    table.setColumnClass(5, String.class, true); //  Locator
    table.setColumnClass(6, String.class, true); //  ASI
    table.setColumnClass(7, String.class, true); //  DocNo
    table.setColumnClass(8, String.class, true); //  Warehouse
    //
    table.autoSize();
  } //	initAtpTab