OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 180 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 180 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 15... Line 15...
15
 
15
 
16
import org.openconcerto.erp.config.Gestion;
16
import org.openconcerto.erp.config.Gestion;
17
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
17
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
18
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
18
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
19
import org.openconcerto.erp.core.edm.AttachmentAction;
19
import org.openconcerto.erp.core.edm.AttachmentAction;
-
 
20
import org.openconcerto.erp.core.sales.order.ui.ReliquatCommandeTableModel;
20
import org.openconcerto.erp.core.supplychain.order.component.CommandeSQLComponent;
21
import org.openconcerto.erp.core.supplychain.order.component.CommandeSQLComponent;
21
import org.openconcerto.erp.core.supplychain.order.component.SaisieAchatSQLComponent;
22
import org.openconcerto.erp.core.supplychain.order.component.SaisieAchatSQLComponent;
22
import org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent;
23
import org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent;
23
import org.openconcerto.erp.generationDoc.gestcomm.CommandeXmlSheet;
24
import org.openconcerto.erp.generationDoc.gestcomm.CommandeXmlSheet;
24
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
25
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
Line 32... Line 33...
32
import org.openconcerto.sql.model.SQLRowValues;
33
import org.openconcerto.sql.model.SQLRowValues;
33
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
34
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
34
import org.openconcerto.sql.model.SQLSelect;
35
import org.openconcerto.sql.model.SQLSelect;
35
import org.openconcerto.sql.model.SQLSelectJoin;
36
import org.openconcerto.sql.model.SQLSelectJoin;
36
import org.openconcerto.sql.model.SQLTable;
37
import org.openconcerto.sql.model.SQLTable;
-
 
38
import org.openconcerto.sql.model.SQLTableEvent;
-
 
39
import org.openconcerto.sql.model.SQLTableEvent.Mode;
-
 
40
import org.openconcerto.sql.model.SQLTableModifiedListener;
37
import org.openconcerto.sql.model.Where;
41
import org.openconcerto.sql.model.Where;
38
import org.openconcerto.sql.preferences.SQLPreferences;
42
import org.openconcerto.sql.preferences.SQLPreferences;
39
import org.openconcerto.sql.view.EditFrame;
43
import org.openconcerto.sql.view.EditFrame;
40
import org.openconcerto.sql.view.EditPanel;
44
import org.openconcerto.sql.view.EditPanel;
41
import org.openconcerto.sql.view.list.IListe;
45
import org.openconcerto.sql.view.list.IListe;
42
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
46
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
43
import org.openconcerto.sql.view.list.RowAction;
47
import org.openconcerto.sql.view.list.RowAction;
44
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
48
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
-
 
49
import org.openconcerto.ui.PanelFrame;
45
import org.openconcerto.utils.ExceptionHandler;
50
import org.openconcerto.utils.ExceptionHandler;
46
import org.openconcerto.utils.cc.ITransformer;
51
import org.openconcerto.utils.cc.ITransformer;
47
 
52
 
-
 
53
import java.awt.GridBagConstraints;
-
 
54
import java.awt.GridBagLayout;
48
import java.awt.event.ActionEvent;
55
import java.awt.event.ActionEvent;
49
import java.sql.SQLException;
56
import java.sql.SQLException;
50
import java.util.ArrayList;
57
import java.util.ArrayList;
51
import java.util.List;
58
import java.util.List;
52
 
59
 
53
import javax.swing.AbstractAction;
60
import javax.swing.AbstractAction;
54
import javax.swing.ImageIcon;
61
import javax.swing.ImageIcon;
55
import javax.swing.JFrame;
62
import javax.swing.JFrame;
56
import javax.swing.JOptionPane;
63
import javax.swing.JOptionPane;
-
 
64
import javax.swing.JPanel;
-
 
65
import javax.swing.JScrollPane;
-
 
66
import javax.swing.JTable;
57
import javax.swing.SwingWorker;
67
import javax.swing.SwingWorker;
58
 
68
 
59
import org.apache.commons.dbutils.handlers.ArrayListHandler;
69
import org.apache.commons.dbutils.handlers.ArrayListHandler;
60
 
70
 
61
public class CommandeSQLElement extends ComptaSQLConfElement {
71
public class CommandeSQLElement extends ComptaSQLConfElement {
Line 67... Line 77...
67
            PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction().getAction(), true);
77
            PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction().getAction(), true);
68
            actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
78
            actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
69
            getRowActions().add(actionAttachment);
79
            getRowActions().add(actionAttachment);
70
        }
80
        }
71
 
81
 
72
        getRowActions().addAll(new MouseSheetXmlListeListener(CommandeXmlSheet.class).getRowActions());
82
        getRowActions().addAll(new MouseSheetXmlListeListener(this, CommandeXmlSheet.class).getRowActions());
73
 
83
 
74
        // Transfert vers BR
84
        // Transfert vers BR
75
        PredicateRowAction bonAction = new PredicateRowAction(new AbstractAction() {
85
        PredicateRowAction bonAction = new PredicateRowAction(new AbstractAction() {
76
            public void actionPerformed(ActionEvent e) {
86
            public void actionPerformed(ActionEvent e) {
77
                final List<SQLRowValues> selectedRows = IListe.get(e).getSelectedRows();
87
                final List<SQLRowValues> selectedRows = IListe.get(e).getSelectedRows();
Line 153... Line 163...
153
                }
163
                }
154
            }
164
            }
155
        }, false, "supplychain.order.valid");
165
        }, false, "supplychain.order.valid");
156
        tagValidAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
166
        tagValidAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
157
        getRowActions().add(tagValidAction);
167
        getRowActions().add(tagValidAction);
-
 
168
 
-
 
169
        // Reliquat
-
 
170
        PredicateRowAction reliquatAction = new PredicateRowAction(new AbstractAction() {
-
 
171
            public void actionPerformed(ActionEvent e) {
-
 
172
                JPanel panelReliquat = new JPanel(new GridBagLayout());
-
 
173
                GridBagConstraints c = new GridBagConstraints();
-
 
174
                final ReliquatCommandeTableModel dm = new ReliquatCommandeTableModel(IListe.get(e).getSelectedRowAccessor());
-
 
175
                if (dm.getRowCount() > 0) {
-
 
176
                    JTable table = new JTable(dm);
-
 
177
                    JScrollPane comp = new JScrollPane(table);
-
 
178
                    c.weightx = 1;
-
 
179
                    c.weighty = 1;
-
 
180
                    c.fill = GridBagConstraints.BOTH;
-
 
181
                    panelReliquat.add(comp, c);
-
 
182
                    PanelFrame frame = new PanelFrame(panelReliquat, "Reliquat commande");
-
 
183
                    frame.pack();
-
 
184
                    frame.setVisible(true);
-
 
185
                } else {
-
 
186
                    JOptionPane.showMessageDialog(null, "Aucun reliquat restant");
-
 
187
                }
-
 
188
            }
-
 
189
 
-
 
190
        }, false, "sales.order.reliquat.show");
-
 
191
 
-
 
192
        reliquatAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
-
 
193
        getRowActions().add(reliquatAction);
158
    }
194
    }
159
 
195
 
160
    @Override
196
    @Override
161
    protected List<String> getListFields() {
197
    protected List<String> getListFields() {
162
        final List<String> l = new ArrayList<>(8);
198
        final List<String> l = new ArrayList<>(8);
Line 191... Line 227...
191
     */
227
     */
192
    public SQLComponent createComponent() {
228
    public SQLComponent createComponent() {
193
        return new CommandeSQLComponent();
229
        return new CommandeSQLComponent();
194
    }
230
    }
195
 
231
 
-
 
232
    private final List<SQLTableModifiedListener> listenerCmdInserted = new ArrayList<>();
-
 
233
 
-
 
234
    public void addInsertedCmdListener(SQLTableModifiedListener l) {
-
 
235
        this.listenerCmdInserted.add(l);
-
 
236
    }
-
 
237
 
-
 
238
    public void removeInsertedCmdListener(SQLTableModifiedListener l) {
-
 
239
        this.listenerCmdInserted.remove(l);
-
 
240
    }
-
 
241
 
-
 
242
    public void fireInsertedCmdListener(SQLRow row) {
-
 
243
        for (SQLTableModifiedListener sqlTableModifiedListener : this.listenerCmdInserted) {
-
 
244
            sqlTableModifiedListener.tableModified(new SQLTableEvent(row, Mode.ROW_ADDED, null));
-
 
245
        }
-
 
246
    }
-
 
247
 
196
    public void transfertBR(final List<SQLRowValues> selectedRows) {
248
    public void transfertBR(final List<SQLRowValues> selectedRows) {
197
 
249
 
198
        EditFrame f = TransfertBaseSQLComponent.openTransfertFrame(selectedRows, "BON_RECEPTION");
250
        EditFrame f = TransfertBaseSQLComponent.openTransfertFrame(selectedRows, "BON_RECEPTION");
199
        BonReceptionSQLComponent comp = (BonReceptionSQLComponent) f.getSQLComponent();
251
        BonReceptionSQLComponent comp = (BonReceptionSQLComponent) f.getSQLComponent();
200
        final SQLTable tableElt = comp.getElement().getTable().getTable("BON_RECEPTION_ELEMENT");
252
        final SQLTable tableElt = comp.getElement().getTable().getTable("BON_RECEPTION_ELEMENT");
Line 217... Line 269...
217
                joinTR.setWhere(new Where(joinTR.getJoinedTable().getField("ID_COMMANDE"), ids));
269
                joinTR.setWhere(new Where(joinTR.getJoinedTable().getField("ID_COMMANDE"), ids));
218
                return input;
270
                return input;
219
            }
271
            }
220
        });
272
        });
221
        comp.loadQuantity(fetcher.fetch());
273
        comp.loadQuantity(fetcher.fetch());
-
 
274
        comp.removeZeroQtyLines();
222
    }
275
    }
223
 
276
 
224
    /**
277
    /**
225
     * Transfert d'une commande en facture
278
     * Transfert d'une commande en facture
226
     * 
279
     *