OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
142 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
185 ilm 4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
142 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.order.action;
15
 
156 ilm 16
import org.openconcerto.erp.action.CreateIListFrameAbstractAction;
17
import org.openconcerto.erp.config.ComptaPropsConfiguration;
142 ilm 18
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
156 ilm 19
import org.openconcerto.erp.core.supplychain.order.element.CommandeElementSQLElement;
142 ilm 20
import org.openconcerto.sql.element.SQLElement;
21
import org.openconcerto.sql.model.SQLName;
22
import org.openconcerto.sql.model.SQLSelect;
23
import org.openconcerto.sql.model.Where;
156 ilm 24
import org.openconcerto.sql.view.IListPanel;
25
import org.openconcerto.sql.view.list.SQLTableModelSource;
142 ilm 26
import org.openconcerto.ui.DefaultGridBagConstraints;
27
import org.openconcerto.utils.cc.ITransformer;
28
 
29
import java.awt.GridBagConstraints;
30
import java.awt.GridBagLayout;
31
 
32
import javax.swing.JPanel;
33
 
156 ilm 34
public class ListeDesElementsACommanderAction extends CreateIListFrameAbstractAction<CommandeElementSQLElement> {
142 ilm 35
 
156 ilm 36
    public ListeDesElementsACommanderAction(final ComptaPropsConfiguration conf) {
37
        super(conf, CommandeElementSQLElement.class);
142 ilm 38
    }
39
 
156 ilm 40
    @Override
41
    protected String getPanelVariant() {
42
        return this.getClass().getSimpleName();
142 ilm 43
    }
44
 
156 ilm 45
    @Override
46
    protected SQLTableModelSource createTableSource() {
47
        final SQLTableModelSource tableSource = super.createTableSource();
48
        final SQLElement eltCmd = getElem();
142 ilm 49
        tableSource.getReq().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
50
 
51
            @Override
52
            public SQLSelect transformChecked(SQLSelect input) {
53
                // new SQLName(eltCmd.getTable().getDBRoot().getName(),
54
                // tableBLElement.getName()).quote()
55
                final String quoteQteL = new SQLName(input.getAlias(eltCmd.getTable()).getAlias(), "QTE_RECUE").quote();
56
                final String quoteQte = new SQLName(input.getAlias(eltCmd.getTable()).getAlias(), "QTE").quote();
57
                final String quoteQteU = new SQLName(input.getAlias(eltCmd.getTable()).getAlias(), "QTE_UNITAIRE").quote();
58
                Where w = Where.createRaw(quoteQteL + " < (" + quoteQte + "*" + quoteQteU + ")", eltCmd.getTable().getField("QTE_RECUE"), eltCmd.getTable().getField("QTE"),
185 ilm 59
                        eltCmd.getTable().getField("QTE_UNITAIRE")).or(Where.isNull(input.getAlias(eltCmd.getTable()).getField("QTE_RECUE")));
156 ilm 60
                w = w.and(new Where(eltCmd.getTable().getField("RECU_FORCED"), "=", Boolean.FALSE));
142 ilm 61
                input.setWhere(w);
62
                return input;
63
            }
64
        });
65
 
156 ilm 66
        return tableSource;
142 ilm 67
    }
68
 
156 ilm 69
    @Override
70
    protected IListPanel instantiateListPanel(final SQLTableModelSource tableSource, String panelVariant) {
71
        final IListPanel panel = super.instantiateListPanel(tableSource, panelVariant);
142 ilm 72
        // final List<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>> fields = new
73
        // ArrayList<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>>(2);
74
        // fields.add(Tuple2.create(panel.getListe().getSource().getColumn(eltCmd.getTable().getField("T_HT")),
75
        // IListTotalPanel.Type.SOMME));
76
        // fields.add(Tuple2.create(this.colAvancement, IListTotalPanel.Type.AVANCEMENT_TTC));
77
        // final IListTotalPanel totalPanel = new IListTotalPanel(panel.getListe(), fields, null,
78
        // "Total des commandes de la liste");
79
 
80
        final GridBagConstraints c = new DefaultGridBagConstraints();
81
        c.gridwidth = GridBagConstraints.REMAINDER;
82
        c.fill = GridBagConstraints.BOTH;
83
        c.anchor = GridBagConstraints.EAST;
84
        c.weightx = 1;
85
        c.gridy = 4;
86
 
87
        // Date panel
156 ilm 88
        final IListFilterDatePanel datePanel = new IListFilterDatePanel(panel.getListe(), getElem().getTable().getForeignTable("ID_COMMANDE").getField("DATE"), IListFilterDatePanel.getDefaultMap());
142 ilm 89
 
90
        datePanel.setFilterOnDefault();
91
 
92
        final JPanel bottomPanel = new JPanel();
93
        bottomPanel.setLayout(new GridBagLayout());
94
        bottomPanel.setOpaque(false);
95
        final GridBagConstraints c2 = new DefaultGridBagConstraints();
96
        c2.fill = GridBagConstraints.NONE;
97
        c2.weightx = 1;
98
        bottomPanel.add(datePanel, c2);
99
 
100
        // c2.gridx++;
101
        // c2.weightx = 0;
102
        // c2.anchor = GridBagConstraints.EAST;
103
        // bottomPanel.add(totalPanel, c2);
104
 
105
        panel.add(bottomPanel, c);
106
        return panel;
107
    }
108
 
109
}