OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 132 | 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();
100
 
101
                panelBanque.add(labelNomBq, c);
102
                c.gridx++;
103
                c.weightx = 1;
104
                panelBanque.add(textNomBq, c);
105
                c.weightx = 0;
106
 
107
                // RIB
108
                JLabel labelRIB = new JLabel(getLabelFor("RIB"));
109
                labelRIB.setHorizontalAlignment(SwingConstants.RIGHT);
110
                JTextField textRIB = new JTextField();
111
 
112
                c.gridy++;
113
                c.gridx = 0;
114
                panelBanque.add(labelRIB, c);
115
                c.gridx++;
116
                c.weightx = 1;
117
                panelBanque.add(textRIB, c);
118
                c.weightx = 0;
119
 
120
                c.gridx = 0;
121
                c.gridy = 0;
122
                c.anchor = GridBagConstraints.NORTHWEST;
123
                c.weightx = 1;
124
                this.add(panelBanque, c);
125
                c.weightx = 0;
126
                c.anchor = GridBagConstraints.WEST;
127
 
128
                /***********************************************************************************
129
                 * Mode de reglement
130
                 **********************************************************************************/
131
                JPanel panelReglement = new JPanel();
132
                // panelReglement.setOpaque(false);
133
                panelReglement.setBorder(BorderFactory.createTitledBorder(getLabelFor("ID_MODE_REGLEMENT_PAYE")));
134
                panelReglement.setLayout(new GridBagLayout());
135
 
136
                // Mode
137
                RadioButtons typeRegl = new RadioButtons("NOM");
138
                typeRegl.setLayout(new FlowLayout(FlowLayout.LEFT));
139
                c.gridy = 0;
140
                c.gridx = 0;
141
                c.gridwidth = GridBagConstraints.REMAINDER;
142
                c.weightx = 1;
143
                panelReglement.add(typeRegl, c);
144
 
145
                // Date de paiement
146
                final JRadioButton radioLe = new JRadioButton("Le");
147
                final JTextField textLe = new JTextField(2);
148
                JLabel labelDu = new JLabel("du mois.");
149
                final JRadioButton radioFin = new JRadioButton("Fin de mois");
150
 
151
                c.gridwidth = 1;
152
                c.weightx = 0;
153
                c.gridy++;
154
                panelReglement.add(radioLe, c);
155
                c.gridx++;
156
                panelReglement.add(textLe, c);
157
                textLe.setText("31");
158
                c.gridx++;
159
                c.weightx = 1;
160
                panelReglement.add(labelDu, c);
161
 
162
                c.gridy++;
163
                c.gridx = 0;
164
                c.gridwidth = GridBagConstraints.REMAINDER;
165
                panelReglement.add(radioFin, c);
166
                radioFin.addActionListener(new ActionListener() {
167
                    public void actionPerformed(ActionEvent e) {
168
                        textLe.setText("31");
169
                        textLe.setEditable(false);
170
                        textLe.setEnabled(false);
171
                    }
172
                });
173
 
174
                radioLe.addActionListener(new ActionListener() {
175
                    public void actionPerformed(ActionEvent e) {
176
                        textLe.setEditable(true);
177
                        textLe.setEnabled(true);
178
                    }
179
                });
180
                ButtonGroup groupDate = new ButtonGroup();
181
                groupDate.add(radioLe);
182
                groupDate.add(radioFin);
183
                radioFin.setSelected(true);
184
                textLe.setEditable(false);
185
                textLe.setEnabled(false);
186
 
187
                c.weightx = 0;
188
                c.gridwidth = 1;
189
 
190
                c.gridx = 1;
191
                c.gridy = 0;
192
                c.anchor = GridBagConstraints.NORTHWEST;
193
                c.fill = GridBagConstraints.HORIZONTAL;
194
                this.add(panelReglement, c);
195
                c.anchor = GridBagConstraints.WEST;
196
 
197
                /***********************************************************************************
198
                 * Comptabilite
199
                 **********************************************************************************/
200
                JPanel panelCompta = new JPanel();
201
                panelCompta.setOpaque(false);
202
                panelCompta.setBorder(BorderFactory.createTitledBorder("Comptabilité"));
203
                panelCompta.setLayout(new GridBagLayout());
204
 
205
                // Compte du salarié
206
                JLabel labelCompteSal = new JLabel(getLabelFor("ID_COMPTE_PCE"));
207
                labelCompteSal.setHorizontalAlignment(SwingConstants.RIGHT);
208
                ISQLCompteSelector compteSal = new ISQLCompteSelector();
209
 
210
                c.gridx = 0;
211
                c.gridy = 0;
212
                c.gridwidth = 1;
213
                panelCompta.add(labelCompteSal, c);
214
                c.gridx++;
215
                c.weightx = 1;
216
                panelCompta.add(compteSal, c);
217
 
218
                c.gridx = 0;
219
                c.gridy = 1;
220
                c.weighty = 1;
221
                c.weightx = 1;
222
                c.gridwidth = GridBagConstraints.REMAINDER;
223
                c.anchor = GridBagConstraints.NORTHWEST;
224
                this.add(panelCompta, c);
225
 
226
                this.addSQLObject(textNomBq, "NOM_BANQUE");
227
                this.addSQLObject(textRIB, "RIB");
228
                this.addRequiredSQLObject(typeRegl, "ID_MODE_REGLEMENT_PAYE");
229
                this.addRequiredSQLObject(textLe, "LE");
230
                this.addRequiredSQLObject(compteSal, "ID_COMPTE_PCE");
231
                // compteSal.init();
232
            }
233
 
234
            protected SQLRowValues createDefaults() {
235
 
236
                SQLRowValues rowVals = new SQLRowValues(getTable());
237
                rowVals.put("ID_MODE_REGLEMENT_PAYE", Integer.valueOf(2));
238
                rowVals.put("ID_COMPTE_PCE", ComptePCESQLElement.getId("421"));
239
                rowVals.put("LE", 31);
240
                return rowVals;
241
            }
242
        };
243
    }
57 ilm 244
 
245
    @Override
246
    protected String createCode() {
156 ilm 247
        return createCodeOfPackage() + ".payment";
57 ilm 248
    }
18 ilm 249
}