18 |
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.supplychain.order.component;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
94 |
ilm |
17 |
import org.openconcerto.erp.core.common.component.AdresseSQLComponent;
|
18 |
ilm |
18 |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
|
63 |
ilm |
19 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
18 |
ilm |
20 |
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
|
28 |
ilm |
21 |
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
|
18 |
ilm |
22 |
import org.openconcerto.erp.core.common.ui.DeviseField;
|
|
|
23 |
import org.openconcerto.erp.core.common.ui.TotalPanel;
|
65 |
ilm |
24 |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
|
94 |
ilm |
25 |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
|
149 |
ilm |
26 |
import org.openconcerto.erp.core.supplychain.order.element.DemandeAchatItemSQLElement;
|
18 |
ilm |
27 |
import org.openconcerto.erp.core.supplychain.order.ui.CommandeItemTable;
|
83 |
ilm |
28 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
|
93 |
ilm |
29 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.TypeStockUpdate;
|
132 |
ilm |
30 |
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
|
94 |
ilm |
31 |
import org.openconcerto.erp.generationDoc.gestcomm.CommandeXmlSheet;
|
|
|
32 |
import org.openconcerto.erp.panel.PanelOOSQLComponent;
|
18 |
ilm |
33 |
import org.openconcerto.erp.preferences.DefaultNXProps;
|
174 |
ilm |
34 |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
|
93 |
ilm |
35 |
import org.openconcerto.erp.utils.TM;
|
18 |
ilm |
36 |
import org.openconcerto.sql.Configuration;
|
28 |
ilm |
37 |
import org.openconcerto.sql.element.DefaultElementSQLObject;
|
94 |
ilm |
38 |
import org.openconcerto.sql.element.ElementSQLObject;
|
18 |
ilm |
39 |
import org.openconcerto.sql.element.SQLElement;
|
|
|
40 |
import org.openconcerto.sql.model.SQLBackgroundTableCache;
|
19 |
ilm |
41 |
import org.openconcerto.sql.model.SQLInjector;
|
18 |
ilm |
42 |
import org.openconcerto.sql.model.SQLRow;
|
|
|
43 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
|
|
44 |
import org.openconcerto.sql.model.SQLRowValues;
|
|
|
45 |
import org.openconcerto.sql.model.SQLTable;
|
57 |
ilm |
46 |
import org.openconcerto.sql.model.Where;
|
156 |
ilm |
47 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
18 |
ilm |
48 |
import org.openconcerto.sql.sqlobject.ElementComboBox;
|
|
|
49 |
import org.openconcerto.sql.sqlobject.JUniqueTextField;
|
61 |
ilm |
50 |
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
|
174 |
ilm |
51 |
import org.openconcerto.sql.sqlobject.SQLTextCombo;
|
18 |
ilm |
52 |
import org.openconcerto.sql.users.UserManager;
|
|
|
53 |
import org.openconcerto.sql.view.EditFrame;
|
73 |
ilm |
54 |
import org.openconcerto.sql.view.list.RowValuesTable;
|
174 |
ilm |
55 |
import org.openconcerto.sql.view.list.RowValuesTableModel;
|
65 |
ilm |
56 |
import org.openconcerto.ui.AutoHideListener;
|
18 |
ilm |
57 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
25 |
ilm |
58 |
import org.openconcerto.ui.FormLayouter;
|
18 |
ilm |
59 |
import org.openconcerto.ui.JDate;
|
|
|
60 |
import org.openconcerto.ui.TitledSeparator;
|
94 |
ilm |
61 |
import org.openconcerto.ui.component.ComboLockedMode;
|
18 |
ilm |
62 |
import org.openconcerto.ui.component.ITextArea;
|
94 |
ilm |
63 |
import org.openconcerto.ui.component.ITextCombo;
|
132 |
ilm |
64 |
import org.openconcerto.ui.component.InteractionMode;
|
18 |
ilm |
65 |
import org.openconcerto.ui.preferences.DefaultProps;
|
|
|
66 |
import org.openconcerto.utils.ExceptionHandler;
|
174 |
ilm |
67 |
import org.openconcerto.utils.checks.ValidState;
|
18 |
ilm |
68 |
|
|
|
69 |
import java.awt.Color;
|
|
|
70 |
import java.awt.GridBagConstraints;
|
|
|
71 |
import java.awt.GridBagLayout;
|
28 |
ilm |
72 |
import java.awt.event.ActionEvent;
|
|
|
73 |
import java.awt.event.ActionListener;
|
19 |
ilm |
74 |
import java.beans.PropertyChangeEvent;
|
|
|
75 |
import java.beans.PropertyChangeListener;
|
18 |
ilm |
76 |
import java.sql.SQLException;
|
174 |
ilm |
77 |
import java.util.HashSet;
|
156 |
ilm |
78 |
import java.util.List;
|
174 |
ilm |
79 |
import java.util.Set;
|
18 |
ilm |
80 |
|
|
|
81 |
import javax.swing.JCheckBox;
|
|
|
82 |
import javax.swing.JLabel;
|
142 |
ilm |
83 |
import javax.swing.JOptionPane;
|
18 |
ilm |
84 |
import javax.swing.JPanel;
|
|
|
85 |
import javax.swing.JScrollPane;
|
|
|
86 |
import javax.swing.JTextField;
|
|
|
87 |
import javax.swing.SwingConstants;
|
|
|
88 |
import javax.swing.SwingUtilities;
|
|
|
89 |
import javax.swing.event.DocumentEvent;
|
|
|
90 |
import javax.swing.event.DocumentListener;
|
|
|
91 |
import javax.swing.event.TableModelEvent;
|
|
|
92 |
import javax.swing.event.TableModelListener;
|
|
|
93 |
|
177 |
ilm |
94 |
import com.ibm.icu.math.BigDecimal;
|
|
|
95 |
|
18 |
ilm |
96 |
public class CommandeSQLComponent extends TransfertBaseSQLComponent {
|
|
|
97 |
|
180 |
ilm |
98 |
protected CommandeItemTable table = new CommandeItemTable();
|
|
|
99 |
protected PanelOOSQLComponent panelOO;
|
94 |
ilm |
100 |
|
180 |
ilm |
101 |
protected JUniqueTextField numeroUniqueCommande;
|
|
|
102 |
protected final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO");
|
|
|
103 |
protected final ITextArea infos = new ITextArea(3, 3);
|
|
|
104 |
protected ElementComboBox fourn = new ElementComboBox();
|
|
|
105 |
protected final JCheckBox boxLivrClient = new JCheckBox("Livrer directement le client");
|
|
|
106 |
protected DefaultElementSQLObject compAdr;
|
|
|
107 |
protected final JPanel panelAdrSpec = new JPanel(new GridBagLayout());
|
90 |
ilm |
108 |
protected ElementComboBox boxAdr;
|
180 |
ilm |
109 |
protected JDate dateCommande = new JDate(true);
|
|
|
110 |
protected ElementSQLObject componentPrincipaleAdr;
|
18 |
ilm |
111 |
|
|
|
112 |
public CommandeSQLComponent() {
|
|
|
113 |
super(Configuration.getInstance().getDirectory().getElement("COMMANDE"));
|
|
|
114 |
}
|
|
|
115 |
|
28 |
ilm |
116 |
public ElementComboBox getBoxFournisseur() {
|
|
|
117 |
return this.fourn;
|
|
|
118 |
}
|
|
|
119 |
|
174 |
ilm |
120 |
@Override
|
|
|
121 |
protected Set<String> createRequiredNames() {
|
|
|
122 |
final Set<String> s = new HashSet<>(4);
|
|
|
123 |
if (getTable().contains("ID_TYPE_CMD")) {
|
|
|
124 |
s.add("ID_TYPE_CMD");
|
|
|
125 |
s.add("DA1");
|
|
|
126 |
s.add("ID_POLE_PRODUIT");
|
|
|
127 |
}
|
|
|
128 |
return s;
|
|
|
129 |
}
|
|
|
130 |
|
18 |
ilm |
131 |
public void addViews() {
|
|
|
132 |
this.setLayout(new GridBagLayout());
|
|
|
133 |
final GridBagConstraints c = new DefaultGridBagConstraints();
|
|
|
134 |
|
|
|
135 |
// Numero du commande
|
|
|
136 |
c.gridx = 0;
|
|
|
137 |
c.weightx = 0;
|
|
|
138 |
this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c);
|
|
|
139 |
|
142 |
ilm |
140 |
this.numeroUniqueCommande = new JUniqueTextField(16) {
|
|
|
141 |
@Override
|
|
|
142 |
public String getAutoRefreshNumber() {
|
|
|
143 |
if (getMode() == Mode.INSERTION) {
|
|
|
144 |
return NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), dateCommande.getDate());
|
|
|
145 |
} else {
|
|
|
146 |
return null;
|
|
|
147 |
}
|
|
|
148 |
}
|
|
|
149 |
};
|
18 |
ilm |
150 |
c.gridx++;
|
|
|
151 |
c.weightx = 1;
|
|
|
152 |
c.fill = GridBagConstraints.NONE;
|
|
|
153 |
DefaultGridBagConstraints.lockMinimumSize(numeroUniqueCommande);
|
|
|
154 |
this.add(this.numeroUniqueCommande, c);
|
|
|
155 |
|
|
|
156 |
// Date
|
|
|
157 |
JLabel labelDate = new JLabel(getLabelFor("DATE"));
|
|
|
158 |
labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
159 |
c.gridx = 2;
|
|
|
160 |
c.weightx = 0;
|
|
|
161 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
162 |
this.add(labelDate, c);
|
|
|
163 |
|
|
|
164 |
c.gridx++;
|
|
|
165 |
c.fill = GridBagConstraints.NONE;
|
|
|
166 |
this.add(dateCommande, c);
|
|
|
167 |
|
93 |
ilm |
168 |
this.dateCommande.addValueListener(new PropertyChangeListener() {
|
|
|
169 |
|
|
|
170 |
@Override
|
|
|
171 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
172 |
if (!isFilling() && dateCommande.getValue() != null) {
|
|
|
173 |
table.setDateDevise(dateCommande.getValue());
|
|
|
174 |
}
|
|
|
175 |
}
|
|
|
176 |
});
|
|
|
177 |
|
18 |
ilm |
178 |
// Fournisseur
|
|
|
179 |
c.gridx = 0;
|
|
|
180 |
c.gridy++;
|
|
|
181 |
c.weightx = 0;
|
|
|
182 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
183 |
this.add(new JLabel(getLabelFor("ID_FOURNISSEUR"), SwingConstants.RIGHT), c);
|
|
|
184 |
|
93 |
ilm |
185 |
c.gridx++;
|
18 |
ilm |
186 |
c.gridwidth = 1;
|
|
|
187 |
c.weightx = 1;
|
|
|
188 |
c.weighty = 0;
|
|
|
189 |
c.fill = GridBagConstraints.NONE;
|
|
|
190 |
this.add(this.fourn, c);
|
149 |
ilm |
191 |
addRequiredSQLObject(this.fourn, "ID_FOURNISSEUR");
|
156 |
ilm |
192 |
fourn.addModelListener("wantedID", new PropertyChangeListener() {
|
18 |
ilm |
193 |
|
156 |
ilm |
194 |
@Override
|
|
|
195 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
196 |
int wantedID = fourn.getWantedID();
|
|
|
197 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
|
|
198 |
|
|
|
199 |
final SQLRow rowF = getTable().getForeignTable("ID_FOURNISSEUR").getRow(wantedID);
|
|
|
200 |
|
|
|
201 |
if (rowF.getObject("ID_CATEGORIE_COMPTABLE") != null && !rowF.isForeignEmpty("ID_CATEGORIE_COMPTABLE")) {
|
|
|
202 |
table.setRowCatComptable(rowF.getForeign("ID_CATEGORIE_COMPTABLE"));
|
|
|
203 |
} else {
|
|
|
204 |
table.setRowCatComptable(null);
|
|
|
205 |
}
|
174 |
ilm |
206 |
if (getTable().contains("OFFRE_COM")) {
|
|
|
207 |
((SQLTextCombo) getView("OFFRE_COM").getComp()).setValue(rowF.getString("RESPONSABLE"));
|
|
|
208 |
}
|
156 |
ilm |
209 |
} else {
|
|
|
210 |
table.setRowCatComptable(null);
|
|
|
211 |
}
|
|
|
212 |
}
|
|
|
213 |
});
|
|
|
214 |
|
174 |
ilm |
215 |
Boolean useCommandeEnCours = SQLPreferences.getMemCached(getElement().getTable().getDBRoot()).getBoolean(GestionCommercialeGlobalPreferencePanel.COMMANDE_FOURNISSEUR_EN_COURS, false);
|
|
|
216 |
|
|
|
217 |
if (!getTable().getFieldsName().contains("LIVRER") && useCommandeEnCours) {
|
28 |
ilm |
218 |
// Commande en cours
|
|
|
219 |
JCheckBox boxEnCours = new JCheckBox(getLabelFor("EN_COURS"));
|
93 |
ilm |
220 |
c.gridx += 2;
|
28 |
ilm |
221 |
c.weightx = 0;
|
|
|
222 |
c.fill = GridBagConstraints.HORIZONTAL;
|
61 |
ilm |
223 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
28 |
ilm |
224 |
this.add(boxEnCours, c);
|
61 |
ilm |
225 |
c.gridwidth = 1;
|
28 |
ilm |
226 |
this.addRequiredSQLObject(boxEnCours, "EN_COURS");
|
|
|
227 |
}
|
19 |
ilm |
228 |
|
94 |
ilm |
229 |
if (getTable().contains("DATE_RECEPTION_DEMANDEE")) {
|
|
|
230 |
// Date
|
|
|
231 |
JLabel labelDateRecptDemande = new JLabel(getLabelFor("DATE_RECEPTION_DEMANDEE"));
|
|
|
232 |
labelDateRecptDemande.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
233 |
c.gridx = 0;
|
|
|
234 |
c.gridy++;
|
|
|
235 |
c.weightx = 0;
|
|
|
236 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
237 |
this.add(labelDateRecptDemande, c);
|
|
|
238 |
|
|
|
239 |
c.gridx++;
|
|
|
240 |
c.fill = GridBagConstraints.NONE;
|
|
|
241 |
JDate dateRecptDemande = new JDate();
|
|
|
242 |
this.add(dateRecptDemande, c);
|
|
|
243 |
this.addView(dateRecptDemande, "DATE_RECEPTION_DEMANDEE", REQ);
|
|
|
244 |
|
|
|
245 |
JLabel labelDateRecptConfirme = new JLabel(getLabelFor("DATE_RECEPTION_CONFIRMEE"));
|
|
|
246 |
labelDateRecptConfirme.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
247 |
c.gridx++;
|
|
|
248 |
c.weightx = 0;
|
|
|
249 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
250 |
this.add(labelDateRecptConfirme, c);
|
|
|
251 |
|
|
|
252 |
c.gridx++;
|
|
|
253 |
c.fill = GridBagConstraints.NONE;
|
|
|
254 |
JDate dateRecptConfirme = new JDate();
|
|
|
255 |
this.add(dateRecptConfirme, c);
|
|
|
256 |
this.addView(dateRecptConfirme, "DATE_RECEPTION_CONFIRMEE");
|
|
|
257 |
}
|
57 |
ilm |
258 |
// Fournisseur
|
|
|
259 |
if (getTable().contains("ID_CONTACT_FOURNISSEUR")) {
|
|
|
260 |
c.gridx = 0;
|
|
|
261 |
c.gridy++;
|
|
|
262 |
c.weightx = 0;
|
|
|
263 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
264 |
this.add(new JLabel(getLabelFor("ID_CONTACT_FOURNISSEUR"), SwingConstants.RIGHT), c);
|
|
|
265 |
|
|
|
266 |
c.gridx = GridBagConstraints.RELATIVE;
|
|
|
267 |
c.gridwidth = 1;
|
|
|
268 |
c.weightx = 1;
|
|
|
269 |
c.weighty = 0;
|
|
|
270 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
271 |
final ElementComboBox boxContactFournisseur = new ElementComboBox();
|
|
|
272 |
final SQLElement contactElement = Configuration.getInstance().getDirectory().getElement("CONTACT_FOURNISSEUR");
|
65 |
ilm |
273 |
boxContactFournisseur.init(contactElement, contactElement.getComboRequest(true));
|
57 |
ilm |
274 |
this.add(boxContactFournisseur, c);
|
|
|
275 |
this.addView(boxContactFournisseur, "ID_CONTACT_FOURNISSEUR", REQ);
|
|
|
276 |
|
|
|
277 |
fourn.addValueListener(new PropertyChangeListener() {
|
|
|
278 |
|
|
|
279 |
@Override
|
|
|
280 |
public void propertyChange(PropertyChangeEvent arg0) {
|
|
|
281 |
if (fourn.getSelectedRow() != null) {
|
|
|
282 |
boxContactFournisseur.getRequest().setWhere(new Where(contactElement.getTable().getField("ID_FOURNISSEUR"), "=", fourn.getSelectedRow().getID()));
|
|
|
283 |
} else {
|
|
|
284 |
boxContactFournisseur.getRequest().setWhere(null);
|
|
|
285 |
}
|
|
|
286 |
}
|
|
|
287 |
});
|
|
|
288 |
}
|
28 |
ilm |
289 |
// Adresse de livraison
|
|
|
290 |
if (getTable().getFieldsName().contains("ID_ADRESSE")) {
|
57 |
ilm |
291 |
if (getTable().getFieldsName().contains("LIVRAISON_F")) {
|
61 |
ilm |
292 |
c.gridx = 0;
|
|
|
293 |
c.gridy++;
|
|
|
294 |
c.weightx = 0;
|
|
|
295 |
c.fill = GridBagConstraints.HORIZONTAL;
|
90 |
ilm |
296 |
|
|
|
297 |
this.boxAdr = new ElementComboBox();
|
|
|
298 |
final SQLElement adrElement = getElement().getForeignElement("ID_ADRESSE");
|
|
|
299 |
boxAdr.init(adrElement);
|
|
|
300 |
c.gridwidth = 1;
|
|
|
301 |
final JLabel labelAdrLiv = new JLabel("Adresse de livraison existante");
|
|
|
302 |
this.add(labelAdrLiv, c);
|
|
|
303 |
c.gridx++;
|
|
|
304 |
c.gridwidth = 2;
|
|
|
305 |
this.add(boxAdr, c);
|
|
|
306 |
|
|
|
307 |
c.gridx = 0;
|
|
|
308 |
c.gridy++;
|
61 |
ilm |
309 |
this.add(new JLabel(getLabelFor("ID_ADRESSE")), c);
|
|
|
310 |
c.gridx++;
|
|
|
311 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
312 |
// c.gridy++;
|
|
|
313 |
this.addView("ID_ADRESSE");
|
|
|
314 |
final DefaultElementSQLObject comp = (DefaultElementSQLObject) this.getView("ID_ADRESSE").getComp();
|
132 |
ilm |
315 |
|
|
|
316 |
componentPrincipaleAdr = (ElementSQLObject) this.getView("ID_ADRESSE");
|
|
|
317 |
((AdresseSQLComponent) componentPrincipaleAdr.getSQLChild()).setDestinataireVisible(true);
|
90 |
ilm |
318 |
final JCheckBox boxLivr = new JCheckBox("Livré par le fournisseur");
|
|
|
319 |
this.add(boxLivr, c);
|
|
|
320 |
this.addSQLObject(boxLivr, "LIVRAISON_F");
|
|
|
321 |
boxLivr.addActionListener(new ActionListener() {
|
28 |
ilm |
322 |
|
90 |
ilm |
323 |
@Override
|
|
|
324 |
public void actionPerformed(ActionEvent e) {
|
132 |
ilm |
325 |
|
90 |
ilm |
326 |
if (boxLivr.isSelected() && !comp.isCreated()) {
|
|
|
327 |
comp.setCreated(true);
|
132 |
ilm |
328 |
componentPrincipaleAdr.setEditable(InteractionMode.READ_WRITE);
|
90 |
ilm |
329 |
if (CommandeSQLComponent.this.getTable().contains("ID_AFFAIRE")) {
|
28 |
ilm |
330 |
|
90 |
ilm |
331 |
final SQLRow selectedRow = ((ElementComboBox) CommandeSQLComponent.this.getView("ID_AFFAIRE").getComp()).getSelectedRow();
|
|
|
332 |
SQLRowValues rowVals = getLivraisonAdr(selectedRow);
|
61 |
ilm |
333 |
|
90 |
ilm |
334 |
comp.setValue(rowVals);
|
|
|
335 |
|
|
|
336 |
if (selectedRow != null && !selectedRow.isUndefined()) {
|
|
|
337 |
final SQLRow clientRow = selectedRow.getForeign("ID_CLIENT");
|
|
|
338 |
Where w = new Where(boxAdr.getRequest().getPrimaryTable().getField("ID_CLIENT"), "=", clientRow.getID());
|
|
|
339 |
w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=", clientRow.getInt("ID_ADRESSE")));
|
|
|
340 |
// w = w.or(new
|
|
|
341 |
// Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=",
|
|
|
342 |
// clientRow.getInt("ID_ADRESSE_F")));
|
|
|
343 |
w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=", clientRow.getInt("ID_ADRESSE_L")));
|
|
|
344 |
if (clientRow.getTable().contains("ID_ADRESSE_L_2")) {
|
|
|
345 |
w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=", clientRow.getInt("ID_ADRESSE_L_2")));
|
|
|
346 |
}
|
|
|
347 |
if (clientRow.getTable().contains("ID_ADRESSE_L_3")) {
|
|
|
348 |
w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=", clientRow.getInt("ID_ADRESSE_L_3")));
|
|
|
349 |
}
|
|
|
350 |
boxAdr.getRequest().setWhere(w);
|
|
|
351 |
} else {
|
|
|
352 |
boxAdr.getRequest().setWhere(null);
|
61 |
ilm |
353 |
}
|
|
|
354 |
|
57 |
ilm |
355 |
}
|
90 |
ilm |
356 |
|
|
|
357 |
} else {
|
|
|
358 |
if (!boxLivr.isSelected()) {
|
|
|
359 |
comp.setCreated(false);
|
132 |
ilm |
360 |
componentPrincipaleAdr.setEditable(InteractionMode.DISABLED);
|
90 |
ilm |
361 |
}
|
61 |
ilm |
362 |
}
|
90 |
ilm |
363 |
}
|
|
|
364 |
});
|
57 |
ilm |
365 |
|
61 |
ilm |
366 |
c.gridy++;
|
|
|
367 |
this.add(comp, c);
|
|
|
368 |
this.add(this.getView("ID_ADRESSE").getComp(), c);
|
90 |
ilm |
369 |
|
|
|
370 |
comp.addValueListener(new PropertyChangeListener() {
|
|
|
371 |
|
|
|
372 |
@Override
|
|
|
373 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
374 |
boxAdr.setVisible(comp.isCreated());
|
|
|
375 |
labelAdrLiv.setVisible(comp.isCreated());
|
|
|
376 |
}
|
|
|
377 |
});
|
|
|
378 |
|
|
|
379 |
boxAdr.addValueListener(new PropertyChangeListener() {
|
|
|
380 |
|
|
|
381 |
@Override
|
|
|
382 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
383 |
final SQLRow selectedRow = boxAdr.getSelectedRow();
|
|
|
384 |
if (selectedRow != null && !selectedRow.isUndefined()) {
|
|
|
385 |
SQLRowValues rowVals = selectedRow.asRowValues();
|
|
|
386 |
rowVals.clearPrimaryKeys();
|
|
|
387 |
comp.setValue(rowVals);
|
|
|
388 |
}
|
|
|
389 |
}
|
|
|
390 |
});
|
|
|
391 |
boxAdr.setVisible(false);
|
|
|
392 |
labelAdrLiv.setVisible(false);
|
|
|
393 |
|
61 |
ilm |
394 |
} else {
|
|
|
395 |
|
|
|
396 |
c.gridy++;
|
149 |
ilm |
397 |
c.gridx = 1;
|
156 |
ilm |
398 |
|
61 |
ilm |
399 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
400 |
this.add(boxLivrClient, c);
|
|
|
401 |
c.gridwidth = 1;
|
|
|
402 |
|
|
|
403 |
final GridBagConstraints cAdr = new DefaultGridBagConstraints();
|
|
|
404 |
|
|
|
405 |
panelAdrSpec.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), cAdr);
|
|
|
406 |
final ElementComboBox boxClient = new ElementComboBox(true);
|
|
|
407 |
cAdr.weightx = 1;
|
|
|
408 |
cAdr.gridx++;
|
|
|
409 |
panelAdrSpec.add(boxClient, cAdr);
|
|
|
410 |
this.addView(boxClient, "ID_CLIENT");
|
|
|
411 |
|
|
|
412 |
cAdr.gridy++;
|
|
|
413 |
cAdr.weightx = 0;
|
|
|
414 |
cAdr.gridx = 0;
|
93 |
ilm |
415 |
panelAdrSpec.add(new JLabel(TM.tr("address"), SwingConstants.RIGHT), cAdr);
|
61 |
ilm |
416 |
final SQLRequestComboBox boxAdr = new SQLRequestComboBox(true);
|
|
|
417 |
boxAdr.uiInit(Configuration.getInstance().getDirectory().getElement(getTable().getTable("ADRESSE")).getComboRequest(true));
|
73 |
ilm |
418 |
boxClient.addModelListener("wantedID", new PropertyChangeListener() {
|
61 |
ilm |
419 |
|
|
|
420 |
@Override
|
|
|
421 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
422 |
if (boxClient.getSelectedRow() != null && !boxClient.getSelectedRow().isUndefined()) {
|
|
|
423 |
Where w = new Where(boxAdr.getRequest().getPrimaryTable().getField("ID_CLIENT"), "=", boxClient.getSelectedRow().getID());
|
|
|
424 |
w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=", boxClient.getSelectedRow().getInt("ID_ADRESSE")));
|
|
|
425 |
w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=", boxClient.getSelectedRow().getInt("ID_ADRESSE_F")));
|
|
|
426 |
w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=", boxClient.getSelectedRow().getInt("ID_ADRESSE_L")));
|
|
|
427 |
boxAdr.getRequest().setWhere(w);
|
57 |
ilm |
428 |
} else {
|
61 |
ilm |
429 |
boxAdr.getRequest().setWhere(null);
|
28 |
ilm |
430 |
}
|
|
|
431 |
}
|
57 |
ilm |
432 |
});
|
61 |
ilm |
433 |
cAdr.weightx = 1;
|
|
|
434 |
cAdr.gridx++;
|
|
|
435 |
panelAdrSpec.add(boxAdr, cAdr);
|
|
|
436 |
|
|
|
437 |
cAdr.gridx = 0;
|
|
|
438 |
cAdr.gridy++;
|
|
|
439 |
cAdr.weightx = 0;
|
|
|
440 |
if (getMode() == Mode.MODIFICATION) {
|
|
|
441 |
panelAdrSpec.add(new JLabel(getLabelFor("ID_ADRESSE")), cAdr);
|
|
|
442 |
}
|
|
|
443 |
cAdr.gridx++;
|
|
|
444 |
cAdr.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
445 |
this.addView("ID_ADRESSE");
|
|
|
446 |
compAdr = (DefaultElementSQLObject) this.getView("ID_ADRESSE").getComp();
|
|
|
447 |
|
|
|
448 |
cAdr.gridy++;
|
|
|
449 |
if (getMode() == Mode.MODIFICATION) {
|
|
|
450 |
panelAdrSpec.add(compAdr, cAdr);
|
|
|
451 |
}
|
|
|
452 |
boxAdr.addValueListener(new PropertyChangeListener() {
|
|
|
453 |
|
|
|
454 |
@Override
|
|
|
455 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
456 |
SQLRow row = boxAdr.getSelectedRow();
|
|
|
457 |
if (row != null && !row.isUndefined()) {
|
|
|
458 |
compAdr.setCreated(true);
|
|
|
459 |
SQLRowValues asRowValues = new SQLRowValues(row.asRowValues());
|
|
|
460 |
compAdr.setValue(asRowValues);
|
|
|
461 |
}
|
|
|
462 |
}
|
|
|
463 |
});
|
|
|
464 |
|
|
|
465 |
c.gridy++;
|
|
|
466 |
c.gridx = 0;
|
|
|
467 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
468 |
c.weightx = 1;
|
|
|
469 |
this.add(panelAdrSpec, c);
|
|
|
470 |
c.gridwidth = 1;
|
|
|
471 |
c.weightx = 0;
|
|
|
472 |
|
|
|
473 |
boxLivrClient.addActionListener(new ActionListener() {
|
|
|
474 |
|
|
|
475 |
@Override
|
|
|
476 |
public void actionPerformed(ActionEvent e) {
|
|
|
477 |
panelAdrSpec.setVisible(boxLivrClient.isSelected());
|
|
|
478 |
|
|
|
479 |
if (!boxLivrClient.isSelected()) {
|
|
|
480 |
boxClient.setValue((Integer) null);
|
|
|
481 |
boxAdr.setValue((Integer) null);
|
|
|
482 |
compAdr.setCreated(false);
|
|
|
483 |
}
|
|
|
484 |
}
|
|
|
485 |
});
|
|
|
486 |
panelAdrSpec.setVisible(false);
|
57 |
ilm |
487 |
}
|
28 |
ilm |
488 |
}
|
|
|
489 |
c.gridwidth = 1;
|
|
|
490 |
|
|
|
491 |
// Champ Module
|
19 |
ilm |
492 |
c.gridx = 0;
|
|
|
493 |
c.gridy++;
|
28 |
ilm |
494 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
63 |
ilm |
495 |
final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
|
28 |
ilm |
496 |
this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
|
|
|
497 |
this.add(addP, c);
|
19 |
ilm |
498 |
|
28 |
ilm |
499 |
c.gridy++;
|
19 |
ilm |
500 |
c.gridwidth = 1;
|
|
|
501 |
|
156 |
ilm |
502 |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
|
|
|
503 |
final boolean showDevise = prefs.getBoolean(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE, false);
|
|
|
504 |
|
28 |
ilm |
505 |
final ElementComboBox boxDevise = new ElementComboBox();
|
156 |
ilm |
506 |
if (showDevise) {
|
28 |
ilm |
507 |
// Devise
|
|
|
508 |
c.gridx = 0;
|
|
|
509 |
c.gridy++;
|
|
|
510 |
c.weightx = 0;
|
|
|
511 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
512 |
this.add(new JLabel(getLabelFor("ID_DEVISE"), SwingConstants.RIGHT), c);
|
|
|
513 |
|
94 |
ilm |
514 |
c.gridx++;
|
28 |
ilm |
515 |
c.gridwidth = 1;
|
|
|
516 |
c.weightx = 1;
|
|
|
517 |
c.weighty = 0;
|
|
|
518 |
c.fill = GridBagConstraints.NONE;
|
132 |
ilm |
519 |
DefaultGridBagConstraints.lockMinimumSize(boxDevise);
|
28 |
ilm |
520 |
this.add(boxDevise, c);
|
|
|
521 |
this.addView(boxDevise, "ID_DEVISE");
|
93 |
ilm |
522 |
|
|
|
523 |
fourn.addValueListener(new PropertyChangeListener() {
|
|
|
524 |
|
|
|
525 |
@Override
|
|
|
526 |
public void propertyChange(PropertyChangeEvent arg0) {
|
|
|
527 |
if (fourn.getSelectedRow() != null) {
|
|
|
528 |
boxDevise.setValue(fourn.getSelectedRow().getForeignID("ID_DEVISE"));
|
|
|
529 |
} else {
|
|
|
530 |
boxDevise.setValue((SQLRowAccessor) null);
|
|
|
531 |
}
|
|
|
532 |
}
|
|
|
533 |
});
|
|
|
534 |
|
94 |
ilm |
535 |
if (getTable().contains("INCOTERM")) {
|
|
|
536 |
// Incoterm
|
|
|
537 |
c.gridx++;
|
|
|
538 |
c.weightx = 0;
|
|
|
539 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
540 |
this.add(new JLabel(getLabelFor("INCOTERM"), SwingConstants.RIGHT), c);
|
|
|
541 |
|
|
|
542 |
c.gridx++;
|
|
|
543 |
c.gridwidth = 1;
|
|
|
544 |
c.weightx = 1;
|
|
|
545 |
c.weighty = 0;
|
|
|
546 |
c.fill = GridBagConstraints.NONE;
|
132 |
ilm |
547 |
final ITextCombo box = new ITextCombo(ComboLockedMode.LOCKED);
|
94 |
ilm |
548 |
|
|
|
549 |
for (String s : ReferenceArticleSQLElement.CONDITIONS) {
|
|
|
550 |
box.addItem(s);
|
|
|
551 |
}
|
|
|
552 |
this.add(box, c);
|
|
|
553 |
this.addView(box, "INCOTERM", REQ);
|
132 |
ilm |
554 |
box.addValueListener(new PropertyChangeListener() {
|
|
|
555 |
|
|
|
556 |
@Override
|
|
|
557 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
558 |
table.setIncoterms(box.getCurrentValue());
|
|
|
559 |
}
|
|
|
560 |
});
|
94 |
ilm |
561 |
}
|
|
|
562 |
|
28 |
ilm |
563 |
}
|
|
|
564 |
|
18 |
ilm |
565 |
// Reference
|
|
|
566 |
c.gridx = 0;
|
|
|
567 |
c.gridy++;
|
|
|
568 |
c.gridwidth = 1;
|
|
|
569 |
c.weightx = 0;
|
|
|
570 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
571 |
c.anchor = GridBagConstraints.EAST;
|
|
|
572 |
this.add(new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT), c);
|
|
|
573 |
|
180 |
ilm |
574 |
final SQLTextCombo textNom = new SQLTextCombo();
|
18 |
ilm |
575 |
c.gridx++;
|
|
|
576 |
c.weightx = 1;
|
|
|
577 |
this.add(textNom, c);
|
|
|
578 |
|
|
|
579 |
String field;
|
|
|
580 |
field = "ID_COMMERCIAL";
|
|
|
581 |
// Commercial
|
|
|
582 |
c.weightx = 0;
|
|
|
583 |
c.gridx++;
|
|
|
584 |
this.add(new JLabel(getLabelFor(field), SwingConstants.RIGHT), c);
|
|
|
585 |
|
|
|
586 |
ElementComboBox commSel = new ElementComboBox(false, 25);
|
|
|
587 |
c.gridx = GridBagConstraints.RELATIVE;
|
|
|
588 |
c.gridwidth = 1;
|
|
|
589 |
c.weightx = 1;
|
|
|
590 |
c.weighty = 0;
|
|
|
591 |
c.fill = GridBagConstraints.NONE;
|
|
|
592 |
c.anchor = GridBagConstraints.WEST;
|
|
|
593 |
this.add(commSel, c);
|
|
|
594 |
addRequiredSQLObject(commSel, field);
|
|
|
595 |
|
|
|
596 |
// Table d'élément
|
|
|
597 |
c.fill = GridBagConstraints.BOTH;
|
|
|
598 |
c.gridy++;
|
|
|
599 |
c.gridx = 0;
|
|
|
600 |
c.weightx = 0;
|
|
|
601 |
c.weighty = 1;
|
|
|
602 |
c.gridwidth = 4;
|
|
|
603 |
this.add(this.table, c);
|
156 |
ilm |
604 |
if (showDevise) {
|
18 |
ilm |
605 |
|
28 |
ilm |
606 |
boxDevise.addValueListener(new PropertyChangeListener() {
|
19 |
ilm |
607 |
|
28 |
ilm |
608 |
@Override
|
|
|
609 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
610 |
table.setDevise(boxDevise.getSelectedRow());
|
|
|
611 |
}
|
|
|
612 |
});
|
|
|
613 |
}
|
67 |
ilm |
614 |
|
|
|
615 |
this.fourn.addValueListener(new PropertyChangeListener() {
|
|
|
616 |
|
|
|
617 |
@Override
|
|
|
618 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
619 |
table.setFournisseur(fourn.getSelectedRow());
|
|
|
620 |
}
|
|
|
621 |
});
|
18 |
ilm |
622 |
// Bottom
|
|
|
623 |
c.gridy++;
|
|
|
624 |
c.weighty = 0;
|
|
|
625 |
this.add(getBottomPanel(), c);
|
|
|
626 |
|
|
|
627 |
c.gridx = 0;
|
|
|
628 |
c.gridy++;
|
94 |
ilm |
629 |
c.fill = GridBagConstraints.NONE;
|
|
|
630 |
c.anchor = GridBagConstraints.SOUTHEAST;
|
18 |
ilm |
631 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
632 |
|
94 |
ilm |
633 |
this.panelOO = new PanelOOSQLComponent(this);
|
|
|
634 |
this.add(this.panelOO, c);
|
|
|
635 |
|
18 |
ilm |
636 |
addSQLObject(textNom, "NOM");
|
|
|
637 |
addRequiredSQLObject(dateCommande, "DATE");
|
|
|
638 |
// addRequiredSQLObject(radioEtat, "ID_ETAT_DEVIS");
|
|
|
639 |
addRequiredSQLObject(this.numeroUniqueCommande, "NUMERO");
|
|
|
640 |
addSQLObject(this.infos, "INFOS");
|
|
|
641 |
|
90 |
ilm |
642 |
this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
|
18 |
ilm |
643 |
|
|
|
644 |
// radioEtat.setValue(EtatDevisSQLElement.EN_ATTENTE);
|
|
|
645 |
// this.numeroUniqueDevis.addLabelWarningMouseListener(new MouseAdapter() {
|
|
|
646 |
// public void mousePressed(MouseEvent e) {
|
|
|
647 |
//
|
|
|
648 |
// if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
|
|
|
649 |
// numeroUniqueDevis.setText(NumerotationAutoSQLElement.getNextNumeroDevis());
|
|
|
650 |
// }
|
|
|
651 |
// }
|
|
|
652 |
// });
|
|
|
653 |
|
|
|
654 |
DefaultGridBagConstraints.lockMinimumSize(this.fourn);
|
|
|
655 |
DefaultGridBagConstraints.lockMinimumSize(commSel);
|
180 |
ilm |
656 |
this.addView(this.table.getRowValuesTable(), "");
|
18 |
ilm |
657 |
}
|
|
|
658 |
|
28 |
ilm |
659 |
protected SQLRowValues getLivraisonAdr(SQLRow rowAffaire) {
|
|
|
660 |
if (rowAffaire != null) {
|
|
|
661 |
SQLRow rowClient = rowAffaire.getForeignRow("ID_CLIENT");
|
|
|
662 |
SQLRow rowAdrL = rowClient.getForeignRow("ID_ADRESSE_L");
|
|
|
663 |
if (rowAdrL == null || rowAdrL.isUndefined()) {
|
|
|
664 |
rowAdrL = rowClient.getForeignRow("ID_ADRESSE");
|
|
|
665 |
}
|
|
|
666 |
SQLRowValues rowVals = rowAdrL.asRowValues();
|
|
|
667 |
rowVals.clearPrimaryKeys();
|
|
|
668 |
return rowVals;
|
|
|
669 |
} else {
|
|
|
670 |
return new SQLRowValues(getTable().getTable("ADRESSE"));
|
|
|
671 |
}
|
|
|
672 |
}
|
|
|
673 |
|
18 |
ilm |
674 |
private JPanel getBottomPanel() {
|
|
|
675 |
final JPanel panel = new JPanel(new GridBagLayout());
|
|
|
676 |
final GridBagConstraints c = new DefaultGridBagConstraints();
|
|
|
677 |
|
|
|
678 |
// Colonne 1 : Infos
|
|
|
679 |
c.gridx = 0;
|
|
|
680 |
c.weightx = 1;
|
|
|
681 |
c.anchor = GridBagConstraints.WEST;
|
|
|
682 |
c.fill = GridBagConstraints.HORIZONTAL;
|
57 |
ilm |
683 |
|
18 |
ilm |
684 |
panel.add(new TitledSeparator(getLabelFor("INFOS")), c);
|
|
|
685 |
|
|
|
686 |
c.gridy++;
|
|
|
687 |
c.weighty = 0;
|
|
|
688 |
c.weightx = 1;
|
|
|
689 |
c.fill = GridBagConstraints.BOTH;
|
|
|
690 |
final JScrollPane scrollPane = new JScrollPane(this.infos);
|
|
|
691 |
scrollPane.setBorder(null);
|
|
|
692 |
panel.add(scrollPane, c);
|
|
|
693 |
|
|
|
694 |
// Colonne 2 : Poids & autres
|
|
|
695 |
DefaultProps props = DefaultNXProps.getInstance();
|
|
|
696 |
Boolean b = props.getBooleanValue("ArticleShowPoids");
|
|
|
697 |
final JTextField textPoidsTotal = new JTextField(8);
|
19 |
ilm |
698 |
JTextField poids = new JTextField();
|
18 |
ilm |
699 |
if (b) {
|
132 |
ilm |
700 |
final JPanel panelPoids = new JPanel(new GridBagLayout());
|
|
|
701 |
GridBagConstraints cPoids = new DefaultGridBagConstraints();
|
|
|
702 |
cPoids.weightx = 0;
|
|
|
703 |
panelPoids.add(new JLabel(getLabelFor("T_POIDS")), cPoids);
|
|
|
704 |
cPoids.weightx = 1;
|
18 |
ilm |
705 |
textPoidsTotal.setEnabled(false);
|
|
|
706 |
textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT);
|
|
|
707 |
textPoidsTotal.setDisabledTextColor(Color.BLACK);
|
132 |
ilm |
708 |
cPoids.gridx++;
|
|
|
709 |
panelPoids.add(textPoidsTotal, cPoids);
|
18 |
ilm |
710 |
|
|
|
711 |
c.gridx++;
|
|
|
712 |
c.gridy = 0;
|
|
|
713 |
c.weightx = 0;
|
|
|
714 |
c.weighty = 0;
|
|
|
715 |
c.gridwidth = 1;
|
|
|
716 |
c.gridheight = 2;
|
|
|
717 |
c.fill = GridBagConstraints.NONE;
|
|
|
718 |
c.anchor = GridBagConstraints.NORTHEAST;
|
|
|
719 |
panel.add(panelPoids, c);
|
|
|
720 |
DefaultGridBagConstraints.lockMinimumSize(panelPoids);
|
19 |
ilm |
721 |
addSQLObject(textPoidsTotal, "T_POIDS");
|
|
|
722 |
} else {
|
|
|
723 |
addSQLObject(poids, "T_POIDS");
|
18 |
ilm |
724 |
}
|
57 |
ilm |
725 |
|
|
|
726 |
DeviseField textPortHT = new DeviseField();
|
149 |
ilm |
727 |
DeviseField textRemiseHT = new DeviseField();
|
132 |
ilm |
728 |
ElementComboBox comboTaxePort = new ElementComboBox(false, 10);
|
57 |
ilm |
729 |
|
|
|
730 |
if (getTable().contains("PORT_HT")) {
|
149 |
ilm |
731 |
|
|
|
732 |
addSQLObject(textPortHT, "PORT_HT");
|
65 |
ilm |
733 |
final JPanel panelPoids = new JPanel(new GridBagLayout());
|
|
|
734 |
GridBagConstraints cPort = new DefaultGridBagConstraints();
|
|
|
735 |
cPort.gridx = 0;
|
132 |
ilm |
736 |
cPort.fill = GridBagConstraints.NONE;
|
65 |
ilm |
737 |
cPort.weightx = 0;
|
|
|
738 |
panelPoids.add(new JLabel(getLabelFor("PORT_HT")), cPort);
|
57 |
ilm |
739 |
textPortHT.setHorizontalAlignment(JTextField.RIGHT);
|
65 |
ilm |
740 |
cPort.gridx++;
|
|
|
741 |
cPort.weightx = 1;
|
|
|
742 |
panelPoids.add(textPortHT, cPort);
|
57 |
ilm |
743 |
|
65 |
ilm |
744 |
cPort.gridy++;
|
|
|
745 |
cPort.gridx = 0;
|
|
|
746 |
cPort.weightx = 0;
|
|
|
747 |
addRequiredSQLObject(comboTaxePort, "ID_TAXE_PORT");
|
|
|
748 |
panelPoids.add(new JLabel(getLabelFor("ID_TAXE_PORT")), cPort);
|
|
|
749 |
cPort.gridx++;
|
132 |
ilm |
750 |
cPort.weightx = 1;
|
65 |
ilm |
751 |
panelPoids.add(comboTaxePort, cPort);
|
57 |
ilm |
752 |
|
149 |
ilm |
753 |
addSQLObject(textRemiseHT, "REMISE_HT");
|
|
|
754 |
cPort.gridy++;
|
|
|
755 |
cPort.gridx = 0;
|
|
|
756 |
cPort.fill = GridBagConstraints.NONE;
|
|
|
757 |
cPort.weightx = 0;
|
|
|
758 |
panelPoids.add(new JLabel(getLabelFor("REMISE_HT")), cPort);
|
|
|
759 |
textRemiseHT.setHorizontalAlignment(JTextField.RIGHT);
|
|
|
760 |
cPort.gridx++;
|
|
|
761 |
cPort.weightx = 1;
|
|
|
762 |
panelPoids.add(textRemiseHT, cPort);
|
|
|
763 |
|
57 |
ilm |
764 |
c.gridx++;
|
|
|
765 |
c.gridy = 0;
|
|
|
766 |
c.weightx = 0;
|
|
|
767 |
c.weighty = 0;
|
|
|
768 |
c.gridwidth = 1;
|
|
|
769 |
c.gridheight = 2;
|
|
|
770 |
c.fill = GridBagConstraints.NONE;
|
|
|
771 |
c.anchor = GridBagConstraints.NORTHEAST;
|
|
|
772 |
panel.add(panelPoids, c);
|
|
|
773 |
DefaultGridBagConstraints.lockMinimumSize(panelPoids);
|
|
|
774 |
}
|
18 |
ilm |
775 |
// Total
|
57 |
ilm |
776 |
|
18 |
ilm |
777 |
DeviseField fieldHT = new DeviseField();
|
142 |
ilm |
778 |
DeviseField fieldEco = new DeviseField();
|
18 |
ilm |
779 |
DeviseField fieldTVA = new DeviseField();
|
|
|
780 |
DeviseField fieldTTC = new DeviseField();
|
19 |
ilm |
781 |
DeviseField fieldDevise = new DeviseField();
|
18 |
ilm |
782 |
DeviseField fieldService = new DeviseField();
|
|
|
783 |
fieldHT.setOpaque(false);
|
|
|
784 |
fieldTVA.setOpaque(false);
|
|
|
785 |
fieldTTC.setOpaque(false);
|
|
|
786 |
fieldService.setOpaque(false);
|
142 |
ilm |
787 |
addRequiredSQLObject(fieldEco, "T_ECO_CONTRIBUTION");
|
19 |
ilm |
788 |
addRequiredSQLObject(fieldDevise, "T_DEVISE");
|
18 |
ilm |
789 |
addRequiredSQLObject(fieldHT, "T_HT");
|
|
|
790 |
addRequiredSQLObject(fieldTVA, "T_TVA");
|
57 |
ilm |
791 |
|
18 |
ilm |
792 |
addRequiredSQLObject(fieldTTC, "T_TTC");
|
|
|
793 |
addRequiredSQLObject(fieldService, "T_SERVICE");
|
94 |
ilm |
794 |
|
|
|
795 |
// Disable
|
142 |
ilm |
796 |
this.allowEditable("T_ECO_CONTRIBUTION", false);
|
94 |
ilm |
797 |
this.allowEditable("T_HT", false);
|
|
|
798 |
this.allowEditable("T_TVA", false);
|
|
|
799 |
this.allowEditable("T_TTC", false);
|
|
|
800 |
this.allowEditable("T_SERVICE", false);
|
|
|
801 |
|
142 |
ilm |
802 |
final TotalPanel totalTTC = new TotalPanel(this.table, fieldEco, fieldHT, fieldTVA, fieldTTC, textPortHT, textRemiseHT, fieldService, null, fieldDevise, null, null,
|
|
|
803 |
(getTable().contains("ID_TAXE_PORT") ? comboTaxePort : null), null);
|
18 |
ilm |
804 |
|
|
|
805 |
c.gridx++;
|
|
|
806 |
c.gridy--;
|
|
|
807 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
808 |
c.gridheight = 2;
|
|
|
809 |
c.anchor = GridBagConstraints.NORTHEAST;
|
|
|
810 |
c.fill = GridBagConstraints.BOTH;
|
|
|
811 |
c.weighty = 0;
|
132 |
ilm |
812 |
c.weightx = 0;
|
18 |
ilm |
813 |
DefaultGridBagConstraints.lockMinimumSize(totalTTC);
|
|
|
814 |
|
|
|
815 |
panel.add(totalTTC, c);
|
|
|
816 |
|
65 |
ilm |
817 |
c.gridy += 3;
|
|
|
818 |
c.gridheight = 2;
|
|
|
819 |
c.fill = GridBagConstraints.NONE;
|
|
|
820 |
c.anchor = GridBagConstraints.EAST;
|
|
|
821 |
panel.add(getModuleTotalPanel(), c);
|
|
|
822 |
|
18 |
ilm |
823 |
table.getModel().addTableModelListener(new TableModelListener() {
|
|
|
824 |
|
|
|
825 |
public void tableChanged(TableModelEvent e) {
|
|
|
826 |
textPoidsTotal.setText(String.valueOf(table.getPoidsTotal()));
|
|
|
827 |
}
|
|
|
828 |
});
|
|
|
829 |
|
|
|
830 |
textPortHT.getDocument().addDocumentListener(new DocumentListener() {
|
|
|
831 |
public void changedUpdate(DocumentEvent e) {
|
|
|
832 |
totalTTC.updateTotal();
|
|
|
833 |
}
|
|
|
834 |
|
|
|
835 |
public void removeUpdate(DocumentEvent e) {
|
|
|
836 |
totalTTC.updateTotal();
|
|
|
837 |
}
|
|
|
838 |
|
|
|
839 |
public void insertUpdate(DocumentEvent e) {
|
|
|
840 |
totalTTC.updateTotal();
|
|
|
841 |
}
|
|
|
842 |
});
|
|
|
843 |
|
65 |
ilm |
844 |
comboTaxePort.addValueListener(new PropertyChangeListener() {
|
|
|
845 |
|
|
|
846 |
@Override
|
|
|
847 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
848 |
totalTTC.updateTotal();
|
|
|
849 |
}
|
|
|
850 |
});
|
|
|
851 |
|
18 |
ilm |
852 |
textRemiseHT.getDocument().addDocumentListener(new DocumentListener() {
|
|
|
853 |
public void changedUpdate(DocumentEvent e) {
|
|
|
854 |
totalTTC.updateTotal();
|
|
|
855 |
}
|
|
|
856 |
|
|
|
857 |
public void removeUpdate(DocumentEvent e) {
|
|
|
858 |
totalTTC.updateTotal();
|
|
|
859 |
}
|
|
|
860 |
|
|
|
861 |
public void insertUpdate(DocumentEvent e) {
|
|
|
862 |
totalTTC.updateTotal();
|
|
|
863 |
}
|
|
|
864 |
});
|
|
|
865 |
return panel;
|
|
|
866 |
}
|
|
|
867 |
|
65 |
ilm |
868 |
protected JPanel getModuleTotalPanel() {
|
|
|
869 |
|
|
|
870 |
return AutoHideListener.listen(new JPanel());
|
|
|
871 |
}
|
|
|
872 |
|
18 |
ilm |
873 |
public int insert(SQLRow order) {
|
|
|
874 |
|
|
|
875 |
int idCommande = getSelectedID();
|
|
|
876 |
// on verifie qu'un devis du meme numero n'a pas été inséré entre temps
|
142 |
ilm |
877 |
int attempt = 0;
|
|
|
878 |
if (!this.numeroUniqueCommande.checkValidation(false)) {
|
|
|
879 |
while (attempt < JUniqueTextField.RETRY_COUNT) {
|
|
|
880 |
String num = NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), dateCommande.getDate());
|
|
|
881 |
this.numeroUniqueCommande.setText(num);
|
|
|
882 |
attempt++;
|
|
|
883 |
if (this.numeroUniqueCommande.checkValidation(false)) {
|
|
|
884 |
System.err.println("ATEMPT " + attempt + " SUCCESS WITH NUMERO " + num);
|
|
|
885 |
break;
|
|
|
886 |
}
|
|
|
887 |
try {
|
|
|
888 |
Thread.sleep(JUniqueTextField.SLEEP_WAIT_MS);
|
|
|
889 |
} catch (InterruptedException e) {
|
|
|
890 |
e.printStackTrace();
|
|
|
891 |
}
|
|
|
892 |
}
|
|
|
893 |
}
|
|
|
894 |
final String num = this.numeroUniqueCommande.getText();
|
|
|
895 |
if (attempt == JUniqueTextField.RETRY_COUNT) {
|
|
|
896 |
idCommande = getSelectedID();
|
|
|
897 |
ExceptionHandler.handle("Impossible d'ajouter, numéro de commande existant.");
|
|
|
898 |
final Object root = SwingUtilities.getRoot(this);
|
|
|
899 |
if (root instanceof EditFrame) {
|
|
|
900 |
final EditFrame frame = (EditFrame) root;
|
|
|
901 |
frame.getPanel().setAlwaysVisible(true);
|
|
|
902 |
}
|
|
|
903 |
} else {
|
18 |
ilm |
904 |
idCommande = super.insert(order);
|
|
|
905 |
this.table.updateField("ID_COMMANDE", idCommande);
|
|
|
906 |
|
|
|
907 |
// Création des articles
|
|
|
908 |
this.table.createArticle(idCommande, this.getElement());
|
|
|
909 |
|
83 |
ilm |
910 |
try {
|
|
|
911 |
updateStock(idCommande);
|
|
|
912 |
} catch (SQLException e) {
|
|
|
913 |
ExceptionHandler.handle("Erreur lors de la mise à jour du stock!", e);
|
|
|
914 |
}
|
|
|
915 |
|
18 |
ilm |
916 |
// generation du document
|
25 |
ilm |
917 |
final CommandeXmlSheet sheet = new CommandeXmlSheet(getTable().getRow(idCommande));
|
|
|
918 |
sheet.createDocumentAsynchronous();
|
94 |
ilm |
919 |
sheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true);
|
18 |
ilm |
920 |
|
|
|
921 |
// incrémentation du numéro auto
|
90 |
ilm |
922 |
if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass()).equalsIgnoreCase(this.numeroUniqueCommande.getText().trim())) {
|
18 |
ilm |
923 |
SQLRowValues rowVals = new SQLRowValues(this.tableNum);
|
90 |
ilm |
924 |
int val = this.tableNum.getRow(2).getInt(NumerotationAutoSQLElement.getLabelNumberFor(getElement().getClass()));
|
18 |
ilm |
925 |
val++;
|
90 |
ilm |
926 |
rowVals.put(NumerotationAutoSQLElement.getLabelNumberFor(getElement().getClass()), new Integer(val));
|
18 |
ilm |
927 |
|
|
|
928 |
try {
|
|
|
929 |
rowVals.update(2);
|
|
|
930 |
} catch (SQLException e) {
|
|
|
931 |
e.printStackTrace();
|
|
|
932 |
}
|
|
|
933 |
}
|
149 |
ilm |
934 |
DemandeAchatItemSQLElement elt = getElement().getDirectory().getElement(DemandeAchatItemSQLElement.class);
|
|
|
935 |
elt.updateStatus(getTable(), getTable().getTable("COMMANDE_ELEMENT"), idCommande);
|
|
|
936 |
|
142 |
ilm |
937 |
if (attempt > 0) {
|
|
|
938 |
SwingUtilities.invokeLater(new Runnable() {
|
|
|
939 |
public void run() {
|
|
|
940 |
JOptionPane.showMessageDialog(null, "Le numéro a été actualisé en " + num);
|
|
|
941 |
}
|
|
|
942 |
});
|
18 |
ilm |
943 |
}
|
|
|
944 |
}
|
|
|
945 |
|
|
|
946 |
return idCommande;
|
|
|
947 |
}
|
|
|
948 |
|
|
|
949 |
@Override
|
|
|
950 |
public void select(SQLRowAccessor r) {
|
61 |
ilm |
951 |
if (!getTable().contains("LIVRAISON_F") && r != null && !r.isUndefined()) {
|
18 |
ilm |
952 |
|
94 |
ilm |
953 |
SQLRowAccessor adr = (r.getFields().contains("ID_ADRESSE") ? r.getForeign("ID_ADRESSE") : null);
|
61 |
ilm |
954 |
boxLivrClient.setSelected(adr != null && !adr.isUndefined());
|
|
|
955 |
panelAdrSpec.setVisible(boxLivrClient.isSelected());
|
|
|
956 |
|
|
|
957 |
if (!boxLivrClient.isSelected()) {
|
|
|
958 |
compAdr.setCreated(false);
|
|
|
959 |
}
|
|
|
960 |
}
|
132 |
ilm |
961 |
if (getTable().contains("LIVRAISON_F") && componentPrincipaleAdr != null) {
|
|
|
962 |
final boolean bLivraison = r != null && r.getFields().contains("ID_ADRESSE") && !r.isForeignEmpty("ID_ADRESSE");
|
|
|
963 |
componentPrincipaleAdr.setEditable(bLivraison ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
|
|
|
964 |
}
|
61 |
ilm |
965 |
|
18 |
ilm |
966 |
super.select(r);
|
|
|
967 |
}
|
|
|
968 |
|
|
|
969 |
@Override
|
|
|
970 |
public void update() {
|
|
|
971 |
if (!this.numeroUniqueCommande.checkValidation()) {
|
|
|
972 |
ExceptionHandler.handle("Impossible d'ajouter, numéro de commande client existant.");
|
|
|
973 |
Object root = SwingUtilities.getRoot(this);
|
|
|
974 |
if (root instanceof EditFrame) {
|
|
|
975 |
EditFrame frame = (EditFrame) root;
|
|
|
976 |
frame.getPanel().setAlwaysVisible(true);
|
|
|
977 |
}
|
|
|
978 |
return;
|
|
|
979 |
}
|
|
|
980 |
|
|
|
981 |
super.update();
|
83 |
ilm |
982 |
final int id = getSelectedID();
|
|
|
983 |
this.table.updateField("ID_COMMANDE", id);
|
|
|
984 |
this.table.createArticle(id, this.getElement());
|
|
|
985 |
ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() {
|
18 |
ilm |
986 |
|
83 |
ilm |
987 |
@Override
|
|
|
988 |
public void run() {
|
|
|
989 |
try {
|
|
|
990 |
|
|
|
991 |
// Mise à jour du stock
|
|
|
992 |
updateStock(id);
|
|
|
993 |
} catch (Exception e) {
|
|
|
994 |
ExceptionHandler.handle("Update error", e);
|
|
|
995 |
}
|
|
|
996 |
}
|
|
|
997 |
});
|
149 |
ilm |
998 |
|
|
|
999 |
DemandeAchatItemSQLElement elt = getElement().getDirectory().getElement(DemandeAchatItemSQLElement.class);
|
|
|
1000 |
elt.updateStatus(getTable(), getTable().getTable("COMMANDE_ELEMENT"), getSelectedID());
|
|
|
1001 |
|
18 |
ilm |
1002 |
// generation du document
|
83 |
ilm |
1003 |
final CommandeXmlSheet sheet = new CommandeXmlSheet(getTable().getRow(id));
|
25 |
ilm |
1004 |
sheet.createDocumentAsynchronous();
|
94 |
ilm |
1005 |
sheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true);
|
25 |
ilm |
1006 |
|
18 |
ilm |
1007 |
}
|
|
|
1008 |
|
83 |
ilm |
1009 |
protected String getLibelleStock(SQLRowAccessor row, SQLRowAccessor rowElt) {
|
|
|
1010 |
return "Commande fournisseur N°" + row.getString("NUMERO");
|
|
|
1011 |
}
|
|
|
1012 |
|
|
|
1013 |
/**
|
|
|
1014 |
* Mise à jour des stocks pour chaque article composant la facture
|
|
|
1015 |
*
|
|
|
1016 |
* @throws SQLException
|
|
|
1017 |
*/
|
|
|
1018 |
private void updateStock(int id) throws SQLException {
|
|
|
1019 |
|
|
|
1020 |
SQLRow row = getTable().getRow(id);
|
|
|
1021 |
StockItemsUpdater stockUpdater = new StockItemsUpdater(new StockLabel() {
|
|
|
1022 |
@Override
|
|
|
1023 |
public String getLabel(SQLRowAccessor rowOrigin, SQLRowAccessor rowElt) {
|
|
|
1024 |
return getLibelleStock(rowOrigin, rowElt);
|
|
|
1025 |
}
|
93 |
ilm |
1026 |
}, row, row.getReferentRows(getTable().getTable("COMMANDE_ELEMENT")), TypeStockUpdate.VIRTUAL_RECEPT);
|
83 |
ilm |
1027 |
|
|
|
1028 |
stockUpdater.update();
|
|
|
1029 |
}
|
|
|
1030 |
|
174 |
ilm |
1031 |
@Override
|
|
|
1032 |
public synchronized ValidState getValidState() {
|
|
|
1033 |
if (getTable().contains("ID_TYPE_CMD") && getTable().contains("ID_AFFAIRE") && getTable().getTable("COMMANDE_ELEMENT").contains("ID_AFFAIRE")) {
|
|
|
1034 |
SQLRequestComboBox boxAff = (SQLRequestComboBox) getView("ID_AFFAIRE").getComp();
|
|
|
1035 |
final SQLRow selectedAff = boxAff.getSelectedRow();
|
|
|
1036 |
if (selectedAff == null || selectedAff.isUndefined()) {
|
|
|
1037 |
RowValuesTableModel tableRow = this.table.getRowValuesTable().getRowValuesTableModel();
|
|
|
1038 |
|
|
|
1039 |
for (int i = 0; i < tableRow.getRowCount(); i++) {
|
|
|
1040 |
SQLRowValues rowVals = tableRow.getRowValuesAt(i);
|
|
|
1041 |
if (rowVals.getInt("QTE") != 0 && (rowVals.getObject("ID_AFFAIRE") == null || rowVals.isForeignEmpty("ID_AFFAIRE"))) {
|
|
|
1042 |
return ValidState.create(false, "Aucune affaire globale sélectionnée et une ligne avec une quantité > 0 n'est pas affectée à une affaire!");
|
|
|
1043 |
}
|
|
|
1044 |
}
|
|
|
1045 |
} else {
|
|
|
1046 |
ValidState.create(false, "Aucune affaire globale sélectionnée!");
|
|
|
1047 |
}
|
|
|
1048 |
}
|
|
|
1049 |
return super.getValidState();
|
|
|
1050 |
}
|
|
|
1051 |
|
18 |
ilm |
1052 |
public void setDefaults() {
|
|
|
1053 |
this.resetValue();
|
90 |
ilm |
1054 |
this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
|
18 |
ilm |
1055 |
this.table.getModel().clearRows();
|
|
|
1056 |
}
|
|
|
1057 |
|
|
|
1058 |
@Override
|
|
|
1059 |
protected SQLRowValues createDefaults() {
|
|
|
1060 |
SQLRowValues rowVals = new SQLRowValues(getTable());
|
|
|
1061 |
rowVals.put("T_POIDS", 0.0F);
|
19 |
ilm |
1062 |
rowVals.put("EN_COURS", Boolean.TRUE);
|
18 |
ilm |
1063 |
|
|
|
1064 |
// User
|
|
|
1065 |
// SQLSelect sel = new SQLSelect(Configuration.getInstance().getBase());
|
|
|
1066 |
SQLElement eltComm = Configuration.getInstance().getDirectory().getElement("COMMERCIAL");
|
|
|
1067 |
int idUser = UserManager.getInstance().getCurrentUser().getId();
|
|
|
1068 |
|
|
|
1069 |
// sel.addSelect(eltComm.getTable().getKey());
|
|
|
1070 |
// sel.setWhere(new Where(eltComm.getTable().getField("ID_USER_COMMON"), "=", idUser));
|
|
|
1071 |
// List<SQLRow> rowsComm = (List<SQLRow>)
|
|
|
1072 |
// Configuration.getInstance().getBase().getDataSource().execute(sel.asString(), new
|
|
|
1073 |
// SQLRowListRSH(eltComm.getTable()));
|
|
|
1074 |
SQLRow rowsComm = SQLBackgroundTableCache.getInstance().getCacheForTable(eltComm.getTable()).getFirstRowContains(idUser, eltComm.getTable().getField("ID_USER_COMMON"));
|
|
|
1075 |
|
|
|
1076 |
if (rowsComm != null) {
|
|
|
1077 |
rowVals.put("ID_COMMERCIAL", rowsComm.getID());
|
|
|
1078 |
}
|
|
|
1079 |
rowVals.put("T_HT", Long.valueOf(0));
|
|
|
1080 |
rowVals.put("T_SERVICE", Long.valueOf(0));
|
28 |
ilm |
1081 |
rowVals.put("T_DEVISE", Long.valueOf(0));
|
18 |
ilm |
1082 |
rowVals.put("T_TVA", Long.valueOf(0));
|
|
|
1083 |
rowVals.put("T_TTC", Long.valueOf(0));
|
90 |
ilm |
1084 |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
|
18 |
ilm |
1085 |
|
65 |
ilm |
1086 |
if (getTable().contains("ID_TAXE_PORT")) {
|
80 |
ilm |
1087 |
rowVals.put("ID_TAXE_PORT", TaxeCache.getCache().getFirstTaxe().getID());
|
65 |
ilm |
1088 |
}
|
132 |
ilm |
1089 |
if (getTable().contains("LIVRAISON_F") && componentPrincipaleAdr != null) {
|
|
|
1090 |
componentPrincipaleAdr.setEditable(InteractionMode.DISABLED);
|
|
|
1091 |
}
|
65 |
ilm |
1092 |
|
18 |
ilm |
1093 |
return rowVals;
|
|
|
1094 |
}
|
19 |
ilm |
1095 |
|
90 |
ilm |
1096 |
public CommandeItemTable getRowValuesTablePanel() {
|
|
|
1097 |
return this.table;
|
|
|
1098 |
}
|
|
|
1099 |
|
73 |
ilm |
1100 |
@Override
|
|
|
1101 |
public RowValuesTable getRowValuesTable() {
|
|
|
1102 |
return this.table.getRowValuesTable();
|
19 |
ilm |
1103 |
}
|
|
|
1104 |
|
|
|
1105 |
/**
|
|
|
1106 |
* Chargement des éléments d'une commande dans la table
|
|
|
1107 |
*
|
|
|
1108 |
* @param idCommande
|
|
|
1109 |
*
|
|
|
1110 |
*/
|
|
|
1111 |
public void loadCommande(int idCommande) {
|
|
|
1112 |
|
|
|
1113 |
SQLElement commande = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT");
|
|
|
1114 |
SQLElement commandeElt = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT_ELEMENT");
|
|
|
1115 |
|
|
|
1116 |
if (idCommande > 1) {
|
|
|
1117 |
SQLInjector injector = SQLInjector.getInjector(commande.getTable(), this.getTable());
|
|
|
1118 |
this.select(injector.createRowValuesFrom(idCommande));
|
|
|
1119 |
}
|
|
|
1120 |
|
|
|
1121 |
loadItem(this.table, commande, idCommande, commandeElt);
|
|
|
1122 |
}
|
|
|
1123 |
|
|
|
1124 |
/**
|
|
|
1125 |
* Chargement des éléments d'un devis dans la table
|
|
|
1126 |
*
|
|
|
1127 |
* @param idDevis
|
|
|
1128 |
*
|
|
|
1129 |
*/
|
|
|
1130 |
public void loadDevis(int idDevis) {
|
|
|
1131 |
|
|
|
1132 |
SQLElement devis = Configuration.getInstance().getDirectory().getElement("DEVIS");
|
|
|
1133 |
SQLElement devisElt = Configuration.getInstance().getDirectory().getElement("DEVIS_ELEMENT");
|
|
|
1134 |
|
|
|
1135 |
if (idDevis > 1) {
|
|
|
1136 |
SQLInjector injector = SQLInjector.getInjector(devis.getTable(), this.getTable());
|
|
|
1137 |
this.select(injector.createRowValuesFrom(idDevis));
|
|
|
1138 |
}
|
|
|
1139 |
|
|
|
1140 |
loadItem(this.table, devis, idDevis, devisElt);
|
|
|
1141 |
}
|
|
|
1142 |
|
|
|
1143 |
/**
|
|
|
1144 |
* Chargement des éléments d'une facture dans la table
|
|
|
1145 |
*
|
|
|
1146 |
* @param idFact
|
|
|
1147 |
*
|
|
|
1148 |
*/
|
|
|
1149 |
public void loadFacture(int idFact) {
|
|
|
1150 |
|
|
|
1151 |
SQLElement facture = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
|
|
|
1152 |
SQLElement factureElt = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE_ELEMENT");
|
|
|
1153 |
|
|
|
1154 |
if (idFact > 1) {
|
|
|
1155 |
SQLInjector injector = SQLInjector.getInjector(facture.getTable(), this.getTable());
|
|
|
1156 |
this.select(injector.createRowValuesFrom(idFact));
|
|
|
1157 |
}
|
|
|
1158 |
|
|
|
1159 |
loadItem(this.table, facture, idFact, factureElt);
|
|
|
1160 |
}
|
|
|
1161 |
|
93 |
ilm |
1162 |
@Override
|
|
|
1163 |
protected void refreshAfterSelect(SQLRowAccessor rSource) {
|
|
|
1164 |
if (this.dateCommande.getValue() != null) {
|
|
|
1165 |
this.table.setDateDevise(this.dateCommande.getValue());
|
|
|
1166 |
}
|
|
|
1167 |
|
|
|
1168 |
}
|
156 |
ilm |
1169 |
|
|
|
1170 |
public void duplicate(final int idCmd) {
|
|
|
1171 |
|
|
|
1172 |
final SQLElement cmd = Configuration.getInstance().getDirectory().getElement("COMMANDE");
|
|
|
1173 |
final SQLElement cmdElt = Configuration.getInstance().getDirectory().getElement("COMMANDE_ELEMENT");
|
|
|
1174 |
|
|
|
1175 |
if (idCmd > 1) {
|
|
|
1176 |
final SQLRow row = cmd.getTable().getRow(idCmd);
|
|
|
1177 |
final SQLRowValues rowVals = new SQLRowValues(cmd.getTable());
|
|
|
1178 |
rowVals.put("ID_FOURNISSEUR", row.getInt("ID_FOURNISSEUR"));
|
|
|
1179 |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
|
|
|
1180 |
|
|
|
1181 |
this.select(rowVals);
|
|
|
1182 |
}
|
|
|
1183 |
|
|
|
1184 |
final List<SQLRow> myListItem = cmd.getTable().getRow(idCmd).getReferentRows(cmdElt.getTable());
|
|
|
1185 |
|
|
|
1186 |
if (myListItem.size() != 0) {
|
|
|
1187 |
this.table.getModel().clearRows();
|
|
|
1188 |
|
|
|
1189 |
for (final SQLRow rowElt : myListItem) {
|
|
|
1190 |
|
|
|
1191 |
final SQLRowValues rowVals = rowElt.createUpdateRow();
|
|
|
1192 |
rowVals.clearPrimaryKeys();
|
177 |
ilm |
1193 |
rowVals.put("RECU", Boolean.FALSE);
|
|
|
1194 |
rowVals.put("RECU_FORCED", Boolean.FALSE);
|
|
|
1195 |
rowVals.put("QTE_RECUE", BigDecimal.ZERO);
|
156 |
ilm |
1196 |
this.table.getModel().addRow(rowVals);
|
|
|
1197 |
final int rowIndex = this.table.getModel().getRowCount() - 1;
|
|
|
1198 |
this.table.getModel().fireTableModelModified(rowIndex);
|
|
|
1199 |
}
|
|
|
1200 |
} else {
|
|
|
1201 |
this.table.getModel().clearRows();
|
|
|
1202 |
}
|
|
|
1203 |
this.table.getModel().fireTableDataChanged();
|
|
|
1204 |
this.table.repaint();
|
|
|
1205 |
|
|
|
1206 |
}
|
18 |
ilm |
1207 |
}
|