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
 
156 ilm 16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
18 ilm 17
import org.openconcerto.sql.element.BaseSQLComponent;
18
import org.openconcerto.sql.element.SQLComponent;
156 ilm 19
import org.openconcerto.sql.model.DBRoot;
18 ilm 20
import org.openconcerto.sql.model.SQLRowValues;
21
import org.openconcerto.ui.DefaultGridBagConstraints;
132 ilm 22
import org.openconcerto.utils.ListMap;
18 ilm 23
 
24
import java.awt.GridBagConstraints;
25
import java.awt.GridBagLayout;
26
import java.util.ArrayList;
27
import java.util.HashMap;
28
import java.util.List;
29
import java.util.Map;
30
 
31
import javax.swing.JCheckBox;
32
 
156 ilm 33
public class PeriodeValiditeSQLElement extends ComptaSQLConfElement {
18 ilm 34
 
156 ilm 35
    public PeriodeValiditeSQLElement(final DBRoot root) {
36
        super(root.getTable("PERIODE_VALIDITE"), "une période de validité", "périodes de validité");
18 ilm 37
    }
38
 
39
    protected List<String> getListFields() {
40
        final List<String> l = new ArrayList<String>();
41
        l.add("JANVIER");
42
        l.add("FEVRIER");
43
        l.add("MARS");
44
        l.add("AVRIL");
45
        l.add("MAI");
46
        l.add("JUIN");
47
        l.add("JUILLET");
48
        l.add("AOUT");
49
        l.add("SEPTEMBRE");
50
        l.add("OCTOBRE");
51
        l.add("NOVEMBRE");
52
        l.add("DECEMBRE");
53
        return l;
54
    }
55
 
132 ilm 56
    @Override
57
    public boolean isPrivate() {
58
        return true;
59
    }
60
 
18 ilm 61
    protected List<String> getComboFields() {
62
        final List<String> l = new ArrayList<String>();
63
        l.add("JANVIER");
64
        l.add("FEVRIER");
65
        return l;
66
    }
67
 
132 ilm 68
    @Override
69
    public ListMap<String, String> getShowAs() {
70
        return ListMap.singleton(null, "JANVIER");
71
    }
72
 
18 ilm 73
    public static final Map<Integer, String> mapTranslate() {
74
 
75
        Map<Integer, String> m = new HashMap<Integer, String>();
76
        m.put(Integer.valueOf(1), "JANVIER");
77
        m.put(Integer.valueOf(2), "FEVRIER");
78
        m.put(Integer.valueOf(3), "MARS");
79
        m.put(Integer.valueOf(4), "AVRIL");
80
        m.put(Integer.valueOf(5), "MAI");
81
        m.put(Integer.valueOf(6), "JUIN");
82
        m.put(Integer.valueOf(7), "JUILLET");
83
        m.put(Integer.valueOf(8), "AOUT");
84
        m.put(Integer.valueOf(9), "SEPTEMBRE");
85
        m.put(Integer.valueOf(10), "OCTOBRE");
86
        m.put(Integer.valueOf(11), "NOVEMBRE");
87
        m.put(Integer.valueOf(12), "DECEMBRE");
88
 
89
        return m;
90
    }
91
 
92
    /*
93
     * (non-Javadoc)
94
     *
95
     * @see org.openconcerto.devis.SQLElement#getComponent()
96
     */
97
    public SQLComponent createComponent() {
98
        return new BaseSQLComponent(this) {
99
 
100
            private JCheckBox checkJanv, checkFev, checkMars, checkAvril, checkMai, checkJuin, checkJuill, checkAout, checkSept, checkOct, checkNov, checkDec;
101
 
102
            public void addViews() {
103
 
104
                this.setLayout(new GridBagLayout());
105
                final GridBagConstraints c = new DefaultGridBagConstraints();
106
 
107
                c.gridy = GridBagConstraints.REMAINDER;
108
                c.weightx = 1;
109
 
110
                this.checkJanv = new JCheckBox(getLabelFor("JANVIER"));
111
                this.checkJanv.setSelected(true);
112
                this.add(this.checkJanv, c);
113
 
114
                this.checkFev = new JCheckBox(getLabelFor("FEVRIER"));
115
                c.gridy++;
116
                this.checkFev.setSelected(true);
117
                this.add(this.checkFev, c);
118
 
119
                this.checkMars = new JCheckBox(getLabelFor("MARS"));
120
                c.gridy++;
121
                this.checkMars.setSelected(true);
122
                this.add(this.checkMars, c);
123
 
124
                this.checkAvril = new JCheckBox(getLabelFor("AVRIL"));
125
                c.gridy++;
126
                this.checkAvril.setSelected(true);
127
                this.add(this.checkAvril, c);
128
 
129
                this.checkMai = new JCheckBox(getLabelFor("MAI"));
130
                c.gridy++;
131
                this.checkMai.setSelected(true);
132
                this.add(this.checkMai, c);
133
 
134
                this.checkJuin = new JCheckBox(getLabelFor("JUIN"));
135
                c.gridy++;
136
                this.checkJuin.setSelected(true);
137
                this.add(this.checkJuin, c);
138
 
139
                this.checkJuill = new JCheckBox(getLabelFor("JUILLET"));
140
                c.gridy++;
141
                this.checkJuill.setSelected(true);
142
                this.add(this.checkJuill, c);
143
 
144
                this.checkAout = new JCheckBox(getLabelFor("AOUT"));
145
                c.gridy++;
146
                this.checkAout.setSelected(true);
147
                this.add(this.checkAout, c);
148
 
149
                this.checkSept = new JCheckBox(getLabelFor("SEPTEMBRE"));
150
                c.gridy++;
151
                this.checkSept.setSelected(true);
152
                this.add(this.checkSept, c);
153
 
154
                this.checkOct = new JCheckBox(getLabelFor("OCTOBRE"));
155
                c.gridy++;
156
                this.checkOct.setSelected(true);
157
                this.add(this.checkOct, c);
158
 
159
                this.checkNov = new JCheckBox(getLabelFor("NOVEMBRE"));
160
                c.gridy++;
161
                this.checkNov.setSelected(true);
162
                this.add(this.checkNov, c);
163
 
164
                this.checkDec = new JCheckBox(getLabelFor("DECEMBRE"));
165
                c.gridy++;
166
                this.checkDec.setSelected(true);
167
                this.add(this.checkDec, c);
168
 
169
                this.addSQLObject(this.checkJanv, "JANVIER");
170
                this.addSQLObject(this.checkFev, "FEVRIER");
171
                this.addSQLObject(this.checkMars, "MARS");
172
                this.addSQLObject(this.checkAvril, "AVRIL");
173
                this.addSQLObject(this.checkMai, "MAI");
174
                this.addSQLObject(this.checkJuin, "JUIN");
175
                this.addSQLObject(this.checkJuill, "JUILLET");
176
                this.addSQLObject(this.checkAout, "AOUT");
177
                this.addSQLObject(this.checkSept, "SEPTEMBRE");
178
                this.addSQLObject(this.checkOct, "OCTOBRE");
179
                this.addSQLObject(this.checkNov, "NOVEMBRE");
180
                this.addSQLObject(this.checkDec, "DECEMBRE");
181
            }
182
 
183
            protected SQLRowValues createDefaults() {
184
                SQLRowValues rowVals = new SQLRowValues(PeriodeValiditeSQLElement.this.getTable());
185
 
186
                rowVals.put("JANVIER", Boolean.TRUE);
187
                rowVals.put("FEVRIER", Boolean.TRUE);
188
                rowVals.put("MARS", Boolean.TRUE);
189
                rowVals.put("AVRIL", Boolean.TRUE);
190
                rowVals.put("MAI", Boolean.TRUE);
191
                rowVals.put("JUIN", Boolean.TRUE);
192
                rowVals.put("JUILLET", Boolean.TRUE);
193
                rowVals.put("AOUT", Boolean.TRUE);
194
                rowVals.put("SEPTEMBRE", Boolean.TRUE);
195
                rowVals.put("OCTOBRE", Boolean.TRUE);
196
                rowVals.put("NOVEMBRE", Boolean.TRUE);
197
                rowVals.put("DECEMBRE", Boolean.TRUE);
198
                return rowVals;
199
            }
200
        };
201
    }
57 ilm 202
 
203
    @Override
204
    protected String createCode() {
205
        return "humanresources.payroll.validity";
206
    }
18 ilm 207
}