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.reports.history.ui;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
|
|
17 |
import org.openconcerto.erp.core.common.ui.PanelFrame;
|
|
|
18 |
import org.openconcerto.erp.preferences.DefaultNXProps;
|
|
|
19 |
import org.openconcerto.sql.Configuration;
|
|
|
20 |
import org.openconcerto.sql.model.SQLBase;
|
|
|
21 |
import org.openconcerto.sql.model.SQLField;
|
|
|
22 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
|
|
23 |
import org.openconcerto.sql.model.SQLTable;
|
21 |
ilm |
24 |
import org.openconcerto.sql.model.Where;
|
65 |
ilm |
25 |
import org.openconcerto.sql.users.rights.JListSQLTablePanel;
|
18 |
ilm |
26 |
|
|
|
27 |
import java.awt.event.WindowAdapter;
|
|
|
28 |
import java.awt.event.WindowEvent;
|
28 |
ilm |
29 |
import java.util.Arrays;
|
18 |
ilm |
30 |
import java.util.HashMap;
|
|
|
31 |
import java.util.List;
|
|
|
32 |
import java.util.Map;
|
|
|
33 |
|
|
|
34 |
import javax.swing.JFrame;
|
|
|
35 |
import javax.swing.event.TableModelEvent;
|
|
|
36 |
import javax.swing.event.TableModelListener;
|
|
|
37 |
|
|
|
38 |
public class HistoriqueClientFrame {
|
|
|
39 |
|
|
|
40 |
private PanelFrame panelFrame;
|
|
|
41 |
private ListeHistoriquePanel listPanel;
|
|
|
42 |
|
|
|
43 |
public HistoriqueClientFrame() {
|
|
|
44 |
final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration.getInstance());
|
|
|
45 |
SQLBase b = comptaPropsConfiguration.getSQLBaseSociete();
|
|
|
46 |
|
28 |
ilm |
47 |
// List<String> l = new ArrayList<String>();
|
|
|
48 |
Map<String, List<String>> mapList = new HashMap<String, List<String>>();
|
18 |
ilm |
49 |
|
41 |
ilm |
50 |
final Boolean bModeVenteComptoir = DefaultNXProps.getInstance().getBooleanValue("ArticleVenteComptoir", true);
|
18 |
ilm |
51 |
if (bModeVenteComptoir) {
|
28 |
ilm |
52 |
mapList.put("Ventes comptoir", Arrays.asList("SAISIE_VENTE_COMPTOIR"));
|
18 |
ilm |
53 |
}
|
28 |
ilm |
54 |
mapList.put("Ventes facture", Arrays.asList("SAISIE_VENTE_FACTURE"));
|
|
|
55 |
mapList.put("Chèques à encaisser", Arrays.asList("CHEQUE_A_ENCAISSER"));
|
|
|
56 |
mapList.put("Echéances", Arrays.asList("ECHEANCE_CLIENT"));
|
|
|
57 |
mapList.put("Relances", Arrays.asList("RELANCE"));
|
|
|
58 |
mapList.put("Devis", Arrays.asList("DEVIS"));
|
180 |
ilm |
59 |
mapList.put("Commandes", Arrays.asList("COMMANDE_CLIENT"));
|
182 |
ilm |
60 |
mapList.put("Bons de livraison", Arrays.asList("BON_DE_LIVRAISON"));
|
28 |
ilm |
61 |
mapList.put("Avoirs", Arrays.asList("AVOIR_CLIENT"));
|
185 |
ilm |
62 |
mapList.put("Articles proposés", Arrays.asList("DEVIS_ELEMENT"));
|
|
|
63 |
mapList.put("Articles commandés", Arrays.asList("COMMANDE_CLIENT_ELEMENT"));
|
93 |
ilm |
64 |
mapList.put("Articles facturés", Arrays.asList("SAISIE_VENTE_FACTURE_ELEMENT"));
|
156 |
ilm |
65 |
mapList.put("Encaissements", Arrays.asList("ENCAISSER_MONTANT"));
|
18 |
ilm |
66 |
Map<SQLTable, SQLField> map = new HashMap<SQLTable, SQLField>();
|
|
|
67 |
map.put(b.getTable("SAISIE_VENTE_FACTURE_ELEMENT"), b.getTable("SAISIE_VENTE_FACTURE_ELEMENT").getField("ID_SAISIE_VENTE_FACTURE"));
|
28 |
ilm |
68 |
map.put(b.getTable("DEVIS_ELEMENT"), b.getTable("DEVIS_ELEMENT").getField("ID_DEVIS"));
|
185 |
ilm |
69 |
map.put(b.getTable("COMMANDE_CLIENT_ELEMENT"), b.getTable("COMMANDE_CLIENT_ELEMENT").getField("ID_COMMANDE_CLIENT"));
|
18 |
ilm |
70 |
|
|
|
71 |
final HistoriqueClientBilanPanel bilanPanel = new HistoriqueClientBilanPanel();
|
67 |
ilm |
72 |
SQLTable tableEch = Configuration.getInstance().getRoot().findTable("ECHEANCE_CLIENT");
|
|
|
73 |
Where wNotRegle = new Where(tableEch.getField("REGLE"), "=", Boolean.FALSE);
|
|
|
74 |
wNotRegle = wNotRegle.and(new Where(tableEch.getField("REG_COMPTA"), "=", Boolean.FALSE));
|
18 |
ilm |
75 |
|
156 |
ilm |
76 |
this.listPanel = new ListeHistoriquePanel("Clients", JListSQLTablePanel.createComboRequest(Configuration.getInstance().getDirectory().getElement(b.getTable("CLIENT")), false), mapList,
|
|
|
77 |
bilanPanel, map, null, wNotRegle);
|
18 |
ilm |
78 |
this.listPanel.addListenerTable(new TableModelListener() {
|
|
|
79 |
public void tableChanged(TableModelEvent arg0) {
|
|
|
80 |
bilanPanel.updateRelance(HistoriqueClientFrame.this.listPanel.getListId("RELANCE"));
|
|
|
81 |
}
|
|
|
82 |
}, "RELANCE");
|
|
|
83 |
|
|
|
84 |
this.listPanel.addListenerTable(new TableModelListener() {
|
|
|
85 |
public void tableChanged(TableModelEvent arg0) {
|
|
|
86 |
bilanPanel.updateEcheance(HistoriqueClientFrame.this.listPanel.getListId("ECHEANCE_CLIENT"));
|
|
|
87 |
}
|
|
|
88 |
}, "ECHEANCE_CLIENT");
|
|
|
89 |
|
|
|
90 |
this.listPanel.addListenerTable(new TableModelListener() {
|
|
|
91 |
public void tableChanged(TableModelEvent arg0) {
|
|
|
92 |
bilanPanel.updateChequeData(HistoriqueClientFrame.this.listPanel.getListId("CHEQUE_A_ENCAISSER"));
|
|
|
93 |
}
|
|
|
94 |
}, "CHEQUE_A_ENCAISSER");
|
|
|
95 |
|
|
|
96 |
this.listPanel.addListenerTable(new TableModelListener() {
|
|
|
97 |
public void tableChanged(TableModelEvent arg0) {
|
|
|
98 |
bilanPanel.updateVCData(HistoriqueClientFrame.this.listPanel.getListId("SAISIE_VENTE_COMPTOIR"));
|
|
|
99 |
}
|
|
|
100 |
}, "SAISIE_VENTE_COMPTOIR");
|
|
|
101 |
|
|
|
102 |
this.listPanel.addListenerTable(new TableModelListener() {
|
|
|
103 |
public void tableChanged(TableModelEvent arg0) {
|
|
|
104 |
SQLRowAccessor rowSel = HistoriqueClientFrame.this.listPanel.getSelectedRow();
|
|
|
105 |
int id = (rowSel == null) ? -1 : rowSel.getID();
|
|
|
106 |
bilanPanel.updateVFData(HistoriqueClientFrame.this.listPanel.getListId("SAISIE_VENTE_FACTURE"), id);
|
|
|
107 |
}
|
|
|
108 |
}, "SAISIE_VENTE_FACTURE");
|
|
|
109 |
|
90 |
ilm |
110 |
this.listPanel.addListenerTable(new TableModelListener() {
|
|
|
111 |
public void tableChanged(TableModelEvent arg0) {
|
|
|
112 |
|
|
|
113 |
SQLRowAccessor rowSel = HistoriqueClientFrame.this.listPanel.getSelectedRow();
|
|
|
114 |
int id = (rowSel == null) ? -1 : rowSel.getID();
|
|
|
115 |
bilanPanel.updateVFArticleData(HistoriqueClientFrame.this.listPanel.getListId("SAISIE_VENTE_FACTURE_ELEMENT"), id);
|
|
|
116 |
}
|
|
|
117 |
}, "SAISIE_VENTE_FACTURE_ELEMENT");
|
|
|
118 |
|
18 |
ilm |
119 |
this.panelFrame = new PanelFrame(this.listPanel, "Historique client");
|
|
|
120 |
this.panelFrame.addWindowListener(new WindowAdapter() {
|
|
|
121 |
public void windowClosing(WindowEvent e) {
|
|
|
122 |
listPanel.removeAllTableListener();
|
|
|
123 |
};
|
|
|
124 |
});
|
|
|
125 |
|
|
|
126 |
this.panelFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
156 |
ilm |
127 |
|
|
|
128 |
// // Daet filter
|
|
|
129 |
// Map<IListe, SQLField> listeFilter = new HashMap<IListe, SQLField>();
|
|
|
130 |
// IListe listeRel = this.listPanel.getIListeFromTableName("RELANCE");
|
|
|
131 |
// listeFilter.put(listeRel, listeRel.getModel().getTable().getField("DATE"));
|
|
|
132 |
// IListe listeVtC = this.listPanel.getIListeFromTableName("SAISIE_VENTE_COMPTOIR");
|
|
|
133 |
// listeFilter.put(listeVtC, listeVtC.getModel().getTable().getField("DATE"));
|
|
|
134 |
// IListe listeDevis = this.listPanel.getIListeFromTableName("DEVIS");
|
|
|
135 |
// listeFilter.put(listeDevis, listeDevis.getModel().getTable().getField("DATE"));
|
|
|
136 |
//
|
|
|
137 |
// IListe listeChq = this.listPanel.getIListeFromTableName("CHEQUE_A_ENCAISSER");
|
|
|
138 |
// listeFilter.put(listeChq, listeChq.getModel().getTable().getField("DATE"));
|
|
|
139 |
//
|
|
|
140 |
// IListe listeEch = this.listPanel.getIListeFromTableName("ECHEANCE_CLIENT");
|
|
|
141 |
// listeFilter.put(listeEch, listeEch.getModel().getTable().getField("DATE"));
|
|
|
142 |
// IListe listedevisElt = this.listPanel.getIListeFromTableName("DEVIS_ELEMENT");
|
|
|
143 |
// listeFilter.put(listedevisElt,
|
|
|
144 |
// listedevisElt.getModel().getTable().getForeignTable("ID_DEVIS").getField("DATE"));
|
|
|
145 |
//
|
|
|
146 |
// IListe listeAvoir = this.listPanel.getIListeFromTableName("AVOIR_CLIENT");
|
|
|
147 |
// listeFilter.put(listeAvoir, listeAvoir.getModel().getTable().getField("DATE"));
|
|
|
148 |
//
|
|
|
149 |
// IListe listefactElt =
|
|
|
150 |
// this.listPanel.getIListeFromTableName("SAISIE_VENTE_FACTURE_ELEMENT");
|
|
|
151 |
// listeFilter.put(listefactElt,
|
|
|
152 |
// listefactElt.getModel().getTable().getForeignTable("ID_SAISIE_VENTE_FACTURE").getField("DATE"));
|
|
|
153 |
//
|
|
|
154 |
// IListe listeFact = this.listPanel.getIListeFromTableName("SAISIE_VENTE_FACTURE");
|
|
|
155 |
// listeFilter.put(listeFact, listeFact.getModel().getTable().getField("DATE"));
|
|
|
156 |
//
|
|
|
157 |
// final IListFilterDatePanel panel = new IListFilterDatePanel(listeFilter,
|
|
|
158 |
// IListFilterDatePanel.getDefaultMap());
|
|
|
159 |
// GridBagConstraints c = new DefaultGridBagConstraints();
|
|
|
160 |
// c.gridy = 4;
|
|
|
161 |
// c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
162 |
// c.weightx = 1;
|
|
|
163 |
// c.gridx=0;
|
|
|
164 |
// this.listPanel.add(panel);
|
|
|
165 |
|
18 |
ilm |
166 |
}
|
|
|
167 |
|
|
|
168 |
public PanelFrame getFrame() {
|
|
|
169 |
return this.panelFrame;
|
|
|
170 |
}
|
|
|
171 |
|
|
|
172 |
public void selectId(int id) {
|
|
|
173 |
this.listPanel.selectIDinJList(id);
|
|
|
174 |
}
|
|
|
175 |
|
|
|
176 |
public void setVisible(boolean b) {
|
|
|
177 |
this.panelFrame.setVisible(b);
|
|
|
178 |
}
|
|
|
179 |
}
|