Search in sources :

Example 11 with MBrowse

use of org.adempiere.model.MBrowse in project adempiere by adempiere.

the class WBrowser method openBrowse.

/**
	 * Open Browser
	 * @param windowNo
	 * @param browserId
	 * @param whereClause
	 * @param isSOTrx
	 * @return
	 */
public static CustomForm openBrowse(int windowNo, int browserId, String whereClause, Boolean isSOTrx) {
    MBrowse browse = new MBrowse(Env.getCtx(), browserId, null);
    boolean modal = false;
    if (windowNo > 0)
        modal = true;
    String value = "";
    String keyColumn = "";
    boolean multiSelection = true;
    return new WBrowser(modal, windowNo, value, browse, keyColumn, multiSelection, whereClause, isSOTrx).getForm();
}
Also used : MBrowse(org.adempiere.model.MBrowse)

Example 12 with MBrowse

use of org.adempiere.model.MBrowse in project adempiere by adempiere.

the class WPOSActionMenu method executeCommand.

private void executeCommand(Command command) {
    BusyDialog waiting = new BusyDialog();
    try {
        CommandReceiver receiver = commandManager.getCommandReceivers(command.getEvent());
        if (command.getCommand() == CommandManager.GENERATE_IMMEDIATE_INVOICE && pos.getC_Order_ID() > 0 && pos.isCompleted() && !pos.isVoided()) {
            receiver.setCtx(pos.getCtx());
            receiver.setPartnerId(queryPartner.getRecord_ID());
            receiver.setOrderId(pos.getC_Order_ID());
            receiver.setPOSId(pos.getC_POS_ID());
            receiver.setBankAccountId(pos.getC_BankAccount_ID());
            MBPartner partner = MBPartner.get(pos.getCtx(), receiver.getPartnerId());
            Optional<String> taxId = Optional.ofNullable(partner.getTaxID());
            String processMessage = receiver.getName() + " @DisplayDocumentInfo@ : " + pos.getDocumentNo() + " @To@ @C_BPartner_ID@ : " + partner.getName() + " @TaxID@ : " + taxId.orElse("");
            if (FDialog.ask(pos.getWindowNo(), popupMenu, "StartProcess?", Msg.parseTranslation(pos.getCtx(), processMessage))) {
                waiting.setPage(pos.v_Panel.getPage());
                waiting.doHighlighted();
                command.execute(receiver);
                ProcessInfo processInfo = receiver.getProcessInfo();
                waiting.dispose();
                if (processInfo != null && processInfo.isError()) {
                    showError(processInfo);
                } else {
                    afterExecutionCommand(command);
                    showOkMessage(processInfo);
                    if (processInfo != null)
                        pos.setOrder(processInfo.getRecord_ID());
                    pos.refreshHeader();
                    //	Print Ticket
                    pos.printTicket();
                }
            }
        } else //Reverse The Sales Transaction
        if (command.getCommand() == CommandManager.GENERATE_REVERSE_SALES && pos.getC_Order_ID() > 0 && !pos.isReturnMaterial() && !pos.isVoided() && !pos.isClosed()) {
            receiver.setCtx(pos.getCtx());
            receiver.setOrderId(pos.getC_Order_ID());
            receiver.setPOSId(pos.getC_POS_ID());
            receiver.setPartnerId(pos.getC_BPartner_ID());
            receiver.setBankAccountId(pos.getC_BankAccount_ID());
            String processMessage = receiver.getName() + " @order.no@ : " + pos.getDocumentNo() + " @To@ @C_BPartner_ID@ : " + pos.getBPName();
            if (FDialog.ask(pos.getWindowNo(), popupMenu, "StartProcess?", Msg.parseTranslation(pos.getCtx(), processMessage))) {
                waiting.setPage(pos.v_Panel.getPage());
                waiting.doHighlighted();
                command.execute(receiver);
                ProcessInfo processInfo = receiver.getProcessInfo();
                waiting.dispose();
                if (processInfo != null && processInfo.isError()) {
                    showError(processInfo);
                } else {
                    afterExecutionCommand(command);
                    showOkMessage(processInfo);
                }
                pos.printTicket();
            }
        } else //Return product
        if (command.getCommand() == CommandManager.GENERATE_RETURN && pos.getC_Order_ID() > 0 && !pos.isReturnMaterial() && pos.isCompleted()) {
            receiver.setCtx(pos.getCtx());
            receiver.setOrderId(pos.getC_Order_ID());
            receiver.setPOSId(pos.getC_POS_ID());
            receiver.setPartnerId(pos.getC_BPartner_ID());
            receiver.setBankAccountId(pos.getC_BankAccount_ID());
            String processMessage = receiver.getName() + " @DisplayDocumentInfo@ : " + pos.getDocumentNo() + " @To@ @C_BPartner_ID@ : " + pos.getBPName();
            if (FDialog.ask(pos.getWindowNo(), popupMenu, "StartProcess?", Msg.parseTranslation(pos.getCtx(), processMessage))) {
                waiting.setPage(pos.v_Panel.getPage());
                waiting.doHighlighted();
                command.execute(receiver);
                ProcessInfo processInfo = receiver.getProcessInfo();
                waiting.dispose();
                if (processInfo != null && processInfo.isError()) {
                    showError(processInfo);
                } else {
                    afterExecutionCommand(command);
                    showOkMessage(processInfo);
                    //execute out transaction
                    if (processInfo != null && processInfo.getRecord_ID() > 0) {
                        pos.setOrder(processInfo.getRecord_ID());
                        pos.refreshHeader();
                    }
                }
            }
        } else if (command.getCommand() == CommandManager.GENERATE_WITHDRAWAL) {
            Env.setContext(pos.getCtx(), pos.getWindowNo(), "C_POS_ID", pos.getC_POS_ID());
            MBrowse browse = new MBrowse(Env.getCtx(), 50056, null);
            WBrowser browser = new WBrowser(true, pos.getWindowNo(), "", browse, "", true, "", true);
            CustomForm ff = browser.getForm();
            ff.setAttribute(org.adempiere.webui.component.Window.MODE_KEY, org.adempiere.webui.component.Window.MODE_EMBEDDED);
            ff.setAttribute(org.adempiere.webui.component.Window.INSERT_POSITION_KEY, org.adempiere.webui.component.Window.INSERT_NEXT);
            ff.setTitle(browse.getTitle());
            SessionManager.getAppDesktop().showWindow(ff);
        } else if (command.getCommand() == CommandManager.CLOSE_STATEMENT) {
            Env.setContext(pos.getCtx(), pos.getWindowNo(), "C_POS_ID", pos.getC_POS_ID());
            MBrowse browse = new MBrowse(Env.getCtx(), 50057, null);
            WBrowser browser = new WBrowser(true, pos.getWindowNo(), "", browse, "", true, "", true);
            CustomForm ff = browser.getForm();
            ff.setAttribute(org.adempiere.webui.component.Window.MODE_KEY, org.adempiere.webui.component.Window.MODE_EMBEDDED);
            ff.setAttribute(org.adempiere.webui.component.Window.INSERT_POSITION_KEY, org.adempiere.webui.component.Window.INSERT_NEXT);
            ff.setTitle(browse.getTitle());
            SessionManager.getAppDesktop().showWindow(ff);
        }
    } catch (Exception exception) {
        waiting.dispose();
        FDialog.error(pos.getWindowNo(), pos.getForm(), exception.getLocalizedMessage());
    } finally {
        waiting.dispose();
        waiting = null;
    }
}
Also used : CustomForm(org.adempiere.webui.panel.CustomForm) CommandReceiver(org.adempiere.pos.command.CommandReceiver) MBPartner(org.compiere.model.MBPartner) ProcessInfo(org.compiere.process.ProcessInfo) BusyDialog(org.adempiere.webui.apps.BusyDialog) MBrowse(org.adempiere.model.MBrowse) AdempiereException(org.adempiere.exceptions.AdempiereException) WBrowser(org.eevolution.form.WBrowser)

Example 13 with MBrowse

use of org.adempiere.model.MBrowse in project adempiere by adempiere.

the class AbstractADWindowPanel method actionButton.

//
/**************************************************************************
	 *	Start Button Process
	 *  @param wButton button
	 */
private void actionButton(WButtonEditor wButton) {
    GridTab currentTab = toolbar.getCurrentPanel().getGridTab();
    if (currentTab.hasChangedCurrentTabAndParents()) {
        String msg = CLogger.retrieveErrorString("Please ReQuery Window");
        FDialog.error(curWindowNo, parent, null, msg);
        return;
    }
    logger.info(wButton.toString());
    boolean startWOasking = false;
    String col = wButton.getColumnName();
    //  Zoom
    if (col.equals("Record_ID")) {
        int AD_Table_ID = Env.getContextAsInt(ctx, curWindowNo, "AD_Table_ID");
        int Record_ID = Env.getContextAsInt(ctx, curWindowNo, "Record_ID");
        AEnv.zoom(AD_Table_ID, Record_ID);
        return;
    }
    if (currentTab.needSave(true, false)) {
        if (!onSave(false))
            return;
    }
    int table_ID = currentTab.getAD_Table_ID();
    //	Record_ID
    int record_ID = currentTab.getRecord_ID();
    if (record_ID == -1 && currentTab.getKeyColumnName().equals("AD_Language"))
        record_ID = Env.getContextAsInt(ctx, curWindowNo, "AD_Language_ID");
    if (record_ID == -1 && (wButton.getProcess_ID() == 306 || wButton.getProcess_ID() == 307)) {
        Integer id = (Integer) currentTab.getValue("AD_ChangeLog_ID");
        record_ID = id.intValue();
    }
    if (record_ID == -1 && currentTab.getKeyColumnName().endsWith("_ID")) {
        FDialog.error(curWindowNo, parent, "SaveErrorRowNotFound");
        return;
    }
    boolean isProcessMandatory = false;
    if (col.equals("PaymentRule")) {
        WPayment vp = new WPayment(curWindowNo, currentTab, wButton);
        if (//	may not be allowed
        vp.isInitOK()) {
            vp.setVisible(true);
            AEnv.showWindow(vp);
        }
        if (vp.needSave()) {
            onSave(false);
            onRefresh(false);
        }
    } else if (col.equals("DocAction")) {
        isProcessMandatory = true;
        WDocActionPanel win = new WDocActionPanel(currentTab);
        if (win.getNumberOfOptions() == 0) {
            logger.info("DocAction - No Options");
            return;
        } else {
            AEnv.showWindow(win);
            if (!win.isStartProcess())
                return;
            //batch = win.isBatch();
            startWOasking = true;
        //vda.dispose();
        }
    } else if (col.equals("CreateFrom")) {
        ICreateFrom cf = WCreateFromFactory.create(currentTab);
        if (cf != null) {
            if (cf.isInitOK()) {
                cf.showWindow();
                currentTab.dataRefresh();
            }
            return;
        }
    // else may start process
    } else if (col.equals("Posted") && MRole.getDefault().isShowAcct()) {
        //  Check Doc Status
        String processed = Env.getContext(ctx, curWindowNo, "Processed");
        if (!processed.equals("Y")) {
            String docStatus = Env.getContext(ctx, curWindowNo, "DocStatus");
            if (DocAction.STATUS_Completed.equals(docStatus) || DocAction.STATUS_Closed.equals(docStatus) || DocAction.STATUS_Reversed.equals(docStatus) || DocAction.STATUS_Voided.equals(docStatus))
                ;
            else {
                FDialog.error(curWindowNo, parent, "PostDocNotComplete");
                return;
            }
        }
        // try to get table and record id from context data (eg for unposted view)
        // otherwise use current table/record
        int tableId = Env.getContextAsInt(ctx, curWindowNo, "AD_Table_ID", true);
        int recordId = Env.getContextAsInt(ctx, curWindowNo, "Record_ID", true);
        if (tableId == 0 || recordId == 0) {
            tableId = currentTab.getAD_Table_ID();
            recordId = currentTab.getRecord_ID();
        }
        //  Check Post Status
        Object ps = currentTab.getValue("Posted");
        if (ps != null && ps.equals("Y")) {
            new org.adempiere.webui.acct.WAcctViewer(Env.getContextAsInt(ctx, curWindowNo, "AD_Client_ID"), tableId, recordId);
        } else {
            if (FDialog.ask(curWindowNo, null, "PostImmediate?")) {
                //	force when problems
                boolean force = ps != null && !ps.equals("N");
                String error = AEnv.postImmediate(curWindowNo, Env.getAD_Client_ID(ctx), tableId, recordId, force);
                if (error != null)
                    FDialog.error(curWindowNo, null, "PostingError-N", error);
                onRefresh(false);
            }
        }
        return;
    }
    //  Posted
    /**
		 *  Start Process ----
		 */
    logger.config("Process_ID=" + wButton.getProcess_ID() + ", Record_ID=" + record_ID);
    if (wButton.getProcess_ID() == 0) {
        if (isProcessMandatory) {
            FDialog.error(curWindowNo, null, null, Msg.parseTranslation(ctx, "@NotFound@ @AD_Process_ID@"));
        }
        return;
    }
    if (currentTab.needSave(true, false)) {
        if (!onSave(false))
            return;
    }
    // call form
    MProcess pr = new MProcess(ctx, wButton.getProcess_ID(), null);
    //	Validate Access
    //	BR [ 147 ]
    MRole role = MRole.getDefault(ctx, false);
    Boolean accessRW = role.checkProcessAccess(pr.getAD_Process_ID());
    if (accessRW == null || !accessRW.booleanValue()) {
        FDialog.error(curWindowNo, parent, "AccessCannotProcess");
        return;
    }
    int adFormID = pr.getAD_Form_ID();
    //	Yamel Senih BR[ 127 ], 2015-11-25
    //	Bug with launch form
    int adBrowseID = pr.getAD_Browse_ID();
    if (adFormID != 0) {
        String title = wButton.getDescription();
        if (title == null || title.length() == 0)
            title = wButton.getDisplay();
        ProcessInfo pi = new ProcessInfo(title, wButton.getProcess_ID(), table_ID, record_ID);
        pi.setWindowNo(curWindowNo);
        pi.setAD_User_ID(Env.getAD_User_ID(ctx));
        pi.setAD_Client_ID(Env.getAD_Client_ID(ctx));
        ADForm form = ADForm.openForm(adFormID);
        form.setProcessInfo(pi);
        //	Yamel Senih FR [ 114 ], 2015-11-25
        form.setAttribute(Window.MODE_KEY, Window.MODE_MODAL);
        form.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
        form.setClosable(true);
        form.setMaximizable(true);
        form.setSizable(true);
        form.setContentStyle("overflow: auto");
        AEnv.showWindow(form);
        //	End Yamel Senih
        currentTab.dataRefreshAll();
    } else if (adBrowseID != 0) {
        String title = wButton.getDescription();
        if (title == null || title.length() == 0)
            title = wButton.getDisplay();
        ProcessInfo pi = new ProcessInfo(title, wButton.getProcess_ID(), table_ID, record_ID);
        pi.setAD_User_ID(Env.getAD_User_ID(ctx));
        pi.setAD_Client_ID(Env.getAD_Client_ID(ctx));
        MBrowse browse = new MBrowse(Env.getCtx(), adBrowseID, null);
        WBrowser browser = new WBrowser(true, curWindowNo, "", browse, "", true, "", "Y".equals(Env.isSOTrx(Env.getCtx(), curWindowNo)));
        browser.setProcessInfo(pi);
        CustomForm ff = browser.getForm();
        ff.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
        ff.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
        ff.setTitle(title);
        SessionManager.getAppDesktop().showWindow(ff);
        onRefresh(false);
    } else {
        ProcessModalDialog dialog = new ProcessModalDialog(this, curWindowNo, wButton.getProcess_ID(), table_ID, record_ID, startWOasking);
        if (dialog.isValid()) {
            dialog.setWidth("500px");
            dialog.setVisible(true);
            dialog.setPosition("center");
            AEnv.showWindow(dialog);
        }
    //onRefresh(true); // Need to fire events to activate subordinate tabs.
    }
}
Also used : MProcess(org.compiere.model.MProcess) MRole(org.compiere.model.MRole) ProcessInfo(org.compiere.process.ProcessInfo) ProcessModalDialog(org.adempiere.webui.apps.ProcessModalDialog) MBrowse(org.adempiere.model.MBrowse) WBrowser(org.eevolution.form.WBrowser) ICreateFrom(org.compiere.grid.ICreateFrom) WPayment(org.adempiere.webui.apps.form.WPayment) GridTab(org.compiere.model.GridTab)

Example 14 with MBrowse

use of org.adempiere.model.MBrowse in project adempiere by adempiere.

the class BrowseCopyFrom method doIt.

/**
	 * Copy Browse
	 * 
	 * @return info
	 */
@SuppressWarnings("unchecked")
protected String doIt() throws Exception {
    MBrowse browseFrom = new MBrowse(getCtx(), p_AD_Browse_ID, get_TrxName());
    MBrowse browseTo = new MBrowse(getCtx(), p_Record_ID, get_TrxName());
    String name = browseTo.getName();
    String value = browseTo.getValue();
    browseTo.copyValues(browseFrom, browseTo);
    browseTo.setName(name);
    browseTo.setValue(value);
    browseTo.saveEx();
    for (MBrowseField fieldFrom : browseFrom.getFields()) {
        MBrowseField fieldTo = new MBrowseField(getCtx(), 0, get_TrxName());
        fieldTo.copyValues(fieldFrom, fieldTo);
        fieldTo.setAD_Browse_ID(browseTo.getAD_Browse_ID());
        fieldTo.saveEx();
    }
    return "@Ok@";
}
Also used : MBrowseField(org.adempiere.model.MBrowseField) MBrowse(org.adempiere.model.MBrowse)

Example 15 with MBrowse

use of org.adempiere.model.MBrowse in project adempiere by adempiere.

the class CreateBrowseField method doIt.

/**
	 * Process - Generate Export Format
	 * 
	 * @return info
	 */
@SuppressWarnings("unchecked")
protected String doIt() throws Exception {
    MBrowse browse = new MBrowse(getCtx(), p_Record_ID, get_TrxName());
    MView view = browse.getAD_View();
    int seq = 10;
    for (MViewColumn column : view.getViewColumns()) {
        if (column.getAD_Column_ID() <= 0)
            continue;
        MBrowseField field = MBrowseField.get(browse, column);
        if (field != null)
            continue;
        field = new MBrowseField(browse, column);
        field.setAD_Browse_ID(browse.get_ID());
        field.setEntityType(browse.getEntityType());
        field.setIsDisplayed(false);
        field.setIsMandatory(false);
        field.setSeqNo(seq);
        field.saveEx();
        seq++;
        addLog(column.getColumnName());
    }
    return "@Ok@";
}
Also used : MBrowseField(org.adempiere.model.MBrowseField) MView(org.adempiere.model.MView) MBrowse(org.adempiere.model.MBrowse) MViewColumn(org.adempiere.model.MViewColumn)

Aggregations

MBrowse (org.adempiere.model.MBrowse)16 MBrowseField (org.adempiere.model.MBrowseField)6 FormFrame (org.compiere.apps.form.FormFrame)4 ProcessInfo (org.compiere.process.ProcessInfo)4 AdempiereException (org.adempiere.exceptions.AdempiereException)3 MViewColumn (org.adempiere.model.MViewColumn)3 I_AD_View_Column (org.adempiere.model.I_AD_View_Column)2 CommandReceiver (org.adempiere.pos.command.CommandReceiver)2 CustomForm (org.adempiere.webui.panel.CustomForm)2 ICreateFrom (org.compiere.grid.ICreateFrom)2 GridTab (org.compiere.model.GridTab)2 MBPartner (org.compiere.model.MBPartner)2 MColumn (org.compiere.model.MColumn)2 MProcess (org.compiere.model.MProcess)2 MRole (org.compiere.model.MRole)2 Query (org.compiere.model.Query)2 VBrowser (org.eevolution.form.VBrowser)2 WBrowser (org.eevolution.form.WBrowser)2 Dimension (java.awt.Dimension)1 Point (java.awt.Point)1