Line 1... |
Line 1... |
1 |
/*
|
1 |
/*
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
3 |
*
|
3 |
*
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
4 |
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
|
5 |
*
|
5 |
*
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
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
|
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
|
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.
|
9 |
* language governing permissions and limitations under the License.
|
Line 50... |
Line 50... |
50 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
50 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
51 |
import org.openconcerto.sql.sqlobject.ElementComboBox;
|
51 |
import org.openconcerto.sql.sqlobject.ElementComboBox;
|
52 |
import org.openconcerto.sql.sqlobject.JUniqueTextField;
|
52 |
import org.openconcerto.sql.sqlobject.JUniqueTextField;
|
53 |
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
|
53 |
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
|
54 |
import org.openconcerto.sql.sqlobject.SQLTextCombo;
|
54 |
import org.openconcerto.sql.sqlobject.SQLTextCombo;
|
- |
|
55 |
import org.openconcerto.sql.sqlobject.itemview.SimpleRowItemView;
|
55 |
import org.openconcerto.sql.ui.RadioButtons;
|
56 |
import org.openconcerto.sql.ui.RadioButtons;
|
56 |
import org.openconcerto.sql.users.UserManager;
|
57 |
import org.openconcerto.sql.users.UserManager;
|
57 |
import org.openconcerto.sql.users.rights.UserRightsManager;
|
58 |
import org.openconcerto.sql.users.rights.UserRightsManager;
|
58 |
import org.openconcerto.sql.view.EditFrame;
|
59 |
import org.openconcerto.sql.view.EditFrame;
|
59 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
60 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
60 |
import org.openconcerto.ui.FormLayouter;
|
61 |
import org.openconcerto.ui.FormLayouter;
|
61 |
import org.openconcerto.ui.JDate;
|
62 |
import org.openconcerto.ui.JDate;
|
62 |
import org.openconcerto.ui.TitledSeparator;
|
63 |
import org.openconcerto.ui.TitledSeparator;
|
63 |
import org.openconcerto.ui.VFlowLayout;
|
64 |
import org.openconcerto.ui.VFlowLayout;
|
64 |
import org.openconcerto.ui.component.ITextArea;
|
65 |
import org.openconcerto.ui.component.ITextArea;
|
- |
|
66 |
import org.openconcerto.ui.valuewrapper.ValidatedValueWrapper;
|
65 |
import org.openconcerto.utils.ExceptionHandler;
|
67 |
import org.openconcerto.utils.ExceptionHandler;
|
66 |
import org.openconcerto.utils.GestionDevise;
|
68 |
import org.openconcerto.utils.GestionDevise;
|
67 |
import org.openconcerto.utils.cc.ITransformer;
|
69 |
import org.openconcerto.utils.cc.ITransformer;
|
68 |
import org.openconcerto.utils.checks.ValidState;
|
70 |
import org.openconcerto.utils.checks.ValidState;
|
69 |
import org.openconcerto.utils.text.SimpleDocumentListener;
|
71 |
import org.openconcerto.utils.text.SimpleDocumentListener;
|
Line 296... |
Line 298... |
296 |
c.weightx = 0;
|
298 |
c.weightx = 0;
|
297 |
c.gridwidth = 1;
|
299 |
c.gridwidth = 1;
|
298 |
c.fill = GridBagConstraints.HORIZONTAL;
|
300 |
c.fill = GridBagConstraints.HORIZONTAL;
|
299 |
this.add(labelClient, c);
|
301 |
this.add(labelClient, c);
|
300 |
|
302 |
|
- |
|
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 |
});
|
301 |
final ElementComboBox comboClient = new ElementComboBox();
|
314 |
final ElementComboBox comboClient = (ElementComboBox) clientValidatedValueWrapper.getComp();
|
- |
|
315 |
|
- |
|
316 |
addView(new SimpleRowItemView<Integer>(clientValidatedValueWrapper), "ID_CLIENT", REQ);
|
302 |
c.gridx++;
|
317 |
c.gridx++;
|
303 |
c.gridwidth = 1;
|
318 |
c.gridwidth = 1;
|
304 |
c.weightx = 0;
|
319 |
c.weightx = 0;
|
305 |
c.weighty = 0;
|
320 |
c.weighty = 0;
|
306 |
c.fill = GridBagConstraints.NONE;
|
321 |
c.fill = GridBagConstraints.NONE;
|
307 |
this.add(comboClient, c);
|
322 |
this.add(comboClient, c);
|
308 |
addRequiredSQLObject(comboClient, "ID_CLIENT");
|
- |
|
309 |
|
323 |
|
310 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
324 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
311 |
|
325 |
|
312 |
@Override
|
326 |
@Override
|
313 |
public void propertyChange(PropertyChangeEvent evt) {
|
327 |
public void propertyChange(PropertyChangeEvent evt) {
|
Line 316... |
Line 330... |
316 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
330 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
317 |
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID);
|
331 |
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID);
|
318 |
if (!rowClient.isForeignEmpty("ID_COMMERCIAL")) {
|
332 |
if (!rowClient.isForeignEmpty("ID_COMMERCIAL")) {
|
319 |
comboCommercial.setValue(rowClient.getForeignID("ID_COMMERCIAL"));
|
333 |
comboCommercial.setValue(rowClient.getForeignID("ID_COMMERCIAL"));
|
320 |
}
|
334 |
}
|
- |
|
335 |
String alerte = rowClient.getString("ALERTE");
|
- |
|
336 |
if (!isFilling() && alerte != null && alerte.trim().length() > 0) {
|
- |
|
337 |
JOptionPane.showMessageDialog(comboClient, alerte);
|
- |
|
338 |
}
|
321 |
}
|
339 |
}
|
322 |
}
|
340 |
}
|
323 |
});
|
341 |
});
|
324 |
if (this.displayDpt) {
|
342 |
if (this.displayDpt) {
|
325 |
c.gridx++;
|
343 |
c.gridx++;
|
Line 460... |
Line 478... |
460 |
JDate dateValidite = new JDate();
|
478 |
JDate dateValidite = new JDate();
|
461 |
this.add(dateValidite, c);
|
479 |
this.add(dateValidite, c);
|
462 |
this.addView(dateValidite, "DATE_VALIDITE");
|
480 |
this.addView(dateValidite, "DATE_VALIDITE");
|
463 |
}
|
481 |
}
|
464 |
|
482 |
|
- |
|
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 |
|
465 |
// Tarif
|
510 |
// Tarif
|
466 |
if (this.getTable().getFieldsName().contains("ID_TARIF")) {
|
511 |
if (this.getTable().getFieldsName().contains("ID_TARIF")) {
|
467 |
// TARIF
|
512 |
// TARIF
|
468 |
c.gridy++;
|
513 |
c.gridy++;
|
469 |
c.gridx = 0;
|
514 |
c.gridx = 0;
|
Line 783... |
Line 828... |
783 |
addSQLObject(this.infos, "INFOS");
|
828 |
addSQLObject(this.infos, "INFOS");
|
784 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
829 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
785 |
|
830 |
|
786 |
@Override
|
831 |
@Override
|
787 |
public void propertyChange(PropertyChangeEvent arg0) {
|
832 |
public void propertyChange(PropertyChangeEvent arg0) {
|
788 |
if (!isFilling()) {
|
- |
|
- |
|
833 |
|
789 |
Integer id = comboClient.getWantedID();
|
834 |
Integer id = comboClient.getWantedID();
|
790 |
|
835 |
|
791 |
if (id > 1) {
|
836 |
if (id > 1) {
|
792 |
|
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 |
|
- |
|
848 |
if (!isFilling()) {
|
- |
|
849 |
|
- |
|
850 |
if (id > 1) {
|
- |
|
851 |
|
793 |
SQLRow row = comboClient.getElement().getTable().getRow(id);
|
852 |
SQLRow row = comboClient.getElement().getTable().getRow(id);
|
794 |
if (comboClient.getElement().getTable().getFieldsName().contains("ID_TARIF")) {
|
853 |
if (comboClient.getElement().getTable().getFieldsName().contains("ID_TARIF")) {
|
795 |
|
854 |
|
796 |
SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
|
855 |
SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
|
797 |
if (!foreignRow.isUndefined() && (boxTarif.getSelectedRow() == null || boxTarif.getSelectedId() != foreignRow.getID())
|
856 |
if (!foreignRow.isUndefined() && (boxTarif.getSelectedRow() == null || boxTarif.getSelectedId() != foreignRow.getID())
|
Line 822... |
Line 881... |
822 |
DefaultGridBagConstraints.lockMinimumSize(comboClient);
|
881 |
DefaultGridBagConstraints.lockMinimumSize(comboClient);
|
823 |
}
|
882 |
}
|
824 |
|
883 |
|
825 |
private enum Type_Diff {
|
884 |
private enum Type_Diff {
|
826 |
SITE("SITE"), DONNEUR_ORDRE("DONNEUR");
|
885 |
SITE("SITE"), DONNEUR_ORDRE("DONNEUR");
|
- |
|
886 |
|
827 |
private final String name;
|
887 |
private final String name;
|
828 |
|
888 |
|
829 |
private Type_Diff(String name) {
|
889 |
private Type_Diff(String name) {
|
830 |
this.name = name;
|
890 |
this.name = name;
|
831 |
}
|
891 |
}
|
Line 1286... |
Line 1346... |
1286 |
|
1346 |
|
1287 |
// generation du document
|
1347 |
// generation du document
|
1288 |
try {
|
1348 |
try {
|
1289 |
final DevisXmlSheet sheet = new DevisXmlSheet(getTable().getRow(idDevis));
|
1349 |
final DevisXmlSheet sheet = new DevisXmlSheet(getTable().getRow(idDevis));
|
1290 |
sheet.createDocumentAsynchronous();
|
1350 |
sheet.createDocumentAsynchronous();
|
1291 |
sheet.showPrintAndExportAsynchronous(DevisSQLComponent.this.panelOO.isVisualisationSelected(), DevisSQLComponent.this.panelOO.isImpressionSelected(), true);
|
1351 |
sheet.showPrintAndExportAsynchronous(DevisSQLComponent.this.panelOO.isVisualisationSelected(), DevisSQLComponent.this.panelOO.isImpressionSelected(), true, getElement(),
|
- |
|
1352 |
getElement().getTable().getRow(idDevis));
|
1292 |
} catch (Exception e) {
|
1353 |
} catch (Exception e) {
|
1293 |
ExceptionHandler.handle("Impossible de créer le devis", e);
|
1354 |
ExceptionHandler.handle("Impossible de créer le devis", e);
|
1294 |
}
|
1355 |
}
|
1295 |
|
1356 |
|
1296 |
// incrémentation du numéro auto
|
1357 |
// incrémentation du numéro auto
|
Line 1364... |
Line 1425... |
1364 |
this.table.createArticle(getSelectedID(), getElement());
|
1425 |
this.table.createArticle(getSelectedID(), getElement());
|
1365 |
|
1426 |
|
1366 |
// generation du document
|
1427 |
// generation du document
|
1367 |
|
1428 |
|
1368 |
try {
|
1429 |
try {
|
- |
|
1430 |
final SQLRow row = getTable().getRow(getSelectedID());
|
1369 |
final DevisXmlSheet sheet = new DevisXmlSheet(getTable().getRow(getSelectedID()));
|
1431 |
final DevisXmlSheet sheet = new DevisXmlSheet(row);
|
1370 |
sheet.createDocumentAsynchronous();
|
1432 |
sheet.createDocumentAsynchronous();
|
1371 |
sheet.showPrintAndExportAsynchronous(DevisSQLComponent.this.panelOO.isVisualisationSelected(), DevisSQLComponent.this.panelOO.isImpressionSelected(), true);
|
1433 |
sheet.showPrintAndExportAsynchronous(DevisSQLComponent.this.panelOO.isVisualisationSelected(), DevisSQLComponent.this.panelOO.isImpressionSelected(), true, getElement(), row);
|
1372 |
} catch (Exception e) {
|
1434 |
} catch (Exception e) {
|
1373 |
ExceptionHandler.handle("Impossible de créer le devis", e);
|
1435 |
ExceptionHandler.handle("Impossible de créer le devis", e);
|
1374 |
}
|
1436 |
}
|
1375 |
|
1437 |
|
1376 |
}
|
1438 |
}
|
Line 1408... |
Line 1470... |
1408 |
|
1470 |
|
1409 |
for (final SQLRow rowElt : myListItem) {
|
1471 |
for (final SQLRow rowElt : myListItem) {
|
1410 |
|
1472 |
|
1411 |
final SQLRowValues rowVals = rowElt.createUpdateRow();
|
1473 |
final SQLRowValues rowVals = rowElt.createUpdateRow();
|
1412 |
rowVals.clearPrimaryKeys();
|
1474 |
rowVals.clearPrimaryKeys();
|
1413 |
this.table.getModel().addRow(rowVals);
|
1475 |
this.table.getModel().addRow(rowVals, false);
|
1414 |
final int rowIndex = this.table.getModel().getRowCount() - 1;
|
1476 |
final int rowIndex = this.table.getModel().getRowCount() - 1;
|
1415 |
this.table.getModel().fireTableModelModified(rowIndex);
|
1477 |
this.table.getModel().fireTableModelModified(rowIndex);
|
1416 |
}
|
1478 |
}
|
1417 |
} else {
|
1479 |
} else {
|
1418 |
this.table.getModel().clearRows();
|
1480 |
this.table.getModel().clearRows();
|