OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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