Dépôt officiel du code source de l'ERP OpenConcerto
Rev 142 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.supplychain.order.action;
import org.openconcerto.erp.action.CreateIListFrameAbstractAction;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
import org.openconcerto.erp.core.supplychain.order.element.CommandeElementSQLElement;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLName;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.view.IListPanel;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.cc.ITransformer;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.JPanel;
public class ListeDesElementsACommanderAction extends CreateIListFrameAbstractAction<CommandeElementSQLElement> {
public ListeDesElementsACommanderAction(final ComptaPropsConfiguration conf) {
super(conf, CommandeElementSQLElement.class);
}
@Override
protected String getPanelVariant() {
return this.getClass().getSimpleName();
}
@Override
protected SQLTableModelSource createTableSource() {
final SQLTableModelSource tableSource = super.createTableSource();
final SQLElement eltCmd = getElem();
tableSource.getReq().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
@Override
public SQLSelect transformChecked(SQLSelect input) {
// new SQLName(eltCmd.getTable().getDBRoot().getName(),
// tableBLElement.getName()).quote()
final String quoteQteL = new SQLName(input.getAlias(eltCmd.getTable()).getAlias(), "QTE_RECUE").quote();
final String quoteQte = new SQLName(input.getAlias(eltCmd.getTable()).getAlias(), "QTE").quote();
final String quoteQteU = new SQLName(input.getAlias(eltCmd.getTable()).getAlias(), "QTE_UNITAIRE").quote();
Where w = Where.createRaw(quoteQteL + " < (" + quoteQte + "*" + quoteQteU + ")", eltCmd.getTable().getField("QTE_RECUE"), eltCmd.getTable().getField("QTE"),
eltCmd.getTable().getField("QTE_UNITAIRE"));
w = w.and(new Where(eltCmd.getTable().getField("RECU_FORCED"), "=", Boolean.FALSE));
input.setWhere(w);
return input;
}
});
return tableSource;
}
@Override
protected IListPanel instantiateListPanel(final SQLTableModelSource tableSource, String panelVariant) {
final IListPanel panel = super.instantiateListPanel(tableSource, panelVariant);
// final List<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>> fields = new
// ArrayList<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>>(2);
// fields.add(Tuple2.create(panel.getListe().getSource().getColumn(eltCmd.getTable().getField("T_HT")),
// IListTotalPanel.Type.SOMME));
// fields.add(Tuple2.create(this.colAvancement, IListTotalPanel.Type.AVANCEMENT_TTC));
// final IListTotalPanel totalPanel = new IListTotalPanel(panel.getListe(), fields, null,
// "Total des commandes de la liste");
final GridBagConstraints c = new DefaultGridBagConstraints();
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.EAST;
c.weightx = 1;
c.gridy = 4;
// Date panel
final IListFilterDatePanel datePanel = new IListFilterDatePanel(panel.getListe(), getElem().getTable().getForeignTable("ID_COMMANDE").getField("DATE"), IListFilterDatePanel.getDefaultMap());
datePanel.setFilterOnDefault();
final JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new GridBagLayout());
bottomPanel.setOpaque(false);
final GridBagConstraints c2 = new DefaultGridBagConstraints();
c2.fill = GridBagConstraints.NONE;
c2.weightx = 1;
bottomPanel.add(datePanel, c2);
// c2.gridx++;
// c2.weightx = 0;
// c2.anchor = GridBagConstraints.EAST;
// bottomPanel.add(totalPanel, c2);
panel.add(bottomPanel, c);
return panel;
}
}