OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 132 Rev 182
Line 1... Line 1...
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
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
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
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.
9
 * language governing permissions and limitations under the License.
Line 14... Line 14...
14
 package org.openconcerto.erp.core.finance.accounting.ui;
14
 package org.openconcerto.erp.core.finance.accounting.ui;
15
 
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
17
import org.openconcerto.erp.config.Gestion;
17
import org.openconcerto.erp.config.Gestion;
18
import org.openconcerto.erp.core.finance.accounting.model.SelectJournauxModel;
18
import org.openconcerto.erp.core.finance.accounting.model.SelectJournauxModel;
19
import org.openconcerto.erp.core.finance.accounting.report.GrandLivreSheet;
19
import org.openconcerto.erp.core.finance.accounting.report.GrandLivrePDF;
20
import org.openconcerto.erp.core.finance.accounting.report.JournauxMoisSheet;
20
import org.openconcerto.erp.core.finance.accounting.report.JournauxMoisSheet;
21
import org.openconcerto.erp.core.finance.accounting.report.JournauxSheet;
21
import org.openconcerto.erp.core.finance.accounting.report.JournauxSheet;
22
import org.openconcerto.erp.core.finance.accounting.report.JournauxSheetXML;
22
import org.openconcerto.erp.core.finance.accounting.report.JournauxSheetXML;
23
import org.openconcerto.erp.generationDoc.SpreadSheetGeneratorCompta;
23
import org.openconcerto.erp.generationDoc.SpreadSheetGeneratorCompta;
24
import org.openconcerto.erp.generationDoc.SpreadSheetGeneratorListener;
24
import org.openconcerto.erp.generationDoc.SpreadSheetGeneratorListener;
Line 40... Line 40...
40
import java.awt.event.KeyEvent;
40
import java.awt.event.KeyEvent;
41
import java.awt.event.MouseAdapter;
41
import java.awt.event.MouseAdapter;
42
import java.awt.event.MouseEvent;
42
import java.awt.event.MouseEvent;
43
import java.beans.PropertyChangeEvent;
43
import java.beans.PropertyChangeEvent;
44
import java.beans.PropertyChangeListener;
44
import java.beans.PropertyChangeListener;
-
 
45
import java.io.File;
45
import java.util.Calendar;
46
import java.util.Calendar;
46
import java.util.Date;
47
import java.util.Date;
47
 
48
 
48
import javax.swing.AbstractAction;
49
import javax.swing.AbstractAction;
49
import javax.swing.BorderFactory;
50
import javax.swing.BorderFactory;
Line 68... Line 69...
68
    private JTable tableJrnl;
69
    private JTable tableJrnl;
69
    private JButton valid;
70
    private JButton valid;
70
    private JButton annul;
71
    private JButton annul;
71
    private JCheckBox checkCentralMois;
72
    private JCheckBox checkCentralMois;
72
    private JCheckBox checkAncienModele;
73
    private JCheckBox checkAncienModele;
-
 
74
    private JTextField compteDeb;
73
    private JTextField compteDeb, compteEnd;
75
    private JTextField compteEnd;
74
    private int mode = GrandLivreSheet.MODEALL;
76
    private int mode = GrandLivrePDF.MODEALL;
75
    private JProgressBar bar = new JProgressBar(0, 3);
77
    private JProgressBar bar = new JProgressBar(0, 3);
76
 
78
 
77
    public ImpressionJournauxPanel() {
79
    public ImpressionJournauxPanel() {
78
        this.setLayout(new GridBagLayout());
80
        this.setLayout(new GridBagLayout());
79
        final GridBagConstraints c = new DefaultGridBagConstraints();
81
        final GridBagConstraints c = new DefaultGridBagConstraints();
80
 
82
 
81
        SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
83
        SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
82
        SQLRow rowExercice = Configuration.getInstance().getBase().getTable("EXERCICE_COMMON").getRow(rowSociete.getInt("ID_EXERCICE_COMMON"));
84
        SQLRow rowExercice = Configuration.getInstance().getBase().getTable("EXERCICE_COMMON").getRow(rowSociete.getInt("ID_EXERCICE_COMMON"));
83
 
-
 
84
        // this.isValidated = false;
-
 
85
        this.dateDeb = new JDate();
85
        this.dateDeb = new JDate();
86
        this.dateEnd = new JDate();
86
        this.dateEnd = new JDate();
87
        this.tableJrnl = new JTable(new SelectJournauxModel());
87
        this.tableJrnl = new JTable(new SelectJournauxModel());
88
 
88
 
89
        this.add(new JLabel("Période du", SwingConstants.RIGHT), c);
89
        this.add(new JLabel("Période du", SwingConstants.RIGHT), c);
Line 160... Line 160...
160
        this.annul = new JButton("Fermer");
160
        this.annul = new JButton("Fermer");
161
 
161
 
162
        // Radio mode
162
        // Radio mode
163
        JRadioButton radioAll = new JRadioButton(new AbstractAction("Toutes") {
163
        JRadioButton radioAll = new JRadioButton(new AbstractAction("Toutes") {
164
            public void actionPerformed(ActionEvent e) {
164
            public void actionPerformed(ActionEvent e) {
165
                // TODO Auto-generated method stub
-
 
-
 
165
 
166
                mode = GrandLivreSheet.MODEALL;
166
                ImpressionJournauxPanel.this.mode = GrandLivrePDF.MODEALL;
167
            }
167
            }
168
        });
168
        });
169
 
169
 
170
        JRadioButton radioLettree = new JRadioButton(new AbstractAction("Lettrées") {
170
        JRadioButton radioLettree = new JRadioButton(new AbstractAction("Lettrées") {
171
            public void actionPerformed(ActionEvent e) {
171
            public void actionPerformed(ActionEvent e) {
172
                // TODO Auto-generated method stub
-
 
-
 
172
 
173
                mode = GrandLivreSheet.MODELETTREE;
173
                ImpressionJournauxPanel.this.mode = GrandLivrePDF.MODELETTREE;
174
            }
174
            }
175
        });
175
        });
176
 
176
 
177
        JRadioButton radioNonLettree = new JRadioButton(new AbstractAction("Non lettrées") {
177
        JRadioButton radioNonLettree = new JRadioButton(new AbstractAction("Non lettrées") {
178
            public void actionPerformed(ActionEvent e) {
178
            public void actionPerformed(ActionEvent e) {
179
                // TODO Auto-generated method stub
-
 
-
 
179
 
180
                mode = GrandLivreSheet.MODENONLETTREE_PERIODE;
180
                ImpressionJournauxPanel.this.mode = GrandLivrePDF.MODENONLETTREE_PERIODE;
181
            }
181
            }
182
        });
182
        });
183
        JPanel panelMode = new JPanel();
183
        JPanel panelMode = new JPanel();
184
        panelMode.add(radioAll);
184
        panelMode.add(radioAll);
185
        panelMode.add(radioLettree);
185
        panelMode.add(radioLettree);
Line 205... Line 205...
205
        c.gridwidth = GridBagConstraints.REMAINDER;
205
        c.gridwidth = GridBagConstraints.REMAINDER;
206
        this.add(this.checkCentralMois, c);
206
        this.add(this.checkCentralMois, c);
207
 
207
 
208
        // Ancien modele
208
        // Ancien modele
209
        this.checkAncienModele = new JCheckBox("Ancien modèle");
209
        this.checkAncienModele = new JCheckBox("Ancien modèle");
210
        // c.gridy++;
-
 
211
        // c.gridx += 2;
-
 
212
        // c.gridwidth = GridBagConstraints.REMAINDER;
-
 
213
        // this.add(this.checkAncienModele, c);
-
 
214
 
210
 
215
        // Progress bar
211
        // Progress bar
216
        c.gridwidth = GridBagConstraints.REMAINDER;
212
        c.gridwidth = GridBagConstraints.REMAINDER;
217
        c.gridy++;
213
        c.gridy++;
218
        c.gridx = 0;
214
        c.gridx = 0;
Line 253... Line 249...
253
                                }
249
                                }
254
                            });
250
                            });
255
                        } else if (checkCentralMois.isSelected()) {
251
                        } else if (checkCentralMois.isSelected()) {
256
                            JournauxSheet bSheet;
252
                            JournauxSheet bSheet;
257
                            bSheet = new JournauxMoisSheet(idS, dateDeb.getDate(), dateEnd.getDate(), mode);
253
                            bSheet = new JournauxMoisSheet(idS, dateDeb.getDate(), dateEnd.getDate(), mode);
-
 
254
 
258
                            final SpreadSheetGeneratorCompta generator = new SpreadSheetGeneratorCompta(bSheet, "Journal_" + Calendar.getInstance().getTimeInMillis(), false, true);
255
                            final SpreadSheetGeneratorCompta generator = new SpreadSheetGeneratorCompta(bSheet, "Journal_" + Calendar.getInstance().getTimeInMillis(), false, true);
259
                            SwingUtilities.invokeLater(new Runnable() {
256
                            SwingUtilities.invokeLater(new Runnable() {
260
                                public void run() {
257
                                public void run() {
261
                                    bar.setValue(2);
258
                                    bar.setValue(2);
262
                                    generator.addGenerateListener(ImpressionJournauxPanel.this);
259
                                    generator.addGenerateListener(ImpressionJournauxPanel.this);
263
                                }
260
                                }
264
                            });
261
                            });
265
                        } else {
262
                        } else {
266
                            for (int i = 0; i < idS.length; i++) {
263
                            for (int i = 0; i < idS.length; i++) {
-
 
264
 
267
                                final JournauxSheetXML xmlSheet = new JournauxSheetXML(idS[i], dateDeb.getDate(), dateEnd.getDate(), mode, compteDeb.getText().trim(), compteEnd.getText().trim());
265
                                final JournauxSheetXML xmlSheet = new JournauxSheetXML(idS[i], dateDeb.getDate(), dateEnd.getDate(), mode, compteDeb.getText().trim(), compteEnd.getText().trim());
-
 
266
 
268
                                SwingUtilities.invokeLater(new Runnable() {
267
                                SwingUtilities.invokeLater(new Runnable() {
269
                                    public void run() {
268
                                    public void run() {
270
                                        bar.setValue(2);
269
                                        bar.setValue(2);
271
                                    }
270
                                    }
272
                                });
271
                                });
273
                                try {
272
                                try {
274
                                    xmlSheet.createDocument();
273
                                    xmlSheet.createDocument();
275
                                    xmlSheet.getOrCreatePDFDocumentFile(false, true);
274
                                    xmlSheet.getOrCreatePDFDocumentFile(false, true);
-
 
275
                                    final File generatedPDFFile = xmlSheet.getGeneratedPDFFile();
-
 
276
                                    if (generatedPDFFile != null)
276
                                    Gestion.openPDF(xmlSheet.getGeneratedPDFFile());
277
                                        Gestion.openPDF(generatedPDFFile);
277
                                } catch (Exception exn) {
278
                                } catch (Exception exn) {
278
                                    ExceptionHandler.handle("Erreur lors de la création du journal !", exn);
279
                                    ExceptionHandler.handle("Erreur lors de la création du journal !", exn);
279
                                }
280
                                }
280
 
281
 
281
                            }
282
                            }