OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev Author Line No. Line
142 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.erp.core.humanresources.payroll.ui.AyantDroitTable;
18
import org.openconcerto.sql.element.BaseSQLComponent;
19
import org.openconcerto.sql.element.SQLComponent;
20
import org.openconcerto.sql.model.SQLRow;
21
import org.openconcerto.sql.model.SQLRowAccessor;
22
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
23
import org.openconcerto.ui.DefaultGridBagConstraints;
24
import org.openconcerto.ui.JDate;
25
import org.openconcerto.utils.ListMap;
26
 
27
import java.awt.GridBagConstraints;
28
import java.awt.GridBagLayout;
29
import java.util.ArrayList;
30
import java.util.List;
31
 
32
import javax.swing.BorderFactory;
33
import javax.swing.JLabel;
34
import javax.swing.JPanel;
35
import javax.swing.JTextField;
36
 
37
public class AyantDroitContratPrevSQLElement extends ComptaSQLConfElement {
38
 
39
    public AyantDroitContratPrevSQLElement() {
40
        super("CONTRAT_PREVOYANCE_AYANT_DROIT", "un ayant droit", "ayants droit");
41
    }
42
 
43
    protected List<String> getListFields() {
44
        final List<String> l = new ArrayList<String>();
45
        l.add("ID_CONTRAT_PREVOYANCE");
46
        return l;
47
    }
48
 
49
    protected List<String> getComboFields() {
50
        final List<String> l = new ArrayList<String>();
51
        l.add("ID_CONTRAT_PREVOYANCE");
52
        return l;
53
    }
54
 
55
    @Override
56
    protected String createCode() {
156 ilm 57
        return createCodeOfPackage() + ".contrat.ayantdroit";
142 ilm 58
    }
59
 
60
    @Override
61
    public ListMap<String, String> getShowAs() {
62
        return ListMap.singleton(null, "ID_CONTRAT_PREVOYANCE");
63
    }
64
 
65
    /*
66
     * (non-Javadoc)
67
     *
68
     * @see org.openconcerto.devis.SQLElement#getComponent()
69
     */
70
    public SQLComponent createComponent() {
71
        return new BaseSQLComponent(this) {
72
 
73
            AyantDroitTable table = new AyantDroitTable();
74
 
75
            public void addViews() {
76
 
77
                this.setLayout(new GridBagLayout());
78
                final GridBagConstraints c = new DefaultGridBagConstraints();
79
 
80
                /***********************************************************************************
81
                 * Renseignements
82
                 **********************************************************************************/
83
                JPanel panelInfos = new JPanel();
84
                panelInfos.setBorder(BorderFactory.createTitledBorder("Renseignements"));
85
                panelInfos.setLayout(new GridBagLayout());
86
 
87
                // Code
88
                JLabel labelSal = new JLabel(getLabelFor("ID_SALARIE"));
89
                SQLRequestComboBox boxSal = new SQLRequestComboBox();
90
                panelInfos.add(labelSal, c);
91
                c.gridx++;
92
                c.weightx = 1;
93
                panelInfos.add(boxSal, c);
94
                this.addRequiredSQLObject(boxSal, "ID_SALARIE");
95
                c.weightx = 0;
96
 
97
                // Nom
98
                JLabel labelNom = new JLabel(getLabelFor("NOM"));
99
                JTextField textNom = new JTextField();
100
                // c.gridx++;
101
                c.weightx = 0;
102
                panelInfos.add(labelNom, c);
103
                c.gridx++;
104
                c.weightx = 1;
105
                panelInfos.add(textNom, c);
106
                c.weightx = 0;
107
                // Ref
108
                JLabel labelPrenoms = new JLabel(getLabelFor("PRENOMS"));
109
                JTextField textPrenoms = new JTextField();
110
                c.gridx++;
111
                panelInfos.add(labelPrenoms, c);
112
                c.gridx++;
113
                c.weightx = 1;
114
                panelInfos.add(textPrenoms, c);
115
                this.addSQLObject(textPrenoms, "PRENOMS");
116
 
117
                c.weightx = 0;
118
 
119
                // Nom
120
                JLabel labelCO = new JLabel(getLabelFor("CODE_OPTION"));
121
                JTextField textCO = new JTextField();
122
                c.gridy++;
123
                c.gridx = 0;
124
                c.weightx = 0;
125
                panelInfos.add(labelCO, c);
126
                c.gridx++;
127
                c.weightx = 1;
128
                panelInfos.add(textCO, c);
129
                this.addSQLObject(textCO, "CODE_OPTION");
130
 
131
                c.weightx = 0;
132
 
133
                // Ref
134
                JLabel labelADT = new JLabel(getLabelFor("ID_AYANT_DROIT_TYPE"));
135
                SQLRequestComboBox boxType = new SQLRequestComboBox();
136
                c.gridx++;
137
                panelInfos.add(labelADT, c);
138
                c.gridx++;
139
                c.weightx = 1;
140
                panelInfos.add(boxType, c);
141
                this.addRequiredSQLObject(boxType, "ID_AYANT_DROIT_TYPE");
142
 
143
                // Nom
144
                JLabel labelD = new JLabel(getLabelFor("DATE_DEBUT"));
145
                JDate d = new JDate();
146
                c.gridy++;
147
                c.gridx = 0;
148
                c.weightx = 0;
149
                panelInfos.add(labelD, c);
150
                c.gridx++;
151
                c.weightx = 1;
152
                panelInfos.add(d, c);
153
                this.addRequiredSQLObject(d, "DATE_DEBUT");
154
 
155
                c.weightx = 0;
156
 
157
                // Ref
158
                JLabel labelDN = new JLabel(getLabelFor("DATE_NAISSANCE"));
159
                JDate dn = new JDate();
160
                c.gridx++;
161
                panelInfos.add(labelDN, c);
162
                c.gridx++;
163
                c.weightx = 1;
164
                panelInfos.add(dn, c);
165
                this.addRequiredSQLObject(dn, "DATE_NAISSANCE");
166
 
167
                // Nom
168
                JLabel labelNIR = new JLabel(getLabelFor("NIR"));
169
                JTextField nir = new JTextField();
170
                c.gridy++;
171
                c.gridx = 0;
172
                c.weightx = 0;
173
                panelInfos.add(labelNIR, c);
174
                c.gridx++;
175
                c.weightx = 1;
176
                panelInfos.add(nir, c);
177
                this.addSQLObject(nir, "NIR");
178
 
179
                c.weightx = 0;
180
 
181
                // Ref
182
                JLabel labelNIRO = new JLabel(getLabelFor("NIR_OUVRANT_DROIT"));
183
                JTextField niro = new JTextField();
184
                c.gridx++;
185
                panelInfos.add(labelNIRO, c);
186
                c.gridx++;
187
                c.weightx = 1;
188
                panelInfos.add(niro, c);
189
                this.addRequiredSQLObject(niro, "NIR_OUVRANT_DROIT");
190
 
191
                // Nom
192
                JLabel labelCodeAffil = new JLabel(getLabelFor("CODE_ORGANISME_AFFILIATION"));
193
                JTextField codeAffil = new JTextField();
194
                c.gridy++;
195
                c.gridx = 0;
196
                c.weightx = 0;
197
                panelInfos.add(labelCodeAffil, c);
198
                c.gridx++;
199
                c.weightx = 1;
200
                panelInfos.add(codeAffil, c);
201
                this.addSQLObject(codeAffil, "CODE_ORGANISME_AFFILIATION");
202
 
203
                c.weightx = 0;
204
 
205
                // Ref
206
                JLabel labelDATEFIN = new JLabel(getLabelFor("DATE_FIN"));
207
                JDate dFin = new JDate();
208
                c.gridx++;
209
                panelInfos.add(labelDATEFIN, c);
210
                c.gridx++;
211
                c.weightx = 1;
212
                panelInfos.add(dFin, c);
213
                this.addRequiredSQLObject(dFin, "DATE_FIN");
214
 
215
                c.weightx = 0;
216
 
217
                c.gridx = 0;
218
                c.gridy++;
219
                c.fill = GridBagConstraints.BOTH;
220
                c.gridwidth = GridBagConstraints.REMAINDER;
221
                c.weighty = 1;
222
                panelInfos.add(table, c);
223
 
224
                c.gridx = 0;
225
                c.gridy++;
226
                c.fill = GridBagConstraints.BOTH;
227
                c.weightx = 1;
228
                c.weighty = 1;
229
                this.add(panelInfos, c);
230
 
231
                this.addSQLObject(textNom, "NOM");
232
 
233
            }
234
 
235
            @Override
236
            public int insert(SQLRow order) {
237
 
238
                int id = super.insert(order);
239
 
240
                table.updateField("ID_AYANT_DROIT", id);
241
                return id;
242
            }
243
 
244
            @Override
245
            public void update() {
246
 
247
                int id = getSelectedID();
248
                super.update();
249
                table.updateField("ID_AYANT_DROIT", id);
250
            }
251
 
252
            @Override
253
            public void select(SQLRowAccessor r) {
254
 
255
                super.select(r);
256
                if (r != null) {
257
                    table.insertFrom("ID_AYANT_DROIT", r.getID());
258
                }
259
            }
260
        };
261
    }
262
}