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.ContratPrevRubriqueTable;
18
import org.openconcerto.erp.core.humanresources.payroll.ui.ContratPrevSalarieTable;
19
import org.openconcerto.sql.element.BaseSQLComponent;
20
import org.openconcerto.sql.element.SQLComponent;
21
import org.openconcerto.sql.model.SQLRow;
22
import org.openconcerto.sql.model.SQLRowAccessor;
23
import org.openconcerto.ui.DefaultGridBagConstraints;
24
import org.openconcerto.ui.JDate;
25
import org.openconcerto.ui.TitledSeparator;
26
import org.openconcerto.utils.ListMap;
27
 
28
import java.awt.GridBagConstraints;
29
import java.awt.GridBagLayout;
30
import java.util.ArrayList;
31
import java.util.List;
32
 
33
import javax.swing.BorderFactory;
34
import javax.swing.JCheckBox;
35
import javax.swing.JLabel;
36
import javax.swing.JPanel;
37
import javax.swing.JTextField;
38
 
39
public class ContratPrevoyanceSQLElement extends ComptaSQLConfElement {
40
 
41
    public ContratPrevoyanceSQLElement() {
42
        super("CONTRAT_PREVOYANCE", "un contrat de prévoyance, mutuelle, formation", "contrats de prévoyance, mutuelle, formation");
43
    }
44
 
45
    protected List<String> getListFields() {
46
        final List<String> l = new ArrayList<String>();
47
        // l.add("CODE_UNIQUE");
48
        l.add("NOM");
49
        l.add("REFERENCE");
50
        l.add("CODE_ORGANISME");
51
        l.add("CODE_DELEGATAIRE");
52
        l.add("COTISATION_ETABLISSEMENT");
53
        return l;
54
    }
55
 
56
    protected List<String> getComboFields() {
57
        final List<String> l = new ArrayList<String>();
58
        l.add("NOM");
59
        l.add("REFERENCE");
60
        return l;
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
            ContratPrevSalarieTable tableSalarie = new ContratPrevSalarieTable();
77
 
78
            ContratPrevRubriqueTable tableRub = new ContratPrevRubriqueTable(false);
79
            ContratPrevRubriqueTable tableRubNet = new ContratPrevRubriqueTable(true);
80
 
81
            public void addViews() {
82
 
83
                this.setLayout(new GridBagLayout());
84
                final GridBagConstraints c = new DefaultGridBagConstraints();
85
 
86
                /***********************************************************************************
87
                 * Renseignements
88
                 **********************************************************************************/
89
                JPanel panelInfos = new JPanel();
90
                panelInfos.setBorder(BorderFactory.createTitledBorder("Renseignements (S21.G00.15)"));
91
                panelInfos.setLayout(new GridBagLayout());
92
 
93
                // // Code
94
                // JLabel labelCode = new JLabel(getLabelFor("CODE_UNIQUE"));
95
                // JTextField textCode = new JTextField();
96
                // panelInfos.add(labelCode, c);
97
                // c.gridx++;
98
                // c.weightx = 1;
99
                // panelInfos.add(textCode, c);
100
                // this.addSQLObject(textCode, "CODE_UNIQUE");
101
                // c.weightx = 0;
102
 
103
                // Nom
104
                JLabel labelNom = new JLabel(getLabelFor("NOM"));
105
                JTextField textNom = new JTextField();
106
                // c.gridx++;
107
                c.weightx = 0;
108
                panelInfos.add(labelNom, c);
109
                c.gridx++;
110
                c.weightx = 1;
111
                panelInfos.add(textNom, c);
112
                c.weightx = 0;
113
                // Ref
114
                JLabel labelRef = new JLabel(getLabelFor("REFERENCE"));
115
                JTextField textRef = new JTextField();
116
                c.gridx++;
117
                panelInfos.add(labelRef, c);
118
                c.gridx++;
119
                c.weightx = 1;
120
                panelInfos.add(textRef, c);
121
 
122
                c.weightx = 0;
123
 
124
                // Nom
125
                JLabel labelCO = new JLabel(getLabelFor("CODE_ORGANISME"));
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
                c.weightx = 0;
135
 
136
                // Ref
137
                JLabel labelCD = new JLabel(getLabelFor("CODE_DELEGATAIRE"));
138
                JTextField textCD = new JTextField();
139
                c.gridx++;
140
                panelInfos.add(labelCD, c);
141
                c.gridx++;
142
                c.weightx = 1;
143
                panelInfos.add(textCD, c);
144
 
145
                // Formation
146
                JCheckBox checkFO = new JCheckBox(getLabelFor("COTISATION_ETABLISSEMENT"));
147
                c.gridy++;
148
                c.gridx = 0;
149
                c.weightx = 0;
150
                c.gridwidth = 2;
151
                panelInfos.add(checkFO, c);
152
 
153
                // Deb
154
                JLabel labelDateDeb = new JLabel(getLabelFor("DATE_DEBUT"));
155
                JDate dateDeb = new JDate();
156
                c.gridx = 0;
157
                c.gridy++;
158
                c.weightx = 0;
159
                panelInfos.add(labelDateDeb, c);
160
                c.gridx++;
161
                c.weightx = 1;
162
                panelInfos.add(dateDeb, c);
163
                this.addSQLObject(dateDeb, "DATE_DEBUT");
164
                c.weightx = 0;
165
                // Fin
166
                JLabel labelDateFin = new JLabel(getLabelFor("DATE_FIN"));
167
                JDate dateFin = new JDate();
168
                c.gridx++;
169
                panelInfos.add(labelDateFin, c);
170
                c.gridx++;
171
                c.weightx = 1;
172
                panelInfos.add(dateFin, c);
173
                this.addSQLObject(dateFin, "DATE_FIN");
174
 
175
                c.weightx = 0;
176
 
177
                TitledSeparator sepRenseignement = new TitledSeparator("Renseignement par contrat salarié (S21.G00.70)");
178
                c.gridwidth = GridBagConstraints.REMAINDER;
179
                c.gridy++;
180
                c.gridx = 0;
181
                panelInfos.add(sepRenseignement, c);
182
                c.gridx = 0;
183
                c.gridy++;
184
                c.fill = GridBagConstraints.BOTH;
185
                c.gridwidth = GridBagConstraints.REMAINDER;
186
                c.weighty = 0.5;
187
 
188
                panelInfos.add(tableSalarie, c);
189
 
190
                TitledSeparator sepRub = new TitledSeparator("Rubriques de cotisation rattachées");
191
                c.gridwidth = GridBagConstraints.REMAINDER;
192
                c.gridy++;
193
                c.gridx = 0;
194
                panelInfos.add(sepRub, c);
195
 
196
                c.gridx = 0;
197
                c.gridy++;
198
                c.fill = GridBagConstraints.BOTH;
199
                c.weighty = 0.5;
200
                panelInfos.add(tableRub, c);
201
 
202
                TitledSeparator sepRubN = new TitledSeparator("Rubriques de net rattachées");
203
                c.gridwidth = GridBagConstraints.REMAINDER;
204
                c.gridy++;
205
                c.gridx = 0;
206
                panelInfos.add(sepRubN, c);
207
 
208
                c.gridx = 0;
209
                c.gridy++;
210
                c.fill = GridBagConstraints.BOTH;
211
                c.weighty = 0.5;
212
                panelInfos.add(tableRubNet, c);
213
 
214
                c.gridx = 0;
215
                c.gridy++;
216
                c.fill = GridBagConstraints.BOTH;
217
                c.weightx = 1;
218
                c.weighty = 1;
219
                this.add(panelInfos, c);
220
 
221
                this.addSQLObject(textNom, "NOM");
222
 
223
                this.addSQLObject(textCD, "CODE_DELEGATAIRE");
224
                this.addSQLObject(textCO, "CODE_ORGANISME");
225
                this.addSQLObject(textRef, "REFERENCE");
226
                this.addSQLObject(checkFO, "COTISATION_ETABLISSEMENT");
227
            }
228
 
229
            @Override
230
            public int insert(SQLRow order) {
231
 
232
                int id = super.insert(order);
233
 
234
                tableRub.updateField("ID_CONTRAT_PREVOYANCE", id);
235
                tableRubNet.updateField("ID_CONTRAT_PREVOYANCE", id);
236
                tableSalarie.updateField("ID_CONTRAT_PREVOYANCE", id);
237
                return id;
238
            }
239
 
240
            @Override
241
            public void update() {
242
 
243
                int id = getSelectedID();
244
                super.update();
245
                tableRub.updateField("ID_CONTRAT_PREVOYANCE", id);
246
                tableRubNet.updateField("ID_CONTRAT_PREVOYANCE", id);
247
                tableSalarie.updateField("ID_CONTRAT_PREVOYANCE", id);
248
 
249
            }
250
 
251
            @Override
252
            public void select(SQLRowAccessor r) {
253
 
254
                super.select(r);
255
                if (r != null) {
256
                    tableRub.insertFrom("ID_CONTRAT_PREVOYANCE", r.getID());
257
                    tableRubNet.insertFrom("ID_CONTRAT_PREVOYANCE", r.getID());
258
                    tableSalarie.insertFrom("ID_CONTRAT_PREVOYANCE", r.getID());
259
                }
260
            }
261
        };
262
    }
263
}