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 177
Line 19... Line 19...
19
import org.openconcerto.erp.core.common.ui.PanelFrame;
19
import org.openconcerto.erp.core.common.ui.PanelFrame;
20
import org.openconcerto.erp.core.humanresources.payroll.component.VariableRowTreeNode;
20
import org.openconcerto.erp.core.humanresources.payroll.component.VariableRowTreeNode;
21
import org.openconcerto.erp.core.humanresources.payroll.report.FichePayeSheetXML;
21
import org.openconcerto.erp.core.humanresources.payroll.report.FichePayeSheetXML;
22
import org.openconcerto.erp.core.humanresources.payroll.ui.FichePayeRenderer;
22
import org.openconcerto.erp.core.humanresources.payroll.ui.FichePayeRenderer;
23
import org.openconcerto.erp.core.humanresources.payroll.ui.PanelCumulsPaye;
23
import org.openconcerto.erp.core.humanresources.payroll.ui.PanelCumulsPaye;
24
import org.openconcerto.erp.generationEcritures.GenerationMvtFichePaye;
-
 
25
import org.openconcerto.erp.model.FichePayeModel;
24
import org.openconcerto.erp.model.FichePayeModel;
26
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
25
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
27
import org.openconcerto.erp.model.RubriquePayeTree;
26
import org.openconcerto.erp.model.RubriquePayeTree;
28
import org.openconcerto.sql.Configuration;
27
import org.openconcerto.sql.Configuration;
29
import org.openconcerto.sql.element.BaseSQLComponent;
28
import org.openconcerto.sql.element.BaseSQLComponent;
Line 47... Line 46...
47
import org.openconcerto.sql.view.list.IListe;
46
import org.openconcerto.sql.view.list.IListe;
48
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
47
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
49
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
48
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
50
import org.openconcerto.ui.DefaultGridBagConstraints;
49
import org.openconcerto.ui.DefaultGridBagConstraints;
51
import org.openconcerto.ui.JDate;
50
import org.openconcerto.ui.JDate;
52
import org.openconcerto.ui.component.ITextArea;
-
 
53
import org.openconcerto.ui.component.InteractionMode;
51
import org.openconcerto.ui.component.InteractionMode;
54
import org.openconcerto.utils.ExceptionHandler;
52
import org.openconcerto.utils.ExceptionHandler;
-
 
53
import org.openconcerto.utils.ListMap;
55
 
54
 
56
import java.awt.GridBagConstraints;
55
import java.awt.GridBagConstraints;
57
import java.awt.GridBagLayout;
56
import java.awt.GridBagLayout;
58
import java.awt.event.ActionEvent;
57
import java.awt.event.ActionEvent;
59
import java.awt.event.ActionListener;
58
import java.awt.event.ActionListener;
Line 100... Line 99...
100
                p.setVisible(true);
99
                p.setVisible(true);
101
            }
100
            }
102
        }, true);
101
        }, true);
103
        actionCumuls.setPredicate(IListeEvent.getSingleSelectionPredicate());
102
        actionCumuls.setPredicate(IListeEvent.getSingleSelectionPredicate());
104
        getRowActions().add(actionCumuls);
103
        getRowActions().add(actionCumuls);
-
 
104
        PredicateRowAction genererNonSimplifie = new PredicateRowAction(new AbstractAction("Créer le bulletin détaillé") {
105
 
105
 
-
 
106
            @Override
-
 
107
            public void actionPerformed(ActionEvent e) {
-
 
108
 
-
 
109
                SQLRow row = IListe.get(e).getSelectedRow().asRow();
-
 
110
                FichePayeSheetXML sheet = new FichePayeSheetXML(row, false);
-
 
111
                try {
-
 
112
                    sheet.createDocument();
-
 
113
                    sheet.showPrintAndExport(true, false, true);
-
 
114
                } catch (Exception e1) {
-
 
115
                    ExceptionHandler.handle("Erreur lors de la création du document.", e1);
-
 
116
                }
-
 
117
            }
-
 
118
        }, false);
-
 
119
        genererNonSimplifie.setPredicate(IListeEvent.getSingleSelectionPredicate());
-
 
120
        getRowActions().add(genererNonSimplifie);
-
 
121
    }
-
 
122
 
-
 
123
    @Override
-
 
124
    public ListMap<String, String> getShowAs() {
-
 
125
        final ListMap<String, String> map = new ListMap<>();
-
 
126
        map.put("ID_SALARIE", Arrays.asList("CODE", "NOM", "PRENOM", "ID_REGLEMENT_PAYE"));
-
 
127
        return map;
106
    }
128
    }
107
 
129
 
108
    protected List<String> getListFields() {
130
    protected List<String> getListFields() {
109
        final List<String> l = new ArrayList<String>();
131
        final List<String> l = new ArrayList<String>();
110
        l.add("ID_SALARIE");
132
        l.add("ID_SALARIE");
Line 153... Line 175...
153
            private int dernMois, dernAnnee;
175
            private int dernMois, dernAnnee;
154
            private JTextField textAnnee;
176
            private JTextField textAnnee;
155
            JDate dateDu, dateAu;
177
            JDate dateDu, dateAu;
156
            private JScrollPane paneTreeLeft;
178
            private JScrollPane paneTreeLeft;
157
            private JPanel pDate;
179
            private JPanel pDate;
158
            private JButton buttonValider, buttonGenCompta;
-
 
159
 
180
 
160
            public void addViews() {
181
            public void addViews() {
161
 
182
 
162
                this.dernMois = 0;
183
                this.dernMois = 0;
163
                this.dernAnnee = 0;
184
                this.dernAnnee = 0;
Line 185... Line 206...
185
                c.weightx = 1;
206
                c.weightx = 1;
186
                c.weighty = 0;
207
                c.weighty = 0;
187
                c.gridheight = 1;
208
                c.gridheight = 1;
188
                c.gridwidth = 2;
209
                c.gridwidth = 2;
189
                this.selSalCombo = new ElementComboBox();
210
                this.selSalCombo = new ElementComboBox();
190
                // c.gridx++;
-
 
-
 
211
 
191
                panelRight.add(this.selSalCombo, c);
212
                panelRight.add(this.selSalCombo, c);
192
 
213
 
193
                // Mois
214
                // Mois
194
 
215
 
195
                JLabel labelMois = new JLabel("Fiche de paye du mois de");
216
                JLabel labelMois = new JLabel("Fiche de paye du mois de");
Line 197... Line 218...
197
                JLabel labelDu = new JLabel("Du");
218
                JLabel labelDu = new JLabel("Du");
198
                JLabel labelAu = new JLabel("Au");
219
                JLabel labelAu = new JLabel("Au");
199
                this.dateDu = new JDate();
220
                this.dateDu = new JDate();
200
                this.dateAu = new JDate();
221
                this.dateAu = new JDate();
201
 
222
 
202
                // JTextField textMois = new JTextField();
-
 
203
                JLabel labelAnnee = new JLabel("Année");
223
                JLabel labelAnnee = new JLabel("Année");
204
                this.textAnnee = new JTextField();
224
                this.textAnnee = new JTextField();
205
                {
225
                {
206
                    this.pDate = new JPanel(new GridBagLayout());
226
                    this.pDate = new JPanel(new GridBagLayout());
207
                    GridBagConstraints cDate = new DefaultGridBagConstraints();
227
                    GridBagConstraints cDate = new DefaultGridBagConstraints();
Line 223... Line 243...
223
                    this.pDate.add(labelAu, cDate);
243
                    this.pDate.add(labelAu, cDate);
224
                    cDate.weightx = 0;
244
                    cDate.weightx = 0;
225
                    this.pDate.add(this.dateAu, cDate);
245
                    this.pDate.add(this.dateAu, cDate);
226
 
246
 
227
                    c.gridy++;
247
                    c.gridy++;
228
                    // c.gridx++;
-
 
229
                    c.fill = GridBagConstraints.HORIZONTAL;
248
                    c.fill = GridBagConstraints.HORIZONTAL;
230
                    c.weightx = 1;
249
                    c.weightx = 1;
231
                    c.weighty = 0;
250
                    c.weighty = 0;
232
                    c.gridheight = 1;
251
                    c.gridheight = 1;
233
                    c.gridwidth = 2;
252
                    c.gridwidth = 2;
234
                    panelRight.add(this.pDate, c);
253
                    panelRight.add(this.pDate, c);
235
                }
254
                }
236
                // c.gridx += 2;
-
 
237
                // c.weightx = 1;
-
 
238
                // c.gridwidth = 1;
-
 
239
                // c.fill = GridBagConstraints.HORIZONTAL;
-
 
240
                // panelRight.add(new JPanel(), c);
-
 
241
 
255
 
242
                // Action Button
256
                // Action Button
243
 
257
 
244
                JPanel pButtons = new JPanel(new GridBagLayout());
258
                JPanel pButtons = new JPanel(new GridBagLayout());
245
                pButtons.setOpaque(false);
259
                pButtons.setOpaque(false);
Line 301... Line 315...
301
                c.weightx = 0;
315
                c.weightx = 0;
302
                panelRight.add(buttonImportProfil, c);
316
                panelRight.add(buttonImportProfil, c);
303
 
317
 
304
                // Total Periode
318
                // Total Periode
305
                JPanel panelTotal = new JPanel(new GridBagLayout());
319
                JPanel panelTotal = new JPanel(new GridBagLayout());
306
                panelTotal.setBorder(BorderFactory.createTitledBorder("Total période"));
320
                panelTotal.setBorder(BorderFactory.createTitledBorder("Totaux sur la période"));
307
 
321
 
308
                GridBagConstraints cPanel = new DefaultGridBagConstraints();
322
                GridBagConstraints cPanel = new DefaultGridBagConstraints();
309
 
323
 
310
                JLabel labelInfosConges = new JLabel(getLabelFor("DETAILS_CONGES"));
324
                JLabel labelInfosConges = new JLabel(getLabelFor("DETAILS_CONGES"));
311
                panelTotal.add(labelInfosConges, cPanel);
325
                panelTotal.add(labelInfosConges, cPanel);
312
                ITextArea textConges = new ITextArea();
326
                JTextField textConges = new JTextField();
313
                cPanel.gridx++;
327
                cPanel.gridx++;
314
                cPanel.weightx = 1;
328
                cPanel.weightx = 1;
315
                cPanel.gridwidth = GridBagConstraints.REMAINDER;
329
                cPanel.gridwidth = 5;
316
                panelTotal.add(textConges, cPanel);
330
                panelTotal.add(textConges, cPanel);
317
                addView(textConges, "DETAILS_CONGES");
331
                addView(textConges, "DETAILS_CONGES");
318
 
332
 
319
                // Salaire brut
333
                // Salaire brut
320
                cPanel.weightx = 0;
334
                cPanel.weightx = 0;
Line 323... Line 337...
323
                cPanel.gridx = 0;
337
                cPanel.gridx = 0;
324
                JLabel labelBrut = new JLabel(getLabelFor("SAL_BRUT"));
338
                JLabel labelBrut = new JLabel(getLabelFor("SAL_BRUT"));
325
                panelTotal.add(labelBrut, cPanel);
339
                panelTotal.add(labelBrut, cPanel);
326
                JTextField textSalBrut = new JTextField(10);
340
                JTextField textSalBrut = new JTextField(10);
327
                cPanel.gridx++;
341
                cPanel.gridx++;
328
                cPanel.weightx = 0;
342
                cPanel.weightx = 1;
329
                panelTotal.add(textSalBrut, cPanel);
343
                panelTotal.add(textSalBrut, cPanel);
330
                textSalBrut.setEditable(false);
344
                textSalBrut.setEditable(false);
331
                textSalBrut.setEnabled(false);
345
                textSalBrut.setEnabled(false);
332
 
346
 
333
                // acompte
347
                // acompte
334
                cPanel.gridx++;
348
                cPanel.gridx++;
-
 
349
                cPanel.weightx = 0;
335
                JLabel labelAcompte = new JLabel(getLabelFor("ACOMPTE"));
350
                JLabel labelAcompte = new JLabel(getLabelFor("ACOMPTE"));
336
                panelTotal.add(labelAcompte, cPanel);
351
                panelTotal.add(labelAcompte, cPanel);
337
                JTextField textAcompte = new JTextField(10);
352
                JTextField textAcompte = new JTextField(10);
338
                cPanel.gridx++;
353
                cPanel.gridx++;
-
 
354
                cPanel.weightx = 1;
339
                panelTotal.add(textAcompte, cPanel);
355
                panelTotal.add(textAcompte, cPanel);
340
                // textAcompte.setEditable(false);
356
                // textAcompte.setEditable(false);
341
                // textAcompte.setEnabled(false);
357
                // textAcompte.setEnabled(false);
342
 
358
 
343
                // Conges Acquis
359
                // Conges Acquis
344
                cPanel.gridx++;
360
                cPanel.gridx++;
-
 
361
                cPanel.weightx = 0;
345
                JLabel labelCongesAcquis = new JLabel(getLabelFor("CONGES_ACQUIS"));
362
                JLabel labelCongesAcquis = new JLabel(getLabelFor("CONGES_ACQUIS"));
346
                panelTotal.add(labelCongesAcquis, cPanel);
363
                panelTotal.add(labelCongesAcquis, cPanel);
347
                JTextField textCongesAcquis = new JTextField(10);
364
                JTextField textCongesAcquis = new JTextField(10);
348
                cPanel.gridx++;
365
                cPanel.gridx++;
-
 
366
                cPanel.weightx = 1;
349
                panelTotal.add(textCongesAcquis, cPanel);
367
                panelTotal.add(textCongesAcquis, cPanel);
350
 
368
 
351
                // cotisation salariale
369
                // cotisation salariale
352
                cPanel.gridx = 0;
370
                cPanel.gridx = 0;
353
                cPanel.gridy++;
371
                cPanel.gridy++;
-
 
372
                cPanel.weightx = 0;
354
                JLabel labelCotSal = new JLabel(getLabelFor("COT_SAL"));
373
                JLabel labelCotSal = new JLabel(getLabelFor("COT_SAL"));
355
                panelTotal.add(labelCotSal, cPanel);
374
                panelTotal.add(labelCotSal, cPanel);
356
                JTextField textCotSal = new JTextField(10);
375
                JTextField textCotSal = new JTextField(10);
357
                cPanel.gridx++;
376
                cPanel.gridx++;
-
 
377
                cPanel.weightx = 1;
358
                panelTotal.add(textCotSal, cPanel);
378
                panelTotal.add(textCotSal, cPanel);
359
                textCotSal.setEditable(false);
379
                textCotSal.setEditable(false);
360
                textCotSal.setEnabled(false);
380
                textCotSal.setEnabled(false);
361
 
381
 
362
                // cotisation patronale
382
                // cotisation patronale
363
                cPanel.gridx++;
383
                cPanel.gridx++;
-
 
384
                cPanel.weightx = 0;
364
                JLabel labelCotPat = new JLabel(getLabelFor("COT_PAT"));
385
                JLabel labelCotPat = new JLabel(getLabelFor("COT_PAT"));
365
                panelTotal.add(labelCotPat, cPanel);
386
                panelTotal.add(labelCotPat, cPanel);
366
                JTextField textCotPat = new JTextField(10);
387
                JTextField textCotPat = new JTextField(10);
367
                cPanel.gridx++;
388
                cPanel.gridx++;
-
 
389
                cPanel.weightx = 1;
368
                panelTotal.add(textCotPat, cPanel);
390
                panelTotal.add(textCotPat, cPanel);
369
                textCotPat.setEditable(false);
391
                textCotPat.setEditable(false);
370
                textCotPat.setEnabled(false);
392
                textCotPat.setEnabled(false);
371
 
393
 
372
                JLabel labelCSG = new JLabel(getLabelFor("CSG"));
394
                JLabel labelCSG = new JLabel(getLabelFor("CSG"));
373
                cPanel.gridx++;
395
                cPanel.gridx++;
-
 
396
                cPanel.weightx = 0;
374
                panelTotal.add(labelCSG, cPanel);
397
                panelTotal.add(labelCSG, cPanel);
375
                JTextField textCSG = new JTextField(10);
398
                JTextField textCSG = new JTextField(10);
376
                cPanel.gridx++;
399
                cPanel.gridx++;
-
 
400
                cPanel.weightx = 1;
377
                panelTotal.add(textCSG, cPanel);
401
                panelTotal.add(textCSG, cPanel);
378
                textCSG.setEditable(false);
402
                textCSG.setEditable(false);
379
                textCSG.setEnabled(false);
403
                textCSG.setEnabled(false);
380
 
404
 
381
                // net imposable
405
                // net imposable
382
                cPanel.gridx = 0;
406
                cPanel.gridx = 0;
383
                cPanel.gridy++;
407
                cPanel.gridy++;
-
 
408
                cPanel.weightx = 0;
384
                JLabel labelNetImp = new JLabel(getLabelFor("NET_IMP"));
409
                JLabel labelNetImp = new JLabel(getLabelFor("NET_IMP"));
385
                panelTotal.add(labelNetImp, cPanel);
410
                panelTotal.add(labelNetImp, cPanel);
386
                JTextField textNetImp = new JTextField(10);
411
                JTextField textNetImp = new JTextField(10);
387
                cPanel.gridx++;
412
                cPanel.gridx++;
-
 
413
                cPanel.weightx = 1;
388
                panelTotal.add(textNetImp, cPanel);
414
                panelTotal.add(textNetImp, cPanel);
389
                textNetImp.setEditable(false);
415
                textNetImp.setEditable(false);
390
                textNetImp.setEnabled(false);
416
                textNetImp.setEnabled(false);
391
 
417
 
392
                cPanel.gridx++;
418
                cPanel.gridx++;
-
 
419
                cPanel.weightx = 0;
393
                JLabel labelNetAPayer = new JLabel(getLabelFor("NET_A_PAYER"));
420
                JLabel labelNetAPayer = new JLabel(getLabelFor("NET_A_PAYER"));
394
                panelTotal.add(labelNetAPayer, cPanel);
421
                panelTotal.add(labelNetAPayer, cPanel);
395
                JTextField textNetAPayer = new JTextField(10);
422
                JTextField textNetAPayer = new JTextField(10);
396
                cPanel.gridx++;
423
                cPanel.gridx++;
-
 
424
                cPanel.weightx = 1;
397
                panelTotal.add(textNetAPayer, cPanel);
425
                panelTotal.add(textNetAPayer, cPanel);
398
                textNetAPayer.setEditable(false);
426
                textNetAPayer.setEditable(false);
399
                textNetAPayer.setEnabled(false);
427
                textNetAPayer.setEnabled(false);
400
 
428
 
401
                cPanel.gridx++;
429
                cPanel.gridx++;
-
 
430
                cPanel.weightx = 0;
402
                JLabel labelCice = new JLabel(getLabelFor("CICE"));
431
                JLabel labelCice = new JLabel(getLabelFor("CICE"));
403
                panelTotal.add(labelCice, cPanel);
432
                panelTotal.add(labelCice, cPanel);
404
                JTextField textCice = new JTextField(10);
433
                JTextField textCice = new JTextField(10);
405
                cPanel.gridx++;
434
                cPanel.gridx++;
-
 
435
                cPanel.weightx = 1;
406
                panelTotal.add(textCice, cPanel);
436
                panelTotal.add(textCice, cPanel);
407
                textCice.setEditable(false);
437
                textCice.setEditable(false);
408
                textCice.setEnabled(false);
438
                textCice.setEnabled(false);
409
                this.addSQLObject(textCice, "CICE");
439
                this.addSQLObject(textCice, "CICE");
410
 
440
 
Line 416... Line 446...
416
                c.gridwidth = GridBagConstraints.REMAINDER;
446
                c.gridwidth = GridBagConstraints.REMAINDER;
417
                panelRight.add(panelTotal, c);
447
                panelRight.add(panelTotal, c);
418
 
448
 
419
                // Cumuls
449
                // Cumuls
420
 
450
 
421
                c.gridx = 1;
-
 
422
                c.gridy++;
-
 
423
                c.gridwidth = 1;
-
 
424
                c.fill = GridBagConstraints.NONE;
-
 
425
                this.buttonValider = new JButton("Valider");
-
 
426
                // panelRight.add(buttonValider, c);
-
 
427
 
-
 
428
                c.gridx++;
-
 
429
                c.gridwidth = 1;
-
 
430
                this.buttonGenCompta = new JButton("Generer la comptabilité");
-
 
431
                // panelRight.add(buttonGenCompta, c);
-
 
432
 
-
 
433
                GridBagConstraints cGlobal = new DefaultGridBagConstraints();
451
                GridBagConstraints cGlobal = new DefaultGridBagConstraints();
434
                cGlobal.gridx = 0;
452
                cGlobal.gridx = 0;
435
                cGlobal.gridy = 0;
453
                cGlobal.gridy = 0;
436
                cGlobal.gridwidth = 1;
454
                cGlobal.gridwidth = 1;
437
                cGlobal.gridheight = 1;
455
                cGlobal.gridheight = 1;
438
                cGlobal.fill = GridBagConstraints.BOTH;
456
                cGlobal.fill = GridBagConstraints.BOTH;
439
                cGlobal.weightx = 1;
457
                cGlobal.weightx = 1;
440
                cGlobal.weighty = 1;
458
                cGlobal.weighty = 1;
441
                this.add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.paneTreeLeft, panelRight), cGlobal);
459
                this.add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.paneTreeLeft, panelRight), cGlobal);
442
 
460
 
443
                // Listeners
-
 
444
                this.buttonGenCompta.addActionListener(new ActionListener() {
-
 
445
                    public void actionPerformed(ActionEvent e) {
-
 
446
                        try {
-
 
447
                            int[] i = new int[1];
-
 
448
                            i[0] = getSelectedID();
-
 
449
 
-
 
450
                            SQLRow rowMois = getTable().getBase().getTable("MOIS").getRow(selMois.getSelectedId());
-
 
451
 
-
 
452
                            new GenerationMvtFichePaye(i, rowMois.getString("NOM"), textAnnee.getText());
-
 
453
                        } catch (Exception ex) {
-
 
454
                            ExceptionHandler.handle("Erreur de génération des mouvements", ex);
-
 
455
                        }
-
 
456
                    }
-
 
457
                });
-
 
458
 
-
 
459
                this.buttonValider.addActionListener(new ActionListener() {
-
 
460
                    public void actionPerformed(ActionEvent e) {
-
 
461
                        try {
-
 
462
                            validationFiche();
-
 
463
                        } catch (SQLException e1) {
-
 
464
                            ExceptionHandler.handle("Error while updating pay slip", e1);
-
 
465
                        }
-
 
466
                    }
-
 
467
                });
-
 
468
 
-
 
469
                buttonUp.addActionListener(new ActionListener() {
461
                buttonUp.addActionListener(new ActionListener() {
470
 
462
 
471
                    public void actionPerformed(ActionEvent e) {
463
                    public void actionPerformed(ActionEvent e) {
472
                        int newRowSelected = model.upRow(table.getSelectedRow());
464
                        int newRowSelected = model.upRow(table.getSelectedRow());
473
                        if (newRowSelected >= 0) {
465
                        if (newRowSelected >= 0) {
Line 563... Line 555...
563
                                cal.setTime(d);
555
                                cal.setTime(d);
564
                                if (selMois.getSelectedId() > 1 && cal.get(Calendar.MONTH) + 2 != selMois.getSelectedId()) {
556
                                if (selMois.getSelectedId() > 1 && cal.get(Calendar.MONTH) + 2 != selMois.getSelectedId()) {
565
 
557
 
566
                                    cal.set(Calendar.DAY_OF_MONTH, 1);
558
                                    cal.set(Calendar.DAY_OF_MONTH, 1);
567
                                    cal.set(Calendar.MONTH, selMois.getSelectedId() - 2);
559
                                    cal.set(Calendar.MONTH, selMois.getSelectedId() - 2);
568
                                    System.err.println("Du " + cal.getTime());
-
 
569
                                    dateDu.setValue(cal.getTime());
560
                                    dateDu.setValue(cal.getTime());
570
                                }
561
                                }
571
                                fireValidChange();
562
                                fireValidChange();
572
                            }
563
                            }
573
                        }
564
                        }
Line 589... Line 580...
589
 
580
 
590
                                    // Calendar.getInstance().set(Calendar.DAY_OF_MONTH, maxDay);
581
                                    // Calendar.getInstance().set(Calendar.DAY_OF_MONTH, maxDay);
591
                                    cal.set(Calendar.DAY_OF_MONTH, 1);
582
                                    cal.set(Calendar.DAY_OF_MONTH, 1);
592
                                    cal.set(Calendar.MONTH, selMois.getSelectedId() - 2);
583
                                    cal.set(Calendar.MONTH, selMois.getSelectedId() - 2);
593
                                    cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
584
                                    cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
594
                                    System.err.println("Au " + cal.getTime());
-
 
595
                                    dateAu.setValue(cal.getTime());
585
                                    dateAu.setValue(cal.getTime());
596
                                }
586
                                }
597
                                fireValidChange();
587
                                fireValidChange();
598
                            }
588
                            }
599
                        }
589
                        }
Line 678... Line 668...
678
                    this.dernMois = rowSal.getInt("DERNIER_MOIS");
668
                    this.dernMois = rowSal.getInt("DERNIER_MOIS");
679
                    this.dernAnnee = rowSal.getInt("DERNIERE_ANNEE");
669
                    this.dernAnnee = rowSal.getInt("DERNIERE_ANNEE");
680
 
670
 
681
                    this.selSalCombo.setVisible(((Boolean) r.getObject("VALIDE")).booleanValue());
671
                    this.selSalCombo.setVisible(((Boolean) r.getObject("VALIDE")).booleanValue());
682
                    this.paneTreeLeft.setVisible(!((Boolean) r.getObject("VALIDE")).booleanValue());
672
                    this.paneTreeLeft.setVisible(!((Boolean) r.getObject("VALIDE")).booleanValue());
683
                    this.buttonValider.setVisible(!((Boolean) r.getObject("VALIDE")).booleanValue());
-
 
684
                    setpDateEnabled(!((Boolean) r.getObject("VALIDE")).booleanValue());
673
                    setpDateEnabled(!((Boolean) r.getObject("VALIDE")).booleanValue());
685
                }
674
                }
686
                this.selSalCombo.setInteractionMode(InteractionMode.DISABLED);
675
                this.selSalCombo.setInteractionMode(InteractionMode.DISABLED);
687
                this.selSalCombo.setEnabled(false);
676
                this.selSalCombo.setEnabled(false);
688
                this.selMois.setButtonsVisible(false);
677
                this.selMois.setButtonsVisible(false);
689
                this.selSalCombo.setButtonsVisible(false);
678
                this.selSalCombo.setButtonsVisible(false);
690
            }
679
            }
691
 
680
 
692
            private void setpDateEnabled(boolean b) {
681
            private void setpDateEnabled(boolean b) {
693
 
-
 
694
                // System.err.println("Set date enable --> " + b);
-
 
695
 
-
 
696
                this.selMois.setInteractionMode((b) ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
682
                this.selMois.setInteractionMode((b) ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
697
                // this.selMois.setEnabled(b);
-
 
698
 
-
 
699
                this.textAnnee.setEditable(b);
683
                this.textAnnee.setEditable(b);
700
                this.textAnnee.setEnabled(b);
684
                this.textAnnee.setEnabled(b);
701
 
-
 
702
                this.dateDu.setInteractionMode((b) ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
685
                this.dateDu.setInteractionMode((b) ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
703
                this.dateAu.setInteractionMode((b) ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
686
                this.dateAu.setInteractionMode((b) ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
704
            }
687
            }
705
 
688
 
706
            private void validationFiche() throws SQLException {
-
 
707
 
-
 
708
                this.update();
-
 
709
                FichePayeSQLElement.validationFiche(this.getSelectedID());
-
 
710
            }
-
 
711
 
-
 
712
            protected SQLRowValues createDefaults() {
689
            protected SQLRowValues createDefaults() {
713
 
-
 
714
                System.err.println("**********Set Defaults on FichePaye.date");
-
 
715
                SQLRowValues rowVals = new SQLRowValues(getTable());
690
                final SQLRowValues rowVals = new SQLRowValues(getTable());
716
                Calendar cal = Calendar.getInstance();
691
                final Calendar cal = Calendar.getInstance();
717
                rowVals.put("ID_MOIS", cal.get(Calendar.MONTH) + 2);
692
                rowVals.put("ID_MOIS", cal.get(Calendar.MONTH) + 2);
718
                rowVals.put("ANNEE", cal.get(Calendar.YEAR));
693
                rowVals.put("ANNEE", cal.get(Calendar.YEAR));
719
 
694
 
720
                cal.set(Calendar.DAY_OF_MONTH, 1);
695
                cal.set(Calendar.DAY_OF_MONTH, 1);
721
                rowVals.put("DU", new java.sql.Date(cal.getTime().getTime()));
696
                rowVals.put("DU", new java.sql.Date(cal.getTime().getTime()));
Line 737... Line 712...
737
        for (SQLRow row : trees.getRows()) {
712
        for (SQLRow row : trees.getRows()) {
738
            if (row != null && row.getID() > 1) {
713
            if (row != null && row.getID() > 1) {
739
                if (JOptionPane.showConfirmDialog(null, "Soustraire les cumuls de cette fiche à celle en cours?", "Suppression d'une fiche de paye",
714
                if (JOptionPane.showConfirmDialog(null, "Soustraire les cumuls de cette fiche à celle en cours?", "Suppression d'une fiche de paye",
740
                        JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
715
                        JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
741
                    // on effectue le cumul
716
                    // on effectue le cumul
742
                    // System.err.println("Calcul des cumuls");
-
 
743
 
717
 
744
                    SQLRow rowSal = row.getForeignRow("ID_SALARIE");
718
                    SQLRow rowSal = row.getForeignRow("ID_SALARIE");
745
 
719
 
746
                    SQLRow rowCumuls = rowSal.getForeignRow("ID_CUMULS_PAYE");
720
                    SQLRow rowCumuls = rowSal.getForeignRow("ID_CUMULS_PAYE");
747
 
721
 
Line 843... Line 817...
843
        stockValidValues(oldID);
817
        stockValidValues(oldID);
844
 
818
 
845
        // creer et associer une nouvelle fiche au salarie
819
        // creer et associer une nouvelle fiche au salarie
846
        final SQLRowValues rowValsNewFiche = new SQLRowValues(tableFiche);
820
        final SQLRowValues rowValsNewFiche = new SQLRowValues(tableFiche);
847
 
821
 
848
        try {
-
 
849
            SQLRow r = rowValsNewFiche.insert();
822
        SQLRow r = rowValsNewFiche.insert();
850
            rowValsNewFiche.put("ID", r.getID());
823
        rowValsNewFiche.put("ID", r.getID());
851
            // System.err.println("rowValsNewFiche -----> " + r.getID());
-
 
852
        } catch (SQLException e) {
-
 
853
            e.printStackTrace();
-
 
854
        }
-
 
855
 
824
 
856
        // mis a jour de la periode
825
        // mis a jour de la periode
857
        int mois = rowFiche.getInt("ID_MOIS");
826
        int mois = rowFiche.getInt("ID_MOIS");
858
        int annee = rowFiche.getInt("ANNEE");
827
        int annee = rowFiche.getInt("ANNEE");
859
        rowValsNewFiche.put("ID_MOIS", mois);
828
        rowValsNewFiche.put("ID_MOIS", mois);
Line 863... Line 832...
863
        calDu.set(Calendar.DAY_OF_MONTH, 1);
832
        calDu.set(Calendar.DAY_OF_MONTH, 1);
864
        rowValsNewFiche.put("DU", calDu.getTime());
833
        rowValsNewFiche.put("DU", calDu.getTime());
865
        calDu.set(Calendar.DAY_OF_MONTH, calDu.getActualMaximum(Calendar.DAY_OF_MONTH));
834
        calDu.set(Calendar.DAY_OF_MONTH, calDu.getActualMaximum(Calendar.DAY_OF_MONTH));
866
        rowValsNewFiche.put("AU", calDu.getTime());
835
        rowValsNewFiche.put("AU", calDu.getTime());
867
        rowValsNewFiche.put("ID_PROFIL_PAYE", rowFiche.getInt("ID_PROFIL_PAYE"));
836
        rowValsNewFiche.put("ID_PROFIL_PAYE", rowFiche.getInt("ID_PROFIL_PAYE"));
868
 
-
 
869
        /*
-
 
870
         * int ancMois = rowFiche.getInt("ID_MOIS"); int ancAnnee = rowFiche.getInt("ANNEE");
-
 
871
         * 
-
 
872
         * rowValsSal.put("DERNIER_MOIS", ancMois); rowValsSal.put("DERNIERE_ANNEE", ancAnnee);
-
 
873
         * 
-
 
874
         * try { rowValsSal.update(rowFiche.getInt("ID_SALARIE")); } catch (SQLException e1) {
-
 
875
         * e1.printStackTrace(); }
-
 
876
         * 
-
 
877
         * int mois = ancMois - 2; mois = (mois + 1) % 12; mois += 2; int annee = ancAnnee; if (mois
-
 
878
         * == 2) { annee++; } rowValsNewFiche.put("ID_MOIS", mois); rowValsNewFiche.put("ANNEE",
-
 
879
         * annee); rowValsNewFiche.put("ID_PROFIL_PAYE", rowFiche.getInt("ID_PROFIL_PAYE"));
-
 
880
         * 
-
 
881
         * try { rowValsNewFiche.update(); } catch (SQLException e) { e.printStackTrace(); }
-
 
882
         */
-
 
883
 
-
 
884
        rowValsNewFiche.put("ID_SALARIE", rowSal.getID());
837
        rowValsNewFiche.put("ID_SALARIE", rowSal.getID());
885
        rowValsSal.put("ID_FICHE_PAYE", rowValsNewFiche.getID());
838
        rowValsSal.put("ID_FICHE_PAYE", rowValsNewFiche.getID());
886
 
839
 
887
        SwingUtilities.invokeLater(new Runnable() {
840
        SwingUtilities.invokeLater(new Runnable() {
888
            public void run() {
841
            public void run() {
Line 917... Line 870...
917
            rowValsTmp.put("ID_FICHE_PAYE", rowValsNewFiche.getID());
870
            rowValsTmp.put("ID_FICHE_PAYE", rowValsNewFiche.getID());
918
            rowValsTmp.commit();
871
            rowValsTmp.commit();
919
        }
872
        }
920
 
873
 
921
        // on effectue le cumul
874
        // on effectue le cumul
922
        // System.err.println("Calcul des cumuls");
-
 
923
        final SQLRow rowVarSal = tableVariableSal.getRow(rowSal.getInt("ID_VARIABLE_SALARIE"));
875
        final SQLRow rowVarSal = tableVariableSal.getRow(rowSal.getInt("ID_VARIABLE_SALARIE"));
924
        int idCumuls = rowSal.getInt("ID_CUMULS_PAYE");
876
        int idCumuls = rowSal.getInt("ID_CUMULS_PAYE");
925
        SQLRow rowCumuls = tableCumuls.getRow(idCumuls);
877
        SQLRow rowCumuls = tableCumuls.getRow(idCumuls);
926
 
878
 
927
        SQLRowValues rowValsCumul = new SQLRowValues(tableCumuls);
879
        SQLRowValues rowValsCumul = new SQLRowValues(tableCumuls);
Line 930... Line 882...
930
            rowValsCumul.put(string + "_C", new Float(cumul));
882
            rowValsCumul.put(string + "_C", new Float(cumul));
931
        }
883
        }
932
        float netAPayer = rowCumuls.getFloat("NET_A_PAYER_C") + rowFiche.getFloat("NET_A_PAYER") + rowFiche.getFloat("ACOMPTE");
884
        float netAPayer = rowCumuls.getFloat("NET_A_PAYER_C") + rowFiche.getFloat("NET_A_PAYER") + rowFiche.getFloat("ACOMPTE");
933
        rowValsCumul.put("NET_A_PAYER_C", new Float(netAPayer));
885
        rowValsCumul.put("NET_A_PAYER_C", new Float(netAPayer));
934
 
886
 
935
        SQLRow r = rowValsCumul.insert();
887
        SQLRow row = rowValsCumul.insert();
936
        rowValsCumul.put("ID", r.getID());
888
        rowValsCumul.put("ID", row.getID());
937
 
889
 
938
        // System.err.println("Mis a jour de la fiche de paye");
-
 
939
        rowValsSal.put("ID_CUMULS_PAYE", rowValsCumul.getID());
890
        rowValsSal.put("ID_CUMULS_PAYE", rowValsCumul.getID());
940
 
891
 
941
        SwingUtilities.invokeLater(new Runnable() {
892
        SwingUtilities.invokeLater(new Runnable() {
942
            public void run() {
893
            public void run() {
943
                // FIXME: Ouch: sql in swing!
894
                // FIXME: Ouch: sql in swing!
Line 1052... Line 1003...
1052
                rowValsSal.update(idSal);
1003
                rowValsSal.update(idSal);
1053
            } catch (SQLException e1) {
1004
            } catch (SQLException e1) {
1054
                e1.printStackTrace();
1005
                e1.printStackTrace();
1055
            }
1006
            }
1056
        }
1007
        }
1057
        /*
-
 
1058
         * int mois = ancMois - 2; mois = (mois + 1) % 12; mois += 2; int annee = ancAnnee; if (mois
-
 
1059
         * == 2) { annee++; } rowValsNewFiche.put("ID_MOIS", mois); rowValsNewFiche.put("ANNEE",
-
 
1060
         * annee); rowValsNewFiche.put("ID_PROFIL_PAYE", rowFiche.getInt("ID_PROFIL_PAYE"));
-
 
1061
         * 
1008
 
1062
         * try { rowValsNewFiche.update(); } catch (SQLException e) { e.printStackTrace(); }
-
 
1063
         */
-
 
1064
    }
1009
    }
1065
 
1010
 
1066
    // stocke les éléments validés (cumuls congés, paye, ...)
1011
    // stocke les éléments validés (cumuls congés, paye, ...)
1067
    private static void stockValidValues(final int id) throws SQLException {
1012
    private static void stockValidValues(final int id) throws SQLException {
1068
        final ComptaPropsConfiguration conf = ComptaPropsConfiguration.getInstanceCompta();
1013
        final ComptaPropsConfiguration conf = ComptaPropsConfiguration.getInstanceCompta();
Line 1092... Line 1037...
1092
 
1037
 
1093
    // FIXME retirer les rubriques non imprime ou pas dans de la periode de la fiche validee ??
1038
    // FIXME retirer les rubriques non imprime ou pas dans de la periode de la fiche validee ??
1094
    private static void validElements(int id) {
1039
    private static void validElements(int id) {
1095
 
1040
 
1096
        SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
1041
        SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
1097
        System.err.println("Validation des éléments de la fiche.");
-
 
1098
        String trueString = "1";
1042
        String trueString = "1";
1099
        if (Configuration.getInstance().getBase().getServer().getSQLSystem() == SQLSystem.POSTGRESQL) {
1043
        if (Configuration.getInstance().getBase().getServer().getSQLSystem() == SQLSystem.POSTGRESQL) {
1100
            trueString = "true";
1044
            trueString = "true";
1101
        }
1045
        }
1102
        String req = "UPDATE \"FICHE_PAYE_ELEMENT\" SET \"VALIDE\" = " + trueString + " WHERE \"FICHE_PAYE_ELEMENT\".\"ID_FICHE_PAYE\" = " + id;
1046
        String req = "UPDATE \"FICHE_PAYE_ELEMENT\" SET \"VALIDE\" = " + trueString + " WHERE \"FICHE_PAYE_ELEMENT\".\"ID_FICHE_PAYE\" = " + id;
1103
 
1047
 
1104
        base.getDataSource().execute(req);
1048
        base.getDataSource().execute(req);
1105
 
1049
 
1106
        System.err.println("Validation terminée.");
-
 
1107
    }
1050
    }
1108
 
1051
 
1109
    private static boolean checkDateValid(int idFiche) {
1052
    private static boolean checkDateValid(int idFiche) {
1110
 
1053
 
1111
        SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
1054
        SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();