156 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
182 |
ilm |
4 |
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
|
156 |
ilm |
5 |
*
|
|
|
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
|
|
|
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.
|
|
|
10 |
*
|
|
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
package org.openconcerto.erp.core.supplychain.stock.element;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
|
|
17 |
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
|
|
|
18 |
import org.openconcerto.erp.core.sales.invoice.report.EtatStockInventaireXmlSheet;
|
|
|
19 |
import org.openconcerto.sql.element.GroupSQLComponent;
|
|
|
20 |
import org.openconcerto.sql.element.SQLComponent;
|
|
|
21 |
import org.openconcerto.sql.element.SQLElement;
|
|
|
22 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
|
|
23 |
import org.openconcerto.sql.model.Where;
|
|
|
24 |
import org.openconcerto.sql.view.IListFrame;
|
|
|
25 |
import org.openconcerto.sql.view.list.IListe;
|
|
|
26 |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
|
|
|
27 |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
|
|
|
28 |
import org.openconcerto.sql.view.list.SQLTableModelSource;
|
|
|
29 |
import org.openconcerto.ui.FrameUtil;
|
177 |
ilm |
30 |
import org.openconcerto.ui.PanelFrame;
|
156 |
ilm |
31 |
import org.openconcerto.utils.ExceptionHandler;
|
|
|
32 |
|
|
|
33 |
import java.awt.event.ActionEvent;
|
|
|
34 |
import java.util.ArrayList;
|
182 |
ilm |
35 |
import java.util.Collections;
|
156 |
ilm |
36 |
import java.util.Date;
|
|
|
37 |
import java.util.List;
|
|
|
38 |
|
|
|
39 |
import javax.swing.AbstractAction;
|
|
|
40 |
import javax.swing.JComponent;
|
|
|
41 |
import javax.swing.JTextField;
|
|
|
42 |
|
|
|
43 |
public class EtatStockSQLElement extends ComptaSQLConfElement {
|
|
|
44 |
|
|
|
45 |
public EtatStockSQLElement() {
|
|
|
46 |
super("ETAT_STOCK");
|
|
|
47 |
setDefaultGroup(new EtatStockGroup());
|
|
|
48 |
{
|
|
|
49 |
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Créer un état de stock") {
|
|
|
50 |
|
|
|
51 |
@Override
|
|
|
52 |
public void actionPerformed(ActionEvent e) {
|
182 |
ilm |
53 |
PanelFrame frame = new PanelFrame(new EtatStockCreationPanel(getDirectory().getElement(DepotStockSQLElement.class)), "Création état de stock");
|
|
|
54 |
FrameUtil.showPacked(frame);
|
156 |
ilm |
55 |
}
|
|
|
56 |
}, true);
|
|
|
57 |
action.setPredicate(IListeEvent.createSelectionCountPredicate(0, Integer.MAX_VALUE));
|
|
|
58 |
getRowActions().add(action);
|
|
|
59 |
}
|
|
|
60 |
{
|
|
|
61 |
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Voir les articles") {
|
|
|
62 |
|
|
|
63 |
@Override
|
|
|
64 |
public void actionPerformed(ActionEvent e) {
|
|
|
65 |
final SQLElement element = getDirectory().getElement("ETAT_STOCK_ELEMENT");
|
|
|
66 |
SQLTableModelSource source = element.createTableSource(new Where(element.getTable().getField("ID_ETAT_STOCK"), "=", IListe.get(e).getSelectedId()));
|
|
|
67 |
final ListeViewPanel panel = new ListeViewPanel(element, new IListe(source));
|
|
|
68 |
IListFrame frame = new IListFrame(panel);
|
|
|
69 |
FrameUtil.show(frame);
|
|
|
70 |
}
|
|
|
71 |
}, true);
|
|
|
72 |
action.setPredicate(IListeEvent.getSingleSelectionPredicate());
|
|
|
73 |
getRowActions().add(action);
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
{
|
|
|
77 |
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Export pour inventaire") {
|
|
|
78 |
@Override
|
|
|
79 |
public void actionPerformed(ActionEvent e) {
|
|
|
80 |
EtatStockInventaireXmlSheet sheet = new EtatStockInventaireXmlSheet(IListe.get(e).getSelectedRow().asRow());
|
|
|
81 |
try {
|
|
|
82 |
sheet.createDocument();
|
182 |
ilm |
83 |
sheet.showPrintAndExport(true, false, false, false, false, Collections.emptyList());
|
156 |
ilm |
84 |
} catch (Exception e1) {
|
|
|
85 |
ExceptionHandler.handle("Erreur lors de la création de l'inventaire", e1);
|
|
|
86 |
}
|
|
|
87 |
}
|
|
|
88 |
}, true);
|
|
|
89 |
action.setPredicate(IListeEvent.getSingleSelectionPredicate());
|
|
|
90 |
getRowActions().add(action);
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
{
|
|
|
94 |
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Import Inventaire") {
|
|
|
95 |
@Override
|
|
|
96 |
public void actionPerformed(ActionEvent e) {
|
177 |
ilm |
97 |
PanelFrame frame = new PanelFrame(new ImportInventairePanel(getDirectory().getElement(DepotStockSQLElement.class)), "Import inventaire");
|
|
|
98 |
FrameUtil.showPacked(frame);
|
156 |
ilm |
99 |
}
|
|
|
100 |
}, true);
|
182 |
ilm |
101 |
action.setPredicate(IListeEvent.createSelectionCountPredicate(0, Integer.MAX_VALUE));
|
156 |
ilm |
102 |
getRowActions().add(action);
|
|
|
103 |
}
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
@Override
|
|
|
107 |
protected List<String> getListFields() {
|
|
|
108 |
final List<String> l = new ArrayList<>(3);
|
|
|
109 |
l.add("DATE");
|
|
|
110 |
l.add("MONTANT_HA");
|
|
|
111 |
l.add("INVENTAIRE");
|
|
|
112 |
return l;
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
@Override
|
|
|
116 |
protected List<String> getComboFields() {
|
|
|
117 |
final List<String> l = new ArrayList<>(2);
|
|
|
118 |
l.add("DATE");
|
|
|
119 |
l.add("MONTANT_HA");
|
|
|
120 |
return l;
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
/*
|
|
|
124 |
* (non-Javadoc)
|
|
|
125 |
*
|
|
|
126 |
* @see org.openconcerto.devis.SQLElement#getComponent()
|
|
|
127 |
*/
|
|
|
128 |
public SQLComponent createComponent() {
|
|
|
129 |
return new GroupSQLComponent(this) {
|
|
|
130 |
|
|
|
131 |
@Override
|
|
|
132 |
public JComponent createEditor(String id) {
|
|
|
133 |
if (id.equals("supplychain.stock.state.items")) {
|
|
|
134 |
return new EtatStockTable((JTextField) getEditor("MONTANT_HA"));
|
|
|
135 |
} else {
|
|
|
136 |
return super.createEditor(id);
|
|
|
137 |
}
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
@Override
|
|
|
141 |
public void select(SQLRowAccessor r) {
|
|
|
142 |
super.select(r);
|
|
|
143 |
EtatStockTable table = (EtatStockTable) getEditor("supplychain.stock.state.items");
|
|
|
144 |
if (r != null) {
|
|
|
145 |
table.insertFrom("ID_ETAT_STOCK", r.getID());
|
|
|
146 |
}
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
@Override
|
|
|
150 |
public void update() {
|
|
|
151 |
super.update();
|
|
|
152 |
EtatStockTable table = (EtatStockTable) getEditor("supplychain.stock.state.items");
|
|
|
153 |
table.updateField("ID_ETAT_STOCK", getSelectedID());
|
|
|
154 |
}
|
|
|
155 |
};
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
@Override
|
|
|
159 |
protected String createCode() {
|
|
|
160 |
return createCodeOfPackage() + ".state";
|
|
|
161 |
}
|
|
|
162 |
|
|
|
163 |
}
|