Dépôt officiel du code source de l'ERP OpenConcerto
Rev 156 | Blame | Compare with Previous | Last modification | View Log | RSS feed
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
/*
* Créé le 18 oct. 2011
*/
package org.openconcerto.erp.core.supplychain.order.element;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.supplychain.order.component.CommandeSQLComponent;
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLInjector;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel.EditMode;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.utils.ListMap;
import java.awt.event.ActionEvent;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractAction;
public class DemandePrixSQLElement extends ComptaSQLConfElement {
private SQLRowValues getLivraisonAdr(SQLRowAccessor rowAffaire) {
SQLRowAccessor rowClient = rowAffaire.getForeign("ID_CLIENT");
SQLRowAccessor rowAdrL = rowClient.getForeign("ID_ADRESSE_L");
if (rowAdrL == null || rowAdrL.isUndefined()) {
rowAdrL = rowClient.getForeign("ID_ADRESSE");
}
SQLRowValues rowVals = rowAdrL.asRowValues();
rowVals.clearPrimaryKeys();
return rowVals;
}
@Override
protected void _initTableSource(SQLTableModelSource source) {
super._initTableSource(source);
}
public DemandePrixSQLElement() {
super("DEMANDE_PRIX");
MouseSheetXmlListeListener l = new MouseSheetXmlListeListener(this, DemandePrixSheetXML.class) {
@Override
protected String getMailObject(SQLRow row) {
return "Veuillez trouver en pièce jointe notre demande de prix.";
}
@Override
public List<RowAction> addToMenu() {
List<RowAction> actions = new ArrayList<RowAction>();
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Marqué comme acceptée et transférer en commande") {
@Override
public void actionPerformed(ActionEvent arg0) {
SQLRowAccessor row = IListe.get(arg0).getSelectedRow().asRow();
SQLRowValues rowVals = row.asRowValues();
rowVals.put("ID_ETAT_DEMANDE_PRIX", EtatDemandePrixSQLElement.ACCEPTE);
try {
rowVals.update();
} catch (SQLException exn) {
exn.printStackTrace();
}
SQLInjector inj = SQLInjector.getInjector(row.getTable(), row.getTable().getTable("COMMANDE"));
EditFrame f = new EditFrame(Configuration.getInstance().getDirectory().getElement("COMMANDE"));
final CommandeSQLComponent sqlComponent = (CommandeSQLComponent) f.getPanel().getSQLComponent();
sqlComponent.select(inj.createRowValuesFrom(row.getID()));
sqlComponent.loadItem(sqlComponent.getRowValuesTablePanel(), Configuration.getInstance().getDirectory().getElement("DEMANDE_PRIX"), row.getID(),
Configuration.getInstance().getDirectory().getElement("DEMANDE_PRIX_ELEMENT"));
f.setVisible(true);
}
}, false);
action.setPredicate(IListeEvent.getSingleSelectionPredicate());
actions.add(action);
PredicateRowAction actionCreate = new PredicateRowAction(new AbstractAction("Créer à partir de ...") {
@Override
public void actionPerformed(ActionEvent arg0) {
SQLRowAccessor row = IListe.get(arg0).getSelectedRow().asRow();
DemandePrixSQLComponent createComponent = (DemandePrixSQLComponent) createComponent();
EditFrame frame = new EditFrame(createComponent, EditMode.CREATION);
createComponent.loadDemandeExistant(row.getID());
frame.setVisible(true);
}
}, false);
actionCreate.setPredicate(IListeEvent.getSingleSelectionPredicate());
actions.add(actionCreate);
// actions.addAll(new DemandePrixAction().getEtatAction());
return actions;
}
};
getRowActions().addAll(l.getRowActions());
}
@Override
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("NUMERO");
l.add("ID_FOURNISSEUR");
l.add("DATE");
l.add("ID_ETAT_DEMANDE_PRIX");
return l;
}
@Override
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("NUMERO");
l.add("ID_FOURNISSEUR");
return l;
}
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, "NUMERO");
}
@Override
public SQLComponent createComponent() {
return new DemandePrixSQLComponent(this);
}
@Override
protected String createCode() {
return createCodeOfPackage() + ".demande";
}
}