OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 142 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 142 Rev 156
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 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.
10
 * 
10
 * 
11
 * When distributing the software, include this License Header Notice in each file.
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
12
 */
13
 
13
 
14
 package org.openconcerto.erp.core.sales.product.element;
14
 package org.openconcerto.erp.core.sales.product.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.sales.invoice.ui.FactureAffacturerTable;
17
import org.openconcerto.erp.core.sales.invoice.ui.FactureAffacturerTable;
18
import org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent;
18
import org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent;
19
import org.openconcerto.sql.element.BaseSQLComponent;
19
import org.openconcerto.sql.element.BaseSQLComponent;
20
import org.openconcerto.sql.element.SQLComponent;
20
import org.openconcerto.sql.element.SQLComponent;
21
import org.openconcerto.sql.model.SQLRowValues;
21
import org.openconcerto.sql.model.SQLRowValues;
22
import org.openconcerto.sql.view.EditFrame;
22
import org.openconcerto.sql.view.EditFrame;
23
import org.openconcerto.sql.view.EditPanel.EditMode;
23
import org.openconcerto.sql.view.EditPanel.EditMode;
24
import org.openconcerto.sql.view.EditPanelListener;
24
import org.openconcerto.sql.view.EditPanelListener;
25
import org.openconcerto.sql.view.list.IListe;
25
import org.openconcerto.sql.view.list.IListe;
26
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
26
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
27
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
27
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
28
import org.openconcerto.ui.DefaultGridBagConstraints;
28
import org.openconcerto.ui.DefaultGridBagConstraints;
29
 
29
 
30
import java.awt.GridBagConstraints;
30
import java.awt.GridBagConstraints;
31
import java.awt.GridBagLayout;
31
import java.awt.GridBagLayout;
32
import java.awt.event.ActionEvent;
32
import java.awt.event.ActionEvent;
33
import java.sql.SQLException;
33
import java.sql.SQLException;
34
import java.util.ArrayList;
34
import java.util.ArrayList;
35
import java.util.List;
35
import java.util.List;
36
 
36
 
37
import javax.swing.AbstractAction;
37
import javax.swing.AbstractAction;
38
import javax.swing.JLabel;
38
import javax.swing.JLabel;
39
 
39
 
40
public class ReliquatSQLElement extends ComptaSQLConfElement {
40
public class ReliquatSQLElement extends ComptaSQLConfElement {
41
 
41
 
42
    private final String tableBonName;
42
    private final String tableBonName;
43
 
43
 
44
    static public class ReliquatBRSQLElement extends ReliquatSQLElement {
44
    static public class ReliquatBRSQLElement extends ReliquatSQLElement {
45
        public ReliquatBRSQLElement() {
45
        public ReliquatBRSQLElement() {
46
            super("RELIQUAT_BR", "un reliquat de BR", "reliquats de BR", "BON_RECEPTION");
46
            super("RELIQUAT_BR", "un reliquat de BR", "reliquats de BR", "BON_RECEPTION");
47
        }
47
        }
48
 
48
 
49
        @Override
49
        @Override
50
        protected String createCode() {
50
        protected String createCode() {
51
            return createCodeFromPackage() + ".reliquatbr";
51
            return createCodeOfPackage() + ".reliquatbr";
52
        }
52
        }
53
    }
53
    }
54
 
54
 
55
    public ReliquatSQLElement(final String tableName, final String singularName, final String pluralName, final String tableBonName) {
55
    public ReliquatSQLElement(final String tableName, final String singularName, final String pluralName, final String tableBonName) {
56
        super(tableName, singularName, pluralName);
56
        super(tableName, singularName, pluralName);
57
        this.tableBonName = tableBonName;
57
        this.tableBonName = tableBonName;
58
 
58
 
59
        PredicateRowAction actionTR = new PredicateRowAction(new AbstractAction("Transfert vers Bon") {
59
        PredicateRowAction actionTR = new PredicateRowAction(new AbstractAction("Transfert vers Bon") {
60
 
60
 
61
            @Override
61
            @Override
62
            public void actionPerformed(ActionEvent e) {
62
            public void actionPerformed(ActionEvent e) {
63
                final List<SQLRowValues> rows = IListe.get(e).getSelectedRows();
63
                final List<SQLRowValues> rows = IListe.get(e).getSelectedRows();
64
                EditFrame frame = new EditFrame(getForeignElement("ID_" + tableBonName), EditMode.CREATION);
64
                EditFrame frame = new EditFrame(getForeignElement("ID_" + tableBonName), EditMode.CREATION);
65
                frame.addEditPanelListener(new EditPanelListener() {
65
                frame.addEditPanelListener(new EditPanelListener() {
66
 
66
 
67
                    @Override
67
                    @Override
68
                    public void modified() {
68
                    public void modified() {
69
                    }
69
                    }
70
 
70
 
71
                    @Override
71
                    @Override
72
                    public void inserted(int id) {
72
                    public void inserted(int id) {
73
                        for (SQLRowValues rowVals : rows) {
73
                        for (SQLRowValues rowVals : rows) {
74
                            try {
74
                            try {
75
                                SQLRowValues upRowVals = rowVals.createEmptyUpdateRow();
75
                                SQLRowValues upRowVals = rowVals.createEmptyUpdateRow();
76
                                upRowVals.put("ID_" + tableBonName, id);
76
                                upRowVals.put("ID_" + tableBonName, id);
77
                                upRowVals.update();
77
                                upRowVals.update();
78
                            } catch (SQLException exn) {
78
                            } catch (SQLException exn) {
79
                                exn.printStackTrace();
79
                                exn.printStackTrace();
80
                            }
80
                            }
81
                        }
81
                        }
82
 
82
 
83
                    }
83
                    }
84
 
84
 
85
                    @Override
85
                    @Override
86
                    public void deleted() {
86
                    public void deleted() {
87
                    }
87
                    }
88
 
88
 
89
                    @Override
89
                    @Override
90
                    public void cancelled() {
90
                    public void cancelled() {
91
                    }
91
                    }
92
                });
92
                });
93
 
93
 
94
                SQLComponent comp = (SQLComponent) frame.getSQLComponent();
94
                SQLComponent comp = (SQLComponent) frame.getSQLComponent();
95
                if (comp instanceof BonReceptionSQLComponent) {
95
                if (comp instanceof BonReceptionSQLComponent) {
96
                    ((BonReceptionSQLComponent) comp).loadFromReliquat(rows);
96
                    ((BonReceptionSQLComponent) comp).loadFromReliquat(rows);
97
                } else {
97
                } else {
98
                    // ((BonDeLivraisonSQLComponent) comp).loadFromReliquat(rows);
98
                    // ((BonDeLivraisonSQLComponent) comp).loadFromReliquat(rows);
99
 
99
 
100
                }
100
                }
101
                frame.setVisible(true);
101
                frame.setVisible(true);
102
 
102
 
103
            }
103
            }
104
        }, true);
104
        }, true);
105
        actionTR.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
105
        actionTR.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
106
        getRowActions().add(actionTR);
106
        getRowActions().add(actionTR);
107
    }
107
    }
108
 
108
 
109
    public ReliquatSQLElement() {
109
    public ReliquatSQLElement() {
110
        this("RELIQUAT_BL", "un reliquat de BL", "reliquats de BL", "BON_DE_LIVRAISON");
110
        this("RELIQUAT_BL", "un reliquat de BL", "reliquats de BL", "BON_DE_LIVRAISON");
111
    }
111
    }
112
 
112
 
113
    @Override
113
    @Override
114
    protected String getParentFFName() {
114
    protected String getParentFFName() {
115
        return "ID_" + this.tableBonName;
115
        return "ID_" + this.tableBonName;
116
    }
116
    }
117
 
117
 
118
    protected List<String> getListFields() {
118
    protected List<String> getListFields() {
119
        final List<String> l = new ArrayList<String>();
119
        final List<String> l = new ArrayList<String>();
120
        // l.add("DATE");
120
        // l.add("DATE");
121
        l.add("ID_" + this.tableBonName + "_ORIGINE");
121
        l.add("ID_" + this.tableBonName + "_ORIGINE");
122
        l.add("ID_ARTICLE");
122
        l.add("ID_ARTICLE");
123
        l.add("QTE_UNITAIRE");
123
        l.add("QTE_UNITAIRE");
124
        l.add("ID_UNITE_VENTE");
124
        l.add("ID_UNITE_VENTE");
125
        l.add("QTE");
125
        l.add("QTE");
126
        l.add("ID_" + this.tableBonName);
126
        l.add("ID_" + this.tableBonName);
127
        return l;
127
        return l;
128
    }
128
    }
129
 
129
 
130
    protected List<String> getComboFields() {
130
    protected List<String> getComboFields() {
131
        final List<String> l = new ArrayList<String>();
131
        final List<String> l = new ArrayList<String>();
132
        l.add("DATE");
132
        l.add("DATE");
133
        l.add("QTE");
133
        l.add("QTE");
134
        return l;
134
        return l;
135
    }
135
    }
136
 
136
 
137
    /*
137
    /*
138
     * (non-Javadoc)
138
     * (non-Javadoc)
139
     * 
139
     * 
140
     * @see org.openconcerto.devis.SQLElement#getComponent()
140
     * @see org.openconcerto.devis.SQLElement#getComponent()
141
     */
141
     */
142
    public SQLComponent createComponent() {
142
    public SQLComponent createComponent() {
143
        return new BaseSQLComponent(this) {
143
        return new BaseSQLComponent(this) {
144
            FactureAffacturerTable table = new FactureAffacturerTable(null);
144
            FactureAffacturerTable table = new FactureAffacturerTable(null);
145
 
145
 
146
            public void addViews() {
146
            public void addViews() {
147
 
147
 
148
                // FIXME CREATION DE L'UI
148
                // FIXME CREATION DE L'UI
149
                this.setLayout(new GridBagLayout());
149
                this.setLayout(new GridBagLayout());
150
 
150
 
151
                GridBagConstraints c = new DefaultGridBagConstraints();
151
                GridBagConstraints c = new DefaultGridBagConstraints();
152
 
152
 
153
                this.add(new JLabel(getLabelFor("NB_FACT")), c);
153
                this.add(new JLabel(getLabelFor("NB_FACT")), c);
154
                // c.gridx++;
154
                // c.gridx++;
155
                // c.weightx = 1;
155
                // c.weightx = 1;
156
                // JTextField fieldNbFact = new JTextField();
156
                // JTextField fieldNbFact = new JTextField();
157
                // this.add(fieldNbFact, c);
157
                // this.add(fieldNbFact, c);
158
                //
158
                //
159
                // c.gridx++;
159
                // c.gridx++;
160
                // c.weightx = 0;
160
                // c.weightx = 0;
161
                // this.add(new JLabel(getLabelFor("MONTANT_FACT")), c);
161
                // this.add(new JLabel(getLabelFor("MONTANT_FACT")), c);
162
                // c.gridx++;
162
                // c.gridx++;
163
                // c.weightx = 1;
163
                // c.weightx = 1;
164
                // DeviseField fieldMontantFact = new DeviseField();
164
                // DeviseField fieldMontantFact = new DeviseField();
165
                // this.add(fieldMontantFact, c);
165
                // this.add(fieldMontantFact, c);
166
                //
166
                //
167
                // c.gridx++;
167
                // c.gridx++;
168
                // c.weightx = 0;
168
                // c.weightx = 0;
169
                // this.add(new JLabel(getLabelFor("DATE")), c);
169
                // this.add(new JLabel(getLabelFor("DATE")), c);
170
                // c.gridx++;
170
                // c.gridx++;
171
                //
171
                //
172
                // JDate date = new JDate();
172
                // JDate date = new JDate();
173
                // this.add(date, c);
173
                // this.add(date, c);
174
                //
174
                //
175
                // c.gridwidth = GridBagConstraints.REMAINDER;
175
                // c.gridwidth = GridBagConstraints.REMAINDER;
176
                // c.gridx = 0;
176
                // c.gridx = 0;
177
                // c.gridy++;
177
                // c.gridy++;
178
                // this.add(this.table, c);
178
                // this.add(this.table, c);
179
                //
179
                //
180
                // this.addView(fieldNbFact, "NB_FACT");
180
                // this.addView(fieldNbFact, "NB_FACT");
181
                // this.addSQLObject(fieldMontantFact, "MONTANT_FACT");
181
                // this.addSQLObject(fieldMontantFact, "MONTANT_FACT");
182
                // this.addView(date, "DATE");
182
                // this.addView(date, "DATE");
183
            }
183
            }
184
 
184
 
185
        };
185
        };
186
    }
186
    }
187
 
187
 
188
    @Override
188
    @Override
189
    protected String createCode() {
189
    protected String createCode() {
190
        return createCodeFromPackage() + ".reliquatbl";
190
        return createCodeOfPackage() + ".reliquatbl";
191
    }
191
    }
192
}
192
}