Line 1... |
Line 1... |
1 |
/*
|
1 |
/*
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
3 |
*
|
3 |
*
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
4 |
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
|
5 |
*
|
5 |
*
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
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
|
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
|
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.
|
9 |
* language governing permissions and limitations under the License.
|
Line 15... |
Line 15... |
15 |
|
15 |
|
16 |
import org.openconcerto.erp.action.CreateIListFrameAbstractAction;
|
16 |
import org.openconcerto.erp.action.CreateIListFrameAbstractAction;
|
17 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
17 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
18 |
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
|
18 |
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
|
19 |
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
|
19 |
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
|
- |
|
20 |
import org.openconcerto.erp.core.common.ui.NumberCellRenderer;
|
20 |
import org.openconcerto.erp.core.sales.order.element.CommandeClientElementSQLElement;
|
21 |
import org.openconcerto.erp.core.sales.order.element.CommandeClientElementSQLElement;
|
21 |
import org.openconcerto.erp.core.sales.product.ui.QteAcommanderRenderer;
|
22 |
import org.openconcerto.erp.core.sales.product.ui.QteAcommanderRenderer;
|
- |
|
23 |
import org.openconcerto.erp.core.supplychain.stock.action.ListeDesStocksAction;
|
22 |
import org.openconcerto.erp.core.supplychain.stock.element.StockSQLElement;
|
24 |
import org.openconcerto.erp.core.supplychain.stock.element.StockSQLElement;
|
23 |
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
|
25 |
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
|
24 |
import org.openconcerto.sql.element.SQLElement;
|
26 |
import org.openconcerto.sql.element.SQLElement;
|
25 |
import org.openconcerto.sql.model.FieldPath;
|
27 |
import org.openconcerto.sql.model.FieldPath;
|
26 |
import org.openconcerto.sql.model.FieldRef;
|
28 |
import org.openconcerto.sql.model.FieldRef;
|
Line 304... |
Line 306... |
304 |
|
306 |
|
305 |
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Calcul des besoins") {
|
307 |
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Calcul des besoins") {
|
306 |
|
308 |
|
307 |
@Override
|
309 |
@Override
|
308 |
public void actionPerformed(ActionEvent e) {
|
310 |
public void actionPerformed(ActionEvent e) {
|
- |
|
311 |
|
- |
|
312 |
final SQLPreferences prefs = SQLPreferences.getMemCached(eltCmd.getTable().getDBRoot());
|
- |
|
313 |
|
- |
|
314 |
if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_MULTI_DEPOT, false)) {
|
- |
|
315 |
ListeDesStocksAction action = new ListeDesStocksAction(true);
|
- |
|
316 |
FrameUtil.show(action.createFrame());
|
- |
|
317 |
} else {
|
- |
|
318 |
|
309 |
final SQLElement artElt = eltCmd.getForeignElement("ID_ARTICLE");
|
319 |
final SQLElement artElt = eltCmd.getForeignElement("ID_ARTICLE");
|
310 |
final SQLTableModelSourceOnline createTableSource = artElt.createTableSource();
|
320 |
final SQLTableModelSourceOnline createTableSource = artElt.createTableSource();
|
311 |
createTableSource.getReq().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
321 |
createTableSource.getReq().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
312 |
@Override
|
322 |
@Override
|
313 |
public SQLSelect transformChecked(SQLSelect input) {
|
323 |
public SQLSelect transformChecked(SQLSelect input) {
|
314 |
FieldRef refStock = input.getAlias(artElt.getTable().getForeignTable("ID_STOCK").getField("QTE_TH"));
|
324 |
FieldRef refStock = input.getAlias(artElt.getTable().getForeignTable("ID_STOCK").getField("QTE_TH"));
|
- |
|
325 |
FieldRef refStockMin = input.getAlias(artElt.getTable().getForeignTable("ID_STOCK").getField("QTE_MIN"));
|
315 |
|
326 |
|
316 |
SQLSelectJoin j = input.getJoinFromField(artElt.getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT"));
|
327 |
SQLSelectJoin j = input.getJoinFromField(artElt.getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT"));
|
- |
|
328 |
if (j == null) {
|
- |
|
329 |
j = input.addBackwardJoin("LEFT", artElt.getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT"), null);
|
- |
|
330 |
}
|
- |
|
331 |
|
317 |
Where w = new Where(refStock, "<", artElt.getTable().getField("QTE_MIN"));
|
332 |
Where w = new Where(refStock, "<", refStockMin);
|
318 |
w = w.and(new Where(j.getJoinedTable().getKey(), "=", (Object) null));
|
333 |
w = w.and(new Where(j.getJoinedTable().getKey(), "=", (Object) null));
|
319 |
input.setWhere(w);
|
334 |
input.setWhere(w);
|
320 |
// input.setHaving(Where.createRaw("COUNT(\"" + j.getJoinedTable().getKey()
|
335 |
// input.setHaving(Where.createRaw("COUNT(\"" +
|
- |
|
336 |
// j.getJoinedTable().getKey()
|
321 |
// + "\")" + " = 0", Arrays.asList(j.getJoinedTable().getKey())));
|
337 |
// + "\")" + " = 0", Arrays.asList(j.getJoinedTable().getKey())));
|
322 |
return input;
|
338 |
return input;
|
323 |
}
|
339 |
}
|
324 |
});
|
340 |
});
|
325 |
|
341 |
|
326 |
IListe listeArt = new IListe(createTableSource);
|
342 |
IListe listeArt = new IListe(createTableSource);
|
327 |
final PredicateRowAction predicateACtion = new PredicateRowAction(new AbstractAction("Passer une commande fournisseur") {
|
343 |
final PredicateRowAction predicateACtion = new PredicateRowAction(new AbstractAction("Passer une commande fournisseur") {
|
328 |
|
344 |
|
329 |
@Override
|
345 |
@Override
|
330 |
public void actionPerformed(ActionEvent e) {
|
346 |
public void actionPerformed(ActionEvent e) {
|
331 |
List<SQLRowValues> selectedRows = IListe.get(e).getSelectedRows();
|
347 |
List<SQLRowAccessor> selectedRows = IListe.get(e).getSelectedRowAccessors();
|
332 |
eltCmd.transfertCommande(selectedRows);
|
348 |
eltCmd.transfertCommande(selectedRows);
|
333 |
}
|
349 |
}
|
334 |
}, true);
|
350 |
}, true);
|
335 |
predicateACtion.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
|
351 |
predicateACtion.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
|
336 |
listeArt.addIListeAction(predicateACtion);
|
352 |
listeArt.addIListeAction(predicateACtion);
|
337 |
ListeViewPanel p = new ListeViewPanel(artElt, listeArt);
|
353 |
ListeViewPanel p = new ListeViewPanel(artElt, listeArt);
|
338 |
IListFrame f = new IListFrame(p);
|
354 |
IListFrame f = new IListFrame(p);
|
339 |
FrameUtil.show(f);
|
355 |
FrameUtil.show(f);
|
340 |
}
|
356 |
}
|
- |
|
357 |
}
|
341 |
|
358 |
|
342 |
}, true);
|
359 |
}, true);
|
343 |
action.setPredicate(IListeEvent.createTotalRowCountPredicate(0, Integer.MAX_VALUE));
|
360 |
action.setPredicate(IListeEvent.createTotalRowCountPredicate(0, Integer.MAX_VALUE));
|
344 |
panel.getListe().addIListeAction(action);
|
361 |
panel.getListe().addIListeAction(action);
|
345 |
|
362 |
|