OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
18 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.erp.core.humanresources.employe.element;
15
 
16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
17
import org.openconcerto.sql.element.BaseSQLComponent;
18
import org.openconcerto.sql.element.ElementSQLObject;
19
import org.openconcerto.sql.element.SQLComponent;
20
import org.openconcerto.sql.model.SQLRowValues;
73 ilm 21
import org.openconcerto.sql.model.SQLTable;
18 ilm 22
import org.openconcerto.sql.sqlobject.ElementComboBox;
23
import org.openconcerto.ui.DefaultGridBagConstraints;
24
import org.openconcerto.ui.JDate;
25
 
26
import java.awt.GridBagConstraints;
27
import java.awt.GridBagLayout;
28
import java.util.ArrayList;
29
import java.util.List;
30
 
31
import javax.swing.BorderFactory;
32
import javax.swing.JLabel;
33
import javax.swing.JPanel;
34
import javax.swing.JTextField;
35
import javax.swing.SwingConstants;
36
 
37
public class EtatCivilSQLElement extends ComptaSQLConfElement {
38
 
39
    public EtatCivilSQLElement() {
40
        super("ETAT_CIVIL", "un état civil", "états civils");
41
    }
42
 
43
    // MAYBE un champ nationnalité???
44
 
45
    protected List<String> getListFields() {
46
        final List<String> l = new ArrayList<String>();
47
        l.add("DATE_NAISSANCE");
48
        l.add("NB_ENFANTS");
49
        return l;
50
    }
51
 
52
    protected List<String> getComboFields() {
53
        final List<String> l = new ArrayList<String>();
54
        l.add("DATE_NAISSANCE");
55
        l.add("NB_ENFANTS");
56
        return l;
57
    }
58
 
132 ilm 59
    @Override
60
    public boolean isPrivate() {
61
        return true;
18 ilm 62
    }
144 ilm 63
 
18 ilm 64
    /*
65
     * (non-Javadoc)
66
     *
67
     * @see org.openconcerto.devis.SQLElement#getComponent()
68
     */
69
    public SQLComponent createComponent() {
70
        return new BaseSQLComponent(this) {
71
 
72
            JDate dateNaissance;
73
            JTextField numeroSS, numeroTel, mail, portable;
74
            JTextField nbEnfants, lieuNaissance, nombrePersonne;
75
            ElementComboBox comboSituationFam;
76
            ElementComboBox comboPays, comboDepartement;
77
 
78
            public void addViews() {
79
                this.setLayout(new GridBagLayout());
80
                final GridBagConstraints c = new DefaultGridBagConstraints();
81
 
82
                /***********************************************************************************
83
                 * PANEL ADRESSE
84
                 **********************************************************************************/
85
                JPanel panelInfos = new JPanel();
86
                panelInfos.setOpaque(false);
87
                panelInfos.setBorder(BorderFactory.createTitledBorder(getLabelFor("ID_ADRESSE")));
88
                panelInfos.setLayout(new GridBagLayout());
89
 
90
                this.addView("ID_ADRESSE", REQ + ";" + DEC + ";" + SEP);
91
                ElementSQLObject eltModeRegl = (ElementSQLObject) this.getView("ID_ADRESSE");
92
                panelInfos.add(eltModeRegl, c);
93
 
94
                // c.fill = GridBagConstraints.BOTH;
95
                c.anchor = GridBagConstraints.NORTHWEST;
96
                this.add(panelInfos, c);
97
                c.anchor = GridBagConstraints.WEST;
98
                // c.fill = GridBagConstraints.HORIZONTAL;
99
 
100
                /***********************************************************************************
101
                 * PANEL CONTACT
102
                 **********************************************************************************/
103
                JPanel panelContact = new JPanel();
104
                panelContact.setOpaque(false);
105
                panelContact.setBorder(BorderFactory.createTitledBorder("Contact"));
106
                panelContact.setLayout(new GridBagLayout());
107
 
108
                // Téléphone
109
                c.fill = GridBagConstraints.NONE;
110
                this.numeroTel = new JTextField(12);
111
                JLabel labelNumeroTel = new JLabel(getLabelFor("TELEPHONE"));
112
                labelNumeroTel.setHorizontalAlignment(SwingConstants.RIGHT);
113
                panelContact.add(labelNumeroTel, c);
114
                c.gridx++;
115
                c.weightx = 1;
116
                panelContact.add(this.numeroTel, c);
117
 
118
                // portable
119
                c.gridwidth = 1;
120
                c.gridx = 0;
121
                c.weightx = 0;
122
                c.gridy++;
123
 
124
                this.portable = new JTextField(12);
125
                JLabel labelNumeroPort = new JLabel(getLabelFor("PORTABLE"));
126
                labelNumeroPort.setHorizontalAlignment(SwingConstants.RIGHT);
127
                panelContact.add(labelNumeroPort, c);
128
                c.gridx++;
129
                c.weightx = 1;
130
                panelContact.add(this.portable, c);
131
                c.fill = GridBagConstraints.HORIZONTAL;
132
 
133
                // mail
134
                c.gridwidth = 1;
135
                c.gridx = 0;
136
                c.gridy++;
137
                c.weightx = 0;
138
 
139
                this.mail = new JTextField();
140
                JLabel labelMail = new JLabel(getLabelFor("MAIL"));
141
                labelMail.setHorizontalAlignment(SwingConstants.RIGHT);
142
                panelContact.add(labelMail, c);
143
                c.gridx++;
144
                c.weightx = 1;
145
                c.weighty = 1;
146
                panelContact.add(this.mail, c);
147
 
148
                c.gridx = 1;
149
                c.gridy = 0;
150
 
151
                c.anchor = GridBagConstraints.NORTHWEST;
152
                c.weighty = 0;
153
                this.add(panelContact, c);
154
                c.anchor = GridBagConstraints.WEST;
155
 
156
                /***********************************************************************************
157
                 * PANEL NAISSANCE
158
                 **********************************************************************************/
159
                JPanel panelNaissance = new JPanel();
160
                panelNaissance.setOpaque(false);
161
                panelNaissance.setBorder(BorderFactory.createTitledBorder("Date et lieu de naissance"));
162
                panelNaissance.setLayout(new GridBagLayout());
163
 
164
                // Date de naissance
165
                c.gridwidth = 1;
166
                c.gridx = 0;
167
                c.gridy = 0;
168
                JLabel labelDateNaissance = new JLabel(getLabelFor("DATE_NAISSANCE"));
169
                labelDateNaissance.setHorizontalAlignment(SwingConstants.RIGHT);
170
                this.dateNaissance = new JDate();
171
                panelNaissance.add(labelDateNaissance, c);
172
                c.gridx++;
173
                panelNaissance.add(this.dateNaissance, c);
174
 
175
                // Commune de naissance
176
                JLabel labelLieuNaissance = new JLabel(getLabelFor("COMMUNE_NAISSANCE"));
177
                labelLieuNaissance.setHorizontalAlignment(SwingConstants.RIGHT);
178
                this.lieuNaissance = new JTextField();
179
                c.gridx++;
180
                panelNaissance.add(labelLieuNaissance, c);
181
                c.gridx++;
182
                c.weightx = 1;
183
                panelNaissance.add(this.lieuNaissance, c);
184
 
185
                // Departement de naissance
186
                c.weightx = 0;
187
                JLabel labelDptNaissance = new JLabel(getLabelFor("ID_DEPARTEMENT_NAISSANCE"));
188
                labelDptNaissance.setHorizontalAlignment(SwingConstants.RIGHT);
189
                this.comboDepartement = new ElementComboBox(false, 20);
190
 
191
                c.gridx = 0;
192
                c.gridy++;
193
                panelNaissance.add(labelDptNaissance, c);
194
                c.gridx++;
195
                c.gridwidth = 1;
196
                c.weightx = 1;
197
                panelNaissance.add(this.comboDepartement, c);
198
                c.gridwidth = 1;
199
 
200
                // Pays de naissance
201
                JLabel labelPaysNaissance = new JLabel(getLabelFor("ID_PAYS_NAISSANCE"));
202
                labelPaysNaissance.setHorizontalAlignment(SwingConstants.RIGHT);
203
                this.comboPays = new ElementComboBox(false, 20);
204
                c.gridx++;
205
                c.weightx = 0;
206
                panelNaissance.add(labelPaysNaissance, c);
207
                c.gridx++;
144 ilm 208
                c.gridwidth = 1;
18 ilm 209
                c.weightx = 1;
210
                c.weighty = 1;
211
                panelNaissance.add(this.comboPays, c);
212
                c.gridwidth = 1;
213
 
144 ilm 214
                // Nationnalite
215
                c.weightx = 0;
216
                JLabel labelNationnalite = new JLabel(getLabelFor("NATIONNALITE"));
217
                labelNationnalite.setHorizontalAlignment(SwingConstants.RIGHT);
218
                c.gridy++;
18 ilm 219
                c.gridx = 0;
144 ilm 220
                panelNaissance.add(labelNationnalite, c);
221
                c.gridx++;
222
                c.gridwidth = 1;
223
                c.weightx = 1;
224
                JTextField fieldNation = new JTextField();
225
                panelNaissance.add(fieldNation, c);
226
                addView(fieldNation, "NATIONNALITE");
227
                c.gridwidth = 1;
228
 
229
                c.gridx = 0;
18 ilm 230
                c.weighty = 0;
231
                c.gridy = 1;
232
                c.weightx = 0;
233
                c.gridwidth = GridBagConstraints.REMAINDER;
234
                c.anchor = GridBagConstraints.NORTHWEST;
235
                this.add(panelNaissance, c);
144 ilm 236
 
18 ilm 237
                c.anchor = GridBagConstraints.WEST;
238
                c.gridwidth = 1;
239
 
240
                /***********************************************************************************
241
                 * SITUATION
242
                 **********************************************************************************/
243
                JPanel panelSituation = new JPanel();
244
                panelSituation.setOpaque(false);
245
                panelSituation.setBorder(BorderFactory.createTitledBorder("Situation personnelle"));
246
                panelSituation.setLayout(new GridBagLayout());
247
                // Numero SS
248
                c.gridy = 0;
249
                c.gridx = 0;
250
                this.numeroSS = new JTextField();
251
                JLabel labelNumeroSS = new JLabel(getLabelFor("NUMERO_SS"));
252
                labelNumeroSS.setHorizontalAlignment(SwingConstants.RIGHT);
253
                panelSituation.add(labelNumeroSS, c);
254
                c.gridx++;
144 ilm 255
                c.gridwidth = 1;
18 ilm 256
                c.weightx = 1;
257
                panelSituation.add(this.numeroSS, c);
144 ilm 258
 
18 ilm 259
                c.weightx = 0;
260
                c.gridwidth = 1;
144 ilm 261
                c.gridx++;
262
                panelSituation.add(new JLabel("CNPS", SwingConstants.RIGHT), c);
263
                c.gridx++;
264
                c.gridwidth = 1;
265
                c.weightx = 1;
266
                JTextField fieldCNPS = new JTextField();
267
                panelSituation.add(fieldCNPS, c);
268
                c.weightx = 0;
269
                c.gridwidth = 1;
270
                addView(fieldCNPS, "CNPS");
18 ilm 271
 
272
                // Situation familiale
273
                JLabel labelSitutationFamiliale = new JLabel(getLabelFor("ID_SITUATION_FAMILIALE"));
274
                labelSitutationFamiliale.setHorizontalAlignment(SwingConstants.RIGHT);
275
 
276
                this.comboSituationFam = new ElementComboBox(false);
277
 
278
                c.gridx = 0;
279
                c.gridy++;
280
                panelSituation.add(labelSitutationFamiliale, c);
281
                c.gridx++;
144 ilm 282
                c.gridwidth = 1;
18 ilm 283
                c.weightx = 1;
284
                panelSituation.add(this.comboSituationFam, c);
285
                c.gridwidth = 1;
286
                c.weightx = 0;
287
 
156 ilm 288
                c.weightx = 0;
289
                c.gridwidth = 1;
290
                c.gridx++;
291
                panelSituation.add(new JLabel(getLabelFor("NTT"), SwingConstants.RIGHT), c);
292
                c.gridx++;
293
                c.gridwidth = 1;
294
                c.weightx = 1;
295
                JTextField fieldNTT = new JTextField();
174 ilm 296
                panelSituation.add(fieldNTT, c);
156 ilm 297
                c.weightx = 0;
298
                c.gridwidth = 1;
299
                addView(fieldNTT, "NTT");
300
 
18 ilm 301
                // Nombre d'enfants
302
                JLabel labelNombreEnfants = new JLabel(getLabelFor("NB_ENFANTS"));
303
                labelNombreEnfants.setHorizontalAlignment(SwingConstants.RIGHT);
304
                this.nbEnfants = new JTextField();
305
                c.gridx = 0;
306
                c.gridy++;
307
                panelSituation.add(labelNombreEnfants, c);
308
                c.gridx++;
309
                c.weightx = 1;
310
                panelSituation.add(this.nbEnfants, c);
311
                c.weightx = 0;
312
 
313
                // Nombre de personnes à charge
314
                JLabel labelNombrePersonne = new JLabel(getLabelFor("NB_PERS_A_CHARGE"));
315
                labelNombrePersonne.setHorizontalAlignment(SwingConstants.RIGHT);
316
                this.nombrePersonne = new JTextField(3);
317
                c.gridx++;
318
                panelSituation.add(labelNombrePersonne, c);
319
                c.gridx++;
320
                c.weightx = 1;
321
                c.weighty = 1;
322
                panelSituation.add(this.nombrePersonne, c);
323
                c.weightx = 1;
324
                c.weighty = 0;
325
 
326
                c.gridx = 0;
327
                c.gridy = 2;
328
                c.anchor = GridBagConstraints.NORTHWEST;
329
                c.gridwidth = GridBagConstraints.REMAINDER;
144 ilm 330
                c.weighty = 0;
18 ilm 331
                this.add(panelSituation, c);
144 ilm 332
 
333
                /***********************************************************************************
334
                 * PIECE IDENTITE
335
                 **********************************************************************************/
336
                JPanel panelIdentite = new JPanel();
337
                panelIdentite.setOpaque(false);
338
                panelIdentite.setBorder(BorderFactory.createTitledBorder("Pièce d'identité"));
339
                panelIdentite.setLayout(new GridBagLayout());
340
                // TYPE_PIECE_IDENTITE
341
                c.gridy = 0;
342
                c.gridx = 0;
18 ilm 343
                c.gridwidth = 1;
144 ilm 344
                JTextField fieldTypePiece = new JTextField();
345
                JLabel typePieceLabel = new JLabel(getLabelFor("TYPE_PIECE_IDENTITE"));
346
                typePieceLabel.setHorizontalAlignment(SwingConstants.RIGHT);
347
                panelIdentite.add(typePieceLabel, c);
348
                c.gridx++;
349
                c.gridwidth = 1;
350
                c.weightx = 1;
351
                panelIdentite.add(fieldTypePiece, c);
352
                addView(fieldTypePiece, "TYPE_PIECE_IDENTITE");
18 ilm 353
 
144 ilm 354
                c.weightx = 0;
355
                c.gridwidth = 1;
356
                c.gridx++;
357
 
358
                panelIdentite.add(new JLabel(getLabelFor("NUMERO_PIECE")), c);
359
                c.gridx++;
360
                c.gridwidth = 1;
361
                c.weightx = 1;
362
                JTextField fieldNumeroPiece = new JTextField();
363
                panelIdentite.add(fieldNumeroPiece, c);
364
                c.weightx = 0;
365
                c.gridwidth = 1;
366
                addView(fieldNumeroPiece, "NUMERO_PIECE");
367
 
368
                // Date debut
369
                JLabel labelDateDebut = new JLabel(getLabelFor("DATE_DEBUT_PIECE"));
370
                labelDateDebut.setHorizontalAlignment(SwingConstants.RIGHT);
371
                c.gridx = 0;
372
                c.gridy++;
373
                panelIdentite.add(labelDateDebut, c);
374
                c.gridx++;
375
                c.gridwidth = 1;
376
                c.weightx = 1;
377
                JDate fieldDateDebut = new JDate();
378
                panelIdentite.add(fieldDateDebut, c);
379
                addView(fieldDateDebut, "DATE_DEBUT_PIECE");
380
                c.gridwidth = 1;
381
                c.weightx = 0;
382
 
383
                // Nombre d'enfants
384
                JLabel labelDateFin = new JLabel(getLabelFor("DATE_FIN_PIECE"));
385
                labelDateFin.setHorizontalAlignment(SwingConstants.RIGHT);
386
                JDate fieldDateFin = new JDate();
387
                c.gridx++;
388
                panelIdentite.add(labelDateFin, c);
389
                c.gridx++;
390
                c.weightx = 1;
391
                panelIdentite.add(fieldDateFin, c);
392
                addView(fieldDateFin, "DATE_FIN_PIECE");
393
                c.weightx = 0;
394
 
395
                c.gridx = 0;
396
                c.gridy = 3;
397
                c.anchor = GridBagConstraints.NORTHWEST;
398
                c.gridwidth = GridBagConstraints.REMAINDER;
399
                c.weighty = 0;
400
                this.add(panelIdentite, c);
401
 
402
                /***********************************************************************************
403
                 * FAMILLE
404
                 **********************************************************************************/
405
                JPanel panelFamille = new JPanel();
406
                panelFamille.setOpaque(false);
407
                panelFamille.setBorder(BorderFactory.createTitledBorder("Famille"));
408
                panelFamille.setLayout(new GridBagLayout());
409
                // TYPE_PIECE_IDENTITE
410
                c.gridy = 0;
411
                c.gridx = 0;
412
                c.gridwidth = 1;
413
                JTextField fieldPere = new JTextField();
414
                JLabel pereLabel = new JLabel(getLabelFor("NOM_PERE"));
415
                pereLabel.setHorizontalAlignment(SwingConstants.RIGHT);
416
                panelFamille.add(pereLabel, c);
417
                c.gridx++;
418
                c.gridwidth = 1;
419
                c.weightx = 1;
420
                panelFamille.add(fieldPere, c);
421
                addView(fieldPere, "NOM_PERE");
422
 
423
                c.weightx = 0;
424
                c.gridwidth = 1;
425
                c.gridx++;
426
                panelFamille.add(new JLabel(getLabelFor("NOM_MERE")), c);
427
                c.gridx++;
428
                c.gridwidth = 1;
429
                c.weightx = 1;
430
                JTextField fieldNomMere = new JTextField();
431
                panelFamille.add(fieldNomMere, c);
432
                c.weightx = 0;
433
                c.gridwidth = 1;
434
                addView(fieldNomMere, "NOM_MERE");
435
 
436
                // Nom
437
                JLabel labelConjointNom = new JLabel(getLabelFor("CONJOINT_NOM"));
438
                labelConjointNom.setHorizontalAlignment(SwingConstants.RIGHT);
439
                c.gridx = 0;
440
                c.gridy++;
441
                panelFamille.add(labelConjointNom, c);
442
                c.gridx++;
443
                c.gridwidth = 1;
444
                c.weightx = 1;
445
                JTextField fieldConjointNom = new JTextField();
446
                panelFamille.add(fieldConjointNom, c);
447
                addView(fieldConjointNom, "CONJOINT_NOM");
448
                c.gridwidth = 1;
449
                c.weightx = 0;
450
 
451
                c.weightx = 0;
452
                c.gridwidth = 1;
453
                c.gridx++;
454
                panelFamille.add(new JLabel(getLabelFor("CONJOINT_PROFESSION")), c);
455
                c.gridx++;
456
                c.gridwidth = 1;
457
                c.weightx = 1;
458
                JTextField fieldProfession = new JTextField();
459
                panelFamille.add(fieldProfession, c);
460
                c.weightx = 0;
461
                c.gridwidth = 1;
462
                addView(fieldProfession, "CONJOINT_PROFESSION");
463
 
464
                // Nombre d'enfants
465
                JLabel labelDateNaissanceConjoint = new JLabel(getLabelFor("CONJOINT_DATE_NAISSANCE"));
466
                labelDateNaissanceConjoint.setHorizontalAlignment(SwingConstants.RIGHT);
467
                JDate fieldDateNaissanceConjoint = new JDate();
468
                c.gridx = 0;
469
                c.gridy++;
470
                panelFamille.add(labelDateNaissanceConjoint, c);
471
                c.gridx++;
472
                c.weightx = 1;
473
                panelFamille.add(fieldDateNaissanceConjoint, c);
474
                addView(fieldDateNaissanceConjoint, "CONJOINT_DATE_NAISSANCE");
475
                c.weightx = 0;
476
 
477
                c.weightx = 0;
478
                c.gridwidth = 1;
479
                c.gridx++;
480
                panelFamille.add(new JLabel(getLabelFor("CONJOINT_LIEU_NAISSANCE")), c);
481
                c.gridx++;
482
                c.gridwidth = 1;
483
                c.weightx = 1;
484
                JTextField fieldLieuNaissanceConjoint = new JTextField();
485
                panelFamille.add(fieldLieuNaissanceConjoint, c);
486
                c.weightx = 0;
487
                c.gridwidth = 1;
488
                addView(fieldLieuNaissanceConjoint, "CONJOINT_LIEU_NAISSANCE");
489
 
490
                c.gridx = 0;
491
                c.gridy = 4;
492
                c.anchor = GridBagConstraints.NORTHWEST;
493
                c.gridwidth = GridBagConstraints.REMAINDER;
494
                c.weighty = 1;
495
                this.add(panelFamille, c);
496
 
18 ilm 497
                this.addRequiredSQLObject(this.dateNaissance, "DATE_NAISSANCE");
498
                this.addSQLObject(this.lieuNaissance, "COMMUNE_NAISSANCE");
499
                this.addSQLObject(this.nbEnfants, "NB_ENFANTS");
500
                this.addSQLObject(this.nombrePersonne, "NB_PERS_A_CHARGE");
501
                this.addRequiredSQLObject(this.numeroSS, "NUMERO_SS");
502
                this.addSQLObject(this.comboPays, "ID_PAYS_NAISSANCE");
503
                this.addSQLObject(this.comboDepartement, "ID_DEPARTEMENT_NAISSANCE");
504
                this.addRequiredSQLObject(this.comboSituationFam, "ID_SITUATION_FAMILIALE");
505
                this.addSQLObject(this.numeroTel, "TELEPHONE");
506
                this.addSQLObject(this.portable, "PORTABLE");
507
                this.addSQLObject(this.mail, "MAIL");
508
                this.comboPays.setButtonsVisible(false);
509
                this.comboDepartement.setButtonsVisible(false);
510
                this.comboSituationFam.setButtonsVisible(false);
511
            }
512
 
513
            protected SQLRowValues createDefaults() {
73 ilm 514
                final SQLTable table = getTable();
515
                final SQLRowValues vals = new SQLRowValues(table);
516
                getElement().loadAllSafe(vals, table.getRow(table.getUndefinedID()));
18 ilm 517
                return vals;
518
            }
519
        };
520
 
521
    }
57 ilm 522
 
523
    @Override
524
    protected String createCode() {
156 ilm 525
        return this.createCodeOfPackage() + ".info";
57 ilm 526
    }
18 ilm 527
}