94 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
|
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
|
|
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 |
package org.openconcerto.erp.core.sales.product.element;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
|
|
17 |
import org.openconcerto.erp.core.sales.invoice.ui.FactureAffacturerTable;
|
|
|
18 |
import org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent;
|
|
|
19 |
import org.openconcerto.sql.element.BaseSQLComponent;
|
|
|
20 |
import org.openconcerto.sql.element.SQLComponent;
|
|
|
21 |
import org.openconcerto.sql.model.SQLRowValues;
|
|
|
22 |
import org.openconcerto.sql.view.EditFrame;
|
|
|
23 |
import org.openconcerto.sql.view.EditPanel.EditMode;
|
|
|
24 |
import org.openconcerto.sql.view.EditPanelListener;
|
|
|
25 |
import org.openconcerto.sql.view.list.IListe;
|
|
|
26 |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
|
|
|
27 |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
|
|
|
28 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
|
|
29 |
|
142 |
ilm |
30 |
import java.awt.GridBagConstraints;
|
|
|
31 |
import java.awt.GridBagLayout;
|
|
|
32 |
import java.awt.event.ActionEvent;
|
|
|
33 |
import java.sql.SQLException;
|
|
|
34 |
import java.util.ArrayList;
|
|
|
35 |
import java.util.List;
|
|
|
36 |
|
|
|
37 |
import javax.swing.AbstractAction;
|
|
|
38 |
import javax.swing.JLabel;
|
|
|
39 |
|
94 |
ilm |
40 |
public class ReliquatSQLElement extends ComptaSQLConfElement {
|
|
|
41 |
|
|
|
42 |
private final String tableBonName;
|
|
|
43 |
|
|
|
44 |
static public class ReliquatBRSQLElement extends ReliquatSQLElement {
|
|
|
45 |
public ReliquatBRSQLElement() {
|
|
|
46 |
super("RELIQUAT_BR", "un reliquat de BR", "reliquats de BR", "BON_RECEPTION");
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
@Override
|
|
|
50 |
protected String createCode() {
|
|
|
51 |
return createCodeFromPackage() + ".reliquatbr";
|
|
|
52 |
}
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
public ReliquatSQLElement(final String tableName, final String singularName, final String pluralName, final String tableBonName) {
|
|
|
56 |
super(tableName, singularName, pluralName);
|
|
|
57 |
this.tableBonName = tableBonName;
|
|
|
58 |
|
|
|
59 |
PredicateRowAction actionTR = new PredicateRowAction(new AbstractAction("Transfert vers Bon") {
|
|
|
60 |
|
|
|
61 |
@Override
|
|
|
62 |
public void actionPerformed(ActionEvent e) {
|
|
|
63 |
final List<SQLRowValues> rows = IListe.get(e).getSelectedRows();
|
|
|
64 |
EditFrame frame = new EditFrame(getForeignElement("ID_" + tableBonName), EditMode.CREATION);
|
|
|
65 |
frame.addEditPanelListener(new EditPanelListener() {
|
|
|
66 |
|
|
|
67 |
@Override
|
|
|
68 |
public void modified() {
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
@Override
|
|
|
72 |
public void inserted(int id) {
|
|
|
73 |
for (SQLRowValues rowVals : rows) {
|
|
|
74 |
try {
|
|
|
75 |
SQLRowValues upRowVals = rowVals.createEmptyUpdateRow();
|
142 |
ilm |
76 |
upRowVals.put("ID_" + tableBonName, id);
|
94 |
ilm |
77 |
upRowVals.update();
|
|
|
78 |
} catch (SQLException exn) {
|
|
|
79 |
exn.printStackTrace();
|
|
|
80 |
}
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
@Override
|
|
|
86 |
public void deleted() {
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
@Override
|
|
|
90 |
public void cancelled() {
|
|
|
91 |
}
|
|
|
92 |
});
|
|
|
93 |
|
142 |
ilm |
94 |
SQLComponent comp = (SQLComponent) frame.getSQLComponent();
|
|
|
95 |
if (comp instanceof BonReceptionSQLComponent) {
|
|
|
96 |
((BonReceptionSQLComponent) comp).loadFromReliquat(rows);
|
|
|
97 |
} else {
|
|
|
98 |
// ((BonDeLivraisonSQLComponent) comp).loadFromReliquat(rows);
|
|
|
99 |
|
|
|
100 |
}
|
94 |
ilm |
101 |
frame.setVisible(true);
|
|
|
102 |
|
|
|
103 |
}
|
|
|
104 |
}, true);
|
|
|
105 |
actionTR.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
|
|
|
106 |
getRowActions().add(actionTR);
|
|
|
107 |
}
|
|
|
108 |
|
|
|
109 |
public ReliquatSQLElement() {
|
|
|
110 |
this("RELIQUAT_BL", "un reliquat de BL", "reliquats de BL", "BON_DE_LIVRAISON");
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
@Override
|
|
|
114 |
protected String getParentFFName() {
|
|
|
115 |
return "ID_" + this.tableBonName;
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
protected List<String> getListFields() {
|
|
|
119 |
final List<String> l = new ArrayList<String>();
|
|
|
120 |
// l.add("DATE");
|
|
|
121 |
l.add("ID_" + this.tableBonName + "_ORIGINE");
|
|
|
122 |
l.add("ID_ARTICLE");
|
|
|
123 |
l.add("QTE_UNITAIRE");
|
|
|
124 |
l.add("ID_UNITE_VENTE");
|
|
|
125 |
l.add("QTE");
|
|
|
126 |
l.add("ID_" + this.tableBonName);
|
|
|
127 |
return l;
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
protected List<String> getComboFields() {
|
|
|
131 |
final List<String> l = new ArrayList<String>();
|
|
|
132 |
l.add("DATE");
|
|
|
133 |
l.add("QTE");
|
|
|
134 |
return l;
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
/*
|
|
|
138 |
* (non-Javadoc)
|
|
|
139 |
*
|
|
|
140 |
* @see org.openconcerto.devis.SQLElement#getComponent()
|
|
|
141 |
*/
|
|
|
142 |
public SQLComponent createComponent() {
|
|
|
143 |
return new BaseSQLComponent(this) {
|
|
|
144 |
FactureAffacturerTable table = new FactureAffacturerTable(null);
|
|
|
145 |
|
|
|
146 |
public void addViews() {
|
|
|
147 |
|
|
|
148 |
// FIXME CREATION DE L'UI
|
|
|
149 |
this.setLayout(new GridBagLayout());
|
|
|
150 |
|
|
|
151 |
GridBagConstraints c = new DefaultGridBagConstraints();
|
|
|
152 |
|
|
|
153 |
this.add(new JLabel(getLabelFor("NB_FACT")), c);
|
|
|
154 |
// c.gridx++;
|
|
|
155 |
// c.weightx = 1;
|
|
|
156 |
// JTextField fieldNbFact = new JTextField();
|
|
|
157 |
// this.add(fieldNbFact, c);
|
|
|
158 |
//
|
|
|
159 |
// c.gridx++;
|
|
|
160 |
// c.weightx = 0;
|
|
|
161 |
// this.add(new JLabel(getLabelFor("MONTANT_FACT")), c);
|
|
|
162 |
// c.gridx++;
|
|
|
163 |
// c.weightx = 1;
|
|
|
164 |
// DeviseField fieldMontantFact = new DeviseField();
|
|
|
165 |
// this.add(fieldMontantFact, c);
|
|
|
166 |
//
|
|
|
167 |
// c.gridx++;
|
|
|
168 |
// c.weightx = 0;
|
|
|
169 |
// this.add(new JLabel(getLabelFor("DATE")), c);
|
|
|
170 |
// c.gridx++;
|
|
|
171 |
//
|
|
|
172 |
// JDate date = new JDate();
|
|
|
173 |
// this.add(date, c);
|
|
|
174 |
//
|
|
|
175 |
// c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
176 |
// c.gridx = 0;
|
|
|
177 |
// c.gridy++;
|
|
|
178 |
// this.add(this.table, c);
|
|
|
179 |
//
|
|
|
180 |
// this.addView(fieldNbFact, "NB_FACT");
|
|
|
181 |
// this.addSQLObject(fieldMontantFact, "MONTANT_FACT");
|
|
|
182 |
// this.addView(date, "DATE");
|
|
|
183 |
}
|
|
|
184 |
|
|
|
185 |
};
|
|
|
186 |
}
|
|
|
187 |
|
|
|
188 |
@Override
|
|
|
189 |
protected String createCode() {
|
|
|
190 |
return createCodeFromPackage() + ".reliquatbl";
|
|
|
191 |
}
|
|
|
192 |
}
|