OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 174 | 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.payroll.element;
15
 
16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
17
import org.openconcerto.sql.element.BaseSQLComponent;
18
import org.openconcerto.sql.element.SQLComponent;
19
import org.openconcerto.sql.sqlobject.ElementComboBox;
20
import org.openconcerto.ui.DefaultGridBagConstraints;
132 ilm 21
import org.openconcerto.ui.JDate;
18 ilm 22
 
23
import java.awt.GridBagConstraints;
24
import java.awt.GridBagLayout;
177 ilm 25
import java.beans.PropertyChangeEvent;
26
import java.beans.PropertyChangeListener;
18 ilm 27
import java.util.ArrayList;
132 ilm 28
import java.util.Arrays;
142 ilm 29
import java.util.HashSet;
18 ilm 30
import java.util.List;
142 ilm 31
import java.util.Set;
18 ilm 32
 
33
import javax.swing.JLabel;
34
import javax.swing.JTextField;
35
import javax.swing.SwingConstants;
36
 
37
public class ContratSalarieSQLElement extends ComptaSQLConfElement {
38
 
39
    public ContratSalarieSQLElement() {
40
        super("CONTRAT_SALARIE", "un contrat salarié", "contrats salariés");
41
    }
42
 
43
    protected List<String> getListFields() {
44
        final List<String> l = new ArrayList<String>();
45
        l.add("NATURE");
46
        return l;
47
    }
48
 
142 ilm 49
    @Override
50
    public Set<String> getInsertOnlyFields() {
51
        Set<String> s = new HashSet<String>();
52
        s.add("DATE_MODIFICATION");
53
        return s;
54
    }
55
 
18 ilm 56
    protected List<String> getComboFields() {
57
        final List<String> l = new ArrayList<String>();
142 ilm 58
        l.add("NUMERO");
59
        l.add("DATE_DEBUT");
18 ilm 60
        return l;
61
    }
62
 
132 ilm 63
    @Override
64
    public boolean isPrivate() {
65
        return true;
66
    }
67
 
18 ilm 68
    /*
69
     * (non-Javadoc)
70
     *
71
     * @see org.openconcerto.devis.SQLElement#getComponent()
72
     */
73
    public SQLComponent createComponent() {
74
        return new BaseSQLComponent(this) {
75
 
76
            public void addViews() {
77
 
78
                this.setLayout(new GridBagLayout());
142 ilm 79
 
18 ilm 80
                GridBagConstraints c = new DefaultGridBagConstraints();
81
 
142 ilm 82
                // Numero
83
                JLabel labelNumero = new JLabel(getLabelFor("NUMERO"));
84
                labelNumero.setHorizontalAlignment(SwingConstants.RIGHT);
85
                JTextField textNumero = new JTextField();
86
 
87
                this.add(labelNumero, c);
88
                c.gridx++;
89
                c.weightx = 1;
90
                this.add(textNumero, c);
91
                this.addRequiredSQLObject(textNumero, "NUMERO");
92
 
93
                c.gridy++;
94
                c.gridx = 0;
18 ilm 95
                // Nature
96
                JLabel labelNature = new JLabel(getLabelFor("NATURE"));
97
                labelNature.setHorizontalAlignment(SwingConstants.RIGHT);
98
                JTextField textNature = new JTextField();
99
 
100
                this.add(labelNature, c);
101
                c.gridx++;
102
                c.weightx = 1;
177 ilm 103
                c.gridwidth = 3;
18 ilm 104
                this.add(textNature, c);
105
 
177 ilm 106
                c.gridwidth = 1;
18 ilm 107
                // Catégorie socioprofessionnelle
108
                JLabel labelCatSocio = new JLabel(getLabelFor("ID_CODE_EMPLOI"));
109
                labelCatSocio.setHorizontalAlignment(SwingConstants.RIGHT);
110
                ElementComboBox selCodeCatSocio = new ElementComboBox();
111
                selCodeCatSocio.setInfoIconVisible(false);
112
                c.gridy++;
113
                c.gridx = 0;
114
                c.weightx = 0;
115
                this.add(labelCatSocio, c);
116
                c.gridx++;
117
                c.weightx = 1;
118
                this.add(selCodeCatSocio, c);
177 ilm 119
 
174 ilm 120
                JLabel complPCSLabel = new JLabel(getLabelFor("COMPLEMENT_PCS"));
121
                complPCSLabel.setHorizontalAlignment(SwingConstants.RIGHT);
122
                JTextField complPCS = new JTextField();
177 ilm 123
                c.gridx++;
174 ilm 124
                c.weightx = 0;
125
                this.add(complPCSLabel, c);
126
                c.gridx++;
127
                c.weightx = 1;
128
                this.add(complPCS, c);
177 ilm 129
                addView(complPCS, "COMPLEMENT_PCS");
18 ilm 130
 
177 ilm 131
                JLabel objetSpecLabel = new JLabel(getLabelFor("SPECTACLE_OBJET"));
132
                objetSpecLabel.setHorizontalAlignment(SwingConstants.RIGHT);
133
                JTextField objetSpec = new JTextField();
134
                c.gridy++;
135
                c.gridx = 0;
136
                c.weightx = 0;
137
                this.add(objetSpecLabel, c);
138
                c.gridx++;
139
                c.weightx = 1;
140
                this.add(objetSpec, c);
141
                addView(objetSpec, "SPECTACLE_OBJET");
142
                objetSpec.setEditable(false);
143
 
144
                JLabel jourContratLabel = new JLabel(getLabelFor("SPECTACLE_JOUR_CONTRAT"));
145
                jourContratLabel.setHorizontalAlignment(SwingConstants.RIGHT);
146
                JTextField jourContrat = new JTextField();
147
                c.gridx++;
148
                c.weightx = 0;
149
                this.add(jourContratLabel, c);
150
                c.gridx++;
151
                c.weightx = 1;
152
                this.add(jourContrat, c);
153
                addView(jourContrat, "SPECTACLE_JOUR_CONTRAT");
154
                jourContrat.setEditable(false);
155
 
156
                final ElementComboBox selCaractActivite = new ElementComboBox();
157
                selCaractActivite.setInfoIconVisible(false);
158
                this.addRequiredSQLObject(selCaractActivite, "ID_CODE_CARACT_ACTIVITE");
159
                selCaractActivite.addModelListener("wantedID", new PropertyChangeListener() {
160
 
161
                    @Override
162
                    public void propertyChange(PropertyChangeEvent evt) {
163
                        final boolean b = selCaractActivite.getSelectedRow() != null && selCaractActivite.getSelectedRow().getString("CODE").equals("04");
164
                        objetSpec.setEditable(b);
165
                        jourContrat.setEditable(b);
166
                        if (!b) {
167
                            objetSpec.setText("");
168
                            ;
169
                            jourContrat.setText("");
170
                        }
171
                    }
172
                });
173
 
18 ilm 174
                // Contrat de travail
175
                JLabel labelContratTravail = new JLabel(getLabelFor("ID_CODE_CONTRAT_TRAVAIL"));
176
                labelContratTravail.setHorizontalAlignment(SwingConstants.RIGHT);
177
                ElementComboBox selContratTravail = new ElementComboBox();
178
                selContratTravail.setInfoIconVisible(false);
179
                c.gridy++;
180
                c.gridx = 0;
181
                c.weightx = 0;
182
                this.add(labelContratTravail, c);
183
                c.gridx++;
184
                c.weightx = 1;
185
                this.add(selContratTravail, c);
186
 
187
                // Droit Contrat de travail
188
                JLabel labelDroitContrat = new JLabel(getLabelFor("ID_CODE_DROIT_CONTRAT"));
189
                labelDroitContrat.setHorizontalAlignment(SwingConstants.RIGHT);
190
                ElementComboBox selDroitContrat = new ElementComboBox();
191
                selDroitContrat.setInfoIconVisible(false);
177 ilm 192
                c.gridx++;
18 ilm 193
                c.weightx = 0;
194
                this.add(labelDroitContrat, c);
195
                c.gridx++;
196
                c.weightx = 1;
197
                this.add(selDroitContrat, c);
198
 
199
                // caracteristiques activité
200
                JLabel labelCaractActivite = new JLabel(getLabelFor("ID_CODE_CARACT_ACTIVITE"));
201
                labelCaractActivite.setHorizontalAlignment(SwingConstants.RIGHT);
177 ilm 202
 
18 ilm 203
                c.gridy++;
204
                c.gridx = 0;
205
                c.weightx = 0;
206
                this.add(labelCaractActivite, c);
207
                c.gridx++;
208
                c.weightx = 1;
209
                this.add(selCaractActivite, c);
210
 
211
                // Statut profesionnel
212
                JLabel labelStatutProf = new JLabel(getLabelFor("ID_CODE_STATUT_PROF"));
213
                labelStatutProf.setHorizontalAlignment(SwingConstants.RIGHT);
214
                ElementComboBox selStatutProf = new ElementComboBox();
215
                selStatutProf.setInfoIconVisible(false);
177 ilm 216
                c.gridx++;
18 ilm 217
                c.weightx = 0;
218
                this.add(labelStatutProf, c);
219
                c.gridx++;
220
                c.weightx = 1;
221
                this.add(selStatutProf, c);
222
 
223
                // Statut categoriel
224
                JLabel labelStatutCat = new JLabel(getLabelFor("ID_CODE_STATUT_CATEGORIEL"));
225
                labelStatutCat.setHorizontalAlignment(SwingConstants.RIGHT);
226
                ElementComboBox selStatutCat = new ElementComboBox();
227
                selStatutCat.setInfoIconVisible(false);
228
                c.gridy++;
229
                c.gridx = 0;
230
                c.weightx = 0;
231
                this.add(labelStatutCat, c);
232
                c.gridx++;
233
                c.weightx = 1;
234
                this.add(selStatutCat, c);
235
 
41 ilm 236
                // Statut categoriel
237
                JLabel labelStatutCatConv = new JLabel(getLabelFor("ID_CODE_STATUT_CAT_CONV"));
238
                labelStatutCatConv.setHorizontalAlignment(SwingConstants.RIGHT);
239
                ElementComboBox selStatutCatConv = new ElementComboBox();
240
                selStatutCatConv.setInfoIconVisible(false);
177 ilm 241
                c.gridx++;
41 ilm 242
                c.weightx = 0;
243
                this.add(labelStatutCatConv, c);
244
                c.gridx++;
245
                c.weightx = 1;
246
                this.add(selStatutCatConv, c);
247
 
132 ilm 248
                List<String> dsnFF = Arrays.asList("ID_CONTRAT_MODALITE_TEMPS", "ID_CONTRAT_REGIME_MALADIE", "ID_CONTRAT_REGIME_VIEILLESSE", "ID_CONTRAT_DETACHE_EXPATRIE",
177 ilm 249
                        "ID_CONTRAT_DISPOSITIF_POLITIQUE", "ID_CONTRAT_MOTIF_RECOURS");
250
                int p = 0;
132 ilm 251
                for (String ffName : dsnFF) {
252
                    JLabel labelFF = new JLabel(getLabelFor(ffName));
253
                    labelFF.setHorizontalAlignment(SwingConstants.RIGHT);
254
                    ElementComboBox selFF = new ElementComboBox();
255
                    selFF.setInfoIconVisible(false);
177 ilm 256
                    if (p % 2 == 0) {
257
                        c.gridy++;
258
                        c.gridx = 0;
259
                    } else {
260
                        c.gridx++;
261
                    }
262
                    p++;
132 ilm 263
                    c.weightx = 0;
264
                    this.add(labelFF, c);
265
                    c.gridx++;
266
                    c.weighty = 1;
267
                    c.weightx = 1;
268
                    this.add(selFF, c);
177 ilm 269
                    if (ffName.equals("ID_CONTRAT_MOTIF_RECOURS")) {
270
                        this.addSQLObject(selFF, ffName);
271
                    } else {
272
                        this.addRequiredSQLObject(selFF, ffName);
273
                    }
132 ilm 274
                }
275
 
174 ilm 276
                // Code Arrco, agirc retirés du contrat et ajoutés dans les caisses de cotisations
277
 
41 ilm 278
                // Code UGRR
279
 
174 ilm 280
                // JLabel labelCodeUGRR = new JLabel(getLabelFor("CODE_IRC_UGRR"));
281
                // labelCodeUGRR.setHorizontalAlignment(SwingConstants.RIGHT);
282
                // JTextField textCodeUGRR = new JTextField();
283
                // c.gridy++;
284
                // c.gridx = 0;
285
                // c.weightx = 0;
286
                // this.add(labelCodeUGRR, c);
287
                // c.gridx++;
288
                // c.weighty = 1;
289
                // c.weightx = 1;
290
                // this.add(textCodeUGRR, c);
291
                // addView(textCodeUGRR, "CODE_IRC_UGRR");
292
                //
293
                // JLabel labelNumUGRR = new JLabel(getLabelFor("NUMERO_RATTACHEMENT_UGRR"));
294
                // labelNumUGRR.setHorizontalAlignment(SwingConstants.RIGHT);
295
                // JTextField textNumUGRR = new JTextField();
296
                // c.gridy++;
297
                // c.gridx = 0;
298
                // c.weightx = 0;
299
                // this.add(labelNumUGRR, c);
300
                // c.gridx++;
301
                // c.weighty = 1;
302
                // c.weightx = 1;
303
                // this.add(textNumUGRR, c);
304
                // addView(textNumUGRR, "NUMERO_RATTACHEMENT_UGRR");
305
                //
306
                // // Code UGRC
307
                // JLabel labelCodeUGRC = new JLabel(getLabelFor("CODE_IRC_UGRC"));
308
                // labelCodeUGRC.setHorizontalAlignment(SwingConstants.RIGHT);
309
                // JTextField textCodeUGRC = new JTextField();
310
                // c.gridy++;
311
                // c.gridx = 0;
312
                // c.weightx = 0;
313
                // this.add(labelCodeUGRC, c);
314
                // c.gridx++;
315
                // c.weighty = 1;
316
                // c.weightx = 1;
317
                // this.add(textCodeUGRC, c);
318
                // addView(textCodeUGRC, "CODE_IRC_UGRC");
319
                //
320
                // JLabel labelNumUGRC = new JLabel(getLabelFor("NUMERO_RATTACHEMENT_UGRC"));
321
                // labelNumUGRC.setHorizontalAlignment(SwingConstants.RIGHT);
322
                // JTextField textNumUGRC = new JTextField();
323
                // c.gridy++;
324
                // c.gridx = 0;
325
                // c.weightx = 0;
326
                // this.add(labelNumUGRC, c);
327
                // c.gridx++;
328
                // c.weighty = 1;
329
                // c.weightx = 1;
330
                // this.add(textNumUGRC, c);
331
                // addView(textNumUGRC, "NUMERO_RATTACHEMENT_UGRC");
332
                //
333
                // // Retraite
334
                // JLabel labelCodeRetraite = new JLabel(getLabelFor("CODE_IRC_RETRAITE"));
335
                // labelCodeRetraite.setHorizontalAlignment(SwingConstants.RIGHT);
336
                // JTextField textCodeRetraite = new JTextField();
337
                // c.gridy++;
338
                // c.gridx = 0;
339
                // c.weightx = 0;
340
                // this.add(labelCodeRetraite, c);
341
                // c.gridx++;
342
                // c.weighty = 1;
343
                // c.weightx = 1;
344
                // this.add(textCodeRetraite, c);
345
                // addView(textCodeRetraite, "CODE_IRC_RETRAITE");
346
                //
347
                // JLabel labelNumRetraite = new
348
                // JLabel(getLabelFor("NUMERO_RATTACHEMENT_RETRAITE"));
349
                // labelNumRetraite.setHorizontalAlignment(SwingConstants.RIGHT);
350
                // JTextField textNumRetraite = new JTextField();
351
                // c.gridy++;
352
                // c.gridx = 0;
353
                // c.weightx = 0;
354
                // this.add(labelNumRetraite, c);
355
                // c.gridx++;
356
                // c.weighty = 1;
357
                // c.weightx = 1;
358
                // this.add(textNumRetraite, c);
359
                // addView(textNumRetraite, "NUMERO_RATTACHEMENT_RETRAITE");
41 ilm 360
 
132 ilm 361
                // JLabel labelCodeRegimeRetraite = new
362
                // JLabel(getLabelFor("CODE_REGIME_RETRAITE_DSN"));
363
                // labelCodeRegimeRetraite.setHorizontalAlignment(SwingConstants.RIGHT);
364
                // JTextField textCodeRegimeRetraite = new JTextField();
365
                // c.gridy++;
366
                // c.gridx = 0;
367
                // c.weightx = 0;
368
                // this.add(labelCodeRegimeRetraite, c);
369
                // c.gridx++;
370
                // c.weighty = 1;
371
                // c.weightx = 1;
372
                // this.add(textCodeRegimeRetraite, c);
373
                // addRequiredSQLObject(textCodeRegimeRetraite, "CODE_REGIME_RETRAITE_DSN");
374
 
177 ilm 375
                // JLabel labelDateModif = new JLabel(getLabelFor("DATE_MODIFICATION"));
376
                // labelDateModif.setHorizontalAlignment(SwingConstants.RIGHT);
377
                // JDate textDateModif = new JDate();
378
                // c.gridy++;
379
                // c.gridx = 0;
380
                // c.weightx = 0;
381
                // this.add(textDateModif, c);
382
                // c.gridx++;
383
                // c.weighty = 1;
384
                // c.weightx = 1;
385
                // this.add(textDateModif, c);
386
                // addSQLObject(textDateModif, "DATE_MODIFICATION");
142 ilm 387
 
388
                // JLabel labelCM = new JLabel(getLabelFor("ID_INFOS_SALARIE_PAYE_MODIFIE"));
389
                // labelCM.setHorizontalAlignment(SwingConstants.RIGHT);
390
                // ElementComboBox selCM = new ElementComboBox();
391
                // final SQLElement elementInfosPaye =
392
                // getDirectory().getElement("INFOS_SALARIE_PAYE");
393
                // selCM.init(elementInfosPaye, elementInfosPaye.createComboRequest());
394
                // selCM.setInfoIconVisible(false);
395
                // c.gridy++;
396
                // c.gridx = 0;
397
                // c.weightx = 0;
398
                // this.add(labelCM, c);
399
                // c.gridx++;
400
                // c.weighty = 1;
401
                // c.weightx = 1;
402
                // this.add(selCM, c);
403
                // this.addSQLObject(selCM, "ID_INFOS_SALARIE_PAYE_MODIFIE");
404
 
405
                JLabel labelDateDebut = new JLabel(getLabelFor("DATE_DEBUT"));
406
                labelDateDebut.setHorizontalAlignment(SwingConstants.RIGHT);
407
                JDate textDateDebut = new JDate();
408
                c.gridy++;
409
                c.gridx = 0;
410
                c.weightx = 0;
411
                this.add(labelDateDebut, c);
412
                c.gridx++;
413
                c.weightx = 1;
414
                this.add(textDateDebut, c);
415
                addSQLObject(textDateDebut, "DATE_DEBUT", REQ);
416
 
132 ilm 417
                JLabel labelDateFin = new JLabel(getLabelFor("DATE_PREV_FIN"));
418
                labelDateFin.setHorizontalAlignment(SwingConstants.RIGHT);
419
                JDate textDateFin = new JDate();
177 ilm 420
                c.gridx++;
132 ilm 421
                c.weightx = 0;
422
                this.add(labelDateFin, c);
423
                c.gridx++;
424
                c.weightx = 1;
425
                this.add(textDateFin, c);
426
                addSQLObject(textDateFin, "DATE_PREV_FIN");
427
 
177 ilm 428
                JLabel labelAmen = new JLabel(getLabelFor("ID_CODE_AMENAGEMENT_PARTIEL"));
429
                labelAmen.setHorizontalAlignment(SwingConstants.RIGHT);
430
                ElementComboBox selAmen = new ElementComboBox();
431
                selAmen.setInfoIconVisible(false);
432
                c.gridy++;
433
                c.gridx = 0;
434
                c.weightx = 0;
435
                this.add(labelAmen, c);
436
                c.gridx++;
437
                c.weightx = 1;
438
                this.add(selAmen, c);
439
                this.addSQLObject(selAmen, "ID_CODE_AMENAGEMENT_PARTIEL");
440
 
441
                JLabel labelSupsension = new JLabel(getLabelFor("ID_CODE_SUSPENSION"));
442
                labelSupsension.setHorizontalAlignment(SwingConstants.RIGHT);
443
                ElementComboBox selSupsension = new ElementComboBox();
444
                selSupsension.setInfoIconVisible(false);
445
                c.gridx++;
446
                c.weightx = 0;
447
                this.add(labelSupsension, c);
448
                c.gridx++;
449
                c.weightx = 1;
450
                this.add(selSupsension, c);
451
                this.addSQLObject(selSupsension, "ID_CODE_SUSPENSION");
452
 
453
                JLabel labelDateDebutSusp = new JLabel(getLabelFor("DATE_DEBUT_SUSPENSION"));
454
                labelDateDebutSusp.setHorizontalAlignment(SwingConstants.RIGHT);
455
                JDate textDateDebutSups = new JDate();
456
                c.gridy++;
457
                c.gridx = 0;
458
                c.weightx = 0;
459
                this.add(labelDateDebutSusp, c);
460
                c.gridx++;
461
                c.weightx = 1;
462
                this.add(textDateDebutSups, c);
463
                this.addSQLObject(textDateDebutSups, "DATE_DEBUT_SUSPENSION");
464
 
465
                JLabel labelDateFinSups = new JLabel(getLabelFor("DATE_FIN_SUSPENSION"));
466
                labelDateFinSups.setHorizontalAlignment(SwingConstants.RIGHT);
467
                JDate textDateFinSuspension = new JDate();
468
                c.gridx++;
469
                c.weightx = 0;
470
                this.add(labelDateFinSups, c);
471
                c.gridx++;
472
                c.weightx = 1;
473
                this.add(textDateFinSuspension, c);
474
                this.addSQLObject(textDateFinSuspension, "DATE_FIN_SUSPENSION");
475
 
132 ilm 476
                this.addRequiredSQLObject(selCodeCatSocio, "ID_CODE_EMPLOI");
151 ilm 477
                this.addRequiredSQLObject(selContratTravail, "ID_CODE_CONTRAT_TRAVAIL");
478
                this.addRequiredSQLObject(selDroitContrat, "ID_CODE_DROIT_CONTRAT");
479
                this.addRequiredSQLObject(selStatutProf, "ID_CODE_STATUT_PROF");
480
                this.addRequiredSQLObject(selStatutCat, "ID_CODE_STATUT_CATEGORIEL");
481
                this.addRequiredSQLObject(selStatutCatConv, "ID_CODE_STATUT_CAT_CONV");
18 ilm 482
                this.addRequiredSQLObject(textNature, "NATURE");
483
            }
484
        };
485
    }
57 ilm 486
 
487
    @Override
488
    protected String createCode() {
156 ilm 489
        return createCodeOfPackage() + ".contract.employe";
57 ilm 490
    }
18 ilm 491
}