144 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
182 |
ilm |
4 |
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
|
144 |
ilm |
5 |
*
|
|
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
|
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
|
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
|
|
9 |
* language governing permissions and limitations under the License.
|
|
|
10 |
*
|
|
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
/*
|
|
|
15 |
* Créé le 18 oct. 2011
|
|
|
16 |
*/
|
|
|
17 |
package org.openconcerto.erp.core.supplychain.order.element;
|
|
|
18 |
|
|
|
19 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
|
|
20 |
import org.openconcerto.erp.core.supplychain.order.component.CommandeSQLComponent;
|
|
|
21 |
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
|
|
|
22 |
import org.openconcerto.sql.Configuration;
|
|
|
23 |
import org.openconcerto.sql.element.SQLComponent;
|
|
|
24 |
import org.openconcerto.sql.model.SQLInjector;
|
|
|
25 |
import org.openconcerto.sql.model.SQLRow;
|
|
|
26 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
|
|
27 |
import org.openconcerto.sql.model.SQLRowValues;
|
|
|
28 |
import org.openconcerto.sql.view.EditFrame;
|
|
|
29 |
import org.openconcerto.sql.view.EditPanel.EditMode;
|
|
|
30 |
import org.openconcerto.sql.view.list.IListe;
|
|
|
31 |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
|
|
|
32 |
import org.openconcerto.sql.view.list.RowAction;
|
|
|
33 |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
|
|
|
34 |
import org.openconcerto.sql.view.list.SQLTableModelSource;
|
|
|
35 |
import org.openconcerto.utils.ListMap;
|
|
|
36 |
|
|
|
37 |
import java.awt.event.ActionEvent;
|
|
|
38 |
import java.sql.SQLException;
|
|
|
39 |
import java.util.ArrayList;
|
|
|
40 |
import java.util.List;
|
|
|
41 |
|
|
|
42 |
import javax.swing.AbstractAction;
|
|
|
43 |
|
|
|
44 |
public class DemandePrixSQLElement extends ComptaSQLConfElement {
|
|
|
45 |
|
|
|
46 |
private SQLRowValues getLivraisonAdr(SQLRowAccessor rowAffaire) {
|
|
|
47 |
SQLRowAccessor rowClient = rowAffaire.getForeign("ID_CLIENT");
|
|
|
48 |
SQLRowAccessor rowAdrL = rowClient.getForeign("ID_ADRESSE_L");
|
|
|
49 |
if (rowAdrL == null || rowAdrL.isUndefined()) {
|
|
|
50 |
rowAdrL = rowClient.getForeign("ID_ADRESSE");
|
|
|
51 |
}
|
|
|
52 |
SQLRowValues rowVals = rowAdrL.asRowValues();
|
|
|
53 |
rowVals.clearPrimaryKeys();
|
|
|
54 |
return rowVals;
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
@Override
|
|
|
58 |
protected void _initTableSource(SQLTableModelSource source) {
|
|
|
59 |
super._initTableSource(source);
|
|
|
60 |
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
public DemandePrixSQLElement() {
|
156 |
ilm |
64 |
super("DEMANDE_PRIX");
|
144 |
ilm |
65 |
|
182 |
ilm |
66 |
MouseSheetXmlListeListener l = new MouseSheetXmlListeListener(this, DemandePrixSheetXML.class) {
|
144 |
ilm |
67 |
|
|
|
68 |
@Override
|
|
|
69 |
protected String getMailObject(SQLRow row) {
|
|
|
70 |
return "Veuillez trouver en pièce jointe notre demande de prix.";
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
@Override
|
|
|
74 |
public List<RowAction> addToMenu() {
|
|
|
75 |
List<RowAction> actions = new ArrayList<RowAction>();
|
|
|
76 |
|
|
|
77 |
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Marqué comme acceptée et transférer en commande") {
|
|
|
78 |
|
|
|
79 |
@Override
|
|
|
80 |
public void actionPerformed(ActionEvent arg0) {
|
|
|
81 |
SQLRowAccessor row = IListe.get(arg0).getSelectedRow().asRow();
|
|
|
82 |
SQLRowValues rowVals = row.asRowValues();
|
|
|
83 |
rowVals.put("ID_ETAT_DEMANDE_PRIX", EtatDemandePrixSQLElement.ACCEPTE);
|
|
|
84 |
try {
|
|
|
85 |
rowVals.update();
|
|
|
86 |
} catch (SQLException exn) {
|
|
|
87 |
exn.printStackTrace();
|
|
|
88 |
}
|
|
|
89 |
SQLInjector inj = SQLInjector.getInjector(row.getTable(), row.getTable().getTable("COMMANDE"));
|
|
|
90 |
EditFrame f = new EditFrame(Configuration.getInstance().getDirectory().getElement("COMMANDE"));
|
|
|
91 |
final CommandeSQLComponent sqlComponent = (CommandeSQLComponent) f.getPanel().getSQLComponent();
|
|
|
92 |
sqlComponent.select(inj.createRowValuesFrom(row.getID()));
|
|
|
93 |
|
|
|
94 |
sqlComponent.loadItem(sqlComponent.getRowValuesTablePanel(), Configuration.getInstance().getDirectory().getElement("DEMANDE_PRIX"), row.getID(),
|
|
|
95 |
Configuration.getInstance().getDirectory().getElement("DEMANDE_PRIX_ELEMENT"));
|
|
|
96 |
f.setVisible(true);
|
|
|
97 |
}
|
|
|
98 |
}, false);
|
|
|
99 |
action.setPredicate(IListeEvent.getSingleSelectionPredicate());
|
|
|
100 |
actions.add(action);
|
|
|
101 |
|
|
|
102 |
PredicateRowAction actionCreate = new PredicateRowAction(new AbstractAction("Créer à partir de ...") {
|
|
|
103 |
|
|
|
104 |
@Override
|
|
|
105 |
public void actionPerformed(ActionEvent arg0) {
|
|
|
106 |
SQLRowAccessor row = IListe.get(arg0).getSelectedRow().asRow();
|
|
|
107 |
DemandePrixSQLComponent createComponent = (DemandePrixSQLComponent) createComponent();
|
|
|
108 |
EditFrame frame = new EditFrame(createComponent, EditMode.CREATION);
|
|
|
109 |
createComponent.loadDemandeExistant(row.getID());
|
|
|
110 |
frame.setVisible(true);
|
|
|
111 |
}
|
|
|
112 |
}, false);
|
|
|
113 |
actionCreate.setPredicate(IListeEvent.getSingleSelectionPredicate());
|
|
|
114 |
actions.add(actionCreate);
|
|
|
115 |
|
|
|
116 |
// actions.addAll(new DemandePrixAction().getEtatAction());
|
|
|
117 |
return actions;
|
|
|
118 |
}
|
|
|
119 |
};
|
|
|
120 |
|
|
|
121 |
getRowActions().addAll(l.getRowActions());
|
|
|
122 |
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
@Override
|
|
|
126 |
protected List<String> getListFields() {
|
|
|
127 |
final List<String> l = new ArrayList<String>();
|
|
|
128 |
l.add("NUMERO");
|
|
|
129 |
l.add("ID_FOURNISSEUR");
|
|
|
130 |
l.add("DATE");
|
|
|
131 |
l.add("ID_ETAT_DEMANDE_PRIX");
|
|
|
132 |
return l;
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
@Override
|
|
|
136 |
protected List<String> getComboFields() {
|
|
|
137 |
final List<String> l = new ArrayList<String>();
|
|
|
138 |
l.add("NUMERO");
|
|
|
139 |
l.add("ID_FOURNISSEUR");
|
|
|
140 |
return l;
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
@Override
|
|
|
144 |
public ListMap<String, String> getShowAs() {
|
|
|
145 |
return ListMap.singleton(null, "NUMERO");
|
|
|
146 |
}
|
|
|
147 |
|
|
|
148 |
@Override
|
|
|
149 |
public SQLComponent createComponent() {
|
|
|
150 |
return new DemandePrixSQLComponent(this);
|
|
|
151 |
}
|
|
|
152 |
|
|
|
153 |
@Override
|
|
|
154 |
protected String createCode() {
|
156 |
ilm |
155 |
return createCodeOfPackage() + ".demande";
|
144 |
ilm |
156 |
}
|
|
|
157 |
|
|
|
158 |
}
|