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.payroll.element;
15
 
16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
17
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
18
import org.openconcerto.erp.model.ISQLCompteSelector;
19
import org.openconcerto.sql.element.BaseSQLComponent;
20
import org.openconcerto.sql.element.SQLComponent;
21
import org.openconcerto.sql.model.SQLRowValues;
22
import org.openconcerto.sql.sqlobject.SQLTextCombo;
23
import org.openconcerto.sql.ui.RadioButtons;
24
import org.openconcerto.ui.DefaultGridBagConstraints;
25
 
26
import java.awt.FlowLayout;
27
import java.awt.GridBagConstraints;
28
import java.awt.GridBagLayout;
29
import java.awt.event.ActionEvent;
30
import java.awt.event.ActionListener;
31
import java.util.ArrayList;
32
import java.util.List;
33
 
34
import javax.swing.BorderFactory;
35
import javax.swing.ButtonGroup;
36
import javax.swing.JLabel;
37
import javax.swing.JPanel;
38
import javax.swing.JRadioButton;
39
import javax.swing.JTextField;
40
import javax.swing.SwingConstants;
41
 
42
public class ReglementPayeSQLElement extends ComptaSQLConfElement {
43
 
44
    public ReglementPayeSQLElement() {
45
        super("REGLEMENT_PAYE", "un règlement de paye", "règlements de paye");
46
    }
47
 
48
    protected List<String> getListFields() {
49
        final List<String> l = new ArrayList<String>();
50
        l.add("NOM_BANQUE");
51
        l.add("RIB");
52
        l.add("ID_COMPTE_PCE");
53
        l.add("ID_MODE_REGLEMENT_PAYE");
54
        l.add("LE");
55
        return l;
56
    }
57
 
58
    protected List<String> getComboFields() {
59
        final List<String> l = new ArrayList<String>();
60
        l.add("NOM_BANQUE");
61
        l.add("RIB");
62
        return l;
63
    }
64
 
132 ilm 65
    @Override
66
    public boolean isPrivate() {
67
        return true;
68
    }
69
 
18 ilm 70
    /*
71
     * protected List getPrivateFields() { final List l = new ArrayList();
72
     * l.add("ID_MODE_REGLEMENT"); return l; }
73
     */
74
 
75
    /*
76
     * (non-Javadoc)
77
     *
78
     * @see org.openconcerto.devis.SQLElement#getComponent()
79
     */
80
    public SQLComponent createComponent() {
81
        return new BaseSQLComponent(this) {
82
 
83
            public void addViews() {
84
 
85
                this.setLayout(new GridBagLayout());
86
                final GridBagConstraints c = new DefaultGridBagConstraints();
87
 
88
                /***********************************************************************************
89
                 * COORDONNEES DE LA BANQUE
90
                 **********************************************************************************/
91
                JPanel panelBanque = new JPanel();
92
                panelBanque.setOpaque(false);
93
                panelBanque.setBorder(BorderFactory.createTitledBorder("Coordonnées bancaires"));
94
                panelBanque.setLayout(new GridBagLayout());
95
 
96
                // Nom Banque
97
                JLabel labelNomBq = new JLabel(getLabelFor("NOM_BANQUE"));
98
                labelNomBq.setHorizontalAlignment(SwingConstants.RIGHT);
99
                SQLTextCombo textNomBq = new SQLTextCombo();
174 ilm 100
                c.weightx = 0;
18 ilm 101
                panelBanque.add(labelNomBq, c);
102
                c.gridx++;
103
                c.weightx = 1;
104
                panelBanque.add(textNomBq, c);
105
                c.weightx = 0;
106
 
174 ilm 107
                // IBAN
108
                JLabel labelIBAN = new JLabel(getLabelFor("IBAN"));
109
                labelIBAN.setHorizontalAlignment(SwingConstants.RIGHT);
110
                JTextField textIBAN = new JTextField();
111
 
112
                c.gridy++;
113
                c.gridx = 0;
114
                c.weightx = 0;
115
                panelBanque.add(labelIBAN, c);
116
                c.gridx++;
117
                c.weightx = 1;
118
                panelBanque.add(textIBAN, c);
119
 
120
                // BIC
121
                JLabel labelBIC = new JLabel(getLabelFor("BIC"));
122
                labelBIC.setHorizontalAlignment(SwingConstants.RIGHT);
123
                JTextField textBIC = new JTextField();
124
 
125
                c.gridy++;
126
                c.gridx = 0;
127
                c.weightx = 0;
128
                panelBanque.add(labelBIC, c);
129
                c.gridx++;
130
                c.weightx = 1;
131
                panelBanque.add(textBIC, c);
132
 
18 ilm 133
                // RIB
134
                JLabel labelRIB = new JLabel(getLabelFor("RIB"));
135
                labelRIB.setHorizontalAlignment(SwingConstants.RIGHT);
136
                JTextField textRIB = new JTextField();
137
 
138
                c.gridy++;
139
                c.gridx = 0;
140
                panelBanque.add(labelRIB, c);
141
                c.gridx++;
142
                c.weightx = 1;
143
                panelBanque.add(textRIB, c);
144
                c.weightx = 0;
145
 
146
                c.gridx = 0;
147
                c.gridy = 0;
148
                c.anchor = GridBagConstraints.NORTHWEST;
149
                c.weightx = 1;
150
                this.add(panelBanque, c);
151
                c.weightx = 0;
152
                c.anchor = GridBagConstraints.WEST;
153
 
154
                /***********************************************************************************
155
                 * Mode de reglement
156
                 **********************************************************************************/
157
                JPanel panelReglement = new JPanel();
158
                // panelReglement.setOpaque(false);
159
                panelReglement.setBorder(BorderFactory.createTitledBorder(getLabelFor("ID_MODE_REGLEMENT_PAYE")));
160
                panelReglement.setLayout(new GridBagLayout());
161
 
162
                // Mode
163
                RadioButtons typeRegl = new RadioButtons("NOM");
164
                typeRegl.setLayout(new FlowLayout(FlowLayout.LEFT));
165
                c.gridy = 0;
166
                c.gridx = 0;
167
                c.gridwidth = GridBagConstraints.REMAINDER;
168
                c.weightx = 1;
169
                panelReglement.add(typeRegl, c);
170
 
171
                // Date de paiement
172
                final JRadioButton radioLe = new JRadioButton("Le");
173
                final JTextField textLe = new JTextField(2);
174
                JLabel labelDu = new JLabel("du mois.");
175
                final JRadioButton radioFin = new JRadioButton("Fin de mois");
176
 
177
                c.gridwidth = 1;
178
                c.weightx = 0;
179
                c.gridy++;
180
                panelReglement.add(radioLe, c);
181
                c.gridx++;
174 ilm 182
                c.weightx = 1;
18 ilm 183
                panelReglement.add(textLe, c);
184
                textLe.setText("31");
185
                c.gridx++;
174 ilm 186
                c.weightx = 0;
187
                panelReglement.add(labelDu, c);
18 ilm 188
                c.weightx = 1;
189
 
190
                c.gridy++;
191
                c.gridx = 0;
192
                c.gridwidth = GridBagConstraints.REMAINDER;
193
                panelReglement.add(radioFin, c);
194
                radioFin.addActionListener(new ActionListener() {
195
                    public void actionPerformed(ActionEvent e) {
196
                        textLe.setText("31");
197
                        textLe.setEditable(false);
198
                        textLe.setEnabled(false);
199
                    }
200
                });
201
 
202
                radioLe.addActionListener(new ActionListener() {
203
                    public void actionPerformed(ActionEvent e) {
204
                        textLe.setEditable(true);
205
                        textLe.setEnabled(true);
206
                    }
207
                });
208
                ButtonGroup groupDate = new ButtonGroup();
209
                groupDate.add(radioLe);
210
                groupDate.add(radioFin);
211
                radioFin.setSelected(true);
212
                textLe.setEditable(false);
213
                textLe.setEnabled(false);
214
 
215
                c.weightx = 0;
216
                c.gridwidth = 1;
217
 
218
                c.gridx = 1;
219
                c.gridy = 0;
220
                c.anchor = GridBagConstraints.NORTHWEST;
221
                c.fill = GridBagConstraints.HORIZONTAL;
222
                this.add(panelReglement, c);
223
                c.anchor = GridBagConstraints.WEST;
224
 
225
                /***********************************************************************************
226
                 * Comptabilite
227
                 **********************************************************************************/
228
                JPanel panelCompta = new JPanel();
229
                panelCompta.setOpaque(false);
230
                panelCompta.setBorder(BorderFactory.createTitledBorder("Comptabilité"));
231
                panelCompta.setLayout(new GridBagLayout());
232
 
233
                // Compte du salarié
234
                JLabel labelCompteSal = new JLabel(getLabelFor("ID_COMPTE_PCE"));
235
                labelCompteSal.setHorizontalAlignment(SwingConstants.RIGHT);
236
                ISQLCompteSelector compteSal = new ISQLCompteSelector();
237
 
238
                c.gridx = 0;
239
                c.gridy = 0;
240
                c.gridwidth = 1;
174 ilm 241
                c.weightx = 0;
18 ilm 242
                panelCompta.add(labelCompteSal, c);
243
                c.gridx++;
244
                c.weightx = 1;
245
                panelCompta.add(compteSal, c);
246
 
247
                c.gridx = 0;
248
                c.gridy = 1;
249
                c.weighty = 1;
250
                c.weightx = 1;
251
                c.gridwidth = GridBagConstraints.REMAINDER;
252
                c.anchor = GridBagConstraints.NORTHWEST;
253
                this.add(panelCompta, c);
254
 
255
                this.addSQLObject(textNomBq, "NOM_BANQUE");
256
                this.addSQLObject(textRIB, "RIB");
174 ilm 257
                this.addSQLObject(textIBAN, "IBAN");
258
                this.addSQLObject(textBIC, "BIC");
18 ilm 259
                this.addRequiredSQLObject(typeRegl, "ID_MODE_REGLEMENT_PAYE");
260
                this.addRequiredSQLObject(textLe, "LE");
261
                this.addRequiredSQLObject(compteSal, "ID_COMPTE_PCE");
262
                // compteSal.init();
263
            }
264
 
265
            protected SQLRowValues createDefaults() {
266
 
267
                SQLRowValues rowVals = new SQLRowValues(getTable());
268
                rowVals.put("ID_MODE_REGLEMENT_PAYE", Integer.valueOf(2));
269
                rowVals.put("ID_COMPTE_PCE", ComptePCESQLElement.getId("421"));
270
                rowVals.put("LE", 31);
271
                return rowVals;
272
            }
273
        };
274
    }
57 ilm 275
 
276
    @Override
277
    protected String createCode() {
156 ilm 278
        return createCodeOfPackage() + ".payment";
57 ilm 279
    }
18 ilm 280
}