OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 151 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 151 Rev 180
Line 12... Line 12...
12
 */
12
 */
13
 
13
 
14
 package org.openconcerto.erp.core.finance.payment.action;
14
 package org.openconcerto.erp.core.finance.payment.action;
15
 
15
 
16
import org.openconcerto.erp.action.CreateFrameAbstractAction;
16
import org.openconcerto.erp.action.CreateFrameAbstractAction;
17
import org.openconcerto.erp.config.ComptaPropsConfiguration;
-
 
18
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
17
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
19
import org.openconcerto.erp.core.sales.invoice.report.VenteFactureXmlSheet;
-
 
20
import org.openconcerto.erp.generationDoc.gestcomm.FicheRelanceSheet;
-
 
21
import org.openconcerto.erp.generationDoc.gestcomm.RelanceSheet;
-
 
22
import org.openconcerto.erp.preferences.PrinterNXProps;
-
 
23
import org.openconcerto.sql.Configuration;
18
import org.openconcerto.sql.Configuration;
24
import org.openconcerto.sql.element.SQLElement;
19
import org.openconcerto.sql.element.SQLElement;
25
import org.openconcerto.sql.model.SQLRow;
-
 
26
import org.openconcerto.sql.model.SQLRowAccessor;
-
 
27
import org.openconcerto.sql.model.SQLRowValues;
20
import org.openconcerto.sql.model.SQLRowValues;
28
import org.openconcerto.sql.view.IListFrame;
21
import org.openconcerto.sql.view.IListFrame;
29
import org.openconcerto.sql.view.ListeAddPanel;
22
import org.openconcerto.sql.view.ListeAddPanel;
30
import org.openconcerto.sql.view.list.SQLTableModelColumn;
23
import org.openconcerto.sql.view.list.SQLTableModelColumn;
31
import org.openconcerto.sql.view.list.SQLTableModelColumnPath;
24
import org.openconcerto.sql.view.list.SQLTableModelColumnPath;
32
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
25
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
33
import org.openconcerto.ui.DefaultGridBagConstraints;
26
import org.openconcerto.ui.DefaultGridBagConstraints;
34
import org.openconcerto.utils.ExceptionHandler;
-
 
35
import org.openconcerto.utils.cc.ITransformer;
27
import org.openconcerto.utils.cc.ITransformer;
36
 
28
 
37
import java.awt.GridBagConstraints;
29
import java.awt.GridBagConstraints;
38
import java.awt.event.ActionEvent;
-
 
39
import java.awt.event.MouseEvent;
-
 
40
import java.awt.event.MouseListener;
-
 
41
import java.util.List;
-
 
42
 
30
 
43
import javax.swing.AbstractAction;
-
 
44
import javax.swing.Action;
31
import javax.swing.Action;
45
import javax.swing.JButton;
32
import javax.swing.JButton;
46
import javax.swing.JFrame;
33
import javax.swing.JFrame;
47
import javax.swing.JPopupMenu;
-
 
48
 
34
 
49
public class ListeDesRelancesAction extends CreateFrameAbstractAction implements MouseListener {
35
public class ListeDesRelancesAction extends CreateFrameAbstractAction {
50
 
36
 
51
    private IListFrame frame;
37
    private IListFrame frame;
52
 
38
 
53
    public ListeDesRelancesAction() {
39
    public ListeDesRelancesAction() {
54
        super();
40
        super();
Line 65... Line 51...
65
                this.btnMngr.setAdditional(this.buttonModifier, new ITransformer<JButton, String>() {
51
                this.btnMngr.setAdditional(this.buttonModifier, new ITransformer<JButton, String>() {
66
 
52
 
67
                    @Override
53
                    @Override
68
                    public String transformChecked(JButton input) {
54
                    public String transformChecked(JButton input) {
69
 
55
 
70
                        SQLRowAccessor row = getListe().fetchSelectedRow();
56
                        SQLRowValues row = getListe().getSelectedRow();
71
 
57
 
72
                        if (row.getForeign("ID_TYPE_LETTRE_RELANCE") == null || row.isForeignEmpty("ID_TYPE_LETTRE_RELANCE")) {
58
                        if (row.getObject("ID_TYPE_LETTRE_RELANCE") == null || row.isForeignEmpty("ID_TYPE_LETTRE_RELANCE")) {
73
                            return "Vous ne pouvez pas modifier une relance envoyée par mail!";
59
                            return "Vous ne pouvez pas modifier une relance envoyée par mail!";
74
                        }
60
                        }
75
                        return null;
61
                        return null;
76
                    }
62
                    }
77
                });
63
                });
Line 88... Line 74...
88
            }
74
            }
89
        }
75
        }
90
 
76
 
91
        ((SQLTableModelColumnPath) src.getColumns(elt.getTable().getField("INFOS")).iterator().next()).setEditable(true);
77
        ((SQLTableModelColumnPath) src.getColumns(elt.getTable().getField("INFOS")).iterator().next()).setEditable(true);
92
 
78
 
93
        this.frame.getPanel().getListe().getJTable().addMouseListener(this);
-
 
94
        this.frame.getPanel().setAddVisible(false);
79
        this.frame.getPanel().setAddVisible(false);
95
 
80
 
96
        // Date panel
81
        // Date panel
97
        GridBagConstraints c = new DefaultGridBagConstraints();
82
        GridBagConstraints c = new DefaultGridBagConstraints();
98
        c.gridwidth = GridBagConstraints.REMAINDER;
83
        c.gridwidth = GridBagConstraints.REMAINDER;
Line 107... Line 92...
107
        frame.getPanel().add(datePanel, c);
92
        frame.getPanel().add(datePanel, c);
108
 
93
 
109
        return this.frame;
94
        return this.frame;
110
    }
95
    }
111
 
96
 
112
    public void mouseClicked(MouseEvent e) {
-
 
113
    }
-
 
114
 
-
 
115
    public void mousePressed(MouseEvent e) {
-
 
116
 
-
 
117
        int selectedId = this.frame.getPanel().getListe().getSelectedId();
-
 
118
        if (selectedId > 1 && e.getButton() == MouseEvent.BUTTON3) {
-
 
119
 
-
 
120
            // String locationRelance =
-
 
121
            // TemplateNXProps.getInstance().getStringProperty("LocationRelanceOO");
-
 
122
            final SQLRow rowRelance = this.frame.getPanel().getListe().fetchSelectedRow();
-
 
123
 
-
 
124
            boolean isNotMail = !(rowRelance.getForeign("ID_TYPE_LETTRE_RELANCE") == null || rowRelance.isForeignEmpty("ID_TYPE_LETTRE_RELANCE"));
-
 
125
            // final String fileName = "Relance_" + rowRelance.getString("NUMERO");
-
 
126
            // final File fileOutOO = new File(locationRelance, fileName + ".odt");
-
 
127
            JPopupMenu menu = new JPopupMenu();
-
 
128
            final RelanceSheet s = new RelanceSheet(rowRelance);
-
 
129
 
-
 
130
            // Voir le document
-
 
131
            AbstractAction actionOpen = new AbstractAction("Voir le document") {
-
 
132
                public void actionPerformed(ActionEvent e) {
-
 
133
                    s.generate(false, false, "");
-
 
134
                    s.showDocument();
-
 
135
                }
-
 
136
            };
-
 
137
            actionOpen.setEnabled(isNotMail);
-
 
138
            menu.add(actionOpen);
-
 
139
 
-
 
140
            // Impression
-
 
141
            AbstractAction actionPrint = new AbstractAction("Imprimer") {
-
 
142
                public void actionPerformed(ActionEvent e) {
-
 
143
                    s.fastPrintDocument();
-
 
144
                }
-
 
145
            };
-
 
146
            actionPrint.setEnabled(isNotMail);
-
 
147
            menu.add(actionPrint);
-
 
148
 
-
 
149
            // Impression
-
 
150
            AbstractAction actionPrintFact = new AbstractAction("Imprimer la facture") {
-
 
151
                public void actionPerformed(ActionEvent e) {
-
 
152
                    final Thread t = new Thread(new Runnable() {
-
 
153
 
-
 
154
                        @Override
-
 
155
                        public void run() {
-
 
156
                            try {
-
 
157
                                printInvoice(rowRelance);
-
 
158
                            } catch (Exception e) {
-
 
159
                                ExceptionHandler.handle("Impression impossible", e);
-
 
160
                            }
-
 
161
                        }
-
 
162
                    });
-
 
163
                    t.start();
-
 
164
 
-
 
165
                }
-
 
166
            };
-
 
167
            actionPrintFact.setEnabled(isNotMail);
-
 
168
            menu.add(actionPrintFact);
-
 
169
 
-
 
170
            // Impression
-
 
171
 
-
 
172
            AbstractAction actionPrintBoth = new AbstractAction("Imprimer la facture et la relance") {
-
 
173
                public void actionPerformed(ActionEvent e) {
-
 
174
                    final Thread t = new Thread(new Runnable() {
-
 
175
                        @Override
-
 
176
                        public void run() {
-
 
177
                            try {
-
 
178
                                s.fastPrintDocument();
-
 
179
                                printInvoice(rowRelance);
-
 
180
                            } catch (Exception e) {
-
 
181
                                ExceptionHandler.handle("Impression impossible", e);
-
 
182
                            }
-
 
183
                        }
-
 
184
                    });
-
 
185
                    t.start();
-
 
186
                }
-
 
187
            };
-
 
188
            actionPrintBoth.setEnabled(isNotMail);
-
 
189
            menu.add(actionPrintBoth);
-
 
190
 
-
 
191
            // Générer
-
 
192
            final AbstractAction actionGenerate = new AbstractAction("Générer") {
-
 
193
                public void actionPerformed(ActionEvent e) {
-
 
194
 
-
 
195
                    String printer = PrinterNXProps.getInstance().getStringProperty("RelancePrinter");
-
 
196
                    s.generate(false, true, printer, true);
-
 
197
                }
-
 
198
            };
-
 
199
            actionGenerate.setEnabled(isNotMail);
-
 
200
            menu.add(actionGenerate);
-
 
201
 
-
 
202
            // Créer la fiche de relance
-
 
203
            menu.add(new AbstractAction("Créer la fiche de relance") {
-
 
204
                public void actionPerformed(ActionEvent e) {
-
 
205
                    try {
-
 
206
                        FicheRelanceSheet sheet = new FicheRelanceSheet(rowRelance);
-
 
207
                        sheet.createDocumentAsynchronous();
-
 
208
                        sheet.showPrintAndExportAsynchronous(true, false, true);
-
 
209
                    } catch (Exception ex) {
-
 
210
                        ExceptionHandler.handle("Impression impossible", ex);
-
 
211
                    }
-
 
212
                }
-
 
213
            });
-
 
214
            menu.show(e.getComponent(), e.getPoint().x, e.getPoint().y);
-
 
215
        }
-
 
216
    }
-
 
217
 
-
 
218
    public void mouseReleased(MouseEvent e) {
-
 
219
    }
-
 
220
 
-
 
221
    public void mouseEntered(MouseEvent e) {
-
 
222
    }
-
 
223
 
-
 
224
    public void mouseExited(MouseEvent e) {
-
 
225
    }
-
 
226
 
-
 
227
    private void printInvoice(final SQLRow rowRelance) throws Exception {
-
 
228
        final VenteFactureXmlSheet sheet = new VenteFactureXmlSheet(rowRelance.getForeignRow("ID_SAISIE_VENTE_FACTURE"));
-
 
229
        sheet.getOrCreateDocumentFile();
-
 
230
        sheet.showPrintAndExport(false, true, true);
-
 
231
    }
-
 
232
}
97
}