OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 151 Rev 156
Line 11... Line 11...
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.order.action;
14
 package org.openconcerto.erp.core.sales.order.action;
15
 
15
 
16
import org.openconcerto.erp.action.CreateFrameAbstractAction;
16
import org.openconcerto.erp.action.CreateIListFrameAbstractAction;
-
 
17
import org.openconcerto.erp.config.ComptaPropsConfiguration;
17
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
18
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
18
import org.openconcerto.erp.core.common.ui.IListTotalPanel;
19
import org.openconcerto.erp.core.common.ui.IListTotalPanel;
19
import org.openconcerto.erp.core.common.ui.IListTotalPanel.Type;
20
import org.openconcerto.erp.core.common.ui.IListTotalPanel.Type;
20
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
21
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
21
import org.openconcerto.sql.Configuration;
22
import org.openconcerto.erp.core.sales.order.element.CommandeClientElementSQLElement;
22
import org.openconcerto.sql.element.SQLElement;
23
import org.openconcerto.sql.element.SQLElement;
23
import org.openconcerto.sql.model.FieldPath;
24
import org.openconcerto.sql.model.FieldPath;
24
import org.openconcerto.sql.model.SQLRowAccessor;
25
import org.openconcerto.sql.model.SQLRowAccessor;
25
import org.openconcerto.sql.model.Where;
26
import org.openconcerto.sql.model.Where;
26
import org.openconcerto.sql.model.graph.Path;
27
import org.openconcerto.sql.model.graph.Path;
27
import org.openconcerto.sql.view.IListFrame;
28
import org.openconcerto.sql.view.IListFrame;
-
 
29
import org.openconcerto.sql.view.IListPanel;
28
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
30
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
29
import org.openconcerto.sql.view.list.IListe;
31
import org.openconcerto.sql.view.list.IListe;
30
import org.openconcerto.sql.view.list.SQLTableModelColumn;
32
import org.openconcerto.sql.view.list.SQLTableModelColumn;
31
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
33
import org.openconcerto.sql.view.list.SQLTableModelSource;
32
import org.openconcerto.ui.DefaultGridBagConstraints;
34
import org.openconcerto.ui.DefaultGridBagConstraints;
33
import org.openconcerto.utils.CollectionUtils;
-
 
34
import org.openconcerto.utils.Tuple2;
35
import org.openconcerto.utils.Tuple2;
35
 
36
 
36
import java.awt.GridBagConstraints;
37
import java.awt.GridBagConstraints;
37
import java.math.BigDecimal;
38
import java.math.BigDecimal;
38
import java.util.ArrayList;
39
import java.util.ArrayList;
-
 
40
import java.util.Arrays;
39
import java.util.List;
41
import java.util.List;
40
import java.util.Set;
42
import java.util.Set;
41
 
43
 
42
import javax.swing.Action;
44
public class ListeDesCommandesClientItemsAction extends CreateIListFrameAbstractAction<CommandeClientElementSQLElement> {
43
import javax.swing.JFrame;
-
 
44
 
45
 
45
public class ListeDesCommandesClientItemsAction extends CreateFrameAbstractAction {
46
    public ListeDesCommandesClientItemsAction(final ComptaPropsConfiguration conf) {
-
 
47
        super(conf, CommandeClientElementSQLElement.class);
-
 
48
    }
-
 
49
 
-
 
50
    @Override
-
 
51
    protected SQLTableModelSource createTableSource() {
-
 
52
        final SQLTableModelSource res = super.createTableSource();
-
 
53
        res.getReq().setWhere(new Where(getElem().getTable().getField("ID_COMMANDE_CLIENT"), ">", 1));
-
 
54
        return res;
-
 
55
    }
46
 
56
 
47
    public ListeDesCommandesClientItemsAction() {
-
 
48
        super();
57
    @Override
-
 
58
    protected IListPanel instantiateListPanel(final SQLTableModelSource tableSource, String panelVariant) {
49
        this.putValue(Action.NAME, "Liste des articles commandés");
59
        return new ListeViewPanel(tableSource.getElem(), new IListe(tableSource));
50
    }
60
    }
51
 
61
 
-
 
62
    @Override
-
 
63
    protected void initFrame(IListFrame frame) {
52
    public JFrame createFrame() {
64
        super.initFrame(frame);
53
        final SQLElement element = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT_ELEMENT");
65
        final SQLElement element = getElem();
54
 
66
 
55
        final SQLTableModelSourceOnline tableSource = element.getTableSource(true);
-
 
56
        IListe liste = new IListe(tableSource);
67
        final IListPanel listeAddPanel = frame.getPanel();
57
        final ListeViewPanel listeAddPanel = new ListeViewPanel(element, liste);
68
        final SQLTableModelSource tableSource = listeAddPanel.getListe().getSource();
58
        listeAddPanel.getListe().getRequest().setWhere(new Where(element.getTable().getField("ID_COMMANDE_CLIENT"), ">", 1));
-
 
59
 
69
 
-
 
70
        final Set<FieldPath> paths = FieldPath.create(new Path(getElem().getTable()), Arrays.asList("QTE", "QTE_UNITAIRE", "QTE_LIVREE"));
60
        BaseSQLTableModelColumn colStockR = new BaseSQLTableModelColumn("Qté restante à livrer", BigDecimal.class) {
71
        BaseSQLTableModelColumn colStockR = new BaseSQLTableModelColumn("Qté restante à livrer", BigDecimal.class) {
61
 
72
 
62
            @Override
73
            @Override
63
            protected Object show_(SQLRowAccessor r) {
74
            protected Object show_(SQLRowAccessor r) {
64
 
75
 
Line 70... Line 81...
70
                return qteAlivrer.subtract(qteLivree);
81
                return qteAlivrer.subtract(qteLivree);
71
            }
82
            }
72
 
83
 
73
            @Override
84
            @Override
74
            public Set<FieldPath> getPaths() {
85
            public Set<FieldPath> getPaths() {
75
                Path p = new Path(element.getTable());
86
                return paths;
76
                return CollectionUtils.createSet(new FieldPath(p, "QTE"), new FieldPath(p, "QTE_UNITAIRE"), new FieldPath(p, "QTE_LIVREE"));
-
 
77
            }
87
            }
78
        };
88
        };
79
        tableSource.getColumns().add(colStockR);
89
        tableSource.getColumns().add(colStockR);
80
 
90
 
81
        List<Tuple2<? extends SQLTableModelColumn, Type>> listField = new ArrayList<Tuple2<? extends SQLTableModelColumn, Type>>();
91
        List<Tuple2<? extends SQLTableModelColumn, Type>> listField = new ArrayList<Tuple2<? extends SQLTableModelColumn, Type>>();
Line 90... Line 100...
90
        c.weightx = 0;
100
        c.weightx = 0;
91
        c.weighty = 0;
101
        c.weighty = 0;
92
        c.anchor = GridBagConstraints.EAST;
102
        c.anchor = GridBagConstraints.EAST;
93
        c.fill = GridBagConstraints.NONE;
103
        c.fill = GridBagConstraints.NONE;
94
        listeAddPanel.add(total, c);
104
        listeAddPanel.add(total, c);
95
        IListFrame frame = new IListFrame(listeAddPanel);
-
 
-
 
105
 
96
        frame.setTextTitle("Liste des articles commandés");
106
        frame.setTextTitle(String.valueOf(getValue(NAME)));
97
        frame.getPanel().getListe().setModificationAllowed(false);
107
        frame.getPanel().getListe().setModificationAllowed(false);
98
        frame.getPanel().setAddVisible(false);
108
        frame.getPanel().setAddVisible(false);
99
        frame.getPanel().setSearchFullMode(true);
109
        frame.getPanel().setSearchFullMode(true);
100
 
110
 
101
        // Date panel
111
        // Date panel
102
        IListFilterDatePanel datePanel = new IListFilterDatePanel(frame.getPanel().getListe(), element.getTable().getTable("COMMANDE_CLIENT").getField("DATE"), IListFilterDatePanel.getDefaultMap());
112
        IListFilterDatePanel datePanel = new IListFilterDatePanel(frame.getPanel().getListe(), element.getTable().getTable("COMMANDE_CLIENT").getField("DATE"), IListFilterDatePanel.getDefaultMap());
103
        c.gridy++;
113
        c.gridy++;
104
        c.anchor = GridBagConstraints.CENTER;
114
        c.anchor = GridBagConstraints.CENTER;
105
        frame.getPanel().add(datePanel, c);
115
        frame.getPanel().add(datePanel, c);
106
 
-
 
107
        return frame;
-
 
108
    }
116
    }
109
}
117
}