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.humanresources.payroll.element;
|
|
|
15 |
|
156 |
ilm |
16 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
142 |
ilm |
17 |
import org.openconcerto.erp.core.humanresources.payroll.ui.CaisseCotisationRenseignementTable;
|
18 |
ilm |
18 |
import org.openconcerto.sql.Configuration;
|
|
|
19 |
import org.openconcerto.sql.element.BaseSQLComponent;
|
|
|
20 |
import org.openconcerto.sql.element.ElementSQLObject;
|
|
|
21 |
import org.openconcerto.sql.element.SQLComponent;
|
156 |
ilm |
22 |
import org.openconcerto.sql.model.DBRoot;
|
18 |
ilm |
23 |
import org.openconcerto.sql.model.SQLRow;
|
142 |
ilm |
24 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
18 |
ilm |
25 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
|
|
26 |
import org.openconcerto.sql.model.SQLSelect;
|
|
|
27 |
import org.openconcerto.sql.model.SQLTable;
|
|
|
28 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
|
|
29 |
import org.openconcerto.ui.TitledSeparator;
|
132 |
ilm |
30 |
import org.openconcerto.utils.ListMap;
|
18 |
ilm |
31 |
|
142 |
ilm |
32 |
import java.awt.GridBagConstraints;
|
|
|
33 |
import java.awt.GridBagLayout;
|
182 |
ilm |
34 |
import java.sql.SQLException;
|
142 |
ilm |
35 |
import java.util.ArrayList;
|
|
|
36 |
import java.util.List;
|
|
|
37 |
|
|
|
38 |
import javax.swing.BorderFactory;
|
|
|
39 |
import javax.swing.JCheckBox;
|
|
|
40 |
import javax.swing.JLabel;
|
|
|
41 |
import javax.swing.JPanel;
|
|
|
42 |
import javax.swing.JTextField;
|
|
|
43 |
|
156 |
ilm |
44 |
public class CaisseCotisationSQLElement extends ComptaSQLConfElement {
|
18 |
ilm |
45 |
|
156 |
ilm |
46 |
public CaisseCotisationSQLElement(final DBRoot root) {
|
|
|
47 |
super(root.getTable("CAISSE_COTISATION"), "une caisse", "caisses");
|
18 |
ilm |
48 |
}
|
|
|
49 |
|
|
|
50 |
protected List<String> getListFields() {
|
|
|
51 |
final List<String> l = new ArrayList<String>();
|
|
|
52 |
l.add("NOM");
|
|
|
53 |
l.add("ID_ADRESSE_COMMON");
|
132 |
ilm |
54 |
l.add("NUMERO_COMPTE_PCE");
|
|
|
55 |
l.add("NUMERO_COMPTE_PCE_CHARGES");
|
18 |
ilm |
56 |
return l;
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
protected List<String> getComboFields() {
|
|
|
60 |
final List<String> l = new ArrayList<String>();
|
|
|
61 |
l.add("NOM");
|
|
|
62 |
return l;
|
|
|
63 |
}
|
|
|
64 |
|
132 |
ilm |
65 |
@Override
|
|
|
66 |
public ListMap<String, String> getShowAs() {
|
|
|
67 |
return ListMap.singleton(null, "NOM");
|
18 |
ilm |
68 |
}
|
|
|
69 |
|
|
|
70 |
private final static SQLTable tableCaisse = Configuration.getInstance().getBase().getTable("CAISSE_COTISATION");
|
|
|
71 |
|
|
|
72 |
private static List<SQLRow> liste;
|
|
|
73 |
|
|
|
74 |
public static List<SQLRow> getCaisseCotisation() {
|
|
|
75 |
if (liste == null) {
|
|
|
76 |
SQLSelect selCaisse = new SQLSelect(Configuration.getInstance().getBase());
|
|
|
77 |
selCaisse.addSelect(tableCaisse.getField("ID"));
|
|
|
78 |
selCaisse.addSelect(tableCaisse.getField("NOM"));
|
|
|
79 |
|
|
|
80 |
String req = selCaisse.asString();
|
|
|
81 |
liste = (List<SQLRow>) Configuration.getInstance().getBase().getDataSource().execute(req, SQLRowListRSH.createFromSelect(selCaisse));
|
|
|
82 |
}
|
|
|
83 |
return liste;
|
|
|
84 |
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
/*
|
|
|
88 |
* (non-Javadoc)
|
|
|
89 |
*
|
|
|
90 |
* @see org.openconcerto.devis.SQLElement#getComponent()
|
|
|
91 |
*/
|
|
|
92 |
public SQLComponent createComponent() {
|
|
|
93 |
return new BaseSQLComponent(this) {
|
142 |
ilm |
94 |
CaisseCotisationRenseignementTable table;
|
18 |
ilm |
95 |
|
|
|
96 |
public void addViews() {
|
|
|
97 |
|
|
|
98 |
this.setLayout(new GridBagLayout());
|
|
|
99 |
final GridBagConstraints c = new DefaultGridBagConstraints();
|
|
|
100 |
|
|
|
101 |
/***********************************************************************************
|
|
|
102 |
* Renseignements
|
|
|
103 |
**********************************************************************************/
|
|
|
104 |
JPanel panelInfos = new JPanel();
|
|
|
105 |
panelInfos.setBorder(BorderFactory.createTitledBorder("Renseignements"));
|
|
|
106 |
panelInfos.setLayout(new GridBagLayout());
|
|
|
107 |
|
|
|
108 |
// Nom
|
|
|
109 |
JLabel labelNom = new JLabel(getLabelFor("NOM"));
|
|
|
110 |
JTextField textNom = new JTextField();
|
|
|
111 |
panelInfos.add(labelNom, c);
|
|
|
112 |
c.gridx++;
|
|
|
113 |
c.weightx = 1;
|
|
|
114 |
panelInfos.add(textNom, c);
|
|
|
115 |
c.weightx = 0;
|
|
|
116 |
|
142 |
ilm |
117 |
// Nom
|
|
|
118 |
JCheckBox boxOrgProt = new JCheckBox(getLabelFor("ORG_PROTECTION_SOCIALE"));
|
|
|
119 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
120 |
c.weightx = 1;
|
|
|
121 |
c.gridy++;
|
|
|
122 |
c.gridx = 0;
|
|
|
123 |
panelInfos.add(boxOrgProt, c);
|
|
|
124 |
this.addSQLObject(boxOrgProt, "ORG_PROTECTION_SOCIALE");
|
|
|
125 |
c.gridwidth = 1;
|
|
|
126 |
|
|
|
127 |
// Nom
|
|
|
128 |
JCheckBox boxUrssaf = new JCheckBox(getLabelFor("URSSAF"));
|
|
|
129 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
130 |
c.weightx = 1;
|
|
|
131 |
c.gridy++;
|
|
|
132 |
c.gridx = 0;
|
|
|
133 |
panelInfos.add(boxUrssaf, c);
|
|
|
134 |
this.addSQLObject(boxUrssaf, "URSSAF");
|
|
|
135 |
c.gridwidth = 1;
|
|
|
136 |
|
18 |
ilm |
137 |
// Adresse
|
|
|
138 |
TitledSeparator sep = new TitledSeparator("Adresse");
|
|
|
139 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
140 |
c.gridy++;
|
|
|
141 |
c.gridx = 0;
|
|
|
142 |
panelInfos.add(sep, c);
|
|
|
143 |
|
67 |
ilm |
144 |
this.addView("ID_ADRESSE_COMMON", REQ + ";" + DEC + ";" + SEP);
|
18 |
ilm |
145 |
ElementSQLObject eltAdr = (ElementSQLObject) this.getView("ID_ADRESSE_COMMON");
|
|
|
146 |
c.gridy++;
|
|
|
147 |
c.gridx = 0;
|
|
|
148 |
|
|
|
149 |
panelInfos.add(eltAdr, c);
|
|
|
150 |
|
|
|
151 |
TitledSeparator sepContact = new TitledSeparator("Contact");
|
|
|
152 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
153 |
c.gridy++;
|
|
|
154 |
c.gridx = 0;
|
|
|
155 |
panelInfos.add(sepContact, c);
|
|
|
156 |
// Telephone
|
|
|
157 |
JLabel labelTel = new JLabel(getLabelFor("TEL"));
|
|
|
158 |
JTextField textTel = new JTextField();
|
|
|
159 |
|
|
|
160 |
c.gridy++;
|
|
|
161 |
c.gridwidth = 1;
|
|
|
162 |
c.gridx = 0;
|
|
|
163 |
panelInfos.add(labelTel, c);
|
|
|
164 |
|
|
|
165 |
c.gridx++;
|
|
|
166 |
c.weightx = 1;
|
|
|
167 |
panelInfos.add(textTel, c);
|
|
|
168 |
c.weightx = 0;
|
|
|
169 |
|
|
|
170 |
// Telephone portable
|
|
|
171 |
JLabel labelTelP = new JLabel(getLabelFor("TEL_PORTABLE"));
|
|
|
172 |
JTextField textTelP = new JTextField();
|
|
|
173 |
|
|
|
174 |
c.gridx++;
|
|
|
175 |
panelInfos.add(labelTelP, c);
|
|
|
176 |
|
|
|
177 |
c.gridx++;
|
|
|
178 |
c.weightx = 1;
|
|
|
179 |
panelInfos.add(textTelP, c);
|
|
|
180 |
c.weightx = 0;
|
|
|
181 |
|
|
|
182 |
// Mail
|
|
|
183 |
JLabel labelMail = new JLabel(getLabelFor("MAIL"));
|
|
|
184 |
JTextField textMail = new JTextField();
|
|
|
185 |
|
|
|
186 |
c.gridy++;
|
|
|
187 |
c.gridx = 0;
|
|
|
188 |
panelInfos.add(labelMail, c);
|
|
|
189 |
|
|
|
190 |
c.gridx++;
|
|
|
191 |
c.weightx = 1;
|
|
|
192 |
panelInfos.add(textMail, c);
|
142 |
ilm |
193 |
|
|
|
194 |
this.addSQLObject(textMail, "MAIL");
|
18 |
ilm |
195 |
c.weightx = 0;
|
|
|
196 |
|
|
|
197 |
c.gridx = 0;
|
|
|
198 |
c.gridy = 0;
|
|
|
199 |
c.fill = GridBagConstraints.BOTH;
|
142 |
ilm |
200 |
c.weightx = 1;
|
|
|
201 |
c.weighty = 1;
|
18 |
ilm |
202 |
this.add(panelInfos, c);
|
142 |
ilm |
203 |
c.weightx = 0;
|
|
|
204 |
c.weighty = 0;
|
18 |
ilm |
205 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
206 |
|
|
|
207 |
/***********************************************************************************
|
|
|
208 |
* Comptabilité
|
|
|
209 |
**********************************************************************************/
|
|
|
210 |
|
132 |
ilm |
211 |
JPanel panelCompta = new JPanel();
|
|
|
212 |
panelCompta.setBorder(BorderFactory.createTitledBorder("Comptabilité"));
|
|
|
213 |
panelCompta.setLayout(new GridBagLayout());
|
|
|
214 |
// Compte tiers
|
|
|
215 |
JLabel labelTiers = new JLabel(getLabelFor("NUMERO_COMPTE_PCE"));
|
|
|
216 |
// JFormattedTextField fieldCompte = new JFormattedTextField();
|
|
|
217 |
// fieldCompte.set
|
|
|
218 |
//
|
|
|
219 |
// MaskFormatter mask;
|
|
|
220 |
// try {
|
|
|
221 |
// mask = new MaskFormatter("AAAAAAAAAAAAAA");
|
|
|
222 |
// mask.setValidCharacters("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
|
|
|
223 |
// mask.s
|
|
|
224 |
// mask.install(this);
|
|
|
225 |
// } catch (ParseException exn) {
|
|
|
226 |
// exn.printStackTrace();
|
|
|
227 |
// }
|
|
|
228 |
JTextField fieldCompte = new JTextField();
|
|
|
229 |
this.addView(fieldCompte, "NUMERO_COMPTE_PCE");
|
|
|
230 |
panelCompta.add(labelTiers, c);
|
|
|
231 |
c.gridx++;
|
|
|
232 |
c.weightx = 1;
|
|
|
233 |
panelCompta.add(fieldCompte, c);
|
|
|
234 |
c.weightx = 0;
|
|
|
235 |
// Compte charge
|
|
|
236 |
JLabel labelCharge = new JLabel(getLabelFor("NUMERO_COMPTE_PCE_CHARGES"));
|
|
|
237 |
c.gridy++;
|
|
|
238 |
c.gridx = 0;
|
|
|
239 |
panelCompta.add(labelCharge, c);
|
|
|
240 |
c.gridx++;
|
|
|
241 |
c.weightx = 1;
|
|
|
242 |
JTextField fieldCompteCharge = new JTextField();
|
|
|
243 |
panelCompta.add(fieldCompteCharge, c);
|
|
|
244 |
this.addView(fieldCompteCharge, "NUMERO_COMPTE_PCE_CHARGES");
|
|
|
245 |
c.weightx = 0;
|
|
|
246 |
|
|
|
247 |
c.gridx = 0;
|
|
|
248 |
c.gridy = 1;
|
|
|
249 |
c.fill = GridBagConstraints.BOTH;
|
142 |
ilm |
250 |
c.weightx = 1;
|
|
|
251 |
c.weighty = 1;
|
132 |
ilm |
252 |
this.add(panelCompta, c);
|
142 |
ilm |
253 |
c.weightx = 0;
|
|
|
254 |
c.weighty = 0;
|
132 |
ilm |
255 |
|
18 |
ilm |
256 |
this.addSQLObject(textNom, "NOM");
|
|
|
257 |
this.addSQLObject(textTel, "TEL");
|
|
|
258 |
this.addSQLObject(textTelP, "TEL_PORTABLE");
|
|
|
259 |
// this.addSQLObject(selCompteTiers, "ID_COMPTE_PCE_TIERS");
|
|
|
260 |
// this.addSQLObject(selCompteCharge, "ID_COMPTE_PCE_CHARGE");
|
|
|
261 |
// selCompteTiers.init();
|
|
|
262 |
// selCompteCharge.init();
|
142 |
ilm |
263 |
TitledSeparator sepRenseignement = new TitledSeparator("Renseignement Organisme de protection social (S21.G00.20)");
|
|
|
264 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
265 |
c.gridy++;
|
|
|
266 |
c.gridx = 0;
|
|
|
267 |
c.weightx = 1;
|
|
|
268 |
this.add(sepRenseignement, c);
|
|
|
269 |
this.table = new CaisseCotisationRenseignementTable();
|
|
|
270 |
this.table.setEnabled(true);
|
|
|
271 |
c.gridy++;
|
|
|
272 |
c.weighty = 1;
|
|
|
273 |
this.add(this.table, c);
|
|
|
274 |
|
18 |
ilm |
275 |
}
|
142 |
ilm |
276 |
|
|
|
277 |
@Override
|
|
|
278 |
public void select(SQLRowAccessor r) {
|
|
|
279 |
super.select(r);
|
|
|
280 |
if (r != null) {
|
|
|
281 |
this.table.getModel().insertFrom(r);
|
|
|
282 |
} else {
|
|
|
283 |
this.table.getModel().clearRows();
|
|
|
284 |
}
|
|
|
285 |
}
|
|
|
286 |
|
|
|
287 |
@Override
|
|
|
288 |
public void update() {
|
|
|
289 |
|
|
|
290 |
super.update();
|
|
|
291 |
this.table.getModel().updateField("ID_CAISSE_COTISATION", getSelectedID());
|
182 |
ilm |
292 |
|
142 |
ilm |
293 |
}
|
|
|
294 |
|
|
|
295 |
@Override
|
|
|
296 |
public int insert(SQLRow order) {
|
|
|
297 |
final int insertID = super.insert(order);
|
|
|
298 |
this.table.getModel().updateField("ID_CAISSE_COTISATION", insertID);
|
|
|
299 |
return insertID;
|
|
|
300 |
}
|
18 |
ilm |
301 |
};
|
|
|
302 |
}
|
|
|
303 |
}
|