OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 Rev 174
Line 13... Line 13...
13
 
13
 
14
 package org.openconcerto.erp.core.humanresources.payroll.element;
14
 package org.openconcerto.erp.core.humanresources.payroll.element;
15
 
15
 
16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
17
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
17
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
-
 
18
import org.openconcerto.erp.core.customerrelationship.customer.element.ContactItemTable;
18
import org.openconcerto.erp.core.edm.AttachmentAction;
19
import org.openconcerto.erp.core.edm.AttachmentAction;
19
import org.openconcerto.sql.element.BaseSQLComponent;
20
import org.openconcerto.sql.element.BaseSQLComponent;
20
import org.openconcerto.sql.element.ElementSQLObject;
21
import org.openconcerto.sql.element.ElementSQLObject;
21
import org.openconcerto.sql.element.SQLComponent;
22
import org.openconcerto.sql.element.SQLComponent;
22
import org.openconcerto.sql.element.SQLElement;
23
import org.openconcerto.sql.element.SQLElement;
23
import org.openconcerto.sql.model.SQLRow;
24
import org.openconcerto.sql.model.SQLRow;
24
import org.openconcerto.sql.model.SQLRowAccessor;
25
import org.openconcerto.sql.model.SQLRowAccessor;
25
import org.openconcerto.sql.model.SQLRowValues;
26
import org.openconcerto.sql.model.SQLRowValues;
26
import org.openconcerto.sql.model.SQLSelect;
27
import org.openconcerto.sql.model.SQLSelect;
27
import org.openconcerto.sql.model.SQLTable;
28
import org.openconcerto.sql.model.SQLTable;
-
 
29
import org.openconcerto.sql.model.UndefinedRowValuesCache;
28
import org.openconcerto.sql.model.Where;
30
import org.openconcerto.sql.model.Where;
29
import org.openconcerto.sql.sqlobject.ElementComboBox;
31
import org.openconcerto.sql.sqlobject.ElementComboBox;
30
import org.openconcerto.sql.view.EditFrame;
32
import org.openconcerto.sql.view.EditFrame;
31
import org.openconcerto.sql.view.EditPanelListener;
-
 
32
import org.openconcerto.sql.view.EditPanel.EditMode;
33
import org.openconcerto.sql.view.EditPanel.EditMode;
-
 
34
import org.openconcerto.sql.view.EditPanelListener;
33
import org.openconcerto.sql.view.list.IListe;
35
import org.openconcerto.sql.view.list.IListe;
34
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
36
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
35
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
37
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
36
import org.openconcerto.ui.DefaultGridBagConstraints;
38
import org.openconcerto.ui.DefaultGridBagConstraints;
-
 
39
import org.openconcerto.ui.FormLayouter;
37
import org.openconcerto.ui.FrameUtil;
40
import org.openconcerto.ui.FrameUtil;
38
import org.openconcerto.ui.warning.JLabelWarning;
41
import org.openconcerto.ui.warning.JLabelWarning;
39
import org.openconcerto.utils.checks.ValidState;
42
import org.openconcerto.utils.checks.ValidState;
40
import org.openconcerto.utils.text.SimpleDocumentListener;
43
import org.openconcerto.utils.text.SimpleDocumentListener;
41
 
44
 
Line 44... Line 47...
44
import java.awt.event.ActionEvent;
47
import java.awt.event.ActionEvent;
45
import java.sql.SQLException;
48
import java.sql.SQLException;
46
import java.util.ArrayList;
49
import java.util.ArrayList;
47
import java.util.Date;
50
import java.util.Date;
48
import java.util.List;
51
import java.util.List;
-
 
52
import java.util.Map;
49
 
53
 
50
import javax.swing.AbstractAction;
54
import javax.swing.AbstractAction;
51
import javax.swing.BorderFactory;
55
import javax.swing.BorderFactory;
-
 
56
import javax.swing.JComponent;
52
import javax.swing.JLabel;
57
import javax.swing.JLabel;
53
import javax.swing.JOptionPane;
58
import javax.swing.JOptionPane;
54
import javax.swing.JPanel;
59
import javax.swing.JPanel;
55
import javax.swing.JScrollPane;
60
import javax.swing.JScrollPane;
56
import javax.swing.JTabbedPane;
61
import javax.swing.JTabbedPane;
Line 92... Line 97...
92
                    @Override
97
                    @Override
93
                    public void inserted(int id) {
98
                    public void inserted(int id) {
94
                        try {
99
                        try {
95
                            rowInfosAncien.createEmptyUpdateRow().put("ID_SALARIE", rowSelected.getID()).commit();
100
                            rowInfosAncien.createEmptyUpdateRow().put("ID_SALARIE", rowSelected.getID()).commit();
96
                            rowSelected.createEmptyUpdateRow().put("ID_INFOS_SALARIE_PAYE", id).commit();
101
                            rowSelected.createEmptyUpdateRow().put("ID_INFOS_SALARIE_PAYE", id).commit();
-
 
102
                            infosPayeElement.getTable().getRow(id).createEmptyUpdateRow().put("ID_SALARIE", rowSelected.getID()).commit();
97
                        } catch (SQLException e) {
103
                        } catch (SQLException e) {
98
                            e.printStackTrace();
104
                            e.printStackTrace();
99
                        }
105
                        }
100
                    }
106
                    }
101
 
107
 
Line 139... Line 145...
139
     */
145
     */
140
    public SQLComponent createComponent() {
146
    public SQLComponent createComponent() {
141
        return new BaseSQLComponent(this) {
147
        return new BaseSQLComponent(this) {
142
            private final JLabel warningCodeSalLabel = new JLabelWarning();
148
            private final JLabel warningCodeSalLabel = new JLabelWarning();
143
            private final JTextField textCode = new JTextField();
149
            private final JTextField textCode = new JTextField();
144
 
-
 
-
 
150
            ContactItemTable tableContact = new ContactItemTable(UndefinedRowValuesCache.getInstance().getDefaultRowValues(getTable().getTable("CONTACT_SALARIE")));
145
            private JTabbedPane tabbedPane;
151
            private JTabbedPane tabbedPane;
146
            private final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO");
152
            private final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO");
147
 
153
 
148
            public void addViews() {
154
            public void addViews() {
149
 
155
 
Line 204... Line 210...
204
                    public void update(DocumentEvent e) {
210
                    public void update(DocumentEvent e) {
205
                        checkCode();
211
                        checkCode();
206
                    }
212
                    }
207
                });
213
                });
208
 
214
 
-
 
215
                // User
-
 
216
                final JLabel labelUser = new JLabel(getLabelFor("ID_USER_COMMON"));
-
 
217
                final ElementComboBox comboUser = new ElementComboBox(false, 50);
-
 
218
                c.gridx = 0;
-
 
219
                c.gridy++;
-
 
220
                this.add(labelUser, c);
-
 
221
                c.gridx++;
-
 
222
                c.weightx = 0;
-
 
223
                c.fill = GridBagConstraints.NONE;
-
 
224
                this.add(comboUser, c);
-
 
225
                this.addView(comboUser, "ID_USER_COMMON");
-
 
226
 
209
                /***********************************************************************************
227
                /***********************************************************************************
210
                 * TABBED PANE
228
                 * TABBED PANE
211
                 **********************************************************************************/
229
                 **********************************************************************************/
212
                this.tabbedPane = new JTabbedPane();
230
                this.tabbedPane = new JTabbedPane();
213
 
231
 
Line 216... Line 234...
216
                ElementSQLObject eltEtatCivil = (ElementSQLObject) this.getView("ID_ETAT_CIVIL");
234
                ElementSQLObject eltEtatCivil = (ElementSQLObject) this.getView("ID_ETAT_CIVIL");
217
                JScrollPane scrollEtatCivil = new JScrollPane(eltEtatCivil);
235
                JScrollPane scrollEtatCivil = new JScrollPane(eltEtatCivil);
218
                scrollEtatCivil.setBorder(null);
236
                scrollEtatCivil.setBorder(null);
219
                this.tabbedPane.add("Etat Civil", scrollEtatCivil);
237
                this.tabbedPane.add("Etat Civil", scrollEtatCivil);
220
 
238
 
-
 
239
                // Contact
-
 
240
                JPanel panelContact = new JPanel(new GridBagLayout());
-
 
241
                DefaultGridBagConstraints cContact = new DefaultGridBagConstraints();
-
 
242
                cContact.weighty = 1;
-
 
243
                cContact.weightx = 1;
-
 
244
                cContact.fill = GridBagConstraints.BOTH;
-
 
245
 
-
 
246
                panelContact.add(tableContact, cContact);
-
 
247
                JScrollPane scrollContact = new JScrollPane(panelContact);
-
 
248
                scrollContact.setBorder(null);
-
 
249
                this.tabbedPane.add("Contacts", scrollContact);
-
 
250
 
221
                // Règlement de la paye
251
                // Règlement de la paye
222
                this.addView("ID_REGLEMENT_PAYE", REQ + ";" + DEC + ";" + SEP);
252
                this.addView("ID_REGLEMENT_PAYE", REQ + ";" + DEC + ";" + SEP);
223
                ElementSQLObject eltReglPaye = (ElementSQLObject) this.getView("ID_REGLEMENT_PAYE");
253
                ElementSQLObject eltReglPaye = (ElementSQLObject) this.getView("ID_REGLEMENT_PAYE");
224
                JScrollPane scrollReglPaye = new JScrollPane(eltReglPaye);
254
                JScrollPane scrollReglPaye = new JScrollPane(eltReglPaye);
225
                scrollReglPaye.setBorder(null);
255
                scrollReglPaye.setBorder(null);
Line 284... Line 314...
284
                panelAllCumul.add(panelVarSalarie, cPanel);
314
                panelAllCumul.add(panelVarSalarie, cPanel);
285
 
315
 
286
                this.tabbedPane.add("Cumuls et variables de la période", new JScrollPane(panelAllCumul));
316
                this.tabbedPane.add("Cumuls et variables de la période", new JScrollPane(panelAllCumul));
287
                // this.tabbedPane.setEnabledAt(this.tabbedPane.getTabCount() - 1, false);
317
                // this.tabbedPane.setEnabledAt(this.tabbedPane.getTabCount() - 1, false);
288
 
318
 
-
 
319
                Map<String, JComponent> additionalFields = getElement().getAdditionalFields();
-
 
320
                if (additionalFields != null && additionalFields.size() > 0) {
-
 
321
                    // Champ Module
-
 
322
                    c.gridx = 0;
-
 
323
                    c.gridy++;
-
 
324
                    c.gridwidth = GridBagConstraints.REMAINDER;
-
 
325
                    final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
-
 
326
                    this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
-
 
327
                    this.tabbedPane.add("Compléments", new JScrollPane(addP));
-
 
328
                }
-
 
329
 
289
                c.gridy++;
330
                c.gridy++;
290
                c.gridx = 0;
331
                c.gridx = 0;
291
                c.weighty = 1;
332
                c.weighty = 1;
292
                c.gridwidth = GridBagConstraints.REMAINDER;
333
                c.gridwidth = GridBagConstraints.REMAINDER;
293
                c.fill = GridBagConstraints.BOTH;
334
                c.fill = GridBagConstraints.BOTH;
Line 333... Line 374...
333
                 * if (r.getID() > 1) { this.tabbedPane.setEnabledAt(this.tabbedPane.getTabCount() -
374
                 * if (r.getID() > 1) { this.tabbedPane.setEnabledAt(this.tabbedPane.getTabCount() -
334
                 * 1, true); this.tabbedPane.setEnabledAt(this.tabbedPane.getTabCount() - 2, true);
375
                 * 1, true); this.tabbedPane.setEnabledAt(this.tabbedPane.getTabCount() - 2, true);
335
                 * }
376
                 * }
336
                 */
377
                 */
337
                checkCode();
378
                checkCode();
-
 
379
                if (r != null) {
-
 
380
                    this.tableContact.insertFrom("ID_SALARIE", r.asRowValues());
-
 
381
                }
338
            }
382
            }
339
 
383
 
340
            public void update() {
384
            public void update() {
341
 
-
 
342
                super.update();
385
                super.update();
343
 
386
 
344
                SQLTable tableFichePaye = getTable().getBase().getTable("FICHE_PAYE");
387
                SQLTable tableFichePaye = getTable().getBase().getTable("FICHE_PAYE");
345
                SQLRowValues rowVals = new SQLRowValues(tableFichePaye);
388
                SQLRowValues rowVals = new SQLRowValues(tableFichePaye);
346
                rowVals.put("ID_SALARIE", getSelectedID());
389
                rowVals.put("ID_SALARIE",
-
 
390
 
-
 
391
                        getSelectedID());
347
                SQLRow row = getTable().getRow(getSelectedID());
392
                SQLRow row = getTable().getRow(getSelectedID());
348
                try {
393
                try {
349
                    rowVals.update(row.getInt("ID_FICHE_PAYE"));
394
                    rowVals.update(row.getInt("ID_FICHE_PAYE"));
350
                } catch (SQLException e) {
395
                } catch (SQLException e) {
351
                    e.printStackTrace();
396
                    e.printStackTrace();
352
                }
397
                }
-
 
398
                this.tableContact.updateField("ID_SALARIE", getSelectedID());
353
            }
399
            }
354
 
400
 
355
            public int insert(SQLRow order) {
401
            public int insert(SQLRow order) {
356
                int id = super.insert(order);
402
                int id = super.insert(order);
357
                SQLTable tableFichePaye = getTable().getBase().getTable("FICHE_PAYE");
403
                SQLTable tableFichePaye = getTable().getBase().getTable("FICHE_PAYE");
Line 385... Line 431...
385
                    } catch (SQLException e) {
431
                    } catch (SQLException e) {
386
 
432
 
387
                        e.printStackTrace();
433
                        e.printStackTrace();
388
                    }
434
                    }
389
                }
435
                }
390
 
-
 
-
 
436
                this.tableContact.updateField("ID_SALARIE", id);
391
                return id;
437
                return id;
392
            }
438
            }
-
 
439
 
393
        };
440
        };
394
    }
441
    }
395
 
442
 
396
    @Override
443
    @Override
397
    protected String createCode() {
444
    protected String createCode() {