OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 181 → Rev 182

/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/stock/action/ListeDesStocksAction.java
1,7 → 1,7
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
* Copyright 2011-2019 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
16,8 → 16,7
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.IListTotalPanel;
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.rights.DepotStockViewRightEditor;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.FieldPath;
28,6 → 27,7
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.users.rights.UserRightsManager;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListe;
34,6 → 34,7
import org.openconcerto.sql.view.list.SQLTableModelColumn;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.PanelFrame;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.Tuple2;
53,8 → 54,15
 
public class ListeDesStocksAction extends CreateFrameAbstractAction {
 
private final boolean besoin;
 
public ListeDesStocksAction() {
this(false);
}
 
public ListeDesStocksAction(boolean b) {
super();
this.besoin = b;
this.putValue(Action.NAME, "Liste des stocks");
 
}
67,9 → 75,32
List<SQLRow> rowsEtat = SQLBackgroundTableCache.getInstance().getCacheForTable(depotTable).getRows();
 
JTabbedPane tabs = new JTabbedPane();
 
boolean canViewAll = true;
for (final SQLRow sqlRow : rowsEtat) {
boolean canView = UserRightsManager.getCurrentUserRights().haveRight(DepotStockViewRightEditor.ID_RIGHT, String.valueOf(sqlRow.getID()));
canViewAll &= canView;
if (canView) {
 
ListeAddPanel panel = createPanel(eltStock, stockTable, sqlRow);
tabs.add(sqlRow.getString("NOM"), panel);
}
 
}
 
if (canViewAll && this.besoin) {
tabs.insertTab("Global", null, createPanel(eltStock, stockTable, null), null, 0);
}
 
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
panel.add(tabs, c);
return new PanelFrame(panel, "Liste des stocks");
}
 
private ListeAddPanel createPanel(SQLElement eltStock, final SQLTable stockTable, final SQLRow sqlRow) {
final SQLTableModelSourceOnline tableSource = eltStock.getTableSource(true);
 
SQLTableModelColumn colStock;
100,7 → 131,6
@Override
public Set<FieldPath> getPaths() {
final SQLTable table = stockTable;
Path p = new Path(table);
Path p2 = new Path(table).addForeignField("ID_ARTICLE");
return CollectionUtils.createSet(new FieldPath(p2, "PA_HT"));
}
113,7 → 143,11
 
@Override
public SQLSelect transformChecked(SQLSelect input) {
input.setWhere(new Where(input.getTable("STOCK").getField("ID_DEPOT_STOCK"), "=", sqlRow.getID()));
Where w = sqlRow == null ? null : new Where(input.getTable("STOCK").getField("ID_DEPOT_STOCK"), "=", sqlRow.getID());
if (besoin) {
w = Where.and(w, new Where(input.getTable("STOCK").getField("QTE_TH"), "<", input.getTable("STOCK").getField("QTE_MIN")));
}
input.setWhere(w);
return input;
}
});
132,14 → 166,6
c2.weightx = 0;
c2.fill = GridBagConstraints.NONE;
panel.add(total, c2);
tabs.add(sqlRow.getString("NOM"), panel);
return panel;
}
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
panel.add(tabs, c);
return new PanelFrame(panel, "Liste des stocks");
}
}