18 |
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.
|
18 |
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 |
package org.openconcerto.erp.core.sales.quote.component;
|
|
|
15 |
|
41 |
ilm |
16 |
import static org.openconcerto.utils.CollectionUtils.createSet;
|
142 |
ilm |
17 |
|
18 |
ilm |
18 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
63 |
ilm |
19 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
18 |
ilm |
20 |
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
|
73 |
ilm |
21 |
import org.openconcerto.erp.core.common.ui.AbstractArticleItemTable;
|
83 |
ilm |
22 |
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable.TypeCalcul;
|
|
|
23 |
import org.openconcerto.erp.core.common.ui.Acompte;
|
|
|
24 |
import org.openconcerto.erp.core.common.ui.AcompteField;
|
|
|
25 |
import org.openconcerto.erp.core.common.ui.AcompteRowItemView;
|
18 |
ilm |
26 |
import org.openconcerto.erp.core.common.ui.DeviseField;
|
|
|
27 |
import org.openconcerto.erp.core.common.ui.TotalPanel;
|
93 |
ilm |
28 |
import org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI;
|
|
|
29 |
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseType;
|
174 |
ilm |
30 |
import org.openconcerto.erp.core.customerrelationship.customer.ui.CategorieComptableChoiceUI;
|
144 |
ilm |
31 |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
|
18 |
ilm |
32 |
import org.openconcerto.erp.core.sales.quote.element.EtatDevisSQLElement;
|
|
|
33 |
import org.openconcerto.erp.core.sales.quote.report.DevisXmlSheet;
|
|
|
34 |
import org.openconcerto.erp.core.sales.quote.ui.DevisItemTable;
|
21 |
ilm |
35 |
import org.openconcerto.erp.panel.PanelOOSQLComponent;
|
93 |
ilm |
36 |
import org.openconcerto.erp.preferences.GestionClientPreferencePanel;
|
94 |
ilm |
37 |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
|
73 |
ilm |
38 |
import org.openconcerto.map.ui.ITextComboVilleViewer;
|
18 |
ilm |
39 |
import org.openconcerto.sql.Configuration;
|
|
|
40 |
import org.openconcerto.sql.element.BaseSQLComponent;
|
|
|
41 |
import org.openconcerto.sql.element.SQLElement;
|
|
|
42 |
import org.openconcerto.sql.model.SQLBackgroundTableCache;
|
|
|
43 |
import org.openconcerto.sql.model.SQLRow;
|
|
|
44 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
|
|
45 |
import org.openconcerto.sql.model.SQLRowValues;
|
90 |
ilm |
46 |
import org.openconcerto.sql.model.SQLSelect;
|
18 |
ilm |
47 |
import org.openconcerto.sql.model.SQLTable;
|
65 |
ilm |
48 |
import org.openconcerto.sql.model.UndefinedRowValuesCache;
|
73 |
ilm |
49 |
import org.openconcerto.sql.model.Where;
|
93 |
ilm |
50 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
18 |
ilm |
51 |
import org.openconcerto.sql.sqlobject.ElementComboBox;
|
|
|
52 |
import org.openconcerto.sql.sqlobject.JUniqueTextField;
|
142 |
ilm |
53 |
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
|
18 |
ilm |
54 |
import org.openconcerto.sql.sqlobject.SQLTextCombo;
|
182 |
ilm |
55 |
import org.openconcerto.sql.sqlobject.itemview.SimpleRowItemView;
|
18 |
ilm |
56 |
import org.openconcerto.sql.ui.RadioButtons;
|
|
|
57 |
import org.openconcerto.sql.users.UserManager;
|
142 |
ilm |
58 |
import org.openconcerto.sql.users.rights.UserRightsManager;
|
18 |
ilm |
59 |
import org.openconcerto.sql.view.EditFrame;
|
|
|
60 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
25 |
ilm |
61 |
import org.openconcerto.ui.FormLayouter;
|
18 |
ilm |
62 |
import org.openconcerto.ui.JDate;
|
|
|
63 |
import org.openconcerto.ui.TitledSeparator;
|
|
|
64 |
import org.openconcerto.ui.VFlowLayout;
|
|
|
65 |
import org.openconcerto.ui.component.ITextArea;
|
182 |
ilm |
66 |
import org.openconcerto.ui.valuewrapper.ValidatedValueWrapper;
|
18 |
ilm |
67 |
import org.openconcerto.utils.ExceptionHandler;
|
90 |
ilm |
68 |
import org.openconcerto.utils.GestionDevise;
|
73 |
ilm |
69 |
import org.openconcerto.utils.cc.ITransformer;
|
90 |
ilm |
70 |
import org.openconcerto.utils.checks.ValidState;
|
18 |
ilm |
71 |
import org.openconcerto.utils.text.SimpleDocumentListener;
|
|
|
72 |
|
|
|
73 |
import java.awt.Color;
|
|
|
74 |
import java.awt.Dimension;
|
|
|
75 |
import java.awt.GridBagConstraints;
|
|
|
76 |
import java.awt.GridBagLayout;
|
|
|
77 |
import java.awt.Insets;
|
73 |
ilm |
78 |
import java.awt.event.ItemEvent;
|
|
|
79 |
import java.awt.event.ItemListener;
|
90 |
ilm |
80 |
import java.awt.event.MouseEvent;
|
19 |
ilm |
81 |
import java.beans.PropertyChangeEvent;
|
|
|
82 |
import java.beans.PropertyChangeListener;
|
18 |
ilm |
83 |
import java.sql.SQLException;
|
19 |
ilm |
84 |
import java.util.Calendar;
|
90 |
ilm |
85 |
import java.util.Date;
|
|
|
86 |
import java.util.HashSet;
|
18 |
ilm |
87 |
import java.util.List;
|
90 |
ilm |
88 |
import java.util.Set;
|
18 |
ilm |
89 |
|
|
|
90 |
import javax.swing.BorderFactory;
|
|
|
91 |
import javax.swing.ButtonGroup;
|
73 |
ilm |
92 |
import javax.swing.JCheckBox;
|
18 |
ilm |
93 |
import javax.swing.JLabel;
|
19 |
ilm |
94 |
import javax.swing.JOptionPane;
|
18 |
ilm |
95 |
import javax.swing.JPanel;
|
|
|
96 |
import javax.swing.JRadioButton;
|
|
|
97 |
import javax.swing.JScrollPane;
|
73 |
ilm |
98 |
import javax.swing.JTabbedPane;
|
18 |
ilm |
99 |
import javax.swing.JTextField;
|
|
|
100 |
import javax.swing.SwingConstants;
|
|
|
101 |
import javax.swing.SwingUtilities;
|
142 |
ilm |
102 |
import javax.swing.SwingWorker;
|
18 |
ilm |
103 |
import javax.swing.event.ChangeEvent;
|
|
|
104 |
import javax.swing.event.ChangeListener;
|
|
|
105 |
import javax.swing.event.DocumentEvent;
|
|
|
106 |
import javax.swing.event.TableModelEvent;
|
|
|
107 |
import javax.swing.event.TableModelListener;
|
|
|
108 |
|
|
|
109 |
public class DevisSQLComponent extends BaseSQLComponent {
|
73 |
ilm |
110 |
private AbstractArticleItemTable table;
|
18 |
ilm |
111 |
private JUniqueTextField numeroUniqueDevis;
|
|
|
112 |
private final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO");
|
|
|
113 |
private final ITextArea infos = new ITextArea();
|
|
|
114 |
private final RadioButtons radioEtat = new RadioButtons("NOM");
|
|
|
115 |
private JTextField textPourcentRemise, textPoidsTotal;
|
|
|
116 |
private DeviseField textRemiseHT;
|
|
|
117 |
private DeviseField fieldHT;
|
21 |
ilm |
118 |
private PanelOOSQLComponent panelOO;
|
18 |
ilm |
119 |
|
73 |
ilm |
120 |
// Site d'intervention
|
|
|
121 |
final JTextField telSite = new JTextField(20);
|
|
|
122 |
final ITextComboVilleViewer villeSite = new ITextComboVilleViewer();
|
|
|
123 |
final JTextField faxSite = new JTextField(20);
|
|
|
124 |
final JTextField telPSite = new JTextField(20);
|
|
|
125 |
final JTextField mailSite = new JTextField(20);
|
|
|
126 |
final JTextField contactSite = new JTextField(20);
|
|
|
127 |
final JTextField desSite = new JTextField(20);
|
|
|
128 |
final ITextArea adrSite = new ITextArea();
|
|
|
129 |
|
|
|
130 |
// Donneur d'ordre
|
|
|
131 |
final JTextField telDonneur = new JTextField(20);
|
|
|
132 |
final JTextField sirenDonneur = new JTextField(20);
|
|
|
133 |
final ITextComboVilleViewer villeDonneur = new ITextComboVilleViewer();
|
|
|
134 |
final JTextField faxDonneur = new JTextField(20);
|
|
|
135 |
final JTextField telPDonneur = new JTextField(20);
|
|
|
136 |
final JTextField mailDonneur = new JTextField(20);
|
|
|
137 |
final JTextField contactDonneur = new JTextField(20);
|
|
|
138 |
final JTextField desDonneur = new JTextField(20);
|
|
|
139 |
final ITextArea adrDonneur = new ITextArea();
|
93 |
ilm |
140 |
private final boolean displayDpt;
|
73 |
ilm |
141 |
|
93 |
ilm |
142 |
private final ElementComboBox comboDpt = new ElementComboBox(false, 25);
|
|
|
143 |
|
18 |
ilm |
144 |
public DevisSQLComponent(final SQLElement elt) {
|
|
|
145 |
super(elt);
|
93 |
ilm |
146 |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
|
|
|
147 |
this.displayDpt = prefs.getBoolean(GestionClientPreferencePanel.DISPLAY_CLIENT_DPT, false);
|
18 |
ilm |
148 |
}
|
|
|
149 |
|
73 |
ilm |
150 |
public AbstractArticleItemTable getRowValuesTable() {
|
61 |
ilm |
151 |
return this.table;
|
|
|
152 |
}
|
|
|
153 |
|
18 |
ilm |
154 |
@Override
|
90 |
ilm |
155 |
public Set<String> getPartialResetNames() {
|
|
|
156 |
Set<String> s = new HashSet<String>();
|
|
|
157 |
s.add("OBJET");
|
|
|
158 |
s.add("NUMERO");
|
|
|
159 |
return s;
|
|
|
160 |
}
|
|
|
161 |
|
93 |
ilm |
162 |
private final JDate dateDevis = new JDate(true);
|
|
|
163 |
|
90 |
ilm |
164 |
@Override
|
18 |
ilm |
165 |
public void addViews() {
|
|
|
166 |
setLayout(new GridBagLayout());
|
|
|
167 |
final GridBagConstraints c = new DefaultGridBagConstraints();
|
|
|
168 |
|
25 |
ilm |
169 |
// Champ Module
|
|
|
170 |
c.gridx = 0;
|
|
|
171 |
c.gridy++;
|
|
|
172 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
63 |
ilm |
173 |
final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
|
41 |
ilm |
174 |
this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
|
25 |
ilm |
175 |
this.add(addP, c);
|
|
|
176 |
|
|
|
177 |
c.gridy++;
|
|
|
178 |
c.gridwidth = 1;
|
18 |
ilm |
179 |
final JLabel labelNumero = new JLabel(getLabelFor("NUMERO"));
|
|
|
180 |
labelNumero.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
181 |
this.add(labelNumero, c);
|
|
|
182 |
|
|
|
183 |
// Ligne 1: Numero du devis
|
|
|
184 |
|
|
|
185 |
c.gridx++;
|
|
|
186 |
c.weightx = 1;
|
|
|
187 |
c.fill = GridBagConstraints.NONE;
|
142 |
ilm |
188 |
this.numeroUniqueDevis = new JUniqueTextField(15) {
|
|
|
189 |
@Override
|
|
|
190 |
public String getAutoRefreshNumber() {
|
|
|
191 |
if (getMode() == Mode.INSERTION) {
|
|
|
192 |
return NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), dateDevis.getDate());
|
|
|
193 |
} else {
|
|
|
194 |
return null;
|
|
|
195 |
}
|
|
|
196 |
}
|
|
|
197 |
};
|
90 |
ilm |
198 |
|
18 |
ilm |
199 |
DefaultGridBagConstraints.lockMinimumSize(this.numeroUniqueDevis);
|
|
|
200 |
DefaultGridBagConstraints.lockMaximumSize(this.numeroUniqueDevis);
|
|
|
201 |
this.add(this.numeroUniqueDevis, c);
|
|
|
202 |
|
|
|
203 |
// Date
|
|
|
204 |
|
|
|
205 |
c.gridx++;
|
|
|
206 |
c.weightx = 0;
|
|
|
207 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
208 |
final JLabel labelDate = new JLabel(getLabelFor("DATE"));
|
|
|
209 |
|
|
|
210 |
labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
211 |
|
|
|
212 |
this.add(labelDate, c);
|
|
|
213 |
c.gridx++;
|
|
|
214 |
|
|
|
215 |
c.weightx = 1;
|
|
|
216 |
|
|
|
217 |
c.fill = GridBagConstraints.NONE;
|
93 |
ilm |
218 |
this.add(this.dateDevis, c);
|
18 |
ilm |
219 |
|
93 |
ilm |
220 |
this.dateDevis.addValueListener(new PropertyChangeListener() {
|
|
|
221 |
|
|
|
222 |
@Override
|
|
|
223 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
224 |
if (!isFilling() && dateDevis.getValue() != null) {
|
|
|
225 |
table.setDateDevise(dateDevis.getValue());
|
|
|
226 |
}
|
|
|
227 |
}
|
|
|
228 |
});
|
|
|
229 |
|
18 |
ilm |
230 |
// Etat devis
|
|
|
231 |
this.radioEtat.setLayout(new VFlowLayout());
|
|
|
232 |
this.radioEtat.setBorder(BorderFactory.createTitledBorder(getLabelFor("ID_ETAT_DEVIS")));
|
|
|
233 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
61 |
ilm |
234 |
c.gridheight = 5;
|
18 |
ilm |
235 |
c.weightx = 0;
|
|
|
236 |
c.fill = GridBagConstraints.NONE;
|
|
|
237 |
c.anchor = GridBagConstraints.EAST;
|
|
|
238 |
c.gridx += 2;
|
73 |
ilm |
239 |
this.radioEtat.initLocalization(new ITransformer<String, String>() {
|
|
|
240 |
@Override
|
|
|
241 |
public String transformChecked(String id) {
|
|
|
242 |
return id;
|
|
|
243 |
// return TranslationManager.getInstance().getTranslationForItem(id);
|
|
|
244 |
}
|
|
|
245 |
});
|
18 |
ilm |
246 |
this.add(this.radioEtat, c);
|
41 |
ilm |
247 |
// this.radioEtat.setVisible(false);
|
18 |
ilm |
248 |
|
|
|
249 |
// Ligne 2: Reference
|
|
|
250 |
c.gridx = 0;
|
|
|
251 |
c.gridy++;
|
|
|
252 |
c.gridwidth = 1;
|
|
|
253 |
c.gridheight = 1;
|
|
|
254 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
255 |
|
|
|
256 |
c.weightx = 0;
|
|
|
257 |
|
|
|
258 |
final JLabel labelObjet = new JLabel(getLabelFor("OBJET"));
|
|
|
259 |
labelObjet.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
260 |
|
|
|
261 |
this.add(labelObjet, c);
|
|
|
262 |
|
|
|
263 |
final SQLTextCombo textObjet = new SQLTextCombo();
|
|
|
264 |
c.gridx++;
|
|
|
265 |
c.weightx = 1;
|
|
|
266 |
c.gridwidth = 1;
|
|
|
267 |
c.fill = GridBagConstraints.BOTH;
|
|
|
268 |
this.add(textObjet, c);
|
|
|
269 |
|
|
|
270 |
String field;
|
|
|
271 |
field = "ID_COMMERCIAL";
|
|
|
272 |
// Commercial
|
|
|
273 |
final JLabel labelCommercial = new JLabel(getLabelFor(field));
|
|
|
274 |
labelCommercial.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
275 |
c.gridx++;
|
|
|
276 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
277 |
c.weightx = 0;
|
|
|
278 |
|
|
|
279 |
this.add(labelCommercial, c);
|
|
|
280 |
|
|
|
281 |
final ElementComboBox comboCommercial = new ElementComboBox(false, 25);
|
|
|
282 |
|
|
|
283 |
comboCommercial.setListIconVisible(false);
|
|
|
284 |
c.gridx++;
|
|
|
285 |
c.weightx = 1;
|
|
|
286 |
c.fill = GridBagConstraints.NONE;
|
|
|
287 |
c.anchor = GridBagConstraints.WEST;
|
|
|
288 |
|
|
|
289 |
this.add(comboCommercial, c);
|
|
|
290 |
addRequiredSQLObject(comboCommercial, field);
|
|
|
291 |
|
|
|
292 |
// Ligne 3: Client
|
|
|
293 |
c.gridx = 0;
|
|
|
294 |
c.gridy++;
|
|
|
295 |
c.gridwidth = 1;
|
|
|
296 |
final JLabel labelClient = new JLabel(getLabelFor("ID_CLIENT"));
|
|
|
297 |
labelClient.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
298 |
c.weightx = 0;
|
|
|
299 |
c.gridwidth = 1;
|
|
|
300 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
301 |
this.add(labelClient, c);
|
|
|
302 |
|
182 |
ilm |
303 |
final ValidatedValueWrapper<Integer> clientValidatedValueWrapper = ValidatedValueWrapper.add(new ElementComboBox(), new ITransformer<Integer, ValidState>() {
|
|
|
304 |
@Override
|
|
|
305 |
public ValidState transformChecked(Integer t) {
|
|
|
306 |
ElementComboBox boxClient = (ElementComboBox) getView("ID_CLIENT").getComp();
|
|
|
307 |
if (getMode() == Mode.INSERTION && boxClient != null && !boxClient.isEmpty() && boxClient.getSelectedRow().getBoolean("BLOQUE")) {
|
|
|
308 |
return ValidState.create(false, "Les intéractions avec ce client sont verrouillées.");
|
|
|
309 |
} else {
|
|
|
310 |
return ValidState.getTrueInstance();
|
|
|
311 |
}
|
|
|
312 |
}
|
|
|
313 |
});
|
|
|
314 |
final ElementComboBox comboClient = (ElementComboBox) clientValidatedValueWrapper.getComp();
|
|
|
315 |
|
|
|
316 |
addView(new SimpleRowItemView<Integer>(clientValidatedValueWrapper), "ID_CLIENT", REQ);
|
18 |
ilm |
317 |
c.gridx++;
|
19 |
ilm |
318 |
c.gridwidth = 1;
|
18 |
ilm |
319 |
c.weightx = 0;
|
|
|
320 |
c.weighty = 0;
|
|
|
321 |
c.fill = GridBagConstraints.NONE;
|
|
|
322 |
this.add(comboClient, c);
|
73 |
ilm |
323 |
|
94 |
ilm |
324 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
|
|
325 |
|
|
|
326 |
@Override
|
|
|
327 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
328 |
int wantedID = comboClient.getWantedID();
|
|
|
329 |
|
|
|
330 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
|
|
331 |
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID);
|
|
|
332 |
if (!rowClient.isForeignEmpty("ID_COMMERCIAL")) {
|
|
|
333 |
comboCommercial.setValue(rowClient.getForeignID("ID_COMMERCIAL"));
|
|
|
334 |
}
|
182 |
ilm |
335 |
String alerte = rowClient.getString("ALERTE");
|
|
|
336 |
if (!isFilling() && alerte != null && alerte.trim().length() > 0) {
|
|
|
337 |
JOptionPane.showMessageDialog(comboClient, alerte);
|
|
|
338 |
}
|
94 |
ilm |
339 |
}
|
|
|
340 |
}
|
|
|
341 |
});
|
93 |
ilm |
342 |
if (this.displayDpt) {
|
|
|
343 |
c.gridx++;
|
|
|
344 |
c.gridwidth = 1;
|
|
|
345 |
final JLabel labelDpt = new JLabel(getLabelFor("ID_CLIENT_DEPARTEMENT"));
|
|
|
346 |
labelDpt.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
347 |
c.weightx = 0;
|
|
|
348 |
c.gridwidth = 1;
|
|
|
349 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
350 |
this.add(labelDpt, c);
|
|
|
351 |
|
|
|
352 |
c.gridx++;
|
|
|
353 |
c.gridwidth = 1;
|
|
|
354 |
c.weightx = 0;
|
|
|
355 |
c.weighty = 0;
|
|
|
356 |
c.fill = GridBagConstraints.NONE;
|
|
|
357 |
this.add(this.comboDpt, c);
|
|
|
358 |
DefaultGridBagConstraints.lockMinimumSize(this.comboDpt);
|
|
|
359 |
addSQLObject(this.comboDpt, "ID_CLIENT_DEPARTEMENT");
|
|
|
360 |
|
|
|
361 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
|
|
362 |
|
|
|
363 |
@Override
|
|
|
364 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
365 |
int wantedID = comboClient.getWantedID();
|
|
|
366 |
|
|
|
367 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
|
|
368 |
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID);
|
|
|
369 |
comboDpt.getRequest().setWhere(new Where(comboDpt.getRequest().getPrimaryTable().getField("ID_CLIENT"), "=", rowClient.getID()));
|
|
|
370 |
} else {
|
|
|
371 |
comboDpt.getRequest().setWhere(null);
|
|
|
372 |
}
|
|
|
373 |
}
|
|
|
374 |
});
|
|
|
375 |
|
|
|
376 |
}
|
149 |
ilm |
377 |
final SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
|
93 |
ilm |
378 |
|
19 |
ilm |
379 |
final ElementComboBox boxTarif = new ElementComboBox();
|
149 |
ilm |
380 |
|
94 |
ilm |
381 |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.ADDRESS_SPEC, true)) {
|
93 |
ilm |
382 |
|
94 |
ilm |
383 |
final SQLElement adrElement = getElement().getForeignElement("ID_ADRESSE");
|
|
|
384 |
final AddressChoiceUI addressUI = new AddressChoiceUI();
|
|
|
385 |
addressUI.addToUI(this, c);
|
|
|
386 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
93 |
ilm |
387 |
|
94 |
ilm |
388 |
@Override
|
|
|
389 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
390 |
int wantedID = comboClient.getWantedID();
|
|
|
391 |
System.err.println("SET WHERE ID_CLIENT = " + wantedID);
|
|
|
392 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
93 |
ilm |
393 |
|
132 |
ilm |
394 |
addressUI.getComboAdrF().getRequest().setWhere(
|
|
|
395 |
new Where(adrElement.getTable().getField("ID_CLIENT"), "=", wantedID).and(new Where(adrElement.getTable().getField("TYPE"), "=", AdresseType.Invoice.getId())));
|
|
|
396 |
addressUI.getComboAdrL().getRequest().setWhere(
|
|
|
397 |
new Where(adrElement.getTable().getField("ID_CLIENT"), "=", wantedID).and(new Where(adrElement.getTable().getField("TYPE"), "=", AdresseType.Delivery.getId())));
|
94 |
ilm |
398 |
} else {
|
|
|
399 |
addressUI.getComboAdrF().getRequest().setWhere(Where.FALSE);
|
|
|
400 |
addressUI.getComboAdrL().getRequest().setWhere(Where.FALSE);
|
|
|
401 |
}
|
93 |
ilm |
402 |
}
|
94 |
ilm |
403 |
});
|
|
|
404 |
}
|
174 |
ilm |
405 |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.CATEGORIE_COMPTABLE_SPEC, false)) {
|
|
|
406 |
// cat spe
|
|
|
407 |
final CategorieComptableChoiceUI catUI = new CategorieComptableChoiceUI();
|
|
|
408 |
catUI.addToUI(this, c);
|
|
|
409 |
catUI.getCombo().addModelListener("wantedID", new PropertyChangeListener() {
|
|
|
410 |
|
|
|
411 |
@Override
|
|
|
412 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
413 |
int wantedID = catUI.getCombo().getWantedID();
|
|
|
414 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
|
|
415 |
table.setRowCatComptable(catUI.getCombo().getElement().getTable().getRow(wantedID));
|
|
|
416 |
} else {
|
|
|
417 |
table.setRowCatComptable(null);
|
|
|
418 |
}
|
|
|
419 |
}
|
|
|
420 |
});
|
|
|
421 |
}
|
83 |
ilm |
422 |
if (getTable().contains("ID_CONTACT")) {
|
|
|
423 |
// Contact Client
|
|
|
424 |
c.gridx = 0;
|
|
|
425 |
c.gridy++;
|
|
|
426 |
c.gridwidth = 1;
|
|
|
427 |
final JLabel labelContact = new JLabel(getLabelFor("ID_CONTACT"));
|
|
|
428 |
labelContact.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
429 |
c.weightx = 0;
|
|
|
430 |
c.gridwidth = 1;
|
|
|
431 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
432 |
this.add(labelContact, c);
|
18 |
ilm |
433 |
|
83 |
ilm |
434 |
final ElementComboBox comboContact = new ElementComboBox();
|
|
|
435 |
c.gridx++;
|
|
|
436 |
c.gridwidth = 1;
|
|
|
437 |
c.weightx = 0;
|
|
|
438 |
c.weighty = 0;
|
|
|
439 |
c.fill = GridBagConstraints.NONE;
|
|
|
440 |
this.add(comboContact, c);
|
|
|
441 |
final SQLElement contactElement = getElement().getForeignElement("ID_CONTACT");
|
|
|
442 |
comboContact.init(contactElement, contactElement.getComboRequest(true));
|
93 |
ilm |
443 |
comboContact.getRequest().setWhere(Where.FALSE);
|
83 |
ilm |
444 |
DefaultGridBagConstraints.lockMinimumSize(comboContact);
|
|
|
445 |
this.addView(comboContact, "ID_CONTACT");
|
|
|
446 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
|
|
447 |
|
|
|
448 |
@Override
|
|
|
449 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
450 |
int wantedID = comboClient.getWantedID();
|
|
|
451 |
System.err.println("SET WHERE ID_CLIENT = " + wantedID);
|
|
|
452 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
|
|
453 |
|
|
|
454 |
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID);
|
|
|
455 |
int idClient = rowClient.getID();
|
|
|
456 |
comboContact.getRequest().setWhere(new Where(contactElement.getTable().getField("ID_CLIENT"), "=", idClient));
|
174 |
ilm |
457 |
|
180 |
ilm |
458 |
table.setClient(rowClient, !isFilling());
|
|
|
459 |
|
83 |
ilm |
460 |
} else {
|
93 |
ilm |
461 |
comboContact.getRequest().setWhere(Where.FALSE);
|
174 |
ilm |
462 |
if (!isFilling()) {
|
|
|
463 |
table.setClient(null, true);
|
|
|
464 |
}
|
83 |
ilm |
465 |
DevisSQLComponent.this.table.setTarif(null, false);
|
|
|
466 |
}
|
|
|
467 |
}
|
|
|
468 |
});
|
|
|
469 |
|
|
|
470 |
}
|
|
|
471 |
|
19 |
ilm |
472 |
if (getTable().getFieldsName().contains("DATE_VALIDITE")) {
|
|
|
473 |
c.gridx++;
|
93 |
ilm |
474 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
475 |
this.add(new JLabel(getLabelFor("DATE_VALIDITE"), SwingConstants.RIGHT), c);
|
|
|
476 |
c.fill = GridBagConstraints.NONE;
|
19 |
ilm |
477 |
c.gridx++;
|
|
|
478 |
JDate dateValidite = new JDate();
|
|
|
479 |
this.add(dateValidite, c);
|
|
|
480 |
this.addView(dateValidite, "DATE_VALIDITE");
|
|
|
481 |
}
|
|
|
482 |
|
182 |
ilm |
483 |
if (getTable().getFieldsName().contains("DATE_LIVRAISON")) {
|
|
|
484 |
c.gridy++;
|
|
|
485 |
c.gridx = 0;
|
|
|
486 |
final JLabel labelTrans = new JLabel(getLabelFor("TRANSFORMATION"));
|
|
|
487 |
labelTrans.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
488 |
|
|
|
489 |
this.add(labelTrans, c);
|
|
|
490 |
|
|
|
491 |
final SQLTextCombo textTrans = new SQLTextCombo();
|
|
|
492 |
c.gridx++;
|
|
|
493 |
c.weightx = 1;
|
|
|
494 |
c.gridwidth = 1;
|
|
|
495 |
c.fill = GridBagConstraints.BOTH;
|
|
|
496 |
this.add(textTrans, c);
|
|
|
497 |
this.addView(textTrans, "TRANSFORMATION");
|
|
|
498 |
|
|
|
499 |
c.gridx++;
|
|
|
500 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
501 |
this.add(new JLabel(getLabelFor("DATE_LIVRAISON"), SwingConstants.RIGHT), c);
|
|
|
502 |
c.fill = GridBagConstraints.NONE;
|
|
|
503 |
c.gridx++;
|
|
|
504 |
JDate dateLivraison = new JDate();
|
|
|
505 |
this.add(dateLivraison, c);
|
|
|
506 |
this.addView(dateLivraison, "DATE_LIVRAISON");
|
|
|
507 |
|
|
|
508 |
}
|
|
|
509 |
|
19 |
ilm |
510 |
// Tarif
|
|
|
511 |
if (this.getTable().getFieldsName().contains("ID_TARIF")) {
|
|
|
512 |
// TARIF
|
|
|
513 |
c.gridy++;
|
|
|
514 |
c.gridx = 0;
|
|
|
515 |
c.weightx = 0;
|
|
|
516 |
c.weighty = 0;
|
|
|
517 |
c.gridwidth = 1;
|
93 |
ilm |
518 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
519 |
JLabel comp = new JLabel(getLabelFor("ID_TARIF"), SwingConstants.RIGHT);
|
61 |
ilm |
520 |
this.add(comp, c);
|
19 |
ilm |
521 |
c.gridx++;
|
93 |
ilm |
522 |
c.fill = GridBagConstraints.NONE;
|
19 |
ilm |
523 |
c.weightx = 1;
|
|
|
524 |
this.add(boxTarif, c);
|
|
|
525 |
this.addView(boxTarif, "ID_TARIF");
|
|
|
526 |
DefaultGridBagConstraints.lockMinimumSize(boxTarif);
|
73 |
ilm |
527 |
boxTarif.addModelListener("wantedID", new PropertyChangeListener() {
|
19 |
ilm |
528 |
|
|
|
529 |
@Override
|
|
|
530 |
public void propertyChange(PropertyChangeEvent evt) {
|
73 |
ilm |
531 |
|
|
|
532 |
SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID());
|
|
|
533 |
table.setTarif(selectedRow, !isFilling());
|
19 |
ilm |
534 |
}
|
|
|
535 |
});
|
93 |
ilm |
536 |
if (this.getTable().getFieldsName().contains("DUNNING_DATE")) {
|
|
|
537 |
c.gridx++;
|
|
|
538 |
c.weightx = 0;
|
151 |
ilm |
539 |
c.fill = GridBagConstraints.HORIZONTAL;
|
93 |
ilm |
540 |
this.add(new JLabel(getLabelFor("DUNNING_DATE"), SwingConstants.RIGHT), c);
|
|
|
541 |
c.gridx++;
|
151 |
ilm |
542 |
c.fill = GridBagConstraints.NONE;
|
93 |
ilm |
543 |
JDate dateRelance = new JDate();
|
|
|
544 |
this.add(dateRelance, c);
|
|
|
545 |
if (getTable().getDBRoot().contains("TARIF_AGENCE")) {
|
|
|
546 |
this.addView(dateRelance, "DUNNING_DATE", REQ);
|
|
|
547 |
} else {
|
|
|
548 |
this.addView(dateRelance, "DUNNING_DATE");
|
|
|
549 |
}
|
|
|
550 |
}
|
|
|
551 |
|
19 |
ilm |
552 |
}
|
|
|
553 |
|
18 |
ilm |
554 |
// Table d'élément
|
73 |
ilm |
555 |
this.table = new DevisItemTable();
|
|
|
556 |
|
83 |
ilm |
557 |
final AcompteField acompteField = new AcompteField();
|
|
|
558 |
acompteField.getDocument().addDocumentListener(new SimpleDocumentListener() {
|
|
|
559 |
|
|
|
560 |
@Override
|
|
|
561 |
public void update(DocumentEvent e) {
|
|
|
562 |
Acompte a = acompteField.getValue();
|
|
|
563 |
((DevisItemTable) table).calculPourcentage(a, TypeCalcul.CALCUL_REMISE);
|
|
|
564 |
}
|
|
|
565 |
});
|
|
|
566 |
|
|
|
567 |
// Remise
|
|
|
568 |
c.gridy++;
|
|
|
569 |
c.gridx = 0;
|
|
|
570 |
c.weightx = 0;
|
|
|
571 |
c.weighty = 0;
|
|
|
572 |
c.gridwidth = 1;
|
|
|
573 |
JLabel comp = new JLabel(getLabelFor("MONTANT_REMISE"), SwingConstants.RIGHT);
|
|
|
574 |
// this.add(comp, c);
|
|
|
575 |
c.gridx++;
|
|
|
576 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
577 |
|
|
|
578 |
c.weightx = 1;
|
|
|
579 |
// this.add(acompteField, c);
|
|
|
580 |
this.addView(new AcompteRowItemView(acompteField), "MONTANT_REMISE,POURCENT_REMISE", null);
|
|
|
581 |
|
|
|
582 |
|
18 |
ilm |
583 |
c.fill = GridBagConstraints.BOTH;
|
|
|
584 |
c.gridx = 0;
|
73 |
ilm |
585 |
c.gridy += 5;
|
18 |
ilm |
586 |
c.weighty = 1;
|
|
|
587 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
588 |
this.add(this.table, c);
|
73 |
ilm |
589 |
this.addView(this.table.getRowValuesTable(), "");
|
18 |
ilm |
590 |
|
|
|
591 |
// Panel en bas
|
|
|
592 |
final JPanel bottomPanel = new JPanel(new GridBagLayout());
|
|
|
593 |
final GridBagConstraints cBottom = new DefaultGridBagConstraints();
|
|
|
594 |
// 1ere Colonne : Infos
|
|
|
595 |
cBottom.weightx = 1;
|
|
|
596 |
bottomPanel.add(new TitledSeparator(getLabelFor("INFOS")), cBottom);
|
|
|
597 |
cBottom.gridy++;
|
|
|
598 |
cBottom.fill = GridBagConstraints.BOTH;
|
|
|
599 |
cBottom.weighty = 0;
|
|
|
600 |
|
|
|
601 |
final JScrollPane scrollPane = new JScrollPane(this.infos);
|
|
|
602 |
scrollPane.setBorder(null);
|
|
|
603 |
bottomPanel.add(scrollPane, cBottom);
|
|
|
604 |
|
|
|
605 |
// 2eme Colonne : Poids total
|
|
|
606 |
final JPanel panel = new JPanel(new GridBagLayout());
|
|
|
607 |
|
|
|
608 |
this.textPoidsTotal = new JTextField(8);
|
|
|
609 |
this.textPoidsTotal.setText("0.0");
|
|
|
610 |
final GridBagConstraints cPanel = new DefaultGridBagConstraints();
|
|
|
611 |
panel.add(new JLabel(getLabelFor("T_POIDS")), cPanel);
|
|
|
612 |
cPanel.weightx = 0;
|
|
|
613 |
cPanel.gridx++;
|
|
|
614 |
panel.add(this.textPoidsTotal, cPanel);
|
|
|
615 |
this.textPoidsTotal.setEnabled(false);
|
|
|
616 |
this.textPoidsTotal.setEditable(false);
|
|
|
617 |
this.textPoidsTotal.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
618 |
this.textPoidsTotal.setDisabledTextColor(Color.BLACK);
|
|
|
619 |
|
|
|
620 |
// Port
|
|
|
621 |
|
|
|
622 |
final DeviseField textPortHT = new DeviseField();
|
144 |
ilm |
623 |
SQLRequestComboBox boxTaxePort = new SQLRequestComboBox(false, 8);
|
18 |
ilm |
624 |
|
144 |
ilm |
625 |
if (getTable().contains("ID_TAXE_PORT")) {
|
|
|
626 |
|
|
|
627 |
JLabel labelPortHT = new JLabel(getLabelFor("PORT_HT"));
|
|
|
628 |
labelPortHT.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
629 |
cPanel.gridx = 0;
|
|
|
630 |
cPanel.gridy++;
|
|
|
631 |
panel.add(labelPortHT, cPanel);
|
|
|
632 |
cPanel.gridx++;
|
|
|
633 |
panel.add(textPortHT, cPanel);
|
|
|
634 |
|
|
|
635 |
JLabel labelTaxeHT = new JLabel(getLabelFor("ID_TAXE_PORT"));
|
|
|
636 |
labelTaxeHT.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
637 |
cPanel.gridx = 0;
|
|
|
638 |
cPanel.gridy++;
|
|
|
639 |
panel.add(labelTaxeHT, cPanel);
|
|
|
640 |
cPanel.gridx++;
|
|
|
641 |
panel.add(boxTaxePort, cPanel);
|
|
|
642 |
this.addView(boxTaxePort, "ID_TAXE_PORT", REQ);
|
|
|
643 |
|
|
|
644 |
}
|
|
|
645 |
|
18 |
ilm |
646 |
// Remise HT
|
|
|
647 |
final JRadioButton radioEuros = new JRadioButton("en €");
|
|
|
648 |
final JRadioButton radioPourCent = new JRadioButton("en %");
|
|
|
649 |
final ButtonGroup radioGroup = new ButtonGroup();
|
|
|
650 |
radioGroup.add(radioEuros);
|
|
|
651 |
radioGroup.add(radioPourCent);
|
|
|
652 |
radioEuros.setSelected(true);
|
|
|
653 |
|
|
|
654 |
final JPanel panelRemise = new JPanel(new GridBagLayout());
|
|
|
655 |
final GridBagConstraints cRemise = new DefaultGridBagConstraints();
|
|
|
656 |
cRemise.insets = new Insets(0, 0, 1, 0);
|
|
|
657 |
final JLabel labelRemise = new JLabel(getLabelFor("REMISE_HT"));
|
|
|
658 |
panelRemise.add(labelRemise, cRemise);
|
132 |
ilm |
659 |
// cRemise.gridx++;
|
|
|
660 |
// panelRemise.add(radioEuros, cRemise);
|
18 |
ilm |
661 |
|
|
|
662 |
cRemise.gridx++;
|
|
|
663 |
cRemise.weightx = 0;
|
|
|
664 |
this.textRemiseHT = new DeviseField();
|
|
|
665 |
panelRemise.add(this.textRemiseHT, cRemise);
|
151 |
ilm |
666 |
this.textRemiseHT.setMinimumSize(new Dimension(150, this.textRemiseHT.getMinimumSize().height));
|
|
|
667 |
this.textRemiseHT.setPreferredSize(new Dimension(150, this.textRemiseHT.getPreferredSize().height));
|
18 |
ilm |
668 |
|
149 |
ilm |
669 |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.ACOMPTE_DEVIS, false)) {
|
|
|
670 |
// Acompte
|
|
|
671 |
cRemise.gridy++;
|
|
|
672 |
cRemise.gridx = 0;
|
|
|
673 |
cRemise.weightx = 0;
|
|
|
674 |
cRemise.weighty = 0;
|
|
|
675 |
cRemise.gridwidth = 1;
|
|
|
676 |
JLabel compAcompte = new JLabel(getLabelFor("T_ACOMPTE"), SwingConstants.RIGHT);
|
|
|
677 |
panelRemise.add(compAcompte, cRemise);
|
|
|
678 |
cRemise.gridx++;
|
|
|
679 |
cRemise.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
680 |
DeviseField fieldAcompte = new DeviseField();
|
|
|
681 |
fieldAcompte.setEnabled(false);
|
|
|
682 |
cRemise.weightx = 1;
|
|
|
683 |
panelRemise.add(fieldAcompte, cRemise);
|
|
|
684 |
this.addView(fieldAcompte, "T_ACOMPTE");
|
|
|
685 |
}
|
|
|
686 |
|
132 |
ilm |
687 |
// cRemise.gridx = 1;
|
|
|
688 |
// cRemise.gridy++;
|
|
|
689 |
// cRemise.weightx = 0;
|
|
|
690 |
// panelRemise.add(radioPourCent, cRemise);
|
|
|
691 |
//
|
18 |
ilm |
692 |
this.textPourcentRemise = new JTextField(5);
|
132 |
ilm |
693 |
// DefaultGridBagConstraints.lockMinimumSize(this.textPourcentRemise);
|
|
|
694 |
// cRemise.gridx++;
|
|
|
695 |
// panelRemise.add(this.textPourcentRemise, cRemise);
|
18 |
ilm |
696 |
|
|
|
697 |
cPanel.gridx = 0;
|
|
|
698 |
cPanel.gridy++;
|
|
|
699 |
cPanel.gridwidth = 2;
|
|
|
700 |
panel.add(panelRemise, cPanel);
|
|
|
701 |
|
|
|
702 |
cBottom.gridy = 0;
|
|
|
703 |
cBottom.gridx++;
|
|
|
704 |
cBottom.weighty = 0;
|
|
|
705 |
cBottom.weightx = 1;
|
|
|
706 |
cBottom.gridheight = 2;
|
|
|
707 |
cBottom.fill = GridBagConstraints.HORIZONTAL;
|
|
|
708 |
cBottom.anchor = GridBagConstraints.NORTHEAST;
|
|
|
709 |
DefaultGridBagConstraints.lockMinimumSize(panel);
|
132 |
ilm |
710 |
bottomPanel.add(panel, cBottom);
|
18 |
ilm |
711 |
|
|
|
712 |
addSQLObject(this.textRemiseHT, "REMISE_HT");
|
|
|
713 |
addSQLObject(textPortHT, "PORT_HT");
|
|
|
714 |
// this.checkImpression.setSelected(true);
|
|
|
715 |
|
|
|
716 |
// Total
|
|
|
717 |
this.fieldHT = new DeviseField();
|
|
|
718 |
final DeviseField fieldTVA = new DeviseField();
|
|
|
719 |
final DeviseField fieldTTC = new DeviseField();
|
142 |
ilm |
720 |
final DeviseField fieldEco = new DeviseField();
|
19 |
ilm |
721 |
final DeviseField fieldDevise = new DeviseField();
|
18 |
ilm |
722 |
final DeviseField fieldService = new DeviseField();
|
73 |
ilm |
723 |
this.fieldHT.setEditable(false);
|
18 |
ilm |
724 |
fieldTVA.setEditable(false);
|
|
|
725 |
fieldTTC.setEditable(false);
|
|
|
726 |
fieldService.setEditable(false);
|
142 |
ilm |
727 |
fieldEco.setEditable(false);
|
18 |
ilm |
728 |
|
142 |
ilm |
729 |
addSQLObject(fieldEco, "T_ECO_CONTRIBUTION");
|
18 |
ilm |
730 |
addRequiredSQLObject(this.fieldHT, "T_HT");
|
|
|
731 |
addRequiredSQLObject(fieldTVA, "T_TVA");
|
19 |
ilm |
732 |
addSQLObject(fieldDevise, "T_DEVISE");
|
18 |
ilm |
733 |
addRequiredSQLObject(fieldTTC, "T_TTC");
|
|
|
734 |
addRequiredSQLObject(fieldService, "T_SERVICE");
|
19 |
ilm |
735 |
JTextField poids = new JTextField();
|
|
|
736 |
// addSQLObject(poids, "T_POIDS");
|
41 |
ilm |
737 |
|
|
|
738 |
// FIXME Field add field T_HA dans installation avec recalcul des devis deja saisis
|
|
|
739 |
final DeviseField fieldHA = new DeviseField();
|
|
|
740 |
|
61 |
ilm |
741 |
if (getTable().contains("PREBILAN")) {
|
|
|
742 |
addSQLObject(fieldHA, "PREBILAN");
|
|
|
743 |
} else if (getTable().contains("T_HA")) {
|
|
|
744 |
|
41 |
ilm |
745 |
addSQLObject(fieldHA, "T_HA");
|
|
|
746 |
}
|
|
|
747 |
|
144 |
ilm |
748 |
final TotalPanel totalTTC = new TotalPanel(this.table, fieldEco, this.fieldHT, fieldTVA, fieldTTC, textPortHT, this.textRemiseHT, fieldService, fieldHA, fieldDevise, poids, null,
|
|
|
749 |
(getTable().contains("ID_TAXE_PORT") ? boxTaxePort : null), null);
|
18 |
ilm |
750 |
cBottom.gridy = 0;
|
|
|
751 |
cBottom.gridx += 2;
|
|
|
752 |
cBottom.gridheight = 2;
|
|
|
753 |
cBottom.gridwidth = 1;
|
|
|
754 |
cBottom.fill = GridBagConstraints.NONE;
|
|
|
755 |
cBottom.weightx = 0;
|
|
|
756 |
cBottom.anchor = GridBagConstraints.NORTHEAST;
|
|
|
757 |
DefaultGridBagConstraints.lockMinimumSize(totalTTC);
|
|
|
758 |
bottomPanel.add(totalTTC, cBottom);
|
|
|
759 |
|
|
|
760 |
c.gridy++;
|
|
|
761 |
c.gridx = 0;
|
|
|
762 |
c.weighty = 0;
|
|
|
763 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
764 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
765 |
this.add(bottomPanel, c);
|
|
|
766 |
|
|
|
767 |
c.gridx = 0;
|
|
|
768 |
c.gridy++;
|
|
|
769 |
c.weighty = 0;
|
|
|
770 |
c.fill = GridBagConstraints.NONE;
|
|
|
771 |
c.anchor = GridBagConstraints.SOUTHEAST;
|
|
|
772 |
|
21 |
ilm |
773 |
this.panelOO = new PanelOOSQLComponent(this);
|
|
|
774 |
this.add(this.panelOO, c);
|
|
|
775 |
|
144 |
ilm |
776 |
boxTaxePort.addValueListener(new PropertyChangeListener() {
|
|
|
777 |
|
|
|
778 |
@Override
|
|
|
779 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
780 |
totalTTC.updateTotal();
|
|
|
781 |
}
|
|
|
782 |
});
|
|
|
783 |
|
18 |
ilm |
784 |
textPortHT.getDocument().addDocumentListener(new SimpleDocumentListener() {
|
|
|
785 |
|
|
|
786 |
@Override
|
|
|
787 |
public void update(final DocumentEvent e) {
|
|
|
788 |
totalTTC.updateTotal();
|
|
|
789 |
}
|
|
|
790 |
});
|
|
|
791 |
|
|
|
792 |
this.textRemiseHT.getDocument().addDocumentListener(new SimpleDocumentListener() {
|
|
|
793 |
|
|
|
794 |
@Override
|
|
|
795 |
public void update(final DocumentEvent e) {
|
|
|
796 |
totalTTC.updateTotal();
|
|
|
797 |
}
|
|
|
798 |
});
|
|
|
799 |
|
|
|
800 |
this.textPourcentRemise.getDocument().addDocumentListener(new SimpleDocumentListener() {
|
|
|
801 |
|
|
|
802 |
@Override
|
|
|
803 |
public void update(final DocumentEvent e) {
|
|
|
804 |
calculPourcentage();
|
|
|
805 |
}
|
|
|
806 |
});
|
|
|
807 |
|
|
|
808 |
radioEuros.addChangeListener(new ChangeListener() {
|
|
|
809 |
|
|
|
810 |
public void stateChanged(final ChangeEvent e) {
|
|
|
811 |
DevisSQLComponent.this.textRemiseHT.setEnabled(radioEuros.isSelected());
|
|
|
812 |
DevisSQLComponent.this.textPourcentRemise.setEnabled(!radioEuros.isSelected());
|
|
|
813 |
}
|
|
|
814 |
});
|
|
|
815 |
|
|
|
816 |
this.table.getModel().addTableModelListener(new TableModelListener() {
|
|
|
817 |
|
|
|
818 |
public void tableChanged(final TableModelEvent e) {
|
|
|
819 |
DevisSQLComponent.this.textPoidsTotal.setText(String.valueOf(DevisSQLComponent.this.table.getPoidsTotal()));
|
|
|
820 |
}
|
|
|
821 |
});
|
|
|
822 |
|
|
|
823 |
addSQLObject(textObjet, "OBJET");
|
|
|
824 |
addSQLObject(this.textPoidsTotal, "T_POIDS");
|
|
|
825 |
addRequiredSQLObject(dateDevis, "DATE");
|
|
|
826 |
addRequiredSQLObject(this.radioEtat, "ID_ETAT_DEVIS");
|
|
|
827 |
addRequiredSQLObject(this.numeroUniqueDevis, "NUMERO");
|
|
|
828 |
addSQLObject(this.infos, "INFOS");
|
73 |
ilm |
829 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
18 |
ilm |
830 |
|
73 |
ilm |
831 |
@Override
|
|
|
832 |
public void propertyChange(PropertyChangeEvent arg0) {
|
182 |
ilm |
833 |
|
|
|
834 |
Integer id = comboClient.getWantedID();
|
|
|
835 |
|
|
|
836 |
if (id > 1) {
|
|
|
837 |
|
|
|
838 |
SQLRow rowClient = comboClient.getElement().getTable().getRow(id);
|
|
|
839 |
if (rowClient.getObject("ID_CATEGORIE_COMPTABLE") != null && !rowClient.isForeignEmpty("ID_CATEGORIE_COMPTABLE")) {
|
|
|
840 |
totalTTC.setCategorieComptable(rowClient.getForeign("ID_CATEGORIE_COMPTABLE"));
|
|
|
841 |
table.setRowCatComptable(rowClient.getForeign("ID_CATEGORIE_COMPTABLE"));
|
|
|
842 |
} else {
|
|
|
843 |
totalTTC.setCategorieComptable(null);
|
|
|
844 |
table.setRowCatComptable(null);
|
|
|
845 |
}
|
|
|
846 |
}
|
|
|
847 |
|
73 |
ilm |
848 |
if (!isFilling()) {
|
|
|
849 |
|
|
|
850 |
if (id > 1) {
|
|
|
851 |
|
|
|
852 |
SQLRow row = comboClient.getElement().getTable().getRow(id);
|
|
|
853 |
if (comboClient.getElement().getTable().getFieldsName().contains("ID_TARIF")) {
|
|
|
854 |
|
|
|
855 |
SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
|
|
|
856 |
if (!foreignRow.isUndefined() && (boxTarif.getSelectedRow() == null || boxTarif.getSelectedId() != foreignRow.getID())
|
|
|
857 |
&& JOptionPane.showConfirmDialog(null, "Appliquer les tarifs associés au client?") == JOptionPane.YES_OPTION) {
|
|
|
858 |
boxTarif.setValue(foreignRow.getID());
|
|
|
859 |
// SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow,
|
|
|
860 |
// true);
|
|
|
861 |
} else {
|
|
|
862 |
boxTarif.setValue(foreignRow.getID());
|
|
|
863 |
}
|
|
|
864 |
|
|
|
865 |
// SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
|
|
|
866 |
// if (foreignRow.isUndefined() &&
|
|
|
867 |
// !row.getForeignRow("ID_DEVISE").isUndefined()) {
|
|
|
868 |
// SQLRowValues rowValsD = new SQLRowValues(foreignRow.getTable());
|
|
|
869 |
// rowValsD.put("ID_DEVISE", row.getObject("ID_DEVISE"));
|
|
|
870 |
// foreignRow = rowValsD;
|
|
|
871 |
//
|
|
|
872 |
// }
|
|
|
873 |
// table.setTarif(foreignRow, true);
|
|
|
874 |
}
|
|
|
875 |
}
|
|
|
876 |
}
|
|
|
877 |
|
|
|
878 |
}
|
|
|
879 |
});
|
18 |
ilm |
880 |
DefaultGridBagConstraints.lockMinimumSize(comboCommercial);
|
|
|
881 |
DefaultGridBagConstraints.lockMinimumSize(comboClient);
|
|
|
882 |
}
|
|
|
883 |
|
73 |
ilm |
884 |
private enum Type_Diff {
|
|
|
885 |
SITE("SITE"), DONNEUR_ORDRE("DONNEUR");
|
182 |
ilm |
886 |
|
73 |
ilm |
887 |
private final String name;
|
|
|
888 |
|
|
|
889 |
private Type_Diff(String name) {
|
|
|
890 |
this.name = name;
|
|
|
891 |
}
|
|
|
892 |
|
|
|
893 |
public String getName() {
|
|
|
894 |
return this.name;
|
|
|
895 |
}
|
|
|
896 |
}
|
|
|
897 |
|
90 |
ilm |
898 |
private ValidState validStateContact = ValidState.getTrueInstance();
|
|
|
899 |
|
|
|
900 |
@Override
|
|
|
901 |
public synchronized ValidState getValidState() {
|
|
|
902 |
assert SwingUtilities.isEventDispatchThread();
|
|
|
903 |
return super.getValidState().and(this.validStateContact);
|
|
|
904 |
}
|
|
|
905 |
|
132 |
ilm |
906 |
private JPanel createGestionSaisieRapport() {
|
|
|
907 |
GridBagConstraints cTabSite = new DefaultGridBagConstraints();
|
|
|
908 |
JPanel tabSite = new JPanel(new GridBagLayout());
|
|
|
909 |
|
|
|
910 |
if (getTable().contains("RAPPORT_A_SAISIR")) {
|
|
|
911 |
cTabSite.gridx = 0;
|
|
|
912 |
cTabSite.gridy++;
|
|
|
913 |
cTabSite.gridheight = 1;
|
|
|
914 |
cTabSite.fill = GridBagConstraints.HORIZONTAL;
|
|
|
915 |
cTabSite.weightx = 0;
|
|
|
916 |
|
142 |
ilm |
917 |
// Coche
|
|
|
918 |
cTabSite.gridx = 0;
|
|
|
919 |
cTabSite.gridwidth = 2;
|
|
|
920 |
cTabSite.weightx = 0;
|
|
|
921 |
JCheckBox boxAsaisir = new JCheckBox("Rapport à saisir");
|
|
|
922 |
tabSite.add(boxAsaisir, cTabSite);
|
|
|
923 |
|
132 |
ilm |
924 |
// Type Rapport
|
|
|
925 |
JLabel labelRapport = new JLabel(getLabelFor("TYPE_RAPPORT"));
|
142 |
ilm |
926 |
cTabSite.gridx = 2;
|
132 |
ilm |
927 |
tabSite.add(labelRapport, cTabSite);
|
|
|
928 |
SQLTextCombo comboType = new SQLTextCombo();
|
|
|
929 |
cTabSite.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
930 |
cTabSite.gridx++;
|
142 |
ilm |
931 |
cTabSite.weightx = 1;
|
132 |
ilm |
932 |
tabSite.add(comboType, cTabSite);
|
|
|
933 |
cTabSite.gridwidth = 1;
|
|
|
934 |
|
142 |
ilm |
935 |
// Nb Rapport
|
132 |
ilm |
936 |
cTabSite.gridx = 0;
|
|
|
937 |
cTabSite.gridy++;
|
142 |
ilm |
938 |
cTabSite.weightx = 0;
|
|
|
939 |
tabSite.add(new JLabel(getLabelFor("NB_RAPPORT_A_SAISIR")), cTabSite);
|
|
|
940 |
cTabSite.gridx++;
|
|
|
941 |
cTabSite.weightx = 1;
|
|
|
942 |
JTextField fieldNbRapportASaisir = new JTextField(5);
|
|
|
943 |
tabSite.add(fieldNbRapportASaisir, cTabSite);
|
|
|
944 |
|
|
|
945 |
// Date
|
|
|
946 |
cTabSite.gridx++;
|
|
|
947 |
cTabSite.weightx = 0;
|
132 |
ilm |
948 |
tabSite.add(new JLabel(getLabelFor("DATE_DEMANDE_SAISIE")), cTabSite);
|
|
|
949 |
cTabSite.gridx++;
|
142 |
ilm |
950 |
cTabSite.weightx = 0;
|
132 |
ilm |
951 |
JDate dateDmdSaisie = new JDate();
|
|
|
952 |
tabSite.add(dateDmdSaisie, cTabSite);
|
|
|
953 |
|
|
|
954 |
cTabSite.gridx++;
|
|
|
955 |
cTabSite.gridwidth = 2;
|
142 |
ilm |
956 |
cTabSite.weightx = 0;
|
132 |
ilm |
957 |
JCheckBox boxAcceptSaisie = new JCheckBox("Accepté en saisie");
|
|
|
958 |
tabSite.add(boxAcceptSaisie, cTabSite);
|
|
|
959 |
cTabSite.gridwidth = 1;
|
|
|
960 |
|
142 |
ilm |
961 |
cTabSite.gridy++;
|
132 |
ilm |
962 |
cTabSite.gridx = 0;
|
142 |
ilm |
963 |
cTabSite.weightx = 0;
|
|
|
964 |
tabSite.add(new JLabel(getLabelFor("NB_RAPPORT_SAISI")), cTabSite);
|
|
|
965 |
cTabSite.gridx++;
|
|
|
966 |
cTabSite.weightx = 1;
|
|
|
967 |
JTextField fieldNbRapportSaisi = new JTextField(5);
|
|
|
968 |
tabSite.add(fieldNbRapportSaisi, cTabSite);
|
|
|
969 |
|
|
|
970 |
cTabSite.gridx++;
|
|
|
971 |
cTabSite.weightx = 0;
|
|
|
972 |
tabSite.add(new JLabel(getLabelFor("DATE_SAISIE")), cTabSite);
|
|
|
973 |
cTabSite.gridx++;
|
|
|
974 |
cTabSite.weightx = 0;
|
|
|
975 |
JDate dateSaisie = new JDate();
|
|
|
976 |
tabSite.add(dateSaisie, cTabSite);
|
|
|
977 |
if (!UserRightsManager.getCurrentUserRights().haveRight("VOIR_DEVIS_4_SEMAINES")) {
|
|
|
978 |
cTabSite.gridx++;
|
|
|
979 |
cTabSite.weightx = 0;
|
|
|
980 |
tabSite.add(new JLabel(getLabelFor("DATE_SAISIE_REELLE")), cTabSite);
|
|
|
981 |
cTabSite.gridx++;
|
|
|
982 |
cTabSite.weightx = 0;
|
|
|
983 |
JDate dateSaisieR = new JDate();
|
|
|
984 |
tabSite.add(dateSaisieR, cTabSite);
|
|
|
985 |
this.addView(dateSaisieR, "DATE_SAISIE_REELLE");
|
|
|
986 |
}
|
132 |
ilm |
987 |
cTabSite.gridy++;
|
142 |
ilm |
988 |
cTabSite.weightx = 0;
|
|
|
989 |
cTabSite.gridx = 0;
|
|
|
990 |
tabSite.add(new JLabel(getLabelFor("TEMPS_SAISIE")), cTabSite);
|
132 |
ilm |
991 |
cTabSite.gridx++;
|
142 |
ilm |
992 |
cTabSite.weightx = 1;
|
|
|
993 |
JTextField fieldTpsSaisi = new JTextField(5);
|
|
|
994 |
tabSite.add(fieldTpsSaisi, cTabSite);
|
132 |
ilm |
995 |
|
|
|
996 |
cTabSite.gridx++;
|
142 |
ilm |
997 |
cTabSite.weightx = 0;
|
|
|
998 |
tabSite.add(new JLabel(getLabelFor("ID_USER_COMMON_SAISIE")), cTabSite);
|
132 |
ilm |
999 |
cTabSite.gridx++;
|
142 |
ilm |
1000 |
cTabSite.weightx = 1;
|
|
|
1001 |
SQLRequestComboBox boxUserSaisi = new SQLRequestComboBox();
|
|
|
1002 |
tabSite.add(boxUserSaisi, cTabSite);
|
132 |
ilm |
1003 |
|
|
|
1004 |
// Date de demande
|
|
|
1005 |
// Nb rapport a saisie
|
|
|
1006 |
// Type
|
|
|
1007 |
// Nb Rapport saisie
|
|
|
1008 |
this.addView(fieldNbRapportASaisir, "NB_RAPPORT_A_SAISIR");
|
|
|
1009 |
this.addView(fieldNbRapportSaisi, "NB_RAPPORT_SAISI");
|
|
|
1010 |
|
|
|
1011 |
this.addView(dateDmdSaisie, "DATE_DEMANDE_SAISIE");
|
|
|
1012 |
this.addView(comboType, "TYPE_RAPPORT");
|
|
|
1013 |
this.addView(dateSaisie, "DATE_SAISIE");
|
|
|
1014 |
this.addView(boxAcceptSaisie, "ACCEPTE_EN_SAISIE");
|
|
|
1015 |
this.addView(boxAsaisir, "RAPPORT_A_SAISIR");
|
142 |
ilm |
1016 |
this.addView(boxUserSaisi, "ID_USER_COMMON_SAISIE");
|
|
|
1017 |
this.addView(fieldTpsSaisi, "TEMPS_SAISIE");
|
132 |
ilm |
1018 |
}
|
|
|
1019 |
return tabSite;
|
|
|
1020 |
}
|
|
|
1021 |
|
73 |
ilm |
1022 |
private JPanel createPanelDiff(final Type_Diff type) {
|
|
|
1023 |
|
|
|
1024 |
GridBagConstraints cTabSite = new DefaultGridBagConstraints();
|
|
|
1025 |
JPanel tabSite = new JPanel(new GridBagLayout());
|
|
|
1026 |
|
|
|
1027 |
cTabSite.weightx = 1;
|
|
|
1028 |
cTabSite.fill = GridBagConstraints.HORIZONTAL;
|
|
|
1029 |
cTabSite.gridwidth = 2;
|
|
|
1030 |
|
|
|
1031 |
final String name = type.getName();
|
|
|
1032 |
final JCheckBox boxSiteDiff = new JCheckBox(getLabelFor(name + "_DIFF"));
|
|
|
1033 |
|
|
|
1034 |
tabSite.add(boxSiteDiff, cTabSite);
|
|
|
1035 |
this.addView(boxSiteDiff, name + "_DIFF");
|
|
|
1036 |
|
|
|
1037 |
final String fieldSiren = "SIREN_" + name;
|
|
|
1038 |
if (getTable().contains(fieldSiren)) {
|
|
|
1039 |
final JLabel labelSrenSite = new JLabel(getLabelFor(fieldSiren));
|
|
|
1040 |
labelSrenSite.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
1041 |
cTabSite.gridwidth = 1;
|
|
|
1042 |
cTabSite.gridx = 2;
|
|
|
1043 |
cTabSite.weightx = 0;
|
|
|
1044 |
tabSite.add(labelSrenSite, cTabSite);
|
|
|
1045 |
|
|
|
1046 |
cTabSite.gridx++;
|
|
|
1047 |
cTabSite.weightx = 1;
|
|
|
1048 |
if (type == Type_Diff.SITE) {
|
|
|
1049 |
throw new IllegalArgumentException("Le siren n'est pas à renseigné pour le site");
|
|
|
1050 |
}
|
|
|
1051 |
final JTextField siren = this.sirenDonneur;
|
|
|
1052 |
tabSite.add(siren, cTabSite);
|
|
|
1053 |
this.addView(siren, fieldSiren);
|
|
|
1054 |
DefaultGridBagConstraints.lockMinimumSize(siren);
|
|
|
1055 |
}
|
|
|
1056 |
cTabSite.gridy++;
|
|
|
1057 |
cTabSite.gridx = 0;
|
|
|
1058 |
cTabSite.weightx = 0;
|
|
|
1059 |
cTabSite.fill = GridBagConstraints.HORIZONTAL;
|
|
|
1060 |
cTabSite.gridwidth = 1;
|
|
|
1061 |
final JLabel labelSiteDes = new JLabel(getLabelFor("DESIGNATION_" + name));
|
|
|
1062 |
|
|
|
1063 |
labelSiteDes.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
1064 |
|
|
|
1065 |
tabSite.add(labelSiteDes, cTabSite);
|
|
|
1066 |
cTabSite.gridx++;
|
|
|
1067 |
cTabSite.weightx = 1;
|
|
|
1068 |
final JTextField designation = type == Type_Diff.SITE ? this.desSite : this.desDonneur;
|
|
|
1069 |
tabSite.add(designation, cTabSite);
|
|
|
1070 |
this.addView(designation, "DESIGNATION_" + name);
|
|
|
1071 |
DefaultGridBagConstraints.lockMinimumSize(designation);
|
|
|
1072 |
|
|
|
1073 |
final JLabel labelTelSite = new JLabel(getLabelFor("TEL_" + name));
|
|
|
1074 |
labelTelSite.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
1075 |
cTabSite.gridx++;
|
|
|
1076 |
cTabSite.weightx = 0;
|
|
|
1077 |
tabSite.add(labelTelSite, cTabSite);
|
|
|
1078 |
|
|
|
1079 |
cTabSite.gridx++;
|
|
|
1080 |
cTabSite.weightx = 1;
|
|
|
1081 |
final JTextField tel = type == Type_Diff.SITE ? this.telSite : this.telDonneur;
|
|
|
1082 |
tabSite.add(tel, cTabSite);
|
|
|
1083 |
this.addView(tel, "TEL_" + name);
|
|
|
1084 |
DefaultGridBagConstraints.lockMinimumSize(tel);
|
|
|
1085 |
|
|
|
1086 |
final JLabel labelSiteAdr = new JLabel(getLabelFor("ADRESSE_" + name));
|
|
|
1087 |
labelSiteAdr.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
1088 |
cTabSite.gridy++;
|
|
|
1089 |
cTabSite.gridx = 0;
|
|
|
1090 |
cTabSite.weightx = 0;
|
|
|
1091 |
tabSite.add(labelSiteAdr, cTabSite);
|
|
|
1092 |
|
|
|
1093 |
cTabSite.gridx++;
|
|
|
1094 |
cTabSite.weightx = 1;
|
|
|
1095 |
final ITextArea adresse = type == Type_Diff.SITE ? this.adrSite : this.adrDonneur;
|
|
|
1096 |
tabSite.add(adresse, cTabSite);
|
|
|
1097 |
this.addView(adresse, "ADRESSE_" + name);
|
|
|
1098 |
DefaultGridBagConstraints.lockMinimumSize(adresse);
|
|
|
1099 |
|
|
|
1100 |
final JLabel labelTelPSite = new JLabel(getLabelFor("TEL_P_" + name));
|
|
|
1101 |
labelTelPSite.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
1102 |
cTabSite.gridx++;
|
|
|
1103 |
cTabSite.weightx = 0;
|
|
|
1104 |
tabSite.add(labelTelPSite, cTabSite);
|
|
|
1105 |
|
|
|
1106 |
cTabSite.gridx++;
|
|
|
1107 |
cTabSite.weightx = 1;
|
|
|
1108 |
final JTextField telP = type == Type_Diff.SITE ? this.telPSite : this.telPDonneur;
|
|
|
1109 |
tabSite.add(telP, cTabSite);
|
|
|
1110 |
this.addView(telP, "TEL_P_" + name);
|
|
|
1111 |
|
|
|
1112 |
cTabSite.gridy++;
|
|
|
1113 |
cTabSite.gridx = 0;
|
|
|
1114 |
cTabSite.weightx = 0;
|
|
|
1115 |
final JLabel labelVilleAdr = new JLabel(getLabelFor("VILLE_" + name));
|
|
|
1116 |
labelVilleAdr.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
1117 |
tabSite.add(labelVilleAdr, cTabSite);
|
|
|
1118 |
|
|
|
1119 |
cTabSite.gridx++;
|
|
|
1120 |
cTabSite.weightx = 1;
|
|
|
1121 |
final ITextComboVilleViewer ville = type == Type_Diff.SITE ? this.villeSite : this.villeDonneur;
|
|
|
1122 |
tabSite.add(ville, cTabSite);
|
|
|
1123 |
this.addView(ville, "VILLE_" + name);
|
|
|
1124 |
DefaultGridBagConstraints.lockMinimumSize(ville);
|
|
|
1125 |
|
|
|
1126 |
cTabSite.gridx++;
|
|
|
1127 |
cTabSite.weightx = 0;
|
|
|
1128 |
|
|
|
1129 |
final JLabel labelFaxSite = new JLabel(getLabelFor("FAX_" + name));
|
|
|
1130 |
labelFaxSite.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
1131 |
tabSite.add(labelFaxSite, cTabSite);
|
|
|
1132 |
|
|
|
1133 |
cTabSite.gridx++;
|
|
|
1134 |
cTabSite.weightx = 1;
|
|
|
1135 |
final JTextField fax = type == Type_Diff.SITE ? this.faxSite : this.faxDonneur;
|
|
|
1136 |
tabSite.add(fax, cTabSite);
|
|
|
1137 |
this.addView(fax, "FAX_" + name);
|
|
|
1138 |
DefaultGridBagConstraints.lockMinimumSize(fax);
|
|
|
1139 |
|
|
|
1140 |
cTabSite.gridy++;
|
|
|
1141 |
cTabSite.gridx = 0;
|
|
|
1142 |
cTabSite.weightx = 0;
|
|
|
1143 |
|
|
|
1144 |
final JLabel labelContactSite = new JLabel(getLabelFor("CONTACT_" + name));
|
|
|
1145 |
labelContactSite.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
1146 |
tabSite.add(labelContactSite, cTabSite);
|
|
|
1147 |
|
|
|
1148 |
cTabSite.gridx++;
|
|
|
1149 |
cTabSite.weightx = 1;
|
|
|
1150 |
final JTextField contact = type == Type_Diff.SITE ? this.contactSite : this.contactDonneur;
|
|
|
1151 |
tabSite.add(contact, cTabSite);
|
|
|
1152 |
this.addView(contact, "CONTACT_" + name);
|
|
|
1153 |
|
|
|
1154 |
cTabSite.gridx++;
|
|
|
1155 |
cTabSite.weightx = 0;
|
|
|
1156 |
|
|
|
1157 |
final JLabel labelMailSite = new JLabel(getLabelFor("MAIL_" + name));
|
|
|
1158 |
labelMailSite.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
1159 |
tabSite.add(labelMailSite, cTabSite);
|
|
|
1160 |
|
|
|
1161 |
cTabSite.gridx++;
|
|
|
1162 |
cTabSite.weightx = 1;
|
|
|
1163 |
final JTextField mail = type == Type_Diff.SITE ? this.mailSite : this.mailDonneur;
|
|
|
1164 |
tabSite.add(mail, cTabSite);
|
|
|
1165 |
this.addView(mail, "MAIL_" + name);
|
|
|
1166 |
|
|
|
1167 |
boxSiteDiff.addItemListener(new ItemListener() {
|
|
|
1168 |
|
|
|
1169 |
@Override
|
|
|
1170 |
public void itemStateChanged(ItemEvent e) {
|
|
|
1171 |
final boolean selected = boxSiteDiff.isSelected();
|
|
|
1172 |
setSiteEnabled(selected, type);
|
|
|
1173 |
if (!selected) {
|
|
|
1174 |
clearFieldDiff(type);
|
|
|
1175 |
}
|
|
|
1176 |
}
|
|
|
1177 |
});
|
|
|
1178 |
return tabSite;
|
|
|
1179 |
}
|
|
|
1180 |
|
|
|
1181 |
private void clearFieldDiff(Type_Diff type) {
|
|
|
1182 |
if (type == Type_Diff.SITE) {
|
|
|
1183 |
this.desSite.setText("");
|
|
|
1184 |
this.adrSite.setText("");
|
|
|
1185 |
this.villeSite.setValue(null);
|
|
|
1186 |
this.telPSite.setText("");
|
|
|
1187 |
this.telSite.setText("");
|
|
|
1188 |
this.mailSite.setText("");
|
|
|
1189 |
this.contactSite.setText("");
|
|
|
1190 |
this.faxSite.setText("");
|
|
|
1191 |
} else {
|
|
|
1192 |
this.sirenDonneur.setText("");
|
|
|
1193 |
this.desDonneur.setText("");
|
|
|
1194 |
this.adrDonneur.setText("");
|
|
|
1195 |
this.villeDonneur.setValue(null);
|
|
|
1196 |
this.telPDonneur.setText("");
|
|
|
1197 |
this.telDonneur.setText("");
|
|
|
1198 |
this.mailDonneur.setText("");
|
|
|
1199 |
this.contactDonneur.setText("");
|
|
|
1200 |
this.faxDonneur.setText("");
|
|
|
1201 |
}
|
|
|
1202 |
}
|
|
|
1203 |
|
|
|
1204 |
private void setSiteEnabled(boolean b, Type_Diff type) {
|
|
|
1205 |
if (type == Type_Diff.SITE) {
|
|
|
1206 |
this.desSite.setEditable(b);
|
|
|
1207 |
this.adrSite.setEditable(b);
|
|
|
1208 |
this.villeSite.setEnabled(b);
|
|
|
1209 |
this.telPSite.setEditable(b);
|
|
|
1210 |
this.telSite.setEditable(b);
|
|
|
1211 |
this.mailSite.setEditable(b);
|
|
|
1212 |
this.contactSite.setEditable(b);
|
|
|
1213 |
this.faxSite.setEditable(b);
|
|
|
1214 |
} else {
|
90 |
ilm |
1215 |
b = false;
|
|
|
1216 |
|
73 |
ilm |
1217 |
this.sirenDonneur.setEditable(b);
|
|
|
1218 |
this.desDonneur.setEditable(b);
|
|
|
1219 |
this.adrDonneur.setEditable(b);
|
|
|
1220 |
this.villeDonneur.setEnabled(b);
|
|
|
1221 |
this.telPDonneur.setEditable(b);
|
|
|
1222 |
this.telDonneur.setEditable(b);
|
|
|
1223 |
this.mailDonneur.setEditable(b);
|
|
|
1224 |
this.contactDonneur.setEditable(b);
|
|
|
1225 |
this.faxDonneur.setEditable(b);
|
|
|
1226 |
}
|
|
|
1227 |
}
|
|
|
1228 |
|
18 |
ilm |
1229 |
@Override
|
|
|
1230 |
protected SQLRowValues createDefaults() {
|
|
|
1231 |
System.err.println("Create defaults");
|
73 |
ilm |
1232 |
|
|
|
1233 |
setSiteEnabled(false, Type_Diff.DONNEUR_ORDRE);
|
|
|
1234 |
setSiteEnabled(false, Type_Diff.SITE);
|
|
|
1235 |
|
18 |
ilm |
1236 |
// Numero incremental auto
|
|
|
1237 |
final SQLRowValues rowVals = new SQLRowValues(getTable());
|
90 |
ilm |
1238 |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
|
18 |
ilm |
1239 |
|
|
|
1240 |
// User
|
|
|
1241 |
// final SQLSelect sel = new SQLSelect(Configuration.getInstance().getBase());
|
|
|
1242 |
final SQLElement eltComm = Configuration.getInstance().getDirectory().getElement("COMMERCIAL");
|
|
|
1243 |
final int idUser = UserManager.getInstance().getCurrentUser().getId();
|
|
|
1244 |
//
|
|
|
1245 |
// sel.addSelect(eltComm.getTable().getKey());
|
|
|
1246 |
// sel.setWhere(new Where(eltComm.getTable().getField("ID_USER_COMMON"), "=", idUser));
|
|
|
1247 |
// final List<SQLRow> rowsComm = (List<SQLRow>)
|
|
|
1248 |
// Configuration.getInstance().getBase().getDataSource().execute(sel.asString(), new
|
|
|
1249 |
// SQLRowListRSH(eltComm.getTable()));
|
|
|
1250 |
|
|
|
1251 |
SQLRow rowsComm = SQLBackgroundTableCache.getInstance().getCacheForTable(eltComm.getTable()).getFirstRowContains(idUser, eltComm.getTable().getField("ID_USER_COMMON"));
|
|
|
1252 |
|
|
|
1253 |
if (rowsComm != null) {
|
|
|
1254 |
rowVals.put("ID_COMMERCIAL", rowsComm.getID());
|
|
|
1255 |
}
|
90 |
ilm |
1256 |
|
41 |
ilm |
1257 |
if (getTable().getUndefinedID() == SQLRow.NONEXISTANT_ID) {
|
|
|
1258 |
rowVals.put("ID_ETAT_DEVIS", EtatDevisSQLElement.EN_ATTENTE);
|
|
|
1259 |
} else {
|
65 |
ilm |
1260 |
SQLRowValues foreign = UndefinedRowValuesCache.getInstance().getDefaultRowValues(getTable());
|
132 |
ilm |
1261 |
if (foreign != null && !foreign.isUndefined() && !foreign.isForeignEmpty("ID_ETAT_DEVIS")) {
|
|
|
1262 |
rowVals.put("ID_ETAT_DEVIS", foreign.getForeignID("ID_ETAT_DEVIS"));
|
41 |
ilm |
1263 |
} else {
|
|
|
1264 |
rowVals.put("ID_ETAT_DEVIS", EtatDevisSQLElement.EN_ATTENTE);
|
|
|
1265 |
}
|
|
|
1266 |
}
|
18 |
ilm |
1267 |
rowVals.put("T_HT", Long.valueOf(0));
|
|
|
1268 |
rowVals.put("T_TVA", Long.valueOf(0));
|
|
|
1269 |
rowVals.put("T_SERVICE", Long.valueOf(0));
|
|
|
1270 |
rowVals.put("T_TTC", Long.valueOf(0));
|
144 |
ilm |
1271 |
if (getTable().contains("ID_TAXE_PORT")) {
|
|
|
1272 |
SQLRow taxeDefault = TaxeCache.getCache().getFirstTaxe();
|
|
|
1273 |
rowVals.put("ID_TAXE_PORT", taxeDefault.getID());
|
|
|
1274 |
}
|
156 |
ilm |
1275 |
if (getTable().contains("ID_TAXE_FRAIS_DOCUMENT")) {
|
|
|
1276 |
SQLRow taxeDefault = TaxeCache.getCache().getFirstTaxe();
|
|
|
1277 |
rowVals.put("ID_TAXE_FRAIS_DOCUMENT", taxeDefault.getID());
|
|
|
1278 |
}
|
19 |
ilm |
1279 |
if (getTable().getFieldsName().contains("DATE_VALIDITE")) {
|
|
|
1280 |
Calendar cal = Calendar.getInstance();
|
|
|
1281 |
cal.add(Calendar.MONTH, 1);
|
142 |
ilm |
1282 |
rowVals.put("DATE_VALIDITE", new java.sql.Date(cal.getTimeInMillis()));
|
19 |
ilm |
1283 |
}
|
18 |
ilm |
1284 |
return rowVals;
|
|
|
1285 |
}
|
|
|
1286 |
|
|
|
1287 |
private void calculPourcentage() {
|
|
|
1288 |
final String remiseP = this.textPourcentRemise.getText().replace(',', '.');
|
73 |
ilm |
1289 |
Long totalHT = this.fieldHT.getValue();
|
|
|
1290 |
Long remiseHT = this.textRemiseHT.getValue();
|
18 |
ilm |
1291 |
|
|
|
1292 |
totalHT = totalHT == null ? Long.valueOf(0) : totalHT;
|
|
|
1293 |
remiseHT = remiseHT == null ? Long.valueOf(0) : remiseHT;
|
|
|
1294 |
|
|
|
1295 |
try {
|
|
|
1296 |
final int valueRemise = Integer.valueOf(remiseP);
|
|
|
1297 |
|
|
|
1298 |
final long remise = valueRemise * (totalHT.longValue() + remiseHT.longValue()) / 100;
|
|
|
1299 |
if (remiseHT != remise) {
|
73 |
ilm |
1300 |
this.textRemiseHT.setValue(remise);
|
18 |
ilm |
1301 |
}
|
|
|
1302 |
|
|
|
1303 |
} catch (final NumberFormatException e) {
|
|
|
1304 |
ExceptionHandler.handle("Erreur durant le calcul de la remise", e);
|
|
|
1305 |
}
|
|
|
1306 |
|
|
|
1307 |
}
|
|
|
1308 |
|
|
|
1309 |
@Override
|
|
|
1310 |
public int insert(final SQLRow order) {
|
|
|
1311 |
|
25 |
ilm |
1312 |
final int idDevis;
|
142 |
ilm |
1313 |
int attempt = 0;
|
18 |
ilm |
1314 |
// on verifie qu'un devis du meme numero n'a pas été inséré entre temps
|
142 |
ilm |
1315 |
if (!this.numeroUniqueDevis.checkValidation(false)) {
|
|
|
1316 |
while (attempt < JUniqueTextField.RETRY_COUNT) {
|
|
|
1317 |
String num = NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), dateDevis.getDate());
|
|
|
1318 |
this.numeroUniqueDevis.setText(num);
|
|
|
1319 |
attempt++;
|
|
|
1320 |
if (this.numeroUniqueDevis.checkValidation(false)) {
|
|
|
1321 |
System.err.println("ATEMPT " + attempt + " SUCCESS WITH NUMERO " + num);
|
|
|
1322 |
break;
|
|
|
1323 |
}
|
|
|
1324 |
try {
|
|
|
1325 |
Thread.sleep(JUniqueTextField.SLEEP_WAIT_MS);
|
|
|
1326 |
} catch (InterruptedException e) {
|
|
|
1327 |
e.printStackTrace();
|
|
|
1328 |
}
|
|
|
1329 |
}
|
|
|
1330 |
}
|
|
|
1331 |
final String num = this.numeroUniqueDevis.getText();
|
|
|
1332 |
if (attempt == JUniqueTextField.RETRY_COUNT) {
|
|
|
1333 |
idDevis = getSelectedID();
|
|
|
1334 |
ExceptionHandler.handle("Impossible d'ajouter, numéro de devis existant.");
|
|
|
1335 |
final Object root = SwingUtilities.getRoot(this);
|
|
|
1336 |
if (root instanceof EditFrame) {
|
|
|
1337 |
final EditFrame frame = (EditFrame) root;
|
|
|
1338 |
frame.getPanel().setAlwaysVisible(true);
|
|
|
1339 |
}
|
|
|
1340 |
} else {
|
18 |
ilm |
1341 |
|
|
|
1342 |
idDevis = super.insert(order);
|
|
|
1343 |
this.table.updateField("ID_DEVIS", idDevis);
|
|
|
1344 |
// Création des articles
|
|
|
1345 |
this.table.createArticle(idDevis, getElement());
|
|
|
1346 |
|
|
|
1347 |
// generation du document
|
25 |
ilm |
1348 |
try {
|
|
|
1349 |
final DevisXmlSheet sheet = new DevisXmlSheet(getTable().getRow(idDevis));
|
|
|
1350 |
sheet.createDocumentAsynchronous();
|
182 |
ilm |
1351 |
sheet.showPrintAndExportAsynchronous(DevisSQLComponent.this.panelOO.isVisualisationSelected(), DevisSQLComponent.this.panelOO.isImpressionSelected(), true, getElement(),
|
|
|
1352 |
getElement().getTable().getRow(idDevis));
|
25 |
ilm |
1353 |
} catch (Exception e) {
|
|
|
1354 |
ExceptionHandler.handle("Impossible de créer le devis", e);
|
|
|
1355 |
}
|
18 |
ilm |
1356 |
|
|
|
1357 |
// incrémentation du numéro auto
|
90 |
ilm |
1358 |
if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass()).equalsIgnoreCase(this.numeroUniqueDevis.getText().trim())) {
|
18 |
ilm |
1359 |
final SQLRowValues rowVals = new SQLRowValues(this.tableNum);
|
90 |
ilm |
1360 |
int val = this.tableNum.getRow(2).getInt(NumerotationAutoSQLElement.getLabelNumberFor(getElement().getClass()));
|
18 |
ilm |
1361 |
val++;
|
90 |
ilm |
1362 |
rowVals.put(NumerotationAutoSQLElement.getLabelNumberFor(getElement().getClass()), new Integer(val));
|
18 |
ilm |
1363 |
try {
|
|
|
1364 |
rowVals.update(2);
|
|
|
1365 |
} catch (final SQLException e) {
|
|
|
1366 |
e.printStackTrace();
|
|
|
1367 |
}
|
|
|
1368 |
}
|
142 |
ilm |
1369 |
if (attempt > 0) {
|
|
|
1370 |
SwingUtilities.invokeLater(new Runnable() {
|
|
|
1371 |
public void run() {
|
|
|
1372 |
JOptionPane.showMessageDialog(null, "Le numéro a été actualisé en " + num);
|
|
|
1373 |
}
|
|
|
1374 |
});
|
18 |
ilm |
1375 |
}
|
|
|
1376 |
}
|
|
|
1377 |
|
|
|
1378 |
return idDevis;
|
|
|
1379 |
}
|
|
|
1380 |
|
|
|
1381 |
@Override
|
|
|
1382 |
public void select(final SQLRowAccessor r) {
|
41 |
ilm |
1383 |
if (r == null || r.getIDNumber() == null)
|
|
|
1384 |
super.select(r);
|
|
|
1385 |
else {
|
|
|
1386 |
System.err.println(r);
|
132 |
ilm |
1387 |
final SQLRowValues rVals = r.asRowValues().deepCopy();
|
41 |
ilm |
1388 |
final SQLRowValues vals = new SQLRowValues(r.getTable());
|
|
|
1389 |
vals.load(rVals, createSet("ID_CLIENT"));
|
|
|
1390 |
vals.setID(rVals.getID());
|
|
|
1391 |
System.err.println("Select CLIENT");
|
|
|
1392 |
|
|
|
1393 |
super.select(vals);
|
|
|
1394 |
rVals.remove("ID_CLIENT");
|
|
|
1395 |
super.select(rVals);
|
|
|
1396 |
}
|
|
|
1397 |
|
|
|
1398 |
// super.select(r);
|
18 |
ilm |
1399 |
if (r != null) {
|
|
|
1400 |
this.table.insertFrom("ID_DEVIS", r.getID());
|
41 |
ilm |
1401 |
// this.radioEtat.setVisible(r.getID() > getTable().getUndefinedID());
|
73 |
ilm |
1402 |
if (getTable().contains("SITE_DIFF"))
|
|
|
1403 |
setSiteEnabled(r.getBoolean("SITE_DIFF"), Type_Diff.SITE);
|
|
|
1404 |
|
|
|
1405 |
if (getTable().contains("DONNEUR_DIFF"))
|
|
|
1406 |
setSiteEnabled(r.getBoolean("DONNEUR_DIFF"), Type_Diff.DONNEUR_ORDRE);
|
18 |
ilm |
1407 |
}
|
73 |
ilm |
1408 |
|
18 |
ilm |
1409 |
}
|
|
|
1410 |
|
|
|
1411 |
@Override
|
|
|
1412 |
public void update() {
|
|
|
1413 |
|
|
|
1414 |
if (!this.numeroUniqueDevis.checkValidation()) {
|
|
|
1415 |
ExceptionHandler.handle("Impossible de modifier, numéro de devis existant.");
|
|
|
1416 |
final Object root = SwingUtilities.getRoot(this);
|
|
|
1417 |
if (root instanceof EditFrame) {
|
|
|
1418 |
final EditFrame frame = (EditFrame) root;
|
|
|
1419 |
frame.getPanel().setAlwaysVisible(true);
|
|
|
1420 |
}
|
|
|
1421 |
return;
|
|
|
1422 |
}
|
|
|
1423 |
super.update();
|
|
|
1424 |
this.table.updateField("ID_DEVIS", getSelectedID());
|
|
|
1425 |
this.table.createArticle(getSelectedID(), getElement());
|
|
|
1426 |
|
|
|
1427 |
// generation du document
|
25 |
ilm |
1428 |
|
|
|
1429 |
try {
|
182 |
ilm |
1430 |
final SQLRow row = getTable().getRow(getSelectedID());
|
|
|
1431 |
final DevisXmlSheet sheet = new DevisXmlSheet(row);
|
25 |
ilm |
1432 |
sheet.createDocumentAsynchronous();
|
182 |
ilm |
1433 |
sheet.showPrintAndExportAsynchronous(DevisSQLComponent.this.panelOO.isVisualisationSelected(), DevisSQLComponent.this.panelOO.isImpressionSelected(), true, getElement(), row);
|
25 |
ilm |
1434 |
} catch (Exception e) {
|
|
|
1435 |
ExceptionHandler.handle("Impossible de créer le devis", e);
|
|
|
1436 |
}
|
|
|
1437 |
|
18 |
ilm |
1438 |
}
|
|
|
1439 |
|
|
|
1440 |
/**
|
|
|
1441 |
* Création d'un devis à partir d'un devis existant
|
|
|
1442 |
*
|
|
|
1443 |
* @param idDevis
|
|
|
1444 |
*
|
|
|
1445 |
*/
|
|
|
1446 |
public void loadDevisExistant(final int idDevis) {
|
|
|
1447 |
|
|
|
1448 |
final SQLElement devis = Configuration.getInstance().getDirectory().getElement("DEVIS");
|
|
|
1449 |
final SQLElement devisElt = Configuration.getInstance().getDirectory().getElement("DEVIS_ELEMENT");
|
|
|
1450 |
|
|
|
1451 |
// On duplique le devis
|
|
|
1452 |
if (idDevis > 1) {
|
|
|
1453 |
final SQLRow row = devis.getTable().getRow(idDevis);
|
|
|
1454 |
final SQLRowValues rowVals = new SQLRowValues(devis.getTable());
|
|
|
1455 |
rowVals.put("ID_CLIENT", row.getInt("ID_CLIENT"));
|
156 |
ilm |
1456 |
if (row.getObject("ID_TARIF") != null && !row.isForeignEmpty("ID_TARIF")) {
|
|
|
1457 |
rowVals.put("ID_TARIF", row.getInt("ID_TARIF"));
|
|
|
1458 |
}
|
90 |
ilm |
1459 |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
|
73 |
ilm |
1460 |
|
|
|
1461 |
|
18 |
ilm |
1462 |
this.select(rowVals);
|
|
|
1463 |
}
|
|
|
1464 |
|
|
|
1465 |
// On duplique les elements de devis
|
|
|
1466 |
final List<SQLRow> myListItem = devis.getTable().getRow(idDevis).getReferentRows(devisElt.getTable());
|
|
|
1467 |
|
|
|
1468 |
if (myListItem.size() != 0) {
|
|
|
1469 |
this.table.getModel().clearRows();
|
|
|
1470 |
|
|
|
1471 |
for (final SQLRow rowElt : myListItem) {
|
|
|
1472 |
|
|
|
1473 |
final SQLRowValues rowVals = rowElt.createUpdateRow();
|
|
|
1474 |
rowVals.clearPrimaryKeys();
|
182 |
ilm |
1475 |
this.table.getModel().addRow(rowVals, false);
|
18 |
ilm |
1476 |
final int rowIndex = this.table.getModel().getRowCount() - 1;
|
|
|
1477 |
this.table.getModel().fireTableModelModified(rowIndex);
|
|
|
1478 |
}
|
|
|
1479 |
} else {
|
|
|
1480 |
this.table.getModel().clearRows();
|
|
|
1481 |
}
|
|
|
1482 |
this.table.getModel().fireTableDataChanged();
|
|
|
1483 |
this.table.repaint();
|
|
|
1484 |
}
|
93 |
ilm |
1485 |
|
18 |
ilm |
1486 |
}
|